Author: lewismc
Date: Mon Sep 29 01:19:48 2014
New Revision: 1628112

URL: http://svn.apache.org/r1628112
Log:
NUTCH-1848 Bug in DashboardPage.html instances counter

Modified:
    nutch/branches/2.x/CHANGES.txt
    
nutch/branches/2.x/src/java/org/apache/nutch/api/model/response/NutchStatus.java

Modified: nutch/branches/2.x/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/nutch/branches/2.x/CHANGES.txt?rev=1628112&r1=1628111&r2=1628112&view=diff
==============================================================================
--- nutch/branches/2.x/CHANGES.txt (original)
+++ nutch/branches/2.x/CHANGES.txt Mon Sep 29 01:19:48 2014
@@ -2,6 +2,8 @@ Nutch Change Log
 
 Current Development
 
+* NUTCH-1848 Bug in DashboardPage.html instances counter (Nima Falaki via 
lewismc)
+
 * NUTCH-841 Create a Wicket-based Web Application for Nutch (Fjodor Vershinin 
via lewismc)
 
 * NUTCH-1832 Make Nutch work without an indexer (mattmann via lewismc)

Modified: 
nutch/branches/2.x/src/java/org/apache/nutch/api/model/response/NutchStatus.java
URL: 
http://svn.apache.org/viewvc/nutch/branches/2.x/src/java/org/apache/nutch/api/model/response/NutchStatus.java?rev=1628112&r1=1628111&r2=1628112&view=diff
==============================================================================
--- 
nutch/branches/2.x/src/java/org/apache/nutch/api/model/response/NutchStatus.java
 (original)
+++ 
nutch/branches/2.x/src/java/org/apache/nutch/api/model/response/NutchStatus.java
 Mon Sep 29 01:19:48 2014
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *     http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,10 +18,13 @@ package org.apache.nutch.api.model.respo
 
 import java.util.Collection;
 import java.util.Date;
+import java.util.Iterator;
 import java.util.Set;
 
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.nutch.api.model.response.JobInfo.State;
+
 public class NutchStatus {
-  
   private Date startDate;
   private Set<String> configuration;
   private Collection<JobInfo> jobs;
@@ -51,11 +54,32 @@ public class NutchStatus {
     this.jobs = jobs;
   }
 
-  public Collection<JobInfo> getRunningJobs() {
-    return runningJobs;
+  public Collection<JobInfo> getRunningJobs()
+  {
+    return purgeFinishedFailedJobs(runningJobs);
   }
 
+
   public void setRunningJobs(Collection<JobInfo> runningJobs) {
     this.runningJobs = runningJobs;
   }
+
+  private Collection<JobInfo> purgeFinishedFailedJobs(Collection<JobInfo> 
runningJobColl)
+  {
+    if (CollectionUtils.isNotEmpty(runningJobColl)) {
+      Iterator<JobInfo> runningJobsIterator = runningJobColl.iterator();
+      while (runningJobsIterator.hasNext()) {
+        JobInfo jobInfo = runningJobsIterator.next();
+
+        if (jobInfo.getState().equals(State.FINISHED)) {
+          runningJobsIterator.remove();
+        }
+        else if (jobInfo.getState().equals(State.FAILED)) {
+          runningJobsIterator.remove();
+        }
+
+      }
+    }
+    return runningJobColl;
+  }
 }


Reply via email to