changeset 189:d2f5c885a367 working

add FLIP API in LocalDataSegmentManager class
author e095732
date Thu, 07 Mar 2013 12:31:05 +0900
parents 38d6a10be9c6
children a85ff8dc16c1
files src/alice/datasegment/DataSegmentKey.java src/alice/datasegment/DataSegmentValue.java src/alice/datasegment/LocalDataSegmentManager.java
diffstat 3 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/alice/datasegment/DataSegmentKey.java	Thu Mar 07 12:30:03 2013 +0900
+++ b/src/alice/datasegment/DataSegmentKey.java	Thu Mar 07 12:31:05 2013 +0900
@@ -95,7 +95,9 @@
 				waitList.add(cmd);
 			break;
 		case FLIP:
-			
+			index = tailIndex.getAndIncrement();
+			dataList.get(0).setDataSegmentValue(index, cmd.val, cmd.reverseKey);
+			// need to check waitList 
 			break;
 		case REMOVE:
 			// TODO: implements later
--- a/src/alice/datasegment/DataSegmentValue.java	Thu Mar 07 12:30:03 2013 +0900
+++ b/src/alice/datasegment/DataSegmentValue.java	Thu Mar 07 12:31:05 2013 +0900
@@ -14,4 +14,10 @@
 		this.from = reverseKey;
 	}
 	
+	public void setDataSegmentValue(int index, Value val, String reverseKey){
+		this.index = index;
+		this.val = val;
+		this.from = reverseKey;
+	}
+	
 }
--- a/src/alice/datasegment/LocalDataSegmentManager.java	Thu Mar 07 12:30:03 2013 +0900
+++ b/src/alice/datasegment/LocalDataSegmentManager.java	Thu Mar 07 12:31:05 2013 +0900
@@ -119,5 +119,13 @@
 	public void close() {
 		
 	}
+
+	public void flip(String key, Value val) {
+		DataSegmentKey dataSegmentKey = getDataSegmentKey(key);
+		Command cmd = new Command(CommandType.FLIP, null, key, val, 0, 0, replyQueue, null, reverseKey);
+		addCommand(dataSegmentKey, cmd);
+		if (logger.isDebugEnabled())
+			logger.debug(cmd.getCommandString());
+	}
 	
 }