Mercurial > hg > RemoteEditor > REPSessionManager
changeset 342:4b056e46ba83
*** empty log message ***
author | kono |
---|---|
date | Mon, 13 Oct 2008 03:33:16 +0900 |
parents | a9a740e685fa |
children | 21ad256c25c2 |
files | test/sematest/TestEditor.java test/sematest/TestInterManagerSession.java |
diffstat | 2 files changed, 25 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/test/sematest/TestEditor.java Mon Oct 13 03:05:53 2008 +0900 +++ b/test/sematest/TestEditor.java Mon Oct 13 03:33:16 2008 +0900 @@ -42,6 +42,7 @@ private int syncCounter=0; private boolean hasInputLock=false; private int port; + private REPSelector<REPCommand> selector; public TestEditor(String name, String _host,int _port, boolean master){ @@ -117,6 +118,7 @@ channel.configureBlocking(false); REPSelector<REPCommand> selector = REPSelector.create(); channel.register(selector, SelectionKey.OP_READ); + this.selector = selector; while(running) { if (inputLock) { // No user input during merge mode (optional) @@ -317,4 +319,10 @@ public int getPort() { return port; } + + public synchronized void setCommand(LinkedList<REPCommand> cmds) { + this.cmds = cmds; + timeout=1; + if(selector!=null) selector.wakeup(); + } }
--- a/test/sematest/TestInterManagerSession.java Mon Oct 13 03:05:53 2008 +0900 +++ b/test/sematest/TestInterManagerSession.java Mon Oct 13 03:33:16 2008 +0900 @@ -1,6 +1,10 @@ package test.sematest; +import java.util.LinkedList; + +import rep.REP; +import rep.REPCommand; import rep.SessionManager; import rep.SessionManagerEvent; import rep.channel.REPServerSocketChannel; @@ -19,7 +23,9 @@ public int slavePort[] = {masterPort,masterPort,masterPort}; public int editorPort[] = {masterPort,masterPort+1,masterPort+2}; - public boolean editorMaster[] = {true,false,false,false}; + public boolean editorMaster[] = {true,false,false,false}; + private LinkedList<REPCommand> editorStartCmds; + private SessionManagerEvent ev2[] = { new SessionManagerEvent() { // event for master @@ -61,13 +67,14 @@ for(TestEditor editor:editors) { if(editor.getPort()==manager.getPort()) { logger.writeLog("Start client "+editor); - editor.start(); + editor.start(); + editors[0].setCommand(editorStartCmds); } } } } }; - + /* * Create all editors, master session managers and slave session * managers with specified port. All instances are not started yet. @@ -93,6 +100,13 @@ // TestEditor extends Thread editors[i] = new TestEditor("Editor"+i,host,port,master); } + LinkedList<REPCommand>cmds = new LinkedList<REPCommand>(); + cmds.add(new REPCommand(REP.SMCMD_PUT,0,0,0,0,"Editor0-file")); + cmds.add(new REPCommand(REP.REPCMD_INSERT,0,0,0,0,"m0")); + cmds.add(new REPCommand(REP.REPCMD_DELETE,0,0,0,0,"m0")); + editorStartCmds = cmds; + LinkedList<REPCommand>nullcmds = new LinkedList<REPCommand>(); + editors[0].setCommand(nullcmds); } @Override