File tree Expand file tree Collapse file tree
main/java/org/elasticsearch/threadpool
test/java/org/elasticsearch/indices/settings Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -550,22 +550,39 @@ static class CachedTimeThread extends Thread {
550550 this .absoluteMillis = System .currentTimeMillis ();
551551 this .counter = new TimeCounter ();
552552 setDaemon (true );
553+ if (interval <= 0 ) {
554+ this .running = false ;
555+ }
553556 }
554557
555558 /**
556559 * Return the current time used for relative calculations. This is
557560 * {@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.
558565 */
559566 long relativeTimeInMillis () {
560- return relativeMillis ;
567+ if (running ) {
568+ return relativeMillis ;
569+ }
570+ return TimeValue .nsecToMSec (System .nanoTime ());
561571 }
562572
563573 /**
564574 * Return the current epoch time, used to find absolute time. This is
565575 * 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.
566580 */
567581 long absoluteTimeInMillis () {
568- return absoluteMillis ;
582+ if (running ) {
583+ return absoluteMillis ;
584+ }
585+ return System .currentTimeMillis ();
569586 }
570587
571588 @ Override
Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ public List<Setting<?>> getSettings() {
134134 @ Override
135135 protected Settings nodeSettings (int nodeOrdinal ) {
136136 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 )
138138 .build ();
139139 }
140140
You can’t perform that action at this time.
0 commit comments