1 package org.apache.helix.tools;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.helix.HelixManager;
23
24 public class TestCommand
25 {
26 public enum CommandType
27 {
28 MODIFY,
29 VERIFY,
30 START,
31 STOP
32 }
33
34 public static class NodeOpArg
35 {
36 public HelixManager _manager;
37 public Thread _thread;
38
39 public NodeOpArg(HelixManager manager, Thread thread)
40 {
41 _manager = manager;
42 _thread = thread;
43 }
44 }
45
46 public TestTrigger _trigger;
47 public CommandType _commandType;
48 public ZnodeOpArg _znodeOpArg;
49 public NodeOpArg _nodeOpArg;
50
51 public long _startTimestamp;
52 public long _finishTimestamp;
53
54
55
56
57
58
59 public TestCommand(CommandType type, ZnodeOpArg arg)
60 {
61 this(type, new TestTrigger(), arg);
62 }
63
64
65
66
67
68
69
70 public TestCommand(CommandType type, TestTrigger trigger, ZnodeOpArg arg)
71 {
72 _commandType = type;
73 _trigger = trigger;
74 _znodeOpArg = arg;
75 }
76
77
78
79
80
81
82
83 public TestCommand(CommandType type, TestTrigger trigger, NodeOpArg arg)
84 {
85 _commandType = type;
86 _trigger = trigger;
87 _nodeOpArg = arg;
88 }
89
90 @Override
91 public String toString()
92 {
93 String ret = super.toString().substring(super.toString().lastIndexOf(".") + 1) + " ";
94 if (_finishTimestamp > 0)
95 {
96 ret += "FINISH@" + _finishTimestamp + "-START@" + _startTimestamp
97 + "=" + (_finishTimestamp - _startTimestamp) + "ms ";
98 }
99 if (_commandType == CommandType.MODIFY || _commandType == CommandType.VERIFY)
100 {
101 ret += _commandType.toString() + "|" + _trigger.toString() + "|" + _znodeOpArg.toString();
102 }
103 else if (_commandType == CommandType.START || _commandType == CommandType.STOP)
104 {
105 ret += _commandType.toString() + "|" + _trigger.toString() + "|" + _nodeOpArg.toString();
106 }
107
108 return ret;
109 }
110 }