SQOOP-1497: Sqoop2: Entity Nomenclature Revisited
Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/049994a0 Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/049994a0 Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/049994a0 Branch: refs/heads/SQOOP-1367 Commit: 049994a0217164b703e754978a85a6c17fcb720a Parents: b04e796 Author: Veena Basavaraj <veena.b...@gmail.com> Authored: Tue Sep 23 15:28:24 2014 -0700 Committer: Abraham Elmahrek <abra...@elmahrek.com> Committed: Thu Oct 9 17:58:18 2014 -0700 ---------------------------------------------------------------------- .../org/apache/sqoop/client/SqoopClient.java | 280 ++++---- .../sqoop/client/request/ConnectionRequest.java | 91 --- .../sqoop/client/request/ConnectorRequest.java | 47 -- .../request/ConnectorResourceRequest.java | 47 ++ .../request/DriverConfigResourceRequest.java | 42 ++ .../sqoop/client/request/FrameworkRequest.java | 42 -- .../apache/sqoop/client/request/JobRequest.java | 91 --- .../client/request/JobResourceRequest.java | 91 +++ .../client/request/LinkResourceRequest.java | 89 +++ .../apache/sqoop/client/request/Request.java | 110 --- .../sqoop/client/request/ResourceRequest.java | 113 +++ .../sqoop/client/request/SqoopRequests.java | 149 ---- .../client/request/SqoopResourceRequests.java | 149 ++++ .../sqoop/client/request/SubmissionRequest.java | 80 --- .../request/SubmissionResourceRequest.java | 80 +++ .../sqoop/client/request/VersionRequest.java | 35 - .../client/request/VersionResourceRequest.java | 35 + .../apache/sqoop/client/TestSqoopClient.java | 105 ++- .../org/apache/sqoop/common/SqoopException.java | 2 +- .../org/apache/sqoop/etl/io/DataReader.java | 10 +- .../org/apache/sqoop/job/etl/ActorContext.java | 77 -- .../apache/sqoop/job/etl/DestroyerContext.java | 2 +- .../apache/sqoop/job/etl/ExtractorContext.java | 2 +- .../sqoop/job/etl/InitializerContext.java | 2 +- .../org/apache/sqoop/job/etl/LoaderContext.java | 2 +- .../sqoop/job/etl/PartitionerContext.java | 2 +- .../sqoop/job/etl/TransferableContext.java | 76 ++ .../org/apache/sqoop/json/ConnectionBean.java | 185 ----- .../sqoop/json/ConnectionValidationBean.java | 143 ---- .../org/apache/sqoop/json/ConnectorBean.java | 37 +- .../org/apache/sqoop/json/DriverConfigBean.java | 92 +++ .../org/apache/sqoop/json/FrameworkBean.java | 102 --- .../java/org/apache/sqoop/json/JobBean.java | 63 +- .../java/org/apache/sqoop/json/LinkBean.java | 184 +++++ .../apache/sqoop/json/LinkValidationBean.java | 143 ++++ .../sqoop/json/util/FormSerialization.java | 2 +- .../json/util/ResourceBundleSerialization.java | 13 +- .../main/java/org/apache/sqoop/model/Input.java | 2 +- .../org/apache/sqoop/model/MConnection.java | 130 ---- .../org/apache/sqoop/model/MDriverConfig.java | 97 +++ .../java/org/apache/sqoop/model/MFramework.java | 99 --- .../java/org/apache/sqoop/model/MInput.java | 2 +- .../main/java/org/apache/sqoop/model/MJob.java | 34 +- .../main/java/org/apache/sqoop/model/MLink.java | 129 ++++ .../apache/sqoop/json/TestConnectionBean.java | 138 ---- .../apache/sqoop/json/TestDriverConfigBean.java | 64 ++ .../apache/sqoop/json/TestFrameworkBean.java | 64 -- .../java/org/apache/sqoop/json/TestJobBean.java | 4 +- .../org/apache/sqoop/json/TestLinkBean.java | 138 ++++ .../java/org/apache/sqoop/json/TestUtil.java | 23 +- .../apache/sqoop/json/TestValidationBean.java | 12 +- .../sqoop/model/TestMAccountableEntity.java | 24 +- .../org/apache/sqoop/model/TestMConnection.java | 122 ---- .../apache/sqoop/model/TestMDriverConfig.java | 47 ++ .../org/apache/sqoop/model/TestMFramework.java | 47 -- .../java/org/apache/sqoop/model/TestMLink.java | 122 ++++ .../connector/jdbc/GenericJdbcConnector.java | 12 +- .../jdbc/GenericJdbcConnectorConstants.java | 2 +- .../GenericJdbcConnectorMetadataUpgrader.java | 83 --- .../jdbc/GenericJdbcConnectorUpgrader.java | 83 +++ .../connector/jdbc/GenericJdbcExtractor.java | 15 +- .../jdbc/GenericJdbcFromDestroyer.java | 6 +- .../jdbc/GenericJdbcFromInitializer.java | 60 +- .../sqoop/connector/jdbc/GenericJdbcLoader.java | 14 +- .../connector/jdbc/GenericJdbcPartitioner.java | 8 +- .../connector/jdbc/GenericJdbcToDestroyer.java | 22 +- .../jdbc/GenericJdbcToInitializer.java | 52 +- .../connector/jdbc/GenericJdbcValidator.java | 66 +- .../configuration/ConnectionConfiguration.java | 34 - .../jdbc/configuration/ConnectionForm.java | 64 -- .../jdbc/configuration/FromJobConfig.java | 68 ++ .../configuration/FromJobConfiguration.java | 4 +- .../jdbc/configuration/FromTableForm.java | 68 -- .../jdbc/configuration/LinkConfig.java | 64 ++ .../jdbc/configuration/LinkConfiguration.java | 34 + .../jdbc/configuration/ToJobConfig.java | 55 ++ .../jdbc/configuration/ToJobConfiguration.java | 4 +- .../jdbc/configuration/ToTableForm.java | 55 -- .../generic-jdbc-connector-config.properties | 127 ++++ .../generic-jdbc-connector-resources.properties | 127 ---- .../sqoop/connector/jdbc/TestExtractor.java | 14 +- .../connector/jdbc/TestFromInitializer.java | 116 +-- .../apache/sqoop/connector/jdbc/TestLoader.java | 8 +- .../sqoop/connector/jdbc/TestPartitioner.java | 36 +- .../sqoop/connector/jdbc/TestToInitializer.java | 132 ++-- .../connector/hdfs/HdfsConfigUpgrader.java | 83 +++ .../sqoop/connector/hdfs/HdfsConnector.java | 16 +- .../sqoop/connector/hdfs/HdfsConstants.java | 2 +- .../sqoop/connector/hdfs/HdfsExtractor.java | 6 +- .../sqoop/connector/hdfs/HdfsInitializer.java | 9 +- .../apache/sqoop/connector/hdfs/HdfsLoader.java | 41 +- .../connector/hdfs/HdfsMetadataUpgrader.java | 83 --- .../sqoop/connector/hdfs/HdfsPartitioner.java | 12 +- .../sqoop/connector/hdfs/HdfsValidator.java | 31 +- .../configuration/ConnectionConfiguration.java | 31 - .../hdfs/configuration/ConnectionForm.java | 29 - .../hdfs/configuration/FromJobConfig.java | 30 + .../configuration/FromJobConfiguration.java | 5 +- .../connector/hdfs/configuration/InputForm.java | 30 - .../hdfs/configuration/LinkConfig.java | 29 + .../hdfs/configuration/LinkConfiguration.java | 31 + .../hdfs/configuration/OutputCompression.java | 33 - .../hdfs/configuration/OutputForm.java | 36 - .../hdfs/configuration/OutputFormat.java | 33 - .../hdfs/configuration/ToCompression.java | 33 + .../connector/hdfs/configuration/ToFormat.java | 33 + .../hdfs/configuration/ToJobConfig.java | 36 + .../hdfs/configuration/ToJobConfiguration.java | 4 +- .../hdfs/hdfsWriter/HdfsSequenceWriter.java | 2 +- .../resources/hdfs-connector-config.properties | 58 ++ .../hdfs-connector-resources.properties | 58 -- .../sqoop/connector/hdfs/TestExtractor.java | 14 +- .../apache/sqoop/connector/hdfs/TestLoader.java | 34 +- .../sqoop/connector/hdfs/TestPartitioner.java | 14 +- .../connector/idf/IntermediateDataFormat.java | 2 +- .../sqoop/connector/ConnectorHandler.java | 2 +- .../sqoop/core/ConfigurationConstants.java | 4 +- .../java/org/apache/sqoop/core/SqoopServer.java | 8 +- .../java/org/apache/sqoop/driver/Driver.java | 179 +++++ .../sqoop/driver/DriverConfigUpgrader.java | 79 ++ .../apache/sqoop/driver/DriverConstants.java | 68 ++ .../org/apache/sqoop/driver/DriverError.java | 66 ++ .../apache/sqoop/driver/DriverValidator.java | 54 ++ .../apache/sqoop/driver/ExecutionEngine.java | 60 ++ .../org/apache/sqoop/driver/JobManager.java | 712 +++++++++++++++++++ .../org/apache/sqoop/driver/JobRequest.java | 356 ++++++++++ .../apache/sqoop/driver/SubmissionEngine.java | 115 +++ .../driver/configuration/JobConfiguration.java | 34 + .../driver/configuration/LinkConfiguration.java | 28 + .../driver/configuration/ThrottlingForm.java | 32 + .../apache/sqoop/framework/ExecutionEngine.java | 60 -- .../sqoop/framework/FrameworkConstants.java | 69 -- .../apache/sqoop/framework/FrameworkError.java | 66 -- .../sqoop/framework/FrameworkManager.java | 178 ----- .../framework/FrameworkMetadataUpgrader.java | 79 -- .../sqoop/framework/FrameworkValidator.java | 54 -- .../org/apache/sqoop/framework/JobManager.java | 710 ------------------ .../org/apache/sqoop/framework/JobRequest.java | 356 ---------- .../sqoop/framework/SubmissionEngine.java | 115 --- .../configuration/ConnectionConfiguration.java | 30 - .../configuration/JobConfiguration.java | 31 - .../framework/configuration/SecurityForm.java | 29 - .../framework/configuration/ThrottlingForm.java | 32 - .../apache/sqoop/repository/JdbcRepository.java | 106 ++- .../sqoop/repository/JdbcRepositoryHandler.java | 190 +++-- .../org/apache/sqoop/repository/Repository.java | 221 +++--- .../sqoop/repository/RepositoryError.java | 44 +- .../src/main/resources/driver-config.properties | 30 + .../resources/framework-resources.properties | 71 -- .../core/MockInvalidConfigurationProvider.java | 7 - .../apache/sqoop/core/TestConfiguration.java | 165 ----- .../sqoop/core/TestSqoopConfiguration.java | 165 +++++ .../java/org/apache/sqoop/core/TestUtils.java | 2 - .../sqoop/driver/TestDriverConfigUpgrader.java | 171 +++++ .../org/apache/sqoop/driver/TestJobManager.java | 190 +++++ .../org/apache/sqoop/driver/TestJobRequest.java | 70 ++ .../TestFrameworkMetadataUpgrader.java | 170 ----- .../sqoop/framework/TestFrameworkValidator.java | 156 ---- .../apache/sqoop/framework/TestJobManager.java | 173 ----- .../apache/sqoop/framework/TestJobRequest.java | 71 -- .../sqoop/repository/TestJdbcRepository.java | 559 ++++++++------- .../sqoop/execution/mapreduce/MRJobRequest.java | 4 +- .../mapreduce/MapreduceExecutionEngine.java | 13 +- .../java/org/apache/sqoop/job/JobConstants.java | 4 +- .../job/mr/SqoopOutputFormatLoadExecutor.java | 4 +- .../repository/derby/DerbyRepoConstants.java | 2 +- .../sqoop/repository/derby/DerbyRepoError.java | 122 ++-- .../derby/DerbyRepositoryHandler.java | 316 ++++---- .../repository/derby/DerbySchemaQuery.java | 2 +- .../sqoop/repository/derby/DerbyTestCase.java | 81 ++- .../derby/TestConnectionHandling.java | 245 ------- .../repository/derby/TestConnectorHandling.java | 18 +- .../derby/TestDriverConfigHandling.java | 126 ++++ .../repository/derby/TestFrameworkHandling.java | 129 ---- .../sqoop/repository/derby/TestInputTypes.java | 34 +- .../sqoop/repository/derby/TestInternals.java | 20 +- .../sqoop/repository/derby/TestJobHandling.java | 74 +- .../repository/derby/TestLinkHandling.java | 244 +++++++ .../derby/TestSubmissionHandling.java | 66 +- .../sqoop/handler/ConnectionRequestHandler.java | 274 ------- .../handler/DriverConfigRequestHandler.java | 50 ++ .../sqoop/handler/FrameworkRequestHandler.java | 53 -- .../apache/sqoop/handler/JobRequestHandler.java | 14 +- .../sqoop/handler/LinkRequestHandler.java | 271 +++++++ .../sqoop/handler/SubmissionRequestHandler.java | 3 +- .../sqoop/server/v1/ConnectionServlet.java | 56 -- .../sqoop/server/v1/DriverConfigServlet.java | 41 ++ .../sqoop/server/v1/FrameworkServlet.java | 40 -- .../org/apache/sqoop/server/v1/JobServlet.java | 13 +- .../org/apache/sqoop/server/v1/LinkServlet.java | 57 ++ .../sqoop/server/v1/SubmissionServlet.java | 11 +- server/src/main/webapp/WEB-INF/web.xml | 21 +- .../org/apache/sqoop/shell/CloneCommand.java | 2 +- .../sqoop/shell/CloneConnectionFunction.java | 109 --- .../apache/sqoop/shell/CloneJobFunction.java | 14 +- .../apache/sqoop/shell/CloneLinkFunction.java | 109 +++ .../org/apache/sqoop/shell/CreateCommand.java | 2 +- .../sqoop/shell/CreateConnectionFunction.java | 108 --- .../apache/sqoop/shell/CreateJobFunction.java | 24 +- .../apache/sqoop/shell/CreateLinkFunction.java | 108 +++ .../org/apache/sqoop/shell/DeleteCommand.java | 2 +- .../sqoop/shell/DeleteConnectionFunction.java | 47 -- .../apache/sqoop/shell/DeleteJobFunction.java | 2 +- .../apache/sqoop/shell/DeleteLinkFunction.java | 47 ++ .../org/apache/sqoop/shell/DisableCommand.java | 2 +- .../sqoop/shell/DisableConnectionFunction.java | 47 -- .../apache/sqoop/shell/DisableLinkFunction.java | 47 ++ .../org/apache/sqoop/shell/EnableCommand.java | 2 +- .../sqoop/shell/EnableConnectionFunction.java | 47 -- .../apache/sqoop/shell/EnableLinkFunction.java | 47 ++ .../org/apache/sqoop/shell/ShowCommand.java | 4 +- .../sqoop/shell/ShowConnectionFunction.java | 128 ---- .../sqoop/shell/ShowConnectorFunction.java | 2 +- .../sqoop/shell/ShowDriverConfigFunction.java | 60 ++ .../sqoop/shell/ShowFrameworkFunction.java | 60 -- .../org/apache/sqoop/shell/ShowJobFunction.java | 10 +- .../apache/sqoop/shell/ShowLinkFunction.java | 128 ++++ .../apache/sqoop/shell/ShowVersionFunction.java | 8 +- .../org/apache/sqoop/shell/UpdateCommand.java | 2 +- .../sqoop/shell/UpdateConnectionFunction.java | 107 --- .../apache/sqoop/shell/UpdateJobFunction.java | 10 +- .../apache/sqoop/shell/UpdateLinkFunction.java | 107 +++ .../org/apache/sqoop/shell/core/Constants.java | 112 +-- .../utils/ConnectionDynamicFormOptions.java | 44 -- .../apache/sqoop/shell/utils/FormDisplayer.java | 20 +- .../apache/sqoop/shell/utils/FormFiller.java | 66 +- .../shell/utils/LinkDynamicFormOptions.java | 43 ++ .../sqoop/shell/utils/SubmissionDisplayer.java | 4 +- .../main/resources/shell-resource.properties | 66 +- .../sqoop/connector/spi/MetadataUpgrader.java | 46 -- .../sqoop/connector/spi/RepositoryUpgrader.java | 51 ++ .../sqoop/connector/spi/SqoopConnector.java | 12 +- .../org/apache/sqoop/job/etl/Destroyer.java | 6 +- .../org/apache/sqoop/job/etl/Extractor.java | 8 +- .../java/org/apache/sqoop/job/etl/From.java | 4 +- .../org/apache/sqoop/job/etl/Initializer.java | 14 +- .../java/org/apache/sqoop/job/etl/Loader.java | 6 +- .../org/apache/sqoop/job/etl/Partitioner.java | 6 +- .../main/java/org/apache/sqoop/job/etl/To.java | 4 +- .../org/apache/sqoop/validation/Validator.java | 10 +- .../mapreduce/MapreduceSubmissionEngine.java | 36 +- .../apache/sqoop/test/db/DatabaseProvider.java | 14 +- .../sqoop/test/db/DatabaseProviderFactory.java | 2 +- .../sqoop/test/testcases/ConnectorTestCase.java | 61 +- .../sqoop/test/testcases/TomcatTestCase.java | 14 +- .../jdbc/generic/FromHDFSToRDBMSTest.java | 32 +- .../jdbc/generic/FromRDBMSToHDFSTest.java | 63 +- .../connector/jdbc/generic/PartitionerTest.java | 37 +- .../jdbc/generic/TableStagedRDBMSTest.java | 32 +- .../SubmissionWithDisabledModelObjectsTest.java | 50 +- .../sqoop/integration/server/VersionTest.java | 8 +- .../apache/sqoop/tools/tool/UpgradeTool.java | 19 +- 252 files changed, 8493 insertions(+), 8768 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/sqoop/blob/049994a0/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 0e45a24..d7e6768 100644 --- a/client/src/main/java/org/apache/sqoop/client/SqoopClient.java +++ b/client/src/main/java/org/apache/sqoop/client/SqoopClient.java @@ -17,16 +17,16 @@ */ package org.apache.sqoop.client; -import org.apache.sqoop.client.request.SqoopRequests; +import org.apache.sqoop.client.request.SqoopResourceRequests; import org.apache.sqoop.common.Direction; import org.apache.sqoop.common.SqoopException; import org.apache.sqoop.json.ConnectorBean; -import org.apache.sqoop.json.FrameworkBean; +import org.apache.sqoop.json.DriverConfigBean; import org.apache.sqoop.json.ValidationResultBean; import org.apache.sqoop.model.FormUtils; -import org.apache.sqoop.model.MConnection; +import org.apache.sqoop.model.MLink; import org.apache.sqoop.model.MConnector; -import org.apache.sqoop.model.MFramework; +import org.apache.sqoop.model.MDriverConfig; import org.apache.sqoop.model.MJob; import org.apache.sqoop.model.MSubmission; import org.apache.sqoop.validation.Status; @@ -45,7 +45,7 @@ import java.util.ResourceBundle; * implementation is not thread safe. * * SqoopClient is keeping cache of objects that are unlikely to be changed - * (Resources, Connector structures). Volatile structures (Connections, Jobs) + * (Resources, Connector structures). Volatile structures (Links, Jobs) * are not cached. */ public class SqoopClient { @@ -53,32 +53,29 @@ public class SqoopClient { /** * Underlying request object to fetch data from Sqoop server. */ - private SqoopRequests requests; + private SqoopResourceRequests resourceRequests; /** * True if user retrieved all connectors at once. */ - private boolean allConnectors; - + private boolean isAllConnectors; /** - * All cached bundles for all connectors. + * All cached connectors. */ - private Map<Long, ResourceBundle> bundles; - + private Map<Long, MConnector> connectors; /** - * Cached framework bundle. + * All cached bundles for all connectors. */ - private ResourceBundle frameworkBundle; + private Map<Long, ResourceBundle> connectorConfigBundles; /** - * All cached connectors. + * Cached driverConfig. */ - private Map<Long, MConnector> connectors; - + private MDriverConfig driverConfig; /** - * Cached framework. + * Cached driverConfig bundle. */ - private MFramework framework; + private ResourceBundle driverConfigBundle; /** * Status flags used when updating the submission callback status @@ -90,7 +87,7 @@ public class SqoopClient { } public SqoopClient(String serverUrl) { - requests = new SqoopRequests(); + resourceRequests = new SqoopResourceRequests(); setServerUrl(serverUrl); } @@ -102,7 +99,7 @@ public class SqoopClient { * @param serverUrl Server URL */ public void setServerUrl(String serverUrl) { - requests.setServerUrl(serverUrl); + resourceRequests.setServerUrl(serverUrl); clearCache(); } @@ -111,8 +108,8 @@ public class SqoopClient { * * @param requests SqoopRequests object */ - public void setSqoopRequests(SqoopRequests requests) { - this.requests = requests; + public void setSqoopRequests(SqoopResourceRequests requests) { + this.resourceRequests = requests; clearCache(); } @@ -120,11 +117,11 @@ public class SqoopClient { * Clear internal cache. */ public void clearCache() { - bundles = new HashMap<Long, ResourceBundle>(); - frameworkBundle = null; + connectorConfigBundles = new HashMap<Long, ResourceBundle>(); + driverConfigBundle = null; connectors = new HashMap<Long, MConnector>(); - framework = null; - allConnectors = false; + driverConfig = null; + isAllConnectors = false; } /** @@ -155,7 +152,7 @@ public class SqoopClient { // If the connector wasn't in cache and we have all connectors, // it simply do not exists. - if(allConnectors) return null; + if(isAllConnectors) return null; // Retrieve all connectors from server getConnectors(); @@ -186,9 +183,9 @@ public class SqoopClient { * @param cid Connector id */ private void retrieveConnector(long cid) { - ConnectorBean request = requests.readConnector(cid); + ConnectorBean request = resourceRequests.readConnector(cid); connectors.put(cid, request.getConnectors().get(0)); - bundles.put(cid, request.getResourceBundles().get(cid)); + connectorConfigBundles.put(cid, request.getResourceBundles().get(cid)); } /** @@ -197,16 +194,16 @@ public class SqoopClient { * @return */ public Collection<MConnector> getConnectors() { - if(allConnectors) { + if(isAllConnectors) { return connectors.values(); } - ConnectorBean bean = requests.readConnector(null); - allConnectors = true; + ConnectorBean bean = resourceRequests.readConnector(null); + isAllConnectors = true; for(MConnector connector : bean.getConnectors()) { connectors.put(connector.getPersistenceId(), connector); } - bundles = bean.getResourceBundles(); + connectorConfigBundles = bean.getResourceBundles(); return connectors.values(); } @@ -214,173 +211,171 @@ public class SqoopClient { /** * Get resource bundle for given connector. * - * @param cid Connector id. + * @param connectorId Connector id. * @return */ - public ResourceBundle getResourceBundle(long cid) { - if(bundles.containsKey(cid)) { - return bundles.get(cid); + public ResourceBundle getConnectorConfigResourceBundle(long connectorId) { + if(connectorConfigBundles.containsKey(connectorId)) { + return connectorConfigBundles.get(connectorId); } - retrieveConnector(cid); - return bundles.get(cid); + retrieveConnector(connectorId); + return connectorConfigBundles.get(connectorId); } /** - * Return framework metadata. + * Return driver config. * * @return */ - public MFramework getFramework() { - if(framework != null) { - return framework.clone(false); + public MDriverConfig getDriverConfig() { + if(driverConfig != null) { + return driverConfig.clone(false); } - - retrieveFramework(); - return framework.clone(false); + retrieveAndCacheDriverConfig(); + return driverConfig.clone(false); } /** - * Retrieve framework structure and cache it. + * Retrieve driverConfig and cache it. */ - private void retrieveFramework() { - FrameworkBean request = requests.readFramework(); - framework = request.getFramework(); - frameworkBundle = request.getResourceBundle(); + private void retrieveAndCacheDriverConfig() { + DriverConfigBean driverConfigBean = resourceRequests.readDriverConfig(); + driverConfig = driverConfigBean.getDriverConfig(); + driverConfigBundle = driverConfigBean.getResourceBundle(); } /** - * Return framework bundle. + * Return driverConfig bundle. * * @return */ - public ResourceBundle getFrameworkResourceBundle() { - if(frameworkBundle != null) { - return frameworkBundle; + public ResourceBundle getDriverConfigBundle() { + if(driverConfigBundle != null) { + return driverConfigBundle; } - - retrieveFramework(); - return frameworkBundle; + retrieveAndCacheDriverConfig(); + return driverConfigBundle; } /** - * Create new connection object for given connector. + * Create new link object for given connector id * - * @param cid Connector id + * @param connectorId Connector id * @return */ - public MConnection newConnection(long cid) { - return new MConnection( - cid, - getConnector(cid).getConnectionForms(), - getFramework().getConnectionForms() + public MLink createLink(long connectorId) { + return new MLink( + connectorId, + getConnector(connectorId).getConnectionForms(), + getDriverConfig().getConnectionForms() ); } /** - * Create new connection object for given connector. + * Create new link object for given connector name * * @param connectorName Connector name * @return */ - public MConnection newConnection(String connectorName) { + public MLink createLink(String connectorName) { MConnector connector = getConnector(connectorName); if(connector == null) { throw new SqoopException(ClientError.CLIENT_0003, connectorName); } - return newConnection(connector.getPersistenceId()); + return createLink(connector.getPersistenceId()); } /** - * Retrieve connection with given id. + * Retrieve link for given id. * - * @param xid Connnection id + * @param linkId Link id * @return */ - public MConnection getConnection(long xid) { - return requests.readConnection(xid).getConnections().get(0); + public MLink getLink(long linkId) { + return resourceRequests.readLink(linkId).getLinks().get(0); } /** - * Retrieve list of all connections. + * Retrieve list of all links. * * @return */ - public List<MConnection> getConnections() { - return requests.readConnection(null).getConnections(); + public List<MLink> getLinks() { + return resourceRequests.readLink(null).getLinks(); } /** - * Create the connection on server. + * Create the link and save to the repository * - * @param connection Connection that should be created + * @param link link that should be created * @return */ - public Status createConnection(MConnection connection) { - return applyValidations(requests.createConnection(connection), connection); + public Status saveLink(MLink link) { + return applyLinkValidations(resourceRequests.saveLink(link), link); } /** - * Update connection on the server. + * Update link on the server. * - * @param connection Connection that should be updated + * @param link link that should be updated * @return */ - public Status updateConnection(MConnection connection) { - return applyValidations(requests.updateConnection(connection), connection); + public Status updateLink(MLink link) { + return applyLinkValidations(resourceRequests.updateLink(link), link); } /** - * Enable/disable connection with given id + * Enable/disable link with given id * - * @param xid Connection id + * @param linkId link id * @param enabled Enable or disable */ - public void enableConnection(long xid, boolean enabled) { - requests.enableConnection(xid, enabled); + public void enableLink(long linkId, boolean enabled) { + resourceRequests.enableLink(linkId, enabled); } /** - * Delete connection with given id. + * Delete link with given id. * - * @param xid Connection id + * @param linkId link id */ - public void deleteConnection(long xid) { - requests.deleteConnection(xid); + public void deleteLink(long linkId) { + resourceRequests.deleteLink(linkId); } /** - * Create new job the for given connections. + * Create new job the for given links. * - * @param fromXid From Connection id - * @param toXid To Connection id + * @param fromLinkId From link id + * @param toLinkId To link id * @return */ - public MJob newJob(long fromXid, long toXid) { - MConnection fromConnection = getConnection(fromXid); - MConnection toConnection = getConnection(toXid); + public MJob createJob(long fromLinkId, long toLinkId) { + MLink fromLink = getLink(fromLinkId); + MLink toLink = getLink(toLinkId); return new MJob( - fromConnection.getConnectorId(), - toConnection.getConnectorId(), - fromConnection.getPersistenceId(), - toConnection.getPersistenceId(), - getConnector(fromConnection.getConnectorId()).getJobForms(Direction.FROM), - getConnector(toConnection.getConnectorId()).getJobForms(Direction.TO), - getFramework().getJobForms() + fromLink.getConnectorId(), + toLink.getConnectorId(), + fromLink.getPersistenceId(), + toLink.getPersistenceId(), + getConnector(fromLink.getConnectorId()).getJobForms(Direction.FROM), + getConnector(toLink.getConnectorId()).getJobForms(Direction.TO), + getDriverConfig().getJobForms() ); } /** * Retrieve job for given id. * - * @param jid Job id + * @param jobId Job id * @return */ - public MJob getJob(long jid) { - return requests.readJob(jid).getJobs().get(0); + public MJob getJob(long jobId) { + return resourceRequests.readJob(jobId).getJobs().get(0); } /** @@ -389,17 +384,17 @@ public class SqoopClient { * @return */ public List<MJob> getJobs() { - return requests.readJob(null).getJobs(); + return resourceRequests.readJob(null).getJobs(); } /** - * Create job on server. + * Create job on server and save to the repository * * @param job Job that should be created * @return */ - public Status createJob(MJob job) { - return applyValidations(requests.createJob(job), job); + public Status saveJob(MJob job) { + return applyJobValidations(resourceRequests.saveJob(job), job); } /** @@ -408,7 +403,7 @@ public class SqoopClient { * @return */ public Status updateJob(MJob job) { - return applyValidations(requests.updateJob(job), job); + return applyJobValidations(resourceRequests.updateJob(job), job); } /** @@ -418,44 +413,45 @@ public class SqoopClient { * @param enabled Enable or disable */ public void enableJob(long jid, boolean enabled) { - requests.enableJob(jid, enabled); + resourceRequests.enableJob(jid, enabled); } /** * Delete job with given id. * - * @param jid Job id + * @param jobId Job id */ - public void deleteJob(long jid) { - requests.deleteJob(jid); + public void deleteJob(long jobId) { + resourceRequests.deleteJob(jobId); } /** * Start job with given id. * - * @param jid Job id + * @param jobId Job id * @return */ - public MSubmission startSubmission(long jid) { - return requests.createSubmission(jid).getSubmissions().get(0); + public MSubmission startSubmission(long jobId) { + return resourceRequests.createSubmission(jobId).getSubmissions().get(0); } /** * Method used for synchronous job submission. * Pass null to callback parameter if submission status is not required and after completion * job execution returns MSubmission which contains final status of submission. - * @param jid - Job ID + * @param jobId - Job ID * @param callback - User may set null if submission status is not required, else callback methods invoked * @param pollTime - Server poll time * @return MSubmission - Final status of job submission * @throws InterruptedException */ - public MSubmission startSubmission(long jid, SubmissionCallback callback, long pollTime) throws InterruptedException { + public MSubmission startSubmission(long jobId, SubmissionCallback callback, long pollTime) + throws InterruptedException { if(pollTime <= 0) { throw new SqoopException(ClientError.CLIENT_0002); } boolean first = true; - MSubmission submission = requests.createSubmission(jid).getSubmissions().get(0); + MSubmission submission = resourceRequests.createSubmission(jobId).getSubmissions().get(0); while(submission.getStatus().isRunning()) { if(first) { submissionCallback(callback, submission, SubmissionStatus.SUBMITTED); @@ -464,7 +460,7 @@ public class SqoopClient { submissionCallback(callback, submission, SubmissionStatus.UPDATED); } Thread.sleep(pollTime); - submission = getSubmissionStatus(jid); + submission = getSubmissionStatus(jobId); } submissionCallback(callback, submission, SubmissionStatus.FINISHED); return submission; @@ -477,9 +473,9 @@ public class SqoopClient { * @param submission * @param status */ - private void submissionCallback(SubmissionCallback callback, - MSubmission submission, SubmissionStatus status) { - if(callback == null) { + private void submissionCallback(SubmissionCallback callback, MSubmission submission, + SubmissionStatus status) { + if (callback == null) { return; } switch (status) { @@ -501,7 +497,7 @@ public class SqoopClient { * @return */ public MSubmission stopSubmission(long jid) { - return requests.deleteSubmission(jid).getSubmissions().get(0); + return resourceRequests.deleteSubmission(jid).getSubmissions().get(0); } /** @@ -511,7 +507,7 @@ public class SqoopClient { * @return */ public MSubmission getSubmissionStatus(long jid) { - return requests.readSubmission(jid).getSubmissions().get(0); + return resourceRequests.readSubmission(jid).getSubmissions().get(0); } /** @@ -520,46 +516,46 @@ public class SqoopClient { * @return */ public List<MSubmission> getSubmissions() { - return requests.readHistory(null).getSubmissions(); + return resourceRequests.readHistory(null).getSubmissions(); } /** * Retrieve list of submissions for given jobId. * - * @param jid Job id + * @param jobId Job id * @return */ - public List<MSubmission> getSubmissionsForJob(long jid) { - return requests.readHistory(jid).getSubmissions(); + public List<MSubmission> getSubmissionsForJob(long jobId) { + return resourceRequests.readHistory(jobId).getSubmissions(); } - private Status applyValidations(ValidationResultBean bean, MConnection connection) { + private Status applyLinkValidations(ValidationResultBean bean, MLink link) { ValidationResult connector = bean.getValidationResults()[0]; - ValidationResult framework = bean.getValidationResults()[1]; + ValidationResult driverConfig = bean.getValidationResults()[1]; // Apply validation results - FormUtils.applyValidation(connection.getConnectorPart().getForms(), connector); - FormUtils.applyValidation(connection.getFrameworkPart().getForms(), framework); + FormUtils.applyValidation(link.getConnectorPart().getForms(), connector); + FormUtils.applyValidation(link.getFrameworkPart().getForms(), driverConfig); Long id = bean.getId(); if(id != null) { - connection.setPersistenceId(id); + link.setPersistenceId(id); } - return Status.getWorstStatus(connector.getStatus(), framework.getStatus()); + return Status.getWorstStatus(connector.getStatus(), driverConfig.getStatus()); } - private Status applyValidations(ValidationResultBean bean, MJob job) { + private Status applyJobValidations(ValidationResultBean bean, MJob job) { ValidationResult fromConnector = bean.getValidationResults()[0]; ValidationResult toConnector = bean.getValidationResults()[1]; - ValidationResult framework = bean.getValidationResults()[2]; + ValidationResult driverConfig = bean.getValidationResults()[2]; // Apply validation results // @TODO(Abe): From/To validation. FormUtils.applyValidation( job.getConnectorPart(Direction.FROM).getForms(), fromConnector); - FormUtils.applyValidation(job.getFrameworkPart().getForms(), framework); + FormUtils.applyValidation(job.getFrameworkPart().getForms(), driverConfig); FormUtils.applyValidation( job.getConnectorPart(Direction.TO).getForms(), toConnector); @@ -569,6 +565,6 @@ public class SqoopClient { job.setPersistenceId(id); } - return Status.getWorstStatus(fromConnector.getStatus(), framework.getStatus(), toConnector.getStatus()); + return Status.getWorstStatus(fromConnector.getStatus(), driverConfig.getStatus(), toConnector.getStatus()); } } http://git-wip-us.apache.org/repos/asf/sqoop/blob/049994a0/client/src/main/java/org/apache/sqoop/client/request/ConnectionRequest.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/sqoop/client/request/ConnectionRequest.java b/client/src/main/java/org/apache/sqoop/client/request/ConnectionRequest.java deleted file mode 100644 index 8436fc5..0000000 --- a/client/src/main/java/org/apache/sqoop/client/request/ConnectionRequest.java +++ /dev/null @@ -1,91 +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.client.request; - -import org.apache.sqoop.json.ConnectionBean; -import org.apache.sqoop.json.ValidationResultBean; -import org.apache.sqoop.model.MConnection; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; - -/** - * Provide CRUD semantics over RESTfull HTTP API for connections. All operations - * are normally supported. - */ -public class ConnectionRequest extends Request { - - public static final String RESOURCE = "v1/connection/"; - - private static final String ENABLE = "/enable"; - private static final String DISABLE = "/disable"; - - public ConnectionBean read(String serverUrl, Long xid) { - String response; - if (xid == null) { - response = super.get(serverUrl + RESOURCE + "all"); - } else { - response = super.get(serverUrl + RESOURCE + xid); - } - JSONObject jsonObject = (JSONObject)JSONValue.parse(response); - - ConnectionBean connectionBean = new ConnectionBean(); - connectionBean.restore(jsonObject); - - return connectionBean; - } - - public ValidationResultBean create(String serverUrl, MConnection connection) { - ConnectionBean connectionBean = new ConnectionBean(connection); - - // Extract all form inputs including sensitive inputs - JSONObject connectionJson = connectionBean.extract(false); - - String response = super.post(serverUrl + RESOURCE, connectionJson.toJSONString()); - - ValidationResultBean validationBean = new ValidationResultBean(); - validationBean.restore((JSONObject) JSONValue.parse(response)); - - return validationBean; - } - - public ValidationResultBean update(String serverUrl, MConnection connection) { - ConnectionBean connectionBean = new ConnectionBean(connection); - - // Extract all form inputs including sensitive inputs - JSONObject connectionJson = connectionBean.extract(false); - - String response = super.put(serverUrl + RESOURCE + connection.getPersistenceId(), connectionJson.toJSONString()); - - ValidationResultBean validationBean = new ValidationResultBean(); - validationBean.restore((JSONObject) JSONValue.parse(response)); - - return validationBean; - } - - public void delete(String serverUrl, Long id) { - super.delete(serverUrl + RESOURCE + id); - } - - public void enable(String serverUrl, Long id, Boolean enabled) { - if (enabled) { - super.put(serverUrl + RESOURCE + id + ENABLE, null); - } else { - super.put(serverUrl + RESOURCE + id + DISABLE, null); - } - } -} http://git-wip-us.apache.org/repos/asf/sqoop/blob/049994a0/client/src/main/java/org/apache/sqoop/client/request/ConnectorRequest.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/sqoop/client/request/ConnectorRequest.java b/client/src/main/java/org/apache/sqoop/client/request/ConnectorRequest.java deleted file mode 100644 index 876099c..0000000 --- a/client/src/main/java/org/apache/sqoop/client/request/ConnectorRequest.java +++ /dev/null @@ -1,47 +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.client.request; - -import org.apache.sqoop.json.ConnectorBean; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; - -/** - * Provide cRud semantics over RESTfull HTTP API for connectors. Only read - * is supported as creation, update and delete might be done only directly on - * server side. - */ -public class ConnectorRequest extends Request -{ - public static final String RESOURCE = "v1/connector/"; - - public ConnectorBean read(String serverUrl, Long cid) { - String response; - if (cid == null) { - response = super.get(serverUrl + RESOURCE + "all"); - } else { - response = super.get(serverUrl + RESOURCE + cid); - } - JSONObject jsonObject = (JSONObject)JSONValue.parse(response); - - ConnectorBean connectorBean = new ConnectorBean(); - connectorBean.restore(jsonObject); - - return connectorBean; - } -} http://git-wip-us.apache.org/repos/asf/sqoop/blob/049994a0/client/src/main/java/org/apache/sqoop/client/request/ConnectorResourceRequest.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/sqoop/client/request/ConnectorResourceRequest.java b/client/src/main/java/org/apache/sqoop/client/request/ConnectorResourceRequest.java new file mode 100644 index 0000000..2855de6 --- /dev/null +++ b/client/src/main/java/org/apache/sqoop/client/request/ConnectorResourceRequest.java @@ -0,0 +1,47 @@ +/** + * 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.client.request; + +import org.apache.sqoop.json.ConnectorBean; +import org.json.simple.JSONObject; +import org.json.simple.JSONValue; + +/** + * Provide cRud semantics over RESTfull HTTP API for connectors. Only read + * is supported as creation, update and delete might be done only directly on + * server side. + */ +public class ConnectorResourceRequest extends ResourceRequest +{ + public static final String RESOURCE = "v1/connector/"; + + public ConnectorBean read(String serverUrl, Long cid) { + String response; + if (cid == null) { + response = super.get(serverUrl + RESOURCE + "all"); + } else { + response = super.get(serverUrl + RESOURCE + cid); + } + JSONObject jsonObject = (JSONObject)JSONValue.parse(response); + + ConnectorBean connectorBean = new ConnectorBean(); + connectorBean.restore(jsonObject); + + return connectorBean; + } +} http://git-wip-us.apache.org/repos/asf/sqoop/blob/049994a0/client/src/main/java/org/apache/sqoop/client/request/DriverConfigResourceRequest.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/sqoop/client/request/DriverConfigResourceRequest.java b/client/src/main/java/org/apache/sqoop/client/request/DriverConfigResourceRequest.java new file mode 100644 index 0000000..7b2ddc2 --- /dev/null +++ b/client/src/main/java/org/apache/sqoop/client/request/DriverConfigResourceRequest.java @@ -0,0 +1,42 @@ +/** + * 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.client.request; + +import org.apache.sqoop.json.DriverConfigBean; +import org.json.simple.JSONObject; +import org.json.simple.JSONValue; + +/** + * Provide cRud semantics over RESTfull HTTP API for driverConfig. Only read + * is supported as creation, update and delete is not allowed. + */ +public class DriverConfigResourceRequest extends ResourceRequest { + + public static final String RESOURCE = "v1/config/driver"; + + public DriverConfigBean read(String serverUrl) { + String response = null; + response = super.get(serverUrl + RESOURCE); + JSONObject jsonObject = (JSONObject) JSONValue.parse(response); + + DriverConfigBean driverConfigBean = new DriverConfigBean(); + driverConfigBean.restore(jsonObject); + + return driverConfigBean; + } +} http://git-wip-us.apache.org/repos/asf/sqoop/blob/049994a0/client/src/main/java/org/apache/sqoop/client/request/FrameworkRequest.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/sqoop/client/request/FrameworkRequest.java b/client/src/main/java/org/apache/sqoop/client/request/FrameworkRequest.java deleted file mode 100644 index 06f9006..0000000 --- a/client/src/main/java/org/apache/sqoop/client/request/FrameworkRequest.java +++ /dev/null @@ -1,42 +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.client.request; - -import org.apache.sqoop.json.FrameworkBean; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; - -/** - * Provide cRud semantics over RESTfull HTTP API for framework. Only read - * is supported as creation, update and delete is not allowed. - */ -public class FrameworkRequest extends Request { - - public static final String RESOURCE = "v1/framework"; - - public FrameworkBean read(String serverUrl) { - String response = null; - response = super.get(serverUrl + RESOURCE); - JSONObject jsonObject = (JSONObject) JSONValue.parse(response); - - FrameworkBean frameworkBean = new FrameworkBean(); - frameworkBean.restore(jsonObject); - - return frameworkBean; - } -} http://git-wip-us.apache.org/repos/asf/sqoop/blob/049994a0/client/src/main/java/org/apache/sqoop/client/request/JobRequest.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/sqoop/client/request/JobRequest.java b/client/src/main/java/org/apache/sqoop/client/request/JobRequest.java deleted file mode 100644 index e520883..0000000 --- a/client/src/main/java/org/apache/sqoop/client/request/JobRequest.java +++ /dev/null @@ -1,91 +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.client.request; - -import org.apache.sqoop.json.JobBean; -import org.apache.sqoop.json.ValidationResultBean; -import org.apache.sqoop.model.MJob; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; - -/** - * Provide CRUD semantics over RESTfull HTTP API for jobs. All operations - * are normally supported. - */ -public class JobRequest extends Request { - - public static final String RESOURCE = "v1/job/"; - - private static final String ENABLE = "/enable"; - private static final String DISABLE = "/disable"; - - public JobBean read(String serverUrl, Long xid) { - String response; - if (xid == null) { - response = super.get(serverUrl + RESOURCE + "all"); - } else { - response = super.get(serverUrl + RESOURCE + xid); - } - JSONObject jsonObject = (JSONObject) JSONValue.parse(response); - - JobBean jobBean = new JobBean(); - jobBean.restore(jsonObject); - - return jobBean; - } - - public ValidationResultBean create(String serverUrl, MJob job) { - JobBean jobBean = new JobBean(job); - - // Extract all form inputs including sensitive inputs - JSONObject jobJson = jobBean.extract(false); - - String response = super.post(serverUrl + RESOURCE, jobJson.toJSONString()); - - ValidationResultBean validationBean = new ValidationResultBean(); - validationBean.restore((JSONObject) JSONValue.parse(response)); - - return validationBean; - } - - public ValidationResultBean update(String serverUrl, MJob job) { - JobBean jobBean = new JobBean(job); - - // Extract all form inputs including sensitive inputs - JSONObject jobJson = jobBean.extract(false); - - String response = super.put(serverUrl + RESOURCE + job.getPersistenceId(), jobJson.toJSONString()); - - ValidationResultBean validationBean = new ValidationResultBean(); - validationBean.restore((JSONObject) JSONValue.parse(response)); - - return validationBean; - } - - public void delete(String serverUrl, Long id) { - super.delete(serverUrl + RESOURCE + id); - } - - public void enable(String serverUrl, Long id, Boolean enabled) { - if (enabled) { - super.put(serverUrl + RESOURCE + id + ENABLE, null); - } else { - super.put(serverUrl + RESOURCE + id + DISABLE, null); - } - } -} http://git-wip-us.apache.org/repos/asf/sqoop/blob/049994a0/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 new file mode 100644 index 0000000..fd858ec --- /dev/null +++ b/client/src/main/java/org/apache/sqoop/client/request/JobResourceRequest.java @@ -0,0 +1,91 @@ +/** + * 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.client.request; + +import org.apache.sqoop.json.JobBean; +import org.apache.sqoop.json.ValidationResultBean; +import org.apache.sqoop.model.MJob; +import org.json.simple.JSONObject; +import org.json.simple.JSONValue; + +/** + * Provide CRUD semantics over RESTfull HTTP API for jobs. All operations + * are normally supported. + */ +public class JobResourceRequest extends ResourceRequest { + + public static final String RESOURCE = "v1/job/"; + + private static final String ENABLE = "/enable"; + private static final String DISABLE = "/disable"; + + public JobBean read(String serverUrl, Long xid) { + String response; + if (xid == null) { + response = super.get(serverUrl + RESOURCE + "all"); + } else { + response = super.get(serverUrl + RESOURCE + xid); + } + JSONObject jsonObject = (JSONObject) JSONValue.parse(response); + + JobBean jobBean = new JobBean(); + jobBean.restore(jsonObject); + + return jobBean; + } + + public ValidationResultBean create(String serverUrl, MJob job) { + JobBean jobBean = new JobBean(job); + + // Extract all form inputs including sensitive inputs + JSONObject jobJson = jobBean.extract(false); + + String response = super.post(serverUrl + RESOURCE, jobJson.toJSONString()); + + ValidationResultBean validationBean = new ValidationResultBean(); + validationBean.restore((JSONObject) JSONValue.parse(response)); + + return validationBean; + } + + public ValidationResultBean update(String serverUrl, MJob job) { + JobBean jobBean = new JobBean(job); + + // Extract all form inputs including sensitive inputs + JSONObject jobJson = jobBean.extract(false); + + String response = super.put(serverUrl + RESOURCE + job.getPersistenceId(), jobJson.toJSONString()); + + ValidationResultBean validationBean = new ValidationResultBean(); + validationBean.restore((JSONObject) JSONValue.parse(response)); + + return validationBean; + } + + public void delete(String serverUrl, Long id) { + super.delete(serverUrl + RESOURCE + id); + } + + public void enable(String serverUrl, Long id, Boolean enabled) { + if (enabled) { + super.put(serverUrl + RESOURCE + id + ENABLE, null); + } else { + super.put(serverUrl + RESOURCE + id + DISABLE, null); + } + } +} http://git-wip-us.apache.org/repos/asf/sqoop/blob/049994a0/client/src/main/java/org/apache/sqoop/client/request/LinkResourceRequest.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/sqoop/client/request/LinkResourceRequest.java b/client/src/main/java/org/apache/sqoop/client/request/LinkResourceRequest.java new file mode 100644 index 0000000..2b784c8 --- /dev/null +++ b/client/src/main/java/org/apache/sqoop/client/request/LinkResourceRequest.java @@ -0,0 +1,89 @@ +/** + * 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.client.request; + +import org.apache.sqoop.json.LinkBean; +import org.apache.sqoop.json.ValidationResultBean; +import org.apache.sqoop.model.MLink; +import org.json.simple.JSONObject; +import org.json.simple.JSONValue; + +/** + * Provide CRUD semantics over RESTfull HTTP API for links. All operations + * are normally supported. + */ +public class LinkResourceRequest extends ResourceRequest { + + public static final String RESOURCE = "v1/link/"; + + private static final String ENABLE = "/enable"; + private static final String DISABLE = "/disable"; + + public LinkBean read(String serverUrl, Long xid) { + String response; + if (xid == null) { + response = super.get(serverUrl + RESOURCE + "all"); + } else { + response = super.get(serverUrl + RESOURCE + xid); + } + JSONObject jsonObject = (JSONObject)JSONValue.parse(response); + LinkBean linkBean = new LinkBean(); + linkBean.restore(jsonObject); + return linkBean; + } + + public ValidationResultBean create(String serverUrl, MLink link) { + LinkBean linkBean = new LinkBean(link); + + // Extract all form inputs including sensitive inputs + JSONObject linkJson = linkBean.extract(false); + + String response = super.post(serverUrl + RESOURCE, linkJson.toJSONString()); + + ValidationResultBean validationBean = new ValidationResultBean(); + validationBean.restore((JSONObject) JSONValue.parse(response)); + + return validationBean; + } + + public ValidationResultBean update(String serverUrl, MLink link) { + LinkBean linkBean = new LinkBean(link); + + // Extract all form inputs including sensitive inputs + JSONObject linkJson = linkBean.extract(false); + + String response = super.put(serverUrl + RESOURCE + link.getPersistenceId(), linkJson.toJSONString()); + + ValidationResultBean validationBean = new ValidationResultBean(); + validationBean.restore((JSONObject) JSONValue.parse(response)); + + return validationBean; + } + + public void delete(String serverUrl, Long id) { + super.delete(serverUrl + RESOURCE + id); + } + + public void enable(String serverUrl, Long id, Boolean enabled) { + if (enabled) { + super.put(serverUrl + RESOURCE + id + ENABLE, null); + } else { + super.put(serverUrl + RESOURCE + id + DISABLE, null); + } + } +} http://git-wip-us.apache.org/repos/asf/sqoop/blob/049994a0/client/src/main/java/org/apache/sqoop/client/request/Request.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/sqoop/client/request/Request.java b/client/src/main/java/org/apache/sqoop/client/request/Request.java deleted file mode 100644 index d9229f5..0000000 --- a/client/src/main/java/org/apache/sqoop/client/request/Request.java +++ /dev/null @@ -1,110 +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.client.request; - -import javax.ws.rs.core.MediaType; - -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientRequest; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.client.WebResource.Builder; -import com.sun.jersey.api.client.filter.ClientFilter; - -import org.apache.sqoop.client.ClientError; -import org.apache.sqoop.common.SqoopException; -import org.apache.sqoop.common.SqoopProtocolConstants; -import org.apache.sqoop.json.ThrowableBean; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; - -import java.util.Locale; - -public class Request -{ - private static ServerExceptionFilter serverExceptionFilter; - - static { - serverExceptionFilter = new ServerExceptionFilter(); - } - - protected Builder getBuilder(String url) { - Client client = Client.create(); - WebResource resource = client.resource(url); - - // Provide filter that will rebuild exception that is sent from server - resource.addFilter(serverExceptionFilter); - - return resource - // Provide name of user executing request. - .header(SqoopProtocolConstants.HEADER_SQOOP_USERNAME, System.getProperty("user.name")) - // Sqoop is using JSON for data transfers - .accept(MediaType.APPLICATION_JSON_TYPE) - // Transfer client locale to return client specific data - .acceptLanguage(Locale.getDefault()); - } - - public String get(String url) { - return getBuilder(url).get(String.class); - } - - public String post(String url, String data) { - return getBuilder(url).post(String.class, data); - } - - public String put(String url, String data) { - return getBuilder(url).put(String.class, data); - } - - public String delete(String url) { - return getBuilder(url).delete(String.class); - } - - /** - * Client filter to intercepting exceptions sent by sqoop server and - * recreating them on client side. Current implementation will create new - * instance of SqoopException and will attach original error code and message. - */ - private static class ServerExceptionFilter extends ClientFilter { - @Override - public ClientResponse handle(ClientRequest cr) { - ClientResponse resp = getNext().handle(cr); - - // Special handling for 500 internal server error in case that server - // has sent us it's exception correctly. We're using default route - // for all other 500 occurrences. - if(resp.getClientResponseStatus() - == ClientResponse.Status.INTERNAL_SERVER_ERROR) { - - if(resp.getHeaders().containsKey( - SqoopProtocolConstants.HEADER_SQOOP_INTERNAL_ERROR_CODE)) { - - ThrowableBean ex = new ThrowableBean(); - - String responseText = resp.getEntity(String.class); - JSONObject json = (JSONObject) JSONValue.parse(responseText); - ex.restore(json); - - throw new SqoopException(ClientError.CLIENT_0001, ex.getThrowable()); - } - } - - return resp; - } - } -} http://git-wip-us.apache.org/repos/asf/sqoop/blob/049994a0/client/src/main/java/org/apache/sqoop/client/request/ResourceRequest.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/sqoop/client/request/ResourceRequest.java b/client/src/main/java/org/apache/sqoop/client/request/ResourceRequest.java new file mode 100644 index 0000000..c84a83e --- /dev/null +++ b/client/src/main/java/org/apache/sqoop/client/request/ResourceRequest.java @@ -0,0 +1,113 @@ +/** + * 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.client.request; + +import javax.ws.rs.core.MediaType; + +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientRequest; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.api.client.WebResource.Builder; +import com.sun.jersey.api.client.filter.ClientFilter; + +import org.apache.sqoop.client.ClientError; +import org.apache.sqoop.common.SqoopException; +import org.apache.sqoop.common.SqoopProtocolConstants; +import org.apache.sqoop.json.ThrowableBean; +import org.json.simple.JSONObject; +import org.json.simple.JSONValue; + +import java.util.Locale; +/** + * Represents the sqoop REST resource requests + * + */ +public class ResourceRequest +{ + private static ServerExceptionFilter serverExceptionFilter; + + static { + serverExceptionFilter = new ServerExceptionFilter(); + } + + protected Builder getBuilder(String url) { + Client client = Client.create(); + WebResource resource = client.resource(url); + + // Provide filter that will rebuild exception that is sent from server + resource.addFilter(serverExceptionFilter); + + return resource + // Provide name of user executing request. + .header(SqoopProtocolConstants.HEADER_SQOOP_USERNAME, System.getProperty("user.name")) + // Sqoop is using JSON for data transfers + .accept(MediaType.APPLICATION_JSON_TYPE) + // Transfer client locale to return client specific data + .acceptLanguage(Locale.getDefault()); + } + + public String get(String url) { + return getBuilder(url).get(String.class); + } + + public String post(String url, String data) { + return getBuilder(url).post(String.class, data); + } + + public String put(String url, String data) { + return getBuilder(url).put(String.class, data); + } + + public String delete(String url) { + return getBuilder(url).delete(String.class); + } + + /** + * Client filter to intercepting exceptions sent by sqoop server and + * recreating them on client side. Current implementation will create new + * instance of SqoopException and will attach original error code and message. + */ + private static class ServerExceptionFilter extends ClientFilter { + @Override + public ClientResponse handle(ClientRequest cr) { + ClientResponse resp = getNext().handle(cr); + + // Special handling for 500 internal server error in case that server + // has sent us it's exception correctly. We're using default route + // for all other 500 occurrences. + if(resp.getClientResponseStatus() + == ClientResponse.Status.INTERNAL_SERVER_ERROR) { + + if(resp.getHeaders().containsKey( + SqoopProtocolConstants.HEADER_SQOOP_INTERNAL_ERROR_CODE)) { + + ThrowableBean ex = new ThrowableBean(); + + String responseText = resp.getEntity(String.class); + JSONObject json = (JSONObject) JSONValue.parse(responseText); + ex.restore(json); + + throw new SqoopException(ClientError.CLIENT_0001, ex.getThrowable()); + } + } + + return resp; + } + } +} http://git-wip-us.apache.org/repos/asf/sqoop/blob/049994a0/client/src/main/java/org/apache/sqoop/client/request/SqoopRequests.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/sqoop/client/request/SqoopRequests.java b/client/src/main/java/org/apache/sqoop/client/request/SqoopRequests.java deleted file mode 100644 index 0d13304..0000000 --- a/client/src/main/java/org/apache/sqoop/client/request/SqoopRequests.java +++ /dev/null @@ -1,149 +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.client.request; - -import org.apache.sqoop.json.ConnectionBean; -import org.apache.sqoop.json.ConnectorBean; -import org.apache.sqoop.json.FrameworkBean; -import org.apache.sqoop.json.JobBean; -import org.apache.sqoop.json.SubmissionBean; -import org.apache.sqoop.json.ValidationResultBean; -import org.apache.sqoop.model.MConnection; -import org.apache.sqoop.model.MJob; - -/** - * Unified class for all request objects. - */ -public class SqoopRequests { - - private String serverUrl; - - private FrameworkRequest frameworkRequest; - private ConnectorRequest connectorRequest; - private ConnectionRequest connectionRequest; - private JobRequest jobRequest; - private SubmissionRequest submissionRequest; - - public void setServerUrl(String serverUrl) { - this.serverUrl = serverUrl; - } - - public FrameworkRequest getFrameworkRequest() { - if (frameworkRequest == null) { - frameworkRequest = new FrameworkRequest(); - } - - return frameworkRequest; - } - - public ConnectorRequest getConnectorRequest() { - if (connectorRequest == null) { - connectorRequest = new ConnectorRequest(); - } - - return connectorRequest; - } - - public ConnectionRequest getConnectionRequest() { - if (connectionRequest == null) { - connectionRequest = new ConnectionRequest(); - } - - return connectionRequest; - } - - public JobRequest getJobRequest() { - if (jobRequest == null) { - jobRequest = new JobRequest(); - } - - return jobRequest; - } - - public SubmissionRequest getSubmissionRequest() { - if (submissionRequest == null) { - submissionRequest = new SubmissionRequest(); - } - - return submissionRequest; - } - - public FrameworkBean readFramework() { - return getFrameworkRequest().read(serverUrl); - } - - public ConnectorBean readConnector(Long cid) { - return getConnectorRequest().read(serverUrl, cid); - } - - public ValidationResultBean createConnection(MConnection connection) { - return getConnectionRequest().create(serverUrl, connection); - } - - public ConnectionBean readConnection(Long connectionId) { - return getConnectionRequest().read(serverUrl, connectionId); - } - - public ValidationResultBean updateConnection(MConnection connection) { - return getConnectionRequest().update(serverUrl, connection); - } - - public void enableConnection(Long xid, Boolean enabled) { - getConnectionRequest().enable(serverUrl, xid, enabled); - } - - public void deleteConnection(Long xid) { - getConnectionRequest().delete(serverUrl, xid); - } - - public ValidationResultBean createJob(MJob job) { - return getJobRequest().create(serverUrl, job); - } - - public JobBean readJob(Long jobId) { - return getJobRequest().read(serverUrl, jobId); - } - - public ValidationResultBean updateJob(MJob job) { - return getJobRequest().update(serverUrl, job); - } - - public void enableJob(Long jid, Boolean enabled) { - getJobRequest().enable(serverUrl, jid, enabled); - } - - public void deleteJob(Long jid) { - getJobRequest().delete(serverUrl, jid); - } - - public SubmissionBean readHistory(Long jid) { - return getSubmissionRequest().readHistory(serverUrl, jid); - } - - public SubmissionBean readSubmission(Long jid) { - return getSubmissionRequest().read(serverUrl, jid); - } - - public SubmissionBean createSubmission(Long jid) { - return getSubmissionRequest().create(serverUrl, jid); - } - - public SubmissionBean deleteSubmission(Long jid) { - return getSubmissionRequest().delete(serverUrl, jid); - } -} http://git-wip-us.apache.org/repos/asf/sqoop/blob/049994a0/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 new file mode 100644 index 0000000..5401eca --- /dev/null +++ b/client/src/main/java/org/apache/sqoop/client/request/SqoopResourceRequests.java @@ -0,0 +1,149 @@ +/** + * 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.client.request; + +import org.apache.sqoop.json.LinkBean; +import org.apache.sqoop.json.ConnectorBean; +import org.apache.sqoop.json.DriverConfigBean; +import org.apache.sqoop.json.JobBean; +import org.apache.sqoop.json.SubmissionBean; +import org.apache.sqoop.json.ValidationResultBean; +import org.apache.sqoop.model.MLink; +import org.apache.sqoop.model.MJob; + +/** + * Unified class for all request objects. + */ +public class SqoopResourceRequests { + + private String serverUrl; + + private DriverConfigResourceRequest driverConfigRequest; + private ConnectorResourceRequest connectorRequest; + private LinkResourceRequest linkRequest; + private JobResourceRequest jobRequest; + private SubmissionResourceRequest submissionRequest; + + public void setServerUrl(String serverUrl) { + this.serverUrl = serverUrl; + } + + public DriverConfigResourceRequest getDriverConfigResourceRequest() { + if (driverConfigRequest == null) { + driverConfigRequest = new DriverConfigResourceRequest(); + } + + return driverConfigRequest; + } + + public ConnectorResourceRequest getConnectorResourceRequest() { + if (connectorRequest == null) { + connectorRequest = new ConnectorResourceRequest(); + } + + return connectorRequest; + } + + public LinkResourceRequest getLinkResourceRequest() { + if (linkRequest == null) { + linkRequest = new LinkResourceRequest(); + } + + return linkRequest; + } + + public JobResourceRequest getJobResourceRequest() { + if (jobRequest == null) { + jobRequest = new JobResourceRequest(); + } + + return jobRequest; + } + + public SubmissionResourceRequest getSubmissionResourceRequest() { + if (submissionRequest == null) { + submissionRequest = new SubmissionResourceRequest(); + } + + return submissionRequest; + } + + public DriverConfigBean readDriverConfig() { + return getDriverConfigResourceRequest().read(serverUrl); + } + + public ConnectorBean readConnector(Long cid) { + return getConnectorResourceRequest().read(serverUrl, cid); + } + + public ValidationResultBean saveLink(MLink link) { + return getLinkResourceRequest().create(serverUrl, link); + } + + public LinkBean readLink(Long linkId) { + return getLinkResourceRequest().read(serverUrl, linkId); + } + + public ValidationResultBean updateLink(MLink link) { + return getLinkResourceRequest().update(serverUrl, link); + } + + public void enableLink(Long lid, Boolean enabled) { + getLinkResourceRequest().enable(serverUrl, lid, enabled); + } + + public void deleteLink(Long lid) { + getLinkResourceRequest().delete(serverUrl, lid); + } + + public ValidationResultBean saveJob(MJob job) { + return getJobResourceRequest().create(serverUrl, job); + } + + public JobBean readJob(Long jobId) { + return getJobResourceRequest().read(serverUrl, jobId); + } + + public ValidationResultBean updateJob(MJob job) { + return getJobResourceRequest().update(serverUrl, job); + } + + public void enableJob(Long jid, Boolean enabled) { + getJobResourceRequest().enable(serverUrl, jid, enabled); + } + + public void deleteJob(Long jid) { + getJobResourceRequest().delete(serverUrl, jid); + } + + public SubmissionBean readHistory(Long jid) { + return getSubmissionResourceRequest().readHistory(serverUrl, jid); + } + + public SubmissionBean readSubmission(Long jid) { + return getSubmissionResourceRequest().read(serverUrl, jid); + } + + public SubmissionBean createSubmission(Long jid) { + return getSubmissionResourceRequest().create(serverUrl, jid); + } + + public SubmissionBean deleteSubmission(Long jid) { + return getSubmissionResourceRequest().delete(serverUrl, jid); + } +} http://git-wip-us.apache.org/repos/asf/sqoop/blob/049994a0/client/src/main/java/org/apache/sqoop/client/request/SubmissionRequest.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/sqoop/client/request/SubmissionRequest.java b/client/src/main/java/org/apache/sqoop/client/request/SubmissionRequest.java deleted file mode 100644 index bafb30f..0000000 --- a/client/src/main/java/org/apache/sqoop/client/request/SubmissionRequest.java +++ /dev/null @@ -1,80 +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.client.request; - -import org.apache.sqoop.json.SubmissionBean; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; - -/** - * Provide CRD semantics over RESTfull HTTP API for submissions. Please note - * that "update" is not supported as client can't update submission status. - */ -public class SubmissionRequest extends Request { - - public static final String RESOURCE = "v1/submission/"; - - public static final String ACTION = RESOURCE + "action/"; - - public static final String HISTORY = RESOURCE + "history/"; - - public SubmissionBean readHistory(String serverUrl, Long jid) { - String response; - if (jid == null) { - response = super.get(serverUrl + HISTORY + "all"); - } else { - response = super.get(serverUrl + HISTORY + jid); - } - - JSONObject jsonObject = (JSONObject) JSONValue.parse(response); - - SubmissionBean submissionBean = new SubmissionBean(); - submissionBean.restore(jsonObject); - - return submissionBean; - } - - public SubmissionBean read(String serverUrl, Long jid) { - String response = super.get(serverUrl + ACTION + jid); - - JSONObject jsonObject = (JSONObject) JSONValue.parse(response); - - SubmissionBean submissionBean = new SubmissionBean(); - submissionBean.restore(jsonObject); - - return submissionBean; - } - - public SubmissionBean create(String serverUrl, Long jid) { - String response = super.post(serverUrl + ACTION + jid, null); - - SubmissionBean submissionBean = new SubmissionBean(); - submissionBean.restore((JSONObject) JSONValue.parse(response)); - - return submissionBean; - } - - public SubmissionBean delete(String serverUrl, Long id) { - String response = super.delete(serverUrl + ACTION + id); - - SubmissionBean submissionBean = new SubmissionBean(); - submissionBean.restore((JSONObject) JSONValue.parse(response)); - - return submissionBean; - } -} http://git-wip-us.apache.org/repos/asf/sqoop/blob/049994a0/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 new file mode 100644 index 0000000..5055783 --- /dev/null +++ b/client/src/main/java/org/apache/sqoop/client/request/SubmissionResourceRequest.java @@ -0,0 +1,80 @@ +/** + * 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.client.request; + +import org.apache.sqoop.json.SubmissionBean; +import org.json.simple.JSONObject; +import org.json.simple.JSONValue; + +/** + * Provide CRD semantics over RESTfull HTTP API for submissions. Please note + * that "update" is not supported as client can't update submission status. + */ +public class SubmissionResourceRequest extends ResourceRequest { + + public static final String RESOURCE = "v1/submission/"; + + public static final String ACTION = RESOURCE + "action/"; + + public static final String HISTORY = RESOURCE + "history/"; + + public SubmissionBean readHistory(String serverUrl, Long jid) { + String response; + if (jid == null) { + response = super.get(serverUrl + HISTORY + "all"); + } else { + response = super.get(serverUrl + HISTORY + jid); + } + + JSONObject jsonObject = (JSONObject) JSONValue.parse(response); + + SubmissionBean submissionBean = new SubmissionBean(); + submissionBean.restore(jsonObject); + + return submissionBean; + } + + public SubmissionBean read(String serverUrl, Long jid) { + String response = super.get(serverUrl + ACTION + jid); + + JSONObject jsonObject = (JSONObject) JSONValue.parse(response); + + SubmissionBean submissionBean = new SubmissionBean(); + submissionBean.restore(jsonObject); + + return submissionBean; + } + + public SubmissionBean create(String serverUrl, Long jid) { + String response = super.post(serverUrl + ACTION + jid, null); + + SubmissionBean submissionBean = new SubmissionBean(); + submissionBean.restore((JSONObject) JSONValue.parse(response)); + + return submissionBean; + } + + public SubmissionBean delete(String serverUrl, Long id) { + String response = super.delete(serverUrl + ACTION + id); + + SubmissionBean submissionBean = new SubmissionBean(); + submissionBean.restore((JSONObject) JSONValue.parse(response)); + + return submissionBean; + } +} http://git-wip-us.apache.org/repos/asf/sqoop/blob/049994a0/client/src/main/java/org/apache/sqoop/client/request/VersionRequest.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/sqoop/client/request/VersionRequest.java b/client/src/main/java/org/apache/sqoop/client/request/VersionRequest.java deleted file mode 100644 index 2b236ba..0000000 --- a/client/src/main/java/org/apache/sqoop/client/request/VersionRequest.java +++ /dev/null @@ -1,35 +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.client.request; - -import org.apache.sqoop.json.VersionBean; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; - -public class VersionRequest extends Request -{ - public VersionBean doGet(String serverUrl) { - String response = super.get(serverUrl + "version"); - JSONObject jsonObject = (JSONObject)JSONValue.parse(response); - - VersionBean versionBean = new VersionBean(); - versionBean.restore(jsonObject); - - return versionBean; - } -} http://git-wip-us.apache.org/repos/asf/sqoop/blob/049994a0/client/src/main/java/org/apache/sqoop/client/request/VersionResourceRequest.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/sqoop/client/request/VersionResourceRequest.java b/client/src/main/java/org/apache/sqoop/client/request/VersionResourceRequest.java new file mode 100644 index 0000000..cdd2a9b --- /dev/null +++ b/client/src/main/java/org/apache/sqoop/client/request/VersionResourceRequest.java @@ -0,0 +1,35 @@ +/** + * 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.client.request; + +import org.apache.sqoop.json.VersionBean; +import org.json.simple.JSONObject; +import org.json.simple.JSONValue; + +public class VersionResourceRequest extends ResourceRequest +{ + public VersionBean read(String serverUrl) { + String response = super.get(serverUrl + "version"); + JSONObject jsonObject = (JSONObject)JSONValue.parse(response); + + VersionBean versionBean = new VersionBean(); + versionBean.restore(jsonObject); + + return versionBean; + } +}