sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kathl...@apache.org
Subject sqoop git commit: SQOOP-2771: Sqoop2: Remove the notion of SubmissionBean (Jarek Jarcec Cecho)
Date Sat, 16 Jan 2016 23:44:23 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 f24e76050 -> 80b1790b9


SQOOP-2771: Sqoop2: Remove the notion of SubmissionBean
 (Jarek Jarcec Cecho)


Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/80b1790b
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/80b1790b
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/80b1790b

Branch: refs/heads/sqoop2
Commit: 80b1790b9dcbd3f6d99bccba7f005de2017388c6
Parents: f24e760
Author: Kate Ting <kathleen@apache.org>
Authored: Sat Jan 16 15:43:26 2016 -0800
Committer: Kate Ting <kathleen@apache.org>
Committed: Sat Jan 16 15:43:26 2016 -0800

----------------------------------------------------------------------
 .../client/request/SqoopResourceRequests.java   |  2 +-
 .../request/SubmissionResourceRequest.java      |  6 +-
 .../org/apache/sqoop/json/SubmissionBean.java   | 24 ++++----
 .../org/apache/sqoop/json/SubmissionsBean.java  | 63 --------------------
 .../apache/sqoop/json/TestSubmissionBean.java   |  9 ++-
 .../sqoop/handler/SubmissionRequestHandler.java |  6 +-
 .../tools/RepositoryDumpLoadToolTest.java       |  4 +-
 .../sqoop/tools/tool/RepositoryDumpTool.java    |  4 +-
 .../sqoop/tools/tool/RepositoryLoadTool.java    |  4 +-
 9 files changed, 29 insertions(+), 93 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/80b1790b/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 bb5242f..33c90a8 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
@@ -174,7 +174,7 @@ public class SqoopResourceRequests {
     return getJobResourceRequest().stop(serverUrl, jArg);
   }
 
