sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject [1/2] SQOOP-1510: Sqoop2: Refactor JobRequestHandler for submit/abort job and SubmissionHandler for get operation only
Date Tue, 04 Nov 2014 18:02:18 GMT
Repository: sqoop
Updated Branches:
  refs/heads/branch-1.99.4 f62e161dc -> fedc12a65


http://git-wip-us.apache.org/repos/asf/sqoop/blob/fedc12a6/server/src/main/java/org/apache/sqoop/server/v1/SubmissionServlet.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/server/v1/SubmissionServlet.java b/server/src/main/java/org/apache/sqoop/server/v1/SubmissionServlet.java
deleted file mode 100644
index 5c1d883..0000000
--- a/server/src/main/java/org/apache/sqoop/server/v1/SubmissionServlet.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.server.v1;
-
-import org.apache.sqoop.handler.SubmissionRequestHandler;
-import org.apache.sqoop.json.JsonBean;
-import org.apache.sqoop.server.RequestContext;
-import org.apache.sqoop.server.RequestHandler;
-import org.apache.sqoop.server.SqoopProtocolServlet;
-
-/**
- *
- */
-@SuppressWarnings("serial")
-public class SubmissionServlet extends SqoopProtocolServlet {
-
-  private RequestHandler submissionRequestHandler;
-
-  public SubmissionServlet() {
-    submissionRequestHandler = new SubmissionRequestHandler();
-  }
-
-  @Override
-  protected JsonBean handleGetRequest(RequestContext ctx) throws Exception {
-    return submissionRequestHandler.handleEvent(ctx);
-  }
-
-  @Override
-  protected JsonBean handlePostRequest(RequestContext ctx) throws Exception {
-    return submissionRequestHandler.handleEvent(ctx);
-  }
-
-  @Override
-  protected JsonBean handleDeleteRequest(RequestContext ctx) throws Exception {
-    return submissionRequestHandler.handleEvent(ctx);
-  }
-}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/fedc12a6/server/src/main/java/org/apache/sqoop/server/v1/SubmissionsServlet.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/server/v1/SubmissionsServlet.java b/server/src/main/java/org/apache/sqoop/server/v1/SubmissionsServlet.java
new file mode 100644
index 0000000..5337fdd
--- /dev/null
+++ b/server/src/main/java/org/apache/sqoop/server/v1/SubmissionsServlet.java
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.server.v1;
+
+import org.apache.sqoop.handler.SubmissionRequestHandler;
+import org.apache.sqoop.json.JsonBean;
+import org.apache.sqoop.server.RequestContext;
+import org.apache.sqoop.server.RequestHandler;
+import org.apache.sqoop.server.SqoopProtocolServlet;
+
+/**
+ * Display job submissions in the sqoop system
+ *
+ * GET /v1/submissions
+ * Get all submissions in the system
+ *
+ * GET /v1/submissions?jname=
+ * Get all submissions for the given job ordered by updated time
+ *
+ */
+@SuppressWarnings("serial")
+public class SubmissionsServlet extends SqoopProtocolServlet {
+
+  private RequestHandler submissionRequestHandler;
+
+  public SubmissionsServlet() {
+    submissionRequestHandler = new SubmissionRequestHandler();
+  }
+
+  @Override
+  protected JsonBean handleGetRequest(RequestContext ctx) throws Exception {
+    return submissionRequestHandler.handleEvent(ctx);
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/fedc12a6/server/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/server/src/main/webapp/WEB-INF/web.xml b/server/src/main/webapp/WEB-INF/web.xml
index 6ad90d2..d405c88 100644
--- a/server/src/main/webapp/WEB-INF/web.xml
+++ b/server/src/main/webapp/WEB-INF/web.xml
@@ -123,16 +123,28 @@ limitations under the License.
     <url-pattern>/v1/job/*</url-pattern>
   </servlet-mapping>
 
-  <!-- Submission servlet -->
+  <!-- Jobs servlet -->
   <servlet>
-    <servlet-name>v1.SubmissionServlet</servlet-name>
-    <servlet-class>org.apache.sqoop.server.v1.SubmissionServlet</servlet-class>
+    <servlet-name>v1.JobsServlet</servlet-name>
+    <servlet-class>org.apache.sqoop.server.v1.JobsServlet</servlet-class>
     <load-on-startup>1</load-on-startup>
   </servlet>
 
   <servlet-mapping>
-    <servlet-name>v1.SubmissionServlet</servlet-name>
-    <url-pattern>/v1/submission/*</url-pattern>
+    <servlet-name>v1.JobsServlet</servlet-name>
+    <url-pattern>/v1/jobs/*</url-pattern>
+  </servlet-mapping>
+
+  <!-- Submissions servlet -->
+  <servlet>
+    <servlet-name>v1.SubmissionsServlet</servlet-name>
+    <servlet-class>org.apache.sqoop.server.v1.SubmissionsServlet</servlet-class>
+    <load-on-startup>1</load-on-startup>
+  </servlet>
+
+  <servlet-mapping>
+    <servlet-name>v1.SubmissionsServlet</servlet-name>
+    <url-pattern>/v1/submissions/*</url-pattern>
   </servlet-mapping>
 
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/fedc12a6/shell/src/main/java/org/apache/sqoop/shell/ShowJobStatusFunction.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/ShowJobStatusFunction.java b/shell/src/main/java/org/apache/sqoop/shell/ShowJobStatusFunction.java
new file mode 100644
index 0000000..8e57d33
--- /dev/null
+++ b/shell/src/main/java/org/apache/sqoop/shell/ShowJobStatusFunction.java
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.shell;
+
+import static org.apache.sqoop.shell.ShellEnvironment.client;
+import static org.apache.sqoop.shell.ShellEnvironment.resourceString;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.sqoop.model.MSubmission;
+import org.apache.sqoop.shell.core.Constants;
+import org.apache.sqoop.shell.utils.SubmissionDisplayer;
+import org.apache.sqoop.submission.SubmissionStatus;
+import org.apache.sqoop.validation.Status;
+
+@SuppressWarnings("serial")
+public class ShowJobStatusFunction extends SqoopFunction {
+
+  @SuppressWarnings("static-access")
+  public ShowJobStatusFunction() {
+    this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_JID)
+       .withDescription(resourceString(Constants.RES_PROMPT_JOB_ID))
+       .withLongOpt(Constants.OPT_JID)
+       .create(Constants.OPT_JID_CHAR));
+  }
+
+  @Override
+  public Object executeFunction(CommandLine line, boolean isInteractive) {
+    if (line.hasOption(Constants.OPT_JID)) {
+      MSubmission submission = client.getJobStatus(getLong(line, Constants.OPT_JID));
+      if(submission.getStatus().isFailure() || submission.getStatus().equals(SubmissionStatus.SUCCEEDED))
{
+        SubmissionDisplayer.displayHeader(submission);
+        SubmissionDisplayer.displayFooter(submission);
+      } else {
+        SubmissionDisplayer.displayHeader(submission);
+        SubmissionDisplayer.displayProgress(submission);
+      }
+    } else {
+      return null;
+    }
+
+    return Status.OK;
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/fedc12a6/shell/src/main/java/org/apache/sqoop/shell/StartJobFunction.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/StartJobFunction.java b/shell/src/main/java/org/apache/sqoop/shell/StartJobFunction.java
index 0dc4e78..dd61d7a 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/StartJobFunction.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/StartJobFunction.java
@@ -72,12 +72,12 @@ public class StartJobFunction extends SqoopFunction {
       };
 
       try {
-        client.startSubmission(getLong(line, Constants.OPT_JID), callback, pollTimeout);
+        client.startJob(getLong(line, Constants.OPT_JID), callback, pollTimeout);
       } catch (InterruptedException e) {
         throw new SqoopException(ShellError.SHELL_0007, e);
       }
     } else if (line.hasOption(Constants.OPT_JID)) {
-      MSubmission submission = client.startSubmission(getLong(line, Constants.OPT_JID));
+      MSubmission submission = client.startJob(getLong(line, Constants.OPT_JID));
       if(submission.getStatus().isFailure()) {
         SubmissionDisplayer.displayFooter(submission);
       } else {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/fedc12a6/shell/src/main/java/org/apache/sqoop/shell/StatusCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/StatusCommand.java b/shell/src/main/java/org/apache/sqoop/shell/StatusCommand.java
index 3447a87..5b4ef1f 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/StatusCommand.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/StatusCommand.java
@@ -28,7 +28,7 @@ public class StatusCommand extends SqoopCommand {
       Constants.CMD_STATUS,
       Constants.CMD_STATUS_SC,
       new ImmutableMap.Builder<String, Class<? extends SqoopFunction>>()
-        .put(Constants.FN_JOB, StatusJobFunction.class)
+        .put(Constants.FN_JOB, ShowJobStatusFunction.class)
         .build()
       );
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/fedc12a6/shell/src/main/java/org/apache/sqoop/shell/StatusJobFunction.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/StatusJobFunction.java b/shell/src/main/java/org/apache/sqoop/shell/StatusJobFunction.java
deleted file mode 100644
index 922977a..0000000
--- a/shell/src/main/java/org/apache/sqoop/shell/StatusJobFunction.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.shell;
-
-import static org.apache.sqoop.shell.ShellEnvironment.client;
-import static org.apache.sqoop.shell.ShellEnvironment.resourceString;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.sqoop.model.MSubmission;
-import org.apache.sqoop.shell.core.Constants;
-import org.apache.sqoop.shell.utils.SubmissionDisplayer;
-import org.apache.sqoop.submission.SubmissionStatus;
-import org.apache.sqoop.validation.Status;
-
-@SuppressWarnings("serial")
-public class StatusJobFunction extends SqoopFunction {
-
-  @SuppressWarnings("static-access")
-  public StatusJobFunction() {
-    this.addOption(OptionBuilder.hasArg().withArgName(Constants.OPT_JID)
-       .withDescription(resourceString(Constants.RES_PROMPT_JOB_ID))
-       .withLongOpt(Constants.OPT_JID)
-       .create(Constants.OPT_JID_CHAR));
-  }
-
-  @Override
-  public Object executeFunction(CommandLine line, boolean isInteractive) {
-    if (line.hasOption(Constants.OPT_JID)) {
-      MSubmission submission = client.getSubmissionStatus(getLong(line, Constants.OPT_JID));
-      if(submission.getStatus().isFailure() || submission.getStatus().equals(SubmissionStatus.SUCCEEDED))
{
-        SubmissionDisplayer.displayHeader(submission);
-        SubmissionDisplayer.displayFooter(submission);
-      } else {
-        SubmissionDisplayer.displayHeader(submission);
-        SubmissionDisplayer.displayProgress(submission);
-      }
-    } else {
-      return null;
-    }
-
-    return Status.OK;
-  }
-}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/fedc12a6/shell/src/main/java/org/apache/sqoop/shell/StopJobFunction.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/StopJobFunction.java b/shell/src/main/java/org/apache/sqoop/shell/StopJobFunction.java
index c34152e..2b28b3b 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/StopJobFunction.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/StopJobFunction.java
@@ -40,7 +40,7 @@ public class StopJobFunction extends SqoopFunction {
   @Override
   public Object executeFunction(CommandLine line, boolean isInteractive) {
     if (line.hasOption(Constants.OPT_JID)) {
-      MSubmission submission = client.stopSubmission(getLong(line, Constants.OPT_JID));
+      MSubmission submission = client.stopJob(getLong(line, Constants.OPT_JID));
       if(submission.getStatus().isFailure()) {
         SubmissionDisplayer.displayFooter(submission);
       } else {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/fedc12a6/shell/src/main/java/org/apache/sqoop/shell/UpdateJobFunction.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/UpdateJobFunction.java b/shell/src/main/java/org/apache/sqoop/shell/UpdateJobFunction.java
index 79a9794..02e8c8c 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/UpdateJobFunction.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/UpdateJobFunction.java
@@ -61,13 +61,13 @@ public class UpdateJobFunction extends SqoopFunction {
 
     ConsoleReader reader = new ConsoleReader();
 
+    // TODO(SQOOP-1634): using from/to and driver config id, this call can be avoided
     MJob job = client.getJob(jobId);
 
     ResourceBundle fromConnectorBundle = client.getConnectorConfigBundle(
         job.getConnectorId(Direction.FROM));
     ResourceBundle toConnectorBundle = client.getConnectorConfigBundle(
         job.getConnectorId(Direction.TO));
-
     ResourceBundle driverConfigBundle = client.getDriverConfigBundle();
 
     Status status = Status.OK;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/fedc12a6/shell/src/main/java/org/apache/sqoop/shell/UpdateLinkFunction.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/UpdateLinkFunction.java b/shell/src/main/java/org/apache/sqoop/shell/UpdateLinkFunction.java
index c3775ad..c0c47e1 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/UpdateLinkFunction.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/UpdateLinkFunction.java
@@ -104,4 +104,4 @@ public class UpdateLinkFunction extends SqoopFunction {
 
     return status;
   }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/fedc12a6/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java b/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java
index c81364b..e9c15a1 100644
--- a/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java
+++ b/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java
@@ -242,7 +242,7 @@ abstract public class ConnectorTestCase extends TomcatTestCase {
    * @throws Exception
    */
   protected void executeJob(long jid) throws Exception {
-    getClient().startSubmission(jid, DEFAULT_SUBMISSION_CALLBACKS, 100);
+    getClient().startJob(jid, DEFAULT_SUBMISSION_CALLBACKS, 100);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/sqoop/blob/fedc12a6/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromRDBMSToHDFSTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromRDBMSToHDFSTest.java
b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromRDBMSToHDFSTest.java
index 36f7443..e482ac5 100644
--- a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromRDBMSToHDFSTest.java
+++ b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromRDBMSToHDFSTest.java
@@ -101,14 +101,14 @@ public class FromRDBMSToHDFSTest extends ConnectorTestCase {
     fillHdfsToConfig(job, ToFormat.TEXT_FILE);
     saveJob(job);
 
-    MSubmission submission = getClient().startSubmission(job.getPersistenceId());
+    MSubmission submission = getClient().startJob(job.getPersistenceId());
     assertTrue(submission.getStatus().isRunning());
 
     // Wait until the job finish - this active waiting will be removed once
     // Sqoop client API will get blocking support.
     do {
       Thread.sleep(5000);
-      submission = getClient().getSubmissionStatus(job.getPersistenceId());
+      submission = getClient().getJobStatus(job.getPersistenceId());
     } while(submission.getStatus().isRunning());
 
     // Assert correct output

http://git-wip-us.apache.org/repos/asf/sqoop/blob/fedc12a6/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryDumpTool.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryDumpTool.java b/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryDumpTool.java
index c219e68..53dac1b 100644
--- a/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryDumpTool.java
+++ b/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryDumpTool.java
@@ -34,7 +34,7 @@ import org.apache.sqoop.connector.ConnectorManager;
 import org.apache.sqoop.json.JobBean;
 import org.apache.sqoop.json.JsonBean;
 import org.apache.sqoop.json.LinkBean;
-import org.apache.sqoop.json.SubmissionBean;
+import org.apache.sqoop.json.SubmissionsBean;
 import org.apache.sqoop.repository.Repository;
 import org.apache.sqoop.repository.RepositoryManager;
 import org.apache.sqoop.tools.ConfiguredTool;
@@ -110,7 +110,7 @@ public class RepositoryDumpTool extends ConfiguredTool {
     result.put(JSONConstants.JOBS, addConnectorName(jobs.extract(skipSensitive)));
 
     LOG.info("Dumping Submissions with skipSensitive=" + String.valueOf(skipSensitive));
-    SubmissionBean submissions = new SubmissionBean(repository.findSubmissions());
+    SubmissionsBean submissions = new SubmissionsBean(repository.findSubmissions());
     result.put(JSONConstants.SUBMISSIONS, submissions.extract(skipSensitive));
 
     result.put(JSONConstants.METADATA, repoMetadata(skipSensitive));


Mime
View raw message