comparison rep/handler/Translator.java @ 449:89a326696c54

mergeMark in sentList
author one
date Wed, 22 Sep 2010 22:11:58 +0900
parents ed97273477a0
children 21cb16b7f3df
comparison
equal deleted inserted replaced
448:ed97273477a0 449:89a326696c54
64 output.add( createUndo(cmd0) ); 64 output.add( createUndo(cmd0) );
65 } 65 }
66 66
67 sortedEditCmds = new TreeSet<REPCommand>(new REPCommandComparator(1)); 67 sortedEditCmds = new TreeSet<REPCommand>(new REPCommandComparator(1));
68 logger.writeLog("sentList"+eid+":"+editor.getSentList()); 68 logger.writeLog("sentList"+eid+":"+editor.getSentList());
69 boolean merged = true;
69 for( REPCommand cmd0 : editor.getSentList()) { 70 for( REPCommand cmd0 : editor.getSentList()) {
71 if (cmd0.cmd==REP.SMCMD_START_MERGE) {
72 merged = false;
73 continue;
74 }
75 if (merged) continue;
70 if (cmd0.cmd==REP.REPCMD_INSERT || cmd0.cmd==REP.REPCMD_DELETE) 76 if (cmd0.cmd==REP.REPCMD_INSERT || cmd0.cmd==REP.REPCMD_DELETE)
71 sortedEditCmds.add(cmd0); 77 sortedEditCmds.add(cmd0);
72 } 78 }
73 logger.writeLog("sortedMerge"+eid+":"+sortedEditCmds); 79 logger.writeLog("sortedMerge"+eid+":"+sortedEditCmds);
74 // logger.writeLog("Ediotr"+eid+" Merge:: sorted sent list => Eid="+eid+cmds+" ack="+prev); 80 // logger.writeLog("Ediotr"+eid+" Merge:: sorted sent list => Eid="+eid+cmds+" ack="+prev);
84 90
85 /** 91 /**
86 * Received all merge command ack 92 * Received all merge command ack
87 */ 93 */
88 public void endMerge() { 94 public void endMerge() {
89 LinkedList<REPCommand> n = new LinkedList<REPCommand>();
90 for(int i=0;i< sortedEditCmds.size()-1;i++) {
91 n.addLast(unMergedCmds.get(i));
92 }
93 sortedEditCmds = null; 95 sortedEditCmds = null;
94 unMergedCmds = n; 96 unMergedCmds = new LinkedList<REPCommand>();
95 } 97 }
96 /** 98 /**
97 * Sent optimized merged command list 99 * Sent optimized merged command list
98 * @param editor 100 * @param editor
99 * @param output 101 * @param output
216 public boolean isMerging() { 218 public boolean isMerging() {
217 return merge_mode; 219 return merge_mode;
218 } 220 }
219 221
220 public void startMerge(REPCommand cmd) { 222 public void startMerge(REPCommand cmd) {
221 logger.writeLog("START MERGE command ="+cmd+" and top of unMergedCmds = "+ unMergedCmds.getLast()); 223 logger.writeLog("START MERGE command ="+cmd+
224 ((unMergedCmds.size()>0)?" and top of unMergedCmds = "+ unMergedCmds.getLast():""));
222 merge_mode = true; 225 merge_mode = true;
223 } 226 }
224 227
225 /** 228 /**
226 * receive SMCMD_START_MERGE_ACK 229 * receive SMCMD_START_MERGE_ACK