Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

NUTCH-1750 Improvement of Fetcher's reportStatus

Julien Nioche37bd8193c78a
diff --git a/CHANGES.txt b/CHANGES.txt
index 582f82fac..4adabf0d0 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,6 +2,8 @@ Nutch Change Log
Nutch Current Development
+* NUTCH-1750 Improvement of Fetcher's reportStatus (jnioche)
+
* NUTCH-1747 Use AtomicInteger as semaphore in Fetcher (jnioche)
* NUTCH-1735 code dedup fetcher queue redirects (snagel)
diff --git a/src/java/org/apache/nutch/fetcher/Fetcher.java b/src/java/org/apache/nutch/fetcher/Fetcher.java
index a4875e419..8bb4cb171 100644
--- a/src/java/org/apache/nutch/fetcher/Fetcher.java
+++ b/src/java/org/apache/nutch/fetcher/Fetcher.java
@@ -1110,20 +1110,21 @@ public class Fetcher extends Configured implements Tool,
private void reportStatus(int pagesLastSec, int bytesLastSec) throws IOException {
- String status;
- long elapsed = (System.currentTimeMillis() - start)/1000;
+ StringBuilder status = new StringBuilder();
+ Long elapsed = new Long((System.currentTimeMillis() - start)/1000);
- float avgPagesSec = Math.round(((float)pages.get()*10)/elapsed)/10;
- float avgBytesSec = Math.round(((((float)bytes.get())*8)/1000)/elapsed);
+ float avgPagesSec = (float) pages.get() / elapsed.floatValue();
+ long avgBytesSec = (bytes.get() /125l) / elapsed.longValue();
- status = activeThreads + " threads, " +
- fetchQueues.getQueueCount() + " queues, "+
- fetchQueues.getTotalSize() + " URLs queued, "+
- pages+" pages, "+errors+" errors, "
- + avgPagesSec + " (" + pagesLastSec + ") pages/s, "
- + avgBytesSec + " (" + bytesLastSec + ") kbits/s, ";
+ status.append(activeThreads).append(" threads, ");
+ status.append(fetchQueues.getQueueCount()).append(" queues, ");
+ status.append(fetchQueues.getTotalSize()).append(" URLs queued, ");
+ status.append(pages).append(" pages, ").append(errors).append(" errors, ");
+ status.append(String.format("%.2f", avgPagesSec)).append(" pages/s (");
+ status.append(pagesLastSec).append(" last sec), ");
+ status.append(avgBytesSec).append(" kbits/s (").append((bytesLastSec / 125)).append(" last sec)");
- reporter.setStatus(status);
+ reporter.setStatus(status.toString());
}
public void configure(JobConf job) {