changeset 61:def989051b0c

add diff time
author axmo
date Thu, 19 Feb 2009 23:05:04 +0900
parents 673085a02ccb
children 4d8c688b1d3c
files src/fdl/test/transfer/cluster/FDLServWithSendMeta.java src/fdl/test/transfer/cluster/MetaProtocolEngine.java
diffstat 2 files changed, 22 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/fdl/test/transfer/cluster/FDLServWithSendMeta.java	Tue Feb 17 23:28:58 2009 +0900
+++ b/src/fdl/test/transfer/cluster/FDLServWithSendMeta.java	Thu Feb 19 23:05:04 2009 +0900
@@ -21,11 +21,12 @@
 	static int chknum;
 	private static String bufstring;
 	private static int bufsize;
-	
+	private static String txt;
+	private static int ring;
 	
 	@Override public void mainLoop() {
 		MetaLinda ml = new MetaLinda(tupleSpace, this);
-		mpe = new MetaProtocolEngine(ml, nextHost, chknum, bufsize);
+		mpe = new MetaProtocolEngine(ml, nextHost, chknum, bufsize, txt);
 		mpe.mainLoop();
 	}
 	
@@ -33,6 +34,9 @@
 		for (int k=0; k<args.length; ++k) {
 			if("-bufsize".equals(args[k])){
 				bufstring = args[++k];
+			} else if("-ring".equals(args[k])){
+				txt = args[++k];
+				ring = Integer.valueOf(txt);
 			} else {
 	        System.err.println("引数指定の誤り:未知の引数が指定されました");
             }
@@ -51,7 +55,7 @@
 	private static void chkhost() throws UnknownHostException{
 		String localhost = null;
 		BufferedReader br = null;
-		String hostTable[] = new String[10];
+		String hostTable[] = new String[ring+1];
 		try {
 			br = new BufferedReader(new FileReader("nodelist"));
 			int i = 0;
@@ -64,7 +68,7 @@
 			for (int j=0; j<hostTable.length; j++) {
 				if(localhost.equals(hostTable[j])){
 					nextHost = hostTable[++j];
-					if(hostTable[j] == null) {
+					if(j == ring) {
 						nextHost = hostTable[0];
 					}
 				}
--- a/src/fdl/test/transfer/cluster/MetaProtocolEngine.java	Tue Feb 17 23:28:58 2009 +0900
+++ b/src/fdl/test/transfer/cluster/MetaProtocolEngine.java	Thu Feb 19 23:05:04 2009 +0900
@@ -27,15 +27,18 @@
 	private int bufsize;
 
 	private String time;
+	private long timelong;
 	private String start;
-
+	private String txt;
 	private String transfer;
+	private long transferlong;
 	
-	public MetaProtocolEngine(MetaLinda ml, String host, int chknum, int bufsize) {
+	public MetaProtocolEngine(MetaLinda ml, String host, int chknum, int bufsize, String txt) {
 		this.host = host;
 		this.fdlmeta = ml;
 		this.chknum = chknum;
 		this.bufsize = bufsize;
+		this.txt = txt;
 	}
 
 	public void mainLoop(){
@@ -109,6 +112,7 @@
 				//outしたbytebufferの変更をこれ以降やっちゃいけない
 				psxsend.out(id,data);
 				transfer = DF.format(new Date());
+				transferlong = new Date().getTime();
 				System.out.println("transfer Time => "+transfer);
 				System.out.println("connect to => "+host);
 				psxsend.sync(1);
@@ -132,6 +136,7 @@
 			int i = data2.getInt();
 			if (i == localhost2){
 				time = DF.format(new Date());
+				timelong = new Date().getTime();
 				System.out.println("Around Time => "+time);
 			}
 			running2 = false;
@@ -142,7 +147,10 @@
 	
 	
 	public void write() throws IOException{
-		File read = new File("resultTime.txt");
+		long result = (timelong - transferlong);
+		String diff = String.valueOf(result);
+		File read = new File("resultTime"+bufsize+"_"+txt+".txt");
+		read.createNewFile();
 		FileWriter filewrite = new FileWriter(read);
 		if (start != "null"){
 		filewrite.write("ServerStart => "+start+"\r\n");
@@ -153,6 +161,9 @@
 		if (time != "null"){
 		filewrite.write("AroundTime => "+time+"\r\n");
 		}
+		if (diff != "null"){
+		filewrite.write("DiffTime => "+diff+"\r\n");
+		}
 		filewrite.close();
 	}
 }