File tree 2 files changed +20
-3
lines changed
main/java/org/elasticsearch/threadpool
test/java/org/elasticsearch/indices/settings 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -550,22 +550,39 @@ static class CachedTimeThread extends Thread {
550
550
this .absoluteMillis = System .currentTimeMillis ();
551
551
this .counter = new TimeCounter ();
552
552
setDaemon (true );
553
+ if (interval <= 0 ) {
554
+ this .running = false ;
555
+ }
553
556
}
554
557
555
558
/**
556
559
* Return the current time used for relative calculations. This is
557
560
* {@link System#nanoTime()} truncated to milliseconds.
561
+ * <p>
562
+ * If {@link ThreadPool#ESTIMATED_TIME_INTERVAL_SETTING} is set to 0
563
+ * then the cache is disabled and the method calls {@link System#nanoTime()}
564
+ * whenever called. Typically used for testing.
558
565
*/
559
566
long relativeTimeInMillis () {
560
- return relativeMillis ;
567
+ if (running ) {
568
+ return relativeMillis ;
569
+ }
570
+ return TimeValue .nsecToMSec (System .nanoTime ());
561
571
}
562
572
563
573
/**
564
574
* Return the current epoch time, used to find absolute time. This is
565
575
* a cached version of {@link System#currentTimeMillis()}.
576
+ * <p>
577
+ * If {@link ThreadPool#ESTIMATED_TIME_INTERVAL_SETTING} is set to 0
578
+ * then the cache is disabled and the method calls {@link System#currentTimeMillis()}
579
+ * whenever called. Typically used for testing.
566
580
*/
567
581
long absoluteTimeInMillis () {
568
- return absoluteMillis ;
582
+ if (running ) {
583
+ return absoluteMillis ;
584
+ }
585
+ return System .currentTimeMillis ();
569
586
}
570
587
571
588
@ Override
Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ public List<Setting<?>> getSettings() {
134
134
@ Override
135
135
protected Settings nodeSettings (int nodeOrdinal ) {
136
136
return Settings .builder ().put (super .nodeSettings (nodeOrdinal ))
137
- .put ("thread_pool.estimated_time_interval" , TimeValue . timeValueMillis ( 1 ) )
137
+ .put ("thread_pool.estimated_time_interval" , 0 )
138
138
.build ();
139
139
}
140
140
You can’t perform that action at this time.
0 commit comments