1 package org.apache.helix.tools;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import java.util.List;
23 import java.util.Map;
24
25 import org.apache.helix.ZNRecord;
26
27
28
29 public class TestTrigger
30 {
31 public long _startTime;
32 public long _timeout;
33 public ZnodeValue _expectValue;
34
35 /**
36 * no time or data trigger
37 */
38 public TestTrigger()
39 {
40 this(0, 0, (ZnodeValue)null);
41 }
42
43 /**
44 * time trigger with a start time, no data trigger
45 * @param startTime
46 * @param timeout
47 */
48 public TestTrigger(long startTime)
49 {
50 this(startTime, 0, (ZnodeValue)null);
51 }
52
53 /**
54 * simple field data trigger
55 * @param expect
56 */
57 public TestTrigger(long startTime, long timeout, String expect)
58 {
59 this(startTime, timeout, new ZnodeValue(expect));
60 }
61
62 /**
63 * list field data trigger
64 * @param expect
65 */
66 public TestTrigger(long startTime, long timeout, List<String> expect)
67 {
68 this(startTime, timeout, new ZnodeValue(expect));
69 }
70
71 /**
72 * map field data trigger
73 * @param expect
74 */
75 public TestTrigger(long startTime, long timeout, Map<String, String> expect)
76 {
77 this(startTime, timeout, new ZnodeValue(expect));
78 }
79
80 /**
81 * znode data trigger
82 * @param expect
83 */
84 public TestTrigger(long startTime, long timeout, ZNRecord expect)
85 {
86 this(startTime, timeout, new ZnodeValue(expect));
87 }
88
89 /**
90 *
91 * @param startTime
92 * @param timeout
93 * @param expect
94 */
95 public TestTrigger(long startTime, long timeout, ZnodeValue expect)
96 {
97 _startTime = startTime;
98 _timeout = timeout;
99 _expectValue = expect;
100 }
101
102 @Override
103 public String toString()
104 {
105 String ret = "<" + _startTime + "~" + _timeout + "ms, " + _expectValue + ">";
106 return ret;
107 }
108
109 // TODO temp test; remove it
110 /*
111 public static void main(String[] args)
112 {
113 TestTrigger trigger = new TestTrigger(0, 0, "simpleValue0");
114 System.out.println("trigger=" + trigger);
115
116 List<String> list = new ArrayList<String>();
117 list.add("listValue1");
118 list.add("listValue2");
119 trigger = new TestTrigger(0, 0, list);
120 System.out.println("trigger=" + trigger);
121
122 Map<String, String> map = new HashMap<String, String>();
123 map.put("mapKey3", "mapValue3");
124 map.put("mapKey4", "mapValue4");
125 trigger = new TestTrigger(0, 0, map);
126 System.out.println("trigger=" + trigger);
127
128 trigger = new TestTrigger();
129 System.out.println("trigger=" + trigger);
130 }
131 */
132 }