Mercurial > hg > Members > tatsuki > Alice
changeset 366:abc54fa0c81b multicast
MulticastDataSegment's extend class change from DataSegmentManager from LocalDataSegmentManager
author | sugi |
---|---|
date | Sat, 17 May 2014 21:34:01 +0900 |
parents | 8072df9130c6 |
children | 514af34ca062 |
files | src/main/java/alice/datasegment/LocalDataSegmentManager.java src/main/java/alice/datasegment/MulticastDataSegmentManager.java |
diffstat | 2 files changed, 19 insertions(+), 50 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/alice/datasegment/LocalDataSegmentManager.java Sat May 17 21:32:24 2014 +0900 +++ b/src/main/java/alice/datasegment/LocalDataSegmentManager.java Sat May 17 21:34:01 2014 +0900 @@ -25,6 +25,10 @@ new Thread(replyThread, "LocalDataSegmentManager-replyCommand").start(); } + public void setReverseKey(String s){ + reverseKey = s; + } + private class RunCommand implements Runnable { DataSegmentKey key; @@ -87,13 +91,10 @@ logger.debug(cmd.getCommandString()); } - @Override public void quickUpdate(String key, Object val) { update(key, val); - } - - + } @Override public void take(Receiver receiver, CodeSegment cs) { @@ -125,7 +126,6 @@ peek(receiver, cs); } - @Override public void remove(String key) { DataSegmentKey dataSegmentKey = getDataSegmentKey(key);
--- a/src/main/java/alice/datasegment/MulticastDataSegmentManager.java Sat May 17 21:32:24 2014 +0900 +++ b/src/main/java/alice/datasegment/MulticastDataSegmentManager.java Sat May 17 21:34:01 2014 +0900 @@ -11,17 +11,17 @@ import org.apache.log4j.Logger; -import alice.codesegment.CodeSegment; import alice.daemon.IncomingUdpConnection; import alice.daemon.MulticastConnection; import alice.daemon.OutboundTcpConnection; -public class MulticastDataSegmentManager extends DataSegmentManager { - MulticastConnection sender; - Logger logger; +public class MulticastDataSegmentManager extends LocalDataSegmentManager { + private MulticastConnection sender; + private Logger logger; - public MulticastDataSegmentManager(final String MCASTADDR, final int port, final String nis) { - logger = Logger.getLogger("multicast"); + public MulticastDataSegmentManager(String connectionKey ,final String MCASTADDR, final int port, final String nis) { + super.setReverseKey(connectionKey); + logger = Logger.getLogger(connectionKey); InetAddress mAddr; try { mAddr = InetAddress.getByName(MCASTADDR); @@ -77,53 +77,22 @@ @Override public void update(String key, Object val) { - + Command cmd = new Command(CommandType.UPDATE, null, key, val, 0, 0, null, null, null); + sender.sendCommand(cmd); + if (logger.isDebugEnabled()) + logger.debug(cmd.getCommandString()); } @Override - public void take(Receiver receiver, CodeSegment cs) {} - @Override - public void peek(Receiver receiver, CodeSegment cs) {} - - @Override public void quickPut(String key, Object val) { - + Command cmd = new Command(CommandType.PUT, null, key, val, 0, 0, null, null, null); + sender.write(cmd); // put command is executed right now } @Override public void quickUpdate(String key, Object val) { - - } - - @Override - public void quickPeek(Receiver receiver, CodeSegment cs) {} - @Override - public void quickTake(Receiver receiver, CodeSegment cs) {} - - @Override - public void remove(String key) { - - } - - @Override - public void shutdown() { - + Command cmd = new Command(CommandType.UPDATE, null, key, val, 0, 0, null, null, null); + sender.write(cmd); } - @Override - public void close() { - - } - - @Override - public void finish() { - - } - - @Override - public void ping(String returnKey) {} - - @Override - public void response(String returnKey) {} - }