@@ -186,9 +186,7 @@ public void init(final Collection<NamedIndexDir> luceneIndexes) {
186
186
submitInitIfIndexExists (executor , indexDir );
187
187
}
188
188
189
- Duration duration = Duration .between (start , Instant .now ());
190
- suggesterInitTimer .record (duration );
191
- shutdownAndAwaitTermination (executor , duration , "Suggester successfully initialized" );
189
+ shutdownAndAwaitTermination (executor , start , "Suggester successfully initialized" );
192
190
initDone .countDown ();
193
191
}
194
192
}
@@ -252,10 +250,13 @@ private boolean indexExists(final Path indexDir) throws IOException {
252
250
}
253
251
}
254
252
255
- private void shutdownAndAwaitTermination (final ExecutorService executorService , Duration duration , final String logMessageOnSuccess ) {
253
+ private void shutdownAndAwaitTermination (final ExecutorService executorService , Instant start ,
254
+ final String logMessageOnSuccess ) {
256
255
executorService .shutdown ();
257
256
try {
258
257
executorService .awaitTermination (awaitTerminationTime .toMillis (), TimeUnit .MILLISECONDS );
258
+ Duration duration = Duration .between (start , Instant .now ());
259
+ suggesterInitTimer .record (duration );
259
260
logger .log (Level .INFO , "{0} (took {1})" , new Object []{logMessageOnSuccess ,
260
261
DurationFormatUtils .formatDurationWords (duration .toMillis (),
261
262
true , true )});
@@ -295,9 +296,8 @@ public void rebuild(final Collection<NamedIndexDir> indexDirs) {
295
296
}
296
297
}
297
298
298
- Duration duration = Duration .between (start , Instant .now ());
299
- suggesterRebuildTimer .record (duration );
300
- shutdownAndAwaitTermination (executor , duration , "Suggesters for " + indexDirs + " were successfully rebuilt" );
299
+ shutdownAndAwaitTermination (executor , start ,
300
+ "Suggesters for " + indexDirs + " were successfully rebuilt" );
301
301
}
302
302
303
303
rebuildLock .lock ();
0 commit comments