Mercurial > hg > Database > Alice
changeset 510:118e150ac9f3 dispose
refactor
author | sugi |
---|---|
date | Fri, 09 Jan 2015 16:11:13 +0900 |
parents | 53d7cff1fe10 |
children | ea3f9fc4f0ce |
files | src/main/java/alice/daemon/IncomingTcpConnection.java src/main/java/alice/daemon/IncomingUdpConnection.java src/test/java/alice/daemon/MulticastTest.java |
diffstat | 3 files changed, 4 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/alice/daemon/IncomingTcpConnection.java Thu Jan 08 12:10:02 2015 +0900 +++ b/src/main/java/alice/daemon/IncomingTcpConnection.java Fri Jan 09 16:11:13 2015 +0900 @@ -4,7 +4,6 @@ import java.io.IOException; import java.nio.channels.ClosedChannelException; -import org.msgpack.unpacker.MessagePackUnpacker; import org.msgpack.unpacker.Unpacker; import alice.codesegment.SingletonMessage; @@ -111,7 +110,7 @@ byte[] b = null; try { len = unpacker.readInt(); - b = ((MessagePackUnpacker) unpacker).getSerializedByteArray(len); + b = unpacker.getSerializedByteArray(len); } catch (IOException e) { e.printStackTrace(); }
--- a/src/main/java/alice/daemon/IncomingUdpConnection.java Thu Jan 08 12:10:02 2015 +0900 +++ b/src/main/java/alice/daemon/IncomingUdpConnection.java Fri Jan 09 16:11:13 2015 +0900 @@ -35,7 +35,6 @@ while (true){ try { Command cmd = null; - byte[] val = null; ReceiveData rData = null; // Max data length is 65507 because of the max length of UDP payload ByteBuffer receive = ByteBuffer.allocate(65507); @@ -47,9 +46,7 @@ switch (type) { case UPDATE: case PUT: - val = new byte[unpacker.readInt()]; - receive.get(val); - rData = new ReceiveData(val, msg.compressed, msg.serialized); + rData = new ReceiveData(unpacker.getSerializedByteArray(unpacker.readInt()), msg.compressed, msg.serialized); cmd = new Command(type, null, null, rData, 0, 0, null, null, reverseKey); getLocalDataSegmentManager().getDataSegmentKey(msg.key).runCommand(cmd); break; @@ -65,9 +62,7 @@ break; case REPLY: cmd = manager.getAndRemoveCmd(msg.seq); - val = new byte[unpacker.readInt()]; - receive.get(val); - rData = new ReceiveData(val, msg.compressed, msg.serialized); + rData = new ReceiveData(unpacker.getSerializedByteArray(unpacker.readInt()), msg.compressed, msg.serialized); Command rCmd = new Command(type, null, null, rData, msg.index, msg.seq, null, null, ""); cmd.cs.ids.reply(cmd.receiver, rCmd); break;
--- a/src/test/java/alice/daemon/MulticastTest.java Thu Jan 08 12:10:02 2015 +0900 +++ b/src/test/java/alice/daemon/MulticastTest.java Fri Jan 09 16:11:13 2015 +0900 @@ -3,7 +3,7 @@ import alice.datasegment.MulticastDataSegmentManager.SocketType; public class MulticastTest { - public static SocketType type = SocketType.Sender; + public static SocketType type = SocketType.Both; public static void main(String[] args){ Config conf = new Config(args); new MulticastStartCodeSegment(conf).execute();