Mercurial > hg > Database > Alice
changeset 543:f3f7e256ee03 dispose
add AliceDaemon on paramater
line wrap: on
line diff
--- a/src/main/java/alice/codesegment/CodeSegment.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/codesegment/CodeSegment.java Mon Aug 03 20:00:53 2015 +0900 @@ -10,11 +10,12 @@ public InputDataSegment ids = new InputDataSegment(this); public OutputDataSegment ods = new OutputDataSegment(this); - private AliceDaemon aliceDaemon; + public AliceDaemon aliceDaemon; private ArrayList<Receiver> list = new ArrayList<Receiver>(); private int priority = Thread.NORM_PRIORITY;//? - public void execute() { + public void execute(AliceDaemon aliceDaemon) { + this.aliceDaemon = aliceDaemon; ids.receive(); }
--- a/src/main/java/alice/daemon/AcceptThread.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/daemon/AcceptThread.java Mon Aug 03 20:00:53 2015 +0900 @@ -31,7 +31,7 @@ Connection connection = new Connection(socket, alice); String key = "accept" + counter; IncomingTcpConnection in = - new IncomingTcpConnection(connection, alice.dataSegment.get("local"), key); + new IncomingTcpConnection(connection, alice.dataSegment.get("local"), key, alice); in.setName(connection.getInfoString()+"-IncomingTcp"); in.start(); alice.dataSegment.setAccept(key, in);
--- a/src/main/java/alice/daemon/AliceDaemon.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/daemon/AliceDaemon.java Mon Aug 03 20:00:53 2015 +0900 @@ -12,6 +12,7 @@ import alice.datasegment.Command; import alice.datasegment.CommandType; import alice.datasegment.DataSegment; +import alice.datasegment.ReceiveData; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.apache.log4j.WriterAppender; @@ -25,13 +26,21 @@ // static public final MessagePack packer = new MessagePack(); - public DataSegment dataSegment = new DataSegment(); + public DataSegment dataSegment = new DataSegment(this); public HashMap<Integer, CommandType> hash = new HashMap<Integer, CommandType>();//コマンド対応表 public CodeSegmentManager codeSegmentManager; + public AliceDaemon() { + setLogger(); + ReceiveData.packer = packer; + codeSegmentManager = new CodeSegmentManager(this); + commandInit();//static + } + public AliceDaemon(Config conf) { this.conf = conf; setLogger(); + ReceiveData.packer = packer; codeSegmentManager = new CodeSegmentManager(this); commandInit();//static }
--- a/src/main/java/alice/daemon/Connection.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/daemon/Connection.java Mon Aug 03 20:00:53 2015 +0900 @@ -11,7 +11,7 @@ public class Connection { - private final AliceDaemon alice; + protected AliceDaemon alice; public Socket socket; public String name; public LinkedBlockingQueue<Command> sendQueue = new LinkedBlockingQueue<Command>(); @@ -26,6 +26,9 @@ this.alice = alice; } + public Connection() { + } + public void sendCommand(Command cmd) { try { sendQueue.put(cmd); @@ -39,7 +42,7 @@ + ":" + socket.getPort(); } - public synchronized void write(Command cmd, Object alie) { + public synchronized void write(Command cmd) { ByteBuffer buffer = cmd.convert(alice); try { while (buffer.hasRemaining()) {
--- a/src/main/java/alice/daemon/IncomingTcpConnection.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/daemon/IncomingTcpConnection.java Mon Aug 03 20:00:53 2015 +0900 @@ -12,21 +12,31 @@ public class IncomingTcpConnection extends Thread { + protected AliceDaemon alice; + protected MessagePack packer; private Connection connection; protected DataSegmentManager manager; protected String reverseKey; - private LocalDataSegmentManager lmanager = AliceDaemon.dataSegment.getLocal(); - private CompressedLocalDataSegmentManager compressedlmanager = AliceDaemon.dataSegment.getCompressedLocal(); - private MessagePack packer = AliceDaemon.packer; + private LocalDataSegmentManager lmanager; + private CompressedLocalDataSegmentManager compressedlmanager; - public IncomingTcpConnection(DataSegmentManager manager) { + public IncomingTcpConnection(DataSegmentManager manager, AliceDaemon alice) { this.manager = manager; + this.alice = alice; + this.lmanager = alice.dataSegment.getLocal(); + this.compressedlmanager = alice.dataSegment.getCompressedLocal(); + this.packer = alice.packer; } + - public IncomingTcpConnection(Connection connection, DataSegmentManager manager, String reverseKey) { + public IncomingTcpConnection(Connection connection, DataSegmentManager manager, String reverseKey, AliceDaemon alice) { this.manager = manager; this.connection = connection; this.reverseKey = reverseKey; + this.alice = alice; + this.lmanager = alice.dataSegment.getLocal(); + this.compressedlmanager = alice.dataSegment.getCompressedLocal(); + this.packer = alice.packer; } public LocalDataSegmentManager getLocalDataSegmentManager(){ @@ -55,7 +65,7 @@ Command cmd = null; ReceiveData rData = null; CommandMessage msg = unpacker.read(CommandMessage.class);///read header - CommandType type = AliceDaemon.getCommandTypeFromId(msg.type); + CommandType type = alice.getCommandTypeFromId(msg.type); switch (type) { case UPDATE: case PUT: @@ -111,12 +121,12 @@ cmd.cs.ids.reply(cmd.receiver, rCmd); break; case PING: - if (AliceDaemon.dataSegment.contains(reverseKey)) - AliceDaemon.dataSegment.get(reverseKey).response(msg.key); + if (alice.dataSegment.contains(reverseKey)) + alice.dataSegment.get(reverseKey).response(msg.key); break; case RESPONSE: rData = new ReceiveData(new RespondData(reverseKey, System.currentTimeMillis())); - AliceDaemon.dataSegment.getLocal().put(msg.key, rData, false); + alice.dataSegment.getLocal().put(msg.key, rData, false); break; default: break;
--- a/src/main/java/alice/daemon/IncomingUdpConnection.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/daemon/IncomingUdpConnection.java Mon Aug 03 20:00:53 2015 +0900 @@ -22,13 +22,14 @@ public MulticastConnection receiver; public MulticastConnection sender; - private MessagePack packer = AliceDaemon.packer; - public IncomingUdpConnection(MulticastConnection s, MulticastConnection r, DataSegmentManager manager) { - super(manager); + public IncomingUdpConnection(MulticastConnection s, MulticastConnection r, DataSegmentManager manager, AliceDaemon alice) { + super(manager, alice); receiver = r; sender = s; reverseKey = "multicast"; + this.alice = alice; + } @Override @@ -43,7 +44,7 @@ Unpacker unpacker = packer.createBufferUnpacker(receive); receive.flip(); CommandMessage msg = unpacker.read(CommandMessage.class); - CommandType type = AliceDaemon.getCommandTypeFromId(msg.type); + CommandType type = alice.getCommandTypeFromId(msg.type); switch (type) { case UPDATE: case PUT: @@ -82,12 +83,12 @@ cmd.cs.ids.reply(cmd.receiver, rCmd); break; case PING: - if (AliceDaemon.dataSegment.contains(reverseKey)) - AliceDaemon.dataSegment.get(reverseKey).response(msg.key); + if (alice.dataSegment.contains(reverseKey)) + alice.dataSegment.get(reverseKey).response(msg.key); break; case RESPONSE: rData = new ReceiveData(new RespondData(reverseKey, System.currentTimeMillis())); - AliceDaemon.dataSegment.getLocal().put(msg.key, rData, false); + alice.dataSegment.getLocal().put(msg.key, rData, false); break; default: break;
--- a/src/main/java/alice/daemon/MulticastConnection.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/daemon/MulticastConnection.java Mon Aug 03 20:00:53 2015 +0900 @@ -11,14 +11,15 @@ private DatagramChannel dc; private SocketAddress sAddr; - public MulticastConnection(DatagramChannel d, SocketAddress s) { + public MulticastConnection(DatagramChannel d, SocketAddress s, AliceDaemon alice) { dc = d; sAddr = s; + this.alice = alice; } // may need to add infomation who send on ds. @Override - public synchronized void write(Command cmd, Object alie){ + public synchronized void write(Command cmd){ ByteBuffer buffer = cmd.convert(alice); try { while (buffer.hasRemaining()){
--- a/src/main/java/alice/daemon/OutboundTcpConnection.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/daemon/OutboundTcpConnection.java Mon Aug 03 20:00:53 2015 +0900 @@ -27,7 +27,7 @@ default: break; } - connection.write(cmd, alie);//ここでconvert()がよばれてる + connection.write(cmd);//ここでconvert()がよばれてる } catch (InterruptedException e) { e.printStackTrace(); }
--- a/src/main/java/alice/datasegment/DataSegment.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/datasegment/DataSegment.java Mon Aug 03 20:00:53 2015 +0900 @@ -57,7 +57,7 @@ } public MulticastDataSegmentManager connectMulticast(String connectionKey ,String MCSTADDR, int port, String nis, SocketType type){ - MulticastDataSegmentManager manager = new MulticastDataSegmentManager(connectionKey ,MCSTADDR, port, nis, type); + MulticastDataSegmentManager manager = new MulticastDataSegmentManager(connectionKey ,MCSTADDR, port, nis, type, alice); if (type!=SocketType.Receiver) register(connectionKey, manager); return manager;
--- a/src/main/java/alice/datasegment/DataSegmentKey.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/datasegment/DataSegmentKey.java Mon Aug 03 20:00:53 2015 +0900 @@ -93,7 +93,7 @@ if (!cmd.getQuickFlag()) { cmd.connection.sendQueue.put(rCmd); } else { - cmd.connection.write(rCmd, alie); + cmd.connection.write(rCmd); } } catch (InterruptedException e) { e.printStackTrace();
--- a/src/main/java/alice/datasegment/MulticastDataSegmentManager.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/datasegment/MulticastDataSegmentManager.java Mon Aug 03 20:00:53 2015 +0900 @@ -18,9 +18,12 @@ public class MulticastDataSegmentManager extends RemoteDataSegmentManager { + private final AliceDaemon alice; + public enum SocketType{Sender, Receiver, Both}; - public MulticastDataSegmentManager(String connectionKey ,final String MCASTADDR, final int port, final String nis, SocketType type) { + public MulticastDataSegmentManager(String connectionKey ,final String MCASTADDR, final int port, final String nis, SocketType type, AliceDaemon alice) { logger = Logger.getLogger(connectionKey); + this.alice = alice; InetAddress mAddr; try { mAddr = InetAddress.getByName(MCASTADDR); @@ -28,17 +31,17 @@ DatagramChannel dcr = createDatagramChannel(mAddr, port, nis); dcr.bind(new InetSocketAddress(port)); SocketAddress sAddrr = new InetSocketAddress(mAddr,port); - MulticastConnection receiver = new MulticastConnection(dcr, sAddrr); + MulticastConnection receiver = new MulticastConnection(dcr, sAddrr, alice); DatagramChannel dcs = createDatagramChannel(mAddr, port, nis); SocketAddress sAddrs = new InetSocketAddress(mAddr,port); - connection = new MulticastConnection(dcs, sAddrs); // sender + connection = new MulticastConnection(dcs, sAddrs, alice); // sender if (type !=SocketType.Sender) { - IncomingUdpConnection in = new IncomingUdpConnection((MulticastConnection) connection, receiver, this); + IncomingUdpConnection in = new IncomingUdpConnection((MulticastConnection) connection, receiver, this, alice); in.setName("multicast-IncomingUdp"); in.start(); - AliceDaemon.dataSegment.setAccept(connectionKey, in); + alice.dataSegment.setAccept(connectionKey, in); } if (type !=SocketType.Receiver) { OutboundTcpConnection out = new OutboundTcpConnection(connection); // OutboundUdpConnection sender
--- a/src/main/java/alice/datasegment/ReceiveData.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/datasegment/ReceiveData.java Mon Aug 03 20:00:53 2015 +0900 @@ -24,7 +24,7 @@ public boolean setTime = false; public int depth = 1; - private MessagePack packer = AliceDaemon.packer; + public static MessagePack packer; /** * コンストラクタ。Object型のDSと圧縮のメタ情報を受け取る。
--- a/src/main/java/alice/datasegment/RemoteDataSegmentManager.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/datasegment/RemoteDataSegmentManager.java Mon Aug 03 20:00:53 2015 +0900 @@ -45,7 +45,7 @@ } } } while (connect); - IncomingTcpConnection in = new IncomingTcpConnection(connection, manager, reverseKey); + IncomingTcpConnection in = new IncomingTcpConnection(connection, manager, reverseKey, alice); in.setName(reverseKey+"-IncomingTcp"); in.setPriority(MAX_PRIORITY); in.start(); @@ -71,7 +71,7 @@ public void put1(boolean quickFlag, Command cmd) { if (quickFlag){ - connection.write(cmd, alie); // put command is executed right now + connection.write(cmd); // put command is executed right now } else { connection.sendCommand(cmd); // put command on the transmission thread } @@ -100,7 +100,7 @@ seqHash.put(seq, cmd); cmd.setQuickFlag(quickFlag); if (quickFlag){ - connection.write(cmd, alie); + connection.write(cmd); } else { connection.sendCommand(cmd); } @@ -131,13 +131,13 @@ @Override public void ping(String returnKey) { Command cmd = new Command(CommandType.PING, null, returnKey, null, 0, 0, null, null, ""); - connection.write(cmd, alie); + connection.write(cmd); } @Override public void response(String returnKey) { Command cmd = new Command(CommandType.RESPONSE, null, returnKey, null, 0, 0, null, null, ""); - connection.write(cmd, alie); + connection.write(cmd); } @Override
--- a/src/main/java/alice/test/codesegment/api/PutCodeSegment.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/test/codesegment/api/PutCodeSegment.java Mon Aug 03 20:00:53 2015 +0900 @@ -25,7 +25,7 @@ } catch (InterruptedException e) { e.printStackTrace(); } - new PutCodeSegment().execute(); + new PutCodeSegment().execute(aliceDaemon); }
--- a/src/main/java/alice/test/codesegment/api/StartCodeSegment.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/test/codesegment/api/StartCodeSegment.java Mon Aug 03 20:00:53 2015 +0900 @@ -27,14 +27,14 @@ ods.update("local", "key", array); } else if ("-put".equals(arg)) { - new PutCodeSegment().execute(); + new PutCodeSegment().execute(aliceDaemon); } else if ("-take".equals(arg)) { - new PutCodeSegment().execute(); + new PutCodeSegment().execute(aliceDaemon); new TakeCodeSegment("num"); } else if ("-flip".equals(arg)) { - new FlipCodeSegment("key").execute(); + new FlipCodeSegment("key").execute(aliceDaemon); } else if ("-peek".equals(arg)) { System.out.println("start peek Test"); String key = "peek";
--- a/src/main/java/alice/test/codesegment/api/TestApiAlice.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/test/codesegment/api/TestApiAlice.java Mon Aug 03 20:00:53 2015 +0900 @@ -9,8 +9,9 @@ * @param args */ public static void main(String[] args) { - new AliceDaemon(new Config(args)).listen(); - new StartCodeSegment(args).execute(); + AliceDaemon aliceDaemon = new AliceDaemon(new Config(args)); + aliceDaemon.listen(); + new StartCodeSegment(args).execute(aliceDaemon); } }
--- a/src/main/java/alice/test/codesegment/local/TestLocalAlice.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/test/codesegment/local/TestLocalAlice.java Mon Aug 03 20:00:53 2015 +0900 @@ -5,8 +5,10 @@ public class TestLocalAlice { public static void main(String args[]) { - new AliceDaemon(new Config(args)).listen(); - new StartCodeSegment().execute(); + AliceDaemon aliceDaemon = new AliceDaemon(new Config(args)); + aliceDaemon.listen(); + + new StartCodeSegment().execute(aliceDaemon); } }
--- a/src/main/java/alice/test/codesegment/local/bitonicsort/LocalBitonicSort.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/test/codesegment/local/bitonicsort/LocalBitonicSort.java Mon Aug 03 20:00:53 2015 +0900 @@ -5,9 +5,10 @@ public class LocalBitonicSort { public static void main(String[] args){ - new AliceDaemon(new Config(args)).listen(); // logger off + AliceDaemon aliceDaemon = new AliceDaemon(new Config(args)); // logger off + aliceDaemon.listen(); SortConfig conf = new SortConfig(args); - new SetInfo(conf).execute(); + new SetInfo(conf).execute(aliceDaemon); } }
--- a/src/main/java/alice/test/codesegment/local/wordcount/StartWordCount.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/test/codesegment/local/wordcount/StartWordCount.java Mon Aug 03 20:00:53 2015 +0900 @@ -8,9 +8,10 @@ public static long t = System.currentTimeMillis(); public static void main(String[] args){ - new AliceDaemon(new Config(args)).listen(); // logger off + AliceDaemon aliceDaemon = new AliceDaemon(new Config(args)); // logger off + aliceDaemon.listen(); WordConfig conf = new WordConfig(args); - new SeparateArray(conf).execute(); + new SeparateArray(conf).execute(aliceDaemon); } }
--- a/src/main/java/alice/test/codesegment/remote/TestRemoteAlice.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/test/codesegment/remote/TestRemoteAlice.java Mon Aug 03 20:00:53 2015 +0900 @@ -1,16 +1,16 @@ package alice.test.codesegment.remote; import alice.daemon.AliceDaemon; -import alice.datasegment.DataSegment; public class TestRemoteAlice { public static void main(String[] args) { TestRemoteConfig conf = new TestRemoteConfig(args);//トポロジー設定をコマンドライン引数からとって設定? - new AliceDaemon(conf).listen();//構成開始?TopMはない - AliceDaemon.dataSegment.connect(conf.key, "", conf.hostname, conf.connectPort); - new RemoteStartCodeSegment().execute(); + AliceDaemon aliceDaemon = new AliceDaemon(conf); + aliceDaemon.listen(); + aliceDaemon.dataSegment.connect(conf.key, "", conf.hostname, conf.connectPort); + new RemoteStartCodeSegment().execute(aliceDaemon); } }
--- a/src/main/java/alice/test/concurrent/AliceConcurrentTest.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/test/concurrent/AliceConcurrentTest.java Mon Aug 03 20:00:53 2015 +0900 @@ -1,5 +1,7 @@ package alice.test.concurrent; +import alice.daemon.AliceDaemon; + public class AliceConcurrentTest { public static void main(String args[]) { @@ -12,7 +14,7 @@ } } - new StartConcurrent(count).execute(); + new StartConcurrent(count).execute(new AliceDaemon()); } }
--- a/src/main/java/alice/test/topology/aquarium/KeyInputCodeSegment.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/test/topology/aquarium/KeyInputCodeSegment.java Mon Aug 03 20:00:53 2015 +0900 @@ -37,7 +37,7 @@ new SendLocation(0.0f,0.0f,-0.1f); break; case 82: // "r" - new ResetFish().execute(); + new ResetFish().execute(aliceDaemon); break; } }
--- a/src/main/java/alice/test/topology/aquarium/fx/Aquarium.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/test/topology/aquarium/fx/Aquarium.java Mon Aug 03 20:00:53 2015 +0900 @@ -6,7 +6,9 @@ import javax.imageio.ImageIO; +import alice.codesegment.CodeSegment; import alice.codesegment.OutputDataSegment; +import alice.daemon.AliceDaemon; import javafx.application.Application; import javafx.embed.swing.SwingFXUtils; import javafx.event.EventHandler; @@ -27,7 +29,7 @@ public class Aquarium extends Application { - private OutputDataSegment ods = new OutputDataSegment(); + private OutputDataSegment ods; @Override public void start(Stage primaryStage) throws IOException {
--- a/src/main/java/alice/test/topology/aquarium/fx/CheckAllFishInfoExist.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/test/topology/aquarium/fx/CheckAllFishInfoExist.java Mon Aug 03 20:00:53 2015 +0900 @@ -31,7 +31,7 @@ new SendDataOthers(info, info.key); ods.put("registeredList", info.getVal()); ArrayValue fishInfoList = info.asClass(Value.class).asArrayValue(); - MessagePack packer = AliceDaemon.packer; + MessagePack packer = aliceDaemon.packer; Group root = info1.asClass(Group.class); for (Value v : fishInfoList){ boolean exist = false;
--- a/src/main/java/alice/test/topology/aquarium/fx/StartAquariumFX.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/test/topology/aquarium/fx/StartAquariumFX.java Mon Aug 03 20:00:53 2015 +0900 @@ -1,5 +1,6 @@ package alice.test.topology.aquarium.fx; +import alice.daemon.AliceDaemon; import alice.topology.node.TopologyNode; public class StartAquariumFX { @@ -12,7 +13,7 @@ new TopologyNode(conf, cs); } else { cs.ods.put("host", "local0"); - cs.execute(); + cs.execute(new AliceDaemon()); } }
--- a/src/main/java/alice/topology/manager/CreateTreeTopology.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/topology/manager/CreateTreeTopology.java Mon Aug 03 20:00:53 2015 +0900 @@ -43,7 +43,7 @@ String nodeName = "node"+comingHostCount; // Manager connect to Node - AliceDaemon.dataSegment.connect(nodeName, nodeName, host.name, host.port); + aliceDaemon.dataSegment.connect(nodeName, nodeName, host.name, host.port); ods.put(nodeName, "host", nodeName); ods.put(nodeName, "cookie", cookie);
--- a/src/main/java/alice/topology/manager/IncomingHosts.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/topology/manager/IncomingHosts.java Mon Aug 03 20:00:53 2015 +0900 @@ -41,7 +41,7 @@ // not have or match cookie String nodeName = nodeNames.poll(); // Manager connect to Node - AliceDaemon.dataSegment.connect(nodeName, "", host.name, host.port); + aliceDaemon.dataSegment.connect(nodeName, "", host.name, host.port); ods.put(nodeName, "host", nodeName); String cookie = this.cookie.asString();
--- a/src/main/java/alice/topology/manager/SearchHostName.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/topology/manager/SearchHostName.java Mon Aug 03 20:00:53 2015 +0900 @@ -31,8 +31,8 @@ @SuppressWarnings("unchecked") HashMap<String, LinkedList<HostMessage>> topology = info1.asClass(HashMap.class); - AliceDaemon.dataSegment.remove(hostInfo.absName); - AliceDaemon.dataSegment.connect(hostInfo.absName, "", hostInfo.name, hostInfo.port); + aliceDaemon.dataSegment.remove(hostInfo.absName); + aliceDaemon.dataSegment.connect(hostInfo.absName, "", hostInfo.name, hostInfo.port); ods.put(hostInfo.absName, "host", hostInfo.absName); // put Host dataSegment on reconnect node
--- a/src/main/java/alice/topology/manager/TopologyManager.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/topology/manager/TopologyManager.java Mon Aug 03 20:00:53 2015 +0900 @@ -7,7 +7,7 @@ public static void main(String[] args) { TopologyManagerConfig conf = new TopologyManagerConfig(args); new AliceDaemon(conf).listen(); - new StartTopologyManager(conf).execute(); + new StartTopologyManager(conf).execute(aliceDaemon); } }
--- a/src/main/java/alice/topology/manager/keeparive/ListManager.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/topology/manager/keeparive/ListManager.java Mon Aug 03 20:00:53 2015 +0900 @@ -87,14 +87,14 @@ System.out.println(); } - public void deleteAll(String name) { + public void deleteAll(String name, AliceDaemon alice) { TaskInfo task = TaskExecuter.getInstance().getNowTask(); if (task!= null) { if (task.getManagerKey() != null && task.getManagerKey().equals(name)) { TaskExecuter.getInstance().skip(); } } - AliceDaemon.dataSegment.getLocal().removeDataSegmentKey("_FORM_"+name); + alice.dataSegment.getLocal().removeDataSegmentKey("_FORM_"+name); task = new TaskInfo(TaskType.CLOSE); task.setInfo(name, 0); while(deleteTask(task));
--- a/src/main/java/alice/topology/manager/keeparive/TaskExecuter.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/topology/manager/keeparive/TaskExecuter.java Mon Aug 03 20:00:53 2015 +0900 @@ -65,8 +65,8 @@ new RespondPing(nowTask.getReturnKey()); } else if (nowTask.getType() == TaskType.CLOSE) { // no response from the Remote DataSegment. So close this connection. - if (AliceDaemon.dataSegment.contains(nowTask.getManagerKey())) { - AliceDaemon.dataSegment.get(nowTask.getManagerKey()).shutdown(); + if (aliceDaemon.dataSegment.contains(nowTask.getManagerKey())) { + aliceDaemon.dataSegment.get(nowTask.getManagerKey()).shutdown(); System.out.println(nowTask.getManagerKey() +" IS SHOTDOWN"); } else { System.out.println(nowTask.getManagerKey() +" IS ALREADY SHOTDOWN");
--- a/src/main/java/alice/topology/node/CloseRemoteDataSegment.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/topology/node/CloseRemoteDataSegment.java Mon Aug 03 20:00:53 2015 +0900 @@ -26,8 +26,8 @@ String managerKey = info.asString(); ListManager manager = info3.asClass(ListManager.class); if (info1.from.equals(managerKey)||info2.from.equals(managerKey)) { - if (AliceDaemon.dataSegment.contains(managerKey)) - AliceDaemon.dataSegment.get(managerKey).shutdown(); + if (aliceDaemon.dataSegment.contains(managerKey)) + aliceDaemon.dataSegment.get(managerKey).shutdown(); manager.deleteAll(managerKey); }
--- a/src/main/java/alice/topology/node/ConfigurationFinish.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/topology/node/ConfigurationFinish.java Mon Aug 03 20:00:53 2015 +0900 @@ -26,7 +26,7 @@ Start cs = new Start(startCS); cs.done.setKey("manager", "start"); - new StartKeepAlive().execute(); + new StartKeepAlive().execute(aliceDaemon); new ReceiveCloseMessage(CommandType.PEEK); ClosedEventManager.getInstance().register(DeleteConnection.class); ClosedEventManager.getInstance().setKey();
--- a/src/main/java/alice/topology/node/DeleteConnection.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/topology/node/DeleteConnection.java Mon Aug 03 20:00:53 2015 +0900 @@ -27,12 +27,12 @@ if (list.contains(name)) list.remove(name); - if (AliceDaemon.dataSegment.contains(name)) { - AliceDaemon.dataSegment.get(name).shutdown(); - AliceDaemon.dataSegment.remove(name); + if (aliceDaemon.dataSegment.contains(name)) { + aliceDaemon.dataSegment.get(name).shutdown(); + aliceDaemon.dataSegment.remove(name); } ListManager manager = info1.asClass(ListManager.class); - manager.deleteAll(name); + manager.deleteAll(name, aliceDaemon); ods.update(info.key, list); ods.update(info1.key, manager); }
--- a/src/main/java/alice/topology/node/IncomingConnectionInfo.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/topology/node/IncomingConnectionInfo.java Mon Aug 03 20:00:53 2015 +0900 @@ -25,11 +25,11 @@ ods.put("local", "configNodeNum", count); } else { HostMessage hostInfo = this.hostInfo.asClass(HostMessage.class); - if (AliceDaemon.dataSegment.contains(hostInfo.connectionName)) { + if (aliceDaemon.dataSegment.contains(hostInfo.connectionName)) { // need to wait remove by DeleteConnection ods.put("manager", absName, hostInfo); } else { - AliceDaemon.dataSegment.connect(hostInfo.connectionName, hostInfo.reverseName, hostInfo.name, hostInfo.port); + aliceDaemon.dataSegment.connect(hostInfo.connectionName, hostInfo.reverseName, hostInfo.name, hostInfo.port); ods.put(hostInfo.connectionName, "reverseKey", hostInfo.reverseName); count++;
--- a/src/main/java/alice/topology/node/IncomingReverseKey.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/topology/node/IncomingReverseKey.java Mon Aug 03 20:00:53 2015 +0900 @@ -15,7 +15,7 @@ public void run() { String reverseKey = this.reverseKey.asString(); String from = this.reverseKey.from; - AliceDaemon.dataSegment.getAccept(from).setReverseKey(reverseKey); + aliceDaemon.dataSegment.getAccept(from).setReverseKey(reverseKey); int reverseCount = this.reverseCount.asInteger(); reverseCount++;
--- a/src/main/java/alice/topology/node/PrepareToClose.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/topology/node/PrepareToClose.java Mon Aug 03 20:00:53 2015 +0900 @@ -26,7 +26,7 @@ List<String> list = info1.asClass(List.class); if (list.contains(managerKey)) { list.remove(managerKey); - DataSegmentManager manager = AliceDaemon.dataSegment.get(managerKey); + DataSegmentManager manager = aliceDaemon.dataSegment.get(managerKey); manager.setSendError(false); ods.put(managerKey, "_CLOSEREADY", managerKey);
--- a/src/main/java/alice/topology/node/Start.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/topology/node/Start.java Mon Aug 03 20:00:53 2015 +0900 @@ -24,7 +24,7 @@ if (startCS == null) return; - startCS.execute(); + startCS.execute(aliceDaemon); }
--- a/src/main/java/alice/topology/node/StartTopologyNode.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/topology/node/StartTopologyNode.java Mon Aug 03 20:00:53 2015 +0900 @@ -21,7 +21,7 @@ @Override public void run() { - AliceDaemon.dataSegment.connect("manager", "manager", conf.getManagerHostName(), conf.getManagerPort()); + aliceDaemon.dataSegment.connect("manager", "manager", conf.getManagerHostName(), conf.getManagerPort()); String localHostName = null; try { localHostName = InetAddress.getLocalHost().getHostName();
--- a/src/main/java/alice/topology/node/TopologyNode.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/main/java/alice/topology/node/TopologyNode.java Mon Aug 03 20:00:53 2015 +0900 @@ -7,7 +7,7 @@ public TopologyNode(TopologyNodeConfig conf, CodeSegment startCS) { new AliceDaemon(conf).listen(); - new StartTopologyNode(conf, startCS).execute(); + new StartTopologyNode(conf, startCS).execute(aliceDaemon); } public static void main(String[] args) {
--- a/src/test/java/alice/daemon/MulticastTest.java Mon Aug 03 19:00:06 2015 +0900 +++ b/src/test/java/alice/daemon/MulticastTest.java Mon Aug 03 20:00:53 2015 +0900 @@ -6,7 +6,7 @@ public static SocketType type = SocketType.Both; public static void main(String[] args){ Config conf = new Config(args); - new MulticastStartCodeSegment(conf).execute(); + new MulticastStartCodeSegment(conf).execute(aliceDaemon); } }