Mercurial > hg > RemoteEditor > REPSessionManager
changeset 471:d2762d669617
sleep command to wait for singleton prevention
author | one |
---|---|
date | Tue, 12 Oct 2010 10:19:59 +0900 |
parents | 7f0d4e49eaf9 |
children | 2107530c3d72 |
files | Todo rep/REP.java rep/channel/REPLogger.java rep/handler/Editor.java test/sematest/TestEditor.java test/sematest/TestInterManagerSession.java |
diffstat | 6 files changed, 25 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/Todo Mon Oct 11 21:12:46 2010 +0900 +++ b/Todo Tue Oct 12 10:19:59 2010 +0900 @@ -1,3 +1,9 @@ +Mon Oct 11 22:12:35 JST 2010 + +あ、そうか。singleton case 中のコマンドは無視されてしまうわけね。SYNC すれば良いはずだが。 + +残念ながら、SYNC すると正しく動かない。 + Mon Oct 11 19:56:48 JST 2010 ackList を別にしたので、quit2 は ackList も見ないとだめだった。
--- a/rep/REP.java Mon Oct 11 21:12:46 2010 +0900 +++ b/rep/REP.java Tue Oct 12 10:19:59 2010 +0900 @@ -35,7 +35,8 @@ MERGE_EID ( -2), SMCMD_SYNC ( 83), - SMCMD_SYNC_ACK ( 84); + SMCMD_SYNC_ACK ( 84), + SMCMD_SLEEP(85); public final int id;
--- a/rep/channel/REPLogger.java Mon Oct 11 21:12:46 2010 +0900 +++ b/rep/channel/REPLogger.java Tue Oct 12 10:19:59 2010 +0900 @@ -15,7 +15,7 @@ protected REPLogger(){ } - private int logLevel; + private int logLevel=3; /** simulation log command */ public void writeLog(String log, int level){ if ( level<=logLevel ) @@ -23,11 +23,15 @@ //System.out.flush(); } public void writeLog(String log){ - writeLog(log, 0); + writeLog(log, 2); } public void setLogLevel(int logLevel) { this.logLevel = logLevel; } + + public int logLevel() { + return logLevel; + } }
--- a/rep/handler/Editor.java Mon Oct 11 21:12:46 2010 +0900 +++ b/rep/handler/Editor.java Tue Oct 12 10:19:59 2010 +0900 @@ -488,8 +488,6 @@ @Override public void handle(REPCommand command, REPSelectionKey<REPCommand> key) throws IOException { - //ServerMainLoop.logger.writeLog("Manager "+manager.getId()+" read : command = " + command - // +" from "+manager.editorList.editorByChannel(channel)); if (command.cmd==REP.SMCMD_JOIN||command.cmd==REP.SMCMD_PUT) { // assert false; // 一つのエディタ上に複数のセッションが作られた場合。 @@ -501,6 +499,7 @@ return; } if (manager.sessionManage(this, command)) return; + // ServerMainLoop.logger.writeLog("Editor"+eid+": handle command="+command); manage(command); } @@ -644,7 +643,7 @@ */ public void transReceiveCmd(REPNode nextEditor,REPCommand cmd){ assert (cmd.eid != eid); - unMergedCmds.addFirst(cmd); + unMergedCmds.addFirst(new REPCommand(cmd)); } public void setEid(int _eid){ @@ -652,7 +651,7 @@ } public boolean checkMergeConflict(REPCommand command) { - unMergedCmds.addFirst(command); + unMergedCmds.addFirst(new REPCommand(command)); REPCommand prev = sentMergedList.getFirst(); if (prev.seq==command.seq) {
--- a/test/sematest/TestEditor.java Mon Oct 11 21:12:46 2010 +0900 +++ b/test/sematest/TestEditor.java Tue Oct 12 10:19:59 2010 +0900 @@ -177,6 +177,12 @@ cmd.setString(del); sendCommand(cmd); break; + case SMCMD_SLEEP: + try { + sleep(1000); + } catch (InterruptedException e) { + } + break; case SMCMD_QUIT: /* * start termination phase 1 by the master editor. @@ -231,7 +237,7 @@ private void handle(REPCommand cmd) { if (cmd==null) return; - ns.writeLog(name +": read "+cmd + " textsize="+text.size()); + ns.writeLog(name +": read "+cmd + " textsize="+text.size()+" "+text); switch(cmd.cmd) { case REPCMD_INSERT : if (cmd.eid!=eid) {
--- a/test/sematest/TestInterManagerSession.java Mon Oct 11 21:12:46 2010 +0900 +++ b/test/sematest/TestInterManagerSession.java Tue Oct 12 10:19:59 2010 +0900 @@ -120,6 +120,7 @@ LinkedList<REPCommand>cmds = new LinkedList<REPCommand>(); //cmds.add(new REPCommand(REP.SMCMD_JOIN,0,0,0,0,"Editor0-file")); cmds.add(new REPCommand(REP.SMCMD_PUT,0,0,0,0,"Editor0-file")); + cmds.add(new REPCommand(REP.SMCMD_SLEEP,0,0,0,0,"")); cmds.add(new REPCommand(REP.REPCMD_INSERT_USER,0,0,0,0,"m0")); // cmds.add(new REPCommand(REP.REPCMD_DELETE_USER,0,0,0,0,"m0")); cmds.add(new REPCommand(REP.SMCMD_QUIT,0,0,0,0,""));