420
|
1 package test.mergertest;
|
|
2
|
|
3 import java.io.IOException;
|
|
4 import java.util.LinkedList;
|
|
5
|
|
6 import rep.REP;
|
|
7 import rep.REPCommand;
|
|
8 import rep.Session;
|
|
9 import rep.channel.REPSelectionKey;
|
|
10 import rep.channel.REPSocketChannel;
|
465
|
11 import rep.handler.Editor;
|
420
|
12 import rep.optimizers.NullOptimizer;
|
|
13 import test.editortest.Logger;
|
|
14
|
465
|
15 public class TestMerger extends Editor {
|
468
|
16 Editor trans;
|
420
|
17 private int seq;
|
|
18 private LinkedList<REPCommand> commandList;
|
|
19 private LinkedList<REPCommand> othersCommandList;
|
|
20
|
|
21 public static void main(String[] args){
|
|
22 TestMerger test = new TestMerger();
|
|
23 test.setCommands();
|
|
24 test.start();
|
|
25 }
|
|
26
|
|
27 public TestMerger(){
|
465
|
28 super(null, 0);
|
420
|
29 eid = 1;
|
|
30 sid = 1;
|
468
|
31 trans = new Editor(eid, new NullOptimizer());
|
420
|
32 }
|
|
33
|
|
34 private void setCommands() {
|
|
35 commandList = new LinkedList<REPCommand>();
|
|
36 commandList.add(new REPCommand(REP.REPCMD_INSERT, sid, eid, seq++, 10, "AAAAA"));
|
|
37 commandList.add(new REPCommand(REP.REPCMD_INSERT, sid, eid, seq++, 10, "BBBBB"));
|
|
38 othersCommandList = new LinkedList<REPCommand>();
|
|
39 othersCommandList.add(new REPCommand(REP.REPCMD_INSERT, sid, eid+1, 1, 10, "CCCCC"));
|
|
40 }
|
|
41
|
|
42 private void start() {
|
|
43 for(REPCommand command : commandList){
|
|
44 Logger.print(command);
|
|
45 trans.transSendCmd(command);
|
|
46 }
|
|
47 for(REPCommand command : othersCommandList){
|
|
48 Logger.print(command);
|
|
49 trans.transReceiveCmd(null, command);
|
|
50 }
|
|
51 for(int i = 0; i < commandList.size(); i++){
|
465
|
52 trans.merge(this,null);
|
420
|
53 System.out.println();
|
|
54 }
|
|
55 }
|
|
56
|
|
57 @Override
|
|
58 public void cancel(REPSocketChannel<REPCommand> channel1) {
|
|
59
|
|
60 }
|
|
61
|
|
62 @Override
|
|
63 public void checkWaitingCommandInMerge() {
|
|
64
|
|
65 }
|
|
66
|
|
67 @Override
|
|
68 public void forwardedCommandManage(REPCommand command) {
|
|
69
|
|
70 }
|
|
71
|
|
72 @Override
|
|
73 public String getLocalHostName() {
|
|
74 return null;
|
|
75 }
|
|
76
|
|
77 @Override
|
|
78 public void handle(REPCommand command, REPSelectionKey<REPCommand> key)
|
|
79 throws IOException {
|
|
80
|
|
81 }
|
|
82
|
|
83 @Override
|
|
84 public void joinAck(REPCommand sendCommand, int sid) {
|
|
85
|
|
86 }
|
|
87
|
|
88 @Override
|
|
89 public boolean manage(REPCommand command) {
|
|
90 return false;
|
|
91 }
|
|
92
|
|
93 @Override
|
|
94 public void selectSession(REPCommand sendCommand, Session session) {
|
|
95
|
|
96 }
|
|
97
|
|
98 @Override
|
|
99 public void send(REPCommand command) {
|
|
100 Logger.print(command);
|
|
101 }
|
|
102
|
|
103 @Override
|
|
104 public void sendWithSeq(REPCommand command) {
|
|
105
|
|
106 }
|
|
107
|
|
108 @Override
|
|
109 public int seq() {
|
|
110 return seq++;
|
|
111 }
|
|
112
|
|
113 @Override
|
|
114 public void setQuit2(REPCommand receivedCommand) {
|
465
|
115
|
420
|
116
|
|
117 }
|
431
|
118
|
450
|
119
|
|
120 @Override
|
|
121 public void write(REPCommand command) {
|
|
122
|
|
123 }
|
465
|
124
|
420
|
125 }
|