Mercurial > hg > Members > tatsuki > Alice
changeset 183:75150396681c working
use synchronizedList
author | e095732 |
---|---|
date | Tue, 26 Feb 2013 14:24:23 +0900 |
parents | 52a1fa5ba38b |
children | 4475ba30238f |
files | src/alice/codesegment/OutputDataSegment.java src/alice/datasegment/LocalDataSegmentManager.java src/alice/test/codesegment/local/TestCodeSegment.java src/alice/topology/node/StartTopologyNode.java |
diffstat | 4 files changed, 77 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/codesegment/OutputDataSegment.java Tue Feb 26 13:46:18 2013 +0900 +++ b/src/alice/codesegment/OutputDataSegment.java Tue Feb 26 14:24:23 2013 +0900 @@ -35,38 +35,51 @@ } } + public void put(String key, Value val) { + DataSegment.getLocal().put(key, val); + } + + public void put(String key, String val) { + DataSegment.getLocal().put(key, ValueFactory.createRawValue(val)); + } + + public void put(String key, byte[] val) { + DataSegment.getLocal().put(key, ValueFactory.createRawValue(val, true)); + } + + public void put(String key, int val) { + DataSegment.getLocal().put(key, ValueFactory.createIntegerValue(val)); + } + + public <T> void put(String key, T val) { + try { + DataSegment.getLocal().put(key, SingletonMessage.getInstance().unconvert(val)); + } catch (IOException e) { + e.printStackTrace(); + } + } + + + /** + * for remote + **/ + public void put(String managerKey, String key, Value val) { DataSegment.get(managerKey).put(key, val); } - public void update(String managerKey, String key, Value val) { - DataSegment.get(managerKey).update(key, val); - } - public void put(String managerKey, String key, String val) { DataSegment.get(managerKey).put(key, ValueFactory.createRawValue(val)); } - public void update(String managerKey, String key, String val) { - DataSegment.get(managerKey).update(key, ValueFactory.createRawValue(val)); - } - public void put(String managerKey, String key, byte[] val) { DataSegment.get(managerKey).put(key, ValueFactory.createRawValue(val, true)); } - public void update(String managerKey, String key, byte[] val) { - DataSegment.get(managerKey).update(key, ValueFactory.createRawValue(val, true)); - } - public void put(String managerKey, String key, int val) { DataSegment.get(managerKey).put(key, ValueFactory.createIntegerValue(val)); } - public void update(String managerKey, String key, int val) { - DataSegment.get(managerKey).update(key, ValueFactory.createIntegerValue(val)); - } - public <T> void put(String managerKey, String key, T val) { try { DataSegment.get(managerKey).put(key, SingletonMessage.getInstance().unconvert(val)); @@ -75,6 +88,46 @@ } } + public void update(String key, Value val) { + DataSegment.getLocal().update(key, val); + } + + public void update(String key, String val) { + DataSegment.getLocal().update(key, ValueFactory.createRawValue(val)); + } + + public void update(String key, byte[] val) { + DataSegment.getLocal().update(key, ValueFactory.createRawValue(val, true)); + } + + public void update(String key, int val) { + DataSegment.getLocal().update(key, ValueFactory.createIntegerValue(val)); + } + + public <T> void update(String key, T val) { + try { + DataSegment.getLocal().update(key, SingletonMessage.getInstance().unconvert(val)); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public void update(String managerKey, String key, Value val) { + DataSegment.get(managerKey).update(key, val); + } + + public void update(String managerKey, String key, String val) { + DataSegment.get(managerKey).update(key, ValueFactory.createRawValue(val)); + } + + public void update(String managerKey, String key, byte[] val) { + DataSegment.get(managerKey).update(key, ValueFactory.createRawValue(val, true)); + } + + public void update(String managerKey, String key, int val) { + DataSegment.get(managerKey).update(key, ValueFactory.createIntegerValue(val)); + } + public <T> void update(String managerKey, String key, T val) { try { DataSegment.get(managerKey).update(key, SingletonMessage.getInstance().unconvert(val));
--- a/src/alice/datasegment/LocalDataSegmentManager.java Tue Feb 26 13:46:18 2013 +0900 +++ b/src/alice/datasegment/LocalDataSegmentManager.java Tue Feb 26 14:24:23 2013 +0900 @@ -1,6 +1,7 @@ package alice.datasegment; -import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.LinkedBlockingQueue; @@ -123,11 +124,9 @@ public void flip(Receiver receiver, Value val){ DataSegmentKey dataSegmentKey = getDataSegmentKey(receiver.key); - ArrayList<DataSegmentValue> dataList = dataSegmentKey.getDataList(); + List<DataSegmentValue> dataList = Collections.synchronizedList( dataSegmentKey.getDataList() ); DataSegmentValue dval = new DataSegmentValue(receiver.index, val, "local"); - synchronized(dataList){ - dataList.set(receiver.index-1, dval); - } + dataList.set(receiver.index-1, dval); } }
--- a/src/alice/test/codesegment/local/TestCodeSegment.java Tue Feb 26 13:46:18 2013 +0900 +++ b/src/alice/test/codesegment/local/TestCodeSegment.java Tue Feb 26 14:24:23 2013 +0900 @@ -31,8 +31,9 @@ TestCodeSegment cs = new TestCodeSegment(); cs.arg1.setKey("key1", arg1.index); */ - ods.update("local","key1",arg1.asInteger()+1); - //ods.flip(arg1, arg1.asInteger()+1); + //ods.update("key1",arg1.asInteger()+1); + //ods.update("local","key1",arg1.asInteger()+1); + ods.flip(arg1, arg1.asInteger()+1); new TestCodeSegment(); //new TestCodeSegment(arg1.index);
--- a/src/alice/topology/node/StartTopologyNode.java Tue Feb 26 13:46:18 2013 +0900 +++ b/src/alice/topology/node/StartTopologyNode.java Tue Feb 26 14:24:23 2013 +0900 @@ -46,6 +46,7 @@ cs3.configNodeNum.setKey("local", "configNodeNum"); } + @SuppressWarnings("unused") private String getIPAddress() throws SocketException { Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();