46
46
@ ClusterScope (scope = Scope .TEST , numDataNodes = 0 )
47
47
public class ClusterServiceIT extends ESIntegTestCase {
48
48
49
+ private static final TimeValue TEN_SECONDS = TimeValue .timeValueSeconds (10L );
50
+
49
51
public void testAckedUpdateTask () throws Exception {
50
52
internalCluster ().startNode ();
51
53
ClusterService clusterService = internalCluster ().getInstance (ClusterService .class );
@@ -56,7 +58,8 @@ public void testAckedUpdateTask() throws Exception {
56
58
final AtomicBoolean executed = new AtomicBoolean (false );
57
59
final CountDownLatch latch = new CountDownLatch (1 );
58
60
final CountDownLatch processedLatch = new CountDownLatch (1 );
59
- clusterService .submitStateUpdateTask ("test" , new AckedClusterStateUpdateTask <Void >(null , null ) {
61
+ clusterService .submitStateUpdateTask ("test" ,
62
+ new AckedClusterStateUpdateTask <Void >(MasterServiceTests .ackedRequest (TEN_SECONDS , TEN_SECONDS ), null ) {
60
63
@ Override
61
64
protected Void newResponse (boolean acknowledged ) {
62
65
return null ;
@@ -79,16 +82,6 @@ public void onAckTimeout() {
79
82
latch .countDown ();
80
83
}
81
84
82
- @ Override
83
- public TimeValue ackTimeout () {
84
- return TimeValue .timeValueSeconds (10 );
85
- }
86
-
87
- @ Override
88
- public TimeValue timeout () {
89
- return TimeValue .timeValueSeconds (10 );
90
- }
91
-
92
85
@ Override
93
86
public void clusterStateProcessed (String source , ClusterState oldState , ClusterState newState ) {
94
87
processedLatch .countDown ();
@@ -129,7 +122,8 @@ public void testAckedUpdateTaskSameClusterState() throws Exception {
129
122
final AtomicBoolean executed = new AtomicBoolean (false );
130
123
final CountDownLatch latch = new CountDownLatch (1 );
131
124
final CountDownLatch processedLatch = new CountDownLatch (1 );
132
- clusterService .submitStateUpdateTask ("test" , new AckedClusterStateUpdateTask <Void >(null , null ) {
125
+ clusterService .submitStateUpdateTask ("test" ,
126
+ new AckedClusterStateUpdateTask <Void >(MasterServiceTests .ackedRequest (TEN_SECONDS , TEN_SECONDS ), null ) {
133
127
@ Override
134
128
protected Void newResponse (boolean acknowledged ) {
135
129
return null ;
@@ -147,16 +141,6 @@ public void onAckTimeout() {
147
141
latch .countDown ();
148
142
}
149
143
150
- @ Override
151
- public TimeValue ackTimeout () {
152
- return TimeValue .timeValueSeconds (10 );
153
- }
154
-
155
- @ Override
156
- public TimeValue timeout () {
157
- return TimeValue .timeValueSeconds (10 );
158
- }
159
-
160
144
@ Override
161
145
public void clusterStateProcessed (String source , ClusterState oldState , ClusterState newState ) {
162
146
processedLatch .countDown ();
@@ -196,7 +180,9 @@ public void testAckedUpdateTaskNoAckExpected() throws Exception {
196
180
final AtomicBoolean onFailure = new AtomicBoolean (false );
197
181
final AtomicBoolean executed = new AtomicBoolean (false );
198
182
final CountDownLatch latch = new CountDownLatch (1 );
199
- clusterService .submitStateUpdateTask ("test" , new AckedClusterStateUpdateTask <Void >(null , null ) {
183
+
184
+ clusterService .submitStateUpdateTask (
185
+ "test" , new AckedClusterStateUpdateTask <Void >(MasterServiceTests .ackedRequest (TEN_SECONDS , TEN_SECONDS ), null ) {
200
186
@ Override
201
187
protected Void newResponse (boolean acknowledged ) {
202
188
return null ;
@@ -219,16 +205,6 @@ public void onAckTimeout() {
219
205
latch .countDown ();
220
206
}
221
207
222
- @ Override
223
- public TimeValue ackTimeout () {
224
- return TimeValue .timeValueSeconds (10 );
225
- }
226
-
227
- @ Override
228
- public TimeValue timeout () {
229
- return TimeValue .timeValueSeconds (10 );
230
- }
231
-
232
208
@ Override
233
209
public void clusterStateProcessed (String source , ClusterState oldState , ClusterState newState ) {
234
210
}
@@ -266,7 +242,8 @@ public void testAckedUpdateTaskTimeoutZero() throws Exception {
266
242
final AtomicBoolean executed = new AtomicBoolean (false );
267
243
final CountDownLatch latch = new CountDownLatch (1 );
268
244
final CountDownLatch processedLatch = new CountDownLatch (1 );
269
- clusterService .submitStateUpdateTask ("test" , new AckedClusterStateUpdateTask <Void >(null , null ) {
245
+ clusterService .submitStateUpdateTask ("test" ,
246
+ new AckedClusterStateUpdateTask <Void >(MasterServiceTests .ackedRequest (TimeValue .ZERO , TEN_SECONDS ), null ) {
270
247
@ Override
271
248
protected Void newResponse (boolean acknowledged ) {
272
249
return null ;
@@ -289,16 +266,6 @@ public void onAckTimeout() {
289
266
latch .countDown ();
290
267
}
291
268
292
- @ Override
293
- public TimeValue ackTimeout () {
294
- return TimeValue .timeValueSeconds (0 );
295
- }
296
-
297
- @ Override
298
- public TimeValue timeout () {
299
- return TimeValue .timeValueSeconds (10 );
300
- }
301
-
302
269
@ Override
303
270
public void clusterStateProcessed (String source , ClusterState oldState , ClusterState newState ) {
304
271
processedLatch .countDown ();
0 commit comments