You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sqoop.apache.org by ab...@apache.org on 2015/01/24 02:11:10 UTC
sqoop git commit: SQOOP-2029: Sqoop2: Get jobs by connector
Repository: sqoop
Updated Branches:
refs/heads/sqoop2 21a44fc15 -> 5ade862b1
SQOOP-2029: Sqoop2: Get jobs by connector
(Veena Basavaraj via Abraham Elmahrek)
Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/5ade862b
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/5ade862b
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/5ade862b
Branch: refs/heads/sqoop2
Commit: 5ade862b10651ac2077691687f7375ecd75f1ec9
Parents: 21a44fc
Author: Abraham Elmahrek <ab...@apache.org>
Authored: Fri Jan 23 16:51:04 2015 -0800
Committer: Abraham Elmahrek <ab...@apache.org>
Committed: Fri Jan 23 17:10:54 2015 -0800
----------------------------------------------------------------------
.../java/org/apache/sqoop/client/SqoopClient.java | 9 +++++++++
.../sqoop/client/request/JobResourceRequest.java | 10 ++++++++++
.../client/request/SqoopResourceRequests.java | 4 ++++
.../main/java/org/apache/sqoop/model/Config.java | 2 +-
.../org/apache/sqoop/server/v1/JobServlet.java | 2 +-
.../org/apache/sqoop/shell/ShowJobFunction.java | 18 ++++++++++++++----
.../org/apache/sqoop/shell/core/Constants.java | 2 ++
.../src/main/resources/shell-resource.properties | 3 ++-
8 files changed, 43 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/sqoop/blob/5ade862b/client/src/main/java/org/apache/sqoop/client/SqoopClient.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/SqoopClient.java b/client/src/main/java/org/apache/sqoop/client/SqoopClient.java
index 6efa016..612f97b 100644
--- a/client/src/main/java/org/apache/sqoop/client/SqoopClient.java
+++ b/client/src/main/java/org/apache/sqoop/client/SqoopClient.java
@@ -401,6 +401,15 @@ public class SqoopClient {
}
/**
+ * Retrieve list of all jobs by connector
+ *
+ * @return
+ */
+ public List<MJob> getJobsByConnector(long cId) {
+ return resourceRequests.readJobsByConnector(cId).getJobs();
+ }
+
+ /**
* Create job on server and save to the repository
*
* @param job Job that should be created
http://git-wip-us.apache.org/repos/asf/sqoop/blob/5ade862b/client/src/main/java/org/apache/sqoop/client/request/JobResourceRequest.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/request/JobResourceRequest.java b/client/src/main/java/org/apache/sqoop/client/request/JobResourceRequest.java
index c95686d..ee0f3f0 100644
--- a/client/src/main/java/org/apache/sqoop/client/request/JobResourceRequest.java
+++ b/client/src/main/java/org/apache/sqoop/client/request/JobResourceRequest.java
@@ -48,6 +48,16 @@ public class JobResourceRequest extends ResourceRequest {
super(token);
}
+ public JobBean readByConnector(String serverUrl, Long cId) {
+ JobsBean bean = new JobsBean();
+ if (cId != null) {
+ String response = super.get(serverUrl + RESOURCE + "?cname=" + cId);
+ JSONObject jsonObject = JSONUtils.parse(response);
+ bean.restore(jsonObject);
+ }
+ return bean;
+ }
+
public JobBean read(String serverUrl, Long jobId) {
String response;
if (jobId == null) {
http://git-wip-us.apache.org/repos/asf/sqoop/blob/5ade862b/client/src/main/java/org/apache/sqoop/client/request/SqoopResourceRequests.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/request/SqoopResourceRequests.java b/client/src/main/java/org/apache/sqoop/client/request/SqoopResourceRequests.java
index a74a56d..adb2c47 100644
--- a/client/src/main/java/org/apache/sqoop/client/request/SqoopResourceRequests.java
+++ b/client/src/main/java/org/apache/sqoop/client/request/SqoopResourceRequests.java
@@ -126,6 +126,10 @@ public class SqoopResourceRequests {
return getJobResourceRequest().read(serverUrl, jobId);
}
+ public JobBean readJobsByConnector(Long cId) {
+ return getJobResourceRequest().readByConnector(serverUrl, cId);
+ }
+
public ValidationResultBean updateJob(MJob job) {
return getJobResourceRequest().update(serverUrl, job);
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/5ade862b/common/src/main/java/org/apache/sqoop/model/Config.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/Config.java b/common/src/main/java/org/apache/sqoop/model/Config.java
index 644cffe..7e8cce9 100644
--- a/common/src/main/java/org/apache/sqoop/model/Config.java
+++ b/common/src/main/java/org/apache/sqoop/model/Config.java
@@ -31,7 +31,7 @@ import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface Config {
/**
- * Optional name for the form object
+ * Optional name for the config object
*
* @return
*/
http://git-wip-us.apache.org/repos/asf/sqoop/blob/5ade862b/server/src/main/java/org/apache/sqoop/server/v1/JobServlet.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/server/v1/JobServlet.java b/server/src/main/java/org/apache/sqoop/server/v1/JobServlet.java
index 0d15d0a..280b479 100644
--- a/server/src/main/java/org/apache/sqoop/server/v1/JobServlet.java
+++ b/server/src/main/java/org/apache/sqoop/server/v1/JobServlet.java
@@ -43,7 +43,7 @@ import org.apache.sqoop.server.SqoopProtocolServlet;
*
* PUT /v1/job/{jid}/enable
* Enable job with id jid
- * PUT /v1/job/{jname}s/disable
+ * PUT /v1/job/{jname}/disable
* Enable job with name jname
*
* PUT /v1/job/{jid}/disable
http://git-wip-us.apache.org/repos/asf/sqoop/blob/5ade862b/shell/src/main/java/org/apache/sqoop/shell/ShowJobFunction.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/ShowJobFunction.java b/shell/src/main/java/org/apache/sqoop/shell/ShowJobFunction.java
index 98363fa..ba8fcf3 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/ShowJobFunction.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/ShowJobFunction.java
@@ -43,6 +43,10 @@ public class ShowJobFunction extends SqoopFunction {
.withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_ALL_JOBS))
.withLongOpt(Constants.OPT_ALL)
.create(Constants.OPT_ALL_CHAR));
+ this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_CID)
+ .withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_JOBS_CID))
+ .withLongOpt(Constants.OPT_CID)
+ .create(Constants.OPT_CID_CHAR));
this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_JID)
.withDescription(resourceString(Constants.RES_SHOW_PROMPT_DISPLAY_JOB_JID))
.withLongOpt(Constants.OPT_JID)
@@ -52,13 +56,14 @@ public class ShowJobFunction extends SqoopFunction {
@Override
public Object executeFunction(CommandLine line, boolean isInteractive) {
if (line.hasOption(Constants.OPT_ALL)) {
- showJobs();
+ showJobs(null);
+ } else if (line.hasOption(Constants.OPT_CID)) {
+ showJobs(getLong(line, Constants.OPT_CID));
} else if (line.hasOption(Constants.OPT_JID)) {
showJob(getLong(line, Constants.OPT_JID));
} else {
showSummary();
}
-
return Status.OK;
}
@@ -91,8 +96,13 @@ public class ShowJobFunction extends SqoopFunction {
TableDisplayer.display(header, ids, names, fromConnectors, toConnectors, availabilities);
}
- private void showJobs() {
- List<MJob> jobs = client.getJobs();
+ private void showJobs(Long id) {
+ List<MJob> jobs;
+ if (id == null) {
+ jobs = client.getJobs();
+ } else {
+ jobs = client.getJobsByConnector(id);
+ }
printlnResource(Constants.RES_SHOW_PROMPT_JOBS_TO_SHOW, jobs.size());
for (MJob job : jobs) {
http://git-wip-us.apache.org/repos/asf/sqoop/blob/5ade862b/shell/src/main/java/org/apache/sqoop/shell/core/Constants.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/core/Constants.java b/shell/src/main/java/org/apache/sqoop/shell/core/Constants.java
index 98d8cbf..ca387d8 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/core/Constants.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/core/Constants.java
@@ -260,6 +260,8 @@ public class Constants {
public static final String RES_SHOW_PROMPT_DISPLAY_ALL_JOBS =
"show.prompt_display_all_jobs";
+ public static final String RES_SHOW_PROMPT_DISPLAY_JOBS_CID =
+ "show.prompt_display_all_jobs_cid";
public static final String RES_SHOW_PROMPT_DISPLAY_JOB_JID =
"show.prompt_display_job_jid";
public static final String RES_SHOW_PROMPT_JOBS_TO_SHOW =
http://git-wip-us.apache.org/repos/asf/sqoop/blob/5ade862b/shell/src/main/resources/shell-resource.properties
----------------------------------------------------------------------
diff --git a/shell/src/main/resources/shell-resource.properties b/shell/src/main/resources/shell-resource.properties
index 6a64fcc..2b5a9b7 100644
--- a/shell/src/main/resources/shell-resource.properties
+++ b/shell/src/main/resources/shell-resource.properties
@@ -144,7 +144,8 @@ show.driver_usage = Usage: show driver
show.prompt_driver_opts = @|bold Driver specific options: |@\nPersistent id: {0}
show.prompt_display_all_jobs = Display all jobs
-show.prompt_display_job_jid = Display jobwith given jid
+show.prompt_display_all_jobs_cid = Display all jobs with given cid
+show.prompt_display_job_jid = Display job with given jid
show.job_usage = Usage: show job
show.prompt_jobs_to_show = @|bold {0} job(s) to show: |@
show.prompt_job_info = Job with id {0} and name {1} (Enabled: {2}, Created by {3} at {4}, Updated by {5} at {6})