Mercurial > hg > RemoteEditor > REPSessionManager
view test/mergertest/TestMerger.java @ 473:596cc0a3beea
new Merge Algorithm
author | one |
---|---|
date | Thu, 14 Oct 2010 16:15:03 +0900 |
parents | b800b33c6988 |
children |
line wrap: on
line source
package test.mergertest; import java.io.IOException; import java.util.LinkedList; import rep.REP; import rep.REPCommand; import rep.Session; import rep.channel.REPSelectionKey; import rep.channel.REPSocketChannel; import rep.handler.Editor; import rep.optimizers.NullOptimizer; import test.editortest.Logger; public class TestMerger extends Editor { Editor trans; private int seq; private LinkedList<REPCommand> commandList; private LinkedList<REPCommand> othersCommandList; public static void main(String[] args){ TestMerger test = new TestMerger(); test.setCommands(); test.start(); } public TestMerger(){ super(null, 0); eid = 1; sid = 1; trans = new Editor(eid, new NullOptimizer()); } private void setCommands() { commandList = new LinkedList<REPCommand>(); commandList.add(new REPCommand(REP.REPCMD_INSERT, sid, eid, seq++, 10, "AAAAA")); commandList.add(new REPCommand(REP.REPCMD_INSERT, sid, eid, seq++, 10, "BBBBB")); othersCommandList = new LinkedList<REPCommand>(); othersCommandList.add(new REPCommand(REP.REPCMD_INSERT, sid, eid+1, 1, 10, "CCCCC")); } private void start() { for(REPCommand command : commandList){ Logger.print(command); trans.transSendCmd(command); } for(REPCommand command : othersCommandList){ Logger.print(command); // trans.transReceiveCmd(null, command); } for(int i = 0; i < commandList.size(); i++){ trans.merge(this,null); System.out.println(); } } @Override public void cancel(REPSocketChannel<REPCommand> channel1) { } @Override public void checkWaitingCommandInMerge() { } @Override public void forwardedCommandManage(REPCommand command) { } @Override public String getLocalHostName() { return null; } @Override public void handle(REPCommand command, REPSelectionKey<REPCommand> key) throws IOException { } @Override public void joinAck(REPCommand sendCommand, int sid) { } @Override public boolean manage(REPCommand command) { return false; } @Override public void selectSession(REPCommand sendCommand, Session session) { } @Override public void send(REPCommand command) { Logger.print(command); } @Override public void sendWithSeq(REPCommand command) { } @Override public int seq() { return seq++; } @Override public void setQuit2(REPCommand receivedCommand) { } @Override public void write(REPCommand command) { } }