changeset 126:669dba7cbb69 working

Use singleton
author sugi
date Fri, 03 Aug 2012 19:14:46 +0900
parents 6773146b353c
children 117dad267a9b
files src/alice/codesegment/OutputDataSegment.java src/alice/daemon/IncomingTcpConnection.java src/alice/datasegment/Receiver.java src/alice/test/topology/fishmodel/alpha/AutoIncrement.java
diffstat 4 files changed, 13 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/alice/codesegment/OutputDataSegment.java	Tue Jul 31 20:21:23 2012 +0900
+++ b/src/alice/codesegment/OutputDataSegment.java	Fri Aug 03 19:14:46 2012 +0900
@@ -2,7 +2,7 @@
 
 import java.io.IOException;
 
-import org.msgpack.MessagePack;
+
 import org.msgpack.type.Value;
 import org.msgpack.type.ValueFactory;
 
@@ -11,7 +11,7 @@
 public class OutputDataSegment {
 	
 	public CodeSegment cs;
-	private static MessagePack MSGPACK = new MessagePack();
+	//private static MessagePack MSGPACK = new MessagePack();
 	
 	public OutputDataSegment(CodeSegment codeSegment) {
 		this.cs = codeSegment;
@@ -51,7 +51,7 @@
 	
 	public <T> void put(String managerKey, String key, T val) {
 		try {
-			DataSegment.get(managerKey).put(key, MSGPACK.unconvert(val), cs);
+			DataSegment.get(managerKey).put(key, SingletonMessage.getInstance().unconvert(val), cs);
 		} catch (IOException e) {
 			e.printStackTrace();
 		}
@@ -59,7 +59,7 @@
 	
 	public <T> void update(String managerKey, String key, T val) {
 		try {
-			DataSegment.get(managerKey).update(key, MSGPACK.unconvert(val), cs);
+			DataSegment.get(managerKey).update(key, SingletonMessage.getInstance().unconvert(val), cs);
 		} catch (IOException e) {
 			e.printStackTrace();
 		}
--- a/src/alice/daemon/IncomingTcpConnection.java	Tue Jul 31 20:21:23 2012 +0900
+++ b/src/alice/daemon/IncomingTcpConnection.java	Fri Aug 03 19:14:46 2012 +0900
@@ -4,9 +4,10 @@
 import java.io.IOException;
 import java.nio.channels.ClosedChannelException;
 
-import org.msgpack.MessagePack;
+//import org.msgpack.MessagePack;
 import org.msgpack.unpacker.Unpacker;
 
+import alice.codesegment.SingletonMessage;
 import alice.datasegment.Command;
 import alice.datasegment.CommandType;
 import alice.datasegment.DataSegment;
@@ -16,7 +17,7 @@
 
 public class IncomingTcpConnection extends Thread {
 	
-	private static MessagePack MSGPACK = new MessagePack();
+	//private static MessagePack MSGPACK = new MessagePack();
 	public Connection connection;
 	public DataSegmentManager manager;
 	public String reverseKey;
@@ -34,7 +35,7 @@
 	public void run() {
 		Unpacker unpacker = null;
 		try {
-			unpacker = MSGPACK.createUnpacker(connection.socket.getInputStream());
+			unpacker = SingletonMessage.getInstance().createUnpacker(connection.socket.getInputStream());
 		} catch (IOException e2) {
 			e2.printStackTrace();
 		}
--- a/src/alice/datasegment/Receiver.java	Tue Jul 31 20:21:23 2012 +0900
+++ b/src/alice/datasegment/Receiver.java	Fri Aug 03 19:14:46 2012 +0900
@@ -2,11 +2,12 @@
 
 import java.io.IOException;
 
-import org.msgpack.MessagePack;
+//import org.msgpack.MessagePack;
 import org.msgpack.type.Value;
 import org.msgpack.type.ValueType;
 
 import alice.codesegment.InputDataSegment;
+import alice.codesegment.SingletonMessage;
 
 /**
  * MessagePack implementation and DataSegment Receiver
@@ -23,7 +24,7 @@
 	public String managerKey; // for debugging
 	public String key; 		  // for debugging
 	
-	private static MessagePack MSGPACK = new MessagePack();
+	//private static MessagePack MSGPACK = new MessagePack();
 	
 	public Receiver(InputDataSegment ids, CommandType type) {
 		this.ids = ids;
@@ -93,7 +94,7 @@
 	
 	public <T> T asClass(Class<T> clazz) {
 		try {
-			return MSGPACK.convert(val, clazz);
+			return SingletonMessage.getInstance().convert(val, clazz);
 		} catch (IOException e) {
 			e.printStackTrace();
 		}
--- a/src/alice/test/topology/fishmodel/alpha/AutoIncrement.java	Tue Jul 31 20:21:23 2012 +0900
+++ b/src/alice/test/topology/fishmodel/alpha/AutoIncrement.java	Fri Aug 03 19:14:46 2012 +0900
@@ -42,15 +42,13 @@
 		ods.update("local", key, FP);
 		/*
 		try {
-			wait(200);
+			wait(100);
 		} catch (InterruptedException e) {
 			// TODO Auto-generated catch block
 			e.printStackTrace();
 		}
 		*/
 		new AutoIncrement(this.key,this.position.index);
-		//Init();
-		//java.lang.System.gc();
 	}
 	
 }