changeset 184:4475ba30238f working

minor change
author e095732
date Wed, 27 Feb 2013 06:30:14 +0900
parents 75150396681c
children 094d8fa4945e
files src/alice/codesegment/OutputDataSegment.java src/alice/datasegment/CommandType.java src/alice/datasegment/DataSegmentKey.java src/alice/datasegment/LocalDataSegmentManager.java src/alice/test/codesegment/local/TestCodeSegment.java
diffstat 5 files changed, 8 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/src/alice/codesegment/OutputDataSegment.java	Tue Feb 26 14:24:23 2013 +0900
+++ b/src/alice/codesegment/OutputDataSegment.java	Wed Feb 27 06:30:14 2013 +0900
@@ -7,34 +7,9 @@
 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 flip(Receiver receiver, String val) {
-		DataSegment.getLocal().flip(receiver, ValueFactory.createRawValue(val));
-	}
-	
-	public void flip(Receiver receiver, int val) {
-		DataSegment.getLocal().flip(receiver, ValueFactory.createIntegerValue(val));
-	}
-	
-	public void flip(Receiver receiver, byte[] val) {
-		DataSegment.getLocal().flip(receiver, ValueFactory.createRawValue(val));
-	}
-	
-	public <T> void filp(Receiver receiver, T val) {
-		try {
-			DataSegment.getLocal().flip(receiver, SingletonMessage.getInstance().unconvert(val));
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-	}
-	
 	public void put(String key, Value val) {
 		DataSegment.getLocal().put(key, val);
 	}
--- a/src/alice/datasegment/CommandType.java	Tue Feb 26 14:24:23 2013 +0900
+++ b/src/alice/datasegment/CommandType.java	Wed Feb 27 06:30:14 2013 +0900
@@ -10,7 +10,8 @@
 	REMOVE,
 	REPLY,
 	CLOSE,
-	FINISH;
+	FINISH,
+	FLIP;
 	
 	public int id;
 	public static HashMap<Integer, CommandType> hash = new HashMap<Integer, CommandType>();
--- a/src/alice/datasegment/DataSegmentKey.java	Tue Feb 26 14:24:23 2013 +0900
+++ b/src/alice/datasegment/DataSegmentKey.java	Wed Feb 27 06:30:14 2013 +0900
@@ -78,6 +78,8 @@
 				break;
 			}
 			boolean waitFlag = true;
+			
+			synchronized(dataList){
 			for (Iterator<DataSegmentValue> iter = dataList.iterator(); iter.hasNext(); ) {
 				DataSegmentValue data = iter.next();
 				if (data.index > cmd.index) {
@@ -91,9 +93,12 @@
 					break;
 				}
 			}
+			}
 			if (waitFlag)
 				waitList.add(cmd);
 			break;
+		case FLIP:
+			break;
 		case REMOVE:
 			// TODO: implements later
 			break;
--- a/src/alice/datasegment/LocalDataSegmentManager.java	Tue Feb 26 14:24:23 2013 +0900
+++ b/src/alice/datasegment/LocalDataSegmentManager.java	Wed Feb 27 06:30:14 2013 +0900
@@ -1,7 +1,5 @@
 package alice.datasegment;
 
-import java.util.Collections;
-import java.util.List;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.LinkedBlockingQueue;
 
@@ -122,11 +120,4 @@
 		
 	}
 	
-	public void flip(Receiver receiver, Value val){
-		DataSegmentKey dataSegmentKey = getDataSegmentKey(receiver.key);
-		List<DataSegmentValue> dataList = Collections.synchronizedList( dataSegmentKey.getDataList() );
-		DataSegmentValue dval = new DataSegmentValue(receiver.index, val, "local");
-		dataList.set(receiver.index-1, dval);
-	}
-	
 }
--- a/src/alice/test/codesegment/local/TestCodeSegment.java	Tue Feb 26 14:24:23 2013 +0900
+++ b/src/alice/test/codesegment/local/TestCodeSegment.java	Wed Feb 27 06:30:14 2013 +0900
@@ -19,22 +19,14 @@
 	
 	@Override
 	public void run() {
-		//System.out.println("index = " + arg1.index);
-		//System.out.println("data = " + arg1.val);
-		//System.out.println(arg1.val.getType());
 		if(count > 10000){
 			System.out.println(System.currentTimeMillis() - StartCodeSegment.t);
 			System.exit(1);
 		}
 		
-		/*
-		TestCodeSegment cs = new TestCodeSegment();
-		cs.arg1.setKey("key1", arg1.index);
-		*/
 		//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);
 		
 		count++;