├── .gitattributes ├── .gitignore ├── CHANGELOG.txt ├── LICENSE.txt ├── NOTICE.txt ├── README.txt ├── client ├── pom.xml └── src │ └── main │ ├── java │ └── org │ │ └── apache │ │ └── sqoop │ │ └── client │ │ ├── core │ │ ├── ClientError.java │ │ ├── Constants.java │ │ ├── Environment.java │ │ └── RequestCache.java │ │ ├── request │ │ ├── ConnectionRequest.java │ │ ├── ConnectorRequest.java │ │ ├── FrameworkRequest.java │ │ ├── JobRequest.java │ │ ├── Request.java │ │ ├── SubmissionRequest.java │ │ └── VersionRequest.java │ │ ├── shell │ │ ├── CloneCommand.java │ │ ├── CloneConnectionFunction.java │ │ ├── CloneJobFunction.java │ │ ├── CreateCommand.java │ │ ├── CreateConnectionFunction.java │ │ ├── CreateJobFunction.java │ │ ├── DeleteCommand.java │ │ ├── DeleteConnectionFunction.java │ │ ├── DeleteJobFunction.java │ │ ├── HelpCommand.java │ │ ├── SetCommand.java │ │ ├── SetOptionFunction.java │ │ ├── SetServerFunction.java │ │ ├── ShowCommand.java │ │ ├── ShowConnectionFunction.java │ │ ├── ShowConnectorFunction.java │ │ ├── ShowFrameworkFunction.java │ │ ├── ShowJobFunction.java │ │ ├── ShowOptionFunction.java │ │ ├── ShowServerFunction.java │ │ ├── ShowVersionFunction.java │ │ ├── SqoopCommand.java │ │ ├── SqoopFunction.java │ │ ├── SqoopShell.java │ │ ├── SubmissionCommand.java │ │ ├── SubmissionStartFunction.java │ │ ├── SubmissionStatusFunction.java │ │ ├── SubmissionStopFunction.java │ │ ├── UpdateCommand.java │ │ ├── UpdateConnectionFunction.java │ │ └── UpdateJobFunction.java │ │ └── utils │ │ ├── FormDisplayer.java │ │ ├── FormFiller.java │ │ ├── SubmissionDisplayer.java │ │ └── ThrowableDisplayer.java │ └── resources │ ├── client-resource.properties │ └── log4j.properties ├── common ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── apache │ │ └── sqoop │ │ ├── common │ │ ├── ErrorCode.java │ │ ├── ImmutableContext.java │ │ ├── MapContext.java │ │ ├── MutableContext.java │ │ ├── MutableMapContext.java │ │ ├── SqoopException.java │ │ ├── SqoopProtocolConstants.java │ │ ├── SqoopResponseCode.java │ │ ├── VersionAnnotation.java │ │ └── VersionInfo.java │ │ ├── json │ │ ├── ConnectionBean.java │ │ ├── ConnectorBean.java │ │ ├── FrameworkBean.java │ │ ├── JobBean.java │ │ ├── JsonBean.java │ │ ├── SubmissionBean.java │ │ ├── ThrowableBean.java │ │ ├── ValidationBean.java │ │ ├── VersionBean.java │ │ └── util │ │ │ ├── FormSerialization.java │ │ │ └── ResourceBundleSerialization.java │ │ ├── model │ │ ├── ConfigurationClass.java │ │ ├── Form.java │ │ ├── FormClass.java │ │ ├── FormUtils.java │ │ ├── Input.java │ │ ├── MAccountableEntity.java │ │ ├── MConnection.java │ │ ├── MConnectionForms.java │ │ ├── MConnector.java │ │ ├── MEnumInput.java │ │ ├── MForm.java │ │ ├── MFormType.java │ │ ├── MFramework.java │ │ ├── MInput.java │ │ ├── MInputType.java │ │ ├── MIntegerInput.java │ │ ├── MJob.java │ │ ├── MJobForms.java │ │ ├── MMapInput.java │ │ ├── MNamedElement.java │ │ ├── MPersistableEntity.java │ │ ├── MStringInput.java │ │ ├── MSubmission.java │ │ ├── MValidatedElement.java │ │ └── ModelError.java │ │ ├── submission │ │ ├── SubmissionStatus.java │ │ └── counter │ │ │ ├── Counter.java │ │ │ ├── CounterGroup.java │ │ │ ├── Counters.java │ │ │ └── SqoopCounters.java │ │ ├── utils │ │ ├── ClassUtils.java │ │ ├── ClassUtils.java.orig │ │ ├── MapResourceBundle.java │ │ ├── StringUtils.java │ │ └── UrlSafeUtils.java │ │ └── validation │ │ ├── Status.java │ │ ├── Validation.java │ │ └── ValidationError.java │ ├── saveVersion.sh │ └── test │ └── java │ └── org │ └── apache │ └── sqoop │ ├── common │ └── TestVersionInfo.java │ ├── json │ ├── TestConnectionBean.java │ ├── TestConnectorBean.java │ ├── TestFrameworkBean.java │ ├── TestJobBean.java │ ├── TestSubmissionBean.java │ ├── TestThrowableBean.java │ ├── TestUtil.java │ └── TestValidationBean.java │ ├── model │ ├── TestFormUtils.java │ ├── TestMFramework.java │ └── TestMPersistableEntity.java │ ├── utils │ ├── TestClassUtils.java │ ├── TestMapResourceBundle.java │ └── TestStringUtils.java │ └── validation │ └── TestStatus.java ├── connector ├── connector-generic-jdbc │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── org │ │ │ │ └── apache │ │ │ │ └── sqoop │ │ │ │ └── connector │ │ │ │ └── jdbc │ │ │ │ ├── GenericJdbcConnector.java │ │ │ │ ├── GenericJdbcConnectorConstants.java │ │ │ │ ├── GenericJdbcConnectorError.java │ │ │ │ ├── GenericJdbcExecutor.java │ │ │ │ ├── GenericJdbcExportDestroyer.java │ │ │ │ ├── GenericJdbcExportInitializer.java │ │ │ │ ├── GenericJdbcExportLoader.java │ │ │ │ ├── GenericJdbcImportDestroyer.java │ │ │ │ ├── GenericJdbcImportExtractor.java │ │ │ │ ├── GenericJdbcImportInitializer.java │ │ │ │ ├── GenericJdbcImportPartition.java │ │ │ │ ├── GenericJdbcImportPartitioner.java │ │ │ │ ├── GenericJdbcValidator.java │ │ │ │ └── configuration │ │ │ │ ├── ConnectionConfiguration.java │ │ │ │ ├── ConnectionForm.java │ │ │ │ ├── ExportJobConfiguration.java │ │ │ │ ├── ExportTableForm.java │ │ │ │ ├── IgnoredForm.java │ │ │ │ ├── ImportJobConfiguration.java │ │ │ │ └── ImportTableForm.java │ │ └── resources │ │ │ ├── generic-jdbc-connector-resources.properties │ │ │ └── sqoopconnector.properties │ │ └── test │ │ └── java │ │ └── org │ │ └── apache │ │ └── sqoop │ │ └── connector │ │ └── jdbc │ │ ├── GenericJdbcTestConstants.java │ │ ├── TestExportInitializer.java │ │ ├── TestExportLoader.java │ │ ├── TestImportExtractor.java │ │ ├── TestImportInitializer.java │ │ └── TestImportPartitioner.java ├── connector-mysql-fastpath │ └── pom.xml ├── connector-mysql-jdbc │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── org │ │ │ └── apache │ │ │ └── sqoop │ │ │ └── connector │ │ │ └── mysqljdbc │ │ │ └── MySqlJdbcConnector.java │ │ └── resources │ │ └── sqoopconnector.properties └── pom.xml ├── core ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── apache │ │ │ └── sqoop │ │ │ ├── connector │ │ │ ├── ConnectorError.java │ │ │ ├── ConnectorHandler.java │ │ │ └── ConnectorManager.java │ │ │ ├── core │ │ │ ├── ConfigurationConstants.java │ │ │ ├── ConfigurationListener.java │ │ │ ├── ConfigurationProvider.java │ │ │ ├── CoreError.java │ │ │ ├── PropertiesConfigurationProvider.java │ │ │ └── SqoopConfiguration.java │ │ │ ├── framework │ │ │ ├── ExecutionEngine.java │ │ │ ├── FrameworkConstants.java │ │ │ ├── FrameworkError.java │ │ │ ├── FrameworkManager.java │ │ │ ├── SubmissionEngine.java │ │ │ ├── SubmissionRequest.java │ │ │ └── configuration │ │ │ │ ├── ConnectionConfiguration.java │ │ │ │ ├── ExportJobConfiguration.java │ │ │ │ ├── ImportJobConfiguration.java │ │ │ │ ├── InputForm.java │ │ │ │ ├── OutputForm.java │ │ │ │ ├── OutputFormat.java │ │ │ │ ├── SecurityForm.java │ │ │ │ ├── StorageType.java │ │ │ │ └── ThrottlingForm.java │ │ │ └── repository │ │ │ ├── JdbcRepository.java │ │ │ ├── JdbcRepositoryContext.java │ │ │ ├── JdbcRepositoryHandler.java │ │ │ ├── JdbcRepositoryProvider.java │ │ │ ├── JdbcRepositoryTransaction.java │ │ │ ├── JdbcRepositoryTransactionFactory.java │ │ │ ├── JdbcTransactionIsolation.java │ │ │ ├── RepoConfigurationConstants.java │ │ │ ├── Repository.java │ │ │ ├── RepositoryError.java │ │ │ ├── RepositoryManager.java │ │ │ ├── RepositoryProvider.java │ │ │ └── RepositoryTransaction.java │ └── resources │ │ └── framework-resources.properties │ └── test │ ├── java │ └── org │ │ └── apache │ │ └── sqoop │ │ ├── core │ │ ├── MockInvalidConfigurationProvider.java │ │ ├── TestConfiguration.java │ │ └── TestUtils.java │ │ └── repository │ │ └── TestRepositoryManager.java │ └── resources │ └── test_config.properties ├── dist ├── pom.xml └── src │ └── main │ ├── bin │ ├── addtowar.sh │ └── sqoop.sh │ └── server │ ├── bin │ ├── setenv.bat │ └── setenv.sh │ ├── conf │ ├── server.xml │ ├── sqoop.properties │ └── sqoop_bootstrap.properties │ └── webapps │ └── ROOT │ ├── WEB-INF │ └── web.xml │ └── index.html ├── docs ├── pom.xml └── src │ ├── main │ └── webapp │ │ ├── WEB-INF │ │ └── web.xml │ │ └── index.html │ └── site │ └── sphinx │ ├── CommandLineClient.rst │ ├── Installation.rst │ ├── Sqoop5MinutesDemo.rst │ ├── conf.py │ ├── index.rst │ └── sqoop-logo.png ├── execution ├── mapreduce │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── org │ │ │ └── apache │ │ │ └── sqoop │ │ │ ├── execution │ │ │ └── mapreduce │ │ │ │ ├── MRSubmissionRequest.java │ │ │ │ └── MapreduceExecutionEngine.java │ │ │ └── job │ │ │ ├── JobConstants.java │ │ │ ├── MapreduceExecutionError.java │ │ │ ├── PrefixContext.java │ │ │ ├── etl │ │ │ ├── HdfsExportPartition.java │ │ │ ├── HdfsExportPartitioner.java │ │ │ ├── HdfsSequenceExportExtractor.java │ │ │ ├── HdfsSequenceImportLoader.java │ │ │ ├── HdfsTextExportExtractor.java │ │ │ └── HdfsTextImportLoader.java │ │ │ ├── io │ │ │ ├── Data.java │ │ │ └── FieldTypes.java │ │ │ └── mr │ │ │ ├── ConfigurationUtils.java │ │ │ ├── SqoopDestroyerExecutor.java │ │ │ ├── SqoopFileOutputFormat.java │ │ │ ├── SqoopInputFormat.java │ │ │ ├── SqoopMapper.java │ │ │ ├── SqoopNullOutputFormat.java │ │ │ ├── SqoopOutputFormatLoadExecutor.java │ │ │ ├── SqoopReducer.java │ │ │ └── SqoopSplit.java │ │ └── test │ │ ├── java │ │ └── org │ │ │ └── apache │ │ │ └── sqoop │ │ │ └── job │ │ │ ├── FileUtils.java │ │ │ ├── JobUtils.java │ │ │ ├── TestHdfsExtract.java │ │ │ ├── TestHdfsLoad.java │ │ │ ├── TestMapReduce.java │ │ │ ├── io │ │ │ └── TestData.java │ │ │ └── mr │ │ │ └── TestSqoopOutputFormatLoadExecutor.java │ │ └── resources │ │ └── log4j.properties └── pom.xml ├── pom.xml ├── repository ├── pom.xml └── repository-derby │ ├── pom.xml │ └── src │ ├── main │ └── java │ │ └── org │ │ └── apache │ │ └── sqoop │ │ └── repository │ │ └── derby │ │ ├── DerbyRepoConfigurationConstants.java │ │ ├── DerbyRepoError.java │ │ ├── DerbyRepositoryHandler.java │ │ ├── DerbySchemaConstants.java │ │ └── DerbySchemaQuery.java │ └── test │ └── java │ └── org │ └── apache │ └── sqoop │ └── repository │ └── derby │ ├── DerbyTestCase.java │ ├── TestConnectionHandling.java │ ├── TestConnectorHandling.java │ ├── TestFrameworkHandling.java │ ├── TestJobHandling.java │ └── TestSubmissionHandling.java ├── server ├── pom.xml └── src │ └── main │ ├── java │ └── org │ │ └── apache │ │ └── sqoop │ │ ├── handler │ │ ├── ConnectionRequestHandler.java │ │ ├── ConnectorRequestHandler.java │ │ ├── FrameworkRequestHandler.java │ │ ├── JobRequestHandler.java │ │ ├── SubmissionRequestHandler.java │ │ └── VersionRequestHandler.java │ │ └── server │ │ ├── RequestContext.java │ │ ├── RequestHandler.java │ │ ├── ServerInitializer.java │ │ ├── SqoopProtocolServlet.java │ │ ├── VersionServlet.java │ │ ├── common │ │ └── ServerError.java │ │ └── v1 │ │ ├── ConnectionServlet.java │ │ ├── ConnectorServlet.java │ │ ├── FrameworkServlet.java │ │ ├── JobServlet.java │ │ └── SubmissionServlet.java │ └── webapp │ ├── WEB-INF │ └── web.xml │ └── index.html ├── spi ├── pom.xml └── src │ └── main │ └── java │ └── org │ └── apache │ └── sqoop │ ├── connector │ └── spi │ │ └── SqoopConnector.java │ ├── job │ ├── Constants.java │ ├── etl │ │ ├── CallbackBase.java │ │ ├── Destroyer.java │ │ ├── Exporter.java │ │ ├── Extractor.java │ │ ├── Importer.java │ │ ├── Initializer.java │ │ ├── Loader.java │ │ ├── Partition.java │ │ └── Partitioner.java │ └── io │ │ ├── DataReader.java │ │ └── DataWriter.java │ └── validation │ └── Validator.java └── submission ├── mapreduce ├── pom.xml └── src │ └── main │ └── java │ └── org │ └── apache │ └── sqoop │ └── submission │ └── mapreduce │ ├── Constants.java │ ├── MapreduceSubmissionEngine.java │ └── MapreduceSubmissionError.java └── pom.xml /.gitattributes: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | # Auto detect text files and perform LF normalization 19 | * text=auto 20 | 21 | *.cs text diff=csharp 22 | *.java text diff=java 23 | *.html text diff=html 24 | *.py text diff=python 25 | *.pl text diff=perl 26 | *.pm text diff=perl 27 | *.css text 28 | *.js text 29 | *.sql text 30 | 31 | *.sh text eol=lf 32 | 33 | *.bat text eol=crlf 34 | *.csproj text merge=union eol=crlf 35 | *.sln text merge=union eol=crlf 36 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .project 3 | .settings 4 | target 5 | *.iml 6 | *.log 7 | .idea 8 | nb-configuration.xml 9 | -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | Apache Sqoop 2 | Copyright 2011-2012 The Apache Software Foundation 3 | 4 | This product includes software developed at 5 | The Apache Software Foundation (http://www.apache.org/). 6 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | = Welcome to Sqoop 2 | 3 | Apache Sqoop is a tool designed for efficiently transferring bulk data between 4 | Apache Hadoop and structured datastores such as relational databases. You can use 5 | Sqoop to import data from external structured datastores into Hadoop Distributed 6 | File System or related systems like Hive and HBase. Conversely, Sqoop can be used 7 | to extract data from Hadoop and export it to external structured datastores such 8 | as relational databases and enterprise data warehouses. 9 | 10 | == Documentation 11 | 12 | Sqoop ships with documentation, please check module "docs" for additional materials. 13 | 14 | More documentation is available online on Sqoop home page: 15 | 16 | http://sqoop.apache.org/ 17 | 18 | == Compiling Sqoop 19 | 20 | Sqoop uses the Maven build system, and it can be compiled and built running the 21 | following commands: 22 | 23 | mvn compile # Compile project 24 | mvn package # Build source artifact 25 | mvn package -Pbinary # Build binary artifact 26 | 27 | Sqoop is using Sphinx plugin to generate documentation that have higher memory 28 | requirements that might not fit into default maven configuration. You might need 29 | to increase maximal memory allowance to successfully execute package goal. This 30 | can done using following command: 31 | 32 | export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=512m" 33 | 34 | Sqoop currently supports multiple Hadoop distributions. In order to compile Sqoop 35 | against a specific Hadoop version, please specify the hadoop.profile property in 36 | Maven commands. For example: 37 | 38 | mvn package -Pbinary -Dhadoop.profile=100 39 | 40 | Please refer to the Sqoop documentation for a full list of supported Hadoop 41 | distributions and values of the hadoop.profile property. 42 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/sqoop/client/core/ClientError.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.client.core; 19 | 20 | import org.apache.sqoop.common.ErrorCode; 21 | 22 | public enum ClientError implements ErrorCode { 23 | 24 | /** An unknown error has occurred. */ 25 | CLIENT_0000("An unknown error has occurred"), 26 | 27 | /** The specified command is not recognized. */ 28 | CLIENT_0001("The specified command is not recognized"), 29 | 30 | /** The specified function is not recognized. */ 31 | CLIENT_0002("The specified function is not recognized"), 32 | 33 | /** An error has occurred when parsing options. */ 34 | CLIENT_0003("An error has occurred when parsing options"), 35 | 36 | /** Unable to resolve the variables. */ 37 | CLIENT_0004("Unable to resolve the variables"), 38 | 39 | /** We're not able to get user input */ 40 | CLIENT_0005("Can't get user input"), 41 | 42 | /** There occurred exception on server side **/ 43 | CLIENT_0006("Server has returned exception"), 44 | 45 | ; 46 | 47 | private final String message; 48 | 49 | private ClientError(String message) { 50 | this.message = message; 51 | } 52 | 53 | public String getCode() { 54 | return name(); 55 | } 56 | 57 | public String getMessage() { 58 | return message; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/sqoop/client/request/ConnectorRequest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.client.request; 19 | 20 | import org.apache.sqoop.json.ConnectorBean; 21 | import org.json.simple.JSONObject; 22 | import org.json.simple.JSONValue; 23 | 24 | /** 25 | * Provide cRud semantics over RESTfull HTTP API for connectors. Only read 26 | * is supported as creation, update and delete might be done only directly on 27 | * server side. 28 | */ 29 | public class ConnectorRequest extends Request 30 | { 31 | public static final String RESOURCE = "v1/connector/"; 32 | 33 | public ConnectorBean read(String serverUrl, String cid) { 34 | String response = null; 35 | if (cid == null) { 36 | response = super.get(serverUrl + RESOURCE + "all"); 37 | } else { 38 | response = super.get(serverUrl + RESOURCE + cid); 39 | } 40 | JSONObject jsonObject = (JSONObject)JSONValue.parse(response); 41 | 42 | ConnectorBean connectorBean = new ConnectorBean(); 43 | connectorBean.restore(jsonObject); 44 | 45 | return connectorBean; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/sqoop/client/request/FrameworkRequest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.client.request; 19 | 20 | import org.apache.sqoop.json.FrameworkBean; 21 | import org.json.simple.JSONObject; 22 | import org.json.simple.JSONValue; 23 | 24 | /** 25 | * Provide cRud semantics over RESTfull HTTP API for framework. Only read 26 | * is supported as creation, update and delete is not allowed. 27 | */ 28 | public class FrameworkRequest extends Request { 29 | 30 | public static final String RESOURCE = "v1/framework"; 31 | 32 | public FrameworkBean read(String serverUrl) { 33 | String response = null; 34 | response = super.get(serverUrl + RESOURCE); 35 | JSONObject jsonObject = (JSONObject) JSONValue.parse(response); 36 | 37 | FrameworkBean frameworkBean = new FrameworkBean(); 38 | frameworkBean.restore(jsonObject); 39 | 40 | return frameworkBean; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/sqoop/client/request/VersionRequest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.client.request; 19 | 20 | import org.apache.sqoop.json.VersionBean; 21 | import org.json.simple.JSONObject; 22 | import org.json.simple.JSONValue; 23 | 24 | public class VersionRequest extends Request 25 | { 26 | public VersionBean doGet(String serverUrl) { 27 | String response = super.get(serverUrl + "version"); 28 | JSONObject jsonObject = (JSONObject)JSONValue.parse(response); 29 | 30 | VersionBean versionBean = new VersionBean(); 31 | versionBean.restore(jsonObject); 32 | 33 | return versionBean; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/sqoop/client/shell/DeleteConnectionFunction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.client.shell; 19 | 20 | import org.apache.commons.cli.CommandLine; 21 | import org.apache.commons.cli.OptionBuilder; 22 | import org.apache.sqoop.client.core.Constants; 23 | import org.codehaus.groovy.tools.shell.IO; 24 | 25 | import java.util.List; 26 | 27 | import static org.apache.sqoop.client.core.RequestCache.*; 28 | 29 | /** 30 | * 31 | */ 32 | public class DeleteConnectionFunction extends SqoopFunction { 33 | 34 | private IO io; 35 | 36 | 37 | @SuppressWarnings("static-access") 38 | public DeleteConnectionFunction(IO io) { 39 | this.io = io; 40 | 41 | this.addOption(OptionBuilder 42 | .withDescription(getResource().getString(Constants.RES_PROMPT_CONN_ID)) 43 | .withLongOpt(Constants.OPT_XID) 44 | .hasArg() 45 | .create('x')); 46 | } 47 | 48 | public Object execute(List args) { 49 | CommandLine line = parseOptions(this, 1, args); 50 | if (!line.hasOption(Constants.OPT_XID)) { 51 | io.out.println(getResource().getString(Constants.RES_ARGS_XID_MISSING)); 52 | return null; 53 | } 54 | 55 | deleteConnection(line.getOptionValue(Constants.OPT_XID)); 56 | 57 | return null; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/sqoop/client/shell/DeleteJobFunction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.client.shell; 19 | 20 | import org.apache.commons.cli.CommandLine; 21 | import org.apache.commons.cli.OptionBuilder; 22 | import org.apache.sqoop.client.core.Constants; 23 | import org.apache.sqoop.client.request.JobRequest; 24 | import org.codehaus.groovy.tools.shell.IO; 25 | 26 | import java.util.List; 27 | 28 | import static org.apache.sqoop.client.core.RequestCache.*; 29 | 30 | /** 31 | * Handles deletion of a job object. 32 | */ 33 | public class DeleteJobFunction extends SqoopFunction { 34 | 35 | private IO io; 36 | 37 | private JobRequest jobRequest; 38 | 39 | 40 | @SuppressWarnings("static-access") 41 | public DeleteJobFunction(IO io) { 42 | this.io = io; 43 | 44 | this.addOption(OptionBuilder 45 | .withDescription(getResource().getString(Constants.RES_PROMPT_JOB_ID)) 46 | .withLongOpt(Constants.OPT_JID) 47 | .hasArg() 48 | .create('j')); 49 | } 50 | 51 | public Object execute(List args) { 52 | CommandLine line = parseOptions(this, 1, args); 53 | if (!line.hasOption(Constants.OPT_JID)) { 54 | io.out.println(getResource().getString(Constants.RES_ARGS_JID_MISSING)); 55 | return null; 56 | } 57 | 58 | if (jobRequest == null) { 59 | jobRequest = new JobRequest(); 60 | } 61 | 62 | deleteJob(line.getOptionValue(Constants.OPT_JID)); 63 | 64 | return null; 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/sqoop/client/shell/SubmissionStartFunction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.client.shell; 19 | 20 | import org.apache.commons.cli.CommandLine; 21 | import org.apache.commons.cli.OptionBuilder; 22 | import org.apache.sqoop.client.core.Constants; 23 | import org.apache.sqoop.client.core.RequestCache; 24 | import org.apache.sqoop.client.utils.SubmissionDisplayer; 25 | import org.apache.sqoop.model.MSubmission; 26 | import org.codehaus.groovy.tools.shell.IO; 27 | 28 | import java.util.List; 29 | 30 | /** 31 | * 32 | */ 33 | public class SubmissionStartFunction extends SqoopFunction { 34 | 35 | private IO io; 36 | 37 | @SuppressWarnings("static-access") 38 | public SubmissionStartFunction(IO io) { 39 | this.io = io; 40 | 41 | this.addOption(OptionBuilder 42 | .withDescription(getResource().getString(Constants.RES_PROMPT_JOB_ID)) 43 | .withLongOpt(Constants.OPT_JID) 44 | .hasArg() 45 | .create(Constants.OPT_JID_CHAR)); 46 | } 47 | 48 | public Object execute(List args) { 49 | CommandLine line = parseOptions(this, 1, args); 50 | if (!line.hasOption(Constants.OPT_JID)) { 51 | io.out.println(getResource().getString(Constants.RES_ARGS_JID_MISSING)); 52 | return null; 53 | } 54 | 55 | MSubmission submission = 56 | RequestCache.createSubmission(line.getOptionValue(Constants.OPT_JID)); 57 | 58 | SubmissionDisplayer.display(io, submission); 59 | return null; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/sqoop/client/shell/SubmissionStatusFunction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.client.shell; 19 | 20 | import org.apache.commons.cli.CommandLine; 21 | import org.apache.commons.cli.OptionBuilder; 22 | import org.apache.sqoop.client.core.Constants; 23 | import org.apache.sqoop.client.core.RequestCache; 24 | import org.apache.sqoop.client.utils.SubmissionDisplayer; 25 | import org.apache.sqoop.model.MSubmission; 26 | import org.codehaus.groovy.tools.shell.IO; 27 | 28 | import java.util.List; 29 | 30 | /** 31 | * 32 | */ 33 | public class SubmissionStatusFunction extends SqoopFunction { 34 | 35 | private IO io; 36 | 37 | @SuppressWarnings("static-access") 38 | public SubmissionStatusFunction(IO io) { 39 | this.io = io; 40 | 41 | this.addOption(OptionBuilder 42 | .withDescription(getResource().getString(Constants.RES_PROMPT_JOB_ID)) 43 | .withLongOpt(Constants.OPT_JID) 44 | .hasArg() 45 | .create(Constants.OPT_JID_CHAR)); 46 | } 47 | 48 | public Object execute(List args) { 49 | CommandLine line = parseOptions(this, 1, args); 50 | if (!line.hasOption(Constants.OPT_JID)) { 51 | io.out.println(getResource().getString(Constants.RES_ARGS_JID_MISSING)); 52 | return null; 53 | } 54 | 55 | MSubmission submission = 56 | RequestCache.readSubmission(line.getOptionValue(Constants.OPT_JID)); 57 | 58 | SubmissionDisplayer.display(io, submission); 59 | return null; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /client/src/main/java/org/apache/sqoop/client/shell/SubmissionStopFunction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.client.shell; 19 | 20 | import org.apache.commons.cli.CommandLine; 21 | import org.apache.commons.cli.OptionBuilder; 22 | import org.apache.sqoop.client.core.Constants; 23 | import org.apache.sqoop.client.core.RequestCache; 24 | import org.apache.sqoop.client.utils.SubmissionDisplayer; 25 | import org.apache.sqoop.model.MSubmission; 26 | import org.codehaus.groovy.tools.shell.IO; 27 | 28 | import java.util.List; 29 | 30 | /** 31 | * 32 | */ 33 | public class SubmissionStopFunction extends SqoopFunction { 34 | 35 | private IO io; 36 | 37 | @SuppressWarnings("static-access") 38 | public SubmissionStopFunction(IO io) { 39 | this.io = io; 40 | 41 | this.addOption(OptionBuilder 42 | .withDescription(getResource().getString(Constants.RES_PROMPT_JOB_ID)) 43 | .withLongOpt(Constants.OPT_JID) 44 | .hasArg() 45 | .create(Constants.OPT_JID_CHAR)); 46 | } 47 | 48 | public Object execute(List args) { 49 | CommandLine line = parseOptions(this, 1, args); 50 | if (!line.hasOption(Constants.OPT_JID)) { 51 | io.out.println(getResource().getString(Constants.RES_ARGS_JID_MISSING)); 52 | return null; 53 | } 54 | 55 | MSubmission submission = 56 | RequestCache.deleteSubmission(line.getOptionValue(Constants.OPT_JID)); 57 | 58 | SubmissionDisplayer.display(io, submission); 59 | return null; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /client/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # Set root logger level to DEBUG and its only appender to A1. 17 | log4j.rootLogger=WARN, A1 18 | 19 | # A1 is set to be a ConsoleAppender. 20 | log4j.appender.A1=org.apache.log4j.ConsoleAppender 21 | 22 | # A1 uses PatternLayout. 23 | log4j.appender.A1.layout=org.apache.log4j.PatternLayout 24 | log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n 25 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/common/ErrorCode.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.common; 19 | 20 | /** 21 | * Defines an error-code contract. Sqoop exceptions use the error code to 22 | * communicate error information where possible. Each error code is associated 23 | * with default message that identifies the high level information related to 24 | * the underlying error condition. 25 | */ 26 | public interface ErrorCode { 27 | 28 | /** 29 | * @return the string representation of the error code. 30 | */ 31 | String getCode(); 32 | 33 | /** 34 | * @return the message associated with error code. 35 | */ 36 | String getMessage(); 37 | } 38 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/common/MutableContext.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.common; 19 | 20 | /** 21 | * Mutable addition to immutable context. 22 | */ 23 | public interface MutableContext extends ImmutableContext { 24 | 25 | /** 26 | * Set string value for given key. 27 | * 28 | * @param key Key 29 | * @param value New value 30 | */ 31 | public void setString(String key, String value); 32 | 33 | /** 34 | * Set long value for given key. 35 | * 36 | * @param key Key 37 | * @param value New value 38 | */ 39 | public void setLong(String key, long value); 40 | 41 | /** 42 | * Set integer value for given key. 43 | * 44 | * @param key Key 45 | * @param value New value 46 | */ 47 | public void setInteger(String key, int value); 48 | } 49 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/common/MutableMapContext.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.common; 19 | 20 | import java.util.HashMap; 21 | import java.util.Iterator; 22 | import java.util.Map; 23 | 24 | /** 25 | * Mutable variant of context class for "special" usage 26 | */ 27 | public class MutableMapContext extends MapContext implements Iterable>, MutableContext { 28 | 29 | public MutableMapContext(Map options) { 30 | super(options); 31 | } 32 | 33 | public MutableMapContext() { 34 | this(new HashMap()); 35 | } 36 | 37 | /** 38 | * {@inheritDoc} 39 | */ 40 | @Override 41 | public void setString(String key, String value) { 42 | getOptions().put(key, value); 43 | } 44 | 45 | @Override 46 | public void setLong(String key, long value) { 47 | getOptions().put(key, Long.toString(value)); 48 | } 49 | 50 | @Override 51 | public void setInteger(String key, int value) { 52 | getOptions().put(key, Integer.toString(value)); 53 | } 54 | 55 | @Override 56 | public Iterator> iterator() { 57 | return getOptions().entrySet().iterator(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/common/SqoopException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.common; 19 | 20 | 21 | /** 22 | * Base exception for Sqoop framework. This exception requires the specification 23 | * of an error code for reference purposes. Where necessary the appropriate 24 | * constructor can be used to pass in additional message beyond what is 25 | * specified by the error code and/or the causal exception. 26 | */ 27 | @SuppressWarnings("serial") 28 | public class SqoopException extends RuntimeException { 29 | 30 | private final ErrorCode code; 31 | 32 | public SqoopException(ErrorCode code) { 33 | super(code.getCode() + ":" + code.getMessage()); 34 | this.code = code; 35 | } 36 | 37 | public SqoopException(ErrorCode code, String extraInfo) { 38 | super(code.getCode() + ":" + code.getMessage() + " - " + extraInfo); 39 | this.code = code; 40 | } 41 | 42 | public SqoopException(ErrorCode code, Throwable cause) { 43 | super(code.getCode() + ":" + code.getMessage(), cause); 44 | this.code = code; 45 | } 46 | 47 | public SqoopException(ErrorCode code, String extraInfo, Throwable cause) { 48 | super(code.getCode() + ":" + code.getMessage() + " - " + extraInfo, cause); 49 | this.code = code; 50 | } 51 | 52 | public ErrorCode getErrorCode() { 53 | return code; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/common/SqoopProtocolConstants.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.common; 19 | 20 | public final class SqoopProtocolConstants { 21 | 22 | public static final String HEADER_SQOOP_ERROR_CODE = "sqoop-error-code"; 23 | 24 | public static final String HEADER_SQOOP_ERROR_MESSAGE = "sqoop-error-message"; 25 | 26 | public static final String HEADER_SQOOP_INTERNAL_ERROR_CODE = 27 | "sqoop-internal-error-code"; 28 | 29 | public static final String HEADER_SQOOP_INTERNAL_ERROR_MESSAGE = 30 | "sqoop-internal-error-message"; 31 | 32 | public static final String JSON_CONTENT_TYPE = 33 | "application/json; charset=\"UTF-8\""; 34 | 35 | private SqoopProtocolConstants() { 36 | // Disable explicit object creation 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/common/SqoopResponseCode.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.common; 19 | 20 | public enum SqoopResponseCode { 21 | 22 | SQOOP_1000("1000", "OK"), 23 | SQOOP_2000("2000", "ERROR"); 24 | 25 | private final String code; 26 | private final String message; 27 | 28 | private SqoopResponseCode(String code, String message) { 29 | this.code = code; 30 | this.message = message; 31 | } 32 | 33 | public String getCode() { 34 | return code; 35 | } 36 | 37 | public String getMessage() { 38 | return message; 39 | } 40 | 41 | public static SqoopResponseCode getFromCode(String code) { 42 | return SqoopResponseCode.valueOf("SQOOP_" + code); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/common/VersionAnnotation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.common; 19 | 20 | import java.lang.annotation.*; 21 | 22 | /** 23 | * A package attribute that captures the version that was compiled. 24 | * Copied down from hadoop. All is same except name of interface. 25 | */ 26 | @Retention(RetentionPolicy.RUNTIME) 27 | @Target(ElementType.PACKAGE) 28 | public @interface VersionAnnotation { 29 | 30 | /** 31 | * Get the Hadoop version 32 | * @return the version string (eg. "2.0.0") 33 | */ 34 | String version(); 35 | 36 | /** 37 | * Get the username that compiled the code. 38 | */ 39 | String user(); 40 | 41 | /** 42 | * Get the date when the code was compiled. 43 | * @return the date in unix 'date' format 44 | */ 45 | String date(); 46 | 47 | /** 48 | * Get the url for the subversion repository. 49 | */ 50 | String url(); 51 | 52 | /** 53 | * Get the subversion revision. 54 | * @return the revision number as a string (eg. "451451") 55 | */ 56 | String revision(); 57 | } 58 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/json/JsonBean.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.json; 19 | 20 | import org.json.simple.JSONObject; 21 | 22 | public interface JsonBean { 23 | 24 | JSONObject extract(); 25 | 26 | void restore(JSONObject jsonObject); 27 | 28 | public static final JsonBean EMPTY_BEAN = new JsonBean() { 29 | 30 | @Override 31 | public JSONObject extract() { 32 | return new JSONObject(); 33 | } 34 | 35 | @Override 36 | public void restore(JSONObject jsonObject) { 37 | } 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/model/ConfigurationClass.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.model; 19 | 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | 23 | /** 24 | * Class annotation. Each class that is used a configuration object where user 25 | * is expected to provide input need to have this annotation. 26 | */ 27 | @Retention(RetentionPolicy.RUNTIME) 28 | public @interface ConfigurationClass { 29 | 30 | } 31 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/model/Form.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.model; 19 | 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | 23 | /** 24 | * Denote form in Configuration class 25 | */ 26 | @Retention(RetentionPolicy.RUNTIME) 27 | public @interface Form { 28 | } 29 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/model/FormClass.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.model; 19 | 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | 23 | /** 24 | * Denote configuration class 25 | */ 26 | @Retention(RetentionPolicy.RUNTIME) 27 | public @interface FormClass { 28 | 29 | /** 30 | * Default size for Inputs in this form. 31 | * 32 | * @return 33 | */ 34 | short defaultSize() default -1; 35 | } 36 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/model/Input.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.model; 19 | 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | 23 | /** 24 | * Field annotation. Each field that user might change in configuration object 25 | * need to have this annotation. 26 | */ 27 | @Retention(RetentionPolicy.RUNTIME) 28 | public @interface Input { 29 | /** 30 | * Sqoop framework will ensure that sensitive information will not be easily 31 | * accessible. 32 | * 33 | * @return True if field is sensitive 34 | */ 35 | boolean sensitive() default false; 36 | 37 | /** 38 | * Maximal length of field if applicable. 39 | * 40 | * @return Maximal length 41 | */ 42 | short size() default -1; 43 | } 44 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/model/MAccountableEntity.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.model; 19 | 20 | import java.util.Date; 21 | 22 | /** 23 | * Accountable entity provides additional fields that might help with identifying 24 | * what and when has happened. 25 | */ 26 | abstract public class MAccountableEntity extends MPersistableEntity { 27 | 28 | /** 29 | * Date when the entity was created. 30 | */ 31 | private Date creationDate; 32 | 33 | /** 34 | * Date when the entity was lastly updated. 35 | */ 36 | private Date lastUpdateDate; 37 | 38 | public MAccountableEntity() { 39 | this.creationDate = new Date(); 40 | this.lastUpdateDate = this.creationDate; 41 | } 42 | 43 | public void setCreationDate(Date createDate) { 44 | this.creationDate = createDate; 45 | } 46 | 47 | public Date getCreationDate() { 48 | return creationDate; 49 | } 50 | 51 | public void setLastUpdateDate(Date lastUpdateDate) { 52 | this.lastUpdateDate = lastUpdateDate; 53 | } 54 | 55 | public Date getLastUpdateDate() { 56 | return lastUpdateDate; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/model/MConnection.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.model; 19 | 20 | /** 21 | * Model describing entire connection object including both connector and 22 | * framework part. 23 | */ 24 | public class MConnection extends MAccountableEntity { 25 | private long connectorId; 26 | private String name; 27 | 28 | private MConnectionForms connectorPart; 29 | private MConnectionForms frameworkPart; 30 | 31 | public MConnection(long connectorId, 32 | MConnectionForms connectorPart, 33 | MConnectionForms frameworkPart) { 34 | this.connectorId = connectorId; 35 | this.connectorPart = connectorPart; 36 | this.frameworkPart = frameworkPart; 37 | } 38 | 39 | @Override 40 | public String toString() { 41 | StringBuilder sb = new StringBuilder("connection: ").append(name); 42 | sb.append(" connector-part: ").append(connectorPart); 43 | sb.append(", framework-part: ").append(frameworkPart); 44 | 45 | return sb.toString(); 46 | } 47 | 48 | public String getName() { 49 | return name; 50 | } 51 | 52 | public void setName(String name) { 53 | this.name = name; 54 | } 55 | 56 | public long getConnectorId() { 57 | return connectorId; 58 | } 59 | 60 | public MConnectionForms getConnectorPart() { 61 | return connectorPart; 62 | } 63 | 64 | public MConnectionForms getFrameworkPart() { 65 | return frameworkPart; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/model/MConnectionForms.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.model; 19 | 20 | import java.util.List; 21 | 22 | /** 23 | * Metadata describing all required information to build up an connection 24 | * object for one part. Both connector and framework need to supply this object 25 | * to build up entire connection. 26 | */ 27 | public class MConnectionForms { 28 | 29 | private final List forms; 30 | 31 | public MConnectionForms(List forms) { 32 | this.forms = forms; 33 | } 34 | 35 | public List getForms() { 36 | return forms; 37 | } 38 | 39 | @Override 40 | public String toString() { 41 | StringBuilder sb = new StringBuilder("connection, forms:"); 42 | sb.append(forms); 43 | return sb.toString(); 44 | } 45 | 46 | @Override 47 | public boolean equals(Object other) { 48 | if (other == this) { 49 | return true; 50 | } 51 | 52 | if (!(other instanceof MConnectionForms)) { 53 | return false; 54 | } 55 | 56 | MConnectionForms mc = (MConnectionForms) other; 57 | return forms.equals(mc.forms); 58 | } 59 | 60 | @Override 61 | public int hashCode() { 62 | int result = super.hashCode(); 63 | for(MForm form : forms) { 64 | result = 31 * result + form.hashCode(); 65 | } 66 | 67 | return result; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/model/MForm.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.model; 19 | 20 | import java.util.List; 21 | 22 | /** 23 | * Represents a group of inputs that are processed together. This allows the 24 | * input gathering process to be broken down into multiple steps that can be 25 | * then paged through by the user interface. 26 | */ 27 | public final class MForm extends MValidatedElement { 28 | 29 | private final List> inputs; 30 | 31 | public MForm(String name, List> inputs) { 32 | super(name); 33 | 34 | this.inputs = inputs; 35 | } 36 | 37 | public List> getInputs() { 38 | return inputs; 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | StringBuilder sb = new StringBuilder("form-").append(getName()); 44 | sb.append(":").append(getPersistenceId()).append(":").append(inputs); 45 | 46 | return sb.toString(); 47 | } 48 | 49 | @Override 50 | public boolean equals(Object other) { 51 | if (other == this) { 52 | return true; 53 | } 54 | 55 | if (!(other instanceof MForm)) { 56 | return false; 57 | } 58 | 59 | MForm mf = (MForm) other; 60 | return getName().equals(mf.getName()) 61 | && inputs.equals(mf.inputs); 62 | } 63 | 64 | @Override 65 | public int hashCode() { 66 | int result = 17; 67 | result = 31 * result + getName().hashCode(); 68 | for (MInput mi : inputs) { 69 | result = 31 * result + mi.hashCode(); 70 | } 71 | 72 | return result; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/model/MFormType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.model; 19 | 20 | /** 21 | * Represents the various form types supported by the system. 22 | */ 23 | public enum MFormType { 24 | 25 | /** Unknown form type */ 26 | OTHER, 27 | 28 | /** Connection form type */ 29 | CONNECTION, 30 | 31 | /** Job form type */ 32 | JOB; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/model/MInputType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.model; 19 | 20 | /** 21 | * Represents the various input types supported by the system. 22 | */ 23 | public enum MInputType { 24 | 25 | /** Unknown input type */ 26 | OTHER, 27 | 28 | /** String input type */ 29 | STRING, 30 | 31 | /** Map input type */ 32 | MAP, 33 | 34 | /** Integer input type */ 35 | INTEGER, 36 | 37 | /** String based input that can contain only predefined values **/ 38 | ENUM, 39 | 40 | ; 41 | } 42 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/model/MIntegerInput.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.model; 19 | 20 | /** 21 | * Integer base user input. 22 | * 23 | * This input is able to process empty (NULL) value. 24 | */ 25 | public class MIntegerInput extends MInput { 26 | 27 | public MIntegerInput(String name) { 28 | super(name); 29 | } 30 | 31 | @Override 32 | public String getUrlSafeValueString() { 33 | if(isEmpty()) { 34 | return ""; 35 | } 36 | 37 | return getValue().toString(); 38 | } 39 | 40 | @Override 41 | public void restoreFromUrlSafeValueString(String valueString) { 42 | if(valueString.isEmpty()) { 43 | setEmpty(); 44 | } 45 | 46 | setValue(Integer.valueOf(valueString)); 47 | } 48 | 49 | @Override 50 | public MInputType getType() { 51 | return MInputType.INTEGER; 52 | } 53 | 54 | @Override 55 | public boolean equals(Object other) { 56 | if (other == this) { 57 | return true; 58 | } 59 | 60 | if (!(other instanceof MIntegerInput)) { 61 | return false; 62 | } 63 | 64 | MIntegerInput i = (MIntegerInput) other; 65 | return getName().equals(i.getName()); 66 | } 67 | 68 | @Override 69 | public int hashCode() { 70 | return 23 + 31 * getName().hashCode(); 71 | } 72 | 73 | @Override 74 | public boolean isEmpty() { 75 | return getValue() == null; 76 | } 77 | 78 | @Override 79 | public void setEmpty() { 80 | setValue(null); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/model/MJobForms.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.model; 19 | 20 | import java.util.List; 21 | 22 | /** 23 | * Metadata describing all required information to build up an job 24 | * object for one part. Both connector and framework need to supply this object 25 | * to build up entire job. 26 | */ 27 | public class MJobForms { 28 | 29 | private final MJob.Type type; 30 | private final List forms; 31 | 32 | public MJobForms(MJob.Type type, List forms) { 33 | this.type = type; 34 | this.forms = forms; 35 | } 36 | 37 | @Override 38 | public String toString() { 39 | StringBuilder sb = new StringBuilder("job type:").append(type.name()); 40 | sb.append(", forms: ").append(forms); 41 | return sb.toString(); 42 | } 43 | 44 | public MJob.Type getType() { 45 | return type; 46 | } 47 | 48 | public List getForms() { 49 | return forms; 50 | } 51 | 52 | @Override 53 | public boolean equals(Object other) { 54 | if (other == this) { 55 | return true; 56 | } 57 | 58 | if (!(other instanceof MJobForms)) { 59 | return false; 60 | } 61 | 62 | MJobForms mj = (MJobForms) other; 63 | return type.equals(mj.type) && forms.equals(mj.forms); 64 | } 65 | 66 | @Override 67 | public int hashCode() { 68 | int result = super.hashCode(); 69 | result = 31 * result + type.hashCode(); 70 | for(MForm form : forms) { 71 | result = 31 * result + form.hashCode(); 72 | } 73 | 74 | return result; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/model/MNamedElement.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.model; 19 | 20 | /** 21 | * Represents an element of metadata used by the connector. 22 | */ 23 | public abstract class MNamedElement extends MPersistableEntity { 24 | private static final String LABEL_KEY_SUFFIX = ".label"; 25 | private static final String HELP_KEY_SUFFIX = ".help"; 26 | 27 | private final String name; 28 | private final String labelKey; 29 | private final String helpKey; 30 | 31 | protected MNamedElement(String name) { 32 | this.name = name; 33 | 34 | labelKey = name + LABEL_KEY_SUFFIX; 35 | helpKey = name + HELP_KEY_SUFFIX; 36 | } 37 | 38 | /** 39 | * @return the name of this parameter 40 | */ 41 | public String getName() { 42 | return name; 43 | } 44 | 45 | /** 46 | * @return the label key to be used for this parameter 47 | */ 48 | public String getLabelKey() { 49 | return labelKey; 50 | } 51 | 52 | /** 53 | * @return the help key to be used for this parameter 54 | */ 55 | public String getHelpKey() { 56 | return helpKey; 57 | } 58 | 59 | public abstract String toString(); 60 | } 61 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/model/MPersistableEntity.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.model; 19 | 20 | /** 21 | * Represents a persistable metadata entity. 22 | */ 23 | public abstract class MPersistableEntity { 24 | 25 | public static final long PERSISTANCE_ID_DEFAULT = -1L; 26 | 27 | private long persistenceId = PERSISTANCE_ID_DEFAULT; 28 | 29 | protected MPersistableEntity() { 30 | // Default constructor 31 | } 32 | 33 | public void setPersistenceId(long persistenceId) { 34 | this.persistenceId = persistenceId; 35 | } 36 | 37 | public long getPersistenceId() { 38 | return persistenceId; 39 | } 40 | 41 | public boolean hasPersistenceId() { 42 | return persistenceId != PERSISTANCE_ID_DEFAULT; 43 | } 44 | 45 | @Override 46 | public abstract String toString(); 47 | } 48 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/model/ModelError.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.model; 19 | 20 | import org.apache.sqoop.common.ErrorCode; 21 | 22 | /** 23 | * 24 | */ 25 | public enum ModelError implements ErrorCode { 26 | 27 | MODEL_001("Attempt to pass two different set of MForms for single job type."), 28 | 29 | MODEL_002("Creating MJob of different job types"), 30 | 31 | MODEL_003("Object is not valid configuration object"), 32 | 33 | MODEL_004("Usage of unsupported data type"), 34 | 35 | MODEL_005("Can't get field value"), 36 | 37 | MODEL_006("Incompatible form list and configuration object"), 38 | 39 | MODEL_007("Primitive types in configuration objects are not allowed"), 40 | 41 | MODEL_008("Invalid input value"), 42 | 43 | MODEL_009("Invalid input name"), 44 | 45 | ; 46 | 47 | private final String message; 48 | 49 | private ModelError(String message) { 50 | this.message = message; 51 | } 52 | 53 | public String getCode() { 54 | return name(); 55 | } 56 | 57 | public String getMessage() { 58 | return message; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/submission/SubmissionStatus.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.submission; 19 | 20 | /** 21 | * List of states where the submission might be. 22 | */ 23 | public enum SubmissionStatus { 24 | 25 | /** 26 | * In the middle of creating new submission. This might be creation step 27 | * on our side on remote cluster side. 28 | */ 29 | BOOTING, 30 | 31 | /** 32 | * We weren't able to submit this submission to remote cluster 33 | */ 34 | FAILURE_ON_SUBMIT, 35 | 36 | /** 37 | * Submission is running. 38 | */ 39 | RUNNING, 40 | 41 | /** 42 | * Submission has finished gracefully 43 | */ 44 | SUCCEEDED, 45 | 46 | /** 47 | * Submission has not finished gracefully, there were issues. 48 | */ 49 | FAILED, 50 | 51 | /** 52 | * We have no idea in what state the submission actually is. 53 | */ 54 | UNKNOWN, 55 | 56 | /** 57 | * Special submission type for job that was never executed. 58 | */ 59 | NEVER_EXECUTED, 60 | 61 | ; 62 | 63 | /** 64 | * Return array of submission status that are considered as unfinished. 65 | * 66 | * @return Array of unfinished submission statuses 67 | */ 68 | public static SubmissionStatus[] unfinished() { 69 | return new SubmissionStatus[] { RUNNING, BOOTING }; 70 | } 71 | 72 | public boolean isRunning() { 73 | return this == RUNNING || this == BOOTING; 74 | } 75 | 76 | public boolean isFailure() { 77 | return this == FAILED || this == UNKNOWN || this == FAILURE_ON_SUBMIT; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/submission/counter/Counter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.submission.counter; 19 | 20 | /** 21 | * 22 | */ 23 | public class Counter { 24 | private final String name; 25 | private long value; 26 | 27 | public Counter(String name) { 28 | this.name = name; 29 | } 30 | 31 | public Counter(String name, long value) { 32 | this(name); 33 | this.value = value; 34 | } 35 | 36 | public String getName() { 37 | return name; 38 | } 39 | 40 | public long getValue() { 41 | return value; 42 | } 43 | 44 | public void setValue(long value) { 45 | this.value = value; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/submission/counter/CounterGroup.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.submission.counter; 19 | 20 | import java.util.HashMap; 21 | import java.util.Iterator; 22 | import java.util.Map; 23 | 24 | /** 25 | * 26 | */ 27 | public class CounterGroup implements Iterable { 28 | 29 | private final String name; 30 | private Map counters; 31 | 32 | public CounterGroup(String name) { 33 | this.name = name; 34 | this.counters = new HashMap(); 35 | } 36 | 37 | public String getName() { 38 | return name; 39 | } 40 | 41 | public CounterGroup addCounter(Counter counter) { 42 | counters.put(counter.getName(), counter); 43 | return this; 44 | } 45 | 46 | public Counter getCounter(String name) { 47 | return counters.get(name); 48 | } 49 | 50 | @Override 51 | public Iterator iterator() { 52 | return counters.values().iterator(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/submission/counter/Counters.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.submission.counter; 19 | 20 | import java.util.HashMap; 21 | import java.util.Iterator; 22 | import java.util.Map; 23 | 24 | /** 25 | * 26 | */ 27 | public class Counters implements Iterable { 28 | Map groups; 29 | 30 | public Counters() { 31 | this.groups = new HashMap(); 32 | } 33 | 34 | public Counters addCounterGroup(CounterGroup group) { 35 | groups.put(group.getName(), group); 36 | return this; 37 | } 38 | 39 | public CounterGroup getCounterGroup(String name) { 40 | return groups.get(name); 41 | } 42 | 43 | @Override 44 | public Iterator iterator() { 45 | return groups.values().iterator(); 46 | } 47 | 48 | public boolean isEmpty() { 49 | return groups.isEmpty(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/submission/counter/SqoopCounters.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.submission.counter; 19 | 20 | /** 21 | * 22 | */ 23 | public enum SqoopCounters { 24 | ROWS_READ; 25 | } 26 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/utils/MapResourceBundle.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.utils; 19 | 20 | import java.util.Collections; 21 | import java.util.Enumeration; 22 | import java.util.Map; 23 | import java.util.ResourceBundle; 24 | 25 | /** 26 | * 27 | */ 28 | public class MapResourceBundle extends ResourceBundle { 29 | 30 | private Map bundle; 31 | 32 | public MapResourceBundle(Map bundle) { 33 | this.bundle = bundle; 34 | } 35 | 36 | @Override 37 | protected Object handleGetObject(String key) { 38 | if(!bundle.containsKey(key)) { 39 | return null; 40 | } 41 | 42 | return bundle.get(key); 43 | } 44 | 45 | @Override 46 | public Enumeration getKeys() { 47 | return Collections.enumeration(bundle.keySet()); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/utils/StringUtils.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.utils; 19 | 20 | /** 21 | * Convenience String methods. 22 | * 23 | * We might consider replacing this with commons-lang library at some point. 24 | */ 25 | public final class StringUtils { 26 | 27 | public static String join(String []array, String separator) { 28 | if(array == null) { 29 | return null; 30 | } 31 | 32 | StringBuilder sb = new StringBuilder(); 33 | boolean first = true; 34 | 35 | for(String item : array) { 36 | if(first) { 37 | first = false; 38 | } else { 39 | sb.append(separator); 40 | } 41 | 42 | sb.append(item); 43 | } 44 | 45 | return sb.toString(); 46 | } 47 | 48 | private StringUtils() { 49 | // Instantiation is prohibited 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/utils/UrlSafeUtils.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.utils; 19 | 20 | import java.io.UnsupportedEncodingException; 21 | import java.net.URLDecoder; 22 | import java.net.URLEncoder; 23 | 24 | /** 25 | * Miscellaneous utility methods that help in URL-safe communication over HTTP. 26 | */ 27 | public final class UrlSafeUtils { 28 | 29 | public static final String ENCODING_UTF8 = "UTF-8"; 30 | 31 | public static String urlEncode(String string) { 32 | try { 33 | return URLEncoder.encode(string, ENCODING_UTF8); 34 | } catch (UnsupportedEncodingException uee) { 35 | throw new RuntimeException(uee); 36 | } 37 | } 38 | 39 | public static String urlDecode(String string) { 40 | try { 41 | return URLDecoder.decode(string, ENCODING_UTF8); 42 | } catch (UnsupportedEncodingException uee) { 43 | throw new RuntimeException(uee); 44 | } 45 | } 46 | 47 | 48 | private UrlSafeUtils() { 49 | // Disable explicit object creation 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /common/src/main/java/org/apache/sqoop/validation/ValidationError.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.validation; 19 | 20 | import org.apache.sqoop.common.ErrorCode; 21 | 22 | /** 23 | * 24 | */ 25 | public enum ValidationError implements ErrorCode { 26 | 27 | VALIDATION_0000("Unknown error"), 28 | 29 | VALIDATION_0001("Missing class declaration."), 30 | 31 | VALIDATION_0002("Usage of missing field"), 32 | 33 | VALIDATION_0003("Invalid representation of form and input field"), 34 | ; 35 | 36 | private final String message; 37 | 38 | private ValidationError(String message) { 39 | this.message = message; 40 | } 41 | 42 | public String getCode() { 43 | return name(); 44 | } 45 | 46 | public String getMessage() { 47 | return message; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /common/src/saveVersion.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This file is used to generate the annotation of package info that 4 | # records the user, url, revision and timestamp. 5 | 6 | # Licensed to the Apache Software Foundation (ASF) under one or more 7 | # contributor license agreements. See the NOTICE file distributed with 8 | # this work for additional information regarding copyright ownership. 9 | # The ASF licenses this file to You under the Apache License, Version 2.0 10 | # (the "License"); you may not use this file except in compliance with 11 | # the License. You may obtain a copy of the License at 12 | # 13 | # http://www.apache.org/licenses/LICENSE-2.0 14 | # 15 | # Unless required by applicable law or agreed to in writing, software 16 | # distributed under the License is distributed on an "AS IS" BASIS, 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | # See the License for the specific language governing permissions and 19 | # limitations under the License. 20 | 21 | unset LANG 22 | unset LC_CTYPE 23 | version=$1 24 | targetDirectory=$2 25 | outputDirectory="$targetDirectory/org/apache/sqoop/common" 26 | outputFile="$outputDirectory/package-info.java" 27 | user=`whoami` 28 | date=`date` 29 | cwd=`pwd` 30 | 31 | # Exit if target file already exists 32 | if [ -e $outputFile ]; then 33 | exit 0 34 | fi 35 | 36 | # Create version annotation 37 | if [ -d .svn ]; then 38 | revision=`svn info | sed -n -e 's/Last Changed Rev: \(.*\)/\1/p'` 39 | url=`svn info | sed -n -e 's/URL: \(.*\)/\1/p'` 40 | elif [ -d ../.git ]; then 41 | revision=`git log -1 --pretty=format:"%H"` 42 | hostname=`hostname` 43 | url="git://${hostname}${cwd}" 44 | else 45 | revision="Unknown" 46 | url="file://$cwd" 47 | fi 48 | mkdir -p $outputDirectory 49 | cat > $outputFile <()); 35 | List jobForms = new ArrayList(); 36 | jobForms.add(new MJobForms(MJob.Type.IMPORT, new ArrayList())); 37 | jobForms.add(new MJobForms(MJob.Type.IMPORT, new ArrayList())); 38 | 39 | try { 40 | new MFramework(connectionForms, jobForms); 41 | fail("We we're expecting exception for invalid usage"); 42 | } catch(Exception ex) { 43 | // Expected case 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /common/src/test/java/org/apache/sqoop/model/TestMPersistableEntity.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.model; 19 | 20 | import static org.junit.Assert.*; 21 | import org.junit.Test; 22 | 23 | public class TestMPersistableEntity { 24 | 25 | @Test 26 | public void testPersistableId() { 27 | PersistentId id = new PersistentId(); 28 | 29 | assertFalse(id.hasPersistenceId()); 30 | 31 | id.setPersistenceId(666); 32 | assertTrue(id.hasPersistenceId()); 33 | assertEquals(666, id.getPersistenceId()); 34 | } 35 | 36 | /** 37 | * Testing class extending MPersistableEntity. 38 | * 39 | * Empty implementation with purpose to just test methods available 40 | * directly in the abstract class. 41 | */ 42 | public static class PersistentId extends MPersistableEntity { 43 | @Override 44 | public String toString() { 45 | return null; 46 | } 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /common/src/test/java/org/apache/sqoop/utils/TestMapResourceBundle.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.utils; 19 | 20 | import org.junit.Test; 21 | 22 | import java.util.HashMap; 23 | import java.util.Map; 24 | 25 | import static org.junit.Assert.*; 26 | 27 | /** 28 | * 29 | */ 30 | public class TestMapResourceBundle { 31 | @Test 32 | public void testUsage() { 33 | Map map = new HashMap(); 34 | map.put("a", "1"); 35 | map.put("b", "2"); 36 | 37 | MapResourceBundle bundle = new MapResourceBundle(map); 38 | assertEquals("1", bundle.getString("a")); 39 | assertEquals("2", bundle.getString("b")); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /common/src/test/java/org/apache/sqoop/utils/TestStringUtils.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.utils; 19 | 20 | import junit.framework.TestCase; 21 | 22 | /** 23 | * 24 | */ 25 | public class TestStringUtils extends TestCase { 26 | 27 | public void testJoin() { 28 | assertNull(StringUtils.join(null, "a")); 29 | 30 | String []a = new String[] {"a", "b", "c"}; 31 | 32 | assertEquals("a,b,c", StringUtils.join(a, ",")); 33 | assertEquals("abc", StringUtils.join(a, "")); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /common/src/test/java/org/apache/sqoop/validation/TestStatus.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.validation; 19 | 20 | import org.junit.Test; 21 | 22 | import static junit.framework.Assert.*; 23 | 24 | /** 25 | * 26 | */ 27 | public class TestStatus { 28 | @Test 29 | public void testGetWorstStatus() { 30 | // Comparing itself with itself 31 | assertEquals(Status.FINE, 32 | Status.getWorstStatus(Status.FINE)); 33 | assertEquals(Status.FINE, 34 | Status.getWorstStatus(Status.FINE, Status.FINE)); 35 | assertEquals(Status.ACCEPTABLE, 36 | Status.getWorstStatus(Status.ACCEPTABLE, Status.ACCEPTABLE)); 37 | assertEquals(Status.UNACCEPTABLE, 38 | Status.getWorstStatus(Status.UNACCEPTABLE, Status.UNACCEPTABLE)); 39 | 40 | // Retriving the worst option 41 | assertEquals(Status.UNACCEPTABLE, 42 | Status.getWorstStatus(Status.FINE, Status.UNACCEPTABLE)); 43 | assertEquals(Status.ACCEPTABLE, 44 | Status.getWorstStatus(Status.FINE, Status.ACCEPTABLE)); 45 | } 46 | 47 | @Test 48 | public void testCanProceed() { 49 | assertTrue(Status.FINE.canProceed()); 50 | assertTrue(Status.ACCEPTABLE.canProceed()); 51 | assertFalse(Status.UNACCEPTABLE.canProceed()); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcExportDestroyer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.connector.jdbc; 19 | 20 | import org.apache.log4j.Logger; 21 | import org.apache.sqoop.common.ImmutableContext; 22 | import org.apache.sqoop.connector.jdbc.configuration.ConnectionConfiguration; 23 | import org.apache.sqoop.connector.jdbc.configuration.ExportJobConfiguration; 24 | import org.apache.sqoop.job.etl.Destroyer; 25 | 26 | public class GenericJdbcExportDestroyer extends Destroyer { 27 | 28 | private static final Logger LOG = Logger.getLogger(GenericJdbcExportDestroyer.class); 29 | 30 | @Override 31 | public void destroy(boolean success, ImmutableContext context, ConnectionConfiguration connection, ExportJobConfiguration job) { 32 | LOG.info("Running generic JDBC connector destroyer"); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcImportDestroyer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.connector.jdbc; 19 | 20 | import org.apache.sqoop.common.ImmutableContext; 21 | import org.apache.sqoop.connector.jdbc.configuration.ConnectionConfiguration; 22 | import org.apache.sqoop.connector.jdbc.configuration.ImportJobConfiguration; 23 | import org.apache.sqoop.job.etl.Destroyer; 24 | 25 | public class GenericJdbcImportDestroyer extends Destroyer { 26 | 27 | @Override 28 | public void destroy(boolean success, ImmutableContext context, ConnectionConfiguration connection, ImportJobConfiguration job) { 29 | // No explicit action at the moment 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcImportPartition.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.connector.jdbc; 19 | 20 | import java.io.DataInput; 21 | import java.io.DataOutput; 22 | import java.io.IOException; 23 | 24 | import org.apache.sqoop.job.etl.Partition; 25 | 26 | public class GenericJdbcImportPartition extends Partition { 27 | 28 | private String conditions; 29 | 30 | public void setConditions(String conditions) { 31 | this.conditions = conditions; 32 | } 33 | 34 | public String getConditions() { 35 | return conditions; 36 | } 37 | 38 | @Override 39 | public void readFields(DataInput in) throws IOException { 40 | conditions = in.readUTF(); 41 | } 42 | 43 | @Override 44 | public void write(DataOutput out) throws IOException { 45 | out.writeUTF(conditions); 46 | } 47 | 48 | @Override 49 | public String toString() { 50 | return conditions; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcValidator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.connector.jdbc; 19 | 20 | import org.apache.sqoop.connector.jdbc.configuration.ConnectionConfiguration; 21 | import org.apache.sqoop.validation.Status; 22 | import org.apache.sqoop.validation.Validation; 23 | import org.apache.sqoop.validation.Validator; 24 | 25 | /** 26 | * 27 | */ 28 | public class GenericJdbcValidator extends Validator { 29 | 30 | @Override 31 | public Validation validateConnection(Object configuration) { 32 | Validation validation = new Validation(ConnectionConfiguration.class); 33 | ConnectionConfiguration config = (ConnectionConfiguration)configuration; 34 | 35 | if(config.connection.connectionString == null 36 | || !config.connection.connectionString.startsWith("jdbc:")) { 37 | validation.addMessage(Status.UNACCEPTABLE, 38 | "connection", "connectionString", 39 | "This do not seem as a valid JDBC URL"); 40 | } 41 | 42 | return validation; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ConnectionConfiguration.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.connector.jdbc.configuration; 19 | 20 | import org.apache.sqoop.model.ConfigurationClass; 21 | import org.apache.sqoop.model.Form; 22 | 23 | /** 24 | * 25 | */ 26 | @ConfigurationClass 27 | public class ConnectionConfiguration { 28 | 29 | @Form public ConnectionForm connection; 30 | 31 | public ConnectionConfiguration() { 32 | connection = new ConnectionForm(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ConnectionForm.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.connector.jdbc.configuration; 19 | 20 | import org.apache.sqoop.model.FormClass; 21 | import org.apache.sqoop.model.Input; 22 | 23 | import java.util.Map; 24 | 25 | /** 26 | * 27 | */ 28 | @FormClass 29 | public class ConnectionForm { 30 | @Input(size = 128) public String jdbcDriver; 31 | @Input(size = 128) public String connectionString; 32 | @Input(size = 40) public String username; 33 | @Input(size = 40, sensitive = true) public String password; 34 | @Input public Map jdbcProperties; 35 | } 36 | -------------------------------------------------------------------------------- /connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ExportJobConfiguration.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.connector.jdbc.configuration; 19 | 20 | import org.apache.sqoop.model.ConfigurationClass; 21 | import org.apache.sqoop.model.Form; 22 | 23 | /** 24 | * 25 | */ 26 | @ConfigurationClass 27 | public class ExportJobConfiguration { 28 | @Form public ExportTableForm table; 29 | 30 | public ExportJobConfiguration() { 31 | table = new ExportTableForm(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ExportTableForm.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.connector.jdbc.configuration; 19 | 20 | import org.apache.sqoop.model.FormClass; 21 | import org.apache.sqoop.model.Input; 22 | 23 | /** 24 | * 25 | */ 26 | @FormClass 27 | public class ExportTableForm { 28 | @Input(size = 50) public String tableName; 29 | @Input(size = 50) public String sql; 30 | @Input(size = 50) public String columns; 31 | } 32 | -------------------------------------------------------------------------------- /connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/IgnoredForm.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.connector.jdbc.configuration; 19 | 20 | import org.apache.sqoop.model.FormClass; 21 | import org.apache.sqoop.model.Input; 22 | 23 | /** 24 | * 25 | */ 26 | @FormClass 27 | public class IgnoredForm { 28 | @Input public String ignored; 29 | } 30 | -------------------------------------------------------------------------------- /connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ImportJobConfiguration.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.connector.jdbc.configuration; 19 | 20 | import org.apache.sqoop.model.ConfigurationClass; 21 | import org.apache.sqoop.model.Form; 22 | 23 | /** 24 | * 25 | */ 26 | @ConfigurationClass 27 | public class ImportJobConfiguration { 28 | @Form public ImportTableForm table; 29 | 30 | public ImportJobConfiguration() { 31 | table = new ImportTableForm(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ImportTableForm.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.connector.jdbc.configuration; 19 | 20 | import org.apache.sqoop.model.FormClass; 21 | import org.apache.sqoop.model.Input; 22 | 23 | /** 24 | * 25 | */ 26 | @FormClass 27 | public class ImportTableForm { 28 | @Input(size = 50) public String tableName; 29 | @Input(size = 50) public String sql; 30 | @Input(size = 50) public String columns; 31 | @Input(size = 50) public String partitionColumn; 32 | @Input(size = 50) public String boundaryQuery; 33 | } 34 | -------------------------------------------------------------------------------- /connector/connector-generic-jdbc/src/main/resources/sqoopconnector.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # Generic JDBC Connector Properties 17 | org.apache.sqoop.connector.class = org.apache.sqoop.connector.jdbc.GenericJdbcConnector 18 | org.apache.sqoop.connector.name = generic-jdbc-connector 19 | -------------------------------------------------------------------------------- /connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/GenericJdbcTestConstants.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.connector.jdbc; 19 | 20 | public class GenericJdbcTestConstants { 21 | 22 | public static final String DRIVER = "org.apache.derby.jdbc.EmbeddedDriver"; 23 | public static final String URL = "jdbc:derby:memory:TESTDB;create=true"; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /connector/connector-mysql-fastpath/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 21 | 22 | 4.0.0 23 | 24 | 25 | org.apache.sqoop 26 | connector 27 | 1.99.1-cdh4.2.1 28 | 29 | 30 | org.apache.sqoop.connector 31 | sqoop-connector-mysql-fastpath 32 | MySQL Fastpath Connector 33 | 34 | 35 | 36 | org.apache.sqoop 37 | sqoop-spi 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /connector/connector-mysql-jdbc/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 21 | 22 | 4.0.0 23 | 24 | 25 | org.apache.sqoop 26 | connector 27 | 1.99.1-cdh4.2.1 28 | 29 | 30 | org.apache.sqoop.connector 31 | sqoop-connector-mysql-jdbc 32 | MySQL JDBC Connector 33 | 34 | 35 | 36 | org.apache.sqoop 37 | sqoop-spi 38 | 39 | 40 | org.apache.sqoop.connector 41 | sqoop-connector-generic-jdbc 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /connector/connector-mysql-jdbc/src/main/resources/sqoopconnector.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # MySQL JDBC COnnector Properties 17 | #org.apache.sqoop.connector.class = org.apache.sqoop.connector.mysqljdbc.MySqlJdbcConnector 18 | #org.apache.sqoop.connector.name = mysql-jdbc-connector 19 | -------------------------------------------------------------------------------- /connector/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 21 | 22 | 4.0.0 23 | 24 | 25 | org.apache 26 | sqoop 27 | 1.99.1-cdh4.2.1 28 | 29 | 30 | org.apache.sqoop 31 | connector 32 | Sqoop Connectors 33 | pom 34 | 35 | 36 | connector-generic-jdbc 37 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/sqoop/core/ConfigurationListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.core; 19 | 20 | public interface ConfigurationListener { 21 | 22 | void configurationChanged(); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/sqoop/core/ConfigurationProvider.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.core; 19 | 20 | import java.io.File; 21 | import java.util.Map; 22 | import java.util.Properties; 23 | 24 | public interface ConfigurationProvider { 25 | 26 | void initialize(File configDir, Properties bootstrapCongiruation); 27 | 28 | void destroy(); 29 | 30 | void registerListener(ConfigurationListener listener); 31 | 32 | Map getConfiguration(); 33 | } 34 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/sqoop/framework/ExecutionEngine.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.framework; 19 | 20 | import org.apache.sqoop.common.ImmutableContext; 21 | import org.apache.sqoop.connector.spi.SqoopConnector; 22 | import org.apache.sqoop.model.MSubmission; 23 | 24 | /** 25 | * Execution engine drive execution of sqoop submission (job). It's responsible 26 | * for executing all defined steps in the import/export workflow. 27 | */ 28 | public abstract class ExecutionEngine { 29 | 30 | /** 31 | * Initialize execution engine 32 | * 33 | * @param context Configuration context 34 | */ 35 | public void initialize(ImmutableContext context, String prefix) { 36 | } 37 | 38 | /** 39 | * Destroy execution engine when stopping server 40 | */ 41 | public void destroy() { 42 | } 43 | 44 | /** 45 | * Return new SubmissionRequest class or any subclass if it's needed by 46 | * execution and submission engine combination. 47 | * 48 | * @return New Submission request object 49 | */ 50 | public SubmissionRequest createSubmissionRequest() { 51 | return new SubmissionRequest(); 52 | } 53 | 54 | /** 55 | * Prepare given submission request for import job type. 56 | * 57 | * @param request Submission request 58 | */ 59 | public abstract void prepareImportSubmission(SubmissionRequest request); 60 | 61 | /** 62 | * Prepare given submission request for export job type.. 63 | * @param request 64 | */ 65 | public abstract void prepareExportSubmission(SubmissionRequest request); 66 | } 67 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/sqoop/framework/FrameworkError.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.framework; 19 | 20 | import org.apache.sqoop.common.ErrorCode; 21 | 22 | /** 23 | * 24 | */ 25 | public enum FrameworkError implements ErrorCode { 26 | 27 | FRAMEWORK_0000("Metadata are not registered in repository"), 28 | 29 | FRAMEWORK_0001("Invalid submission engine"), 30 | 31 | FRAMEWORK_0002("Given job is already running"), 32 | 33 | FRAMEWORK_0003("Given job is not running"), 34 | 35 | FRAMEWORK_0004("Unknown job id"), 36 | 37 | FRAMEWORK_0005("Unsupported job type"), 38 | 39 | FRAMEWORK_0006("Can't bootstrap job"), 40 | 41 | FRAMEWORK_0007("Invalid execution engine"), 42 | 43 | FRAMEWORK_0008("Invalid combination of submission and execution engines"), 44 | 45 | ; 46 | 47 | private final String message; 48 | 49 | private FrameworkError(String message) { 50 | this.message = message; 51 | } 52 | 53 | public String getCode() { 54 | return name(); 55 | } 56 | 57 | public String getMessage() { 58 | return message; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/sqoop/framework/configuration/ConnectionConfiguration.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.framework.configuration; 19 | 20 | import org.apache.sqoop.model.ConfigurationClass; 21 | import org.apache.sqoop.model.Form; 22 | 23 | /** 24 | * Framework class representing connection configuration 25 | */ 26 | @ConfigurationClass 27 | public class ConnectionConfiguration { 28 | 29 | @Form SecurityForm security; 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/sqoop/framework/configuration/ExportJobConfiguration.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.framework.configuration; 19 | 20 | import org.apache.sqoop.model.ConfigurationClass; 21 | import org.apache.sqoop.model.Form; 22 | 23 | /** 24 | * 25 | */ 26 | @ConfigurationClass 27 | public class ExportJobConfiguration { 28 | 29 | @Form public InputForm input; 30 | 31 | @Form public ThrottlingForm throttling; 32 | 33 | public ExportJobConfiguration() { 34 | throttling = new ThrottlingForm(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/sqoop/framework/configuration/ImportJobConfiguration.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.framework.configuration; 19 | 20 | import org.apache.sqoop.model.ConfigurationClass; 21 | import org.apache.sqoop.model.Form; 22 | 23 | /** 24 | * 25 | */ 26 | @ConfigurationClass 27 | public class ImportJobConfiguration { 28 | 29 | @Form public OutputForm output; 30 | 31 | @Form public ThrottlingForm throttling; 32 | 33 | public ImportJobConfiguration() { 34 | output = new OutputForm(); 35 | throttling = new ThrottlingForm(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/sqoop/framework/configuration/InputForm.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.framework.configuration; 19 | 20 | import org.apache.sqoop.model.FormClass; 21 | import org.apache.sqoop.model.Input; 22 | 23 | /** 24 | * 25 | */ 26 | @FormClass 27 | public class InputForm { 28 | 29 | @Input(size = 50) public String inputDirectory; 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/sqoop/framework/configuration/OutputForm.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.framework.configuration; 19 | 20 | import org.apache.sqoop.model.FormClass; 21 | import org.apache.sqoop.model.Input; 22 | 23 | /** 24 | * 25 | */ 26 | @FormClass 27 | public class OutputForm { 28 | 29 | @Input public StorageType storageType; 30 | 31 | @Input public OutputFormat outputFormat; 32 | 33 | @Input(size = 25) public String outputDirectory; 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/sqoop/framework/configuration/OutputFormat.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.framework.configuration; 19 | 20 | /** 21 | * Various supported formats on disk 22 | */ 23 | public enum OutputFormat { 24 | /** 25 | * Comma separated text file 26 | */ 27 | TEXT_FILE, 28 | 29 | /** 30 | * Sequence file 31 | */ 32 | SEQUENCE_FILE, 33 | } 34 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/sqoop/framework/configuration/SecurityForm.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.framework.configuration; 19 | 20 | import org.apache.sqoop.model.FormClass; 21 | import org.apache.sqoop.model.Input; 22 | 23 | /** 24 | * Security form 25 | */ 26 | @FormClass 27 | public class SecurityForm { 28 | @Input public Integer maxConnections; 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/sqoop/framework/configuration/StorageType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.framework.configuration; 19 | 20 | /** 21 | * Various storage types that Sqoop is supporting 22 | */ 23 | public enum StorageType { 24 | /** 25 | * Direct HDFS import 26 | */ 27 | HDFS, 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/sqoop/framework/configuration/ThrottlingForm.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.framework.configuration; 19 | 20 | import org.apache.sqoop.model.FormClass; 21 | import org.apache.sqoop.model.Input; 22 | 23 | /** 24 | * Form to set up number of loaders and extractors 25 | */ 26 | @FormClass 27 | public class ThrottlingForm { 28 | 29 | @Input public Integer extractors; 30 | 31 | @Input public Integer loaders; 32 | } 33 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryTransactionFactory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.repository; 19 | 20 | import javax.sql.DataSource; 21 | 22 | public class JdbcRepositoryTransactionFactory extends 23 | ThreadLocal { 24 | 25 | private final DataSource dataSource; 26 | 27 | protected JdbcRepositoryTransactionFactory(DataSource dataSource) { 28 | super(); 29 | this.dataSource = dataSource; 30 | } 31 | 32 | @Override 33 | protected JdbcRepositoryTransaction initialValue() { 34 | return new JdbcRepositoryTransaction(dataSource, this); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/sqoop/repository/JdbcTransactionIsolation.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.repository; 19 | 20 | import java.sql.Connection; 21 | 22 | public enum JdbcTransactionIsolation { 23 | 24 | READ_UNCOMMITTED("READ_UNCOMMITTED", Connection.TRANSACTION_READ_UNCOMMITTED), 25 | READ_COMMITTED("READ_COMMITTED", Connection.TRANSACTION_READ_COMMITTED), 26 | REPEATABLE_READ("REPEATABLE_READ", Connection.TRANSACTION_REPEATABLE_READ), 27 | SERIALIZABLE("SERIALIZABLE", Connection.TRANSACTION_SERIALIZABLE); 28 | 29 | private final String name; 30 | private final int code; 31 | 32 | private JdbcTransactionIsolation(String name, int code) { 33 | this.name = name; 34 | this.code = code; 35 | } 36 | 37 | public int getCode() { 38 | return code; 39 | } 40 | 41 | public String getName() { 42 | return name; 43 | } 44 | 45 | public String toString() { 46 | return getName(); 47 | } 48 | 49 | public static JdbcTransactionIsolation getByName(String name) { 50 | if (name == null || name.trim().length() == 0) { 51 | return null; 52 | } 53 | return valueOf(name.trim().toUpperCase()); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/sqoop/repository/RepositoryProvider.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.repository; 19 | 20 | import org.apache.sqoop.common.MapContext; 21 | 22 | public interface RepositoryProvider { 23 | 24 | void initialize(MapContext context); 25 | 26 | void destroy(); 27 | 28 | Repository getRepository(); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/org/apache/sqoop/repository/RepositoryTransaction.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.repository; 19 | 20 | /** 21 | * A transaction that can be used to group multiple repository operations into 22 | * a single transaction. 23 | */ 24 | public interface RepositoryTransaction { 25 | 26 | void begin(); 27 | 28 | void commit(); 29 | 30 | void rollback(); 31 | 32 | void close(); 33 | } 34 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/sqoop/core/MockInvalidConfigurationProvider.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.core; 19 | 20 | import java.io.File; 21 | import java.util.Map; 22 | import java.util.Properties; 23 | 24 | public class MockInvalidConfigurationProvider implements ConfigurationProvider { 25 | 26 | public MockInvalidConfigurationProvider() { 27 | throw new RuntimeException("Cannot instantiate"); 28 | } 29 | 30 | @Override 31 | public void initialize(File configDir, Properties bootstrapCongiruation) { 32 | // TODO Auto-generated method stub 33 | 34 | } 35 | 36 | @Override 37 | public void registerListener(ConfigurationListener listener) { 38 | // TODO Auto-generated method stub 39 | 40 | } 41 | 42 | @Override 43 | public Map getConfiguration() { 44 | // TODO Auto-generated method stub 45 | return null; 46 | } 47 | 48 | @Override 49 | public void destroy() { 50 | // TODO Auto-generated method stub 51 | 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /core/src/test/java/org/apache/sqoop/repository/TestRepositoryManager.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.repository; 19 | 20 | import java.util.Properties; 21 | 22 | import org.apache.sqoop.common.SqoopException; 23 | import org.apache.sqoop.core.ConfigurationConstants; 24 | import org.apache.sqoop.core.PropertiesConfigurationProvider; 25 | import org.apache.sqoop.core.SqoopConfiguration; 26 | import org.apache.sqoop.core.TestUtils; 27 | import org.junit.Assert; 28 | import org.junit.Test; 29 | 30 | public class TestRepositoryManager { 31 | 32 | @Test 33 | public void testSystemNotInitialized() throws Exception { 34 | // Unset any configuration dir if it is set by another test 35 | System.getProperties().remove(ConfigurationConstants.SYSPROP_CONFIG_DIR); 36 | Properties bootProps = new Properties(); 37 | bootProps.setProperty(ConfigurationConstants.BOOTCFG_CONFIG_PROVIDER, 38 | PropertiesConfigurationProvider.class.getCanonicalName()); 39 | Properties configProps = new Properties(); 40 | TestUtils.setupTestConfigurationUsingProperties(bootProps, configProps); 41 | try { 42 | SqoopConfiguration.getInstance().initialize(); 43 | RepositoryManager.getInstance().initialize(); 44 | } catch (Exception ex) { 45 | Assert.assertTrue(ex instanceof SqoopException); 46 | Assert.assertSame(((SqoopException) ex).getErrorCode(), 47 | RepositoryError.REPO_0001); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /core/src/test/resources/test_config.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # General configuration 17 | org.apache.sqoop.foo = bar 18 | 19 | 20 | # Logging Configuration 21 | org.apache.sqoop.log4j.rootLogger=warn, console 22 | org.apache.sqoop.log4j.logger.org.apache.sqoop=debug,console 23 | org.apache.sqoop.log4j.appender.console=org.apache.log4j.ConsoleAppender 24 | org.apache.sqoop.log4j.appender.console.layout=org.apache.log4j.PatternLayout 25 | org.apache.sqoop.log4j.appender.console.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n 26 | -------------------------------------------------------------------------------- /dist/src/main/bin/sqoop.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one or more 4 | # contributor license agreements. See the NOTICE file distributed with 5 | # this work for additional information regarding copyright ownership. 6 | # The ASF licenses this file to You under the Apache License, Version 2.0 7 | # (the "License"); you may not use this file except in compliance with 8 | # the License. You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | function print_usage(){ 19 | echo "Usage: sqoop.sh COMMAND" 20 | echo " where COMMAND is one of:" 21 | echo " server Start/stop the server" 22 | echo " client [script] Start an interactive shell without a script" 23 | echo " or run a script with a batch shell" 24 | echo "" 25 | } 26 | 27 | if [ $# = 0 ]; then 28 | print_usage 29 | exit 30 | fi 31 | 32 | OLD_DIR=`pwd` 33 | CUR_DIR=`cd $(dirname $(which $0))/..; pwd` 34 | cd ${CUR_DIR} 35 | echo "Sqoop home directory: ${CUR_DIR}..." 36 | 37 | CATALINA_BIN=${CATALINA_BIN:-server/bin} 38 | CLIENT_LIB=${CLIENT_LIB:-client/lib} 39 | 40 | COMMAND=$1 41 | case $COMMAND in 42 | server) 43 | if [ $# = 1 ]; then 44 | echo "Usage: sqoop.sh server " 45 | exit 46 | fi 47 | 48 | $CATALINA_BIN/catalina.sh $2 49 | ;; 50 | 51 | client) 52 | # Build class path with full path to each library 53 | for f in $CLIENT_LIB/*.jar; do 54 | CLASSPATH="${CLASSPATH}:$CUR_DIR/$f" 55 | done 56 | 57 | # We need to change current directory back to original as optional user side script 58 | # might be specified with relative path. 59 | cd ${OLD_DIR} 60 | java -classpath ${CLASSPATH} org.apache.sqoop.client.shell.SqoopShell $2 61 | ;; 62 | 63 | *) 64 | echo "Command is not recognized." 65 | ;; 66 | esac 67 | 68 | cd ${OLD_DIR} 69 | -------------------------------------------------------------------------------- /dist/src/main/server/bin/setenv.bat: -------------------------------------------------------------------------------- 1 | :: 2 | :: Licensed to the Apache Software Foundation (ASF) under one or more 3 | :: contributor license agreements. See the NOTICE file distributed with 4 | :: this work for additional information regarding copyright ownership. 5 | :: The ASF licenses this file to You under the Apache License, Version 2.0 6 | :: (the "License"); you may not use this file except in compliance with 7 | :: the License. You may obtain a copy of the License at 8 | :: 9 | :: http://www.apache.org/licenses/LICENSE-2.0 10 | :: 11 | :: Unless required by applicable law or agreed to in writing, software 12 | :: distributed under the License is distributed on an "AS IS" BASIS, 13 | :: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | :: See the License for the specific language governing permissions and 15 | :: limitations under the License. 16 | :: 17 | set JAVA_OPTS=-Dsqoop.config.dir=%~dp0 -------------------------------------------------------------------------------- /dist/src/main/server/bin/setenv.sh: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | JAVA_OPTS=-Dsqoop.config.dir=`dirname $0`/../conf 18 | -------------------------------------------------------------------------------- /dist/src/main/server/conf/sqoop_bootstrap.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | # 19 | # Bootstrap configuration for Sqoop. This file is picked up 20 | # from the directory specified by the system property 21 | # "sqoop.config.dir". Sqoop will not boot up if this property 22 | # is not set, or if there is no file by the name 23 | # "sqoop_bootstrap.properties" in the directory pointed by 24 | # this system property. 25 | # 26 | 27 | # 28 | # Specifies the configuration provider to be used. 29 | # This is a required configuration that must be specified. 30 | # The default value for this is: 31 | # org.apache.sqoop.core.PropertiesConfigurationProvider 32 | # The PropertiesConfigurationProvider expects the system 33 | # configuration directory to be specified by the system 34 | # property "sqoop.config.dir", and it must contain a file 35 | # by the name "sqoop.properties". 36 | # 37 | sqoop.config.provider=org.apache.sqoop.core.PropertiesConfigurationProvider 38 | 39 | -------------------------------------------------------------------------------- /dist/src/main/server/webapps/ROOT/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 26 | 27 | ROOT 28 | 29 | 30 | -------------------------------------------------------------------------------- /dist/src/main/server/webapps/ROOT/index.html: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | Apache Sqoop ROOT 21 | 22 | Apache Sqoop ROOT 23 | 24 | 25 | -------------------------------------------------------------------------------- /docs/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 21 | 22 | Apache Sqoop 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /docs/src/main/webapp/index.html: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | Apache Sqoop 20 | 21 | Apache Sqoop 22 | 23 | 24 | -------------------------------------------------------------------------------- /docs/src/site/sphinx/sqoop-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudera/sqoop2/a3b41c1aea89e479a677370a39e102f68ff7ac2b/docs/src/site/sphinx/sqoop-logo.png -------------------------------------------------------------------------------- /execution/mapreduce/src/main/java/org/apache/sqoop/job/io/FieldTypes.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.job.io; 19 | 20 | public final class FieldTypes { 21 | 22 | public static final int NULL = 0; 23 | 24 | public static final int BOOLEAN = 1; 25 | 26 | public static final int BYTE = 10; 27 | public static final int CHAR = 11; 28 | 29 | public static final int SHORT = 20; 30 | public static final int INT = 21; 31 | public static final int LONG = 22; 32 | 33 | public static final int FLOAT = 50; 34 | public static final int DOUBLE = 51; 35 | 36 | public static final int BIN = 100; 37 | public static final int UTF = 101; 38 | 39 | private FieldTypes() { 40 | // Disable explicit object creation 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/SqoopReducer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.job.mr; 19 | 20 | import org.apache.commons.logging.Log; 21 | import org.apache.commons.logging.LogFactory; 22 | import org.apache.hadoop.io.NullWritable; 23 | import org.apache.hadoop.mapreduce.Reducer; 24 | import org.apache.sqoop.job.io.Data; 25 | 26 | /** 27 | * A reducer to perform reduce function. 28 | */ 29 | public class SqoopReducer 30 | extends Reducer { 31 | 32 | public static final Log LOG = 33 | LogFactory.getLog(SqoopReducer.class.getName()); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /execution/mapreduce/src/test/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # Set root logger level to DEBUG and its only appender to A1. 17 | log4j.rootLogger=DEBUG, A1 18 | 19 | # A1 is set to be a ConsoleAppender. 20 | log4j.appender.A1=org.apache.log4j.ConsoleAppender 21 | 22 | # A1 uses PatternLayout. 23 | log4j.appender.A1.layout=org.apache.log4j.PatternLayout 24 | log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n 25 | -------------------------------------------------------------------------------- /execution/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 4.0.0 20 | 21 | 22 | org.apache 23 | sqoop 24 | 1.99.1-cdh4.2.1 25 | 26 | 27 | org.apache.sqoop 28 | execution 29 | Sqoop Execution Engines 30 | pom 31 | 32 | 33 | mapreduce 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /repository/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 21 | 22 | 4.0.0 23 | 24 | 25 | org.apache 26 | sqoop 27 | 1.99.1-cdh4.2.1 28 | 29 | 30 | org.apache.sqoop 31 | repository 32 | Sqoop Repository 33 | pom 34 | 35 | 36 | repository-derby 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /repository/repository-derby/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 21 | 22 | 4.0.0 23 | 24 | 25 | org.apache.sqoop 26 | repository 27 | 1.99.1-cdh4.2.1 28 | 29 | 30 | org.apache.sqoop.repository 31 | sqoop-repository-derby 32 | Sqoop Derby Repository 33 | 34 | 35 | 36 | org.apache.sqoop 37 | sqoop-core 38 | 39 | 40 | 41 | org.apache.derby 42 | derby 43 | 44 | 45 | 46 | junit 47 | junit 48 | test 49 | 50 | 51 | 52 | org.apache.sqoop 53 | sqoop-core 54 | test-jar 55 | test 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoConfigurationConstants.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.repository.derby; 19 | 20 | public final class DerbyRepoConfigurationConstants { 21 | 22 | public static final String PREFIX_DERBY = "derby."; 23 | 24 | private DerbyRepoConfigurationConstants() { 25 | // Disable explicit object creation 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /server/src/main/java/org/apache/sqoop/handler/FrameworkRequestHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.handler; 19 | 20 | import org.apache.log4j.Logger; 21 | import org.apache.sqoop.common.SqoopException; 22 | import org.apache.sqoop.framework.FrameworkManager; 23 | import org.apache.sqoop.json.FrameworkBean; 24 | import org.apache.sqoop.json.JsonBean; 25 | import org.apache.sqoop.server.RequestContext; 26 | import org.apache.sqoop.server.RequestHandler; 27 | 28 | /** 29 | * 30 | */ 31 | public class FrameworkRequestHandler implements RequestHandler { 32 | 33 | private static final Logger LOG = 34 | Logger.getLogger(ConnectorRequestHandler.class); 35 | 36 | public FrameworkRequestHandler() { 37 | LOG.info("FrameworkRequestHandler initialized"); 38 | } 39 | 40 | @Override 41 | public JsonBean handleEvent(RequestContext ctx) { 42 | return new FrameworkBean(FrameworkManager.getInstance().getFramework(), 43 | FrameworkManager.getInstance().getBundle(ctx.getAcceptLanguageHeader())); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /server/src/main/java/org/apache/sqoop/handler/VersionRequestHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.handler; 19 | 20 | import org.apache.log4j.Logger; 21 | import org.apache.sqoop.common.VersionInfo; 22 | import org.apache.sqoop.common.SqoopException; 23 | import org.apache.sqoop.json.JsonBean; 24 | import org.apache.sqoop.json.VersionBean; 25 | import org.apache.sqoop.server.RequestContext; 26 | import org.apache.sqoop.server.RequestHandler; 27 | 28 | public class VersionRequestHandler implements RequestHandler { 29 | 30 | private static final Logger LOG = 31 | Logger.getLogger(VersionRequestHandler.class); 32 | 33 | /** The API version supported by this server */ 34 | public static final String PROTOCOL_V1 = "1"; 35 | 36 | 37 | private final VersionBean versionBean; 38 | 39 | public VersionRequestHandler() { 40 | String[] protocols = { PROTOCOL_V1 }; 41 | versionBean = new VersionBean(VersionInfo.getVersion(), 42 | VersionInfo.getRevision(), VersionInfo.getDate(), 43 | VersionInfo.getUser(), VersionInfo.getUrl(), protocols); 44 | 45 | LOG.info("VersionRequestHandler initialized"); 46 | } 47 | 48 | 49 | @Override 50 | public JsonBean handleEvent(RequestContext ctx) { 51 | return versionBean; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /server/src/main/java/org/apache/sqoop/server/RequestHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.server; 19 | 20 | 21 | import org.apache.sqoop.json.JsonBean; 22 | 23 | public interface RequestHandler { 24 | 25 | JsonBean handleEvent(RequestContext ctx); 26 | } 27 | -------------------------------------------------------------------------------- /server/src/main/java/org/apache/sqoop/server/VersionServlet.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.server; 19 | 20 | import org.apache.sqoop.handler.VersionRequestHandler; 21 | import org.apache.sqoop.json.JsonBean; 22 | 23 | /** 24 | * Exposes the supported versions available in the server. 25 | * 26 | */ 27 | @SuppressWarnings("serial") 28 | public class VersionServlet extends SqoopProtocolServlet { 29 | 30 | private RequestHandler versionRequestHandler; 31 | 32 | public VersionServlet() { 33 | versionRequestHandler = new VersionRequestHandler(); 34 | } 35 | 36 | @Override 37 | protected JsonBean handleGetRequest(RequestContext ctx) throws Exception { 38 | return versionRequestHandler.handleEvent(ctx); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /server/src/main/java/org/apache/sqoop/server/common/ServerError.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.server.common; 19 | 20 | import org.apache.sqoop.common.ErrorCode; 21 | 22 | /** 23 | * 24 | */ 25 | public enum ServerError implements ErrorCode { 26 | 27 | /** Unknown error on server side. */ 28 | SERVER_0001("Unknown server error"), 29 | 30 | /** Unknown error on server side. */ 31 | SERVER_0002("Unsupported HTTP method"), 32 | 33 | /** We've received invalid HTTP request */ 34 | SERVER_0003("Invalid HTTP request"), 35 | 36 | /** Invalid argument in HTTP request */ 37 | SERVER_0004("Invalid argument in HTTP request"), 38 | 39 | ; 40 | 41 | private final String message; 42 | 43 | private ServerError(String message) { 44 | this.message = message; 45 | } 46 | 47 | public String getCode() { 48 | return name(); 49 | } 50 | 51 | public String getMessage() { 52 | return message; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /server/src/main/java/org/apache/sqoop/server/v1/ConnectionServlet.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.server.v1; 19 | 20 | import org.apache.sqoop.handler.ConnectionRequestHandler; 21 | import org.apache.sqoop.json.JsonBean; 22 | import org.apache.sqoop.server.RequestContext; 23 | import org.apache.sqoop.server.RequestHandler; 24 | import org.apache.sqoop.server.SqoopProtocolServlet; 25 | 26 | /** 27 | * 28 | */ 29 | public class ConnectionServlet extends SqoopProtocolServlet { 30 | 31 | private RequestHandler requestHandler; 32 | 33 | public ConnectionServlet() { 34 | requestHandler = new ConnectionRequestHandler(); 35 | } 36 | 37 | @Override 38 | protected JsonBean handleGetRequest(RequestContext ctx) throws Exception { 39 | return requestHandler.handleEvent(ctx); 40 | } 41 | 42 | @Override 43 | protected JsonBean handlePostRequest(RequestContext ctx) throws Exception { 44 | return requestHandler.handleEvent(ctx); 45 | } 46 | 47 | @Override 48 | protected JsonBean handlePutRequest(RequestContext ctx) throws Exception { 49 | return requestHandler.handleEvent(ctx); 50 | } 51 | 52 | @Override 53 | protected JsonBean handleDeleteRequest(RequestContext ctx) throws Exception { 54 | return requestHandler.handleEvent(ctx); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /server/src/main/java/org/apache/sqoop/server/v1/ConnectorServlet.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.server.v1; 19 | 20 | import org.apache.sqoop.handler.ConnectorRequestHandler; 21 | import org.apache.sqoop.json.JsonBean; 22 | import org.apache.sqoop.server.RequestContext; 23 | import org.apache.sqoop.server.RequestHandler; 24 | import org.apache.sqoop.server.SqoopProtocolServlet; 25 | 26 | /** 27 | * Displays the list of connectors that are available in the system via 28 | * a GET request. 29 | */ 30 | @SuppressWarnings("serial") 31 | public class ConnectorServlet extends SqoopProtocolServlet { 32 | 33 | private RequestHandler connectorRequestHandler; 34 | 35 | public ConnectorServlet() { 36 | connectorRequestHandler = new ConnectorRequestHandler(); 37 | } 38 | 39 | @Override 40 | protected JsonBean handleGetRequest(RequestContext ctx) throws Exception { 41 | return connectorRequestHandler.handleEvent(ctx); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /server/src/main/java/org/apache/sqoop/server/v1/FrameworkServlet.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.server.v1; 19 | 20 | import org.apache.sqoop.handler.FrameworkRequestHandler; 21 | import org.apache.sqoop.json.JsonBean; 22 | import org.apache.sqoop.server.RequestContext; 23 | import org.apache.sqoop.server.RequestHandler; 24 | import org.apache.sqoop.server.SqoopProtocolServlet; 25 | 26 | /** 27 | * Get framework metadata 28 | */ 29 | public class FrameworkServlet extends SqoopProtocolServlet { 30 | private RequestHandler frameworkRequestHandler; 31 | 32 | public FrameworkServlet() { 33 | frameworkRequestHandler = new FrameworkRequestHandler(); 34 | } 35 | 36 | @Override 37 | protected JsonBean handleGetRequest(RequestContext ctx) throws Exception { 38 | return frameworkRequestHandler.handleEvent(ctx); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /server/src/main/java/org/apache/sqoop/server/v1/JobServlet.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.server.v1; 19 | 20 | import org.apache.sqoop.handler.JobRequestHandler; 21 | import org.apache.sqoop.json.JsonBean; 22 | import org.apache.sqoop.server.RequestContext; 23 | import org.apache.sqoop.server.RequestHandler; 24 | import org.apache.sqoop.server.SqoopProtocolServlet; 25 | 26 | /** 27 | * 28 | */ 29 | public class JobServlet extends SqoopProtocolServlet { 30 | 31 | private RequestHandler requestHandler; 32 | 33 | public JobServlet() { 34 | requestHandler = new JobRequestHandler(); 35 | } 36 | 37 | @Override 38 | protected JsonBean handleGetRequest(RequestContext ctx) throws Exception { 39 | return requestHandler.handleEvent(ctx); 40 | } 41 | 42 | @Override 43 | protected JsonBean handlePostRequest(RequestContext ctx) throws Exception { 44 | return requestHandler.handleEvent(ctx); 45 | } 46 | 47 | @Override 48 | protected JsonBean handlePutRequest(RequestContext ctx) throws Exception { 49 | return requestHandler.handleEvent(ctx); 50 | } 51 | 52 | @Override 53 | protected JsonBean handleDeleteRequest(RequestContext ctx) throws Exception { 54 | return requestHandler.handleEvent(ctx); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /server/src/main/java/org/apache/sqoop/server/v1/SubmissionServlet.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.server.v1; 19 | 20 | import org.apache.sqoop.handler.SubmissionRequestHandler; 21 | import org.apache.sqoop.json.JsonBean; 22 | import org.apache.sqoop.server.RequestContext; 23 | import org.apache.sqoop.server.RequestHandler; 24 | import org.apache.sqoop.server.SqoopProtocolServlet; 25 | 26 | /** 27 | * 28 | */ 29 | public class SubmissionServlet extends SqoopProtocolServlet { 30 | 31 | private RequestHandler requestHandler; 32 | 33 | public SubmissionServlet() { 34 | requestHandler = new SubmissionRequestHandler(); 35 | } 36 | 37 | @Override 38 | protected JsonBean handleGetRequest(RequestContext ctx) throws Exception { 39 | return requestHandler.handleEvent(ctx); 40 | } 41 | 42 | @Override 43 | protected JsonBean handlePostRequest(RequestContext ctx) throws Exception { 44 | return requestHandler.handleEvent(ctx); 45 | } 46 | 47 | @Override 48 | protected JsonBean handleDeleteRequest(RequestContext ctx) throws Exception { 49 | return requestHandler.handleEvent(ctx); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /server/src/main/webapp/index.html: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | Apache Sqoop Server 20 | 21 | Apache Sqoop Server 22 | 23 | 24 | -------------------------------------------------------------------------------- /spi/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 21 | 22 | 4.0.0 23 | 24 | 25 | org.apache 26 | sqoop 27 | 1.99.1-cdh4.2.1 28 | 29 | 30 | org.apache.sqoop 31 | sqoop-spi 32 | Sqoop SPI 33 | 34 | 35 | 36 | org.apache.sqoop 37 | sqoop-common 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /spi/src/main/java/org/apache/sqoop/job/Constants.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.job; 19 | 20 | public class Constants { 21 | 22 | /** 23 | * All job related configuration is prefixed with this: 24 | * org.apache.sqoop.job. 25 | */ 26 | public static final String PREFIX_CONFIG = "org.apache.sqoop.job."; 27 | 28 | public static final String JOB_ETL_NUMBER_PARTITIONS = PREFIX_CONFIG 29 | + "etl.number.partitions"; 30 | 31 | public static final String JOB_ETL_FIELD_NAMES = PREFIX_CONFIG 32 | + "etl.field.names"; 33 | 34 | public static final String JOB_ETL_OUTPUT_DIRECTORY = PREFIX_CONFIG 35 | + "etl.output.directory"; 36 | 37 | public static final String JOB_ETL_INPUT_DIRECTORY = PREFIX_CONFIG 38 | + "etl.input.directory"; 39 | 40 | protected Constants() { 41 | // Disable explicit object creation 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /spi/src/main/java/org/apache/sqoop/job/etl/CallbackBase.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.job.etl; 19 | 20 | /** 21 | * Set of default callbacks that must be implement by each job type. 22 | */ 23 | public abstract class CallbackBase { 24 | 25 | private Class initializer; 26 | private Class destroyer; 27 | 28 | public CallbackBase( 29 | Class initializer, 30 | Class destroyer 31 | ) { 32 | this.initializer = initializer; 33 | this.destroyer = destroyer; 34 | } 35 | 36 | public Class getDestroyer() { 37 | return destroyer; 38 | } 39 | 40 | public Class getInitializer() { 41 | return initializer; 42 | } 43 | 44 | @Override 45 | public String toString() { 46 | return "initializer=" + initializer.getName() + 47 | ", destroyer=" + destroyer.getName(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /spi/src/main/java/org/apache/sqoop/job/etl/Destroyer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.job.etl; 19 | 20 | import org.apache.sqoop.common.ImmutableContext; 21 | 22 | /** 23 | * This allows connector to define work to complete execution, for example, 24 | * resource cleaning. 25 | */ 26 | public abstract class Destroyer { 27 | 28 | /** 29 | * Callback to clean up after job execution. 30 | * 31 | * @param success True if the execution was successfull 32 | * @param context Connector context object 33 | * @param connectionConfiguration Connection configuration object 34 | * @param jobConfiguration Job configuration object 35 | */ 36 | public abstract void destroy(boolean success, 37 | ImmutableContext context, 38 | ConnectionConfiguration connectionConfiguration, 39 | JobConfiguration jobConfiguration); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /spi/src/main/java/org/apache/sqoop/job/etl/Exporter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.job.etl; 19 | 20 | /** 21 | * This specifies classes that perform connector-defined steps 22 | * within export execution: 23 | * Initializer 24 | * -> (framework-defined steps) 25 | * -> Loader 26 | * -> Destroyer 27 | */ 28 | public class Exporter extends CallbackBase { 29 | 30 | private Class loader; 31 | 32 | public Exporter( 33 | Class initializer, 34 | Class loader, 35 | Class destroyer 36 | ) { 37 | super(initializer, destroyer); 38 | this.loader = loader; 39 | } 40 | 41 | public Class getLoader() { 42 | return loader; 43 | } 44 | 45 | @Override 46 | public String toString() { 47 | return "Exporter{" + super.toString() + 48 | ", loader=" + loader + 49 | '}'; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /spi/src/main/java/org/apache/sqoop/job/etl/Importer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.job.etl; 19 | 20 | /** 21 | * This specifies classes that perform connector-defined steps 22 | * within import execution: 23 | * Initializer 24 | * -> Partitioner 25 | * -> Extractor 26 | * -> (framework-defined steps) 27 | * -> Destroyer 28 | */ 29 | public class Importer extends CallbackBase { 30 | 31 | private Class partitioner; 32 | private Class extractor; 33 | 34 | public Importer(Class initializer, 35 | Class partitioner, 36 | Class extractor, 37 | Class destroyer) { 38 | super(initializer, destroyer); 39 | this.partitioner = partitioner; 40 | this.extractor = extractor; 41 | } 42 | 43 | public Class getPartitioner() { 44 | return partitioner; 45 | } 46 | 47 | public Class getExtractor() { 48 | return extractor; 49 | } 50 | 51 | @Override 52 | public String toString() { 53 | return "Importer{" + super.toString() + 54 | ", partitioner=" + partitioner.getName() + 55 | ", extractor=" + extractor.getName() + 56 | '}'; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /spi/src/main/java/org/apache/sqoop/job/etl/Loader.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.job.etl; 19 | 20 | import org.apache.sqoop.common.ImmutableContext; 21 | import org.apache.sqoop.job.io.DataReader; 22 | 23 | /** 24 | * This allows connector to load data into a target system. 25 | */ 26 | public abstract class Loader { 27 | 28 | /** 29 | * Load data to target. 30 | * 31 | * @param context Context object 32 | * @param connectionConfiguration Connection configuration 33 | * @param jobConfiguration Job configuration 34 | * @param reader Data reader object 35 | * @throws Exception 36 | */ 37 | public abstract void load(ImmutableContext context, 38 | ConnectionConfiguration connectionConfiguration, 39 | JobConfiguration jobConfiguration, 40 | DataReader reader) throws Exception; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /spi/src/main/java/org/apache/sqoop/job/etl/Partition.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.job.etl; 19 | 20 | import java.io.DataInput; 21 | import java.io.DataOutput; 22 | import java.io.IOException; 23 | 24 | /** 25 | * A part of the input data partitioned by the Partitioner. 26 | */ 27 | public abstract class Partition { 28 | 29 | /** 30 | * Deserialize the fields of this partition from input. 31 | */ 32 | public abstract void readFields(DataInput in) throws IOException; 33 | 34 | /** 35 | * Serialize the fields of this partition to output. 36 | */ 37 | public abstract void write(DataOutput out) throws IOException; 38 | 39 | /** 40 | * Each partition must be easily serializable to human readable form so that 41 | * it can be logged for debugging purpose. 42 | * 43 | * @return Human readable representation 44 | */ 45 | public abstract String toString(); 46 | } 47 | -------------------------------------------------------------------------------- /spi/src/main/java/org/apache/sqoop/job/etl/Partitioner.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.job.etl; 19 | 20 | import org.apache.sqoop.common.ImmutableContext; 21 | 22 | import java.util.List; 23 | 24 | /** 25 | * This allows connector to define how input data to be partitioned. 26 | * The number of data partitions also determines the degree of parallelism. 27 | */ 28 | public abstract class Partitioner { 29 | 30 | public abstract List getPartitions(ImmutableContext context, 31 | long maxPartitions, 32 | ConnectionConfiguration connectionConfiguration, 33 | JobConfiguration jobConfiguration); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /spi/src/main/java/org/apache/sqoop/job/io/DataReader.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.job.io; 19 | 20 | /** 21 | * An intermediate layer for passing data from the MR framework 22 | * to the ETL framework. 23 | */ 24 | public abstract class DataReader { 25 | 26 | public abstract Object[] readArrayRecord() throws Exception; 27 | 28 | public abstract String readCsvRecord() throws Exception; 29 | 30 | public abstract Object readContent(int type) throws Exception; 31 | 32 | public abstract void setFieldDelimiter(char fieldDelimiter); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /spi/src/main/java/org/apache/sqoop/job/io/DataWriter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.job.io; 19 | 20 | /** 21 | * An intermediate layer for passing data from the ETL framework 22 | * to the MR framework. 23 | */ 24 | public abstract class DataWriter { 25 | 26 | public abstract void writeArrayRecord(Object[] array); 27 | 28 | public abstract void writeCsvRecord(String csv); 29 | 30 | public abstract void writeContent(Object content, int type); 31 | 32 | public abstract void setFieldDelimiter(char fieldDelimiter); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /spi/src/main/java/org/apache/sqoop/validation/Validator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.validation; 19 | 20 | import org.apache.sqoop.model.MJob; 21 | 22 | /** 23 | * Connection and job metadata validator. 24 | * 25 | * This class should be extended by connector to provide configuration 26 | * validation for connection and job configuration objects. 27 | */ 28 | public class Validator { 29 | 30 | /** 31 | * Validate connection configuration object. 32 | * 33 | * @param connectionConfiguration Connection object to be validated 34 | * @return Validation status 35 | */ 36 | public Validation validateConnection(Object connectionConfiguration) { 37 | return new Validation(EmptyClass.class); 38 | } 39 | 40 | /** 41 | * Validate configuration object for job . 42 | * 43 | * @param type Type of jobs that being validated 44 | * @param jobConfiguration Job to be validated 45 | * @return Validation status 46 | */ 47 | public Validation validateJob(MJob.Type type, Object jobConfiguration) { 48 | return new Validation(EmptyClass.class); 49 | } 50 | 51 | /** 52 | * Private class with no properties to properly create dump validation 53 | * objects. 54 | */ 55 | private class EmptyClass { 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /submission/mapreduce/src/main/java/org/apache/sqoop/submission/mapreduce/Constants.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.submission.mapreduce; 19 | 20 | /** 21 | * Configuration constants for Mapreduce submission engine 22 | */ 23 | public class Constants { 24 | 25 | public static final String PREFIX_MAPREDUCE = "mapreduce."; 26 | 27 | public static final String CONF_CONFIG_DIR = 28 | PREFIX_MAPREDUCE + "configuration.directory"; 29 | 30 | private Constants() { 31 | // Instantiation is prohibited 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /submission/mapreduce/src/main/java/org/apache/sqoop/submission/mapreduce/MapreduceSubmissionError.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.sqoop.submission.mapreduce; 19 | 20 | import org.apache.sqoop.common.ErrorCode; 21 | 22 | /** 23 | * 24 | */ 25 | public enum MapreduceSubmissionError implements ErrorCode { 26 | 27 | MAPREDUCE_0001("Unknown error"), 28 | 29 | MAPREDUCE_0002("Failure on submission engine initialization"), 30 | 31 | MAPREDUCE_0003("Can't get RunningJob instance"), 32 | 33 | MAPREDUCE_0004("Unknown map reduce job status"), 34 | 35 | ; 36 | 37 | private final String message; 38 | 39 | private MapreduceSubmissionError(String message) { 40 | this.message = message; 41 | } 42 | 43 | public String getCode() { 44 | return name(); 45 | } 46 | 47 | public String getMessage() { 48 | return message; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /submission/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 4.0.0 20 | 21 | 22 | org.apache 23 | sqoop 24 | 1.99.1-cdh4.2.1 25 | 26 | 27 | org.apache.sqoop 28 | submission 29 | Sqoop Submission Engines 30 | pom 31 | 32 | 33 | mapreduce 34 | 35 | 36 | 37 | --------------------------------------------------------------------------------