You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nutch.apache.org by le...@apache.org on 2016/08/23 15:50:25 UTC
[1/2] nutch git commit: NUTCH-2306 Id of Active Configuration Could
Be Stored at NutchStatus and Exposed via REST API
Repository: nutch
Updated Branches:
refs/heads/2.x 6227f3b17 -> 5012c742c
NUTCH-2306 Id of Active Configuration Could Be Stored at NutchStatus and Exposed via REST API
Project: http://git-wip-us.apache.org/repos/asf/nutch/repo
Commit: http://git-wip-us.apache.org/repos/asf/nutch/commit/ed96b104
Tree: http://git-wip-us.apache.org/repos/asf/nutch/tree/ed96b104
Diff: http://git-wip-us.apache.org/repos/asf/nutch/diff/ed96b104
Branch: refs/heads/2.x
Commit: ed96b104ddf82bcb20557a29b251c3fd73eb146a
Parents: 22683a1
Author: Furkan KAMACI <fu...@gmail.com>
Authored: Tue Aug 23 12:55:54 2016 +0300
Committer: Furkan KAMACI <fu...@gmail.com>
Committed: Tue Aug 23 12:55:54 2016 +0300
----------------------------------------------------------------------
.../nutch/api/model/response/NutchStatus.java | 65 ++++++++++++++++++++
.../nutch/api/resources/AbstractResource.java | 14 +++++
.../nutch/api/resources/AdminResource.java | 1 +
3 files changed, 80 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/nutch/blob/ed96b104/src/java/org/apache/nutch/api/model/response/NutchStatus.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/nutch/api/model/response/NutchStatus.java b/src/java/org/apache/nutch/api/model/response/NutchStatus.java
index 3674447..95aac20 100644
--- a/src/java/org/apache/nutch/api/model/response/NutchStatus.java
+++ b/src/java/org/apache/nutch/api/model/response/NutchStatus.java
@@ -24,44 +24,109 @@ import java.util.Set;
import org.apache.commons.collections.CollectionUtils;
import org.apache.nutch.api.model.response.JobInfo.State;
+/**
+ * Information object for status of {@link org.apache.nutch.api.NutchServer}.
+ * Gives information about when server is started, its configurations, jobs, running jobs
+ * and active configuration id.
+ *
+ * @see org.apache.nutch.api.NutchServer
+ */
public class NutchStatus {
private Date startDate;
private Set<String> configuration;
private Collection<JobInfo> jobs;
private Collection<JobInfo> runningJobs;
+ private String activeConfId;
+ /**
+ * Gets start date of the {@link org.apache.nutch.api.NutchServer}
+ *
+ * @return start date of the server
+ */
public Date getStartDate() {
return startDate;
}
+ /**
+ * Sets start date of the {@link org.apache.nutch.api.NutchServer}
+ *
+ * @param startDate start date
+ */
public void setStartDate(Date startDate) {
this.startDate = startDate;
}
+ /**
+ * Gets configuration ids
+ *
+ * @return configuration ids
+ */
public Set<String> getConfiguration() {
return configuration;
}
+ /**
+ * Sets configuration ids
+ *
+ * @param configuration configuration ids
+ */
public void setConfiguration(Set<String> configuration) {
this.configuration = configuration;
}
+ /**
+ * Gets jobs
+ *
+ * @return jobs
+ */
public Collection<JobInfo> getJobs() {
return jobs;
}
+ /**
+ * Sets jobs
+ * @param jobs jobs
+ */
public void setJobs(Collection<JobInfo> jobs) {
this.jobs = jobs;
}
+ /**
+ * Gets running jobs
+ *
+ * @return running jobs
+ */
public Collection<JobInfo> getRunningJobs() {
return purgeFinishedFailedJobs(runningJobs);
}
+ /**
+ * Sets running jobs
+ *
+ * @param runningJobs running jobs
+ */
public void setRunningJobs(Collection<JobInfo> runningJobs) {
this.runningJobs = runningJobs;
}
+ /**
+ * Gets active configuration id
+ *
+ * @return active configuration id
+ */
+ public String getActiveConfId() {
+ return activeConfId;
+ }
+
+ /**
+ * Sets active configuration id
+ *
+ * @param activeConfId active configuration id
+ */
+ public void setActiveConfId(String activeConfId) {
+ this.activeConfId = activeConfId;
+ }
+
private Collection<JobInfo> purgeFinishedFailedJobs(
Collection<JobInfo> runningJobColl) {
if (CollectionUtils.isNotEmpty(runningJobColl)) {
http://git-wip-us.apache.org/repos/asf/nutch/blob/ed96b104/src/java/org/apache/nutch/api/resources/AbstractResource.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/nutch/api/resources/AbstractResource.java b/src/java/org/apache/nutch/api/resources/AbstractResource.java
index 9e6811e..dfea2dd 100644
--- a/src/java/org/apache/nutch/api/resources/AbstractResource.java
+++ b/src/java/org/apache/nutch/api/resources/AbstractResource.java
@@ -27,20 +27,34 @@ import org.apache.nutch.api.JobManager;
import org.apache.nutch.api.NutchServer;
import org.restlet.Context;
+/**
+ * Abstract base class for {@link NutchServer} REST APIs.
+ */
@Produces({ MediaType.APPLICATION_JSON })
public abstract class AbstractResource {
protected ConfManager configManager;
protected JobManager jobManager;
+ protected String activeConfId;
protected NutchServer server;
+ /**
+ * Constructor method for {@link AbstractResource}
+ * Retrieves {@link org.apache.nutch.api.NutchServer} information from {@link org.restlet.Context}
+ */
public AbstractResource() {
server = (NutchServer) Context.getCurrent().getAttributes()
.get(NutchServer.NUTCH_SERVER);
configManager = server.getConfMgr();
jobManager = server.getJobMgr();
+ activeConfId = server.getActiveConfId();
}
+ /**
+ * Throws HTTP 400 Bad Request Exception with given message
+ *
+ * @param message message to be placed at exception
+ */
protected void throwBadRequestException(String message) {
throw new WebApplicationException(Response.status(Status.BAD_REQUEST)
.entity(message).build());
http://git-wip-us.apache.org/repos/asf/nutch/blob/ed96b104/src/java/org/apache/nutch/api/resources/AdminResource.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/nutch/api/resources/AdminResource.java b/src/java/org/apache/nutch/api/resources/AdminResource.java
index 58d08b4..cfbf8d5 100644
--- a/src/java/org/apache/nutch/api/resources/AdminResource.java
+++ b/src/java/org/apache/nutch/api/resources/AdminResource.java
@@ -56,6 +56,7 @@ public class AdminResource extends AbstractResource {
status.setConfiguration(configManager.list());
status.setJobs(jobManager.list(null, State.ANY));
status.setRunningJobs(jobManager.list(null, State.RUNNING));
+ status.setActiveConfId(activeConfId);
return status;
}
[2/2] nutch git commit: Merge branch 'NUTCH-2306' of
https://github.com/kamaci/nutch into 2.x
Posted by le...@apache.org.
Merge branch 'NUTCH-2306' of https://github.com/kamaci/nutch into 2.x
Project: http://git-wip-us.apache.org/repos/asf/nutch/repo
Commit: http://git-wip-us.apache.org/repos/asf/nutch/commit/5012c742
Tree: http://git-wip-us.apache.org/repos/asf/nutch/tree/5012c742
Diff: http://git-wip-us.apache.org/repos/asf/nutch/diff/5012c742
Branch: refs/heads/2.x
Commit: 5012c742c0621897c28a50dbf1ba795f0af4d968
Parents: 6227f3b ed96b10
Author: Lewis John McGibbney <le...@gmail.com>
Authored: Tue Aug 23 08:57:46 2016 -0700
Committer: Lewis John McGibbney <le...@gmail.com>
Committed: Tue Aug 23 08:57:46 2016 -0700
----------------------------------------------------------------------
.../nutch/api/model/response/NutchStatus.java | 65 ++++++++++++++++++++
.../nutch/api/resources/AbstractResource.java | 14 +++++
.../nutch/api/resources/AdminResource.java | 1 +
3 files changed, 80 insertions(+)
----------------------------------------------------------------------