changeset 499:4bcc6b563d52 global-seq-sort

looks like working now.
author one
date Sun, 24 Oct 2010 15:07:23 +0900
parents 138f3b33aa5e
children 66096af6a0e0
files Todo rep/handler/Editor.java
diffstat 2 files changed, 19 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/Todo	Sun Oct 24 14:19:52 2010 +0900
+++ b/Todo	Sun Oct 24 15:07:23 2010 +0900
@@ -11,8 +11,16 @@
 一周後に、それより前のcommandは来ないので、そこまで
 確定させて良い。(sentListから削除)
 
+自分のcommandがsortされないで残る感じ?
+
 unMergeCmds がないので、mergeAgain を作り直す必要がある。
 
+editor のseqは、sm 側で付けなおす必要がある。
+
+editor間のトポロジーが狂うバグがあるらしい
+    1->2->1->3
+のような。
+
 Sat Oct 23 22:24:31 JST 2010
 
     Editor1    Editor2    Editor3 
--- a/rep/handler/Editor.java	Sun Oct 24 14:19:52 2010 +0900
+++ b/rep/handler/Editor.java	Sun Oct 24 15:07:23 2010 +0900
@@ -126,7 +126,9 @@
 					checkReturnedCommand(command);
 					checkQuit();
 					return;
-				} 
+				} else 	if (mergeMode==MergeMode.Direct) {
+					truncateUnMergedCmds(command);
+				}
 				// Second Phase が終わって同期が終了。
 				// SessionManager.logger.writeLog("Complete "+command);
 				checkAck(command);
@@ -168,7 +170,7 @@
 					checkAck(command);
 					sendAck(command);
 				} else	if (mergeMode==MergeMode.Direct) {
-					truncateUnMergedCmds(command);
+					// truncateUnMergedCmds(command);
 					checkAck(command);
 					sendAck(command);
 				} else {
@@ -616,6 +618,7 @@
 	public REPCommand transSendCmd(REPCommand cmd){
 		assert(cmd.eid==eid);
 		
+		cmd.seq = seq(); // renumber editor's seq
 		//マージ中にユーザから割り込みがあった場合
 		if(isMerging()){
 			logger.writeLog("mergeAgain"+eid+":"+cmd);
@@ -737,8 +740,8 @@
 		public int compare(REPCommand o1, REPCommand o2) {
 			int eid1 = o1.eid-base; if (eid1<0) eid1 += Integer.MAX_VALUE;
 			int eid2 = o2.eid-base; if (eid2<0) eid2 += Integer.MAX_VALUE;
-			if ( gSeq(o1)<gSeq(o2) ) return -1;
-			if ( gSeq(o1)>gSeq(o2) ) return 1;
+			if ( gSeq(o1.seq)<gSeq(o2.seq) ) return -1;
+			if ( gSeq(o1.seq)>gSeq(o2.seq) ) return 1;
 			if ( eid1<eid2 ) return -1;
 			if ( eid1>eid2 ) return 1;
 			if ( o1.seq<o2.seq ) return -1;
@@ -760,8 +763,8 @@
 
 	final int gseqLimit = 1000;
 	
-	private int gSeq(REPCommand cmd) {
-		return cmd.seq/gseqLimit;
+	private int gSeq(int seq) {
+		return seq/gseqLimit;
 	}
 	
 	/**
@@ -769,8 +772,8 @@
 	 * @param oseq
 	 */
 	private void incrementGseq( REPCommand cmd) {
-		if (gSeq(cmd) / gseqLimit >= seq / gseqLimit) {
-			setSeq((gSeq(cmd)/gseqLimit+1)*gseqLimit);
+		if (gSeq(cmd.seq)  >= gSeq(seq)) {
+			setSeq((gSeq(cmd.seq)+1)*gseqLimit);
 		}
 	}