Mercurial > hg > RemoteEditor > REPSessionManager
changeset 398:7de83b6a34e7
not yet fixed....
author | one |
---|---|
date | Sun, 23 Nov 2008 18:38:52 +0900 |
parents | 149c9a53fc37 |
children | 19705f4b8015 |
files | rep/handler/Editor.java test/sematest/TestEditor.java |
diffstat | 2 files changed, 32 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/rep/handler/Editor.java Sun Nov 23 16:35:20 2008 +0900 +++ b/rep/handler/Editor.java Sun Nov 23 18:38:52 2008 +0900 @@ -47,6 +47,7 @@ // Second Phase が終わって同期が終了。 return; } + if (waitingRequired(command)) return; checkReturnedCommand(command); return; } @@ -70,52 +71,41 @@ // これは、distributed case では、うまくいかないので、送り先のforwarder で処理する。 if (next.isDirect()) { REPCommand keep; - switch (command.cmd) { - case REPCMD_INSERT: - keep = new REPCommand(command); - keep.cmd = REP.REPCMD_INSERT_ACK; - sentList.add(keep); - ServerMainLoop.logger.writeLog("Editor eid:"+eid+" sentList = "+sentList); - break; - case REPCMD_DELETE: - keep = new REPCommand(command); - keep.cmd = REP.REPCMD_DELETE_ACK; - sentList.add(keep); - ServerMainLoop.logger.writeLog("Editor eid:"+eid+" sentList = "+sentList); - break; - } + if (waitingRequired(command)) return; + keep = new REPCommand(command); + sentList.add(keep); + ServerMainLoop.logger.writeLog("Editor eid:"+eid+" sentList = "+sentList); ((Editor) next).checkReturnedCommand(command); } else next.send(command); } else { //他のエディタからの編集コマンド - if (manager.hasWaitingCommand(channel)) { - // We cannot do this operation before watingCommandQueue. - manager.addWaitingCommand(new PacketSet(channel, this, command)); - } else if (isMerging()) { - manager.addWaitingCommand(new PacketSet(getChannel(), this, new REPCommand(command))); - } else { - translator.transReceiveCmd(next,command); - if(command.cmd==REP.REPCMD_DELETE) { - // delete のundo用の文字列は、外に出す意味はない - command.string=null; - } - sendEditorCommand(command); + if (waitingRequired(command)) return; + translator.transReceiveCmd(next,command); + if(command.cmd==REP.REPCMD_DELETE) { + // delete のundo用の文字列は、外に出す意味はない + command.string=null; } + sendEditorCommand(command); } return; } + + private boolean waitingRequired(REPCommand command) { + if (manager.hasWaitingCommand(channel)) { + // We cannot do this operation before watingCommandQueue. + manager.addWaitingCommand(new PacketSet(channel, this, command)); + return true; + } else if (isMerging()) { + manager.addWaitingCommand(new PacketSet(getChannel(), this, new REPCommand(command))); + return true; + } + ServerMainLoop.logger.writeLog("Editor eid:"+eid+" no waiting"); + return false; + } private void sendEditorCommand(REPCommand command) { REPCommand keep = new REPCommand(command); - switch(command.cmd) { - case REPCMD_INSERT: - keep.cmd = REP.REPCMD_INSERT_ACK; - break; - case REPCMD_DELETE: - keep.cmd = REP.REPCMD_DELETE_ACK; - break; - } sentList.add(keep); ServerMainLoop.logger.writeLog("Editor eid:"+eid+" sentList = "+sentList); assert(sentList.size()<limit); @@ -133,9 +123,11 @@ */ void checkReturnedCommand(REPCommand command) { REPCommand prev = sentList.remove(0); + ServerMainLoop.logger.writeLog("Editor eid="+eid+" remove sentList:"+(prev==null?"null":prev)); if (prev==null || prev.seq != command.seq || prev.eid!=command.eid) { - String err = "Editor.checkReturnedCommand() : command = " + command + " prev="; - err += prev==null?"null":prev.toString(); + String err = "Editor eid="+eid+" checkReturnedCommand() : command = " + command + " prev="+ + (prev==null?"null":prev)+" sentList="; + err += sentList; ServerMainLoop.logger.writeLog(err); assert(false); } @@ -203,12 +195,8 @@ // First Phase End, send ACK REPCommand keep = new REPCommand(preMergeCommand); switch(keep.cmd) { - case REPCMD_INSERT: - keep.cmd = REP.REPCMD_INSERT_ACK; - break; - case REPCMD_DELETE: - keep.cmd = REP.REPCMD_DELETE_ACK; - break; + case REPCMD_INSERT: keep.cmd = REP.REPCMD_INSERT_ACK;break; + case REPCMD_DELETE: keep.cmd = REP.REPCMD_DELETE_ACK;break; } sentList.add(keep); ServerMainLoop.logger.writeLog("Editor eid:"+eid+" sentList = "+sentList);
--- a/test/sematest/TestEditor.java Sun Nov 23 16:35:20 2008 +0900 +++ b/test/sematest/TestEditor.java Sun Nov 23 18:38:52 2008 +0900 @@ -61,14 +61,14 @@ this.master=true; text = new Text(txts); cmds.add(new REPCommand(REP.SMCMD_PUT,0,0,0,0,name+"-file")); - cmds.add(new REPCommand(REP.REPCMD_INSERT,0,0,0,0,"m0")); + //cmds.add(new REPCommand(REP.REPCMD_INSERT,0,0,0,0,"m0")); cmds.add(new REPCommand(REP.REPCMD_DELETE,0,0,0,0,"m0")); //cmds.add(new REPCommand(REP.SMCMD_QUIT,0,0,0,0,"")); } else { text = new Text(new String[0]); cmds.add(new REPCommand(REP.SMCMD_JOIN,0,0,0,0,name)); cmds.add(new REPCommand(REP.REPCMD_INSERT,0,0,0,0,"c0")); - cmds.add(new REPCommand(REP.REPCMD_DELETE,0,0,0,0,"c0")); + //cmds.add(new REPCommand(REP.REPCMD_DELETE,0,0,0,0,"c0")); } }