1 22 package org.objectweb.petals.kernel.registry.thread; 23 24 import java.util.ArrayList ; 25 import java.util.List ; 26 import java.util.Map ; 27 28 import org.objectweb.petals.kernel.admin.ContainerInformation; 29 import org.objectweb.petals.kernel.registry.RegistryServer; 30 import org.objectweb.petals.kernel.registry.msg.request.FullUpdateRequest; 31 import org.objectweb.petals.kernel.registry.msg.request.RegistryRequest; 32 import org.objectweb.petals.util.LoggingUtil; 33 34 39 public class FullUpdateThread extends Thread { 40 41 protected RegistryServer server; 42 43 protected LoggingUtil log; 44 45 protected long sender; 46 47 public FullUpdateThread(RegistryServer server) { 48 super("ElectMasterThread" 49 + server.getStartTime()); 50 this.server = server; 51 sender = server.getStartTime(); 52 } 53 54 public void run() { 55 log = server.getLog(); 56 int counter = 0; 57 log.call(); 58 try { 59 Thread.sleep(1000); 60 } catch (InterruptedException e2) { 61 } 63 if (server.getChannel().getCurrentGroup().getMembers().size() > 1) { 64 RegistryRequest electRequest = new FullUpdateRequest(sender, 0); 65 try { 66 server.getChannel().send(electRequest); 67 } catch (Exception e) { 68 log.error("Problem while sending full update request", e); 69 } 70 counter = 0; 71 while (!server.isFullyUpdated() 72 && counter < 10) { 73 try { 74 Thread.sleep(300); 75 counter++; 76 } catch (InterruptedException e) { 77 } 79 } 80 81 Map <String , Object > contMap = server.getData().get("/containers/"); 82 if (contMap != null) { 83 List <ContainerInformation> contList = new ArrayList <ContainerInformation>(); 84 for (Object object : contMap.values()) { 85 contList.add((ContainerInformation) object); 86 } 87 server.getConfigurationService().setContainers(contList); 88 } 89 } else { 90 server.setFullyUpdated(true); 91 } 92 server.getConfigurationService().setUpConfiguration(); 93 } 94 95 } 96 | Popular Tags |