You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nutch.apache.org by jn...@apache.org on 2010/07/30 14:19:52 UTC

svn commit: r980748 - in /nutch/branches/nutchbase/src/java/org/apache/nutch: fetcher/FetcherReducer.java storage/ProtocolStatusUtils.java

Author: jnioche
Date: Fri Jul 30 12:19:52 2010
New Revision: 980748

URL: http://svn.apache.org/viewvc?rev=980748&view=rev
Log:
Fetcher displays protocol status names in counters instead of their code

Modified:
    nutch/branches/nutchbase/src/java/org/apache/nutch/fetcher/FetcherReducer.java
    nutch/branches/nutchbase/src/java/org/apache/nutch/storage/ProtocolStatusUtils.java

Modified: nutch/branches/nutchbase/src/java/org/apache/nutch/fetcher/FetcherReducer.java
URL: http://svn.apache.org/viewvc/nutch/branches/nutchbase/src/java/org/apache/nutch/fetcher/FetcherReducer.java?rev=980748&r1=980747&r2=980748&view=diff
==============================================================================
--- nutch/branches/nutchbase/src/java/org/apache/nutch/fetcher/FetcherReducer.java (original)
+++ nutch/branches/nutchbase/src/java/org/apache/nutch/fetcher/FetcherReducer.java Fri Jul 30 12:19:52 2010
@@ -455,7 +455,7 @@ extends GoraReducer<IntWritable, FetchEn
               // unblock queue
               fetchQueues.finishFetchItem(fit);
 
-              context.getCounter("FetcherStatus", "code_"+status.getCode()).increment(1);
+              context.getCounter("FetcherStatus", ProtocolStatusUtils.getName(status.getCode())).increment(1);
 
               int length = 0;
               if (content!=null && content.getContent()!=null) length= content.getContent().length;

Modified: nutch/branches/nutchbase/src/java/org/apache/nutch/storage/ProtocolStatusUtils.java
URL: http://svn.apache.org/viewvc/nutch/branches/nutchbase/src/java/org/apache/nutch/storage/ProtocolStatusUtils.java?rev=980748&r1=980747&r2=980748&view=diff
==============================================================================
--- nutch/branches/nutchbase/src/java/org/apache/nutch/storage/ProtocolStatusUtils.java (original)
+++ nutch/branches/nutchbase/src/java/org/apache/nutch/storage/ProtocolStatusUtils.java Fri Jul 30 12:19:52 2010
@@ -22,6 +22,42 @@ public class ProtocolStatusUtils impleme
   public static final ProtocolStatus STATUS_WOULDBLOCK = makeStatus(WOULDBLOCK);
   public static final ProtocolStatus STATUS_BLOCKED = makeStatus(BLOCKED);
 
+  public static String getName(int code) {
+    if (code == SUCCESS)
+      return "SUCCESS";
+    else if (code == FAILED)
+      return "FAILED";
+    else if (code == PROTO_NOT_FOUND)
+      return "PROTO_NOT_FOUND";
+    else if (code == GONE)
+      return "GONE";
+    else if (code == MOVED)
+      return "MOVED";
+    else if (code == TEMP_MOVED)
+      return "TEMP_MOVED";
+    else if (code == NOTFOUND)
+      return "NOTFOUND";
+    else if (code == RETRY)
+      return "RETRY";
+    else if (code == EXCEPTION)
+      return "EXCEPTION";
+    else if (code == ACCESS_DENIED)
+      return "ACCESS_DENIED";
+    else if (code == ROBOTS_DENIED)
+      return "ROBOTS_DENIED";
+    else if (code == REDIR_EXCEEDED)
+      return "REDIR_EXCEEDED";
+    else if (code == NOTFETCHING)
+      return "NOTFETCHING";
+    else if (code == NOTMODIFIED)
+      return "NOTMODIFIED";
+    else if (code == WOULDBLOCK)
+      return "WOULDBLOCK";
+    else if (code == BLOCKED)
+      return "BLOCKED";
+    return "UNKNOWN_CODE_" + code;
+  }
+
   public static ProtocolStatus makeStatus(int code) {
     ProtocolStatus pstatus = new ProtocolStatus();
     pstatus.setCode(code);
@@ -47,4 +83,3 @@ public class ProtocolStatusUtils impleme
     return TableUtil.toString(args.iterator().next());
   }
 }
-