Mercurial > hg > Database > Alice
changeset 41:f9334781344a
add close api
author | kazz <kazz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 02 Feb 2012 10:48:39 +0900 |
parents | 20616fe4d28a |
children | 92aeb6e34683 |
files | src/alice/codesegment/OutputDataSegment.java src/alice/daemon/OutboundTcpConnection.java src/alice/datasegment/CommandType.java src/alice/datasegment/DataSegmentManager.java src/alice/datasegment/LocalDataSegmentManager.java src/alice/datasegment/RemoteDataSegmentManager.java src/alice/test/topology/ring/CheckMyName.java |
diffstat | 7 files changed, 24 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/codesegment/OutputDataSegment.java Tue Jan 31 15:19:35 2012 +0900 +++ b/src/alice/codesegment/OutputDataSegment.java Thu Feb 02 10:48:39 2012 +0900 @@ -62,5 +62,8 @@ DataSegment.get(managerKey).finish(); } + public void close(String managerKey) { + DataSegment.get(managerKey).close(); + } }
--- a/src/alice/daemon/OutboundTcpConnection.java Tue Jan 31 15:19:35 2012 +0900 +++ b/src/alice/daemon/OutboundTcpConnection.java Thu Feb 02 10:48:39 2012 +0900 @@ -25,7 +25,11 @@ while (true) { try { Command cmd = connection.sendQueue.take(); - if (cmd.type == CommandType.FINISH) { + switch (cmd.type) { + case CLOSE: + connection.socket.close(); + return; + case FINISH: System.exit(0); return; }
--- a/src/alice/datasegment/CommandType.java Tue Jan 31 15:19:35 2012 +0900 +++ b/src/alice/datasegment/CommandType.java Thu Feb 02 10:48:39 2012 +0900 @@ -9,6 +9,7 @@ TAKE, REMOVE, REPLY, + CLOSE, FINISH; public int id;
--- a/src/alice/datasegment/DataSegmentManager.java Tue Jan 31 15:19:35 2012 +0900 +++ b/src/alice/datasegment/DataSegmentManager.java Thu Feb 02 10:48:39 2012 +0900 @@ -44,6 +44,7 @@ } public abstract void peek(Receiver receiver, String key, int index, CodeSegment cs); public abstract void remove(String key); + public abstract void close(); public abstract void finish(); }
--- a/src/alice/datasegment/LocalDataSegmentManager.java Tue Jan 31 15:19:35 2012 +0900 +++ b/src/alice/datasegment/LocalDataSegmentManager.java Thu Feb 02 10:48:39 2012 +0900 @@ -76,5 +76,10 @@ @Override public void finish() { System.exit(0); } + + @Override + public void close() { + + } }
--- a/src/alice/datasegment/RemoteDataSegmentManager.java Tue Jan 31 15:19:35 2012 +0900 +++ b/src/alice/datasegment/RemoteDataSegmentManager.java Thu Feb 02 10:48:39 2012 +0900 @@ -83,10 +83,17 @@ connection.sendCommand(cmd); logger.debug(cmd.getCommandString()); } - + + @Override public void finish() { Command cmd = new Command(CommandType.FINISH, null, null, null, 0, 0, null, null, null); connection.sendCommand(cmd); } + @Override + public void close() { + Command cmd = new Command(CommandType.CLOSE, null, null, null, 0, 0, null, null, null); + connection.sendCommand(cmd); + } + }
--- a/src/alice/test/topology/ring/CheckMyName.java Tue Jan 31 15:19:35 2012 +0900 +++ b/src/alice/test/topology/ring/CheckMyName.java Thu Feb 02 10:48:39 2012 +0900 @@ -21,6 +21,7 @@ } else { System.out.println("I am normal node"); + ods.close("manager"); RingMessagePassing cs1 = new RingMessagePassing(); cs1.counter.setKey("local", "counter"); RingFinish cs2 = new RingFinish("right");