Skip to content

Commit 0fbbebc

Browse files
ahornaceVladimir Kotal
authored andcommitted
Log also duration it took to initialize specific suggesters
1 parent f5ff778 commit 0fbbebc

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

suggester/src/main/java/org/opengrok/suggest/FieldWFSTCollection.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,15 @@ public void unlock() {
455455
lock.readLock().unlock();
456456
}
457457

458+
@Override
459+
public String toString() {
460+
return "FieldWFSTCollection{" +
461+
"indexDir=" + indexDir +
462+
", suggesterDir=" + suggesterDir +
463+
", allowMostPopular=" + allowMostPopular +
464+
'}';
465+
}
466+
458467
/**
459468
* An {@link InputIterator} for WFST data structure with most popular completion support.
460469
*/

suggester/src/main/java/org/opengrok/suggest/Suggester.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import java.io.IOException;
3737
import java.nio.file.Path;
3838
import java.time.Duration;
39+
import java.time.Instant;
3940
import java.util.Collection;
4041
import java.util.Collections;
4142
import java.util.List;
@@ -143,6 +144,7 @@ private void submitInitIfIndexExists(final ExecutorService executorService, fina
143144
private Runnable getInitRunnable(final Path indexDir) {
144145
return () -> {
145146
try {
147+
Instant start = Instant.now();
146148
logger.log(Level.FINE, "Initializing {0}", indexDir);
147149

148150
FieldWFSTCollection wfst = new FieldWFSTCollection(FSDirectory.open(indexDir), getSuggesterDir(indexDir),
@@ -154,7 +156,8 @@ private Runnable getInitRunnable(final Path indexDir) {
154156
projectData.put(PROJECTS_DISABLED_KEY, wfst);
155157
}
156158

157-
logger.log(Level.FINE, "Finished initialization of {0}", indexDir);
159+
Duration d = Duration.between(start, Instant.now());
160+
logger.log(Level.FINE, "Finished initialization of {0}, took {1}", new Object[] {indexDir, d});
158161
} catch (Exception e) {
159162
logger.log(Level.SEVERE, "Could not initialize suggester data for " + indexDir, e);
160163
}
@@ -216,9 +219,12 @@ public void rebuild(final List<Path> indexDirs) {
216219
private Runnable getRebuildRunnable(final FieldWFSTCollection fieldsWFST) {
217220
return () -> {
218221
try {
222+
Instant start = Instant.now();
219223
logger.log(Level.FINE, "Rebuilding {0}", fieldsWFST);
220224
fieldsWFST.rebuild();
221-
logger.log(Level.FINE, "Rebuild of {0} finished", fieldsWFST);
225+
226+
Duration d = Duration.between(start, Instant.now());
227+
logger.log(Level.FINE, "Rebuild of {0} finished, took {1}", new Object[] {fieldsWFST, d});
222228
} catch (Exception e) {
223229
logger.log(Level.SEVERE, "Could not rebuild suggester", e);
224230
}

0 commit comments

Comments
 (0)