5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-10 03:10:52 +08:00

SQOOP-531. Define connector execution lifecycle.

(Bilung Lee via Jarek Jarcec Cecho)


git-svn-id: https://svn.apache.org/repos/asf/sqoop/branches/sqoop2@1370203 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jarek Jarcec Cecho 2012-08-07 12:24:55 +00:00
parent d096c57fae
commit b5d0e56aa0
17 changed files with 465 additions and 0 deletions

View File

@ -22,6 +22,8 @@
import java.util.Locale;
import java.util.ResourceBundle;
import org.apache.sqoop.job.etl.Exporter;
import org.apache.sqoop.job.etl.Importer;
import org.apache.sqoop.model.MForm;
import org.apache.sqoop.model.MInput;
import org.apache.sqoop.model.MMapInput;
@ -33,6 +35,17 @@ public class GenericJdbcConnector implements SqoopConnector {
private static final List<MForm> CONNECTION_FORMS = new ArrayList<MForm>();
private static final List<MForm> JOB_FORMS = new ArrayList<MForm>();
private Importer IMPORTER = new Importer(
GenericJdbcImportInitializer.class,
GenericJdbcImportPartitioner.class,
GenericJdbcImportExtractor.class,
GenericJdbcImportDestroyer.class);
private Exporter EXPORTER = new Exporter(
GenericJdbcExportInitializer.class,
GenericJdbcExportLoader.class,
GenericJdbcExportDestroyer.class);
static {
// Build the connection form
List<MInput<?>> connFormInputs = new ArrayList<MInput<?>>();
@ -81,4 +94,14 @@ public List<MForm> getJobForms() {
return JOB_FORMS;
}
@Override
public Importer getImporter() {
return IMPORTER;
}
@Override
public Exporter getExporter() {
return EXPORTER;
}
}

View File

@ -0,0 +1,24 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.sqoop.connector.jdbc;
import org.apache.sqoop.job.etl.Destroyer;
public class GenericJdbcExportDestroyer extends Destroyer {
}

View File

@ -0,0 +1,24 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.sqoop.connector.jdbc;
import org.apache.sqoop.job.etl.Initializer;
public class GenericJdbcExportInitializer extends Initializer {
}

View File

@ -0,0 +1,24 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.sqoop.connector.jdbc;
import org.apache.sqoop.job.etl.Loader;
public class GenericJdbcExportLoader extends Loader {
}

View File

@ -0,0 +1,24 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.sqoop.connector.jdbc;
import org.apache.sqoop.job.etl.Destroyer;
public class GenericJdbcImportDestroyer extends Destroyer {
}

View File

@ -0,0 +1,24 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.sqoop.connector.jdbc;
import org.apache.sqoop.job.etl.Extractor;
public class GenericJdbcImportExtractor extends Extractor {
}

View File

@ -0,0 +1,24 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.sqoop.connector.jdbc;
import org.apache.sqoop.job.etl.Initializer;
public class GenericJdbcImportInitializer extends Initializer {
}

View File

@ -0,0 +1,24 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.sqoop.connector.jdbc;
import org.apache.sqoop.job.etl.Partitioner;
public class GenericJdbcImportPartitioner extends Partitioner {
}

View File

@ -22,6 +22,8 @@
import java.util.Locale;
import java.util.ResourceBundle;
import org.apache.sqoop.job.etl.Exporter;
import org.apache.sqoop.job.etl.Importer;
import org.apache.sqoop.model.MForm;
import org.apache.sqoop.connector.spi.SqoopConnector;
@ -46,4 +48,16 @@ public List<MForm> getJobForms() {
// TODO Auto-generated method stub
return JOB_FORMS;
}
@Override
public Importer getImporter() {
// TODO Auto-generated method stub
return null;
}
@Override
public Exporter getExporter() {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -21,6 +21,8 @@
import java.util.Locale;
import java.util.ResourceBundle;
import org.apache.sqoop.job.etl.Exporter;
import org.apache.sqoop.job.etl.Importer;
import org.apache.sqoop.model.MForm;
/**
@ -46,4 +48,15 @@ public interface SqoopConnector {
* by Sqoop to create a job object using this connector.
*/
public List<MForm> getJobForms();
/**
* @return an <tt>Importer</tt> that provides classes for performing import.
*/
public Importer getImporter();
/**
* @return an <tt>Exporter</tt> that provides classes for performing export.
*/
public Exporter getExporter();
}

View File

@ -0,0 +1,26 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.sqoop.job.etl;
/**
* This allows connector to define work to complete execution, for example,
* resource cleaning.
*/
public abstract class Destroyer {
}

View File

@ -0,0 +1,56 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.sqoop.job.etl;
/**
* This specifies classes that perform connector-defined steps
* within export execution:
* Initializer
* -> (framework-defined steps)
* -> Loader
* -> Destroyer
*/
public class Exporter {
private Class<? extends Initializer> initializer;
private Class<? extends Loader> loader;
private Class<? extends Destroyer> destroyer;
public Exporter(
Class<? extends Initializer> initializer,
Class<? extends Loader> loader,
Class<? extends Destroyer> destroyer
) {
this.initializer = initializer;
this.loader = loader;
this.destroyer = destroyer;
}
public Class<? extends Initializer> getInitializer() {
return initializer;
}
public Class<? extends Loader> getLoader() {
return loader;
}
public Class<? extends Destroyer> getDestroyer() {
return destroyer;
}
}

View File

@ -0,0 +1,26 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.sqoop.job.etl;
/**
* This allows connector to extract data from a source system
* based on each partition.
*/
public abstract class Extractor {
}

View File

@ -0,0 +1,62 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.sqoop.job.etl;
/**
* This specifies classes that perform connector-defined steps
* within import execution:
* Initializer
* -> Partitioner
* -> Extractor
* -> (framework-defined steps)
* -> Destroyer
*/
public class Importer {
private Class<? extends Initializer> initializer;
private Class<? extends Partitioner> partitioner;
private Class<? extends Extractor> extractor;
private Class<? extends Destroyer> destroyer;
public Importer(Class<? extends Initializer> initializer,
Class<? extends Partitioner> partitioner,
Class<? extends Extractor> extractor,
Class<? extends Destroyer> destroyer) {
this.initializer = initializer;
this.partitioner = partitioner;
this.extractor = extractor;
this.destroyer = destroyer;
}
public Class<? extends Initializer> getInitializer() {
return initializer;
}
public Class<? extends Partitioner> getPartitioner() {
return partitioner;
}
public Class<? extends Extractor> getExtractor() {
return extractor;
}
public Class<? extends Destroyer> getDestroyer() {
return destroyer;
}
}

View File

@ -0,0 +1,26 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.sqoop.job.etl;
/**
* This allows connector to define initialization work for execution,
* for example, context configuration.
*/
public abstract class Initializer {
}

View File

@ -0,0 +1,25 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.sqoop.job.etl;
/**
* This allows connector to load data into a target system.
*/
public abstract class Loader {
}

View File

@ -0,0 +1,26 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.sqoop.job.etl;
/**
* This allows connector to define how input data to be partitioned.
* The number of data partitions also determines the degree of parallelism.
*/
public abstract class Partitioner {
}