annotate test/mergertest/TestMerger.java @ 468:b800b33c6988

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