111
111
import static org .apache .lucene .util .TestUtil .randomSimpleString ;
112
112
import static org .elasticsearch .action .bulk .BackoffPolicy .constantBackoff ;
113
113
import static org .elasticsearch .common .unit .TimeValue .timeValueMillis ;
114
- import static org .elasticsearch .common .unit .TimeValue .timeValueNanos ;
115
114
import static org .elasticsearch .common .unit .TimeValue .timeValueSeconds ;
116
115
import static org .hamcrest .Matchers .contains ;
117
116
import static org .hamcrest .Matchers .containsString ;
@@ -255,7 +254,7 @@ public void testScrollResponseSetsTotal() {
255
254
256
255
long total = randomIntBetween (0 , Integer .MAX_VALUE );
257
256
ScrollableHitSource .Response response = new ScrollableHitSource .Response (false , emptyList (), total , emptyList (), null );
258
- simulateScrollResponse (new DummyAsyncBulkByScrollAction (), timeValueSeconds ( 0 ) , 0 , response );
257
+ simulateScrollResponse (new DummyAsyncBulkByScrollAction (), 0 , 0 , response );
259
258
assertEquals (total , testTask .getStatus ().getTotal ());
260
259
}
261
260
@@ -268,7 +267,7 @@ public void testScrollResponseBatchingBehavior() throws Exception {
268
267
Hit hit = new ScrollableHitSource .BasicHit ("index" , "id" , 0 );
269
268
ScrollableHitSource .Response response = new ScrollableHitSource .Response (false , emptyList (), 1 , singletonList (hit ), null );
270
269
DummyAsyncBulkByScrollAction action = new DummyAsyncBulkByScrollAction ();
271
- simulateScrollResponse (action , timeValueNanos ( System .nanoTime () ), 0 , response );
270
+ simulateScrollResponse (action , System .nanoTime (), 0 , response );
272
271
273
272
// Use assert busy because the update happens on another thread
274
273
final int expectedBatches = batches ;
@@ -354,7 +353,7 @@ public ScheduledCancellable schedule(Runnable command, TimeValue delay, String n
354
353
}
355
354
});
356
355
ScrollableHitSource .Response response = new ScrollableHitSource .Response (false , emptyList (), 0 , emptyList (), null );
357
- simulateScrollResponse (new DummyAsyncBulkByScrollAction (), timeValueNanos ( System .nanoTime () ), 10 , response );
356
+ simulateScrollResponse (new DummyAsyncBulkByScrollAction (), System .nanoTime (), 10 , response );
358
357
ExecutionException e = expectThrows (ExecutionException .class , () -> listener .get ());
359
358
assertThat (e .getCause (), instanceOf (EsRejectedExecutionException .class ));
360
359
assertThat (e .getCause (), hasToString (containsString ("test" )));
@@ -372,7 +371,7 @@ public void testShardFailuresAbortRequest() throws Exception {
372
371
SearchFailure shardFailure = new SearchFailure (new RuntimeException ("test" ));
373
372
ScrollableHitSource .Response scrollResponse = new ScrollableHitSource .Response (false , singletonList (shardFailure ), 0 ,
374
373
emptyList (), null );
375
- simulateScrollResponse (new DummyAsyncBulkByScrollAction (), timeValueNanos ( System .nanoTime () ), 0 , scrollResponse );
374
+ simulateScrollResponse (new DummyAsyncBulkByScrollAction (), System .nanoTime (), 0 , scrollResponse );
376
375
BulkByScrollResponse response = listener .get ();
377
376
assertThat (response .getBulkFailures (), empty ());
378
377
assertThat (response .getSearchFailures (), contains (shardFailure ));
@@ -386,7 +385,7 @@ public void testShardFailuresAbortRequest() throws Exception {
386
385
*/
387
386
public void testSearchTimeoutsAbortRequest () throws Exception {
388
387
ScrollableHitSource .Response scrollResponse = new ScrollableHitSource .Response (true , emptyList (), 0 , emptyList (), null );
389
- simulateScrollResponse (new DummyAsyncBulkByScrollAction (), timeValueNanos ( System .nanoTime () ), 0 , scrollResponse );
388
+ simulateScrollResponse (new DummyAsyncBulkByScrollAction (), System .nanoTime (), 0 , scrollResponse );
390
389
BulkByScrollResponse response = listener .get ();
391
390
assertThat (response .getBulkFailures (), empty ());
392
391
assertThat (response .getSearchFailures (), empty ());
@@ -423,7 +422,7 @@ protected AbstractAsyncBulkByScrollAction.RequestWrapper<?> buildRequest(Hit doc
423
422
ScrollableHitSource .BasicHit hit = new ScrollableHitSource .BasicHit ("index" , "id" , 0 );
424
423
hit .setSource (new BytesArray ("{}" ), XContentType .JSON );
425
424
ScrollableHitSource .Response response = new ScrollableHitSource .Response (false , emptyList (), 1 , singletonList (hit ), null );
426
- simulateScrollResponse (action , timeValueNanos ( System .nanoTime () ), 0 , response );
425
+ simulateScrollResponse (action , System .nanoTime (), 0 , response );
427
426
ExecutionException e = expectThrows (ExecutionException .class , () -> listener .get ());
428
427
assertThat (e .getCause (), instanceOf (RuntimeException .class ));
429
428
assertThat (e .getCause ().getMessage (), equalTo ("surprise" ));
@@ -619,7 +618,7 @@ public void testCancelBeforeInitialSearch() throws Exception {
619
618
}
620
619
621
620
public void testCancelBeforeScrollResponse () throws Exception {
622
- cancelTaskCase ((DummyAsyncBulkByScrollAction action ) -> simulateScrollResponse (action , timeValueNanos ( System .nanoTime () ), 1 ,
621
+ cancelTaskCase ((DummyAsyncBulkByScrollAction action ) -> simulateScrollResponse (action , System .nanoTime (), 1 ,
623
622
new ScrollableHitSource .Response (false , emptyList (), between (1 , 100000 ), emptyList (), null )));
624
623
}
625
624
@@ -634,7 +633,7 @@ public void testCancelBeforeOnBulkResponse() throws Exception {
634
633
}
635
634
636
635
public void testCancelBeforeStartNextScroll () throws Exception {
637
- TimeValue now = timeValueNanos ( System .nanoTime () );
636
+ long now = System .nanoTime ();
638
637
cancelTaskCase ((DummyAsyncBulkByScrollAction action ) -> action .notifyDone (now , null , 0 ));
639
638
}
640
639
@@ -683,7 +682,7 @@ public ScheduledCancellable schedule(Runnable command, TimeValue delay, String n
683
682
ScrollableHitSource .Response response = new ScrollableHitSource .Response (false , emptyList (), total , emptyList (), null );
684
683
// Use a long delay here so the test will time out if the cancellation doesn't reschedule the throttled task
685
684
worker .rethrottle (1 );
686
- simulateScrollResponse (action , timeValueNanos ( System .nanoTime () ), 1000 , response );
685
+ simulateScrollResponse (action , System .nanoTime (), 1000 , response );
687
686
688
687
// Now that we've got our cancel we'll just verify that it all came through all right
689
688
assertEquals (reason , listener .get (10 , TimeUnit .SECONDS ).getReasonCancelled ());
@@ -712,7 +711,7 @@ private void cancelTaskCase(Consumer<DummyAsyncBulkByScrollAction> testMe) throw
712
711
/**
713
712
* Simulate a scroll response by setting the scroll id and firing the onScrollResponse method.
714
713
*/
715
- private void simulateScrollResponse (DummyAsyncBulkByScrollAction action , TimeValue lastBatchTime , int lastBatchSize ,
714
+ private void simulateScrollResponse (DummyAsyncBulkByScrollAction action , long lastBatchTime , int lastBatchSize ,
716
715
ScrollableHitSource .Response response ) {
717
716
action .setScroll (scrollId ());
718
717
action .onScrollResponse (lastBatchTime , lastBatchSize , new ScrollableHitSource .AsyncResponse () {
0 commit comments