Skip to content

Commit fe29303

Browse files
Use metrics counter group constants introduced in NUTCH-3132
1 parent c7cfa39 commit fe29303

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

src/java/org/apache/nutch/crawl/Generator.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,10 +1204,13 @@ public Path[] generate(Path dbDir, Path segments, int numLists, long topN,
12041204
}
12051205

12061206
LOG.info("Generator: number of items rejected during selection:");
1207-
for (Counter counter : job.getCounters().getGroup("Generator")) {
1208-
LOG.info("Generator: {} {}",
1209-
String.format(Locale.ROOT, "%6d", counter.getValue()),
1210-
counter.getName());
1207+
for (Counter counter : job.getCounters()
1208+
.getGroup(NutchMetrics.GROUP_GENERATOR)) {
1209+
long counterValue = counter.getValue();
1210+
if (counterValue > 0) {
1211+
LOG.info("Generator: {} {}",
1212+
String.format(Locale.ROOT, "%6d", counterValue), counter.getName());
1213+
}
12111214
}
12121215
if (!getConf().getBoolean(GENERATE_UPDATE_CRAWLDB, false)) {
12131216
/*

src/java/org/apache/nutch/indexer/IndexingJob.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
import org.apache.commons.lang3.time.StopWatch;
3232
import org.apache.nutch.metadata.Nutch;
33+
import org.apache.nutch.metrics.NutchMetrics;
3334
import org.apache.nutch.segment.SegmentChecker;
3435
import org.apache.hadoop.conf.Configuration;
3536
import org.apache.hadoop.fs.FileStatus;
@@ -155,10 +156,14 @@ public void index(Path crawlDb, Path linkDb, List<Path> segments,
155156
throw e;
156157
}
157158
LOG.info("Indexer: number of documents indexed, deleted, or skipped:");
158-
for (Counter counter : job.getCounters().getGroup("IndexerStatus")) {
159-
LOG.info("Indexer: {} {}",
160-
String.format(Locale.ROOT, "%6d", counter.getValue()),
161-
counter.getName());
159+
for (Counter counter : job.getCounters()
160+
.getGroup(NutchMetrics.GROUP_INDEXER)) {
161+
long counterValue = counter.getValue();
162+
if (counterValue > 0) {
163+
LOG.info("Indexer: {} {}",
164+
String.format(Locale.ROOT, "%6d", counterValue),
165+
counter.getName());
166+
}
162167
}
163168
stopWatch.stop();
164169
LOG.info("Indexer: finished, elapsed: {} ms", stopWatch.getTime(

0 commit comments

Comments
 (0)