22
22
*/
23
23
package org .opengrok .suggest ;
24
24
25
+ import org .apache .commons .lang3 .time .DurationFormatUtils ;
25
26
import org .apache .lucene .index .DirectoryReader ;
26
27
import org .apache .lucene .index .IndexReader ;
27
28
import org .apache .lucene .index .Term ;
@@ -148,6 +149,7 @@ public void init(final Collection<NamedIndexDir> luceneIndexes) {
148
149
}
149
150
150
151
synchronized (lock ) {
152
+ Instant start = Instant .now ();
151
153
logger .log (Level .INFO , "Initializing suggester" );
152
154
153
155
ExecutorService executor = Executors .newWorkStealingPool (rebuildParallelismLevel );
@@ -156,7 +158,7 @@ public void init(final Collection<NamedIndexDir> luceneIndexes) {
156
158
submitInitIfIndexExists (executor , indexDir );
157
159
}
158
160
159
- shutdownAndAwaitTermination (executor , "Suggester successfully initialized" );
161
+ shutdownAndAwaitTermination (executor , start , "Suggester successfully initialized" );
160
162
}
161
163
}
162
164
@@ -209,11 +211,13 @@ private boolean indexExists(final Path indexDir) throws IOException {
209
211
}
210
212
}
211
213
212
- private void shutdownAndAwaitTermination (final ExecutorService executorService , final String logMessageOnSuccess ) {
214
+ private void shutdownAndAwaitTermination (final ExecutorService executorService , Instant start , final String logMessageOnSuccess ) {
213
215
executorService .shutdown ();
214
216
try {
215
217
executorService .awaitTermination (awaitTerminationTime .toMillis (), TimeUnit .MILLISECONDS );
216
- logger .log (Level .INFO , logMessageOnSuccess );
218
+ logger .log (Level .INFO , "{0} (took {1})" , new Object []{logMessageOnSuccess ,
219
+ DurationFormatUtils .formatDurationWords (Duration .between (start , Instant .now ()).toMillis (),
220
+ true , true )});
217
221
} catch (InterruptedException e ) {
218
222
logger .log (Level .SEVERE , "Interrupted while building suggesters" , e );
219
223
Thread .currentThread ().interrupt ();
@@ -231,6 +235,7 @@ public void rebuild(final Collection<NamedIndexDir> indexDirs) {
231
235
}
232
236
233
237
synchronized (lock ) {
238
+ Instant start = Instant .now ();
234
239
logger .log (Level .INFO , "Rebuilding the following suggesters: {0}" , indexDirs );
235
240
236
241
ExecutorService executor = Executors .newWorkStealingPool (rebuildParallelismLevel );
@@ -244,7 +249,7 @@ public void rebuild(final Collection<NamedIndexDir> indexDirs) {
244
249
}
245
250
}
246
251
247
- shutdownAndAwaitTermination (executor , "Suggesters for " + indexDirs + " were successfully rebuilt" );
252
+ shutdownAndAwaitTermination (executor , start , "Suggesters for " + indexDirs + " were successfully rebuilt" );
248
253
}
249
254
}
250
255
0 commit comments