changeset 179:8d3cb7e5fa57 working

add TEST API flip
author e095732
date Sun, 03 Feb 2013 18:29:45 +0900
parents 1b532146b355
children 481dab56c3dc
files src/alice/codesegment/OutputDataSegment.java src/alice/datasegment/DataSegmentKey.java src/alice/datasegment/LocalDataSegmentManager.java
diffstat 3 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/alice/codesegment/OutputDataSegment.java	Sun Feb 03 18:20:46 2013 +0900
+++ b/src/alice/codesegment/OutputDataSegment.java	Sun Feb 03 18:29:45 2013 +0900
@@ -7,9 +7,14 @@
 import org.msgpack.type.ValueFactory;
 
 import alice.datasegment.DataSegment;
+import alice.datasegment.Receiver;
 
 public class OutputDataSegment {
 	
+	public void flip(Receiver receiver, Value val) {
+		DataSegment.getLocal().flip(receiver, val);
+	}
+	
 	public void put(String managerKey, String key, Value val) {
 		DataSegment.get(managerKey).put(key, val);
 	}
--- a/src/alice/datasegment/DataSegmentKey.java	Sun Feb 03 18:20:46 2013 +0900
+++ b/src/alice/datasegment/DataSegmentKey.java	Sun Feb 03 18:29:45 2013 +0900
@@ -17,6 +17,10 @@
 	private ArrayList<Command> waitList = new ArrayList<Command>();
 	private AtomicInteger tailIndex = new AtomicInteger(1);
 	
+	public ArrayList<DataSegmentValue> getDataList(){
+		return dataList;
+	}
+	
 	public void runCommand(Command cmd) {
 		switch (cmd.type) {
 		case UPDATE:
--- a/src/alice/datasegment/LocalDataSegmentManager.java	Sun Feb 03 18:20:46 2013 +0900
+++ b/src/alice/datasegment/LocalDataSegmentManager.java	Sun Feb 03 18:29:45 2013 +0900
@@ -1,5 +1,6 @@
 package alice.datasegment;
 
+import java.util.ArrayList;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.LinkedBlockingQueue;
 
@@ -120,4 +121,13 @@
 		
 	}
 	
+	public void flip(Receiver receiver, Value val){
+		DataSegmentKey dataSegmentKey = getDataSegmentKey(receiver.key);
+		ArrayList<DataSegmentValue> dataList = dataSegmentKey.getDataList();
+		DataSegmentValue dval = new DataSegmentValue(receiver.index, val, "local");
+		synchronized(dataList){
+			dataList.set(receiver.index, dval);
+		}
+	}
+	
 }