Skip to content

Commit 7be51e6

Browse files
committed
change addFile() duration reporting to use listener
1 parent ee6de1f commit 7be51e6

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/index/DefaultIndexChangedListener.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424
package org.opengrok.indexer.index;
2525

2626
import org.opengrok.indexer.logger.LoggerFactory;
27+
import org.opengrok.indexer.util.Statistics;
2728

29+
import java.util.Map;
30+
import java.util.concurrent.ConcurrentHashMap;
2831
import java.util.logging.Level;
2932
import java.util.logging.Logger;
3033

@@ -39,11 +42,16 @@ public class DefaultIndexChangedListener implements IndexChangedListener {
3942

4043
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultIndexChangedListener.class);
4144

45+
private final Map<String, Statistics> statMap = new ConcurrentHashMap<>();
46+
4247
@Override
4348
public void fileAdd(String path, String analyzer) {
4449
if (LOGGER.isLoggable(Level.FINE)) {
4550
LOGGER.log(Level.FINE, "Add: ''{0}'' ({1})", new Object[]{path, analyzer});
4651
}
52+
if (LOGGER.isLoggable(Level.FINEST)) {
53+
statMap.put(path, new Statistics());
54+
}
4755
}
4856

4957
@Override
@@ -53,6 +61,16 @@ public void fileRemove(String path) {
5361

5462
@Override
5563
public void fileAdded(String path, String analyzer) {
64+
if (LOGGER.isLoggable(Level.FINEST)) {
65+
Statistics stat = statMap.get(path);
66+
if (stat != null) {
67+
stat.report(LOGGER, Level.FINEST, String.format("Added: '%s' (%s)", path, analyzer),
68+
"indexer.file.add.latency");
69+
statMap.remove(path, stat);
70+
return;
71+
}
72+
}
73+
5674
if (LOGGER.isLoggable(Level.FINER)) {
5775
LOGGER.log(Level.FINER, "Added: ''{0}'' ({1})", new Object[]{path, analyzer});
5876
}

opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexDatabase.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,7 +1772,6 @@ private void indexParallel(String dir, IndexDownArgs args) {
17721772
int tries = 0;
17731773
Ctags pctags = null;
17741774
boolean ret;
1775-
Statistics stats = new Statistics();
17761775
while (true) {
17771776
try {
17781777
if (alreadyClosedCounter.get() > 0) {
@@ -1810,8 +1809,6 @@ private void indexParallel(String dir, IndexDownArgs args) {
18101809
}
18111810

18121811
progress.increment();
1813-
stats.report(LOGGER, Level.FINEST,
1814-
String.format("file '%s' %s", x.file, ret ? "indexed" : "failed indexing"));
18151812
return ret;
18161813
}
18171814
}))).get();

0 commit comments

Comments
 (0)