Mercurial > hg > RemoteEditor > REPSessionManager
changeset 464:295c257ac073
ack list separation
author | one |
---|---|
date | Fri, 01 Oct 2010 18:48:40 +0900 |
parents | 3c2918368de3 |
children | c83af820eb62 |
files | Todo rep/handler/Editor.java rep/handler/Translator.java |
diffstat | 3 files changed, 15 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/Todo Fri Oct 01 17:20:12 2010 +0900 +++ b/Todo Fri Oct 01 18:48:40 2010 +0900 @@ -4,6 +4,9 @@ SMCMD_QUITをSMCMD_QUIT_2に変えているのは誰? Editor 側でやっているのかぁ。 +自分のinsert commandを落してしまうらしい。ack のcheckと、editor list +をわけるべきなのか? + Tue Sep 28 10:43:14 JST 2010 廻る順序でコマンド順は確定する。
--- a/rep/handler/Editor.java Fri Oct 01 17:20:12 2010 +0900 +++ b/rep/handler/Editor.java Fri Oct 01 18:48:40 2010 +0900 @@ -17,15 +17,16 @@ private Translator translator; // REPCommands we are going to send to the next editor private LinkedList<REPCommand> sentList = new LinkedList<REPCommand>(); + // Expected acknowledge list + private LinkedList<REPCommand> ackList = new LinkedList<REPCommand>(); public LinkedList<REPCommand> waitingCommandInMerge= new LinkedList<REPCommand>(); private REPCommand quit_2=null; private REPCommand preMergeCommand; private boolean merging; - private REPCommand mergeMark = new REPCommand(REP.SMCMD_START_MERGE, 0,0, 0, 0, ""); public static boolean noMergeMode=false; static final boolean doOptimize = false; private LinkedList<REPCommand> writeQueue = new LinkedList<REPCommand>(); - static boolean slowMerge = false; + static boolean slowMerge = true; public Editor(SessionManager manager,int editorNo){ // no translator case @@ -35,7 +36,6 @@ public Editor(int editorNo, SessionManager manager,REPSocketChannel<REPCommand> channel){ super(editorNo,manager,channel); eid = editorNo; - sentList.add(mergeMark); // merge mark REPCommandOptimizer optimizer; if (doOptimize) optimizer = new DeleteInsertOptimizer(); //タカノがつくったおぷてぃまいざ else optimizer = new NullOptimizer(); //なにもしないけどOptimizer. @@ -230,8 +230,9 @@ private void sendEditorCommand(REPCommand command) { REPCommand keep = new REPCommand(command); sentList.add(keep); + ackList.add(keep); //ServerMainLoop.logger.writeLog("Editor eid:"+eid+" sentList = "+sentList); - assert(sentList.size()<limit); + assert(ackList.size()<limit); if (command.cmd==REP.REPCMD_DELETE) { // delete のundo用の文字列は、外に出す意味はない command.string=null; @@ -290,12 +291,12 @@ private boolean checkAck(REPCommand command) { assert(!isMerging()); REPCommand prev; - if (sentList.getFirst()==mergeMark) prev=sentList.remove(1); else prev=sentList.remove(0); + prev=ackList.remove(0); if (prev==null || prev.seq != command.seq || prev.eid!=command.eid) { // should be more robust to allow communication failure String err = "Editor eid="+eid+" checkReturnedCommand() : command = " + command + " prev="+ - (prev==null?"null":prev)+" sentList="; - err += sentList; + (prev==null?"null":prev)+" ackList="; + err += ackList; ServerMainLoop.logger.writeLog(err); assert(false); } @@ -349,8 +350,7 @@ } else { next.send(preMergeCommand); } - sentList.remove(mergeMark); - sentList.addLast(mergeMark); + sentList.clear(); preMergeCommand = null; } @@ -362,18 +362,15 @@ case REPCMD_DELETE: keep.cmd = REP.REPCMD_DELETE_ACK;break; default: assert(false); } - if (slowMerge) - sentList.addLast(keep); - else - sentList.addLast(command); + ackList.addLast(keep); ServerMainLoop.logger.writeLog("Editor"+eid+": sendAck sentList = "+sentList); - assert(sentList.size()<limit); + assert(ackList.size()<limit); keep.string = ""; next.send(keep); } private boolean checkQuit() { - if (quit_2!=null && sentList.size()==1&&!isMerging() && waitingCommandInMerge.size()==0) { + if (quit_2!=null && sentList.size()==0&&!isMerging() && waitingCommandInMerge.size()==0) { sendToEditor(quit_2); quit_2 = null; return true;
--- a/rep/handler/Translator.java Fri Oct 01 17:20:12 2010 +0900 +++ b/rep/handler/Translator.java Fri Oct 01 18:48:40 2010 +0900 @@ -66,13 +66,7 @@ sortedEditCmds = new TreeSet<REPCommand>(new REPCommandComparator(1)); logger.writeLog("sentList"+eid+":"+editor.getSentList()); - boolean merged = true; for( REPCommand cmd0 : editor.getSentList()) { - if (cmd0.cmd==REP.SMCMD_START_MERGE) { - merged = false; - continue; - } - if (merged) continue; if (cmd0.cmd==REP.REPCMD_INSERT || cmd0.cmd==REP.REPCMD_DELETE) sortedEditCmds.add(cmd0); }