@@ -88,7 +88,7 @@ public void tearDown() throws Exception {
8888 super .tearDown ();
8989 }
9090
91- TimedClusterApplierService createTimedClusterService (boolean makeMaster ) throws InterruptedException {
91+ TimedClusterApplierService createTimedClusterService (boolean makeMaster ) {
9292 DiscoveryNode localNode = new DiscoveryNode ("node1" , buildNewFakeTransportAddress (), emptyMap (),
9393 emptySet (), Version .CURRENT );
9494 TimedClusterApplierService timedClusterApplierService = new TimedClusterApplierService (Settings .builder ().put ("cluster.name" ,
@@ -141,9 +141,9 @@ public void testClusterStateUpdateLogging() throws Exception {
141141 Logger clusterLogger = LogManager .getLogger (ClusterApplierService .class );
142142 Loggers .addAppender (clusterLogger , mockAppender );
143143 try {
144- clusterApplierService .currentTimeOverride = System . nanoTime ();
144+ clusterApplierService .currentTimeOverride = threadPool . relativeTimeInMillis ();
145145 clusterApplierService .runOnApplierThread ("test1" ,
146- currentState -> clusterApplierService .currentTimeOverride += TimeValue .timeValueSeconds (1 ).nanos (),
146+ currentState -> clusterApplierService .currentTimeOverride += TimeValue .timeValueSeconds (1 ).millis (),
147147 new ClusterApplyListener () {
148148 @ Override
149149 public void onSuccess (String source ) { }
@@ -155,7 +155,7 @@ public void onFailure(String source, Exception e) {
155155 });
156156 clusterApplierService .runOnApplierThread ("test2" ,
157157 currentState -> {
158- clusterApplierService .currentTimeOverride += TimeValue .timeValueSeconds (2 ).nanos ();
158+ clusterApplierService .currentTimeOverride += TimeValue .timeValueSeconds (2 ).millis ();
159159 throw new IllegalArgumentException ("Testing handling of exceptions in the cluster state task" );
160160 },
161161 new ClusterApplyListener () {
@@ -214,9 +214,9 @@ public void testLongClusterStateUpdateLogging() throws Exception {
214214 try {
215215 final CountDownLatch latch = new CountDownLatch (4 );
216216 final CountDownLatch processedFirstTask = new CountDownLatch (1 );
217- clusterApplierService .currentTimeOverride = System . nanoTime ();
217+ clusterApplierService .currentTimeOverride = threadPool . relativeTimeInMillis ();
218218 clusterApplierService .runOnApplierThread ("test1" ,
219- currentState -> clusterApplierService .currentTimeOverride += TimeValue .timeValueSeconds (1 ).nanos (),
219+ currentState -> clusterApplierService .currentTimeOverride += TimeValue .timeValueSeconds (1 ).millis (),
220220 new ClusterApplyListener () {
221221 @ Override
222222 public void onSuccess (String source ) {
@@ -232,7 +232,7 @@ public void onFailure(String source, Exception e) {
232232 processedFirstTask .await ();
233233 clusterApplierService .runOnApplierThread ("test2" ,
234234 currentState -> {
235- clusterApplierService .currentTimeOverride += TimeValue .timeValueSeconds (32 ).nanos ();
235+ clusterApplierService .currentTimeOverride += TimeValue .timeValueSeconds (32 ).millis ();
236236 throw new IllegalArgumentException ("Testing handling of exceptions in the cluster state task" );
237237 },
238238 new ClusterApplyListener () {
@@ -247,7 +247,7 @@ public void onFailure(String source, Exception e) {
247247 }
248248 });
249249 clusterApplierService .runOnApplierThread ("test3" ,
250- currentState -> clusterApplierService .currentTimeOverride += TimeValue .timeValueSeconds (34 ).nanos (),
250+ currentState -> clusterApplierService .currentTimeOverride += TimeValue .timeValueSeconds (34 ).millis (),
251251 new ClusterApplyListener () {
252252 @ Override
253253 public void onSuccess (String source ) {
@@ -510,11 +510,11 @@ static class TimedClusterApplierService extends ClusterApplierService {
510510 }
511511
512512 @ Override
513- protected long currentTimeInNanos () {
513+ protected long currentTimeInMillis () {
514514 if (currentTimeOverride != null ) {
515515 return currentTimeOverride ;
516516 }
517- return super .currentTimeInNanos ();
517+ return super .currentTimeInMillis ();
518518 }
519519 }
520520}
0 commit comments