-  public SubmissionsBean readSubmission(String jArg) {
+  public SubmissionBean readSubmission(String jArg) {
     return getSubmissionResourceRequest().read(serverUrl, jArg);
   }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/80b1790b/client/src/main/java/org/apache/sqoop/client/request/SubmissionResourceRequest.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/request/SubmissionResourceRequest.java
b/client/src/main/java/org/apache/sqoop/client/request/SubmissionResourceRequest.java
index 0317b93..1da8c6f 100644
--- a/client/src/main/java/org/apache/sqoop/client/request/SubmissionResourceRequest.java
+++ b/client/src/main/java/org/apache/sqoop/client/request/SubmissionResourceRequest.java
@@ -19,7 +19,7 @@ package org.apache.sqoop.client.request;
 
 import org.apache.hadoop.security.token.delegation.web.DelegationTokenAuthenticatedURL;
 import org.apache.sqoop.json.JSONUtils;
-import org.apache.sqoop.json.SubmissionsBean;
+import org.apache.sqoop.json.SubmissionBean;
 import org.apache.sqoop.utils.UrlSafeUtils;
 import org.json.simple.JSONObject;
 
@@ -39,7 +39,7 @@ public class SubmissionResourceRequest extends  ResourceRequest {
     super(token);
   }
 
-  public SubmissionsBean read(String serverUrl, String jArg) {
+  public SubmissionBean read(String serverUrl, String jArg) {
     String response;
     if (jArg == null) {
       // all submissions
@@ -49,7 +49,7 @@ public class SubmissionResourceRequest extends  ResourceRequest {
       response = super.get(serverUrl + RESOURCE + "?jname=" + UrlSafeUtils.urlEncode(jArg));
     }
     JSONObject jsonObject = JSONUtils.parse(response);
-    SubmissionsBean submissionBean = new SubmissionsBean();
+    SubmissionBean submissionBean = new SubmissionBean();
     submissionBean.restore(jsonObject);
     return submissionBean;
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/80b1790b/common/src/main/java/org/apache/sqoop/json/SubmissionBean.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/json/SubmissionBean.java b/common/src/main/java/org/apache/sqoop/json/SubmissionBean.java
index 4040688..b19ada1 100644
--- a/common/src/main/java/org/apache/sqoop/json/SubmissionBean.java
+++ b/common/src/main/java/org/apache/sqoop/json/SubmissionBean.java
@@ -43,7 +43,7 @@ import org.json.simple.JSONObject;
 @InterfaceStability.Unstable
 public class SubmissionBean implements JsonBean {
 
-  private static final String SUBMISSION = "submission";
+  private static final String SUBMISSIONS = "submissions";
   private static final String JOB_NAME = "job-name";
   private static final String CREATION_USER = "creation-user";
   private static final String CREATION_DATE = "creation-date";
@@ -84,9 +84,16 @@ public class SubmissionBean implements JsonBean {
   @Override
   @SuppressWarnings("unchecked")
   public JSONObject extract(boolean skipSensitive) {
-    JSONObject submission = new JSONObject();
-    submission.put(SUBMISSION, extractSubmission(submissions.get(0)));
-    return submission;
+    JSONArray submissionsArray = extractSubmissions();
+    JSONObject submissions = new JSONObject();
+    submissions.put(SUBMISSIONS, submissionsArray);
+    return submissions;
+  }
+
+  @Override
+  public void restore(JSONObject json) {
+    JSONArray submissionsArray = JSONUtils.getJSONArray(json, SUBMISSIONS);
+    restoreSubmissions(submissionsArray);
   }
 
   @SuppressWarnings("unchecked")
@@ -156,15 +163,8 @@ public class SubmissionBean implements JsonBean {
     return counterArray;
   }
 
-  @Override
-  public void restore(JSONObject json) {
-    submissions = new ArrayList<MSubmission>();
-    JSONObject obj = JSONUtils.getJSONObject(json, SUBMISSION);
-    submissions.add(restoreSubmission(obj));
-  }
-
   protected void restoreSubmissions(JSONArray array) {
-    submissions = new ArrayList<MSubmission>();
+    submissions = new ArrayList<>();
     for (Object obj : array) {
       submissions.add(restoreSubmission(obj));
     }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/80b1790b/common/src/main/java/org/apache/sqoop/json/SubmissionsBean.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/json/SubmissionsBean.java b/common/src/main/java/org/apache/sqoop/json/SubmissionsBean.java
deleted file mode 100644
index 52e8efa..0000000
--- a/common/src/main/java/org/apache/sqoop/json/SubmissionsBean.java
+++ /dev/null
@@ -1,63 +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.json;
-
-import java.util.List;
-
-import org.apache.sqoop.classification.InterfaceAudience;
-import org.apache.sqoop.classification.InterfaceStability;
-import org.apache.sqoop.model.MSubmission;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-
-@InterfaceAudience.Private
-@InterfaceStability.Unstable
-public class SubmissionsBean extends SubmissionBean {
-
-  private static final String SUBMISSIONS = "submissions";
-
-  // For "extract"
-  public SubmissionsBean(MSubmission submission) {
-    super(submission);
-  }
-
-  public SubmissionsBean(List<MSubmission> submissions) {
-    super(submissions);
-
-  }
-
-  // For "restore"
-  public SubmissionsBean() {
-  }
-
-  @Override
-  @SuppressWarnings("unchecked")
-  public JSONObject extract(boolean skipSensitive) {
-    JSONArray submissionsArray = super.extractSubmissions();
-    JSONObject submissions = new JSONObject();
-    submissions.put(SUBMISSIONS, submissionsArray);
-    return submissions;
-  }
-
-  @Override
-  public void restore(JSONObject json) {
-    JSONArray submissionsArray = JSONUtils.getJSONArray(json, SUBMISSIONS);
-    restoreSubmissions(submissionsArray);
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/80b1790b/common/src/test/java/org/apache/sqoop/json/TestSubmissionBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestSubmissionBean.java b/common/src/test/java/org/apache/sqoop/json/TestSubmissionBean.java
index 204c1de..02dcd94 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestSubmissionBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestSubmissionBean.java
@@ -36,7 +36,6 @@ import java.util.List;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNotNull;
 
-// NOTE: This tests both the submission and submissions list bean
 public class TestSubmissionBean {
 
   private static final double EPSILON = 0.01;
@@ -460,13 +459,13 @@ public class TestSubmissionBean {
    * @return
    */
   private MSubmission transfer(MSubmission submission) {
-    SubmissionsBean bean = new SubmissionsBean(submission);
+    SubmissionBean bean = new SubmissionBean(submission);
     JSONObject json = bean.extract(false);
 
     String string = json.toString();
 
     JSONObject retrievedJson = JSONUtils.parse(string);
-    SubmissionsBean retrievedBean = new SubmissionsBean();
+    SubmissionBean retrievedBean = new SubmissionBean();
     retrievedBean.restore(retrievedJson);
 
     return retrievedBean.getSubmissions().get(0);
@@ -479,13 +478,13 @@ public class TestSubmissionBean {
    * @return
    */
   private List<MSubmission> transfer(List<MSubmission> submissions) {
-    SubmissionsBean bean = new SubmissionsBean(submissions);
+    SubmissionBean bean = new SubmissionBean(submissions);
     JSONObject json = bean.extract(false);
 
     String string = json.toString();
 
     JSONObject retrievedJson = JSONUtils.parse(string);
-    SubmissionsBean retrievedBean = new SubmissionsBean();
+    SubmissionBean retrievedBean = new SubmissionBean();
     retrievedBean.restore(retrievedJson);
 
     return retrievedBean.getSubmissions();

http://git-wip-us.apache.org/repos/asf/sqoop/blob/80b1790b/server/src/main/java/org/apache/sqoop/handler/SubmissionRequestHandler.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/handler/SubmissionRequestHandler.java b/server/src/main/java/org/apache/sqoop/handler/SubmissionRequestHandler.java
index 6cf3dbe..b894e37 100644
--- a/server/src/main/java/org/apache/sqoop/handler/SubmissionRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/SubmissionRequestHandler.java
@@ -23,7 +23,7 @@ import org.apache.log4j.Logger;
 import org.apache.sqoop.audit.AuditLoggerManager;
 import org.apache.sqoop.common.SqoopException;
 import org.apache.sqoop.json.JsonBean;
-import org.apache.sqoop.json.SubmissionsBean;
+import org.apache.sqoop.json.SubmissionBean;
 import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.model.MSubmission;
 import org.apache.sqoop.repository.RepositoryManager;
@@ -72,7 +72,7 @@ public class SubmissionRequestHandler implements RequestHandler {
     //Authorization check
     submissions = AuthorizationEngine.filterSubmission(ctx.getUserName(), submissions);
 
-    return new SubmissionsBean(submissions);
+    return new SubmissionBean(submissions);
   }
 
   private JsonBean getSubmissionsForJob(String jobIdentifier, RequestContext ctx) {
@@ -85,6 +85,6 @@ public class SubmissionRequestHandler implements RequestHandler {
     List<MSubmission> submissions = RepositoryManager.getInstance().getRepository()
         .findSubmissionsForJob(jobName);
 
-    return new SubmissionsBean(submissions);
+    return new SubmissionBean(submissions);
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/80b1790b/test/src/test/java/org/apache/sqoop/integration/tools/RepositoryDumpLoadToolTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/tools/RepositoryDumpLoadToolTest.java
b/test/src/test/java/org/apache/sqoop/integration/tools/RepositoryDumpLoadToolTest.java
index f046e25..c1a10bc 100644
--- a/test/src/test/java/org/apache/sqoop/integration/tools/RepositoryDumpLoadToolTest.java
+++ b/test/src/test/java/org/apache/sqoop/integration/tools/RepositoryDumpLoadToolTest.java
@@ -23,7 +23,7 @@ import org.apache.sqoop.common.VersionInfo;
 import org.apache.sqoop.json.JSONUtils;
 import org.apache.sqoop.json.JobBean;
 import org.apache.sqoop.json.LinkBean;
-import org.apache.sqoop.json.SubmissionsBean;
+import org.apache.sqoop.json.SubmissionBean;
 import org.apache.sqoop.model.*;
 import org.apache.sqoop.submission.SubmissionStatus;
 import org.apache.sqoop.test.infrastructure.Infrastructure;
@@ -81,7 +81,7 @@ public class RepositoryDumpLoadToolTest extends SqoopTestCase {
 
       // verify the submission
       JSONObject jsonSubmissions = (JSONObject) json.get(JSONConstants.SUBMISSIONS);
-      SubmissionsBean submissionsBean = new SubmissionsBean();
+      SubmissionBean submissionsBean = new SubmissionBean();
       submissionsBean.restore(jsonSubmissions);
       verifySubmissions(submissionsBean.getSubmissions());
     }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/80b1790b/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 49978fa..e0d1173 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
@@ -35,7 +35,7 @@ import org.apache.sqoop.common.VersionInfo;
 import org.apache.sqoop.connector.ConnectorManager;
 import org.apache.sqoop.json.JobBean;
 import org.apache.sqoop.json.LinkBean;
-import org.apache.sqoop.json.SubmissionsBean;
+import org.apache.sqoop.json.SubmissionBean;
 import org.apache.sqoop.model.MLink;
 import org.apache.sqoop.repository.Repository;
 import org.apache.sqoop.repository.RepositoryManager;
@@ -117,7 +117,7 @@ public class RepositoryDumpTool extends ConfiguredTool {
     result.put(JSONConstants.JOBS, jobsJsonObject);
 
     LOG.info("Dumping Submissions with skipSensitive=" + String.valueOf(skipSensitive));
-    SubmissionsBean submissions = new SubmissionsBean(repository.findSubmissions());
+    SubmissionBean submissions = new SubmissionBean(repository.findSubmissions());
     JSONObject submissionsJsonObject = submissions.extract(skipSensitive);
     result.put(JSONConstants.SUBMISSIONS, submissionsJsonObject);
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/80b1790b/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryLoadTool.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryLoadTool.java b/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryLoadTool.java
index 08c914a..d51c860 100644
--- a/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryLoadTool.java
+++ b/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryLoadTool.java
@@ -43,7 +43,7 @@ import org.apache.sqoop.driver.DriverUpgrader;
 import org.apache.sqoop.json.JSONUtils;
 import org.apache.sqoop.json.JobBean;
 import org.apache.sqoop.json.LinkBean;
-import org.apache.sqoop.json.SubmissionsBean;
+import org.apache.sqoop.json.SubmissionBean;
 import org.apache.sqoop.model.ConfigUtils;
 import org.apache.sqoop.model.MConfig;
 import org.apache.sqoop.model.MConnector;
@@ -205,7 +205,7 @@ public class RepositoryLoadTool extends ConfiguredTool {
 
     removeSubmissionIfJobNotExist((JSONArray)jsonSubmissions.get(JSONConstants.SUBMISSIONS));
 
-    SubmissionsBean submissionsBean = new SubmissionsBean();
+    SubmissionBean submissionsBean = new SubmissionBean();
     submissionsBean.restore(jsonSubmissions);
     for (MSubmission submission : submissionsBean.getSubmissions()) {
       resetPersistenceId(submission);


Mime
View raw message