You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sqoop.apache.org by ab...@apache.org on 2014/10/03 08:53:15 UTC
[01/13] SQOOP-1498: Sqoop2: Repository Object refactoring (objects
prefixed with M)
Repository: sqoop
Updated Branches:
refs/heads/SQOOP-1367 e0a2b7749 -> f63c080dd
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/shell/src/main/java/org/apache/sqoop/shell/utils/FormFiller.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/utils/FormFiller.java b/shell/src/main/java/org/apache/sqoop/shell/utils/FormFiller.java
deleted file mode 100644
index a0a5dc2..0000000
--- a/shell/src/main/java/org/apache/sqoop/shell/utils/FormFiller.java
+++ /dev/null
@@ -1,939 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.shell.utils;
-
-import jline.ConsoleReader;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.lang.StringUtils;
-import org.apache.sqoop.common.Direction;
-import org.apache.sqoop.model.MBooleanInput;
-import org.apache.sqoop.model.MLink;
-import org.apache.sqoop.model.MEnumInput;
-import org.apache.sqoop.model.MForm;
-import org.apache.sqoop.model.MInput;
-import org.apache.sqoop.model.MIntegerInput;
-import org.apache.sqoop.model.MMapInput;
-import org.apache.sqoop.model.MJob;
-import org.apache.sqoop.model.MNamedElement;
-import org.apache.sqoop.model.MStringInput;
-import org.apache.sqoop.model.MValidatedElement;
-import org.apache.sqoop.validation.Message;
-import org.apache.sqoop.validation.Status;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.ResourceBundle;
-
-import static org.apache.sqoop.shell.ShellEnvironment.*;
-
-/**
- * Convenient methods for retrieving user input and CLI options.
- */
-public final class FormFiller {
-
- /**
- * Internal input that will be reused for loading names for link and
- * job objects.
- */
- private static MStringInput nameInput = new MStringInput("object-name", false, (short)25);
-
- /**
- * Fill job object based on CLI options.
- *
- * @param line Associated console reader object
- * @param job Job that user is suppose to fill in
- * @return True if we filled all inputs, false if user has stopped processing
- * @throws IOException
- */
- public static boolean fillJob(CommandLine line,
- MJob job)
- throws IOException {
-
- job.setName(line.getOptionValue("name"));
-
- // Fill in data from user
- return fillForms(line,
- job.getConnectorPart(Direction.FROM).getForms(),
- job.getFrameworkPart().getForms());
- }
-
- /**
- * Fill job object based on user input.
- *
- * @param reader Associated console reader object
- * @param job Job that user is suppose to fill in
- * @param fromConnectorBundle Connector resource bundle
- * @param driverConfigBundle Driver config resource bundle
- * @return True if we filled all inputs, false if user has stopped processing
- * @throws IOException
- */
- public static boolean fillJob(ConsoleReader reader,
- MJob job,
- ResourceBundle fromConnectorBundle,
- ResourceBundle driverConfigBundle,
- ResourceBundle toConnectorBundle)
- throws IOException {
-
- job.setName(getName(reader, job.getName()));
-
- // Fill in data from user
- return fillForms(reader,
- job.getConnectorPart(Direction.FROM).getForms(),
- fromConnectorBundle,
- job.getFrameworkPart().getForms(),
- driverConfigBundle,
- job.getConnectorPart(Direction.TO).getForms(),
- toConnectorBundle);
- }
-
- /**
- * Fill link object based on CLI options.
- *
- * @param line Associated command line options
- * @param link Link that user is suppose to fill in
- * @return True if we filled all inputs, false if user has stopped processing
- * @throws IOException
- */
- public static boolean fillConnection(CommandLine line,
- MLink link)
- throws IOException {
-
- link.setName(line.getOptionValue("name"));
-
- // Fill in data from user
- return fillForms(line,
- link.getConnectorPart().getForms(),
- link.getFrameworkPart().getForms());
- }
-
- /**
- * Fill link object based on user input.
- *
- * @param reader Associated console reader object
- * @param link Link that user is suppose to fill in
- * @param connectorConfigBundle Connector resource bundle
- * @param driverConfigBundle Driver config resource bundle
- * @return True if we filled all inputs, false if user has stopped processing
- * @throws IOException
- */
- public static boolean fillLink(ConsoleReader reader,
- MLink link,
- ResourceBundle connectorConfigBundle,
- ResourceBundle driverConfigBundle)
- throws IOException {
-
- link.setName(getName(reader, link.getName()));
-
- // Fill in data from user
- return fillForms(reader,
- link.getConnectorPart().getForms(),
- connectorConfigBundle,
- link.getFrameworkPart().getForms(),
- driverConfigBundle);
- }
-
- /**
- * Load CLI options for framework forms and connector forms.
- *
- * @param line CLI options container
- * @param connectorForms Connector forms to read or edit
- * @param frameworkForms Framework forms to read or edit
- * @return
- * @throws IOException
- */
- public static boolean fillForms(CommandLine line,
- List<MForm> connectorForms,
- List<MForm> frameworkForms)
- throws IOException {
- // Query connector forms and framework forms
- return fillForms("connector", connectorForms, line)
- && fillForms("framework", frameworkForms, line);
- }
-
- /**
- * Load all CLI options for a list of forms.
- *
- * @param prefix placed at the beginning of the CLI option key
- * @param forms Forms to read or edit
- * @param line CLI options container
- * @return
- * @throws IOException
- */
- public static boolean fillForms(String prefix,
- List<MForm> forms,
- CommandLine line)
- throws IOException {
- for (MForm form : forms) {
- if (!fillForm(prefix, form, line)) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Load all CLI options for a particular form.
- *
- * @param prefix placed at the beginning of the CLI option key
- * @param form Form to read or edit
- * @param line CLI options container
- * @return
- * @throws IOException
- */
- @SuppressWarnings("rawtypes")
- public static boolean fillForm(String prefix,
- MForm form,
- CommandLine line) throws IOException {
- for (MInput input : form.getInputs()) {
- if (!fillInput(prefix, input, line)) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Load CLI option.
- * Chooses the appropriate 'fill' method to use based on input type.
- *
- * Keys for CLI options are automatically created from the 'prefix' argument
- * and 'input' argument: <prefix>-<form name>-<input name>
- *
- * @param prefix placed at the beginning of the CLI option key
- * @param input Input that we should read or edit
- * @param line CLI options container
- * @return
- * @throws IOException
- */
- @SuppressWarnings("rawtypes")
- public static boolean fillInput(String prefix,
- MInput input,
- CommandLine line) throws IOException {
- // Based on the input type, let's perform specific load
- switch (input.getType()) {
- case STRING:
- return fillInputString(prefix, (MStringInput) input, line);
- case INTEGER:
- return fillInputInteger(prefix, (MIntegerInput) input, line);
- case BOOLEAN:
- return fillInputBoolean(prefix, (MBooleanInput) input, line);
- case MAP:
- return fillInputMap(prefix, (MMapInput) input, line);
- case ENUM:
- return fillInputEnum(prefix, (MEnumInput) input, line);
- default:
- println("Unsupported data type " + input.getType());
- return true;
- }
- }
-
- /**
- * Load CLI option for enum type.
- *
- * Currently only supports numeric values.
- *
- * @param prefix placed at the beginning of the CLI option key
- * @param input Input that we should read or edit
- * @param line CLI options container
- * @return
- * @throws IOException
- */
- private static boolean fillInputEnum(String prefix,
- MEnumInput input,
- CommandLine line)
- throws IOException {
- String opt = FormOptions.getOptionKey(prefix, input);
- if (line.hasOption(opt)) {
- String value = line.getOptionValue(opt);
- int index = java.util.Arrays.asList(input.getValues()).indexOf(value);
-
- if(index < 0) {
- errorMessage(input, String.format("Invalid option %s. Please use one of %s.", value, StringUtils.join(input.getValues(), ", ")));
- return false;
- }
-
- input.setValue(value);
- } else {
- input.setEmpty();
- }
- return true;
- }
-
- /**
- * Load CLI options for map type.
- *
- * Parses Key-Value pairs that take the form "<key>=<value>&<key>=<value>&...".
- *
- * @param prefix placed at the beginning of the CLI option key
- * @param input Input that we should read or edit
- * @param line CLI options container
- * @return
- * @throws IOException
- */
- private static boolean fillInputMap(String prefix,
- MMapInput input,
- CommandLine line)
- throws IOException {
- String opt = FormOptions.getOptionKey(prefix, input);
- if (line.hasOption(opt)) {
- String value = line.getOptionValue(opt);
- Map<String, String> values = new HashMap<String, String>();
- String[] entries = value.split("&");
- for (String entry : entries) {
- if (entry.contains("=")) {
- String[] keyValue = entry.split("=");
- values.put(keyValue[0], keyValue[1]);
- } else {
- errorMessage(input, "Don't know what to do with " + entry);
- return false;
- }
- }
- input.setValue(values);
- } else {
- input.setEmpty();
- }
- return true;
- }
-
- /**
- * Load integer input from CLI option.
- *
- * @param prefix placed at the beginning of the CLI option key
- * @param input Input that we should read or edit
- * @param line CLI options container
- * @return
- * @throws IOException
- */
- private static boolean fillInputInteger(String prefix,
- MIntegerInput input,
- CommandLine line)
- throws IOException {
- String opt = FormOptions.getOptionKey(prefix, input);
- if (line.hasOption(opt)) {
- try {
- input.setValue(Integer.valueOf(line.getOptionValue(FormOptions.getOptionKey(prefix, input))));
- } catch (NumberFormatException ex) {
- errorMessage(input, "Input is not valid integer number");
- return false;
- }
- } else {
- input.setEmpty();
- }
- return true;
- }
-
- /**
- * Load string input from CLI option.
- *
- * @param prefix placed at the beginning of the CLI option key
- * @param input Input that we should read or edit
- * @param line CLI options container
- * @return
- * @throws IOException
- */
- public static boolean fillInputString(String prefix,
- MStringInput input,
- CommandLine line)
- throws IOException {
- String opt = FormOptions.getOptionKey(prefix, input);
- if (line.hasOption(opt)) {
- String value = line.getOptionValue(FormOptions.getOptionKey(prefix, input));
- if(value.length() > input.getMaxLength()) {
- errorMessage(input, "Size of input exceeds allowance for this input"
- + " field. Maximal allowed size is " + input.getMaxLength());
- }
- input.setValue(value);
- } else {
- input.setEmpty();
- }
- return true;
- }
-
- /**
- * Load boolean input from CLI option.
- *
- * @param prefix placed at the beginning of the CLI option key
- * @param input Input that we should read or edit
- * @param line CLI options container
- * @return
- * @throws IOException
- */
- public static boolean fillInputBoolean(String prefix,
- MBooleanInput input,
- CommandLine line)
- throws IOException {
- String opt = FormOptions.getOptionKey(prefix, input);
- if (line.hasOption(opt)) {
- input.setValue(Boolean.valueOf(line.getOptionValue(FormOptions.getOptionKey(prefix, input))));
- } else {
- input.setEmpty();
- }
- return true;
- }
-
- public static boolean fillForms(ConsoleReader reader,
- List<MForm> connectorForms,
- ResourceBundle connectorConfigBundle,
- List<MForm> frameworkForms,
- ResourceBundle driverConfigBundle) throws IOException {
-
-
- // Query connector forms
- if(!fillForms(connectorForms, reader, connectorConfigBundle)) {
- return false;
- }
-
- // Query framework forms
- if(!fillForms(frameworkForms, reader, driverConfigBundle)) {
- return false;
- }
- return true;
- }
-
- public static boolean fillForms(ConsoleReader reader,
- List<MForm> fromConnectorForms,
- ResourceBundle fromConnectorBundle,
- List<MForm> frameworkForms,
- ResourceBundle driverConfigBundle,
- List<MForm> toConnectorForms,
- ResourceBundle toConnectorBundle) throws IOException {
-
-
- // From connector forms
- if(!fillForms(fromConnectorForms, reader, fromConnectorBundle)) {
- return false;
- }
-
- // Query framework forms
- if(!fillForms(frameworkForms, reader, driverConfigBundle)) {
- return false;
- }
-
- // To connector forms
- if(!fillForms(toConnectorForms, reader, toConnectorBundle)) {
- return false;
- }
-
- return true;
- }
-
- public static boolean fillForms(List<MForm> forms,
- ConsoleReader reader,
- ResourceBundle bundle)
- throws IOException {
- for (MForm form : forms) {
- if(!fillForm(form, reader, bundle)) {
- return false;
- }
- }
-
- return true;
- }
-
- @SuppressWarnings("rawtypes")
- public static boolean fillForm(MForm form,
- ConsoleReader reader,
- ResourceBundle bundle) throws IOException {
- println("");
- println(bundle.getString(form.getLabelKey()));
-
- // Print out form validation
- printValidationMessage(form, false);
- println("");
-
- for (MInput input : form.getInputs()) {
- if(!fillInput(input, reader, bundle)) {
- return false;
- }
- }
-
- return true;
- }
-
- @SuppressWarnings("rawtypes")
- public static boolean fillInput(MInput input,
- ConsoleReader reader,
- ResourceBundle bundle) throws IOException {
- // Print out validation
- printValidationMessage(input, false);
-
- // Based on the input type, let's perform specific load
- switch (input.getType()) {
- case STRING:
- return fillInputString((MStringInput) input, reader, bundle);
- case INTEGER:
- return fillInputInteger((MIntegerInput) input, reader, bundle);
- case BOOLEAN:
- return fillInputBoolean((MBooleanInput) input, reader, bundle);
- case MAP:
- return fillInputMap((MMapInput) input, reader, bundle);
- case ENUM:
- return fillInputEnum((MEnumInput) input, reader, bundle);
- default:
- println("Unsupported data type " + input.getType());
- return true;
- }
- }
-
- /**
- * Load user input for enum type.
- *
- * Print out numbered list of all available options and let user choose one
- * item from that.
- *
- * @param input Input that we should read or edit
- * @param reader Associated console reader
- * @param bundle Resource bundle
- * @return True if user with to continue with loading addtional inputs
- * @throws IOException
- */
- private static boolean fillInputEnum(MEnumInput input,
- ConsoleReader reader,
- ResourceBundle bundle)
- throws IOException {
- // Prompt in enum case
- println(bundle.getString(input.getLabelKey()) + ": ");
-
- // Indexes
- int i = -1;
- int lastChoice = -1;
-
- // Print out all values as a numbered list
- for(String value : input.getValues()) {
- i++;
-
- println(" " + i + " : " + value);
-
- // Only show last choice if not sensitive
- if(!input.isEmpty() && value.equals(input.getValue()) && !input.isSensitive()) {
- lastChoice = i;
- }
- }
-
- // Prompt
- reader.printString("Choose: ");
-
- // Fill previously filled index when available
- if(lastChoice != -1) {
- reader.putString(Integer.toString(lastChoice));
- }
-
- reader.flushConsole();
- String userTyped;
- if(input.isSensitive()) {
- userTyped = reader.readLine('*');
- } else {
- userTyped = reader.readLine();
- }
-
- if (userTyped == null) {
- return false;
- } else if (userTyped.isEmpty()) {
- input.setEmpty();
- } else {
- Integer index;
- try {
- index = Integer.valueOf(userTyped);
-
- if(index < 0 || index >= input.getValues().length) {
- errorMessage("Invalid index");
- return fillInputEnum(input, reader, bundle);
- }
-
- input.setValue(input.getValues()[index]);
- } catch (NumberFormatException ex) {
- errorMessage("Input is not valid integer number");
- return fillInputEnum(input, reader, bundle);
- }
- }
-
- return true;
- }
-
- /**
- * Load user input for map type.
- *
- * This implementation will load one map entry at the time. Current flows is
- * as follows: if user did not enter anything (empty input) finish loading
- * and return from function. If user specified input with equal sign (=),
- * lets add new key value pair. Otherwise consider entire input as a key name
- * and try to remove it from the map.
- *
- * Please note that following code do not supports equal sign in property
- * name. It's however perfectly fine to have equal sign in value.
- *
- * @param input Input that we should read or edit
- * @param reader Associated console reader
- * @param bundle Resource bundle
- * @return True if user wish to continue with loading additional inputs
- * @throws IOException
- */
- private static boolean fillInputMap(MMapInput input,
- ConsoleReader reader,
- ResourceBundle bundle)
- throws IOException {
- // Special prompt in Map case
- println(bundle.getString(input.getLabelKey()) + ": ");
-
- // Internal loading map
- Map<String, String> values = input.getValue();
- if(values == null) {
- values = new HashMap<String, String>();
- }
-
- String userTyped;
-
- while(true) {
- // Print all current items in each iteration
- // However do not printout if this input contains sensitive information.
- println("There are currently " + values.size() + " values in the map:");
- if (!input.isSensitive()) {
- for(Map.Entry<String, String> entry : values.entrySet()) {
- println(entry.getKey() + " = " + entry.getValue());
- }
- }
-
- // Special prompt for Map entry
- reader.printString("entry# ");
- reader.flushConsole();
-
- if(input.isSensitive()) {
- userTyped = reader.readLine('*');
- } else {
- userTyped = reader.readLine();
- }
-
- if(userTyped == null) {
- // Finish loading and return back to Sqoop shell
- return false;
- } else if(userTyped.isEmpty()) {
- // User has finished loading data to Map input, either set input empty
- // if there are no entries or propagate entries to the input
- if(values.size() == 0) {
- input.setEmpty();
- } else {
- input.setValue(values);
- }
- return true;
- } else {
- // User has specified regular input, let's check if it contains equals
- // sign. Save new entry (or update existing one) if it does. Otherwise
- // try to remove entry that user specified.
- if(userTyped.contains("=")) {
- String []keyValue = userTyped.split("=", 2);
- values.put(handleUserInput(keyValue[0]), handleUserInput(keyValue[1]));
- } else {
- String key = handleUserInput(userTyped);
- if(values.containsKey(key)) {
- values.remove(key);
- } else {
- errorMessage("Don't know what to do with " + userTyped);
- }
- }
- }
-
- }
- }
-
- /**
- * Handle special cases in user input.
- *
- * Preserve null and empty values, remove whitespace characters before and
- * after loaded string and de-quote the string if it's quoted (to preserve
- * spaces for example).
- *
- * @param input String loaded from user
- * @return Unquoted transformed string
- */
- private static String handleUserInput(String input) {
- // Preserve null and empty values
- if(input == null) {
- return null;
- }
- if(input.isEmpty()) {
- return input;
- }
-
- // Removes empty characters at the begging and end of loaded string
- input = input.trim();
-
- int lastIndex = input.length() - 1;
- char first = input.charAt(0);
- char last = input.charAt(lastIndex);
-
- // Remove quoting if present
- if(first == '\'' && last == '\'') {
- input = input.substring(1, lastIndex);
- } else if(first == '"' && last == '"') {
- input = input.substring(1, lastIndex);
- }
-
- // Return final string
- return input;
- }
-
- private static boolean fillInputInteger(MIntegerInput input,
- ConsoleReader reader,
- ResourceBundle bundle)
- throws IOException {
- generatePrompt(reader, bundle, input);
-
- // Fill already filled data when available
- // However do not printout if this input contains sensitive information.
- if(!input.isEmpty() && !input.isSensitive()) {
- reader.putString(input.getValue().toString());
- }
-
- // Get the data
- String userTyped;
- if(input.isSensitive()) {
- userTyped = reader.readLine('*');
- } else {
- userTyped = reader.readLine();
- }
-
- if (userTyped == null) {
- return false;
- } else if (userTyped.isEmpty()) {
- input.setEmpty();
- } else {
- Integer value;
- try {
- value = Integer.valueOf(userTyped);
- input.setValue(value);
- } catch (NumberFormatException ex) {
- errorMessage("Input is not valid integer number");
- return fillInputInteger(input, reader, bundle);
- }
-
- input.setValue(Integer.valueOf(userTyped));
- }
-
- return true;
- }
-
- /**
- * Load string input from the user.
- *
- * @param input Input that we should load in
- * @param reader Associated console reader
- * @param bundle Resource bundle for this input
- * @return
- * @throws IOException
- */
- public static boolean fillInputString(MStringInput input,
- ConsoleReader reader,
- ResourceBundle bundle)
- throws IOException {
- generatePrompt(reader, bundle, input);
-
- // Fill already filled data when available
- // However do not printout if this input contains sensitive information.
- if(!input.isEmpty() && !input.isSensitive()) {
- reader.putString(input.getValue());
- }
-
- // Get the data
- String userTyped;
- if(input.isSensitive()) {
- userTyped = reader.readLine('*');
- } else {
- userTyped = reader.readLine();
- }
-
- if (userTyped == null) {
- // Propagate end of loading process
- return false;
- } else if (userTyped.isEmpty()) {
- // Empty input in case that nothing was given
- input.setEmpty();
- } else {
- // Set value that user has entered
- input.setValue(userTyped);
-
- // Check that it did not exceeds maximal allowance for given input
- if(userTyped.length() > input.getMaxLength()) {
- errorMessage("Size of input exceeds allowance for this input"
- + " field. Maximal allowed size is " + input.getMaxLength());
- return fillInputString(input, reader, bundle);
- }
- }
-
- return true;
- }
-
- /**
- * Load boolean input from the user.
- *
- * @param input Input that we should load in
- * @param reader Associated console reader
- * @param bundle Resource bundle for this input
- * @return
- * @throws IOException
- */
- public static boolean fillInputBoolean(MBooleanInput input,
- ConsoleReader reader,
- ResourceBundle bundle)
- throws IOException {
- generatePrompt(reader, bundle, input);
-
- // Fill already filled data when available
- // However do not printout if this input contains sensitive information.
- if(!input.isEmpty() && !input.isSensitive()) {
- reader.putString(input.getValue().toString());
- }
-
- // Get the data
- String userTyped;
- if(input.isSensitive()) {
- userTyped = reader.readLine('*');
- } else {
- userTyped = reader.readLine();
- }
-
- if (userTyped == null) {
- // Propagate end of loading process
- return false;
- } else if (userTyped.isEmpty()) {
- // Empty input in case that nothing was given
- input.setEmpty();
- } else {
- // Set value that user has entered
- input.setValue(Boolean.valueOf(userTyped));
- }
-
- return true;
- }
-
- @SuppressWarnings("rawtypes")
- public static void generatePrompt(ConsoleReader reader,
- ResourceBundle bundle,
- MInput input)
- throws IOException {
- reader.printString(bundle.getString(input.getLabelKey()) + ": ");
- reader.flushConsole();
- }
-
- public static String getName(ConsoleReader reader,
- String name) throws IOException {
- if(name == null) {
- nameInput.setEmpty();
- } else {
- nameInput.setValue(name);
- }
-
- fillInputString(nameInput, reader, getResourceBundle());
-
- return nameInput.getValue();
- }
-
- /**
- * Print validation message in cases that it's not in state "FINE"
- *
- * @param element Validated element
- */
- public static void printValidationMessage(MValidatedElement element, boolean includeInputPrefix) {
- if(element.getValidationStatus() == Status.getDefault()) {
- return;
- }
-
- for(Message message : element.getValidationMessages())
- switch (message.getStatus()) {
- case UNACCEPTABLE:
- if (includeInputPrefix) {
- errorMessage(element, message.getMessage());
- } else {
- errorMessage(message.getMessage());
- }
- break;
- case ACCEPTABLE:
- if (includeInputPrefix) {
- warningMessage(element, message.getMessage());
- } else {
- warningMessage(message.getMessage());
- }
- break;
- default:
- // Simply ignore all other states for the moment
- break;
- }
- }
-
- public static void errorMessage(String message) {
- println("Error message: @|red " + message + " |@");
- }
-
- public static void errorMessage(MNamedElement input, String message) {
- print(input.getName());
- print(": ");
- errorMessage(message);
- }
-
- public static void warningMessage(String message) {
- println("Warning message: @|yellow " + message + " |@");
- }
-
- public static void warningMessage(MNamedElement input, String message) {
- print(input.getName());
- print(": ");
- warningMessage(message);
- }
-
- public static void errorIntroduction() {
- println();
- println("@|red There are issues with entered data, please revise your input:|@");
- }
-
- public static void printLinkValidationMessages(MLink link) {
- for (MForm form : link.getConnectorPart().getForms()) {
- for (MInput<?> input : form.getInputs()) {
- printValidationMessage(input, true);
- }
- }
- for (MForm form : link.getFrameworkPart().getForms()) {
- for (MInput<?> input : form.getInputs()) {
- printValidationMessage(input, true);
- }
- }
- }
-
- public static void printJobValidationMessages(MJob job) {
- for (MForm form : job.getConnectorPart(Direction.FROM).getForms()) {
- for (MInput<?> input : form.getInputs()) {
- printValidationMessage(input, true);
- }
- }
- for (MForm form : job.getFrameworkPart().getForms()) {
- for (MInput<?> input : form.getInputs()) {
- printValidationMessage(input, true);
- }
- }
- for (MForm form : job.getConnectorPart(Direction.TO).getForms()) {
- for (MInput<?> input : form.getInputs()) {
- printValidationMessage(input, true);
- }
- }
- }
-
- private FormFiller() {
- // Do not instantiate
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/shell/src/main/java/org/apache/sqoop/shell/utils/FormOptions.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/utils/FormOptions.java b/shell/src/main/java/org/apache/sqoop/shell/utils/FormOptions.java
deleted file mode 100644
index efd002e..0000000
--- a/shell/src/main/java/org/apache/sqoop/shell/utils/FormOptions.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.shell.utils;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.GnuParser;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-import org.apache.sqoop.common.SqoopException;
-import org.apache.sqoop.model.MForm;
-import org.apache.sqoop.model.MInput;
-import org.apache.sqoop.model.MInputType;
-import org.apache.sqoop.shell.core.ShellError;
-
-/**
- * Utilities for automatically creating org.apache.commons.cli.Option objects.
- */
-public class FormOptions {
- /**
- * This method is used to automatically generate keys
- * for a particular input.
- *
- * @param prefix Prefix to prepend to CLI option keys
- * @param input
- * @return
- */
- @SuppressWarnings("rawtypes")
- public static String getOptionKey(String prefix, MInput input) {
- return prefix + "-" + input.getName().replace('.', '-');
- }
-
- /**
- * This method is used to automatically generate CLI options
- * for a list of forms.
- *
- * @param prefix Prefix to prepend to CLI option keys
- * @param forms Forms to get options for
- * @return
- */
- public static List<Option> getFormsOptions(String prefix, List<MForm> forms) {
- List<Option> options = new LinkedList<Option>();
- for (MForm form : forms) {
- List<Option> formOptions = getFormOptions(prefix, form);
- options.addAll(formOptions);
- }
- return options;
- }
-
- /**
- * This method is used to automatically generate CLI options
- * for a particular form.
- *
- * @param prefix Prefix to prepend to CLI option keys
- * @param form Form to get options for
- * @return List<Option>
- */
- @SuppressWarnings({ "rawtypes", "static-access" })
- public static List<Option> getFormOptions(String prefix, MForm form) {
- List<Option> options = new LinkedList<Option>();
- for (MInput input : form.getInputs()) {
- if (input.getType().equals(MInputType.BOOLEAN)) {
- options.add(OptionBuilder
- .withLongOpt(getOptionKey(prefix, input))
- .create());
- } else {
- options.add(OptionBuilder
- .withLongOpt(getOptionKey(prefix, input))
- .hasArg()
- .create());
- }
- }
- return options;
- }
-
- /**
- * Parses command line options.
- *
- * @param options parse arglist against these.
- * @param start beginning index in arglist.
- * @param arglist arguments to parse.
- * @param stopAtNonOption stop parsing when nonoption found in arglist.
- * @return CommandLine object
- */
- public static CommandLine parseOptions(Options options, int start, List<String> arglist, boolean stopAtNonOption) {
- String[] args = arglist.subList(start, arglist.size()).toArray(new String[arglist.size() - start]);
-
- CommandLineParser parser = new GnuParser();
- CommandLine line;
- try {
- line = parser.parse(options, args, stopAtNonOption);
- } catch (ParseException e) {
- throw new SqoopException(ShellError.SHELL_0003, e.getMessage(), e);
- }
- return line;
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/shell/src/main/java/org/apache/sqoop/shell/utils/JobDynamicConfigOptions.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/utils/JobDynamicConfigOptions.java b/shell/src/main/java/org/apache/sqoop/shell/utils/JobDynamicConfigOptions.java
new file mode 100644
index 0000000..49b09c7
--- /dev/null
+++ b/shell/src/main/java/org/apache/sqoop/shell/utils/JobDynamicConfigOptions.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.shell.utils;
+
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.sqoop.common.Direction;
+import org.apache.sqoop.model.MJob;
+
+/**
+ * Automatically create dynamic options for jobs.
+ */
+@SuppressWarnings("serial")
+public class JobDynamicConfigOptions extends DynamicConfigOptions<MJob> {
+
+ @SuppressWarnings("static-access")
+ @Override
+ public void prepareOptions(MJob job) {
+ this.addOption(OptionBuilder
+ .withLongOpt("name")
+ .hasArg()
+ .create());
+ for (Option option : ConfigOptions.getConfigsOptions("from", job.getJobConfig(Direction.FROM).getConfigs())) {
+ this.addOption(option);
+ }
+ for (Option option : ConfigOptions.getConfigsOptions("driver", job.getDriverConfig().getConfigs())) {
+ this.addOption(option);
+ }
+ for (Option option : ConfigOptions.getConfigsOptions("to", job.getJobConfig(Direction.TO).getConfigs())) {
+ this.addOption(option);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/shell/src/main/java/org/apache/sqoop/shell/utils/JobDynamicFormOptions.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/utils/JobDynamicFormOptions.java b/shell/src/main/java/org/apache/sqoop/shell/utils/JobDynamicFormOptions.java
deleted file mode 100644
index 87c0776..0000000
--- a/shell/src/main/java/org/apache/sqoop/shell/utils/JobDynamicFormOptions.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.shell.utils;
-
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.sqoop.common.Direction;
-import org.apache.sqoop.model.MJob;
-
-/**
- * Automatically create dynamic options for jobs.
- */
-@SuppressWarnings("serial")
-public class JobDynamicFormOptions extends DynamicFormOptions<MJob> {
-
- @SuppressWarnings("static-access")
- @Override
- public void prepareOptions(MJob job) {
- this.addOption(OptionBuilder
- .withLongOpt("name")
- .hasArg()
- .create());
- for (Option option : FormOptions.getFormsOptions("connector", job.getConnectorPart(Direction.FROM).getForms())) {
- this.addOption(option);
- }
- for (Option option : FormOptions.getFormsOptions("framework", job.getFrameworkPart().getForms())) {
- this.addOption(option);
- }
- for (Option option : FormOptions.getFormsOptions("connector", job.getConnectorPart(Direction.TO).getForms())) {
- this.addOption(option);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/shell/src/main/java/org/apache/sqoop/shell/utils/LinkDynamicConfigOptions.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/utils/LinkDynamicConfigOptions.java b/shell/src/main/java/org/apache/sqoop/shell/utils/LinkDynamicConfigOptions.java
new file mode 100644
index 0000000..ef279f7
--- /dev/null
+++ b/shell/src/main/java/org/apache/sqoop/shell/utils/LinkDynamicConfigOptions.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.shell.utils;
+
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.sqoop.model.MLink;
+
+/**
+ * Automatically create dynamic options for connections.
+ */
+@SuppressWarnings("serial")
+public class LinkDynamicConfigOptions extends DynamicConfigOptions<MLink> {
+
+ @SuppressWarnings("static-access")
+ @Override
+ public void prepareOptions(MLink link) {
+ this.addOption(OptionBuilder.withLongOpt("name").hasArg().create());
+ for (Option option : ConfigOptions.getConfigsOptions("link", link.getConnectorLinkConfig()
+ .getConfigs())) {
+ this.addOption(option);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/shell/src/main/java/org/apache/sqoop/shell/utils/LinkDynamicFormOptions.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/utils/LinkDynamicFormOptions.java b/shell/src/main/java/org/apache/sqoop/shell/utils/LinkDynamicFormOptions.java
deleted file mode 100644
index 2952be2..0000000
--- a/shell/src/main/java/org/apache/sqoop/shell/utils/LinkDynamicFormOptions.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.shell.utils;
-
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.sqoop.model.MLink;
-
-/**
- * Automatically create dynamic options for connections.
- */
-@SuppressWarnings("serial")
-public class LinkDynamicFormOptions extends DynamicFormOptions<MLink> {
-
- @SuppressWarnings("static-access")
- @Override
- public void prepareOptions(MLink link) {
- this.addOption(OptionBuilder.withLongOpt("name").hasArg().create());
- for (Option option : FormOptions.getFormsOptions("connector", link.getConnectorPart()
- .getForms())) {
- this.addOption(option);
- }
- for (Option option : FormOptions.getFormsOptions("framework", link.getFrameworkPart()
- .getForms())) {
- this.addOption(option);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/shell/src/main/resources/shell-resource.properties
----------------------------------------------------------------------
diff --git a/shell/src/main/resources/shell-resource.properties b/shell/src/main/resources/shell-resource.properties
index c0f86f7..e2381dd 100644
--- a/shell/src/main/resources/shell-resource.properties
+++ b/shell/src/main/resources/shell-resource.properties
@@ -16,7 +16,7 @@
# Client Resources in default language (english)
############################
-# Security Form
+# Security Config
#############################
object-name.label = Name
object-name.help = Non unique name of the entity to help you remember \
@@ -200,22 +200,22 @@ table.header.status = Status
table.header.date = Last Update Date
table.header.enabled = Enabled
-#Form displayer resources
-formdisplayer.link = link
-formdisplayer.job = Job
-formdisplayer.form = form
-formdisplayer.name = Name
-formdisplayer.label = Label
-formdisplayer.help = Help
-formdisplayer.input = Input
-formdisplayer.type = Type
-formdisplayer.sensitive = Sensitive
-formdisplayer.size = Size
-formdisplayer.possible_values = Possible values
-formdisplayer.unsupported_datatype = Unsupported data type
-formdisplayer.input_sensitive = This input is sensitive
-
-formdisplayer.warning_message = There were warnings while create or update, but saved successfully.
+#Config displayer resources
+config.displayer.link = link
+config.displayer.job = Job
+config.displayer.config = config
+config.displayer.name = Name
+config.displayer.label = Label
+config.displayer.help = Help
+config.displayer.input = Input
+config.displayer.type = Type
+config.displayer.sensitive = Sensitive
+config.displayer.size = Size
+config.displayer.possible_values = Possible values
+config.displayer.unsupported_datatype = Unsupported data type
+config.displayer.input_sensitive = This input is sensitive
+
+config.displayer.warning_message = There were warnings while create or update, but saved successfully.
submission.submission_detail = Submission details
submission.job_id = Job ID
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/spi/src/main/java/org/apache/sqoop/connector/spi/RepositoryUpgrader.java
----------------------------------------------------------------------
diff --git a/spi/src/main/java/org/apache/sqoop/connector/spi/RepositoryUpgrader.java b/spi/src/main/java/org/apache/sqoop/connector/spi/RepositoryUpgrader.java
index e00b404..879e428 100644
--- a/spi/src/main/java/org/apache/sqoop/connector/spi/RepositoryUpgrader.java
+++ b/spi/src/main/java/org/apache/sqoop/connector/spi/RepositoryUpgrader.java
@@ -18,8 +18,8 @@
*/
package org.apache.sqoop.connector.spi;
-import org.apache.sqoop.model.MConnectionForms;
-import org.apache.sqoop.model.MJobForms;
+import org.apache.sqoop.model.MConfigList;
+import org.apache.sqoop.model.MLinkConfig;
/**
* Repository represents the sqoop entity store. Sqoop entities include
@@ -29,23 +29,23 @@ import org.apache.sqoop.model.MJobForms;
public abstract class RepositoryUpgrader {
/**
- * Upgrade the original connection and fill into the upgradeTarget. Note
- * that any metadata already in {@code upgradeTarget} maybe overwritten.
- * @param original - original connection metadata as in the repository
+ * Upgrade the original link config and fill into the upgradeTarget. Note
+ * that any data already in {@code upgradeTarget} maybe overwritten.
+ * @param original - original link config as in the repository
* @param upgradeTarget - the instance that will be filled in with the
- * upgraded metadata.
+ * upgraded link config.
*/
- public abstract void upgrade(MConnectionForms original,
- MConnectionForms upgradeTarget);
+ public abstract void upgrade(MLinkConfig original, MLinkConfig upgradeTarget);
/**
- * Upgrade the original job and fill into the upgradeTarget. Note
- * that any metadata already in {@code upgradeTarget} maybe overwritten.
- * This method must be called only after the connection metadata has
+ * Upgrade the original job config and fill into the upgradeTarget. Note
+ * that any config data already in {@code upgradeTarget} maybe overwritten.
+ * This method must be called only after the link config has
* already been upgraded.
- * @param original - original connection metadata as in the repository
+ * @param original - original job config as in the repository
* @param upgradeTarget - the instance that will be filled in with the
- * upgraded metadata.
+ * upgraded job config.
+ * NOTE(VB): This api will be revisited to accomodate from and to job config update
*/
- public abstract void upgrade(MJobForms original, MJobForms upgradeTarget);
+ public abstract void upgrade(MConfigList original, MConfigList upgradeTarget);
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/spi/src/main/java/org/apache/sqoop/connector/spi/SqoopConnector.java
----------------------------------------------------------------------
diff --git a/spi/src/main/java/org/apache/sqoop/connector/spi/SqoopConnector.java b/spi/src/main/java/org/apache/sqoop/connector/spi/SqoopConnector.java
index 7b78ba0..849f091 100644
--- a/spi/src/main/java/org/apache/sqoop/connector/spi/SqoopConnector.java
+++ b/spi/src/main/java/org/apache/sqoop/connector/spi/SqoopConnector.java
@@ -58,12 +58,12 @@ public abstract class SqoopConnector {
}
/**
- * @return Get connection configuration class
+ * @return Get link configuration group class
*/
public abstract Class getLinkConfigurationClass();
/**
- * @return Get job configuration class for given type or null if not supported
+ * @return Get job configuration group class per direction type or null if not supported
*/
public abstract Class getJobConfigurationClass(Direction jobType);
@@ -79,12 +79,10 @@ public abstract class SqoopConnector {
/**
* Returns validation object that Sqoop can use to validate user
- * supplied forms before accepting them. This object will be used both for
- * connection and job forms.
- *
+ * supplied configs before accepting them. This object will be used both link and job configs
* @return Validator object
*/
- public abstract Validator getValidator();
+ public abstract Validator getConfigValidator();
/**
* Returns an {@linkplain RepositoryUpgrader} object that can upgrade the
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/spi/src/main/java/org/apache/sqoop/job/etl/Destroyer.java
----------------------------------------------------------------------
diff --git a/spi/src/main/java/org/apache/sqoop/job/etl/Destroyer.java b/spi/src/main/java/org/apache/sqoop/job/etl/Destroyer.java
index f965bdd..a133106 100644
--- a/spi/src/main/java/org/apache/sqoop/job/etl/Destroyer.java
+++ b/spi/src/main/java/org/apache/sqoop/job/etl/Destroyer.java
@@ -28,7 +28,7 @@ public abstract class Destroyer<LinkConfiguration, JobConfiguration> {
*
* @param context Destroyer context
* @param linkConfiguration link configuration object
- * @param jobConfiguration Job configuration object
+ * @param jobConfiguration job configuration object
*/
public abstract void destroy(DestroyerContext context,
LinkConfiguration linkConfiguration,
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/spi/src/main/java/org/apache/sqoop/job/etl/Extractor.java
----------------------------------------------------------------------
diff --git a/spi/src/main/java/org/apache/sqoop/job/etl/Extractor.java b/spi/src/main/java/org/apache/sqoop/job/etl/Extractor.java
index 34f02c9..d6c186d 100644
--- a/spi/src/main/java/org/apache/sqoop/job/etl/Extractor.java
+++ b/spi/src/main/java/org/apache/sqoop/job/etl/Extractor.java
@@ -27,8 +27,8 @@ public abstract class Extractor<LinkConfiguration, JobConfiguration, Partition>
* Extract data from source and pass them into the Sqoop.
*
* @param context Extractor context object
- * @param linkConfiguration link configuration
- * @param jobConfiguration Job configuration
+ * @param linkConfiguration link configuration object
+ * @param jobConfiguration job configuration object
* @param partition Partition that this extract should work on
*/
public abstract void extract(ExtractorContext context,
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/spi/src/main/java/org/apache/sqoop/job/etl/Initializer.java
----------------------------------------------------------------------
diff --git a/spi/src/main/java/org/apache/sqoop/job/etl/Initializer.java b/spi/src/main/java/org/apache/sqoop/job/etl/Initializer.java
index c9ae540..5c48fc3 100644
--- a/spi/src/main/java/org/apache/sqoop/job/etl/Initializer.java
+++ b/spi/src/main/java/org/apache/sqoop/job/etl/Initializer.java
@@ -34,28 +34,28 @@ public abstract class Initializer<LinkConfiguration, JobConfiguration> {
* promoted to all other part of the workflow automatically.
*
* @param context Initializer context object
- * @param linkConfiguration Connector's link configuration object
- * @param jobConfiguration Connector's job configuration object
+ * @param linkConfiguration link configuration object
+ * @param jobConfiguration job configuration object
*/
- public abstract void initialize(InitializerContext context,
- LinkConfiguration linkConfiguration,
- JobConfiguration jobConfiguration);
+ public abstract void initialize(InitializerContext context,
+ LinkConfiguration linkConfiguration,
+ JobConfiguration jobConfiguration);
- /**
- * Return list of all jars that this particular connector needs to operate
- * on following job. This method will be called after running initialize
- * method.
- *
- * @return
- */
- public List<String> getJars(InitializerContext context,
- LinkConfiguration linkConfiguration,
- JobConfiguration jobConfiguration) {
- return new LinkedList<String>();
- }
+ /**
+ * Return list of all jars that this particular connector needs to operate
+ * on following job. This method will be called after running initialize
+ * method.
+ *
+ * @return
+ */
+ public List<String> getJars(InitializerContext context,
+ LinkConfiguration linkConfiguration,
+ JobConfiguration jobConfiguration) {
+ return new LinkedList<String>();
+ }
- public abstract Schema getSchema(InitializerContext context,
- LinkConfiguration linkConfiguration,
- JobConfiguration jobConfiguration);
+ public abstract Schema getSchema(InitializerContext context,
+ LinkConfiguration linkConfiguration,
+ JobConfiguration jobConfiguration);
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/spi/src/main/java/org/apache/sqoop/job/etl/Loader.java
----------------------------------------------------------------------
diff --git a/spi/src/main/java/org/apache/sqoop/job/etl/Loader.java b/spi/src/main/java/org/apache/sqoop/job/etl/Loader.java
index 434dcf6..cc32ada 100644
--- a/spi/src/main/java/org/apache/sqoop/job/etl/Loader.java
+++ b/spi/src/main/java/org/apache/sqoop/job/etl/Loader.java
@@ -26,12 +26,12 @@ public abstract class Loader<LinkConfiguration, JobConfiguration> {
* Load data to target.
*
* @param context Loader context object
- * @param linkConfiguration link configuration
- * @param jobConfiguration Job configuration
+ * @param linkConfiguration link configuration object
+ * @param jobConfiguration job configuration object
* @throws Exception
*/
- public abstract void load(LoaderContext context,
- LinkConfiguration linkConfiguration,
- JobConfiguration jobConfiguration) throws Exception;
+ public abstract void load(LoaderContext context,
+ LinkConfiguration linkConfiguration,
+ JobConfiguration jobConfiguration) throws Exception;
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/spi/src/main/java/org/apache/sqoop/job/etl/Partitioner.java
----------------------------------------------------------------------
diff --git a/spi/src/main/java/org/apache/sqoop/job/etl/Partitioner.java b/spi/src/main/java/org/apache/sqoop/job/etl/Partitioner.java
index 8156762..57507df 100644
--- a/spi/src/main/java/org/apache/sqoop/job/etl/Partitioner.java
+++ b/spi/src/main/java/org/apache/sqoop/job/etl/Partitioner.java
@@ -31,12 +31,12 @@ public abstract class Partitioner<LinkConfiguration, JobConfiguration> {
* Each partition will be then processed in separate extractor.
*
* @param context Partitioner context object
- * @param linkConfiguration link configuration
- * @param jobConfiguration Job configuration
+ * @param linkConfiguration link configuration object
+ * @param jobConfiguration job configuration object
* @return
*/
- public abstract List<Partition> getPartitions(PartitionerContext context,
- LinkConfiguration linkConfiguration,
- JobConfiguration jobConfiguration);
+ public abstract List<Partition> getPartitions(PartitionerContext context,
+ LinkConfiguration linkConfiguration,
+ JobConfiguration jobConfiguration);
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/spi/src/main/java/org/apache/sqoop/validation/Validator.java
----------------------------------------------------------------------
diff --git a/spi/src/main/java/org/apache/sqoop/validation/Validator.java b/spi/src/main/java/org/apache/sqoop/validation/Validator.java
index 894f412..2909905 100644
--- a/spi/src/main/java/org/apache/sqoop/validation/Validator.java
+++ b/spi/src/main/java/org/apache/sqoop/validation/Validator.java
@@ -29,21 +29,21 @@ public class Validator {
/**
* Validate link configuration object.
*
- * @param linkConfiguration Connection object to be validated
+ * @param linkConfiguration link config object to be validated
* @return Validation status
*/
- public Validation validateLink(Object linkConfiguration) {
- return new Validation(EmptyClass.class);
+ public ConfigValidator validateConfigForLink(Object linkConfiguration) {
+ return new ConfigValidator(EmptyClass.class);
}
/**
* Validate configuration object for job .
*
- * @param jobConfiguration Job to be validated
+ * @param jobConfiguration Job config to be validated
* @return Validation status
*/
- public Validation validateJob(Object jobConfiguration) {
- return new Validation(EmptyClass.class);
+ public ConfigValidator validateConfigForJob(Object jobConfiguration) {
+ return new ConfigValidator(EmptyClass.class);
}
/**
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/submission/mapreduce/src/main/java/org/apache/sqoop/submission/mapreduce/MapreduceSubmissionEngine.java
----------------------------------------------------------------------
diff --git a/submission/mapreduce/src/main/java/org/apache/sqoop/submission/mapreduce/MapreduceSubmissionEngine.java b/submission/mapreduce/src/main/java/org/apache/sqoop/submission/mapreduce/MapreduceSubmissionEngine.java
index 25255ae..0c492ef 100644
--- a/submission/mapreduce/src/main/java/org/apache/sqoop/submission/mapreduce/MapreduceSubmissionEngine.java
+++ b/submission/mapreduce/src/main/java/org/apache/sqoop/submission/mapreduce/MapreduceSubmissionEngine.java
@@ -141,7 +141,7 @@ public class MapreduceSubmissionEngine extends SubmissionEngine {
* {@inheritDoc}
*/
@Override
- public boolean isExecutionEngineSupported(Class executionEngineClass) {
+ public boolean isExecutionEngineSupported(Class<?> executionEngineClass) {
return executionEngineClass == MapreduceExecutionEngine.class;
}
@@ -201,16 +201,16 @@ public class MapreduceSubmissionEngine extends SubmissionEngine {
try {
Job job = new Job(configuration);
- // And finally put all configuration objects to credentials cache
- ConfigurationUtils.setConnectorConnectionConfig(Direction.FROM, job, request.getConnectorLinkConfig(Direction.FROM));
- ConfigurationUtils.setConnectorJobConfig(Direction.FROM, job, request.getConnectorJobConfig(Direction.FROM));
- ConfigurationUtils.setConnectorConnectionConfig(Direction.TO, job, request.getConnectorLinkConfig(Direction.TO));
- ConfigurationUtils.setConnectorJobConfig(Direction.TO, job, request.getConnectorJobConfig(Direction.TO));
+ // link configs
+ ConfigurationUtils.setConnectorLinkConfig(Direction.FROM, job, request.getConnectorLinkConfig(Direction.FROM));
+ ConfigurationUtils.setConnectorLinkConfig(Direction.TO, job, request.getConnectorLinkConfig(Direction.TO));
- ConfigurationUtils.setFrameworkConnectionConfig(Direction.FROM, job, request.getFrameworkLinkConfig(Direction.FROM));
- ConfigurationUtils.setFrameworkConnectionConfig(Direction.TO, job, request.getFrameworkLinkConfig(Direction.TO));
- ConfigurationUtils.setFrameworkJobConfig(job, request.getFrameworkJobConfig());
+ // from and to configs
+ ConfigurationUtils.setConnectorJobConfig(Direction.FROM, job, request.getJobConfig(Direction.FROM));
+ ConfigurationUtils.setConnectorJobConfig(Direction.TO, job, request.getJobConfig(Direction.TO));
+ ConfigurationUtils.setDriverConfig(job, request.getDriverConfig());
+ // @TODO(Abe): Persist TO schema.
ConfigurationUtils.setConnectorSchema(Direction.FROM, job, request.getSummary().getFromSchema());
ConfigurationUtils.setConnectorSchema(Direction.TO, job, request.getSummary().getToSchema());
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/test/src/main/java/org/apache/sqoop/test/minicluster/TomcatSqoopMiniCluster.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/sqoop/test/minicluster/TomcatSqoopMiniCluster.java b/test/src/main/java/org/apache/sqoop/test/minicluster/TomcatSqoopMiniCluster.java
index 9ecc9da..7504e76 100644
--- a/test/src/main/java/org/apache/sqoop/test/minicluster/TomcatSqoopMiniCluster.java
+++ b/test/src/main/java/org/apache/sqoop/test/minicluster/TomcatSqoopMiniCluster.java
@@ -17,6 +17,12 @@
*/
package org.apache.sqoop.test.minicluster;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
import org.apache.hadoop.conf.Configuration;
import org.codehaus.cargo.container.ContainerType;
import org.codehaus.cargo.container.InstalledLocalContainer;
@@ -25,16 +31,9 @@ import org.codehaus.cargo.container.configuration.LocalConfiguration;
import org.codehaus.cargo.container.deployable.WAR;
import org.codehaus.cargo.container.installer.Installer;
import org.codehaus.cargo.container.installer.ZipURLInstaller;
-import org.codehaus.cargo.container.property.GeneralPropertySet;
import org.codehaus.cargo.generic.DefaultContainerFactory;
import org.codehaus.cargo.generic.configuration.DefaultConfigurationFactory;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
/**
* Embedded tomcat Sqoop server mini cluster.
*
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java b/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java
index 6074d36..af31769 100644
--- a/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java
+++ b/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java
@@ -17,15 +17,18 @@
*/
package org.apache.sqoop.test.testcases;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
+
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.mapred.JobConf;
import org.apache.log4j.Logger;
import org.apache.sqoop.client.SubmissionCallback;
import org.apache.sqoop.common.Direction;
import org.apache.sqoop.connector.hdfs.configuration.ToFormat;
-import org.apache.sqoop.model.MLink;
-import org.apache.sqoop.model.MFormList;
+import org.apache.sqoop.model.MConfigList;
import org.apache.sqoop.model.MJob;
+import org.apache.sqoop.model.MLink;
import org.apache.sqoop.model.MPersistableEntity;
import org.apache.sqoop.model.MSubmission;
import org.apache.sqoop.test.asserts.ProviderAsserts;
@@ -39,9 +42,6 @@ import org.apache.sqoop.validation.Status;
import org.junit.AfterClass;
import org.junit.BeforeClass;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-
/**
* Base test case suitable for connector testing.
*
@@ -121,41 +121,50 @@ abstract public class ConnectorTestCase extends TomcatTestCase {
}
/**
- * Fill link form based on currently active provider.
+ * Fill link config based on currently active provider.
*
* @param link MLink object to fill
*/
- protected void fillRdbmsLinkForm(MLink link) {
- MFormList forms = link.getConnectorPart();
- forms.getStringInput("link.jdbcDriver").setValue(provider.getJdbcDriver());
- forms.getStringInput("link.connectionString").setValue(provider.getConnectionUrl());
- forms.getStringInput("link.username").setValue(provider.getConnectionUsername());
- forms.getStringInput("link.password").setValue(provider.getConnectionPassword());
+ protected void fillRdbmsLinkConfig(MLink link) {
+ MConfigList configs = link.getConnectorLinkConfig();
+ configs.getStringInput("linkConfig.jdbcDriver").setValue(provider.getJdbcDriver());
+ configs.getStringInput("linkConfig.connectionString").setValue(provider.getConnectionUrl());
+ configs.getStringInput("linkConfig.username").setValue(provider.getConnectionUsername());
+ configs.getStringInput("linkConfig.password").setValue(provider.getConnectionPassword());
}
/**
- * Fill TO form with specific storage and output type.
+ * Fill TO config with specific storage and output type.
*
* @param job MJob object to fill
* @param output Output type that should be set
*/
- protected void fillToJobForm(MJob job, ToFormat output) {
- MFormList toForms = job.getConnectorPart(Direction.TO);
- toForms.getEnumInput("toJobConfig.outputFormat").setValue(output);
- toForms.getStringInput("toJobConfig.outputDirectory").setValue(getMapreduceDirectory());
+ protected void fillHdfsToConfig(MJob job, ToFormat output) {
+ MConfigList toConfig = job.getJobConfig(Direction.TO);
+ toConfig.getEnumInput("toJobConfig.outputFormat").setValue(output);
+ toConfig.getStringInput("toJobConfig.outputDirectory").setValue(getMapreduceDirectory());
}
/**
- * Fill FROM form
+ * Fill FROM config
*
* @param job MJob object to fill
*/
- protected void fillFromJobForm(MJob job) {
- MFormList forms = job.getConnectorPart(Direction.FROM);
- forms.getStringInput("fromJobConfig.inputDirectory").setValue(getMapreduceDirectory());
+ protected void fillHdfsFromConfig(MJob job) {
+ MConfigList fromConfig = job.getJobConfig(Direction.FROM);
+ fromConfig.getStringInput("fromJobConfig.inputDirectory").setValue(getMapreduceDirectory());
}
/**
+ * Fill Driver config
+ * @param job
+ */
+ protected void fillDriverConfig(MJob job) {
+ job.getDriverConfig().getStringInput("throttlingConfig.numExtractors").setValue("3");
+ }
+
+
+ /**
* Create table cities.
*/
protected void createTableCities() {
@@ -186,7 +195,7 @@ abstract public class ConnectorTestCase extends TomcatTestCase {
/**
* Assert row in testing table.
*
- * @param conditions Conditions in form that are expected by the database provider
+ * @param conditions Conditions in config that are expected by the database provider
* @param values Values that are expected in the table (with corresponding types)
*/
protected void assertRow(Object []conditions, Object ...values) {
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/test/src/main/java/org/apache/sqoop/test/testcases/TomcatTestCase.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/sqoop/test/testcases/TomcatTestCase.java b/test/src/main/java/org/apache/sqoop/test/testcases/TomcatTestCase.java
index 63736ab..5e1d564 100644
--- a/test/src/main/java/org/apache/sqoop/test/testcases/TomcatTestCase.java
+++ b/test/src/main/java/org/apache/sqoop/test/testcases/TomcatTestCase.java
@@ -165,7 +165,7 @@ abstract public class TomcatTestCase {
* @throws IOException
*/
protected void assertTo(String... lines) throws IOException {
- // TODO(VB): fix this to be not directly dependent on mapreduce
+ // TODO(VB): fix this to be not directly dependent on hdfs/MR
HdfsAsserts.assertMapreduceOutput(hdfsClient, getMapreduceDirectory(), lines);
}
@@ -175,7 +175,7 @@ abstract public class TomcatTestCase {
* @param expectedFiles Expected number of files
*/
protected void assertToFiles(int expectedFiles) throws IOException {
- // TODO(VB): fix this to be not directly dependent on mapreduce
+ // TODO(VB): fix this to be not directly dependent on hdfs/MR
HdfsAsserts.assertMapreduceOutputFiles(hdfsClient, getMapreduceDirectory(), expectedFiles);
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromHDFSToRDBMSTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromHDFSToRDBMSTest.java b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromHDFSToRDBMSTest.java
index 5e1abc1..b1b3b16 100644
--- a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromHDFSToRDBMSTest.java
+++ b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromHDFSToRDBMSTest.java
@@ -19,8 +19,9 @@ package org.apache.sqoop.integration.connector.jdbc.generic;
import org.apache.sqoop.common.Direction;
import org.apache.sqoop.test.testcases.ConnectorTestCase;
+import org.apache.sqoop.model.MDriverConfig;
import org.apache.sqoop.model.MLink;
-import org.apache.sqoop.model.MFormList;
+import org.apache.sqoop.model.MConfigList;
import org.apache.sqoop.model.MJob;
import org.junit.Test;
@@ -43,7 +44,7 @@ public class FromHDFSToRDBMSTest extends ConnectorTestCase {
// RDBMS link
MLink rdbmsLink = getClient().createLink("generic-jdbc-connector");
- fillRdbmsLinkForm(rdbmsLink);
+ fillRdbmsLinkConfig(rdbmsLink);
saveLink(rdbmsLink);
// HDFS link
@@ -53,10 +54,16 @@ public class FromHDFSToRDBMSTest extends ConnectorTestCase {
// Job creation
MJob job = getClient().createJob(hdfsLink.getPersistenceId(), rdbmsLink.getPersistenceId());
- // Connector values
- MFormList toForms = job.getConnectorPart(Direction.TO);
- toForms.getStringInput("toJobConfig.tableName").setValue(provider.escapeTableName(getTableName()));
- fillFromJobForm(job);
+ // set hdfs "FROM" config for the job, since the connector test case base class only has utilities for hdfs!
+ fillHdfsFromConfig(job);
+
+ // set the rdms "TO" config here
+ MConfigList toConfig = job.getJobConfig(Direction.TO);
+ toConfig.getStringInput("toJobConfig.tableName").setValue(provider.escapeTableName(getTableName()));
+
+ // driver config
+ MDriverConfig driverConfig = job.getDriverConfig();
+ driverConfig.getIntegerInput("throttlingConfig.numExtractors").setValue(3);
saveJob(job);
executeJob(job);
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromRDBMSToHDFSTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromRDBMSToHDFSTest.java b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromRDBMSToHDFSTest.java
index 2dc0613..36f7443 100644
--- a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromRDBMSToHDFSTest.java
+++ b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromRDBMSToHDFSTest.java
@@ -17,17 +17,18 @@
*/
package org.apache.sqoop.integration.connector.jdbc.generic;
+import static org.junit.Assert.assertTrue;
+
import org.apache.sqoop.common.Direction;
import org.apache.sqoop.connector.hdfs.configuration.ToFormat;
-import org.apache.sqoop.model.MLink;
-import org.apache.sqoop.model.MFormList;
+import org.apache.sqoop.model.MConfigList;
+import org.apache.sqoop.model.MDriverConfig;
import org.apache.sqoop.model.MJob;
+import org.apache.sqoop.model.MLink;
import org.apache.sqoop.model.MSubmission;
import org.apache.sqoop.test.testcases.ConnectorTestCase;
import org.junit.Test;
-import static org.junit.Assert.assertTrue;
-
/**
* Import simple table with various configurations.
*/
@@ -39,7 +40,7 @@ public class FromRDBMSToHDFSTest extends ConnectorTestCase {
// RDBMS link
MLink rdbmsConnection = getClient().createLink("generic-jdbc-connector");
- fillRdbmsLinkForm(rdbmsConnection);
+ fillRdbmsLinkConfig(rdbmsConnection);
saveLink(rdbmsConnection);
// HDFS link
@@ -49,11 +50,17 @@ public class FromRDBMSToHDFSTest extends ConnectorTestCase {
// Job creation
MJob job = getClient().createJob(rdbmsConnection.getPersistenceId(), hdfsConnection.getPersistenceId());
- // Connector values
- MFormList forms = job.getConnectorPart(Direction.FROM);
- forms.getStringInput("fromJobConfig.tableName").setValue(provider.escapeTableName(getTableName()));
- forms.getStringInput("fromJobConfig.partitionColumn").setValue(provider.escapeColumnName("id"));
- fillToJobForm(job, ToFormat.TEXT_FILE);
+ // srt rdbms "FROM" config
+ MConfigList fromConfig = job.getJobConfig(Direction.FROM);
+ fromConfig.getStringInput("fromJobConfig.tableName").setValue(provider.escapeTableName(getTableName()));
+ fromConfig.getStringInput("fromJobConfig.partitionColumn").setValue(provider.escapeColumnName("id"));
+
+ // fill the hdfs "TO" config
+ fillHdfsToConfig(job, ToFormat.TEXT_FILE);
+ // driver config
+ MDriverConfig driverConfig = job.getDriverConfig();
+ driverConfig.getIntegerInput("throttlingConfig.numExtractors").setValue(3);
+
saveJob(job);
executeJob(job);
@@ -76,7 +83,7 @@ public class FromRDBMSToHDFSTest extends ConnectorTestCase {
// RDBMS link
MLink rdbmsLink = getClient().createLink("generic-jdbc-connector");
- fillRdbmsLinkForm(rdbmsLink);
+ fillRdbmsLinkConfig(rdbmsLink);
saveLink(rdbmsLink);
// HDFS link
@@ -87,11 +94,11 @@ public class FromRDBMSToHDFSTest extends ConnectorTestCase {
MJob job = getClient().createJob(rdbmsLink.getPersistenceId(), hdfsLink.getPersistenceId());
// Connector values
- MFormList forms = job.getConnectorPart(Direction.FROM);
- forms.getStringInput("fromJobConfig.tableName").setValue(provider.escapeTableName(getTableName()));
- forms.getStringInput("fromJobConfig.partitionColumn").setValue(provider.escapeColumnName("id"));
- forms.getStringInput("fromJobConfig.columns").setValue(provider.escapeColumnName("id") + "," + provider.escapeColumnName("country"));
- fillToJobForm(job, ToFormat.TEXT_FILE);
+ MConfigList configs = job.getJobConfig(Direction.FROM);
+ configs.getStringInput("fromJobConfig.tableName").setValue(provider.escapeTableName(getTableName()));
+ configs.getStringInput("fromJobConfig.partitionColumn").setValue(provider.escapeColumnName("id"));
+ configs.getStringInput("fromJobConfig.columns").setValue(provider.escapeColumnName("id") + "," + provider.escapeColumnName("country"));
+ fillHdfsToConfig(job, ToFormat.TEXT_FILE);
saveJob(job);
MSubmission submission = getClient().startSubmission(job.getPersistenceId());
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/PartitionerTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/PartitionerTest.java b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/PartitionerTest.java
index 729f95e..824a51d 100644
--- a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/PartitionerTest.java
+++ b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/PartitionerTest.java
@@ -19,8 +19,9 @@ package org.apache.sqoop.integration.connector.jdbc.generic;
import org.apache.sqoop.common.Direction;
import org.apache.sqoop.connector.hdfs.configuration.ToFormat;
+import org.apache.sqoop.model.MDriverConfig;
import org.apache.sqoop.model.MLink;
-import org.apache.sqoop.model.MFormList;
+import org.apache.sqoop.model.MConfigList;
import org.apache.sqoop.model.MJob;
import org.apache.sqoop.test.testcases.ConnectorTestCase;
import org.apache.sqoop.test.utils.ParametrizedUtils;
@@ -59,8 +60,8 @@ public class PartitionerTest extends ConnectorTestCase {
}
private String partitionColumn;
- private int extractors;
private int maxOutputFiles;
+ private int extractors;
public PartitionerTest(String partitionColumn, int expectedOutputFiles, int extractors) {
this.partitionColumn = partitionColumn;
@@ -74,7 +75,7 @@ public class PartitionerTest extends ConnectorTestCase {
// RDBMS link
MLink rdbmsLink = getClient().createLink("generic-jdbc-connector");
- fillRdbmsLinkForm(rdbmsLink);
+ fillRdbmsLinkConfig(rdbmsLink);
saveLink(rdbmsLink);
// HDFS link
@@ -84,13 +85,17 @@ public class PartitionerTest extends ConnectorTestCase {
// Job creation
MJob job = getClient().createJob(rdbmsLink.getPersistenceId(), hdfsLink.getPersistenceId());
- // Connector values
- MFormList forms = job.getConnectorPart(Direction.FROM);
- forms.getStringInput("fromJobConfig.tableName").setValue(provider.escapeTableName(getTableName()));
- forms.getStringInput("fromJobConfig.partitionColumn").setValue(provider.escapeColumnName(partitionColumn));
- fillToJobForm(job, ToFormat.TEXT_FILE);
- forms = job.getFrameworkPart();
- forms.getIntegerInput("throttling.extractors").setValue(extractors);
+ // set the rdbms "FROM" config
+ MConfigList fromConfig = job.getJobConfig(Direction.FROM);
+ fromConfig.getStringInput("fromJobConfig.tableName").setValue(provider.escapeTableName(getTableName()));
+ fromConfig.getStringInput("fromJobConfig.partitionColumn").setValue(provider.escapeColumnName(partitionColumn));
+ // fill hdfs "TO" config
+ fillHdfsToConfig(job, ToFormat.TEXT_FILE);
+
+ // set driver config
+ MDriverConfig driverConfig = job.getDriverConfig();
+ driverConfig.getIntegerInput("throttlingConfig.numExtractors").setValue(extractors);
+
saveJob(job);
executeJob(job);
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableStagedRDBMSTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableStagedRDBMSTest.java b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableStagedRDBMSTest.java
index 562a6a6..f42fa32 100644
--- a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableStagedRDBMSTest.java
+++ b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableStagedRDBMSTest.java
@@ -17,16 +17,16 @@
*/
package org.apache.sqoop.integration.connector.jdbc.generic;
+import static org.junit.Assert.assertEquals;
+
import org.apache.sqoop.common.Direction;
-import org.apache.sqoop.model.MLink;
-import org.apache.sqoop.model.MFormList;
+import org.apache.sqoop.model.MConfigList;
import org.apache.sqoop.model.MJob;
+import org.apache.sqoop.model.MLink;
import org.apache.sqoop.test.data.Cities;
import org.apache.sqoop.test.testcases.ConnectorTestCase;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-
/**
*
*/
@@ -46,7 +46,7 @@ public class TableStagedRDBMSTest extends ConnectorTestCase {
// RDBMS link
MLink rdbmsLink = getClient().createLink("generic-jdbc-connector");
- fillRdbmsLinkForm(rdbmsLink);
+ fillRdbmsLinkConfig(rdbmsLink);
saveLink(rdbmsLink);
// HDFS link
@@ -57,13 +57,19 @@ public class TableStagedRDBMSTest extends ConnectorTestCase {
MJob job = getClient().createJob(hdfsLink.getPersistenceId(),
rdbmsLink.getPersistenceId());
- // Connector values
- MFormList forms = job.getConnectorPart(Direction.TO);
- forms.getStringInput("toJobConfig.tableName").setValue(
+ // fill HDFS "FROM" config
+ fillHdfsFromConfig(job);
+
+ // fill rdbms "TO" config here
+ MConfigList configs = job.getJobConfig(Direction.TO);
+ configs.getStringInput("toJobConfig.tableName").setValue(
provider.escapeTableName(getTableName()));
- forms.getStringInput("toJobConfig.stageTableName").setValue(
+ configs.getStringInput("toJobConfig.stageTableName").setValue(
provider.escapeTableName(stageTableName));
- fillFromJobForm(job);
+ // driver config
+ MConfigList driverConfig = job.getDriverConfig();
+ driverConfig.getIntegerInput("throttlingConfig.numExtractors").setValue(3);
+
saveJob(job);
executeJob(job);
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/test/src/test/java/org/apache/sqoop/integration/server/SubmissionWithDisabledModelObjectsTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/server/SubmissionWithDisabledModelObjectsTest.java b/test/src/test/java/org/apache/sqoop/integration/server/SubmissionWithDisabledModelObjectsTest.java
index 507ac53..055bc3d 100644
--- a/test/src/test/java/org/apache/sqoop/integration/server/SubmissionWithDisabledModelObjectsTest.java
+++ b/test/src/test/java/org/apache/sqoop/integration/server/SubmissionWithDisabledModelObjectsTest.java
@@ -23,7 +23,7 @@ import org.apache.sqoop.common.SqoopException;
import org.apache.sqoop.connector.hdfs.configuration.ToFormat;
import org.apache.sqoop.driver.DriverError;
import org.apache.sqoop.model.MLink;
-import org.apache.sqoop.model.MFormList;
+import org.apache.sqoop.model.MConfigList;
import org.apache.sqoop.model.MJob;
import org.apache.sqoop.test.testcases.ConnectorTestCase;
import org.junit.runner.RunWith;
@@ -67,7 +67,7 @@ public class SubmissionWithDisabledModelObjectsTest extends ConnectorTestCase {
// RDBMS link
MLink rdbmsLink = getClient().createLink("generic-jdbc-connector");
- fillRdbmsLinkForm(rdbmsLink);
+ fillRdbmsLinkConfig(rdbmsLink);
saveLink(rdbmsLink);
// HDFS link
@@ -77,15 +77,21 @@ public class SubmissionWithDisabledModelObjectsTest extends ConnectorTestCase {
// Job creation
MJob job = getClient().createJob(rdbmsLink.getPersistenceId(), hdfsLink.getPersistenceId());
- // Connector values
- MFormList forms = job.getConnectorPart(Direction.FROM);
- forms.getStringInput("fromJobConfig.tableName").setValue(provider.escapeTableName(getTableName()));
- forms.getStringInput("fromJobConfig.partitionColumn").setValue(provider.escapeColumnName("id"));
- // Framework values
- fillToJobForm(job, ToFormat.TEXT_FILE);
+ // rdms "FROM" config
+ MConfigList fromConfig = job.getJobConfig(Direction.FROM);
+ fromConfig.getStringInput("fromJobConfig.tableName").setValue(provider.escapeTableName(getTableName()));
+ fromConfig.getStringInput("fromJobConfig.partitionColumn").setValue(provider.escapeColumnName("id"));
+
+ // hdfs "TO" config
+ fillHdfsToConfig(job, ToFormat.TEXT_FILE);
+
+ // driver config
+ MConfigList driverConfig = job.getDriverConfig();
+ //driverConfig.getIntegerInput("throttlingConfig.extractors").setValue(3);
+
saveJob(job);
- // Disable model entities as per parametrized run
+ // Disable model entities as per parameterized run
getClient().enableLink(rdbmsLink.getPersistenceId(), enabledLink);
getClient().enableJob(job.getPersistenceId(), enabledJob);
[06/13] SQOOP-1498: Sqoop2: Repository Object refactoring (objects
prefixed with M)
Posted by ab...@apache.org.
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java b/core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java
index 19b0023..e6e4760 100644
--- a/core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java
+++ b/core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java
@@ -17,6 +17,23 @@
*/
package org.apache.sqoop.repository;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.when;
+
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Collections;
@@ -29,40 +46,27 @@ import org.apache.sqoop.connector.ConnectorManager;
import org.apache.sqoop.connector.spi.RepositoryUpgrader;
import org.apache.sqoop.connector.spi.SqoopConnector;
import org.apache.sqoop.driver.Driver;
-import org.apache.sqoop.driver.configuration.JobConfiguration;
+import org.apache.sqoop.driver.configuration.DriverConfiguration;
+import org.apache.sqoop.json.DriverBean;
+import org.apache.sqoop.model.ConfigUtils;
import org.apache.sqoop.model.ConfigurationClass;
-import org.apache.sqoop.model.FormUtils;
-import org.apache.sqoop.model.MConnectionForms;
+import org.apache.sqoop.model.MConfig;
+import org.apache.sqoop.model.MConfigList;
import org.apache.sqoop.model.MConnector;
+import org.apache.sqoop.model.MDriver;
import org.apache.sqoop.model.MDriverConfig;
-import org.apache.sqoop.model.MForm;
+import org.apache.sqoop.model.MFromConfig;
import org.apache.sqoop.model.MJob;
-import org.apache.sqoop.model.MJobForms;
import org.apache.sqoop.model.MLink;
+import org.apache.sqoop.model.MLinkConfig;
+import org.apache.sqoop.model.MToConfig;
+import org.apache.sqoop.validation.ConfigValidator;
import org.apache.sqoop.validation.Status;
-import org.apache.sqoop.validation.Validation;
import org.apache.sqoop.validation.Validator;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InOrder;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyLong;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.inOrder;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.mockito.Mockito.when;
-
public class TestJdbcRepository {
private JdbcRepository repoSpy;
@@ -73,8 +77,8 @@ public class TestJdbcRepository {
private Validator validatorMock;
private RepositoryUpgrader upgraderMock;
- private Validation validRepoMock;
- private Validation invalidRepoMock;
+ private ConfigValidator validRepoMock;
+ private ConfigValidator invalidRepoMock;
@Before
public void setUp() throws Exception {
@@ -91,20 +95,20 @@ public class TestJdbcRepository {
ConnectorManager.setInstance(connectorMgrMock);
Driver.setInstance(driverMock);
- validRepoMock = mock(Validation.class);
+ validRepoMock = mock(ConfigValidator.class);
when(validRepoMock.getStatus()).thenReturn(Status.ACCEPTABLE);
- invalidRepoMock = mock(Validation.class);
+ invalidRepoMock = mock(ConfigValidator.class);
when(invalidRepoMock.getStatus()).thenReturn(Status.UNACCEPTABLE);
- doNothing().when(upgraderMock).upgrade(any(MConnectionForms.class), any(MConnectionForms.class));
- doNothing().when(upgraderMock).upgrade(any(MJobForms.class), any(MJobForms.class));
+ doNothing().when(upgraderMock).upgrade(any(MLinkConfig.class), any(MLinkConfig.class));
+ doNothing().when(upgraderMock).upgrade(any(MFromConfig.class), any(MFromConfig.class));
}
/**
* Test the procedure when the connector auto upgrade option is enabled
*/
@Test
- public void testConnectorEnableAutoUpgrade() {
+ public void testConnectorConfigEnableAutoUpgrade() {
MConnector newConnector = connector(1, "1.1");
MConnector oldConnector = connector(1, "1.0");
@@ -155,22 +159,22 @@ public class TestJdbcRepository {
*/
@Test
public void testDriverConfigEnableAutoUpgrade() {
- MDriverConfig newDriverConfig = driverConfig();
- MDriverConfig oldDriverConfig = anotherDriverConfig();
+ MDriver newDriverConfig = driver();
+ MDriver oldDriverConfig = anotherDriver();
- when(repoHandlerMock.findDriverConfig(any(Connection.class))).thenReturn(oldDriverConfig);
+ when(repoHandlerMock.findDriver(any(Connection.class))).thenReturn(oldDriverConfig);
// make the upgradeDriverConfig to throw an exception to prove that it has been called
SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
"upgradeDriverConfig() has been called.");
- doThrow(exception).when(repoHandlerMock).findLinks(any(Connection.class));
+ doThrow(exception).when(repoHandlerMock).findJobs(any(Connection.class));
try {
- repoSpy.registerDriverConfig(newDriverConfig, true);
+ repoSpy.registerDriver(newDriverConfig, true);
} catch (SqoopException ex) {
assertEquals(ex.getMessage(), exception.getMessage());
- verify(repoHandlerMock, times(1)).findDriverConfig(any(Connection.class));
- verify(repoHandlerMock, times(1)).findLinks(any(Connection.class));
+ verify(repoHandlerMock, times(1)).findDriver(any(Connection.class));
+ verify(repoHandlerMock, times(1)).findJobs(any(Connection.class));
verifyNoMoreInteractions(repoHandlerMock);
return ;
}
@@ -183,16 +187,16 @@ public class TestJdbcRepository {
*/
@Test
public void testDriverConfigDisableAutoUpgrade() {
- MDriverConfig newDriverConfig = driverConfig();
- MDriverConfig oldDriverConfig = anotherDriverConfig();
+ MDriver newDriverConfig = driver();
+ MDriver oldDriverConfig = anotherDriver();
- when(repoHandlerMock.findDriverConfig(any(Connection.class))).thenReturn(oldDriverConfig);
+ when(repoHandlerMock.findDriver(any(Connection.class))).thenReturn(oldDriverConfig);
try {
- repoSpy.registerDriverConfig(newDriverConfig, false);
+ repoSpy.registerDriver(newDriverConfig, false);
} catch (SqoopException ex) {
assertEquals(ex.getErrorCode(), RepositoryError.JDBCREPO_0026);
- verify(repoHandlerMock, times(1)).findDriverConfig(any(Connection.class));
+ verify(repoHandlerMock, times(1)).findDriver(any(Connection.class));
verifyNoMoreInteractions(repoHandlerMock);
return ;
}
@@ -205,18 +209,18 @@ public class TestJdbcRepository {
* jobs using the old connector are still valid for the new connector
*/
@Test
- public void testConnectorUpgradeWithValidLinksAndJobs() {
+ public void testConnectorConfigUpgradeWithValidLinksAndJobs() {
MConnector newConnector = connector(1, "1.1");
MConnector oldConnector = connector(1);
// prepare the sqoop connector
SqoopConnector sqconnector = mock(SqoopConnector.class);
- when(validatorMock.validateLink(any(MLink.class))).thenReturn(validRepoMock);
- when(validatorMock.validateJob(any(MJob.class))).thenReturn(validRepoMock);
- when(sqconnector.getValidator()).thenReturn(validatorMock);
+ when(validatorMock.validateConfigForLink(any(MLink.class))).thenReturn(validRepoMock);
+ when(validatorMock.validateConfigForJob(any(MJob.class))).thenReturn(validRepoMock);
+ when(sqconnector.getConfigValidator()).thenReturn(validatorMock);
when(sqconnector.getRepositoryUpgrader()).thenReturn(upgraderMock);
- when(sqconnector.getLinkConfigurationClass()).thenReturn(EmptyConfigurationClass.class);
- when(sqconnector.getJobConfigurationClass(any(Direction.class))).thenReturn(JobConfiguration.class);
+ when(sqconnector.getLinkConfigurationClass()).thenReturn(EmptyConfigurationGroup.class);
+ when(sqconnector.getJobConfigurationClass(any(Direction.class))).thenReturn(DriverConfiguration.class);
when(connectorMgrMock.getConnector(anyString())).thenReturn(sqconnector);
// prepare the links and jobs
@@ -252,160 +256,82 @@ public class TestJdbcRepository {
txOrder.verify(repoTransactionMock, times(1)).commit();
txOrder.verify(repoTransactionMock, times(1)).close();
txOrder.verifyNoMoreInteractions();
- upgraderOrder.verify(upgraderMock, times(2)).upgrade(any(MConnectionForms.class), any(MConnectionForms.class));
- upgraderOrder.verify(upgraderMock, times(4)).upgrade(any(MJobForms.class), any(MJobForms.class));
+ upgraderOrder.verify(upgraderMock, times(2)).upgrade(any(MLinkConfig.class), any(MLinkConfig.class));
+ upgraderOrder.verify(upgraderMock, times(4)).upgrade(any(MFromConfig.class), any(MFromConfig.class));
upgraderOrder.verifyNoMoreInteractions();
- validatorOrder.verify(validatorMock, times(2)).validateLink(anyObject());
+ validatorOrder.verify(validatorMock, times(2)).validateConfigForLink(anyObject());
// @TODO(Abe): Re-enable job validation?
- validatorOrder.verify(validatorMock, times(0)).validateJob(anyObject());
+ validatorOrder.verify(validatorMock, times(0)).validateConfigForJob(anyObject());
validatorOrder.verifyNoMoreInteractions();
}
/**
- * @TODO(Abe): To re-enable with Validation in Repository upgrade.
- * Test the connector upgrade procedure, when all the links and
- * jobs using the old connector are invalid for the new connector
- */
-// @Test
-// public void testConnectorUpgradeWithInvalidLinksAndJobs() {
-// MConnector newConnector = connector(1, "1.1");
-// MConnector oldConnector = connector(1);
-//
-// // prepare the sqoop connector
-// SqoopConnector sqconnector = mock(SqoopConnector.class);
-// when(validator.validateLink(any(MLink.class))).thenReturn(invalid);
-// when(validator.validateJob(any(MJob.class))).thenReturn(invalid);
-// when(sqconnector.getValidator()).thenReturn(validator);
-// when(sqconnector.getDriverConfigRepositoryUpgrader()).thenReturn(upgrader);
-// when(sqconnector.getLinkConfigurationClass()).thenReturn(EmptyConfigurationClass.class);
-// when(sqconnector.getJobConfigurationClass(any(Direction.class))).thenReturn(JobConfiguration.class);
-// when(connectorMgr.getConnector(anyString())).thenReturn(sqconnector);
-//
-// // prepare the links and jobs
-// List<MLink> linkList = links(link(1,1), link(2,1));
-// List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,1));
-//
-// doReturn(linkList).when(repo).findLinksForConnector(anyLong());
-// doReturn(jobList).when(repo).findJobsForConnector(anyLong());
-// doNothing().when(repo).updateLink(any(MLink.class), any(RepositoryTransaction.class));
-// doNothing().when(repo).updateJob(any(MJob.class), any(RepositoryTransaction.class));
-// doNothing().when(repo).updateConnector(any(MConnector.class), any(RepositoryTransaction.class));
-//
-// try {
-// repo.upgradeConnector(oldConnector, newConnector);
-// } catch (SqoopException ex) {
-// assertEquals(ex.getErrorCode(), RepositoryError.JDBCREPO_0027);
-//
-// InOrder repoOrder = inOrder(repo);
-// InOrder txOrder = inOrder(tx);
-// InOrder upgraderOrder = inOrder(upgrader);
-// InOrder validatorOrder = inOrder(validator);
-//
-// repoOrder.verify(repo, times(1)).findLinksForConnector(anyLong());
-// repoOrder.verify(repo, times(1)).findJobsForConnector(anyLong());
-// repoOrder.verify(repo, times(1)).getTransaction();
-// repoOrder.verify(repo, times(1)).deleteJobInputs(1, tx);
-// repoOrder.verify(repo, times(1)).deleteJobInputs(2, tx);
-// repoOrder.verify(repo, times(1)).deleteLinkInputs(1, tx);
-// repoOrder.verify(repo, times(1)).deleteLinkInputs(2, tx);
-// repoOrder.verify(repo, times(1)).updateConnector(any(MConnector.class), any(RepositoryTransaction.class));
-// repoOrder.verifyNoMoreInteractions();
-// txOrder.verify(tx, times(1)).begin();
-// txOrder.verify(tx, times(1)).rollback();
-// txOrder.verify(tx, times(1)).close();
-// txOrder.verifyNoMoreInteractions();
-// upgraderOrder.verify(upgrader, times(2)).upgrade(any(MConnectionForms.class), any(MConnectionForms.class));
-// upgraderOrder.verify(upgrader, times(2)).upgrade(any(MJobForms.class), any(MJobForms.class));
-// upgraderOrder.verifyNoMoreInteractions();
-// validatorOrder.verify(validator, times(2)).validateLink(anyObject());
-// validatorOrder.verify(validator, times(2)).validateJob(anyObject());
-// validatorOrder.verifyNoMoreInteractions();
-// return ;
-// }
-//
-// fail("Should throw out an exception with code: " + RepositoryError.JDBCREPO_0027);
-// }
-
- /**
- * Test the driverConfig upgrade procedure, when all the links and
- * jobs using the old connector are still valid for the new connector
+ * Test the driverConfig upgrade procedure, when all jobs
+ * using the old connector are still valid for the new connector
*/
@Test
- public void testDriverConfigUpgradeWithValidLinksAndJobs() {
- MDriverConfig newDriverConfig = driverConfig();
+ public void testDriverConfigUpgradeWithValidJobs() {
+ MDriver newDriverConfig = driver();
- when(validatorMock.validateLink(any(MLink.class))).thenReturn(validRepoMock);
- when(validatorMock.validateJob(any(MJob.class))).thenReturn(validRepoMock);
+ when(validatorMock.validateConfigForLink(any(MLink.class))).thenReturn(validRepoMock);
+ when(validatorMock.validateConfigForJob(any(MJob.class))).thenReturn(validRepoMock);
when(driverMock.getValidator()).thenReturn(validatorMock);
when(driverMock.getDriverConfigRepositoryUpgrader()).thenReturn(upgraderMock);
- when(driverMock.getLinkConfigurationClass()).thenReturn(EmptyConfigurationClass.class);
- when(driverMock.getJobConfigurationClass()).thenReturn(JobConfiguration.class);
+ when(driverMock.getDriverConfigurationGroupClass()).thenReturn(EmptyConfigurationGroup.class);
- List<MLink> linkList = links(link(1,1), link(2,1));
List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,1));
- doReturn(linkList).when(repoSpy).findLinks();
doReturn(jobList).when(repoSpy).findJobs();
doNothing().when(repoSpy).updateLink(any(MLink.class), any(RepositoryTransaction.class));
doNothing().when(repoSpy).updateJob(any(MJob.class), any(RepositoryTransaction.class));
- doNothing().when(repoSpy).updateDriverConfig(any(MDriverConfig.class), any(RepositoryTransaction.class));
+ doNothing().when(repoSpy).updateDriver(any(MDriver.class), any(RepositoryTransaction.class));
- repoSpy.upgradeDriverConfig(newDriverConfig);
+ repoSpy.upgradeDriver(newDriverConfig);
InOrder repoOrder = inOrder(repoSpy);
InOrder txOrder = inOrder(repoTransactionMock);
InOrder upgraderOrder = inOrder(upgraderMock);
InOrder validatorOrder = inOrder(validatorMock);
- repoOrder.verify(repoSpy, times(1)).findLinks();
repoOrder.verify(repoSpy, times(1)).findJobs();
repoOrder.verify(repoSpy, times(1)).getTransaction();
repoOrder.verify(repoSpy, times(1)).deleteJobInputs(1, repoTransactionMock);
repoOrder.verify(repoSpy, times(1)).deleteJobInputs(2, repoTransactionMock);
- repoOrder.verify(repoSpy, times(1)).deleteLinkInputs(1, repoTransactionMock);
- repoOrder.verify(repoSpy, times(1)).deleteLinkInputs(2, repoTransactionMock);
- repoOrder.verify(repoSpy, times(1)).updateDriverConfig(any(MDriverConfig.class), any(RepositoryTransaction.class));
- repoOrder.verify(repoSpy, times(2)).updateLink(any(MLink.class), any(RepositoryTransaction.class));
+ repoOrder.verify(repoSpy, times(1)).updateDriver(any(MDriver.class), any(RepositoryTransaction.class));
repoOrder.verify(repoSpy, times(2)).updateJob(any(MJob.class), any(RepositoryTransaction.class));
repoOrder.verifyNoMoreInteractions();
txOrder.verify(repoTransactionMock, times(1)).begin();
txOrder.verify(repoTransactionMock, times(1)).commit();
txOrder.verify(repoTransactionMock, times(1)).close();
txOrder.verifyNoMoreInteractions();
- upgraderOrder.verify(upgraderMock, times(2)).upgrade(any(MConnectionForms.class), any(MConnectionForms.class));
- upgraderOrder.verify(upgraderMock, times(2)).upgrade(any(MJobForms.class), any(MJobForms.class));
+ upgraderOrder.verify(upgraderMock, times(2)).upgrade(any(MConfigList.class), any(MConfigList.class));
upgraderOrder.verifyNoMoreInteractions();
- validatorOrder.verify(validatorMock, times(2)).validateLink(anyObject());
- validatorOrder.verify(validatorMock, times(2)).validateJob(anyObject());
+ validatorOrder.verify(validatorMock, times(2)).validateConfigForJob(anyObject());
validatorOrder.verifyNoMoreInteractions();
}
/**
- * Test the driverConfig upgrade procedure, when all the links and
- * jobs using the old connector are invalid for the new connector
+ * Test the driverConfig upgrade procedure, when all the jobs
+ * using the old connector are invalid for the new connector
*/
@Test
- public void testDriverConfigUpgradeWithInvalidLinksAndJobs() {
- MDriverConfig newDriverConfig = driverConfig();
+ public void testDriverConfigUpgradeWithInvalidJobs() {
+ MDriver newDriverConfig = driver();
- when(validatorMock.validateLink(any(MLink.class))).thenReturn(invalidRepoMock);
- when(validatorMock.validateJob(any(MJob.class))).thenReturn(invalidRepoMock);
+ when(validatorMock.validateConfigForLink(any(MLink.class))).thenReturn(invalidRepoMock);
+ when(validatorMock.validateConfigForJob(any(MJob.class))).thenReturn(invalidRepoMock);
when(driverMock.getValidator()).thenReturn(validatorMock);
when(driverMock.getDriverConfigRepositoryUpgrader()).thenReturn(upgraderMock);
- when(driverMock.getLinkConfigurationClass()).thenReturn(EmptyConfigurationClass.class);
- when(driverMock.getJobConfigurationClass()).thenReturn(JobConfiguration.class);
+ when(driverMock.getDriverConfigurationGroupClass()).thenReturn(EmptyConfigurationGroup.class);
- List<MLink> linkList = links(link(1,1), link(2,1));
List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,1));
- doReturn(linkList).when(repoSpy).findLinks();
doReturn(jobList).when(repoSpy).findJobs();
- doNothing().when(repoSpy).updateLink(any(MLink.class), any(RepositoryTransaction.class));
doNothing().when(repoSpy).updateJob(any(MJob.class), any(RepositoryTransaction.class));
- doNothing().when(repoSpy).updateDriverConfig(any(MDriverConfig.class), any(RepositoryTransaction.class));
+ doNothing().when(repoSpy).updateDriver(any(MDriver.class), any(RepositoryTransaction.class));
try {
- repoSpy.upgradeDriverConfig(newDriverConfig);
+ repoSpy.upgradeDriver(newDriverConfig);
} catch (SqoopException ex) {
assertEquals(ex.getErrorCode(), RepositoryError.JDBCREPO_0027);
@@ -414,24 +340,20 @@ public class TestJdbcRepository {
InOrder upgraderOrder = inOrder(upgraderMock);
InOrder validatorOrder = inOrder(validatorMock);
- repoOrder.verify(repoSpy, times(1)).findLinks();
repoOrder.verify(repoSpy, times(1)).findJobs();
repoOrder.verify(repoSpy, times(1)).getTransaction();
repoOrder.verify(repoSpy, times(1)).deleteJobInputs(1, repoTransactionMock);
repoOrder.verify(repoSpy, times(1)).deleteJobInputs(2, repoTransactionMock);
- repoOrder.verify(repoSpy, times(1)).deleteLinkInputs(1, repoTransactionMock);
- repoOrder.verify(repoSpy, times(1)).deleteLinkInputs(2, repoTransactionMock);
- repoOrder.verify(repoSpy, times(1)).updateDriverConfig(any(MDriverConfig.class), any(RepositoryTransaction.class));
+ repoOrder.verify(repoSpy, times(1)).updateDriver(any(MDriver.class), any(RepositoryTransaction.class));
repoOrder.verifyNoMoreInteractions();
txOrder.verify(repoTransactionMock, times(1)).begin();
txOrder.verify(repoTransactionMock, times(1)).rollback();
txOrder.verify(repoTransactionMock, times(1)).close();
txOrder.verifyNoMoreInteractions();
- upgraderOrder.verify(upgraderMock, times(2)).upgrade(any(MConnectionForms.class), any(MConnectionForms.class));
- upgraderOrder.verify(upgraderMock, times(2)).upgrade(any(MJobForms.class), any(MJobForms.class));
+ upgraderOrder.verify(upgraderMock, times(2)).upgrade(any(MConfigList.class), any(MConfigList.class));
upgraderOrder.verifyNoMoreInteractions();
- validatorOrder.verify(validatorMock, times(2)).validateLink(anyObject());
- validatorOrder.verify(validatorMock, times(2)).validateJob(anyObject());
+ // driver configs are per job.
+ validatorOrder.verify(validatorMock, times(2)).validateConfigForJob(anyObject());
validatorOrder.verifyNoMoreInteractions();
return ;
}
@@ -444,12 +366,12 @@ public class TestJdbcRepository {
* find links for a given connector
*/
@Test
- public void testConnectorUpgradeHandlerFindLinksForConnectorError() {
+ public void testConnectorConfigUpgradeHandlerWithFindLinksForConnectorError() {
MConnector newConnector = connector(1, "1.1");
MConnector oldConnector = connector(1);
SqoopConnector sqconnector = mock(SqoopConnector.class);
- when(sqconnector.getValidator()).thenReturn(validatorMock);
+ when(sqconnector.getConfigValidator()).thenReturn(validatorMock);
when(sqconnector.getRepositoryUpgrader()).thenReturn(upgraderMock);
when(connectorMgrMock.getConnector(anyString())).thenReturn(sqconnector);
@@ -474,12 +396,12 @@ public class TestJdbcRepository {
* find jobs for a given connector
*/
@Test
- public void testConnectorUpgradeHandlerFindJobsForConnectorError() {
+ public void testConnectorConfigUpgradeHandlerWithFindJobsForConnectorError() {
MConnector newConnector = connector(1, "1.1");
MConnector oldConnector = connector(1);
SqoopConnector sqconnector = mock(SqoopConnector.class);
- when(sqconnector.getValidator()).thenReturn(validatorMock);
+ when(sqconnector.getConfigValidator()).thenReturn(validatorMock);
when(sqconnector.getRepositoryUpgrader()).thenReturn(upgraderMock);
when(connectorMgrMock.getConnector(anyString())).thenReturn(sqconnector);
@@ -508,12 +430,12 @@ public class TestJdbcRepository {
* delete job inputs for a given connector
*/
@Test
- public void testConnectorUpgradeHandlerDeleteJobInputsError() {
+ public void testConnectorConfigUpgradeHandlerWithDeleteJobInputsError() {
MConnector newConnector = connector(1, "1.1");
MConnector oldConnector = connector(1);
SqoopConnector sqconnector = mock(SqoopConnector.class);
- when(sqconnector.getValidator()).thenReturn(validatorMock);
+ when(sqconnector.getConfigValidator()).thenReturn(validatorMock);
when(sqconnector.getRepositoryUpgrader()).thenReturn(upgraderMock);
when(connectorMgrMock.getConnector(anyString())).thenReturn(sqconnector);
@@ -545,12 +467,12 @@ public class TestJdbcRepository {
* delete link inputs for a given connector
*/
@Test
- public void testConnectorUpgradeHandlerDeleteLinkInputsError() {
+ public void testConnectorConfigUpgradeHandlerWithDeleteLinkInputsError() {
MConnector newConnector = connector(1, "1.1");
MConnector oldConnector = connector(1);
SqoopConnector sqconnector = mock(SqoopConnector.class);
- when(sqconnector.getValidator()).thenReturn(validatorMock);
+ when(sqconnector.getConfigValidator()).thenReturn(validatorMock);
when(sqconnector.getRepositoryUpgrader()).thenReturn(upgraderMock);
when(connectorMgrMock.getConnector(anyString())).thenReturn(sqconnector);
@@ -584,12 +506,12 @@ public class TestJdbcRepository {
* update the connector entity
*/
@Test
- public void testConnectorUpgradeHandlerUpdateConnectorError() {
+ public void testConnectorConfigUpgradeHandlerWithUpdateConnectorError() {
MConnector newConnector = connector(1, "1.1");
MConnector oldConnector = connector(1);
SqoopConnector sqconnector = mock(SqoopConnector.class);
- when(sqconnector.getValidator()).thenReturn(validatorMock);
+ when(sqconnector.getConfigValidator()).thenReturn(validatorMock);
when(sqconnector.getRepositoryUpgrader()).thenReturn(upgraderMock);
when(connectorMgrMock.getConnector(anyString())).thenReturn(sqconnector);
@@ -625,17 +547,17 @@ public class TestJdbcRepository {
* update the link entity
*/
@Test
- public void testConnectorUpgradeHandlerUpdateLinkError() {
+ public void testConnectorConfigUpgradeHandlerWithUpdateLinkError() {
MConnector newConnector = connector(1, "1.1");
MConnector oldConnector = connector(1);
SqoopConnector sqconnector = mock(SqoopConnector.class);
- when(validatorMock.validateLink(any(MLink.class))).thenReturn(validRepoMock);
- when(validatorMock.validateJob(any(MJob.class))).thenReturn(validRepoMock);
- when(sqconnector.getValidator()).thenReturn(validatorMock);
+ when(validatorMock.validateConfigForLink(any(MLink.class))).thenReturn(validRepoMock);
+ when(validatorMock.validateConfigForJob(any(MJob.class))).thenReturn(validRepoMock);
+ when(sqconnector.getConfigValidator()).thenReturn(validatorMock);
when(sqconnector.getRepositoryUpgrader()).thenReturn(upgraderMock);
- when(sqconnector.getLinkConfigurationClass()).thenReturn(EmptyConfigurationClass.class);
- when(sqconnector.getJobConfigurationClass(any(Direction.class))).thenReturn(JobConfiguration.class);
+ when(sqconnector.getLinkConfigurationClass()).thenReturn(EmptyConfigurationGroup.class);
+ when(sqconnector.getJobConfigurationClass(any(Direction.class))).thenReturn(DriverConfiguration.class);
when(connectorMgrMock.getConnector(anyString())).thenReturn(sqconnector);
List<MLink> linkList = links(link(1,1), link(2,1));
@@ -674,17 +596,17 @@ public class TestJdbcRepository {
* update the job entity
*/
@Test
- public void testConnectorUpgradeHandlerUpdateJobError() {
+ public void testConnectorConfigUpgradeHandlerWithUpdateJobError() {
MConnector newConnector = connector(1, "1.1");
MConnector oldConnector = connector(1);
SqoopConnector sqconnector = mock(SqoopConnector.class);
- when(validatorMock.validateLink(any(MLink.class))).thenReturn(validRepoMock);
- when(validatorMock.validateJob(any(MJob.class))).thenReturn(validRepoMock);
- when(sqconnector.getValidator()).thenReturn(validatorMock);
+ when(validatorMock.validateConfigForLink(any(MLink.class))).thenReturn(validRepoMock);
+ when(validatorMock.validateConfigForJob(any(MJob.class))).thenReturn(validRepoMock);
+ when(sqconnector.getConfigValidator()).thenReturn(validatorMock);
when(sqconnector.getRepositoryUpgrader()).thenReturn(upgraderMock);
- when(sqconnector.getLinkConfigurationClass()).thenReturn(EmptyConfigurationClass.class);
- when(sqconnector.getJobConfigurationClass(any(Direction.class))).thenReturn(JobConfiguration.class);
+ when(sqconnector.getLinkConfigurationClass()).thenReturn(EmptyConfigurationGroup.class);
+ when(sqconnector.getJobConfigurationClass(any(Direction.class))).thenReturn(DriverConfiguration.class);
when(connectorMgrMock.getConnector(anyString())).thenReturn(sqconnector);
List<MLink> linkList = links(link(1,1), link(2,1));
@@ -724,54 +646,23 @@ public class TestJdbcRepository {
/**
* Test the exception handling procedure when the database handler fails to
- * find links for driverConfig
- */
- @Test
- public void testDriverConfigUpgradeHandlerFindLinksError() {
- MDriverConfig newDriverConfig = driverConfig();
-
- when(driverMock.getValidator()).thenReturn(validatorMock);
- when(driverMock.getDriverConfigRepositoryUpgrader()).thenReturn(upgraderMock);
-
- SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
- "find links error.");
- doThrow(exception).when(repoHandlerMock).findLinks(any(Connection.class));
-
- try {
- repoSpy.upgradeDriverConfig(newDriverConfig);
- } catch (SqoopException ex) {
- assertEquals(ex.getMessage(), exception.getMessage());
- verify(repoHandlerMock, times(1)).findLinks(any(Connection.class));
- verifyNoMoreInteractions(repoHandlerMock);
- return ;
- }
-
- fail("Should throw out an exception with message: " + exception.getMessage());
- }
-
- /**
- * Test the exception handling procedure when the database handler fails to
* find jobs for driverConfig
*/
@Test
- public void testDriverConfigUpgradeHandlerFindJobsError() {
- MDriverConfig newDriverConfig = driverConfig();
+ public void testDriverConfigUpgradeHandlerWithFindJobsError() {
+ MDriver newDriverConfig = driver();
when(driverMock.getValidator()).thenReturn(validatorMock);
when(driverMock.getDriverConfigRepositoryUpgrader()).thenReturn(upgraderMock);
- List<MLink> linkList = links(link(1,1), link(2,1));
- doReturn(linkList).when(repoHandlerMock).findLinks(any(Connection.class));
-
SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
"find jobs error.");
doThrow(exception).when(repoHandlerMock).findJobs(any(Connection.class));
try {
- repoSpy.upgradeDriverConfig(newDriverConfig);
+ repoSpy.upgradeDriver(newDriverConfig);
} catch (SqoopException ex) {
assertEquals(ex.getMessage(), exception.getMessage());
- verify(repoHandlerMock, times(1)).findLinks(any(Connection.class));
verify(repoHandlerMock, times(1)).findJobs(any(Connection.class));
verifyNoMoreInteractions(repoHandlerMock);
return ;
@@ -785,15 +676,13 @@ public class TestJdbcRepository {
* delete job inputs for driverConfig upgrade
*/
@Test
- public void testDriverConfigUpgradeHandlerDeleteJobInputsError() {
- MDriverConfig newDriverConfig = driverConfig();
+ public void testDriverConfigUpgradeHandlerWithDeleteJobInputsError() {
+ MDriver newDriverConfig = driver();
when(driverMock.getValidator()).thenReturn(validatorMock);
when(driverMock.getDriverConfigRepositoryUpgrader()).thenReturn(upgraderMock);
- List<MLink> linkList = links(link(1,1), link(2,1));
List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,1));
- doReturn(linkList).when(repoHandlerMock).findLinks(any(Connection.class));
doReturn(jobList).when(repoHandlerMock).findJobs(any(Connection.class));
SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
@@ -801,10 +690,9 @@ public class TestJdbcRepository {
doThrow(exception).when(repoHandlerMock).deleteJobInputs(anyLong(), any(Connection.class));
try {
- repoSpy.upgradeDriverConfig(newDriverConfig);
+ repoSpy.upgradeDriver(newDriverConfig);
} catch (SqoopException ex) {
assertEquals(ex.getMessage(), exception.getMessage());
- verify(repoHandlerMock, times(1)).findLinks(any(Connection.class));
verify(repoHandlerMock, times(1)).findJobs(any(Connection.class));
verify(repoHandlerMock, times(1)).deleteJobInputs(anyLong(), any(Connection.class));
verifyNoMoreInteractions(repoHandlerMock);
@@ -816,71 +704,31 @@ public class TestJdbcRepository {
/**
* Test the exception handling procedure when the database handler fails to
- * delete link inputs for driverConfig upgrade
- */
- @Test
- public void testDriverConfigUpgradeHandlerDeleteConnectionInputsError() {
- MDriverConfig newDriverConfig = driverConfig();
-
- when(driverMock.getValidator()).thenReturn(validatorMock);
- when(driverMock.getDriverConfigRepositoryUpgrader()).thenReturn(upgraderMock);
-
- List<MLink> linkList = links(link(1,1), link(2,1));
- List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,1));
- doReturn(linkList).when(repoHandlerMock).findLinks(any(Connection.class));
- doReturn(jobList).when(repoHandlerMock).findJobs(any(Connection.class));
- doNothing().when(repoHandlerMock).deleteJobInputs(anyLong(), any(Connection.class));
-
- SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
- "delete link inputs error.");
- doThrow(exception).when(repoHandlerMock).deleteLinkInputs(anyLong(), any(Connection.class));
-
- try {
- repoSpy.upgradeDriverConfig(newDriverConfig);
- } catch (SqoopException ex) {
- assertEquals(ex.getMessage(), exception.getMessage());
- verify(repoHandlerMock, times(1)).findLinks(any(Connection.class));
- verify(repoHandlerMock, times(1)).findJobs(any(Connection.class));
- verify(repoHandlerMock, times(2)).deleteJobInputs(anyLong(), any(Connection.class));
- verify(repoHandlerMock, times(1)).deleteLinkInputs(anyLong(), any(Connection.class));
- verifyNoMoreInteractions(repoHandlerMock);
- return ;
- }
-
- fail("Should throw out an exception with message: " + exception.getMessage());
- }
-
- /**
- * Test the exception handling procedure when the database handler fails to
* update the driverConfig entity
*/
@Test
- public void testDriverConfigUpgradeHandlerUpdateDriverConfigError() {
- MDriverConfig newDriverConfig = driverConfig();
+ public void testDriverConfigUpgradeHandlerWithUpdateDriverConfigError() {
+ MDriver newDriverConfig = driver();
when(driverMock.getValidator()).thenReturn(validatorMock);
when(driverMock.getDriverConfigRepositoryUpgrader()).thenReturn(upgraderMock);
- List<MLink> linkList = links(link(1,1), link(2,1));
List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,1));
- doReturn(linkList).when(repoHandlerMock).findLinks(any(Connection.class));
doReturn(jobList).when(repoHandlerMock).findJobs(any(Connection.class));
doNothing().when(repoHandlerMock).deleteJobInputs(anyLong(), any(Connection.class));
doNothing().when(repoHandlerMock).deleteLinkInputs(anyLong(), any(Connection.class));
SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
"update driverConfig entity error.");
- doThrow(exception).when(repoHandlerMock).updateDriverConfig(any(MDriverConfig.class), any(Connection.class));
+ doThrow(exception).when(repoHandlerMock).updateDriver(any(MDriver.class), any(Connection.class));
try {
- repoSpy.upgradeDriverConfig(newDriverConfig);
+ repoSpy.upgradeDriver(newDriverConfig);
} catch (SqoopException ex) {
assertEquals(ex.getMessage(), exception.getMessage());
- verify(repoHandlerMock, times(1)).findLinks(any(Connection.class));
verify(repoHandlerMock, times(1)).findJobs(any(Connection.class));
verify(repoHandlerMock, times(2)).deleteJobInputs(anyLong(), any(Connection.class));
- verify(repoHandlerMock, times(2)).deleteLinkInputs(anyLong(), any(Connection.class));
- verify(repoHandlerMock, times(1)).updateDriverConfig(any(MDriverConfig.class), any(Connection.class));
+ verify(repoHandlerMock, times(1)).updateDriver(any(MDriver.class), any(Connection.class));
verifyNoMoreInteractions(repoHandlerMock);
return ;
}
@@ -888,93 +736,38 @@ public class TestJdbcRepository {
fail("Should throw out an exception with message: " + exception.getMessage());
}
- /**
- * Test the exception handling procedure when the database handler fails to
- * update the link entity
- */
- @Test
- public void testDriverConfigUpgradeHandlerUpdateConnectionError() {
- MDriverConfig newDriverConfig = driverConfig();
-
- when(validatorMock.validateLink(any(MLink.class))).thenReturn(validRepoMock);
- when(validatorMock.validateJob(any(MJob.class))).thenReturn(validRepoMock);
- when(driverMock.getValidator()).thenReturn(validatorMock);
- when(driverMock.getDriverConfigRepositoryUpgrader()).thenReturn(upgraderMock);
- when(driverMock.getLinkConfigurationClass()).thenReturn(EmptyConfigurationClass.class);
- when(driverMock.getJobConfigurationClass()).thenReturn(JobConfiguration.class);
-
- List<MLink> linkList = links(link(1,1), link(2,1));
- List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,1));
- doReturn(linkList).when(repoHandlerMock).findLinks(any(Connection.class));
- doReturn(jobList).when(repoHandlerMock).findJobs(any(Connection.class));
- doNothing().when(repoHandlerMock).deleteJobInputs(anyLong(), any(Connection.class));
- doNothing().when(repoHandlerMock).deleteLinkInputs(anyLong(), any(Connection.class));
- doNothing().when(repoHandlerMock).updateDriverConfig(any(MDriverConfig.class), any(Connection.class));
- doReturn(true).when(repoHandlerMock).existsLink(anyLong(), any(Connection.class));
-
- SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
- "update link error.");
- doThrow(exception).when(repoHandlerMock).updateLink(any(MLink.class), any(Connection.class));
-
- try {
- repoSpy.upgradeDriverConfig(newDriverConfig);
- } catch (SqoopException ex) {
- assertEquals(ex.getMessage(), exception.getMessage());
- verify(repoHandlerMock, times(1)).findLinks(any(Connection.class));
- verify(repoHandlerMock, times(1)).findJobs(any(Connection.class));
- verify(repoHandlerMock, times(2)).deleteJobInputs(anyLong(), any(Connection.class));
- verify(repoHandlerMock, times(2)).deleteLinkInputs(anyLong(), any(Connection.class));
- verify(repoHandlerMock, times(1)).updateDriverConfig(any(MDriverConfig.class), any(Connection.class));
- verify(repoHandlerMock, times(1)).existsLink(anyLong(), any(Connection.class));
- verify(repoHandlerMock, times(1)).updateLink(any(MLink.class), any(Connection.class));
- verifyNoMoreInteractions(repoHandlerMock);
- return ;
- }
-
- fail("Should throw out an exception with message: " + exception.getMessage());
- }
/**
* Test the exception handling procedure when the database handler fails to
* update the job entity
*/
@Test
- public void testDriverConfigUpgradeHandlerUpdateJobError() {
- MDriverConfig driverConfig = driverConfig();
+ public void testDriverConfigUpgradeHandlerWithUpdateJobError() {
+ MDriver driverConfig = driver();
- when(validatorMock.validateLink(any(MLink.class))).thenReturn(validRepoMock);
- when(validatorMock.validateJob(any(MJob.class))).thenReturn(validRepoMock);
+ when(validatorMock.validateConfigForLink(any(MLink.class))).thenReturn(validRepoMock);
+ when(validatorMock.validateConfigForJob(any(MJob.class))).thenReturn(validRepoMock);
when(driverMock.getValidator()).thenReturn(validatorMock);
when(driverMock.getDriverConfigRepositoryUpgrader()).thenReturn(upgraderMock);
- when(driverMock.getLinkConfigurationClass()).thenReturn(EmptyConfigurationClass.class);
- when(driverMock.getJobConfigurationClass()).thenReturn(JobConfiguration.class);
+ when(driverMock.getDriverConfigurationGroupClass()).thenReturn(EmptyConfigurationGroup.class);
- List<MLink> linkList = links(link(1,1), link(2,1));
List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,1));
- doReturn(linkList).when(repoHandlerMock).findLinks(any(Connection.class));
doReturn(jobList).when(repoHandlerMock).findJobs(any(Connection.class));
doNothing().when(repoHandlerMock).deleteJobInputs(anyLong(), any(Connection.class));
- doNothing().when(repoHandlerMock).deleteLinkInputs(anyLong(), any(Connection.class));
- doNothing().when(repoHandlerMock).updateDriverConfig(any(MDriverConfig.class), any(Connection.class));
- doReturn(true).when(repoHandlerMock).existsLink(anyLong(), any(Connection.class));
+ doNothing().when(repoHandlerMock).updateDriver(any(MDriver.class), any(Connection.class));
doReturn(true).when(repoHandlerMock).existsJob(anyLong(), any(Connection.class));
- doNothing().when(repoHandlerMock).updateLink(any(MLink.class), any(Connection.class));
SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
"update job error.");
doThrow(exception).when(repoHandlerMock).updateJob(any(MJob.class), any(Connection.class));
try {
- repoSpy.upgradeDriverConfig(driverConfig);
+ repoSpy.upgradeDriver(driverConfig);
} catch (SqoopException ex) {
assertEquals(ex.getMessage(), exception.getMessage());
- verify(repoHandlerMock, times(1)).findLinks(any(Connection.class));
verify(repoHandlerMock, times(1)).findJobs(any(Connection.class));
verify(repoHandlerMock, times(2)).deleteJobInputs(anyLong(), any(Connection.class));
- verify(repoHandlerMock, times(2)).deleteLinkInputs(anyLong(), any(Connection.class));
- verify(repoHandlerMock, times(1)).updateDriverConfig(any(MDriverConfig.class), any(Connection.class));
- verify(repoHandlerMock, times(2)).existsLink(anyLong(), any(Connection.class));
- verify(repoHandlerMock, times(2)).updateLink(any(MLink.class), any(Connection.class));
+ verify(repoHandlerMock, times(1)).updateDriver(any(MDriver.class), any(Connection.class));
verify(repoHandlerMock, times(1)).existsJob(anyLong(), any(Connection.class));
verify(repoHandlerMock, times(1)).updateJob(any(MJob.class), any(Connection.class));
verifyNoMoreInteractions(repoHandlerMock);
@@ -986,9 +779,9 @@ public class TestJdbcRepository {
private MConnector connector(long connectorId, String version) {
MConnector connector = new MConnector("A" + connectorId, "A" + connectorId, version + connectorId,
- new MConnectionForms(new LinkedList<MForm>()),
- new MJobForms(FormUtils.toForms(JobConfiguration.class)),
- new MJobForms(FormUtils.toForms(JobConfiguration.class)));
+ new MLinkConfig(new LinkedList<MConfig>()),
+ new MFromConfig(ConfigUtils.toConfigs(FromJobConfigurationGroup.class)),
+ new MToConfig(ConfigUtils.toConfigs(ToJobConfigurationGroup.class)));
connector.setPersistenceId(connectorId);
return connector;
}
@@ -997,34 +790,30 @@ public class TestJdbcRepository {
return connector(connectoId, "1.0");
}
- private MDriverConfig driverConfig() {
- MDriverConfig driverConfig = new MDriverConfig(
- new MConnectionForms(new LinkedList<MForm>()),
- new MJobForms(FormUtils.toForms(JobConfiguration.class)),
- Driver.CURRENT_DRIVER_VERSION);
- driverConfig.setPersistenceId(1);
- return driverConfig;
+ private MDriver driver() {
+ MDriver driver = new MDriver(new MDriverConfig(new LinkedList<MConfig>()),
+ DriverBean.CURRENT_DRIVER_VERSION);
+ driver.setPersistenceId(1);
+ return driver;
}
- private MDriverConfig anotherDriverConfig() {
- MDriverConfig driverConfig = new MDriverConfig(null, null,
- Driver.CURRENT_DRIVER_VERSION);
- driverConfig.setPersistenceId(1);
- return driverConfig;
+ private MDriver anotherDriver() {
+ MDriver driver = new MDriver(null, DriverBean.CURRENT_DRIVER_VERSION);
+ driver.setPersistenceId(1);
+ return driver;
}
private MLink link(long linkId, long connectorId) {
- MLink link = new MLink(connectorId, new MConnectionForms(new LinkedList<MForm>()),
- new MConnectionForms(new LinkedList<MForm>()));
+ MLink link = new MLink(connectorId, new MLinkConfig(new LinkedList<MConfig>()));
link.setPersistenceId(linkId);
return link;
}
private MJob job(long id, long fromConnectorId, long toConnectorId, long fromLinkId, long toLinkId) {
MJob job = new MJob(fromConnectorId, toConnectorId, fromLinkId, toLinkId,
- new MJobForms(new LinkedList<MForm>()),
- new MJobForms(new LinkedList<MForm>()),
- new MJobForms(new LinkedList<MForm>()));
+ new MFromConfig(new LinkedList<MConfig>()),
+ new MToConfig(new LinkedList<MConfig>()),
+ new MDriverConfig(new LinkedList<MConfig>()));
job.setPersistenceId(id);
return job;
}
@@ -1042,6 +831,12 @@ public class TestJdbcRepository {
}
@ConfigurationClass
- public static class EmptyConfigurationClass {
+ public static class EmptyConfigurationGroup {
+ }
+ @ConfigurationClass
+ public static class FromJobConfigurationGroup {
+ }
+ @ConfigurationClass
+ public static class ToJobConfigurationGroup {
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/execution/mapreduce/src/main/java/org/apache/sqoop/job/io/Data.java
----------------------------------------------------------------------
diff --git a/execution/mapreduce/src/main/java/org/apache/sqoop/job/io/Data.java b/execution/mapreduce/src/main/java/org/apache/sqoop/job/io/Data.java
index 83c670c..5423b7b 100644
--- a/execution/mapreduce/src/main/java/org/apache/sqoop/job/io/Data.java
+++ b/execution/mapreduce/src/main/java/org/apache/sqoop/job/io/Data.java
@@ -526,4 +526,4 @@ public class Data implements WritableComparable<Data> {
String replacement = String.valueOf(stringDelimiter);
return string.replaceAll(regex, replacement);
}
-}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/ConfigurationUtils.java
----------------------------------------------------------------------
diff --git a/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/ConfigurationUtils.java b/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/ConfigurationUtils.java
index b533837..0fa07f7 100644
--- a/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/ConfigurationUtils.java
+++ b/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/ConfigurationUtils.java
@@ -25,7 +25,7 @@ import org.apache.log4j.PropertyConfigurator;
import org.apache.sqoop.common.Direction;
import org.apache.sqoop.job.JobConstants;
import org.apache.sqoop.json.util.SchemaSerialization;
-import org.apache.sqoop.model.FormUtils;
+import org.apache.sqoop.model.ConfigUtils;
import org.apache.sqoop.schema.Schema;
import org.apache.sqoop.utils.ClassUtils;
import org.json.simple.JSONObject;
@@ -40,47 +40,35 @@ import java.util.Properties;
*/
public final class ConfigurationUtils {
- private static final String JOB_CONFIG_CLASS_FROM_CONNECTOR_CONNECTION = JobConstants.PREFIX_JOB_CONFIG + "config.class.connector.from.connection";
+ private static final String MR_JOB_CONFIG_CLASS_FROM_CONNECTOR_LINK = JobConstants.PREFIX_JOB_CONFIG + "config.class.connector.from.link";
- private static final String JOB_CONFIG_CLASS_TO_CONNECTOR_CONNECTION = JobConstants.PREFIX_JOB_CONFIG + "config.class.connector.to.connection";
+ private static final String MR_JOB_CONFIG_CLASS_TO_CONNECTOR_LINK = JobConstants.PREFIX_JOB_CONFIG + "config.class.connector.to.link";
- private static final String JOB_CONFIG_CLASS_FROM_CONNECTOR_JOB = JobConstants.PREFIX_JOB_CONFIG + "config.class.connector.from.job";
+ private static final String MR_JOB_CONFIG_CLASS_FROM_CONNECTOR_JOB = JobConstants.PREFIX_JOB_CONFIG + "config.class.connector.from.job";
- private static final String JOB_CONFIG_CLASS_TO_CONNECTOR_JOB = JobConstants.PREFIX_JOB_CONFIG + "config.class.connector.to.job";
+ private static final String MR_JOB_CONFIG_CLASS_TO_CONNECTOR_JOB = JobConstants.PREFIX_JOB_CONFIG + "config.class.connector.to.job";
- private static final String JOB_CONFIG_CLASS_FROM_FRAMEWORK_CONNECTION = JobConstants.PREFIX_JOB_CONFIG + "config.class.framework.from.connection";
+ private static final String MR_JOB_CONFIG_DRIVER_CONFIG_CLASS = JobConstants.PREFIX_JOB_CONFIG + "config.class.driver";
- private static final String JOB_CONFIG_CLASS_TO_FRAMEWORK_CONNECTION = JobConstants.PREFIX_JOB_CONFIG + "config.class.framework.to.connection";
+ private static final String MR_JOB_CONFIG_FROM_CONNECTOR_LINK = JobConstants.PREFIX_JOB_CONFIG + "config.connector.from.link";
- private static final String JOB_CONFIG_CLASS_FRAMEWORK_JOB = JobConstants.PREFIX_JOB_CONFIG + "config.class.framework.job";
+ private static final Text MR_JOB_CONFIG_FROM_CONNECTOR_LINK_KEY = new Text(MR_JOB_CONFIG_FROM_CONNECTOR_LINK);
- private static final String JOB_CONFIG_FROM_CONNECTOR_CONNECTION = JobConstants.PREFIX_JOB_CONFIG + "config.connector.from.connection";
+ private static final String MR_JOB_CONFIG_TO_CONNECTOR_LINK = JobConstants.PREFIX_JOB_CONFIG + "config.connector.to.link";
- private static final Text JOB_CONFIG_FROM_CONNECTOR_CONNECTION_KEY = new Text(JOB_CONFIG_FROM_CONNECTOR_CONNECTION);
+ private static final Text MR_JOB_CONFIG_TO_CONNECTOR_LINK_KEY = new Text(MR_JOB_CONFIG_TO_CONNECTOR_LINK);
- private static final String JOB_CONFIG_TO_CONNECTOR_CONNECTION = JobConstants.PREFIX_JOB_CONFIG + "config.connector.to.connection";
+ private static final String MR_JOB_CONFIG_FROM_JOB_CONFIG = JobConstants.PREFIX_JOB_CONFIG + "config.connector.from.job";
- private static final Text JOB_CONFIG_TO_CONNECTOR_CONNECTION_KEY = new Text(JOB_CONFIG_TO_CONNECTOR_CONNECTION);
+ private static final Text MR_JOB_CONFIG_FROM_JOB_CONFIG_KEY = new Text(MR_JOB_CONFIG_FROM_JOB_CONFIG);
- private static final String JOB_CONFIG_FROM_CONNECTOR_JOB = JobConstants.PREFIX_JOB_CONFIG + "config.connector.from.job";
+ private static final String MR_JOB_CONFIG_TO_JOB_CONFIG = JobConstants.PREFIX_JOB_CONFIG + "config.connector.to.job";
- private static final Text JOB_CONFIG_FROM_CONNECTOR_JOB_KEY = new Text(JOB_CONFIG_FROM_CONNECTOR_JOB);
+ private static final Text MR_JOB_CONFIG_TO_JOB_CONFIG_KEY = new Text(MR_JOB_CONFIG_TO_JOB_CONFIG);
- private static final String JOB_CONFIG_TO_CONNECTOR_JOB = JobConstants.PREFIX_JOB_CONFIG + "config.connector.to.job";
+ private static final String MR_JOB_CONFIG_DRIVER_CONFIG = JobConstants.PREFIX_JOB_CONFIG + "config.driver";
- private static final Text JOB_CONFIG_TO_CONNECTOR_JOB_KEY = new Text(JOB_CONFIG_TO_CONNECTOR_JOB);
-
- private static final String JOB_CONFIG_FROM_FRAMEWORK_CONNECTION = JobConstants.PREFIX_JOB_CONFIG + "config.framework.from.connection";
-
- private static final Text JOB_CONFIG_FROM_FRAMEWORK_CONNECTION_KEY = new Text(JOB_CONFIG_FROM_FRAMEWORK_CONNECTION);
-
- private static final String JOB_CONFIG_TO_FRAMEWORK_CONNECTION = JobConstants.PREFIX_JOB_CONFIG + "config.framework.from.connection";
-
- private static final Text JOB_CONFIG_TO_FRAMEWORK_CONNECTION_KEY = new Text(JOB_CONFIG_TO_FRAMEWORK_CONNECTION);
-
- private static final String JOB_CONFIG_FRAMEWORK_JOB = JobConstants.PREFIX_JOB_CONFIG + "config.framework.job";
-
- private static final Text JOB_CONFIG_FRAMEWORK_JOB_KEY = new Text(JOB_CONFIG_FRAMEWORK_JOB);
+ private static final Text MR_JOB_CONFIG_DRIVER_CONFIG_KEY = new Text(MR_JOB_CONFIG_DRIVER_CONFIG);
private static final String SCHEMA_FROM = JobConstants.PREFIX_JOB_CONFIG + "schema.connector.from";
@@ -92,21 +80,21 @@ public final class ConfigurationUtils {
/**
- * Persist Connector configuration object for connection.
+ * Persist Connector configuration object for link.
*
* @param job MapReduce job object
* @param obj Configuration object
*/
- public static void setConnectorConnectionConfig(Direction type, Job job, Object obj) {
+ public static void setConnectorLinkConfig(Direction type, Job job, Object obj) {
switch (type) {
case FROM:
- job.getConfiguration().set(JOB_CONFIG_CLASS_FROM_CONNECTOR_CONNECTION, obj.getClass().getName());
- job.getCredentials().addSecretKey(JOB_CONFIG_FROM_CONNECTOR_CONNECTION_KEY, FormUtils.toJson(obj).getBytes());
+ job.getConfiguration().set(MR_JOB_CONFIG_CLASS_FROM_CONNECTOR_LINK, obj.getClass().getName());
+ job.getCredentials().addSecretKey(MR_JOB_CONFIG_FROM_CONNECTOR_LINK_KEY, ConfigUtils.toJson(obj).getBytes());
break;
case TO:
- job.getConfiguration().set(JOB_CONFIG_CLASS_TO_CONNECTOR_CONNECTION, obj.getClass().getName());
- job.getCredentials().addSecretKey(JOB_CONFIG_TO_CONNECTOR_CONNECTION_KEY, FormUtils.toJson(obj).getBytes());
+ job.getConfiguration().set(MR_JOB_CONFIG_CLASS_TO_CONNECTOR_LINK, obj.getClass().getName());
+ job.getCredentials().addSecretKey(MR_JOB_CONFIG_TO_CONNECTOR_LINK_KEY, ConfigUtils.toJson(obj).getBytes());
break;
}
}
@@ -120,46 +108,27 @@ public final class ConfigurationUtils {
public static void setConnectorJobConfig(Direction type, Job job, Object obj) {
switch (type) {
case FROM:
- job.getConfiguration().set(JOB_CONFIG_CLASS_FROM_CONNECTOR_JOB, obj.getClass().getName());
- job.getCredentials().addSecretKey(JOB_CONFIG_FROM_CONNECTOR_JOB_KEY, FormUtils.toJson(obj).getBytes());
+ job.getConfiguration().set(MR_JOB_CONFIG_CLASS_FROM_CONNECTOR_JOB, obj.getClass().getName());
+ job.getCredentials().addSecretKey(MR_JOB_CONFIG_FROM_JOB_CONFIG_KEY, ConfigUtils.toJson(obj).getBytes());
break;
case TO:
- job.getConfiguration().set(JOB_CONFIG_CLASS_TO_CONNECTOR_JOB, obj.getClass().getName());
- job.getCredentials().addSecretKey(JOB_CONFIG_TO_CONNECTOR_JOB_KEY, FormUtils.toJson(obj).getBytes());
+ job.getConfiguration().set(MR_JOB_CONFIG_CLASS_TO_CONNECTOR_JOB, obj.getClass().getName());
+ job.getCredentials().addSecretKey(MR_JOB_CONFIG_TO_JOB_CONFIG_KEY, ConfigUtils.toJson(obj).getBytes());
break;
}
}
- /**
- * Persist Framework configuration object for connection.
- *
- * @param job MapReduce job object
- * @param obj Configuration object
- */
- public static void setFrameworkConnectionConfig(Direction type, Job job, Object obj) {
- switch (type) {
- case FROM:
- job.getConfiguration().set(JOB_CONFIG_CLASS_FROM_FRAMEWORK_CONNECTION, obj.getClass().getName());
- job.getCredentials().addSecretKey(JOB_CONFIG_FROM_FRAMEWORK_CONNECTION_KEY, FormUtils.toJson(obj).getBytes());
- break;
-
- case TO:
- job.getConfiguration().set(JOB_CONFIG_CLASS_TO_FRAMEWORK_CONNECTION, obj.getClass().getName());
- job.getCredentials().addSecretKey(JOB_CONFIG_TO_FRAMEWORK_CONNECTION_KEY, FormUtils.toJson(obj).getBytes());
- break;
- }
- }
/**
- * Persist Framework configuration object for job.
+ * Persist driver configuration object for job.
*
* @param job MapReduce job object
* @param obj Configuration object
*/
- public static void setFrameworkJobConfig(Job job, Object obj) {
- job.getConfiguration().set(JOB_CONFIG_CLASS_FRAMEWORK_JOB, obj.getClass().getName());
- job.getCredentials().addSecretKey(JOB_CONFIG_FRAMEWORK_JOB_KEY, FormUtils.toJson(obj).getBytes());
+ public static void setDriverConfig(Job job, Object obj) {
+ job.getConfiguration().set(MR_JOB_CONFIG_DRIVER_CONFIG_CLASS, obj.getClass().getName());
+ job.getCredentials().addSecretKey(MR_JOB_CONFIG_DRIVER_CONFIG_KEY, ConfigUtils.toJson(obj).getBytes());
}
/**
@@ -185,17 +154,16 @@ public final class ConfigurationUtils {
/**
* Retrieve Connector configuration object for connection.
- *
* @param configuration MapReduce configuration object
* @return Configuration object
*/
public static Object getConnectorConnectionConfig(Direction type, Configuration configuration) {
switch (type) {
case FROM:
- return loadConfiguration((JobConf) configuration, JOB_CONFIG_CLASS_FROM_CONNECTOR_CONNECTION, JOB_CONFIG_FROM_CONNECTOR_CONNECTION_KEY);
+ return loadConfiguration((JobConf) configuration, MR_JOB_CONFIG_CLASS_FROM_CONNECTOR_LINK, MR_JOB_CONFIG_FROM_CONNECTOR_LINK_KEY);
case TO:
- return loadConfiguration((JobConf) configuration, JOB_CONFIG_CLASS_TO_CONNECTOR_CONNECTION, JOB_CONFIG_TO_CONNECTOR_CONNECTION_KEY);
+ return loadConfiguration((JobConf) configuration, MR_JOB_CONFIG_CLASS_TO_CONNECTOR_LINK, MR_JOB_CONFIG_TO_CONNECTOR_LINK_KEY);
}
return null;
@@ -210,28 +178,10 @@ public final class ConfigurationUtils {
public static Object getConnectorJobConfig(Direction type, Configuration configuration) {
switch (type) {
case FROM:
- return loadConfiguration((JobConf) configuration, JOB_CONFIG_CLASS_FROM_CONNECTOR_JOB, JOB_CONFIG_FROM_CONNECTOR_JOB_KEY);
-
- case TO:
- return loadConfiguration((JobConf) configuration, JOB_CONFIG_CLASS_TO_CONNECTOR_JOB, JOB_CONFIG_TO_CONNECTOR_JOB_KEY);
- }
-
- return null;
- }
-
- /**
- * Retrieve Framework configuration object for connection.
- *
- * @param configuration MapReduce configuration object
- * @return Configuration object
- */
- public static Object getFrameworkConnectionConfig(Direction type, Configuration configuration) {
- switch (type) {
- case FROM:
- return loadConfiguration((JobConf) configuration, JOB_CONFIG_CLASS_FROM_FRAMEWORK_CONNECTION, JOB_CONFIG_FROM_FRAMEWORK_CONNECTION_KEY);
+ return loadConfiguration((JobConf) configuration, MR_JOB_CONFIG_CLASS_FROM_CONNECTOR_JOB, MR_JOB_CONFIG_FROM_JOB_CONFIG_KEY);
case TO:
- return loadConfiguration((JobConf) configuration, JOB_CONFIG_CLASS_TO_FRAMEWORK_CONNECTION, JOB_CONFIG_TO_FRAMEWORK_CONNECTION_KEY);
+ return loadConfiguration((JobConf) configuration, MR_JOB_CONFIG_CLASS_TO_CONNECTOR_JOB, MR_JOB_CONFIG_TO_JOB_CONFIG_KEY);
}
return null;
@@ -243,8 +193,8 @@ public final class ConfigurationUtils {
* @param configuration MapReduce configuration object
* @return Configuration object
*/
- public static Object getFrameworkJobConfig(Configuration configuration) {
- return loadConfiguration((JobConf) configuration, JOB_CONFIG_CLASS_FRAMEWORK_JOB, JOB_CONFIG_FRAMEWORK_JOB_KEY);
+ public static Object getDriverConfig(Configuration configuration) {
+ return loadConfiguration((JobConf) configuration, MR_JOB_CONFIG_DRIVER_CONFIG_CLASS, MR_JOB_CONFIG_DRIVER_CONFIG_KEY);
}
@@ -303,7 +253,7 @@ public final class ConfigurationUtils {
String json = new String(configuration.getCredentials().getSecretKey(valueProperty));
// Fill it with JSON data
- FormUtils.fillValues(json, object);
+ ConfigUtils.fillValues(json, object);
// And give it back
return object;
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/SqoopDestroyerExecutor.java
----------------------------------------------------------------------
diff --git a/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/SqoopDestroyerExecutor.java b/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/SqoopDestroyerExecutor.java
index aecde40..8d2a1da 100644
--- a/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/SqoopDestroyerExecutor.java
+++ b/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/SqoopDestroyerExecutor.java
@@ -37,7 +37,7 @@ public class SqoopDestroyerExecutor {
/**
* Execute destroyer.
*
- * @param success True if the job execution was successfull
+ * @param success True if the job execution was successful
* @param configuration Configuration object to get destroyer class with context
* and configuration objects.
* @param direction The direction of the Destroyer to execute.
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/execution/mapreduce/src/test/java/org/apache/sqoop/job/JobUtils.java
----------------------------------------------------------------------
diff --git a/execution/mapreduce/src/test/java/org/apache/sqoop/job/JobUtils.java b/execution/mapreduce/src/test/java/org/apache/sqoop/job/JobUtils.java
index 1952cbb..0d14fc7 100644
--- a/execution/mapreduce/src/test/java/org/apache/sqoop/job/JobUtils.java
+++ b/execution/mapreduce/src/test/java/org/apache/sqoop/job/JobUtils.java
@@ -19,8 +19,6 @@ package org.apache.sqoop.job;
import java.io.IOException;
-import org.junit.Assert;
-
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.InputFormat;
@@ -33,6 +31,7 @@ import org.apache.sqoop.job.mr.SqoopInputFormat;
import org.apache.sqoop.job.mr.SqoopMapper;
import org.apache.sqoop.job.mr.SqoopNullOutputFormat;
import org.apache.sqoop.job.mr.SqoopSplit;
+import org.junit.Assert;
public class JobUtils {
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/execution/mapreduce/src/test/java/org/apache/sqoop/job/TestMapReduce.java
----------------------------------------------------------------------
diff --git a/execution/mapreduce/src/test/java/org/apache/sqoop/job/TestMapReduce.java b/execution/mapreduce/src/test/java/org/apache/sqoop/job/TestMapReduce.java
index 032cc11..e3b68e2 100644
--- a/execution/mapreduce/src/test/java/org/apache/sqoop/job/TestMapReduce.java
+++ b/execution/mapreduce/src/test/java/org/apache/sqoop/job/TestMapReduce.java
@@ -253,7 +253,6 @@ public class TestMapReduce {
public static class DummyLoader extends Loader {
private int index = START_PARTITION*NUMBER_OF_ROWS_PER_PARTITION;
private Data expected = new Data();
- private CSVIntermediateDataFormat actual = new CSVIntermediateDataFormat();
@Override
public void load(LoaderContext context, Object oc, Object oj) throws Exception{
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/execution/mapreduce/src/test/java/org/apache/sqoop/job/mr/TestConfigurationUtils.java
----------------------------------------------------------------------
diff --git a/execution/mapreduce/src/test/java/org/apache/sqoop/job/mr/TestConfigurationUtils.java b/execution/mapreduce/src/test/java/org/apache/sqoop/job/mr/TestConfigurationUtils.java
index 1447e00..501e32c 100644
--- a/execution/mapreduce/src/test/java/org/apache/sqoop/job/mr/TestConfigurationUtils.java
+++ b/execution/mapreduce/src/test/java/org/apache/sqoop/job/mr/TestConfigurationUtils.java
@@ -17,130 +17,118 @@
*/
package org.apache.sqoop.job.mr;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapreduce.Job;
import org.apache.sqoop.common.Direction;
import org.apache.sqoop.model.ConfigurationClass;
-import org.apache.sqoop.model.Form;
-import org.apache.sqoop.model.FormClass;
+import org.apache.sqoop.model.Config;
+import org.apache.sqoop.model.ConfigClass;
import org.apache.sqoop.model.Input;
-import org.apache.sqoop.model.MJob;
import org.apache.sqoop.schema.Schema;
import org.apache.sqoop.schema.type.Text;
import org.junit.Before;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
/**
- * Current tests are using mockito to propagate credentials from Job object
- * to JobConf object. This implementation was chosen because it's not clear
+ * Current tests are using mockito to propagate credentials from hadoop Job object
+ * to hadoop JobConf object. This implementation was chosen because it's not clear
* how MapReduce is converting one object to another.
*/
public class TestConfigurationUtils {
Job job;
- JobConf jobConf;
+ JobConf jobConfSpy;
@Before
public void setUp() throws Exception {
- setUpJob();
- setUpJobConf();
+ setUpHadoopJob();
+ setUpHadoopJobConf();
}
- public void setUpJob() throws Exception {
+ public void setUpHadoopJob() throws Exception {
job = new Job();
}
- public void setUpJobConf() throws Exception {
- jobConf = spy(new JobConf(job.getConfiguration()));
- when(jobConf.getCredentials()).thenReturn(job.getCredentials());
+ public void setUpHadoopJobConf() throws Exception {
+ jobConfSpy = spy(new JobConf(job.getConfiguration()));
+ when(jobConfSpy.getCredentials()).thenReturn(job.getCredentials());
}
@Test
- public void testConfigConnectorConnection() throws Exception {
- ConfigurationUtils.setConnectorConnectionConfig(Direction.FROM, job, getConfig());
- setUpJobConf();
- assertEquals(getConfig(), ConfigurationUtils.getConnectorConnectionConfig(Direction.FROM, jobConf));
-
- ConfigurationUtils.setConnectorConnectionConfig(Direction.TO, job, getConfig());
- setUpJobConf();
- assertEquals(getConfig(), ConfigurationUtils.getConnectorConnectionConfig(Direction.TO, jobConf));
+ public void testLinkConfiguration() throws Exception {
+ ConfigurationUtils.setConnectorLinkConfig(Direction.FROM, job, getConfig());
+ setUpHadoopJobConf();
+ assertEquals(getConfig(), ConfigurationUtils.getConnectorConnectionConfig(Direction.FROM, jobConfSpy));
+
+ ConfigurationUtils.setConnectorLinkConfig(Direction.TO, job, getConfig());
+ setUpHadoopJobConf();
+ assertEquals(getConfig(), ConfigurationUtils.getConnectorConnectionConfig(Direction.TO, jobConfSpy));
}
@Test
- public void testConfigConnectorJob() throws Exception {
+ public void testJobConfiguration() throws Exception {
ConfigurationUtils.setConnectorJobConfig(Direction.FROM, job, getConfig());
- setUpJobConf();
- assertEquals(getConfig(), ConfigurationUtils.getConnectorJobConfig(Direction.FROM, jobConf));
+ setUpHadoopJobConf();
+ assertEquals(getConfig(), ConfigurationUtils.getConnectorJobConfig(Direction.FROM, jobConfSpy));
ConfigurationUtils.setConnectorJobConfig(Direction.TO, job, getConfig());
- setUpJobConf();
- assertEquals(getConfig(), ConfigurationUtils.getConnectorJobConfig(Direction.TO, jobConf));
- }
-
- @Test
- public void testConfigFrameworkConnection() throws Exception {
- ConfigurationUtils.setFrameworkConnectionConfig(Direction.FROM, job, getConfig());
- setUpJobConf();
- assertEquals(getConfig(), ConfigurationUtils.getFrameworkConnectionConfig(Direction.FROM, jobConf));
-
- ConfigurationUtils.setFrameworkConnectionConfig(Direction.TO, job, getConfig());
- setUpJobConf();
- assertEquals(getConfig(), ConfigurationUtils.getFrameworkConnectionConfig(Direction.TO, jobConf));
+ setUpHadoopJobConf();
+ assertEquals(getConfig(), ConfigurationUtils.getConnectorJobConfig(Direction.TO, jobConfSpy));
}
@Test
- public void testConfigFrameworkJob() throws Exception {
- ConfigurationUtils.setFrameworkJobConfig(job, getConfig());
- setUpJobConf();
- assertEquals(getConfig(), ConfigurationUtils.getFrameworkJobConfig(jobConf));
+ public void testDriverConfiguration() throws Exception {
+ ConfigurationUtils.setDriverConfig(job, getConfig());
+ setUpHadoopJobConf();
+ assertEquals(getConfig(), ConfigurationUtils.getDriverConfig(jobConfSpy));
}
@Test
public void testConnectorSchema() throws Exception {
ConfigurationUtils.setConnectorSchema(Direction.FROM, job, getSchema("a"));
- assertEquals(getSchema("a"), ConfigurationUtils.getConnectorSchema(Direction.FROM, jobConf));
+ assertEquals(getSchema("a"), ConfigurationUtils.getConnectorSchema(Direction.FROM, jobConfSpy));
ConfigurationUtils.setConnectorSchema(Direction.TO, job, getSchema("b"));
- assertEquals(getSchema("b"), ConfigurationUtils.getConnectorSchema(Direction.TO, jobConf));
+ assertEquals(getSchema("b"), ConfigurationUtils.getConnectorSchema(Direction.TO, jobConfSpy));
}
@Test
public void testConnectorSchemaNull() throws Exception {
ConfigurationUtils.setConnectorSchema(Direction.FROM, job, null);
- assertNull(ConfigurationUtils.getConnectorSchema(Direction.FROM, jobConf));
+ assertNull(ConfigurationUtils.getConnectorSchema(Direction.FROM, jobConfSpy));
ConfigurationUtils.setConnectorSchema(Direction.TO, job, null);
- assertNull(ConfigurationUtils.getConnectorSchema(Direction.FROM, jobConf));
+ assertNull(ConfigurationUtils.getConnectorSchema(Direction.FROM, jobConfSpy));
}
private Schema getSchema(String name) {
return new Schema(name).addColumn(new Text("c1"));
}
- private Config getConfig() {
- Config c = new Config();
- c.f.A = "This is secret text!";
+ private TestConfiguration getConfig() {
+ TestConfiguration c = new TestConfiguration();
+ c.c.A = "This is secret text!";
return c;
}
- @FormClass
- public static class F {
+ @ConfigClass
+ public static class C {
@Input String A;
@Override
public boolean equals(Object o) {
if (this == o) return true;
- if (!(o instanceof F)) return false;
+ if (!(o instanceof C)) return false;
- F f = (F) o;
+ C c = (C) o;
- if (A != null ? !A.equals(f.A) : f.A != null) return false;
+ if (A != null ? !A.equals(c.A) : c.A != null) return false;
return true;
}
@@ -152,21 +140,21 @@ public class TestConfigurationUtils {
}
@ConfigurationClass
- public static class Config {
- @Form F f;
+ public static class TestConfiguration {
+ @Config C c;
- public Config() {
- f = new F();
+ public TestConfiguration() {
+ c = new C();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
- if (!(o instanceof Config)) return false;
+ if (!(o instanceof TestConfiguration)) return false;
- Config config = (Config) o;
+ TestConfiguration config = (TestConfiguration) o;
- if (f != null ? !f.equals(config.f) : config.f != null)
+ if (c != null ? !c.equals(config.c) : config.c != null)
return false;
return true;
@@ -174,7 +162,7 @@ public class TestConfigurationUtils {
@Override
public int hashCode() {
- return f != null ? f.hashCode() : 0;
+ return c != null ? c.hashCode() : 0;
}
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoError.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoError.java b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoError.java
index 61dc3b4..cc31d06 100644
--- a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoError.java
+++ b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoError.java
@@ -1,7 +1,7 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional inconfigation
+ * 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
[09/13] SQOOP-1498: Sqoop2: Repository Object refactoring (objects
prefixed with M)
Posted by ab...@apache.org.
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/model/TestMJob.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMJob.java b/common/src/test/java/org/apache/sqoop/model/TestMJob.java
index 8f2943e..848c2cc 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMJob.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMJob.java
@@ -17,17 +17,15 @@
*/
package org.apache.sqoop.model;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
import java.util.ArrayList;
import java.util.List;
import org.apache.sqoop.common.Direction;
import org.junit.Test;
-import static org.junit.Assert.*;
-
-/**
- * Test class for org.apache.sqoop.model.MJob
- */
public class TestMJob {
/**
* Test class for initialization
@@ -40,9 +38,9 @@ public class TestMJob {
assertEquals(456l, job.getConnectorId(Direction.TO));
assertEquals("Buffy", job.getCreationUser());
assertEquals("Vampire", job.getName());
- assertEquals(fromForms(), job.getConnectorPart(Direction.FROM));
- assertEquals(toForms(), job.getConnectorPart(Direction.TO));
- assertEquals(frameworkForms(), job.getFrameworkPart());
+ assertEquals(fromConfig(), job.getJobConfig(Direction.FROM));
+ assertEquals(toConfig(), job.getJobConfig(Direction.TO));
+ assertEquals(driverConfig(), job.getDriverConfig());
// Test copy constructor
MJob copy = new MJob(job);
@@ -50,19 +48,19 @@ public class TestMJob {
assertEquals(456l, copy.getConnectorId(Direction.TO));
assertEquals("Buffy", copy.getCreationUser());
assertEquals("Vampire", copy.getName());
- assertEquals(fromForms(), copy.getConnectorPart(Direction.FROM));
- assertEquals(toForms(), copy.getConnectorPart(Direction.TO));
- assertEquals(frameworkForms(), copy.getFrameworkPart());
+ assertEquals(fromConfig(), copy.getJobConfig(Direction.FROM));
+ assertEquals(toConfig(), copy.getJobConfig(Direction.TO));
+ assertEquals(driverConfig(), copy.getDriverConfig());
- // Test constructor for metadata upgrade (the order of forms is different)
- MJob upgradeCopy = new MJob(job, fromForms(), toForms(), frameworkForms());
+ // Test constructor for metadata upgrade (the order of configs is different)
+ MJob upgradeCopy = new MJob(job, fromConfig(), toConfig(), driverConfig());
assertEquals(123l, upgradeCopy.getConnectorId(Direction.FROM));
assertEquals(456l, upgradeCopy.getConnectorId(Direction.TO));
assertEquals("Buffy", upgradeCopy.getCreationUser());
assertEquals("Vampire", upgradeCopy.getName());
- assertEquals(fromForms(), upgradeCopy.getConnectorPart(Direction.FROM));
- assertEquals(toForms(), upgradeCopy.getConnectorPart(Direction.TO));
- assertEquals(frameworkForms(), upgradeCopy.getFrameworkPart());
+ assertEquals(fromConfig(), upgradeCopy.getJobConfig(Direction.FROM));
+ assertEquals(toConfig(), upgradeCopy.getJobConfig(Direction.TO));
+ assertEquals(driverConfig(), upgradeCopy.getDriverConfig());
}
@Test
@@ -70,42 +68,42 @@ public class TestMJob {
MJob job = job();
// Clone without value
- MJob withoutValue = job.clone(false);
- assertEquals(job, withoutValue);
- assertEquals(MPersistableEntity.PERSISTANCE_ID_DEFAULT, withoutValue.getPersistenceId());
- assertNull(withoutValue.getName());
- assertNull(withoutValue.getCreationUser());
- assertEquals(fromForms(), withoutValue.getConnectorPart(Direction.FROM));
- assertEquals(toForms(), withoutValue.getConnectorPart(Direction.TO));
- assertEquals(frameworkForms(), withoutValue.getFrameworkPart());
- assertNull(withoutValue.getConnectorPart(Direction.FROM)
- .getForm("FORMNAME").getInput("INTEGER-INPUT").getValue());
- assertNull(withoutValue.getConnectorPart(Direction.FROM)
- .getForm("FORMNAME").getInput("STRING-INPUT").getValue());
+ MJob withoutJobValue = job.clone(false);
+ assertEquals(job, withoutJobValue);
+ assertEquals(MPersistableEntity.PERSISTANCE_ID_DEFAULT, withoutJobValue.getPersistenceId());
+ assertNull(withoutJobValue.getName());
+ assertNull(withoutJobValue.getCreationUser());
+ assertEquals(fromConfig(), withoutJobValue.getJobConfig(Direction.FROM));
+ assertEquals(toConfig(), withoutJobValue.getJobConfig(Direction.TO));
+ assertEquals(driverConfig(), withoutJobValue.getDriverConfig());
+ assertNull(withoutJobValue.getJobConfig(Direction.FROM)
+ .getConfig("CONFIGFROMNAME").getInput("INTEGER-INPUT").getValue());
+ assertNull(withoutJobValue.getJobConfig(Direction.FROM)
+ .getConfig("CONFIGFROMNAME").getInput("STRING-INPUT").getValue());
// Clone with value
- MJob withValue = job.clone(true);
- assertEquals(job, withValue);
- assertEquals(job.getPersistenceId(), withValue.getPersistenceId());
- assertEquals(job.getName(), withValue.getName());
- assertEquals(job.getCreationUser(), withValue.getCreationUser());
- assertEquals(fromForms(), withValue.getConnectorPart(Direction.FROM));
- assertEquals(toForms(), withValue.getConnectorPart(Direction.TO));
- assertEquals(frameworkForms(), withValue.getFrameworkPart());
- assertEquals(100, withValue.getConnectorPart(Direction.FROM)
- .getForm("FORMNAME").getInput("INTEGER-INPUT").getValue());
- assertEquals("TEST-VALUE", withValue.getConnectorPart(Direction.FROM)
- .getForm("FORMNAME").getInput("STRING-INPUT").getValue()); }
+ MJob withJobValue = job.clone(true);
+ assertEquals(job, withJobValue);
+ assertEquals(job.getPersistenceId(), withJobValue.getPersistenceId());
+ assertEquals(job.getName(), withJobValue.getName());
+ assertEquals(job.getCreationUser(), withJobValue.getCreationUser());
+ assertEquals(fromConfig(), withJobValue.getJobConfig(Direction.FROM));
+ assertEquals(toConfig(), withJobValue.getJobConfig(Direction.TO));
+ assertEquals(driverConfig(), withJobValue.getDriverConfig());
+ assertEquals(100, withJobValue.getJobConfig(Direction.FROM)
+ .getConfig("CONFIGFROMNAME").getInput("INTEGER-INPUT").getValue());
+ assertEquals("TEST-VALUE", withJobValue.getJobConfig(Direction.FROM)
+ .getConfig("CONFIGFROMNAME").getInput("STRING-INPUT").getValue()); }
private MJob job() {
- MJob job = new MJob(123l, 456l, 1L, 2L, fromForms(), toForms(), frameworkForms());
+ MJob job = new MJob(123l, 456l, 1L, 2L, fromConfig(), toConfig(), driverConfig());
job.setName("Vampire");
job.setCreationUser("Buffy");
return job;
}
- private MJobForms fromForms() {
- List<MForm> forms = new ArrayList<MForm>();
+ private MFromConfig fromConfig() {
+ List<MConfig> configs = new ArrayList<MConfig>();
MIntegerInput input = new MIntegerInput("INTEGER-INPUT", false);
input.setValue(100);
MStringInput strInput = new MStringInput("STRING-INPUT",false,(short)20);
@@ -113,28 +111,28 @@ public class TestMJob {
List<MInput<?>> list = new ArrayList<MInput<?>>();
list.add(input);
list.add(strInput);
- MForm form = new MForm("FORMNAME", list);
- forms.add(form);
- return new MJobForms(forms);
+ MConfig config = new MConfig("CONFIGFROMNAME", list);
+ configs.add(config);
+ return new MFromConfig(configs);
}
- private MJobForms toForms() {
- List<MForm> forms = new ArrayList<MForm>();
+ private MToConfig toConfig() {
+ List<MConfig> configs = new ArrayList<MConfig>();
MMapInput input = new MMapInput("MAP-INPUT", false);
List<MInput<?>> list = new ArrayList<MInput<?>>();
list.add(input);
- MForm form = new MForm("form", list);
- forms.add(form);
- return new MJobForms(forms);
+ MConfig config = new MConfig("CONFIGTONAME", list);
+ configs.add(config);
+ return new MToConfig(configs);
}
- private MJobForms frameworkForms() {
- List<MForm> forms = new ArrayList<MForm>();
+ private MDriverConfig driverConfig() {
+ List<MConfig> configs = new ArrayList<MConfig>();
MMapInput input = new MMapInput("MAP-INPUT", false);
List<MInput<?>> list = new ArrayList<MInput<?>>();
list.add(input);
- MForm form = new MForm("form", list);
- forms.add(form);
- return new MJobForms(forms);
+ MConfig config = new MConfig("CONFIGDRIVERNAME", list);
+ configs.add(config);
+ return new MDriverConfig(configs);
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/model/TestMJobConfig.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMJobConfig.java b/common/src/test/java/org/apache/sqoop/model/TestMJobConfig.java
new file mode 100644
index 0000000..7d0641e
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/model/TestMJobConfig.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class TestMJobConfig {
+ /**
+ * Test for class initialization and values
+ */
+ @Test
+ public void testInitialization() {
+ List<MConfig> configs = new ArrayList<MConfig>();
+ MFromConfig fromJobConfig = new MFromConfig(configs);
+ List<MConfig> configs2 = new ArrayList<MConfig>();
+ MFromConfig fromJobConfig2 = new MFromConfig(configs2);
+ assertEquals(fromJobConfig2, fromJobConfig);
+ MConfig c = new MConfig("test", null);
+ configs2.add(c);
+ assertFalse(fromJobConfig.equals(fromJobConfig2));
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/model/TestMJobForms.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMJobForms.java b/common/src/test/java/org/apache/sqoop/model/TestMJobForms.java
deleted file mode 100644
index e59b282..0000000
--- a/common/src/test/java/org/apache/sqoop/model/TestMJobForms.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Test class for org.apache.sqoop.model.MJobForms
- */
-public class TestMJobForms {
- /**
- * Test for class initialization and values
- */
- @Test
- public void testInitialization() {
- List<MForm> forms = new ArrayList<MForm>();
- MJobForms jobform1 = new MJobForms(forms);
- List<MForm> forms2 = new ArrayList<MForm>();
- MJobForms jobform2 = new MJobForms(forms2);
- assertEquals(jobform2, jobform1);
- // Add a form to list for checking not equals
- MForm m = new MForm("test", null);
- forms2.add(m);
- assertFalse(jobform1.equals(jobform2));
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/model/TestMLink.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMLink.java b/common/src/test/java/org/apache/sqoop/model/TestMLink.java
index 77fa2a9..9ad8954 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMLink.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMLink.java
@@ -24,9 +24,6 @@ import org.junit.Test;
import static org.junit.Assert.*;
-/**
- * Test class for org.apache.sqoop.model.MConnection
- */
public class TestMLink {
/**
@@ -39,8 +36,7 @@ public class TestMLink {
assertEquals(123l, link.getConnectorId());
assertEquals("Vampire", link.getName());
assertEquals("Buffy", link.getCreationUser());
- assertEquals(forms1(), link.getConnectorPart());
- assertEquals(forms2(), link.getFrameworkPart());
+ assertEquals(linkConfig(), link.getConnectorLinkConfig());
// Test copy constructor
MLink copy = new MLink(link);
@@ -48,17 +44,7 @@ public class TestMLink {
assertEquals("Vampire", copy.getName());
assertEquals("Buffy", copy.getCreationUser());
assertEquals(link.getCreationDate(), copy.getCreationDate());
- assertEquals(forms1(), copy.getConnectorPart());
- assertEquals(forms2(), copy.getFrameworkPart());
-
- // Test constructor for metadata upgrade (the order of forms is different)
- MLink upgradeCopy = new MLink(link, forms2(), forms1());
- assertEquals(123l, upgradeCopy.getConnectorId());
- assertEquals("Vampire", upgradeCopy.getName());
- assertEquals("Buffy", upgradeCopy.getCreationUser());
- assertEquals(link.getCreationDate(), upgradeCopy.getCreationDate());
- assertEquals(forms2(), upgradeCopy.getConnectorPart());
- assertEquals(forms1(), upgradeCopy.getFrameworkPart());
+ assertEquals(linkConfig(), copy.getConnectorLinkConfig());
}
@Test
@@ -66,37 +52,35 @@ public class TestMLink {
MLink link = link();
// Clone without value
- MLink withoutValue = link.clone(false);
- assertEquals(link, withoutValue);
- assertEquals(MPersistableEntity.PERSISTANCE_ID_DEFAULT, withoutValue.getPersistenceId());
- assertNull(withoutValue.getName());
- assertNull(withoutValue.getCreationUser());
- assertEquals(forms1(), withoutValue.getConnectorPart());
- assertEquals(forms2(), withoutValue.getFrameworkPart());
- assertNull(withoutValue.getConnectorPart().getForm("FORMNAME").getInput("INTEGER-INPUT").getValue());
- assertNull(withoutValue.getConnectorPart().getForm("FORMNAME").getInput("STRING-INPUT").getValue());
+ MLink withoutLinkValue = link.clone(false);
+ assertEquals(link, withoutLinkValue);
+ assertEquals(MPersistableEntity.PERSISTANCE_ID_DEFAULT, withoutLinkValue.getPersistenceId());
+ assertNull(withoutLinkValue.getName());
+ assertNull(withoutLinkValue.getCreationUser());
+ assertEquals(linkConfig(), withoutLinkValue.getConnectorLinkConfig());
+ assertNull(withoutLinkValue.getConnectorLinkConfig().getConfig("CONFIGNAME").getInput("INTEGER-INPUT").getValue());
+ assertNull(withoutLinkValue.getConnectorLinkConfig().getConfig("CONFIGNAME").getInput("STRING-INPUT").getValue());
// Clone with value
- MLink withValue = link.clone(true);
- assertEquals(link, withValue);
- assertEquals(link.getPersistenceId(), withValue.getPersistenceId());
- assertEquals(link.getName(), withValue.getName());
- assertEquals(link.getCreationUser(), withValue.getCreationUser());
- assertEquals(forms1(), withValue.getConnectorPart());
- assertEquals(forms2(), withValue.getFrameworkPart());
- assertEquals(100, withValue.getConnectorPart().getForm("FORMNAME").getInput("INTEGER-INPUT").getValue());
- assertEquals("TEST-VALUE", withValue.getConnectorPart().getForm("FORMNAME").getInput("STRING-INPUT").getValue());
+ MLink withLinkValue = link.clone(true);
+ assertEquals(link, withLinkValue);
+ assertEquals(link.getPersistenceId(), withLinkValue.getPersistenceId());
+ assertEquals(link.getName(), withLinkValue.getName());
+ assertEquals(link.getCreationUser(), withLinkValue.getCreationUser());
+ assertEquals(linkConfig(), withLinkValue.getConnectorLinkConfig());
+ assertEquals(100, withLinkValue.getConnectorLinkConfig().getConfig("CONFIGNAME").getInput("INTEGER-INPUT").getValue());
+ assertEquals("TEST-VALUE", withLinkValue.getConnectorLinkConfig().getConfig("CONFIGNAME").getInput("STRING-INPUT").getValue());
}
private MLink link() {
- MLink link = new MLink(123l, forms1(), forms2());
+ MLink link = new MLink(123l, linkConfig());
link.setName("Vampire");
link.setCreationUser("Buffy");
return link;
}
- private MConnectionForms forms1() {
- List<MForm> forms = new ArrayList<MForm>();
+ private MLinkConfig linkConfig() {
+ List<MConfig> configs = new ArrayList<MConfig>();
MIntegerInput input = new MIntegerInput("INTEGER-INPUT", false);
input.setValue(100);
MStringInput strInput = new MStringInput("STRING-INPUT",false,(short)20);
@@ -104,19 +88,9 @@ public class TestMLink {
List<MInput<?>> list = new ArrayList<MInput<?>>();
list.add(input);
list.add(strInput);
- MForm form = new MForm("FORMNAME", list);
- forms.add(form);
- return new MConnectionForms(forms);
- }
-
- private MConnectionForms forms2() {
- List<MForm> forms = new ArrayList<MForm>();
- MMapInput input = new MMapInput("MAP-INPUT", false);
- List<MInput<?>> list = new ArrayList<MInput<?>>();
- list.add(input);
- MForm form = new MForm("form", list);
- forms.add(form);
- return new MConnectionForms(forms);
+ MConfig config = new MConfig("CONFIGNAME", list);
+ configs.add(config);
+ return new MLinkConfig(configs);
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/model/TestMLinkConfig.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMLinkConfig.java b/common/src/test/java/org/apache/sqoop/model/TestMLinkConfig.java
new file mode 100644
index 0000000..62f61a6
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/model/TestMLinkConfig.java
@@ -0,0 +1,45 @@
+/**
+ * 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.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class TestMLinkConfig {
+
+ /**
+ * Test for class initialization and values
+ */
+ @Test
+ public void testInitialization() {
+ List<MConfig> configs = new ArrayList<MConfig>();
+ MLinkConfig linkConfig = new MLinkConfig(configs);
+ List<MConfig> testConfig = new ArrayList<MConfig>();
+ assertEquals(testConfig, linkConfig.getConfigs());
+ MLinkConfig linkConfig2 = new MLinkConfig(testConfig);
+ assertEquals(linkConfig2, linkConfig);
+ // Add a config to list for checking not equals
+ MConfig c = new MConfig("test", null);
+ testConfig.add(c);
+ assertFalse(linkConfig.equals(linkConfig2));
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/validation/TestValidation.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/validation/TestValidation.java b/common/src/test/java/org/apache/sqoop/validation/TestValidation.java
index 85e9e1c..16a8bbe 100644
--- a/common/src/test/java/org/apache/sqoop/validation/TestValidation.java
+++ b/common/src/test/java/org/apache/sqoop/validation/TestValidation.java
@@ -17,16 +17,20 @@
*/
package org.apache.sqoop.validation;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.HashMap;
import java.util.Map;
import org.apache.sqoop.common.SqoopException;
-import org.apache.sqoop.validation.Validation.FormInput;
-import org.apache.sqoop.validation.Validation.Message;
+import org.apache.sqoop.validation.ConfigValidator.ConfigInput;
+import org.apache.sqoop.validation.ConfigValidator.Message;
import org.junit.Test;
-import static org.junit.Assert.*;
-
/**
* Test class for org.apache.sqoop.validation.Validation
*/
@@ -38,42 +42,42 @@ public class TestValidation {
@Test
public void testInitialization() {
/* Check initialization with class */
- Validation validation = new Validation(Class.class);
+ ConfigValidator validation = new ConfigValidator(Class.class);
assertNotNull(validation);
assertEquals(Status.FINE, validation.getStatus());
assertEquals(0, validation.getMessages().size());
/* Check initialization with status and message as null */
- Validation validationNull = new Validation(null, null);
+ ConfigValidator validationNull = new ConfigValidator(null, null);
assertNotNull(validationNull);
assertNull(validationNull.getStatus());
assertNull(validationNull.getMessages());
/* Check initialization with status and message with values */
Status s1 = Status.FINE;
- Map<FormInput, Message> msg1 = new HashMap<Validation.FormInput, Validation.Message>();
- Validation validation1 = new Validation(s1, msg1);
+ Map<ConfigInput, Message> msg1 = new HashMap<ConfigValidator.ConfigInput, ConfigValidator.Message>();
+ ConfigValidator validation1 = new ConfigValidator(s1, msg1);
assertNotNull(validation1);
assertEquals(Status.FINE, validation1.getStatus());
assertEquals(0, validation1.getMessages().size());
/* Check initialization with status and message with values */
Status s2 = Status.ACCEPTABLE;
- Map<FormInput, Message> msg2 = new HashMap<Validation.FormInput, Validation.Message>();
- Validation validation2 = new Validation(s2, msg2);
+ Map<ConfigInput, Message> msg2 = new HashMap<ConfigValidator.ConfigInput, ConfigValidator.Message>();
+ ConfigValidator validation2 = new ConfigValidator(s2, msg2);
assertNotNull(validation2);
assertEquals(Status.ACCEPTABLE, validation2.getStatus());
assertEquals(0, validation2.getMessages().size());
/* Check initialization with status and message with values */
Status s3 = Status.ACCEPTABLE;
- Map<FormInput, Message> msg3 = new HashMap<Validation.FormInput, Validation.Message>();
- Validation.FormInput fi = new Validation.FormInput("form\\.input");
- Validation.Message message = new Validation.Message(Status.FINE, "sqoop");
+ Map<ConfigInput, Message> msg3 = new HashMap<ConfigValidator.ConfigInput, ConfigValidator.Message>();
+ ConfigValidator.ConfigInput fi = new ConfigValidator.ConfigInput("config\\.input");
+ ConfigValidator.Message message = new ConfigValidator.Message(Status.FINE, "sqoop");
msg3.put(fi, message);
- Validation validation3 = new Validation(s3, msg3);
- Validation.FormInput fiTest = new Validation.FormInput("form\\.input");
- Validation.Message messageTest = new Validation.Message(Status.FINE,
+ ConfigValidator validation3 = new ConfigValidator(s3, msg3);
+ ConfigValidator.ConfigInput fiTest = new ConfigValidator.ConfigInput("config\\.input");
+ ConfigValidator.Message messageTest = new ConfigValidator.Message(Status.FINE,
"sqoop");
assertEquals(messageTest, validation3.getMessages().get(fiTest));
assertEquals(Status.ACCEPTABLE, validation3.getStatus());
@@ -82,13 +86,13 @@ public class TestValidation {
/**
* Test for Validation.ForInput
*/
- public void testFormInput() {
- Validation.FormInput fi = new Validation.FormInput("test\\.test");
+ public void testConfigInput() {
+ ConfigValidator.ConfigInput fi = new ConfigValidator.ConfigInput("test\\.test");
assertNotNull(fi);
/* Passing null */
try {
- new Validation.FormInput(null);
+ new ConfigValidator.ConfigInput(null);
fail("Assert error is expected");
} catch (AssertionError e) {
assertTrue(true);
@@ -96,31 +100,31 @@ public class TestValidation {
/* Passing empty and check exception messages */
try {
- new Validation.FormInput("");
+ new ConfigValidator.ConfigInput("");
fail("SqoopException is expected");
} catch (SqoopException e) {
- assertEquals(ValidationError.VALIDATION_0003.getMessage(), e
+ assertEquals(ConfigValidationError.VALIDATION_0003.getMessage(), e
.getErrorCode().getMessage());
}
/* Passing value and check */
- Validation.FormInput fi2 = new Validation.FormInput("form\\.input");
- assertEquals("form\\", fi2.getForm());
+ ConfigValidator.ConfigInput fi2 = new ConfigValidator.ConfigInput("config\\.input");
+ assertEquals("config\\", fi2.getConfig());
assertEquals("input", fi2.getInput());
/* Check equals */
- Validation.FormInput fiOne = new Validation.FormInput("form\\.input");
- Validation.FormInput fiTwo = new Validation.FormInput("form\\.input");
+ ConfigValidator.ConfigInput fiOne = new ConfigValidator.ConfigInput("config\\.input");
+ ConfigValidator.ConfigInput fiTwo = new ConfigValidator.ConfigInput("config\\.input");
assertEquals(fiOne, fiTwo);
/* toString() method check */
- assertEquals("form\\.input", fiOne.toString());
+ assertEquals("config\\.input", fiOne.toString());
- // Checking null as input field (form validation)
- Validation.FormInput fi3 = new FormInput("form");
- assertEquals("form", fi3.getForm());
+ // Checking null as input field (config validation)
+ ConfigValidator.ConfigInput fi3 = new ConfigInput("config");
+ assertEquals("config", fi3.getConfig());
assertNull(fi3.getInput());
- assertEquals("form", fi3.toString());
+ assertEquals("config", fi3.toString());
}
@@ -129,17 +133,17 @@ public class TestValidation {
*/
public void testMessage() {
/* Passing null */
- Validation.Message msg1 = new Validation.Message(null, null);
+ ConfigValidator.Message msg1 = new ConfigValidator.Message(null, null);
assertNull(msg1.getStatus());
assertNull(msg1.getMessage());
/* Passing values */
- Validation.Message msg2 = new Validation.Message(Status.FINE, "sqoop");
+ ConfigValidator.Message msg2 = new ConfigValidator.Message(Status.FINE, "sqoop");
assertEquals(Status.FINE, msg2.getStatus());
assertEquals("sqoop", msg2.getMessage());
/* Check for equal */
- Validation.Message msg3 = new Validation.Message(Status.FINE, "sqoop");
+ ConfigValidator.Message msg3 = new ConfigValidator.Message(Status.FINE, "sqoop");
assertEquals(msg2, msg3);
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/validation/TestValidationRunner.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/validation/TestValidationRunner.java b/common/src/test/java/org/apache/sqoop/validation/TestValidationRunner.java
index 647abe0..579d1c5 100644
--- a/common/src/test/java/org/apache/sqoop/validation/TestValidationRunner.java
+++ b/common/src/test/java/org/apache/sqoop/validation/TestValidationRunner.java
@@ -18,8 +18,8 @@
package org.apache.sqoop.validation;
import org.apache.sqoop.model.ConfigurationClass;
-import org.apache.sqoop.model.Form;
-import org.apache.sqoop.model.FormClass;
+import org.apache.sqoop.model.Config;
+import org.apache.sqoop.model.ConfigClass;
import org.apache.sqoop.model.Input;
import org.apache.sqoop.model.Validator;
import org.apache.sqoop.validation.validators.Contains;
@@ -35,18 +35,18 @@ import static org.junit.Assert.assertTrue;
*/
public class TestValidationRunner {
- @FormClass(validators = {@Validator(FormA.FormValidator.class)})
- public static class FormA {
+ @ConfigClass(validators = {@Validator(ConfigA.ConfigValidator.class)})
+ public static class ConfigA {
@Input(validators = {@Validator(NotNull.class)})
String notNull;
- public static class FormValidator extends AbstractValidator<FormA> {
+ public static class ConfigValidator extends AbstractValidator<ConfigA> {
@Override
- public void validate(FormA form) {
- if(form.notNull == null) {
+ public void validate(ConfigA config) {
+ if(config.notNull == null) {
addMessage(Status.UNACCEPTABLE, "null");
}
- if("error".equals(form.notNull)) {
+ if("error".equals(config.notNull)) {
addMessage(Status.UNACCEPTABLE, "error");
}
}
@@ -54,83 +54,83 @@ public class TestValidationRunner {
}
@Test
- public void testValidateForm() {
- FormA form = new FormA();
- ValidationRunner runner = new ValidationRunner();
- ValidationResult result;
-
- // Null string should fail on Input level and should not call form level validators
- form.notNull = null;
- result = runner.validateForm("formName", form);
+ public void testValidateConfig() {
+ ConfigA config = new ConfigA();
+ ConfigValidationRunner runner = new ConfigValidationRunner();
+ ConfigValidationResult result;
+
+ // Null string should fail on Input level and should not call config level validators
+ config.notNull = null;
+ result = runner.validateConfig("configName", config);
assertEquals(Status.UNACCEPTABLE, result.getStatus());
assertEquals(1, result.getMessages().size());
- assertTrue(result.getMessages().containsKey("formName.notNull"));
+ assertTrue(result.getMessages().containsKey("configName.notNull"));
- // String "error" should trigger form level error, but not Input level
- form.notNull = "error";
- result = runner.validateForm("formName", form);
+ // String "error" should trigger config level error, but not Input level
+ config.notNull = "error";
+ result = runner.validateConfig("configName", config);
assertEquals(Status.UNACCEPTABLE, result.getStatus());
assertEquals(1, result.getMessages().size());
- assertTrue(result.getMessages().containsKey("formName"));
+ assertTrue(result.getMessages().containsKey("configName"));
// Acceptable state
- form.notNull = "This is truly random string";
- result = runner.validateForm("formName", form);
+ config.notNull = "This is truly random string";
+ result = runner.validateConfig("configName", config);
assertEquals(Status.FINE, result.getStatus());
assertEquals(0, result.getMessages().size());
}
- @FormClass
- public static class FormB {
+ @ConfigClass
+ public static class ConfigB {
@Input(validators = {@Validator(NotNull.class), @Validator(NotEmpty.class)})
String str;
}
- @FormClass
- public static class FormC {
+ @ConfigClass
+ public static class ConfigC {
@Input(validators = {@Validator(value = Contains.class, strArg = "findme")})
String str;
}
@Test
public void testMultipleValidatorsOnSingleInput() {
- FormB form = new FormB();
- ValidationRunner runner = new ValidationRunner();
- ValidationResult result;
+ ConfigB config = new ConfigB();
+ ConfigValidationRunner runner = new ConfigValidationRunner();
+ ConfigValidationResult result;
- form.str = null;
- result = runner.validateForm("formName", form);
+ config.str = null;
+ result = runner.validateConfig("configName", config);
assertEquals(Status.UNACCEPTABLE, result.getStatus());
assertEquals(1, result.getMessages().size());
- assertTrue(result.getMessages().containsKey("formName.str"));
- assertEquals(2, result.getMessages().get("formName.str").size());
+ assertTrue(result.getMessages().containsKey("configName.str"));
+ assertEquals(2, result.getMessages().get("configName.str").size());
}
@Test
public void testValidatorWithParameters() {
- FormC form = new FormC();
- ValidationRunner runner = new ValidationRunner();
- ValidationResult result;
+ ConfigC config = new ConfigC();
+ ConfigValidationRunner runner = new ConfigValidationRunner();
+ ConfigValidationResult result;
// Sub string not found
- form.str = "Mordor";
- result = runner.validateForm("formName", form);
+ config.str = "Mordor";
+ result = runner.validateConfig("configName", config);
assertEquals(Status.UNACCEPTABLE, result.getStatus());
assertEquals(1, result.getMessages().size());
- assertTrue(result.getMessages().containsKey("formName.str"));
+ assertTrue(result.getMessages().containsKey("configName.str"));
// Sub string found
- form.str = "Morfindmedor";
- result = runner.validateForm("formName", form);
+ config.str = "Morfindmedor";
+ result = runner.validateConfig("configName", config);
assertEquals(Status.FINE, result.getStatus());
assertEquals(0, result.getMessages().size());
}
@ConfigurationClass(validators = {@Validator(ConfigurationA.ClassValidator.class)})
public static class ConfigurationA {
- @Form FormA formA;
+ @Config ConfigA formA;
public ConfigurationA() {
- formA = new FormA();
+ formA = new ConfigA();
}
public static class ClassValidator extends AbstractValidator<ConfigurationA> {
@@ -149,24 +149,24 @@ public class TestValidationRunner {
@Test
public void testValidate() {
ConfigurationA conf = new ConfigurationA();
- ValidationRunner runner = new ValidationRunner();
- ValidationResult result;
+ ConfigValidationRunner runner = new ConfigValidationRunner();
+ ConfigValidationResult result;
- // Null string should fail on Input level and should not call form nor class level validators
+ // Null string should fail on Input level and should not call config nor class level validators
conf.formA.notNull = null;
result = runner.validate(conf);
assertEquals(Status.UNACCEPTABLE, result.getStatus());
assertEquals(1, result.getMessages().size());
assertTrue(result.getMessages().containsKey("formA.notNull"));
- // String "error" should trigger form level error, but not Input nor class level
+ // String "error" should trigger config level error, but not Input nor class level
conf.formA.notNull = "error";
result = runner.validate(conf);
assertEquals(Status.UNACCEPTABLE, result.getStatus());
assertEquals(1, result.getMessages().size());
assertTrue(result.getMessages().containsKey("formA"));
- // String "conf-error" should trigger class level error, but not Input nor Form level
+ // String "conf-error" should trigger class level error, but not Input nor Config level
conf.formA.notNull = "conf-error";
result = runner.validate(conf);
assertEquals(Status.UNACCEPTABLE, result.getStatus());
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/validation/validators/TestClassAvailable.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/validation/validators/TestClassAvailable.java b/common/src/test/java/org/apache/sqoop/validation/validators/TestClassAvailable.java
index 62b2e0a..3a15274 100644
--- a/common/src/test/java/org/apache/sqoop/validation/validators/TestClassAvailable.java
+++ b/common/src/test/java/org/apache/sqoop/validation/validators/TestClassAvailable.java
@@ -17,19 +17,17 @@
*/
package org.apache.sqoop.validation.validators;
-import org.apache.sqoop.validation.Message;
-import org.apache.sqoop.validation.Status;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
import java.util.List;
-import static org.junit.Assert.assertEquals;
+import org.apache.sqoop.validation.Message;
+import org.apache.sqoop.validation.Status;
+import org.junit.Test;
-/**
- */
public class TestClassAvailable {
- AbstractValidator validator = new ClassAvailable();
+ AbstractValidator<String> validator = new ClassAvailable();
@Test
public void test() {
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcConnector.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcConnector.java b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcConnector.java
index b4b6966..87ac2af 100644
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcConnector.java
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcConnector.java
@@ -92,7 +92,7 @@ public class GenericJdbcConnector extends SqoopConnector {
}
@Override
- public Validator getValidator() {
+ public Validator getConfigValidator() {
return genericJdbcValidator;
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcConnectorUpgrader.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcConnectorUpgrader.java b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcConnectorUpgrader.java
index 8deddb0..a069b3e 100644
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcConnectorUpgrader.java
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcConnectorUpgrader.java
@@ -18,21 +18,20 @@
*/
package org.apache.sqoop.connector.jdbc;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.apache.log4j.Logger;
import org.apache.sqoop.common.SqoopException;
import org.apache.sqoop.connector.spi.RepositoryUpgrader;
-import org.apache.sqoop.model.MConnectionForms;
-import org.apache.sqoop.model.MForm;
+import org.apache.sqoop.model.MConfigList;
+import org.apache.sqoop.model.MConfig;
import org.apache.sqoop.model.MInput;
-import org.apache.sqoop.model.MJobForms;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import org.apache.sqoop.model.MLinkConfig;
public class GenericJdbcConnectorUpgrader extends RepositoryUpgrader {
- private static final Logger LOG =
- Logger.getLogger(GenericJdbcConnectorUpgrader.class);
+ private static final Logger LOG = Logger.getLogger(GenericJdbcConnectorUpgrader.class);
/*
* For now, there is no real upgrade. So copy all data over,
@@ -41,41 +40,40 @@ public class GenericJdbcConnectorUpgrader extends RepositoryUpgrader {
*/
@Override
- public void upgrade(MConnectionForms original,
- MConnectionForms upgradeTarget) {
- doUpgrade(original.getForms(), upgradeTarget.getForms());
+ public void upgrade(MLinkConfig original, MLinkConfig upgradeTarget) {
+ doUpgrade(original.getConfigs(), upgradeTarget.getConfigs());
}
@Override
- public void upgrade(MJobForms original, MJobForms upgradeTarget) {
- doUpgrade(original.getForms(), upgradeTarget.getForms());
+ public void upgrade(MConfigList original, MConfigList upgradeTarget) {
+ doUpgrade(original.getConfigs(), upgradeTarget.getConfigs());
}
@SuppressWarnings("unchecked")
- private void doUpgrade(List<MForm> original, List<MForm> target) {
- // Easier to find the form in the original forms list if we use a map.
- // Since the constructor of MJobForms takes a list,
+ private void doUpgrade(List<MConfig> original, List<MConfig> target) {
+ // Easier to find the config in the original list if we use a map.
+ // Since the constructor takes a list,
// index is not guaranteed to be the same, so we need to look for
// equivalence
- Map<String, MForm> formMap = new HashMap<String, MForm>();
- for (MForm form : original) {
- formMap.put(form.getName(), form);
+ Map<String, MConfig> configMap = new HashMap<String, MConfig>();
+ for (MConfig config : original) {
+ configMap.put(config.getName(), config);
}
- for (MForm form : target) {
- List<MInput<?>> inputs = form.getInputs();
- MForm originalForm = formMap.get(form.getName());
- if (originalForm == null) {
- LOG.warn("Form: '" + form.getName() + "' not present in old " +
- "connector. So it and its inputs will not be transferred by the upgrader.");
+ for (MConfig config : target) {
+ List<MInput<?>> inputs = config.getInputs();
+ MConfig orginalConfig = configMap.get(config.getName());
+ if (orginalConfig == null) {
+ LOG.warn("Config: '" + config.getName() + "' not present in old " +
+ "generic JDBC connector. So it and its inputs will not be transferred by the upgrader.");
continue;
}
for (MInput input : inputs) {
try {
- MInput originalInput = originalForm.getInput(input.getName());
+ MInput originalInput = orginalConfig.getInput(input.getName());
input.setValue(originalInput.getValue());
} catch (SqoopException ex) {
LOG.warn("Input: '" + input.getName() + "' not present in old " +
- "connector. So it will not be transferred by the upgrader.");
+ "generic JDBC connector. So it will not be transferred by the upgrader.");
}
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcExtractor.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcExtractor.java b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcExtractor.java
index e52610a..af9320b 100644
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcExtractor.java
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcExtractor.java
@@ -34,12 +34,12 @@ public class GenericJdbcExtractor extends Extractor<LinkConfiguration, FromJobCo
private long rowsRead = 0;
@Override
- public void extract(ExtractorContext context, LinkConfiguration linkConf,
- FromJobConfiguration fromJobConf, GenericJdbcPartition partition) {
- String driver = linkConf.link.jdbcDriver;
- String url = linkConf.link.connectionString;
- String username = linkConf.link.username;
- String password = linkConf.link.password;
+ public void extract(ExtractorContext context, LinkConfiguration linkConfig,
+ FromJobConfiguration fromJobConfig, GenericJdbcPartition partition) {
+ String driver = linkConfig.linkConfig.jdbcDriver;
+ String url = linkConfig.linkConfig.connectionString;
+ String username = linkConfig.linkConfig.username;
+ String password = linkConfig.linkConfig.password;
GenericJdbcExecutor executor = new GenericJdbcExecutor(driver, url, username, password);
String query = context.getString(GenericJdbcConnectorConstants.CONNECTOR_JDBC_FROM_DATA_SQL);
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcFromDestroyer.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcFromDestroyer.java b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcFromDestroyer.java
index d3a893f..3a783be 100644
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcFromDestroyer.java
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcFromDestroyer.java
@@ -29,7 +29,7 @@ public class GenericJdbcFromDestroyer extends Destroyer<LinkConfiguration, FromJ
Logger.getLogger(GenericJdbcFromDestroyer.class);
@Override
- public void destroy(DestroyerContext context, LinkConfiguration linkConf, FromJobConfiguration fromJobConf) {
+ public void destroy(DestroyerContext context, LinkConfiguration linkConfig, FromJobConfiguration fromJobConfig) {
LOG.info("Running generic JDBC connector destroyer");
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcFromInitializer.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcFromInitializer.java b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcFromInitializer.java
index 9d0c178..ef4ecc4 100644
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcFromInitializer.java
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcFromInitializer.java
@@ -45,34 +45,34 @@ public class GenericJdbcFromInitializer extends Initializer<LinkConfiguration, F
private GenericJdbcExecutor executor;
@Override
- public void initialize(InitializerContext context, LinkConfiguration linkConf, FromJobConfiguration fromJobConf) {
- configureJdbcProperties(context.getContext(), linkConf, fromJobConf);
+ public void initialize(InitializerContext context, LinkConfiguration linkConfig, FromJobConfiguration fromJobConfig) {
+ configureJdbcProperties(context.getContext(), linkConfig, fromJobConfig);
try {
- configurePartitionProperties(context.getContext(), linkConf, fromJobConf);
- configureTableProperties(context.getContext(), linkConf, fromJobConf);
+ configurePartitionProperties(context.getContext(), linkConfig, fromJobConfig);
+ configureTableProperties(context.getContext(), linkConfig, fromJobConfig);
} finally {
executor.close();
}
}
@Override
- public List<String> getJars(InitializerContext context, LinkConfiguration linkConf, FromJobConfiguration fromJobConf) {
+ public List<String> getJars(InitializerContext context, LinkConfiguration linkConfig, FromJobConfiguration fromJobConfig) {
List<String> jars = new LinkedList<String>();
- jars.add(ClassUtils.jarForClass(linkConf.link.jdbcDriver));
+ jars.add(ClassUtils.jarForClass(linkConfig.linkConfig.jdbcDriver));
return jars;
}
@Override
- public Schema getSchema(InitializerContext context, LinkConfiguration linkConf, FromJobConfiguration fromJobConf) {
- configureJdbcProperties(context.getContext(), linkConf, fromJobConf);
+ public Schema getSchema(InitializerContext context, LinkConfiguration linkConfig, FromJobConfiguration fromJobConfig) {
+ configureJdbcProperties(context.getContext(), linkConfig, fromJobConfig);
- String schemaName = fromJobConf.fromJobConfig.tableName;
+ String schemaName = fromJobConfig.fromJobConfig.tableName;
if(schemaName == null) {
schemaName = "Query";
- } else if(fromJobConf.fromJobConfig.schemaName != null) {
- schemaName = fromJobConf.fromJobConfig.schemaName + "." + schemaName;
+ } else if(fromJobConfig.fromJobConfig.schemaName != null) {
+ schemaName = fromJobConfig.fromJobConfig.schemaName + "." + schemaName;
}
Schema schema = new Schema(schemaName);
@@ -117,11 +117,11 @@ public class GenericJdbcFromInitializer extends Initializer<LinkConfiguration, F
}
}
- private void configureJdbcProperties(MutableContext context, LinkConfiguration connectionConfig, FromJobConfiguration fromJobConfig) {
- String driver = connectionConfig.link.jdbcDriver;
- String url = connectionConfig.link.connectionString;
- String username = connectionConfig.link.username;
- String password = connectionConfig.link.password;
+ private void configureJdbcProperties(MutableContext context, LinkConfiguration linkConfig, FromJobConfiguration fromJobConfig) {
+ String driver = linkConfig.linkConfig.jdbcDriver;
+ String url = linkConfig.linkConfig.connectionString;
+ String username = linkConfig.linkConfig.username;
+ String password = linkConfig.linkConfig.password;
assert driver != null;
assert url != null;
@@ -129,7 +129,7 @@ public class GenericJdbcFromInitializer extends Initializer<LinkConfiguration, F
executor = new GenericJdbcExecutor(driver, url, username, password);
}
- private void configurePartitionProperties(MutableContext context, LinkConfiguration connectionConfig, FromJobConfiguration fromJobConfig) {
+ private void configurePartitionProperties(MutableContext context, LinkConfiguration linkConfig, FromJobConfiguration fromJobConfig) {
// ----- configure column name -----
String partitionColumnName = fromJobConfig.fromJobConfig.partitionColumn;
@@ -234,7 +234,7 @@ public class GenericJdbcFromInitializer extends Initializer<LinkConfiguration, F
}
}
- private void configureTableProperties(MutableContext context, LinkConfiguration connectionConfig, FromJobConfiguration fromJobConfig) {
+ private void configureTableProperties(MutableContext context, LinkConfiguration linkConfig, FromJobConfiguration fromJobConfig) {
String dataSql;
String fieldNames;
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcLoader.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcLoader.java b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcLoader.java
index 991e686..6340a70 100644
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcLoader.java
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcLoader.java
@@ -30,11 +30,11 @@ public class GenericJdbcLoader extends Loader<LinkConfiguration, ToJobConfigurat
private int batchesPerTransaction = DEFAULT_BATCHES_PER_TRANSACTION;
@Override
- public void load(LoaderContext context, LinkConfiguration linkConf, ToJobConfiguration toJobConf) throws Exception{
- String driver = linkConf.link.jdbcDriver;
- String url = linkConf.link.connectionString;
- String username = linkConf.link.username;
- String password = linkConf.link.password;
+ public void load(LoaderContext context, LinkConfiguration linkConfig, ToJobConfiguration toJobConfig) throws Exception{
+ String driver = linkConfig.linkConfig.jdbcDriver;
+ String url = linkConfig.linkConfig.connectionString;
+ String username = linkConfig.linkConfig.username;
+ String password = linkConfig.linkConfig.password;
GenericJdbcExecutor executor = new GenericJdbcExecutor(driver, url, username, password);
executor.setAutoCommit(false);
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcPartitioner.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcPartitioner.java b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcPartitioner.java
index 6b11228..2411169 100644
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcPartitioner.java
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcPartitioner.java
@@ -47,7 +47,8 @@ public class GenericJdbcPartitioner extends Partitioner<LinkConfiguration, FromJ
private Boolean partitionColumnNull;
@Override
- public List<Partition> getPartitions(PartitionerContext context,LinkConfiguration linkConf, FromJobConfiguration fromJobConf) {
+ public List<Partition> getPartitions(PartitionerContext context, LinkConfiguration linkConfig,
+ FromJobConfiguration fromJobConfig) {
List<Partition> partitions = new LinkedList<Partition>();
numberPartitions = context.getMaxPartitions();
@@ -56,7 +57,7 @@ public class GenericJdbcPartitioner extends Partitioner<LinkConfiguration, FromJ
partitionMinValue = context.getString(GenericJdbcConnectorConstants.CONNECTOR_JDBC_PARTITION_MINVALUE);
partitionMaxValue = context.getString(GenericJdbcConnectorConstants.CONNECTOR_JDBC_PARTITION_MAXVALUE);
- partitionColumnNull = fromJobConf.fromJobConfig.partitionColumnNull;
+ partitionColumnNull = fromJobConfig.fromJobConfig.partitionColumnNull;
if (partitionColumnNull == null) {
partitionColumnNull = false;
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcToDestroyer.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcToDestroyer.java b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcToDestroyer.java
index 7bed1d9..e381651 100644
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcToDestroyer.java
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcToDestroyer.java
@@ -28,26 +28,26 @@ public class GenericJdbcToDestroyer extends Destroyer<LinkConfiguration, ToJobCo
private static final Logger LOG = Logger.getLogger(GenericJdbcToDestroyer.class);
@Override
- public void destroy(DestroyerContext context, LinkConfiguration linkConf, ToJobConfiguration toJobConf) {
+ public void destroy(DestroyerContext context, LinkConfiguration linkConfig, ToJobConfiguration toJobConfig) {
LOG.info("Running generic JDBC connector destroyer");
- final String tableName = toJobConf.toJobConfig.tableName;
- final String stageTableName = toJobConf.toJobConfig.stageTableName;
+ final String tableName = toJobConfig.toJobConfig.tableName;
+ final String stageTableName = toJobConfig.toJobConfig.stageTableName;
final boolean stageEnabled = stageTableName != null &&
stageTableName.length() > 0;
if(stageEnabled) {
- moveDataToDestinationTable(linkConf,
+ moveDataToDestinationTable(linkConfig,
context.isSuccess(), stageTableName, tableName);
}
}
- private void moveDataToDestinationTable(LinkConfiguration linkConf,
+ private void moveDataToDestinationTable(LinkConfiguration linkConfig,
boolean success, String stageTableName, String tableName) {
GenericJdbcExecutor executor =
- new GenericJdbcExecutor(linkConf.link.jdbcDriver,
- linkConf.link.connectionString,
- linkConf.link.username,
- linkConf.link.password);
+ new GenericJdbcExecutor(linkConfig.linkConfig.jdbcDriver,
+ linkConfig.linkConfig.connectionString,
+ linkConfig.linkConfig.username,
+ linkConfig.linkConfig.password);
try {
if(success) {
LOG.info("Job completed, transferring data from stage fromTable to " +
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcToInitializer.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcToInitializer.java b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcToInitializer.java
index 5d0ec93..1747347 100644
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcToInitializer.java
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcToInitializer.java
@@ -43,35 +43,35 @@ public class GenericJdbcToInitializer extends Initializer<LinkConfiguration, ToJ
Logger.getLogger(GenericJdbcToInitializer.class);
@Override
- public void initialize(InitializerContext context, LinkConfiguration linkConf, ToJobConfiguration toJobConf) {
- configureJdbcProperties(context.getContext(), linkConf, toJobConf);
+ public void initialize(InitializerContext context, LinkConfiguration linkConfig, ToJobConfiguration toJobConfig) {
+ configureJdbcProperties(context.getContext(), linkConfig, toJobConfig);
try {
- configureTableProperties(context.getContext(), linkConf, toJobConf);
+ configureTableProperties(context.getContext(), linkConfig, toJobConfig);
} finally {
executor.close();
}
}
@Override
- public List<String> getJars(InitializerContext context, LinkConfiguration linkConf, ToJobConfiguration toJobConf) {
+ public List<String> getJars(InitializerContext context, LinkConfiguration linkConfig, ToJobConfiguration toJobConfig) {
List<String> jars = new LinkedList<String>();
- jars.add(ClassUtils.jarForClass(linkConf.link.jdbcDriver));
+ jars.add(ClassUtils.jarForClass(linkConfig.linkConfig.jdbcDriver));
return jars;
}
@Override
- public Schema getSchema(InitializerContext context, LinkConfiguration linkConf, ToJobConfiguration toJobConf) {
- configureJdbcProperties(context.getContext(), linkConf, toJobConf);
+ public Schema getSchema(InitializerContext context, LinkConfiguration linkConfig, ToJobConfiguration toJobConfig) {
+ configureJdbcProperties(context.getContext(), linkConfig, toJobConfig);
- String schemaName = toJobConf.toJobConfig.tableName;
+ String schemaName = toJobConfig.toJobConfig.tableName;
if (schemaName == null) {
throw new SqoopException(GenericJdbcConnectorError.GENERIC_JDBC_CONNECTOR_0019,
"Table name extraction not supported yet.");
}
- if(toJobConf.toJobConfig.schemaName != null) {
- schemaName = toJobConf.toJobConfig.schemaName + "." + schemaName;
+ if(toJobConfig.toJobConfig.schemaName != null) {
+ schemaName = toJobConfig.toJobConfig.schemaName + "." + schemaName;
}
Schema schema = new Schema(schemaName);
@@ -110,11 +110,11 @@ public class GenericJdbcToInitializer extends Initializer<LinkConfiguration, ToJ
}
}
- private void configureJdbcProperties(MutableContext context, LinkConfiguration linkConf, ToJobConfiguration toJobConf) {
- String driver = linkConf.link.jdbcDriver;
- String url = linkConf.link.connectionString;
- String username = linkConf.link.username;
- String password = linkConf.link.password;
+ private void configureJdbcProperties(MutableContext context, LinkConfiguration linkConfig, ToJobConfiguration toJobConfig) {
+ String driver = linkConfig.linkConfig.jdbcDriver;
+ String url = linkConfig.linkConfig.connectionString;
+ String username = linkConfig.linkConfig.username;
+ String password = linkConfig.linkConfig.password;
assert driver != null;
assert url != null;
@@ -122,7 +122,7 @@ public class GenericJdbcToInitializer extends Initializer<LinkConfiguration, ToJ
executor = new GenericJdbcExecutor(driver, url, username, password);
}
- private void configureTableProperties(MutableContext context, LinkConfiguration linkConf, ToJobConfiguration toJobConfig) {
+ private void configureTableProperties(MutableContext context, LinkConfiguration linkConfig, ToJobConfiguration toJobConfig) {
String dataSql;
String schemaName = toJobConfig.toJobConfig.schemaName;
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcValidator.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcValidator.java b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcValidator.java
index ad1ee5c..93989a4 100644
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcValidator.java
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcValidator.java
@@ -22,7 +22,7 @@ import org.apache.sqoop.connector.jdbc.configuration.LinkConfiguration;
import org.apache.sqoop.connector.jdbc.configuration.FromJobConfiguration;
import org.apache.sqoop.connector.jdbc.configuration.ToJobConfiguration;
import org.apache.sqoop.validation.Status;
-import org.apache.sqoop.validation.Validation;
+import org.apache.sqoop.validation.ConfigValidator;
import org.apache.sqoop.validation.Validator;
import java.sql.DriverManager;
@@ -34,30 +34,30 @@ import java.sql.SQLException;
public class GenericJdbcValidator extends Validator {
@Override
- public Validation validateLink(Object configuration) {
- Validation validation = new Validation(LinkConfiguration.class);
- LinkConfiguration linkConf = (LinkConfiguration)configuration;
+ public ConfigValidator validateConfigForLink(Object configuration) {
+ ConfigValidator validation = new ConfigValidator(LinkConfiguration.class);
+ LinkConfiguration linkConfig = (LinkConfiguration)configuration;
- if(linkConf.link.jdbcDriver == null) {
+ if(linkConfig.linkConfig.jdbcDriver == null) {
validation.addMessage(Status.UNACCEPTABLE, "link", "jdbcDriver", "Driver can't be empty");
} else {
try {
- Class.forName(linkConf.link.jdbcDriver);
+ Class.forName(linkConfig.linkConfig.jdbcDriver);
} catch (ClassNotFoundException e) {
validation.addMessage(Status.UNACCEPTABLE, "link", "jdbcDriver", "Can't load specified driver");
}
}
- if(linkConf.link.connectionString == null) {
+ if(linkConfig.linkConfig.connectionString == null) {
validation.addMessage(Status.UNACCEPTABLE, "link", "connectionString", "JDBC URL can't be empty");
- } else if(!linkConf.link.connectionString.startsWith("jdbc:")) {
+ } else if(!linkConfig.linkConfig.connectionString.startsWith("jdbc:")) {
validation.addMessage(Status.UNACCEPTABLE, "link", "connectionString", "This do not seem as a valid JDBC URL");
}
// See if we can connect to the database
try {
- DriverManager.getConnection(linkConf.link.connectionString,
- linkConf.link.username, linkConf.link.password);
+ DriverManager.getConnection(linkConfig.linkConfig.connectionString,
+ linkConfig.linkConfig.username, linkConfig.linkConfig.password);
} catch (SQLException e) {
validation.addMessage(Status.ACCEPTABLE, "link", "Can't connect to the database with given credentials: " + e.getMessage());
}
@@ -67,7 +67,7 @@ public class GenericJdbcValidator extends Validator {
}
@Override
- public Validation validateJob(Object jobConfiguration) {
+ public ConfigValidator validateConfigForJob(Object jobConfiguration) {
if (jobConfiguration instanceof FromJobConfiguration) {
return validateFromJobConfiguration((FromJobConfiguration)jobConfiguration);
} else if (jobConfiguration instanceof ToJobConfiguration) {
@@ -78,8 +78,8 @@ public class GenericJdbcValidator extends Validator {
}
}
- private Validation validateToJobConfiguration(ToJobConfiguration configuration) {
- Validation validation = new Validation(FromJobConfiguration.class);
+ private ConfigValidator validateToJobConfiguration(ToJobConfiguration configuration) {
+ ConfigValidator validation = new ConfigValidator(FromJobConfiguration.class);
if(configuration.toJobConfig.tableName == null && configuration.toJobConfig.sql == null) {
validation.addMessage(Status.UNACCEPTABLE, "toJobConfig", "Either table name or SQL must be specified");
@@ -102,8 +102,8 @@ public class GenericJdbcValidator extends Validator {
return validation;
}
- private Validation validateFromJobConfiguration(FromJobConfiguration configuration) {
- Validation validation = new Validation(FromJobConfiguration.class);
+ private ConfigValidator validateFromJobConfiguration(FromJobConfiguration configuration) {
+ ConfigValidator validation = new ConfigValidator(FromJobConfiguration.class);
if(configuration.fromJobConfig.tableName == null && configuration.fromJobConfig.sql == null) {
validation.addMessage(Status.UNACCEPTABLE, "fromJobConfig", "Either table name or SQL must be specified");
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/FromJobConfig.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/FromJobConfig.java b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/FromJobConfig.java
index 8b23144..12ceb21 100644
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/FromJobConfig.java
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/FromJobConfig.java
@@ -18,7 +18,7 @@
package org.apache.sqoop.connector.jdbc.configuration;
import org.apache.sqoop.connector.jdbc.GenericJdbcConnectorConstants;
-import org.apache.sqoop.model.FormClass;
+import org.apache.sqoop.model.ConfigClass;
import org.apache.sqoop.model.Input;
import org.apache.sqoop.model.Validator;
import org.apache.sqoop.validation.Status;
@@ -28,7 +28,7 @@ import org.apache.sqoop.validation.validators.NullOrContains;
/**
*
*/
-@FormClass( validators = {@Validator(FromJobConfig.FormValidator.class)})
+@ConfigClass( validators = {@Validator(FromJobConfig.ConfigValidator.class)})
public class FromJobConfig {
@Input(size = 50)
public String schemaName;
@@ -51,16 +51,16 @@ public class FromJobConfig {
@Input(size = 50)
public String boundaryQuery;
- public static class FormValidator extends AbstractValidator<FromJobConfig> {
+ public static class ConfigValidator extends AbstractValidator<FromJobConfig> {
@Override
- public void validate(FromJobConfig form) {
- if(form.tableName == null && form.sql == null) {
+ public void validate(FromJobConfig config) {
+ if(config.tableName == null && config.sql == null) {
addMessage(Status.UNACCEPTABLE, "Either table name or SQL must be specified");
}
- if(form.tableName != null && form.sql != null) {
+ if(config.tableName != null && config.sql != null) {
addMessage(Status.UNACCEPTABLE, "Both table name and SQL cannot be specified");
}
- if(form.schemaName != null && form.sql != null) {
+ if(config.schemaName != null && config.sql != null) {
addMessage(Status.UNACCEPTABLE, "Both schema name and SQL cannot be specified");
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/FromJobConfiguration.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/FromJobConfiguration.java b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/FromJobConfiguration.java
index b036421..39e8edd 100644
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/FromJobConfiguration.java
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/FromJobConfiguration.java
@@ -18,14 +18,14 @@
package org.apache.sqoop.connector.jdbc.configuration;
import org.apache.sqoop.model.ConfigurationClass;
-import org.apache.sqoop.model.Form;
+import org.apache.sqoop.model.Config;
/**
*
*/
@ConfigurationClass
public class FromJobConfiguration {
- @Form public FromJobConfig fromJobConfig;
+ @Config public FromJobConfig fromJobConfig;
public FromJobConfiguration() {
fromJobConfig = new FromJobConfig();
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/LinkConfig.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/LinkConfig.java b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/LinkConfig.java
index 7b76eeb..be86855 100644
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/LinkConfig.java
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/LinkConfig.java
@@ -17,7 +17,7 @@
*/
package org.apache.sqoop.connector.jdbc.configuration;
-import org.apache.sqoop.model.FormClass;
+import org.apache.sqoop.model.ConfigClass;
import org.apache.sqoop.model.Input;
import org.apache.sqoop.model.Validator;
import org.apache.sqoop.validation.Status;
@@ -33,7 +33,7 @@ import java.util.Map;
/**
*
*/
-@FormClass(validators = {@Validator(LinkConfig.FormValidator.class)})
+@ConfigClass(validators = {@Validator(LinkConfig.ConfigValidator.class)})
public class LinkConfig {
@Input(size = 128, validators = {@Validator(NotEmpty.class), @Validator(ClassAvailable.class)} )
public String jdbcDriver;
@@ -50,7 +50,7 @@ public class LinkConfig {
@Input
public Map<String, String> jdbcProperties;
- public static class FormValidator extends AbstractValidator<LinkConfig> {
+ public static class ConfigValidator extends AbstractValidator<LinkConfig> {
@Override
public void validate(LinkConfig linkConfig) {
// See if we can connect to the database
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/LinkConfiguration.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/LinkConfiguration.java b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/LinkConfiguration.java
index 7d614f7..ed55bff 100644
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/LinkConfiguration.java
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/LinkConfiguration.java
@@ -18,7 +18,7 @@
package org.apache.sqoop.connector.jdbc.configuration;
import org.apache.sqoop.model.ConfigurationClass;
-import org.apache.sqoop.model.Form;
+import org.apache.sqoop.model.Config;
/**
*
@@ -26,9 +26,9 @@ import org.apache.sqoop.model.Form;
@ConfigurationClass
public class LinkConfiguration {
- @Form public LinkConfig link;
+ @Config public LinkConfig linkConfig;
public LinkConfiguration() {
- link = new LinkConfig();
+ linkConfig = new LinkConfig();
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ToJobConfig.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ToJobConfig.java b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ToJobConfig.java
index a42a6ec..2428601 100644
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ToJobConfig.java
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ToJobConfig.java
@@ -17,7 +17,7 @@
*/
package org.apache.sqoop.connector.jdbc.configuration;
-import org.apache.sqoop.model.FormClass;
+import org.apache.sqoop.model.ConfigClass;
import org.apache.sqoop.model.Input;
import org.apache.sqoop.model.Validator;
import org.apache.sqoop.validation.Status;
@@ -26,7 +26,7 @@ import org.apache.sqoop.validation.validators.AbstractValidator;
/**
*
*/
-@FormClass(validators = {@Validator(ToJobConfig.FormValidator.class)})
+@ConfigClass(validators = {@Validator(ToJobConfig.ConfigValidator.class)})
public class ToJobConfig {
@Input(size = 50) public String schemaName;
@Input(size = 2000) public String tableName;
@@ -35,19 +35,19 @@ public class ToJobConfig {
@Input(size = 2000) public String stageTableName;
@Input public Boolean clearStageTable;
- public static class FormValidator extends AbstractValidator<ToJobConfig> {
+ public static class ConfigValidator extends AbstractValidator<ToJobConfig> {
@Override
- public void validate(ToJobConfig form) {
- if(form.tableName == null && form.sql == null) {
+ public void validate(ToJobConfig config) {
+ if(config.tableName == null && config.sql == null) {
addMessage(Status.UNACCEPTABLE, "Either table name or SQL must be specified");
}
- if(form.tableName != null && form.sql != null) {
+ if(config.tableName != null && config.sql != null) {
addMessage(Status.UNACCEPTABLE, "Both table name and SQL cannot be specified");
}
- if(form.tableName == null && form.stageTableName != null) {
+ if(config.tableName == null && config.stageTableName != null) {
addMessage(Status.UNACCEPTABLE, "Stage table name cannot be specified without specifying table name");
}
- if(form.stageTableName == null && form.clearStageTable != null) {
+ if(config.stageTableName == null && config.clearStageTable != null) {
addMessage(Status.UNACCEPTABLE, "Clear stage table cannot be specified without specifying name of the stage table.");
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ToJobConfiguration.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ToJobConfiguration.java b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ToJobConfiguration.java
index ad68681..fd5d54b 100644
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ToJobConfiguration.java
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ToJobConfiguration.java
@@ -18,14 +18,14 @@
package org.apache.sqoop.connector.jdbc.configuration;
import org.apache.sqoop.model.ConfigurationClass;
-import org.apache.sqoop.model.Form;
+import org.apache.sqoop.model.Config;
/**
*
*/
@ConfigurationClass
public class ToJobConfiguration {
- @Form public ToJobConfig toJobConfig;
+ @Config public ToJobConfig toJobConfig;
public ToJobConfiguration() {
toJobConfig = new ToJobConfig();
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-generic-jdbc/src/main/resources/generic-jdbc-connector-config.properties
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/resources/generic-jdbc-connector-config.properties b/connector/connector-generic-jdbc/src/main/resources/generic-jdbc-connector-config.properties
index 921ac28..c535e9b 100644
--- a/connector/connector-generic-jdbc/src/main/resources/generic-jdbc-connector-config.properties
+++ b/connector/connector-generic-jdbc/src/main/resources/generic-jdbc-connector-config.properties
@@ -18,33 +18,33 @@
############################
# Link Config
#
-link.label = Link configuration
-link.help = You must supply the information requested in order to \
+linkConfig.label = Link configuration
+linkConfig.help = You must supply the information requested in order to \
create a connection object.
# jdbc driver
-link.jdbcDriver.label = JDBC Driver Class
-link.jdbcDriver.help = Enter the fully qualified class name of the JDBC \
+linkConfig.jdbcDriver.label = JDBC Driver Class
+linkConfig.jdbcDriver.help = Enter the fully qualified class name of the JDBC \
driver that will be used for establishing this connection.
# connect string
-link.connectionString.label = JDBC Connection String
-link.connectionString.help = Enter the value of JDBC connection string to be \
+linkConfig.connectionString.label = JDBC Connection String
+linkConfig.connectionString.help = Enter the value of JDBC connection string to be \
used by this connector for creating connections.
# username string
-link.username.label = Username
-link.username.help = Enter the username to be used for connecting to the \
+linkConfig.username.label = Username
+linkConfig.username.help = Enter the username to be used for connecting to the \
database.
# password string
-link.password.label = Password
-link.password.help = Enter the password to be used for connecting to the \
+linkConfig.password.label = Password
+linkConfig.password.help = Enter the password to be used for connecting to the \
database.
# jdbc properties
-link.jdbcProperties.label = JDBC Connection Properties
-link.jdbcProperties.help = Enter any JDBC properties that should be \
+linkConfig.jdbcProperties.label = JDBC Connection Properties
+linkConfig.jdbcProperties.help = Enter any JDBC properties that should be \
supplied during the creation of connection.
# From Job Config
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/GenericJdbcExecutorTest.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/GenericJdbcExecutorTest.java b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/GenericJdbcExecutorTest.java
index 1022370..61846b7 100644
--- a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/GenericJdbcExecutorTest.java
+++ b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/GenericJdbcExecutorTest.java
@@ -60,7 +60,6 @@ public class GenericJdbcExecutorTest {
}
@Test
- @SuppressWarnings("unchecked")
public void testDeleteTableData() throws Exception {
executor.deleteTableData(table);
assertEquals("Table " + table + " is expected to be empty.",
@@ -68,7 +67,6 @@ public class GenericJdbcExecutorTest {
}
@Test
- @SuppressWarnings("unchecked")
public void testMigrateData() throws Exception {
assertEquals("Table " + emptyTable + " is expected to be empty.",
0, executor.getTableRowCount(emptyTable));
@@ -86,7 +84,6 @@ public class GenericJdbcExecutorTest {
}
@Test
- @SuppressWarnings("unchecked")
public void testGetTableRowCount() throws Exception {
assertEquals("Table " + table + " is expected to be empty.",
NUMBER_OF_ROWS, executor.getTableRowCount(table));
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestExtractor.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestExtractor.java b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestExtractor.java
index fbdf9c6..d1e6805 100644
--- a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestExtractor.java
+++ b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestExtractor.java
@@ -74,10 +74,10 @@ public class TestExtractor {
public void testQuery() throws Exception {
MutableContext context = new MutableMapContext();
- LinkConfiguration connectionConfig = new LinkConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
- connectionConfig.link.jdbcDriver = GenericJdbcTestConstants.DRIVER;
- connectionConfig.link.connectionString = GenericJdbcTestConstants.URL;
+ linkConfig.linkConfig.jdbcDriver = GenericJdbcTestConstants.DRIVER;
+ linkConfig.linkConfig.connectionString = GenericJdbcTestConstants.URL;
FromJobConfiguration jobConfig = new FromJobConfiguration();
@@ -92,25 +92,25 @@ public class TestExtractor {
partition = new GenericJdbcPartition();
partition.setConditions("-50.0 <= DCOL AND DCOL < -16.6666666666666665");
- extractor.extract(extractorContext, connectionConfig, jobConfig, partition);
+ extractor.extract(extractorContext, linkConfig, jobConfig, partition);
partition = new GenericJdbcPartition();
partition.setConditions("-16.6666666666666665 <= DCOL AND DCOL < 16.666666666666667");
- extractor.extract(extractorContext, connectionConfig, jobConfig, partition);
+ extractor.extract(extractorContext, linkConfig, jobConfig, partition);
partition = new GenericJdbcPartition();
partition.setConditions("16.666666666666667 <= DCOL AND DCOL <= 50.0");
- extractor.extract(extractorContext, connectionConfig, jobConfig, partition);
+ extractor.extract(extractorContext, linkConfig, jobConfig, partition);
}
@Test
public void testSubquery() throws Exception {
MutableContext context = new MutableMapContext();
- LinkConfiguration connectionConfig = new LinkConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
- connectionConfig.link.jdbcDriver = GenericJdbcTestConstants.DRIVER;
- connectionConfig.link.connectionString = GenericJdbcTestConstants.URL;
+ linkConfig.linkConfig.jdbcDriver = GenericJdbcTestConstants.DRIVER;
+ linkConfig.linkConfig.connectionString = GenericJdbcTestConstants.URL;
FromJobConfiguration jobConfig = new FromJobConfiguration();
@@ -127,15 +127,15 @@ public class TestExtractor {
partition = new GenericJdbcPartition();
partition.setConditions("-50 <= ICOL AND ICOL < -16");
- extractor.extract(extractorContext, connectionConfig, jobConfig, partition);
+ extractor.extract(extractorContext, linkConfig, jobConfig, partition);
partition = new GenericJdbcPartition();
partition.setConditions("-16 <= ICOL AND ICOL < 17");
- extractor.extract(extractorContext, connectionConfig, jobConfig, partition);
+ extractor.extract(extractorContext, linkConfig, jobConfig, partition);
partition = new GenericJdbcPartition();
partition.setConditions("17 <= ICOL AND ICOL < 50");
- extractor.extract(extractorContext, connectionConfig, jobConfig, partition);
+ extractor.extract(extractorContext, linkConfig, jobConfig, partition);
}
public class DummyWriter extends DataWriter {
[03/13] SQOOP-1498: Sqoop2: Repository Object refactoring (objects
prefixed with M)
Posted by ab...@apache.org.
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestJobHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestJobHandling.java b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestJobHandling.java
index 47350ea..595b1c8 100644
--- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestJobHandling.java
+++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestJobHandling.java
@@ -17,9 +17,14 @@
*/
package org.apache.sqoop.repository.derby;
+import java.sql.Connection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.apache.sqoop.common.Direction;
import org.apache.sqoop.common.SqoopException;
-import org.apache.sqoop.model.MForm;
+import org.apache.sqoop.model.MConfig;
import org.apache.sqoop.model.MJob;
import org.apache.sqoop.model.MMapInput;
import org.apache.sqoop.model.MStringInput;
@@ -38,18 +43,19 @@ import static org.junit.Assert.*;
public class TestJobHandling extends DerbyTestCase {
DerbyRepositoryHandler handler;
+ Connection derbyConnection;
@Before
public void setUp() throws Exception {
super.setUp();
+ derbyConnection = getDerbyDatabaseConnection();
handler = new DerbyRepositoryHandler();
// We always needs schema for this test case
createSchema();
- // We always needs connector and framework structures in place
- loadConnectorAndDriverConfig();
+ loadConnectorLinkConfig();
// We always needs connection metadata in place
loadLinks();
@@ -59,58 +65,53 @@ public class TestJobHandling extends DerbyTestCase {
public void testFindJob() throws Exception {
// Let's try to find non existing job
try {
- handler.findJob(1, getDerbyDatabaseConnection());
+ handler.findJob(1, derbyConnection);
fail();
} catch(SqoopException ex) {
assertEquals(DerbyRepoError.DERBYREPO_0030, ex.getErrorCode());
}
- // Load prepared connections into database
loadJobs();
- MJob jobImport = handler.findJob(1, getDerbyDatabaseConnection());
- assertNotNull(jobImport);
- assertEquals(1, jobImport.getPersistenceId());
- assertEquals("JA", jobImport.getName());
-
- List<MForm> forms;
-
- // Check connector parts
- forms = jobImport.getConnectorPart(Direction.FROM).getForms();
- assertEquals(2, forms.size());
- assertEquals("Value5", forms.get(0).getInputs().get(0).getValue());
- assertNull(forms.get(0).getInputs().get(1).getValue());
- assertEquals("Value5", forms.get(0).getInputs().get(0).getValue());
- assertNull(forms.get(1).getInputs().get(1).getValue());
-
- forms = jobImport.getConnectorPart(Direction.TO).getForms();
- assertEquals(2, forms.size());
- assertEquals("Value9", forms.get(0).getInputs().get(0).getValue());
- assertNull(forms.get(0).getInputs().get(1).getValue());
- assertEquals("Value9", forms.get(0).getInputs().get(0).getValue());
- assertNull(forms.get(1).getInputs().get(1).getValue());
-
- // Check framework part
- forms = jobImport.getFrameworkPart().getForms();
- assertEquals(2, forms.size());
- assertEquals("Value17", forms.get(0).getInputs().get(0).getValue());
- assertNull(forms.get(0).getInputs().get(1).getValue());
- assertEquals("Value19", forms.get(1).getInputs().get(0).getValue());
- assertNull(forms.get(1).getInputs().get(1).getValue());
+ MJob firstJob = handler.findJob(1, derbyConnection);
+ assertNotNull(firstJob);
+ assertEquals(1, firstJob.getPersistenceId());
+ assertEquals("JA", firstJob.getName());
+
+ List<MConfig> configs;
+
+ configs = firstJob.getJobConfig(Direction.FROM).getConfigs();
+ assertEquals(2, configs.size());
+ assertEquals("Value5", configs.get(0).getInputs().get(0).getValue());
+ assertNull(configs.get(0).getInputs().get(1).getValue());
+ assertEquals("Value5", configs.get(0).getInputs().get(0).getValue());
+ assertNull(configs.get(1).getInputs().get(1).getValue());
+
+ configs = firstJob.getJobConfig(Direction.TO).getConfigs();
+ assertEquals(2, configs.size());
+ assertEquals("Value9", configs.get(0).getInputs().get(0).getValue());
+ assertNull(configs.get(0).getInputs().get(1).getValue());
+ assertEquals("Value9", configs.get(0).getInputs().get(0).getValue());
+ assertNull(configs.get(1).getInputs().get(1).getValue());
+
+ configs = firstJob.getDriverConfig().getConfigs();
+ assertEquals(2, configs.size());
+ assertEquals("Value13", configs.get(0).getInputs().get(0).getValue());
+ assertNull(configs.get(0).getInputs().get(1).getValue());
+ assertEquals("Value15", configs.get(1).getInputs().get(0).getValue());
+ assertNull(configs.get(1).getInputs().get(1).getValue());
}
@Test
public void testFindJobs() throws Exception {
List<MJob> list;
-
// Load empty list on empty repository
- list = handler.findJobs(getDerbyDatabaseConnection());
+ list = handler.findJobs(derbyConnection);
assertEquals(0, list.size());
-
loadJobs();
// Load all two connections on loaded repository
- list = handler.findJobs(getDerbyDatabaseConnection());
+ list = handler.findJobs(derbyConnection);
assertEquals(4, list.size());
assertEquals("JA", list.get(0).getName());
@@ -125,19 +126,19 @@ public class TestJobHandling extends DerbyTestCase {
@Test
public void testExistsJob() throws Exception {
// There shouldn't be anything on empty repository
- assertFalse(handler.existsJob(1, getDerbyDatabaseConnection()));
- assertFalse(handler.existsJob(2, getDerbyDatabaseConnection()));
- assertFalse(handler.existsJob(3, getDerbyDatabaseConnection()));
- assertFalse(handler.existsJob(4, getDerbyDatabaseConnection()));
- assertFalse(handler.existsJob(5, getDerbyDatabaseConnection()));
+ assertFalse(handler.existsJob(1, derbyConnection));
+ assertFalse(handler.existsJob(2, derbyConnection));
+ assertFalse(handler.existsJob(3, derbyConnection));
+ assertFalse(handler.existsJob(4, derbyConnection));
+ assertFalse(handler.existsJob(5, derbyConnection));
loadJobs();
- assertTrue(handler.existsJob(1, getDerbyDatabaseConnection()));
- assertTrue(handler.existsJob(2, getDerbyDatabaseConnection()));
- assertTrue(handler.existsJob(3, getDerbyDatabaseConnection()));
- assertTrue(handler.existsJob(4, getDerbyDatabaseConnection()));
- assertFalse(handler.existsJob(5, getDerbyDatabaseConnection()));
+ assertTrue(handler.existsJob(1, derbyConnection));
+ assertTrue(handler.existsJob(2, derbyConnection));
+ assertTrue(handler.existsJob(3, derbyConnection));
+ assertTrue(handler.existsJob(4, derbyConnection));
+ assertFalse(handler.existsJob(5, derbyConnection));
}
@Test
@@ -145,10 +146,10 @@ public class TestJobHandling extends DerbyTestCase {
loadJobs();
loadSubmissions();
- assertTrue(handler.inUseJob(1, getDerbyDatabaseConnection()));
- assertFalse(handler.inUseJob(2, getDerbyDatabaseConnection()));
- assertFalse(handler.inUseJob(3, getDerbyDatabaseConnection()));
- assertFalse(handler.inUseJob(4, getDerbyDatabaseConnection()));
+ assertTrue(handler.inUseJob(1, derbyConnection));
+ assertFalse(handler.inUseJob(2, derbyConnection));
+ assertFalse(handler.inUseJob(3, derbyConnection));
+ assertFalse(handler.inUseJob(4, derbyConnection));
}
@Test
@@ -158,34 +159,34 @@ public class TestJobHandling extends DerbyTestCase {
// Load some data
fillJob(job);
- handler.createJob(job, getDerbyDatabaseConnection());
+ handler.createJob(job, derbyConnection);
assertEquals(1, job.getPersistenceId());
assertCountForTable("SQOOP.SQ_JOB", 1);
assertCountForTable("SQOOP.SQ_JOB_INPUT", 6);
- MJob retrieved = handler.findJob(1, getDerbyDatabaseConnection());
+ MJob retrieved = handler.findJob(1, derbyConnection);
assertEquals(1, retrieved.getPersistenceId());
- List<MForm> forms;
- forms = job.getConnectorPart(Direction.FROM).getForms();
- assertEquals("Value1", forms.get(0).getInputs().get(0).getValue());
- assertNull(forms.get(0).getInputs().get(1).getValue());
- forms = job.getConnectorPart(Direction.TO).getForms();
- assertEquals("Value1", forms.get(0).getInputs().get(0).getValue());
- assertNull(forms.get(0).getInputs().get(1).getValue());
+ List<MConfig> configs;
+ configs = job.getJobConfig(Direction.FROM).getConfigs();
+ assertEquals("Value1", configs.get(0).getInputs().get(0).getValue());
+ assertNull(configs.get(0).getInputs().get(1).getValue());
+ configs = job.getJobConfig(Direction.TO).getConfigs();
+ assertEquals("Value1", configs.get(0).getInputs().get(0).getValue());
+ assertNull(configs.get(0).getInputs().get(1).getValue());
- forms = job.getFrameworkPart().getForms();
- assertEquals("Value13", forms.get(0).getInputs().get(0).getValue());
- assertNull(forms.get(0).getInputs().get(1).getValue());
- assertEquals("Value15", forms.get(1).getInputs().get(0).getValue());
- assertNull(forms.get(1).getInputs().get(1).getValue());
+ configs = job.getDriverConfig().getConfigs();
+ assertEquals("Value13", configs.get(0).getInputs().get(0).getValue());
+ assertNull(configs.get(0).getInputs().get(1).getValue());
+ assertEquals("Value15", configs.get(1).getInputs().get(0).getValue());
+ assertNull(configs.get(1).getInputs().get(1).getValue());
// Let's create second job
job = getJob();
fillJob(job);
- handler.createJob(job, getDerbyDatabaseConnection());
+ handler.createJob(job, derbyConnection);
assertEquals(2, job.getPersistenceId());
assertCountForTable("SQOOP.SQ_JOB", 2);
@@ -199,48 +200,49 @@ public class TestJobHandling extends DerbyTestCase {
assertCountForTable("SQOOP.SQ_JOB", 4);
assertCountForTable("SQOOP.SQ_JOB_INPUT", 24);
- MJob job = handler.findJob(1, getDerbyDatabaseConnection());
+ MJob job = handler.findJob(1, derbyConnection);
+
+ List<MConfig> configs;
- List<MForm> forms;
+ configs = job.getJobConfig(Direction.FROM).getConfigs();
+ ((MStringInput)configs.get(0).getInputs().get(0)).setValue("Updated");
+ ((MMapInput)configs.get(0).getInputs().get(1)).setValue(null);
- forms = job.getConnectorPart(Direction.FROM).getForms();
- ((MStringInput)forms.get(0).getInputs().get(0)).setValue("Updated");
- ((MMapInput)forms.get(0).getInputs().get(1)).setValue(null);
- forms = job.getConnectorPart(Direction.TO).getForms();
- ((MStringInput)forms.get(0).getInputs().get(0)).setValue("Updated");
- ((MMapInput)forms.get(0).getInputs().get(1)).setValue(null);
+ configs = job.getJobConfig(Direction.TO).getConfigs();
+ ((MStringInput)configs.get(0).getInputs().get(0)).setValue("Updated");
+ ((MMapInput)configs.get(0).getInputs().get(1)).setValue(null);
- forms = job.getFrameworkPart().getForms();
- ((MStringInput)forms.get(0).getInputs().get(0)).setValue("Updated");
- ((MMapInput)forms.get(0).getInputs().get(1)).setValue(new HashMap<String, String>()); // inject new map value
- ((MStringInput)forms.get(1).getInputs().get(0)).setValue("Updated");
- ((MMapInput)forms.get(1).getInputs().get(1)).setValue(new HashMap<String, String>()); // inject new map value
+ configs = job.getDriverConfig().getConfigs();
+ ((MStringInput)configs.get(0).getInputs().get(0)).setValue("Updated");
+ ((MMapInput)configs.get(0).getInputs().get(1)).setValue(new HashMap<String, String>()); // inject new map value
+ ((MStringInput)configs.get(1).getInputs().get(0)).setValue("Updated");
+ ((MMapInput)configs.get(1).getInputs().get(1)).setValue(new HashMap<String, String>()); // inject new map value
job.setName("name");
- handler.updateJob(job, getDerbyDatabaseConnection());
+ handler.updateJob(job, derbyConnection);
assertEquals(1, job.getPersistenceId());
assertCountForTable("SQOOP.SQ_JOB", 4);
assertCountForTable("SQOOP.SQ_JOB_INPUT", 26);
- MJob retrieved = handler.findJob(1, getDerbyDatabaseConnection());
+ MJob retrieved = handler.findJob(1, derbyConnection);
assertEquals("name", retrieved.getName());
- forms = job.getConnectorPart(Direction.FROM).getForms();
- assertEquals(2, forms.size());
- assertEquals("Updated", forms.get(0).getInputs().get(0).getValue());
- assertNull(forms.get(0).getInputs().get(1).getValue());
- forms = job.getConnectorPart(Direction.TO).getForms();
- assertEquals(2, forms.size());
- assertEquals("Updated", forms.get(0).getInputs().get(0).getValue());
- assertNull(forms.get(0).getInputs().get(1).getValue());
-
- forms = retrieved.getFrameworkPart().getForms();
- assertEquals(2, forms.size());
- assertEquals("Updated", forms.get(0).getInputs().get(0).getValue());
- assertNotNull(forms.get(0).getInputs().get(1).getValue());
- assertEquals(((Map)forms.get(0).getInputs().get(1).getValue()).size(), 0);
+ configs = job.getJobConfig(Direction.FROM).getConfigs();
+ assertEquals(2, configs.size());
+ assertEquals("Updated", configs.get(0).getInputs().get(0).getValue());
+ assertNull(configs.get(0).getInputs().get(1).getValue());
+ configs = job.getJobConfig(Direction.TO).getConfigs();
+ assertEquals(2, configs.size());
+ assertEquals("Updated", configs.get(0).getInputs().get(0).getValue());
+ assertNull(configs.get(0).getInputs().get(1).getValue());
+
+ configs = retrieved.getDriverConfig().getConfigs();
+ assertEquals(2, configs.size());
+ assertEquals("Updated", configs.get(0).getInputs().get(0).getValue());
+ assertNotNull(configs.get(0).getInputs().get(1).getValue());
+ assertEquals(((Map)configs.get(0).getInputs().get(1).getValue()).size(), 0);
}
@Test
@@ -248,16 +250,16 @@ public class TestJobHandling extends DerbyTestCase {
loadJobs();
// disable job 1
- handler.enableJob(1, false, getDerbyDatabaseConnection());
+ handler.enableJob(1, false, derbyConnection);
- MJob retrieved = handler.findJob(1, getDerbyDatabaseConnection());
+ MJob retrieved = handler.findJob(1, derbyConnection);
assertNotNull(retrieved);
assertEquals(false, retrieved.getEnabled());
// enable job 1
- handler.enableJob(1, true, getDerbyDatabaseConnection());
+ handler.enableJob(1, true, derbyConnection);
- retrieved = handler.findJob(1, getDerbyDatabaseConnection());
+ retrieved = handler.findJob(1, derbyConnection);
assertNotNull(retrieved);
assertEquals(true, retrieved.getEnabled());
}
@@ -266,28 +268,28 @@ public class TestJobHandling extends DerbyTestCase {
public void testDeleteJob() throws Exception {
loadJobs();
- handler.deleteJob(1, getDerbyDatabaseConnection());
+ handler.deleteJob(1, derbyConnection);
assertCountForTable("SQOOP.SQ_JOB", 3);
assertCountForTable("SQOOP.SQ_JOB_INPUT", 18);
- handler.deleteJob(2, getDerbyDatabaseConnection());
+ handler.deleteJob(2, derbyConnection);
assertCountForTable("SQOOP.SQ_JOB", 2);
assertCountForTable("SQOOP.SQ_JOB_INPUT", 12);
- handler.deleteJob(3, getDerbyDatabaseConnection());
+ handler.deleteJob(3, derbyConnection);
assertCountForTable("SQOOP.SQ_JOB", 1);
assertCountForTable("SQOOP.SQ_JOB_INPUT", 6);
- handler.deleteJob(4, getDerbyDatabaseConnection());
+ handler.deleteJob(4, derbyConnection);
assertCountForTable("SQOOP.SQ_JOB", 0);
assertCountForTable("SQOOP.SQ_JOB_INPUT", 0);
}
public MJob getJob() {
return new MJob(1, 1, 1, 1,
- handler.findConnector("A", getDerbyDatabaseConnection()).getJobForms(Direction.FROM),
- handler.findConnector("A", getDerbyDatabaseConnection()).getJobForms(Direction.TO),
- handler.findDriverConfig(getDerbyDatabaseConnection()).getJobForms()
+ handler.findConnector("A", derbyConnection).getFromConfig(),
+ handler.findConnector("A", derbyConnection).getToConfig(),
+ handler.findDriver(derbyConnection).getDriverConfig()
);
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestLinkHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestLinkHandling.java b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestLinkHandling.java
index 8dd1ce2..38e632a 100644
--- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestLinkHandling.java
+++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestLinkHandling.java
@@ -17,9 +17,11 @@
*/
package org.apache.sqoop.repository.derby;
+import java.util.List;
+
import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.model.MConfig;
import org.apache.sqoop.model.MLink;
-import org.apache.sqoop.model.MForm;
import org.apache.sqoop.model.MMapInput;
import org.apache.sqoop.model.MStringInput;
import org.junit.Before;
@@ -48,7 +50,7 @@ public class TestLinkHandling extends DerbyTestCase {
createSchema();
// We always needs connector and framework structures in place
- loadConnectorAndDriverConfig();
+ loadConnectorLinkConfig();
}
@Test
@@ -64,26 +66,19 @@ public class TestLinkHandling extends DerbyTestCase {
// Load prepared connections into database
loadLinks();
- MLink connA = handler.findLink(1, getDerbyDatabaseConnection());
- assertNotNull(connA);
- assertEquals(1, connA.getPersistenceId());
- assertEquals("CA", connA.getName());
-
- List<MForm> forms;
-
- // Check connector part
- forms = connA.getConnectorPart().getForms();
- assertEquals("Value1", forms.get(0).getInputs().get(0).getValue());
- assertNull(forms.get(0).getInputs().get(1).getValue());
- assertEquals("Value3", forms.get(1).getInputs().get(0).getValue());
- assertNull(forms.get(1).getInputs().get(1).getValue());
-
- // Check framework part
- forms = connA.getFrameworkPart().getForms();
- assertEquals("Value13", forms.get(0).getInputs().get(0).getValue());
- assertNull(forms.get(0).getInputs().get(1).getValue());
- assertEquals("Value15", forms.get(1).getInputs().get(0).getValue());
- assertNull(forms.get(1).getInputs().get(1).getValue());
+ MLink linkA = handler.findLink(1, getDerbyDatabaseConnection());
+ assertNotNull(linkA);
+ assertEquals(1, linkA.getPersistenceId());
+ assertEquals("CA", linkA.getName());
+
+ List<MConfig> configs;
+
+ // Check connector link config
+ configs = linkA.getConnectorLinkConfig().getConfigs();
+ assertEquals("Value1", configs.get(0).getInputs().get(0).getValue());
+ assertNull(configs.get(0).getInputs().get(1).getValue());
+ assertEquals("Value3", configs.get(1).getInputs().get(0).getValue());
+ assertNull(configs.get(1).getInputs().get(1).getValue());
}
@Test
@@ -128,24 +123,18 @@ public class TestLinkHandling extends DerbyTestCase {
handler.createLink(link, getDerbyDatabaseConnection());
assertEquals(1, link.getPersistenceId());
- assertCountForTable("SQOOP.SQ_CONNECTION", 1);
- assertCountForTable("SQOOP.SQ_CONNECTION_INPUT", 4);
+ assertCountForTable("SQOOP.SQ_LINK", 1);
+ assertCountForTable("SQOOP.SQ_LINK_INPUT", 2);
MLink retrieved = handler.findLink(1, getDerbyDatabaseConnection());
assertEquals(1, retrieved.getPersistenceId());
- List<MForm> forms;
- forms = link.getConnectorPart().getForms();
- assertEquals("Value1", forms.get(0).getInputs().get(0).getValue());
- assertNull(forms.get(0).getInputs().get(1).getValue());
- assertEquals("Value2", forms.get(1).getInputs().get(0).getValue());
- assertNull(forms.get(1).getInputs().get(1).getValue());
-
- forms = link.getFrameworkPart().getForms();
- assertEquals("Value13", forms.get(0).getInputs().get(0).getValue());
- assertNull(forms.get(0).getInputs().get(1).getValue());
- assertEquals("Value15", forms.get(1).getInputs().get(0).getValue());
- assertNull(forms.get(1).getInputs().get(1).getValue());
+ List<MConfig> configs;
+ configs = link.getConnectorLinkConfig().getConfigs();
+ assertEquals("Value1", configs.get(0).getInputs().get(0).getValue());
+ assertNull(configs.get(0).getInputs().get(1).getValue());
+ assertEquals("Value2", configs.get(1).getInputs().get(0).getValue());
+ assertNull(configs.get(1).getInputs().get(1).getValue());
// Let's create second link
link = getLink();
@@ -154,8 +143,8 @@ public class TestLinkHandling extends DerbyTestCase {
handler.createLink(link, getDerbyDatabaseConnection());
assertEquals(2, link.getPersistenceId());
- assertCountForTable("SQOOP.SQ_CONNECTION", 2);
- assertCountForTable("SQOOP.SQ_CONNECTION_INPUT", 8);
+ assertCountForTable("SQOOP.SQ_LINK", 2);
+ assertCountForTable("SQOOP.SQ_LINK_INPUT", 4);
}
@Test
@@ -175,44 +164,30 @@ public class TestLinkHandling extends DerbyTestCase {
MLink link = handler.findLink(1, getDerbyDatabaseConnection());
- List<MForm> forms;
-
- forms = link.getConnectorPart().getForms();
- ((MStringInput)forms.get(0).getInputs().get(0)).setValue("Updated");
- ((MMapInput)forms.get(0).getInputs().get(1)).setValue(null);
- ((MStringInput)forms.get(1).getInputs().get(0)).setValue("Updated");
- ((MMapInput)forms.get(1).getInputs().get(1)).setValue(null);
+ List<MConfig> configs;
- forms = link.getFrameworkPart().getForms();
- ((MStringInput)forms.get(0).getInputs().get(0)).setValue("Updated");
- ((MMapInput)forms.get(0).getInputs().get(1)).setValue(new HashMap<String, String>()); // inject new map value
- ((MStringInput)forms.get(1).getInputs().get(0)).setValue("Updated");
- ((MMapInput)forms.get(1).getInputs().get(1)).setValue(new HashMap<String, String>()); // inject new map value
+ configs = link.getConnectorLinkConfig().getConfigs();
+ ((MStringInput)configs.get(0).getInputs().get(0)).setValue("Updated");
+ ((MMapInput)configs.get(0).getInputs().get(1)).setValue(null);
+ ((MStringInput)configs.get(1).getInputs().get(0)).setValue("Updated");
+ ((MMapInput)configs.get(1).getInputs().get(1)).setValue(null);
link.setName("name");
handler.updateLink(link, getDerbyDatabaseConnection());
assertEquals(1, link.getPersistenceId());
- assertCountForTable("SQOOP.SQ_CONNECTION", 2);
- assertCountForTable("SQOOP.SQ_CONNECTION_INPUT", 10);
+ assertCountForTable("SQOOP.SQ_LINK", 2);
+ assertCountForTable("SQOOP.SQ_LINK_INPUT", 6);
MLink retrieved = handler.findLink(1, getDerbyDatabaseConnection());
assertEquals("name", link.getName());
- forms = retrieved.getConnectorPart().getForms();
- assertEquals("Updated", forms.get(0).getInputs().get(0).getValue());
- assertNull(forms.get(0).getInputs().get(1).getValue());
- assertEquals("Updated", forms.get(1).getInputs().get(0).getValue());
- assertNull(forms.get(1).getInputs().get(1).getValue());
-
- forms = retrieved.getFrameworkPart().getForms();
- assertEquals("Updated", forms.get(0).getInputs().get(0).getValue());
- assertNotNull(forms.get(0).getInputs().get(1).getValue());
- assertEquals(((Map)forms.get(0).getInputs().get(1).getValue()).size(), 0);
- assertEquals("Updated", forms.get(1).getInputs().get(0).getValue());
- assertNotNull(forms.get(1).getInputs().get(1).getValue());
- assertEquals(((Map)forms.get(1).getInputs().get(1).getValue()).size(), 0);
+ configs = retrieved.getConnectorLinkConfig().getConfigs();
+ assertEquals("Updated", configs.get(0).getInputs().get(0).getValue());
+ assertNull(configs.get(0).getInputs().get(1).getValue());
+ assertEquals("Updated", configs.get(1).getInputs().get(0).getValue());
+ assertNull(configs.get(1).getInputs().get(1).getValue());
}
@Test
@@ -239,18 +214,15 @@ public class TestLinkHandling extends DerbyTestCase {
loadLinks();
handler.deleteLink(1, getDerbyDatabaseConnection());
- assertCountForTable("SQOOP.SQ_CONNECTION", 1);
- assertCountForTable("SQOOP.SQ_CONNECTION_INPUT", 4);
+ assertCountForTable("SQOOP.SQ_LINK", 1);
+ assertCountForTable("SQOOP.SQ_LINK_INPUT", 4);
handler.deleteLink(2, getDerbyDatabaseConnection());
- assertCountForTable("SQOOP.SQ_CONNECTION", 0);
- assertCountForTable("SQOOP.SQ_CONNECTION_INPUT", 0);
+ assertCountForTable("SQOOP.SQ_LINK", 0);
+ assertCountForTable("SQOOP.SQ_LINK_INPUT", 0);
}
public MLink getLink() {
- return new MLink(1,
- handler.findConnector("A", getDerbyDatabaseConnection()).getConnectionForms(),
- handler.findDriverConfig(getDerbyDatabaseConnection()).getConnectionForms()
- );
+ return new MLink(1, handler.findConnector("A", getDerbyDatabaseConnection()).getLinkConfig());
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestSubmissionHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestSubmissionHandling.java b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestSubmissionHandling.java
index cf0944d..8402d8c 100644
--- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestSubmissionHandling.java
+++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestSubmissionHandling.java
@@ -48,7 +48,7 @@ public class TestSubmissionHandling extends DerbyTestCase {
createSchema();
// We always needs connector and framework structures in place
- loadConnectorAndDriverConfig();
+ loadConnectorLinkConfig();
// We also always needs connection metadata in place
loadLinks();
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/server/src/main/java/org/apache/sqoop/handler/ConnectorRequestHandler.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/handler/ConnectorRequestHandler.java b/server/src/main/java/org/apache/sqoop/handler/ConnectorRequestHandler.java
index d1b6b9a..7109ae5 100644
--- a/server/src/main/java/org/apache/sqoop/handler/ConnectorRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/ConnectorRequestHandler.java
@@ -87,7 +87,7 @@ public class ConnectorRequestHandler implements RequestHandler {
connectors = new LinkedList<MConnector>();
bundles = new HashMap<Long, ResourceBundle>();
- connectors.add(ConnectorManager.getInstance().getConnectorMetadata(id));
+ connectors.add(ConnectorManager.getInstance().getConnectorConfig(id));
bundles.put(id, ConnectorManager.getInstance().getResourceBundle(id, locale));
AuditLoggerManager.getInstance()
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/server/src/main/java/org/apache/sqoop/handler/DriverConfigRequestHandler.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/handler/DriverConfigRequestHandler.java b/server/src/main/java/org/apache/sqoop/handler/DriverConfigRequestHandler.java
index c0d363e..aa773a9 100644
--- a/server/src/main/java/org/apache/sqoop/handler/DriverConfigRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/DriverConfigRequestHandler.java
@@ -20,7 +20,7 @@ package org.apache.sqoop.handler;
import org.apache.log4j.Logger;
import org.apache.sqoop.audit.AuditLoggerManager;
import org.apache.sqoop.driver.Driver;
-import org.apache.sqoop.json.DriverConfigBean;
+import org.apache.sqoop.json.DriverBean;
import org.apache.sqoop.json.JsonBean;
import org.apache.sqoop.server.RequestContext;
import org.apache.sqoop.server.RequestHandler;
@@ -40,11 +40,10 @@ public class DriverConfigRequestHandler implements RequestHandler {
@Override
public JsonBean handleEvent(RequestContext ctx) {
- AuditLoggerManager.getInstance()
- .logAuditEvent(ctx.getUserName(), ctx.getRequest().getRemoteAddr(),
- "get", "framework", "");
+ AuditLoggerManager.getInstance().logAuditEvent(ctx.getUserName(),
+ ctx.getRequest().getRemoteAddr(), "get", "driverConfig", "");
- return new DriverConfigBean(Driver.getInstance().getDriverConfig(),
- Driver.getInstance().getBundle(ctx.getAcceptLanguageHeader()));
+ return new DriverBean(Driver.getInstance().getDriver(), Driver.getInstance()
+ .getBundle(ctx.getAcceptLanguageHeader()));
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java b/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
index b61d3f5..462579c 100644
--- a/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
@@ -17,6 +17,10 @@
*/
package org.apache.sqoop.handler;
+import java.io.IOException;
+import java.util.List;
+import java.util.Locale;
+
import org.apache.log4j.Logger;
import org.apache.sqoop.audit.AuditLoggerManager;
import org.apache.sqoop.common.Direction;
@@ -27,25 +31,24 @@ import org.apache.sqoop.driver.Driver;
import org.apache.sqoop.json.JobBean;
import org.apache.sqoop.json.JsonBean;
import org.apache.sqoop.json.ValidationResultBean;
-import org.apache.sqoop.model.FormUtils;
+import org.apache.sqoop.json.util.ConfigSerialization;
+import org.apache.sqoop.model.ConfigUtils;
+import org.apache.sqoop.model.MDriverConfig;
+import org.apache.sqoop.model.MFromConfig;
import org.apache.sqoop.model.MJob;
-import org.apache.sqoop.model.MJobForms;
+import org.apache.sqoop.model.MToConfig;
import org.apache.sqoop.repository.Repository;
import org.apache.sqoop.repository.RepositoryManager;
import org.apache.sqoop.server.RequestContext;
import org.apache.sqoop.server.RequestHandler;
import org.apache.sqoop.server.common.ServerError;
import org.apache.sqoop.utils.ClassUtils;
+import org.apache.sqoop.validation.ConfigValidationResult;
+import org.apache.sqoop.validation.ConfigValidationRunner;
import org.apache.sqoop.validation.Status;
-import org.apache.sqoop.validation.ValidationResult;
-import org.apache.sqoop.validation.ValidationRunner;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
-import java.io.IOException;
-import java.util.List;
-import java.util.Locale;
-
/**
* Job request handler is supporting following resources:
*
@@ -109,7 +112,7 @@ public class JobRequestHandler implements RequestHandler {
}
/**
- * Delete job from metadata repository.
+ * Delete job from repository.
*
* @param ctx Context object
* @return Empty bean
@@ -129,18 +132,14 @@ public class JobRequestHandler implements RequestHandler {
}
/**
- * Update or create job metadata in repository.
+ * Update or create job in repository.
*
* @param ctx Context object
* @return Validation bean object
*/
private JsonBean createUpdateJob(RequestContext ctx, boolean update) {
-// Check that given ID equals with sent ID, otherwise report an error UPDATE
-// String sxid = ctx.getLastURLElement();
-// long xid = Long.valueOf(sxid);
String username = ctx.getUserName();
-
JobBean bean = new JobBean();
try {
@@ -157,30 +156,29 @@ public class JobRequestHandler implements RequestHandler {
if(jobs.size() != 1) {
throw new SqoopException(ServerError.SERVER_0003,
- "Expected one job metadata but got " + jobs.size());
+ "Expected one job but got " + jobs.size());
}
// Job object
MJob job = jobs.get(0);
// Verify that user is not trying to spoof us
- MJobForms fromConnectorForms = ConnectorManager.getInstance()
- .getConnectorMetadata(job.getConnectorId(Direction.FROM))
- .getJobForms(Direction.FROM);
- MJobForms toConnectorForms = ConnectorManager.getInstance()
- .getConnectorMetadata(job.getConnectorId(Direction.TO))
- .getJobForms(Direction.TO);
- MJobForms frameworkForms = Driver.getInstance().getDriverConfig()
- .getJobForms();
-
- if(!fromConnectorForms.equals(job.getConnectorPart(Direction.FROM))
- || !frameworkForms.equals(job.getFrameworkPart())
- || !toConnectorForms.equals(job.getConnectorPart(Direction.TO))) {
+ MFromConfig fromConfig = ConnectorManager.getInstance()
+ .getConnectorConfig(job.getConnectorId(Direction.FROM))
+ .getFromConfig();
+ MToConfig toConfig = ConnectorManager.getInstance()
+ .getConnectorConfig(job.getConnectorId(Direction.TO))
+ .getToConfig();
+ MDriverConfig driverConfig = Driver.getInstance().getDriver().getDriverConfig();
+
+ if(!fromConfig.equals(job.getJobConfig(Direction.FROM))
+ || !driverConfig.equals(job.getDriverConfig())
+ || !toConfig.equals(job.getJobConfig(Direction.TO))) {
throw new SqoopException(ServerError.SERVER_0003,
- "Detected incorrect form structure");
+ "Detected incorrect config structure");
}
- // Responsible connector for this session
+ // Corresponding connectors for this
SqoopConnector fromConnector = ConnectorManager.getInstance().getConnector(job.getConnectorId(Direction.FROM));
SqoopConnector toConnector = ConnectorManager.getInstance().getConnector(job.getConnectorId(Direction.TO));
@@ -194,25 +192,27 @@ public class JobRequestHandler implements RequestHandler {
+ " does not support TO direction.");
}
- // We need translate forms to configuration objects
- Object fromConnectorConfig = ClassUtils.instantiate(fromConnector.getJobConfigurationClass(Direction.FROM));
- Object frameworkConfig = ClassUtils.instantiate(Driver.getInstance().getJobConfigurationClass());
- Object toConnectorConfig = ClassUtils.instantiate(toConnector.getJobConfigurationClass(Direction.TO));
+ // We need translate configs
+ Object fromConfigObject = ClassUtils.instantiate(fromConnector.getJobConfigurationClass(Direction.FROM));
+ Object toConfigObject = ClassUtils.instantiate(toConnector.getJobConfigurationClass(Direction.TO));
+
+ Object driverConfigObject = ClassUtils.instantiate(Driver.getInstance().getDriverConfigurationGroupClass());
+
+ ConfigUtils.fromConfigs(job.getJobConfig(Direction.FROM).getConfigs(), fromConfigObject);
+ ConfigUtils.fromConfigs(job.getJobConfig(Direction.TO).getConfigs(), toConfigObject);
+ ConfigUtils.fromConfigs(job.getDriverConfig().getConfigs(), driverConfigObject);
- FormUtils.fromForms(job.getConnectorPart(Direction.FROM).getForms(), fromConnectorConfig);
- FormUtils.fromForms(job.getFrameworkPart().getForms(), frameworkConfig);
- FormUtils.fromForms(job.getConnectorPart(Direction.TO).getForms(), toConnectorConfig);
+ // Validate all configs
+ ConfigValidationRunner validationRunner = new ConfigValidationRunner();
+ ConfigValidationResult fromConfigvalidator = validationRunner.validate(fromConfigObject);
+ ConfigValidationResult toConfigValidator = validationRunner.validate(toConfigObject);
+ ConfigValidationResult driverConfigValidator = validationRunner.validate(driverConfigObject);
- // Validate all parts
- ValidationRunner validationRunner = new ValidationRunner();
- ValidationResult fromConnectorValidation = validationRunner.validate(fromConnectorConfig);
- ValidationResult frameworkValidation = validationRunner.validate(frameworkConfig);
- ValidationResult toConnectorValidation = validationRunner.validate(toConnectorConfig);
- Status finalStatus = Status.getWorstStatus(fromConnectorValidation.getStatus(), frameworkValidation.getStatus(), toConnectorValidation.getStatus());
+ Status finalStatus = Status.getWorstStatus(fromConfigvalidator.getStatus(), toConfigValidator.getStatus(), driverConfigValidator.getStatus());
// Return back validations in all cases
- ValidationResultBean outputBean = new ValidationResultBean(fromConnectorValidation, frameworkValidation, toConnectorValidation);
+ ValidationResultBean validationResultBean = new ValidationResultBean(fromConfigvalidator, toConfigValidator);
// If we're good enough let's perform the action
if(finalStatus.canProceed()) {
@@ -227,7 +227,7 @@ public class JobRequestHandler implements RequestHandler {
job.setCreationUser(username);
job.setLastUpdateUser(username);
RepositoryManager.getInstance().getRepository().createJob(job);
- outputBean.setId(job.getPersistenceId());
+ validationResultBean.setId(job.getPersistenceId());
AuditLoggerManager.getInstance()
.logAuditEvent(ctx.getUserName(), ctx.getRequest().getRemoteAddr(),
@@ -236,7 +236,7 @@ public class JobRequestHandler implements RequestHandler {
}
- return outputBean;
+ return validationResultBean;
}
private JsonBean getJobs(RequestContext ctx) {
@@ -250,7 +250,7 @@ public class JobRequestHandler implements RequestHandler {
Locale locale = ctx.getAcceptLanguageHeader();
Repository repository = RepositoryManager.getInstance().getRepository();
- if (sjid.equals("all")) {
+ if (sjid.equals(ConfigSerialization.ALL)) {
List<MJob> jobs = repository.findJobs();
bean = new JobBean(jobs);
@@ -269,11 +269,8 @@ public class JobRequestHandler implements RequestHandler {
MJob job = repository.findJob(jid);
// @TODO(Abe): From/To
-
long connectorId = job.getConnectorId(Direction.FROM);
-
bean = new JobBean(job);
-
bean.addConnectorConfigBundle(connectorId,
ConnectorManager.getInstance().getResourceBundle(connectorId, locale));
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java b/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java
index 23fc9f1..80e65b8 100644
--- a/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java
@@ -17,18 +17,21 @@
*/
package org.apache.sqoop.handler;
+import java.io.IOException;
+import java.util.List;
+import java.util.Locale;
+
import org.apache.log4j.Logger;
import org.apache.sqoop.audit.AuditLoggerManager;
import org.apache.sqoop.common.SqoopException;
import org.apache.sqoop.connector.ConnectorManager;
import org.apache.sqoop.connector.spi.SqoopConnector;
-import org.apache.sqoop.driver.Driver;
-import org.apache.sqoop.json.LinkBean;
import org.apache.sqoop.json.JsonBean;
+import org.apache.sqoop.json.LinkBean;
import org.apache.sqoop.json.ValidationResultBean;
-import org.apache.sqoop.model.FormUtils;
+import org.apache.sqoop.model.ConfigUtils;
import org.apache.sqoop.model.MLink;
-import org.apache.sqoop.model.MConnectionForms;
+import org.apache.sqoop.model.MLinkConfig;
import org.apache.sqoop.repository.Repository;
import org.apache.sqoop.repository.RepositoryManager;
import org.apache.sqoop.server.RequestContext;
@@ -36,41 +39,37 @@ import org.apache.sqoop.server.RequestHandler;
import org.apache.sqoop.server.common.ServerError;
import org.apache.sqoop.utils.ClassUtils;
import org.apache.sqoop.validation.Status;
-import org.apache.sqoop.validation.ValidationResult;
-import org.apache.sqoop.validation.ValidationRunner;
+import org.apache.sqoop.validation.ConfigValidationResult;
+import org.apache.sqoop.validation.ConfigValidationRunner;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
-import java.io.IOException;
-import java.util.List;
-import java.util.Locale;
-
/**
* Connection request handler is supporting following resources:
*
- * GET /v1/connection/:xid
- * Return details about one particular connection with id :xid or about all of
+ * GET /v1/link/:xid
+ * Return details about one particular link with id :xid or about all of
* them if :xid equals to "all".
*
- * POST /v1/connection
- * Create new connection
+ * POST /v1/link
+ * Create new link
*
- * PUT /v1/connection/:xid
- * Update connection with id :xid.
+ * PUT /v1/link/:xid
+ * Update link with id :xid.
*
- * PUT /v1/connection/:xid/enable
- * Enable connection with id :xid
+ * PUT /v1/link/:xid/enable
+ * Enable link with id :xid
*
- * PUT /v1/connection/:xid/disable
- * Disable connection with id :xid
+ * PUT /v1/link/:xid/disable
+ * Disable link with id :xid
*
- * DELETE /v1/connection/:xid
- * Remove connection with id :xid
+ * DELETE /v1/link/:xid
+ * Remove link with id :xid
*
* Planned resources:
*
- * GET /v1/connection
- * Get brief list of all connections present in the system.
+ * GET /v1/link
+ * Get brief list of all links present in the system.
*
*/
public class LinkRequestHandler implements RequestHandler {
@@ -89,37 +88,37 @@ public class LinkRequestHandler implements RequestHandler {
public JsonBean handleEvent(RequestContext ctx) {
switch (ctx.getMethod()) {
case GET:
- return getConnections(ctx);
+ return getLink(ctx);
case POST:
- return createUpdateConnection(ctx, false);
+ return createUpdateLink(ctx, false);
case PUT:
if (ctx.getLastURLElement().equals(ENABLE)) {
- return enableConnection(ctx, true);
+ return enableLink(ctx, true);
} else if (ctx.getLastURLElement().equals(DISABLE)) {
- return enableConnection(ctx, false);
+ return enableLink(ctx, false);
} else {
- return createUpdateConnection(ctx, true);
+ return createUpdateLink(ctx, true);
}
case DELETE:
- return deleteConnection(ctx);
+ return deleteLink(ctx);
}
return null;
}
/**
- * Delete connection from metadata repository.
+ * Delete link from thes repository.
*
* @param ctx Context object
* @return Empty bean
*/
- private JsonBean deleteConnection(RequestContext ctx) {
+ private JsonBean deleteLink(RequestContext ctx) {
String sxid = ctx.getLastURLElement();
long xid = Long.valueOf(sxid);
AuditLoggerManager.getInstance()
.logAuditEvent(ctx.getUserName(), ctx.getRequest().getRemoteAddr(),
- "delete", "connection", sxid);
+ "delete", "link", sxid);
Repository repository = RepositoryManager.getInstance().getRepository();
repository.deleteLink(xid);
@@ -128,20 +127,15 @@ public class LinkRequestHandler implements RequestHandler {
}
/**
- * Update or create connection metadata in repository.
+ * Update or create link in repository.
*
* @param ctx Context object
* @return Validation bean object
*/
- private JsonBean createUpdateConnection(RequestContext ctx, boolean update) {
-// Check that given ID equals with sent ID, otherwise report an error UPDATE
-// String sxid = ctx.getLastURLElement();
-// long xid = Long.valueOf(sxid);
+ private JsonBean createUpdateLink(RequestContext ctx, boolean update) {
String username = ctx.getUserName();
-
LinkBean bean = new LinkBean();
-
try {
JSONObject json =
(JSONObject) JSONValue.parse(ctx.getRequest().getReader());
@@ -152,93 +146,86 @@ public class LinkRequestHandler implements RequestHandler {
"Can't read request content", e);
}
- // Get connection object
- List<MLink> connections = bean.getLinks();
+ // Get link object
+ List<MLink> links = bean.getLinks();
- if(connections.size() != 1) {
+ if(links.size() != 1) {
throw new SqoopException(ServerError.SERVER_0003,
- "Expected one connection metadata but got " + connections.size());
+ "Expected one link but got " + links.size());
}
- MLink connection = connections.get(0);
+ MLink link = links.get(0);
// Verify that user is not trying to spoof us
- MConnectionForms connectorForms =
- ConnectorManager.getInstance().getConnectorMetadata(connection.getConnectorId())
- .getConnectionForms();
- MConnectionForms frameworkForms = Driver.getInstance().getDriverConfig()
- .getConnectionForms();
-
- if(!connectorForms.equals(connection.getConnectorPart())
- || !frameworkForms.equals(connection.getFrameworkPart())) {
+ MLinkConfig linkConfig =
+ ConnectorManager.getInstance().getConnectorConfig(link.getConnectorId())
+ .getLinkConfig();
+ if(!linkConfig.equals(link.getConnectorLinkConfig())) {
throw new SqoopException(ServerError.SERVER_0003,
- "Detected incorrect form structure");
+ "Detected incorrect config structure");
}
// Responsible connector for this session
- SqoopConnector connector = ConnectorManager.getInstance().getConnector(connection.getConnectorId());
+ SqoopConnector connector = ConnectorManager.getInstance().getConnector(link.getConnectorId());
- // We need translate forms to configuration objects
- Object connectorConfig = ClassUtils.instantiate(connector.getLinkConfigurationClass());
- Object frameworkConfig = ClassUtils.instantiate(Driver.getInstance().getLinkConfigurationClass());
+ // We need translate configs
+ Object connectorLinkConfig = ClassUtils.instantiate(connector.getLinkConfigurationClass());
- FormUtils.fromForms(connection.getConnectorPart().getForms(), connectorConfig);
- FormUtils.fromForms(connection.getFrameworkPart().getForms(), frameworkConfig);
+ ConfigUtils.fromConfigs(link.getConnectorLinkConfig().getConfigs(), connectorLinkConfig);
// Validate both parts
- ValidationRunner validationRunner = new ValidationRunner();
- ValidationResult connectorValidation = validationRunner.validate(connectorConfig);
- ValidationResult frameworkValidation = validationRunner.validate(frameworkConfig);
+ ConfigValidationRunner validationRunner = new ConfigValidationRunner();
+ ConfigValidationResult connectorLinkValidation = validationRunner.validate(connectorLinkConfig);
- Status finalStatus = Status.getWorstStatus(connectorValidation.getStatus(), frameworkValidation.getStatus());
+ Status finalStatus = Status.getWorstStatus(connectorLinkValidation.getStatus());
// Return back validations in all cases
- ValidationResultBean outputBean = new ValidationResultBean(connectorValidation, frameworkValidation);
+ ValidationResultBean outputBean = new ValidationResultBean(connectorLinkValidation);
// If we're good enough let's perform the action
if(finalStatus.canProceed()) {
if(update) {
AuditLoggerManager.getInstance()
.logAuditEvent(ctx.getUserName(), ctx.getRequest().getRemoteAddr(),
- "update", "connection", String.valueOf(connection.getPersistenceId()));
+ "update", "link", String.valueOf(link.getPersistenceId()));
- connection.setLastUpdateUser(username);
- RepositoryManager.getInstance().getRepository().updateLink(connection);
+ link.setLastUpdateUser(username);
+ RepositoryManager.getInstance().getRepository().updateLink(link);
} else {
- connection.setCreationUser(username);
- connection.setLastUpdateUser(username);
- RepositoryManager.getInstance().getRepository().createLink(connection);
- outputBean.setId(connection.getPersistenceId());
+ link.setCreationUser(username);
+ link.setLastUpdateUser(username);
+ RepositoryManager.getInstance().getRepository().createLink(link);
+ outputBean.setId(link.getPersistenceId());
AuditLoggerManager.getInstance()
.logAuditEvent(ctx.getUserName(), ctx.getRequest().getRemoteAddr(),
- "create", "connection", String.valueOf(connection.getPersistenceId()));
+ "create", "link", String.valueOf(link.getPersistenceId()));
}
}
return outputBean;
}
- private JsonBean getConnections(RequestContext ctx) {
+ private JsonBean getLink(RequestContext ctx) {
String sxid = ctx.getLastURLElement();
LinkBean bean;
AuditLoggerManager.getInstance()
.logAuditEvent(ctx.getUserName(), ctx.getRequest().getRemoteAddr(),
- "get", "connection", sxid);
+ "get", "link", sxid);
Locale locale = ctx.getAcceptLanguageHeader();
Repository repository = RepositoryManager.getInstance().getRepository();
if (sxid.equals("all")) {
- List<MLink> connections = repository.findLinks();
- bean = new LinkBean(connections);
+ List<MLink> links = repository.findLinks();
+ bean = new LinkBean(links);
// Add associated resources into the bean
- for( MLink connection : connections) {
- long connectorId = connection.getConnectorId();
- if(!bean.hasConnectorBundle(connectorId)) {
+ for( MLink link : links) {
+ long connectorId = link.getConnectorId();
+ if(!bean.hasConnectorConfigBundle(connectorId)) {
bean.addConnectorConfigBundle(connectorId,
ConnectorManager.getInstance().getResourceBundle(connectorId, locale));
}
@@ -246,21 +233,18 @@ public class LinkRequestHandler implements RequestHandler {
} else {
long xid = Long.valueOf(sxid);
- MLink connection = repository.findLink(xid);
- long connectorId = connection.getConnectorId();
+ MLink link = repository.findLink(xid);
+ long connectorId = link.getConnectorId();
- bean = new LinkBean(connection);
+ bean = new LinkBean(link);
bean.addConnectorConfigBundle(connectorId,
ConnectorManager.getInstance().getResourceBundle(connectorId, locale));
}
-
- // Sent framework resource bundle in all cases
- bean.setDriverConfigBundle(Driver.getInstance().getBundle(locale));
return bean;
}
- private JsonBean enableConnection(RequestContext ctx, boolean enabled) {
+ private JsonBean enableLink(RequestContext ctx, boolean enabled) {
String[] elements = ctx.getUrlElements();
String sLinkId = elements[elements.length - 2];
long linkId = Long.valueOf(sLinkId);
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/shell/src/main/java/org/apache/sqoop/shell/CloneJobFunction.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/CloneJobFunction.java b/shell/src/main/java/org/apache/sqoop/shell/CloneJobFunction.java
index 97d8e6f..8188831 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/CloneJobFunction.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/CloneJobFunction.java
@@ -24,8 +24,8 @@ import org.apache.sqoop.common.Direction;
import org.apache.sqoop.model.MJob;
import org.apache.sqoop.model.MPersistableEntity;
import org.apache.sqoop.shell.core.Constants;
-import org.apache.sqoop.shell.utils.FormOptions;
-import org.apache.sqoop.shell.utils.JobDynamicFormOptions;
+import org.apache.sqoop.shell.utils.ConfigOptions;
+import org.apache.sqoop.shell.utils.JobDynamicConfigOptions;
import org.apache.sqoop.validation.Status;
import java.io.IOException;
@@ -33,7 +33,7 @@ import java.util.List;
import java.util.ResourceBundle;
import static org.apache.sqoop.shell.ShellEnvironment.*;
-import static org.apache.sqoop.shell.utils.FormFiller.*;
+import static org.apache.sqoop.shell.utils.ConfigFiller.*;
/**
*
@@ -63,11 +63,11 @@ public class CloneJobFunction extends SqoopFunction {
MJob job = client.getJob(jobId);
job.setPersistenceId(MPersistableEntity.PERSISTANCE_ID_DEFAULT);
- ResourceBundle fromConnectorBundle = client.getConnectorConfigResourceBundle(
+ ResourceBundle fromConnectorBundle = client.getConnectorConfigBundle(
job.getConnectorId(Direction.FROM));
- ResourceBundle driverConfigBundle = client.getDriverConfigBundle();
- ResourceBundle toConnectorBundle = client.getConnectorConfigResourceBundle(
+ ResourceBundle toConnectorBundle = client.getConnectorConfigBundle(
job.getConnectorId(Direction.TO));
+ ResourceBundle driverConfigBundle = client.getDriverConfigBundle();
Status status = Status.FINE;
@@ -84,7 +84,7 @@ public class CloneJobFunction extends SqoopFunction {
}
// Fill in data from user
- if(!fillJob(reader, job, fromConnectorBundle, driverConfigBundle, toConnectorBundle)) {
+ if(!fillJobWithBundle(reader, job, fromConnectorBundle, toConnectorBundle, driverConfigBundle)) {
return null;
}
@@ -92,9 +92,9 @@ public class CloneJobFunction extends SqoopFunction {
status = client.saveJob(job);
} while(!status.canProceed());
} else {
- JobDynamicFormOptions options = new JobDynamicFormOptions();
+ JobDynamicConfigOptions options = new JobDynamicConfigOptions();
options.prepareOptions(job);
- CommandLine line = FormOptions.parseOptions(options, 0, args, false);
+ CommandLine line = ConfigOptions.parseOptions(options, 0, args, false);
if (fillJob(line, job)) {
status = client.saveJob(job);
if (!status.canProceed()) {
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/shell/src/main/java/org/apache/sqoop/shell/CloneLinkFunction.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/CloneLinkFunction.java b/shell/src/main/java/org/apache/sqoop/shell/CloneLinkFunction.java
index d9babe0..c1a4f55 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/CloneLinkFunction.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/CloneLinkFunction.java
@@ -23,8 +23,8 @@ import org.apache.commons.cli.OptionBuilder;
import org.apache.sqoop.model.MLink;
import org.apache.sqoop.model.MPersistableEntity;
import org.apache.sqoop.shell.core.Constants;
-import org.apache.sqoop.shell.utils.LinkDynamicFormOptions;
-import org.apache.sqoop.shell.utils.FormOptions;
+import org.apache.sqoop.shell.utils.LinkDynamicConfigOptions;
+import org.apache.sqoop.shell.utils.ConfigOptions;
import org.apache.sqoop.validation.Status;
import java.io.IOException;
@@ -32,7 +32,7 @@ import java.util.List;
import java.util.ResourceBundle;
import static org.apache.sqoop.shell.ShellEnvironment.*;
-import static org.apache.sqoop.shell.utils.FormFiller.*;
+import static org.apache.sqoop.shell.utils.ConfigFiller.*;
/**
*
@@ -67,8 +67,7 @@ public class CloneLinkFunction extends SqoopFunction {
Status status = Status.FINE;
- ResourceBundle connectorConfigBundle = client.getConnectorConfigResourceBundle(connection.getConnectorId());
- ResourceBundle driverConfigBundle = client.getDriverConfigBundle();
+ ResourceBundle linkConfigBundle = client.getConnectorConfigBundle(connection.getConnectorId());
if (isInteractive) {
printlnResource(Constants.RES_PROMPT_UPDATE_LINK_CONFIG);
@@ -80,17 +79,17 @@ public class CloneLinkFunction extends SqoopFunction {
}
// Fill in data from user
- if(!fillLink(reader, connection, connectorConfigBundle, driverConfigBundle)) {
+ if(!fillLinkWithBundle(reader, connection, linkConfigBundle)) {
return null;
}
status = client.saveLink(connection);
} while(!status.canProceed());
} else {
- LinkDynamicFormOptions options = new LinkDynamicFormOptions();
+ LinkDynamicConfigOptions options = new LinkDynamicConfigOptions();
options.prepareOptions(connection);
- CommandLine line = FormOptions.parseOptions(options, 0, args, false);
- if (fillConnection(line, connection)) {
+ CommandLine line = ConfigOptions.parseOptions(options, 0, args, false);
+ if (fillLink(line, connection)) {
status = client.saveLink(connection);
if (!status.canProceed()) {
printLinkValidationMessages(connection);
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/shell/src/main/java/org/apache/sqoop/shell/CreateJobFunction.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/CreateJobFunction.java b/shell/src/main/java/org/apache/sqoop/shell/CreateJobFunction.java
index ccfed31..0d3d2b5 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/CreateJobFunction.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/CreateJobFunction.java
@@ -23,9 +23,9 @@ import org.apache.commons.cli.OptionBuilder;
import org.apache.sqoop.common.Direction;
import org.apache.sqoop.model.MJob;
import org.apache.sqoop.shell.core.Constants;
-import org.apache.sqoop.shell.utils.FormDisplayer;
-import org.apache.sqoop.shell.utils.FormOptions;
-import org.apache.sqoop.shell.utils.JobDynamicFormOptions;
+import org.apache.sqoop.shell.utils.ConfigDisplayer;
+import org.apache.sqoop.shell.utils.ConfigOptions;
+import org.apache.sqoop.shell.utils.JobDynamicConfigOptions;
import org.apache.sqoop.validation.Status;
import java.io.IOException;
@@ -33,7 +33,7 @@ import java.util.List;
import java.util.ResourceBundle;
import static org.apache.sqoop.shell.ShellEnvironment.*;
-import static org.apache.sqoop.shell.utils.FormFiller.*;
+import static org.apache.sqoop.shell.utils.ConfigFiller.*;
/**
* Handles creation of new job objects.
@@ -67,16 +67,16 @@ public class CreateJobFunction extends SqoopFunction {
isInteractive);
}
- private Status createJob(Long fromConnectionId, Long toConnectionId, List<String> args, boolean isInteractive) throws IOException {
- printlnResource(Constants.RES_CREATE_CREATING_JOB, fromConnectionId, toConnectionId);
+ private Status createJob(Long fromLinkId, Long toLinkId, List<String> args, boolean isInteractive) throws IOException {
+ printlnResource(Constants.RES_CREATE_CREATING_JOB, fromLinkId, toLinkId);
ConsoleReader reader = new ConsoleReader();
- MJob job = client.createJob(fromConnectionId, toConnectionId);
+ MJob job = client.createJob(fromLinkId, toLinkId);
// @TODO(Abe): From/To.
- ResourceBundle fromConnectorBundle = client.getConnectorConfigResourceBundle(
+ ResourceBundle fromConfigBundle = client.getConnectorConfigBundle(
job.getConnectorId(Direction.FROM));
- ResourceBundle toConnectorBundle = client.getConnectorConfigResourceBundle(
+ ResourceBundle toConfigBundle = client.getConnectorConfigBundle(
job.getConnectorId(Direction.TO));
ResourceBundle driverConfigBundle = client.getDriverConfigBundle();
@@ -92,7 +92,7 @@ public class CreateJobFunction extends SqoopFunction {
}
// Fill in data from user
- if(!fillJob(reader, job, fromConnectorBundle, driverConfigBundle, toConnectorBundle)) {
+ if(!fillJobWithBundle(reader, job, fromConfigBundle, toConfigBundle, driverConfigBundle)) {
return null;
}
@@ -100,9 +100,9 @@ public class CreateJobFunction extends SqoopFunction {
status = client.saveJob(job);
} while(!status.canProceed());
} else {
- JobDynamicFormOptions options = new JobDynamicFormOptions();
+ JobDynamicConfigOptions options = new JobDynamicConfigOptions();
options.prepareOptions(job);
- CommandLine line = FormOptions.parseOptions(options, 0, args, false);
+ CommandLine line = ConfigOptions.parseOptions(options, 0, args, false);
if (fillJob(line, job)) {
status = client.saveJob(job);
if (!status.canProceed()) {
@@ -115,7 +115,7 @@ public class CreateJobFunction extends SqoopFunction {
}
}
- FormDisplayer.displayFormWarning(job);
+ ConfigDisplayer.displayConfigWarning(job);
printlnResource(Constants.RES_CREATE_JOB_SUCCESSFUL, status.name(), job.getPersistenceId());
return status;
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/shell/src/main/java/org/apache/sqoop/shell/CreateLinkFunction.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/CreateLinkFunction.java b/shell/src/main/java/org/apache/sqoop/shell/CreateLinkFunction.java
index 33d60c8..ce9988f 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/CreateLinkFunction.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/CreateLinkFunction.java
@@ -22,9 +22,9 @@ import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.OptionBuilder;
import org.apache.sqoop.model.MLink;
import org.apache.sqoop.shell.core.Constants;
-import org.apache.sqoop.shell.utils.LinkDynamicFormOptions;
-import org.apache.sqoop.shell.utils.FormDisplayer;
-import org.apache.sqoop.shell.utils.FormOptions;
+import org.apache.sqoop.shell.utils.LinkDynamicConfigOptions;
+import org.apache.sqoop.shell.utils.ConfigDisplayer;
+import org.apache.sqoop.shell.utils.ConfigOptions;
import org.apache.sqoop.validation.Status;
import java.io.IOException;
@@ -32,7 +32,7 @@ import java.util.List;
import java.util.ResourceBundle;
import static org.apache.sqoop.shell.ShellEnvironment.*;
-import static org.apache.sqoop.shell.utils.FormFiller.*;
+import static org.apache.sqoop.shell.utils.ConfigFiller.*;
/**
*
@@ -62,11 +62,9 @@ public class CreateLinkFunction extends SqoopFunction {
MLink link = client.createLink(connectorId);
- ResourceBundle connectorConfigBundle = client.getConnectorConfigResourceBundle(connectorId);
- ResourceBundle driverConfigBundle = client.getDriverConfigBundle();
+ ResourceBundle connectorConfigBundle = client.getConnectorConfigBundle(connectorId);
Status status = Status.FINE;
-
if (isInteractive) {
printlnResource(Constants.RES_PROMPT_FILL_LINK_CONFIG);
@@ -77,7 +75,7 @@ public class CreateLinkFunction extends SqoopFunction {
}
// Fill in data from user
- if(!fillLink(reader, link, connectorConfigBundle, driverConfigBundle)) {
+ if(!fillLinkWithBundle(reader, link, connectorConfigBundle)) {
return null;
}
@@ -85,10 +83,10 @@ public class CreateLinkFunction extends SqoopFunction {
status = client.saveLink(link);
} while(!status.canProceed());
} else {
- LinkDynamicFormOptions options = new LinkDynamicFormOptions();
+ LinkDynamicConfigOptions options = new LinkDynamicConfigOptions();
options.prepareOptions(link);
- CommandLine line = FormOptions.parseOptions(options, 0, args, false);
- if (fillConnection(line, link)) {
+ CommandLine line = ConfigOptions.parseOptions(options, 0, args, false);
+ if (fillLink(line, link)) {
status = client.saveLink(link);
if (!status.canProceed()) {
printLinkValidationMessages(link);
@@ -100,7 +98,7 @@ public class CreateLinkFunction extends SqoopFunction {
}
}
- FormDisplayer.displayFormWarning(link);
+ ConfigDisplayer.displayConfigWarning(link);
printlnResource(Constants.RES_CREATE_LINK_SUCCESSFUL, status.name(), link.getPersistenceId());
return status;
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/shell/src/main/java/org/apache/sqoop/shell/ShowCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/ShowCommand.java b/shell/src/main/java/org/apache/sqoop/shell/ShowCommand.java
index 28bc752..329b4d6 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/ShowCommand.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/ShowCommand.java
@@ -31,7 +31,7 @@ public class ShowCommand extends SqoopCommand {
.put(Constants.FN_SERVER, ShowServerFunction.class)
.put(Constants.FN_VERSION, ShowVersionFunction.class)
.put(Constants.FN_CONNECTOR, ShowConnectorFunction.class)
- .put(Constants.FN_DRIVER_CONFIG, ShowDriverConfigFunction.class)
+ .put(Constants.FN_DRIVER_CONFIG, ShowDriverFunction.class)
.put(Constants.FN_LINK, ShowLinkFunction.class)
.put(Constants.FN_JOB, ShowJobFunction.class)
.put(Constants.FN_SUBMISSION, ShowSubmissionFunction.class)
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/shell/src/main/java/org/apache/sqoop/shell/ShowConnectorFunction.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/ShowConnectorFunction.java b/shell/src/main/java/org/apache/sqoop/shell/ShowConnectorFunction.java
index 2ba75b4..09fb195 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/ShowConnectorFunction.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/ShowConnectorFunction.java
@@ -31,7 +31,7 @@ import org.apache.sqoop.shell.utils.TableDisplayer;
import org.apache.sqoop.validation.Status;
import static org.apache.sqoop.shell.ShellEnvironment.*;
-import static org.apache.sqoop.shell.utils.FormDisplayer.*;
+import static org.apache.sqoop.shell.utils.ConfigDisplayer.*;
@SuppressWarnings("serial")
public class ShowConnectorFunction extends SqoopFunction {
@@ -115,7 +115,7 @@ public class ShowConnectorFunction extends SqoopFunction {
connector.getVersion(),
getSupportedDirections(connector)
);
- displayFormMetadataDetails(connector, client.getConnectorConfigResourceBundle(connector.getPersistenceId()));
+ displayConnectorConfigDetails(connector, client.getConnectorConfigBundle(connector.getPersistenceId()));
}
/**
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/shell/src/main/java/org/apache/sqoop/shell/ShowDriverConfigFunction.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/ShowDriverConfigFunction.java b/shell/src/main/java/org/apache/sqoop/shell/ShowDriverConfigFunction.java
deleted file mode 100644
index e6e1004..0000000
--- a/shell/src/main/java/org/apache/sqoop/shell/ShowDriverConfigFunction.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.shell;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.sqoop.model.MDriverConfig;
-import org.apache.sqoop.shell.core.Constants;
-import org.apache.sqoop.validation.Status;
-
-import java.util.ResourceBundle;
-
-import static org.apache.sqoop.shell.ShellEnvironment.*;
-import static org.apache.sqoop.shell.utils.FormDisplayer.*;
-
-/**
- *
- */
-@SuppressWarnings("serial")
-public class ShowDriverConfigFunction extends SqoopFunction {
- public ShowDriverConfigFunction() {
- }
-
- @Override
- public boolean validateArgs(CommandLine line) {
- if (line.getArgs().length != 0) {
- printlnResource(Constants.RES_SHOW_DRIVER_CONFIG_USAGE);
- return false;
- }
- return true;
- }
-
- @Override
- public Object executeFunction(CommandLine line, boolean isInteractive) {
- showFramework();
- return Status.FINE;
- }
-
- private void showFramework() {
- MDriverConfig framework = client.getDriverConfig();
- ResourceBundle bundle = client.getDriverConfigBundle();
-
- printlnResource(Constants.RES_SHOW_PROMPT_DRIVER_CONFIG_OPTS, framework.getPersistenceId());
- displayFormMetadataDetails(framework, bundle);
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/shell/src/main/java/org/apache/sqoop/shell/ShowDriverFunction.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/ShowDriverFunction.java b/shell/src/main/java/org/apache/sqoop/shell/ShowDriverFunction.java
new file mode 100644
index 0000000..080792b
--- /dev/null
+++ b/shell/src/main/java/org/apache/sqoop/shell/ShowDriverFunction.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.shell;
+
+import static org.apache.sqoop.shell.ShellEnvironment.client;
+import static org.apache.sqoop.shell.ShellEnvironment.printlnResource;
+import static org.apache.sqoop.shell.utils.ConfigDisplayer.displayDriverConfigDetails;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.sqoop.shell.core.Constants;
+import org.apache.sqoop.validation.Status;
+
+/**
+ *
+ */
+@SuppressWarnings("serial")
+public class ShowDriverFunction extends SqoopFunction {
+ public ShowDriverFunction() {
+ }
+
+ @Override
+ public boolean validateArgs(CommandLine line) {
+ if (line.getArgs().length != 0) {
+ printlnResource(Constants.RES_SHOW_DRIVER_CONFIG_USAGE);
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public Object executeFunction(CommandLine line, boolean isInteractive) {
+ showDriver();
+ return Status.FINE;
+ }
+
+ private void showDriver() {
+ printlnResource(Constants.RES_SHOW_PROMPT_DRIVER_CONFIG_OPTS, client.getDriver().getPersistenceId());
+ displayDriverConfigDetails(client.getDriverConfig(), client.getDriverConfigBundle());
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/shell/src/main/java/org/apache/sqoop/shell/ShowJobFunction.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/ShowJobFunction.java b/shell/src/main/java/org/apache/sqoop/shell/ShowJobFunction.java
index e3f1f47..0640283 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/ShowJobFunction.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/ShowJobFunction.java
@@ -30,7 +30,7 @@ import java.util.LinkedList;
import java.util.List;
import static org.apache.sqoop.shell.ShellEnvironment.*;
-import static org.apache.sqoop.shell.utils.FormDisplayer.*;
+import static org.apache.sqoop.shell.utils.ConfigDisplayer.*;
/**
*
@@ -124,12 +124,11 @@ public class ShowJobFunction extends SqoopFunction {
job.getLinkId(Direction.FROM),
job.getConnectorId(Direction.FROM));
- // Display connector part
- displayForms(job.getConnectorPart(Direction.FROM).getForms(),
- client.getConnectorConfigResourceBundle(job.getConnectorId(Direction.FROM)));
- displayForms(job.getFrameworkPart().getForms(),
+ displayConfig(job.getJobConfig(Direction.FROM).getConfigs(),
+ client.getConnectorConfigBundle(job.getConnectorId(Direction.FROM)));
+ displayConfig(job.getDriverConfig().getConfigs(),
client.getDriverConfigBundle());
- displayForms(job.getConnectorPart(Direction.TO).getForms(),
- client.getConnectorConfigResourceBundle(job.getConnectorId(Direction.TO)));
+ displayConfig(job.getJobConfig(Direction.TO).getConfigs(),
+ client.getConnectorConfigBundle(job.getConnectorId(Direction.TO)));
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/shell/src/main/java/org/apache/sqoop/shell/ShowLinkFunction.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/ShowLinkFunction.java b/shell/src/main/java/org/apache/sqoop/shell/ShowLinkFunction.java
index f500b9e..f4eae33 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/ShowLinkFunction.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/ShowLinkFunction.java
@@ -29,7 +29,7 @@ import java.util.LinkedList;
import java.util.List;
import static org.apache.sqoop.shell.ShellEnvironment.*;
-import static org.apache.sqoop.shell.utils.FormDisplayer.*;
+import static org.apache.sqoop.shell.utils.ConfigDisplayer.*;
/**
*
@@ -103,26 +103,24 @@ public class ShowLinkFunction extends SqoopFunction {
displayLink(link);
}
- private void displayLink(MLink connection) {
+ private void displayLink(MLink link) {
DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
printlnResource(Constants.RES_SHOW_PROMPT_LINK_INFO,
- connection.getPersistenceId(),
- connection.getName(),
- connection.getEnabled(),
- connection.getCreationUser(),
- formatter.format(connection.getCreationDate()),
- connection.getLastUpdateUser(),
- formatter.format(connection.getLastUpdateDate())
+ link.getPersistenceId(),
+ link.getName(),
+ link.getEnabled(),
+ link.getCreationUser(),
+ formatter.format(link.getCreationDate()),
+ link.getLastUpdateUser(),
+ formatter.format(link.getLastUpdateDate())
);
- long connectorId = connection.getConnectorId();
+ long connectorId = link.getConnectorId();
printlnResource(Constants.RES_SHOW_PROMPT_LINK_CID_INFO, connectorId);
- // Display connector part
- displayForms(connection.getConnectorPart().getForms(),
- client.getConnectorConfigResourceBundle(connectorId));
- displayForms(connection.getFrameworkPart().getForms(),
- client.getDriverConfigBundle());
+ // Display link config
+ displayConfig(link.getConnectorLinkConfig().getConfigs(),
+ client.getConnectorConfigBundle(connectorId));
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/shell/src/main/java/org/apache/sqoop/shell/SqoopFunction.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/SqoopFunction.java b/shell/src/main/java/org/apache/sqoop/shell/SqoopFunction.java
index 5d69c2a..0845d8e 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/SqoopFunction.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/SqoopFunction.java
@@ -25,7 +25,7 @@ import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.sqoop.common.SqoopException;
import org.apache.sqoop.shell.core.ShellError;
-import org.apache.sqoop.shell.utils.FormOptions;
+import org.apache.sqoop.shell.utils.ConfigOptions;
import static org.apache.sqoop.shell.ShellEnvironment.*;
@@ -44,7 +44,7 @@ abstract public class SqoopFunction extends Options {
}
public Object execute(List<String> args) {
- CommandLine line = FormOptions.parseOptions(this, 1, args, true);
+ CommandLine line = ConfigOptions.parseOptions(this, 1, args, true);
try {
if (validateArgs(line)) {
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/shell/src/main/java/org/apache/sqoop/shell/UpdateJobFunction.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/UpdateJobFunction.java b/shell/src/main/java/org/apache/sqoop/shell/UpdateJobFunction.java
index 96d1fd8..dd075d7 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/UpdateJobFunction.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/UpdateJobFunction.java
@@ -23,9 +23,9 @@ import org.apache.commons.cli.OptionBuilder;
import org.apache.sqoop.common.Direction;
import org.apache.sqoop.model.MJob;
import org.apache.sqoop.shell.core.Constants;
-import org.apache.sqoop.shell.utils.FormDisplayer;
-import org.apache.sqoop.shell.utils.FormOptions;
-import org.apache.sqoop.shell.utils.JobDynamicFormOptions;
+import org.apache.sqoop.shell.utils.ConfigDisplayer;
+import org.apache.sqoop.shell.utils.ConfigOptions;
+import org.apache.sqoop.shell.utils.JobDynamicConfigOptions;
import org.apache.sqoop.validation.Status;
import java.io.IOException;
@@ -33,7 +33,7 @@ import java.util.List;
import java.util.ResourceBundle;
import static org.apache.sqoop.shell.ShellEnvironment.*;
-import static org.apache.sqoop.shell.utils.FormFiller.*;
+import static org.apache.sqoop.shell.utils.ConfigFiller.*;
/**
*
@@ -57,18 +57,19 @@ public class UpdateJobFunction extends SqoopFunction {
}
private Status updateJob(Long jobId, List<String> args, boolean isInteractive) throws IOException {
- printlnResource(Constants.RES_UPDATE_UPDATING_JOB, jobId);
+ printlnResource(Constants.RES_SQOOP_UPDATING_JOB, jobId);
ConsoleReader reader = new ConsoleReader();
MJob job = client.getJob(jobId);
- ResourceBundle fromConnectorBundle = client.getConnectorConfigResourceBundle(
+ ResourceBundle fromConnectorBundle = client.getConnectorConfigBundle(
job.getConnectorId(Direction.FROM));
- ResourceBundle driverConfigBundle = client.getDriverConfigBundle();
- ResourceBundle toConnectorBundle = client.getConnectorConfigResourceBundle(
+ ResourceBundle toConnectorBundle = client.getConnectorConfigBundle(
job.getConnectorId(Direction.TO));
+ ResourceBundle driverConfigBundle = client.getDriverConfigBundle();
+
Status status = Status.FINE;
if (isInteractive) {
@@ -81,7 +82,7 @@ public class UpdateJobFunction extends SqoopFunction {
}
// Fill in data from user
- if(!fillJob(reader, job, fromConnectorBundle, driverConfigBundle, toConnectorBundle)) {
+ if(!fillJobWithBundle(reader, job, fromConnectorBundle, toConnectorBundle, driverConfigBundle)) {
return status;
}
@@ -89,9 +90,9 @@ public class UpdateJobFunction extends SqoopFunction {
status = client.updateJob(job);
} while(!status.canProceed());
} else {
- JobDynamicFormOptions options = new JobDynamicFormOptions();
+ JobDynamicConfigOptions options = new JobDynamicConfigOptions();
options.prepareOptions(job);
- CommandLine line = FormOptions.parseOptions(options, 0, args, false);
+ CommandLine line = ConfigOptions.parseOptions(options, 0, args, false);
if (fillJob(line, job)) {
status = client.updateJob(job);
if (!status.canProceed()) {
@@ -104,7 +105,7 @@ public class UpdateJobFunction extends SqoopFunction {
}
}
- FormDisplayer.displayFormWarning(job);
+ ConfigDisplayer.displayConfigWarning(job);
printlnResource(Constants.RES_UPDATE_JOB_SUCCESSFUL, status.name());
return status;
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/shell/src/main/java/org/apache/sqoop/shell/UpdateLinkFunction.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/UpdateLinkFunction.java b/shell/src/main/java/org/apache/sqoop/shell/UpdateLinkFunction.java
index 30bb63e..d5ead38 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/UpdateLinkFunction.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/UpdateLinkFunction.java
@@ -22,9 +22,9 @@ import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.OptionBuilder;
import org.apache.sqoop.model.MLink;
import org.apache.sqoop.shell.core.Constants;
-import org.apache.sqoop.shell.utils.LinkDynamicFormOptions;
-import org.apache.sqoop.shell.utils.FormDisplayer;
-import org.apache.sqoop.shell.utils.FormOptions;
+import org.apache.sqoop.shell.utils.LinkDynamicConfigOptions;
+import org.apache.sqoop.shell.utils.ConfigDisplayer;
+import org.apache.sqoop.shell.utils.ConfigOptions;
import org.apache.sqoop.validation.Status;
import java.io.IOException;
@@ -32,7 +32,7 @@ import java.util.List;
import java.util.ResourceBundle;
import static org.apache.sqoop.shell.ShellEnvironment.*;
-import static org.apache.sqoop.shell.utils.FormFiller.*;
+import static org.apache.sqoop.shell.utils.ConfigFiller.*;
/**
*
@@ -56,14 +56,13 @@ public class UpdateLinkFunction extends SqoopFunction {
}
private Status updateLink(Long linkId, List<String> args, boolean isInteractive) throws IOException {
- printlnResource(Constants.RES_UPDATE_UPDATING_LINK, linkId);
+ printlnResource(Constants.RES_SQOOP_UPDATING_LINK, linkId);
ConsoleReader reader = new ConsoleReader();
MLink link = client.getLink(linkId);
- ResourceBundle connectorConfigBundle = client.getConnectorConfigResourceBundle(link.getConnectorId());
- ResourceBundle driverConfigBundle = client.getDriverConfigBundle();
+ ResourceBundle connectorLinkConfigBundle = client.getConnectorConfigBundle(link.getConnectorId());
Status status = Status.FINE;
@@ -77,7 +76,7 @@ public class UpdateLinkFunction extends SqoopFunction {
}
// Fill in data from user
- if(!fillLink(reader, link, connectorConfigBundle, driverConfigBundle)) {
+ if(!fillLinkWithBundle(reader, link, connectorLinkConfigBundle)) {
return null;
}
@@ -85,10 +84,10 @@ public class UpdateLinkFunction extends SqoopFunction {
status = client.updateLink(link);
} while(!status.canProceed());
} else {
- LinkDynamicFormOptions options = new LinkDynamicFormOptions();
+ LinkDynamicConfigOptions options = new LinkDynamicConfigOptions();
options.prepareOptions(link);
- CommandLine line = FormOptions.parseOptions(options, 0, args, false);
- if (fillConnection(line, link)) {
+ CommandLine line = ConfigOptions.parseOptions(options, 0, args, false);
+ if (fillLink(line, link)) {
status = client.updateLink(link);
if (!status.canProceed()) {
printLinkValidationMessages(link);
@@ -99,7 +98,7 @@ public class UpdateLinkFunction extends SqoopFunction {
return null;
}
}
- FormDisplayer.displayFormWarning(link);
+ ConfigDisplayer.displayConfigWarning(link);
printlnResource(Constants.RES_UPDATE_LINK_SUCCESSFUL, status.name());
return status;
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/shell/src/main/java/org/apache/sqoop/shell/core/Constants.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/core/Constants.java b/shell/src/main/java/org/apache/sqoop/shell/core/Constants.java
index 4d3838c..a1bc5d5 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/core/Constants.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/core/Constants.java
@@ -1,7 +1,7 @@
/**
* 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
+ * distributed with this work for additional inconfigation
* 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
@@ -316,11 +316,11 @@ public class Constants {
public static final String RES_SQOOP_PROMPT_SHELL_LOADEDRC =
"sqoop.prompt_shell_loadedrc";
- public static final String RES_UPDATE_UPDATING_LINK =
+ public static final String RES_SQOOP_UPDATING_LINK =
"update.link";
public static final String RES_UPDATE_LINK_SUCCESSFUL =
"update.link_successful";
- public static final String RES_UPDATE_UPDATING_JOB =
+ public static final String RES_SQOOP_UPDATING_JOB =
"update.job";
public static final String RES_UPDATE_JOB_SUCCESSFUL =
"update.job_successful";
@@ -352,35 +352,35 @@ public class Constants {
public static final String RES_TABLE_HEADER_ENABLED =
"table.header.enabled";
- public static final String RES_FORMDISPLAYER_CONNECTION =
- "formdisplayer.link";
- public static final String RES_FORMDISPLAYER_JOB =
- "formdisplayer.job";
- public static final String RES_FORMDISPLAYER_FORM =
- "formdisplayer.form";
- public static final String RES_FORMDISPLAYER_NAME =
- "formdisplayer.name";
- public static final String RES_FORMDISPLAYER_LABEL =
- "formdisplayer.label";
- public static final String RES_FORMDISPLAYER_HELP =
- "formdisplayer.help";
- public static final String RES_FORMDISPLAYER_INPUT =
- "formdisplayer.input";
- public static final String RES_FORMDISPLAYER_TYPE =
- "formdisplayer.type";
- public static final String RES_FORMDISPLAYER_SENSITIVE =
- "formdisplayer.sensitive";
- public static final String RES_FORMDISPLAYER_SIZE =
- "formdisplayer.size";
- public static final String RES_FORMDISPLAYER_POSSIBLE_VALUES =
- "formdisplayer.possible_values";
- public static final String RES_FORMDISPLAYER_UNSUPPORTED_DATATYPE =
- "formdisplayer.unsupported_datatype";
- public static final String RES_FORMDISPLAYER_INPUT_SENSITIVE =
- "formdisplayer.input_sensitive";
-
- public static final String RES_FORMDISPLAYER_FORM_WARNING =
- "formdisplayer.warning_message";
+ public static final String RES_CONFIG_DISPLAYER_LINK =
+ "config.displayer.link";
+ public static final String RES_CONFIG_DISPLAYER_JOB =
+ "config.displayer.job";
+ public static final String RES_CONFIG_DISPLAYER_CONFIG =
+ "config.displayer.config";
+ public static final String RES_CONFIG_DISPLAYER_NAME =
+ "config.displayer.name";
+ public static final String RES_CONFIG_DISPLAYER_LABEL =
+ "config.displayer.label";
+ public static final String RES_CONFIG_DISPLAYER_HELP =
+ "config.displayer.help";
+ public static final String RES_CONFIG_DISPLAYER_INPUT =
+ "config.displayer.input";
+ public static final String RES_CONFIG_DISPLAYER_TYPE =
+ "config.displayer.type";
+ public static final String RES_CONFIG_DISPLAYER_SENSITIVE =
+ "config.displayer.sensitive";
+ public static final String RES_CONFIG_DISPLAYER_SIZE =
+ "config.displayer.size";
+ public static final String RES_CONFIG_DISPLAYER_POSSIBLE_VALUES =
+ "config.displayer.possible_values";
+ public static final String RES_CONFIG_DISPLAYER_UNSUPPORTED_DATATYPE =
+ "config.displayer.unsupported_datatype";
+ public static final String RES_CONFIG_DISPLAYER_INPUT_SENSITIVE =
+ "config.displayer.input_sensitive";
+
+ public static final String RES_CONFIG_DISPLAYER_FORM_WARNING =
+ "config.displayer.warning_message";
public static final String RES_SUBMISSION_SUBMISSION_DETAIL =
"submission.submission_detail";
[05/13] SQOOP-1498: Sqoop2: Repository Object refactoring (objects
prefixed with M)
Posted by ab...@apache.org.
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
index 5dd7970..39702ca 100644
--- a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
+++ b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
@@ -28,31 +28,38 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.sql.Types;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
-import org.apache.log4j.Logger;
import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
import org.apache.sqoop.common.Direction;
import org.apache.sqoop.common.DirectionError;
import org.apache.sqoop.common.SqoopException;
import org.apache.sqoop.connector.ConnectorHandler;
import org.apache.sqoop.connector.ConnectorManagerUtils;
import org.apache.sqoop.model.MBooleanInput;
-import org.apache.sqoop.model.MLink;
-import org.apache.sqoop.model.MConnectionForms;
-import org.apache.sqoop.model.MEnumInput;
-import org.apache.sqoop.model.MIntegerInput;
-import org.apache.sqoop.model.MJob;
-import org.apache.sqoop.model.MJobForms;
+import org.apache.sqoop.model.MConfig;
+import org.apache.sqoop.model.MConfigType;
import org.apache.sqoop.model.MConnector;
-import org.apache.sqoop.model.MForm;
-import org.apache.sqoop.model.MFormType;
+import org.apache.sqoop.model.MDriver;
import org.apache.sqoop.model.MDriverConfig;
+import org.apache.sqoop.model.MEnumInput;
+import org.apache.sqoop.model.MFromConfig;
import org.apache.sqoop.model.MInput;
import org.apache.sqoop.model.MInputType;
+import org.apache.sqoop.model.MIntegerInput;
+import org.apache.sqoop.model.MJob;
+import org.apache.sqoop.model.MLink;
+import org.apache.sqoop.model.MLinkConfig;
import org.apache.sqoop.model.MMapInput;
import org.apache.sqoop.model.MStringInput;
import org.apache.sqoop.model.MSubmission;
+import org.apache.sqoop.model.MToConfig;
import org.apache.sqoop.repository.JdbcRepositoryContext;
import org.apache.sqoop.repository.JdbcRepositoryHandler;
import org.apache.sqoop.submission.SubmissionStatus;
@@ -93,74 +100,69 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
mc.getUniqueName());
}
mc.setPersistenceId(getConnectorId(mc, conn));
- insertFormsForConnector(mc, conn);
+ insertConfigsForConnector(mc, conn);
}
/**
- * Helper method to insert the forms from the into the
- * repository. The job and connector forms within <code>mc</code> will get
- * updated with the id of the forms when this function returns.
- * @param mDriverConfig The MFramework instance to use to upgrade.
- * @param conn JDBC link to use for updating the forms
+ * Helper method to insert the configs from the into the
+ * repository.
+ * @param mDriver The driver instance to use to upgrade.
+ * @param conn JDBC link to use for updating the configs
*/
- private void insertFormsForFramework(MDriverConfig mDriverConfig, Connection conn) {
- PreparedStatement baseFormStmt = null;
+ private void insertConfigsForDriver(MDriver mDriver, Connection conn) {
+ PreparedStatement baseConfigStmt = null;
PreparedStatement baseInputStmt = null;
try{
- baseFormStmt = conn.prepareStatement(STMT_INSERT_FORM_BASE,
+ baseConfigStmt = conn.prepareStatement(STMT_INSERT_CONFIG_BASE,
Statement.RETURN_GENERATED_KEYS);
baseInputStmt = conn.prepareStatement(STMT_INSERT_INPUT_BASE,
Statement.RETURN_GENERATED_KEYS);
- // Register connector forms
- registerForms(null, null, mDriverConfig.getConnectionForms().getForms(),
- MFormType.CONNECTION.name(), baseFormStmt, baseInputStmt);
-
- // Register job forms
- registerForms(null, null, mDriverConfig.getJobForms().getForms(),
- MFormType.JOB.name(), baseFormStmt, baseInputStmt);
+ // Register the job config type, since driver config is per job
+ registerConfigs(null, null, mDriver.getDriverConfig().getConfigs(),
+ MConfigType.JOB.name(), baseConfigStmt, baseInputStmt);
} catch (SQLException ex) {
- throw new SqoopException(DerbyRepoError.DERBYREPO_0014, mDriverConfig.toString(), ex);
+ throw new SqoopException(DerbyRepoError.DERBYREPO_0014, mDriver.toString(), ex);
} finally {
- closeStatements(baseFormStmt, baseInputStmt);
+ closeStatements(baseConfigStmt, baseInputStmt);
}
}
/**
- * Helper method to insert the forms from the MConnector into the
- * repository. The job and connector forms within <code>mc</code> will get
- * updated with the id of the forms when this function returns.
- * @param mc The connector to use for updating forms
- * @param conn JDBC link to use for updating the forms
+ * Helper method to insert the configs from the MConnector into the
+ * repository. The job and connector configs within <code>mc</code> will get
+ * updated with the id of the configs when this function returns.
+ * @param mc The connector to use for updating configs
+ * @param conn JDBC link to use for updating the configs
*/
- private void insertFormsForConnector (MConnector mc, Connection conn) {
+ private void insertConfigsForConnector (MConnector mc, Connection conn) {
long connectorId = mc.getPersistenceId();
- PreparedStatement baseFormStmt = null;
+ PreparedStatement baseConfigStmt = null;
PreparedStatement baseInputStmt = null;
try{
- baseFormStmt = conn.prepareStatement(STMT_INSERT_FORM_BASE,
+ baseConfigStmt = conn.prepareStatement(STMT_INSERT_CONFIG_BASE,
Statement.RETURN_GENERATED_KEYS);
baseInputStmt = conn.prepareStatement(STMT_INSERT_INPUT_BASE,
Statement.RETURN_GENERATED_KEYS);
- // Register connector forms
- registerForms(connectorId, null, mc.getConnectionForms().getForms(),
- MFormType.CONNECTION.name(), baseFormStmt, baseInputStmt);
+ // Register link type config
+ registerConfigs(connectorId, null, mc.getLinkConfig().getConfigs(),
+ MConfigType.LINK.name(), baseConfigStmt, baseInputStmt);
- // Register all jobs
- registerForms(connectorId, Direction.FROM, mc.getJobForms(Direction.FROM).getForms(),
- MFormType.JOB.name(), baseFormStmt, baseInputStmt);
- registerForms(connectorId, Direction.TO, mc.getJobForms(Direction.TO).getForms(),
- MFormType.JOB.name(), baseFormStmt, baseInputStmt);
+ // Register both from/to job type config
+ registerConfigs(connectorId, Direction.FROM, mc.getConfig(Direction.FROM).getConfigs(),
+ MConfigType.JOB.name(), baseConfigStmt, baseInputStmt);
+ registerConfigs(connectorId, Direction.TO, mc.getConfig(Direction.TO).getConfigs(),
+ MConfigType.JOB.name(), baseConfigStmt, baseInputStmt);
} catch (SQLException ex) {
throw new SqoopException(DerbyRepoError.DERBYREPO_0014,
mc.toString(), ex);
} finally {
- closeStatements(baseFormStmt, baseInputStmt);
+ closeStatements(baseConfigStmt, baseInputStmt);
}
}
@@ -239,7 +241,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
}
} else {
LOG.warn("Even though embedded Derby driver was loaded, the connect "
- + "URL is of an unexpected form: " + connectUrl + ". Therefore no "
+ + "URL is of an unexpected config: " + connectUrl + ". Therefore no "
+ "attempt will be made to shutdown embedded Derby instance.");
}
}
@@ -335,9 +337,9 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
/**
* Create or update driver version
* @param conn Connection to the the repository
- * @param mDriverConfig
+ * @param mDriver
*/
- private void createOrUpdateDriverVersion(Connection conn, MDriverConfig mDriverConfig) {
+ private void createOrUpdateDriverSystemVersion(Connection conn, String version) {
ResultSet rs = null;
PreparedStatement stmt = null;
try {
@@ -348,7 +350,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
stmt = conn.prepareStatement(STMT_INSERT_SYSTEM);
stmt.setString(1, DerbyRepoConstants.SYSKEY_DRIVER_VERSION);
- stmt.setString(2, mDriverConfig.getVersion());
+ stmt.setString(2, version);
stmt.executeUpdate();
} catch (SQLException e) {
logException(e);
@@ -369,11 +371,11 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
if(version <= 0) {
runQuery(QUERY_CREATE_SCHEMA_SQOOP, conn);
runQuery(QUERY_CREATE_TABLE_SQ_CONNECTOR, conn);
- runQuery(QUERY_CREATE_TABLE_SQ_FORM, conn);
+ runQuery(QUERY_CREATE_TABLE_SQ_CONFIG, conn);
runQuery(QUERY_CREATE_TABLE_SQ_INPUT, conn);
- runQuery(QUERY_CREATE_TABLE_SQ_CONNECTION, conn);
+ runQuery(QUERY_CREATE_TABLE_SQ_LINK, conn);
runQuery(QUERY_CREATE_TABLE_SQ_JOB, conn);
- runQuery(QUERY_CREATE_TABLE_SQ_CONNECTION_INPUT, conn);
+ runQuery(QUERY_CREATE_TABLE_SQ_LINK_INPUT, conn);
runQuery(QUERY_CREATE_TABLE_SQ_JOB_INPUT, conn);
runQuery(QUERY_CREATE_TABLE_SQ_SUBMISSION, conn);
runQuery(QUERY_CREATE_TABLE_SQ_COUNTER_GROUP, conn);
@@ -382,10 +384,10 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
}
if(version <= 1) {
runQuery(QUERY_CREATE_TABLE_SQ_SYSTEM, conn);
- runQuery(QUERY_UPGRADE_TABLE_SQ_CONNECTION_ADD_COLUMN_ENABLED, conn);
+ runQuery(QUERY_UPGRADE_TABLE_SQ_LINK_ADD_COLUMN_ENABLED, conn);
runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_COLUMN_ENABLED, conn);
- runQuery(QUERY_UPGRADE_TABLE_SQ_CONNECTION_ADD_COLUMN_CREATION_USER, conn);
- runQuery(QUERY_UPGRADE_TABLE_SQ_CONNECTION_ADD_COLUMN_UPDATE_USER, conn);
+ runQuery(QUERY_UPGRADE_TABLE_SQ_LINK_ADD_COLUMN_CREATION_USER, conn);
+ runQuery(QUERY_UPGRADE_TABLE_SQ_LINK_ADD_COLUMN_UPDATE_USER, conn);
runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_COLUMN_CREATION_USER, conn);
runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_COLUMN_UPDATE_USER, conn);
runQuery(QUERY_UPGRADE_TABLE_SQ_SUBMISSION_ADD_COLUMN_CREATION_USER, conn);
@@ -397,17 +399,17 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
}
if(version <= 3) {
// Schema modifications
- runQuery(QUERY_UPGRADE_TABLE_SQ_FORM_RENAME_COLUMN_SQF_OPERATION_TO_SQF_DIRECTION, conn);
- runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_RENAME_COLUMN_SQB_CONNECTION_TO_SQB_FROM_CONNECTION, conn);
- runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_COLUMN_SQB_TO_CONNECTION, conn);
- runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_REMOVE_CONSTRAINT_SQB_SQN, conn);
- runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_CONSTRAINT_SQB_SQN_FROM, conn);
- runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_CONSTRAINT_SQB_SQN_TO, conn);
+ runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_RENAME_COLUMN_SQ_CFG_OPERATION_TO_SQ_CFG_DIRECTION, conn);
+ runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_RENAME_COLUMN_SQB_LINK_TO_SQB_FROM_LINK, conn);
+ runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_COLUMN_SQB_TO_LINK, conn);
+ runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_REMOVE_CONSTRAINT_SQB_SQ_LNK, conn);
+ runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_CONSTRAINT_SQB_SQ_LNK_FROM, conn);
+ runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_CONSTRAINT_SQB_SQ_LNK_TO, conn);
// Data modifications only for non-fresh install.
if (version > 0) {
// Register HDFS connector
- updateJobData(conn, registerHdfsConnector(conn));
+ updteJobInternals(conn, registerHdfsConnector(conn));
}
// Wait to remove SQB_TYPE (IMPORT/EXPORT) until we update data.
@@ -440,84 +442,84 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
* Upgrade job data from IMPORT/EXPORT to FROM/TO.
* Since the framework is no longer responsible for HDFS,
* the HDFS connector/link must be added.
- * Also, the framework forms are moved around such that
- * they belong to the added HDFS connector. Any extra forms
+ * Also, the framework configs are moved around such that
+ * they belong to the added HDFS connector. Any extra configs
* are removed.
- * NOTE: Connector forms should have a direction (FROM/TO),
- * but framework forms should not.
+ * NOTE: Connector configs should have a direction (FROM/TO),
+ * but framework configs should not.
*
* Here's a brief list describing the data migration process.
- * 1. Change SQ_FORM.SQF_DIRECTION from IMPORT to FROM.
- * 2. Change SQ_FORM.SQF_DIRECTION from EXPORT to TO.
- * 3. Change EXPORT to TO in newly existing SQF_DIRECTION.
- * This should affect connectors only since Connector forms
- * should have had a value for SQF_OPERATION.
- * 4. Change IMPORT to FROM in newly existing SQF_DIRECTION.
- * This should affect connectors only since Connector forms
- * should have had a value for SQF_OPERATION.
+ * 1. Change SQ_CONFIG.SQ_CFG_DIRECTION from IMPORT to FROM.
+ * 2. Change SQ_CONFIG.SQ_CFG_DIRECTION from EXPORT to TO.
+ * 3. Change EXPORT to TO in newly existing SQ_CFG_DIRECTION.
+ * This should affect connectors only since Connector configs
+ * should have had a value for SQ_CFG_OPERATION.
+ * 4. Change IMPORT to FROM in newly existing SQ_CFG_DIRECTION.
+ * This should affect connectors only since Connector configs
+ * should have had a value for SQ_CFG_OPERATION.
* 5. Add HDFS connector for jobs to reference.
- * 6. Set 'input' and 'output' forms connector.
+ * 6. Set 'input' and 'output' configs connector.
* to HDFS connector.
- * 7. Throttling form was originally the second form in
- * the framework. It should now be the first form.
- * 8. Remove the EXPORT throttling form and ensure all of
- * its dependencies point to the IMPORT throttling form.
- * Then make sure the throttling form does not have a direction.
- * Framework forms should not have a direction.
+ * 7. Throttling config was originally the second config in
+ * the framework. It should now be the first config.
+ * 8. Remove the EXPORT throttling config and ensure all of
+ * its dependencies point to the IMPORT throttling config.
+ * Then make sure the throttling config does not have a direction.
+ * Framework configs should not have a direction.
* 9. Create an HDFS link to reference and update
* jobs to reference that link. IMPORT jobs
* should have TO HDFS connector, EXPORT jobs should have
* FROM HDFS connector.
- * 10. Update 'table' form names to 'fromJobConfig' and 'toTable'.
+ * 10. Update 'table' config names to 'fromJobConfig' and 'toTable'.
* Also update the relevant inputs as well.
* @param conn
*/
- private void updateJobData(Connection conn, long connectorId) {
+ private void updteJobInternals(Connection conn, long connectorId) {
if (LOG.isTraceEnabled()) {
LOG.trace("Updating existing data for generic connectors.");
}
- runQuery(QUERY_UPGRADE_TABLE_SQ_FORM_UPDATE_SQF_OPERATION_TO_SQF_DIRECTION, conn,
+ runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_UPDATE_SQ_CFG_OPERATION_TO_SQ_CFG_DIRECTION, conn,
Direction.FROM.toString(), "IMPORT");
- runQuery(QUERY_UPGRADE_TABLE_SQ_FORM_UPDATE_SQF_OPERATION_TO_SQF_DIRECTION, conn,
+ runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_UPDATE_SQ_CFG_OPERATION_TO_SQ_CFG_DIRECTION, conn,
Direction.TO.toString(), "EXPORT");
- runQuery(QUERY_UPGRADE_TABLE_SQ_FORM_UPDATE_CONNECTOR_HDFS_FORM_DIRECTION, conn,
+ runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_UPDATE_CONNECTOR_HDFS_CONFIG_DIRECTION, conn,
Direction.FROM.toString(),
"input");
- runQuery(QUERY_UPGRADE_TABLE_SQ_FORM_UPDATE_CONNECTOR_HDFS_FORM_DIRECTION, conn,
+ runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_UPDATE_CONNECTOR_HDFS_CONFIG_DIRECTION, conn,
Direction.TO.toString(),
"output");
- runQuery(QUERY_UPGRADE_TABLE_SQ_FORM_UPDATE_CONNECTOR, conn,
+ runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_UPDATE_CONNECTOR, conn,
new Long(connectorId), "input", "output");
- runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_INPUT_UPDATE_THROTTLING_FORM_INPUTS, conn,
+ runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_INPUT_UPDATE_THROTTLING_CONFIG_INPUTS, conn,
"IMPORT", "EXPORT");
- runQuery(QUERY_UPGRADE_TABLE_SQ_FORM_REMOVE_EXTRA_FORM_INPUTS, conn,
+ runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_REMOVE_EXTRA_CONFIG_INPUTS, conn,
"throttling", "EXPORT");
- runQuery(QUERY_UPGRADE_TABLE_SQ_FORM_REMOVE_EXTRA_FRAMEWORK_FORM, conn,
+ runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_REMOVE_EXTRA_DRIVER_CONFIG, conn,
"throttling", "EXPORT");
- runQuery(QUERY_UPGRADE_TABLE_SQ_FORM_UPDATE_DIRECTION_TO_NULL, conn,
+ runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_UPDATE_DIRECTION_TO_NULL, conn,
"throttling");
- runQuery(QUERY_UPGRADE_TABLE_SQ_FORM_UPDATE_FRAMEWORK_INDEX, conn,
+ runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_UPDATE_DRIVER_INDEX, conn,
new Long(0), "throttling");
- MLink hdfsConnection = createHdfsConnection(conn);
- runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_UPDATE_SQB_TO_CONNECTION_COPY_SQB_FROM_CONNECTION, conn,
+ MLink hdfsLink = createHdfsLink(conn);
+ runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_UPDATE_SQB_TO_LINK_COPY_SQB_FROM_LINK, conn,
"EXPORT");
- runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_UPDATE_SQB_FROM_CONNECTION, conn,
- new Long(hdfsConnection.getPersistenceId()), "EXPORT");
- runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_UPDATE_SQB_TO_CONNECTION, conn,
- new Long(hdfsConnection.getPersistenceId()), "IMPORT");
+ runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_UPDATE_SQB_FROM_LINK, conn,
+ new Long(hdfsLink.getPersistenceId()), "EXPORT");
+ runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_UPDATE_SQB_TO_LINK, conn,
+ new Long(hdfsLink.getPersistenceId()), "IMPORT");
- runQuery(QUERY_UPGRADE_TABLE_SQ_FORM_UPDATE_SQF_NAME, conn,
+ runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_UPDATE_SQ_CFG_NAME, conn,
"fromJobConfig", "table", Direction.FROM.toString());
- runQuery(QUERY_UPGRADE_TABLE_SQ_FORM_UPDATE_TABLE_INPUT_NAMES, conn,
+ runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_UPDATE_TABLE_INPUT_NAMES, conn,
Direction.FROM.toString().toLowerCase(), "fromJobConfig", Direction.FROM.toString());
- runQuery(QUERY_UPGRADE_TABLE_SQ_FORM_UPDATE_SQF_NAME, conn,
+ runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_UPDATE_SQ_CFG_NAME, conn,
"toJobConfig", "table", Direction.TO.toString());
- runQuery(QUERY_UPGRADE_TABLE_SQ_FORM_UPDATE_TABLE_INPUT_NAMES, conn,
+ runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_UPDATE_TABLE_INPUT_NAMES, conn,
Direction.TO.toString().toLowerCase(), "toJobConfig", Direction.TO.toString());
if (LOG.isTraceEnabled()) {
@@ -526,7 +528,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
}
/**
- * Pre-register HDFS Connector so that metadata upgrade will work.
+ * Pre-register HDFS Connector so that config upgrade will work.
*/
protected long registerHdfsConnector(Connection conn) {
if (LOG.isTraceEnabled()) {
@@ -536,7 +538,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
List<URL> connectorConfigs = ConnectorManagerUtils.getConnectorConfigs();
if (LOG.isInfoEnabled()) {
- LOG.info("Connector config urls: " + connectorConfigs);
+ LOG.info("Connector configs: " + connectorConfigs);
}
ConnectorHandler handler = null;
@@ -582,24 +584,22 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
*
* NOTE: Upgrade path only!
*/
- private MLink createHdfsConnection(Connection conn) {
+ private MLink createHdfsLink(Connection conn) {
if (LOG.isTraceEnabled()) {
LOG.trace("Creating HDFS link.");
}
MConnector hdfsConnector = this.findConnector(CONNECTOR_HDFS, conn);
- MDriverConfig driverConfig = findDriverConfig(conn);
- MLink hdfsConnection = new MLink(
+ MLink hdfsLink = new MLink(
hdfsConnector.getPersistenceId(),
- hdfsConnector.getConnectionForms(),
- driverConfig.getConnectionForms());
- this.createLink(hdfsConnection, conn);
+ hdfsConnector.getLinkConfig());
+ this.createLink(hdfsLink, conn);
if (LOG.isTraceEnabled()) {
LOG.trace("Created HDFS link.");
}
- return hdfsConnection;
+ return hdfsLink;
}
/**
@@ -675,92 +675,80 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
* {@inheritDoc}
*/
@Override
- public void registerDriverConfig(MDriverConfig mDriverConfig, Connection conn) {
- if (mDriverConfig.hasPersistenceId()) {
+ public void registerDriver(MDriver mDriver, Connection conn) {
+ if (mDriver.hasPersistenceId()) {
throw new SqoopException(DerbyRepoError.DERBYREPO_0011,
- "Framework metadata");
+ "Driver");
}
- PreparedStatement baseFormStmt = null;
+ PreparedStatement baseConfigStmt = null;
PreparedStatement baseInputStmt = null;
try {
- baseFormStmt = conn.prepareStatement(STMT_INSERT_FORM_BASE,
+ baseConfigStmt = conn.prepareStatement(STMT_INSERT_CONFIG_BASE,
Statement.RETURN_GENERATED_KEYS);
baseInputStmt = conn.prepareStatement(STMT_INSERT_INPUT_BASE,
Statement.RETURN_GENERATED_KEYS);
- // Register connector forms
- registerForms(null, null, mDriverConfig.getConnectionForms().getForms(),
- MFormType.CONNECTION.name(), baseFormStmt, baseInputStmt);
-
- // Register all jobs
- registerForms(null, null, mDriverConfig.getJobForms().getForms(),
- MFormType.JOB.name(), baseFormStmt, baseInputStmt);
+ // Register a driver config as a job type with no owner/connector and direction
+ registerConfigs(null/* owner*/, null /*direction*/, mDriver.getDriverConfig().getConfigs(),
+ MConfigType.JOB.name(), baseConfigStmt, baseInputStmt);
- // We're using hardcoded value for framework metadata as they are
+ // We're using hardcoded value for driver config as they are
// represented as NULL in the database.
- mDriverConfig.setPersistenceId(1);
+ mDriver.setPersistenceId(1);
} catch (SQLException ex) {
- logException(ex, mDriverConfig);
+ logException(ex, mDriver);
throw new SqoopException(DerbyRepoError.DERBYREPO_0014, ex);
} finally {
- closeStatements(baseFormStmt, baseInputStmt);
+ closeStatements(baseConfigStmt, baseInputStmt);
}
- createOrUpdateDriverVersion(conn, mDriverConfig);
+ createOrUpdateDriverSystemVersion(conn, mDriver.getVersion());
}
/**
* {@inheritDoc}
*/
@Override
- public MDriverConfig findDriverConfig(Connection conn) {
- LOG.debug("Looking up driver config");
- MDriverConfig mDriverConfig = null;
- PreparedStatement formFetchStmt = null;
- PreparedStatement inputFetchStmt = null;
+ public MDriver findDriver(Connection conn) {
+ LOG.debug("Looking up Driver config to create a driver ");
+ MDriver mDriver = null;
+ PreparedStatement driverConfigFetchStmt = null;
+ PreparedStatement driverConfigInputFetchStmt = null;
try {
- formFetchStmt = conn.prepareStatement(STMT_FETCH_FORM_FRAMEWORK);
- inputFetchStmt = conn.prepareStatement(STMT_FETCH_INPUT);
-
- List<MForm> connectionForms = new ArrayList<MForm>();
- List<MForm> jobForms = new ArrayList<MForm>();
+ driverConfigFetchStmt = conn.prepareStatement(STMT_FETCH_CONFIG_DRIVER);
+ driverConfigInputFetchStmt = conn.prepareStatement(STMT_FETCH_INPUT);
+ List<MConfig> driverConfigs = new ArrayList<MConfig>();
+ loadDriverConfigs(driverConfigs, driverConfigFetchStmt, driverConfigInputFetchStmt, 1);
- loadFrameworkForms(connectionForms, jobForms, formFetchStmt, inputFetchStmt, 1);
-
- // Return nothing If there aren't any framework metadata
- if(connectionForms.isEmpty() && jobForms.isEmpty()) {
+ if(driverConfigs.isEmpty()) {
return null;
}
- mDriverConfig = new MDriverConfig(new MConnectionForms(connectionForms),
- new MJobForms(jobForms), detectDriverVersion(conn));
-
- // We're using hardcoded value for driver config as they are
- // represented as NULL in the database.
- mDriverConfig.setPersistenceId(1);
+ mDriver = new MDriver(new MDriverConfig(driverConfigs), detectDriverVersion(conn));
+ mDriver.setPersistenceId(1);
} catch (SQLException ex) {
throw new SqoopException(DerbyRepoError.DERBYREPO_0004,
"Driver config", ex);
} finally {
- if (formFetchStmt != null) {
+ if (driverConfigFetchStmt != null) {
try {
- formFetchStmt.close();
+ driverConfigFetchStmt.close();
} catch (SQLException ex) {
- LOG.error("Unable to close form fetch statement", ex);
+ LOG.error("Unable to close config fetch statement", ex);
}
}
- if (inputFetchStmt != null) {
+ if (driverConfigInputFetchStmt != null) {
try {
- inputFetchStmt.close();
+ driverConfigInputFetchStmt.close();
} catch (SQLException ex) {
LOG.error("Unable to close input fetch statement", ex);
}
}
}
- LOG.debug("Looking up driver config found:" + mDriverConfig);
- return mDriverConfig;
+ LOG.debug("Looking up Driver config and created driver:" + mDriver);
+ return mDriver;
}
/**
@@ -779,7 +767,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
PreparedStatement stmt = null;
int result;
try {
- stmt = conn.prepareStatement(STMT_INSERT_CONNECTION,
+ stmt = conn.prepareStatement(STMT_INSERT_LINK,
Statement.RETURN_GENERATED_KEYS);
stmt.setString(1, link.getName());
stmt.setLong(2, link.getConnectorId());
@@ -803,15 +791,10 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
long connectionId = rsetConnectionId.getLong(1);
- createInputValues(STMT_INSERT_CONNECTION_INPUT,
+ createInputValues(STMT_INSERT_LINK_INPUT,
connectionId,
- link.getConnectorPart().getForms(),
+ link.getConnectorLinkConfig().getConfigs(),
conn);
- createInputValues(STMT_INSERT_CONNECTION_INPUT,
- connectionId,
- link.getFrameworkPart().getForms(),
- conn);
-
link.setPersistenceId(connectionId);
} catch (SQLException ex) {
@@ -831,12 +814,12 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
PreparedStatement updateStmt = null;
try {
// Firstly remove old values
- deleteStmt = conn.prepareStatement(STMT_DELETE_CONNECTION_INPUT);
+ deleteStmt = conn.prepareStatement(STMT_DELETE_LINK_INPUT);
deleteStmt.setLong(1, link.getPersistenceId());
deleteStmt.executeUpdate();
- // Update CONNECTION table
- updateStmt = conn.prepareStatement(STMT_UPDATE_CONNECTION);
+ // Update LINK_CONFIG table
+ updateStmt = conn.prepareStatement(STMT_UPDATE_LINK);
updateStmt.setString(1, link.getName());
updateStmt.setString(2, link.getLastUpdateUser());
updateStmt.setTimestamp(3, new Timestamp(new Date().getTime()));
@@ -845,13 +828,9 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
updateStmt.executeUpdate();
// And reinsert new values
- createInputValues(STMT_INSERT_CONNECTION_INPUT,
- link.getPersistenceId(),
- link.getConnectorPart().getForms(),
- conn);
- createInputValues(STMT_INSERT_CONNECTION_INPUT,
+ createInputValues(STMT_INSERT_LINK_INPUT,
link.getPersistenceId(),
- link.getFrameworkPart().getForms(),
+ link.getConnectorLinkConfig().getConfigs(),
conn);
} catch (SQLException ex) {
@@ -870,7 +849,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
PreparedStatement stmt = null;
ResultSet rs = null;
try {
- stmt = conn.prepareStatement(STMT_SELECT_CONNECTION_CHECK);
+ stmt = conn.prepareStatement(STMT_SELECT_LINK_CHECK);
stmt.setLong(1, id);
rs = stmt.executeQuery();
@@ -893,7 +872,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
ResultSet rs = null;
try {
- stmt = conn.prepareStatement(STMT_SELECT_JOBS_FOR_CONNECTION_CHECK);
+ stmt = conn.prepareStatement(STMT_SELECT_JOBS_FOR_LINK_CHECK);
stmt.setLong(1, connectionId);
rs = stmt.executeQuery();
@@ -916,7 +895,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
PreparedStatement enableConn = null;
try {
- enableConn = conn.prepareStatement(STMT_ENABLE_CONNECTION);
+ enableConn = conn.prepareStatement(STMT_ENABLE_LINK);
enableConn.setBoolean(1, enabled);
enableConn.setLong(2, connectionId);
enableConn.executeUpdate();
@@ -937,7 +916,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
try {
deleteLinkInputs(id, conn);
- dltConn = conn.prepareStatement(STMT_DELETE_CONNECTION);
+ dltConn = conn.prepareStatement(STMT_DELETE_LINK);
dltConn.setLong(1, id);
dltConn.executeUpdate();
} catch (SQLException ex) {
@@ -955,7 +934,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
public void deleteLinkInputs(long id, Connection conn) {
PreparedStatement dltConnInput = null;
try {
- dltConnInput = conn.prepareStatement(STMT_DELETE_CONNECTION_INPUT);
+ dltConnInput = conn.prepareStatement(STMT_DELETE_LINK_INPUT);
dltConnInput.setLong(1, id);
dltConnInput.executeUpdate();
} catch (SQLException ex) {
@@ -973,7 +952,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
public MLink findLink(long id, Connection conn) {
PreparedStatement stmt = null;
try {
- stmt = conn.prepareStatement(STMT_SELECT_CONNECTION_SINGLE);
+ stmt = conn.prepareStatement(STMT_SELECT_LINK_SINGLE);
stmt.setLong(1, id);
List<MLink> connections = loadLinks(stmt, conn);
@@ -1001,7 +980,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
public List<MLink> findLinks(Connection conn) {
PreparedStatement stmt = null;
try {
- stmt = conn.prepareStatement(STMT_SELECT_CONNECTION_ALL);
+ stmt = conn.prepareStatement(STMT_SELECT_LINK_ALL);
return loadLinks(stmt, conn);
@@ -1023,7 +1002,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
public List<MLink> findLinksForConnector(long connectorID, Connection conn) {
PreparedStatement stmt = null;
try {
- stmt = conn.prepareStatement(STMT_SELECT_CONNECTION_FOR_CONNECTOR);
+ stmt = conn.prepareStatement(STMT_SELECT_LINK_FOR_CONNECTOR);
stmt.setLong(1, connectorID);
return loadLinks(stmt, conn);
@@ -1042,12 +1021,12 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
@Override
public void updateConnector(MConnector mConnector, Connection conn) {
PreparedStatement updateConnectorStatement = null;
- PreparedStatement deleteForm = null;
+ PreparedStatement deleteConfig = null;
PreparedStatement deleteInput = null;
try {
updateConnectorStatement = conn.prepareStatement(STMT_UPDATE_CONNECTOR);
deleteInput = conn.prepareStatement(STMT_DELETE_INPUTS_FOR_CONNECTOR);
- deleteForm = conn.prepareStatement(STMT_DELETE_FORMS_FOR_CONNECTOR);
+ deleteConfig = conn.prepareStatement(STMT_DELETE_CONFIGS_FOR_CONNECTOR);
updateConnectorStatement.setString(1, mConnector.getUniqueName());
updateConnectorStatement.setString(2, mConnector.getClassName());
updateConnectorStatement.setString(3, mConnector.getVersion());
@@ -1057,17 +1036,17 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
throw new SqoopException(DerbyRepoError.DERBYREPO_0038);
}
deleteInput.setLong(1, mConnector.getPersistenceId());
- deleteForm.setLong(1, mConnector.getPersistenceId());
+ deleteConfig.setLong(1, mConnector.getPersistenceId());
deleteInput.executeUpdate();
- deleteForm.executeUpdate();
+ deleteConfig.executeUpdate();
} catch (SQLException e) {
logException(e, mConnector);
throw new SqoopException(DerbyRepoError.DERBYREPO_0038, e);
} finally {
- closeStatements(updateConnectorStatement, deleteForm, deleteInput);
+ closeStatements(updateConnectorStatement, deleteConfig, deleteInput);
}
- insertFormsForConnector(mConnector, conn);
+ insertConfigsForConnector(mConnector, conn);
}
@@ -1075,25 +1054,24 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
* {@inheritDoc}
*/
@Override
- public void updateDriverConfig(MDriverConfig mDriverConfig, Connection conn) {
- PreparedStatement deleteForm = null;
+ public void updateDriver(MDriver mDriver, Connection conn) {
+ PreparedStatement deleteConfig = null;
PreparedStatement deleteInput = null;
try {
- deleteInput = conn.prepareStatement(STMT_DELETE_FRAMEWORK_INPUTS);
- deleteForm = conn.prepareStatement(STMT_DELETE_FRAMEWORK_FORMS);
+ deleteInput = conn.prepareStatement(STMT_DELETE_DRIVER_INPUTS);
+ deleteConfig = conn.prepareStatement(STMT_DELETE_DRIVER_CONFIGS);
deleteInput.executeUpdate();
- deleteForm.executeUpdate();
+ deleteConfig.executeUpdate();
} catch (SQLException e) {
- logException(e, mDriverConfig);
+ logException(e, mDriver);
throw new SqoopException(DerbyRepoError.DERBYREPO_0044, e);
} finally {
- closeStatements(deleteForm, deleteInput);
+ closeStatements(deleteConfig, deleteInput);
}
- createOrUpdateDriverVersion(conn, mDriverConfig);
- insertFormsForFramework(mDriverConfig, conn);
-
+ createOrUpdateDriverSystemVersion(conn, mDriver.getVersion());
+ insertConfigsForDriver(mDriver, conn);
}
/**
@@ -1104,8 +1082,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
PreparedStatement stmt = null;
int result;
try {
- stmt = conn.prepareStatement(STMT_INSERT_JOB,
- Statement.RETURN_GENERATED_KEYS);
+ stmt = conn.prepareStatement(STMT_INSERT_JOB, Statement.RETURN_GENERATED_KEYS);
stmt.setString(1, job.getName());
stmt.setLong(2, job.getLinkId(Direction.FROM));
stmt.setLong(3, job.getLinkId(Direction.TO));
@@ -1129,17 +1106,20 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
long jobId = rsetJobId.getLong(1);
+ // from config for the job
createInputValues(STMT_INSERT_JOB_INPUT,
jobId,
- job.getConnectorPart(Direction.FROM).getForms(),
+ job.getJobConfig(Direction.FROM).getConfigs(),
conn);
+ // to config for the job
createInputValues(STMT_INSERT_JOB_INPUT,
jobId,
- job.getConnectorPart(Direction.TO).getForms(),
+ job.getJobConfig(Direction.TO).getConfigs(),
conn);
+ // driver config per job
createInputValues(STMT_INSERT_JOB_INPUT,
jobId,
- job.getFrameworkPart().getForms(),
+ job.getDriverConfig().getConfigs(),
conn);
job.setPersistenceId(jobId);
@@ -1177,15 +1157,15 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
// And reinsert new values
createInputValues(STMT_INSERT_JOB_INPUT,
job.getPersistenceId(),
- job.getConnectorPart(Direction.FROM).getForms(),
+ job.getJobConfig(Direction.FROM).getConfigs(),
conn);
createInputValues(STMT_INSERT_JOB_INPUT,
job.getPersistenceId(),
- job.getConnectorPart(Direction.TO).getForms(),
+ job.getJobConfig(Direction.TO).getConfigs(),
conn);
createInputValues(STMT_INSERT_JOB_INPUT,
job.getPersistenceId(),
- job.getFrameworkPart().getForms(),
+ job.getDriverConfig().getConfigs(),
conn);
} catch (SQLException ex) {
@@ -1788,13 +1768,13 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
private List<MConnector> loadConnectors(PreparedStatement stmt,Connection conn) throws SQLException {
List<MConnector> connectors = new ArrayList<MConnector>();
ResultSet rsConnectors = null;
- PreparedStatement formFetchStmt = null;
- PreparedStatement inputFetchStmt = null;
+ PreparedStatement connectorConfigFetchStmt = null;
+ PreparedStatement connectorConfigInputFetchStmt = null;
try {
rsConnectors = stmt.executeQuery();
- formFetchStmt = conn.prepareStatement(STMT_FETCH_FORM_CONNECTOR);
- inputFetchStmt = conn.prepareStatement(STMT_FETCH_INPUT);
+ connectorConfigFetchStmt = conn.prepareStatement(STMT_FETCH_CONFIG_CONNECTOR);
+ connectorConfigInputFetchStmt = conn.prepareStatement(STMT_FETCH_INPUT);
while(rsConnectors.next()) {
long connectorId = rsConnectors.getLong(1);
@@ -1802,26 +1782,26 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
String connectorClassName = rsConnectors.getString(3);
String connectorVersion = rsConnectors.getString(4);
- formFetchStmt.setLong(1, connectorId);
+ connectorConfigFetchStmt.setLong(1, connectorId);
- List<MForm> connectionForms = new ArrayList<MForm>();
- List<MForm> fromJobForms = new ArrayList<MForm>();
- List<MForm> toJobForms = new ArrayList<MForm>();
+ List<MConfig> linkConfig = new ArrayList<MConfig>();
+ List<MConfig> fromConfig = new ArrayList<MConfig>();
+ List<MConfig> toConfig = new ArrayList<MConfig>();
- loadConnectorForms(connectionForms, fromJobForms, toJobForms,
- formFetchStmt, inputFetchStmt, 1);
+ loadConfigTypes(linkConfig, fromConfig, toConfig,
+ connectorConfigFetchStmt, connectorConfigInputFetchStmt, 1);
MConnector mc = new MConnector(connectorName, connectorClassName, connectorVersion,
- new MConnectionForms(connectionForms),
- new MJobForms(fromJobForms),
- new MJobForms(toJobForms));
+ new MLinkConfig(linkConfig),
+ new MFromConfig(fromConfig),
+ new MToConfig(toConfig));
mc.setPersistenceId(connectorId);
connectors.add(mc);
}
} finally {
closeResultSets(rsConnectors);
- closeStatements(formFetchStmt,inputFetchStmt);
+ closeStatements(connectorConfigFetchStmt,connectorConfigInputFetchStmt);
}
return connectors;
@@ -1832,16 +1812,15 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
throws SQLException {
List<MLink> links = new ArrayList<MLink>();
ResultSet rsConnection = null;
- PreparedStatement formConnectorFetchStmt = null;
- PreparedStatement formFrameworkFetchStmt = null;
- PreparedStatement inputFetchStmt = null;
+ PreparedStatement connectorConfigFetchStatement = null;
+ PreparedStatement connectorConfigInputStatement = null;
try {
rsConnection = stmt.executeQuery();
- formConnectorFetchStmt = conn.prepareStatement(STMT_FETCH_FORM_CONNECTOR);
- formFrameworkFetchStmt = conn.prepareStatement(STMT_FETCH_FORM_FRAMEWORK);
- inputFetchStmt = conn.prepareStatement(STMT_FETCH_CONNECTION_INPUT);
+ //
+ connectorConfigFetchStatement = conn.prepareStatement(STMT_FETCH_CONFIG_CONNECTOR);
+ connectorConfigInputStatement = conn.prepareStatement(STMT_FETCH_LINK_INPUT);
while(rsConnection.next()) {
long id = rsConnection.getLong(1);
@@ -1853,26 +1832,17 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
String updateUser = rsConnection.getString(7);
Date lastUpdateDate = rsConnection.getTimestamp(8);
- formConnectorFetchStmt.setLong(1, connectorId);
-
- inputFetchStmt.setLong(1, id);
- //inputFetchStmt.setLong(2, XXX); // Will be filled by loadFrameworkForms
- inputFetchStmt.setLong(3, id);
-
- List<MForm> connectorConnForms = new ArrayList<MForm>();
- List<MForm> frameworkConnForms = new ArrayList<MForm>();
- List<MForm> frameworkJobForms = new ArrayList<MForm>();
- List<MForm> fromJobForms = new ArrayList<MForm>();
- List<MForm> toJobForms = new ArrayList<MForm>();
+ connectorConfigFetchStatement.setLong(1, connectorId);
+ connectorConfigInputStatement.setLong(1, id);
+ connectorConfigInputStatement.setLong(3, id);
- loadConnectorForms(connectorConnForms, fromJobForms, toJobForms,
- formConnectorFetchStmt, inputFetchStmt, 2);
- loadFrameworkForms(frameworkConnForms, frameworkJobForms,
- formFrameworkFetchStmt, inputFetchStmt, 2);
+ List<MConfig> connectorLinkConfig = new ArrayList<MConfig>();
+ List<MConfig> fromConfig = new ArrayList<MConfig>();
+ List<MConfig> toConfig = new ArrayList<MConfig>();
- MLink link = new MLink(connectorId,
- new MConnectionForms(connectorConnForms),
- new MConnectionForms(frameworkConnForms));
+ loadConfigTypes(connectorLinkConfig, fromConfig, toConfig, connectorConfigFetchStatement,
+ connectorConfigInputStatement, 2);
+ MLink link = new MLink(connectorId, new MLinkConfig(connectorLinkConfig));
link.setPersistenceId(id);
link.setName(name);
@@ -1886,8 +1856,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
}
} finally {
closeResultSets(rsConnection);
- closeStatements(formConnectorFetchStmt,
- formFrameworkFetchStmt, inputFetchStmt);
+ closeStatements(connectorConfigFetchStatement, connectorConfigInputStatement);
}
return links;
@@ -1898,20 +1867,21 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
throws SQLException {
List<MJob> jobs = new ArrayList<MJob>();
ResultSet rsJob = null;
- PreparedStatement toFormConnectorFetchStmt = null;
- PreparedStatement fromFormConnectorFetchStmt = null;
- PreparedStatement formFrameworkFetchStmt = null;
- PreparedStatement inputFetchStmt = null;
+ PreparedStatement fromConfigFetchStmt = null;
+ PreparedStatement toConfigFetchStmt = null;
+ PreparedStatement driverConfigfetchStmt = null;
+ PreparedStatement jobInputFetchStmt = null;
try {
rsJob = stmt.executeQuery();
- toFormConnectorFetchStmt = conn.prepareStatement(STMT_FETCH_FORM_CONNECTOR);
- fromFormConnectorFetchStmt = conn.prepareStatement(STMT_FETCH_FORM_CONNECTOR);
- formFrameworkFetchStmt = conn.prepareStatement(STMT_FETCH_FORM_FRAMEWORK);
- inputFetchStmt = conn.prepareStatement(STMT_FETCH_JOB_INPUT);
+ fromConfigFetchStmt = conn.prepareStatement(STMT_FETCH_CONFIG_CONNECTOR);
+ toConfigFetchStmt = conn.prepareStatement(STMT_FETCH_CONFIG_CONNECTOR);
+ driverConfigfetchStmt = conn.prepareStatement(STMT_FETCH_CONFIG_DRIVER);
+ jobInputFetchStmt = conn.prepareStatement(STMT_FETCH_JOB_INPUT);
while(rsJob.next()) {
+ // why use connector? why cant it be link id?
long fromConnectorId = rsJob.getLong(1);
long toConnectorId = rsJob.getLong(2);
long id = rsJob.getLong(3);
@@ -1924,48 +1894,40 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
String updateBy = rsJob.getString(10);
Date lastUpdateDate = rsJob.getTimestamp(11);
- fromFormConnectorFetchStmt.setLong(1, fromConnectorId);
- toFormConnectorFetchStmt.setLong(1,toConnectorId);
+ fromConfigFetchStmt.setLong(1, fromConnectorId);
+ toConfigFetchStmt.setLong(1,toConnectorId);
- inputFetchStmt.setLong(1, id);
- //inputFetchStmt.setLong(1, XXX); // Will be filled by loadFrameworkForms
- inputFetchStmt.setLong(3, id);
+ jobInputFetchStmt.setLong(1, id);
+ //inputFetchStmt.setLong(1, XXX); // Will be filled by loadFrameworkConfigs
+ jobInputFetchStmt.setLong(3, id);
- List<MForm> toConnectorConnForms = new ArrayList<MForm>();
- List<MForm> fromConnectorConnForms = new ArrayList<MForm>();
+ // FROM entity configs
+ List<MConfig> fromConnectorLinkConfig = new ArrayList<MConfig>();
+ List<MConfig> fromConnectorFromJobConfig = new ArrayList<MConfig>();
+ List<MConfig> fromConnectorToJobConfig = new ArrayList<MConfig>();
- List<MForm> frameworkConnForms = new ArrayList<MForm>();
- List<MForm> frameworkJobForms = new ArrayList<MForm>();
+ loadConfigTypes(fromConnectorLinkConfig, fromConnectorFromJobConfig, fromConnectorToJobConfig,
+ fromConfigFetchStmt, jobInputFetchStmt, 2);
- // This looks confusing but our job has 2 connectors, each connector has two job forms
- // To define the job, we need to TO job form of the TO connector
- // and the FROM job form of the FROM connector
- List<MForm> fromConnectorFromJobForms = new ArrayList<MForm>();
- List<MForm> fromConnectorToJobForms = new ArrayList<MForm>();
- List<MForm> toConnectorFromJobForms = new ArrayList<MForm>();
- List<MForm> toConnectorToJobForms = new ArrayList<MForm>();
+ // TO entity configs
+ List<MConfig> toConnectorLinkConfig = new ArrayList<MConfig>();
+ List<MConfig> toConnectorFromJobConfig = new ArrayList<MConfig>();
+ List<MConfig> toConnectorToJobConfig = new ArrayList<MConfig>();
+ // ?? dont we need 2 different driver configs for the from/to?
+ List<MConfig> driverConfig = new ArrayList<MConfig>();
- loadConnectorForms(fromConnectorConnForms,
- fromConnectorFromJobForms,
- fromConnectorToJobForms,
- fromFormConnectorFetchStmt,
- inputFetchStmt,
- 2);
- loadConnectorForms(toConnectorConnForms,
- toConnectorFromJobForms,
- toConnectorToJobForms,
- toFormConnectorFetchStmt, inputFetchStmt, 2);
+ loadConfigTypes(toConnectorLinkConfig, toConnectorFromJobConfig, toConnectorToJobConfig,
+ toConfigFetchStmt, jobInputFetchStmt, 2);
- loadFrameworkForms(frameworkConnForms, frameworkJobForms,
- formFrameworkFetchStmt, inputFetchStmt, 2);
+ loadDriverConfigs(driverConfig, driverConfigfetchStmt, jobInputFetchStmt, 2);
MJob job = new MJob(
fromConnectorId, toConnectorId,
fromLinkId, toLinkId,
- new MJobForms(fromConnectorFromJobForms),
- new MJobForms(toConnectorToJobForms),
- new MJobForms(frameworkJobForms));
+ new MFromConfig(fromConnectorFromJobConfig),
+ new MToConfig(toConnectorToJobConfig),
+ new MDriverConfig(driverConfig));
job.setPersistenceId(id);
job.setName(name);
@@ -1979,65 +1941,65 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
}
} finally {
closeResultSets(rsJob);
- closeStatements(fromFormConnectorFetchStmt, toFormConnectorFetchStmt, formFrameworkFetchStmt, inputFetchStmt);
+ closeStatements(fromConfigFetchStmt, toConfigFetchStmt, driverConfigfetchStmt, jobInputFetchStmt);
}
return jobs;
}
/**
- * Register forms in derby database. This method will insert the ids
- * generated by the repository into the forms passed in itself.
+ * Register configs in derby database. This method will insert the ids
+ * generated by the repository into the configs passed in itself.
*
- * Use given prepared statements to create entire form structure in database.
+ * Use given prepared statements to create entire config structure in database.
*
* @param connectorId
- * @param forms
+ * @param configs
* @param type
- * @param baseFormStmt
+ * @param baseConfigStmt
* @param baseInputStmt
- * @return short number of forms registered.
+ * @return short number of configs registered.
* @throws SQLException
*/
- private short registerForms(Long connectorId, Direction direction,
- List<MForm> forms, String type, PreparedStatement baseFormStmt,
+ private short registerConfigs(Long connectorId, Direction direction,
+ List<MConfig> configs, String type, PreparedStatement baseConfigStmt,
PreparedStatement baseInputStmt)
throws SQLException {
- short formIndex = 0;
+ short configIndex = 0;
- for (MForm form : forms) {
+ for (MConfig config : configs) {
if(connectorId == null) {
- baseFormStmt.setNull(1, Types.BIGINT);
+ baseConfigStmt.setNull(1, Types.BIGINT);
} else {
- baseFormStmt.setLong(1, connectorId);
+ baseConfigStmt.setLong(1, connectorId);
}
if(direction == null) {
- baseFormStmt.setNull(2, Types.VARCHAR);
+ baseConfigStmt.setNull(2, Types.VARCHAR);
} else {
- baseFormStmt.setString(2, direction.name());
+ baseConfigStmt.setString(2, direction.name());
}
- baseFormStmt.setString(3, form.getName());
- baseFormStmt.setString(4, type);
- baseFormStmt.setShort(5, formIndex++);
+ baseConfigStmt.setString(3, config.getName());
+ baseConfigStmt.setString(4, type);
+ baseConfigStmt.setShort(5, configIndex++);
- int baseFormCount = baseFormStmt.executeUpdate();
- if (baseFormCount != 1) {
+ int baseConfigCount = baseConfigStmt.executeUpdate();
+ if (baseConfigCount != 1) {
throw new SqoopException(DerbyRepoError.DERBYREPO_0015,
- Integer.toString(baseFormCount));
+ Integer.toString(baseConfigCount));
}
- ResultSet rsetFormId = baseFormStmt.getGeneratedKeys();
- if (!rsetFormId.next()) {
+ ResultSet rsetConfigId = baseConfigStmt.getGeneratedKeys();
+ if (!rsetConfigId.next()) {
throw new SqoopException(DerbyRepoError.DERBYREPO_0016);
}
- long formId = rsetFormId.getLong(1);
- form.setPersistenceId(formId);
+ long configId = rsetConfigId.getLong(1);
+ config.setPersistenceId(configId);
// Insert all the inputs
- List<MInput<?>> inputs = form.getInputs();
- registerFormInputs(formId, inputs, baseInputStmt);
+ List<MInput<?>> inputs = config.getInputs();
+ registerConfigInputs(configId, inputs, baseInputStmt);
}
- return formIndex;
+ return configIndex;
}
/**
@@ -2045,17 +2007,17 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
*
* Use given prepare statement to save all inputs into repository.
*
- * @param formId Identifier for corresponding form
+ * @param configId Identifier for corresponding config
* @param inputs List of inputs that needs to be saved
* @param baseInputStmt Statement that we can utilize
* @throws SQLException In case of any failure on Derby side
*/
- private void registerFormInputs(long formId, List<MInput<?>> inputs,
+ private void registerConfigInputs(long configId, List<MInput<?>> inputs,
PreparedStatement baseInputStmt) throws SQLException {
short inputIndex = 0;
for (MInput<?> input : inputs) {
baseInputStmt.setString(1, input.getName());
- baseInputStmt.setLong(2, formId);
+ baseInputStmt.setLong(2, configId);
baseInputStmt.setShort(3, inputIndex++);
baseInputStmt.setString(4, input.getType().name());
baseInputStmt.setBoolean(5, input.isSensitive());
@@ -2128,43 +2090,42 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
}
/**
- * Load forms and corresponding inputs from Derby database.
+ * Load configs and corresponding inputs from Derby database.
*
- * Use given prepared statements to load all forms and corresponding inputs
+ * Use given prepared statements to load all configs and corresponding inputs
* from Derby.
*
- * @param connectionForms List of link forms that will be filled up
- * @param jobForms Map with job forms that will be filled up
- * @param formFetchStmt Prepared statement for fetching forms
+ * @param driverConfig List of driver configs that will be filled up
+ * @param configFetchStatement Prepared statement for fetching configs
* @param inputFetchStmt Prepare statement for fetching inputs
+ * @param configPosition position of the config
* @throws SQLException In case of any failure on Derby side
*/
- public void loadFrameworkForms(List<MForm> connectionForms,
- List<MForm> jobForms,
- PreparedStatement formFetchStmt,
+ public void loadDriverConfigs(List<MConfig> driverConfig,
+ PreparedStatement configFetchStatement,
PreparedStatement inputFetchStmt,
- int formPosition) throws SQLException {
+ int configPosition) throws SQLException {
// Get list of structures from database
- ResultSet rsetForm = formFetchStmt.executeQuery();
- while (rsetForm.next()) {
- long formId = rsetForm.getLong(1);
- Long formConnectorId = rsetForm.getLong(2);
- String formName = rsetForm.getString(4);
- String formType = rsetForm.getString(5);
- int formIndex = rsetForm.getInt(6);
- List<MInput<?>> formInputs = new ArrayList<MInput<?>>();
+ ResultSet rsetConfig = configFetchStatement.executeQuery();
+ while (rsetConfig.next()) {
+ long configId = rsetConfig.getLong(1);
+ Long fromConnectorId = rsetConfig.getLong(2);
+ String configName = rsetConfig.getString(4);
+ String configTYpe = rsetConfig.getString(5);
+ int configIndex = rsetConfig.getInt(6);
+ List<MInput<?>> configInputs = new ArrayList<MInput<?>>();
- MForm mDriverConfig = new MForm(formName, formInputs);
- mDriverConfig.setPersistenceId(formId);
+ MConfig mDriverConfig = new MConfig(configName, configInputs);
+ mDriverConfig.setPersistenceId(configId);
- inputFetchStmt.setLong(formPosition, formId);
+ inputFetchStmt.setLong(configPosition, configId);
ResultSet rsetInput = inputFetchStmt.executeQuery();
while (rsetInput.next()) {
long inputId = rsetInput.getLong(1);
String inputName = rsetInput.getString(2);
- long inputForm = rsetInput.getLong(3);
+ long inputConfig = rsetInput.getLong(3);
short inputIndex = rsetInput.getShort(4);
String inputType = rsetInput.getString(5);
boolean inputSensitivity = rsetInput.getBoolean(6);
@@ -2194,7 +2155,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
default:
throw new SqoopException(DerbyRepoError.DERBYREPO_0006,
"input-" + inputName + ":" + inputId + ":"
- + "form-" + inputForm + ":" + mit.name());
+ + "config-" + inputConfig + ":" + mit.name());
}
// Set persistent ID
@@ -2209,7 +2170,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
if (mDriverConfig.getInputs().size() != inputIndex) {
throw new SqoopException(DerbyRepoError.DERBYREPO_0009,
- "form: " + mDriverConfig
+ "config: " + mDriverConfig
+ "; input: " + input
+ "; index: " + inputIndex
+ "; expected: " + mDriverConfig.getInputs().size()
@@ -2221,83 +2182,69 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
if (mDriverConfig.getInputs().size() == 0) {
throw new SqoopException(DerbyRepoError.DERBYREPO_0008,
- "connector-" + formConnectorId
- + "; form: " + mDriverConfig
+ "owner-" + fromConnectorId
+ + "; config: " + mDriverConfig
);
}
- MFormType mDriverConfigt = MFormType.valueOf(formType);
- switch (mDriverConfigt) {
- case CONNECTION:
- if (connectionForms.size() != formIndex) {
- throw new SqoopException(DerbyRepoError.DERBYREPO_0010,
- "connector-" + formConnectorId
- + "; form: " + mDriverConfig
- + "; index: " + formIndex
- + "; expected: " + connectionForms.size()
- );
- }
- connectionForms.add(mDriverConfig);
- break;
+ MConfigType configType = MConfigType.valueOf(configTYpe);
+ switch (configType) {
case JOB:
- if (jobForms.size() != formIndex) {
+ if (driverConfig.size() != configIndex) {
throw new SqoopException(DerbyRepoError.DERBYREPO_0010,
- "connector-" + formConnectorId
- + "; form: " + mDriverConfig
- + "; index: " + formIndex
- + "; expected: " + jobForms.size()
+ "owner-" + fromConnectorId
+ + "; config: " + configType
+ + "; index: " + configIndex
+ + "; expected: " + driverConfig.size()
);
}
- jobForms.add(mDriverConfig);
+ driverConfig.add(mDriverConfig);
break;
default:
throw new SqoopException(DerbyRepoError.DERBYREPO_0007,
- "connector-" + formConnectorId + ":" + mDriverConfig);
+ "connector-" + fromConnectorId + ":" + configType);
}
}
}
/**
- * Load forms and corresponding inputs from Derby database.
+ * Load configs and corresponding inputs from Derby database.
*
- * Use given prepared statements to load all forms and corresponding inputs
+ * Use given prepared statements to load all configs and corresponding inputs
* from Derby.
*
- * @param connectionForms List of link forms that will be filled up
- * @param fromJobForms FROM job forms that will be filled up
- * @param toJobForms TO job forms that will be filled up
- * @param formFetchStmt Prepared statement for fetching forms
+ * @param linkConfig List of link configs that will be filled up
+ * @param fromConfig FROM job configs that will be filled up
+ * @param toConfig TO job configs that will be filled up
+ * @param configFetchStmt Prepared statement for fetching configs
* @param inputFetchStmt Prepare statement for fetching inputs
* @throws SQLException In case of any failure on Derby side
*/
- public void loadConnectorForms(List<MForm> connectionForms,
- List<MForm> fromJobForms,
- List<MForm> toJobForms,
- PreparedStatement formFetchStmt,
- PreparedStatement inputFetchStmt,
- int formPosition) throws SQLException {
+ public void loadConfigTypes(List<MConfig> linkConfig, List<MConfig> fromConfig,
+ List<MConfig> toConfig, PreparedStatement configFetchStmt, PreparedStatement inputFetchStmt,
+ int configPosition) throws SQLException {
// Get list of structures from database
- ResultSet rsetForm = formFetchStmt.executeQuery();
- while (rsetForm.next()) {
- long formId = rsetForm.getLong(1);
- Long formConnectorId = rsetForm.getLong(2);
- String operation = rsetForm.getString(3);
- String formName = rsetForm.getString(4);
- String formType = rsetForm.getString(5);
- int formIndex = rsetForm.getInt(6);
- List<MInput<?>> formInputs = new ArrayList<MInput<?>>();
+ ResultSet rsetConfig = configFetchStmt.executeQuery();
+ while (rsetConfig.next()) {
+ long configId = rsetConfig.getLong(1);
+ Long configConnectorId = rsetConfig.getLong(2);
+ String operation = rsetConfig.getString(3);
+ String configName = rsetConfig.getString(4);
+ String configType = rsetConfig.getString(5);
+ int configIndex = rsetConfig.getInt(6);
+ List<MInput<?>> configInputs = new ArrayList<MInput<?>>();
- MForm mDriverConfig = new MForm(formName, formInputs);
- mDriverConfig.setPersistenceId(formId);
+ MConfig config = new MConfig(configName, configInputs);
+ config.setPersistenceId(configId);
- inputFetchStmt.setLong(formPosition, formId);
+ inputFetchStmt.setLong(configPosition, configId);
ResultSet rsetInput = inputFetchStmt.executeQuery();
while (rsetInput.next()) {
long inputId = rsetInput.getLong(1);
String inputName = rsetInput.getString(2);
- long inputForm = rsetInput.getLong(3);
+ long inputConfig = rsetInput.getLong(3);
short inputIndex = rsetInput.getShort(4);
String inputType = rsetInput.getString(5);
boolean inputSensitivity = rsetInput.getBoolean(6);
@@ -2327,7 +2274,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
default:
throw new SqoopException(DerbyRepoError.DERBYREPO_0006,
"input-" + inputName + ":" + inputId + ":"
- + "form-" + inputForm + ":" + mit.name());
+ + "config-" + inputConfig + ":" + mit.name());
}
// Set persistent ID
@@ -2340,75 +2287,75 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
input.restoreFromUrlSafeValueString(value);
}
- if (mDriverConfig.getInputs().size() != inputIndex) {
+ if (config.getInputs().size() != inputIndex) {
throw new SqoopException(DerbyRepoError.DERBYREPO_0009,
- "form: " + mDriverConfig
+ "config: " + config
+ "; input: " + input
+ "; index: " + inputIndex
- + "; expected: " + mDriverConfig.getInputs().size()
+ + "; expected: " + config.getInputs().size()
);
}
- mDriverConfig.getInputs().add(input);
+ config.getInputs().add(input);
}
- if (mDriverConfig.getInputs().size() == 0) {
+ if (config.getInputs().size() == 0) {
throw new SqoopException(DerbyRepoError.DERBYREPO_0008,
- "connector-" + formConnectorId
- + "; form: " + mDriverConfig
+ "connector-" + configConnectorId
+ + "; config: " + config
);
}
- MFormType mDriverConfigt = MFormType.valueOf(formType);
- switch (mDriverConfigt) {
- case CONNECTION:
- if (connectionForms.size() != formIndex) {
+ MConfigType mConfigType = MConfigType.valueOf(configType);
+ switch (mConfigType) {
+ case LINK:
+ if (linkConfig.size() != configIndex) {
throw new SqoopException(DerbyRepoError.DERBYREPO_0010,
- "connector-" + formConnectorId
- + "; form: " + mDriverConfig
- + "; index: " + formIndex
- + "; expected: " + connectionForms.size()
+ "connector-" + configConnectorId
+ + "; config: " + config
+ + "; index: " + configIndex
+ + "; expected: " + linkConfig.size()
);
}
- connectionForms.add(mDriverConfig);
+ linkConfig.add(config);
break;
case JOB:
Direction type = Direction.valueOf(operation);
- List<MForm> jobForms;
+ List<MConfig> jobConfigs;
switch(type) {
case FROM:
- jobForms = fromJobForms;
+ jobConfigs = fromConfig;
break;
case TO:
- jobForms = toJobForms;
+ jobConfigs = toConfig;
break;
default:
throw new SqoopException(DirectionError.DIRECTION_0000, "Direction: " + type);
}
- if (jobForms.size() != formIndex) {
+ if (jobConfigs.size() != configIndex) {
throw new SqoopException(DerbyRepoError.DERBYREPO_0010,
- "connector-" + formConnectorId
- + "; form: " + mDriverConfig
- + "; index: " + formIndex
- + "; expected: " + jobForms.size()
+ "connector-" + configConnectorId
+ + "; config: " + config
+ + "; index: " + configIndex
+ + "; expected: " + jobConfigs.size()
);
}
- jobForms.add(mDriverConfig);
+ jobConfigs.add(config);
break;
default:
throw new SqoopException(DerbyRepoError.DERBYREPO_0007,
- "connector-" + formConnectorId + ":" + mDriverConfig);
+ "connector-" + configConnectorId + ":" + config);
}
}
}
private void createInputValues(String query,
long id,
- List<MForm> forms,
+ List<MConfig> configs,
Connection conn) throws SQLException {
PreparedStatement stmt = null;
int result;
@@ -2416,8 +2363,8 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
try {
stmt = conn.prepareStatement(query);
- for (MForm form : forms) {
- for (MInput input : form.getInputs()) {
+ for (MConfig config : configs) {
+ for (MInput input : config.getInputs()) {
// Skip empty values as we're not interested in storing those in db
if (input.isEmpty()) {
continue;
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaConstants.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaConstants.java b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaConstants.java
index 58eed2d..fc3ec18 100644
--- a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaConstants.java
+++ b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaConstants.java
@@ -56,30 +56,30 @@ public final class DerbySchemaConstants {
public static final String COLUMN_SQC_VERSION = "SQC_VERSION";
- // SQ_FORM
+ // SQ_CONFIG
- public static final String TABLE_SQ_FORM_NAME = "SQ_FORM";
+ public static final String TABLE_SQ_CONFIG_NAME = "SQ_CONFIG";
- public static final String TABLE_SQ_FORM = SCHEMA_PREFIX
- + TABLE_SQ_FORM_NAME;
+ public static final String TABLE_SQ_CONFIG = SCHEMA_PREFIX
+ + TABLE_SQ_CONFIG_NAME;
- public static final String COLUMN_SQF_ID = "SQF_ID";
+ public static final String COLUMN_SQ_CFG_ID = "SQ_CFG_ID";
- public static final String COLUMN_SQF_CONNECTOR = "SQF_CONNECTOR";
+ public static final String COLUMN_SQ_CFG_OWNER = "SQ_CFG_OWNER";
- public static final String COLUMN_SQF_OPERATION = "SQF_OPERATION";
+ public static final String COLUMN_SQ_CFG_OPERATION = "SQ_CFG_OPERATION";
- public static final String COLUMN_SQF_DIRECTION = "SQF_DIRECTION";
+ public static final String COLUMN_SQ_CFG_DIRECTION = "SQ_CFG_DIRECTION";
- public static final String COLUMN_SQF_NAME = "SQF_NAME";
+ public static final String COLUMN_SQ_CFG_NAME = "SQ_CFG_NAME";
- public static final String COLUMN_SQF_TYPE = "SQF_TYPE";
+ public static final String COLUMN_SQ_CFG_TYPE = "SQ_CFG_TYPE";
- public static final String COLUMN_SQF_INDEX = "SQF_INDEX";
+ public static final String COLUMN_SQ_CFG_INDEX = "SQ_CFG_INDEX";
- public static final String CONSTRAINT_SQF_SQC_NAME = CONSTRAINT_PREFIX + "SQF_SQC";
+ public static final String CONSTRAINT_SQ_CFG_SQC_NAME = CONSTRAINT_PREFIX + "SQ_CFG_SQC";
- public static final String CONSTRAINT_SQF_SQC = SCHEMA_PREFIX + CONSTRAINT_SQF_SQC_NAME;
+ public static final String CONSTRAINT_SQ_CFG_SQC = SCHEMA_PREFIX + CONSTRAINT_SQ_CFG_SQC_NAME;
// SQ_INPUT
@@ -92,7 +92,7 @@ public final class DerbySchemaConstants {
public static final String COLUMN_SQI_NAME = "SQI_NAME";
- public static final String COLUMN_SQI_FORM = "SQI_FORM";
+ public static final String COLUMN_SQI_CONFIG = "SQI_CONFIG";
public static final String COLUMN_SQI_INDEX = "SQI_INDEX";
@@ -104,36 +104,34 @@ public final class DerbySchemaConstants {
public static final String COLUMN_SQI_ENUMVALS = "SQI_ENUMVALS";
- public static final String CONSTRAINT_SQI_SQF_NAME = CONSTRAINT_PREFIX + "SQI_SQF";
+ public static final String CONSTRAINT_SQI_SQ_CFG_NAME = CONSTRAINT_PREFIX + "SQI_SQ_CFG";
- public static final String CONSTRAINT_SQI_SQF = SCHEMA_PREFIX + CONSTRAINT_SQI_SQF_NAME;
+ public static final String CONSTRAINT_SQI_SQ_CFG = SCHEMA_PREFIX + CONSTRAINT_SQI_SQ_CFG_NAME;
- // SQ_CONNECTION
+ public static final String TABLE_SQ_LINK_NAME = "SQ_LINK";
- public static final String TABLE_SQ_CONNECTION_NAME = "SQ_CONNECTION";
+ public static final String TABLE_SQ_LINK = SCHEMA_PREFIX
+ + TABLE_SQ_LINK_NAME;
- public static final String TABLE_SQ_CONNECTION = SCHEMA_PREFIX
- + TABLE_SQ_CONNECTION_NAME;
+ public static final String COLUMN_SQ_LNK_ID = "SQ_LNK_ID";
- public static final String COLUMN_SQN_ID = "SQN_ID";
+ public static final String COLUMN_SQ_LNK_NAME = "SQ_LNK_NAME";
- public static final String COLUMN_SQN_NAME = "SQN_NAME";
+ public static final String COLUMN_SQ_LNK_CONNECTOR = "SQ_LNK_CONNECTOR";
- public static final String COLUMN_SQN_CONNECTOR = "SQN_CONNECTOR";
+ public static final String COLUMN_SQ_LNK_CREATION_USER = "SQ_LNK_CREATION_USER";
- public static final String COLUMN_SQN_CREATION_USER = "SQN_CREATION_USER";
+ public static final String COLUMN_SQ_LNK_CREATION_DATE = "SQ_LNK_CREATION_DATE";
- public static final String COLUMN_SQN_CREATION_DATE = "SQN_CREATION_DATE";
+ public static final String COLUMN_SQ_LNK_UPDATE_USER = "SQ_LNK_UPDATE_USER";
- public static final String COLUMN_SQN_UPDATE_USER = "SQN_UPDATE_USER";
+ public static final String COLUMN_SQ_LNK_UPDATE_DATE = "SQ_LNK_UPDATE_DATE";
- public static final String COLUMN_SQN_UPDATE_DATE = "SQN_UPDATE_DATE";
+ public static final String COLUMN_SQ_LNK_ENABLED = "SQ_LNK_ENABLED";
- public static final String COLUMN_SQN_ENABLED = "SQN_ENABLED";
+ public static final String CONSTRAINT_SQ_LNK_SQC_NAME = CONSTRAINT_PREFIX + "SQ_LNK_SQC";
- public static final String CONSTRAINT_SQN_SQC_NAME = CONSTRAINT_PREFIX + "SQN_SQC";
-
- public static final String CONSTRAINT_SQN_SQC = SCHEMA_PREFIX + CONSTRAINT_SQN_SQC_NAME;
+ public static final String CONSTRAINT_SQ_LNK_SQC = SCHEMA_PREFIX + CONSTRAINT_SQ_LNK_SQC_NAME;
// SQ_JOB
@@ -146,13 +144,13 @@ public final class DerbySchemaConstants {
public static final String COLUMN_SQB_NAME = "SQB_NAME";
- public static final String COLUMN_SQB_CONNECTION = "SQB_CONNECTION";
+ public static final String COLUMN_SQB_LINK = "SQB_LINK";
public static final String COLUMN_SQB_TYPE = "SQB_TYPE";
- public static final String COLUMN_SQB_FROM_CONNECTION = "SQB_FROM_CONNECTION";
+ public static final String COLUMN_SQB_FROM_LINK = "SQB_FROM_LINK";
- public static final String COLUMN_SQB_TO_CONNECTION = "SQB_TO_CONNECTION";
+ public static final String COLUMN_SQB_TO_LINK = "SQB_TO_LINK";
public static final String COLUMN_SQB_CREATION_USER = "SQB_CREATION_USER";
@@ -164,39 +162,37 @@ public final class DerbySchemaConstants {
public static final String COLUMN_SQB_ENABLED = "SQB_ENABLED";
- public static final String CONSTRAINT_SQB_SQN_NAME = CONSTRAINT_PREFIX + "SQB_SQN";
-
- public static final String CONSTRAINT_SQB_SQN = SCHEMA_PREFIX + CONSTRAINT_SQB_SQN_NAME;
+ public static final String CONSTRAINT_SQB_SQ_LNK_NAME = CONSTRAINT_PREFIX + "SQB_SQ_LNK";
- public static final String CONSTRAINT_SQB_SQN_FROM_NAME = CONSTRAINT_PREFIX + "SQB_SQN_FROM";
+ public static final String CONSTRAINT_SQB_SQ_LNK = SCHEMA_PREFIX + CONSTRAINT_SQB_SQ_LNK_NAME;
- public static final String CONSTRAINT_SQB_SQN_FROM = SCHEMA_PREFIX + CONSTRAINT_SQB_SQN_FROM_NAME;
+ public static final String CONSTRAINT_SQB_SQ_LNK_FROM_NAME = CONSTRAINT_PREFIX + "SQB_SQ_LNK_FROM";
- public static final String CONSTRAINT_SQB_SQN_TO_NAME = CONSTRAINT_PREFIX + "SQB_SQN_TO";
+ public static final String CONSTRAINT_SQB_SQ_LNK_FROM = SCHEMA_PREFIX + CONSTRAINT_SQB_SQ_LNK_FROM_NAME;
- public static final String CONSTRAINT_SQB_SQN_TO = SCHEMA_PREFIX + CONSTRAINT_SQB_SQN_TO_NAME;
+ public static final String CONSTRAINT_SQB_SQ_LNK_TO_NAME = CONSTRAINT_PREFIX + "SQB_SQ_LNK_TO";
- // SQ_CONNECTION_INPUT
+ public static final String CONSTRAINT_SQB_SQ_LNK_TO = SCHEMA_PREFIX + CONSTRAINT_SQB_SQ_LNK_TO_NAME;
- public static final String TABLE_SQ_CONNECTION_INPUT_NAME =
- "SQ_CONNECTION_INPUT";
+ public static final String TABLE_SQ_LINK_INPUT_NAME =
+ "SQ_LINK_INPUT";
- public static final String TABLE_SQ_CONNECTION_INPUT = SCHEMA_PREFIX
- + TABLE_SQ_CONNECTION_INPUT_NAME;
+ public static final String TABLE_SQ_LINK_INPUT = SCHEMA_PREFIX
+ + TABLE_SQ_LINK_INPUT_NAME;
- public static final String COLUMN_SQNI_CONNECTION = "SQNI_CONNECTION";
+ public static final String COLUMN_SQ_LNKI_LINK = "SQ_LNKI_LINK";
- public static final String COLUMN_SQNI_INPUT = "SQNI_INPUT";
+ public static final String COLUMN_SQ_LNKI_INPUT = "SQ_LNKI_INPUT";
- public static final String COLUMN_SQNI_VALUE = "SQNI_VALUE";
+ public static final String COLUMN_SQ_LNKI_VALUE = "SQ_LNKI_VALUE";
- public static final String CONSTRAINT_SQNI_SQN_NAME = CONSTRAINT_PREFIX + "SQNI_SQN";
+ public static final String CONSTRAINT_SQ_LNKI_SQ_LNK_NAME = CONSTRAINT_PREFIX + "SQ_LNKI_SQ_LNK";
- public static final String CONSTRAINT_SQNI_SQN = SCHEMA_PREFIX + CONSTRAINT_SQNI_SQN_NAME;
+ public static final String CONSTRAINT_SQ_LNKI_SQ_LNK = SCHEMA_PREFIX + CONSTRAINT_SQ_LNKI_SQ_LNK_NAME;
- public static final String CONSTRAINT_SQNI_SQI_NAME = CONSTRAINT_PREFIX + "SQNI_SQI";
+ public static final String CONSTRAINT_SQ_LNKI_SQI_NAME = CONSTRAINT_PREFIX + "SQ_LNKI_SQI";
- public static final String CONSTRAINT_SQNI_SQI = SCHEMA_PREFIX + CONSTRAINT_SQNI_SQI_NAME;
+ public static final String CONSTRAINT_SQ_LNKI_SQI = SCHEMA_PREFIX + CONSTRAINT_SQ_LNKI_SQI_NAME;
// SQ_JOB_INPUT
@@ -314,12 +310,12 @@ public final class DerbySchemaConstants {
static {
tablesV1 = new HashSet<String>();
tablesV1.add(TABLE_SQ_CONNECTOR_NAME);
- tablesV1.add(TABLE_SQ_CONNECTION_NAME);
- tablesV1.add(TABLE_SQ_CONNECTION_INPUT_NAME);
+ tablesV1.add(TABLE_SQ_LINK_NAME);
+ tablesV1.add(TABLE_SQ_LINK_INPUT_NAME);
tablesV1.add(TABLE_SQ_COUNTER_NAME);
tablesV1.add(TABLE_SQ_COUNTER_GROUP_NAME);
tablesV1.add(TABLE_SQ_COUNTER_SUBMISSION_NAME);
- tablesV1.add(TABLE_SQ_FORM_NAME);
+ tablesV1.add(TABLE_SQ_CONFIG_NAME);
tablesV1.add(TABLE_SQ_INPUT_NAME);
tablesV1.add(TABLE_SQ_JOB_NAME);
tablesV1.add(TABLE_SQ_JOB_INPUT_NAME);
[04/13] SQOOP-1498: Sqoop2: Repository Object refactoring (objects
prefixed with M)
Posted by ab...@apache.org.
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaQuery.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaQuery.java b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaQuery.java
index ad42901..951d9b4 100644
--- a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaQuery.java
+++ b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaQuery.java
@@ -48,17 +48,17 @@ import static org.apache.sqoop.repository.derby.DerbySchemaConstants.*;
* </pre>
* </p>
* <p>
- * <strong>SQ_FORM</strong>: Form details.
+ * <strong>SQ_CONFIG</strong>: Config details.
* <pre>
* +----------------------------------+
- * | SQ_FORM |
+ * | SQ_CONFIG |
* +----------------------------------+
- * | SQF_ID: BIGINT PK AUTO-GEN |
- * | SQF_CONNECTOR: BIGINT | FK SQ_CONNECTOR(SQC_ID),NULL for framework
- * | SQF_DIRECTION: VARCHAR(32) | "FROM"|"TO"|NULL
- * | SQF_NAME: VARCHAR(64) |
- * | SQF_TYPE: VARCHAR(32) | "CONNECTION"|"JOB"
- * | SQF_INDEX: SMALLINT |
+ * | SQ_CFG_ID: BIGINT PK AUTO-GEN |
+ * | SQ_CFG_OWNER: BIGINT | FK SQ_CFG_OWNER(SQC_ID),NULL for driver
+ * | SQ_CFG_DIRECTION: VARCHAR(32) | "FROM"|"TO"|NULL
+ * | SQ_CFG_NAME: VARCHAR(64) |
+ * | SQ_CFG_TYPE: VARCHAR(32) | "LINK"|"JOB"
+ * | SQ_CFG_INDEX: SMALLINT |
* +----------------------------------+
* </pre>
* </p>
@@ -70,7 +70,7 @@ import static org.apache.sqoop.repository.derby.DerbySchemaConstants.*;
* +----------------------------+
* | SQI_ID: BIGINT PK AUTO-GEN |
* | SQI_NAME: VARCHAR(64) |
- * | SQI_FORM: BIGINT | FK SQ_FORM(SQF_ID)
+ * | SQI_CONFIG: BIGINT | FK SQ_CONFIG(SQ_CFG_ID)
* | SQI_INDEX: SMALLINT |
* | SQI_TYPE: VARCHAR(32) | "STRING"|"MAP"
* | SQI_STRMASK: BOOLEAN |
@@ -80,19 +80,19 @@ import static org.apache.sqoop.repository.derby.DerbySchemaConstants.*;
* </pre>
* </p>
* <p>
- * <strong>SQ_CONNECTION</strong>: Stored connections
+ * <strong>SQ_LINK</strong>: Stored connections
* <pre>
* +--------------------------------+
- * | SQ_CONNECTION |
+ * | SQ_LINK |
* +--------------------------------+
- * | SQN_ID: BIGINT PK AUTO-GEN |
- * | SQN_NAME: VARCHAR(64) |
- * | SQN_CONNECTOR: BIGINT | FK SQ_CONNECTOR(SQC_ID)
- * | SQN_CREATION_USER: VARCHAR(32) |
- * | SQN_CREATION_DATE: TIMESTAMP |
- * | SQN_UPDATE_USER: VARCHAR(32) |
- * | SQN_UPDATE_DATE: TIMESTAMP |
- * | SQN_ENABLED: BOOLEAN |
+ * | SQ_LNK_ID: BIGINT PK AUTO-GEN |
+ * | SQ_LNK_NAME: VARCHAR(64) |
+ * | SQ_LNK_CONNECTOR: BIGINT | FK SQ_CONNECTOR(SQC_ID)
+ * | SQ_LNK_CREATION_USER: VARCHAR(32) |
+ * | SQ_LNK_CREATION_DATE: TIMESTAMP |
+ * | SQ_LNK_UPDATE_USER: VARCHAR(32) |
+ * | SQ_LNK_UPDATE_DATE: TIMESTAMP |
+ * | SQ_LNK_ENABLED: BOOLEAN |
* +--------------------------------+
* </pre>
* </p>
@@ -104,8 +104,8 @@ import static org.apache.sqoop.repository.derby.DerbySchemaConstants.*;
* +--------------------------------+
* | SQB_ID: BIGINT PK AUTO-GEN |
* | SQB_NAME: VARCHAR(64) |
- * | SQB_FROM_CONNECTION: BIGINT | FK SQ_CONNECTION(SQN_ID)
- * | SQB_TO_CONNECTION: BIGINT | FK SQ_CONNECTION(SQN_ID)
+ * | SQB_FROM_LINK: BIGINT | FK SQ_LINK(SQ_LNK_ID)
+ * | SQB_TO_LINK: BIGINT | FK SQ_LINK(SQ_LNK_ID)
* | SQB_CREATION_USER: VARCHAR(32) |
* | SQB_CREATION_DATE: TIMESTAMP |
* | SQB_UPDATE_USER: VARCHAR(32) |
@@ -115,14 +115,14 @@ import static org.apache.sqoop.repository.derby.DerbySchemaConstants.*;
* </pre>
* </p>
* <p>
- * <strong>SQ_CONNECTION_INPUT</strong>: N:M relationship connection and input
+ * <strong>SQ_LINK_INPUT</strong>: N:M relationship link and input
* <pre>
* +----------------------------+
- * | SQ_CONNECTION_INPUT |
+ * | SQ_LINK_INPUT |
* +----------------------------+
- * | SQNI_CONNECTION: BIGINT PK | FK SQ_CONNECTION(SQN_ID)
- * | SQNI_INPUT: BIGINT PK | FK SQ_INPUT(SQI_ID)
- * | SQNI_VALUE: LONG VARCHAR |
+ * | SQ_LNKI_LINK: BIGINT PK | FK SQ_LINK(SQ_LNK_ID)
+ * | SQ_LNKI_INPUT: BIGINT PK | FK SQ_INPUT(SQI_ID)
+ * | SQ_LNKI_VALUE: LONG VARCHAR |
* +----------------------------+
* </pre>
* </p>
@@ -221,17 +221,17 @@ public final class DerbySchemaQuery {
+ COLUMN_SQC_VERSION + " VARCHAR(64) "
+ ")";
- // DDL: Create table SQ_FORM
- public static final String QUERY_CREATE_TABLE_SQ_FORM =
- "CREATE TABLE " + TABLE_SQ_FORM + " ("
- + COLUMN_SQF_ID + " BIGINT GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1) PRIMARY KEY, "
- + COLUMN_SQF_CONNECTOR + " BIGINT, "
- + COLUMN_SQF_OPERATION + " VARCHAR(32), "
- + COLUMN_SQF_NAME + " VARCHAR(64), "
- + COLUMN_SQF_TYPE + " VARCHAR(32), "
- + COLUMN_SQF_INDEX + " SMALLINT, "
- + "CONSTRAINT " + CONSTRAINT_SQF_SQC + " "
- + "FOREIGN KEY (" + COLUMN_SQF_CONNECTOR + ") "
+ // DDL: Create table SQ_CONFIG ( It stores the configs defined by every connector), if connector is null then it is driver config
+ public static final String QUERY_CREATE_TABLE_SQ_CONFIG =
+ "CREATE TABLE " + TABLE_SQ_CONFIG + " ("
+ + COLUMN_SQ_CFG_ID + " BIGINT GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1) PRIMARY KEY, "
+ + COLUMN_SQ_CFG_OWNER + " BIGINT, "
+ + COLUMN_SQ_CFG_OPERATION + " VARCHAR(32), "
+ + COLUMN_SQ_CFG_NAME + " VARCHAR(64), "
+ + COLUMN_SQ_CFG_TYPE + " VARCHAR(32), "
+ + COLUMN_SQ_CFG_INDEX + " SMALLINT, "
+ + "CONSTRAINT " + CONSTRAINT_SQ_CFG_SQC + " "
+ + "FOREIGN KEY (" + COLUMN_SQ_CFG_OWNER + ") "
+ "REFERENCES " + TABLE_SQ_CONNECTOR + " (" + COLUMN_SQC_ID + ")"
+ ")";
@@ -240,60 +240,60 @@ public final class DerbySchemaQuery {
"CREATE TABLE " + TABLE_SQ_INPUT + " ("
+ COLUMN_SQI_ID + " BIGINT GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1) PRIMARY KEY, "
+ COLUMN_SQI_NAME + " VARCHAR(64), "
- + COLUMN_SQI_FORM + " BIGINT, "
+ + COLUMN_SQI_CONFIG + " BIGINT, "
+ COLUMN_SQI_INDEX + " SMALLINT, "
+ COLUMN_SQI_TYPE + " VARCHAR(32), "
+ COLUMN_SQI_STRMASK + " BOOLEAN, "
+ COLUMN_SQI_STRLENGTH + " SMALLINT, "
+ COLUMN_SQI_ENUMVALS + " VARCHAR(100),"
- + "CONSTRAINT " + CONSTRAINT_SQI_SQF + " "
- + "FOREIGN KEY (" + COLUMN_SQI_FORM + ") "
- + "REFERENCES " + TABLE_SQ_FORM + " (" + COLUMN_SQF_ID + ")"
+ + "CONSTRAINT " + CONSTRAINT_SQI_SQ_CFG + " "
+ + "FOREIGN KEY (" + COLUMN_SQI_CONFIG + ") "
+ + "REFERENCES " + TABLE_SQ_CONFIG + " (" + COLUMN_SQ_CFG_ID + ")"
+ ")";
- // DDL: Create table SQ_CONNECTION
- public static final String QUERY_CREATE_TABLE_SQ_CONNECTION =
- "CREATE TABLE " + TABLE_SQ_CONNECTION + " ("
- + COLUMN_SQN_ID + " BIGINT GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1) PRIMARY KEY, "
- + COLUMN_SQN_CONNECTOR + " BIGINT, "
- + COLUMN_SQN_NAME + " VARCHAR(32),"
- + COLUMN_SQN_CREATION_DATE + " TIMESTAMP,"
- + COLUMN_SQN_UPDATE_DATE + " TIMESTAMP,"
- + "CONSTRAINT " + CONSTRAINT_SQN_SQC + " "
- + "FOREIGN KEY(" + COLUMN_SQN_CONNECTOR + ") "
+ // DDL: Create table SQ_LINK
+ public static final String QUERY_CREATE_TABLE_SQ_LINK =
+ "CREATE TABLE " + TABLE_SQ_LINK + " ("
+ + COLUMN_SQ_LNK_ID + " BIGINT GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1) PRIMARY KEY, "
+ + COLUMN_SQ_LNK_CONNECTOR + " BIGINT, "
+ + COLUMN_SQ_LNK_NAME + " VARCHAR(32),"
+ + COLUMN_SQ_LNK_CREATION_DATE + " TIMESTAMP,"
+ + COLUMN_SQ_LNK_UPDATE_DATE + " TIMESTAMP,"
+ + "CONSTRAINT " + CONSTRAINT_SQ_LNK_SQC + " "
+ + "FOREIGN KEY(" + COLUMN_SQ_LNK_CONNECTOR + ") "
+ " REFERENCES " + TABLE_SQ_CONNECTOR + " (" + COLUMN_SQC_ID + ")"
+ ")";
- // DDL: Add enabled column to table SQ_CONNECTION
- public static final String QUERY_UPGRADE_TABLE_SQ_CONNECTION_ADD_COLUMN_ENABLED =
- "ALTER TABLE " + TABLE_SQ_CONNECTION + " ADD "
- + COLUMN_SQN_ENABLED + " BOOLEAN "
+ // DDL: Add enabled column to table SQ_LINK
+ public static final String QUERY_UPGRADE_TABLE_SQ_LINK_ADD_COLUMN_ENABLED =
+ "ALTER TABLE " + TABLE_SQ_LINK + " ADD "
+ + COLUMN_SQ_LNK_ENABLED + " BOOLEAN "
+ "DEFAULT TRUE";
- // DDL: Add creation_user column to table SQ_CONNECTION
- public static final String QUERY_UPGRADE_TABLE_SQ_CONNECTION_ADD_COLUMN_CREATION_USER =
- "ALTER TABLE " + TABLE_SQ_CONNECTION + " ADD "
- + COLUMN_SQN_CREATION_USER + " VARCHAR(32) "
+ // DDL: Add creation_user column to table SQ_LINK
+ public static final String QUERY_UPGRADE_TABLE_SQ_LINK_ADD_COLUMN_CREATION_USER =
+ "ALTER TABLE " + TABLE_SQ_LINK + " ADD "
+ + COLUMN_SQ_LNK_CREATION_USER + " VARCHAR(32) "
+ "DEFAULT NULL";
- // DDL: Add update_user column to table SQ_CONNECTION
- public static final String QUERY_UPGRADE_TABLE_SQ_CONNECTION_ADD_COLUMN_UPDATE_USER =
- "ALTER TABLE " + TABLE_SQ_CONNECTION + " ADD "
- + COLUMN_SQN_UPDATE_USER + " VARCHAR(32) "
+ // DDL: Add update_user column to table SQ_LINK
+ public static final String QUERY_UPGRADE_TABLE_SQ_LINK_ADD_COLUMN_UPDATE_USER =
+ "ALTER TABLE " + TABLE_SQ_LINK + " ADD "
+ + COLUMN_SQ_LNK_UPDATE_USER + " VARCHAR(32) "
+ "DEFAULT NULL";
// DDL: Create table SQ_JOB
public static final String QUERY_CREATE_TABLE_SQ_JOB =
"CREATE TABLE " + TABLE_SQ_JOB + " ("
+ COLUMN_SQB_ID + " BIGINT GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1) PRIMARY KEY, "
- + COLUMN_SQB_CONNECTION + " BIGINT, "
+ + COLUMN_SQB_LINK + " BIGINT, "
+ COLUMN_SQB_NAME + " VARCHAR(64), "
+ COLUMN_SQB_TYPE + " VARCHAR(64),"
+ COLUMN_SQB_CREATION_DATE + " TIMESTAMP,"
+ COLUMN_SQB_UPDATE_DATE + " TIMESTAMP,"
- + "CONSTRAINT " + CONSTRAINT_SQB_SQN + " "
- + "FOREIGN KEY(" + COLUMN_SQB_CONNECTION + ") "
- + "REFERENCES " + TABLE_SQ_CONNECTION + " (" + COLUMN_SQN_ID + ")"
+ + "CONSTRAINT " + CONSTRAINT_SQB_SQ_LNK + " "
+ + "FOREIGN KEY(" + COLUMN_SQB_LINK + ") "
+ + "REFERENCES " + TABLE_SQ_LINK + " (" + COLUMN_SQ_LNK_ID + ")"
+ ")";
// DDL: Add enabled column to table SQ_JOB
@@ -314,18 +314,18 @@ public final class DerbySchemaQuery {
+ COLUMN_SQB_UPDATE_USER + " VARCHAR(32) "
+ "DEFAULT NULL";
- // DDL: Create table SQ_CONNECTION_INPUT
- public static final String QUERY_CREATE_TABLE_SQ_CONNECTION_INPUT =
- "CREATE TABLE " + TABLE_SQ_CONNECTION_INPUT + " ("
- + COLUMN_SQNI_CONNECTION + " BIGINT, "
- + COLUMN_SQNI_INPUT + " BIGINT, "
- + COLUMN_SQNI_VALUE + " LONG VARCHAR,"
- + "PRIMARY KEY (" + COLUMN_SQNI_CONNECTION + ", " + COLUMN_SQNI_INPUT + "), "
- + "CONSTRAINT " + CONSTRAINT_SQNI_SQN + " "
- + "FOREIGN KEY (" + COLUMN_SQNI_CONNECTION + ") "
- + "REFERENCES " + TABLE_SQ_CONNECTION + " (" + COLUMN_SQN_ID + "),"
- + "CONSTRAINT " + CONSTRAINT_SQNI_SQI + " "
- + "FOREIGN KEY (" + COLUMN_SQNI_INPUT + ") "
+ // DDL: Create table SQ_LINK_INPUT
+ public static final String QUERY_CREATE_TABLE_SQ_LINK_INPUT =
+ "CREATE TABLE " + TABLE_SQ_LINK_INPUT + " ("
+ + COLUMN_SQ_LNKI_LINK + " BIGINT, "
+ + COLUMN_SQ_LNKI_INPUT + " BIGINT, "
+ + COLUMN_SQ_LNKI_VALUE + " LONG VARCHAR,"
+ + "PRIMARY KEY (" + COLUMN_SQ_LNKI_LINK + ", " + COLUMN_SQ_LNKI_INPUT + "), "
+ + "CONSTRAINT " + CONSTRAINT_SQ_LNKI_SQ_LNK + " "
+ + "FOREIGN KEY (" + COLUMN_SQ_LNKI_LINK + ") "
+ + "REFERENCES " + TABLE_SQ_LINK + " (" + COLUMN_SQ_LNK_ID + "),"
+ + "CONSTRAINT " + CONSTRAINT_SQ_LNKI_SQI + " "
+ + "FOREIGN KEY (" + COLUMN_SQ_LNKI_INPUT + ") "
+ "REFERENCES " + TABLE_SQ_INPUT + " (" + COLUMN_SQI_ID + ")"
+ ")";
@@ -454,38 +454,38 @@ public final class DerbySchemaQuery {
+ COLUMN_SQC_VERSION
+ " FROM " + TABLE_SQ_CONNECTOR;
- // DML: Fetch all forms for a given connector
- public static final String STMT_FETCH_FORM_CONNECTOR =
+ // DML: Fetch all configs for a given connector
+ public static final String STMT_FETCH_CONFIG_CONNECTOR =
"SELECT "
- + COLUMN_SQF_ID + ", "
- + COLUMN_SQF_CONNECTOR + ", "
- + COLUMN_SQF_DIRECTION + ", "
- + COLUMN_SQF_NAME + ", "
- + COLUMN_SQF_TYPE + ", "
- + COLUMN_SQF_INDEX
- + " FROM " + TABLE_SQ_FORM
- + " WHERE " + COLUMN_SQF_CONNECTOR + " = ? "
- + " ORDER BY " + COLUMN_SQF_INDEX;
-
- // DML: Fetch all framework forms
- public static final String STMT_FETCH_FORM_FRAMEWORK =
+ + COLUMN_SQ_CFG_ID + ", "
+ + COLUMN_SQ_CFG_OWNER + ", "
+ + COLUMN_SQ_CFG_DIRECTION + ", "
+ + COLUMN_SQ_CFG_NAME + ", "
+ + COLUMN_SQ_CFG_TYPE + ", "
+ + COLUMN_SQ_CFG_INDEX
+ + " FROM " + TABLE_SQ_CONFIG
+ + " WHERE " + COLUMN_SQ_CFG_OWNER + " = ? "
+ + " ORDER BY " + COLUMN_SQ_CFG_INDEX;
+
+ // DML: Fetch all driver configs
+ public static final String STMT_FETCH_CONFIG_DRIVER =
"SELECT "
- + COLUMN_SQF_ID + ", "
- + COLUMN_SQF_CONNECTOR + ", "
- + COLUMN_SQF_DIRECTION + ", "
- + COLUMN_SQF_NAME + ", "
- + COLUMN_SQF_TYPE + ", "
- + COLUMN_SQF_INDEX
- + " FROM " + TABLE_SQ_FORM
- + " WHERE " + COLUMN_SQF_CONNECTOR + " IS NULL "
- + " ORDER BY " + COLUMN_SQF_TYPE + ", " + COLUMN_SQF_DIRECTION + ", " + COLUMN_SQF_INDEX;
-
- // DML: Fetch inputs for a given form
+ + COLUMN_SQ_CFG_ID + ", "
+ + COLUMN_SQ_CFG_OWNER + ", "
+ + COLUMN_SQ_CFG_DIRECTION + ", "
+ + COLUMN_SQ_CFG_NAME + ", "
+ + COLUMN_SQ_CFG_TYPE + ", "
+ + COLUMN_SQ_CFG_INDEX
+ + " FROM " + TABLE_SQ_CONFIG
+ + " WHERE " + COLUMN_SQ_CFG_OWNER + " IS NULL "
+ + " ORDER BY " + COLUMN_SQ_CFG_TYPE + ", " + COLUMN_SQ_CFG_DIRECTION + ", " + COLUMN_SQ_CFG_INDEX;
+
+ // DML: Fetch inputs for a given config
public static final String STMT_FETCH_INPUT =
"SELECT "
+ COLUMN_SQI_ID + ", "
+ COLUMN_SQI_NAME + ", "
- + COLUMN_SQI_FORM + ", "
+ + COLUMN_SQI_CONFIG + ", "
+ COLUMN_SQI_INDEX + ", "
+ COLUMN_SQI_TYPE + ", "
+ COLUMN_SQI_STRMASK + ", "
@@ -493,27 +493,27 @@ public final class DerbySchemaQuery {
+ COLUMN_SQI_ENUMVALS + ", "
+ "cast(null as varchar(100))"
+ " FROM " + TABLE_SQ_INPUT
- + " WHERE " + COLUMN_SQI_FORM + " = ?"
+ + " WHERE " + COLUMN_SQI_CONFIG + " = ?"
+ " ORDER BY " + COLUMN_SQI_INDEX;
- // DML: Fetch inputs and values for a given connection
- public static final String STMT_FETCH_CONNECTION_INPUT =
+ // DML: Fetch inputs and values for a given link
+ public static final String STMT_FETCH_LINK_INPUT =
"SELECT "
+ COLUMN_SQI_ID + ", "
+ COLUMN_SQI_NAME + ", "
- + COLUMN_SQI_FORM + ", "
+ + COLUMN_SQI_CONFIG + ", "
+ COLUMN_SQI_INDEX + ", "
+ COLUMN_SQI_TYPE + ", "
+ COLUMN_SQI_STRMASK + ", "
+ COLUMN_SQI_STRLENGTH + ","
+ COLUMN_SQI_ENUMVALS + ", "
- + COLUMN_SQNI_VALUE
+ + COLUMN_SQ_LNKI_VALUE
+ " FROM " + TABLE_SQ_INPUT
- + " LEFT OUTER JOIN " + TABLE_SQ_CONNECTION_INPUT
- + " ON " + COLUMN_SQNI_INPUT + " = " + COLUMN_SQI_ID
- + " AND " + COLUMN_SQNI_CONNECTION + " = ?"
- + " WHERE " + COLUMN_SQI_FORM + " = ?"
- + " AND (" + COLUMN_SQNI_CONNECTION + " = ?" + " OR " + COLUMN_SQNI_CONNECTION + " IS NULL)"
+ + " LEFT OUTER JOIN " + TABLE_SQ_LINK_INPUT
+ + " ON " + COLUMN_SQ_LNKI_INPUT + " = " + COLUMN_SQI_ID
+ + " AND " + COLUMN_SQ_LNKI_LINK + " = ?"
+ + " WHERE " + COLUMN_SQI_CONFIG + " = ?"
+ + " AND (" + COLUMN_SQ_LNKI_LINK + " = ?" + " OR " + COLUMN_SQ_LNKI_LINK + " IS NULL)"
+ " ORDER BY " + COLUMN_SQI_INDEX;
// DML: Fetch inputs and values for a given job
@@ -521,7 +521,7 @@ public final class DerbySchemaQuery {
"SELECT "
+ COLUMN_SQI_ID + ", "
+ COLUMN_SQI_NAME + ", "
- + COLUMN_SQI_FORM + ", "
+ + COLUMN_SQI_CONFIG + ", "
+ COLUMN_SQI_INDEX + ", "
+ COLUMN_SQI_TYPE + ", "
+ COLUMN_SQI_STRMASK + ", "
@@ -532,7 +532,7 @@ public final class DerbySchemaQuery {
+ " LEFT OUTER JOIN " + TABLE_SQ_JOB_INPUT
+ " ON " + COLUMN_SQBI_INPUT + " = " + COLUMN_SQI_ID
+ " AND " + COLUMN_SQBI_JOB + " = ?"
- + " WHERE " + COLUMN_SQI_FORM + " = ?"
+ + " WHERE " + COLUMN_SQI_CONFIG + " = ?"
+ " AND (" + COLUMN_SQBI_JOB + " = ? OR " + COLUMN_SQBI_JOB + " IS NULL)"
+ " ORDER BY " + COLUMN_SQI_INDEX;
@@ -544,21 +544,21 @@ public final class DerbySchemaQuery {
+ COLUMN_SQC_VERSION
+ ") VALUES (?, ?, ?)";
- // DML: Insert form base
- public static final String STMT_INSERT_FORM_BASE =
- "INSERT INTO " + TABLE_SQ_FORM + " ("
- + COLUMN_SQF_CONNECTOR + ", "
- + COLUMN_SQF_DIRECTION + ", "
- + COLUMN_SQF_NAME + ", "
- + COLUMN_SQF_TYPE + ", "
- + COLUMN_SQF_INDEX
+ // DML: Insert config base
+ public static final String STMT_INSERT_CONFIG_BASE =
+ "INSERT INTO " + TABLE_SQ_CONFIG + " ("
+ + COLUMN_SQ_CFG_OWNER + ", "
+ + COLUMN_SQ_CFG_DIRECTION + ", "
+ + COLUMN_SQ_CFG_NAME + ", "
+ + COLUMN_SQ_CFG_TYPE + ", "
+ + COLUMN_SQ_CFG_INDEX
+ ") VALUES ( ?, ?, ?, ?, ?)";
- // DML: Insert form input
+ // DML: Insert config input
public static final String STMT_INSERT_INPUT_BASE =
"INSERT INTO " + TABLE_SQ_INPUT + " ("
+ COLUMN_SQI_NAME + ", "
- + COLUMN_SQI_FORM + ", "
+ + COLUMN_SQI_CONFIG + ", "
+ COLUMN_SQI_INDEX + ", "
+ COLUMN_SQI_TYPE + ", "
+ COLUMN_SQI_STRMASK + ", "
@@ -566,37 +566,37 @@ public final class DerbySchemaQuery {
+ COLUMN_SQI_ENUMVALS
+ ") VALUES (?, ?, ?, ?, ?, ?, ?)";
- // Delete all forms for a given connector
- public static final String STMT_DELETE_FORMS_FOR_CONNECTOR =
- "DELETE FROM " + TABLE_SQ_FORM
- + " WHERE " + COLUMN_SQF_CONNECTOR + " = ?";
+ // Delete all configs for a given connector
+ public static final String STMT_DELETE_CONFIGS_FOR_CONNECTOR =
+ "DELETE FROM " + TABLE_SQ_CONFIG
+ + " WHERE " + COLUMN_SQ_CFG_OWNER + " = ?";
// Delete all inputs for a given connector
public static final String STMT_DELETE_INPUTS_FOR_CONNECTOR =
"DELETE FROM " + TABLE_SQ_INPUT
+ " WHERE "
- + COLUMN_SQI_FORM
+ + COLUMN_SQI_CONFIG
+ " IN (SELECT "
- + COLUMN_SQF_ID
- + " FROM " + TABLE_SQ_FORM
+ + COLUMN_SQ_CFG_ID
+ + " FROM " + TABLE_SQ_CONFIG
+ " WHERE "
- + COLUMN_SQF_CONNECTOR + " = ?)";
+ + COLUMN_SQ_CFG_OWNER + " = ?)";
- // Delete all framework inputs
- public static final String STMT_DELETE_FRAMEWORK_INPUTS =
+ // Delete all driver inputs
+ public static final String STMT_DELETE_DRIVER_INPUTS =
"DELETE FROM " + TABLE_SQ_INPUT
+ " WHERE "
- + COLUMN_SQI_FORM
+ + COLUMN_SQI_CONFIG
+ " IN (SELECT "
- + COLUMN_SQF_ID
- + " FROM " + TABLE_SQ_FORM
+ + COLUMN_SQ_CFG_ID
+ + " FROM " + TABLE_SQ_CONFIG
+ " WHERE "
- + COLUMN_SQF_CONNECTOR + " IS NULL)";
+ + COLUMN_SQ_CFG_OWNER + " IS NULL)";
- // Delete all framework forms
- public static final String STMT_DELETE_FRAMEWORK_FORMS =
- "DELETE FROM " + TABLE_SQ_FORM
- + " WHERE " + COLUMN_SQF_CONNECTOR + " IS NULL";
+ // Delete all driver configs
+ public static final String STMT_DELETE_DRIVER_CONFIGS =
+ "DELETE FROM " + TABLE_SQ_CONFIG
+ + " WHERE " + COLUMN_SQ_CFG_OWNER + " IS NULL";
@@ -608,102 +608,102 @@ public final class DerbySchemaQuery {
+ COLUMN_SQC_VERSION + " = ? "
+ " WHERE " + COLUMN_SQC_ID + " = ?";
- // DML: Insert new connection
- public static final String STMT_INSERT_CONNECTION =
- "INSERT INTO " + TABLE_SQ_CONNECTION + " ("
- + COLUMN_SQN_NAME + ", "
- + COLUMN_SQN_CONNECTOR + ", "
- + COLUMN_SQN_ENABLED + ", "
- + COLUMN_SQN_CREATION_USER + ", "
- + COLUMN_SQN_CREATION_DATE + ", "
- + COLUMN_SQN_UPDATE_USER + ", "
- + COLUMN_SQN_UPDATE_DATE
+ // DML: Insert new link
+ public static final String STMT_INSERT_LINK =
+ "INSERT INTO " + TABLE_SQ_LINK + " ("
+ + COLUMN_SQ_LNK_NAME + ", "
+ + COLUMN_SQ_LNK_CONNECTOR + ", "
+ + COLUMN_SQ_LNK_ENABLED + ", "
+ + COLUMN_SQ_LNK_CREATION_USER + ", "
+ + COLUMN_SQ_LNK_CREATION_DATE + ", "
+ + COLUMN_SQ_LNK_UPDATE_USER + ", "
+ + COLUMN_SQ_LNK_UPDATE_DATE
+ ") VALUES (?, ?, ?, ?, ?, ?, ?)";
- // DML: Insert new connection inputs
- public static final String STMT_INSERT_CONNECTION_INPUT =
- "INSERT INTO " + TABLE_SQ_CONNECTION_INPUT + " ("
- + COLUMN_SQNI_CONNECTION + ", "
- + COLUMN_SQNI_INPUT + ", "
- + COLUMN_SQNI_VALUE
+ // DML: Insert new link inputs
+ public static final String STMT_INSERT_LINK_INPUT =
+ "INSERT INTO " + TABLE_SQ_LINK_INPUT + " ("
+ + COLUMN_SQ_LNKI_LINK + ", "
+ + COLUMN_SQ_LNKI_INPUT + ", "
+ + COLUMN_SQ_LNKI_VALUE
+ ") VALUES (?, ?, ?)";
- // DML: Update connection
- public static final String STMT_UPDATE_CONNECTION =
- "UPDATE " + TABLE_SQ_CONNECTION + " SET "
- + COLUMN_SQN_NAME + " = ?, "
- + COLUMN_SQN_UPDATE_USER + " = ?, "
- + COLUMN_SQN_UPDATE_DATE + " = ? "
- + " WHERE " + COLUMN_SQN_ID + " = ?";
-
- // DML: Enable or disable connection
- public static final String STMT_ENABLE_CONNECTION =
- "UPDATE " + TABLE_SQ_CONNECTION + " SET "
- + COLUMN_SQN_ENABLED + " = ? "
- + " WHERE " + COLUMN_SQN_ID + " = ?";
-
- // DML: Delete rows from connection input table
- public static final String STMT_DELETE_CONNECTION_INPUT =
- "DELETE FROM " + TABLE_SQ_CONNECTION_INPUT
- + " WHERE " + COLUMN_SQNI_CONNECTION + " = ?";
-
- // DML: Delete row from connection table
- public static final String STMT_DELETE_CONNECTION =
- "DELETE FROM " + TABLE_SQ_CONNECTION
- + " WHERE " + COLUMN_SQN_ID + " = ?";
-
- // DML: Select one specific connection
- public static final String STMT_SELECT_CONNECTION_SINGLE =
+ // DML: Update link
+ public static final String STMT_UPDATE_LINK =
+ "UPDATE " + TABLE_SQ_LINK + " SET "
+ + COLUMN_SQ_LNK_NAME + " = ?, "
+ + COLUMN_SQ_LNK_UPDATE_USER + " = ?, "
+ + COLUMN_SQ_LNK_UPDATE_DATE + " = ? "
+ + " WHERE " + COLUMN_SQ_LNK_ID + " = ?";
+
+ // DML: Enable or disable link
+ public static final String STMT_ENABLE_LINK =
+ "UPDATE " + TABLE_SQ_LINK + " SET "
+ + COLUMN_SQ_LNK_ENABLED + " = ? "
+ + " WHERE " + COLUMN_SQ_LNK_ID + " = ?";
+
+ // DML: Delete rows from link input table
+ public static final String STMT_DELETE_LINK_INPUT =
+ "DELETE FROM " + TABLE_SQ_LINK_INPUT
+ + " WHERE " + COLUMN_SQ_LNKI_LINK + " = ?";
+
+ // DML: Delete row from link table
+ public static final String STMT_DELETE_LINK =
+ "DELETE FROM " + TABLE_SQ_LINK
+ + " WHERE " + COLUMN_SQ_LNK_ID + " = ?";
+
+ // DML: Select one specific link
+ public static final String STMT_SELECT_LINK_SINGLE =
"SELECT "
- + COLUMN_SQN_ID + ", "
- + COLUMN_SQN_NAME + ", "
- + COLUMN_SQN_CONNECTOR + ", "
- + COLUMN_SQN_ENABLED + ", "
- + COLUMN_SQN_CREATION_USER + ", "
- + COLUMN_SQN_CREATION_DATE + ", "
- + COLUMN_SQN_UPDATE_USER + ", "
- + COLUMN_SQN_UPDATE_DATE
- + " FROM " + TABLE_SQ_CONNECTION
- + " WHERE " + COLUMN_SQN_ID + " = ?";
+ + COLUMN_SQ_LNK_ID + ", "
+ + COLUMN_SQ_LNK_NAME + ", "
+ + COLUMN_SQ_LNK_CONNECTOR + ", "
+ + COLUMN_SQ_LNK_ENABLED + ", "
+ + COLUMN_SQ_LNK_CREATION_USER + ", "
+ + COLUMN_SQ_LNK_CREATION_DATE + ", "
+ + COLUMN_SQ_LNK_UPDATE_USER + ", "
+ + COLUMN_SQ_LNK_UPDATE_DATE
+ + " FROM " + TABLE_SQ_LINK
+ + " WHERE " + COLUMN_SQ_LNK_ID + " = ?";
// DML: Select all connections
- public static final String STMT_SELECT_CONNECTION_ALL =
+ public static final String STMT_SELECT_LINK_ALL =
"SELECT "
- + COLUMN_SQN_ID + ", "
- + COLUMN_SQN_NAME + ", "
- + COLUMN_SQN_CONNECTOR + ", "
- + COLUMN_SQN_ENABLED + ", "
- + COLUMN_SQN_CREATION_USER + ", "
- + COLUMN_SQN_CREATION_DATE + ", "
- + COLUMN_SQN_UPDATE_USER + ", "
- + COLUMN_SQN_UPDATE_DATE
- + " FROM " + TABLE_SQ_CONNECTION;
+ + COLUMN_SQ_LNK_ID + ", "
+ + COLUMN_SQ_LNK_NAME + ", "
+ + COLUMN_SQ_LNK_CONNECTOR + ", "
+ + COLUMN_SQ_LNK_ENABLED + ", "
+ + COLUMN_SQ_LNK_CREATION_USER + ", "
+ + COLUMN_SQ_LNK_CREATION_DATE + ", "
+ + COLUMN_SQ_LNK_UPDATE_USER + ", "
+ + COLUMN_SQ_LNK_UPDATE_DATE
+ + " FROM " + TABLE_SQ_LINK;
// DML: Select all connections for a specific connector.
- public static final String STMT_SELECT_CONNECTION_FOR_CONNECTOR =
+ public static final String STMT_SELECT_LINK_FOR_CONNECTOR =
"SELECT "
- + COLUMN_SQN_ID + ", "
- + COLUMN_SQN_NAME + ", "
- + COLUMN_SQN_CONNECTOR + ", "
- + COLUMN_SQN_ENABLED + ", "
- + COLUMN_SQN_CREATION_USER + ", "
- + COLUMN_SQN_CREATION_DATE + ", "
- + COLUMN_SQN_UPDATE_USER + ", "
- + COLUMN_SQN_UPDATE_DATE
- + " FROM " + TABLE_SQ_CONNECTION
- + " WHERE " + COLUMN_SQN_CONNECTOR + " = ?";
-
- // DML: Check if given connection exists
- public static final String STMT_SELECT_CONNECTION_CHECK =
- "SELECT count(*) FROM " + TABLE_SQ_CONNECTION
- + " WHERE " + COLUMN_SQN_ID + " = ?";
+ + COLUMN_SQ_LNK_ID + ", "
+ + COLUMN_SQ_LNK_NAME + ", "
+ + COLUMN_SQ_LNK_CONNECTOR + ", "
+ + COLUMN_SQ_LNK_ENABLED + ", "
+ + COLUMN_SQ_LNK_CREATION_USER + ", "
+ + COLUMN_SQ_LNK_CREATION_DATE + ", "
+ + COLUMN_SQ_LNK_UPDATE_USER + ", "
+ + COLUMN_SQ_LNK_UPDATE_DATE
+ + " FROM " + TABLE_SQ_LINK
+ + " WHERE " + COLUMN_SQ_LNK_CONNECTOR + " = ?";
+
+ // DML: Check if given link exists
+ public static final String STMT_SELECT_LINK_CHECK =
+ "SELECT count(*) FROM " + TABLE_SQ_LINK
+ + " WHERE " + COLUMN_SQ_LNK_ID + " = ?";
// DML: Insert new job
public static final String STMT_INSERT_JOB =
"INSERT INTO " + TABLE_SQ_JOB + " ("
+ COLUMN_SQB_NAME + ", "
- + COLUMN_SQB_FROM_CONNECTION + ", "
- + COLUMN_SQB_TO_CONNECTION + ", "
+ + COLUMN_SQB_FROM_LINK + ", "
+ + COLUMN_SQB_TO_LINK + ", "
+ COLUMN_SQB_ENABLED + ", "
+ COLUMN_SQB_CREATION_USER + ", "
+ COLUMN_SQB_CREATION_DATE + ", "
@@ -747,59 +747,59 @@ public final class DerbySchemaQuery {
"SELECT count(*) FROM " + TABLE_SQ_JOB
+ " WHERE " + COLUMN_SQB_ID + " = ?";
- // DML: Check if there are jobs for given connection
- public static final String STMT_SELECT_JOBS_FOR_CONNECTION_CHECK =
+ // DML: Check if there are jobs for given link
+ public static final String STMT_SELECT_JOBS_FOR_LINK_CHECK =
"SELECT"
+ " count(*)"
+ " FROM " + TABLE_SQ_JOB
- + " JOIN " + TABLE_SQ_CONNECTION
- + " ON " + COLUMN_SQB_FROM_CONNECTION + " = " + COLUMN_SQN_ID
- + " WHERE " + COLUMN_SQN_ID + " = ? ";
+ + " JOIN " + TABLE_SQ_LINK
+ + " ON " + COLUMN_SQB_FROM_LINK + " = " + COLUMN_SQ_LNK_ID
+ + " WHERE " + COLUMN_SQ_LNK_ID + " = ? ";
// DML: Select one specific job
public static final String STMT_SELECT_JOB_SINGLE =
"SELECT "
- + "FROM_CONNECTOR." + COLUMN_SQN_CONNECTOR + ", "
- + "TO_CONNECTOR." + COLUMN_SQN_CONNECTOR + ", "
+ + "FROM_CONNECTOR." + COLUMN_SQ_LNK_CONNECTOR + ", "
+ + "TO_CONNECTOR." + COLUMN_SQ_LNK_CONNECTOR + ", "
+ "job." + COLUMN_SQB_ID + ", "
+ "job." + COLUMN_SQB_NAME + ", "
- + "job." + COLUMN_SQB_FROM_CONNECTION + ", "
- + "job." + COLUMN_SQB_TO_CONNECTION + ", "
+ + "job." + COLUMN_SQB_FROM_LINK + ", "
+ + "job." + COLUMN_SQB_TO_LINK + ", "
+ "job." + COLUMN_SQB_ENABLED + ", "
+ "job." + COLUMN_SQB_CREATION_USER + ", "
+ "job." + COLUMN_SQB_CREATION_DATE + ", "
+ "job." + COLUMN_SQB_UPDATE_USER + ", "
+ "job." + COLUMN_SQB_UPDATE_DATE
+ " FROM " + TABLE_SQ_JOB + " job"
- + " LEFT JOIN " + TABLE_SQ_CONNECTION
- + " FROM_CONNECTOR ON " + COLUMN_SQB_FROM_CONNECTION + " = FROM_CONNECTOR." + COLUMN_SQN_ID
- + " LEFT JOIN " + TABLE_SQ_CONNECTION
- + " TO_CONNECTOR ON " + COLUMN_SQB_TO_CONNECTION + " = TO_CONNECTOR." + COLUMN_SQN_ID
+ + " LEFT JOIN " + TABLE_SQ_LINK
+ + " FROM_CONNECTOR ON " + COLUMN_SQB_FROM_LINK + " = FROM_CONNECTOR." + COLUMN_SQ_LNK_ID
+ + " LEFT JOIN " + TABLE_SQ_LINK
+ + " TO_CONNECTOR ON " + COLUMN_SQB_TO_LINK + " = TO_CONNECTOR." + COLUMN_SQ_LNK_ID
+ " WHERE " + COLUMN_SQB_ID + " = ?";
// DML: Select all jobs
public static final String STMT_SELECT_JOB_ALL =
"SELECT "
- + "FROM_CONNECTION." + COLUMN_SQN_CONNECTOR + ", "
- + "TO_CONNECTION." + COLUMN_SQN_CONNECTOR + ", "
+ + "FROM_LINK." + COLUMN_SQ_LNK_CONNECTOR + ", "
+ + "TO_LINK." + COLUMN_SQ_LNK_CONNECTOR + ", "
+ "JOB." + COLUMN_SQB_ID + ", "
+ "JOB." + COLUMN_SQB_NAME + ", "
- + "JOB." + COLUMN_SQB_FROM_CONNECTION + ", "
- + "JOB." + COLUMN_SQB_TO_CONNECTION + ", "
+ + "JOB." + COLUMN_SQB_FROM_LINK + ", "
+ + "JOB." + COLUMN_SQB_TO_LINK + ", "
+ "JOB." + COLUMN_SQB_ENABLED + ", "
+ "JOB." + COLUMN_SQB_CREATION_USER + ", "
+ "JOB." + COLUMN_SQB_CREATION_DATE + ", "
+ "JOB." + COLUMN_SQB_UPDATE_USER + ", "
+ "JOB." + COLUMN_SQB_UPDATE_DATE
+ " FROM " + TABLE_SQ_JOB + " JOB"
- + " LEFT JOIN " + TABLE_SQ_CONNECTION + " FROM_CONNECTION"
- + " ON " + COLUMN_SQB_FROM_CONNECTION + " = FROM_CONNECTION." + COLUMN_SQN_ID
- + " LEFT JOIN " + TABLE_SQ_CONNECTION + " TO_CONNECTION"
- + " ON " + COLUMN_SQB_TO_CONNECTION + " = TO_CONNECTION." + COLUMN_SQN_ID;
+ + " LEFT JOIN " + TABLE_SQ_LINK + " FROM_LINK"
+ + " ON " + COLUMN_SQB_FROM_LINK + " = FROM_LINK." + COLUMN_SQ_LNK_ID
+ + " LEFT JOIN " + TABLE_SQ_LINK + " TO_LINK"
+ + " ON " + COLUMN_SQB_TO_LINK + " = TO_LINK." + COLUMN_SQ_LNK_ID;
// DML: Select all jobs for a Connector
public static final String STMT_SELECT_ALL_JOBS_FOR_CONNECTOR = STMT_SELECT_JOB_ALL
- + " WHERE FROM_CONNECTION." + COLUMN_SQN_CONNECTOR + " = ? OR TO_CONNECTION." + COLUMN_SQN_CONNECTOR + " = ?";
+ + " WHERE FROM_LINK." + COLUMN_SQ_LNK_CONNECTOR + " = ? OR TO_LINK." + COLUMN_SQ_LNK_CONNECTOR + " = ?";
// DML: Insert new submission
public static final String STMT_INSERT_SUBMISSION =
@@ -951,117 +951,117 @@ public final class DerbySchemaQuery {
+ COLUMN_SQC_VERSION + " SET DATA TYPE VARCHAR(64)";
// Version 4 Upgrade
- public static final String QUERY_UPGRADE_TABLE_SQ_JOB_RENAME_COLUMN_SQB_CONNECTION_TO_SQB_FROM_CONNECTION =
- "RENAME COLUMN " + TABLE_SQ_JOB + "." + COLUMN_SQB_CONNECTION
- + " TO " + COLUMN_SQB_FROM_CONNECTION;
+ public static final String QUERY_UPGRADE_TABLE_SQ_JOB_RENAME_COLUMN_SQB_LINK_TO_SQB_FROM_LINK =
+ "RENAME COLUMN " + TABLE_SQ_JOB + "." + COLUMN_SQB_LINK
+ + " TO " + COLUMN_SQB_FROM_LINK;
- public static final String QUERY_UPGRADE_TABLE_SQ_JOB_ADD_COLUMN_SQB_TO_CONNECTION =
- "ALTER TABLE " + TABLE_SQ_JOB + " ADD COLUMN " + COLUMN_SQB_TO_CONNECTION
+ public static final String QUERY_UPGRADE_TABLE_SQ_JOB_ADD_COLUMN_SQB_TO_LINK =
+ "ALTER TABLE " + TABLE_SQ_JOB + " ADD COLUMN " + COLUMN_SQB_TO_LINK
+ " BIGINT";
- public static final String QUERY_UPGRADE_TABLE_SQ_JOB_REMOVE_CONSTRAINT_SQB_SQN =
- "ALTER TABLE " + TABLE_SQ_JOB + " DROP CONSTRAINT " + CONSTRAINT_SQB_SQN;
+ public static final String QUERY_UPGRADE_TABLE_SQ_JOB_REMOVE_CONSTRAINT_SQB_SQ_LNK =
+ "ALTER TABLE " + TABLE_SQ_JOB + " DROP CONSTRAINT " + CONSTRAINT_SQB_SQ_LNK;
- public static final String QUERY_UPGRADE_TABLE_SQ_JOB_ADD_CONSTRAINT_SQB_SQN_FROM =
- "ALTER TABLE " + TABLE_SQ_JOB + " ADD CONSTRAINT " + CONSTRAINT_SQB_SQN_FROM
- + " FOREIGN KEY (" + COLUMN_SQB_FROM_CONNECTION + ") REFERENCES "
- + TABLE_SQ_CONNECTION + " (" + COLUMN_SQN_ID + ")";
+ public static final String QUERY_UPGRADE_TABLE_SQ_JOB_ADD_CONSTRAINT_SQB_SQ_LNK_FROM =
+ "ALTER TABLE " + TABLE_SQ_JOB + " ADD CONSTRAINT " + CONSTRAINT_SQB_SQ_LNK_FROM
+ + " FOREIGN KEY (" + COLUMN_SQB_FROM_LINK + ") REFERENCES "
+ + TABLE_SQ_LINK + " (" + COLUMN_SQ_LNK_ID + ")";
- public static final String QUERY_UPGRADE_TABLE_SQ_JOB_ADD_CONSTRAINT_SQB_SQN_TO =
- "ALTER TABLE " + TABLE_SQ_JOB + " ADD CONSTRAINT " + CONSTRAINT_SQB_SQN_TO
- + " FOREIGN KEY (" + COLUMN_SQB_TO_CONNECTION + ") REFERENCES "
- + TABLE_SQ_CONNECTION + " (" + COLUMN_SQN_ID + ")";
+ public static final String QUERY_UPGRADE_TABLE_SQ_JOB_ADD_CONSTRAINT_SQB_SQ_LNK_TO =
+ "ALTER TABLE " + TABLE_SQ_JOB + " ADD CONSTRAINT " + CONSTRAINT_SQB_SQ_LNK_TO
+ + " FOREIGN KEY (" + COLUMN_SQB_TO_LINK + ") REFERENCES "
+ + TABLE_SQ_LINK + " (" + COLUMN_SQ_LNK_ID + ")";
- public static final String QUERY_UPGRADE_TABLE_SQ_FORM_RENAME_COLUMN_SQF_OPERATION_TO_SQF_DIRECTION =
- "RENAME COLUMN " + TABLE_SQ_FORM + "." + COLUMN_SQF_OPERATION
- + " TO " + COLUMN_SQF_DIRECTION;
+ public static final String QUERY_UPGRADE_TABLE_SQ_CONFIG_RENAME_COLUMN_SQ_CFG_OPERATION_TO_SQ_CFG_DIRECTION =
+ "RENAME COLUMN " + TABLE_SQ_CONFIG + "." + COLUMN_SQ_CFG_OPERATION
+ + " TO " + COLUMN_SQ_CFG_DIRECTION;
- public static final String QUERY_UPGRADE_TABLE_SQ_FORM_UPDATE_SQF_OPERATION_TO_SQF_DIRECTION =
- "UPDATE " + TABLE_SQ_FORM + " SET " + COLUMN_SQF_DIRECTION
- + "=? WHERE " + COLUMN_SQF_DIRECTION + "=?"
- + " AND " + COLUMN_SQF_CONNECTOR + " IS NOT NULL";
+ public static final String QUERY_UPGRADE_TABLE_SQ_CONFIG_UPDATE_SQ_CFG_OPERATION_TO_SQ_CFG_DIRECTION =
+ "UPDATE " + TABLE_SQ_CONFIG + " SET " + COLUMN_SQ_CFG_DIRECTION
+ + "=? WHERE " + COLUMN_SQ_CFG_DIRECTION + "=?"
+ + " AND " + COLUMN_SQ_CFG_OWNER + " IS NOT NULL";
- public static final String QUERY_UPGRADE_TABLE_SQ_FORM_UPDATE_CONNECTOR =
- "UPDATE " + TABLE_SQ_FORM + " SET " + COLUMN_SQF_CONNECTOR + "= ?"
- + " WHERE " + COLUMN_SQF_CONNECTOR + " IS NULL AND "
- + COLUMN_SQF_NAME + " IN (?, ?)";
+ public static final String QUERY_UPGRADE_TABLE_SQ_CONFIG_UPDATE_CONNECTOR =
+ "UPDATE " + TABLE_SQ_CONFIG + " SET " + COLUMN_SQ_CFG_OWNER + "= ?"
+ + " WHERE " + COLUMN_SQ_CFG_OWNER + " IS NULL AND "
+ + COLUMN_SQ_CFG_NAME + " IN (?, ?)";
- public static final String QUERY_UPGRADE_TABLE_SQ_FORM_UPDATE_CONNECTOR_HDFS_FORM_DIRECTION =
- "UPDATE " + TABLE_SQ_FORM + " SET " + COLUMN_SQF_DIRECTION + "= ?"
- + " WHERE " + COLUMN_SQF_NAME + "= ?";
+ public static final String QUERY_UPGRADE_TABLE_SQ_CONFIG_UPDATE_CONNECTOR_HDFS_CONFIG_DIRECTION =
+ "UPDATE " + TABLE_SQ_CONFIG + " SET " + COLUMN_SQ_CFG_DIRECTION + "= ?"
+ + " WHERE " + COLUMN_SQ_CFG_NAME + "= ?";
- public static final String QUERY_UPGRADE_TABLE_SQ_JOB_UPDATE_SQB_TO_CONNECTION_COPY_SQB_FROM_CONNECTION =
+ public static final String QUERY_UPGRADE_TABLE_SQ_JOB_UPDATE_SQB_TO_LINK_COPY_SQB_FROM_LINK =
"UPDATE " + TABLE_SQ_JOB + " SET "
- + COLUMN_SQB_TO_CONNECTION + "=" + COLUMN_SQB_FROM_CONNECTION
+ + COLUMN_SQB_TO_LINK + "=" + COLUMN_SQB_FROM_LINK
+ " WHERE " + COLUMN_SQB_TYPE + "= ?";
- public static final String QUERY_UPGRADE_TABLE_SQ_JOB_UPDATE_SQB_FROM_CONNECTION =
- "UPDATE " + TABLE_SQ_JOB + " SET " + COLUMN_SQB_FROM_CONNECTION + "=?"
+ public static final String QUERY_UPGRADE_TABLE_SQ_JOB_UPDATE_SQB_FROM_LINK =
+ "UPDATE " + TABLE_SQ_JOB + " SET " + COLUMN_SQB_FROM_LINK + "=?"
+ " WHERE " + COLUMN_SQB_TYPE + "= ?";
- public static final String QUERY_UPGRADE_TABLE_SQ_JOB_UPDATE_SQB_TO_CONNECTION =
- "UPDATE " + TABLE_SQ_JOB + " SET " + COLUMN_SQB_TO_CONNECTION + "=?"
+ public static final String QUERY_UPGRADE_TABLE_SQ_JOB_UPDATE_SQB_TO_LINK =
+ "UPDATE " + TABLE_SQ_JOB + " SET " + COLUMN_SQB_TO_LINK + "=?"
+ " WHERE " + COLUMN_SQB_TYPE + "= ?";
- public static final String QUERY_UPGRADE_TABLE_SQ_FORM_UPDATE_SQF_NAME =
- "UPDATE " + TABLE_SQ_FORM + " SET "
- + COLUMN_SQF_NAME + "= ?"
- + " WHERE " + COLUMN_SQF_NAME + "= ?"
- + " AND " + COLUMN_SQF_DIRECTION + "= ?";
+ public static final String QUERY_UPGRADE_TABLE_SQ_CONFIG_UPDATE_SQ_CFG_NAME =
+ "UPDATE " + TABLE_SQ_CONFIG + " SET "
+ + COLUMN_SQ_CFG_NAME + "= ?"
+ + " WHERE " + COLUMN_SQ_CFG_NAME + "= ?"
+ + " AND " + COLUMN_SQ_CFG_DIRECTION + "= ?";
/**
- * Intended to rename forms based on direction.
- * e.g. If SQ_FORM.SQF_NAME = 'table' and parameter 1 = 'from'
- * then SQ_FORM.SQF_NAME = 'fromJobConfig'.
+ * Intended to rename configs based on direction.
+ * e.g. If SQ_CONFIG.SQ_CFG_NAME = 'table' and parameter 1 = 'from'
+ * then SQ_CONFIG.SQ_CFG_NAME = 'fromJobConfig'.
*/
- public static final String QUERY_UPGRADE_TABLE_SQ_FORM_UPDATE_TABLE_INPUT_NAMES =
+ public static final String QUERY_UPGRADE_TABLE_SQ_CONFIG_UPDATE_TABLE_INPUT_NAMES =
"UPDATE " + TABLE_SQ_INPUT + " SET "
+ COLUMN_SQI_NAME + "=("
+ "? || UPPER(SUBSTR(" + COLUMN_SQI_NAME + ",1,1))"
+ " || SUBSTR(" + COLUMN_SQI_NAME + ",2) )"
- + " WHERE " + COLUMN_SQI_FORM + " IN ("
- + " SELECT " + COLUMN_SQF_ID + " FROM " + TABLE_SQ_FORM + " WHERE " + COLUMN_SQF_NAME + "= ?"
- + " AND " + COLUMN_SQF_DIRECTION + "= ?)";
+ + " WHERE " + COLUMN_SQI_CONFIG + " IN ("
+ + " SELECT " + COLUMN_SQ_CFG_ID + " FROM " + TABLE_SQ_CONFIG + " WHERE " + COLUMN_SQ_CFG_NAME + "= ?"
+ + " AND " + COLUMN_SQ_CFG_DIRECTION + "= ?)";
- public static final String QUERY_UPGRADE_TABLE_SQ_FORM_UPDATE_DIRECTION_TO_NULL =
- "UPDATE " + TABLE_SQ_FORM + " SET "
- + COLUMN_SQF_DIRECTION + "= NULL"
- + " WHERE " + COLUMN_SQF_NAME + "= ?";
+ public static final String QUERY_UPGRADE_TABLE_SQ_CONFIG_UPDATE_DIRECTION_TO_NULL =
+ "UPDATE " + TABLE_SQ_CONFIG + " SET "
+ + COLUMN_SQ_CFG_DIRECTION + "= NULL"
+ + " WHERE " + COLUMN_SQ_CFG_NAME + "= ?";
- public static final String QUERY_SELECT_THROTTLING_FORM_INPUT_IDS =
+ public static final String QUERY_SELECT_THROTTLING_CONFIG_INPUT_IDS =
"SELECT SQI." + COLUMN_SQI_ID + " FROM " + TABLE_SQ_INPUT + " SQI"
- + " INNER JOIN " + TABLE_SQ_FORM + " SQF ON SQI." + COLUMN_SQI_FORM + "=SQF." + COLUMN_SQF_ID
- + " WHERE SQF." + COLUMN_SQF_NAME + "='throttling' AND SQF." + COLUMN_SQF_DIRECTION + "=?";
+ + " INNER JOIN " + TABLE_SQ_CONFIG + " SQ_CFG ON SQI." + COLUMN_SQI_CONFIG + "=SQ_CFG." + COLUMN_SQ_CFG_ID
+ + " WHERE SQ_CFG." + COLUMN_SQ_CFG_NAME + "='throttling' AND SQ_CFG." + COLUMN_SQ_CFG_DIRECTION + "=?";
/**
* Intended to change SQ_JOB_INPUT.SQBI_INPUT from EXPORT
- * throttling form, to IMPORT throttling form.
+ * throttling config, to IMPORT throttling config.
*/
- public static final String QUERY_UPGRADE_TABLE_SQ_JOB_INPUT_UPDATE_THROTTLING_FORM_INPUTS =
+ public static final String QUERY_UPGRADE_TABLE_SQ_JOB_INPUT_UPDATE_THROTTLING_CONFIG_INPUTS =
"UPDATE " + TABLE_SQ_JOB_INPUT + " SQBI SET"
- + " SQBI." + COLUMN_SQBI_INPUT + "=(" + QUERY_SELECT_THROTTLING_FORM_INPUT_IDS
+ + " SQBI." + COLUMN_SQBI_INPUT + "=(" + QUERY_SELECT_THROTTLING_CONFIG_INPUT_IDS
+ " AND SQI." + COLUMN_SQI_NAME + "=("
+ "SELECT SQI2." + COLUMN_SQI_NAME + " FROM " + TABLE_SQ_INPUT + " SQI2"
+ " WHERE SQI2." + COLUMN_SQI_ID + "=SQBI." + COLUMN_SQBI_INPUT + " FETCH FIRST 1 ROWS ONLY"
+ "))"
- + "WHERE SQBI." + COLUMN_SQBI_INPUT + " IN (" + QUERY_SELECT_THROTTLING_FORM_INPUT_IDS + ")";
+ + "WHERE SQBI." + COLUMN_SQBI_INPUT + " IN (" + QUERY_SELECT_THROTTLING_CONFIG_INPUT_IDS + ")";
- public static final String QUERY_UPGRADE_TABLE_SQ_FORM_REMOVE_EXTRA_FORM_INPUTS =
+ public static final String QUERY_UPGRADE_TABLE_SQ_CONFIG_REMOVE_EXTRA_CONFIG_INPUTS =
"DELETE FROM " + TABLE_SQ_INPUT + " SQI"
- + " WHERE SQI." + COLUMN_SQI_FORM + " IN ("
- + "SELECT SQF." + COLUMN_SQF_ID + " FROM " + TABLE_SQ_FORM + " SQF "
- + " WHERE SQF." + COLUMN_SQF_NAME + "= ?"
- + " AND SQF." + COLUMN_SQF_DIRECTION + "= ?)";
-
- public static final String QUERY_UPGRADE_TABLE_SQ_FORM_REMOVE_EXTRA_FRAMEWORK_FORM =
- "DELETE FROM " + TABLE_SQ_FORM
- + " WHERE " + COLUMN_SQF_NAME + "= ?"
- + " AND " + COLUMN_SQF_DIRECTION + "= ?";
-
- public static final String QUERY_UPGRADE_TABLE_SQ_FORM_UPDATE_FRAMEWORK_INDEX =
- "UPDATE " + TABLE_SQ_FORM + " SET "
- + COLUMN_SQF_INDEX + "= ?"
- + " WHERE " + COLUMN_SQF_NAME + "= ?";
+ + " WHERE SQI." + COLUMN_SQI_CONFIG + " IN ("
+ + "SELECT SQ_CFG." + COLUMN_SQ_CFG_ID + " FROM " + TABLE_SQ_CONFIG + " SQ_CFG "
+ + " WHERE SQ_CFG." + COLUMN_SQ_CFG_NAME + "= ?"
+ + " AND SQ_CFG." + COLUMN_SQ_CFG_DIRECTION + "= ?)";
+
+ public static final String QUERY_UPGRADE_TABLE_SQ_CONFIG_REMOVE_EXTRA_DRIVER_CONFIG =
+ "DELETE FROM " + TABLE_SQ_CONFIG
+ + " WHERE " + COLUMN_SQ_CFG_NAME + "= ?"
+ + " AND " + COLUMN_SQ_CFG_DIRECTION + "= ?";
+
+ public static final String QUERY_UPGRADE_TABLE_SQ_CONFIG_UPDATE_DRIVER_INDEX =
+ "UPDATE " + TABLE_SQ_CONFIG + " SET "
+ + COLUMN_SQ_CFG_INDEX + "= ?"
+ + " WHERE " + COLUMN_SQ_CFG_NAME + "= ?";
public static final String QUERY_UPGRADE_TABLE_SQ_JOB_REMOVE_COLUMN_SQB_TYPE =
"ALTER TABLE " + TABLE_SQ_JOB + " DROP COLUMN " + COLUMN_SQB_TYPE;
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/DerbyTestCase.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/DerbyTestCase.java b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/DerbyTestCase.java
index 4b95687..bf72626 100644
--- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/DerbyTestCase.java
+++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/DerbyTestCase.java
@@ -17,20 +17,35 @@
*/
package org.apache.sqoop.repository.derby;
-import org.apache.sqoop.common.Direction;
-import org.apache.sqoop.driver.Driver;
-import org.apache.sqoop.model.MLink;
-import org.apache.sqoop.model.MConnectionForms;
-import org.apache.sqoop.model.MConnector;
-import org.apache.sqoop.model.MForm;
-import org.apache.sqoop.model.MDriverConfig;
-import org.apache.sqoop.model.MInput;
-import org.apache.sqoop.model.MJob;
-import org.apache.sqoop.model.MJobForms;
-import org.apache.sqoop.model.MMapInput;
-import org.apache.sqoop.model.MStringInput;
-import org.junit.After;
-import org.junit.Before;
+import static org.apache.sqoop.repository.derby.DerbySchemaQuery.QUERY_CREATE_SCHEMA_SQOOP;
+import static org.apache.sqoop.repository.derby.DerbySchemaQuery.QUERY_CREATE_TABLE_SQ_CONFIG;
+import static org.apache.sqoop.repository.derby.DerbySchemaQuery.QUERY_CREATE_TABLE_SQ_CONNECTOR;
+import static org.apache.sqoop.repository.derby.DerbySchemaQuery.QUERY_CREATE_TABLE_SQ_COUNTER;
+import static org.apache.sqoop.repository.derby.DerbySchemaQuery.QUERY_CREATE_TABLE_SQ_COUNTER_GROUP;
+import static org.apache.sqoop.repository.derby.DerbySchemaQuery.QUERY_CREATE_TABLE_SQ_COUNTER_SUBMISSION;
+import static org.apache.sqoop.repository.derby.DerbySchemaQuery.QUERY_CREATE_TABLE_SQ_INPUT;
+import static org.apache.sqoop.repository.derby.DerbySchemaQuery.QUERY_CREATE_TABLE_SQ_JOB;
+import static org.apache.sqoop.repository.derby.DerbySchemaQuery.QUERY_CREATE_TABLE_SQ_JOB_INPUT;
+import static org.apache.sqoop.repository.derby.DerbySchemaQuery.QUERY_CREATE_TABLE_SQ_LINK;
+import static org.apache.sqoop.repository.derby.DerbySchemaQuery.QUERY_CREATE_TABLE_SQ_LINK_INPUT;
+import static org.apache.sqoop.repository.derby.DerbySchemaQuery.QUERY_CREATE_TABLE_SQ_SUBMISSION;
+import static org.apache.sqoop.repository.derby.DerbySchemaQuery.QUERY_CREATE_TABLE_SQ_SYSTEM;
+import static org.apache.sqoop.repository.derby.DerbySchemaQuery.QUERY_UPGRADE_TABLE_SQ_CONFIG_RENAME_COLUMN_SQ_CFG_OPERATION_TO_SQ_CFG_DIRECTION;
+import static org.apache.sqoop.repository.derby.DerbySchemaQuery.QUERY_UPGRADE_TABLE_SQ_JOB_ADD_COLUMN_CREATION_USER;
+import static org.apache.sqoop.repository.derby.DerbySchemaQuery.QUERY_UPGRADE_TABLE_SQ_JOB_ADD_COLUMN_ENABLED;
+import static org.apache.sqoop.repository.derby.DerbySchemaQuery.QUERY_UPGRADE_TABLE_SQ_JOB_ADD_COLUMN_SQB_TO_LINK;
+import static org.apache.sqoop.repository.derby.DerbySchemaQuery.QUERY_UPGRADE_TABLE_SQ_JOB_ADD_COLUMN_UPDATE_USER;
+import static org.apache.sqoop.repository.derby.DerbySchemaQuery.QUERY_UPGRADE_TABLE_SQ_JOB_ADD_CONSTRAINT_SQB_SQ_LNK_FROM;
+import static org.apache.sqoop.repository.derby.DerbySchemaQuery.QUERY_UPGRADE_TABLE_SQ_JOB_ADD_CONSTRAINT_SQB_SQ_LNK_TO;
+import static org.apache.sqoop.repository.derby.DerbySchemaQuery.QUERY_UPGRADE_TABLE_SQ_JOB_REMOVE_COLUMN_SQB_TYPE;
+import static org.apache.sqoop.repository.derby.DerbySchemaQuery.QUERY_UPGRADE_TABLE_SQ_JOB_REMOVE_CONSTRAINT_SQB_SQ_LNK;
+import static org.apache.sqoop.repository.derby.DerbySchemaQuery.QUERY_UPGRADE_TABLE_SQ_JOB_RENAME_COLUMN_SQB_LINK_TO_SQB_FROM_LINK;
+import static org.apache.sqoop.repository.derby.DerbySchemaQuery.QUERY_UPGRADE_TABLE_SQ_LINK_ADD_COLUMN_CREATION_USER;
+import static org.apache.sqoop.repository.derby.DerbySchemaQuery.QUERY_UPGRADE_TABLE_SQ_LINK_ADD_COLUMN_ENABLED;
+import static org.apache.sqoop.repository.derby.DerbySchemaQuery.QUERY_UPGRADE_TABLE_SQ_LINK_ADD_COLUMN_UPDATE_USER;
+import static org.apache.sqoop.repository.derby.DerbySchemaQuery.QUERY_UPGRADE_TABLE_SQ_SUBMISSION_ADD_COLUMN_CREATION_USER;
+import static org.apache.sqoop.repository.derby.DerbySchemaQuery.QUERY_UPGRADE_TABLE_SQ_SUBMISSION_ADD_COLUMN_UPDATE_USER;
+import static org.junit.Assert.assertEquals;
import java.sql.Connection;
import java.sql.DriverManager;
@@ -42,8 +57,22 @@ import java.sql.Statement;
import java.util.LinkedList;
import java.util.List;
-import static org.apache.sqoop.repository.derby.DerbySchemaQuery.*;
-import static org.junit.Assert.assertEquals;
+import org.apache.sqoop.common.Direction;
+import org.apache.sqoop.json.DriverBean;
+import org.apache.sqoop.model.MConfig;
+import org.apache.sqoop.model.MConnector;
+import org.apache.sqoop.model.MDriver;
+import org.apache.sqoop.model.MDriverConfig;
+import org.apache.sqoop.model.MFromConfig;
+import org.apache.sqoop.model.MInput;
+import org.apache.sqoop.model.MJob;
+import org.apache.sqoop.model.MLink;
+import org.apache.sqoop.model.MLinkConfig;
+import org.apache.sqoop.model.MMapInput;
+import org.apache.sqoop.model.MStringInput;
+import org.apache.sqoop.model.MToConfig;
+import org.junit.After;
+import org.junit.Before;
/**
* Abstract class with convenience methods for testing derby repository.
@@ -91,11 +120,11 @@ abstract public class DerbyTestCase {
if (version > 0) {
runQuery(QUERY_CREATE_SCHEMA_SQOOP);
runQuery(QUERY_CREATE_TABLE_SQ_CONNECTOR);
- runQuery(QUERY_CREATE_TABLE_SQ_FORM);
+ runQuery(QUERY_CREATE_TABLE_SQ_CONFIG);
runQuery(QUERY_CREATE_TABLE_SQ_INPUT);
- runQuery(QUERY_CREATE_TABLE_SQ_CONNECTION);
+ runQuery(QUERY_CREATE_TABLE_SQ_LINK);
runQuery(QUERY_CREATE_TABLE_SQ_JOB);
- runQuery(QUERY_CREATE_TABLE_SQ_CONNECTION_INPUT);
+ runQuery(QUERY_CREATE_TABLE_SQ_LINK_INPUT);
runQuery(QUERY_CREATE_TABLE_SQ_JOB_INPUT);
runQuery(QUERY_CREATE_TABLE_SQ_SUBMISSION);
runQuery(QUERY_CREATE_TABLE_SQ_COUNTER_GROUP);
@@ -105,10 +134,10 @@ abstract public class DerbyTestCase {
if (version > 1) {
runQuery(QUERY_CREATE_TABLE_SQ_SYSTEM);
- runQuery(QUERY_UPGRADE_TABLE_SQ_CONNECTION_ADD_COLUMN_ENABLED);
+ runQuery(QUERY_UPGRADE_TABLE_SQ_LINK_ADD_COLUMN_ENABLED);
runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_COLUMN_ENABLED);
- runQuery(QUERY_UPGRADE_TABLE_SQ_CONNECTION_ADD_COLUMN_CREATION_USER);
- runQuery(QUERY_UPGRADE_TABLE_SQ_CONNECTION_ADD_COLUMN_UPDATE_USER);
+ runQuery(QUERY_UPGRADE_TABLE_SQ_LINK_ADD_COLUMN_CREATION_USER);
+ runQuery(QUERY_UPGRADE_TABLE_SQ_LINK_ADD_COLUMN_UPDATE_USER);
runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_COLUMN_CREATION_USER);
runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_COLUMN_UPDATE_USER);
runQuery(QUERY_UPGRADE_TABLE_SQ_SUBMISSION_ADD_COLUMN_CREATION_USER);
@@ -116,12 +145,12 @@ abstract public class DerbyTestCase {
}
if (version > 3) {
- runQuery(QUERY_UPGRADE_TABLE_SQ_FORM_RENAME_COLUMN_SQF_OPERATION_TO_SQF_DIRECTION);
- runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_RENAME_COLUMN_SQB_CONNECTION_TO_SQB_FROM_CONNECTION);
- runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_COLUMN_SQB_TO_CONNECTION);
- runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_REMOVE_CONSTRAINT_SQB_SQN);
- runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_CONSTRAINT_SQB_SQN_FROM);
- runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_CONSTRAINT_SQB_SQN_TO);
+ runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_RENAME_COLUMN_SQ_CFG_OPERATION_TO_SQ_CFG_DIRECTION);
+ runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_RENAME_COLUMN_SQB_LINK_TO_SQB_FROM_LINK);
+ runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_COLUMN_SQB_TO_LINK);
+ runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_REMOVE_CONSTRAINT_SQB_SQ_LNK);
+ runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_CONSTRAINT_SQB_SQ_LNK_FROM);
+ runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_CONSTRAINT_SQB_SQ_LNK_TO);
runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_REMOVE_COLUMN_SQB_TYPE);
}
@@ -180,65 +209,64 @@ abstract public class DerbyTestCase {
String connector = "1";
- // Connector form entries
+ // Connector config entries
for(String operation : new String[] {"null", "'IMPORT'", "'EXPORT'"}) {
String type;
if(operation.equals("null")) {
- type = "CONNECTION";
+ type = "LINK";
} else {
type = "JOB";
}
- runQuery("INSERT INTO SQOOP.SQ_FORM"
- + "(SQF_CONNECTOR, SQF_OPERATION, SQF_NAME, SQF_TYPE, SQF_INDEX) "
+ runQuery("INSERT INTO SQOOP.SQ_CONFIG"
+ + "(SQ_CFG_OWNER, SQ_CFG_OPERATION, SQ_CFG_NAME, SQ_CFG_TYPE, SQ_CFG_INDEX) "
+ "VALUES("
+ connector + ", "
+ operation
- + ", 'F1', '"
+ + ", 'C1', '"
+ type
+ "', 0)");
- runQuery("INSERT INTO SQOOP.SQ_FORM"
- + "(SQF_CONNECTOR, SQF_OPERATION, SQF_NAME, SQF_TYPE, SQF_INDEX) "
+ runQuery("INSERT INTO SQOOP.SQ_CONFIG"
+ + "(SQ_CFG_OWNER, SQ_CFG_OPERATION, SQ_CFG_NAME, SQ_CFG_TYPE, SQ_CFG_INDEX) "
+ "VALUES("
+ connector + ", "
+ operation
- + ", 'F2', '"
+ + ", 'C2', '"
+ type
+ "', 1)");
}
- // Framework form entries
- runQuery("INSERT INTO SQOOP.SQ_FORM"
- + "(SQF_CONNECTOR, SQF_OPERATION, SQF_NAME, SQF_TYPE, SQF_INDEX) VALUES"
+ // Driver config entries
+ runQuery("INSERT INTO SQOOP.SQ_CONFIG"
+ + "(SQ_CFG_OWNER, SQ_CFG_OPERATION, SQ_CFG_NAME, SQ_CFG_TYPE, SQ_CFG_INDEX) VALUES"
+ "(NULL, 'IMPORT', 'output', 'JOB', 0),"
+ "(NULL, 'IMPORT', 'throttling', 'JOB', 1),"
+ "(NULL, 'EXPORT', 'input', 'JOB', 0),"
+ "(NULL, 'EXPORT', 'throttling', 'JOB', 1),"
- + "(NULL, NULL, 'security', 'CONNECTION', 0)");
+ + "(NULL, NULL, 'security', 'LINK', 0)");
// Connector input entries
- int x = 0;
for(int i = 0; i < 3; i++) {
- // First form
+ // First config
runQuery("INSERT INTO SQOOP.SQ_INPUT"
- +"(SQI_NAME, SQI_FORM, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
+ +"(SQI_NAME, SQI_CONFIG, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
+ " VALUES('I1', " + (i * 2 + 1) + ", 0, 'STRING', false, 30)");
runQuery("INSERT INTO SQOOP.SQ_INPUT"
- +"(SQI_NAME, SQI_FORM, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
+ +"(SQI_NAME, SQI_CONFIG, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
+ " VALUES('I2', " + (i * 2 + 1) + ", 1, 'MAP', false, 30)");
- // Second form
+ // Second config
runQuery("INSERT INTO SQOOP.SQ_INPUT"
- +"(SQI_NAME, SQI_FORM, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
+ +"(SQI_NAME, SQI_CONFIG, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
+ " VALUES('I3', " + (i * 2 + 2) + ", 0, 'STRING', false, 30)");
runQuery("INSERT INTO SQOOP.SQ_INPUT"
- +"(SQI_NAME, SQI_FORM, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
+ +"(SQI_NAME, SQI_CONFIG, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
+ " VALUES('I4', " + (i * 2 + 2) + ", 1, 'MAP', false, 30)");
}
- // Framework input entries.
- runQuery("INSERT INTO SQOOP.SQ_INPUT (SQI_NAME, SQI_FORM, SQI_INDEX,"
+ // Driver input entries.
+ runQuery("INSERT INTO SQOOP.SQ_INPUT (SQI_NAME, SQI_CONFIG, SQI_INDEX,"
+ " SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH, SQI_ENUMVALS)"
+" VALUES ('security.maxConnections',11,0,'INTEGER','false',NULL,NULL),"
+ "('input.inputDirectory',9,0,'STRING','false',255,NULL),"
@@ -257,74 +285,72 @@ abstract public class DerbyTestCase {
runQuery("INSERT INTO SQOOP.SQ_CONNECTOR(SQC_NAME, SQC_CLASS, SQC_VERSION)"
+ "VALUES('A', 'org.apache.sqoop.test.A', '1.0-test')");
- // Connector part
for (String connector : new String[]{"1"}) {
- // Form entries
+ // connector configs
for (String direction : new String[]{"null", "'FROM'", "'TO'"}) {
String type;
if (direction.equals("null")) {
- type = "CONNECTION";
+ type = "LINK";
} else {
type = "JOB";
}
- runQuery("INSERT INTO SQOOP.SQ_FORM"
- + "(SQF_CONNECTOR, SQF_DIRECTION, SQF_NAME, SQF_TYPE, SQF_INDEX) "
+ runQuery("INSERT INTO SQOOP.SQ_CONFIG"
+ + "(SQ_CFG_OWNER, SQ_CFG_DIRECTION, SQ_CFG_NAME, SQ_CFG_TYPE, SQ_CFG_INDEX) "
+ "VALUES("
+ connector + ", "
+ direction
- + ", 'F1', '"
+ + ", 'C1', '"
+ type
+ "', 0)");
- runQuery("INSERT INTO SQOOP.SQ_FORM"
- + "(SQF_CONNECTOR, SQF_DIRECTION, SQF_NAME, SQF_TYPE, SQF_INDEX) "
+ runQuery("INSERT INTO SQOOP.SQ_CONFIG"
+ + "(SQ_CFG_OWNER, SQ_CFG_DIRECTION, SQ_CFG_NAME, SQ_CFG_TYPE, SQ_CFG_INDEX) "
+ "VALUES("
+ connector + ", "
+ direction
- + ", 'F2', '"
+ + ", 'C2', '"
+ type
+ "', 1)");
}
}
- // Framework part
- for (String type : new String[]{"CONNECTION", "JOB"}) {
- runQuery("INSERT INTO SQOOP.SQ_FORM"
- + "(SQF_CONNECTOR, SQF_DIRECTION, SQF_NAME, SQF_TYPE, SQF_INDEX) "
+ // driver config
+ for (String type : new String[]{"JOB"}) {
+ runQuery("INSERT INTO SQOOP.SQ_CONFIG"
+ + "(SQ_CFG_OWNER, SQ_CFG_DIRECTION, SQ_CFG_NAME, SQ_CFG_TYPE, SQ_CFG_INDEX) "
+ "VALUES(NULL, NULL"
- + ", 'F1', '"
+ + ", 'C1', '"
+ type
+ "', 0)");
- runQuery("INSERT INTO SQOOP.SQ_FORM"
- + "(SQF_CONNECTOR, SQF_DIRECTION, SQF_NAME, SQF_TYPE, SQF_INDEX) "
+ runQuery("INSERT INTO SQOOP.SQ_CONFIG"
+ + "(SQ_CFG_OWNER, SQ_CFG_DIRECTION, SQ_CFG_NAME, SQ_CFG_TYPE, SQ_CFG_INDEX) "
+ "VALUES(NULL, NULL"
- + ", 'F2', '"
+ + ", 'C2', '"
+ type
+ "', 1)");
}
// Input entries
- // Connector link parts: 0-3
- // Connector job (FROM) parts: 4-7
- // Connector job (TO) parts: 8-11
- // Framework link parts: 12-15
- // Framework job parts: 16-19
- for (int i = 0; i < 5; i++) {
- // First form
+ // Connector LINK config: 0-3
+ // Connector job (FROM) config: 4-7
+ // Connector job (TO) config: 8-11
+ // Driver JOB config: 12-15
+ for (int i = 0; i < 4; i++) {
+ // First config
runQuery("INSERT INTO SQOOP.SQ_INPUT"
- + "(SQI_NAME, SQI_FORM, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
+ + "(SQI_NAME, SQI_CONFIG, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
+ " VALUES('I1', " + (i * 2 + 1) + ", 0, 'STRING', false, 30)");
runQuery("INSERT INTO SQOOP.SQ_INPUT"
- + "(SQI_NAME, SQI_FORM, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
+ + "(SQI_NAME, SQI_CONFIG, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
+ " VALUES('I2', " + (i * 2 + 1) + ", 1, 'MAP', false, 30)");
- // Second form
+ // Second config
runQuery("INSERT INTO SQOOP.SQ_INPUT"
- + "(SQI_NAME, SQI_FORM, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
+ + "(SQI_NAME, SQI_CONFIG, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
+ " VALUES('I3', " + (i * 2 + 2) + ", 0, 'STRING', false, 30)");
runQuery("INSERT INTO SQOOP.SQ_INPUT"
- + "(SQI_NAME, SQI_FORM, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
+ + "(SQI_NAME, SQI_CONFIG, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH)"
+ " VALUES('I4', " + (i * 2 + 2) + ", 1, 'MAP', false, 30)");
}
}
@@ -350,7 +376,7 @@ abstract public class DerbyTestCase {
}
}
- protected void loadConnectorAndDriverConfig() throws Exception {
+ protected void loadConnectorLinkConfig() throws Exception {
loadConnectorAndDriverConfig(LATEST_SYSTEM_VERSION);
}
@@ -364,15 +390,15 @@ abstract public class DerbyTestCase {
switch (version) {
case 2:
// Insert two links - CA and CB
- runQuery("INSERT INTO SQOOP.SQ_CONNECTION(SQN_NAME, SQN_CONNECTOR) "
+ runQuery("INSERT INTO SQOOP.SQ_LINK(SQ_LNK_NAME, SQ_LNK_CONNECTOR) "
+ "VALUES('CA', 1)");
- runQuery("INSERT INTO SQOOP.SQ_CONNECTION(SQN_NAME, SQN_CONNECTOR) "
+ runQuery("INSERT INTO SQOOP.SQ_LINK(SQ_LNK_NAME, SQ_LNK_CONNECTOR) "
+ "VALUES('CB', 1)");
for(String ci : new String[] {"1", "2"}) {
for(String i : new String[] {"1", "3", "13", "15"}) {
- runQuery("INSERT INTO SQOOP.SQ_CONNECTION_INPUT"
- + "(SQNI_CONNECTION, SQNI_INPUT, SQNI_VALUE) "
+ runQuery("INSERT INTO SQOOP.SQ_LINK_INPUT"
+ + "(SQ_LNKI_LINK, SQ_LNKI_INPUT, SQ_LNKI_VALUE) "
+ "VALUES(" + ci + ", " + i + ", 'Value" + i + "')");
}
}
@@ -380,15 +406,15 @@ abstract public class DerbyTestCase {
case 4:
// Insert two links - CA and CB
- runQuery("INSERT INTO SQOOP.SQ_CONNECTION(SQN_NAME, SQN_CONNECTOR) "
+ runQuery("INSERT INTO SQOOP.SQ_LINK(SQ_LNK_NAME, SQ_LNK_CONNECTOR) "
+ "VALUES('CA', 1)");
- runQuery("INSERT INTO SQOOP.SQ_CONNECTION(SQN_NAME, SQN_CONNECTOR) "
+ runQuery("INSERT INTO SQOOP.SQ_LINK(SQ_LNK_NAME, SQ_LNK_CONNECTOR) "
+ "VALUES('CB', 1)");
for (String ci : new String[]{"1", "2"}) {
for (String i : new String[]{"1", "3", "13", "15"}) {
- runQuery("INSERT INTO SQOOP.SQ_CONNECTION_INPUT"
- + "(SQNI_CONNECTION, SQNI_INPUT, SQNI_VALUE) "
+ runQuery("INSERT INTO SQOOP.SQ_LINK_INPUT"
+ + "(SQ_LNKI_LINK, SQ_LNKI_INPUT, SQ_LNKI_VALUE) "
+ "VALUES(" + ci + ", " + i + ", 'Value" + i + "')");
}
}
@@ -414,7 +440,7 @@ abstract public class DerbyTestCase {
case 2:
for(String type : new String[] {"IMPORT", "EXPORT"}) {
for(String name : new String[] {"JA", "JB"} ) {
- runQuery("INSERT INTO SQOOP.SQ_JOB(SQB_NAME, SQB_CONNECTION, SQB_TYPE)"
+ runQuery("INSERT INTO SQOOP.SQ_JOB(SQB_NAME, SQB_LINK, SQB_TYPE)"
+ " VALUES('" + name + "', 1, '" + type + "')");
}
}
@@ -441,19 +467,19 @@ abstract public class DerbyTestCase {
case 4:
for (String name : new String[]{"JA", "JB", "JC", "JD"}) {
- runQuery("INSERT INTO SQOOP.SQ_JOB(SQB_NAME, SQB_FROM_CONNECTION, SQB_TO_CONNECTION)"
+ runQuery("INSERT INTO SQOOP.SQ_JOB(SQB_NAME, SQB_FROM_LINK, SQB_TO_LINK)"
+ " VALUES('" + name + "', 1, 1)");
}
// Odd IDs inputs have values
for (String ci : new String[]{"1", "2", "3", "4"}) {
- for (String i : new String[]{"5", "9", "17"}) {
+ for (String i : new String[]{"5", "9", "13"}) {
runQuery("INSERT INTO SQOOP.SQ_JOB_INPUT"
+ "(SQBI_JOB, SQBI_INPUT, SQBI_VALUE) "
+ "VALUES(" + ci + ", " + i + ", 'Value" + i + "')");
}
- for (String i : new String[]{"7", "11", "19"}) {
+ for (String i : new String[]{"7", "11", "15"}) {
runQuery("INSERT INTO SQOOP.SQ_JOB_INPUT"
+ "(SQBI_JOB, SQBI_INPUT, SQBI_VALUE) "
+ "VALUES(" + ci + ", " + i + ", 'Value" + i + "')");
@@ -524,71 +550,70 @@ abstract public class DerbyTestCase {
protected MConnector getConnector() {
return new MConnector("A", "org.apache.sqoop.test.A", "1.0-test",
- getConnectionForms(), getJobForms(), getJobForms());
+ getLinkConfig(), getFromConfig(), getToConfig());
}
-
- protected MDriverConfig getDriverConfig() {
- return new MDriverConfig(getConnectionForms(), getJobForms(),
- Driver.CURRENT_DRIVER_VERSION);
+
+ protected MDriver getDriver() {
+ return new MDriver(getDriverConfig(), DriverBean.CURRENT_DRIVER_VERSION);
}
protected void fillLink(MLink link) {
- List<MForm> forms;
-
- forms = link.getConnectorPart().getForms();
- ((MStringInput)forms.get(0).getInputs().get(0)).setValue("Value1");
- ((MStringInput)forms.get(1).getInputs().get(0)).setValue("Value2");
-
- forms = link.getFrameworkPart().getForms();
- ((MStringInput)forms.get(0).getInputs().get(0)).setValue("Value13");
- ((MStringInput)forms.get(1).getInputs().get(0)).setValue("Value15");
+ List<MConfig> configs = link.getConnectorLinkConfig().getConfigs();
+ ((MStringInput)configs.get(0).getInputs().get(0)).setValue("Value1");
+ ((MStringInput)configs.get(1).getInputs().get(0)).setValue("Value2");
}
protected void fillJob(MJob job) {
- List<MForm> forms;
+ List<MConfig> configs = job.getJobConfig(Direction.FROM).getConfigs();
+ ((MStringInput)configs.get(0).getInputs().get(0)).setValue("Value1");
+ ((MStringInput)configs.get(1).getInputs().get(0)).setValue("Value2");
- forms = job.getConnectorPart(Direction.FROM).getForms();
- ((MStringInput)forms.get(0).getInputs().get(0)).setValue("Value1");
- ((MStringInput)forms.get(1).getInputs().get(0)).setValue("Value2");
+ configs = job.getJobConfig(Direction.TO).getConfigs();
+ ((MStringInput)configs.get(0).getInputs().get(0)).setValue("Value1");
+ ((MStringInput)configs.get(1).getInputs().get(0)).setValue("Value2");
+
+ configs = job.getDriverConfig().getConfigs();
+ ((MStringInput)configs.get(0).getInputs().get(0)).setValue("Value13");
+ ((MStringInput)configs.get(1).getInputs().get(0)).setValue("Value15");
+ }
- forms = job.getConnectorPart(Direction.TO).getForms();
- ((MStringInput)forms.get(0).getInputs().get(0)).setValue("Value1");
- ((MStringInput)forms.get(1).getInputs().get(0)).setValue("Value2");
+ protected MLinkConfig getLinkConfig() {
+ return new MLinkConfig(getConfigs());
+ }
- forms = job.getFrameworkPart().getForms();
- ((MStringInput)forms.get(0).getInputs().get(0)).setValue("Value13");
- ((MStringInput)forms.get(1).getInputs().get(0)).setValue("Value15");
+ protected MFromConfig getFromConfig() {
+ return new MFromConfig(getConfigs());
}
- protected MConnectionForms getConnectionForms() {
- return new MConnectionForms(getForms());
+ protected MToConfig getToConfig() {
+ return new MToConfig(getConfigs());
}
- protected MJobForms getJobForms() {
- return new MJobForms(getForms());
+ protected MDriverConfig getDriverConfig() {
+ return new MDriverConfig(getConfigs());
}
- protected List<MForm> getForms() {
- List<MForm> forms = new LinkedList<MForm>();
+ protected List<MConfig> getConfigs() {
+ List<MConfig> jobConfigs = new LinkedList<MConfig>();
- List<MInput<?>> inputs;
- MInput input;
-
- inputs = new LinkedList<MInput<?>>();
- input = new MStringInput("I1", false, (short)30);
+ List<MInput<?>> inputs = new LinkedList<MInput<?>>();
+ MInput input = new MStringInput("I1", false, (short)30);
inputs.add(input);
input = new MMapInput("I2", false);
inputs.add(input);
- forms.add(new MForm("F1", inputs));
+ // adding the from part of the job config
+ jobConfigs.add(new MConfig("C1", inputs));
+ // to
inputs = new LinkedList<MInput<?>>();
input = new MStringInput("I3", false, (short)30);
inputs.add(input);
input = new MMapInput("I4", false);
inputs.add(input);
- forms.add(new MForm("F2", inputs));
+ // adding the to part of the job config
+ jobConfigs.add(new MConfig("C2", inputs));
- return forms;
+ return jobConfigs;
}
/**
@@ -641,8 +666,8 @@ abstract public class DerbyTestCase {
* @throws Exception
*/
protected void generateDatabaseState() throws Exception {
- for(String tbl : new String[] {"SQ_CONNECTOR", "SQ_FORM", "SQ_INPUT",
- "SQ_CONNECTION", "SQ_CONNECTION_INPUT", "SQ_JOB", "SQ_JOB_INPUT"}) {
+ for(String tbl : new String[] {"SQ_CONNECTOR", "SQ_CONFIG", "SQ_INPUT",
+ "SQ_LINK", "SQ_LINK_INPUT", "SQ_JOB", "SQ_JOB_INPUT"}) {
generateTableState("SQOOP." + tbl);
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectorHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectorHandling.java b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectorHandling.java
index 15306c2..a0e8b91 100644
--- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectorHandling.java
+++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectorHandling.java
@@ -51,7 +51,7 @@ public class TestConnectorHandling extends DerbyTestCase {
assertNull(handler.findConnector("B", getDerbyDatabaseConnection()));
// Load connector into repository
- loadConnectorAndDriverConfig();
+ loadConnectorLinkConfig();
// Retrieve it
MConnector connector = handler.findConnector("A", getDerbyDatabaseConnection());
@@ -69,7 +69,7 @@ public class TestConnectorHandling extends DerbyTestCase {
// No connectors in an empty repository, we expect an empty list
assertEquals(handler.findConnectors(getDerbyDatabaseConnection()).size(),0);
- loadConnectorAndDriverConfig();
+ loadConnectorLinkConfig();
addConnector();
// Retrieve connectors
@@ -93,7 +93,7 @@ public class TestConnectorHandling extends DerbyTestCase {
// Now check content in corresponding tables
assertCountForTable("SQOOP.SQ_CONNECTOR", 1);
- assertCountForTable("SQOOP.SQ_FORM", 6);
+ assertCountForTable("SQOOP.SQ_CONFIG", 6);
assertCountForTable("SQOOP.SQ_INPUT", 12);
// Registered connector should be easily recovered back
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestDriverConfigHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestDriverConfigHandling.java b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestDriverConfigHandling.java
deleted file mode 100644
index 9b18bd3..0000000
--- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestDriverConfigHandling.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.repository.derby;
-
-import org.apache.sqoop.driver.Driver;
-import org.apache.sqoop.model.MDriverConfig;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-/**
- * Test driver config methods on Derby repository.
- */
-public class TestDriverConfigHandling extends DerbyTestCase {
-
- DerbyRepositoryHandler handler;
-
- @Before
- public void setUp() throws Exception {
- super.setUp();
-
- handler = new DerbyRepositoryHandler();
-
- // We always needs schema for this test case
- createSchema();
- }
-
- @Test
- public void testFindDriverConfig() throws Exception {
- // On empty repository, no driverConfig should be there
- assertNull(handler.findDriverConfig(getDerbyDatabaseConnection()));
- // Load Connector and DriverConfig into repository
- loadConnectorAndDriverConfig();
- // Retrieve it
- MDriverConfig driverConfig = handler.findDriverConfig(getDerbyDatabaseConnection());
- assertNotNull(driverConfig);
-
- // Get original structure
- MDriverConfig originalDriverConfig = getDriverConfig();
-
- // And compare them
- assertEquals(originalDriverConfig, driverConfig);
- }
-
- @Test
- public void testRegisterConnector() throws Exception {
- MDriverConfig driverConfig = getDriverConfig();
- handler.registerDriverConfig(driverConfig, getDerbyDatabaseConnection());
-
- // Connector should get persistence ID
- assertEquals(1, driverConfig.getPersistenceId());
-
- // Now check content in corresponding tables
- assertCountForTable("SQOOP.SQ_CONNECTOR", 0);
- assertCountForTable("SQOOP.SQ_FORM", 4);
- assertCountForTable("SQOOP.SQ_INPUT", 8);
-
- // Registered framework should be easily recovered back
- MDriverConfig retrieved = handler.findDriverConfig(getDerbyDatabaseConnection());
- assertNotNull(retrieved);
- assertEquals(driverConfig, retrieved);
- assertEquals(driverConfig.getVersion(), retrieved.getVersion());
- }
-
- private String getDriverVersion() throws Exception {
- final String frameworkVersionQuery =
- "SELECT SQM_VALUE FROM SQOOP.SQ_SYSTEM WHERE SQM_KEY=?";
- String retVal = null;
- PreparedStatement preparedStmt = null;
- ResultSet resultSet = null;
- try {
- preparedStmt =
- getDerbyDatabaseConnection().prepareStatement(frameworkVersionQuery);
- preparedStmt.setString(1, DerbyRepoConstants.SYSKEY_DRIVER_VERSION);
- resultSet = preparedStmt.executeQuery();
- if(resultSet.next())
- retVal = resultSet.getString(1);
- return retVal;
- } finally {
- if(preparedStmt !=null) {
- try {
- preparedStmt.close();
- } catch(SQLException e) {
- }
- }
- if(resultSet != null) {
- try {
- resultSet.close();
- } catch(SQLException e) {
- }
- }
- }
- }
-
- @Test
- public void testDriverVersion() throws Exception {
- handler.registerDriverConfig(getDriverConfig(), getDerbyDatabaseConnection());
-
- final String lowerVersion = Integer.toString(
- Integer.parseInt(Driver.CURRENT_DRIVER_VERSION) - 1);
- assertEquals(Driver.CURRENT_DRIVER_VERSION, getDriverVersion());
- runQuery("UPDATE SQOOP.SQ_SYSTEM SET SQM_VALUE='" + lowerVersion +
- "' WHERE SQM_KEY = '" + DerbyRepoConstants.SYSKEY_DRIVER_VERSION + "'");
- assertEquals(lowerVersion, getDriverVersion());
-
- MDriverConfig framework = getDriverConfig();
- handler.updateDriverConfig(framework, getDerbyDatabaseConnection());
-
- assertEquals(Driver.CURRENT_DRIVER_VERSION, framework.getVersion());
-
- assertEquals(Driver.CURRENT_DRIVER_VERSION, getDriverVersion());
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestDriverHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestDriverHandling.java b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestDriverHandling.java
new file mode 100644
index 0000000..d597bd8
--- /dev/null
+++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestDriverHandling.java
@@ -0,0 +1,135 @@
+/**
+ * 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.repository.derby;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.apache.sqoop.json.DriverBean;
+import org.apache.sqoop.model.MDriver;
+import org.apache.sqoop.model.MDriverConfig;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test driver config methods on Derby repository.
+ */
+public class TestDriverHandling extends DerbyTestCase {
+
+ private static final Object CURRENT_DRIVER_VERSION = "1";
+ DerbyRepositoryHandler handler;
+
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+
+ handler = new DerbyRepositoryHandler();
+
+ // We always needs schema for this test case
+ createSchema();
+ }
+
+ @Test
+ public void testFindDriverConfig() throws Exception {
+ // On empty repository, no driverConfig should be there
+ assertNull(handler.findDriver(getDerbyDatabaseConnection()));
+ // Load Connector and DriverConfig into repository
+ loadConnectorLinkConfig();
+ // Retrieve it
+ MDriver driver = handler.findDriver(getDerbyDatabaseConnection());
+ assertNotNull(driver);
+
+ // Get original structure
+ MDriverConfig originalDriverConfig = getDriverConfig();
+ // And compare them
+ assertEquals(originalDriverConfig, driver.getDriverConfig());
+ }
+
+ public void testRegisterDriverAndConnectorConfig() throws Exception {
+ MDriver driver = getDriver();
+ handler.registerDriver(driver, getDerbyDatabaseConnection());
+
+ // Connector should get persistence ID
+ assertEquals(1, driver.getPersistenceId());
+
+ // Now check content in corresponding tables
+ assertCountForTable("SQOOP.SQ_CONNECTOR", 0);
+ assertCountForTable("SQOOP.SQ_CONFIG", 2);
+ assertCountForTable("SQOOP.SQ_INPUT", 4);
+
+ // Registered driver config should be easily recovered back
+ MDriver retrieved = handler.findDriver(getDerbyDatabaseConnection());
+ assertNotNull(retrieved);
+ assertEquals(driver, retrieved);
+ assertEquals(driver.getVersion(), retrieved.getVersion());
+ }
+
+ private String getDriverVersion() throws Exception {
+ final String frameworkVersionQuery =
+ "SELECT SQM_VALUE FROM SQOOP.SQ_SYSTEM WHERE SQM_KEY=?";
+ String retVal = null;
+ PreparedStatement preparedStmt = null;
+ ResultSet resultSet = null;
+ try {
+ preparedStmt =
+ getDerbyDatabaseConnection().prepareStatement(frameworkVersionQuery);
+ preparedStmt.setString(1, DerbyRepoConstants.SYSKEY_DRIVER_VERSION);
+ resultSet = preparedStmt.executeQuery();
+ if(resultSet.next())
+ retVal = resultSet.getString(1);
+ return retVal;
+ } finally {
+ if(preparedStmt !=null) {
+ try {
+ preparedStmt.close();
+ } catch(SQLException e) {
+ }
+ }
+ if(resultSet != null) {
+ try {
+ resultSet.close();
+ } catch(SQLException e) {
+ }
+ }
+ }
+ }
+
+ @Test
+ public void testDriverVersion() throws Exception {
+ MDriver driver = getDriver();
+ handler.registerDriver(driver, getDerbyDatabaseConnection());
+
+ final String lowerVersion = Integer.toString(Integer
+ .parseInt(DriverBean.CURRENT_DRIVER_VERSION) - 1);
+ assertEquals(CURRENT_DRIVER_VERSION, getDriverVersion());
+ runQuery("UPDATE SQOOP.SQ_SYSTEM SET SQM_VALUE='" + lowerVersion + "' WHERE SQM_KEY = '"
+ + DerbyRepoConstants.SYSKEY_DRIVER_VERSION + "'");
+ assertEquals(lowerVersion, getDriverVersion());
+
+ handler.updateDriver(driver, getDerbyDatabaseConnection());
+
+ assertEquals(CURRENT_DRIVER_VERSION, driver.getVersion());
+
+ assertEquals(CURRENT_DRIVER_VERSION, getDriverVersion());
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestInputTypes.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestInputTypes.java b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestInputTypes.java
index d744693..260c2a9 100644
--- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestInputTypes.java
+++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestInputTypes.java
@@ -19,11 +19,11 @@ package org.apache.sqoop.repository.derby;
import org.apache.sqoop.model.MBooleanInput;
import org.apache.sqoop.model.MLink;
-import org.apache.sqoop.model.MConnectionForms;
+import org.apache.sqoop.model.MLinkConfig;
import org.apache.sqoop.model.MConnector;
import org.apache.sqoop.model.MEnumInput;
-import org.apache.sqoop.model.MForm;
-import org.apache.sqoop.model.MDriverConfig;
+import org.apache.sqoop.model.MConfig;
+import org.apache.sqoop.model.MDriver;
import org.apache.sqoop.model.MInput;
import org.apache.sqoop.model.MIntegerInput;
import org.apache.sqoop.model.MMapInput;
@@ -86,19 +86,19 @@ public class TestInputTypes extends DerbyTestCase {
@Test
public void testEntityDataSerialization() throws Exception {
MConnector connector = getConnector();
- MDriverConfig driverConfig = getDriverConfig();
+ MDriver driver = getDriver();
// Register objects for everything and our new connector
handler.registerConnector(connector, getDerbyDatabaseConnection());
- handler.registerDriverConfig(driverConfig, getDerbyDatabaseConnection());
+ handler.registerDriver(driver, getDerbyDatabaseConnection());
// Inserted values
Map<String, String> map = new HashMap<String, String>();
map.put("A", "B");
// Connection object with all various values
- MLink link = new MLink(connector.getPersistenceId(), connector.getConnectionForms(), driverConfig.getConnectionForms());
- MConnectionForms forms = link.getConnectorPart();
+ MLink link = new MLink(connector.getPersistenceId(), connector.getLinkConfig());
+ MLinkConfig forms = link.getConnectorLinkConfig();
forms.getStringInput("f.String").setValue("A");
forms.getMapInput("f.Map").setValue(map);
forms.getIntegerInput("f.Integer").setValue(1);
@@ -111,7 +111,7 @@ public class TestInputTypes extends DerbyTestCase {
// Retrieve created link
MLink retrieved = handler.findLink(link.getPersistenceId(), getDerbyDatabaseConnection());
- forms = retrieved.getConnectorPart();
+ forms = retrieved.getConnectorLinkConfig();
assertEquals("A", forms.getStringInput("f.String").getValue());
assertEquals(map, forms.getMapInput("f.Map").getValue());
assertEquals(1, (int)forms.getIntegerInput("f.Integer").getValue());
@@ -125,8 +125,8 @@ public class TestInputTypes extends DerbyTestCase {
* @return Forms with all data types
*/
@Override
- protected List<MForm> getForms() {
- List<MForm> forms = new LinkedList<MForm>();
+ protected List<MConfig> getConfigs() {
+ List<MConfig> forms = new LinkedList<MConfig>();
List<MInput<?>> inputs;
MInput input;
@@ -148,7 +148,7 @@ public class TestInputTypes extends DerbyTestCase {
input = new MEnumInput("f.Enum", false, new String[] {"YES", "NO"});
inputs.add(input);
- forms.add(new MForm("f", inputs));
+ forms.add(new MConfig("f", inputs));
return forms;
}
}
[02/13] SQOOP-1498: Sqoop2: Repository Object refactoring (objects
prefixed with M)
Posted by ab...@apache.org.
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigDisplayer.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigDisplayer.java b/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigDisplayer.java
new file mode 100644
index 0000000..dea271a
--- /dev/null
+++ b/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigDisplayer.java
@@ -0,0 +1,258 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.shell.utils;
+
+import static org.apache.sqoop.shell.ShellEnvironment.print;
+import static org.apache.sqoop.shell.ShellEnvironment.println;
+import static org.apache.sqoop.shell.ShellEnvironment.resourceString;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.ResourceBundle;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.sqoop.common.Direction;
+import org.apache.sqoop.model.MAccountableEntity;
+import org.apache.sqoop.model.MBooleanInput;
+import org.apache.sqoop.model.MConfig;
+import org.apache.sqoop.model.MConnector;
+import org.apache.sqoop.model.MDriverConfig;
+import org.apache.sqoop.model.MEnumInput;
+import org.apache.sqoop.model.MInput;
+import org.apache.sqoop.model.MInputType;
+import org.apache.sqoop.model.MIntegerInput;
+import org.apache.sqoop.model.MJob;
+import org.apache.sqoop.model.MLink;
+import org.apache.sqoop.model.MMapInput;
+import org.apache.sqoop.model.MStringInput;
+import org.apache.sqoop.shell.core.Constants;
+import org.apache.sqoop.validation.Message;
+import org.apache.sqoop.validation.Status;
+
+/**
+ * Convenience static methods for displaying config related information
+ */
+public final class ConfigDisplayer {
+
+ public static void displayDriverConfigDetails(MDriverConfig driverConfig, ResourceBundle bundle) {
+ displayConfig(driverConfig.getConfigs(),
+ resourceString(Constants.RES_CONFIG_DISPLAYER_JOB), bundle);
+ }
+
+ public static void displayConnectorConfigDetails(MConnector connector, ResourceBundle bundle) {
+ displayConfig(
+ connector.getLinkConfig().getConfigs(),
+ resourceString(Constants.RES_CONFIG_DISPLAYER_LINK),
+ bundle);
+
+ displayConfig(
+ connector.getConfig(Direction.FROM).getConfigs(),
+ Direction.FROM.toString() + " " + resourceString(Constants.RES_CONFIG_DISPLAYER_JOB),
+ bundle);
+
+ displayConfig(
+ connector.getConfig(Direction.TO).getConfigs(),
+ Direction.TO.toString() + " " + resourceString(Constants.RES_CONFIG_DISPLAYER_JOB),
+ bundle);
+ }
+
+ private static void displayConfig(List<MConfig> configs,
+ String type,
+ ResourceBundle bundle) {
+ Iterator<MConfig> iterator = configs.iterator();
+ int findx = 1;
+ while (iterator.hasNext()) {
+ print(" ");
+ print(type);
+ print(" %s ", resourceString(Constants.RES_CONFIG_DISPLAYER_CONFIG));
+ print(findx++);
+ println(":");
+
+ MConfig config = iterator.next();
+ print(" %s: ", resourceString(Constants.RES_CONFIG_DISPLAYER_NAME));
+ println(config.getName());
+
+ // Label
+ print(" %s: ", resourceString(Constants.RES_CONFIG_DISPLAYER_LABEL));
+ println(bundle.getString(config.getLabelKey()));
+
+ // Help text
+ print(" %s: ", resourceString(Constants.RES_CONFIG_DISPLAYER_HELP));
+ println(bundle.getString(config.getHelpKey()));
+
+ List<MInput<?>> inputs = config.getInputs();
+ Iterator<MInput<?>> iiter = inputs.iterator();
+ int iindx = 1;
+ while (iiter.hasNext()) {
+ print(" %s ", resourceString(Constants.RES_CONFIG_DISPLAYER_INPUT));
+ print(iindx++);
+ println(":");
+
+ MInput<?> input = iiter.next();
+ print(" %s: ", resourceString(Constants.RES_CONFIG_DISPLAYER_NAME));
+ println(input.getName());
+ print(" %s: ", resourceString(Constants.RES_CONFIG_DISPLAYER_LABEL));
+ println(bundle.getString(input.getLabelKey()));
+ print(" %s: ", resourceString(Constants.RES_CONFIG_DISPLAYER_HELP));
+ println(bundle.getString(input.getHelpKey()));
+ print(" %s: ", resourceString(Constants.RES_CONFIG_DISPLAYER_TYPE));
+ println(input.getType());
+ print(" %s: ", resourceString(Constants.RES_CONFIG_DISPLAYER_SENSITIVE));
+ println(input.isSensitive());
+ if (input.getType() == MInputType.STRING) {
+ print(" %s: ", resourceString(Constants.RES_CONFIG_DISPLAYER_SIZE));
+ println(((MStringInput)input).getMaxLength());
+ } else if(input.getType() == MInputType.ENUM) {
+ print(" %s: ", resourceString(Constants.RES_CONFIG_DISPLAYER_POSSIBLE_VALUES));
+ println(StringUtils.join(((MEnumInput)input).getValues(), ","));
+ }
+ }
+ }
+ }
+
+ public static void displayConfig(List<MConfig> configs, ResourceBundle bundle) {
+ for(MConfig config : configs) {
+ displayConfig(config, bundle);
+ }
+ }
+
+ /**
+ * Method prints the warning message of ACCEPTABLE status
+ * @param entity - link or job instance
+ */
+ public static void displayConfigWarning(MAccountableEntity entity) {
+ List<MConfig> configList = new ArrayList<MConfig>();
+ boolean showMessage = true;
+ if (entity instanceof MLink) {
+ MLink link = (MLink) entity;
+ configList.addAll(link.getConnectorLinkConfig().getConfigs());
+ } else if(entity instanceof MJob) {
+ MJob job = (MJob) entity;
+ configList.addAll(job.getJobConfig(Direction.FROM).getConfigs());
+ configList.addAll(job.getDriverConfig().getConfigs());
+ configList.addAll(job.getJobConfig(Direction.TO).getConfigs());
+ }
+ for(MConfig config : configList) {
+ if(config.getValidationStatus() == Status.ACCEPTABLE) {
+ if(showMessage) {
+ print("\n@|yellow %s|@\n", resourceString(Constants.RES_CONFIG_DISPLAYER_FORM_WARNING));
+ showMessage = false;
+ }
+ for(Message message : config.getValidationMessages()) {
+ ConfigFiller.warningMessage(message.getMessage());
+ }
+ }
+ }
+ }
+
+ private static void displayConfig(MConfig config, ResourceBundle bundle) {
+ print(" ");
+ println(bundle.getString(config.getLabelKey()));
+
+ for (MInput<?> input : config.getInputs()) {
+ print(" ");
+ print(bundle.getString(input.getLabelKey()));
+ print(": ");
+ if(!input.isEmpty()) {
+ if (input.isSensitive()) {
+ print("(%s)", resourceString(Constants.RES_CONFIG_DISPLAYER_INPUT_SENSITIVE));
+ } else {
+ // Based on the input type, let's perconfig specific load
+ switch (input.getType()) {
+ case STRING:
+ displayInputString((MStringInput) input);
+ break;
+ case INTEGER:
+ displayInputInteger((MIntegerInput) input);
+ break;
+ case BOOLEAN:
+ displayInputBoolean((MBooleanInput) input);
+ break;
+ case MAP:
+ displayInputMap((MMapInput) input);
+ break;
+ case ENUM:
+ displayInputEnum((MEnumInput) input);
+ break;
+ default:
+ print("\n%s " + input.getType(), resourceString(Constants.RES_CONFIG_DISPLAYER_UNSUPPORTED_DATATYPE));
+ return;
+ }
+ }
+ }
+ println("");
+ }
+ }
+
+ /**
+ * Display content of String input.
+ *
+ * @param input String input
+ */
+ private static void displayInputString(MStringInput input) {
+ print(input.getValue());
+ }
+
+ /**
+ * Display content of Integer input.
+ *
+ * @param input Integer input
+ */
+ private static void displayInputInteger(MIntegerInput input) {
+ print(input.getValue());
+ }
+
+ /**
+ * Display content of Boolean input.
+ *
+ * @param input Boolean input
+ */
+ private static void displayInputBoolean(MBooleanInput input) {
+ print(input.getValue());
+ }
+
+ /**
+ * Display content of Map input
+ *
+ * @param input Map input
+ */
+ private static void displayInputMap(MMapInput input) {
+ for(Map.Entry<String, String> entry : input.getValue().entrySet()) {
+ println();
+ print(" ");
+ print(entry.getKey());
+ print(" = ");
+ print(entry.getValue());
+ }
+ }
+
+ /**
+ * Display content of Enum input
+ *
+ * @param input Enum input
+ */
+ private static void displayInputEnum(MEnumInput input) {
+ print(input.getValue());
+ }
+
+ private ConfigDisplayer() {
+ // Do not instantiate
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigFiller.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigFiller.java b/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigFiller.java
new file mode 100644
index 0000000..c61d33b
--- /dev/null
+++ b/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigFiller.java
@@ -0,0 +1,911 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.shell.utils;
+
+import jline.ConsoleReader;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.lang.StringUtils;
+import org.apache.sqoop.common.Direction;
+import org.apache.sqoop.model.MBooleanInput;
+import org.apache.sqoop.model.MLink;
+import org.apache.sqoop.model.MEnumInput;
+import org.apache.sqoop.model.MConfig;
+import org.apache.sqoop.model.MInput;
+import org.apache.sqoop.model.MIntegerInput;
+import org.apache.sqoop.model.MMapInput;
+import org.apache.sqoop.model.MJob;
+import org.apache.sqoop.model.MNamedElement;
+import org.apache.sqoop.model.MStringInput;
+import org.apache.sqoop.model.MValidatedElement;
+import org.apache.sqoop.validation.Message;
+import org.apache.sqoop.validation.Status;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.ResourceBundle;
+
+import static org.apache.sqoop.shell.ShellEnvironment.*;
+
+/**
+ * Convenient methods for retrieving user input and CLI options.
+ */
+public final class ConfigFiller {
+
+ /**
+ * Internal input that will be reused for loading names for link and
+ * job objects.
+ */
+ private static MStringInput nameInput = new MStringInput("object-name", false, (short)25);
+
+ /**
+ * Fill job object based on CLI options.
+ *
+ * @param line Associated console reader object
+ * @param job Job that user is suppose to fill in
+ * @return True if we filled all inputs, false if user has stopped processing
+ * @throws IOException
+ */
+ public static boolean fillJob(CommandLine line,
+ MJob job)
+ throws IOException {
+
+ job.setName(line.getOptionValue("name"));
+ return fillJobConfig(line,
+ job.getJobConfig(Direction.FROM).getConfigs(),
+ job.getJobConfig(Direction.TO).getConfigs(),
+ job.getDriverConfig().getConfigs());
+ }
+
+ /**
+ * Fill link object based on CLI options.
+ *
+ * @param line Associated command line options
+ * @param link Link that user is suppose to fill in
+ * @return True if we filled all inputs, false if user has stopped processing
+ * @throws IOException
+ */
+ public static boolean fillLink(CommandLine line, MLink link) throws IOException {
+
+ link.setName(line.getOptionValue("name"));
+ return fillLinkConfig(line, link.getConnectorLinkConfig().getConfigs());
+ }
+
+ /**
+ * Load CLI options for link configs
+ *
+ * @param line CLI options container
+ * @param linkConfig from config to read or edit
+ * @return
+ * @throws IOException
+ */
+ public static boolean fillLinkConfig(CommandLine line,
+ List<MConfig> linkConfig)
+ throws IOException {
+ return fillConfigs("link", linkConfig, line);
+ }
+
+ /**
+ * Load CLI options for job configs
+ *
+ * @param line CLI options container
+ * @param fromConfig from config to read or edit
+ * @param toConfig to config to read or edit
+ * @param driverConfig driver config to read or edit
+ * @return
+ * @throws IOException
+ */
+ public static boolean fillJobConfig(CommandLine line,
+ List<MConfig> fromConfig,
+ List<MConfig> toConfig,
+ List<MConfig> driverConfig)
+ throws IOException {
+ return fillConfigs("from", fromConfig, line)
+ && fillConfigs("to", toConfig, line)
+ && fillConfigs("driver", driverConfig, line);
+ }
+
+ /**
+ * Load all CLI options for a list of configs.
+ *
+ * @param prefix placed at the beginning of the CLI option key
+ * @param configs Forms to read or edit
+ * @param line CLI options container
+ * @return
+ * @throws IOException
+ */
+ static boolean fillConfigs(String prefix, List<MConfig> configs, CommandLine line)
+ throws IOException {
+ for (MConfig config : configs) {
+ if (!fillConfig(prefix, config, line)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Load all CLI options for a particular config.
+ *
+ * @param prefix placed at the beginning of the CLI option key
+ * @param config Config to read or edit
+ * @param line CLI options container
+ * @return
+ * @throws IOException
+ */
+ @SuppressWarnings("rawtypes")
+ static boolean fillConfig(String prefix, MConfig config, CommandLine line) throws IOException {
+ for (MInput input : config.getInputs()) {
+ if (!fillInput(prefix, input, line)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Load CLI option.
+ * Chooses the appropriate 'fill' method to use based on input type.
+ *
+ * Keys for CLI options are automatically created from the 'prefix' argument
+ * and 'input' argument: <prefix>-<config name>-<input name>
+ *
+ * @param prefix placed at the beginning of the CLI option key
+ * @param input Input that we should read or edit
+ * @param line CLI options container
+ * @return
+ * @throws IOException
+ */
+ @SuppressWarnings("rawtypes")
+ public static boolean fillInput(String prefix, MInput input, CommandLine line) throws IOException {
+ // Based on the input type, let's perconfig specific load
+ switch (input.getType()) {
+ case STRING:
+ return fillInputString(prefix, (MStringInput) input, line);
+ case INTEGER:
+ return fillInputInteger(prefix, (MIntegerInput) input, line);
+ case BOOLEAN:
+ return fillInputBoolean(prefix, (MBooleanInput) input, line);
+ case MAP:
+ return fillInputMap(prefix, (MMapInput) input, line);
+ case ENUM:
+ return fillInputEnum(prefix, (MEnumInput) input, line);
+ default:
+ println("Unsupported data type " + input.getType());
+ return true;
+ }
+ }
+
+ /**
+ * Load CLI option for enum type.
+ *
+ * Currently only supports numeric values.
+ *
+ * @param prefix placed at the beginning of the CLI option key
+ * @param input Input that we should read or edit
+ * @param line CLI options container
+ * @return
+ * @throws IOException
+ */
+ private static boolean fillInputEnum(String prefix,
+ MEnumInput input,
+ CommandLine line)
+ throws IOException {
+ String opt = ConfigOptions.getOptionKey(prefix, input);
+ if (line.hasOption(opt)) {
+ String value = line.getOptionValue(opt);
+ int index = java.util.Arrays.asList(input.getValues()).indexOf(value);
+
+ if(index < 0) {
+ errorMessage(input, String.format("Invalid option %s. Please use one of %s.", value, StringUtils.join(input.getValues(), ", ")));
+ return false;
+ }
+
+ input.setValue(value);
+ } else {
+ input.setEmpty();
+ }
+ return true;
+ }
+
+ /**
+ * Load CLI options for map type.
+ *
+ * Parses Key-Value pairs that take the config "<key>=<value>&<key>=<value>&...".
+ *
+ * @param prefix placed at the beginning of the CLI option key
+ * @param input Input that we should read or edit
+ * @param line CLI options container
+ * @return
+ * @throws IOException
+ */
+ private static boolean fillInputMap(String prefix,
+ MMapInput input,
+ CommandLine line)
+ throws IOException {
+ String opt = ConfigOptions.getOptionKey(prefix, input);
+ if (line.hasOption(opt)) {
+ String value = line.getOptionValue(opt);
+ Map<String, String> values = new HashMap<String, String>();
+ String[] entries = value.split("&");
+ for (String entry : entries) {
+ if (entry.contains("=")) {
+ String[] keyValue = entry.split("=");
+ values.put(keyValue[0], keyValue[1]);
+ } else {
+ errorMessage(input, "Don't know what to do with " + entry);
+ return false;
+ }
+ }
+ input.setValue(values);
+ } else {
+ input.setEmpty();
+ }
+ return true;
+ }
+
+ /**
+ * Load integer input from CLI option.
+ *
+ * @param prefix placed at the beginning of the CLI option key
+ * @param input Input that we should read or edit
+ * @param line CLI options container
+ * @return
+ * @throws IOException
+ */
+ private static boolean fillInputInteger(String prefix,
+ MIntegerInput input,
+ CommandLine line)
+ throws IOException {
+ String opt = ConfigOptions.getOptionKey(prefix, input);
+ if (line.hasOption(opt)) {
+ try {
+ input.setValue(Integer.valueOf(line.getOptionValue(ConfigOptions.getOptionKey(prefix, input))));
+ } catch (NumberFormatException ex) {
+ errorMessage(input, "Input is not valid integer number");
+ return false;
+ }
+ } else {
+ input.setEmpty();
+ }
+ return true;
+ }
+
+ /**
+ * Load string input from CLI option.
+ *
+ * @param prefix placed at the beginning of the CLI option key
+ * @param input Input that we should read or edit
+ * @param line CLI options container
+ * @return
+ * @throws IOException
+ */
+ public static boolean fillInputString(String prefix,
+ MStringInput input,
+ CommandLine line)
+ throws IOException {
+ String opt = ConfigOptions.getOptionKey(prefix, input);
+ if (line.hasOption(opt)) {
+ String value = line.getOptionValue(ConfigOptions.getOptionKey(prefix, input));
+ if(value.length() > input.getMaxLength()) {
+ errorMessage(input, "Size of input exceeds allowance for this input"
+ + " field. Maximal allowed size is " + input.getMaxLength());
+ }
+ input.setValue(value);
+ } else {
+ input.setEmpty();
+ }
+ return true;
+ }
+
+ /**
+ * Load boolean input from CLI option.
+ *
+ * @param prefix placed at the beginning of the CLI option key
+ * @param input Input that we should read or edit
+ * @param line CLI options container
+ * @return
+ * @throws IOException
+ */
+ public static boolean fillInputBoolean(String prefix,
+ MBooleanInput input,
+ CommandLine line)
+ throws IOException {
+ String opt = ConfigOptions.getOptionKey(prefix, input);
+ if (line.hasOption(opt)) {
+ input.setValue(Boolean.valueOf(line.getOptionValue(ConfigOptions.getOptionKey(prefix, input))));
+ } else {
+ input.setEmpty();
+ }
+ return true;
+ }
+
+ /**
+ * Fill link object based on user input.
+ *
+ * @param reader Associated console reader object
+ * @param link Link that user is suppose to fill in
+ * @param linkConfigBundle Connector resource bundle
+ * @return True if we filled all inputs, false if user has stopped processing
+ * @throws IOException
+ */
+ public static boolean fillLinkWithBundle(ConsoleReader reader, MLink link, ResourceBundle linkConfigBundle)
+ throws IOException {
+
+ link.setName(getName(reader, link.getName()));
+ return fillLinkConfigWithBundle(reader, link.getConnectorLinkConfig().getConfigs(), linkConfigBundle);
+ }
+
+ /**
+ * Fill job object based on user input.
+ *
+ * @param reader Associated console reader object
+ * @param job Job that user is suppose to fill in
+ * @param fromConfigBundle Connector resource bundle
+ * @param driverConfigBundle Driver config resource bundle
+ * @return True if we filled all inputs, false if user has stopped processing
+ * @throws IOException
+ */
+ public static boolean fillJobWithBundle(ConsoleReader reader,
+ MJob job,
+ ResourceBundle fromConfigBundle,
+ ResourceBundle toConfigBundle,
+ ResourceBundle driverConfigBundle)
+ throws IOException {
+
+ job.setName(getName(reader, job.getName()));
+
+ return fillJobConfigWithBundle(reader,
+ job.getJobConfig(Direction.FROM).getConfigs(),
+ fromConfigBundle,
+ job.getJobConfig(Direction.TO).getConfigs(),
+ toConfigBundle,
+ job.getDriverConfig().getConfigs(),
+ driverConfigBundle);
+ }
+ public static boolean fillLinkConfigWithBundle(ConsoleReader reader,
+ List<MConfig> linkConfig,
+ ResourceBundle linkConfigBundle) throws IOException {
+
+
+ if(!fillConfigsWithBundle(linkConfig, reader, linkConfigBundle)) {
+ return false;
+ }
+ return true;
+ }
+
+ public static boolean fillJobConfigWithBundle(ConsoleReader reader,
+ List<MConfig> fromConfig,
+ ResourceBundle fromConfigBundle,
+ List<MConfig> toConfig,
+ ResourceBundle toConfigBundle,
+ List<MConfig> driverConfig,
+ ResourceBundle driverConfigBundle) throws IOException {
+
+
+ // Job From config
+ if(!fillConfigsWithBundle(fromConfig, reader, fromConfigBundle)) {
+ return false;
+ }
+ // Job To config
+ if(!fillConfigsWithBundle(toConfig, reader, toConfigBundle)) {
+ return false;
+ }
+ // Job Driver config
+ if(!fillConfigsWithBundle(driverConfig, reader, driverConfigBundle)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public static boolean fillConfigsWithBundle(List<MConfig> configs, ConsoleReader reader,
+ ResourceBundle configBundle) throws IOException {
+ for (MConfig config : configs) {
+ if (!fillConfigWithBundle(config, reader, configBundle)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ @SuppressWarnings("rawtypes")
+ public static boolean fillConfigWithBundle(MConfig config, ConsoleReader reader, ResourceBundle bundle)
+ throws IOException {
+ println("");
+ println(bundle.getString(config.getLabelKey()));
+
+ // Print out config validation
+ printValidationMessage(config, false);
+ println("");
+
+ for (MInput input : config.getInputs()) {
+ if(!fillInputWithBundle(input, reader, bundle)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ @SuppressWarnings("rawtypes")
+ static boolean fillInputWithBundle(MInput input, ConsoleReader reader, ResourceBundle bundle)
+ throws IOException {
+ // Print out validation
+ printValidationMessage(input, false);
+
+ // Based on the input type, let's perconfig specific load
+ switch (input.getType()) {
+ case STRING:
+ return fillInputStringWithBundle((MStringInput) input, reader, bundle);
+ case INTEGER:
+ return fillInputInteger((MIntegerInput) input, reader, bundle);
+ case BOOLEAN:
+ return fillInputBooleanWithBundle((MBooleanInput) input, reader, bundle);
+ case MAP:
+ return fillInputMapWithBundle((MMapInput) input, reader, bundle);
+ case ENUM:
+ return fillInputEnumWithBundle((MEnumInput) input, reader, bundle);
+ default:
+ println("Unsupported data type " + input.getType());
+ return true;
+ }
+ }
+
+ /**
+ * Load user input for enum type.
+ *
+ * Print out numbered list of all available options and let user choose one
+ * item from that.
+ *
+ * @param input Input that we should read or edit
+ * @param reader Associated console reader
+ * @param bundle Resource bundle
+ * @return True if user with to continue with loading addtional inputs
+ * @throws IOException
+ */
+ private static boolean fillInputEnumWithBundle(MEnumInput input,
+ ConsoleReader reader,
+ ResourceBundle bundle)
+ throws IOException {
+ // Prompt in enum case
+ println(bundle.getString(input.getLabelKey()) + ": ");
+
+ // Indexes
+ int i = -1;
+ int lastChoice = -1;
+
+ // Print out all values as a numbered list
+ for(String value : input.getValues()) {
+ i++;
+
+ println(" " + i + " : " + value);
+
+ // Only show last choice if not sensitive
+ if(!input.isEmpty() && value.equals(input.getValue()) && !input.isSensitive()) {
+ lastChoice = i;
+ }
+ }
+
+ // Prompt
+ reader.printString("Choose: ");
+
+ // Fill previously filled index when available
+ if(lastChoice != -1) {
+ reader.putString(Integer.toString(lastChoice));
+ }
+
+ reader.flushConsole();
+ String userTyped;
+ if(input.isSensitive()) {
+ userTyped = reader.readLine('*');
+ } else {
+ userTyped = reader.readLine();
+ }
+
+ if (userTyped == null) {
+ return false;
+ } else if (userTyped.isEmpty()) {
+ input.setEmpty();
+ } else {
+ Integer index;
+ try {
+ index = Integer.valueOf(userTyped);
+
+ if(index < 0 || index >= input.getValues().length) {
+ errorMessage("Invalid index");
+ return fillInputEnumWithBundle(input, reader, bundle);
+ }
+
+ input.setValue(input.getValues()[index]);
+ } catch (NumberFormatException ex) {
+ errorMessage("Input is not valid integer number");
+ return fillInputEnumWithBundle(input, reader, bundle);
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Load user input for map type.
+ *
+ * This implementation will load one map entry at the time. Current flows is
+ * as follows: if user did not enter anything (empty input) finish loading
+ * and return from function. If user specified input with equal sign (=),
+ * lets add new key value pair. Otherwise consider entire input as a key name
+ * and try to remove it from the map.
+ *
+ * Please note that following code do not supports equal sign in property
+ * name. It's however perfectly fine to have equal sign in value.
+ *
+ * @param input Input that we should read or edit
+ * @param reader Associated console reader
+ * @param bundle Resource bundle
+ * @return True if user wish to continue with loading additional inputs
+ * @throws IOException
+ */
+ private static boolean fillInputMapWithBundle(MMapInput input,
+ ConsoleReader reader,
+ ResourceBundle bundle)
+ throws IOException {
+ // Special prompt in Map case
+ println(bundle.getString(input.getLabelKey()) + ": ");
+
+ // Internal loading map
+ Map<String, String> values = input.getValue();
+ if(values == null) {
+ values = new HashMap<String, String>();
+ }
+
+ String userTyped;
+
+ while(true) {
+ // Print all current items in each iteration
+ // However do not printout if this input contains sensitive information.
+ println("There are currently " + values.size() + " values in the map:");
+ if (!input.isSensitive()) {
+ for(Map.Entry<String, String> entry : values.entrySet()) {
+ println(entry.getKey() + " = " + entry.getValue());
+ }
+ }
+
+ // Special prompt for Map entry
+ reader.printString("entry# ");
+ reader.flushConsole();
+
+ if(input.isSensitive()) {
+ userTyped = reader.readLine('*');
+ } else {
+ userTyped = reader.readLine();
+ }
+
+ if(userTyped == null) {
+ // Finish loading and return back to Sqoop shell
+ return false;
+ } else if(userTyped.isEmpty()) {
+ // User has finished loading data to Map input, either set input empty
+ // if there are no entries or propagate entries to the input
+ if(values.size() == 0) {
+ input.setEmpty();
+ } else {
+ input.setValue(values);
+ }
+ return true;
+ } else {
+ // User has specified regular input, let's check if it contains equals
+ // sign. Save new entry (or update existing one) if it does. Otherwise
+ // try to remove entry that user specified.
+ if(userTyped.contains("=")) {
+ String []keyValue = userTyped.split("=", 2);
+ values.put(handleUserInput(keyValue[0]), handleUserInput(keyValue[1]));
+ } else {
+ String key = handleUserInput(userTyped);
+ if(values.containsKey(key)) {
+ values.remove(key);
+ } else {
+ errorMessage("Don't know what to do with " + userTyped);
+ }
+ }
+ }
+
+ }
+ }
+
+ /**
+ * Handle special cases in user input.
+ *
+ * Preserve null and empty values, remove whitespace characters before and
+ * after loaded string and de-quote the string if it's quoted (to preserve
+ * spaces for example).
+ *
+ * @param input String loaded from user
+ * @return Unquoted transconfiged string
+ */
+ private static String handleUserInput(String input) {
+ // Preserve null and empty values
+ if(input == null) {
+ return null;
+ }
+ if(input.isEmpty()) {
+ return input;
+ }
+
+ // Removes empty characters at the begging and end of loaded string
+ input = input.trim();
+
+ int lastIndex = input.length() - 1;
+ char first = input.charAt(0);
+ char last = input.charAt(lastIndex);
+
+ // Remove quoting if present
+ if(first == '\'' && last == '\'') {
+ input = input.substring(1, lastIndex);
+ } else if(first == '"' && last == '"') {
+ input = input.substring(1, lastIndex);
+ }
+
+ // Return final string
+ return input;
+ }
+
+ private static boolean fillInputInteger(MIntegerInput input,
+ ConsoleReader reader,
+ ResourceBundle bundle)
+ throws IOException {
+ generatePrompt(reader, bundle, input);
+
+ // Fill already filled data when available
+ // However do not printout if this input contains sensitive information.
+ if(!input.isEmpty() && !input.isSensitive()) {
+ reader.putString(input.getValue().toString());
+ }
+
+ // Get the data
+ String userTyped;
+ if(input.isSensitive()) {
+ userTyped = reader.readLine('*');
+ } else {
+ userTyped = reader.readLine();
+ }
+
+ if (userTyped == null) {
+ return false;
+ } else if (userTyped.isEmpty()) {
+ input.setEmpty();
+ } else {
+ Integer value;
+ try {
+ value = Integer.valueOf(userTyped);
+ input.setValue(value);
+ } catch (NumberFormatException ex) {
+ errorMessage("Input is not valid integer number");
+ return fillInputInteger(input, reader, bundle);
+ }
+
+ input.setValue(Integer.valueOf(userTyped));
+ }
+
+ return true;
+ }
+
+ /**
+ * Load string input from the user.
+ *
+ * @param input Input that we should load in
+ * @param reader Associated console reader
+ * @param bundle Resource bundle for this input
+ * @return
+ * @throws IOException
+ */
+ static boolean fillInputStringWithBundle(MStringInput input,
+ ConsoleReader reader,
+ ResourceBundle bundle)
+ throws IOException {
+ generatePrompt(reader, bundle, input);
+
+ // Fill already filled data when available
+ // However do not printout if this input contains sensitive information.
+ if(!input.isEmpty() && !input.isSensitive()) {
+ reader.putString(input.getValue());
+ }
+
+ // Get the data
+ String userTyped;
+ if(input.isSensitive()) {
+ userTyped = reader.readLine('*');
+ } else {
+ userTyped = reader.readLine();
+ }
+
+ if (userTyped == null) {
+ // Propagate end of loading process
+ return false;
+ } else if (userTyped.isEmpty()) {
+ // Empty input in case that nothing was given
+ input.setEmpty();
+ } else {
+ // Set value that user has entered
+ input.setValue(userTyped);
+
+ // Check that it did not exceeds maximal allowance for given input
+ if(userTyped.length() > input.getMaxLength()) {
+ errorMessage("Size of input exceeds allowance for this input"
+ + " field. Maximal allowed size is " + input.getMaxLength());
+ return fillInputStringWithBundle(input, reader, bundle);
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Load boolean input from the user.
+ *
+ * @param input Input that we should load in
+ * @param reader Associated console reader
+ * @param bundle Resource bundle for this input
+ * @return
+ * @throws IOException
+ */
+ static boolean fillInputBooleanWithBundle(MBooleanInput input,
+ ConsoleReader reader,
+ ResourceBundle bundle)
+ throws IOException {
+ generatePrompt(reader, bundle, input);
+
+ // Fill already filled data when available
+ // However do not printout if this input contains sensitive information.
+ if(!input.isEmpty() && !input.isSensitive()) {
+ reader.putString(input.getValue().toString());
+ }
+
+ // Get the data
+ String userTyped;
+ if(input.isSensitive()) {
+ userTyped = reader.readLine('*');
+ } else {
+ userTyped = reader.readLine();
+ }
+
+ if (userTyped == null) {
+ // Propagate end of loading process
+ return false;
+ } else if (userTyped.isEmpty()) {
+ // Empty input in case that nothing was given
+ input.setEmpty();
+ } else {
+ // Set value that user has entered
+ input.setValue(Boolean.valueOf(userTyped));
+ }
+
+ return true;
+ }
+
+ @SuppressWarnings("rawtypes")
+ static void generatePrompt(ConsoleReader reader, ResourceBundle bundle, MInput input)
+ throws IOException {
+ reader.printString(bundle.getString(input.getLabelKey()) + ": ");
+ reader.flushConsole();
+ }
+
+ static String getName(ConsoleReader reader, String name) throws IOException {
+ if (name == null) {
+ nameInput.setEmpty();
+ } else {
+ nameInput.setValue(name);
+ }
+
+ fillInputStringWithBundle(nameInput, reader, getResourceBundle());
+
+ return nameInput.getValue();
+ }
+
+ /**
+ * Print validation message in cases that it's not in state "FINE"
+ *
+ * @param element Validated element
+ */
+ static void printValidationMessage(MValidatedElement element, boolean includeInputPrefix) {
+ if(element.getValidationStatus() == Status.getDefault()) {
+ return;
+ }
+
+ for(Message message : element.getValidationMessages())
+ switch (message.getStatus()) {
+ case UNACCEPTABLE:
+ if (includeInputPrefix) {
+ errorMessage(element, message.getMessage());
+ } else {
+ errorMessage(message.getMessage());
+ }
+ break;
+ case ACCEPTABLE:
+ if (includeInputPrefix) {
+ warningMessage(element, message.getMessage());
+ } else {
+ warningMessage(message.getMessage());
+ }
+ break;
+ default:
+ // Simply ignore all other states for the moment
+ break;
+ }
+ }
+
+ static void errorMessage(String message) {
+ println("Error message: @|red " + message + " |@");
+ }
+
+ static void errorMessage(MNamedElement input, String message) {
+ print(input.getName());
+ print(": ");
+ errorMessage(message);
+ }
+
+ static void warningMessage(String message) {
+ println("Warning message: @|yellow " + message + " |@");
+ }
+
+ static void warningMessage(MNamedElement input, String message) {
+ print(input.getName());
+ print(": ");
+ warningMessage(message);
+ }
+
+ public static void errorIntroduction() {
+ println("\n @|red There are issues with entered data, please revise your input:|@");
+ }
+
+ // link object has the connector link config
+ public static void printLinkValidationMessages(MLink link) {
+ for (MConfig config : link.getConnectorLinkConfig().getConfigs()) {
+ for (MInput<?> input : config.getInputs()) {
+ printValidationMessage(input, true);
+ }
+ }
+ }
+
+ // job has the from/to and the driver config
+ public static void printJobValidationMessages(MJob job) {
+ for (MConfig config : job.getJobConfig(Direction.FROM).getConfigs()) {
+ for (MInput<?> input : config.getInputs()) {
+ printValidationMessage(input, true);
+ }
+ }
+
+ for (MConfig config : job.getJobConfig(Direction.TO).getConfigs()) {
+ for (MInput<?> input : config.getInputs()) {
+ printValidationMessage(input, true);
+ }
+ }
+
+ for (MConfig config : job.getDriverConfig().getConfigs()) {
+ for (MInput<?> input : config.getInputs()) {
+ printValidationMessage(input, true);
+ }
+ }
+ }
+
+ private ConfigFiller() {
+ // Do not instantiate
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigOptions.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigOptions.java b/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigOptions.java
new file mode 100644
index 0000000..97b6e3b
--- /dev/null
+++ b/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigOptions.java
@@ -0,0 +1,117 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.shell.utils;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.GnuParser;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.model.MConfig;
+import org.apache.sqoop.model.MInput;
+import org.apache.sqoop.model.MInputType;
+import org.apache.sqoop.shell.core.ShellError;
+
+/**
+ * Utilities for automatically creating org.apache.commons.cli.Option objects.
+ */
+public class ConfigOptions {
+ /**
+ * This method is used to automatically generate keys
+ * for a particular input.
+ *
+ * @param prefix Prefix to prepend to CLI option keys
+ * @param input
+ * @return
+ */
+ @SuppressWarnings("rawtypes")
+ public static String getOptionKey(String prefix, MInput input) {
+ return prefix + "-" + input.getName().replace('.', '-');
+ }
+
+ /**
+ * This method is used to automatically generate CLI options
+ * for a list of configs.
+ *
+ * @param prefix Prefix to prepend to CLI option keys
+ * @param configs Forms to get options for
+ * @return
+ */
+ public static List<Option> getConfigsOptions(String prefix, List<MConfig> configs) {
+ List<Option> options = new LinkedList<Option>();
+ for (MConfig config : configs) {
+ List<Option> configOptions = getConfigOptions(prefix, config);
+ options.addAll(configOptions);
+ }
+ return options;
+ }
+
+ /**
+ * This method is used to automatically generate CLI options
+ * for a particular config.
+ *
+ * @param prefix Prefix to prepend to CLI option keys
+ * @param config Config to get options for
+ * @return List<Option>
+ */
+ @SuppressWarnings({ "rawtypes", "static-access" })
+ public static List<Option> getConfigOptions(String prefix, MConfig config) {
+ List<Option> options = new LinkedList<Option>();
+ for (MInput input : config.getInputs()) {
+ if (input.getType().equals(MInputType.BOOLEAN)) {
+ options.add(OptionBuilder
+ .withLongOpt(getOptionKey(prefix, input))
+ .create());
+ } else {
+ options.add(OptionBuilder
+ .withLongOpt(getOptionKey(prefix, input))
+ .hasArg()
+ .create());
+ }
+ }
+ return options;
+ }
+
+ /**
+ * Parses command line options.
+ *
+ * @param options parse arglist against these.
+ * @param start beginning index in arglist.
+ * @param arglist arguments to parse.
+ * @param stopAtNonOption stop parsing when nonoption found in arglist.
+ * @return CommandLine object
+ */
+ public static CommandLine parseOptions(Options options, int start, List<String> arglist, boolean stopAtNonOption) {
+ String[] args = arglist.subList(start, arglist.size()).toArray(new String[arglist.size() - start]);
+
+ CommandLineParser parser = new GnuParser();
+ CommandLine line;
+ try {
+ line = parser.parse(options, args, stopAtNonOption);
+ } catch (ParseException e) {
+ throw new SqoopException(ShellError.SHELL_0003, e.getMessage(), e);
+ }
+ return line;
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/shell/src/main/java/org/apache/sqoop/shell/utils/DynamicConfigOptions.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/utils/DynamicConfigOptions.java b/shell/src/main/java/org/apache/sqoop/shell/utils/DynamicConfigOptions.java
new file mode 100644
index 0000000..d12bd2f
--- /dev/null
+++ b/shell/src/main/java/org/apache/sqoop/shell/utils/DynamicConfigOptions.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.shell.utils;
+
+import org.apache.commons.cli.Options;
+
+/**
+ * Automatically create options for different components.
+ */
+@SuppressWarnings("serial")
+public abstract class DynamicConfigOptions<M> extends Options {
+
+ /**
+ * Create dynamic options.
+ *
+ * @param model generate options from this
+ * @return this
+ */
+ public abstract void prepareOptions(M model);
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/shell/src/main/java/org/apache/sqoop/shell/utils/DynamicFormOptions.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/utils/DynamicFormOptions.java b/shell/src/main/java/org/apache/sqoop/shell/utils/DynamicFormOptions.java
deleted file mode 100644
index cc63610..0000000
--- a/shell/src/main/java/org/apache/sqoop/shell/utils/DynamicFormOptions.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.shell.utils;
-
-import org.apache.commons.cli.Options;
-
-/**
- * Automatically create options for different components.
- */
-@SuppressWarnings("serial")
-public abstract class DynamicFormOptions<M> extends Options {
-
- /**
- * Create dynamic options.
- *
- * @param model generate options from this
- * @return this
- */
- public abstract void prepareOptions(M model);
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/shell/src/main/java/org/apache/sqoop/shell/utils/FormDisplayer.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/utils/FormDisplayer.java b/shell/src/main/java/org/apache/sqoop/shell/utils/FormDisplayer.java
deleted file mode 100644
index dcbccef..0000000
--- a/shell/src/main/java/org/apache/sqoop/shell/utils/FormDisplayer.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.shell.utils;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.sqoop.common.Direction;
-import org.apache.sqoop.model.MAccountableEntity;
-import org.apache.sqoop.model.MBooleanInput;
-import org.apache.sqoop.model.MLink;
-import org.apache.sqoop.model.MConnector;
-import org.apache.sqoop.model.MEnumInput;
-import org.apache.sqoop.model.MForm;
-import org.apache.sqoop.model.MDriverConfig;
-import org.apache.sqoop.model.MInput;
-import org.apache.sqoop.model.MInputType;
-import org.apache.sqoop.model.MIntegerInput;
-import org.apache.sqoop.model.MJob;
-import org.apache.sqoop.model.MMapInput;
-import org.apache.sqoop.model.MStringInput;
-import org.apache.sqoop.shell.core.Constants;
-import org.apache.sqoop.validation.Message;
-import org.apache.sqoop.validation.Status;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.ResourceBundle;
-
-import static org.apache.sqoop.shell.ShellEnvironment.*;
-
-/**
- * Convenience static methods for displaying form related information
- */
-public final class FormDisplayer {
-
- public static void displayFormMetadataDetails(MDriverConfig driverConfig,
- ResourceBundle bundle) {
- displayFormsMetadata(
- driverConfig.getConnectionForms().getForms(),
- resourceString(Constants.RES_FORMDISPLAYER_CONNECTION),
- bundle);
-
- displayFormsMetadata(
- driverConfig.getJobForms().getForms(),
- resourceString(Constants.RES_FORMDISPLAYER_JOB),
- bundle);
- }
-
- public static void displayFormMetadataDetails(MConnector connector,
- ResourceBundle bundle) {
- displayFormsMetadata(
- connector.getConnectionForms().getForms(),
- resourceString(Constants.RES_FORMDISPLAYER_CONNECTION),
- bundle);
-
- // @TODO(Abe): Validate From/To output is correct.
- displayFormsMetadata(
- connector.getJobForms(Direction.FROM).getForms(),
- Direction.FROM.toString() + " " + resourceString(Constants.RES_FORMDISPLAYER_JOB),
- bundle);
-
- displayFormsMetadata(
- connector.getJobForms(Direction.TO).getForms(),
- Direction.TO.toString() + " " + resourceString(Constants.RES_FORMDISPLAYER_JOB),
- bundle);
- }
-
- public static void displayFormsMetadata(List<MForm> forms,
- String type,
- ResourceBundle bundle) {
- Iterator<MForm> fiter = forms.iterator();
- int findx = 1;
- while (fiter.hasNext()) {
- print(" ");
- print(type);
- print(" %s ", resourceString(Constants.RES_FORMDISPLAYER_FORM));
- print(findx++);
- println(":");
-
- MForm form = fiter.next();
- print(" %s: ", resourceString(Constants.RES_FORMDISPLAYER_NAME));
- println(form.getName());
-
- // Label
- print(" %s: ", resourceString(Constants.RES_FORMDISPLAYER_LABEL));
- println(bundle.getString(form.getLabelKey()));
-
- // Help text
- print(" %s: ", resourceString(Constants.RES_FORMDISPLAYER_HELP));
- println(bundle.getString(form.getHelpKey()));
-
- List<MInput<?>> inputs = form.getInputs();
- Iterator<MInput<?>> iiter = inputs.iterator();
- int iindx = 1;
- while (iiter.hasNext()) {
- print(" %s ", resourceString(Constants.RES_FORMDISPLAYER_INPUT));
- print(iindx++);
- println(":");
-
- MInput<?> input = iiter.next();
- print(" %s: ", resourceString(Constants.RES_FORMDISPLAYER_NAME));
- println(input.getName());
- print(" %s: ", resourceString(Constants.RES_FORMDISPLAYER_LABEL));
- println(bundle.getString(input.getLabelKey()));
- print(" %s: ", resourceString(Constants.RES_FORMDISPLAYER_HELP));
- println(bundle.getString(input.getHelpKey()));
- print(" %s: ", resourceString(Constants.RES_FORMDISPLAYER_TYPE));
- println(input.getType());
- print(" %s: ", resourceString(Constants.RES_FORMDISPLAYER_SENSITIVE));
- println(input.isSensitive());
- if (input.getType() == MInputType.STRING) {
- print(" %s: ", resourceString(Constants.RES_FORMDISPLAYER_SIZE));
- println(((MStringInput)input).getMaxLength());
- } else if(input.getType() == MInputType.ENUM) {
- print(" %s: ", resourceString(Constants.RES_FORMDISPLAYER_POSSIBLE_VALUES));
- println(StringUtils.join(((MEnumInput)input).getValues(), ","));
- }
- }
- }
- }
-
- public static void displayForms(List<MForm> forms, ResourceBundle bundle) {
- for(MForm form : forms) {
- displayForm(form, bundle);
- }
- }
-
- /**
- * Method prints the warning message of ACCEPTABLE status
- * @param entity - link or job instance
- */
- public static void displayFormWarning(MAccountableEntity entity) {
- List<MForm> formList = new ArrayList<MForm>();
- boolean showMessage = true;
- if (entity instanceof MLink) {
- MLink link = (MLink) entity;
- formList.addAll(link.getConnectorPart().getForms());
- formList.addAll(link.getFrameworkPart().getForms());
- } else if(entity instanceof MJob) {
- MJob job = (MJob) entity;
- formList.addAll(job.getConnectorPart(Direction.FROM).getForms());
- formList.addAll(job.getFrameworkPart().getForms());
- formList.addAll(job.getConnectorPart(Direction.TO).getForms());
- }
- for(MForm form : formList) {
- if(form.getValidationStatus() == Status.ACCEPTABLE) {
- if(showMessage) {
- print("\n@|yellow %s|@\n", resourceString(Constants.RES_FORMDISPLAYER_FORM_WARNING));
- showMessage = false;
- }
- for(Message message : form.getValidationMessages()) {
- FormFiller.warningMessage(message.getMessage());
- }
- }
- }
- }
-
- private static void displayForm(MForm form, ResourceBundle bundle) {
- print(" ");
- println(bundle.getString(form.getLabelKey()));
-
- for (MInput<?> input : form.getInputs()) {
- print(" ");
- print(bundle.getString(input.getLabelKey()));
- print(": ");
- if(!input.isEmpty()) {
- if (input.isSensitive()) {
- print("(%s)", resourceString(Constants.RES_FORMDISPLAYER_INPUT_SENSITIVE));
- } else {
- // Based on the input type, let's perform specific load
- switch (input.getType()) {
- case STRING:
- displayInputString((MStringInput) input);
- break;
- case INTEGER:
- displayInputInteger((MIntegerInput) input);
- break;
- case BOOLEAN:
- displayInputBoolean((MBooleanInput) input);
- break;
- case MAP:
- displayInputMap((MMapInput) input);
- break;
- case ENUM:
- displayInputEnum((MEnumInput) input);
- break;
- default:
- print("\n%s " + input.getType(), resourceString(Constants.RES_FORMDISPLAYER_UNSUPPORTED_DATATYPE));
- return;
- }
- }
- }
- println("");
- }
- }
-
- /**
- * Display content of String input.
- *
- * @param input String input
- */
- private static void displayInputString(MStringInput input) {
- print(input.getValue());
- }
-
- /**
- * Display content of Integer input.
- *
- * @param input Integer input
- */
- private static void displayInputInteger(MIntegerInput input) {
- print(input.getValue());
- }
-
- /**
- * Display content of Boolean input.
- *
- * @param input Boolean input
- */
- private static void displayInputBoolean(MBooleanInput input) {
- print(input.getValue());
- }
-
- /**
- * Display content of Map input
- *
- * @param input Map input
- */
- private static void displayInputMap(MMapInput input) {
- for(Map.Entry<String, String> entry : input.getValue().entrySet()) {
- println();
- print(" ");
- print(entry.getKey());
- print(" = ");
- print(entry.getValue());
- }
- }
-
- /**
- * Display content of Enum input
- *
- * @param input Enum input
- */
- private static void displayInputEnum(MEnumInput input) {
- print(input.getValue());
- }
-
- private FormDisplayer() {
- // Do not instantiate
- }
-}
[12/13] SQOOP-1498: Sqoop2: Repository Object refactoring (objects
prefixed with M)
Posted by ab...@apache.org.
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/json/util/ConfigSerialization.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/json/util/ConfigSerialization.java b/common/src/main/java/org/apache/sqoop/json/util/ConfigSerialization.java
new file mode 100644
index 0000000..cec46f6
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/json/util/ConfigSerialization.java
@@ -0,0 +1,226 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.json.util;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.model.MBooleanInput;
+import org.apache.sqoop.model.MEnumInput;
+import org.apache.sqoop.model.MConfig;
+import org.apache.sqoop.model.MConfigType;
+import org.apache.sqoop.model.MInput;
+import org.apache.sqoop.model.MInputType;
+import org.apache.sqoop.model.MIntegerInput;
+import org.apache.sqoop.model.MMapInput;
+import org.apache.sqoop.model.MStringInput;
+import org.json.simple.JSONArray;
+import org.json.simple.JSONObject;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Convenient static methods for serializing config objects.
+ */
+public final class ConfigSerialization {
+
+ public static final String ALL = "all";
+ public static final String ID = "id";
+ public static final String NAME = "name";
+ public static final String VERSION = "version";
+ public static final String CLASS = "class";
+ public static final String ENABLED = "enabled";
+ public static final String CREATION_USER = "creation-user";
+ public static final String CREATION_DATE = "creation-date";
+ public static final String UPDATE_USER = "update-user";
+ public static final String UPDATE_DATE = "update-date";
+ // TODO(VB): Move these constants to connector bean
+ public static final String CONNECTOR_LINK_CONFIG = "link-config";
+ public static final String CONNECTOR_JOB_CONFIG = "job-config";
+ // TODO:move these configs to driver bean
+ public static final String DRIVER_VERSION = "driver-version";
+ public static final String DRIVER_CONFIG = "driver-config";
+
+ public static final String CONFIG_NAME = "name";
+ public static final String CONFIG_TYPE = "type";
+ public static final String CONFIG_INPUTS = "inputs";
+ public static final String CONFIG_INPUT_NAME = "name";
+ public static final String CONFIG_INPUT_TYPE = "type";
+ public static final String CONFIG_INPUT_SENSITIVE = "sensitive";
+ public static final String CONFIG_INPUT_SIZE = "size";
+ public static final String CONFIG_INPUT_VALUE = "value";
+ public static final String CONFIG_INPUT_VALUES = "values";
+
+ /**
+ * Transform given list of configs to JSON Array object.
+ *
+ * @param mConfigs List of configs.
+ * @return JSON object with serialized config of the list.
+ */
+ @SuppressWarnings("unchecked")
+ public static JSONArray extractConfigList(List<MConfig> mConfigs, boolean skipSensitive) {
+ JSONArray configs = new JSONArray();
+
+ for (MConfig mConfig : mConfigs) {
+ configs.add(extractConfig(mConfig, skipSensitive));
+ }
+
+ return configs;
+ }
+
+ /**
+ * Transform given config to JSON Object.
+ *
+ * @param mConfig Given MConfig instance
+ * @param skipSensitive conditionally add sensitive input values
+ * @return Serialized JSON object.
+ */
+ @SuppressWarnings("unchecked")
+ static JSONObject extractConfig(MConfig mConfig, boolean skipSensitive) {
+ JSONObject config = new JSONObject();
+ config.put(ID, mConfig.getPersistenceId());
+ config.put(CONFIG_NAME, mConfig.getName());
+ config.put(CONFIG_TYPE, MConfigType.LINK.toString());
+ JSONArray mInputs = new JSONArray();
+ config.put(CONFIG_INPUTS, mInputs);
+
+ for (MInput<?> mInput : mConfig.getInputs()) {
+ JSONObject input = new JSONObject();
+ input.put(ID, mInput.getPersistenceId());
+ input.put(CONFIG_INPUT_NAME, mInput.getName());
+ input.put(CONFIG_INPUT_TYPE, mInput.getType().toString());
+ input.put(CONFIG_INPUT_SENSITIVE, mInput.isSensitive());
+
+ // String specific serialization
+ if (mInput.getType() == MInputType.STRING) {
+ input.put(CONFIG_INPUT_SIZE,
+ ((MStringInput)mInput).getMaxLength());
+ }
+
+ // Enum specific serialization
+ if(mInput.getType() == MInputType.ENUM) {
+ input.put(CONFIG_INPUT_VALUES,
+ StringUtils.join(((MEnumInput)mInput).getValues(), ","));
+ }
+
+ // Serialize value if is there
+ // Skip if sensitive
+ if (!mInput.isEmpty() && !(skipSensitive && mInput.isSensitive())) {
+ if (mInput.getType() == MInputType.MAP) {
+ input.put(CONFIG_INPUT_VALUE, mInput.getValue());
+ } else {
+ input.put(CONFIG_INPUT_VALUE, mInput.getUrlSafeValueString());
+ }
+ }
+
+ mInputs.add(input);
+ }
+
+ return config;
+ }
+
+ /**
+ * Restore List of MConfigs from JSON Array.
+ *
+ * @param configs JSON array representing list of MConfigs
+ * @return Restored list of MConfigs
+ */
+ public static List<MConfig> restoreConfigList(JSONArray configs) {
+ List<MConfig> mConfigs = new ArrayList<MConfig>();
+
+ for (int i = 0; i < configs.size(); i++) {
+ mConfigs.add(restoreConfig((JSONObject) configs.get(i)));
+ }
+
+ return mConfigs;
+ }
+
+ /**
+ * Restore one MConfig from JSON Object.
+ *
+ * @param config JSON representation of the MConfig.
+ * @return Restored MConfig.
+ */
+ static MConfig restoreConfig(JSONObject config) {
+ JSONArray inputs = (JSONArray) config.get(CONFIG_INPUTS);
+
+ List<MInput<?>> mInputs = new ArrayList<MInput<?>>();
+ for (int i = 0; i < inputs.size(); i++) {
+ JSONObject input = (JSONObject) inputs.get(i);
+ MInputType type =
+ MInputType.valueOf((String) input.get(CONFIG_INPUT_TYPE));
+ String name = (String) input.get(CONFIG_INPUT_NAME);
+ Boolean sensitive = (Boolean) input.get(CONFIG_INPUT_SENSITIVE);
+ MInput mInput = null;
+ switch (type) {
+ case STRING: {
+ long size = (Long) input.get(CONFIG_INPUT_SIZE);
+ mInput = new MStringInput(name, sensitive.booleanValue(), (short) size);
+ break;
+ }
+ case MAP: {
+ mInput = new MMapInput(name, sensitive.booleanValue());
+ break;
+ }
+ case INTEGER: {
+ mInput = new MIntegerInput(name, sensitive.booleanValue());
+ break;
+ }
+ case BOOLEAN: {
+ mInput = new MBooleanInput(name, sensitive.booleanValue());
+ break;
+ }
+ case ENUM: {
+ String values = (String) input.get(CONFIG_INPUT_VALUES);
+ mInput = new MEnumInput(name, sensitive.booleanValue(), values.split(","));
+ break;
+ }
+ }
+
+ // Propagate config ID
+ mInput.setPersistenceId((Long)input.get(ID));
+
+ // Propagate config optional value
+ if(input.containsKey(CONFIG_INPUT_VALUE)) {
+ switch (type) {
+ case MAP:
+ try {
+ mInput.setValue((Map<String, String>)input.get(CONFIG_INPUT_VALUE));
+ } catch (ClassCastException e) {
+ throw new SqoopException(SerializationError.SERIALIZATION_001, name + " requires a 'map' value.");
+ }
+ break;
+ default:
+ mInput.restoreFromUrlSafeValueString(
+ (String) input.get(CONFIG_INPUT_VALUE));
+ break;
+ }
+ }
+ mInputs.add(mInput);
+ }
+
+ MConfig mConfig = new MConfig((String) config.get(CONFIG_NAME), mInputs);
+ mConfig.setPersistenceId((Long) config.get(ID));
+ return mConfig;
+ }
+
+ private ConfigSerialization() {
+ // Do not instantiate
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/json/util/FormSerialization.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/json/util/FormSerialization.java b/common/src/main/java/org/apache/sqoop/json/util/FormSerialization.java
deleted file mode 100644
index 77f6191..0000000
--- a/common/src/main/java/org/apache/sqoop/json/util/FormSerialization.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.json.util;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.sqoop.common.SqoopException;
-import org.apache.sqoop.model.MBooleanInput;
-import org.apache.sqoop.model.MEnumInput;
-import org.apache.sqoop.model.MForm;
-import org.apache.sqoop.model.MFormType;
-import org.apache.sqoop.model.MInput;
-import org.apache.sqoop.model.MInputType;
-import org.apache.sqoop.model.MIntegerInput;
-import org.apache.sqoop.model.MMapInput;
-import org.apache.sqoop.model.MStringInput;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Convenient static methods for serializing forms.
- */
-public final class FormSerialization {
-
- public static final String ALL = "all";
- public static final String ID = "id";
- public static final String NAME = "name";
- public static final String VERSION = "version";
- public static final String DRIVER_VERSION = "driver-version";
- public static final String CLASS = "class";
- public static final String ENABLED = "enabled";
- public static final String CREATION_USER = "creation-user";
- public static final String CREATION_DATE = "creation-date";
- public static final String UPDATE_USER = "update-user";
- public static final String UPDATE_DATE = "update-date";
- public static final String CON_FORMS = "con-forms";
- public static final String JOB_FORMS = "job-forms";
-
- public static final String FORM_NAME = "name";
- public static final String FORM_TYPE = "type";
- public static final String FORM_INPUTS = "inputs";
- public static final String FORM_INPUT_NAME = "name";
- public static final String FORM_INPUT_TYPE = "type";
- public static final String FORM_INPUT_SENSITIVE = "sensitive";
- public static final String FORM_INPUT_SIZE = "size";
- public static final String FORM_INPUT_VALUE = "value";
- public static final String FORM_INPUT_VALUES = "values";
-
- /**
- * Transform given list of forms to JSON Array object.
- *
- * @param mForms List of forms.
- * @return JSON object with serialized form of the list.
- */
- @SuppressWarnings("unchecked")
- public static JSONArray extractForms(List<MForm> mForms, boolean skipSensitive) {
- JSONArray forms = new JSONArray();
-
- for (MForm mForm : mForms) {
- forms.add(extractForm(mForm, skipSensitive));
- }
-
- return forms;
- }
-
- /**
- * Transform given form to JSON Object.
- *
- * @param mForm Given MForm instance
- * @param skipSensitive conditionally add sensitive input values
- * @return Serialized JSON object.
- */
- @SuppressWarnings("unchecked")
- public static JSONObject extractForm(MForm mForm, boolean skipSensitive) {
- JSONObject form = new JSONObject();
- form.put(ID, mForm.getPersistenceId());
- form.put(FORM_NAME, mForm.getName());
- form.put(FORM_TYPE, MFormType.CONNECTION.toString());
- JSONArray mInputs = new JSONArray();
- form.put(FORM_INPUTS, mInputs);
-
- for (MInput<?> mInput : mForm.getInputs()) {
- JSONObject input = new JSONObject();
- input.put(ID, mInput.getPersistenceId());
- input.put(FORM_INPUT_NAME, mInput.getName());
- input.put(FORM_INPUT_TYPE, mInput.getType().toString());
- input.put(FORM_INPUT_SENSITIVE, mInput.isSensitive());
-
- // String specific serialization
- if (mInput.getType() == MInputType.STRING) {
- input.put(FORM_INPUT_SIZE,
- ((MStringInput)mInput).getMaxLength());
- }
-
- // Enum specific serialization
- if(mInput.getType() == MInputType.ENUM) {
- input.put(FORM_INPUT_VALUES,
- StringUtils.join(((MEnumInput)mInput).getValues(), ","));
- }
-
- // Serialize value if is there
- // Skip if sensitive
- if (!mInput.isEmpty() && !(skipSensitive && mInput.isSensitive())) {
- if (mInput.getType() == MInputType.MAP) {
- input.put(FORM_INPUT_VALUE, mInput.getValue());
- } else {
- input.put(FORM_INPUT_VALUE, mInput.getUrlSafeValueString());
- }
- }
-
- mInputs.add(input);
- }
-
- return form;
- }
-
- /**
- * Restore List of MForms from JSON Array.
- *
- * @param forms JSON array representing list of MForms
- * @return Restored list of MForms
- */
- public static List<MForm> restoreForms(JSONArray forms) {
- List<MForm> mForms = new ArrayList<MForm>();
-
- for (int i = 0; i < forms.size(); i++) {
- mForms.add(restoreForm((JSONObject) forms.get(i)));
- }
-
- return mForms;
- }
-
- /**
- * Restore one MForm from JSON Object.
- *
- * @param form JSON representation of the MForm.
- * @return Restored MForm.
- */
- public static MForm restoreForm(JSONObject form) {
- JSONArray inputs = (JSONArray) form.get(FORM_INPUTS);
-
- List<MInput<?>> mInputs = new ArrayList<MInput<?>>();
- for (int i = 0; i < inputs.size(); i++) {
- JSONObject input = (JSONObject) inputs.get(i);
- MInputType type =
- MInputType.valueOf((String) input.get(FORM_INPUT_TYPE));
- String name = (String) input.get(FORM_INPUT_NAME);
- Boolean sensitive = (Boolean) input.get(FORM_INPUT_SENSITIVE);
- MInput mInput = null;
- switch (type) {
- case STRING: {
- long size = (Long) input.get(FORM_INPUT_SIZE);
- mInput = new MStringInput(name, sensitive.booleanValue(), (short) size);
- break;
- }
- case MAP: {
- mInput = new MMapInput(name, sensitive.booleanValue());
- break;
- }
- case INTEGER: {
- mInput = new MIntegerInput(name, sensitive.booleanValue());
- break;
- }
- case BOOLEAN: {
- mInput = new MBooleanInput(name, sensitive.booleanValue());
- break;
- }
- case ENUM: {
- String values = (String) input.get(FORM_INPUT_VALUES);
- mInput = new MEnumInput(name, sensitive.booleanValue(), values.split(","));
- break;
- }
- }
-
- // Propagate form ID
- mInput.setPersistenceId((Long)input.get(ID));
-
- // Propagate form optional value
- if(input.containsKey(FORM_INPUT_VALUE)) {
- switch (type) {
- case MAP:
- try {
- mInput.setValue((Map<String, String>)input.get(FORM_INPUT_VALUE));
- } catch (ClassCastException e) {
- throw new SqoopException(SerializationError.SERIALIZATION_001, name + " requires a 'map' value.");
- }
- break;
- default:
- mInput.restoreFromUrlSafeValueString(
- (String) input.get(FORM_INPUT_VALUE));
- break;
- }
- }
- mInputs.add(mInput);
- }
-
- MForm mForm = new MForm((String) form.get(FORM_NAME), mInputs);
- mForm.setPersistenceId((Long) form.get(ID));
- return mForm;
- }
-
- private FormSerialization() {
- // Do not instantiate
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/json/util/ResourceBundleSerialization.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/json/util/ResourceBundleSerialization.java b/common/src/main/java/org/apache/sqoop/json/util/ResourceBundleSerialization.java
index 20ee5f3..f27d81d 100644
--- a/common/src/main/java/org/apache/sqoop/json/util/ResourceBundleSerialization.java
+++ b/common/src/main/java/org/apache/sqoop/json/util/ResourceBundleSerialization.java
@@ -43,7 +43,6 @@ public final class ResourceBundleSerialization {
for (ResourceBundle bundle : bundles) {
array.add(extractResourceBundle(bundle));
}
-
return array;
}
@@ -58,7 +57,6 @@ public final class ResourceBundleSerialization {
return json;
}
- @SuppressWarnings("unchecked")
public static List<ResourceBundle> restoreResourceBundles(JSONArray array) {
List<ResourceBundle> bundles = new LinkedList<ResourceBundle>();
for (Object item : array) {
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/model/Config.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/Config.java b/common/src/main/java/org/apache/sqoop/model/Config.java
new file mode 100644
index 0000000..46e7268
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/model/Config.java
@@ -0,0 +1,28 @@
+/**
+ * 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.model;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Denote config in Configuration class
+ */
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Config {
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/model/ConfigClass.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/ConfigClass.java b/common/src/main/java/org/apache/sqoop/model/ConfigClass.java
new file mode 100644
index 0000000..f925759
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/model/ConfigClass.java
@@ -0,0 +1,45 @@
+/**
+ * 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.model;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Denote configuration class
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface ConfigClass {
+
+ /**
+ * Default size for Inputs in this config.
+ *
+ * @return
+ */
+ short defaultSize() default -1;
+
+ /**
+ * List of validators associated with this config.
+ *
+ * @return
+ */
+ Validator[] validators() default {};
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/model/ConfigUtils.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/ConfigUtils.java b/common/src/main/java/org/apache/sqoop/model/ConfigUtils.java
new file mode 100644
index 0000000..290e7fc
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/model/ConfigUtils.java
@@ -0,0 +1,565 @@
+/**
+ * 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.model;
+
+import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.utils.ClassUtils;
+import org.apache.sqoop.validation.Message;
+import org.apache.sqoop.validation.Status;
+import org.apache.sqoop.validation.ConfigValidator;
+import org.apache.sqoop.validation.ConfigValidationResult;
+import org.json.simple.JSONObject;
+import org.json.simple.JSONValue;
+
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Util class for transforming data from correctly annotated configuration
+ * objects to different structures and vice-versa.
+ *
+ * TODO: This class should see some overhaul into more reusable code, especially expose and re-use the methods at the end.
+ */
+public class ConfigUtils {
+
+ /**
+ * Transform correctly annotated configuration object to corresponding
+ * list of configs.
+ *
+ * Configs will be order according to the occurrence in the configuration
+ * class. Inputs will be also ordered based on occurrence.
+ *
+ * @param configuration Annotated arbitrary configuration object
+ * @return Corresponding list of configs
+ */
+ public static List<MConfig> toConfigs(Object configuration) {
+ return toConfigs(configuration.getClass(), configuration);
+ }
+
+ public static List<MConfig> toConfigs(Class klass) {
+ return toConfigs(klass, null);
+ }
+
+ @SuppressWarnings("unchecked")
+ public static List<MConfig> toConfigs(Class klass, Object configuration) {
+ ConfigurationClass configurationClass =
+ (ConfigurationClass)klass.getAnnotation(ConfigurationClass.class);
+
+ // Each configuration object must have this class annotation
+ if(configurationClass == null) {
+ throw new SqoopException(ModelError.MODEL_003,
+ "Missing annotation ConfigurationClass on class " + klass.getName());
+ }
+
+ List<MConfig> configs = new LinkedList<MConfig>();
+
+ // Iterate over all declared fields
+ for (Field field : klass.getDeclaredFields()) {
+ field.setAccessible(true);
+
+ String formName = field.getName();
+
+ // Each field that should be part of user input should have Input
+ // annotation.
+ Config formAnnotation = field.getAnnotation(Config.class);
+
+ if(formAnnotation != null) {
+ Class type = field.getType();
+
+ Object value = null;
+ if(configuration != null) {
+ try {
+ value = field.get(configuration);
+ } catch (IllegalAccessException e) {
+ throw new SqoopException(ModelError.MODEL_005,
+ "Can't retrieve value from " + field.getName(), e);
+ }
+ }
+
+ configs.add(toConfig(formName, type, value));
+ }
+ }
+
+ return configs;
+ }
+
+ @SuppressWarnings("unchecked")
+ private static MConfig toConfig(String formName, Class klass, Object object) {
+ ConfigClass global =
+ (ConfigClass)klass.getAnnotation(ConfigClass.class);
+
+ // Each configuration object must have this class annotation
+ if(global == null) {
+ throw new SqoopException(ModelError.MODEL_003,
+ "Missing annotation ConfigClass on class " + klass.getName());
+ }
+
+ // Intermediate list of inputs
+ List<MInput<?>> inputs = new LinkedList<MInput<?>>();
+
+ // Iterate over all declared fields
+ for (Field field : klass.getDeclaredFields()) {
+ field.setAccessible(true);
+
+ String fieldName = field.getName();
+ String inputName = formName + "." + fieldName;
+
+ // Each field that should be part of user input should have Input
+ // annotation.
+ Input inputAnnotation = field.getAnnotation(Input.class);
+
+ if(inputAnnotation != null) {
+ boolean sensitive = inputAnnotation.sensitive();
+ short maxLen = inputAnnotation.size();
+ Class type = field.getType();
+
+ MInput input;
+
+ // We need to support NULL, so we do not support primitive types
+ if(type.isPrimitive()) {
+ throw new SqoopException(ModelError.MODEL_007,
+ "Detected primitive type " + type + " for field " + fieldName);
+ }
+
+ // Instantiate corresponding MInput<?> structure
+ if(type == String.class) {
+ input = new MStringInput(inputName, sensitive, maxLen);
+ } else if (type.isAssignableFrom(Map.class)) {
+ input = new MMapInput(inputName, sensitive);
+ } else if(type == Integer.class) {
+ input = new MIntegerInput(inputName, sensitive);
+ } else if(type == Boolean.class) {
+ input = new MBooleanInput(inputName, sensitive);
+ } else if(type.isEnum()) {
+ input = new MEnumInput(inputName, sensitive, ClassUtils.getEnumStrings(type));
+ } else {
+ throw new SqoopException(ModelError.MODEL_004,
+ "Unsupported type " + type.getName() + " for input " + fieldName);
+ }
+
+ // Move value if it's present in original configuration object
+ if(object != null) {
+ Object value;
+ try {
+ value = field.get(object);
+ } catch (IllegalAccessException e) {
+ throw new SqoopException(ModelError.MODEL_005,
+ "Can't retrieve value from " + field.getName(), e);
+ }
+ if(value == null) {
+ input.setEmpty();
+ } else {
+ input.setValue(value);
+ }
+ }
+
+ inputs.add(input);
+ }
+ }
+
+ return new MConfig(formName, inputs);
+ }
+
+ /**
+ * Move config values from config list into corresponding configuration object.
+ *
+ * @param configs Input config list
+ * @param configuration Output configuration object
+ */
+ public static void fromConfigs(List<MConfig> configs, Object configuration) {
+ Class klass = configuration.getClass();
+
+ for(MConfig config : configs) {
+ Field configField;
+ try {
+ configField = klass.getDeclaredField(config.getName());
+ } catch (NoSuchFieldException e) {
+ throw new SqoopException(ModelError.MODEL_006,
+ "Missing field " + config.getName() + " on config class " + klass.getCanonicalName(), e);
+ }
+
+ // We need to access this field even if it would be declared as private
+ configField.setAccessible(true);
+
+ Class configClass = configField.getType();
+ Object newValue = ClassUtils.instantiate(configClass);
+
+ if(newValue == null) {
+ throw new SqoopException(ModelError.MODEL_006,
+ "Can't instantiate new config " + configClass);
+ }
+
+ for(MInput input : config.getInputs()) {
+ String[] splitNames = input.getName().split("\\.");
+ if(splitNames.length != 2) {
+ throw new SqoopException(ModelError.MODEL_009,
+ "Invalid name: " + input.getName());
+ }
+
+ String inputName = splitNames[1];
+ // TODO(jarcec): Names structures fix, handle error cases
+ Field inputField;
+ try {
+ inputField = configClass.getDeclaredField(inputName);
+ } catch (NoSuchFieldException e) {
+ throw new SqoopException(ModelError.MODEL_006,
+ "Missing field " + input.getName(), e);
+ }
+
+ // We need to access this field even if it would be declared as private
+ inputField.setAccessible(true);
+
+ try {
+ if(input.isEmpty()) {
+ inputField.set(newValue, null);
+ } else {
+ if (input.getType() == MInputType.ENUM) {
+ inputField.set(newValue, Enum.valueOf((Class<? extends Enum>)inputField.getType(), (String) input.getValue()));
+ } else {
+ inputField.set(newValue, input.getValue());
+ }
+ }
+ } catch (IllegalAccessException e) {
+ throw new SqoopException(ModelError.MODEL_005,
+ "Issue with field " + inputField.getName(), e);
+ }
+ }
+
+ try {
+ configField.set(configuration, newValue);
+ } catch (IllegalAccessException e) {
+ throw new SqoopException(ModelError.MODEL_005,
+ "Issue with field " + configField.getName(), e);
+ }
+ }
+ }
+
+ /**
+ * Apply validations on the configs.
+ *
+ * @param configs Configs that should be updated
+ * @param validation Validation that we should apply
+ */
+ public static void applyValidation(List<MConfig> configs, ConfigValidator validation) {
+ Map<ConfigValidator.ConfigInput, ConfigValidator.Message> messages = validation.getMessages();
+
+ for(MConfig config : configs) {
+ applyValidation(config, messages);
+
+ for(MInput input : config.getInputs()) {
+ applyValidation(input, messages);
+ }
+ }
+ }
+
+ /**
+ * Apply validation on given validated element.
+ *
+ * @param element Element on what we're applying the validations
+ * @param messages Map of all validation messages
+ */
+ public static void applyValidation(MValidatedElement element, Map<ConfigValidator.ConfigInput, ConfigValidator.Message> messages) {
+ ConfigValidator.ConfigInput name = new ConfigValidator.ConfigInput(element.getName());
+
+ if(messages.containsKey(name)) {
+ ConfigValidator.Message message = messages.get(name);
+ element.addValidationMessage(new Message(message.getStatus(), message.getMessage()));
+ } else {
+ element.addValidationMessage(new Message(Status.getDefault(), null));
+ }
+ }
+
+
+ /**
+ * Apply given validations on list of configs.
+ *
+ * @param configs
+ * @param result
+ */
+ public static void applyValidation(List<MConfig> configs, ConfigValidationResult result) {
+ for(MConfig config : configs) {
+ applyValidation(config, result);
+
+ for(MInput input : config.getInputs()) {
+ applyValidation(input, result);
+ }
+ }
+ }
+
+ /**
+ * Apply validation messages on given element.
+ *
+ * Element's state will be set to default if there are no associated messages.
+ *
+ * @param element
+ * @param result
+ */
+ public static void applyValidation(MValidatedElement element, ConfigValidationResult result) {
+ List<Message> messages = result.getMessages().get(element.getName());
+
+ if(messages != null) {
+ element.setValidationMessages(messages);
+ } else {
+ element.resetValidationMessages();
+ }
+ }
+
+ /**
+ * Convert configuration object to JSON. Only filled properties are serialized,
+ * properties with null value are skipped.
+ *
+ * @param configuration Correctly annotated configuration object
+ * @return String of JSON representation
+ */
+ @SuppressWarnings("unchecked")
+ public static String toJson(Object configuration) {
+ Class klass = configuration.getClass();
+
+ ConfigurationClass configurationClass =
+ (ConfigurationClass)klass.getAnnotation(ConfigurationClass.class);
+
+ // Each configuration object must have this class annotation
+ if(configurationClass == null) {
+ throw new SqoopException(ModelError.MODEL_003,
+ "Missing annotation ConfigurationGroup on class " + klass.getName());
+ }
+
+ JSONObject jsonOutput = new JSONObject();
+
+ // Iterate over all declared fields
+ for (Field formField : klass.getDeclaredFields()) {
+ formField.setAccessible(true);
+ String formName = formField.getName();
+
+ // We're processing only config validations
+ Config formAnnotation = formField.getAnnotation(Config.class);
+ if(formAnnotation == null) {
+ continue;
+ }
+
+ Object formValue;
+ try {
+ formValue = formField.get(configuration);
+ } catch (IllegalAccessException e) {
+ throw new SqoopException(ModelError.MODEL_005,
+ "Issue with field " + formName, e);
+ }
+
+ JSONObject jsonConfig = new JSONObject();
+
+ // Now process each input on the config
+ for(Field inputField : formField.getType().getDeclaredFields()) {
+ inputField.setAccessible(true);
+ String inputName = inputField.getName();
+
+ Object value;
+ try {
+ value = inputField.get(formValue);
+ } catch (IllegalAccessException e) {
+ throw new SqoopException(ModelError.MODEL_005,
+ "Issue with field " + formName + "." + inputName, e);
+ }
+
+ Input inputAnnotation = inputField.getAnnotation(Input.class);
+
+ // Do not serialize all values
+ if(inputAnnotation != null && value != null) {
+ Class type = inputField.getType();
+
+ // We need to support NULL, so we do not support primitive types
+ if(type.isPrimitive()) {
+ throw new SqoopException(ModelError.MODEL_007,
+ "Detected primitive type " + type + " for field " + formName + "." + inputName);
+ }
+
+ if(type == String.class) {
+ jsonConfig.put(inputName, value);
+ } else if (type.isAssignableFrom(Map.class)) {
+ JSONObject map = new JSONObject();
+ for(Object key : ((Map)value).keySet()) {
+ map.put(key, ((Map)value).get(key));
+ }
+ jsonConfig.put(inputName, map);
+ } else if(type == Integer.class) {
+ jsonConfig.put(inputName, value);
+ } else if(type.isEnum()) {
+ jsonConfig.put(inputName, value.toString());
+ } else if(type == Boolean.class) {
+ jsonConfig.put(inputName, value);
+ }else {
+ throw new SqoopException(ModelError.MODEL_004,
+ "Unsupported type " + type.getName() + " for input " + formName + "." + inputName);
+ }
+ }
+ }
+
+ jsonOutput.put(formName, jsonConfig);
+ }
+
+ return jsonOutput.toJSONString();
+ }
+
+ /**
+ * Parse given input JSON string and move it's values to given configuration
+ * object.
+ *
+ * @param json JSON representation of the configuration object
+ * @param configuration ConfigurationGroup object to be filled
+ */
+ public static void fillValues(String json, Object configuration) {
+ Class klass = configuration.getClass();
+
+ JSONObject jsonConfigs = (JSONObject) JSONValue.parse(json);
+
+ for(Field configField : klass.getDeclaredFields()) {
+ configField.setAccessible(true);
+ String configName = configField.getName();
+
+ // We're processing only config validations
+ Config formAnnotation = configField.getAnnotation(Config.class);
+ if(formAnnotation == null) {
+ continue;
+ }
+
+ try {
+ configField.set(configuration, configField.getType().newInstance());
+ } catch (Exception e) {
+ throw new SqoopException(ModelError.MODEL_005,
+ "Issue with field " + configName, e);
+ }
+
+ JSONObject jsonInputs = (JSONObject) jsonConfigs.get(configField.getName());
+ if(jsonInputs == null) {
+ continue;
+ }
+
+ Object configValue;
+ try {
+ configValue = configField.get(configuration);
+ } catch (IllegalAccessException e) {
+ throw new SqoopException(ModelError.MODEL_005,
+ "Issue with field " + configName, e);
+ }
+
+ for(Field inputField : configField.getType().getDeclaredFields()) {
+ inputField.setAccessible(true);
+ String inputName = inputField.getName();
+
+ Input inputAnnotation = inputField.getAnnotation(Input.class);
+
+ if(inputAnnotation == null || jsonInputs.get(inputName) == null) {
+ try {
+ inputField.set(configValue, null);
+ } catch (IllegalAccessException e) {
+ throw new SqoopException(ModelError.MODEL_005,
+ "Issue with field " + configName + "." + inputName, e);
+ }
+ continue;
+ }
+
+ Class type = inputField.getType();
+
+ try {
+ if(type == String.class) {
+ inputField.set(configValue, jsonInputs.get(inputName));
+ } else if (type.isAssignableFrom(Map.class)) {
+ Map<String, String> map = new HashMap<String, String>();
+ JSONObject jsonObject = (JSONObject) jsonInputs.get(inputName);
+ for(Object key : jsonObject.keySet()) {
+ map.put((String)key, (String)jsonObject.get(key));
+ }
+ inputField.set(configValue, map);
+ } else if(type == Integer.class) {
+ inputField.set(configValue, ((Long)jsonInputs.get(inputName)).intValue());
+ } else if(type.isEnum()) {
+ inputField.set(configValue, Enum.valueOf((Class<? extends Enum>) inputField.getType(), (String) jsonInputs.get(inputName)));
+ } else if(type == Boolean.class) {
+ inputField.set(configValue, (Boolean) jsonInputs.get(inputName));
+ }else {
+ throw new SqoopException(ModelError.MODEL_004,
+ "Unsupported type " + type.getName() + " for input " + configName + "." + inputName);
+ }
+ } catch (IllegalAccessException e) {
+ throw new SqoopException(ModelError.MODEL_005,
+ "Issue with field " + configName + "." + inputName, e);
+ }
+ }
+ }
+ }
+
+ public static String getName(Field input, Input annotation) {
+ return input.getName();
+ }
+
+ public static String getName(Field config, Config annotation) {
+ return config.getName();
+ }
+
+ public static ConfigurationClass getConfigurationClassAnnotation(Object object, boolean strict) {
+ ConfigurationClass annotation = object.getClass().getAnnotation(ConfigurationClass.class);
+
+ if(strict && annotation == null) {
+ throw new SqoopException(ModelError.MODEL_003, "Missing annotation ConfigurationGroupClass on class " + object.getClass().getName());
+ }
+
+ return annotation;
+ }
+
+ public static ConfigClass getConfigClassAnnotation(Object object, boolean strict) {
+ ConfigClass annotation = object.getClass().getAnnotation(ConfigClass.class);
+
+ if(strict && annotation == null) {
+ throw new SqoopException(ModelError.MODEL_003, "Missing annotation ConfigurationGroupClass on class " + object.getClass().getName());
+ }
+
+ return annotation;
+ }
+
+ public static Config getConfigAnnotation(Field field, boolean strict) {
+ Config annotation = field.getAnnotation(Config.class);
+
+ if(strict && annotation == null) {
+ throw new SqoopException(ModelError.MODEL_003, "Missing annotation Config on Field " + field.getName() + " on class " + field.getDeclaringClass().getName());
+ }
+
+ return annotation;
+ }
+
+ public static Input getInputAnnotation(Field field, boolean strict) {
+ Input annotation = field.getAnnotation(Input.class);
+
+ if(strict && annotation == null) {
+ throw new SqoopException(ModelError.MODEL_003, "Missing annotation Input on Field " + field.getName() + " on class " + field.getDeclaringClass().getName());
+ }
+
+ return annotation;
+ }
+
+ public static Object getFieldValue(Field field, Object object) {
+ try {
+ field.setAccessible(true);
+ return field.get(object);
+ } catch (IllegalAccessException e) {
+ throw new SqoopException(ModelError.MODEL_012, e);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/model/ConfigurationClass.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/ConfigurationClass.java b/common/src/main/java/org/apache/sqoop/model/ConfigurationClass.java
index 73374d8..c65c478 100644
--- a/common/src/main/java/org/apache/sqoop/model/ConfigurationClass.java
+++ b/common/src/main/java/org/apache/sqoop/model/ConfigurationClass.java
@@ -23,15 +23,16 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
- * Class annotation. Each class that is used a configuration object where user
- * is expected to provide input need to have this annotation.
+ * Class annotation to represent configuration for the connectors
+ * Each class that is used a configuration group object, the connector developer
+ * is expected to provide the inputs needed for this annotation
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface ConfigurationClass {
/**
- * List of validators associated with this Configuration class.
+ * List of validators associated with this Configuration group class.
*
* @return
*/
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/model/Form.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/Form.java b/common/src/main/java/org/apache/sqoop/model/Form.java
deleted file mode 100644
index 4321582..0000000
--- a/common/src/main/java/org/apache/sqoop/model/Form.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.model;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * Denote form in Configuration class
- */
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Form {
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/model/FormClass.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/FormClass.java b/common/src/main/java/org/apache/sqoop/model/FormClass.java
deleted file mode 100644
index 6048d03..0000000
--- a/common/src/main/java/org/apache/sqoop/model/FormClass.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.model;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Denote configuration class
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-public @interface FormClass {
-
- /**
- * Default size for Inputs in this form.
- *
- * @return
- */
- short defaultSize() default -1;
-
- /**
- * List of validators associated with this form.
- *
- * @return
- */
- Validator[] validators() default {};
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/model/FormUtils.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/FormUtils.java b/common/src/main/java/org/apache/sqoop/model/FormUtils.java
deleted file mode 100644
index ae025ab..0000000
--- a/common/src/main/java/org/apache/sqoop/model/FormUtils.java
+++ /dev/null
@@ -1,565 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.model;
-
-import org.apache.sqoop.common.SqoopException;
-import org.apache.sqoop.utils.ClassUtils;
-import org.apache.sqoop.validation.Message;
-import org.apache.sqoop.validation.Status;
-import org.apache.sqoop.validation.Validation;
-import org.apache.sqoop.validation.ValidationResult;
-import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
-
-import java.lang.reflect.Field;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Util class for transforming data from correctly annotated configuration
- * objects to different structures and vice-versa.
- *
- * TODO: This class should see some overhaul into more reusable code, especially expose and re-use the methods at the end.
- */
-public class FormUtils {
-
- /**
- * Transform correctly annotated configuration object to corresponding
- * list of forms.
- *
- * Forms will be order according to the occurrence in the configuration
- * class. Inputs will be also ordered based on occurrence.
- *
- * @param configuration Annotated arbitrary configuration object
- * @return Corresponding list of forms
- */
- public static List<MForm> toForms(Object configuration) {
- return toForms(configuration.getClass(), configuration);
- }
-
- public static List<MForm> toForms(Class klass) {
- return toForms(klass, null);
- }
-
- @SuppressWarnings("unchecked")
- public static List<MForm> toForms(Class klass, Object configuration) {
- ConfigurationClass global =
- (ConfigurationClass)klass.getAnnotation(ConfigurationClass.class);
-
- // Each configuration object must have this class annotation
- if(global == null) {
- throw new SqoopException(ModelError.MODEL_003,
- "Missing annotation ConfigurationClass on class " + klass.getName());
- }
-
- List<MForm> forms = new LinkedList<MForm>();
-
- // Iterate over all declared fields
- for (Field field : klass.getDeclaredFields()) {
- field.setAccessible(true);
-
- String formName = field.getName();
-
- // Each field that should be part of user input should have Input
- // annotation.
- Form formAnnotation = field.getAnnotation(Form.class);
-
- if(formAnnotation != null) {
- Class type = field.getType();
-
- Object value = null;
- if(configuration != null) {
- try {
- value = field.get(configuration);
- } catch (IllegalAccessException e) {
- throw new SqoopException(ModelError.MODEL_005,
- "Can't retrieve value from " + field.getName(), e);
- }
- }
-
- forms.add(toForm(formName, type, value));
- }
- }
-
- return forms;
- }
-
- @SuppressWarnings("unchecked")
- private static MForm toForm(String formName, Class klass, Object object) {
- FormClass global =
- (FormClass)klass.getAnnotation(FormClass.class);
-
- // Each configuration object must have this class annotation
- if(global == null) {
- throw new SqoopException(ModelError.MODEL_003,
- "Missing annotation FormClass on class " + klass.getName());
- }
-
- // Intermediate list of inputs
- List<MInput<?>> inputs = new LinkedList<MInput<?>>();
-
- // Iterate over all declared fields
- for (Field field : klass.getDeclaredFields()) {
- field.setAccessible(true);
-
- String fieldName = field.getName();
- String inputName = formName + "." + fieldName;
-
- // Each field that should be part of user input should have Input
- // annotation.
- Input inputAnnotation = field.getAnnotation(Input.class);
-
- if(inputAnnotation != null) {
- boolean sensitive = inputAnnotation.sensitive();
- short maxLen = inputAnnotation.size();
- Class type = field.getType();
-
- MInput input;
-
- // We need to support NULL, so we do not support primitive types
- if(type.isPrimitive()) {
- throw new SqoopException(ModelError.MODEL_007,
- "Detected primitive type " + type + " for field " + fieldName);
- }
-
- // Instantiate corresponding MInput<?> structure
- if(type == String.class) {
- input = new MStringInput(inputName, sensitive, maxLen);
- } else if (type.isAssignableFrom(Map.class)) {
- input = new MMapInput(inputName, sensitive);
- } else if(type == Integer.class) {
- input = new MIntegerInput(inputName, sensitive);
- } else if(type == Boolean.class) {
- input = new MBooleanInput(inputName, sensitive);
- } else if(type.isEnum()) {
- input = new MEnumInput(inputName, sensitive, ClassUtils.getEnumStrings(type));
- } else {
- throw new SqoopException(ModelError.MODEL_004,
- "Unsupported type " + type.getName() + " for input " + fieldName);
- }
-
- // Move value if it's present in original configuration object
- if(object != null) {
- Object value;
- try {
- value = field.get(object);
- } catch (IllegalAccessException e) {
- throw new SqoopException(ModelError.MODEL_005,
- "Can't retrieve value from " + field.getName(), e);
- }
- if(value == null) {
- input.setEmpty();
- } else {
- input.setValue(value);
- }
- }
-
- inputs.add(input);
- }
- }
-
- return new MForm(formName, inputs);
- }
-
- /**
- * Move form values from form list into corresponding configuration object.
- *
- * @param forms Input form list
- * @param configuration Output configuration object
- */
- public static void fromForms(List<MForm> forms, Object configuration) {
- Class klass = configuration.getClass();
-
- for(MForm form : forms) {
- Field formField;
- try {
- formField = klass.getDeclaredField(form.getName());
- } catch (NoSuchFieldException e) {
- throw new SqoopException(ModelError.MODEL_006,
- "Missing field " + form.getName() + " on form class " + klass.getCanonicalName(), e);
- }
-
- // We need to access this field even if it would be declared as private
- formField.setAccessible(true);
-
- Class formClass = formField.getType();
- Object newValue = ClassUtils.instantiate(formClass);
-
- if(newValue == null) {
- throw new SqoopException(ModelError.MODEL_006,
- "Can't instantiate new form " + formClass);
- }
-
- for(MInput input : form.getInputs()) {
- String[] splitNames = input.getName().split("\\.");
- if(splitNames.length != 2) {
- throw new SqoopException(ModelError.MODEL_009,
- "Invalid name: " + input.getName());
- }
-
- String inputName = splitNames[1];
- // TODO(jarcec): Names structures fix, handle error cases
- Field inputField;
- try {
- inputField = formClass.getDeclaredField(inputName);
- } catch (NoSuchFieldException e) {
- throw new SqoopException(ModelError.MODEL_006,
- "Missing field " + input.getName(), e);
- }
-
- // We need to access this field even if it would be declared as private
- inputField.setAccessible(true);
-
- try {
- if(input.isEmpty()) {
- inputField.set(newValue, null);
- } else {
- if (input.getType() == MInputType.ENUM) {
- inputField.set(newValue, Enum.valueOf((Class<? extends Enum>)inputField.getType(), (String) input.getValue()));
- } else {
- inputField.set(newValue, input.getValue());
- }
- }
- } catch (IllegalAccessException e) {
- throw new SqoopException(ModelError.MODEL_005,
- "Issue with field " + inputField.getName(), e);
- }
- }
-
- try {
- formField.set(configuration, newValue);
- } catch (IllegalAccessException e) {
- throw new SqoopException(ModelError.MODEL_005,
- "Issue with field " + formField.getName(), e);
- }
- }
- }
-
- /**
- * Apply validations on the forms.
- *
- * @param forms Forms that should be updated
- * @param validation Validation that we should apply
- */
- public static void applyValidation(List<MForm> forms, Validation validation) {
- Map<Validation.FormInput, Validation.Message> messages = validation.getMessages();
-
- for(MForm form : forms) {
- applyValidation(form, messages);
-
- for(MInput input : form.getInputs()) {
- applyValidation(input, messages);
- }
- }
- }
-
- /**
- * Apply validation on given validated element.
- *
- * @param element Element on what we're applying the validations
- * @param messages Map of all validation messages
- */
- public static void applyValidation(MValidatedElement element, Map<Validation.FormInput, Validation.Message> messages) {
- Validation.FormInput name = new Validation.FormInput(element.getName());
-
- if(messages.containsKey(name)) {
- Validation.Message message = messages.get(name);
- element.addValidationMessage(new Message(message.getStatus(), message.getMessage()));
- } else {
- element.addValidationMessage(new Message(Status.getDefault(), null));
- }
- }
-
-
- /**
- * Apply given validations on list of forms.
- *
- * @param forms
- * @param result
- */
- public static void applyValidation(List<MForm> forms, ValidationResult result) {
- for(MForm form : forms) {
- applyValidation(form, result);
-
- for(MInput input : form.getInputs()) {
- applyValidation(input, result);
- }
- }
- }
-
- /**
- * Apply validation messages on given element.
- *
- * Element's state will be set to default if there are no associated messages.
- *
- * @param element
- * @param result
- */
- public static void applyValidation(MValidatedElement element, ValidationResult result) {
- List<Message> messages = result.getMessages().get(element.getName());
-
- if(messages != null) {
- element.setValidationMessages(messages);
- } else {
- element.resetValidationMessages();
- }
- }
-
- /**
- * Convert configuration object to JSON. Only filled properties are serialized,
- * properties with null value are skipped.
- *
- * @param configuration Correctly annotated configuration object
- * @return String of JSON representation
- */
- @SuppressWarnings("unchecked")
- public static String toJson(Object configuration) {
- Class klass = configuration.getClass();
-
- ConfigurationClass global =
- (ConfigurationClass)klass.getAnnotation(ConfigurationClass.class);
-
- // Each configuration object must have this class annotation
- if(global == null) {
- throw new SqoopException(ModelError.MODEL_003,
- "Missing annotation Configuration on class " + klass.getName());
- }
-
- JSONObject jsonOutput = new JSONObject();
-
- // Iterate over all declared fields
- for (Field formField : klass.getDeclaredFields()) {
- formField.setAccessible(true);
- String formName = formField.getName();
-
- // We're processing only form validations
- Form formAnnotation = formField.getAnnotation(Form.class);
- if(formAnnotation == null) {
- continue;
- }
-
- Object formValue;
- try {
- formValue = formField.get(configuration);
- } catch (IllegalAccessException e) {
- throw new SqoopException(ModelError.MODEL_005,
- "Issue with field " + formName, e);
- }
-
- JSONObject jsonForm = new JSONObject();
-
- // Now process each input on the form
- for(Field inputField : formField.getType().getDeclaredFields()) {
- inputField.setAccessible(true);
- String inputName = inputField.getName();
-
- Object value;
- try {
- value = inputField.get(formValue);
- } catch (IllegalAccessException e) {
- throw new SqoopException(ModelError.MODEL_005,
- "Issue with field " + formName + "." + inputName, e);
- }
-
- Input inputAnnotation = inputField.getAnnotation(Input.class);
-
- // Do not serialize all values
- if(inputAnnotation != null && value != null) {
- Class type = inputField.getType();
-
- // We need to support NULL, so we do not support primitive types
- if(type.isPrimitive()) {
- throw new SqoopException(ModelError.MODEL_007,
- "Detected primitive type " + type + " for field " + formName + "." + inputName);
- }
-
- if(type == String.class) {
- jsonForm.put(inputName, value);
- } else if (type.isAssignableFrom(Map.class)) {
- JSONObject map = new JSONObject();
- for(Object key : ((Map)value).keySet()) {
- map.put(key, ((Map)value).get(key));
- }
- jsonForm.put(inputName, map);
- } else if(type == Integer.class) {
- jsonForm.put(inputName, value);
- } else if(type.isEnum()) {
- jsonForm.put(inputName, value.toString());
- } else if(type == Boolean.class) {
- jsonForm.put(inputName, value);
- }else {
- throw new SqoopException(ModelError.MODEL_004,
- "Unsupported type " + type.getName() + " for input " + formName + "." + inputName);
- }
- }
- }
-
- jsonOutput.put(formName, jsonForm);
- }
-
- return jsonOutput.toJSONString();
- }
-
- /**
- * Parse given input JSON string and move it's values to given configuration
- * object.
- *
- * @param json JSON representation of the configuration object
- * @param configuration Configuration object to be filled
- */
- public static void fillValues(String json, Object configuration) {
- Class klass = configuration.getClass();
-
- JSONObject jsonForms = (JSONObject) JSONValue.parse(json);
-
- for(Field formField : klass.getDeclaredFields()) {
- formField.setAccessible(true);
- String formName = formField.getName();
-
- // We're processing only form validations
- Form formAnnotation = formField.getAnnotation(Form.class);
- if(formAnnotation == null) {
- continue;
- }
-
- try {
- formField.set(configuration, formField.getType().newInstance());
- } catch (Exception e) {
- throw new SqoopException(ModelError.MODEL_005,
- "Issue with field " + formName, e);
- }
-
- JSONObject jsonInputs = (JSONObject) jsonForms.get(formField.getName());
- if(jsonInputs == null) {
- continue;
- }
-
- Object formValue;
- try {
- formValue = formField.get(configuration);
- } catch (IllegalAccessException e) {
- throw new SqoopException(ModelError.MODEL_005,
- "Issue with field " + formName, e);
- }
-
- for(Field inputField : formField.getType().getDeclaredFields()) {
- inputField.setAccessible(true);
- String inputName = inputField.getName();
-
- Input inputAnnotation = inputField.getAnnotation(Input.class);
-
- if(inputAnnotation == null || jsonInputs.get(inputName) == null) {
- try {
- inputField.set(formValue, null);
- } catch (IllegalAccessException e) {
- throw new SqoopException(ModelError.MODEL_005,
- "Issue with field " + formName + "." + inputName, e);
- }
- continue;
- }
-
- Class type = inputField.getType();
-
- try {
- if(type == String.class) {
- inputField.set(formValue, jsonInputs.get(inputName));
- } else if (type.isAssignableFrom(Map.class)) {
- Map<String, String> map = new HashMap<String, String>();
- JSONObject jsonObject = (JSONObject) jsonInputs.get(inputName);
- for(Object key : jsonObject.keySet()) {
- map.put((String)key, (String)jsonObject.get(key));
- }
- inputField.set(formValue, map);
- } else if(type == Integer.class) {
- inputField.set(formValue, ((Long)jsonInputs.get(inputName)).intValue());
- } else if(type.isEnum()) {
- inputField.set(formValue, Enum.valueOf((Class<? extends Enum>) inputField.getType(), (String) jsonInputs.get(inputName)));
- } else if(type == Boolean.class) {
- inputField.set(formValue, (Boolean) jsonInputs.get(inputName));
- }else {
- throw new SqoopException(ModelError.MODEL_004,
- "Unsupported type " + type.getName() + " for input " + formName + "." + inputName);
- }
- } catch (IllegalAccessException e) {
- throw new SqoopException(ModelError.MODEL_005,
- "Issue with field " + formName + "." + inputName, e);
- }
- }
- }
- }
-
- public static String getName(Field input, Input annotation) {
- return input.getName();
- }
-
- public static String getName(Field form, Form annotation) {
- return form.getName();
- }
-
- public static ConfigurationClass getConfigurationClassAnnotation(Object object, boolean strict) {
- ConfigurationClass annotation = object.getClass().getAnnotation(ConfigurationClass.class);
-
- if(strict && annotation == null) {
- throw new SqoopException(ModelError.MODEL_003, "Missing annotation ConfigurationClass on class " + object.getClass().getName());
- }
-
- return annotation;
- }
-
- public static FormClass getFormClassAnnotation(Object object, boolean strict) {
- FormClass annotation = object.getClass().getAnnotation(FormClass.class);
-
- if(strict && annotation == null) {
- throw new SqoopException(ModelError.MODEL_003, "Missing annotation ConfigurationClass on class " + object.getClass().getName());
- }
-
- return annotation;
- }
-
- public static Form getFormAnnotation(Field field, boolean strict) {
- Form annotation = field.getAnnotation(Form.class);
-
- if(strict && annotation == null) {
- throw new SqoopException(ModelError.MODEL_003, "Missing annotation Form on Field " + field.getName() + " on class " + field.getDeclaringClass().getName());
- }
-
- return annotation;
- }
-
- public static Input getInputAnnotation(Field field, boolean strict) {
- Input annotation = field.getAnnotation(Input.class);
-
- if(strict && annotation == null) {
- throw new SqoopException(ModelError.MODEL_003, "Missing annotation Input on Field " + field.getName() + " on class " + field.getDeclaringClass().getName());
- }
-
- return annotation;
- }
-
- public static Object getFieldValue(Field field, Object object) {
- try {
- field.setAccessible(true);
- return field.get(object);
- } catch (IllegalAccessException e) {
- throw new SqoopException(ModelError.MODEL_012, e);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/model/MConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MConfig.java b/common/src/main/java/org/apache/sqoop/model/MConfig.java
new file mode 100644
index 0000000..b5d2afd
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/model/MConfig.java
@@ -0,0 +1,117 @@
+/**
+ * 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.model;
+
+import org.apache.sqoop.common.SqoopException;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents a group of inputs that are processed together. This allows the
+ * input gathering process to be broken down into multiple steps that can be
+ * then paged through by the user interface.
+ */
+public final class MConfig extends MValidatedElement implements MClonable {
+
+ private final List<MInput<?>> inputs;
+
+ public MConfig(String name, List<MInput<?>> inputs) {
+ super(name);
+
+ this.inputs = inputs;
+ }
+
+ public List<MInput<?>> getInputs() {
+ return inputs;
+ }
+
+ public MInput<?> getInput(String inputName) {
+ for(MInput<?> input: inputs) {
+ if(inputName.equals(input.getName())) {
+ return input;
+ }
+ }
+
+ throw new SqoopException(ModelError.MODEL_011, "Input name: " + inputName);
+ }
+
+ public MStringInput getStringInput(String inputName) {
+ return (MStringInput)getInput(inputName);
+ }
+
+ public MEnumInput getEnumInput(String inputName) {
+ return (MEnumInput)getInput(inputName);
+ }
+
+ public MIntegerInput getIntegerInput(String inputName) {
+ return (MIntegerInput)getInput(inputName);
+ }
+
+ public MBooleanInput getBooleanInput(String inputName) {
+ return (MBooleanInput)getInput(inputName);
+ }
+
+ public MMapInput getMapInput(String inputName) {
+ return (MMapInput)getInput(inputName);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("config-").append(getName());
+ sb.append(":").append(getPersistenceId()).append(":").append(inputs);
+
+ return sb.toString();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ }
+
+ if (!(other instanceof MConfig)) {
+ return false;
+ }
+
+ MConfig mf = (MConfig) other;
+ return getName().equals(mf.getName())
+ && inputs.equals(mf.inputs);
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 17;
+ result = 31 * result + getName().hashCode();
+ for (MInput<?> mi : inputs) {
+ result = 31 * result + mi.hashCode();
+ }
+
+ return result;
+ }
+
+ @Override
+ public MConfig clone(boolean cloneWithValue) {
+ List<MInput<?>> copyInputs = new ArrayList<MInput<?>>();
+ for(MInput<?> itr : this.getInputs()) {
+ copyInputs.add((MInput<?>)itr.clone(cloneWithValue));
+ }
+ MConfig copyConfig = new MConfig(this.getName(), copyInputs);
+ return copyConfig;
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/model/MConfigList.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MConfigList.java b/common/src/main/java/org/apache/sqoop/model/MConfigList.java
new file mode 100644
index 0000000..8747b55
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/model/MConfigList.java
@@ -0,0 +1,124 @@
+/**
+ * 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.model;
+
+import org.apache.sqoop.common.SqoopException;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Arbitrary list of config objects.
+ */
+public class MConfigList implements MClonable {
+
+ private final List<MConfig> configObjects;
+
+ public MConfigList(List<MConfig> configObjects) {
+ this.configObjects = configObjects;
+ }
+
+ public List<MConfig> getConfigs() {
+ return configObjects;
+ }
+
+ public MConfig getConfig(String configName) {
+ for(MConfig config: configObjects) {
+ if(configName.equals(config.getName())) {
+ return config;
+ }
+ }
+
+ throw new SqoopException(ModelError.MODEL_010, "config name: " + configName);
+ }
+
+ public MInput getInput(String name) {
+ String []parts = name.split("\\.");
+ if(parts.length != 2) {
+ throw new SqoopException(ModelError.MODEL_009, name);
+ }
+
+ return getConfig(parts[0]).getInput(name);
+ }
+
+ public MStringInput getStringInput(String name) {
+ return (MStringInput)getInput(name);
+ }
+
+ public MEnumInput getEnumInput(String name) {
+ return (MEnumInput)getInput(name);
+ }
+
+ public MIntegerInput getIntegerInput(String name) {
+ return (MIntegerInput)getInput(name);
+ }
+
+ public MMapInput getMapInput(String name) {
+ return (MMapInput)getInput(name);
+ }
+
+ public MBooleanInput getBooleanInput(String name) {
+ return (MBooleanInput)getInput(name);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof MConfigList)) return false;
+
+ MConfigList mConfigList = (MConfigList) o;
+
+ if (!configObjects.equals(mConfigList.configObjects)) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = super.hashCode();
+ for(MConfig config : configObjects) {
+ result = 31 * result + config.hashCode();
+ }
+
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("Configs: ");
+ for(MConfig config : configObjects) {
+ sb.append(config.toString());
+ }
+ return sb.toString();
+ }
+
+ @Override
+ public MConfigList clone(boolean cloneWithValue) {
+ List<MConfig> copyConfigs = null;
+ if(this.getConfigs() != null) {
+ copyConfigs = new ArrayList<MConfig>();
+ for(MConfig itr : this.getConfigs()) {
+ MConfig newConfig = itr.clone(cloneWithValue);
+ newConfig.setPersistenceId(itr.getPersistenceId());
+ copyConfigs.add(newConfig);
+ }
+ }
+ MConfigList copyConfigList = new MConfigList(copyConfigs);
+ return copyConfigList;
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/model/MConfigType.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MConfigType.java b/common/src/main/java/org/apache/sqoop/model/MConfigType.java
new file mode 100644
index 0000000..de05332
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/model/MConfigType.java
@@ -0,0 +1,34 @@
+/**
+ * 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.model;
+
+/**
+ * Represents the various config types supported by the system.
+ */
+public enum MConfigType {
+
+ /** Unknown config type */
+ OTHER,
+
+ /** link config type */
+ LINK,
+
+ /** Job config type */
+ JOB;
+
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/model/MConnectionForms.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MConnectionForms.java b/common/src/main/java/org/apache/sqoop/model/MConnectionForms.java
deleted file mode 100644
index 457ccdb..0000000
--- a/common/src/main/java/org/apache/sqoop/model/MConnectionForms.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.model;
-
-import java.util.List;
-
-/**
- * Metadata describing all required information to build up an connection
- * object for one part. Both connector and framework need to supply this object
- * to build up entire connection.
- */
-public class MConnectionForms extends MFormList {
-
- public MConnectionForms(List<MForm> forms) {
- super(forms);
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder("Connection: ");
- sb.append(super.toString());
- return sb.toString();
- }
-
- @Override
- public boolean equals(Object other) {
- if (other == this) {
- return true;
- }
-
- return super.equals(other);
- }
-
- @Override
- public MConnectionForms clone(boolean cloneWithValue) {
- MConnectionForms copy = new MConnectionForms(super.clone(cloneWithValue).getForms());
- return copy;
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/model/MConnector.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MConnector.java b/common/src/main/java/org/apache/sqoop/model/MConnector.java
index 7999b08..2f42191 100644
--- a/common/src/main/java/org/apache/sqoop/model/MConnector.java
+++ b/common/src/main/java/org/apache/sqoop/model/MConnector.java
@@ -23,28 +23,27 @@ import org.apache.sqoop.common.SqoopException;
import org.apache.sqoop.common.SupportedDirections;
/**
- * Connector metadata.
- *
- * Includes unique id that identifies connector in metadata store, unique human
- * readable name, corresponding name and all forms for all supported job types.
+ * Connector entity supports the FROM/TO {@link Transferable} Includes unique id
+ * that identifies connector in the repository, unique human readable name,
+ * corresponding name and all configs to support the from and to data sources
*/
public final class MConnector extends MPersistableEntity implements MClonable {
private final String uniqueName;
private final String className;
- private final MConnectionForms connectionForms;
- private final MJobForms fromJobForms;
- private final MJobForms toJobForms;
- String version;
-
- public MConnector(String uniqueName, String className,
- String version, MConnectionForms connectionForms,
- MJobForms fromJobForms, MJobForms toJobForms) {
+ private final String version;
+ private final MLinkConfig linkConfig;
+ private final MFromConfig fromConfig;
+ private final MToConfig toConfig;
+
+ public MConnector(String uniqueName, String className, String version, MLinkConfig linkConfig,
+ MFromConfig fromConfig, MToConfig toConfig) {
this.version = version;
- this.connectionForms = connectionForms;
- this.fromJobForms = fromJobForms;
- this.toJobForms = toJobForms;
+ this.linkConfig = linkConfig;
+ this.fromConfig = fromConfig;
+ this.toConfig = toConfig;
+ // Why are we abusing NPE?
if (uniqueName == null || className == null) {
throw new NullPointerException();
}
@@ -63,17 +62,15 @@ public final class MConnector extends MPersistableEntity implements MClonable {
@Override
public String toString() {
- MJobForms fromJobForms = this.getJobForms(Direction.FROM);
- MJobForms toJobForms = this.getJobForms(Direction.TO);
StringBuilder sb = new StringBuilder("connector-");
sb.append(uniqueName).append(":").append(getPersistenceId()).append(":");
sb.append(className);
- sb.append(", ").append(getConnectionForms().toString());
- if (fromJobForms != null) {
- sb.append(", ").append(fromJobForms.toString());
+ sb.append(", ").append(getLinkConfig().toString());
+ if (getConfig(Direction.FROM) != null) {
+ sb.append(", ").append(getConfig(Direction.FROM).toString());
}
- if (toJobForms != null) {
- sb.append(", ").append(toJobForms.toString());
+ if (getConfig(Direction.TO) != null) {
+ sb.append(", ").append(getConfig(Direction.TO).toString());
}
return sb.toString();
}
@@ -94,41 +91,39 @@ public final class MConnector extends MPersistableEntity implements MClonable {
if (supportedDirections.isDirectionSupported(Direction.FROM)
&& mcSupportedDirections.isDirectionSupported(Direction.FROM)
- && !getJobForms(Direction.FROM).equals(mc.getJobForms(Direction.FROM))) {
+ && !getFromConfig().equals(mc.getFromConfig())) {
return false;
}
- if (supportedDirections.isDirectionSupported(Direction.FROM)
- != mcSupportedDirections.isDirectionSupported(Direction.FROM)) {
+ if (supportedDirections.isDirectionSupported(Direction.FROM) != mcSupportedDirections
+ .isDirectionSupported(Direction.FROM)) {
return false;
}
if (supportedDirections.isDirectionSupported(Direction.TO)
&& mcSupportedDirections.isDirectionSupported(Direction.TO)
- && !getJobForms(Direction.TO).equals(mc.getJobForms(Direction.TO))) {
+ && !getToConfig().equals(mc.getToConfig())) {
return false;
}
- if (supportedDirections.isDirectionSupported(Direction.TO)
- != mcSupportedDirections.isDirectionSupported(Direction.TO)) {
+ if (supportedDirections.isDirectionSupported(Direction.TO) != mcSupportedDirections
+ .isDirectionSupported(Direction.TO)) {
return false;
}
- return uniqueName.equals(mc.uniqueName)
- && className.equals(mc.className)
- && version.equals(mc.version)
- && connectionForms.equals(mc.getConnectionForms());
+ return uniqueName.equals(mc.uniqueName) && className.equals(mc.className)
+ && version.equals(mc.version) && linkConfig.equals((mc.getLinkConfig()));
}
@Override
public int hashCode() {
SupportedDirections supportedDirections = getSupportedDirections();
- int result = getConnectionForms().hashCode();
+ int result = getLinkConfig().hashCode();
if (supportedDirections.isDirectionSupported(Direction.FROM)) {
- result = 31 * result + getJobForms(Direction.FROM).hashCode();
+ result = 31 * result + getFromConfig().hashCode();
}
if (supportedDirections.isDirectionSupported(Direction.TO)) {
- result = 31 * result + getJobForms(Direction.TO).hashCode();
+ result = 31 * result + getToConfig().hashCode();
}
result = 31 * result + version.hashCode();
result = 31 * result + uniqueName.hashCode();
@@ -137,58 +132,57 @@ public final class MConnector extends MPersistableEntity implements MClonable {
}
public MConnector clone(boolean cloneWithValue) {
- //Connector never have any values filled
+ // Connector never have any values filled
cloneWithValue = false;
- MJobForms fromJobForms = this.getJobForms(Direction.FROM);
- MJobForms toJobForms = this.getJobForms(Direction.TO);
+ MFromConfig fromConfig = this.getFromConfig();
+ MToConfig toConfig = this.getToConfig();
- if (fromJobForms != null) {
- fromJobForms = fromJobForms.clone(cloneWithValue);
+ if (fromConfig != null) {
+ fromConfig = fromConfig.clone(cloneWithValue);
}
- if (toJobForms != null) {
- toJobForms = toJobForms.clone(cloneWithValue);
+ if (toConfig != null) {
+ toConfig = toConfig.clone(cloneWithValue);
}
- MConnector copy = new MConnector(
- this.getUniqueName(),
- this.getClassName(),
- this.getVersion(),
- this.getConnectionForms().clone(cloneWithValue),
- fromJobForms,
- toJobForms);
+ MConnector copy = new MConnector(this.getUniqueName(), this.getClassName(), this.getVersion(),
+ this.getLinkConfig().clone(cloneWithValue), fromConfig, toConfig);
copy.setPersistenceId(this.getPersistenceId());
return copy;
}
- public MConnectionForms getConnectionForms() {
- return connectionForms;
+ public MLinkConfig getLinkConfig() {
+ return linkConfig;
}
- public MJobForms getJobForms(Direction type) {
- switch(type) {
- case FROM:
- return fromJobForms;
+ public MConfigList getConfig(Direction type) {
+ switch (type) {
+ case FROM:
+ return fromConfig;
- case TO:
- return toJobForms;
+ case TO:
+ return toConfig;
- default:
- throw new SqoopException(DirectionError.DIRECTION_0000, "Direction: " + type);
+ default:
+ throw new SqoopException(DirectionError.DIRECTION_0000, "Direction: " + type);
}
}
- public String getVersion() {
- return version;
+ public MFromConfig getFromConfig() {
+ return fromConfig;
}
- public void setVersion(String version) {
- this.version = version;
+ public MToConfig getToConfig() {
+ return toConfig;
+ }
+
+ public String getVersion() {
+ return version;
}
public SupportedDirections getSupportedDirections() {
- return new SupportedDirections(this.getJobForms(Direction.FROM) != null,
- this.getJobForms(Direction.TO) != null);
+ return new SupportedDirections(this.getConfig(Direction.FROM) != null,
+ this.getConfig(Direction.TO) != null);
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/model/MDriver.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MDriver.java b/common/src/main/java/org/apache/sqoop/model/MDriver.java
new file mode 100644
index 0000000..685439e
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/model/MDriver.java
@@ -0,0 +1,82 @@
+/**
+ * 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.model;
+
+import java.sql.Driver;
+
+/**
+ * Describes the configs associated with the {@link Driver} for executing sqoop jobs.
+ */
+public class MDriver extends MPersistableEntity implements MClonable {
+
+ private final MDriverConfig driverConfig;
+ private final String version;
+
+ public MDriver(MDriverConfig driverConfig, String version) {
+ this.driverConfig = driverConfig;
+ this.version = version;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("driver-");
+ sb.append(getPersistenceId()).append(":");
+ sb.append("version = " + version);
+ sb.append(", ").append(driverConfig.toString());
+
+ return sb.toString();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ }
+
+ if (!(other instanceof MDriver)) {
+ return false;
+ }
+
+ MDriver driver = (MDriver) other;
+ return version.equals(driver.getVersion()) &&
+ driverConfig.equals(driver.driverConfig);
+ }
+
+ @Override
+ public int hashCode() {
+ int result = driverConfig.hashCode();
+ result = 31 * result + version.hashCode();
+ return result;
+ }
+
+ public MDriverConfig getDriverConfig() {
+ return driverConfig;
+ }
+
+ @Override
+ public MDriver clone(boolean cloneWithValue) {
+ cloneWithValue = false;
+ MDriver copy = new MDriver(this.driverConfig.clone(cloneWithValue), this.version);
+ copy.setPersistenceId(this.getPersistenceId());
+ return copy;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+}
\ No newline at end of file
[08/13] SQOOP-1498: Sqoop2: Repository Object refactoring (objects
prefixed with M)
Posted by ab...@apache.org.
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestFromInitializer.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestFromInitializer.java b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestFromInitializer.java
index 54e6acf..345fe9b 100644
--- a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestFromInitializer.java
+++ b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestFromInitializer.java
@@ -116,19 +116,19 @@ public class TestFromInitializer {
@Test
@SuppressWarnings("unchecked")
public void testTableName() throws Exception {
- LinkConfiguration connConf = new LinkConfiguration();
- FromJobConfiguration jobConf = new FromJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ FromJobConfiguration jobConfig = new FromJobConfiguration();
- connConf.link.jdbcDriver = GenericJdbcTestConstants.DRIVER;
- connConf.link.connectionString = GenericJdbcTestConstants.URL;
- jobConf.fromJobConfig.tableName = schemalessTableName;
+ linkConfig.linkConfig.jdbcDriver = GenericJdbcTestConstants.DRIVER;
+ linkConfig.linkConfig.connectionString = GenericJdbcTestConstants.URL;
+ jobConfig.fromJobConfig.tableName = schemalessTableName;
MutableContext context = new MutableMapContext();
InitializerContext initializerContext = new InitializerContext(context);
@SuppressWarnings("rawtypes")
Initializer initializer = new GenericJdbcFromInitializer();
- initializer.initialize(initializerContext, connConf, jobConf);
+ initializer.initialize(initializerContext, linkConfig, jobConfig);
verifyResult(context,
"SELECT * FROM " + executor.delimitIdentifier(schemalessTableName)
@@ -143,20 +143,20 @@ public class TestFromInitializer {
@Test
@SuppressWarnings("unchecked")
public void testTableNameWithTableColumns() throws Exception {
- LinkConfiguration connConf = new LinkConfiguration();
- FromJobConfiguration jobConf = new FromJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ FromJobConfiguration jobConfig = new FromJobConfiguration();
- connConf.link.jdbcDriver = GenericJdbcTestConstants.DRIVER;
- connConf.link.connectionString = GenericJdbcTestConstants.URL;
- jobConf.fromJobConfig.tableName = schemalessTableName;
- jobConf.fromJobConfig.columns = tableColumns;
+ linkConfig.linkConfig.jdbcDriver = GenericJdbcTestConstants.DRIVER;
+ linkConfig.linkConfig.connectionString = GenericJdbcTestConstants.URL;
+ jobConfig.fromJobConfig.tableName = schemalessTableName;
+ jobConfig.fromJobConfig.columns = tableColumns;
MutableContext context = new MutableMapContext();
InitializerContext initializerContext = new InitializerContext(context);
@SuppressWarnings("rawtypes")
Initializer initializer = new GenericJdbcFromInitializer();
- initializer.initialize(initializerContext, connConf, jobConf);
+ initializer.initialize(initializerContext, linkConfig, jobConfig);
verifyResult(context,
"SELECT ICOL,VCOL FROM " + executor.delimitIdentifier(schemalessTableName)
@@ -171,20 +171,20 @@ public class TestFromInitializer {
@Test
@SuppressWarnings("unchecked")
public void testTableSql() throws Exception {
- LinkConfiguration connConf = new LinkConfiguration();
- FromJobConfiguration jobConf = new FromJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ FromJobConfiguration jobConfig = new FromJobConfiguration();
- connConf.link.jdbcDriver = GenericJdbcTestConstants.DRIVER;
- connConf.link.connectionString = GenericJdbcTestConstants.URL;
- jobConf.fromJobConfig.sql = schemalessTableSql;
- jobConf.fromJobConfig.partitionColumn = "DCOL";
+ linkConfig.linkConfig.jdbcDriver = GenericJdbcTestConstants.DRIVER;
+ linkConfig.linkConfig.connectionString = GenericJdbcTestConstants.URL;
+ jobConfig.fromJobConfig.sql = schemalessTableSql;
+ jobConfig.fromJobConfig.partitionColumn = "DCOL";
MutableContext context = new MutableMapContext();
InitializerContext initializerContext = new InitializerContext(context);
@SuppressWarnings("rawtypes")
Initializer initializer = new GenericJdbcFromInitializer();
- initializer.initialize(initializerContext, connConf, jobConf);
+ initializer.initialize(initializerContext, linkConfig, jobConfig);
verifyResult(context,
"SELECT * FROM " + executor.delimitIdentifier(schemalessTableName)
@@ -199,21 +199,21 @@ public class TestFromInitializer {
@Test
@SuppressWarnings("unchecked")
public void testTableSqlWithTableColumns() throws Exception {
- LinkConfiguration connConf = new LinkConfiguration();
- FromJobConfiguration jobConf = new FromJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ FromJobConfiguration jobConfig = new FromJobConfiguration();
- connConf.link.jdbcDriver = GenericJdbcTestConstants.DRIVER;
- connConf.link.connectionString = GenericJdbcTestConstants.URL;
- jobConf.fromJobConfig.sql = schemalessTableSql;
- jobConf.fromJobConfig.columns = tableColumns;
- jobConf.fromJobConfig.partitionColumn = "DCOL";
+ linkConfig.linkConfig.jdbcDriver = GenericJdbcTestConstants.DRIVER;
+ linkConfig.linkConfig.connectionString = GenericJdbcTestConstants.URL;
+ jobConfig.fromJobConfig.sql = schemalessTableSql;
+ jobConfig.fromJobConfig.columns = tableColumns;
+ jobConfig.fromJobConfig.partitionColumn = "DCOL";
MutableContext context = new MutableMapContext();
InitializerContext initializerContext = new InitializerContext(context);
@SuppressWarnings("rawtypes")
Initializer initializer = new GenericJdbcFromInitializer();
- initializer.initialize(initializerContext, connConf, jobConf);
+ initializer.initialize(initializerContext, linkConfig, jobConfig);
verifyResult(context,
"SELECT SQOOP_SUBQUERY_ALIAS.ICOL,SQOOP_SUBQUERY_ALIAS.VCOL FROM "
@@ -229,22 +229,22 @@ public class TestFromInitializer {
@Test
@SuppressWarnings("unchecked")
public void testTableNameWithSchema() throws Exception {
- LinkConfiguration connConf = new LinkConfiguration();
- FromJobConfiguration jobConf = new FromJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ FromJobConfiguration jobConfig = new FromJobConfiguration();
String fullTableName = executor.delimitIdentifier(schemaName) + "." + executor.delimitIdentifier(tableName);
- connConf.link.jdbcDriver = GenericJdbcTestConstants.DRIVER;
- connConf.link.connectionString = GenericJdbcTestConstants.URL;
- jobConf.fromJobConfig.schemaName = schemaName;
- jobConf.fromJobConfig.tableName = tableName;
+ linkConfig.linkConfig.jdbcDriver = GenericJdbcTestConstants.DRIVER;
+ linkConfig.linkConfig.connectionString = GenericJdbcTestConstants.URL;
+ jobConfig.fromJobConfig.schemaName = schemaName;
+ jobConfig.fromJobConfig.tableName = tableName;
MutableContext context = new MutableMapContext();
InitializerContext initializerContext = new InitializerContext(context);
@SuppressWarnings("rawtypes")
Initializer initializer = new GenericJdbcFromInitializer();
- initializer.initialize(initializerContext, connConf, jobConf);
+ initializer.initialize(initializerContext, linkConfig, jobConfig);
verifyResult(context,
"SELECT * FROM " + fullTableName
@@ -259,23 +259,23 @@ public class TestFromInitializer {
@Test
@SuppressWarnings("unchecked")
public void testTableNameWithTableColumnsWithSchema() throws Exception {
- LinkConfiguration connConf = new LinkConfiguration();
- FromJobConfiguration jobConf = new FromJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ FromJobConfiguration jobConfig = new FromJobConfiguration();
String fullTableName = executor.delimitIdentifier(schemaName) + "." + executor.delimitIdentifier(tableName);
- connConf.link.jdbcDriver = GenericJdbcTestConstants.DRIVER;
- connConf.link.connectionString = GenericJdbcTestConstants.URL;
- jobConf.fromJobConfig.schemaName = schemaName;
- jobConf.fromJobConfig.tableName = tableName;
- jobConf.fromJobConfig.columns = tableColumns;
+ linkConfig.linkConfig.jdbcDriver = GenericJdbcTestConstants.DRIVER;
+ linkConfig.linkConfig.connectionString = GenericJdbcTestConstants.URL;
+ jobConfig.fromJobConfig.schemaName = schemaName;
+ jobConfig.fromJobConfig.tableName = tableName;
+ jobConfig.fromJobConfig.columns = tableColumns;
MutableContext context = new MutableMapContext();
InitializerContext initializerContext = new InitializerContext(context);
@SuppressWarnings("rawtypes")
Initializer initializer = new GenericJdbcFromInitializer();
- initializer.initialize(initializerContext, connConf, jobConf);
+ initializer.initialize(initializerContext, linkConfig, jobConfig);
verifyResult(context,
"SELECT ICOL,VCOL FROM " + fullTableName
@@ -290,23 +290,23 @@ public class TestFromInitializer {
@Test
@SuppressWarnings("unchecked")
public void testTableSqlWithSchema() throws Exception {
- LinkConfiguration connConf = new LinkConfiguration();
- FromJobConfiguration jobConf = new FromJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ FromJobConfiguration jobConfig = new FromJobConfiguration();
String fullTableName = executor.delimitIdentifier(schemaName) + "." + executor.delimitIdentifier(tableName);
- connConf.link.jdbcDriver = GenericJdbcTestConstants.DRIVER;
- connConf.link.connectionString = GenericJdbcTestConstants.URL;
- jobConf.fromJobConfig.schemaName = schemaName;
- jobConf.fromJobConfig.sql = tableSql;
- jobConf.fromJobConfig.partitionColumn = "DCOL";
+ linkConfig.linkConfig.jdbcDriver = GenericJdbcTestConstants.DRIVER;
+ linkConfig.linkConfig.connectionString = GenericJdbcTestConstants.URL;
+ jobConfig.fromJobConfig.schemaName = schemaName;
+ jobConfig.fromJobConfig.sql = tableSql;
+ jobConfig.fromJobConfig.partitionColumn = "DCOL";
MutableContext context = new MutableMapContext();
InitializerContext initializerContext = new InitializerContext(context);
@SuppressWarnings("rawtypes")
Initializer initializer = new GenericJdbcFromInitializer();
- initializer.initialize(initializerContext, connConf, jobConf);
+ initializer.initialize(initializerContext, linkConfig, jobConfig);
verifyResult(context,
"SELECT * FROM " + fullTableName
@@ -321,68 +321,68 @@ public class TestFromInitializer {
@Test
@SuppressWarnings("unchecked")
public void testGetSchemaForTable() throws Exception {
- LinkConfiguration connConf = new LinkConfiguration();
- FromJobConfiguration jobConf = new FromJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ FromJobConfiguration jobConfig = new FromJobConfiguration();
- connConf.link.jdbcDriver = GenericJdbcTestConstants.DRIVER;
- connConf.link.connectionString = GenericJdbcTestConstants.URL;
- jobConf.fromJobConfig.schemaName = schemaName;
- jobConf.fromJobConfig.tableName = tableName;
- jobConf.fromJobConfig.partitionColumn = "DCOL";
+ linkConfig.linkConfig.jdbcDriver = GenericJdbcTestConstants.DRIVER;
+ linkConfig.linkConfig.connectionString = GenericJdbcTestConstants.URL;
+ jobConfig.fromJobConfig.schemaName = schemaName;
+ jobConfig.fromJobConfig.tableName = tableName;
+ jobConfig.fromJobConfig.partitionColumn = "DCOL";
MutableContext context = new MutableMapContext();
InitializerContext initializerContext = new InitializerContext(context);
@SuppressWarnings("rawtypes")
Initializer initializer = new GenericJdbcFromInitializer();
- initializer.initialize(initializerContext, connConf, jobConf);
- Schema schema = initializer.getSchema(initializerContext, connConf, jobConf);
- assertEquals(getSchema(jobConf.fromJobConfig.schemaName + "." + tableName), schema);
+ initializer.initialize(initializerContext, linkConfig, jobConfig);
+ Schema schema = initializer.getSchema(initializerContext, linkConfig, jobConfig);
+ assertEquals(getSchema(jobConfig.fromJobConfig.schemaName + "." + tableName), schema);
}
@Test
@SuppressWarnings("unchecked")
public void testGetSchemaForSql() throws Exception {
- LinkConfiguration connConf = new LinkConfiguration();
- FromJobConfiguration jobConf = new FromJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ FromJobConfiguration jobConfig = new FromJobConfiguration();
- connConf.link.jdbcDriver = GenericJdbcTestConstants.DRIVER;
- connConf.link.connectionString = GenericJdbcTestConstants.URL;
- jobConf.fromJobConfig.schemaName = schemaName;
- jobConf.fromJobConfig.sql = tableSql;
- jobConf.fromJobConfig.partitionColumn = "DCOL";
+ linkConfig.linkConfig.jdbcDriver = GenericJdbcTestConstants.DRIVER;
+ linkConfig.linkConfig.connectionString = GenericJdbcTestConstants.URL;
+ jobConfig.fromJobConfig.schemaName = schemaName;
+ jobConfig.fromJobConfig.sql = tableSql;
+ jobConfig.fromJobConfig.partitionColumn = "DCOL";
MutableContext context = new MutableMapContext();
InitializerContext initializerContext = new InitializerContext(context);
@SuppressWarnings("rawtypes")
Initializer initializer = new GenericJdbcFromInitializer();
- initializer.initialize(initializerContext, connConf, jobConf);
- Schema schema = initializer.getSchema(initializerContext, connConf, jobConf);
+ initializer.initialize(initializerContext, linkConfig, jobConfig);
+ Schema schema = initializer.getSchema(initializerContext, linkConfig, jobConfig);
assertEquals(getSchema("Query"), schema);
}
@Test
@SuppressWarnings("unchecked")
public void testTableSqlWithTableColumnsWithSchema() throws Exception {
- LinkConfiguration connConf = new LinkConfiguration();
- FromJobConfiguration jobConf = new FromJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ FromJobConfiguration jobConfig = new FromJobConfiguration();
String fullTableName = executor.delimitIdentifier(schemaName) + "." + executor.delimitIdentifier(tableName);
- connConf.link.jdbcDriver = GenericJdbcTestConstants.DRIVER;
- connConf.link.connectionString = GenericJdbcTestConstants.URL;
- jobConf.fromJobConfig.schemaName = schemaName;
- jobConf.fromJobConfig.sql = tableSql;
- jobConf.fromJobConfig.columns = tableColumns;
- jobConf.fromJobConfig.partitionColumn = "DCOL";
+ linkConfig.linkConfig.jdbcDriver = GenericJdbcTestConstants.DRIVER;
+ linkConfig.linkConfig.connectionString = GenericJdbcTestConstants.URL;
+ jobConfig.fromJobConfig.schemaName = schemaName;
+ jobConfig.fromJobConfig.sql = tableSql;
+ jobConfig.fromJobConfig.columns = tableColumns;
+ jobConfig.fromJobConfig.partitionColumn = "DCOL";
MutableContext context = new MutableMapContext();
InitializerContext initializerContext = new InitializerContext(context);
@SuppressWarnings("rawtypes")
Initializer initializer = new GenericJdbcFromInitializer();
- initializer.initialize(initializerContext, connConf, jobConf);
+ initializer.initialize(initializerContext, linkConfig, jobConfig);
verifyResult(context,
"SELECT SQOOP_SUBQUERY_ALIAS.ICOL,SQOOP_SUBQUERY_ALIAS.VCOL FROM "
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestLoader.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestLoader.java b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestLoader.java
index 144b92a..538b033 100644
--- a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestLoader.java
+++ b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestLoader.java
@@ -82,10 +82,10 @@ public class TestLoader {
public void testInsert() throws Exception {
MutableContext context = new MutableMapContext();
- LinkConfiguration connectionConfig = new LinkConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
- connectionConfig.link.jdbcDriver = GenericJdbcTestConstants.DRIVER;
- connectionConfig.link.connectionString = GenericJdbcTestConstants.URL;
+ linkConfig.linkConfig.jdbcDriver = GenericJdbcTestConstants.DRIVER;
+ linkConfig.linkConfig.connectionString = GenericJdbcTestConstants.URL;
ToJobConfiguration jobConfig = new ToJobConfiguration();
@@ -95,7 +95,7 @@ public class TestLoader {
Loader loader = new GenericJdbcLoader();
DummyReader reader = new DummyReader();
LoaderContext loaderContext = new LoaderContext(context, reader, null);
- loader.load(loaderContext, connectionConfig, jobConfig);
+ loader.load(loaderContext, linkConfig, jobConfig);
int index = START;
ResultSet rs = executor.executeQuery("SELECT * FROM "
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestPartitioner.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestPartitioner.java b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestPartitioner.java
index ec75e1e..3ae64f0 100644
--- a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestPartitioner.java
+++ b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestPartitioner.java
@@ -58,12 +58,12 @@ public class TestPartitioner {
GenericJdbcConnectorConstants.CONNECTOR_JDBC_PARTITION_MAXVALUE,
String.valueOf(START + NUMBER_OF_ROWS - 1));
- LinkConfiguration connConf = new LinkConfiguration();
- FromJobConfiguration jobConf = new FromJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ FromJobConfiguration jobConfig = new FromJobConfiguration();
Partitioner partitioner = new GenericJdbcPartitioner();
PartitionerContext partitionerContext = new PartitionerContext(context, 5, null);
- List<Partition> partitions = partitioner.getPartitions(partitionerContext, connConf, jobConf);
+ List<Partition> partitions = partitioner.getPartitions(partitionerContext, linkConfig, jobConfig);
verifyResult(partitions, new String[] {
"-5 <= ICOL AND ICOL < -3",
@@ -90,12 +90,12 @@ public class TestPartitioner {
GenericJdbcConnectorConstants.CONNECTOR_JDBC_PARTITION_MAXVALUE,
String.valueOf(START + NUMBER_OF_ROWS - 1));
- LinkConfiguration connConf = new LinkConfiguration();
- FromJobConfiguration jobConf = new FromJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ FromJobConfiguration jobConfig = new FromJobConfiguration();
Partitioner partitioner = new GenericJdbcPartitioner();
PartitionerContext partitionerContext = new PartitionerContext(context, 3, null);
- List<Partition> partitions = partitioner.getPartitions(partitionerContext, connConf, jobConf);
+ List<Partition> partitions = partitioner.getPartitions(partitionerContext, linkConfig, jobConfig);
verifyResult(partitions, new String[] {
"-5 <= ICOL AND ICOL < -1",
@@ -120,12 +120,12 @@ public class TestPartitioner {
GenericJdbcConnectorConstants.CONNECTOR_JDBC_PARTITION_MAXVALUE,
String.valueOf(START + NUMBER_OF_ROWS - 1));
- LinkConfiguration connConf = new LinkConfiguration();
- FromJobConfiguration jobConf = new FromJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ FromJobConfiguration jobConfig = new FromJobConfiguration();
Partitioner partitioner = new GenericJdbcPartitioner();
PartitionerContext partitionerContext = new PartitionerContext(context, 13, null);
- List<Partition> partitions = partitioner.getPartitions(partitionerContext, connConf, jobConf);
+ List<Partition> partitions = partitioner.getPartitions(partitionerContext, linkConfig, jobConfig);
verifyResult(partitions, new String[] {
"-5 <= ICOL AND ICOL < -4",
@@ -157,12 +157,12 @@ public class TestPartitioner {
GenericJdbcConnectorConstants.CONNECTOR_JDBC_PARTITION_MAXVALUE,
String.valueOf((double)(START + NUMBER_OF_ROWS - 1)));
- LinkConfiguration connConf = new LinkConfiguration();
- FromJobConfiguration jobConf = new FromJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ FromJobConfiguration jobConfig = new FromJobConfiguration();
Partitioner partitioner = new GenericJdbcPartitioner();
PartitionerContext partitionerContext = new PartitionerContext(context, 5, null);
- List<Partition> partitions = partitioner.getPartitions(partitionerContext, connConf, jobConf);
+ List<Partition> partitions = partitioner.getPartitions(partitionerContext, linkConfig, jobConfig);
verifyResult(partitions, new String[] {
"-5.0 <= DCOL AND DCOL < -3.0",
@@ -189,12 +189,12 @@ public class TestPartitioner {
GenericJdbcConnectorConstants.CONNECTOR_JDBC_PARTITION_MAXVALUE,
String.valueOf((double)(START + NUMBER_OF_ROWS - 1)));
- LinkConfiguration connConf = new LinkConfiguration();
- FromJobConfiguration jobConf = new FromJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ FromJobConfiguration jobConfig = new FromJobConfiguration();
Partitioner partitioner = new GenericJdbcPartitioner();
PartitionerContext partitionerContext = new PartitionerContext(context, 3, null);
- List<Partition> partitions = partitioner.getPartitions(partitionerContext, connConf, jobConf);
+ List<Partition> partitions = partitioner.getPartitions(partitionerContext, linkConfig, jobConfig);
verifyResult(partitions, new String[] {
"-5.0 <= DCOL AND DCOL < -1.6666666666666665",
@@ -211,12 +211,12 @@ public class TestPartitioner {
context.setString(GenericJdbcConnectorConstants.CONNECTOR_JDBC_PARTITION_MINVALUE, String.valueOf(START));
context.setString(GenericJdbcConnectorConstants.CONNECTOR_JDBC_PARTITION_MAXVALUE, String.valueOf(START + NUMBER_OF_ROWS - 1));
- LinkConfiguration connConf = new LinkConfiguration();
- FromJobConfiguration jobConf = new FromJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ FromJobConfiguration jobConfig = new FromJobConfiguration();
Partitioner partitioner = new GenericJdbcPartitioner();
PartitionerContext partitionerContext = new PartitionerContext(context, 5, null);
- List<Partition> partitions = partitioner.getPartitions(partitionerContext, connConf, jobConf);
+ List<Partition> partitions = partitioner.getPartitions(partitionerContext, linkConfig, jobConfig);
verifyResult(partitions, new String[] {
"-5 <= ICOL AND ICOL < -3",
@@ -235,12 +235,12 @@ public class TestPartitioner {
context.setString(GenericJdbcConnectorConstants.CONNECTOR_JDBC_PARTITION_MINVALUE, String.valueOf(new BigDecimal(START)));
context.setString(GenericJdbcConnectorConstants.CONNECTOR_JDBC_PARTITION_MAXVALUE, String.valueOf(new BigDecimal(START + NUMBER_OF_ROWS - 1)));
- LinkConfiguration connConf = new LinkConfiguration();
- FromJobConfiguration jobConf = new FromJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ FromJobConfiguration jobConfig = new FromJobConfiguration();
Partitioner partitioner = new GenericJdbcPartitioner();
PartitionerContext partitionerContext = new PartitionerContext(context, 3, null);
- List<Partition> partitions = partitioner.getPartitions(partitionerContext, connConf, jobConf);
+ List<Partition> partitions = partitioner.getPartitions(partitionerContext, linkConfig, jobConfig);
verifyResult(partitions, new String[]{
"-5 <= DCOL AND DCOL < -2",
@@ -257,12 +257,12 @@ public class TestPartitioner {
context.setString(GenericJdbcConnectorConstants.CONNECTOR_JDBC_PARTITION_MINVALUE, String.valueOf(new BigDecimal(START)));
context.setString(GenericJdbcConnectorConstants.CONNECTOR_JDBC_PARTITION_MAXVALUE, String.valueOf(new BigDecimal(START)));
- LinkConfiguration connConf = new LinkConfiguration();
- FromJobConfiguration jobConf = new FromJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ FromJobConfiguration jobConfig = new FromJobConfiguration();
Partitioner partitioner = new GenericJdbcPartitioner();
PartitionerContext partitionerContext = new PartitionerContext(context, 3, null);
- List<Partition> partitions = partitioner.getPartitions(partitionerContext, connConf, jobConf);
+ List<Partition> partitions = partitioner.getPartitions(partitionerContext, linkConfig, jobConfig);
verifyResult(partitions, new String[]{
"DCOL = -5",
@@ -282,12 +282,12 @@ public class TestPartitioner {
.toString());
- LinkConfiguration connConf = new LinkConfiguration();
- FromJobConfiguration jobConf = new FromJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ FromJobConfiguration jobConfig = new FromJobConfiguration();
Partitioner partitioner = new GenericJdbcPartitioner();
PartitionerContext partitionerContext = new PartitionerContext(context, 3, null);
- List<Partition> partitions = partitioner.getPartitions(partitionerContext, connConf, jobConf);
+ List<Partition> partitions = partitioner.getPartitions(partitionerContext, linkConfig, jobConfig);
verifyResult(partitions, new String[]{
@@ -311,12 +311,12 @@ public class TestPartitioner {
Time.valueOf("10:40:50").toString());
- LinkConfiguration connConf = new LinkConfiguration();
- FromJobConfiguration jobConf = new FromJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ FromJobConfiguration jobConfig = new FromJobConfiguration();
Partitioner partitioner = new GenericJdbcPartitioner();
PartitionerContext partitionerContext = new PartitionerContext(context, 3, null);
- List<Partition> partitions = partitioner.getPartitions(partitionerContext, connConf, jobConf);
+ List<Partition> partitions = partitioner.getPartitions(partitionerContext, linkConfig, jobConfig);
verifyResult(partitions, new String[]{
"'01:01:01' <= TCOL AND TCOL < '04:14:17'",
@@ -337,12 +337,12 @@ public class TestPartitioner {
context.setString(GenericJdbcConnectorConstants.CONNECTOR_JDBC_PARTITION_MAXVALUE,
Timestamp.valueOf("2013-12-31 10:40:50.654").toString());
- LinkConfiguration connConf = new LinkConfiguration();
- FromJobConfiguration jobConf = new FromJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ FromJobConfiguration jobConfig = new FromJobConfiguration();
Partitioner partitioner = new GenericJdbcPartitioner();
PartitionerContext partitionerContext = new PartitionerContext(context, 3, null);
- List<Partition> partitions = partitioner.getPartitions(partitionerContext, connConf, jobConf);
+ List<Partition> partitions = partitioner.getPartitions(partitionerContext, linkConfig, jobConfig);
verifyResult(partitions, new String[]{
"'2013-01-01 01:01:01.123' <= TSCOL AND TSCOL < '2013-05-02 12:14:17.634'",
"'2013-05-02 12:14:17.634' <= TSCOL AND TSCOL < '2013-08-31 23:27:34.144'",
@@ -362,12 +362,12 @@ public class TestPartitioner {
context.setString(GenericJdbcConnectorConstants
.CONNECTOR_JDBC_PARTITION_MAXVALUE, "1");
- LinkConfiguration connConf = new LinkConfiguration();
- FromJobConfiguration jobConf = new FromJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ FromJobConfiguration jobConfig = new FromJobConfiguration();
Partitioner partitioner = new GenericJdbcPartitioner();
PartitionerContext partitionerContext = new PartitionerContext(context, 3, null);
- List<Partition> partitions = partitioner.getPartitions(partitionerContext, connConf, jobConf);
+ List<Partition> partitions = partitioner.getPartitions(partitionerContext, linkConfig, jobConfig);
verifyResult(partitions, new String[]{
"BCOL = TRUE",
"BCOL = FALSE",
@@ -386,12 +386,12 @@ public class TestPartitioner {
context.setString(GenericJdbcConnectorConstants
.CONNECTOR_JDBC_PARTITION_MAXVALUE, "Z");
- LinkConfiguration connConf = new LinkConfiguration();
- FromJobConfiguration jobConf = new FromJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ FromJobConfiguration jobConfig = new FromJobConfiguration();
Partitioner partitioner = new GenericJdbcPartitioner();
PartitionerContext partitionerContext = new PartitionerContext(context, 25, null);
- List<Partition> partitions = partitioner.getPartitions(partitionerContext, connConf, jobConf);
+ List<Partition> partitions = partitioner.getPartitions(partitionerContext, linkConfig, jobConfig);
verifyResult(partitions, new String[] {
"'A' <= VCCOL AND VCCOL < 'B'",
@@ -434,11 +434,11 @@ public class TestPartitioner {
context.setString(GenericJdbcConnectorConstants
.CONNECTOR_JDBC_PARTITION_MAXVALUE, "Warty Warthog");
- LinkConfiguration connConf = new LinkConfiguration();
- FromJobConfiguration jobConf = new FromJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ FromJobConfiguration jobConfig = new FromJobConfiguration();
Partitioner partitioner = new GenericJdbcPartitioner();
PartitionerContext partitionerContext = new PartitionerContext(context, 5, null);
- List<Partition> partitions = partitioner.getPartitions(partitionerContext, connConf, jobConf);
+ List<Partition> partitions = partitioner.getPartitions(partitionerContext, linkConfig, jobConfig);
assertEquals(partitions.size(), 5);
// First partition needs to contain entire upper bound
assertTrue(partitions.get(0).toString().contains("Breezy Badger"));
@@ -458,13 +458,13 @@ public class TestPartitioner {
context.setString(GenericJdbcConnectorConstants
.CONNECTOR_JDBC_PARTITION_MAXVALUE, "AAF");
- LinkConfiguration connConf = new LinkConfiguration();
- FromJobConfiguration jobConf = new FromJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ FromJobConfiguration jobConfig = new FromJobConfiguration();
Partitioner partitioner = new GenericJdbcPartitioner();
PartitionerContext partitionerContext = new PartitionerContext(context, 5, null);
- List<Partition> partitions = partitioner.getPartitions(partitionerContext, connConf, jobConf);
+ List<Partition> partitions = partitioner.getPartitions(partitionerContext, linkConfig, jobConfig);
verifyResult(partitions, new String[] {
"'AAA' <= VCCOL AND VCCOL < 'AAB'",
@@ -488,14 +488,14 @@ public class TestPartitioner {
context.setString(GenericJdbcConnectorConstants
.CONNECTOR_JDBC_PARTITION_MAXVALUE, "AAE");
- LinkConfiguration connConf = new LinkConfiguration();
- FromJobConfiguration jobConf = new FromJobConfiguration();
- jobConf.fromJobConfig.partitionColumnNull = true;
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ FromJobConfiguration jobConfig = new FromJobConfiguration();
+ jobConfig.fromJobConfig.partitionColumnNull = true;
Partitioner partitioner = new GenericJdbcPartitioner();
PartitionerContext partitionerContext = new PartitionerContext(context, 5, null);
- List<Partition> partitions = partitioner.getPartitions(partitionerContext, connConf, jobConf);
+ List<Partition> partitions = partitioner.getPartitions(partitionerContext, linkConfig, jobConfig);
verifyResult(partitions, new String[] {
"VCCOL IS NULL",
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestToInitializer.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestToInitializer.java b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestToInitializer.java
index a87ce7a..243de01 100644
--- a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestToInitializer.java
+++ b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestToInitializer.java
@@ -17,6 +17,10 @@
*/
package org.apache.sqoop.connector.jdbc;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import org.apache.sqoop.common.MutableContext;
import org.apache.sqoop.common.MutableMapContext;
import org.apache.sqoop.common.SqoopException;
@@ -24,17 +28,13 @@ import org.apache.sqoop.connector.jdbc.configuration.LinkConfiguration;
import org.apache.sqoop.connector.jdbc.configuration.ToJobConfiguration;
import org.apache.sqoop.job.etl.Initializer;
import org.apache.sqoop.job.etl.InitializerContext;
+import org.apache.sqoop.validation.ConfigValidationResult;
+import org.apache.sqoop.validation.ConfigValidationRunner;
import org.apache.sqoop.validation.Status;
-import org.apache.sqoop.validation.ValidationResult;
-import org.apache.sqoop.validation.ValidationRunner;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
public class TestToInitializer {
private final String schemaName;
private final String tableName;
@@ -82,21 +82,21 @@ public class TestToInitializer {
@Test
@SuppressWarnings("unchecked")
public void testTableName() throws Exception {
- LinkConfiguration connConf = new LinkConfiguration();
- ToJobConfiguration jobConf = new ToJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ ToJobConfiguration jobConfig = new ToJobConfiguration();
String fullTableName = executor.delimitIdentifier(schemalessTableName);
- connConf.link.jdbcDriver = GenericJdbcTestConstants.DRIVER;
- connConf.link.connectionString = GenericJdbcTestConstants.URL;
- jobConf.toJobConfig.tableName = schemalessTableName;
+ linkConfig.linkConfig.jdbcDriver = GenericJdbcTestConstants.DRIVER;
+ linkConfig.linkConfig.connectionString = GenericJdbcTestConstants.URL;
+ jobConfig.toJobConfig.tableName = schemalessTableName;
MutableContext context = new MutableMapContext();
InitializerContext initializerContext = new InitializerContext(context);
@SuppressWarnings("rawtypes")
Initializer initializer = new GenericJdbcToInitializer();
- initializer.initialize(initializerContext, connConf, jobConf);
+ initializer.initialize(initializerContext, linkConfig, jobConfig);
verifyResult(context, "INSERT INTO " + fullTableName + " VALUES (?,?,?)");
}
@@ -104,22 +104,22 @@ public class TestToInitializer {
@Test
@SuppressWarnings("unchecked")
public void testTableNameWithTableColumns() throws Exception {
- LinkConfiguration connConf = new LinkConfiguration();
- ToJobConfiguration jobConf = new ToJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ ToJobConfiguration jobConfig = new ToJobConfiguration();
String fullTableName = executor.delimitIdentifier(schemalessTableName);
- connConf.link.jdbcDriver = GenericJdbcTestConstants.DRIVER;
- connConf.link.connectionString = GenericJdbcTestConstants.URL;
- jobConf.toJobConfig.tableName = schemalessTableName;
- jobConf.toJobConfig.columns = tableColumns;
+ linkConfig.linkConfig.jdbcDriver = GenericJdbcTestConstants.DRIVER;
+ linkConfig.linkConfig.connectionString = GenericJdbcTestConstants.URL;
+ jobConfig.toJobConfig.tableName = schemalessTableName;
+ jobConfig.toJobConfig.columns = tableColumns;
MutableContext context = new MutableMapContext();
InitializerContext initializerContext = new InitializerContext(context);
@SuppressWarnings("rawtypes")
Initializer initializer = new GenericJdbcToInitializer();
- initializer.initialize(initializerContext, connConf, jobConf);
+ initializer.initialize(initializerContext, linkConfig, jobConfig);
verifyResult(context, "INSERT INTO " + fullTableName + " (" + tableColumns + ") VALUES (?,?)");
}
@@ -127,19 +127,19 @@ public class TestToInitializer {
@Test
@SuppressWarnings("unchecked")
public void testTableSql() throws Exception {
- LinkConfiguration connConf = new LinkConfiguration();
- ToJobConfiguration jobConf = new ToJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ ToJobConfiguration jobConfig = new ToJobConfiguration();
- connConf.link.jdbcDriver = GenericJdbcTestConstants.DRIVER;
- connConf.link.connectionString = GenericJdbcTestConstants.URL;
- jobConf.toJobConfig.sql = schemalessTableSql;
+ linkConfig.linkConfig.jdbcDriver = GenericJdbcTestConstants.DRIVER;
+ linkConfig.linkConfig.connectionString = GenericJdbcTestConstants.URL;
+ jobConfig.toJobConfig.sql = schemalessTableSql;
MutableContext context = new MutableMapContext();
InitializerContext initializerContext = new InitializerContext(context);
@SuppressWarnings("rawtypes")
Initializer initializer = new GenericJdbcToInitializer();
- initializer.initialize(initializerContext, connConf, jobConf);
+ initializer.initialize(initializerContext, linkConfig, jobConfig);
verifyResult(context, "INSERT INTO " + executor.delimitIdentifier(schemalessTableName) + " VALUES (?,?,?)");
}
@@ -147,22 +147,22 @@ public class TestToInitializer {
@Test
@SuppressWarnings("unchecked")
public void testTableNameWithSchema() throws Exception {
- LinkConfiguration connConf = new LinkConfiguration();
- ToJobConfiguration jobConf = new ToJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ ToJobConfiguration jobConfig = new ToJobConfiguration();
String fullTableName = executor.delimitIdentifier(schemaName) + "." + executor.delimitIdentifier(tableName);
- connConf.link.jdbcDriver = GenericJdbcTestConstants.DRIVER;
- connConf.link.connectionString = GenericJdbcTestConstants.URL;
- jobConf.toJobConfig.schemaName = schemaName;
- jobConf.toJobConfig.tableName = tableName;
+ linkConfig.linkConfig.jdbcDriver = GenericJdbcTestConstants.DRIVER;
+ linkConfig.linkConfig.connectionString = GenericJdbcTestConstants.URL;
+ jobConfig.toJobConfig.schemaName = schemaName;
+ jobConfig.toJobConfig.tableName = tableName;
MutableContext context = new MutableMapContext();
InitializerContext initializerContext = new InitializerContext(context);
@SuppressWarnings("rawtypes")
Initializer initializer = new GenericJdbcToInitializer();
- initializer.initialize(initializerContext, connConf, jobConf);
+ initializer.initialize(initializerContext, linkConfig, jobConfig);
verifyResult(context, "INSERT INTO " + fullTableName + " VALUES (?,?,?)");
}
@@ -170,23 +170,23 @@ public class TestToInitializer {
@Test
@SuppressWarnings("unchecked")
public void testTableNameWithTableColumnsWithSchema() throws Exception {
- LinkConfiguration connConf = new LinkConfiguration();
- ToJobConfiguration jobConf = new ToJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ ToJobConfiguration jobConfig = new ToJobConfiguration();
String fullTableName = executor.delimitIdentifier(schemaName) + "." + executor.delimitIdentifier(tableName);
- connConf.link.jdbcDriver = GenericJdbcTestConstants.DRIVER;
- connConf.link.connectionString = GenericJdbcTestConstants.URL;
- jobConf.toJobConfig.schemaName = schemaName;
- jobConf.toJobConfig.tableName = tableName;
- jobConf.toJobConfig.columns = tableColumns;
+ linkConfig.linkConfig.jdbcDriver = GenericJdbcTestConstants.DRIVER;
+ linkConfig.linkConfig.connectionString = GenericJdbcTestConstants.URL;
+ jobConfig.toJobConfig.schemaName = schemaName;
+ jobConfig.toJobConfig.tableName = tableName;
+ jobConfig.toJobConfig.columns = tableColumns;
MutableContext context = new MutableMapContext();
InitializerContext initializerContext = new InitializerContext(context);
@SuppressWarnings("rawtypes")
Initializer initializer = new GenericJdbcToInitializer();
- initializer.initialize(initializerContext, connConf, jobConf);
+ initializer.initialize(initializerContext, linkConfig, jobConfig);
verifyResult(context, "INSERT INTO " + fullTableName + " (" + tableColumns + ") VALUES (?,?)");
}
@@ -194,20 +194,20 @@ public class TestToInitializer {
@Test
@SuppressWarnings("unchecked")
public void testTableSqlWithSchema() throws Exception {
- LinkConfiguration connConf = new LinkConfiguration();
- ToJobConfiguration jobConf = new ToJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ ToJobConfiguration jobConfig = new ToJobConfiguration();
- connConf.link.jdbcDriver = GenericJdbcTestConstants.DRIVER;
- connConf.link.connectionString = GenericJdbcTestConstants.URL;
- jobConf.toJobConfig.schemaName = schemaName;
- jobConf.toJobConfig.sql = tableSql;
+ linkConfig.linkConfig.jdbcDriver = GenericJdbcTestConstants.DRIVER;
+ linkConfig.linkConfig.connectionString = GenericJdbcTestConstants.URL;
+ jobConfig.toJobConfig.schemaName = schemaName;
+ jobConfig.toJobConfig.sql = tableSql;
MutableContext context = new MutableMapContext();
InitializerContext initializerContext = new InitializerContext(context);
@SuppressWarnings("rawtypes")
Initializer initializer = new GenericJdbcToInitializer();
- initializer.initialize(initializerContext, connConf, jobConf);
+ initializer.initialize(initializerContext, linkConfig, jobConfig);
verifyResult(context, "INSERT INTO " + executor.delimitIdentifier(tableName) + " VALUES (?,?,?)");
}
@@ -229,13 +229,13 @@ public class TestToInitializer {
@Test
public void testNonExistingStageTable() throws Exception {
- LinkConfiguration connConf = new LinkConfiguration();
- ToJobConfiguration jobConf = new ToJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ ToJobConfiguration jobConfig = new ToJobConfiguration();
- connConf.link.jdbcDriver = GenericJdbcTestConstants.DRIVER;
- connConf.link.connectionString = GenericJdbcTestConstants.URL;
- jobConf.toJobConfig.tableName = schemalessTableName;
- jobConf.toJobConfig.stageTableName = stageTableName;
+ linkConfig.linkConfig.jdbcDriver = GenericJdbcTestConstants.DRIVER;
+ linkConfig.linkConfig.connectionString = GenericJdbcTestConstants.URL;
+ jobConfig.toJobConfig.tableName = schemalessTableName;
+ jobConfig.toJobConfig.stageTableName = stageTableName;
MutableContext context = new MutableMapContext();
InitializerContext initializerContext = new InitializerContext(context);
@@ -243,7 +243,7 @@ public class TestToInitializer {
@SuppressWarnings("rawtypes")
Initializer initializer = new GenericJdbcToInitializer();
try {
- initializer.initialize(initializerContext, connConf, jobConf);
+ initializer.initialize(initializerContext, linkConfig, jobConfig);
fail("Initialization should fail for non-existing stage table.");
} catch(SqoopException se) {
//expected
@@ -253,15 +253,15 @@ public class TestToInitializer {
@Test
@SuppressWarnings("unchecked")
public void testNonEmptyStageTable() throws Exception {
- LinkConfiguration connConf = new LinkConfiguration();
- ToJobConfiguration jobConf = new ToJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ ToJobConfiguration jobConfig = new ToJobConfiguration();
String fullStageTableName = executor.delimitIdentifier(stageTableName);
- connConf.link.jdbcDriver = GenericJdbcTestConstants.DRIVER;
- connConf.link.connectionString = GenericJdbcTestConstants.URL;
- jobConf.toJobConfig.tableName = schemalessTableName;
- jobConf.toJobConfig.stageTableName = stageTableName;
+ linkConfig.linkConfig.jdbcDriver = GenericJdbcTestConstants.DRIVER;
+ linkConfig.linkConfig.connectionString = GenericJdbcTestConstants.URL;
+ jobConfig.toJobConfig.tableName = schemalessTableName;
+ jobConfig.toJobConfig.stageTableName = stageTableName;
createTable(fullStageTableName);
executor.executeUpdate("INSERT INTO " + fullStageTableName +
" VALUES(1, 1.1, 'one')");
@@ -271,7 +271,7 @@ public class TestToInitializer {
@SuppressWarnings("rawtypes")
Initializer initializer = new GenericJdbcToInitializer();
try {
- initializer.initialize(initializerContext, connConf, jobConf);
+ initializer.initialize(initializerContext, linkConfig, jobConfig);
fail("Initialization should fail for non-empty stage table.");
} catch(SqoopException se) {
//expected
@@ -280,17 +280,17 @@ public class TestToInitializer {
@Test
public void testClearStageTableValidation() throws Exception {
- LinkConfiguration connConf = new LinkConfiguration();
- ToJobConfiguration jobConf = new ToJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ ToJobConfiguration jobConfig = new ToJobConfiguration();
- connConf.link.jdbcDriver = GenericJdbcTestConstants.DRIVER;
- connConf.link.connectionString = GenericJdbcTestConstants.URL;
+ linkConfig.linkConfig.jdbcDriver = GenericJdbcTestConstants.DRIVER;
+ linkConfig.linkConfig.connectionString = GenericJdbcTestConstants.URL;
//specifying clear stage table flag without specifying name of
// the stage table
- jobConf.toJobConfig.tableName = schemalessTableName;
- jobConf.toJobConfig.clearStageTable = false;
- ValidationRunner validationRunner = new ValidationRunner();
- ValidationResult result = validationRunner.validate(jobConf);
+ jobConfig.toJobConfig.tableName = schemalessTableName;
+ jobConfig.toJobConfig.clearStageTable = false;
+ ConfigValidationRunner validationRunner = new ConfigValidationRunner();
+ ConfigValidationResult result = validationRunner.validate(jobConfig);
assertEquals("User should not specify clear stage table flag without " +
"specifying name of the stage table",
Status.UNACCEPTABLE,
@@ -298,8 +298,8 @@ public class TestToInitializer {
assertTrue(result.getMessages().containsKey(
"toJobConfig"));
- jobConf.toJobConfig.clearStageTable = true;
- result = validationRunner.validate(jobConf);
+ jobConfig.toJobConfig.clearStageTable = true;
+ result = validationRunner.validate(jobConfig);
assertEquals("User should not specify clear stage table flag without " +
"specifying name of the stage table",
Status.UNACCEPTABLE,
@@ -310,17 +310,17 @@ public class TestToInitializer {
@Test
public void testStageTableWithoutTable() throws Exception {
- LinkConfiguration connConf = new LinkConfiguration();
- ToJobConfiguration jobConf = new ToJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ ToJobConfiguration jobConfig = new ToJobConfiguration();
- connConf.link.jdbcDriver = GenericJdbcTestConstants.DRIVER;
- connConf.link.connectionString = GenericJdbcTestConstants.URL;
+ linkConfig.linkConfig.jdbcDriver = GenericJdbcTestConstants.DRIVER;
+ linkConfig.linkConfig.connectionString = GenericJdbcTestConstants.URL;
//specifying stage table without specifying table name
- jobConf.toJobConfig.stageTableName = stageTableName;
- jobConf.toJobConfig.sql = "";
+ jobConfig.toJobConfig.stageTableName = stageTableName;
+ jobConfig.toJobConfig.sql = "";
- ValidationRunner validationRunner = new ValidationRunner();
- ValidationResult result = validationRunner.validate(jobConf);
+ ConfigValidationRunner validationRunner = new ConfigValidationRunner();
+ ConfigValidationResult result = validationRunner.validate(jobConfig);
assertEquals("Stage table name cannot be specified without specifying " +
"table name", Status.UNACCEPTABLE, result.getStatus());
assertTrue(result.getMessages().containsKey(
@@ -330,16 +330,16 @@ public class TestToInitializer {
@Test
@SuppressWarnings("unchecked")
public void testClearStageTable() throws Exception {
- LinkConfiguration connConf = new LinkConfiguration();
- ToJobConfiguration jobConf = new ToJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ ToJobConfiguration jobConfig = new ToJobConfiguration();
String fullStageTableName = executor.delimitIdentifier(stageTableName);
- connConf.link.jdbcDriver = GenericJdbcTestConstants.DRIVER;
- connConf.link.connectionString = GenericJdbcTestConstants.URL;
- jobConf.toJobConfig.tableName = schemalessTableName;
- jobConf.toJobConfig.stageTableName = stageTableName;
- jobConf.toJobConfig.clearStageTable = true;
+ linkConfig.linkConfig.jdbcDriver = GenericJdbcTestConstants.DRIVER;
+ linkConfig.linkConfig.connectionString = GenericJdbcTestConstants.URL;
+ jobConfig.toJobConfig.tableName = schemalessTableName;
+ jobConfig.toJobConfig.stageTableName = stageTableName;
+ jobConfig.toJobConfig.clearStageTable = true;
createTable(fullStageTableName);
executor.executeUpdate("INSERT INTO " + fullStageTableName +
" VALUES(1, 1.1, 'one')");
@@ -348,7 +348,7 @@ public class TestToInitializer {
@SuppressWarnings("rawtypes")
Initializer initializer = new GenericJdbcToInitializer();
- initializer.initialize(initializerContext, connConf, jobConf);
+ initializer.initialize(initializerContext, linkConfig, jobConfig);
assertEquals("Stage table should have been cleared", 0,
executor.getTableRowCount(stageTableName));
}
@@ -356,22 +356,22 @@ public class TestToInitializer {
@Test
@SuppressWarnings("unchecked")
public void testStageTable() throws Exception {
- LinkConfiguration connConf = new LinkConfiguration();
- ToJobConfiguration jobConf = new ToJobConfiguration();
+ LinkConfiguration linkConfig = new LinkConfiguration();
+ ToJobConfiguration jobConfig = new ToJobConfiguration();
String fullStageTableName = executor.delimitIdentifier(stageTableName);
- connConf.link.jdbcDriver = GenericJdbcTestConstants.DRIVER;
- connConf.link.connectionString = GenericJdbcTestConstants.URL;
- jobConf.toJobConfig.tableName = schemalessTableName;
- jobConf.toJobConfig.stageTableName = stageTableName;
+ linkConfig.linkConfig.jdbcDriver = GenericJdbcTestConstants.DRIVER;
+ linkConfig.linkConfig.connectionString = GenericJdbcTestConstants.URL;
+ jobConfig.toJobConfig.tableName = schemalessTableName;
+ jobConfig.toJobConfig.stageTableName = stageTableName;
createTable(fullStageTableName);
MutableContext context = new MutableMapContext();
InitializerContext initializerContext = new InitializerContext(context);
@SuppressWarnings("rawtypes")
Initializer initializer = new GenericJdbcToInitializer();
- initializer.initialize(initializerContext, connConf, jobConf);
+ initializer.initialize(initializerContext, linkConfig, jobConfig);
verifyResult(context, "INSERT INTO " + fullStageTableName +
" VALUES (?,?,?)");
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsConfigUpgrader.java
----------------------------------------------------------------------
diff --git a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsConfigUpgrader.java b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsConfigUpgrader.java
index 47b186c..b17aa21 100644
--- a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsConfigUpgrader.java
+++ b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsConfigUpgrader.java
@@ -18,21 +18,20 @@
*/
package org.apache.sqoop.connector.hdfs;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.apache.log4j.Logger;
import org.apache.sqoop.common.SqoopException;
import org.apache.sqoop.connector.spi.RepositoryUpgrader;
-import org.apache.sqoop.model.MConnectionForms;
-import org.apache.sqoop.model.MForm;
+import org.apache.sqoop.model.MConfigList;
+import org.apache.sqoop.model.MConfig;
import org.apache.sqoop.model.MInput;
-import org.apache.sqoop.model.MJobForms;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import org.apache.sqoop.model.MLinkConfig;
public class HdfsConfigUpgrader extends RepositoryUpgrader {
- private static final Logger LOG =
- Logger.getLogger(HdfsConfigUpgrader.class);
+ private static final Logger LOG = Logger.getLogger(HdfsConfigUpgrader.class);
/*
* For now, there is no real upgrade. So copy all data over,
@@ -41,37 +40,36 @@ public class HdfsConfigUpgrader extends RepositoryUpgrader {
*/
@Override
- public void upgrade(MConnectionForms original,
- MConnectionForms upgradeTarget) {
- doUpgrade(original.getForms(), upgradeTarget.getForms());
+ public void upgrade(MLinkConfig original, MLinkConfig upgradeTarget) {
+ doUpgrade(original.getConfigs(), upgradeTarget.getConfigs());
}
@Override
- public void upgrade(MJobForms original, MJobForms upgradeTarget) {
- doUpgrade(original.getForms(), upgradeTarget.getForms());
+ public void upgrade(MConfigList original, MConfigList upgradeTarget) {
+ doUpgrade(original.getConfigs(), upgradeTarget.getConfigs());
}
@SuppressWarnings("unchecked")
- private void doUpgrade(List<MForm> original, List<MForm> target) {
- // Easier to find the form in the original forms list if we use a map.
- // Since the constructor of MJobForms takes a list,
+ private void doUpgrade(List<MConfig> original, List<MConfig> target) {
+ // Easier to find the config in the original list if we use a map.
+ // Since the constructor takes a list,
// index is not guaranteed to be the same, so we need to look for
// equivalence
- Map<String, MForm> formMap = new HashMap<String, MForm>();
- for (MForm form : original) {
- formMap.put(form.getName(), form);
+ Map<String, MConfig> configMap = new HashMap<String, MConfig>();
+ for (MConfig config : original) {
+ configMap.put(config.getName(), config);
}
- for (MForm form : target) {
- List<MInput<?>> inputs = form.getInputs();
- MForm originalForm = formMap.get(form.getName());
- if (originalForm == null) {
- LOG.warn("Form: '" + form.getName() + "' not present in old " +
+ for (MConfig config : target) {
+ List<MInput<?>> inputs = config.getInputs();
+ MConfig originalConfig = configMap.get(config.getName());
+ if (originalConfig == null) {
+ LOG.warn("Config: '" + config.getName() + "' not present in old " +
"connector. So it and its inputs will not be transferred by the upgrader.");
continue;
}
for (MInput input : inputs) {
try {
- MInput originalInput = originalForm.getInput(input.getName());
+ MInput originalInput = originalConfig.getInput(input.getName());
input.setValue(originalInput.getValue());
} catch (SqoopException ex) {
LOG.warn("Input: '" + input.getName() + "' not present in old " +
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsConnector.java
----------------------------------------------------------------------
diff --git a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsConnector.java b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsConnector.java
index cd5350e..606b9fa 100644
--- a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsConnector.java
+++ b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsConnector.java
@@ -118,7 +118,7 @@ public class HdfsConnector extends SqoopConnector {
* @return Validator object
*/
@Override
- public Validator getValidator() {
+ public Validator getConfigValidator() {
return hdfsValidator;
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsExtractor.java
----------------------------------------------------------------------
diff --git a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsExtractor.java b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsExtractor.java
index 436d243..2c8b6c8 100644
--- a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsExtractor.java
+++ b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsExtractor.java
@@ -52,8 +52,8 @@ public class HdfsExtractor extends Extractor<LinkConfiguration, FromJobConfigura
@Override
public void extract(ExtractorContext context,
- LinkConfiguration connectionConfiguration,
- FromJobConfiguration jobConfiguration, HdfsPartition partition) {
+ LinkConfiguration linkConfig,
+ FromJobConfiguration fromJobConfig, HdfsPartition partition) {
conf = ((PrefixContext) context.getContext()).getConfiguration();
dataWriter = context.getDataWriter();
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsInitializer.java
----------------------------------------------------------------------
diff --git a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsInitializer.java b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsInitializer.java
index c2dc1a5..bb5e353 100644
--- a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsInitializer.java
+++ b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsInitializer.java
@@ -29,16 +29,16 @@ public class HdfsInitializer extends Initializer {
* promoted to all other part of the workflow automatically.
*
* @param context Initializer context object
- * @param linkConf Connector's link configuration object
+ * @param linkConfig Connector's link configuration object
* @param jobConf Connector's job configuration object
*/
@Override
- public void initialize(InitializerContext context, Object linkConf, Object jobConf) {
+ public void initialize(InitializerContext context, Object linkConfig, Object jobConf) {
}
@Override
- public Schema getSchema(InitializerContext context, Object linkConf, Object jobConf) {
+ public Schema getSchema(InitializerContext context, Object linkConfig, Object jobConfig) {
return new Schema("HDFS file");
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsLoader.java
----------------------------------------------------------------------
diff --git a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsLoader.java b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsLoader.java
index 4c546ba..660418d 100644
--- a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsLoader.java
+++ b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsLoader.java
@@ -42,19 +42,19 @@ public class HdfsLoader extends Loader<LinkConfiguration, ToJobConfiguration> {
* Load data to target.
*
* @param context Loader context object
- * @param linkConf Link configuration
- * @param toJobConf Job configuration
+ * @param linkConfig Link configuration
+ * @param toJobConfig Job configuration
* @throws Exception
*/
@Override
- public void load(LoaderContext context, LinkConfiguration linkConf, ToJobConfiguration toJobConf) throws Exception {
+ public void load(LoaderContext context, LinkConfiguration linkConfig, ToJobConfiguration toJobConfig) throws Exception {
DataReader reader = context.getDataReader();
Configuration conf = ((PrefixContext)context.getContext()).getConfiguration();
- String directoryName = toJobConf.toJobConfig.outputDirectory;
- String codecname = getCompressionCodecName(toJobConf);
+ String directoryName = toJobConfig.toJobConfig.outputDirectory;
+ String codecname = getCompressionCodecName(toJobConfig);
CompressionCodec codec = null;
if (codecname != null) {
@@ -73,12 +73,12 @@ public class HdfsLoader extends Loader<LinkConfiguration, ToJobConfiguration> {
}
}
- String filename = directoryName + "/" + UUID.randomUUID() + getExtension(toJobConf,codec);
+ String filename = directoryName + "/" + UUID.randomUUID() + getExtension(toJobConfig,codec);
try {
Path filepath = new Path(filename);
- GenericHdfsWriter filewriter = getWriter(toJobConf);
+ GenericHdfsWriter filewriter = getWriter(toJobConfig);
filewriter.initialize(filepath,conf,codec);
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsPartitioner.java
----------------------------------------------------------------------
diff --git a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsPartitioner.java b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsPartitioner.java
index 6828de8..f40459f 100644
--- a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsPartitioner.java
+++ b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsPartitioner.java
@@ -68,12 +68,12 @@ public class HdfsPartitioner extends Partitioner<LinkConfiguration, FromJobConfi
@Override
public List<Partition> getPartitions(PartitionerContext context,
- LinkConfiguration linkConfiguration, FromJobConfiguration jobConfiguration) {
+ LinkConfiguration linkConfig, FromJobConfiguration fromJobConfig) {
Configuration conf = ((PrefixContext)context.getContext()).getConfiguration();
try {
- long numInputBytes = getInputSize(conf, jobConfiguration.fromJobConfig.inputDirectory);
+ long numInputBytes = getInputSize(conf, fromJobConfig.fromJobConfig.inputDirectory);
maxSplitSize = numInputBytes / context.getMaxPartitions();
if(numInputBytes % context.getMaxPartitions() != 0 ) {
@@ -118,7 +118,7 @@ public class HdfsPartitioner extends Partitioner<LinkConfiguration, FromJobConfi
}
// all the files in input set
- String indir = jobConfiguration.fromJobConfig.inputDirectory;
+ String indir = fromJobConfig.fromJobConfig.inputDirectory;
FileSystem fs = FileSystem.get(conf);
List<Path> paths = new LinkedList<Path>();
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsValidator.java
----------------------------------------------------------------------
diff --git a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsValidator.java b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsValidator.java
index dfa3659..b995efd 100644
--- a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsValidator.java
+++ b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsValidator.java
@@ -19,7 +19,7 @@ package org.apache.sqoop.connector.hdfs;
import org.apache.sqoop.connector.hdfs.configuration.*;
import org.apache.sqoop.validation.Status;
-import org.apache.sqoop.validation.Validation;
+import org.apache.sqoop.validation.ConfigValidator;
import org.apache.sqoop.validation.Validator;
/**
@@ -28,54 +28,45 @@ import org.apache.sqoop.validation.Validator;
public class HdfsValidator extends Validator {
@Override
- public Validation validateLink(Object connectionConfiguration) {
- Validation validation = new Validation(LinkConfiguration.class);
- // No validation on connection object
- return validation;
- }
-
-
- @Override
- public Validation validateJob(Object jobConfiguration) {
- //TODO: I'm pretty sure this needs to call either validateExportJob or validateImportJob, depending on context
- return super.validateJob(jobConfiguration);
+ public ConfigValidator validateConfigForJob(Object jobConfiguration) {
+ return super.validateConfigForJob(jobConfiguration);
}
@SuppressWarnings("unused")
- private Validation validateFromJob(Object jobConfiguration) {
- Validation validation = new Validation(FromJobConfiguration.class);
+ private ConfigValidator validateFromJob(Object jobConfiguration) {
+ ConfigValidator validation = new ConfigValidator(FromJobConfiguration.class);
FromJobConfiguration configuration = (FromJobConfiguration)jobConfiguration;
- validateInputForm(validation, configuration.fromJobConfig);
+ validateInputConfig(validation, configuration.fromJobConfig);
return validation;
}
@SuppressWarnings("unused")
- private Validation validateToJob(Object jobConfiguration) {
- Validation validation = new Validation(ToJobConfiguration.class);
+ private ConfigValidator validateToJob(Object jobConfiguration) {
+ ConfigValidator validation = new ConfigValidator(ToJobConfiguration.class);
ToJobConfiguration configuration = (ToJobConfiguration)jobConfiguration;
- validateOutputForm(validation, configuration.toJobConfig);
+ validateOutputConfig(validation, configuration.toJobConfig);
return validation;
}
- private void validateInputForm(Validation validation, FromJobConfig input) {
- if(input.inputDirectory == null || input.inputDirectory.isEmpty()) {
+ private void validateInputConfig(ConfigValidator validation, FromJobConfig inputConfig) {
+ if(inputConfig.inputDirectory == null || inputConfig.inputDirectory.isEmpty()) {
validation.addMessage(Status.UNACCEPTABLE, "input", "inputDirectory", "Input directory is empty");
}
}
- private void validateOutputForm(Validation validation, ToJobConfig output) {
- if(output.outputDirectory == null || output.outputDirectory.isEmpty()) {
+ private void validateOutputConfig(ConfigValidator validation, ToJobConfig outputConfig) {
+ if(outputConfig.outputDirectory == null || outputConfig.outputDirectory.isEmpty()) {
validation.addMessage(Status.UNACCEPTABLE, "output", "outputDirectory", "Output directory is empty");
}
- if(output.customCompression != null &&
- output.customCompression.trim().length() > 0 &&
- output.compression != ToCompression.CUSTOM) {
+ if(outputConfig.customCompression != null &&
+ outputConfig.customCompression.trim().length() > 0 &&
+ outputConfig.compression != ToCompression.CUSTOM) {
validation.addMessage(Status.UNACCEPTABLE, "output", "compression",
- "custom compression should be blank as " + output.compression + " is being used.");
+ "custom compression should be blank as " + outputConfig.compression + " is being used.");
}
- if(output.compression == ToCompression.CUSTOM &&
- (output.customCompression == null ||
- output.customCompression.trim().length() == 0)
+ if(outputConfig.compression == ToCompression.CUSTOM &&
+ (outputConfig.customCompression == null ||
+ outputConfig.customCompression.trim().length() == 0)
) {
validation.addMessage(Status.UNACCEPTABLE, "output", "compression",
"custom compression is blank.");
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/FromJobConfig.java
----------------------------------------------------------------------
diff --git a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/FromJobConfig.java b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/FromJobConfig.java
index 2c98051..037fe59 100644
--- a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/FromJobConfig.java
+++ b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/FromJobConfig.java
@@ -17,13 +17,13 @@
*/
package org.apache.sqoop.connector.hdfs.configuration;
-import org.apache.sqoop.model.FormClass;
+import org.apache.sqoop.model.ConfigClass;
import org.apache.sqoop.model.Input;
/**
*
*/
-@FormClass
+@ConfigClass
public class FromJobConfig {
@Input(size = 255) public String inputDirectory;
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/FromJobConfiguration.java
----------------------------------------------------------------------
diff --git a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/FromJobConfiguration.java b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/FromJobConfiguration.java
index f861237..618366e 100644
--- a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/FromJobConfiguration.java
+++ b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/FromJobConfiguration.java
@@ -18,11 +18,11 @@
package org.apache.sqoop.connector.hdfs.configuration;
import org.apache.sqoop.model.ConfigurationClass;
-import org.apache.sqoop.model.Form;
+import org.apache.sqoop.model.Config;
@ConfigurationClass
public class FromJobConfiguration {
- @Form public FromJobConfig fromJobConfig;
+ @Config public FromJobConfig fromJobConfig;
public FromJobConfiguration() {
fromJobConfig = new FromJobConfig();
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/LinkConfig.java
----------------------------------------------------------------------
diff --git a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/LinkConfig.java b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/LinkConfig.java
index b689854..5d48a29 100644
--- a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/LinkConfig.java
+++ b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/LinkConfig.java
@@ -17,13 +17,13 @@
*/
package org.apache.sqoop.connector.hdfs.configuration;
-import org.apache.sqoop.model.FormClass;
+import org.apache.sqoop.model.ConfigClass;
import org.apache.sqoop.model.Input;
-@FormClass
+@ConfigClass
public class LinkConfig {
//Todo: Didn't find anything that belongs here...
- // Since empty forms don't work (DERBYREPO_0008:The form contains no input metadata), I'm putting a dummy form here
+ // Since empty forms don't work (DERBYREPO_0008:The config contains no input metadata), I'm putting a dummy config here
@Input(size = 255) public String dummy;
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/LinkConfiguration.java
----------------------------------------------------------------------
diff --git a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/LinkConfiguration.java b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/LinkConfiguration.java
index 4970821..c0cd336 100644
--- a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/LinkConfiguration.java
+++ b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/LinkConfiguration.java
@@ -18,14 +18,14 @@
package org.apache.sqoop.connector.hdfs.configuration;
import org.apache.sqoop.model.ConfigurationClass;
-import org.apache.sqoop.model.Form;
+import org.apache.sqoop.model.Config;
@ConfigurationClass
public class LinkConfiguration {
- @Form
- public LinkConfig link;
+ @Config
+ public LinkConfig linkConfig;
public LinkConfiguration() {
- link = new LinkConfig();
+ linkConfig = new LinkConfig();
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/ToJobConfig.java
----------------------------------------------------------------------
diff --git a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/ToJobConfig.java b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/ToJobConfig.java
index b1308db..2dfd738 100644
--- a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/ToJobConfig.java
+++ b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/ToJobConfig.java
@@ -17,13 +17,13 @@
*/
package org.apache.sqoop.connector.hdfs.configuration;
-import org.apache.sqoop.model.FormClass;
+import org.apache.sqoop.model.ConfigClass;
import org.apache.sqoop.model.Input;
/**
*
*/
-@FormClass
+@ConfigClass
public class ToJobConfig {
@Input public ToFormat outputFormat;
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/ToJobConfiguration.java
----------------------------------------------------------------------
diff --git a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/ToJobConfiguration.java b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/ToJobConfiguration.java
index bba249c..c91a975 100644
--- a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/ToJobConfiguration.java
+++ b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/configuration/ToJobConfiguration.java
@@ -18,11 +18,11 @@
package org.apache.sqoop.connector.hdfs.configuration;
import org.apache.sqoop.model.ConfigurationClass;
-import org.apache.sqoop.model.Form;
+import org.apache.sqoop.model.Config;
@ConfigurationClass
public class ToJobConfiguration {
- @Form
+ @Config
public ToJobConfig toJobConfig;
public ToJobConfiguration() {
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-hdfs/src/main/resources/hdfs-connector-config.properties
----------------------------------------------------------------------
diff --git a/connector/connector-hdfs/src/main/resources/hdfs-connector-config.properties b/connector/connector-hdfs/src/main/resources/hdfs-connector-config.properties
index b603f2f..9b8c6ba 100644
--- a/connector/connector-hdfs/src/main/resources/hdfs-connector-config.properties
+++ b/connector/connector-hdfs/src/main/resources/hdfs-connector-config.properties
@@ -18,12 +18,12 @@
############################
# Link Config
#
-link.label = Link configuration
-link.help = You must supply the information requested in order to \
+linkConfig.label = Link configuration
+linkConfig.help = You must supply the information requested in order to \
create a connection object.
-link.dummy.label = Dummy parameter needed to get HDFS connector to register
-link.dummy.help = You can write anything here. Doesn't matter.
+linkConfig.dummy.label = Dummy parameter needed to get HDFS connector to register
+linkConfig.dummy.help = You can write anything here. Doesn't matter.
# To Job Config
#
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/connector/connector-sdk/src/test/java/org/apache/sqoop/connector/idf/TestCSVIntermediateDataFormat.java
----------------------------------------------------------------------
diff --git a/connector/connector-sdk/src/test/java/org/apache/sqoop/connector/idf/TestCSVIntermediateDataFormat.java b/connector/connector-sdk/src/test/java/org/apache/sqoop/connector/idf/TestCSVIntermediateDataFormat.java
index 765bedd..f5fbab7 100644
--- a/connector/connector-sdk/src/test/java/org/apache/sqoop/connector/idf/TestCSVIntermediateDataFormat.java
+++ b/connector/connector-sdk/src/test/java/org/apache/sqoop/connector/idf/TestCSVIntermediateDataFormat.java
@@ -18,6 +18,13 @@
*/
package org.apache.sqoop.connector.idf;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Arrays;
+
import org.apache.sqoop.common.SqoopException;
import org.apache.sqoop.schema.Schema;
import org.apache.sqoop.schema.type.Binary;
@@ -26,13 +33,6 @@ import org.apache.sqoop.schema.type.Text;
import org.junit.Before;
import org.junit.Test;
-import java.io.UnsupportedEncodingException;
-import java.util.Arrays;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
public class TestCSVIntermediateDataFormat {
private final String BYTE_FIELD_ENCODING = "ISO-8859-1";
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/core/src/main/java/org/apache/sqoop/connector/ConnectorHandler.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/connector/ConnectorHandler.java b/core/src/main/java/org/apache/sqoop/connector/ConnectorHandler.java
index dbfdc03..54bdd13 100644
--- a/core/src/main/java/org/apache/sqoop/connector/ConnectorHandler.java
+++ b/core/src/main/java/org/apache/sqoop/connector/ConnectorHandler.java
@@ -19,19 +19,18 @@ package org.apache.sqoop.connector;
import java.io.IOException;
import java.net.URL;
-import java.util.ArrayList;
import java.util.Properties;
import org.apache.log4j.Logger;
import org.apache.sqoop.common.Direction;
-import org.apache.sqoop.core.ConfigurationConstants;
-import org.apache.sqoop.model.FormUtils;
-import org.apache.sqoop.model.MConnectionForms;
-import org.apache.sqoop.model.MConnector;
import org.apache.sqoop.common.SqoopException;
import org.apache.sqoop.connector.spi.SqoopConnector;
-import org.apache.sqoop.model.MForm;
-import org.apache.sqoop.model.MJobForms;
+import org.apache.sqoop.core.ConfigurationConstants;
+import org.apache.sqoop.model.ConfigUtils;
+import org.apache.sqoop.model.MConnector;
+import org.apache.sqoop.model.MFromConfig;
+import org.apache.sqoop.model.MLinkConfig;
+import org.apache.sqoop.model.MToConfig;
public final class ConnectorHandler {
@@ -92,26 +91,25 @@ public final class ConnectorHandler {
connectorClassName, ex);
}
- // Initialize Metadata
- MJobForms fromJobForms = null;
- MJobForms toJobForms = null;
+ MFromConfig fromConfig = null;
+ MToConfig toConfig = null;
if (connector.getSupportedDirections().contains(Direction.FROM)) {
- fromJobForms = new MJobForms(FormUtils.toForms(
+ fromConfig = new MFromConfig(ConfigUtils.toConfigs(
connector.getJobConfigurationClass(Direction.FROM)));
}
if (connector.getSupportedDirections().contains(Direction.TO)) {
- toJobForms = new MJobForms(FormUtils.toForms(
+ toConfig = new MToConfig(ConfigUtils.toConfigs(
connector.getJobConfigurationClass(Direction.TO)));
}
- MConnectionForms connectionForms = new MConnectionForms(
- FormUtils.toForms(connector.getLinkConfigurationClass()));
+ MLinkConfig connectionForms = new MLinkConfig(
+ ConfigUtils.toConfigs(connector.getLinkConfigurationClass()));
String connectorVersion = connector.getVersion();
mConnector = new MConnector(connectorUniqueName, connectorClassName, connectorVersion,
- connectionForms, fromJobForms, toJobForms);
+ connectionForms, fromConfig, toConfig);
if (LOG.isInfoEnabled()) {
LOG.info("Connector [" + connectorClassName + "] initialized.");
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java b/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
index c87df84..5226926 100644
--- a/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
+++ b/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
@@ -119,7 +119,7 @@ public class ConnectorManager implements Reconfigurable {
return handler.getConnector().getBundle(locale);
}
- public MConnector getConnectorMetadata(long connectorId) {
+ public MConnector getConnectorConfig(long connectorId) {
ConnectorHandler handler = handlerMap.get(nameMap.get(connectorId));
if(handler == null) {
return null;
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/core/src/main/java/org/apache/sqoop/driver/Driver.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/driver/Driver.java b/core/src/main/java/org/apache/sqoop/driver/Driver.java
index 5297bde..f1b45bb 100644
--- a/core/src/main/java/org/apache/sqoop/driver/Driver.java
+++ b/core/src/main/java/org/apache/sqoop/driver/Driver.java
@@ -17,6 +17,7 @@
*/
package org.apache.sqoop.driver;
+import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
@@ -26,12 +27,12 @@ import org.apache.sqoop.core.ConfigurationConstants;
import org.apache.sqoop.core.Reconfigurable;
import org.apache.sqoop.core.SqoopConfiguration;
import org.apache.sqoop.core.SqoopConfiguration.CoreConfigurationListener;
-import org.apache.sqoop.driver.configuration.JobConfiguration;
-import org.apache.sqoop.driver.configuration.LinkConfiguration;
-import org.apache.sqoop.model.FormUtils;
-import org.apache.sqoop.model.MConnectionForms;
+import org.apache.sqoop.driver.configuration.DriverConfiguration;
+import org.apache.sqoop.json.DriverBean;
+import org.apache.sqoop.model.ConfigUtils;
+import org.apache.sqoop.model.MConfig;
+import org.apache.sqoop.model.MDriver;
import org.apache.sqoop.model.MDriverConfig;
-import org.apache.sqoop.model.MJobForms;
import org.apache.sqoop.repository.RepositoryManager;
import org.apache.sqoop.validation.Validator;
@@ -92,14 +93,14 @@ public class Driver implements Reconfigurable {
}
/**
- * Driver config structure
+ * Driver structure
*/
- private MDriverConfig mDriverConfig;
+ private MDriver mDriver;
/**
* Validator instance
*/
- private final Validator validator;
+ private final Validator driverValidator;
/**
* Driver config upgrader instance
@@ -111,38 +112,30 @@ public class Driver implements Reconfigurable {
*/
private static final boolean DEFAULT_AUTO_UPGRADE = false;
- public static final String CURRENT_DRIVER_VERSION = "1";
-
- public Class getJobConfigurationClass() {
- return JobConfiguration.class;
- }
-
- public Class getLinkConfigurationClass() {
- return LinkConfiguration.class;
+ public Class getDriverConfigurationGroupClass() {
+ return DriverConfiguration.class;
}
public Driver() {
- MConnectionForms connectionForms = new MConnectionForms(
- FormUtils.toForms(getLinkConfigurationClass())
- );
- mDriverConfig = new MDriverConfig(connectionForms, new MJobForms(FormUtils.toForms(getJobConfigurationClass())),
- CURRENT_DRIVER_VERSION);
+ List<MConfig> driverConfig = ConfigUtils.toConfigs(getDriverConfigurationGroupClass());
+ mDriver = new MDriver(new MDriverConfig(driverConfig), DriverBean.CURRENT_DRIVER_VERSION);
// Build validator
- validator = new DriverValidator();
+ driverValidator = new DriverConfigValidator();
// Build upgrader
driverConfigUpgrader = new DriverConfigUpgrader();
}
public synchronized void initialize() {
- initialize(SqoopConfiguration.getInstance().getContext().getBoolean(ConfigurationConstants.DRIVER_AUTO_UPGRADE, DEFAULT_AUTO_UPGRADE));
+ initialize(SqoopConfiguration.getInstance().getContext()
+ .getBoolean(ConfigurationConstants.DRIVER_AUTO_UPGRADE, DEFAULT_AUTO_UPGRADE));
}
public synchronized void initialize(boolean autoUpgrade) {
LOG.trace("Begin Driver Config initialization");
// Register driver config in repository
- mDriverConfig = RepositoryManager.getInstance().getRepository().registerDriverConfig(mDriverConfig, autoUpgrade);
+ mDriver = RepositoryManager.getInstance().getRepository().registerDriver(mDriver, autoUpgrade);
SqoopConfiguration.getInstance().getProvider().registerListener(new CoreConfigurationListener(this));
@@ -154,15 +147,15 @@ public class Driver implements Reconfigurable {
}
public Validator getValidator() {
- return validator;
+ return driverValidator;
}
public RepositoryUpgrader getDriverConfigRepositoryUpgrader() {
return driverConfigUpgrader;
}
- public MDriverConfig getDriverConfig() {
- return mDriverConfig;
+ public MDriver getDriver() {
+ return mDriver;
}
public ResourceBundle getBundle(Locale locale) {
[13/13] git commit: SQOOP-1498: Sqoop2: Repository Object refactoring
(objects prefixed with M)
Posted by ab...@apache.org.
SQOOP-1498: Sqoop2: Repository Object refactoring (objects prefixed with M)
(Veena Basavaraj via Abraham Elmahrek)
Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/f63c080d
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/f63c080d
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/f63c080d
Branch: refs/heads/SQOOP-1367
Commit: f63c080dd6b20c8c5848d930aeb8cce204cc702d
Parents: e0a2b77
Author: Abraham Elmahrek <ab...@elmahrek.com>
Authored: Thu Oct 2 23:29:50 2014 -0700
Committer: Abraham Elmahrek <ab...@elmahrek.com>
Committed: Thu Oct 2 23:29:50 2014 -0700
----------------------------------------------------------------------
.../org/apache/sqoop/client/SqoopClient.java | 119 +--
.../request/ConnectorResourceRequest.java | 4 +-
.../request/DriverConfigResourceRequest.java | 15 +-
.../client/request/JobResourceRequest.java | 26 +-
.../client/request/LinkResourceRequest.java | 10 +-
.../client/request/SqoopResourceRequests.java | 4 +-
.../apache/sqoop/client/TestSqoopClient.java | 73 +-
.../org/apache/sqoop/json/ConnectorBean.java | 129 +--
.../java/org/apache/sqoop/json/DriverBean.java | 90 ++
.../org/apache/sqoop/json/DriverConfigBean.java | 92 --
.../java/org/apache/sqoop/json/JobBean.java | 77 +-
.../apache/sqoop/json/JobValidationBean.java | 83 +-
.../java/org/apache/sqoop/json/LinkBean.java | 96 +-
.../apache/sqoop/json/LinkValidationBean.java | 56 +-
.../org/apache/sqoop/json/ThrowableBean.java | 2 +-
.../apache/sqoop/json/ValidationResultBean.java | 18 +-
.../sqoop/json/util/ConfigSerialization.java | 226 +++++
.../sqoop/json/util/FormSerialization.java | 223 -----
.../json/util/ResourceBundleSerialization.java | 2 -
.../java/org/apache/sqoop/model/Config.java | 28 +
.../org/apache/sqoop/model/ConfigClass.java | 45 +
.../org/apache/sqoop/model/ConfigUtils.java | 565 +++++++++++
.../apache/sqoop/model/ConfigurationClass.java | 7 +-
.../main/java/org/apache/sqoop/model/Form.java | 28 -
.../java/org/apache/sqoop/model/FormClass.java | 45 -
.../java/org/apache/sqoop/model/FormUtils.java | 565 -----------
.../java/org/apache/sqoop/model/MConfig.java | 117 +++
.../org/apache/sqoop/model/MConfigList.java | 124 +++
.../org/apache/sqoop/model/MConfigType.java | 34 +
.../apache/sqoop/model/MConnectionForms.java | 54 --
.../java/org/apache/sqoop/model/MConnector.java | 124 ++-
.../java/org/apache/sqoop/model/MDriver.java | 82 ++
.../org/apache/sqoop/model/MDriverConfig.java | 65 +-
.../main/java/org/apache/sqoop/model/MForm.java | 117 ---
.../java/org/apache/sqoop/model/MFormList.java | 124 ---
.../java/org/apache/sqoop/model/MFormType.java | 34 -
.../org/apache/sqoop/model/MFromConfig.java | 64 ++
.../main/java/org/apache/sqoop/model/MJob.java | 102 +-
.../java/org/apache/sqoop/model/MJobForms.java | 55 --
.../main/java/org/apache/sqoop/model/MLink.java | 72 +-
.../org/apache/sqoop/model/MLinkConfig.java | 54 ++
.../java/org/apache/sqoop/model/MToConfig.java | 64 ++
.../java/org/apache/sqoop/model/ModelError.java | 6 +-
.../java/org/apache/sqoop/utils/ClassUtils.java | 6 +-
.../sqoop/validation/ConfigValidationError.java | 52 +
.../validation/ConfigValidationResult.java | 98 ++
.../validation/ConfigValidationRunner.java | 177 ++++
.../sqoop/validation/ConfigValidator.java | 228 +++++
.../org/apache/sqoop/validation/Message.java | 2 +-
.../org/apache/sqoop/validation/Validation.java | 228 -----
.../sqoop/validation/ValidationError.java | 52 -
.../sqoop/validation/ValidationResult.java | 98 --
.../sqoop/validation/ValidationRunner.java | 176 ----
.../org/apache/sqoop/json/ConfigTestUtil.java | 217 +++++
.../apache/sqoop/json/TestConnectorBean.java | 37 +-
.../org/apache/sqoop/json/TestDriverBean.java | 62 ++
.../apache/sqoop/json/TestDriverConfigBean.java | 62 --
.../java/org/apache/sqoop/json/TestJobBean.java | 40 +-
.../org/apache/sqoop/json/TestLinkBean.java | 56 +-
.../java/org/apache/sqoop/json/TestUtil.java | 153 ---
.../apache/sqoop/json/TestValidationBean.java | 83 +-
.../sqoop/json/TestValidationResultBean.java | 24 +-
.../json/util/TestConfigSerialization.java | 157 ++++
.../sqoop/json/util/TestFormSerialization.java | 157 ----
.../org/apache/sqoop/model/TestConfigUtils.java | 217 +++++
.../org/apache/sqoop/model/TestFormUtils.java | 226 -----
.../sqoop/model/TestMAccountableEntity.java | 9 +-
.../org/apache/sqoop/model/TestMConfig.java | 86 ++
.../org/apache/sqoop/model/TestMConfigList.java | 55 ++
.../sqoop/model/TestMConnectionForms.java | 48 -
.../org/apache/sqoop/model/TestMConnector.java | 144 +--
.../org/apache/sqoop/model/TestMDriver.java | 40 +
.../apache/sqoop/model/TestMDriverConfig.java | 47 -
.../java/org/apache/sqoop/model/TestMForm.java | 89 --
.../org/apache/sqoop/model/TestMFormList.java | 58 --
.../java/org/apache/sqoop/model/TestMJob.java | 110 ++-
.../org/apache/sqoop/model/TestMJobConfig.java | 42 +
.../org/apache/sqoop/model/TestMJobForms.java | 46 -
.../java/org/apache/sqoop/model/TestMLink.java | 74 +-
.../org/apache/sqoop/model/TestMLinkConfig.java | 45 +
.../apache/sqoop/validation/TestValidation.java | 70 +-
.../sqoop/validation/TestValidationRunner.java | 98 +-
.../validators/TestClassAvailable.java | 12 +-
.../connector/jdbc/GenericJdbcConnector.java | 2 +-
.../jdbc/GenericJdbcConnectorUpgrader.java | 54 +-
.../connector/jdbc/GenericJdbcExtractor.java | 12 +-
.../jdbc/GenericJdbcFromDestroyer.java | 2 +-
.../jdbc/GenericJdbcFromInitializer.java | 36 +-
.../sqoop/connector/jdbc/GenericJdbcLoader.java | 10 +-
.../connector/jdbc/GenericJdbcPartitioner.java | 5 +-
.../connector/jdbc/GenericJdbcToDestroyer.java | 18 +-
.../jdbc/GenericJdbcToInitializer.java | 32 +-
.../connector/jdbc/GenericJdbcValidator.java | 30 +-
.../jdbc/configuration/FromJobConfig.java | 14 +-
.../configuration/FromJobConfiguration.java | 4 +-
.../jdbc/configuration/LinkConfig.java | 6 +-
.../jdbc/configuration/LinkConfiguration.java | 6 +-
.../jdbc/configuration/ToJobConfig.java | 16 +-
.../jdbc/configuration/ToJobConfiguration.java | 4 +-
.../generic-jdbc-connector-config.properties | 24 +-
.../connector/jdbc/GenericJdbcExecutorTest.java | 3 -
.../sqoop/connector/jdbc/TestExtractor.java | 24 +-
.../connector/jdbc/TestFromInitializer.java | 158 ++--
.../apache/sqoop/connector/jdbc/TestLoader.java | 8 +-
.../sqoop/connector/jdbc/TestPartitioner.java | 98 +-
.../sqoop/connector/jdbc/TestToInitializer.java | 188 ++--
.../connector/hdfs/HdfsConfigUpgrader.java | 50 +-
.../sqoop/connector/hdfs/HdfsConnector.java | 2 +-
.../sqoop/connector/hdfs/HdfsExtractor.java | 4 +-
.../sqoop/connector/hdfs/HdfsInitializer.java | 6 +-
.../apache/sqoop/connector/hdfs/HdfsLoader.java | 14 +-
.../sqoop/connector/hdfs/HdfsPartitioner.java | 6 +-
.../sqoop/connector/hdfs/HdfsValidator.java | 49 +-
.../hdfs/configuration/FromJobConfig.java | 4 +-
.../configuration/FromJobConfiguration.java | 4 +-
.../hdfs/configuration/LinkConfig.java | 6 +-
.../hdfs/configuration/LinkConfiguration.java | 8 +-
.../hdfs/configuration/ToJobConfig.java | 4 +-
.../hdfs/configuration/ToJobConfiguration.java | 4 +-
.../resources/hdfs-connector-config.properties | 8 +-
.../idf/TestCSVIntermediateDataFormat.java | 14 +-
.../sqoop/connector/ConnectorHandler.java | 28 +-
.../sqoop/connector/ConnectorManager.java | 2 +-
.../java/org/apache/sqoop/driver/Driver.java | 47 +-
.../sqoop/driver/DriverConfigUpgrader.java | 48 +-
.../sqoop/driver/DriverConfigValidator.java | 46 +
.../apache/sqoop/driver/DriverValidator.java | 54 --
.../org/apache/sqoop/driver/JobManager.java | 72 +-
.../org/apache/sqoop/driver/JobRequest.java | 63 +-
.../configuration/DriverConfiguration.java | 34 +
.../driver/configuration/JobConfiguration.java | 34 -
.../driver/configuration/LinkConfiguration.java | 28 -
.../driver/configuration/ThrottlingConfig.java | 32 +
.../driver/configuration/ThrottlingForm.java | 32 -
.../apache/sqoop/repository/JdbcRepository.java | 46 +-
.../sqoop/repository/JdbcRepositoryHandler.java | 14 +-
.../org/apache/sqoop/repository/Repository.java | 254 +++--
.../sqoop/repository/RepositoryManager.java | 2 +-
.../src/main/resources/driver-config.properties | 12 +-
.../sqoop/driver/TestDriverConfigUpgrader.java | 88 +-
.../org/apache/sqoop/driver/TestJobManager.java | 18 +-
.../sqoop/repository/TestJdbcRepository.java | 495 +++-------
.../main/java/org/apache/sqoop/job/io/Data.java | 2 +-
.../apache/sqoop/job/mr/ConfigurationUtils.java | 124 +--
.../sqoop/job/mr/SqoopDestroyerExecutor.java | 2 +-
.../java/org/apache/sqoop/job/JobUtils.java | 3 +-
.../org/apache/sqoop/job/TestMapReduce.java | 1 -
.../sqoop/job/mr/TestConfigurationUtils.java | 118 ++-
.../sqoop/repository/derby/DerbyRepoError.java | 2 +-
.../derby/DerbyRepositoryHandler.java | 777 +++++++--------
.../repository/derby/DerbySchemaConstants.java | 108 +--
.../repository/derby/DerbySchemaQuery.java | 640 ++++++-------
.../sqoop/repository/derby/DerbyTestCase.java | 287 +++---
.../repository/derby/TestConnectorHandling.java | 6 +-
.../derby/TestDriverConfigHandling.java | 135 ---
.../repository/derby/TestDriverHandling.java | 135 +++
.../sqoop/repository/derby/TestInputTypes.java | 22 +-
.../sqoop/repository/derby/TestJobHandling.java | 216 ++---
.../repository/derby/TestLinkHandling.java | 118 +--
.../derby/TestSubmissionHandling.java | 2 +-
.../sqoop/handler/ConnectorRequestHandler.java | 2 +-
.../handler/DriverConfigRequestHandler.java | 11 +-
.../apache/sqoop/handler/JobRequestHandler.java | 95 +-
.../sqoop/handler/LinkRequestHandler.java | 158 ++--
.../apache/sqoop/shell/CloneJobFunction.java | 18 +-
.../apache/sqoop/shell/CloneLinkFunction.java | 17 +-
.../apache/sqoop/shell/CreateJobFunction.java | 26 +-
.../apache/sqoop/shell/CreateLinkFunction.java | 22 +-
.../org/apache/sqoop/shell/ShowCommand.java | 2 +-
.../sqoop/shell/ShowConnectorFunction.java | 4 +-
.../sqoop/shell/ShowDriverConfigFunction.java | 60 --
.../apache/sqoop/shell/ShowDriverFunction.java | 55 ++
.../org/apache/sqoop/shell/ShowJobFunction.java | 13 +-
.../apache/sqoop/shell/ShowLinkFunction.java | 28 +-
.../org/apache/sqoop/shell/SqoopFunction.java | 4 +-
.../apache/sqoop/shell/UpdateJobFunction.java | 25 +-
.../apache/sqoop/shell/UpdateLinkFunction.java | 23 +-
.../org/apache/sqoop/shell/core/Constants.java | 64 +-
.../sqoop/shell/utils/ConfigDisplayer.java | 258 +++++
.../apache/sqoop/shell/utils/ConfigFiller.java | 911 ++++++++++++++++++
.../apache/sqoop/shell/utils/ConfigOptions.java | 117 +++
.../sqoop/shell/utils/DynamicConfigOptions.java | 35 +
.../sqoop/shell/utils/DynamicFormOptions.java | 35 -
.../apache/sqoop/shell/utils/FormDisplayer.java | 267 ------
.../apache/sqoop/shell/utils/FormFiller.java | 939 -------------------
.../apache/sqoop/shell/utils/FormOptions.java | 117 ---
.../shell/utils/JobDynamicConfigOptions.java | 48 +
.../shell/utils/JobDynamicFormOptions.java | 48 -
.../shell/utils/LinkDynamicConfigOptions.java | 39 +
.../shell/utils/LinkDynamicFormOptions.java | 43 -
.../main/resources/shell-resource.properties | 34 +-
.../sqoop/connector/spi/RepositoryUpgrader.java | 28 +-
.../sqoop/connector/spi/SqoopConnector.java | 10 +-
.../org/apache/sqoop/job/etl/Destroyer.java | 2 +-
.../org/apache/sqoop/job/etl/Extractor.java | 4 +-
.../org/apache/sqoop/job/etl/Initializer.java | 40 +-
.../java/org/apache/sqoop/job/etl/Loader.java | 10 +-
.../org/apache/sqoop/job/etl/Partitioner.java | 10 +-
.../org/apache/sqoop/validation/Validator.java | 12 +-
.../mapreduce/MapreduceSubmissionEngine.java | 18 +-
.../minicluster/TomcatSqoopMiniCluster.java | 13 +-
.../sqoop/test/testcases/ConnectorTestCase.java | 53 +-
.../sqoop/test/testcases/TomcatTestCase.java | 4 +-
.../jdbc/generic/FromHDFSToRDBMSTest.java | 19 +-
.../jdbc/generic/FromRDBMSToHDFSTest.java | 39 +-
.../connector/jdbc/generic/PartitionerTest.java | 25 +-
.../jdbc/generic/TableStagedRDBMSTest.java | 26 +-
.../SubmissionWithDisabledModelObjectsTest.java | 24 +-
208 files changed, 8047 insertions(+), 8493 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/client/src/main/java/org/apache/sqoop/client/SqoopClient.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/SqoopClient.java b/client/src/main/java/org/apache/sqoop/client/SqoopClient.java
index d7e6768..bffb599 100644
--- a/client/src/main/java/org/apache/sqoop/client/SqoopClient.java
+++ b/client/src/main/java/org/apache/sqoop/client/SqoopClient.java
@@ -17,26 +17,27 @@
*/
package org.apache.sqoop.client;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.ResourceBundle;
+
import org.apache.sqoop.client.request.SqoopResourceRequests;
import org.apache.sqoop.common.Direction;
import org.apache.sqoop.common.SqoopException;
import org.apache.sqoop.json.ConnectorBean;
-import org.apache.sqoop.json.DriverConfigBean;
+import org.apache.sqoop.json.DriverBean;
import org.apache.sqoop.json.ValidationResultBean;
-import org.apache.sqoop.model.FormUtils;
-import org.apache.sqoop.model.MLink;
+import org.apache.sqoop.model.ConfigUtils;
import org.apache.sqoop.model.MConnector;
+import org.apache.sqoop.model.MDriver;
import org.apache.sqoop.model.MDriverConfig;
import org.apache.sqoop.model.MJob;
+import org.apache.sqoop.model.MLink;
import org.apache.sqoop.model.MSubmission;
+import org.apache.sqoop.validation.ConfigValidationResult;
import org.apache.sqoop.validation.Status;
-import org.apache.sqoop.validation.ValidationResult;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.ResourceBundle;
/**
* Sqoop client API.
@@ -69,9 +70,9 @@ public class SqoopClient {
private Map<Long, ResourceBundle> connectorConfigBundles;
/**
- * Cached driverConfig.
+ * Cached driver.
*/
- private MDriverConfig driverConfig;
+ private MDriver mDriver;
/**
* Cached driverConfig bundle.
*/
@@ -120,7 +121,7 @@ public class SqoopClient {
connectorConfigBundles = new HashMap<Long, ResourceBundle>();
driverConfigBundle = null;
connectors = new HashMap<Long, MConnector>();
- driverConfig = null;
+ mDriver = null;
isAllConnectors = false;
}
@@ -214,11 +215,10 @@ public class SqoopClient {
* @param connectorId Connector id.
* @return
*/
- public ResourceBundle getConnectorConfigResourceBundle(long connectorId) {
+ public ResourceBundle getConnectorConfigBundle(long connectorId) {
if(connectorConfigBundles.containsKey(connectorId)) {
return connectorConfigBundles.get(connectorId);
}
-
retrieveConnector(connectorId);
return connectorConfigBundles.get(connectorId);
}
@@ -229,33 +229,46 @@ public class SqoopClient {
* @return
*/
public MDriverConfig getDriverConfig() {
- if(driverConfig != null) {
- return driverConfig.clone(false);
+ if (mDriver != null) {
+ return mDriver.clone(false).getDriverConfig();
}
- retrieveAndCacheDriverConfig();
- return driverConfig.clone(false);
-
+ retrieveAndCacheDriver();
+ return mDriver.clone(false).getDriverConfig();
+ }
+
+ /**
+ * Return driver.
+ *
+ * @return
+ */
+ public MDriver getDriver() {
+ if (mDriver != null) {
+ return mDriver.clone(false);
+ }
+ retrieveAndCacheDriver();
+ return mDriver.clone(false);
+
}
/**
* Retrieve driverConfig and cache it.
*/
- private void retrieveAndCacheDriverConfig() {
- DriverConfigBean driverConfigBean = resourceRequests.readDriverConfig();
- driverConfig = driverConfigBean.getDriverConfig();
- driverConfigBundle = driverConfigBean.getResourceBundle();
+ private void retrieveAndCacheDriver() {
+ DriverBean driverBean = resourceRequests.readDriver();
+ mDriver = driverBean.getDriver();
+ driverConfigBundle = driverBean.getDriverConfigResourceBundle();
}
/**
* Return driverConfig bundle.
- *
+ *xx
* @return
*/
public ResourceBundle getDriverConfigBundle() {
if(driverConfigBundle != null) {
return driverConfigBundle;
}
- retrieveAndCacheDriverConfig();
+ retrieveAndCacheDriver();
return driverConfigBundle;
}
@@ -266,11 +279,7 @@ public class SqoopClient {
* @return
*/
public MLink createLink(long connectorId) {
- return new MLink(
- connectorId,
- getConnector(connectorId).getConnectionForms(),
- getDriverConfig().getConnectionForms()
- );
+ return new MLink(connectorId, getConnector(connectorId).getLinkConfig());
}
/**
@@ -281,10 +290,9 @@ public class SqoopClient {
*/
public MLink createLink(String connectorName) {
MConnector connector = getConnector(connectorName);
- if(connector == null) {
+ if (connector == null) {
throw new SqoopException(ClientError.CLIENT_0003, connectorName);
}
-
return createLink(connector.getPersistenceId());
}
@@ -362,9 +370,9 @@ public class SqoopClient {
toLink.getConnectorId(),
fromLink.getPersistenceId(),
toLink.getPersistenceId(),
- getConnector(fromLink.getConnectorId()).getJobForms(Direction.FROM),
- getConnector(toLink.getConnectorId()).getJobForms(Direction.TO),
- getDriverConfig().getJobForms()
+ getConnector(fromLink.getConnectorId()).getFromConfig(),
+ getConnector(toLink.getConnectorId()).getToConfig(),
+ getDriverConfig()
);
}
@@ -530,41 +538,36 @@ public class SqoopClient {
}
private Status applyLinkValidations(ValidationResultBean bean, MLink link) {
- ValidationResult connector = bean.getValidationResults()[0];
- ValidationResult driverConfig = bean.getValidationResults()[1];
-
+ ConfigValidationResult linkConfig = bean.getValidationResults()[0];
// Apply validation results
- FormUtils.applyValidation(link.getConnectorPart().getForms(), connector);
- FormUtils.applyValidation(link.getFrameworkPart().getForms(), driverConfig);
-
+ ConfigUtils.applyValidation(link.getConnectorLinkConfig().getConfigs(), linkConfig);
Long id = bean.getId();
if(id != null) {
link.setPersistenceId(id);
}
-
- return Status.getWorstStatus(connector.getStatus(), driverConfig.getStatus());
+ return Status.getWorstStatus(linkConfig.getStatus());
}
private Status applyJobValidations(ValidationResultBean bean, MJob job) {
- ValidationResult fromConnector = bean.getValidationResults()[0];
- ValidationResult toConnector = bean.getValidationResults()[1];
- ValidationResult driverConfig = bean.getValidationResults()[2];
-
- // Apply validation results
- // @TODO(Abe): From/To validation.
- FormUtils.applyValidation(
- job.getConnectorPart(Direction.FROM).getForms(),
- fromConnector);
- FormUtils.applyValidation(job.getFrameworkPart().getForms(), driverConfig);
- FormUtils.applyValidation(
- job.getConnectorPart(Direction.TO).getForms(),
- toConnector);
+ ConfigValidationResult fromConfig = bean.getValidationResults()[0];
+ ConfigValidationResult toConfig = bean.getValidationResults()[1];
+ // TODO(VB): fix this as part of SQOOP 1509
+ //ConfigValidationResult driverConfig = bean.getValidationResults()[2];
+
+ ConfigUtils.applyValidation(
+ job.getJobConfig(Direction.FROM).getConfigs(),
+ fromConfig);
+ ConfigUtils.applyValidation(
+ job.getJobConfig(Direction.TO).getConfigs(),
+ toConfig);
+ //ConfigUtils.applyValidation(job.getDriverConfig().getSelf().getConfigs(), driverConfig);
Long id = bean.getId();
if(id != null) {
job.setPersistenceId(id);
}
- return Status.getWorstStatus(fromConnector.getStatus(), driverConfig.getStatus(), toConnector.getStatus());
+ return Status.getWorstStatus(fromConfig.getStatus(), toConfig.getStatus());
+ // driverConfig.getStatus());
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/client/src/main/java/org/apache/sqoop/client/request/ConnectorResourceRequest.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/request/ConnectorResourceRequest.java b/client/src/main/java/org/apache/sqoop/client/request/ConnectorResourceRequest.java
index 2855de6..e2aae98 100644
--- a/client/src/main/java/org/apache/sqoop/client/request/ConnectorResourceRequest.java
+++ b/client/src/main/java/org/apache/sqoop/client/request/ConnectorResourceRequest.java
@@ -22,7 +22,7 @@ import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
/**
- * Provide cRud semantics over RESTfull HTTP API for connectors. Only read
+ * Provide Read semantics over RESTfull HTTP API for connectors. Only read
* is supported as creation, update and delete might be done only directly on
* server side.
*/
@@ -38,10 +38,8 @@ public class ConnectorResourceRequest extends ResourceRequest
response = super.get(serverUrl + RESOURCE + cid);
}
JSONObject jsonObject = (JSONObject)JSONValue.parse(response);
-
ConnectorBean connectorBean = new ConnectorBean();
connectorBean.restore(jsonObject);
-
return connectorBean;
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/client/src/main/java/org/apache/sqoop/client/request/DriverConfigResourceRequest.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/request/DriverConfigResourceRequest.java b/client/src/main/java/org/apache/sqoop/client/request/DriverConfigResourceRequest.java
index 7b2ddc2..f6066fc 100644
--- a/client/src/main/java/org/apache/sqoop/client/request/DriverConfigResourceRequest.java
+++ b/client/src/main/java/org/apache/sqoop/client/request/DriverConfigResourceRequest.java
@@ -17,26 +17,23 @@
*/
package org.apache.sqoop.client.request;
-import org.apache.sqoop.json.DriverConfigBean;
+import org.apache.sqoop.json.DriverBean;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
/**
- * Provide cRud semantics over RESTfull HTTP API for driverConfig. Only read
- * is supported as creation, update and delete is not allowed.
+ * Provide CRUD semantics over RESTfull HTTP API for driverConfig
*/
public class DriverConfigResourceRequest extends ResourceRequest {
public static final String RESOURCE = "v1/config/driver";
- public DriverConfigBean read(String serverUrl) {
+ public DriverBean read(String serverUrl) {
String response = null;
response = super.get(serverUrl + RESOURCE);
JSONObject jsonObject = (JSONObject) JSONValue.parse(response);
-
- DriverConfigBean driverConfigBean = new DriverConfigBean();
- driverConfigBean.restore(jsonObject);
-
- return driverConfigBean;
+ DriverBean driverBean = new DriverBean();
+ driverBean.restore(jsonObject);
+ return driverBean;
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/client/src/main/java/org/apache/sqoop/client/request/JobResourceRequest.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/request/JobResourceRequest.java b/client/src/main/java/org/apache/sqoop/client/request/JobResourceRequest.java
index fd858ec..83c08b3 100644
--- a/client/src/main/java/org/apache/sqoop/client/request/JobResourceRequest.java
+++ b/client/src/main/java/org/apache/sqoop/client/request/JobResourceRequest.java
@@ -34,46 +34,36 @@ public class JobResourceRequest extends ResourceRequest {
private static final String ENABLE = "/enable";
private static final String DISABLE = "/disable";
- public JobBean read(String serverUrl, Long xid) {
+ public JobBean read(String serverUrl, Long linkId) {
String response;
- if (xid == null) {
+ if (linkId == null) {
response = super.get(serverUrl + RESOURCE + "all");
} else {
- response = super.get(serverUrl + RESOURCE + xid);
+ response = super.get(serverUrl + RESOURCE + linkId);
}
JSONObject jsonObject = (JSONObject) JSONValue.parse(response);
-
JobBean jobBean = new JobBean();
jobBean.restore(jsonObject);
-
return jobBean;
}
public ValidationResultBean create(String serverUrl, MJob job) {
JobBean jobBean = new JobBean(job);
-
- // Extract all form inputs including sensitive inputs
+ // Extract all config inputs including sensitive inputs
JSONObject jobJson = jobBean.extract(false);
-
String response = super.post(serverUrl + RESOURCE, jobJson.toJSONString());
-
- ValidationResultBean validationBean = new ValidationResultBean();
- validationBean.restore((JSONObject) JSONValue.parse(response));
-
- return validationBean;
+ ValidationResultBean validationResultBean = new ValidationResultBean();
+ validationResultBean.restore((JSONObject) JSONValue.parse(response));
+ return validationResultBean;
}
public ValidationResultBean update(String serverUrl, MJob job) {
JobBean jobBean = new JobBean(job);
-
- // Extract all form inputs including sensitive inputs
+ // Extract all config inputs including sensitive inputs
JSONObject jobJson = jobBean.extract(false);
-
String response = super.put(serverUrl + RESOURCE + job.getPersistenceId(), jobJson.toJSONString());
-
ValidationResultBean validationBean = new ValidationResultBean();
validationBean.restore((JSONObject) JSONValue.parse(response));
-
return validationBean;
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/client/src/main/java/org/apache/sqoop/client/request/LinkResourceRequest.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/request/LinkResourceRequest.java b/client/src/main/java/org/apache/sqoop/client/request/LinkResourceRequest.java
index 2b784c8..64e5cb1 100644
--- a/client/src/main/java/org/apache/sqoop/client/request/LinkResourceRequest.java
+++ b/client/src/main/java/org/apache/sqoop/client/request/LinkResourceRequest.java
@@ -50,28 +50,22 @@ public class LinkResourceRequest extends ResourceRequest {
public ValidationResultBean create(String serverUrl, MLink link) {
LinkBean linkBean = new LinkBean(link);
- // Extract all form inputs including sensitive inputs
+ // Extract all config inputs including sensitive inputs
JSONObject linkJson = linkBean.extract(false);
-
String response = super.post(serverUrl + RESOURCE, linkJson.toJSONString());
-
ValidationResultBean validationBean = new ValidationResultBean();
validationBean.restore((JSONObject) JSONValue.parse(response));
-
return validationBean;
}
public ValidationResultBean update(String serverUrl, MLink link) {
LinkBean linkBean = new LinkBean(link);
- // Extract all form inputs including sensitive inputs
+ // Extract all config inputs including sensitive inputs
JSONObject linkJson = linkBean.extract(false);
-
String response = super.put(serverUrl + RESOURCE + link.getPersistenceId(), linkJson.toJSONString());
-
ValidationResultBean validationBean = new ValidationResultBean();
validationBean.restore((JSONObject) JSONValue.parse(response));
-
return validationBean;
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/client/src/main/java/org/apache/sqoop/client/request/SqoopResourceRequests.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/request/SqoopResourceRequests.java b/client/src/main/java/org/apache/sqoop/client/request/SqoopResourceRequests.java
index 5401eca..a4dee75 100644
--- a/client/src/main/java/org/apache/sqoop/client/request/SqoopResourceRequests.java
+++ b/client/src/main/java/org/apache/sqoop/client/request/SqoopResourceRequests.java
@@ -19,7 +19,7 @@ package org.apache.sqoop.client.request;
import org.apache.sqoop.json.LinkBean;
import org.apache.sqoop.json.ConnectorBean;
-import org.apache.sqoop.json.DriverConfigBean;
+import org.apache.sqoop.json.DriverBean;
import org.apache.sqoop.json.JobBean;
import org.apache.sqoop.json.SubmissionBean;
import org.apache.sqoop.json.ValidationResultBean;
@@ -83,7 +83,7 @@ public class SqoopResourceRequests {
return submissionRequest;
}
- public DriverConfigBean readDriverConfig() {
+ public DriverBean readDriver() {
return getDriverConfigResourceRequest().read(serverUrl);
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/client/src/test/java/org/apache/sqoop/client/TestSqoopClient.java
----------------------------------------------------------------------
diff --git a/client/src/test/java/org/apache/sqoop/client/TestSqoopClient.java b/client/src/test/java/org/apache/sqoop/client/TestSqoopClient.java
index 54ea3d2..18b6132 100644
--- a/client/src/test/java/org/apache/sqoop/client/TestSqoopClient.java
+++ b/client/src/test/java/org/apache/sqoop/client/TestSqoopClient.java
@@ -17,28 +17,36 @@
*/
package org.apache.sqoop.client;
-import org.apache.sqoop.client.request.SqoopResourceRequests;
-import org.apache.sqoop.common.SqoopException;
-import org.apache.sqoop.json.ConnectorBean;
-import org.apache.sqoop.json.DriverConfigBean;
-import org.apache.sqoop.model.MConnectionForms;
-import org.apache.sqoop.model.MConnector;
-import org.apache.sqoop.model.MDriverConfig;
-import org.apache.sqoop.model.MJobForms;
-import org.apache.sqoop.utils.MapResourceBundle;
-import org.junit.Before;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.mockito.Mockito.*;
+import org.apache.sqoop.client.request.SqoopResourceRequests;
+import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.json.ConnectorBean;
+import org.apache.sqoop.json.DriverBean;
+import org.apache.sqoop.model.MConfig;
+import org.apache.sqoop.model.MConnector;
+import org.apache.sqoop.model.MDriver;
+import org.apache.sqoop.model.MDriverConfig;
+import org.apache.sqoop.model.MFromConfig;
+import org.apache.sqoop.model.MLinkConfig;
+import org.apache.sqoop.model.MToConfig;
+import org.apache.sqoop.utils.MapResourceBundle;
+import org.junit.Before;
+import org.junit.Test;
public class TestSqoopClient {
@@ -62,7 +70,7 @@ public class TestSqoopClient {
MConnector connector = client.getConnector(1);
assertEquals(1, connector.getPersistenceId());
- client.getConnectorConfigResourceBundle(1L);
+ client.getConnectorConfigBundle(1L);
verify(resourceRequests, times(1)).readConnector(1L);
}
@@ -74,7 +82,7 @@ public class TestSqoopClient {
assertEquals(1, connector.getPersistenceId());
assertEquals("A1", connector.getUniqueName());
- client.getConnectorConfigResourceBundle(1L);
+ client.getConnectorConfigBundle(1L);
verify(resourceRequests, times(0)).readConnector(1L);
verify(resourceRequests, times(1)).readConnector(null);
@@ -87,7 +95,7 @@ public class TestSqoopClient {
@Test
public void testGetConnectorBundle() {
when(resourceRequests.readConnector(1L)).thenReturn(connectorBean(connector(1)));
- client.getConnectorConfigResourceBundle(1L);
+ client.getConnectorConfigBundle(1L);
MConnector connector = client.getConnector(1);
assertEquals(1, connector.getPersistenceId());
@@ -101,12 +109,12 @@ public class TestSqoopClient {
*/
@Test
public void testGetDriverConfig() {
- when(resourceRequests.readDriverConfig()).thenReturn(driverConfigBean(driverConfig()));
+ when(resourceRequests.readDriver()).thenReturn(driverBean(driver()));
client.getDriverConfig();
client.getDriverConfigBundle();
- verify(resourceRequests, times(1)).readDriverConfig();
+ verify(resourceRequests, times(1)).readDriver();
}
/**
@@ -115,12 +123,12 @@ public class TestSqoopClient {
*/
@Test
public void testGetDriverConfigBundle() {
- when(resourceRequests.readDriverConfig()).thenReturn(driverConfigBean(driverConfig()));
+ when(resourceRequests.readDriver()).thenReturn(driverBean(driver()));
client.getDriverConfigBundle();
client.getDriverConfig();
- verify(resourceRequests, times(1)).readDriverConfig();
+ verify(resourceRequests, times(1)).readDriver();
}
/**
@@ -135,12 +143,12 @@ public class TestSqoopClient {
Collection<MConnector> connectors = client.getConnectors();
assertEquals(2, connectors.size());
- client.getConnectorConfigResourceBundle(1);
+ client.getConnectorConfigBundle(1);
connector = client.getConnector(1);
assertEquals(1, connector.getPersistenceId());
connector = client.getConnector(2);
- client.getConnectorConfigResourceBundle(2);
+ client.getConnectorConfigBundle(2);
assertEquals(2, connector.getPersistenceId());
connectors = client.getConnectors();
@@ -173,11 +181,11 @@ public class TestSqoopClient {
when(resourceRequests.readConnector(1L)).thenReturn(bean);
when(resourceRequests.readConnector(2L)).thenReturn(bean);
- client.getConnectorConfigResourceBundle(1);
+ client.getConnectorConfigBundle(1);
client.getConnector(1);
client.getConnector(2);
- client.getConnectorConfigResourceBundle(2);
+ client.getConnectorConfigBundle(2);
Collection<MConnector> connectors = client.getConnectors();
assertEquals(2, connectors.size());
@@ -207,21 +215,20 @@ public class TestSqoopClient {
}
return new ConnectorBean(connectorList, bundles);
}
- private DriverConfigBean driverConfigBean(MDriverConfig driverConfig) {
- return new DriverConfigBean(driverConfig, new MapResourceBundle(null));
+ private DriverBean driverBean(MDriver driver) {
+ return new DriverBean(driver, new MapResourceBundle(null));
}
private MConnector connector(long id) {
MConnector connector = new MConnector("A" + id, "A" + id, "1.0" + id,
- new MConnectionForms(null), new MJobForms(null), new MJobForms(null));
+ new MLinkConfig(null), new MFromConfig(null), new MToConfig(null));
connector.setPersistenceId(id);
return connector;
}
- private MDriverConfig driverConfig() {
- MDriverConfig driverConfig = new MDriverConfig(new MConnectionForms(null),
- new MJobForms(null), "1");
- driverConfig.setPersistenceId(1);
- return driverConfig;
+ private MDriver driver() {
+ MDriver driver = new MDriver(new MDriverConfig(new LinkedList<MConfig>()), "1");
+ driver.setPersistenceId(1);
+ return driver;
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/json/ConnectorBean.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/json/ConnectorBean.java b/common/src/main/java/org/apache/sqoop/json/ConnectorBean.java
index d726a14..d12b6b0 100644
--- a/common/src/main/java/org/apache/sqoop/json/ConnectorBean.java
+++ b/common/src/main/java/org/apache/sqoop/json/ConnectorBean.java
@@ -17,15 +17,15 @@
*/
package org.apache.sqoop.json;
-import static org.apache.sqoop.json.util.FormSerialization.ALL;
-import static org.apache.sqoop.json.util.FormSerialization.CLASS;
-import static org.apache.sqoop.json.util.FormSerialization.CON_FORMS;
-import static org.apache.sqoop.json.util.FormSerialization.ID;
-import static org.apache.sqoop.json.util.FormSerialization.JOB_FORMS;
-import static org.apache.sqoop.json.util.FormSerialization.NAME;
-import static org.apache.sqoop.json.util.FormSerialization.VERSION;
-import static org.apache.sqoop.json.util.FormSerialization.extractForms;
-import static org.apache.sqoop.json.util.FormSerialization.restoreForms;
+import static org.apache.sqoop.json.util.ConfigSerialization.ALL;
+import static org.apache.sqoop.json.util.ConfigSerialization.CLASS;
+import static org.apache.sqoop.json.util.ConfigSerialization.ID;
+import static org.apache.sqoop.json.util.ConfigSerialization.CONNECTOR_JOB_CONFIG;
+import static org.apache.sqoop.json.util.ConfigSerialization.CONNECTOR_LINK_CONFIG;
+import static org.apache.sqoop.json.util.ConfigSerialization.NAME;
+import static org.apache.sqoop.json.util.ConfigSerialization.VERSION;
+import static org.apache.sqoop.json.util.ConfigSerialization.extractConfigList;
+import static org.apache.sqoop.json.util.ConfigSerialization.restoreConfigList;
import static org.apache.sqoop.json.util.ResourceBundleSerialization.CONNECTOR_CONFIGS;
import static org.apache.sqoop.json.util.ResourceBundleSerialization.extractResourceBundle;
import static org.apache.sqoop.json.util.ResourceBundleSerialization.restoreResourceBundle;
@@ -38,24 +38,28 @@ import java.util.ResourceBundle;
import java.util.Set;
import org.apache.sqoop.common.Direction;
-import org.apache.sqoop.model.MConnectionForms;
+import org.apache.sqoop.model.MConfig;
import org.apache.sqoop.model.MConnector;
-import org.apache.sqoop.model.MForm;
-import org.apache.sqoop.model.MJobForms;
+import org.apache.sqoop.model.MFromConfig;
+import org.apache.sqoop.model.MLinkConfig;
+import org.apache.sqoop.model.MToConfig;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
+/**
+ * Json representation of the connector object
+ *
+ */
public class ConnectorBean implements JsonBean {
private List<MConnector> connectors;
- private Map<Long, ResourceBundle> bundles;
+ private Map<Long, ResourceBundle> connectorConfigBundles;
// for "extract"
- public ConnectorBean(List<MConnector> connectors,
- Map<Long, ResourceBundle> bundles) {
+ public ConnectorBean(List<MConnector> connectors, Map<Long, ResourceBundle> bundles) {
this.connectors = connectors;
- this.bundles = bundles;
+ this.connectorConfigBundles = bundles;
}
// for "restore"
@@ -67,46 +71,46 @@ public class ConnectorBean implements JsonBean {
}
public Map<Long, ResourceBundle> getResourceBundles() {
- return bundles;
+ return connectorConfigBundles;
}
@SuppressWarnings("unchecked")
@Override
public JSONObject extract(boolean skipSensitive) {
- JSONArray array = new JSONArray();
+ JSONArray connectorArray = new JSONArray();
for (MConnector connector : connectors) {
- JSONObject object = new JSONObject();
-
- object.put(ID, connector.getPersistenceId());
- object.put(NAME, connector.getUniqueName());
- object.put(CLASS, connector.getClassName());
- object.put(VERSION, connector.getVersion());
-
- object.put(CON_FORMS, extractForms(connector.getConnectionForms().getForms(), skipSensitive));
- object.put(JOB_FORMS, new JSONObject());
- if (connector.getJobForms(Direction.FROM) != null) {
- ((JSONObject)object.get(JOB_FORMS)).put(
- Direction.FROM, extractForms(connector.getJobForms(Direction.FROM).getForms(), skipSensitive));
+ JSONObject connectorJsonObject = new JSONObject();
+
+ connectorJsonObject.put(ID, connector.getPersistenceId());
+ connectorJsonObject.put(NAME, connector.getUniqueName());
+ connectorJsonObject.put(CLASS, connector.getClassName());
+ connectorJsonObject.put(VERSION, connector.getVersion());
+ connectorJsonObject.put(CONNECTOR_LINK_CONFIG,
+ extractConfigList(connector.getLinkConfig().getConfigs(), skipSensitive));
+
+ connectorJsonObject.put(CONNECTOR_JOB_CONFIG, new JSONObject());
+ // add sub fields to the job config for from and to
+ if (connector.getFromConfig() != null) {
+ ((JSONObject) connectorJsonObject.get(CONNECTOR_JOB_CONFIG)).put(Direction.FROM,
+ extractConfigList(connector.getFromConfig().getConfigs(), skipSensitive));
}
-
- if (connector.getJobForms(Direction.TO) != null) {
- ((JSONObject)object.get(JOB_FORMS)).put(
- Direction.TO, extractForms(connector.getJobForms(Direction.TO).getForms(), skipSensitive));
+ if (connector.getToConfig() != null) {
+ ((JSONObject) connectorJsonObject.get(CONNECTOR_JOB_CONFIG)).put(Direction.TO,
+ extractConfigList(connector.getToConfig().getConfigs(), skipSensitive));
}
- array.add(object);
+ connectorArray.add(connectorJsonObject);
}
JSONObject all = new JSONObject();
- all.put(ALL, array);
+ all.put(ALL, connectorArray);
- if(bundles != null && !bundles.isEmpty()) {
+ if (connectorConfigBundles != null && !connectorConfigBundles.isEmpty()) {
JSONObject jsonBundles = new JSONObject();
- for(Map.Entry<Long, ResourceBundle> entry : bundles.entrySet()) {
- jsonBundles.put(entry.getKey().toString(),
- extractResourceBundle(entry.getValue()));
+ for (Map.Entry<Long, ResourceBundle> entry : connectorConfigBundles.entrySet()) {
+ jsonBundles.put(entry.getKey().toString(), extractResourceBundle(entry.getValue()));
}
all.put(CONNECTOR_CONFIGS, jsonBundles);
}
@@ -129,35 +133,42 @@ public class ConnectorBean implements JsonBean {
String className = (String) object.get(CLASS);
String version = (String) object.get(VERSION);
- MJobForms fromJob = null;
- MJobForms toJob = null;
- List<MForm> connForms = restoreForms((JSONArray) object.get(CON_FORMS));
- JSONObject jobJson = (JSONObject) object.get(JOB_FORMS);
- JSONArray fromJobJson = (JSONArray)jobJson.get(Direction.FROM.name());
- JSONArray toJobJson = (JSONArray)jobJson.get(Direction.TO.name());
- if (fromJobJson != null) {
- List<MForm> fromJobForms = restoreForms(fromJobJson);
- fromJob = new MJobForms(fromJobForms);
+ List<MConfig> linkConfigs = restoreConfigList((JSONArray) object.get(CONNECTOR_LINK_CONFIG));
+
+ // parent that encapsualtes both the from/to configs
+ JSONObject jobConfigJson = (JSONObject) object.get(CONNECTOR_JOB_CONFIG);
+ JSONArray fromJobConfigJson = (JSONArray) jobConfigJson.get(Direction.FROM.name());
+ JSONArray toJobConfigJson = (JSONArray) jobConfigJson.get(Direction.TO.name());
+
+ MFromConfig fromConfig = null;
+ MToConfig toConfig = null;
+ if (fromJobConfigJson != null) {
+
+ List<MConfig> fromJobConfig = restoreConfigList(fromJobConfigJson);
+ fromConfig = new MFromConfig(fromJobConfig);
+
}
- if (toJobJson != null) {
- List<MForm> toJobForms = restoreForms(toJobJson);
- toJob = new MJobForms(toJobForms);
+ if (toJobConfigJson != null) {
+ List<MConfig> toJobConfig = restoreConfigList(toJobConfigJson);
+ toConfig = new MToConfig(toJobConfig);
}
- MConnectionForms connection = new MConnectionForms(connForms);
- MConnector connector = new MConnector(uniqueName, className, version,
- connection, fromJob, toJob);
+
+ MLinkConfig linkConfig = new MLinkConfig(linkConfigs);
+ MConnector connector = new MConnector(uniqueName, className, version, linkConfig, fromConfig,
+ toConfig);
+
connector.setPersistenceId(connectorId);
connectors.add(connector);
}
- if(jsonObject.containsKey(CONNECTOR_CONFIGS)) {
- bundles = new HashMap<Long, ResourceBundle>();
+ if (jsonObject.containsKey(CONNECTOR_CONFIGS)) {
+ connectorConfigBundles = new HashMap<Long, ResourceBundle>();
JSONObject jsonBundles = (JSONObject) jsonObject.get(CONNECTOR_CONFIGS);
Set<Map.Entry<String, JSONObject>> entrySet = jsonBundles.entrySet();
for (Map.Entry<String, JSONObject> entry : entrySet) {
- bundles.put(Long.parseLong(entry.getKey()),
- restoreResourceBundle(entry.getValue()));
+ connectorConfigBundles.put(Long.parseLong(entry.getKey()),
+ restoreResourceBundle(entry.getValue()));
}
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/json/DriverBean.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/json/DriverBean.java b/common/src/main/java/org/apache/sqoop/json/DriverBean.java
new file mode 100644
index 0000000..90cdbef
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/json/DriverBean.java
@@ -0,0 +1,90 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.json;
+
+import static org.apache.sqoop.json.util.ConfigSerialization.DRIVER_CONFIG;
+import static org.apache.sqoop.json.util.ConfigSerialization.DRIVER_VERSION;
+import static org.apache.sqoop.json.util.ConfigSerialization.ID;
+import static org.apache.sqoop.json.util.ConfigSerialization.extractConfigList;
+import static org.apache.sqoop.json.util.ConfigSerialization.restoreConfigList;
+import static org.apache.sqoop.json.util.ResourceBundleSerialization.CONFIGS;
+import static org.apache.sqoop.json.util.ResourceBundleSerialization.extractResourceBundle;
+import static org.apache.sqoop.json.util.ResourceBundleSerialization.restoreResourceBundle;
+
+import java.util.List;
+import java.util.ResourceBundle;
+
+import org.apache.sqoop.model.MConfig;
+import org.apache.sqoop.model.MDriver;
+import org.apache.sqoop.model.MDriverConfig;
+import org.json.simple.JSONArray;
+import org.json.simple.JSONObject;
+/**
+ * Json representation of the driver
+ *
+ */
+public class DriverBean implements JsonBean {
+
+ public static final String CURRENT_DRIVER_VERSION = "1";
+
+ private MDriver driver;
+
+ private ResourceBundle bundle;
+
+ // for "extract"
+ public DriverBean(MDriver driver, ResourceBundle bundle) {
+ this.driver = driver;
+ this.bundle = bundle;
+ }
+
+ // for "restore"
+ public DriverBean() {
+ }
+
+ public MDriver getDriver() {
+ return driver;
+ }
+
+ public ResourceBundle getDriverConfigResourceBundle() {
+ return bundle;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public JSONObject extract(boolean skipSensitive) {
+ JSONArray configs =
+ extractConfigList(driver.getDriverConfig().getConfigs(), skipSensitive);
+
+ JSONObject result = new JSONObject();
+ result.put(ID, driver.getPersistenceId());
+ result.put(DRIVER_VERSION, driver.getVersion());
+ result.put(DRIVER_CONFIG, configs);
+ result.put(CONFIGS, extractResourceBundle(bundle));
+ return result;
+ }
+
+ @Override
+ public void restore(JSONObject jsonObject) {
+ long id = (Long) jsonObject.get(ID);
+ String driverVersion = (String) jsonObject.get(DRIVER_VERSION);
+ List<MConfig> driverConfig = restoreConfigList((JSONArray) jsonObject.get(DRIVER_CONFIG));
+ driver = new MDriver(new MDriverConfig(driverConfig), driverVersion);
+ driver.setPersistenceId(id);
+ bundle = restoreResourceBundle((JSONObject) jsonObject.get(CONFIGS));
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/json/DriverConfigBean.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/json/DriverConfigBean.java b/common/src/main/java/org/apache/sqoop/json/DriverConfigBean.java
deleted file mode 100644
index a2cc8b8..0000000
--- a/common/src/main/java/org/apache/sqoop/json/DriverConfigBean.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.json;
-
-import org.apache.sqoop.model.MConnectionForms;
-import org.apache.sqoop.model.MForm;
-import org.apache.sqoop.model.MDriverConfig;
-import org.apache.sqoop.model.MJobForms;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-
-import java.util.List;
-import java.util.ResourceBundle;
-
-import static org.apache.sqoop.json.util.FormSerialization.*;
-import static org.apache.sqoop.json.util.ResourceBundleSerialization.*;
-
-public class DriverConfigBean implements JsonBean {
-
- private MDriverConfig driverConfig;
-
- private ResourceBundle bundle;
-
- // for "extract"
- public DriverConfigBean(MDriverConfig driverConfig, ResourceBundle bundle) {
- this.driverConfig = driverConfig;
- this.bundle = bundle;
- }
-
- // for "restore"
- public DriverConfigBean() {
- }
-
- public MDriverConfig getDriverConfig() {
- return driverConfig;
- }
-
- public ResourceBundle getResourceBundle() {
- return bundle;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public JSONObject extract(boolean skipSensitive) {
- // TODO(Abe): Add From/To connection forms.
- JSONArray conForms =
- extractForms(driverConfig.getConnectionForms().getForms(), skipSensitive);
- JSONArray jobForms = extractForms(driverConfig.getJobForms().getForms(), skipSensitive);
-
- JSONObject result = new JSONObject();
- result.put(ID, driverConfig.getPersistenceId());
- result.put(DRIVER_VERSION, driverConfig.getVersion());
- result.put(CON_FORMS, conForms);
- result.put(JOB_FORMS, jobForms);
- result.put(CONFIGS, extractResourceBundle(bundle));
- return result;
- }
-
- @Override
- public void restore(JSONObject jsonObject) {
- long id = (Long) jsonObject.get(ID);
- String driverVersion = (String) jsonObject.get(DRIVER_VERSION);
-
- List<MForm> connForms = restoreForms((JSONArray) jsonObject.get(CON_FORMS));
- List<MForm> jobForms = restoreForms((JSONArray) jsonObject.get(JOB_FORMS));
-
- // TODO(Abe): Get From/To connection forms.
- driverConfig = new MDriverConfig(
- new MConnectionForms(connForms),
- new MJobForms(jobForms),
- driverVersion);
- driverConfig.setPersistenceId(id);
-
- bundle = restoreResourceBundle((JSONObject) jsonObject.get(CONFIGS));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/json/JobBean.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/json/JobBean.java b/common/src/main/java/org/apache/sqoop/json/JobBean.java
index a3e6071..8f42edb 100644
--- a/common/src/main/java/org/apache/sqoop/json/JobBean.java
+++ b/common/src/main/java/org/apache/sqoop/json/JobBean.java
@@ -17,12 +17,17 @@
*/
package org.apache.sqoop.json;
-import org.apache.sqoop.common.Direction;
-import org.apache.sqoop.model.MForm;
-import org.apache.sqoop.model.MJob;
-import org.apache.sqoop.model.MJobForms;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
+import static org.apache.sqoop.json.util.ConfigSerialization.CREATION_DATE;
+import static org.apache.sqoop.json.util.ConfigSerialization.CREATION_USER;
+import static org.apache.sqoop.json.util.ConfigSerialization.ENABLED;
+import static org.apache.sqoop.json.util.ConfigSerialization.UPDATE_DATE;
+import static org.apache.sqoop.json.util.ConfigSerialization.UPDATE_USER;
+import static org.apache.sqoop.json.util.ConfigSerialization.extractConfigList;
+import static org.apache.sqoop.json.util.ConfigSerialization.restoreConfigList;
+import static org.apache.sqoop.json.util.ResourceBundleSerialization.CONNECTOR_CONFIGS;
+import static org.apache.sqoop.json.util.ResourceBundleSerialization.DRIVER_CONFIGS;
+import static org.apache.sqoop.json.util.ResourceBundleSerialization.extractResourceBundle;
+import static org.apache.sqoop.json.util.ResourceBundleSerialization.restoreResourceBundle;
import java.util.ArrayList;
import java.util.Date;
@@ -32,11 +37,18 @@ import java.util.Map;
import java.util.ResourceBundle;
import java.util.Set;
-import static org.apache.sqoop.json.util.FormSerialization.*;
-import static org.apache.sqoop.json.util.ResourceBundleSerialization.*;
+import org.apache.sqoop.common.Direction;
+import org.apache.sqoop.model.MConfig;
+import org.apache.sqoop.model.MDriver;
+import org.apache.sqoop.model.MDriverConfig;
+import org.apache.sqoop.model.MFromConfig;
+import org.apache.sqoop.model.MJob;
+import org.apache.sqoop.model.MToConfig;
+import org.json.simple.JSONArray;
+import org.json.simple.JSONObject;
/**
- *
+ * Json representation of the job config
*/
public class JobBean implements JsonBean {
@@ -47,9 +59,9 @@ public class JobBean implements JsonBean {
private static final String TO_LINK_ID = "to-link-id";
private static final String FROM_CONNECTOR_ID = "from-connector-id";
private static final String TO_CONNECTOR_ID = "to-connector-id";
- private static final String FROM_CONNECTOR_PART = "from-connector";
- private static final String TO_CONNECTOR_PART = "to-connector";
- private static final String FRAMEWORK_PART = "framework";
+ private static final String FROM_CONFIG = "from-config";
+ private static final String TO_CONFIG = "to-config";
+ private static final String DRIVER_CONFIG = "driver-config";
// Required
private List<MJob> jobs;
@@ -114,18 +126,21 @@ public class JobBean implements JsonBean {
object.put(CREATION_DATE, job.getCreationDate().getTime());
object.put(UPDATE_USER, job.getLastUpdateUser());
object.put(UPDATE_DATE, job.getLastUpdateDate().getTime());
- object.put(FROM_LINK_ID, job.getLinkId(Direction.FROM));
- object.put(TO_LINK_ID, job.getLinkId(Direction.TO));
+ // job link associated connectors
object.put(FROM_CONNECTOR_ID, job.getConnectorId(Direction.FROM));
object.put(TO_CONNECTOR_ID, job.getConnectorId(Direction.TO));
- object.put(FROM_CONNECTOR_PART,
- extractForms(job.getConnectorPart(Direction.FROM).getForms(),skipSensitive));
- object.put(TO_CONNECTOR_PART,
- extractForms(job.getConnectorPart(Direction.TO).getForms(), skipSensitive));
- object.put(FRAMEWORK_PART,
- extractForms(job.getFrameworkPart().getForms(), skipSensitive));
-
- array.add(object);
+ // job associated links
+ object.put(FROM_LINK_ID, job.getLinkId(Direction.FROM));
+ object.put(TO_LINK_ID, job.getLinkId(Direction.TO));
+ // job configs
+ object.put(FROM_CONFIG, extractConfigList(job
+ .getJobConfig(Direction.FROM).getConfigs(), skipSensitive));
+ object.put(TO_CONFIG,
+ extractConfigList(job.getJobConfig(Direction.TO).getConfigs(), skipSensitive));
+ object.put(DRIVER_CONFIG,
+ extractConfigList(job.getDriverConfig().getConfigs(), skipSensitive));
+
+ array.add(object);
}
JSONObject all = new JSONObject();
@@ -160,22 +175,22 @@ public class JobBean implements JsonBean {
long toConnectorId = (Long) object.get(TO_CONNECTOR_ID);
long fromConnectionId = (Long) object.get(FROM_LINK_ID);
long toConnectionId = (Long) object.get(TO_LINK_ID);
- JSONArray fromConnectorPart = (JSONArray) object.get(FROM_CONNECTOR_PART);
- JSONArray toConnectorPart = (JSONArray) object.get(TO_CONNECTOR_PART);
- JSONArray frameworkPart = (JSONArray) object.get(FRAMEWORK_PART);
+ JSONArray fromConfigJson = (JSONArray) object.get(FROM_CONFIG);
+ JSONArray toConfigJson = (JSONArray) object.get(TO_CONFIG);
+ JSONArray driverConfigJson = (JSONArray) object.get(DRIVER_CONFIG);
- List<MForm> fromConnectorParts = restoreForms(fromConnectorPart);
- List<MForm> toConnectorParts = restoreForms(toConnectorPart);
- List<MForm> frameworkForms = restoreForms(frameworkPart);
+ List<MConfig> fromConfig = restoreConfigList(fromConfigJson);
+ List<MConfig> toConfig = restoreConfigList(toConfigJson);
+ List<MConfig> driverConfig = restoreConfigList(driverConfigJson);
MJob job = new MJob(
fromConnectorId,
toConnectorId,
fromConnectionId,
toConnectionId,
- new MJobForms(fromConnectorParts),
- new MJobForms(toConnectorParts),
- new MJobForms(frameworkForms)
+ new MFromConfig(fromConfig),
+ new MToConfig(toConfig),
+ new MDriverConfig(driverConfig)
);
job.setPersistenceId((Long) object.get(ID));
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/json/JobValidationBean.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/json/JobValidationBean.java b/common/src/main/java/org/apache/sqoop/json/JobValidationBean.java
index 34c0a4b..9e78fe9 100644
--- a/common/src/main/java/org/apache/sqoop/json/JobValidationBean.java
+++ b/common/src/main/java/org/apache/sqoop/json/JobValidationBean.java
@@ -21,41 +21,41 @@ import org.apache.sqoop.common.Direction;
import org.apache.sqoop.common.DirectionError;
import org.apache.sqoop.common.SqoopException;
import org.apache.sqoop.validation.Status;
-import org.apache.sqoop.validation.Validation;
+import org.apache.sqoop.validation.ConfigValidator;
import org.json.simple.JSONObject;
import java.util.HashMap;
import java.util.Map;
/**
- * Bean for sending validations across network. This bean will move two
- * validation objects at one time - one for connector and second for framework
- * part of validated entity. Optionally validation bean can also transfer
+ * Bean for sending validations across network. This bean will send job validation results
+ * Optionally validation bean can also transfer
* created persistent id in case that new entity was created.
*/
public class JobValidationBean implements JsonBean {
private static final String ID = "id";
- private static final String FRAMEWORK = "framework";
- private static final String CONNECTOR = "connector";
+ private static final String JOB = "job";
private static final String FROM = "from";
private static final String TO = "to";
+ private static final String DRIVER = "driver";
+
private static final String STATUS = "status";
private static final String MESSAGE = "message";
private static final String MESSAGES = "messages";
private Long id;
- private Validation fromConnectorValidation;
- private Validation toConnectorValidation;
- private Validation frameworkValidation;
+ private ConfigValidator fromConfigValidation;
+ private ConfigValidator toConfigValidation;
+ private ConfigValidator driverConfigValidation;
// For "extract"
- public JobValidationBean(Validation fromConnector, Validation framework, Validation toConnector) {
+ public JobValidationBean(ConfigValidator fromConnector, ConfigValidator framework, ConfigValidator toConnector) {
this();
- this.fromConnectorValidation = fromConnector;
- this.toConnectorValidation = toConnector;
- this.frameworkValidation = framework;
+ this.fromConfigValidation = fromConnector;
+ this.toConfigValidation = toConnector;
+ this.driverConfigValidation = framework;
}
// For "restore"
@@ -63,21 +63,21 @@ public class JobValidationBean implements JsonBean {
id = null;
}
- public Validation getConnectorValidation(Direction type) {
+ public ConfigValidator getConnectorValidation(Direction type) {
switch(type) {
case FROM:
- return fromConnectorValidation;
+ return fromConfigValidation;
case TO:
- return toConnectorValidation;
+ return toConfigValidation;
default:
throw new SqoopException(DirectionError.DIRECTION_0000, "Direction: " + type);
}
}
- public Validation getFrameworkValidation() {
- return frameworkValidation;
+ public ConfigValidator getFrameworkValidation() {
+ return driverConfigValidation;
}
public void setId(Long id) {
@@ -91,32 +91,30 @@ public class JobValidationBean implements JsonBean {
@SuppressWarnings("unchecked")
public JSONObject extract(boolean skipSensitive) {
JSONObject object = new JSONObject();
- JSONObject connectorObject = new JSONObject();
+ JSONObject jobObject = new JSONObject();
// Optionally transfer id
if(id != null) {
object.put(ID, id);
}
- connectorObject.put(FROM, extractValidation(getConnectorValidation(Direction.FROM)));
- connectorObject.put(TO, extractValidation(getConnectorValidation(Direction.TO)));
-
- object.put(FRAMEWORK, extractValidation(frameworkValidation));
- object.put(CONNECTOR, connectorObject);
-
+ jobObject.put(FROM, extractValidation(getConnectorValidation(Direction.FROM)));
+ jobObject.put(TO, extractValidation(getConnectorValidation(Direction.TO)));
+ jobObject.put(DRIVER, extractValidation(driverConfigValidation));
+ object.put(JOB, jobObject);
return object;
}
@SuppressWarnings("unchecked")
- private JSONObject extractValidation(Validation validation) {
+ private JSONObject extractValidation(ConfigValidator validation) {
JSONObject object = new JSONObject();
object.put(STATUS, validation.getStatus().name());
JSONObject jsonMessages = new JSONObject();
- Map<Validation.FormInput, Validation.Message> messages = validation.getMessages();
+ Map<ConfigValidator.ConfigInput, ConfigValidator.Message> messages = validation.getMessages();
- for(Map.Entry<Validation.FormInput, Validation.Message> entry : messages.entrySet()) {
+ for(Map.Entry<ConfigValidator.ConfigInput, ConfigValidator.Message> entry : messages.entrySet()) {
JSONObject jsonEntry = new JSONObject();
jsonEntry.put(STATUS, entry.getValue().getStatus().name());
jsonEntry.put(MESSAGE, entry.getValue().getMessage());
@@ -133,20 +131,21 @@ public class JobValidationBean implements JsonBean {
// Optional and accepting NULLs
id = (Long) jsonObject.get(ID);
- JSONObject jsonConnectorObject = (JSONObject)jsonObject.get(CONNECTOR);
+ JSONObject jobJsonObject = (JSONObject)jsonObject.get(JOB);
- fromConnectorValidation = restoreValidation(
- (JSONObject)jsonConnectorObject.get(FROM));
- toConnectorValidation = restoreValidation(
- (JSONObject)jsonConnectorObject.get(TO));
- frameworkValidation = restoreValidation(
- (JSONObject)jsonObject.get(FRAMEWORK));
+ fromConfigValidation = restoreValidation(
+ (JSONObject)jobJsonObject.get(FROM));
+ toConfigValidation = restoreValidation(
+ (JSONObject)jobJsonObject.get(TO));
+ driverConfigValidation = restoreValidation(
+ (JSONObject)jobJsonObject.get(DRIVER));
}
- public Validation restoreValidation(JSONObject jsonObject) {
+ public ConfigValidator restoreValidation(JSONObject jsonObject) {
+
JSONObject jsonMessages = (JSONObject) jsonObject.get(MESSAGES);
- Map<Validation.FormInput, Validation.Message> messages
- = new HashMap<Validation.FormInput, Validation.Message>();
+ Map<ConfigValidator.ConfigInput, ConfigValidator.Message> messages
+ = new HashMap<ConfigValidator.ConfigInput, ConfigValidator.Message>();
for(Object key : jsonMessages.keySet()) {
JSONObject jsonMessage = (JSONObject) jsonMessages.get(key);
@@ -154,14 +153,14 @@ public class JobValidationBean implements JsonBean {
Status status = Status.valueOf((String) jsonMessage.get(STATUS));
String stringMessage = (String) jsonMessage.get(MESSAGE);
- Validation.Message message
- = new Validation.Message(status, stringMessage);
+ ConfigValidator.Message message
+ = new ConfigValidator.Message(status, stringMessage);
- messages.put(new Validation.FormInput((String)key), message);
+ messages.put(new ConfigValidator.ConfigInput((String)key), message);
}
Status status = Status.valueOf((String) jsonObject.get(STATUS));
- return new Validation(status, messages);
+ return new ConfigValidator(status, messages);
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/json/LinkBean.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/json/LinkBean.java b/common/src/main/java/org/apache/sqoop/json/LinkBean.java
index 8981ea7..af0fc9d 100644
--- a/common/src/main/java/org/apache/sqoop/json/LinkBean.java
+++ b/common/src/main/java/org/apache/sqoop/json/LinkBean.java
@@ -18,8 +18,8 @@
package org.apache.sqoop.json;
import org.apache.sqoop.model.MLink;
-import org.apache.sqoop.model.MConnectionForms;
-import org.apache.sqoop.model.MForm;
+import org.apache.sqoop.model.MLinkConfig;
+import org.apache.sqoop.model.MConfig;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
@@ -31,7 +31,7 @@ import java.util.Map;
import java.util.ResourceBundle;
import java.util.Set;
-import static org.apache.sqoop.json.util.FormSerialization.*;
+import static org.apache.sqoop.json.util.ConfigSerialization.*;
import static org.apache.sqoop.json.util.ResourceBundleSerialization.*;
/**
@@ -42,16 +42,14 @@ import static org.apache.sqoop.json.util.ResourceBundleSerialization.*;
*/
public class LinkBean implements JsonBean {
- private static final String CONNECTOR_ID = "connector-id";
- private static final String CONNECTOR_PART = "connector";
- private static final String FRAMEWORK_PART = "framework";
+ static final String CONNECTOR_ID = "connector-id";
+ static final String LINK_CONFIG = "link-config";
// Required
private List<MLink> links;
// Optional
- private Map<Long, ResourceBundle> connectorConfigBundles;
- private ResourceBundle driverConfigBundle;
+ private Map<Long, ResourceBundle> linkConfigBundles;
// For "extract"
public LinkBean(MLink link) {
@@ -67,72 +65,56 @@ public class LinkBean implements JsonBean {
// For "restore"
public LinkBean() {
- connectorConfigBundles = new HashMap<Long, ResourceBundle>();
- }
-
- public void setDriverConfigBundle(ResourceBundle driverConfigBundle) {
- this.driverConfigBundle = driverConfigBundle;
+ linkConfigBundles = new HashMap<Long, ResourceBundle>();
}
public void addConnectorConfigBundle(Long id, ResourceBundle connectorConfigBundle) {
- connectorConfigBundles.put(id, connectorConfigBundle);
+ linkConfigBundles.put(id, connectorConfigBundle);
}
- public boolean hasConnectorBundle(Long id) {
- return connectorConfigBundles.containsKey(id);
+ public boolean hasConnectorConfigBundle(Long id) {
+ return linkConfigBundles.containsKey(id);
}
public List<MLink> getLinks() {
return links;
}
- public ResourceBundle getConnectorBundle(Long id) {
- return connectorConfigBundles.get(id);
- }
-
- public ResourceBundle getFrameworkBundle() {
- return driverConfigBundle;
+ public ResourceBundle getConnectorConfigBundle(Long id) {
+ return linkConfigBundles.get(id);
}
@Override
@SuppressWarnings("unchecked")
public JSONObject extract(boolean skipSensitive) {
- JSONArray array = new JSONArray();
+ JSONArray linkArray = new JSONArray();
for(MLink link : links) {
- JSONObject object = new JSONObject();
-
- object.put(ID, link.getPersistenceId());
- object.put(NAME, link.getName());
- object.put(ENABLED, link.getEnabled());
- object.put(CREATION_USER, link.getCreationUser());
- object.put(CREATION_DATE, link.getCreationDate().getTime());
- object.put(UPDATE_USER, link.getLastUpdateUser());
- object.put(UPDATE_DATE, link.getLastUpdateDate().getTime());
- object.put(CONNECTOR_ID, link.getConnectorId());
- object.put(CONNECTOR_PART,
- extractForms(link.getConnectorPart().getForms(), skipSensitive));
- object.put(FRAMEWORK_PART,
- extractForms(link.getFrameworkPart().getForms(), skipSensitive));
-
- array.add(object);
+ JSONObject linkJsonObject = new JSONObject();
+
+ linkJsonObject.put(ID, link.getPersistenceId());
+ linkJsonObject.put(NAME, link.getName());
+ linkJsonObject.put(ENABLED, link.getEnabled());
+ linkJsonObject.put(CREATION_USER, link.getCreationUser());
+ linkJsonObject.put(CREATION_DATE, link.getCreationDate().getTime());
+ linkJsonObject.put(UPDATE_USER, link.getLastUpdateUser());
+ linkJsonObject.put(UPDATE_DATE, link.getLastUpdateDate().getTime());
+ linkJsonObject.put(CONNECTOR_ID, link.getConnectorId());
+ linkJsonObject.put(LINK_CONFIG,
+ extractConfigList(link.getConnectorLinkConfig().getConfigs(), skipSensitive));
+
+ linkArray.add(linkJsonObject);
}
JSONObject all = new JSONObject();
- all.put(ALL, array);
-
- if(!connectorConfigBundles.isEmpty()) {
+ all.put(ALL, linkArray);
+ if (!linkConfigBundles.isEmpty()) {
JSONObject bundles = new JSONObject();
-
- for(Map.Entry<Long, ResourceBundle> entry : connectorConfigBundles.entrySet()) {
- bundles.put(entry.getKey().toString(),
- extractResourceBundle(entry.getValue()));
+ for (Map.Entry<Long, ResourceBundle> entry : linkConfigBundles.entrySet()) {
+ bundles.put(entry.getKey().toString(), extractResourceBundle(entry.getValue()));
}
all.put(CONNECTOR_CONFIGS, bundles);
}
- if(driverConfigBundle != null) {
- all.put(DRIVER_CONFIGS,extractResourceBundle(driverConfigBundle));
- }
return all;
}
@@ -147,15 +129,11 @@ public class LinkBean implements JsonBean {
JSONObject object = (JSONObject) obj;
long connectorId = (Long) object.get(CONNECTOR_ID);
- JSONArray connectorPart = (JSONArray) object.get(CONNECTOR_PART);
- JSONArray frameworkPart = (JSONArray) object.get(FRAMEWORK_PART);
+ JSONArray connectorLinkConfig = (JSONArray) object.get(LINK_CONFIG);
- List<MForm> connectorForms = restoreForms(connectorPart);
- List<MForm> frameworkForms = restoreForms(frameworkPart);
+ List<MConfig> linkConfig = restoreConfigList(connectorLinkConfig);
- MLink link = new MLink(connectorId,
- new MConnectionForms(connectorForms),
- new MConnectionForms(frameworkForms));
+ MLink link = new MLink(connectorId, new MLinkConfig(linkConfig));
link.setPersistenceId((Long) object.get(ID));
link.setName((String) object.get(NAME));
@@ -172,13 +150,9 @@ public class LinkBean implements JsonBean {
JSONObject bundles = (JSONObject) jsonObject.get(CONNECTOR_CONFIGS);
Set<Map.Entry<String, JSONObject>> entrySet = bundles.entrySet();
for (Map.Entry<String, JSONObject> entry : entrySet) {
- connectorConfigBundles.put(Long.parseLong(entry.getKey()),
+ linkConfigBundles.put(Long.parseLong(entry.getKey()),
restoreResourceBundle(entry.getValue()));
}
}
- if(jsonObject.containsKey(DRIVER_CONFIGS)) {
- driverConfigBundle = restoreResourceBundle(
- (JSONObject) jsonObject.get(DRIVER_CONFIGS));
- }
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/json/LinkValidationBean.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/json/LinkValidationBean.java b/common/src/main/java/org/apache/sqoop/json/LinkValidationBean.java
index a6a6b65..682f63b 100644
--- a/common/src/main/java/org/apache/sqoop/json/LinkValidationBean.java
+++ b/common/src/main/java/org/apache/sqoop/json/LinkValidationBean.java
@@ -18,37 +18,32 @@
package org.apache.sqoop.json;
import org.apache.sqoop.validation.Status;
-import org.apache.sqoop.validation.Validation;
+import org.apache.sqoop.validation.ConfigValidator;
import org.json.simple.JSONObject;
import java.util.HashMap;
import java.util.Map;
/**
- * Bean for sending validations across network. This bean will move two
- * validation objects at one time - one for connector and second for framework
- * part of validated entity. Optionally validation bean can also transfer
+ * Bean for sending validations across network.This bean will transfer link config
+ * validation results. Optionally validation bean can also transfer
* created persistent id in case that new entity was created.
*/
public class LinkValidationBean implements JsonBean {
private static final String ID = "id";
- private static final String FRAMEWORK = "framework";
- private static final String CONNECTOR = "connector";
private static final String STATUS = "status";
private static final String MESSAGE = "message";
private static final String MESSAGES = "messages";
private Long id;
- private Validation connectorValidation;
- private Validation frameworkValidation;
+ private ConfigValidator linkConfigValidation;
// For "extract"
- public LinkValidationBean(Validation connector, Validation framework) {
+ public LinkValidationBean(ConfigValidator linkConfigValidator) {
this();
- this.connectorValidation = connector;
- this.frameworkValidation = framework;
+ this.linkConfigValidation = linkConfigValidator;
}
// For "restore"
@@ -56,12 +51,8 @@ public class LinkValidationBean implements JsonBean {
id = null;
}
- public Validation getConnectorValidation() {
- return connectorValidation;
- }
-
- public Validation getFrameworkValidation() {
- return frameworkValidation;
+ public ConfigValidator getLinkConfigValidator() {
+ return linkConfigValidation;
}
public void setId(Long id) {
@@ -80,23 +71,20 @@ public class LinkValidationBean implements JsonBean {
if(id != null) {
object.put(ID, id);
}
-
- object.put(CONNECTOR, extractValidation(connectorValidation));
- object.put(FRAMEWORK, extractValidation(frameworkValidation));
-
+ object.put(LinkBean.LINK_CONFIG, extractValidation(linkConfigValidation));
return object;
}
@SuppressWarnings("unchecked")
- private JSONObject extractValidation(Validation validation) {
+ private JSONObject extractValidation(ConfigValidator validation) {
JSONObject object = new JSONObject();
object.put(STATUS, validation.getStatus().name());
JSONObject jsonMessages = new JSONObject();
- Map<Validation.FormInput, Validation.Message> messages = validation.getMessages();
+ Map<ConfigValidator.ConfigInput, ConfigValidator.Message> messages = validation.getMessages();
- for(Map.Entry<Validation.FormInput, Validation.Message> entry : messages.entrySet()) {
+ for(Map.Entry<ConfigValidator.ConfigInput, ConfigValidator.Message> entry : messages.entrySet()) {
JSONObject jsonEntry = new JSONObject();
jsonEntry.put(STATUS, entry.getValue().getStatus().name());
jsonEntry.put(MESSAGE, entry.getValue().getMessage());
@@ -113,16 +101,14 @@ public class LinkValidationBean implements JsonBean {
// Optional and accepting NULLs
id = (Long) jsonObject.get(ID);
- connectorValidation = restoreValidation(
- (JSONObject)jsonObject.get(CONNECTOR));
- frameworkValidation = restoreValidation(
- (JSONObject)jsonObject.get(FRAMEWORK));
+ linkConfigValidation = restoreValidation(
+ (JSONObject)jsonObject.get(LinkBean.LINK_CONFIG));
}
- public Validation restoreValidation(JSONObject jsonObject) {
+ public ConfigValidator restoreValidation(JSONObject jsonObject) {
JSONObject jsonMessages = (JSONObject) jsonObject.get(MESSAGES);
- Map<Validation.FormInput, Validation.Message> messages
- = new HashMap<Validation.FormInput, Validation.Message>();
+ Map<ConfigValidator.ConfigInput, ConfigValidator.Message> messages
+ = new HashMap<ConfigValidator.ConfigInput, ConfigValidator.Message>();
for(Object key : jsonMessages.keySet()) {
JSONObject jsonMessage = (JSONObject) jsonMessages.get(key);
@@ -130,14 +116,14 @@ public class LinkValidationBean implements JsonBean {
Status status = Status.valueOf((String) jsonMessage.get(STATUS));
String stringMessage = (String) jsonMessage.get(MESSAGE);
- Validation.Message message
- = new Validation.Message(status, stringMessage);
+ ConfigValidator.Message message
+ = new ConfigValidator.Message(status, stringMessage);
- messages.put(new Validation.FormInput((String)key), message);
+ messages.put(new ConfigValidator.ConfigInput((String)key), message);
}
Status status = Status.valueOf((String) jsonObject.get(STATUS));
- return new Validation(status, messages);
+ return new ConfigValidator(status, messages);
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/json/ThrowableBean.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/json/ThrowableBean.java b/common/src/main/java/org/apache/sqoop/json/ThrowableBean.java
index fc63ed4..cd26020 100644
--- a/common/src/main/java/org/apache/sqoop/json/ThrowableBean.java
+++ b/common/src/main/java/org/apache/sqoop/json/ThrowableBean.java
@@ -26,7 +26,7 @@ import java.util.LinkedList;
import java.util.List;
/**
- * Transfer throwable instance.
+ * Transfer throwable instance as a throwable bean.
*/
public class ThrowableBean implements JsonBean {
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/json/ValidationResultBean.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/json/ValidationResultBean.java b/common/src/main/java/org/apache/sqoop/json/ValidationResultBean.java
index 89bc8db..4b3fc37 100644
--- a/common/src/main/java/org/apache/sqoop/json/ValidationResultBean.java
+++ b/common/src/main/java/org/apache/sqoop/json/ValidationResultBean.java
@@ -19,7 +19,7 @@ package org.apache.sqoop.json;
import org.apache.sqoop.validation.Message;
import org.apache.sqoop.validation.Status;
-import org.apache.sqoop.validation.ValidationResult;
+import org.apache.sqoop.validation.ConfigValidationResult;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
@@ -38,18 +38,18 @@ public class ValidationResultBean implements JsonBean {
private static final String STATUS = "STATUS";
private static final String TEXT = "TEXT";
- private ValidationResult[] results;
+ private ConfigValidationResult[] results;
private Long id;
public ValidationResultBean() {
// Empty, for restore
}
- public ValidationResultBean(ValidationResult ... results) {
+ public ValidationResultBean(ConfigValidationResult ... results) {
this.results = results;
}
- public ValidationResult[] getValidationResults() {
+ public ConfigValidationResult[] getValidationResults() {
return results;
}
@@ -65,7 +65,7 @@ public class ValidationResultBean implements JsonBean {
public JSONObject extract(boolean skipSensitive) {
JSONArray array = new JSONArray();
- for(ValidationResult result : results) {
+ for(ConfigValidationResult result : results) {
JSONObject output = extractValidationResult(result);
array.add(output);
}
@@ -78,7 +78,7 @@ public class ValidationResultBean implements JsonBean {
return object;
}
- private JSONObject extractValidationResult(ValidationResult result) {
+ private JSONObject extractValidationResult(ConfigValidationResult result) {
JSONObject ret = new JSONObject();
for(Map.Entry<String, List<Message>> entry : result.getMessages().entrySet()) {
@@ -110,7 +110,7 @@ public class ValidationResultBean implements JsonBean {
@Override
public void restore(JSONObject jsonObject) {
JSONArray array = (JSONArray) jsonObject.get(ROOT);
- results = new ValidationResult[array.size()];
+ results = new ConfigValidationResult[array.size()];
int i = 0;
for(Object item : array) {
@@ -122,8 +122,8 @@ public class ValidationResultBean implements JsonBean {
}
}
- private ValidationResult restoreValidationResult(JSONObject item) {
- ValidationResult result = new ValidationResult();
+ private ConfigValidationResult restoreValidationResult(JSONObject item) {
+ ConfigValidationResult result = new ConfigValidationResult();
Set<Map.Entry<String, JSONArray>> entrySet = item.entrySet();
for(Map.Entry<String, JSONArray> entry : entrySet) {
[11/13] SQOOP-1498: Sqoop2: Repository Object refactoring (objects
prefixed with M)
Posted by ab...@apache.org.
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/model/MDriverConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MDriverConfig.java b/common/src/main/java/org/apache/sqoop/model/MDriverConfig.java
index 62eb197..679859a 100644
--- a/common/src/main/java/org/apache/sqoop/model/MDriverConfig.java
+++ b/common/src/main/java/org/apache/sqoop/model/MDriverConfig.java
@@ -17,29 +17,23 @@
*/
package org.apache.sqoop.model;
-/**
- * Describes the configs associated with the {@link Driver} for executing sqoop jobs.
- */
-public class MDriverConfig extends MPersistableEntity implements MClonable {
+import java.util.List;
- private final MConnectionForms connectionForms;
- private final MJobForms jobForms;
- String version;
+/**
+ * Config describing all required information for the driver
+ * NOTE: It extends a config list since {@link MToConfig} could consist of a related config groups
+ * In future this could be simplified to hold a single list of all configs for the driver
- public MDriverConfig(MConnectionForms connectionForms, MJobForms jobForms, String version) {
- this.connectionForms = connectionForms;
- this.jobForms = jobForms;
- this.version = version;
+ */
+public class MDriverConfig extends MConfigList {
+ public MDriverConfig(List<MConfig> configs) {
+ super(configs);
}
@Override
public String toString() {
- StringBuilder sb = new StringBuilder("driver-");
- sb.append(getPersistenceId()).append(":");
- sb.append("version = " + version);
- sb.append(", ").append(connectionForms.toString());
- sb.append(jobForms.toString());
-
+ StringBuilder sb = new StringBuilder("Driver:");
+ sb.append(super.toString());
return sb.toString();
}
@@ -53,45 +47,18 @@ public class MDriverConfig extends MPersistableEntity implements MClonable {
return false;
}
- MDriverConfig mo = (MDriverConfig) other;
- return version.equals(mo.getVersion()) &&
- connectionForms.equals(mo.connectionForms) &&
- jobForms.equals(mo.jobForms);
+ MDriverConfig mDriver = (MDriverConfig) other;
+ return super.equals(mDriver);
}
@Override
public int hashCode() {
- int result = connectionForms.hashCode();
- result = 31 * result + jobForms.hashCode();
- result = 31 * result + version.hashCode();
- return result;
- }
-
- public MConnectionForms getConnectionForms() {
- return connectionForms;
- }
-
- public MJobForms getJobForms() {
- return jobForms;
+ return super.hashCode();
}
@Override
public MDriverConfig clone(boolean cloneWithValue) {
- //Framework never have any values filled
- cloneWithValue = false;
- MDriverConfig copy = new MDriverConfig(this.getConnectionForms().clone(cloneWithValue),
- this.getJobForms().clone(cloneWithValue), this.version);
- copy.setPersistenceId(this.getPersistenceId());
+ MDriverConfig copy = new MDriverConfig(super.clone(cloneWithValue).getConfigs());
return copy;
}
-
- public String getVersion() {
- return version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
-}
-
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/model/MForm.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MForm.java b/common/src/main/java/org/apache/sqoop/model/MForm.java
deleted file mode 100644
index ff94660..0000000
--- a/common/src/main/java/org/apache/sqoop/model/MForm.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.model;
-
-import org.apache.sqoop.common.SqoopException;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Represents a group of inputs that are processed together. This allows the
- * input gathering process to be broken down into multiple steps that can be
- * then paged through by the user interface.
- */
-public final class MForm extends MValidatedElement implements MClonable {
-
- private final List<MInput<?>> inputs;
-
- public MForm(String name, List<MInput<?>> inputs) {
- super(name);
-
- this.inputs = inputs;
- }
-
- public List<MInput<?>> getInputs() {
- return inputs;
- }
-
- public MInput<?> getInput(String inputName) {
- for(MInput<?> input: inputs) {
- if(inputName.equals(input.getName())) {
- return input;
- }
- }
-
- throw new SqoopException(ModelError.MODEL_011, "Input name: " + inputName);
- }
-
- public MStringInput getStringInput(String inputName) {
- return (MStringInput)getInput(inputName);
- }
-
- public MEnumInput getEnumInput(String inputName) {
- return (MEnumInput)getInput(inputName);
- }
-
- public MIntegerInput getIntegerInput(String inputName) {
- return (MIntegerInput)getInput(inputName);
- }
-
- public MBooleanInput getBooleanInput(String inputName) {
- return (MBooleanInput)getInput(inputName);
- }
-
- public MMapInput getMapInput(String inputName) {
- return (MMapInput)getInput(inputName);
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder("form-").append(getName());
- sb.append(":").append(getPersistenceId()).append(":").append(inputs);
-
- return sb.toString();
- }
-
- @Override
- public boolean equals(Object other) {
- if (other == this) {
- return true;
- }
-
- if (!(other instanceof MForm)) {
- return false;
- }
-
- MForm mf = (MForm) other;
- return getName().equals(mf.getName())
- && inputs.equals(mf.inputs);
- }
-
- @Override
- public int hashCode() {
- int result = 17;
- result = 31 * result + getName().hashCode();
- for (MInput<?> mi : inputs) {
- result = 31 * result + mi.hashCode();
- }
-
- return result;
- }
-
- @Override
- public MForm clone(boolean cloneWithValue) {
- List<MInput<?>> copyInputs = new ArrayList<MInput<?>>();
- for(MInput<?> itr : this.getInputs()) {
- copyInputs.add((MInput<?>)itr.clone(cloneWithValue));
- }
- MForm copyForm = new MForm(this.getName(), copyInputs);
- return copyForm;
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/model/MFormList.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MFormList.java b/common/src/main/java/org/apache/sqoop/model/MFormList.java
deleted file mode 100644
index 9130ada..0000000
--- a/common/src/main/java/org/apache/sqoop/model/MFormList.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.model;
-
-import org.apache.sqoop.common.SqoopException;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Arbitrary list of forms.
- */
-public class MFormList implements MClonable {
-
- private final List<MForm> forms;
-
- public MFormList(List<MForm> forms) {
- this.forms = forms;
- }
-
- public List<MForm> getForms() {
- return forms;
- }
-
- public MForm getForm(String formName) {
- for(MForm form: forms) {
- if(formName.equals(form.getName())) {
- return form;
- }
- }
-
- throw new SqoopException(ModelError.MODEL_010, "Form name: " + formName);
- }
-
- public MInput getInput(String name) {
- String []parts = name.split("\\.");
- if(parts.length != 2) {
- throw new SqoopException(ModelError.MODEL_009, name);
- }
-
- return getForm(parts[0]).getInput(name);
- }
-
- public MStringInput getStringInput(String name) {
- return (MStringInput)getInput(name);
- }
-
- public MEnumInput getEnumInput(String name) {
- return (MEnumInput)getInput(name);
- }
-
- public MIntegerInput getIntegerInput(String name) {
- return (MIntegerInput)getInput(name);
- }
-
- public MMapInput getMapInput(String name) {
- return (MMapInput)getInput(name);
- }
-
- public MBooleanInput getBooleanInput(String name) {
- return (MBooleanInput)getInput(name);
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof MFormList)) return false;
-
- MFormList mFormList = (MFormList) o;
-
- if (!forms.equals(mFormList.forms)) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = super.hashCode();
- for(MForm form : forms) {
- result = 31 * result + form.hashCode();
- }
-
- return result;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder("Forms: ");
- for(MForm form : forms) {
- sb.append(form.toString());
- }
- return sb.toString();
- }
-
- @Override
- public MFormList clone(boolean cloneWithValue) {
- List<MForm> copyForms = null;
- if(this.getForms() != null) {
- copyForms = new ArrayList<MForm>();
- for(MForm itr : this.getForms()) {
- MForm newForm = itr.clone(cloneWithValue);
- newForm.setPersistenceId(itr.getPersistenceId());
- copyForms.add(newForm);
- }
- }
- MFormList copyFormList = new MFormList(copyForms);
- return copyFormList;
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/model/MFormType.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MFormType.java b/common/src/main/java/org/apache/sqoop/model/MFormType.java
deleted file mode 100644
index 2f403df..0000000
--- a/common/src/main/java/org/apache/sqoop/model/MFormType.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.model;
-
-/**
- * Represents the various form types supported by the system.
- */
-public enum MFormType {
-
- /** Unknown form type */
- OTHER,
-
- /** Connection form type */
- CONNECTION,
-
- /** Job form type */
- JOB;
-
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/model/MFromConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MFromConfig.java b/common/src/main/java/org/apache/sqoop/model/MFromConfig.java
new file mode 100644
index 0000000..1b450d6
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/model/MFromConfig.java
@@ -0,0 +1,64 @@
+/**
+ * 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.model;
+
+import java.util.List;
+
+/**
+ * Config describing all required information to build the FROM part of the job
+ * NOTE: It extends a config list since {@link MFromConfig} could consist of a related config groups
+ * In future this could be simplified to hold a single list of all configs for the FROM object
+
+ */
+public class MFromConfig extends MConfigList {
+ public MFromConfig(List<MConfig> configs) {
+ super(configs);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("From: ");
+ sb.append(super.toString());
+ return sb.toString();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ }
+
+ if (!(other instanceof MFromConfig)) {
+ return false;
+ }
+
+ MFromConfig mj = (MFromConfig) other;
+ return super.equals(mj);
+ }
+
+ @Override
+ public int hashCode() {
+ return super.hashCode();
+ }
+
+ @Override
+ public MFromConfig clone(boolean cloneWithValue) {
+ MFromConfig copy = new MFromConfig(super.clone(cloneWithValue).getConfigs());
+ return copy;
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/model/MJob.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MJob.java b/common/src/main/java/org/apache/sqoop/model/MJob.java
index c9b45a5..b3dec27 100644
--- a/common/src/main/java/org/apache/sqoop/model/MJob.java
+++ b/common/src/main/java/org/apache/sqoop/model/MJob.java
@@ -22,29 +22,23 @@ import org.apache.sqoop.common.DirectionError;
import org.apache.sqoop.common.SqoopException;
/**
- * Model describing entire job object including both connector and
- * framework part.
+ * Model describing entire job object including the from/to and driver config information
+ * to execute the job
*/
public class MJob extends MAccountableEntity implements MClonable {
/**
- * Connector reference.
- *
- * Job object do not immediately depend on connector as there is indirect
+ * NOTE : Job object do not immediately depend on connector as there is indirect
* dependency through link object, but having this dependency explicitly
- * carried along helps a lot.
+ * carried along helps with not having to make the DB call everytime
*/
private final long fromConnectorId;
private final long toConnectorId;
-
- /**
- * Corresponding link objects for connector.
- */
private final long fromLinkId;
private final long toLinkId;
- private final MJobForms fromConnectorPart;
- private final MJobForms toConnectorPart;
- private final MJobForms frameworkPart;
+ private final MFromConfig fromConfig;
+ private final MToConfig toConfig;
+ private final MDriverConfig driverConfig;
/**
* Default constructor to build new MJob model.
@@ -53,24 +47,24 @@ public class MJob extends MAccountableEntity implements MClonable {
* @param toConnectorId TO Connector id
* @param fromLinkId FROM Link id
* @param toLinkId TO Link id
- * @param fromPart FROM Connector forms
- * @param toPart TO Connector forms
- * @param frameworkPart Framework forms
+ * @param fromConfig FROM job config
+ * @param toConfig TO job config
+ * @param driverConfig driver config
*/
public MJob(long fromConnectorId,
long toConnectorId,
- long fromConnectionId,
- long toConnectionId,
- MJobForms fromPart,
- MJobForms toPart,
- MJobForms frameworkPart) {
+ long fromLinkId,
+ long toLinkId,
+ MFromConfig fromConfig,
+ MToConfig toConfig,
+ MDriverConfig driverConfig) {
this.fromConnectorId = fromConnectorId;
this.toConnectorId = toConnectorId;
- this.fromLinkId = fromConnectionId;
- this.toLinkId = toConnectionId;
- this.fromConnectorPart = fromPart;
- this.toConnectorPart = toPart;
- this.frameworkPart = frameworkPart;
+ this.fromLinkId = fromLinkId;
+ this.toLinkId = toLinkId;
+ this.fromConfig = fromConfig;
+ this.toConfig = toConfig;
+ this.driverConfig = driverConfig;
}
/**
@@ -80,9 +74,9 @@ public class MJob extends MAccountableEntity implements MClonable {
*/
public MJob(MJob other) {
this(other,
- other.getConnectorPart(Direction.FROM).clone(true),
- other.getConnectorPart(Direction.TO).clone(true),
- other.frameworkPart.clone(true));
+ other.getFromJobConfig().clone(true),
+ other.getToJobConfig().clone(true),
+ other.driverConfig.clone(true));
}
/**
@@ -92,29 +86,29 @@ public class MJob extends MAccountableEntity implements MClonable {
* used otherwise.
*
* @param other MJob model to copy
- * @param fromPart FROM Connector forms
- * @param toPart TO Connector forms
- * @param frameworkPart Framework forms
+ * @param fromConfig FROM Job config
+ * @param toConfig TO Job config
+ * @param driverConfig driverConfig
*/
- public MJob(MJob other, MJobForms fromPart, MJobForms toPart, MJobForms frameworkPart) {
+ public MJob(MJob other, MFromConfig fromConfig, MToConfig toConfig, MDriverConfig driverConfig) {
super(other);
this.fromConnectorId = other.getConnectorId(Direction.FROM);
this.toConnectorId = other.getConnectorId(Direction.TO);
this.fromLinkId = other.getLinkId(Direction.FROM);
this.toLinkId = other.getLinkId(Direction.TO);
- this.fromConnectorPart = fromPart;
- this.toConnectorPart = toPart;
- this.frameworkPart = frameworkPart;
+ this.fromConfig = fromConfig;
+ this.toConfig = toConfig;
+ this.driverConfig = driverConfig;
this.setPersistenceId(other.getPersistenceId());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("job");
- sb.append(" connector-from-part: ").append(getConnectorPart(Direction.FROM));
- sb.append(", connector-to-part: ").append(getConnectorPart(Direction.TO));
- sb.append(", framework-part: ").append(frameworkPart);
+ sb.append("From job config: ").append(getJobConfig(Direction.FROM));
+ sb.append(", To job config: ").append(getJobConfig(Direction.TO));
+ sb.append(", Driver config: ").append(driverConfig);
return sb.toString();
}
@@ -145,21 +139,29 @@ public class MJob extends MAccountableEntity implements MClonable {
}
}
- public MJobForms getConnectorPart(Direction type) {
+ public MConfigList getJobConfig(Direction type) {
switch(type) {
case FROM:
- return fromConnectorPart;
+ return fromConfig;
case TO:
- return toConnectorPart;
+ return toConfig;
default:
throw new SqoopException(DirectionError.DIRECTION_0000, "Direction: " + type);
}
}
- public MJobForms getFrameworkPart() {
- return frameworkPart;
+ public MFromConfig getFromJobConfig() {
+ return fromConfig;
+ }
+
+ public MToConfig getToJobConfig() {
+ return toConfig;
+ }
+
+ public MDriverConfig getDriverConfig() {
+ return driverConfig;
}
@Override
@@ -172,9 +174,9 @@ public class MJob extends MAccountableEntity implements MClonable {
getConnectorId(Direction.TO),
getLinkId(Direction.FROM),
getLinkId(Direction.TO),
- getConnectorPart(Direction.FROM).clone(false),
- getConnectorPart(Direction.TO).clone(false),
- frameworkPart.clone(false));
+ getFromJobConfig().clone(false),
+ getToJobConfig().clone(false),
+ getDriverConfig().clone(false));
}
}
@@ -194,8 +196,8 @@ public class MJob extends MAccountableEntity implements MClonable {
&& (job.getLinkId(Direction.FROM) == this.getLinkId(Direction.FROM))
&& (job.getLinkId(Direction.TO) == this.getLinkId(Direction.TO))
&& (job.getPersistenceId() == this.getPersistenceId())
- && (job.getConnectorPart(Direction.FROM).equals(this.getConnectorPart(Direction.FROM)))
- && (job.getConnectorPart(Direction.TO).equals(this.getConnectorPart(Direction.TO)))
- && (job.frameworkPart.equals(this.frameworkPart));
+ && (job.getFromJobConfig().equals(this.getJobConfig(Direction.FROM)))
+ && (job.getToJobConfig().equals(this.getJobConfig(Direction.TO)))
+ && (job.getDriverConfig().equals(this.driverConfig));
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/model/MJobForms.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MJobForms.java b/common/src/main/java/org/apache/sqoop/model/MJobForms.java
deleted file mode 100644
index 08b9a78..0000000
--- a/common/src/main/java/org/apache/sqoop/model/MJobForms.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.model;
-
-import java.util.List;
-
-/**
- * Metadata describing all required information to build a job
- * object with two connectors and a framework.
- */
-public class MJobForms extends MFormList {
- public MJobForms(List<MForm> forms) {
- super(forms);
- }
-
- @Override
- public boolean equals(Object other) {
- if (other == this) {
- return true;
- }
-
- if (!(other instanceof MJobForms)) {
- return false;
- }
-
- MJobForms mj = (MJobForms) other;
- return super.equals(mj);
- }
-
- @Override
- public int hashCode() {
- return super.hashCode();
- }
-
- @Override
- public MJobForms clone(boolean cloneWithValue) {
- MJobForms copy = new MJobForms(super.clone(cloneWithValue).getForms());
- return copy;
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/model/MLink.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MLink.java b/common/src/main/java/org/apache/sqoop/model/MLink.java
index 6a8c424..7a9f538 100644
--- a/common/src/main/java/org/apache/sqoop/model/MLink.java
+++ b/common/src/main/java/org/apache/sqoop/model/MLink.java
@@ -22,57 +22,49 @@ package org.apache.sqoop.model;
*/
public class MLink extends MAccountableEntity implements MClonable {
private long connectorId;
-
- private final MConnectionForms connectorPart;
- private final MConnectionForms frameworkPart;
+ // NOTE: we hold this in the model for easy access to the link config object, it might as well be retrieved on the fly using the connectorId
+ private final MLinkConfig connectorLinkConfig;
/**
- * Default constructor to build new MConnection model.
+ * Default constructor to build new MLink model.
*
* @param connectorId Connector id
- * @param connectorPart Connector forms
- * @param frameworkPart Framework forms
+ * @param linkConfig Connector forms
*/
- public MLink(long connectorId,
- MConnectionForms connectorPart,
- MConnectionForms frameworkPart) {
+ public MLink(long connectorId, MLinkConfig linkConfig) {
this.connectorId = connectorId;
- this.connectorPart = connectorPart;
- this.frameworkPart = frameworkPart;
+ this.connectorLinkConfig = linkConfig;
}
/**
- * Constructor to create deep copy of another MConnection model.
+ * Constructor to create deep copy of another MLink model.
*
- * @param other MConnection model to copy
+ * @param other MLink model to copy
*/
public MLink(MLink other) {
- this(other, other.connectorPart.clone(true), other.frameworkPart.clone(true));
+ this(other, other.connectorLinkConfig.clone(true));
}
/**
- * Construct new MConnection model as a copy of another with replaced forms.
+ * Construct new MLink model as a copy of another with replaced forms.
*
- * This method is suitable only for metadata upgrade path and should not be
+ * This method is suitable only for link upgrade path and should not be
* used otherwise.
*
- * @param other MConnection model to copy
- * @param connectorPart Connector forms
- * @param frameworkPart Framework forms
+ * @param other MLink model to copy
+ * @param linkConfig link config
*/
- public MLink(MLink other, MConnectionForms connectorPart, MConnectionForms frameworkPart) {
+ public MLink(MLink other, MLinkConfig linkConfig) {
super(other);
this.connectorId = other.connectorId;
- this.connectorPart = connectorPart;
- this.frameworkPart = frameworkPart;
+ this.connectorLinkConfig = linkConfig;
this.setPersistenceId(other.getPersistenceId());
}
@Override
public String toString() {
- StringBuilder sb = new StringBuilder("connection: ").append(getName());
- sb.append(" connector-part: ").append(connectorPart);
- sb.append(", framework-part: ").append(frameworkPart);
+ StringBuilder sb = new StringBuilder("link: ").append(getName());
+ sb.append(" link-config: ").append(connectorLinkConfig);
return sb.toString();
}
@@ -85,20 +77,11 @@ public class MLink extends MAccountableEntity implements MClonable {
this.connectorId = connectorId;
}
- public MConnectionForms getConnectorPart() {
- return connectorPart;
- }
-
- public MConnectionForms getFrameworkPart() {
- return frameworkPart;
- }
-
- public MForm getConnectorForm(String formName) {
- return connectorPart.getForm(formName);
+ public MLinkConfig getConnectorLinkConfig() {
+ return connectorLinkConfig;
}
-
- public MForm getFrameworkForm(String formName) {
- return frameworkPart.getForm(formName);
+ public MConfig getConnectorLinkConfig(String formName) {
+ return connectorLinkConfig.getConfig(formName);
}
@Override
@@ -106,7 +89,7 @@ public class MLink extends MAccountableEntity implements MClonable {
if(cloneWithValue) {
return new MLink(this);
} else {
- return new MLink(connectorId, connectorPart.clone(false), frameworkPart.clone(false));
+ return new MLink(connectorId, connectorLinkConfig.clone(false));
}
}
@@ -120,10 +103,9 @@ public class MLink extends MAccountableEntity implements MClonable {
return false;
}
- MLink mc = (MLink)object;
- return (mc.connectorId == this.connectorId)
- && (mc.getPersistenceId() == this.getPersistenceId())
- && (mc.connectorPart.equals(this.connectorPart))
- && (mc.frameworkPart.equals(this.frameworkPart));
- }
+ MLink mLink = (MLink)object;
+ return (mLink.connectorId == this.connectorId)
+ && (mLink.getPersistenceId() == this.getPersistenceId())
+ && (mLink.connectorLinkConfig.equals(this.connectorLinkConfig));
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/model/MLinkConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MLinkConfig.java b/common/src/main/java/org/apache/sqoop/model/MLinkConfig.java
new file mode 100644
index 0000000..318b63c
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/model/MLinkConfig.java
@@ -0,0 +1,54 @@
+/**
+ * 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.model;
+
+import java.util.List;
+
+/**
+ * Config describing all required information to build up an link object
+ * NOTE: It extends a config list since {@link MLink} could consist of a related config groups
+ * In future this could be simplified to hold a single list of all configs for the link object
+ */
+public class MLinkConfig extends MConfigList {
+
+ public MLinkConfig(List<MConfig> configs) {
+ super(configs);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("Link: ");
+ sb.append(super.toString());
+ return sb.toString();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ }
+
+ return super.equals(other);
+ }
+
+ @Override
+ public MLinkConfig clone(boolean cloneWithValue) {
+ MLinkConfig copy = new MLinkConfig(super.clone(cloneWithValue).getConfigs());
+ return copy;
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/model/MToConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MToConfig.java b/common/src/main/java/org/apache/sqoop/model/MToConfig.java
new file mode 100644
index 0000000..b4fbe41
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/model/MToConfig.java
@@ -0,0 +1,64 @@
+/**
+ * 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.model;
+
+import java.util.List;
+
+/**
+ * Config describing all required information to build the TO part of the job
+ * NOTE: It extends a config list since {@link MToConfig} could consist of a related config groups
+ * In future this could be simplified to hold a single list of all configs for the TO object
+
+ */
+public class MToConfig extends MConfigList {
+ public MToConfig(List<MConfig> configs) {
+ super(configs);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("To: ");
+ sb.append(super.toString());
+ return sb.toString();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ }
+
+ if (!(other instanceof MToConfig)) {
+ return false;
+ }
+
+ MToConfig mj = (MToConfig) other;
+ return super.equals(mj);
+ }
+
+ @Override
+ public int hashCode() {
+ return super.hashCode();
+ }
+
+ @Override
+ public MToConfig clone(boolean cloneWithValue) {
+ MToConfig copy = new MToConfig(super.clone(cloneWithValue).getConfigs());
+ return copy;
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/model/ModelError.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/ModelError.java b/common/src/main/java/org/apache/sqoop/model/ModelError.java
index 470b61c..6bb2c3b 100644
--- a/common/src/main/java/org/apache/sqoop/model/ModelError.java
+++ b/common/src/main/java/org/apache/sqoop/model/ModelError.java
@@ -24,7 +24,7 @@ import org.apache.sqoop.common.ErrorCode;
*/
public enum ModelError implements ErrorCode {
- MODEL_001("Attempt to pass two different set of MForms for single job type."),
+ MODEL_001("Attempt to pass two different set of MConfigs for single job type."),
MODEL_002("Creating MJob of different job types"),
@@ -34,7 +34,7 @@ public enum ModelError implements ErrorCode {
MODEL_005("Can't get field value"),
- MODEL_006("Incompatible form list and configuration object"),
+ MODEL_006("Incompatible config list and configuration object"),
MODEL_007("Primitive types in configuration objects are not allowed"),
@@ -42,7 +42,7 @@ public enum ModelError implements ErrorCode {
MODEL_009("Invalid input name"),
- MODEL_010("Form do not exist"),
+ MODEL_010("Config do not exist"),
MODEL_011("Input do not exist"),
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/utils/ClassUtils.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/utils/ClassUtils.java b/common/src/main/java/org/apache/sqoop/utils/ClassUtils.java
index eca9f7e..0be4d41 100644
--- a/common/src/main/java/org/apache/sqoop/utils/ClassUtils.java
+++ b/common/src/main/java/org/apache/sqoop/utils/ClassUtils.java
@@ -17,14 +17,12 @@
*/
package org.apache.sqoop.utils;
-import org.apache.log4j.Logger;
-
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
+
+import org.apache.log4j.Logger;
public final class ClassUtils {
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/validation/ConfigValidationError.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/validation/ConfigValidationError.java b/common/src/main/java/org/apache/sqoop/validation/ConfigValidationError.java
new file mode 100644
index 0000000..3453648
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/validation/ConfigValidationError.java
@@ -0,0 +1,52 @@
+/**
+ * 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.validation;
+
+import org.apache.sqoop.common.ErrorCode;
+
+/**
+ *
+ */
+public enum ConfigValidationError implements ErrorCode {
+
+ VALIDATION_0000("Unknown error"),
+
+ VALIDATION_0001("Missing class declaration."),
+
+ VALIDATION_0002("Usage of missing field"),
+
+ VALIDATION_0003("Invalid representation of config and input field"),
+
+ VALIDATION_0004("Can't find validator class"),
+
+ ;
+
+ private final String message;
+
+ private ConfigValidationError(String message) {
+ this.message = message;
+ }
+
+ public String getCode() {
+ return name();
+ }
+
+ public String getMessage() {
+ return message;
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/validation/ConfigValidationResult.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/validation/ConfigValidationResult.java b/common/src/main/java/org/apache/sqoop/validation/ConfigValidationResult.java
new file mode 100644
index 0000000..4c4d123
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/validation/ConfigValidationResult.java
@@ -0,0 +1,98 @@
+/**
+ * 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.validation;
+
+import org.apache.sqoop.validation.validators.AbstractValidator;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Result of validation execution.
+ */
+public class ConfigValidationResult {
+
+ /**
+ * All messages for each named item.
+ */
+ Map<String, List<Message>> messages;
+
+ /**
+ * Overall status.
+ */
+ Status status;
+
+ public ConfigValidationResult() {
+ messages = new HashMap<String, List<Message>>();
+ status = Status.getDefault();
+ }
+
+ /**
+ * Add given validator result to this instance.
+ *
+ * @param name Full name of the validated object
+ * @param validator Executed validator
+ */
+ public void addValidatorResult(String name, AbstractValidator<String> validator) {
+ if(validator.getStatus() == Status.getDefault()) {
+ return;
+ }
+
+ status = Status.getWorstStatus(status, validator.getStatus());
+ if(messages.containsKey(name)) {
+ messages.get(name).addAll(validator.getMessages());
+ } else {
+ messages.put(name, validator.getMessages());
+ }
+ }
+
+ /**
+ * Merge results with another validation result.
+ *
+ * @param result Other validation result
+ */
+ public void mergeValidatorResult(ConfigValidationResult result) {
+ messages.putAll(result.messages);
+ status = Status.getWorstStatus(status, result.status);
+ }
+
+ /**
+ * Method to directly add messages for given name.
+ *
+ * This method will replace previous messages for given name.
+ *
+ * @param name Name of the entity
+ * @param messages List of messages associated with the name
+ */
+ public void addMessages(String name, List<Message> messages) {
+ this.messages.put(name, messages);
+
+ for(Message message : messages) {
+ this.status = Status.getWorstStatus(status, message.getStatus());
+ }
+ }
+
+ public Status getStatus() {
+ return status;
+ }
+
+ public Map<String, List<Message>> getMessages() {
+ return messages;
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/validation/ConfigValidationRunner.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/validation/ConfigValidationRunner.java b/common/src/main/java/org/apache/sqoop/validation/ConfigValidationRunner.java
new file mode 100644
index 0000000..8c66b3d
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/validation/ConfigValidationRunner.java
@@ -0,0 +1,177 @@
+/**
+ * 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.validation;
+
+import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.model.ConfigurationClass;
+import org.apache.sqoop.model.Config;
+import org.apache.sqoop.model.ConfigClass;
+import org.apache.sqoop.model.ConfigUtils;
+import org.apache.sqoop.model.Input;
+import org.apache.sqoop.model.Validator;
+import org.apache.sqoop.utils.ClassUtils;
+import org.apache.sqoop.validation.validators.AbstractValidator;
+
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Validation runner that will run validators associated with given configuration
+ * class or config object.
+ *
+ * Execution follows following rules:
+ * * Run children first (Inputs -> Config -> Class)
+ * * If any children is not suitable (canProceed = false), skip running parent
+ *
+ * Which means that config validator don't have to repeat it's input validators as it will
+ * be never called if the input's are not valid. Similarly Class validators won't be called
+ * unless all configs will pass validators.
+ *
+ */
+public class ConfigValidationRunner {
+
+ /**
+ * Private cache of instantiated validators.
+ *
+ * We're expecting that this cache will be very small as the number of possible validators
+ * is driven to high extent by the number of connectors and hence we don't have a cache
+ * eviction at the moment.
+ */
+ private Map<Class<? extends AbstractValidator>, AbstractValidator> cache;
+
+ public ConfigValidationRunner() {
+ cache = new HashMap<Class<? extends AbstractValidator>, AbstractValidator>();
+ }
+
+ /**
+ * Validate given configuration instance.
+ *
+ * @param config Configuration instance
+ * @return
+ */
+ public ConfigValidationResult validate(Object config) {
+ ConfigValidationResult result = new ConfigValidationResult();
+ ConfigurationClass globalAnnotation = ConfigUtils.getConfigurationClassAnnotation(config, true);
+
+ // Iterate over all declared config and call their validators
+ for (Field field : config.getClass().getDeclaredFields()) {
+ field.setAccessible(true);
+
+ Config configAnnotation = ConfigUtils.getConfigAnnotation(field, false);
+ if(configAnnotation == null) {
+ continue;
+ }
+
+ String configName = ConfigUtils.getName(field, configAnnotation);
+ ConfigValidationResult r = validateConfig(configName, ConfigUtils.getFieldValue(field, config));
+ result.mergeValidatorResult(r);
+ }
+
+ // Call class validator only as long as we are in suitable state
+ if(result.getStatus().canProceed()) {
+ ConfigValidationResult r = validateArray("", config, globalAnnotation.validators());
+ result.mergeValidatorResult(r);
+ }
+
+ return result;
+ }
+
+ /**
+ * Validate given config instance.
+ *
+ * @param configName Config's name to build full name for all inputs.
+ * @param config Config instance
+ * @return
+ */
+ public ConfigValidationResult validateConfig(String configName, Object config) {
+ ConfigValidationResult result = new ConfigValidationResult();
+ ConfigClass configAnnotation = ConfigUtils.getConfigClassAnnotation(config, true);
+
+ // Iterate over all declared inputs and call their validators
+ for (Field field : config.getClass().getDeclaredFields()) {
+ Input inputAnnotation = ConfigUtils.getInputAnnotation(field, false);
+ if(inputAnnotation == null) {
+ continue;
+ }
+
+ String name = configName + "." + ConfigUtils.getName(field, inputAnnotation);
+
+ ConfigValidationResult r = validateArray(name, ConfigUtils.getFieldValue(field, config), inputAnnotation.validators());
+ result.mergeValidatorResult(r);
+ }
+
+ // Call config validator only as long as we are in suitable state
+ if(result.getStatus().canProceed()) {
+ ConfigValidationResult r = validateArray(configName, config, configAnnotation.validators());
+ result.mergeValidatorResult(r);
+ }
+
+ return result;
+ }
+
+ /**
+ * Execute array of validators on given object (can be input/config/class).
+ *
+ * @param name Full name of the object
+ * @param object Input, Config or Class instance
+ * @param validators Validators array
+ * @return
+ */
+ private ConfigValidationResult validateArray(String name, Object object, Validator[] validators) {
+ ConfigValidationResult result = new ConfigValidationResult();
+
+ for (Validator validator : validators) {
+ AbstractValidator v = executeValidator(object, validator);
+ result.addValidatorResult(name, v);
+ }
+
+ return result;
+ }
+
+ /**
+ * Execute single validator.
+ *
+ * @param object Input, Config or Class instance
+ * @param validator Validator annotation
+ * @return
+ */
+ private AbstractValidator executeValidator(Object object, Validator validator) {
+ // Try to get validator instance from the cache
+ AbstractValidator instance = cache.get(validator.value());
+
+ if(instance == null) {
+ instance = (AbstractValidator) ClassUtils.instantiate(validator.value());
+
+ // This could happen if we would be missing some connector's jars on our classpath
+ if(instance == null) {
+ throw new SqoopException(ConfigValidationError.VALIDATION_0004, validator.value().getName());
+ }
+
+ cache.put(validator.value(), instance);
+ } else {
+ instance.reset();
+ }
+
+ instance.setStringArgument(validator.strArg());
+ instance.validate(object);
+ return instance;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/validation/ConfigValidator.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/validation/ConfigValidator.java b/common/src/main/java/org/apache/sqoop/validation/ConfigValidator.java
new file mode 100644
index 0000000..eac789e
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/validation/ConfigValidator.java
@@ -0,0 +1,228 @@
+/**
+ * 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.validation;
+
+import org.apache.sqoop.common.SqoopException;
+
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Config validators.
+ *
+ * This class represents validations for the sqoop objects
+ */
+public class ConfigValidator {
+
+ // Configuration class that belongs to this validation
+ Class klass;
+
+ // Entire validation status
+ Status status;
+
+ // Status messages for various fields
+ Map<ConfigInput, Message> messages;
+
+ public ConfigValidator(Class klass) {
+ this.klass = klass;
+ status = Status.getDefault();
+ messages = new HashMap<ConfigInput, Message>();
+ }
+
+ public ConfigValidator(Status status, Map<ConfigInput, Message> messages) {
+ this.status = status;
+ this.messages = messages;
+ }
+
+ public Status getStatus() {
+ return status;
+ }
+
+ public Map<ConfigInput, Message> getMessages() {
+ return messages;
+ }
+
+ /**
+ * Add message to config.
+ *
+ * @param status Severity of the message
+ * @param config Config name, must be defined in the class
+ * @param message Validation message
+ */
+ public void addMessage(Status status, String config, String message) {
+ addMessage(status, config, null, message);
+ }
+
+ /**
+ * Add message to input in one of the configs.
+ *
+ * @param status Severity of the message
+ * @param config Config name, must be defined in the class
+ * @param input Field name, must be defined in the config class
+ * @param message Validation message
+ */
+ public void addMessage(Status status, String config, String input, String message ) {
+ if( klass == null) {
+ throw new SqoopException(ConfigValidationError.VALIDATION_0001);
+ }
+
+ assert config != null;
+ assert message != null;
+
+ // Field for specified config
+ Field configField;
+
+ // Load the config field and verify that it exists
+ try {
+ configField = klass.getDeclaredField(config);
+ } catch (NoSuchFieldException e) {
+ throw new SqoopException(ConfigValidationError.VALIDATION_0002,
+ "Can't get config " + config + " from " + klass.getName(), e);
+ }
+
+ // If this is config message, just save the message and continue
+ if(input == null) {
+ setMessage(status, config, input, message);
+ return;
+ }
+
+ // Verify that specified input exists on the config
+ try {
+ configField.getType().getDeclaredField(input);
+ } catch (NoSuchFieldException e) {
+ throw new SqoopException(ConfigValidationError.VALIDATION_0002,
+ "Can't get input " + input + " from config" + configField.getType().getName(), e);
+ }
+
+ setMessage(status, config, input, message);
+ }
+
+ private void setMessage(Status status, String config, String input, String message) {
+ this.status = Status.getWorstStatus(this.status, status);
+ messages.put(new ConfigInput(config, input), new Message(status, message));
+ }
+
+ public static class Message {
+ private Status status;
+ private String message;
+
+ public Message(Status status, String message) {
+ this.status = status;
+ this.message = message;
+ }
+
+ public Status getStatus() {
+ return status;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof Message)) return false;
+
+ Message message1 = (Message) o;
+
+ if (message != null ? !message.equals(message1.message) : message1.message != null)
+ return false;
+ if (status != message1.status) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = status != null ? status.hashCode() : 0;
+ result = 31 * result + (message != null ? message.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "{" + status.name() + ": " + message + "}";
+ }
+ }
+
+ public static class ConfigInput{
+ private String config;
+ private String input;
+
+ public ConfigInput(String config, String input) {
+ this.config = config;
+ this.input = input;
+ }
+
+ public ConfigInput(String configInput) {
+ assert configInput != null;
+ String []parts = configInput.split("\\.");
+
+ if(configInput.isEmpty() || (parts.length != 1 && parts.length != 2)) {
+ throw new SqoopException(ConfigValidationError.VALIDATION_0003,
+ "Specification " + configInput + " is not in valid configat config.input");
+ }
+
+ this.config = parts[0];
+ if(parts.length == 2) {
+ this.input = parts[1];
+ }
+ }
+
+ public String getConfig() {
+ return config;
+ }
+
+ public String getInput() {
+ return input;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ ConfigInput configInput = (ConfigInput) o;
+
+ if (config != null ? !config.equals(configInput.config) : configInput.config != null)
+ return false;
+ if (input != null ? !input.equals(configInput.input) : configInput.input != null)
+ return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = config != null ? config.hashCode() : 0;
+ result = 31 * result + (input != null ? input.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ if(input == null) {
+ return config;
+ }
+
+ return config + "." + input;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/validation/Message.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/validation/Message.java b/common/src/main/java/org/apache/sqoop/validation/Message.java
index cb55b6a..3361b6f 100644
--- a/common/src/main/java/org/apache/sqoop/validation/Message.java
+++ b/common/src/main/java/org/apache/sqoop/validation/Message.java
@@ -21,7 +21,7 @@ package org.apache.sqoop.validation;
* Validation message.
*
* Validation message have always two parts - severity and textual information about what
- * is wrong. It can be associated with Input, Form or Configuration class.
+ * is wrong. It can be associated with Input, Config or ConfigurationGroup class.
*/
public class Message {
private Status status;
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/validation/Validation.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/validation/Validation.java b/common/src/main/java/org/apache/sqoop/validation/Validation.java
deleted file mode 100644
index fce6e88..0000000
--- a/common/src/main/java/org/apache/sqoop/validation/Validation.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.validation;
-
-import org.apache.sqoop.common.SqoopException;
-
-import java.lang.reflect.Field;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Validation class.
- *
- * This class represents validations to given configuration object.
- */
-public class Validation {
-
- // Configuration class that belongs to this validation
- Class klass;
-
- // Entire validation status
- Status status;
-
- // Status messages for various fields
- Map<FormInput, Message> messages;
-
- public Validation(Class klass) {
- this.klass = klass;
- status = Status.getDefault();
- messages = new HashMap<FormInput, Message>();
- }
-
- public Validation(Status status, Map<FormInput, Message> messages) {
- this.status = status;
- this.messages = messages;
- }
-
- public Status getStatus() {
- return status;
- }
-
- public Map<FormInput, Message> getMessages() {
- return messages;
- }
-
- /**
- * Add message to form.
- *
- * @param status Severity of the message
- * @param form Form name, must be defined in the class
- * @param message Validation message
- */
- public void addMessage(Status status, String form, String message) {
- addMessage(status, form, null, message);
- }
-
- /**
- * Add message to input in one of the forms.
- *
- * @param status Severity of the message
- * @param form Form name, must be defined in the class
- * @param input Field name, must be defined in the form class
- * @param message Validation message
- */
- public void addMessage(Status status, String form, String input, String message ) {
- if( klass == null) {
- throw new SqoopException(ValidationError.VALIDATION_0001);
- }
-
- assert form != null;
- assert message != null;
-
- // Field for specified form
- Field formField;
-
- // Load the form field and verify that it exists
- try {
- formField = klass.getDeclaredField(form);
- } catch (NoSuchFieldException e) {
- throw new SqoopException(ValidationError.VALIDATION_0002,
- "Can't get form " + form + " from " + klass.getName(), e);
- }
-
- // If this is form message, just save the message and continue
- if(input == null) {
- setMessage(status, form, input, message);
- return;
- }
-
- // Verify that specified input exists on the form
- try {
- formField.getType().getDeclaredField(input);
- } catch (NoSuchFieldException e) {
- throw new SqoopException(ValidationError.VALIDATION_0002,
- "Can't get input " + input + " from form" + formField.getType().getName(), e);
- }
-
- setMessage(status, form, input, message);
- }
-
- private void setMessage(Status status, String form, String input, String message) {
- this.status = Status.getWorstStatus(this.status, status);
- messages.put(new FormInput(form, input), new Message(status, message));
- }
-
- public static class Message {
- private Status status;
- private String message;
-
- public Message(Status status, String message) {
- this.status = status;
- this.message = message;
- }
-
- public Status getStatus() {
- return status;
- }
-
- public String getMessage() {
- return message;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof Message)) return false;
-
- Message message1 = (Message) o;
-
- if (message != null ? !message.equals(message1.message) : message1.message != null)
- return false;
- if (status != message1.status) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = status != null ? status.hashCode() : 0;
- result = 31 * result + (message != null ? message.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString() {
- return "{" + status.name() + ": " + message + "}";
- }
- }
-
- public static class FormInput {
- private String form;
- private String input;
-
- public FormInput(String form, String input) {
- this.form = form;
- this.input = input;
- }
-
- public FormInput(String formInput) {
- assert formInput != null;
- String []parts = formInput.split("\\.");
-
- if(formInput.isEmpty() || (parts.length != 1 && parts.length != 2)) {
- throw new SqoopException(ValidationError.VALIDATION_0003,
- "Specification " + formInput + " is not in valid format form.input");
- }
-
- this.form = parts[0];
- if(parts.length == 2) {
- this.input = parts[1];
- }
- }
-
- public String getForm() {
- return form;
- }
-
- public String getInput() {
- return input;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- FormInput formInput = (FormInput) o;
-
- if (form != null ? !form.equals(formInput.form) : formInput.form != null)
- return false;
- if (input != null ? !input.equals(formInput.input) : formInput.input != null)
- return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = form != null ? form.hashCode() : 0;
- result = 31 * result + (input != null ? input.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString() {
- if(input == null) {
- return form;
- }
-
- return form + "." + input;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/validation/ValidationError.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/validation/ValidationError.java b/common/src/main/java/org/apache/sqoop/validation/ValidationError.java
deleted file mode 100644
index ec64f10..0000000
--- a/common/src/main/java/org/apache/sqoop/validation/ValidationError.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.validation;
-
-import org.apache.sqoop.common.ErrorCode;
-
-/**
- *
- */
-public enum ValidationError implements ErrorCode {
-
- VALIDATION_0000("Unknown error"),
-
- VALIDATION_0001("Missing class declaration."),
-
- VALIDATION_0002("Usage of missing field"),
-
- VALIDATION_0003("Invalid representation of form and input field"),
-
- VALIDATION_0004("Can't find validator class"),
-
- ;
-
- private final String message;
-
- private ValidationError(String message) {
- this.message = message;
- }
-
- public String getCode() {
- return name();
- }
-
- public String getMessage() {
- return message;
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/validation/ValidationResult.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/validation/ValidationResult.java b/common/src/main/java/org/apache/sqoop/validation/ValidationResult.java
deleted file mode 100644
index ae8f1d1..0000000
--- a/common/src/main/java/org/apache/sqoop/validation/ValidationResult.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.validation;
-
-import org.apache.sqoop.validation.validators.AbstractValidator;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Result of validation execution.
- */
-public class ValidationResult {
-
- /**
- * All messages for each named item.
- */
- Map<String, List<Message>> messages;
-
- /**
- * Overall status.
- */
- Status status;
-
- public ValidationResult() {
- messages = new HashMap<String, List<Message>>();
- status = Status.getDefault();
- }
-
- /**
- * Add given validator result to this instance.
- *
- * @param name Full name of the validated object
- * @param validator Executed validator
- */
- public void addValidator(String name, AbstractValidator validator) {
- if(validator.getStatus() == Status.getDefault()) {
- return;
- }
-
- status = Status.getWorstStatus(status, validator.getStatus());
- if(messages.containsKey(name)) {
- messages.get(name).addAll(validator.getMessages());
- } else {
- messages.put(name, validator.getMessages());
- }
- }
-
- /**
- * Merge results with another validation result.
- *
- * @param result Other validation result
- */
- public void merge(ValidationResult result) {
- messages.putAll(result.messages);
- status = Status.getWorstStatus(status, result.status);
- }
-
- /**
- * Method to directly add messages for given name.
- *
- * This method will replace previous messages for given name.
- *
- * @param name Name of the entity
- * @param messages List of messages associated with the name
- */
- public void addMessages(String name, List<Message> messages) {
- this.messages.put(name, messages);
-
- for(Message message : messages) {
- this.status = Status.getWorstStatus(status, message.getStatus());
- }
- }
-
- public Status getStatus() {
- return status;
- }
-
- public Map<String, List<Message>> getMessages() {
- return messages;
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/main/java/org/apache/sqoop/validation/ValidationRunner.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/validation/ValidationRunner.java b/common/src/main/java/org/apache/sqoop/validation/ValidationRunner.java
deleted file mode 100644
index 8ffc0d4..0000000
--- a/common/src/main/java/org/apache/sqoop/validation/ValidationRunner.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.validation;
-
-import org.apache.sqoop.common.SqoopException;
-import org.apache.sqoop.model.ConfigurationClass;
-import org.apache.sqoop.model.Form;
-import org.apache.sqoop.model.FormClass;
-import org.apache.sqoop.model.FormUtils;
-import org.apache.sqoop.model.Input;
-import org.apache.sqoop.model.Validator;
-import org.apache.sqoop.utils.ClassUtils;
-import org.apache.sqoop.validation.validators.AbstractValidator;
-
-import java.lang.reflect.Field;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Validation runner that will run validators associated with given configuration
- * class or form object.
- *
- * Execution follows following rules:
- * * Run children first (Inputs -> Form -> Class)
- * * If any children is not suitable (canProceed = false), skip running parent
- *
- * Which means that form validator don't have to repeat it's input validators as it will
- * be never called if the input's are not valid. Similarly Class validators won't be called
- * unless all forms will pass validators.
- */
-public class ValidationRunner {
-
- /**
- * Private cache of instantiated validators.
- *
- * We're expecting that this cache will be very small as the number of possible validators
- * is driven to high extent by the number of connectors and hence we don't have a cache
- * eviction at the moment.
- */
- private Map<Class<? extends AbstractValidator>, AbstractValidator> cache;
-
- public ValidationRunner() {
- cache = new HashMap<Class<? extends AbstractValidator>, AbstractValidator>();
- }
-
- /**
- * Validate given configuration instance.
- *
- * @param config Configuration instance
- * @return
- */
- public ValidationResult validate(Object config) {
- ValidationResult result = new ValidationResult();
- ConfigurationClass globalAnnotation = FormUtils.getConfigurationClassAnnotation(config, true);
-
- // Iterate over all declared form and call their validators
- for (Field field : config.getClass().getDeclaredFields()) {
- field.setAccessible(true);
-
- Form formAnnotation = FormUtils.getFormAnnotation(field, false);
- if(formAnnotation == null) {
- continue;
- }
-
- String formName = FormUtils.getName(field, formAnnotation);
- ValidationResult r = validateForm(formName, FormUtils.getFieldValue(field, config));
- result.merge(r);
- }
-
- // Call class validator only as long as we are in suitable state
- if(result.getStatus().canProceed()) {
- ValidationResult r = validateArray("", config, globalAnnotation.validators());
- result.merge(r);
- }
-
- return result;
- }
-
- /**
- * Validate given form instance.
- *
- * @param formName Form's name to build full name for all inputs.
- * @param form Form instance
- * @return
- */
- public ValidationResult validateForm(String formName, Object form) {
- ValidationResult result = new ValidationResult();
- FormClass formAnnotation = FormUtils.getFormClassAnnotation(form, true);
-
- // Iterate over all declared inputs and call their validators
- for (Field field : form.getClass().getDeclaredFields()) {
- Input inputAnnotation = FormUtils.getInputAnnotation(field, false);
- if(inputAnnotation == null) {
- continue;
- }
-
- String name = formName + "." + FormUtils.getName(field, inputAnnotation);
-
- ValidationResult r = validateArray(name, FormUtils.getFieldValue(field, form), inputAnnotation.validators());
- result.merge(r);
- }
-
- // Call form validator only as long as we are in suitable state
- if(result.getStatus().canProceed()) {
- ValidationResult r = validateArray(formName, form, formAnnotation.validators());
- result.merge(r);
- }
-
- return result;
- }
-
- /**
- * Execute array of validators on given object (can be input/form/class).
- *
- * @param name Full name of the object
- * @param object Input, Form or Class instance
- * @param validators Validators array
- * @return
- */
- private ValidationResult validateArray(String name, Object object, Validator[] validators) {
- ValidationResult result = new ValidationResult();
-
- for (Validator validator : validators) {
- AbstractValidator v = executeValidator(object, validator);
- result.addValidator(name, v);
- }
-
- return result;
- }
-
- /**
- * Execute single validator.
- *
- * @param object Input, Form or Class instance
- * @param validator Validator annotation
- * @return
- */
- private AbstractValidator executeValidator(Object object, Validator validator) {
- // Try to get validator instance from the cache
- AbstractValidator instance = cache.get(validator.value());
-
- if(instance == null) {
- instance = (AbstractValidator) ClassUtils.instantiate(validator.value());
-
- // This could happen if we would be missing some connector's jars on our classpath
- if(instance == null) {
- throw new SqoopException(ValidationError.VALIDATION_0004, validator.value().getName());
- }
-
- cache.put(validator.value(), instance);
- } else {
- instance.reset();
- }
-
- instance.setStringArgument(validator.strArg());
- instance.validate(object);
- return instance;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/json/ConfigTestUtil.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/ConfigTestUtil.java b/common/src/test/java/org/apache/sqoop/json/ConfigTestUtil.java
new file mode 100644
index 0000000..4372171
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/json/ConfigTestUtil.java
@@ -0,0 +1,217 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.json;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.ResourceBundle;
+
+import org.apache.sqoop.model.MConfig;
+import org.apache.sqoop.model.MConnector;
+import org.apache.sqoop.model.MDriver;
+import org.apache.sqoop.model.MDriverConfig;
+import org.apache.sqoop.model.MFromConfig;
+import org.apache.sqoop.model.MInput;
+import org.apache.sqoop.model.MIntegerInput;
+import org.apache.sqoop.model.MJob;
+import org.apache.sqoop.model.MLink;
+import org.apache.sqoop.model.MLinkConfig;
+import org.apache.sqoop.model.MStringInput;
+import org.apache.sqoop.model.MToConfig;
+import org.apache.sqoop.utils.MapResourceBundle;
+
+/**
+ *
+ */
+public class ConfigTestUtil {
+ public static MConnector getConnector(String name) {
+ return getConnector(name, true, true);
+ }
+
+ public static MConnector getConnector(String name, boolean from, boolean to) {
+ MFromConfig fromConfig = null;
+ MToConfig toConfig = null;
+ if (from) {
+ fromConfig = getFromConfig();
+ }
+ if (to) {
+ toConfig = getToConfig();
+ }
+ return new MConnector(name, name + ".class", "1.0-test",
+ getLinkConfig(), fromConfig, toConfig);
+ }
+
+
+ public static MLink getLink(String name) {
+ return new MLink(1, getConnector(name).getLinkConfig());
+ }
+
+ public static MJob getJob(String name) {
+ return new MJob(1, 2, 1, 2, getConnector(name).getFromConfig(), getConnector(name)
+ .getToConfig(), getDriverConfig());
+ }
+
+ public static MDriverConfig getDriverConfig() {
+ List<MInput<?>> inputs;
+ MIntegerInput input;
+ MConfig config;
+ List<MConfig> driverConfigs = new ArrayList<MConfig>();
+ inputs = new ArrayList<MInput<?>>();
+
+ input = new MIntegerInput("numExtractors", false);
+ input.setPersistenceId(1);
+ inputs.add(input);
+
+ input = new MIntegerInput("numLoaders", false);
+ input.setPersistenceId(2);
+ inputs.add(input);
+
+ config = new MConfig("driver", inputs);
+ config.setPersistenceId(10);
+ driverConfigs.add(config);
+ return new MDriverConfig(driverConfigs);
+ }
+
+ public static MLinkConfig getLinkConfig() {
+ List<MInput<?>> inputs;
+ MStringInput input;
+ MConfig config;
+ List<MConfig> linkConfig = new ArrayList<MConfig>();
+ inputs = new ArrayList<MInput<?>>();
+
+ input = new MStringInput("url", false, (short) 10);
+ input.setPersistenceId(1);
+ inputs.add(input);
+
+ input = new MStringInput("username", false, (short) 10);
+ input.setPersistenceId(2);
+ input.setValue("test");
+ inputs.add(input);
+
+ input = new MStringInput("password", true, (short) 10);
+ input.setPersistenceId(3);
+ input.setValue("test");
+ inputs.add(input);
+
+ config = new MConfig("connection", inputs);
+ config.setPersistenceId(10);
+ linkConfig.add(config);
+
+ return new MLinkConfig(linkConfig);
+ }
+
+ static MFromConfig getFromConfig() {
+ List<MInput<?>> inputs;
+ MStringInput input;
+ MConfig config;
+ List<MConfig> jobConfigs = new ArrayList<MConfig>();
+
+ inputs = new ArrayList<MInput<?>>();
+
+ input = new MStringInput("A", false, (short) 10);
+ input.setPersistenceId(4);
+ inputs.add(input);
+
+ input = new MStringInput("B", false, (short) 10);
+ input.setPersistenceId(5);
+ inputs.add(input);
+
+ input = new MStringInput("C", false, (short) 10);
+ input.setPersistenceId(6);
+ inputs.add(input);
+
+ config = new MConfig("Z", inputs);
+ config.setPersistenceId(11);
+ jobConfigs.add(config);
+
+ inputs = new ArrayList<MInput<?>>();
+
+ input = new MStringInput("D", false, (short) 10);
+ input.setPersistenceId(7);
+ inputs.add(input);
+
+ input = new MStringInput("E", false, (short) 10);
+ input.setPersistenceId(8);
+ inputs.add(input);
+
+ input = new MStringInput("F", false, (short) 10);
+ input.setPersistenceId(9);
+ inputs.add(input);
+
+ config = new MConfig("from-table", inputs);
+ config.setPersistenceId(12);
+ jobConfigs.add(config);
+
+ return new MFromConfig(jobConfigs);
+ }
+
+ static MToConfig getToConfig() {
+ List<MInput<?>> inputs;
+ MStringInput input;
+ MConfig config;
+ List<MConfig> jobConfigs = new ArrayList<MConfig>();
+
+ inputs = new ArrayList<MInput<?>>();
+
+ input = new MStringInput("A", false, (short) 10);
+ input.setPersistenceId(4);
+ inputs.add(input);
+
+ input = new MStringInput("B", false, (short) 10);
+ input.setPersistenceId(5);
+ inputs.add(input);
+
+ input = new MStringInput("C", false, (short) 10);
+ input.setPersistenceId(6);
+ inputs.add(input);
+
+ config = new MConfig("Z", inputs);
+ config.setPersistenceId(11);
+ jobConfigs.add(config);
+
+ inputs = new ArrayList<MInput<?>>();
+
+ input = new MStringInput("D", false, (short) 10);
+ input.setPersistenceId(7);
+ inputs.add(input);
+
+ input = new MStringInput("E", false, (short) 10);
+ input.setPersistenceId(8);
+ inputs.add(input);
+
+ input = new MStringInput("F", false, (short) 10);
+ input.setPersistenceId(9);
+ inputs.add(input);
+
+ config = new MConfig("to-table", inputs);
+ config.setPersistenceId(12);
+ jobConfigs.add(config);
+
+ return new MToConfig(jobConfigs);
+ }
+
+ public static ResourceBundle getResourceBundle() {
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("a", "a");
+ map.put("b", "b");
+
+ return new MapResourceBundle(map);
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/json/TestConnectorBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestConnectorBean.java b/common/src/test/java/org/apache/sqoop/json/TestConnectorBean.java
index fe75ee0..9fd2fe3 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestConnectorBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestConnectorBean.java
@@ -17,10 +17,9 @@
*/
package org.apache.sqoop.json;
-import org.apache.sqoop.model.MConnector;
-import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
-import org.junit.Test;
+import static org.apache.sqoop.json.ConfigTestUtil.getConnector;
+import static org.apache.sqoop.json.ConfigTestUtil.getResourceBundle;
+import static org.junit.Assert.*;
import java.util.HashMap;
import java.util.LinkedList;
@@ -28,8 +27,10 @@ import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
-import static org.apache.sqoop.json.TestUtil.*;
-import static org.junit.Assert.*;
+import org.apache.sqoop.model.MConnector;
+import org.json.simple.JSONObject;
+import org.json.simple.JSONValue;
+import org.junit.Test;
/**
*
@@ -48,26 +49,26 @@ public class TestConnectorBean {
connectors.add(getConnector("mysql"));
// Create testing bundles
- Map<Long, ResourceBundle> bundles = new HashMap<Long, ResourceBundle>();
- bundles.put(1L, getResourceBundle());
- bundles.put(2L, getResourceBundle());
+ Map<Long, ResourceBundle> configBundles = new HashMap<Long, ResourceBundle>();
+ configBundles.put(1L, getResourceBundle());
+ configBundles.put(2L, getResourceBundle());
// Serialize it to JSON object
- ConnectorBean bean = new ConnectorBean(connectors, bundles);
- JSONObject json = bean.extract(false);
+ ConnectorBean connectorBean = new ConnectorBean(connectors, configBundles);
+ JSONObject connectorJSON = connectorBean.extract(false);
// "Move" it across network in text form
- String string = json.toJSONString();
+ String connectorJSONString = connectorJSON.toJSONString();
// Retrieved transferred object
- JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
- ConnectorBean retrievedBean = new ConnectorBean();
- retrievedBean.restore(retrievedJson);
+ JSONObject parsedConnector = (JSONObject) JSONValue.parse(connectorJSONString);
+ ConnectorBean parsedConnectorBean = new ConnectorBean();
+ parsedConnectorBean.restore(parsedConnector);
- assertEquals(connectors.size(), retrievedBean.getConnectors().size());
- assertEquals(connectors.get(0), retrievedBean.getConnectors().get(0));
+ assertEquals(connectors.size(), parsedConnectorBean.getConnectors().size());
+ assertEquals(connectors.get(0), parsedConnectorBean.getConnectors().get(0));
- ResourceBundle retrievedBundle = retrievedBean.getResourceBundles().get(1L);
+ ResourceBundle retrievedBundle = parsedConnectorBean.getResourceBundles().get(1L);
assertNotNull(retrievedBundle);
assertEquals("a", retrievedBundle.getString("a"));
assertEquals("b", retrievedBundle.getString("b"));
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/json/TestDriverBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestDriverBean.java b/common/src/test/java/org/apache/sqoop/json/TestDriverBean.java
new file mode 100644
index 0000000..8c92aef
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/json/TestDriverBean.java
@@ -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.json;
+
+import static org.apache.sqoop.json.ConfigTestUtil.getResourceBundle;
+import static org.junit.Assert.assertEquals;
+
+import java.util.ResourceBundle;
+
+import org.apache.sqoop.model.MDriver;
+import org.json.simple.JSONObject;
+import org.json.simple.JSONValue;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class TestDriverBean {
+
+ /**
+ * Test that by JSON serialization followed by deserialization we will get
+ * equal drive config object.
+ */
+ @Test
+ public void testSerialization() {
+ MDriver driver = new MDriver(ConfigTestUtil.getDriverConfig(), DriverBean.CURRENT_DRIVER_VERSION);
+
+ // Serialize it to JSON object
+ DriverBean bean = new DriverBean(driver, getResourceBundle());
+ JSONObject json = bean.extract(false);
+
+ // "Move" it across network in text form
+ String string = json.toJSONString();
+
+ // Retrieved transferred object
+ JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
+ DriverBean retrievedBean = new DriverBean();
+ retrievedBean.restore(retrievedJson);
+
+ assertEquals(driver, retrievedBean.getDriver());
+
+ ResourceBundle retrievedBundle = retrievedBean.getDriverConfigResourceBundle();
+ assertEquals("a", retrievedBundle.getString("a"));
+ assertEquals("b", retrievedBundle.getString("b"));
+ }
+
+}
[10/13] SQOOP-1498: Sqoop2: Repository Object refactoring (objects
prefixed with M)
Posted by ab...@apache.org.
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/json/TestDriverConfigBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestDriverConfigBean.java b/common/src/test/java/org/apache/sqoop/json/TestDriverConfigBean.java
deleted file mode 100644
index fcce7b5..0000000
--- a/common/src/test/java/org/apache/sqoop/json/TestDriverConfigBean.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.json;
-
-import org.apache.sqoop.model.MDriverConfig;
-import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
-import org.junit.Test;
-
-import java.util.ResourceBundle;
-
-import static org.apache.sqoop.json.TestUtil.*;
-import static org.junit.Assert.*;
-
-/**
- *
- */
-public class TestDriverConfigBean {
-
- /**
- * Test that by JSON serialization followed by deserialization we will get
- * equal framework object.
- */
- @Test
- public void testSerialization() {
- MDriverConfig driverConfig = getDriverConfig();
-
- // Serialize it to JSON object
- DriverConfigBean bean = new DriverConfigBean(driverConfig, getResourceBundle());
- JSONObject json = bean.extract(false);
-
- // "Move" it across network in text form
- String string = json.toJSONString();
-
- // Retrieved transferred object
- JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
- DriverConfigBean retrievedBean = new DriverConfigBean();
- retrievedBean.restore(retrievedJson);
-
- assertEquals(driverConfig, retrievedBean.getDriverConfig());
-
- ResourceBundle retrievedBundle = retrievedBean.getResourceBundle();
- assertEquals("a", retrievedBundle.getString("a"));
- assertEquals("b", retrievedBundle.getString("b"));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/json/TestJobBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestJobBean.java b/common/src/test/java/org/apache/sqoop/json/TestJobBean.java
index 78a3420..1fc8dbd 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestJobBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestJobBean.java
@@ -17,6 +17,11 @@
*/
package org.apache.sqoop.json;
+import static org.apache.sqoop.json.ConfigTestUtil.getJob;
+import static org.junit.Assert.assertEquals;
+
+import java.util.Date;
+
import org.apache.sqoop.common.Direction;
import org.apache.sqoop.model.MJob;
import org.apache.sqoop.model.MStringInput;
@@ -25,11 +30,6 @@ import org.json.simple.JSONValue;
import org.json.simple.parser.ParseException;
import org.junit.Test;
-import java.util.Date;
-
-import static org.apache.sqoop.json.TestUtil.getJob;
-import static org.junit.Assert.assertEquals;
-
/**
*
*/
@@ -46,25 +46,25 @@ public class TestJobBean {
job.setEnabled(false);
// Fill some data at the beginning
- MStringInput input = (MStringInput) job.getConnectorPart(Direction.FROM)
- .getForms().get(0).getInputs().get(0);
+ MStringInput input = (MStringInput) job.getJobConfig(Direction.FROM)
+ .getConfigs().get(0).getInputs().get(0);
input.setValue("Hi there!");
- input = (MStringInput) job.getConnectorPart(Direction.TO)
- .getForms().get(0).getInputs().get(0);
+ input = (MStringInput) job.getJobConfig(Direction.TO)
+ .getConfigs().get(0).getInputs().get(0);
input.setValue("Hi there again!");
// Serialize it to JSON object
- JobBean bean = new JobBean(job);
- JSONObject json = bean.extract(false);
+ JobBean jobBean = new JobBean(job);
+ JSONObject jobJson = jobBean.extract(false);
// "Move" it across network in text form
- String string = json.toJSONString();
+ String jobJsonString = jobJson.toJSONString();
// Retrieved transferred object
- JSONObject retrievedJson = (JSONObject)JSONValue.parseWithException(string);
- JobBean retrievedBean = new JobBean();
- retrievedBean.restore(retrievedJson);
- MJob target = retrievedBean.getJobs().get(0);
+ JSONObject parsedJobJson = (JSONObject)JSONValue.parseWithException(jobJsonString);
+ JobBean parsedJobBean = new JobBean();
+ parsedJobBean.restore(parsedJobJson);
+ MJob target = parsedJobBean.getJobs().get(0);
// Check id and name
assertEquals(666, target.getPersistenceId());
@@ -78,11 +78,11 @@ public class TestJobBean {
assertEquals(false, target.getEnabled());
// Test that value was correctly moved
- MStringInput targetInput = (MStringInput) target.getConnectorPart(Direction.FROM)
- .getForms().get(0).getInputs().get(0);
+ MStringInput targetInput = (MStringInput) target.getJobConfig(Direction.FROM)
+ .getConfigs().get(0).getInputs().get(0);
assertEquals("Hi there!", targetInput.getValue());
- targetInput = (MStringInput) target.getConnectorPart(Direction.TO)
- .getForms().get(0).getInputs().get(0);
+ targetInput = (MStringInput) target.getJobConfig(Direction.TO)
+ .getConfigs().get(0).getInputs().get(0);
assertEquals("Hi there again!", targetInput.getValue());
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/json/TestLinkBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestLinkBean.java b/common/src/test/java/org/apache/sqoop/json/TestLinkBean.java
index 9ca6b64..ac07137 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestLinkBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestLinkBean.java
@@ -17,19 +17,21 @@
*/
package org.apache.sqoop.json;
+import static org.apache.sqoop.json.ConfigTestUtil.getLink;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Date;
+
+import org.apache.sqoop.json.util.ConfigSerialization;
import org.apache.sqoop.model.MLink;
import org.apache.sqoop.model.MStringInput;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
-import org.json.simple.JSONArray;
import org.json.simple.JSONValue;
import org.junit.Test;
-import java.util.Date;
-
-import static org.junit.Assert.*;
-import static org.apache.sqoop.json.TestUtil.*;
-
/**
*
*/
@@ -48,31 +50,31 @@ public class TestLinkBean {
link.setEnabled(false);
// Fill some data at the beginning
- MStringInput input = (MStringInput) link.getConnectorPart().getForms()
+ MStringInput input = (MStringInput) link.getConnectorLinkConfig().getConfigs()
.get(0).getInputs().get(0);
input.setValue("Hi there!");
// Serialize it to JSON object
- LinkBean bean = new LinkBean(link);
- JSONObject json = bean.extract(false);
+ LinkBean linkBean = new LinkBean(link);
+ JSONObject json = linkBean.extract(false);
// Check for sensitivity
- JSONArray all = (JSONArray)json.get("all");
+ JSONArray all = (JSONArray)json.get(ConfigSerialization.ALL);
JSONObject allItem = (JSONObject)all.get(0);
- JSONArray connectors = (JSONArray)allItem.get("connector");
+ JSONArray connectors = (JSONArray)allItem.get(LinkBean.LINK_CONFIG);
JSONObject connector = (JSONObject)connectors.get(0);
- JSONArray inputs = (JSONArray)connector.get("inputs");
+ JSONArray inputs = (JSONArray)connector.get(ConfigSerialization.CONFIG_INPUTS);
for (Object input1 : inputs) {
- assertTrue(((JSONObject)input1).containsKey("sensitive"));
+ assertTrue(((JSONObject)input1).containsKey(ConfigSerialization.CONFIG_INPUT_SENSITIVE));
}
// "Move" it across network in text form
- String string = json.toJSONString();
+ String linkJsonString = json.toJSONString();
// Retrieved transferred object
- JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
+ JSONObject parsedLinkJson = (JSONObject) JSONValue.parse(linkJsonString);
LinkBean retrievedBean = new LinkBean();
- retrievedBean.restore(retrievedJson);
+ retrievedBean.restore(parsedLinkJson);
MLink target = retrievedBean.getLinks().get(0);
// Check id and name
@@ -85,8 +87,8 @@ public class TestLinkBean {
assertEquals(false, target.getEnabled());
// Test that value was correctly moved
- MStringInput targetInput = (MStringInput) target.getConnectorPart()
- .getForms().get(0).getInputs().get(0);
+ MStringInput targetInput = (MStringInput) target.getConnectorLinkConfig()
+ .getConfigs().get(0).getInputs().get(0);
assertEquals("Hi there!", targetInput.getValue());
}
@@ -104,7 +106,7 @@ public class TestLinkBean {
link.setEnabled(true);
// Fill some data at the beginning
- MStringInput input = (MStringInput) link.getConnectorPart().getForms()
+ MStringInput input = (MStringInput) link.getConnectorLinkConfig().getConfigs()
.get(0).getInputs().get(0);
input.setValue("Hi there!");
@@ -114,25 +116,25 @@ public class TestLinkBean {
JSONObject jsonFiltered = bean.extract(true);
// Sensitive values should exist
- JSONArray all = (JSONArray)json.get("all");
+ JSONArray all = (JSONArray)json.get(ConfigSerialization.ALL);
JSONObject allItem = (JSONObject)all.get(0);
- JSONArray connectors = (JSONArray)allItem.get("connector");
+ JSONArray connectors = (JSONArray)allItem.get(LinkBean.LINK_CONFIG);
JSONObject connector = (JSONObject)connectors.get(0);
- JSONArray inputs = (JSONArray)connector.get("inputs");
+ JSONArray inputs = (JSONArray)connector.get(ConfigSerialization.CONFIG_INPUTS);
assertEquals(3, inputs.size());
// Inputs are ordered when creating link
JSONObject password = (JSONObject)inputs.get(2);
- assertTrue(password.containsKey("value"));
+ assertTrue(password.containsKey(ConfigSerialization.CONFIG_INPUT_VALUE));
// Sensitive values should not exist
- all = (JSONArray)jsonFiltered.get("all");
+ all = (JSONArray)jsonFiltered.get(ConfigSerialization.ALL);
allItem = (JSONObject)all.get(0);
- connectors = (JSONArray)allItem.get("connector");
+ connectors = (JSONArray)allItem.get(LinkBean.LINK_CONFIG);
connector = (JSONObject)connectors.get(0);
- inputs = (JSONArray)connector.get("inputs");
+ inputs = (JSONArray)connector.get(ConfigSerialization.CONFIG_INPUTS);
assertEquals(3, inputs.size());
// Inputs are ordered when creating link
password = (JSONObject)inputs.get(2);
- assertFalse(password.containsKey("value"));
+ assertFalse(password.containsKey(ConfigSerialization.CONFIG_INPUT_VALUE));
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/json/TestUtil.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestUtil.java b/common/src/test/java/org/apache/sqoop/json/TestUtil.java
deleted file mode 100644
index 9875219..0000000
--- a/common/src/test/java/org/apache/sqoop/json/TestUtil.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.json;
-
-import org.apache.sqoop.common.Direction;
-import org.apache.sqoop.model.MLink;
-import org.apache.sqoop.model.MConnectionForms;
-import org.apache.sqoop.model.MConnector;
-import org.apache.sqoop.model.MForm;
-import org.apache.sqoop.model.MDriverConfig;
-import org.apache.sqoop.model.MInput;
-import org.apache.sqoop.model.MJob;
-import org.apache.sqoop.model.MJobForms;
-import org.apache.sqoop.model.MStringInput;
-import org.apache.sqoop.utils.MapResourceBundle;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.ResourceBundle;
-
-/**
- *
- */
-public class TestUtil {
- public static MConnector getConnector(String name) {
- return getConnector(name, true, true);
- }
-
- public static MConnector getConnector(String name, boolean from, boolean to) {
- MJobForms fromJobForms = null;
- MJobForms toJobForms = null;
- if (from) {
- fromJobForms = getJobForms();
- }
- if (to) {
- toJobForms = getJobForms();
- }
- return new MConnector(name, name + ".class", "1.0-test",
- getConnectionForms(), fromJobForms, toJobForms);
- }
-
- public static MDriverConfig getDriverConfig() {
- return new MDriverConfig(getConnectionForms(), getJobForms(), "1");
- }
-
- public static MLink getLink(String name) {
- return new MLink(1, getConnector(name).getConnectionForms(), getDriverConfig()
- .getConnectionForms());
- }
-
- public static MJob getJob(String name) {
- return new MJob(1, 2, 1, 2, getConnector(name).getJobForms(Direction.FROM), getConnector(name)
- .getJobForms(Direction.TO), getDriverConfig().getJobForms());
- }
-
- public static MConnectionForms getConnectionForms() {
- List<MInput<?>> inputs;
- MStringInput input;
- MForm form;
- List<MForm> connectionForms = new ArrayList<MForm>();
- inputs = new ArrayList<MInput<?>>();
-
- input = new MStringInput("url", false, (short) 10);
- input.setPersistenceId(1);
- inputs.add(input);
-
- input = new MStringInput("username", false, (short) 10);
- input.setPersistenceId(2);
- input.setValue("test");
- inputs.add(input);
-
- input = new MStringInput("password", true, (short) 10);
- input.setPersistenceId(3);
- input.setValue("test");
- inputs.add(input);
-
- form = new MForm("connection", inputs);
- form.setPersistenceId(10);
- connectionForms.add(form);
-
- return new MConnectionForms(connectionForms);
- }
-
- public static MJobForms getJobForms() {
- List<MInput<?>> inputs;
- MStringInput input;
- MForm form;
- List<MForm> jobForms = new ArrayList<MForm>();
-
- inputs = new ArrayList<MInput<?>>();
-
- input = new MStringInput("A", false, (short) 10);
- input.setPersistenceId(4);
- inputs.add(input);
-
- input = new MStringInput("B", false, (short) 10);
- input.setPersistenceId(5);
- inputs.add(input);
-
- input = new MStringInput("C", false, (short) 10);
- input.setPersistenceId(6);
- inputs.add(input);
-
- form = new MForm("Z", inputs);
- form.setPersistenceId(11);
- jobForms.add(form);
-
- inputs = new ArrayList<MInput<?>>();
-
- input = new MStringInput("D", false, (short) 10);
- input.setPersistenceId(7);
- inputs.add(input);
-
- input = new MStringInput("E", false, (short) 10);
- input.setPersistenceId(8);
- inputs.add(input);
-
- input = new MStringInput("F", false, (short) 10);
- input.setPersistenceId(9);
- inputs.add(input);
-
- form = new MForm("connection", inputs);
- form.setPersistenceId(12);
- jobForms.add(form);
-
- return new MJobForms(jobForms);
- }
-
- public static ResourceBundle getResourceBundle() {
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("a", "a");
- map.put("b", "b");
-
- return new MapResourceBundle(map);
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/json/TestValidationBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestValidationBean.java b/common/src/test/java/org/apache/sqoop/json/TestValidationBean.java
index f5f3389..fc5b21d 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestValidationBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestValidationBean.java
@@ -17,18 +17,20 @@
*/
package org.apache.sqoop.json;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.sqoop.common.Direction;
+import org.apache.sqoop.validation.ConfigValidator;
import org.apache.sqoop.validation.Status;
-import org.apache.sqoop.validation.Validation;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
import org.junit.Test;
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.junit.Assert.*;
-
/**
*
*/
@@ -44,7 +46,7 @@ public class TestValidationBean {
);
JSONObject json = bean.extract(false);
- // "Move" it across network in text form
+ // "Move" it across network in text config
String string = json.toJSONString();
// Retrieved transferred object
@@ -54,43 +56,43 @@ public class TestValidationBean {
assertNull(retrievedBean.getId());
- Validation.FormInput fa = new Validation.FormInput("f", "i");
- Validation.FormInput fb = new Validation.FormInput("f2", "i2");
+ ConfigValidator.ConfigInput fa = new ConfigValidator.ConfigInput("c", "i");
+ ConfigValidator.ConfigInput fb = new ConfigValidator.ConfigInput("c2", "i2");
- Validation fromConnector = retrievedBean.getConnectorValidation(Direction.FROM);
+ ConfigValidator fromConnector = retrievedBean.getConnectorValidation(Direction.FROM);
assertEquals(Status.FINE, fromConnector.getStatus());
assertEquals(2, fromConnector.getMessages().size());
assertTrue(fromConnector.getMessages().containsKey(fa));
- assertEquals(new Validation.Message(Status.FINE, "d"),
+ assertEquals(new ConfigValidator.Message(Status.FINE, "d"),
fromConnector.getMessages().get(fa));
- Validation toConnector = retrievedBean.getConnectorValidation(Direction.TO);
+ ConfigValidator toConnector = retrievedBean.getConnectorValidation(Direction.TO);
assertEquals(Status.FINE, toConnector.getStatus());
assertEquals(2, toConnector.getMessages().size());
assertTrue(toConnector.getMessages().containsKey(fa));
- assertEquals(new Validation.Message(Status.FINE, "d"),
+ assertEquals(new ConfigValidator.Message(Status.FINE, "d"),
toConnector.getMessages().get(fa));
- Validation framework = retrievedBean.getFrameworkValidation();
+ ConfigValidator framework = retrievedBean.getFrameworkValidation();
assertEquals(Status.UNACCEPTABLE, framework.getStatus());
assertEquals(2, framework.getMessages().size());
assertTrue(framework.getMessages().containsKey(fb));
- assertEquals(new Validation.Message(Status.UNACCEPTABLE, "c"),
+ assertEquals(new ConfigValidator.Message(Status.UNACCEPTABLE, "c"),
framework.getMessages().get(fb));
}
@Test
public void testJobValidationBeanId() {
// Serialize it to JSON object
- JobValidationBean bean = new JobValidationBean(
+ JobValidationBean jobValidatioBean = new JobValidationBean(
getValidation(Status.FINE),
getValidation(Status.FINE),
getValidation(Status.FINE)
);
- bean.setId((long) 10);
- JSONObject json = bean.extract(false);
+ jobValidatioBean.setId((long) 10);
+ JSONObject json = jobValidatioBean.extract(false);
- // "Move" it across network in text form
+ // "Move" it across network in text config
String string = json.toJSONString();
// Retrieved transferred object
@@ -105,12 +107,10 @@ public class TestValidationBean {
public void testLinkValidationBeanSerialization() {
// Serialize it to JSON object
LinkValidationBean bean = new LinkValidationBean(
- getValidation(Status.FINE),
- getValidation(Status.UNACCEPTABLE)
- );
+ getValidation(Status.FINE));
JSONObject json = bean.extract(false);
- // "Move" it across network in text form
+ // "Move" it across network in text config
String string = json.toJSONString();
// Retrieved transferred object
@@ -120,35 +120,25 @@ public class TestValidationBean {
assertNull(retrievedBean.getId());
- Validation.FormInput fa = new Validation.FormInput("f", "i");
- Validation.FormInput fb = new Validation.FormInput("f2", "i2");
-
- Validation connector = retrievedBean.getConnectorValidation();
+ ConfigValidator.ConfigInput ca = new ConfigValidator.ConfigInput("c", "i");
+ ConfigValidator connector = retrievedBean.getLinkConfigValidator();
assertEquals(Status.FINE, connector.getStatus());
assertEquals(2, connector.getMessages().size());
- assertTrue(connector.getMessages().containsKey(fa));
- assertEquals(new Validation.Message(Status.FINE, "d"),
- connector.getMessages().get(fa));
-
- Validation framework = retrievedBean.getFrameworkValidation();
- assertEquals(Status.UNACCEPTABLE, framework.getStatus());
- assertEquals(2, framework.getMessages().size());
- assertTrue(framework.getMessages().containsKey(fb));
- assertEquals(new Validation.Message(Status.UNACCEPTABLE, "c"),
- framework.getMessages().get(fb));
+ assertTrue(connector.getMessages().containsKey(ca));
+ assertEquals(new ConfigValidator.Message(Status.FINE, "d"),
+ connector.getMessages().get(ca));
}
@Test
public void testLinkValidationBeanId() {
// Serialize it to JSON object
LinkValidationBean bean = new LinkValidationBean(
- getValidation(Status.FINE),
getValidation(Status.FINE)
);
bean.setId((long) 10);
JSONObject json = bean.extract(false);
- // "Move" it across network in text form
+ // "Move" it across network in text config
String string = json.toJSONString();
// Retrieved transferred object
@@ -159,17 +149,12 @@ public class TestValidationBean {
assertEquals((Long)(long) 10, retrievedBean.getId());
}
- public Validation getValidation(Status status) {
- Map<Validation.FormInput, Validation.Message> messages =
- new HashMap<Validation.FormInput, Validation.Message>();
+ public ConfigValidator getValidation(Status status) {
+ Map<ConfigValidator.ConfigInput, ConfigValidator.Message> messages = new HashMap<ConfigValidator.ConfigInput, ConfigValidator.Message>();
- messages.put(
- new Validation.FormInput("f", "i"),
- new Validation.Message(status, "d"));
- messages.put(
- new Validation.FormInput("f2", "i2"),
- new Validation.Message(status, "c"));
+ messages.put(new ConfigValidator.ConfigInput("c", "i"), new ConfigValidator.Message(status, "d"));
+ messages.put(new ConfigValidator.ConfigInput("c2", "i2"), new ConfigValidator.Message(status, "c"));
- return new Validation(status, messages);
+ return new ConfigValidator(status, messages);
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/json/TestValidationResultBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestValidationResultBean.java b/common/src/test/java/org/apache/sqoop/json/TestValidationResultBean.java
index 5c094fb..bdbad72 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestValidationResultBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestValidationResultBean.java
@@ -19,7 +19,7 @@ package org.apache.sqoop.json;
import org.apache.sqoop.validation.Message;
import org.apache.sqoop.validation.Status;
-import org.apache.sqoop.validation.ValidationResult;
+import org.apache.sqoop.validation.ConfigValidationResult;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
import org.junit.Test;
@@ -39,31 +39,31 @@ public class TestValidationResultBean {
@Test
public void testEmptyTransfer() {
- ValidationResult []empty = new ValidationResult[0];
+ ConfigValidationResult []empty = new ConfigValidationResult[0];
- ValidationResult []retrieved = transfer(empty);
+ ConfigValidationResult []retrieved = transfer(empty);
assertEquals(0, retrieved.length);
}
@Test
public void testOneMessage() {
- ValidationResult []empty = new ValidationResult[] {
+ ConfigValidationResult []empty = new ConfigValidationResult[] {
getResultA()
};
- ValidationResult []retrieved = transfer(empty);
+ ConfigValidationResult []retrieved = transfer(empty);
assertEquals(1, retrieved.length);
verifyResultA(retrieved[0]);
}
@Test
public void testTwoMessages() {
- ValidationResult []empty = new ValidationResult[] {
+ ConfigValidationResult []empty = new ConfigValidationResult[] {
getResultA(),
getResultA()
};
- ValidationResult []retrieved = transfer(empty);
+ ConfigValidationResult []retrieved = transfer(empty);
assertEquals(2, retrieved.length);
verifyResultA(retrieved[0]);
@@ -79,7 +79,7 @@ public class TestValidationResultBean {
assertNull(idNull);
}
- public void verifyResultA(ValidationResult result) {
+ public void verifyResultA(ConfigValidationResult result) {
assertNotNull(result);
assertEquals(Status.UNACCEPTABLE, result.getStatus());
@@ -98,8 +98,8 @@ public class TestValidationResultBean {
assertEquals("B", messagesA.get(1).getMessage());
}
- public ValidationResult getResultA() {
- ValidationResult result = new ValidationResult();
+ public ConfigValidationResult getResultA() {
+ ConfigValidationResult result = new ConfigValidationResult();
List<Message> messages = new LinkedList<Message>();
messages.add(new Message(Status.ACCEPTABLE, "A"));
messages.add(new Message(Status.UNACCEPTABLE, "B"));
@@ -109,7 +109,7 @@ public class TestValidationResultBean {
private Long transfer(Long id) {
- ValidationResultBean bean = new ValidationResultBean(new ValidationResult[0]);
+ ValidationResultBean bean = new ValidationResultBean(new ConfigValidationResult[0]);
bean.setId(id);
JSONObject json = bean.extract(false);
@@ -122,7 +122,7 @@ public class TestValidationResultBean {
return retrievedBean.getId();
}
- private ValidationResult[] transfer(ValidationResult [] results) {
+ private ConfigValidationResult[] transfer(ConfigValidationResult [] results) {
ValidationResultBean bean = new ValidationResultBean(results);
JSONObject json = bean.extract(false);
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/json/util/TestConfigSerialization.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/util/TestConfigSerialization.java b/common/src/test/java/org/apache/sqoop/json/util/TestConfigSerialization.java
new file mode 100644
index 0000000..4f0c84d
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/json/util/TestConfigSerialization.java
@@ -0,0 +1,157 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.json.util;
+
+import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.model.MBooleanInput;
+import org.apache.sqoop.model.MEnumInput;
+import org.apache.sqoop.model.MConfig;
+import org.apache.sqoop.model.MInput;
+import org.apache.sqoop.model.MIntegerInput;
+import org.apache.sqoop.model.MMapInput;
+import org.apache.sqoop.model.MStringInput;
+import org.json.simple.JSONObject;
+import org.json.simple.JSONValue;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ *
+ */
+public class TestConfigSerialization {
+
+ @Test
+ public void testAllDataTypes() {
+ // Inserted values
+ Map<String, String> map = new HashMap<String, String>();
+ map.put("A", "B");
+
+ // Fill config with all values
+ MConfig config = getConfig();
+ config.getStringInput("String").setValue("A");
+ config.getMapInput("Map").setValue(map);
+ config.getIntegerInput("Integer").setValue(1);
+ config.getBooleanInput("Boolean").setValue(true);
+ config.getEnumInput("Enum").setValue("YES");
+
+ // Serialize that into JSON
+ JSONObject jsonObject = ConfigSerialization.extractConfig(config, false);
+ assertNotNull(jsonObject);
+
+ // Exchange the data on string level
+ String serializedJson = jsonObject.toJSONString();
+ JSONObject retrievedJson = (JSONObject) JSONValue.parse(serializedJson);
+
+ // And retrieve back from JSON representation
+ MConfig retrieved = ConfigSerialization.restoreConfig(retrievedJson);
+
+ // Verify all expected values
+ assertEquals("A", retrieved.getStringInput("String").getValue());
+ assertEquals(map, retrieved.getMapInput("Map").getValue());
+ assertEquals(1, (int)retrieved.getIntegerInput("Integer").getValue());
+ assertEquals(true, retrieved.getBooleanInput("Boolean").getValue());
+ assertEquals("YES", retrieved.getEnumInput("Enum").getValue());
+ }
+
+ @Test
+ public void testMapDataType() {
+ MConfig config = getMapConfig();
+
+ // Inserted values
+ Map<String, String> map = new HashMap<String, String>();
+ map.put("A", "B");
+ config.getMapInput("Map").setValue(map);
+
+ // Serialize
+ JSONObject jsonObject = ConfigSerialization.extractConfig(config, false);
+ String serializedJson = jsonObject.toJSONString();
+
+ // Deserialize
+ JSONObject retrievedJson = (JSONObject) JSONValue.parse(serializedJson);
+ MConfig retrieved = ConfigSerialization.restoreConfig(retrievedJson);
+ assertEquals(map, retrieved.getMapInput("Map").getValue());
+ }
+
+ @Test(expected=SqoopException.class)
+ public void testMapDataTypeException() {
+ MConfig config = getMapConfig();
+
+ // Inserted values
+ Map<String, String> map = new HashMap<String, String>();
+ map.put("A", "B");
+ config.getMapInput("Map").setValue(map);
+
+ // Serialize
+ JSONObject jsonObject = ConfigSerialization.extractConfig(config, false);
+ String serializedJson = jsonObject.toJSONString();
+
+ // Replace map value with a fake string to force exception
+ String badSerializedJson = serializedJson.replace("{\"A\":\"B\"}", "\"nonsensical string\"");
+ System.out.println(badSerializedJson);
+ JSONObject retrievedJson = (JSONObject) JSONValue.parse(badSerializedJson);
+ ConfigSerialization.restoreConfig(retrievedJson);
+ }
+
+ protected MConfig getMapConfig() {
+ List<MInput<?>> inputs;
+ MInput input;
+
+ inputs = new LinkedList<MInput<?>>();
+
+ input = new MMapInput("Map", false);
+ inputs.add(input);
+
+ return new MConfig("c", inputs);
+ }
+
+ /**
+ * Return config with all data types.
+ *
+ * @return
+ */
+ protected MConfig getConfig() {
+ List<MInput<?>> inputs;
+ MInput input;
+
+ inputs = new LinkedList<MInput<?>>();
+
+ input = new MStringInput("String", false, (short)30);
+ inputs.add(input);
+
+ input = new MMapInput("Map", false);
+ inputs.add(input);
+
+ input = new MIntegerInput("Integer", false);
+ inputs.add(input);
+
+ input = new MBooleanInput("Boolean", false);
+ inputs.add(input);
+
+ input = new MEnumInput("Enum", false, new String[] {"YES", "NO"});
+ inputs.add(input);
+
+ return new MConfig("c", inputs);
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/json/util/TestFormSerialization.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/util/TestFormSerialization.java b/common/src/test/java/org/apache/sqoop/json/util/TestFormSerialization.java
deleted file mode 100644
index c4223ec..0000000
--- a/common/src/test/java/org/apache/sqoop/json/util/TestFormSerialization.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.json.util;
-
-import org.apache.sqoop.common.SqoopException;
-import org.apache.sqoop.model.MBooleanInput;
-import org.apache.sqoop.model.MEnumInput;
-import org.apache.sqoop.model.MForm;
-import org.apache.sqoop.model.MInput;
-import org.apache.sqoop.model.MIntegerInput;
-import org.apache.sqoop.model.MMapInput;
-import org.apache.sqoop.model.MStringInput;
-import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
-import org.junit.Test;
-
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-/**
- *
- */
-public class TestFormSerialization {
-
- @Test
- public void testAllDataTypes() {
- // Inserted values
- Map<String, String> map = new HashMap<String, String>();
- map.put("A", "B");
-
- // Fill form with all values
- MForm form = getForm();
- form.getStringInput("String").setValue("A");
- form.getMapInput("Map").setValue(map);
- form.getIntegerInput("Integer").setValue(1);
- form.getBooleanInput("Boolean").setValue(true);
- form.getEnumInput("Enum").setValue("YES");
-
- // Serialize that into JSON
- JSONObject jsonObject = FormSerialization.extractForm(form, false);
- assertNotNull(jsonObject);
-
- // Exchange the data on string level
- String serializedJson = jsonObject.toJSONString();
- JSONObject retrievedJson = (JSONObject) JSONValue.parse(serializedJson);
-
- // And retrieve back from JSON representation
- MForm retrieved = FormSerialization.restoreForm(retrievedJson);
-
- // Verify all expected values
- assertEquals("A", retrieved.getStringInput("String").getValue());
- assertEquals(map, retrieved.getMapInput("Map").getValue());
- assertEquals(1, (int)retrieved.getIntegerInput("Integer").getValue());
- assertEquals(true, retrieved.getBooleanInput("Boolean").getValue());
- assertEquals("YES", retrieved.getEnumInput("Enum").getValue());
- }
-
- @Test
- public void testMapDataType() {
- MForm form = getMapForm();
-
- // Inserted values
- Map<String, String> map = new HashMap<String, String>();
- map.put("A", "B");
- form.getMapInput("Map").setValue(map);
-
- // Serialize
- JSONObject jsonObject = FormSerialization.extractForm(form, false);
- String serializedJson = jsonObject.toJSONString();
-
- // Deserialize
- JSONObject retrievedJson = (JSONObject) JSONValue.parse(serializedJson);
- MForm retrieved = FormSerialization.restoreForm(retrievedJson);
- assertEquals(map, retrieved.getMapInput("Map").getValue());
- }
-
- @Test(expected=SqoopException.class)
- public void testMapDataTypeException() {
- MForm form = getMapForm();
-
- // Inserted values
- Map<String, String> map = new HashMap<String, String>();
- map.put("A", "B");
- form.getMapInput("Map").setValue(map);
-
- // Serialize
- JSONObject jsonObject = FormSerialization.extractForm(form, false);
- String serializedJson = jsonObject.toJSONString();
-
- // Replace map value with a fake string to force exception
- String badSerializedJson = serializedJson.replace("{\"A\":\"B\"}", "\"nonsensical string\"");
- System.out.println(badSerializedJson);
- JSONObject retrievedJson = (JSONObject) JSONValue.parse(badSerializedJson);
- FormSerialization.restoreForm(retrievedJson);
- }
-
- protected MForm getMapForm() {
- List<MInput<?>> inputs;
- MInput input;
-
- inputs = new LinkedList<MInput<?>>();
-
- input = new MMapInput("Map", false);
- inputs.add(input);
-
- return new MForm("f", inputs);
- }
-
- /**
- * Return form with all data types.
- *
- * @return
- */
- protected MForm getForm() {
- List<MInput<?>> inputs;
- MInput input;
-
- inputs = new LinkedList<MInput<?>>();
-
- input = new MStringInput("String", false, (short)30);
- inputs.add(input);
-
- input = new MMapInput("Map", false);
- inputs.add(input);
-
- input = new MIntegerInput("Integer", false);
- inputs.add(input);
-
- input = new MBooleanInput("Boolean", false);
- inputs.add(input);
-
- input = new MEnumInput("Enum", false, new String[] {"YES", "NO"});
- inputs.add(input);
-
- return new MForm("f", inputs);
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/model/TestConfigUtils.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestConfigUtils.java b/common/src/test/java/org/apache/sqoop/model/TestConfigUtils.java
new file mode 100644
index 0000000..9d7cd4b
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/model/TestConfigUtils.java
@@ -0,0 +1,217 @@
+/**
+ * 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.model;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.sqoop.common.SqoopException;
+
+/**
+ * Test config utils
+ */
+public class TestConfigUtils extends TestCase {
+
+ public void testConfigs() {
+ TestConfiguration config = new TestConfiguration();
+ config.aConfig.a1 = "value";
+
+ List<MConfig> configsByInstance = ConfigUtils.toConfigs(config);
+ assertEquals(getConfigs(), configsByInstance);
+ assertEquals("value", configsByInstance.get(0).getInputs().get(0).getValue());
+
+ List<MConfig> configsByClass = ConfigUtils.toConfigs(TestConfiguration.class);
+ assertEquals(getConfigs(), configsByClass);
+
+ List<MConfig> configsByBoth = ConfigUtils.toConfigs(TestConfiguration.class, config);
+ assertEquals(getConfigs(), configsByBoth);
+ assertEquals("value", configsByBoth.get(0).getInputs().get(0).getValue());
+ }
+
+ public void testConfigsMissingAnnotation() {
+ try {
+ ConfigUtils.toConfigs(ConfigWithout.class);
+ } catch(SqoopException ex) {
+ assertEquals(ModelError.MODEL_003, ex.getErrorCode());
+ return;
+ }
+
+ fail("Correct exception wasn't thrown");
+ }
+
+ public void testFailureOnPrimitiveType() {
+ PrimitiveConfig config = new PrimitiveConfig();
+
+ try {
+ ConfigUtils.toConfigs(config);
+ fail("We were expecting exception for unsupported type.");
+ } catch(SqoopException ex) {
+ assertEquals(ModelError.MODEL_007, ex.getErrorCode());
+ }
+ }
+
+ public void testFillValues() {
+ List<MConfig> configs = getConfigs();
+
+ ((MStringInput)configs.get(0).getInputs().get(0)).setValue("value");
+
+ TestConfiguration config = new TestConfiguration();
+
+ ConfigUtils.fromConfigs(configs, config);
+ assertEquals("value", config.aConfig.a1);
+ }
+
+ public void testFillValuesObjectReuse() {
+ List<MConfig> configs = getConfigs();
+
+ ((MStringInput)configs.get(0).getInputs().get(0)).setValue("value");
+
+ TestConfiguration config = new TestConfiguration();
+ config.aConfig.a2 = "x";
+ config.bConfig.b1 = "y";
+
+ ConfigUtils.fromConfigs(configs, config);
+ assertEquals("value", config.aConfig.a1);
+ assertNull(config.aConfig.a2);
+ assertNull(config.bConfig.b2);
+ assertNull(config.bConfig.b2);
+ }
+
+ public void testJson() {
+ TestConfiguration config = new TestConfiguration();
+ config.aConfig.a1 = "A";
+ config.bConfig.b2 = "B";
+ config.cConfig.intValue = 4;
+ config.cConfig.map.put("C", "D");
+ config.cConfig.enumeration = Enumeration.X;
+
+ String json = ConfigUtils.toJson(config);
+
+ TestConfiguration targetConfig = new TestConfiguration();
+
+ // Old values from should be always removed
+ targetConfig.aConfig.a2 = "X";
+ targetConfig.bConfig.b1 = "Y";
+ // Nulls in configs shouldn't be an issue either
+ targetConfig.cConfig = null;
+
+ ConfigUtils.fillValues(json, targetConfig);
+
+ assertEquals("A", targetConfig.aConfig.a1);
+ assertNull(targetConfig.aConfig.a2);
+
+ assertNull(targetConfig.bConfig.b1);
+ assertEquals("B", targetConfig.bConfig.b2);
+
+ assertEquals((Integer)4, targetConfig.cConfig.intValue);
+ assertEquals(1, targetConfig.cConfig.map.size());
+ assertTrue(targetConfig.cConfig.map.containsKey("C"));
+ assertEquals("D", targetConfig.cConfig.map.get("C"));
+ assertEquals(Enumeration.X, targetConfig.cConfig.enumeration);
+ }
+
+ /**
+ * Config structure that corresponds to Config class declared below
+ * @return Config structure
+ */
+ protected List<MConfig> getConfigs() {
+ List<MConfig> ret = new LinkedList<MConfig>();
+
+ List<MInput<?>> inputs;
+
+ // Config A
+ inputs = new LinkedList<MInput<?>>();
+ inputs.add(new MStringInput("aConfig.a1", false, (short)30));
+ inputs.add(new MStringInput("aConfig.a2", true, (short)-1));
+ ret.add(new MConfig("aConfig", inputs));
+
+ // Config B
+ inputs = new LinkedList<MInput<?>>();
+ inputs.add(new MStringInput("bConfig.b1", false, (short)2));
+ inputs.add(new MStringInput("bConfig.b2", false, (short)3));
+ ret.add(new MConfig("bConfig", inputs));
+
+ // Config C
+ inputs = new LinkedList<MInput<?>>();
+ inputs.add(new MIntegerInput("cConfig.intValue", false));
+ inputs.add(new MMapInput("cConfig.map", false));
+ inputs.add(new MEnumInput("cConfig.enumeration", false, new String[]{"X", "Y"}));
+ ret.add(new MConfig("cConfig", inputs));
+
+ return ret;
+ }
+
+ @ConfigurationClass
+ public static class TestConfiguration {
+
+ public TestConfiguration() {
+ aConfig = new AConfig();
+ bConfig = new BConfig();
+ cConfig = new CConfig();
+ }
+
+ @Config AConfig aConfig;
+ @Config BConfig bConfig;
+ @Config CConfig cConfig;
+ }
+
+ @ConfigurationClass
+ public static class PrimitiveConfig {
+ @Config DConfig dConfig;
+ }
+
+ @ConfigClass
+ public static class AConfig {
+ @Input(size = 30) String a1;
+ @Input(sensitive = true) String a2;
+ }
+
+ @ConfigClass
+ public static class BConfig {
+ @Input(size = 2) String b1;
+ @Input(size = 3) String b2;
+ }
+
+ @ConfigClass
+ public static class CConfig {
+ @Input Integer intValue;
+ @Input Map<String, String> map;
+ @Input Enumeration enumeration;
+
+ public CConfig() {
+ map = new HashMap<String, String>();
+ }
+ }
+
+ @ConfigClass
+ public static class DConfig {
+ @Input int value;
+ }
+
+ public static class ConfigWithout {
+ }
+
+ enum Enumeration {
+ X,
+ Y,
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/model/TestFormUtils.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestFormUtils.java b/common/src/test/java/org/apache/sqoop/model/TestFormUtils.java
deleted file mode 100644
index 18c9692..0000000
--- a/common/src/test/java/org/apache/sqoop/model/TestFormUtils.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.model;
-
-import org.apache.sqoop.common.SqoopException;
-import org.apache.sqoop.validation.Status;
-import org.apache.sqoop.validation.Validation;
-import org.junit.Test;
-
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.*;
-
-/**
- * Test form utils
- */
-public class TestFormUtils {
-
- @Test
- public void testToForms() {
- Config config = new Config();
- config.aForm.a1 = "value";
-
- List<MForm> formsByInstance = FormUtils.toForms(config);
- assertEquals(getForms(), formsByInstance);
- assertEquals("value", formsByInstance.get(0).getInputs().get(0).getValue());
-
- List<MForm> formsByClass = FormUtils.toForms(Config.class);
- assertEquals(getForms(), formsByClass);
-
- List<MForm> formsByBoth = FormUtils.toForms(Config.class, config);
- assertEquals(getForms(), formsByBoth);
- assertEquals("value", formsByBoth.get(0).getInputs().get(0).getValue());
- }
-
- @Test
- public void testToFormsMissingAnnotation() {
- try {
- FormUtils.toForms(ConfigWithout.class);
- } catch(SqoopException ex) {
- assertEquals(ModelError.MODEL_003, ex.getErrorCode());
- return;
- }
-
- fail("Correct exception wasn't thrown");
- }
-
- @Test
- public void testFailureOnPrimitiveType() {
- PrimitiveConfig config = new PrimitiveConfig();
-
- try {
- FormUtils.toForms(config);
- fail("We were expecting exception for unsupported type.");
- } catch(SqoopException ex) {
- assertEquals(ModelError.MODEL_007, ex.getErrorCode());
- }
- }
-
- @Test
- public void testFillValues() {
- List<MForm> forms = getForms();
-
- ((MStringInput)forms.get(0).getInputs().get(0)).setValue("value");
-
- Config config = new Config();
-
- FormUtils.fromForms(forms, config);
- assertEquals("value", config.aForm.a1);
- }
-
- @Test
- public void testFillValuesObjectReuse() {
- List<MForm> forms = getForms();
-
- ((MStringInput)forms.get(0).getInputs().get(0)).setValue("value");
-
- Config config = new Config();
- config.aForm.a2 = "x";
- config.bForm.b1 = "y";
-
- FormUtils.fromForms(forms, config);
- assertEquals("value", config.aForm.a1);
- assertNull(config.aForm.a2);
- assertNull(config.bForm.b2);
- assertNull(config.bForm.b2);
- }
-
- @Test
- public void testJson() {
- Config config = new Config();
- config.aForm.a1 = "A";
- config.bForm.b2 = "B";
- config.cForm.intValue = 4;
- config.cForm.map.put("C", "D");
- config.cForm.enumeration = Enumeration.X;
-
- String json = FormUtils.toJson(config);
-
- Config targetConfig = new Config();
-
- // Old values from should be always removed
- targetConfig.aForm.a2 = "X";
- targetConfig.bForm.b1 = "Y";
- // Nulls in forms shouldn't be an issue either
- targetConfig.cForm = null;
-
- FormUtils.fillValues(json, targetConfig);
-
- assertEquals("A", targetConfig.aForm.a1);
- assertNull(targetConfig.aForm.a2);
-
- assertNull(targetConfig.bForm.b1);
- assertEquals("B", targetConfig.bForm.b2);
-
- assertEquals((Integer)4, targetConfig.cForm.intValue);
- assertEquals(1, targetConfig.cForm.map.size());
- assertTrue(targetConfig.cForm.map.containsKey("C"));
- assertEquals("D", targetConfig.cForm.map.get("C"));
- assertEquals(Enumeration.X, targetConfig.cForm.enumeration);
- }
-
- /**
- * Form structure that corresponds to Config class declared below
- * @return Form structure
- */
- protected List<MForm> getForms() {
- List<MForm> ret = new LinkedList<MForm>();
-
- List<MInput<?>> inputs;
-
- // Form A
- inputs = new LinkedList<MInput<?>>();
- inputs.add(new MStringInput("aForm.a1", false, (short)30));
- inputs.add(new MStringInput("aForm.a2", true, (short)-1));
- ret.add(new MForm("aForm", inputs));
-
- // Form B
- inputs = new LinkedList<MInput<?>>();
- inputs.add(new MStringInput("bForm.b1", false, (short)2));
- inputs.add(new MStringInput("bForm.b2", false, (short)3));
- ret.add(new MForm("bForm", inputs));
-
- // Form C
- inputs = new LinkedList<MInput<?>>();
- inputs.add(new MIntegerInput("cForm.intValue", false));
- inputs.add(new MMapInput("cForm.map", false));
- inputs.add(new MEnumInput("cForm.enumeration", false, new String[]{"X", "Y"}));
- ret.add(new MForm("cForm", inputs));
-
- return ret;
- }
-
- @ConfigurationClass
- public static class Config {
-
- public Config() {
- aForm = new AForm();
- bForm = new BForm();
- cForm = new CForm();
- }
-
- @Form AForm aForm;
- @Form BForm bForm;
- @Form CForm cForm;
- }
-
- @ConfigurationClass
- public static class PrimitiveConfig {
- @Form DForm dForm;
- }
-
- @FormClass
- public static class AForm {
- @Input(size = 30) String a1;
- @Input(sensitive = true) String a2;
- }
-
- @FormClass
- public static class BForm {
- @Input(size = 2) String b1;
- @Input(size = 3) String b2;
- }
-
- @FormClass
- public static class CForm {
- @Input Integer intValue;
- @Input Map<String, String> map;
- @Input Enumeration enumeration;
-
- public CForm() {
- map = new HashMap<String, String>();
- }
- }
-
- @FormClass
- public static class DForm {
- @Input int value;
- }
-
- public static class ConfigWithout {
- }
-
- enum Enumeration {
- X,
- Y,
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java b/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java
index af0f450..ba53739 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java
@@ -35,14 +35,13 @@ public class TestMAccountableEntity {
*/
@Test
public void testInitialization() {
- List<MForm> forms = new ArrayList<MForm>();
+ List<MConfig> configs = new ArrayList<MConfig>();
MIntegerInput input = new MIntegerInput("INTEGER-INPUT", false);
List<MInput<?>> list = new ArrayList<MInput<?>>();
list.add(input);
- MForm form = new MForm("FORMNAME", list);
- forms.add(form);
- MAccountableEntity link = new MLink(123l, new MConnectionForms(
- forms), new MConnectionForms(forms));
+ MConfig config = new MConfig("CONFIGNAME", list);
+ configs.add(config);
+ MAccountableEntity link = new MLink(123l, new MLinkConfig(configs));
// Initially creation date and last update date is same
assertEquals(link.getCreationDate(), link.getLastUpdateDate());
Date testCreationDate = new Date();
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/model/TestMConfig.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMConfig.java b/common/src/test/java/org/apache/sqoop/model/TestMConfig.java
new file mode 100644
index 0000000..c5a07a0
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/model/TestMConfig.java
@@ -0,0 +1,86 @@
+/**
+ * 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.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class TestMConfig {
+
+ /**
+ * Test for initialization
+ */
+ @Test
+ public void testInitialization() {
+ MInput<String> input1 = new MStringInput("sqoopsqoop1", true, (short) 5);
+ MInput<String> input2 = new MStringInput("sqoopsqoop2", true, (short) 5);
+
+ List<MInput<?>> list = new ArrayList<MInput<?>>();
+ list.add(input1);
+ list.add(input2);
+ MConfig mConfig = new MConfig("config", list);
+
+ assertEquals("config", mConfig.getName());
+ assertEquals(2, mConfig.getInputs().size());
+ }
+
+ /**
+ * Test for equals method
+ */
+ @Test
+ public void testEquals() {
+ MInput<Integer> input1 = new MIntegerInput("sqoopsqoop1", false);
+ MInput<Integer> input2 = new MIntegerInput("sqoopsqoop2", false);
+ List<MInput<?>> list1 = new ArrayList<MInput<?>>();
+ list1.add(input1);
+ list1.add(input2);
+ MConfig mform1 = new MConfig("config", list1);
+
+ MInput<Integer> input3 = new MIntegerInput("sqoopsqoop1", false);
+ MInput<Integer> input4 = new MIntegerInput("sqoopsqoop2", false);
+ List<MInput<?>> list2 = new ArrayList<MInput<?>>();
+ list2.add(input3);
+ list2.add(input4);
+ MConfig mform2 = new MConfig("config", list2);
+ assertEquals(mform2, mform1);
+ }
+
+ @Test
+ public void testGetInputs() {
+ MIntegerInput intInput = new MIntegerInput("Config.A", false);
+ MMapInput mapInput = new MMapInput("Config.B", false);
+ MStringInput stringInput = new MStringInput("Config.C", false, (short)3);
+ MEnumInput enumInput = new MEnumInput("Config.D", false, new String[] {"I", "V"});
+
+ List<MInput<?>> inputs = new ArrayList<MInput<?>>();
+ inputs.add(intInput);
+ inputs.add(mapInput);
+ inputs.add(stringInput);
+ inputs.add(enumInput);
+
+ MConfig config = new MConfig("Config", inputs);
+ assertEquals(intInput, config.getIntegerInput("Config.A"));
+ assertEquals(mapInput, config.getMapInput("Config.B"));
+ assertEquals(stringInput, config.getStringInput("Config.C"));
+ assertEquals(enumInput, config.getEnumInput("Config.D"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/model/TestMConfigList.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMConfigList.java b/common/src/test/java/org/apache/sqoop/model/TestMConfigList.java
new file mode 100644
index 0000000..9b60055
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/model/TestMConfigList.java
@@ -0,0 +1,55 @@
+/**
+ * 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.model;
+
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
+public class TestMConfigList {
+ @Test
+ public void testGetInputs() {
+ List<MConfig> configs = new LinkedList<MConfig>();
+
+ MIntegerInput intInput = new MIntegerInput("Config1.A", false);
+ MMapInput mapInput = new MMapInput("Config1.B", false);
+
+ List<MInput<?>> inputs = new ArrayList<MInput<?>>();
+ inputs.add(intInput);
+ inputs.add(mapInput);
+ configs.add(new MConfig("Config1", inputs));
+
+ MStringInput stringInput = new MStringInput("Config2.C", false, (short)3);
+ MEnumInput enumInput = new MEnumInput("Config2.D", false, new String[] {"I", "V"});
+
+ inputs = new ArrayList<MInput<?>>();
+ inputs.add(stringInput);
+ inputs.add(enumInput);
+ configs.add(new MConfig("Config2", inputs));
+
+ MConfigList config = new MConfigList(configs);
+ assertEquals(intInput, config.getIntegerInput("Config1.A"));
+ assertEquals(mapInput, config.getMapInput("Config1.B"));
+ assertEquals(stringInput, config.getStringInput("Config2.C"));
+ assertEquals(enumInput, config.getEnumInput("Config2.D"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/model/TestMConnectionForms.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMConnectionForms.java b/common/src/test/java/org/apache/sqoop/model/TestMConnectionForms.java
deleted file mode 100644
index 243fff9..0000000
--- a/common/src/test/java/org/apache/sqoop/model/TestMConnectionForms.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Test class for org.apache.sqoop.model.MConnectionForms
- */
-public class TestMConnectionForms {
-
- /**
- * Test for class initialization and values
- */
- @Test
- public void testInitialization() {
- List<MForm> forms = new ArrayList<MForm>();
- MConnectionForms connectionForms1 = new MConnectionForms(forms);
- List<MForm> testForms = new ArrayList<MForm>();
- assertEquals(testForms, connectionForms1.getForms());
- MConnectionForms connectionForms2 = new MConnectionForms(testForms);
- assertEquals(connectionForms2, connectionForms1);
- // Add a form to list for checking not equals
- MForm m = new MForm("test", null);
- testForms.add(m);
- assertFalse(connectionForms1.equals(connectionForms2));
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/model/TestMConnector.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMConnector.java b/common/src/test/java/org/apache/sqoop/model/TestMConnector.java
index d8bc94d..89ae440 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMConnector.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMConnector.java
@@ -17,6 +17,13 @@
*/
package org.apache.sqoop.model;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -24,39 +31,34 @@ import java.util.List;
import org.apache.sqoop.common.Direction;
import org.junit.Test;
-import static org.junit.Assert.*;
-
-/**
- * Test class for org.apache.sqoop.model.TestMConnector
- */
public class TestMConnector {
private MConnector createConnector(List<Direction> supportedDirections) {
- List<MForm> forms = new ArrayList<MForm>();
- MIntegerInput input = new MIntegerInput("INTEGER-INPUT", false);
- input.setValue(100);
+ List<MConfig> configs = new ArrayList<MConfig>();
+ MIntegerInput inputs = new MIntegerInput("INTEGER-INPUT", false);
+ inputs.setValue(100);
MStringInput strInput = new MStringInput("STRING-INPUT",false,(short)20);
strInput.setValue("TEST-VALUE");
List<MInput<?>> list = new ArrayList<MInput<?>>();
- list.add(input);
+ list.add(inputs);
list.add(strInput);
- MForm form = new MForm("FORMNAME", list);
- forms.add(form);
+ MConfig config = new MConfig("CONFIGNAME", list);
+ configs.add(config);
- MConnectionForms connectionForms1 = new MConnectionForms(forms);
- MJobForms fromForm = null;
- MJobForms toForm = null;
+ MLinkConfig linkConfig = new MLinkConfig(configs);
+ MFromConfig fromConfig = null;
+ MToConfig toConfig = null;
if (supportedDirections.contains(Direction.FROM)) {
- fromForm = new MJobForms(forms);
+ fromConfig = new MFromConfig(configs);
}
if (supportedDirections.contains(Direction.TO)) {
- toForm = new MJobForms(forms);
+ toConfig = new MToConfig(configs);
}
return new MConnector("NAME", "CLASSNAME", "1.0",
- connectionForms1, fromForm, toForm);
+ linkConfig, fromConfig, toConfig);
}
/**
@@ -64,32 +66,32 @@ public class TestMConnector {
*/
@Test
public void testInitialization() {
- List<MForm> fromJobForms = new ArrayList<MForm>();
- List<MForm> toJobForms = new ArrayList<MForm>();
- MConnectionForms connectionForms1 = new MConnectionForms(fromJobForms);
- MJobForms fromJobForm1 = new MJobForms(fromJobForms);
- MJobForms toJobForm1 = new MJobForms(toJobForms);
+ List<MConfig> fromJobConfig = new ArrayList<MConfig>();
+ List<MConfig> toJobConfig = new ArrayList<MConfig>();
+ MLinkConfig linkConfig = new MLinkConfig(fromJobConfig);
+ MFromConfig fromConfig1 = new MFromConfig(fromJobConfig);
+ MToConfig toConfig1 = new MToConfig(toJobConfig);
MConnector connector1 = new MConnector("NAME", "CLASSNAME", "1.0",
- connectionForms1, fromJobForm1, toJobForm1);
+ linkConfig, fromConfig1, toConfig1);
assertEquals("NAME", connector1.getUniqueName());
assertEquals("CLASSNAME", connector1.getClassName());
assertEquals("1.0", connector1.getVersion());
MConnector connector2 = new MConnector("NAME", "CLASSNAME", "1.0",
- connectionForms1, fromJobForm1, toJobForm1);
+ linkConfig, fromConfig1, toConfig1);
assertEquals(connector2, connector1);
MConnector connector3 = new MConnector("NAME1", "CLASSNAME", "2.0",
- connectionForms1, fromJobForm1, toJobForm1);
+ linkConfig, fromConfig1, toConfig1);
assertFalse(connector1.equals(connector3));
try {
- connector1 = new MConnector(null, "CLASSNAME", "1.0", connectionForms1,
- fromJobForm1, toJobForm1); // Expecting null pointer exception
+ connector1 = new MConnector(null, "CLASSNAME", "1.0", linkConfig,
+ fromConfig1, toConfig1); // Expecting null pointer exception
} catch (NullPointerException e) {
assertTrue(true);
}
try {
- connector1 = new MConnector("NAME", null, "1.0", connectionForms1,
- fromJobForm1, toJobForm1); // Expecting null pointer exception
+ connector1 = new MConnector("NAME", null, "1.0", linkConfig,
+ fromConfig1, toConfig1); // Expecting null pointer exception
} catch (NullPointerException e) {
assertTrue(true);
}
@@ -97,48 +99,48 @@ public class TestMConnector {
@Test
public void testClone() {
- MConnector connector1 = createConnector(Arrays.asList(Direction.FROM, Direction.TO));
- assertEquals("NAME", connector1.getUniqueName());
- assertEquals("CLASSNAME", connector1.getClassName());
- assertEquals("1.0", connector1.getVersion());
- //Clone with values. Checking values copying after the cloning. But form values will be null
- MConnector clone1 = connector1.clone(true);
- assertEquals("NAME", clone1.getUniqueName());
- assertEquals("CLASSNAME", clone1.getClassName());
- assertEquals("1.0", clone1.getVersion());
- MForm clonedForm1 = clone1.getConnectionForms().getForms().get(0);
- assertNull(clonedForm1.getInputs().get(0).getValue());
- assertNull(clonedForm1.getInputs().get(1).getValue());
-
- MForm clonedForm2 = clone1.getJobForms(Direction.FROM).getForms().get(0);
- assertNull(clonedForm2.getInputs().get(0).getValue());
- assertNull(clonedForm2.getInputs().get(1).getValue());
-
- MForm clonedForm3 = clone1.getJobForms(Direction.TO).getForms().get(0);
- assertNull(clonedForm3.getInputs().get(0).getValue());
- assertNull(clonedForm3.getInputs().get(1).getValue());
+ MConnector connector = createConnector(Arrays.asList(Direction.FROM, Direction.TO));
+ assertEquals("NAME", connector.getUniqueName());
+ assertEquals("CLASSNAME", connector.getClassName());
+ assertEquals("1.0", connector.getVersion());
+ //Clone with values. Checking values copying after the cloning. But config values will be null
+ MConnector cloneConnector1 = connector.clone(true);
+ assertEquals("NAME", cloneConnector1.getUniqueName());
+ assertEquals("CLASSNAME", cloneConnector1.getClassName());
+ assertEquals("1.0", cloneConnector1.getVersion());
+ MConfig clonedLinkConfig = cloneConnector1.getLinkConfig().getConfigs().get(0);
+ assertNull(clonedLinkConfig.getInputs().get(0).getValue());
+ assertNull(clonedLinkConfig.getInputs().get(1).getValue());
+
+ MConfig clonedFromConfig = cloneConnector1.getConfig(Direction.FROM).getConfigs().get(0);
+ assertNull(clonedFromConfig.getInputs().get(0).getValue());
+ assertNull(clonedFromConfig.getInputs().get(1).getValue());
+
+ MConfig clonedToConfig = cloneConnector1.getConfig(Direction.TO).getConfigs().get(0);
+ assertNull(clonedToConfig.getInputs().get(0).getValue());
+ assertNull(clonedToConfig.getInputs().get(1).getValue());
//Clone without values. Inputs value will be null after cloning.
- MConnector clone2 = connector1.clone(false);
- clonedForm1 = clone2.getConnectionForms().getForms().get(0);
- assertNull(clonedForm1.getInputs().get(0).getValue());
- assertNull(clonedForm1.getInputs().get(1).getValue());
- clonedForm2 = clone2.getJobForms(Direction.FROM).getForms().get(0);
- assertNull(clonedForm2.getInputs().get(0).getValue());
- assertNull(clonedForm2.getInputs().get(1).getValue());
- clonedForm3 = clone2.getJobForms(Direction.TO).getForms().get(0);
- assertNull(clonedForm3.getInputs().get(0).getValue());
- assertNull(clonedForm3.getInputs().get(1).getValue());
+ MConnector clonedConnector2 = connector.clone(false);
+ clonedLinkConfig = clonedConnector2.getLinkConfig().getConfigs().get(0);
+ assertNull(clonedLinkConfig.getInputs().get(0).getValue());
+ assertNull(clonedLinkConfig.getInputs().get(1).getValue());
+ clonedFromConfig = clonedConnector2.getConfig(Direction.FROM).getConfigs().get(0);
+ assertNull(clonedFromConfig.getInputs().get(0).getValue());
+ assertNull(clonedFromConfig.getInputs().get(1).getValue());
+ clonedToConfig = clonedConnector2.getConfig(Direction.TO).getConfigs().get(0);
+ assertNull(clonedToConfig.getInputs().get(0).getValue());
+ assertNull(clonedToConfig.getInputs().get(1).getValue());
}
@Test
public void testFromDirection() {
MConnector connector = createConnector(Arrays.asList(Direction.FROM));
- // Clone should clone only one job form.
+ // Clone should clone only one job config.
MConnector clone = connector.clone(true);
- assertNotNull(clone.getJobForms(Direction.FROM));
- assertNull(clone.getJobForms(Direction.TO));
+ assertNotNull(clone.getFromConfig());
+ assertNull(clone.getToConfig());
assertEquals(connector, clone);
assertEquals(connector.toString(), clone.toString());
assertNotEquals(connector.hashCode(), clone.hashCode());
@@ -148,10 +150,10 @@ public class TestMConnector {
public void testToDirection() {
MConnector connector = createConnector(Arrays.asList(Direction.TO));
- // Clone should clone only one job form.
+ // Clone should clone only one job config.
MConnector clone = connector.clone(true);
- assertNull(clone.getJobForms(Direction.FROM));
- assertNotNull(clone.getJobForms(Direction.TO));
+ assertNull(clone.getFromConfig());
+ assertNotNull(clone.getToConfig());
assertEquals(connector, clone);
assertEquals(connector.toString(), clone.toString());
assertNotEquals(connector.hashCode(), clone.hashCode());
@@ -161,10 +163,10 @@ public class TestMConnector {
public void testNoDirection() {
MConnector connector = createConnector(Arrays.asList(new Direction[0]));
- // Clone should clone only one job form.
+ // Clone should clone only one job config.
MConnector clone = connector.clone(true);
- assertNull(clone.getJobForms(Direction.FROM));
- assertNull(clone.getJobForms(Direction.TO));
+ assertNull(clone.getFromConfig());
+ assertNull(clone.getToConfig());
assertEquals(connector, clone);
assertEquals(connector.toString(), clone.toString());
assertNotEquals(connector.hashCode(), clone.hashCode());
@@ -174,10 +176,10 @@ public class TestMConnector {
public void testBothDirections() {
MConnector connector = createConnector(Arrays.asList(Direction.FROM, Direction.TO));
- // Clone should clone only one job form.
+ // Clone should clone only one job config.
MConnector clone = connector.clone(true);
- assertNotNull(clone.getJobForms(Direction.FROM));
- assertNotNull(clone.getJobForms(Direction.TO));
+ assertNotNull(clone.getFromConfig());
+ assertNotNull(clone.getToConfig());
assertEquals(connector, clone);
assertEquals(connector.toString(), clone.toString());
assertNotEquals(connector.hashCode(), clone.hashCode());
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/model/TestMDriver.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMDriver.java b/common/src/test/java/org/apache/sqoop/model/TestMDriver.java
new file mode 100644
index 0000000..aa1ee34
--- /dev/null
+++ b/common/src/test/java/org/apache/sqoop/model/TestMDriver.java
@@ -0,0 +1,40 @@
+/**
+ * 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.model;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.sqoop.json.DriverBean;
+import org.junit.Test;
+
+public class TestMDriver {
+
+ @Test
+ public void testDriver() {
+ List<MConfig> driverConfig = new ArrayList<MConfig>();
+ driverConfig.add(new MConfig("driver-test", new ArrayList<MInput<?>>()));
+ MDriverConfig mDriverConfig = new MDriverConfig(driverConfig);
+
+ MDriver driver = new MDriver(mDriverConfig, DriverBean.CURRENT_DRIVER_VERSION);
+ assertEquals(1, driver.getDriverConfig().getConfigs().size());
+ assertEquals("driver-test", driver.getDriverConfig().getConfigs().get(0).getName());
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/model/TestMDriverConfig.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMDriverConfig.java b/common/src/test/java/org/apache/sqoop/model/TestMDriverConfig.java
deleted file mode 100644
index 9c23cc3..0000000
--- a/common/src/test/java/org/apache/sqoop/model/TestMDriverConfig.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.model;
-
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.*;
-
-/**
- *
- */
-public class TestMDriverConfig {
-
- @Test
- public void testForms() {
- List<MForm> connectionFormList = new ArrayList<MForm>();
- List<MForm> jobFormList = new ArrayList<MForm>();
- connectionFormList.add(new MForm("connection-test", new ArrayList<MInput<?>>()));
- jobFormList.add(new MForm("job-test", new ArrayList<MInput<?>>()));
- MConnectionForms connectionForms = new MConnectionForms(connectionFormList);
- MJobForms jobForms = new MJobForms(jobFormList);
-
- MDriverConfig driver = new MDriverConfig(connectionForms, jobForms, "1");
- assertEquals(1, driver.getJobForms().getForms().size());
- assertEquals("job-test", driver.getJobForms().getForms().get(0).getName());
- assertEquals(1, driver.getConnectionForms().getForms().size());
- assertEquals("connection-test", driver.getConnectionForms().getForms().get(0).getName());
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/model/TestMForm.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMForm.java b/common/src/test/java/org/apache/sqoop/model/TestMForm.java
deleted file mode 100644
index 536b650..0000000
--- a/common/src/test/java/org/apache/sqoop/model/TestMForm.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Test class for org.apache.sqoop.model.MForm
- */
-public class TestMForm {
-
- /**
- * Test for initialization
- */
- @Test
- public void testInitialization() {
- MInput<String> input1 = new MStringInput("sqoopsqoop1", true, (short) 5);
- MInput<String> input2 = new MStringInput("sqoopsqoop2", true, (short) 5);
-
- List<MInput<?>> list = new ArrayList<MInput<?>>();
- list.add(input1);
- list.add(input2);
- MForm mform = new MForm("form", list);
-
- assertEquals("form", mform.getName());
- assertEquals(2, mform.getInputs().size());
- }
-
- /**
- * Test for equals method
- */
- @Test
- public void testEquals() {
- MInput<Integer> input1 = new MIntegerInput("sqoopsqoop1", false);
- MInput<Integer> input2 = new MIntegerInput("sqoopsqoop2", false);
- List<MInput<?>> list1 = new ArrayList<MInput<?>>();
- list1.add(input1);
- list1.add(input2);
- MForm mform1 = new MForm("form", list1);
-
- MInput<Integer> input3 = new MIntegerInput("sqoopsqoop1", false);
- MInput<Integer> input4 = new MIntegerInput("sqoopsqoop2", false);
- List<MInput<?>> list2 = new ArrayList<MInput<?>>();
- list2.add(input3);
- list2.add(input4);
- MForm mform2 = new MForm("form", list2);
- assertEquals(mform2, mform1);
- }
-
- @Test
- public void testGetInputs() {
- MIntegerInput intInput = new MIntegerInput("Form.A", false);
- MMapInput mapInput = new MMapInput("Form.B", false);
- MStringInput stringInput = new MStringInput("Form.C", false, (short)3);
- MEnumInput enumInput = new MEnumInput("Form.D", false, new String[] {"I", "V"});
-
- List<MInput<?>> inputs = new ArrayList<MInput<?>>();
- inputs.add(intInput);
- inputs.add(mapInput);
- inputs.add(stringInput);
- inputs.add(enumInput);
-
- MForm form = new MForm("Form", inputs);
- assertEquals(intInput, form.getIntegerInput("Form.A"));
- assertEquals(mapInput, form.getMapInput("Form.B"));
- assertEquals(stringInput, form.getStringInput("Form.C"));
- assertEquals(enumInput, form.getEnumInput("Form.D"));
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/common/src/test/java/org/apache/sqoop/model/TestMFormList.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMFormList.java b/common/src/test/java/org/apache/sqoop/model/TestMFormList.java
deleted file mode 100644
index b8d3d37..0000000
--- a/common/src/test/java/org/apache/sqoop/model/TestMFormList.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.model;
-
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- *
- */
-public class TestMFormList {
- @Test
- public void testGetInputs() {
- List<MForm> forms = new LinkedList<MForm>();
-
- MIntegerInput intInput = new MIntegerInput("Form1.A", false);
- MMapInput mapInput = new MMapInput("Form1.B", false);
-
- List<MInput<?>> inputs = new ArrayList<MInput<?>>();
- inputs.add(intInput);
- inputs.add(mapInput);
- forms.add(new MForm("Form1", inputs));
-
- MStringInput stringInput = new MStringInput("Form2.C", false, (short)3);
- MEnumInput enumInput = new MEnumInput("Form2.D", false, new String[] {"I", "V"});
-
- inputs = new ArrayList<MInput<?>>();
- inputs.add(stringInput);
- inputs.add(enumInput);
- forms.add(new MForm("Form2", inputs));
-
- MFormList form = new MFormList(forms);
- assertEquals(intInput, form.getIntegerInput("Form1.A"));
- assertEquals(mapInput, form.getMapInput("Form1.B"));
- assertEquals(stringInput, form.getStringInput("Form2.C"));
- assertEquals(enumInput, form.getEnumInput("Form2.D"));
- }
-}
[07/13] SQOOP-1498: Sqoop2: Repository Object refactoring (objects
prefixed with M)
Posted by ab...@apache.org.
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/core/src/main/java/org/apache/sqoop/driver/DriverConfigUpgrader.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/driver/DriverConfigUpgrader.java b/core/src/main/java/org/apache/sqoop/driver/DriverConfigUpgrader.java
index 8d6eb78..847b73d 100644
--- a/core/src/main/java/org/apache/sqoop/driver/DriverConfigUpgrader.java
+++ b/core/src/main/java/org/apache/sqoop/driver/DriverConfigUpgrader.java
@@ -18,56 +18,54 @@
*/
package org.apache.sqoop.driver;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.apache.log4j.Logger;
import org.apache.sqoop.common.SqoopException;
import org.apache.sqoop.connector.spi.RepositoryUpgrader;
-import org.apache.sqoop.model.MConnectionForms;
-import org.apache.sqoop.model.MForm;
+import org.apache.sqoop.model.MConfigList;
+import org.apache.sqoop.model.MConfig;
import org.apache.sqoop.model.MInput;
-import org.apache.sqoop.model.MJobForms;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import org.apache.sqoop.model.MLinkConfig;
public class DriverConfigUpgrader extends RepositoryUpgrader{
private static final Logger LOG = Logger.getLogger(DriverConfigUpgrader.class);
@Override
- public void upgrade(MConnectionForms original,
- MConnectionForms upgradeTarget) {
- doUpgrade(original.getForms(), upgradeTarget.getForms());
+ public void upgrade(MLinkConfig original, MLinkConfig upgradeTarget) {
+ // NOTE(VB): There are no link configs anymore for driver, this code remains for previous versions
}
@Override
- public void upgrade(MJobForms original, MJobForms upgradeTarget) {
- doUpgrade(original.getForms(), upgradeTarget.getForms());
-
+ public void upgrade(MConfigList original, MConfigList upgradeTarget) {
+ doUpgrade(original.getConfigs(), upgradeTarget.getConfigs());
}
@SuppressWarnings("unchecked")
- private void doUpgrade(List<MForm> original, List<MForm> target) {
- // Easier to find the form in the original forms list if we use a map.
- // Since the constructor of MJobForms takes a list,
+ private void doUpgrade(List<MConfig> original, List<MConfig> target) {
+ // Easier to find the config in the original list if we use a map.
+ // Since the constructor takes a list,
// index is not guaranteed to be the same, so we need to look for
// equivalence
- Map<String, MForm> formMap = new HashMap<String, MForm>();
- for (MForm form : original) {
- formMap.put(form.getName(), form);
+ Map<String, MConfig> configMap = new HashMap<String, MConfig>();
+ for (MConfig config : original) {
+ configMap.put(config.getName(), config);
}
- for (MForm form : target) {
- List<MInput<?>> inputs = form.getInputs();
- MForm originalForm = formMap.get(form.getName());
- if(originalForm == null) {
- LOG.warn("Form: " + form.getName() + " not present in old " +
+ for (MConfig config : target) {
+ List<MInput<?>> inputs = config.getInputs();
+ MConfig originalConfig = configMap.get(config.getName());
+ if(originalConfig == null) {
+ LOG.warn("Config: " + config.getName() + " not present in old " +
"driver config. So it will not be transferred by the upgrader.");
continue;
}
for (MInput input : inputs) {
try {
- MInput originalInput = originalForm.getInput(input.getName());
+ MInput originalInput = originalConfig.getInput(input.getName());
input.setValue(originalInput.getValue());
} catch (SqoopException ex) {
LOG.warn("Input: " + input.getName() + " not present in old " +
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/core/src/main/java/org/apache/sqoop/driver/DriverConfigValidator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/driver/DriverConfigValidator.java b/core/src/main/java/org/apache/sqoop/driver/DriverConfigValidator.java
new file mode 100644
index 0000000..9c3b660
--- /dev/null
+++ b/core/src/main/java/org/apache/sqoop/driver/DriverConfigValidator.java
@@ -0,0 +1,46 @@
+/**
+ * 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.driver;
+
+import org.apache.sqoop.driver.configuration.DriverConfiguration;
+import org.apache.sqoop.driver.configuration.ThrottlingConfig;
+import org.apache.sqoop.validation.Status;
+import org.apache.sqoop.validation.ConfigValidator;
+import org.apache.sqoop.validation.Validator;
+
+public class DriverConfigValidator extends Validator {
+ @Override
+ public ConfigValidator validateConfigForJob(Object jobConfiguration) {
+ ConfigValidator validation = new ConfigValidator(DriverConfiguration.class);
+ DriverConfiguration conf = (DriverConfiguration)jobConfiguration;
+ validateThrottlingConfig(validation,conf.throttlingConfig);
+
+ return validation;
+ };
+
+ private void validateThrottlingConfig(ConfigValidator validation, ThrottlingConfig throttlingConfig) {
+ if(throttlingConfig.numExtractors != null && throttlingConfig.numExtractors < 1) {
+ validation.addMessage(Status.UNACCEPTABLE, "throttlingConfig", "numExtractors", "You need to specify more than one extractor");
+ }
+
+ if(throttlingConfig.numLoaders != null && throttlingConfig.numLoaders < 1) {
+ validation.addMessage(Status.UNACCEPTABLE, "throttlingConfig", "numLoaders", "You need to specify more than one loader");
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/core/src/main/java/org/apache/sqoop/driver/DriverValidator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/driver/DriverValidator.java b/core/src/main/java/org/apache/sqoop/driver/DriverValidator.java
deleted file mode 100644
index 9cc51dd..0000000
--- a/core/src/main/java/org/apache/sqoop/driver/DriverValidator.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.driver;
-
-import org.apache.sqoop.driver.configuration.LinkConfiguration;
-import org.apache.sqoop.driver.configuration.JobConfiguration;
-import org.apache.sqoop.driver.configuration.ThrottlingForm;
-import org.apache.sqoop.validation.Status;
-import org.apache.sqoop.validation.Validation;
-import org.apache.sqoop.validation.Validator;
-
-public class DriverValidator extends Validator {
- @Override
- public Validation validateLink(Object linkConfiguration) {
- Validation validation = new Validation(LinkConfiguration.class);
- // No validation on link object
- return validation;
- }
-
- @Override
- public Validation validateJob(Object jobConfiguration) {
- Validation validation = new Validation(JobConfiguration.class);
- JobConfiguration conf = (JobConfiguration)jobConfiguration;
- validateThrottlingForm(validation,conf.throttling);
-
- return validation;
- };
-
- private void validateThrottlingForm(Validation validation, ThrottlingForm throttling) {
- if(throttling.extractors != null && throttling.extractors < 1) {
- validation.addMessage(Status.UNACCEPTABLE, "throttling", "extractors", "You need to specify more than one extractor");
- }
-
- if(throttling.loaders != null && throttling.loaders < 1) {
- validation.addMessage(Status.UNACCEPTABLE, "throttling", "loaders", "You need to specify more than one loader");
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/core/src/main/java/org/apache/sqoop/driver/JobManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/driver/JobManager.java b/core/src/main/java/org/apache/sqoop/driver/JobManager.java
index e91c436..df2a5ab 100644
--- a/core/src/main/java/org/apache/sqoop/driver/JobManager.java
+++ b/core/src/main/java/org/apache/sqoop/driver/JobManager.java
@@ -30,13 +30,13 @@ import org.apache.sqoop.connector.spi.SqoopConnector;
import org.apache.sqoop.core.Reconfigurable;
import org.apache.sqoop.core.SqoopConfiguration;
import org.apache.sqoop.core.SqoopConfiguration.CoreConfigurationListener;
-import org.apache.sqoop.driver.configuration.JobConfiguration;
+import org.apache.sqoop.driver.configuration.DriverConfiguration;
import org.apache.sqoop.job.etl.Destroyer;
import org.apache.sqoop.job.etl.DestroyerContext;
import org.apache.sqoop.job.etl.Initializer;
import org.apache.sqoop.job.etl.InitializerContext;
import org.apache.sqoop.job.etl.Transferable;
-import org.apache.sqoop.model.FormUtils;
+import org.apache.sqoop.model.ConfigUtils;
import org.apache.sqoop.model.MJob;
import org.apache.sqoop.model.MLink;
import org.apache.sqoop.model.MSubmission;
@@ -311,35 +311,27 @@ public class JobManager implements Reconfigurable {
SqoopConnector toConnector = getConnector(toConnection.getConnectorId());
validateSupportedDirection(toConnector, Direction.TO);
- // Transform config to fromConnector specific classes
- Object fromConnectionConfig = ClassUtils.instantiate(fromConnector
- .getLinkConfigurationClass());
- FormUtils.fromForms(fromConnection.getConnectorPart().getForms(), fromConnectionConfig);
+ // link config for the FROM part of the job
+ Object fromLinkConfig = ClassUtils.instantiate(fromConnector.getLinkConfigurationClass());
+ ConfigUtils.fromConfigs(fromConnection.getConnectorLinkConfig().getConfigs(), fromLinkConfig);
- // Transform config to toConnector specific classes
- Object toConnectorConfig = ClassUtils
- .instantiate(toConnector.getLinkConfigurationClass());
- FormUtils.fromForms(toConnection.getConnectorPart().getForms(), toConnectorConfig);
+ // link config for the TO part of the job
+ Object toLinkConfig = ClassUtils.instantiate(toConnector.getLinkConfigurationClass());
+ ConfigUtils.fromConfigs(toConnection.getConnectorLinkConfig().getConfigs(), toLinkConfig);
+ // from config for the job
Object fromJob = ClassUtils.instantiate(fromConnector.getJobConfigurationClass(Direction.FROM));
- FormUtils.fromForms(job.getConnectorPart(Direction.FROM).getForms(), fromJob);
+ ConfigUtils.fromConfigs(job.getJobConfig(Direction.FROM).getConfigs(), fromJob);
+ // to config for the job
Object toJob = ClassUtils.instantiate(toConnector.getJobConfigurationClass(Direction.TO));
- FormUtils.fromForms(job.getConnectorPart(Direction.TO).getForms(), toJob);
+ ConfigUtils.fromConfigs(job.getJobConfig(Direction.TO).getConfigs(), toJob);
- // Transform framework specific configs
- // Q(VB) : Aren't the following 2 exactly the same?
- Object fromDriverConnection = ClassUtils.instantiate(Driver.getInstance()
- .getLinkConfigurationClass());
- FormUtils.fromForms(fromConnection.getFrameworkPart().getForms(), fromDriverConnection);
+ // the only driver config for the job
+ Object driverConfig = ClassUtils
+ .instantiate(Driver.getInstance().getDriverConfigurationGroupClass());
+ ConfigUtils.fromConfigs(job.getDriverConfig().getConfigs(), driverConfig);
- Object toDriverConnection = ClassUtils.instantiate(Driver.getInstance()
- .getLinkConfigurationClass());
- FormUtils.fromForms(toConnection.getFrameworkPart().getForms(), toDriverConnection);
-
- Object frameworkJob = ClassUtils.instantiate(Driver.getInstance()
- .getJobConfigurationClass());
- FormUtils.fromForms(job.getFrameworkPart().getForms(), frameworkJob);
// Create a job request for submit/execution
JobRequest jobRequest = executionEngine.createJobRequest();
@@ -347,14 +339,14 @@ public class JobManager implements Reconfigurable {
jobRequest.setSummary(submission);
jobRequest.setConnector(Direction.FROM, fromConnector);
jobRequest.setConnector(Direction.TO, toConnector);
- jobRequest.setConnectorLinkConfig(Direction.FROM, fromConnectionConfig);
- jobRequest.setConnectorLinkConfig(Direction.TO, toConnectorConfig);
- jobRequest.setConnectorJobConfig(Direction.FROM, fromJob);
- jobRequest.setConnectorJobConfig(Direction.TO, toJob);
- // TODO(Abe): Should we actually have 2 different Driver Connection config objects?
- jobRequest.setFrameworkLinkConfig(Direction.FROM, fromDriverConnection);
- jobRequest.setFrameworkLinkConfig(Direction.TO, toDriverConnection);
- jobRequest.setFrameworkJobConfig(frameworkJob);
+
+ jobRequest.setConnectorLinkConfig(Direction.FROM, fromLinkConfig);
+ jobRequest.setConnectorLinkConfig(Direction.TO, toLinkConfig);
+
+ jobRequest.setJobConfig(Direction.FROM, fromJob);
+ jobRequest.setJobConfig(Direction.TO, toJob);
+
+ jobRequest.setDriverConfig(driverConfig);
jobRequest.setJobName(job.getName());
jobRequest.setJobId(job.getPersistenceId());
jobRequest.setNotificationUrl(notificationBaseUrl + jobId);
@@ -453,12 +445,12 @@ public class JobManager implements Reconfigurable {
// Initialize submission from the connector perspective
initializer.initialize(initializerContext, jobRequest.getConnectorLinkConfig(direction),
- jobRequest.getConnectorJobConfig(direction));
+ jobRequest.getJobConfig(direction));
return initializer.getSchema(initializerContext,
jobRequest.getConnectorLinkConfig(direction),
- jobRequest.getConnectorJobConfig(direction));
+ jobRequest.getJobConfig(direction));
}
private void addConnectorInitializerJars(JobRequest jobRequest, Direction direction) {
@@ -468,7 +460,7 @@ public class JobManager implements Reconfigurable {
// Add job specific jars to
jobRequest.addJars(initializer.getJars(initializerContext,
jobRequest.getConnectorLinkConfig(direction),
- jobRequest.getConnectorJobConfig(direction)));
+ jobRequest.getJobConfig(direction)));
}
private Initializer getConnectorInitializer(JobRequest jobRequest, Direction direction) {
@@ -488,12 +480,12 @@ public class JobManager implements Reconfigurable {
}
void prepareJob(JobRequest request) {
- JobConfiguration jobConfiguration = (JobConfiguration) request.getFrameworkJobConfig();
+ DriverConfiguration jobConfiguration = (DriverConfiguration) request.getDriverConfig();
// We're directly moving configured number of extractors and loaders to
// underlying request object. In the future we might need to throttle this
// count based on other running jobs to meet our SLAs.
- request.setExtractors(jobConfiguration.throttling.extractors);
- request.setLoaders(jobConfiguration.throttling.loaders);
+ request.setExtractors(jobConfiguration.throttlingConfig.numExtractors);
+ request.setLoaders(jobConfiguration.throttlingConfig.numLoaders);
// Delegate rest of the job to execution engine
executionEngine.prepareJob(request);
@@ -532,9 +524,9 @@ public class JobManager implements Reconfigurable {
// destroy submission from connector perspective
fromDestroyer.destroy(fromDestroyerContext, request.getConnectorLinkConfig(Direction.FROM),
- request.getConnectorJobConfig(Direction.FROM));
+ request.getJobConfig(Direction.FROM));
toDestroyer.destroy(toDestroyerContext, request.getConnectorLinkConfig(Direction.TO),
- request.getConnectorJobConfig(Direction.TO));
+ request.getJobConfig(Direction.TO));
}
public MSubmission stop(long jobId, HttpEventContext ctx) {
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/core/src/main/java/org/apache/sqoop/driver/JobRequest.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/driver/JobRequest.java b/core/src/main/java/org/apache/sqoop/driver/JobRequest.java
index 63e1e49..2666320 100644
--- a/core/src/main/java/org/apache/sqoop/driver/JobRequest.java
+++ b/core/src/main/java/org/apache/sqoop/driver/JobRequest.java
@@ -78,11 +78,11 @@ public class JobRequest {
*/
Object fromConnectorLinkConfig;
Object toConnectorLinkConfig;
- Object fromConnectorJobConfig;
- Object toConnectorJobConfig;
- Object fromFrameworkLinkConfig;
- Object toFrameworkLinkConfig;
- Object frameworkJobConfig;
+
+ Object fromConfig;
+ Object toConfig;
+
+ Object driverConfig;
/**
* Connector context (submission specific configuration)
@@ -124,10 +124,9 @@ public class JobRequest {
this.toConnector = null;
this.fromConnectorLinkConfig = null;
this.toConnectorLinkConfig = null;
- this.fromConnectorJobConfig = null;
- this.toConnectorJobConfig = null;
- this.fromFrameworkLinkConfig = null;
- this.toFrameworkLinkConfig = null;
+ this.fromConfig = null;
+ this.toConfig = null;
+ this.driverConfig = null;
}
public MSubmission getSummary() {
@@ -244,64 +243,38 @@ public class JobRequest {
}
}
- public Object getConnectorJobConfig(Direction type) {
- switch(type) {
- case FROM:
- return fromConnectorJobConfig;
-
- case TO:
- return toConnectorJobConfig;
-
- default:
- throw new SqoopException(DirectionError.DIRECTION_0000, "Direction: " + type);
- }
- }
-
- public void setConnectorJobConfig(Direction type, Object config) {
- switch(type) {
- case FROM:
- fromConnectorJobConfig = config;
- break;
- case TO:
- toConnectorJobConfig = config;
- break;
- default:
- throw new SqoopException(DirectionError.DIRECTION_0000, "Direction: " + type);
- }
- }
-
- public Object getFrameworkLinkConfig(Direction type) {
+ public Object getJobConfig(Direction type) {
switch(type) {
case FROM:
- return fromFrameworkLinkConfig;
+ return fromConfig;
case TO:
- return toFrameworkLinkConfig;
+ return toConfig;
default:
throw new SqoopException(DirectionError.DIRECTION_0000, "Direction: " + type);
}
}
- public void setFrameworkLinkConfig(Direction type, Object config) {
+ public void setJobConfig(Direction type, Object config) {
switch(type) {
case FROM:
- fromFrameworkLinkConfig = config;
+ fromConfig = config;
break;
case TO:
- toFrameworkLinkConfig = config;
+ toConfig = config;
break;
default:
throw new SqoopException(DirectionError.DIRECTION_0000, "Direction: " + type);
}
}
- public Object getFrameworkJobConfig() {
- return frameworkJobConfig;
+ public Object getDriverConfig() {
+ return driverConfig;
}
- public void setFrameworkJobConfig(Object config) {
- frameworkJobConfig = config;
+ public void setDriverConfig(Object config) {
+ driverConfig = config;
}
public MutableMapContext getConnectorContext(Direction type) {
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/core/src/main/java/org/apache/sqoop/driver/configuration/DriverConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/driver/configuration/DriverConfiguration.java b/core/src/main/java/org/apache/sqoop/driver/configuration/DriverConfiguration.java
new file mode 100644
index 0000000..d4e2254
--- /dev/null
+++ b/core/src/main/java/org/apache/sqoop/driver/configuration/DriverConfiguration.java
@@ -0,0 +1,34 @@
+/**
+ * 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.driver.configuration;
+
+import org.apache.sqoop.model.ConfigurationClass;
+import org.apache.sqoop.model.Config;
+
+/**
+ * Representing the core job configuration
+ */
+@ConfigurationClass
+public class DriverConfiguration {
+ @Config
+ public ThrottlingConfig throttlingConfig;
+
+ public DriverConfiguration() {
+ throttlingConfig = new ThrottlingConfig();
+ }
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/core/src/main/java/org/apache/sqoop/driver/configuration/JobConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/driver/configuration/JobConfiguration.java b/core/src/main/java/org/apache/sqoop/driver/configuration/JobConfiguration.java
deleted file mode 100644
index 908a4eb..0000000
--- a/core/src/main/java/org/apache/sqoop/driver/configuration/JobConfiguration.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.driver.configuration;
-
-import org.apache.sqoop.model.ConfigurationClass;
-import org.apache.sqoop.model.Form;
-
-/**
- * Representing the core job configuration
- */
-@ConfigurationClass
-public class JobConfiguration {
- @Form
- public ThrottlingForm throttling;
-
- public JobConfiguration() {
- throttling = new ThrottlingForm();
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/core/src/main/java/org/apache/sqoop/driver/configuration/LinkConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/driver/configuration/LinkConfiguration.java b/core/src/main/java/org/apache/sqoop/driver/configuration/LinkConfiguration.java
deleted file mode 100644
index 3202844..0000000
--- a/core/src/main/java/org/apache/sqoop/driver/configuration/LinkConfiguration.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.driver.configuration;
-
-import org.apache.sqoop.model.ConfigurationClass;
-
-/**
- * Representing the core link configuration
- */
-@ConfigurationClass
-public class LinkConfiguration {
-
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/core/src/main/java/org/apache/sqoop/driver/configuration/ThrottlingConfig.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/driver/configuration/ThrottlingConfig.java b/core/src/main/java/org/apache/sqoop/driver/configuration/ThrottlingConfig.java
new file mode 100644
index 0000000..357d8e5
--- /dev/null
+++ b/core/src/main/java/org/apache/sqoop/driver/configuration/ThrottlingConfig.java
@@ -0,0 +1,32 @@
+/**
+ * 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.driver.configuration;
+
+import org.apache.sqoop.model.ConfigClass;
+import org.apache.sqoop.model.Input;
+
+/**
+ * Config to set up number of loaders and extractors
+ */
+@ConfigClass
+public class ThrottlingConfig {
+
+ @Input public Integer numExtractors;
+
+ @Input public Integer numLoaders;
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/core/src/main/java/org/apache/sqoop/driver/configuration/ThrottlingForm.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/driver/configuration/ThrottlingForm.java b/core/src/main/java/org/apache/sqoop/driver/configuration/ThrottlingForm.java
deleted file mode 100644
index e73007e..0000000
--- a/core/src/main/java/org/apache/sqoop/driver/configuration/ThrottlingForm.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.driver.configuration;
-
-import org.apache.sqoop.model.FormClass;
-import org.apache.sqoop.model.Input;
-
-/**
- * Form to set up number of loaders and extractors
- */
-@FormClass
-public class ThrottlingForm {
-
- @Input public Integer extractors;
-
- @Input public Integer loaders;
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java b/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
index 3466116..3ade247 100644
--- a/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
+++ b/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
@@ -25,7 +25,7 @@ import org.apache.log4j.Logger;
import org.apache.sqoop.common.SqoopException;
import org.apache.sqoop.model.MLink;
import org.apache.sqoop.model.MConnector;
-import org.apache.sqoop.model.MDriverConfig;
+import org.apache.sqoop.model.MDriver;
import org.apache.sqoop.model.MJob;
import org.apache.sqoop.model.MSubmission;
@@ -51,7 +51,7 @@ public class JdbcRepository extends Repository {
/**
* Do what is needed to be done with given link object.
*
- * @param conn Connection to metadata repository.
+ * @param conn Connection to the repository.
* @return Arbitrary value
*/
Object doIt(Connection conn) throws Exception;
@@ -158,8 +158,8 @@ public class JdbcRepository extends Repository {
public Object doIt(Connection conn) throws Exception {
String connectorUniqueName = mConnector.getUniqueName();
- MConnector result = handler.findConnector(connectorUniqueName, conn);
- if (result == null) {
+ MConnector connectorResult = handler.findConnector(connectorUniqueName, conn);
+ if (connectorResult == null) {
handler.registerConnector(mConnector, conn);
return mConnector;
} else {
@@ -167,23 +167,23 @@ public class JdbcRepository extends Repository {
// For now, use the "string" versions itself - later we should
// probably include a build number or something that is
// monotonically increasing.
- if (result.getUniqueName().equals(mConnector.getUniqueName()) &&
- mConnector.getVersion().compareTo(result.getVersion()) > 0) {
+ if (connectorResult.getUniqueName().equals(mConnector.getUniqueName()) &&
+ mConnector.getVersion().compareTo(connectorResult.getVersion()) > 0) {
if (autoUpgrade) {
- upgradeConnector(result, mConnector);
+ upgradeConnector(connectorResult, mConnector);
return mConnector;
} else {
throw new SqoopException(RepositoryError.JDBCREPO_0026,
"Connector: " + mConnector.getUniqueName());
}
}
- if (!result.equals(mConnector)) {
+ if (!connectorResult.equals(mConnector)) {
throw new SqoopException(RepositoryError.JDBCREPO_0013,
"Connector: " + mConnector.getUniqueName()
+ " given: " + mConnector
- + " found: " + result);
+ + " found: " + connectorResult);
}
- return result;
+ return connectorResult;
}
}
});
@@ -220,27 +220,27 @@ public class JdbcRepository extends Repository {
* {@inheritDoc}
*/
@Override
- public MDriverConfig registerDriverConfig(final MDriverConfig mDriverConfig, final boolean autoUpgrade) {
- return (MDriverConfig) doWithConnection(new DoWithConnection() {
+ public MDriver registerDriver(final MDriver mDriver, final boolean autoUpgrade) {
+ return (MDriver) doWithConnection(new DoWithConnection() {
@Override
public Object doIt(Connection conn) {
- MDriverConfig result = handler.findDriverConfig(conn);
- if (result == null) {
- handler.registerDriverConfig(mDriverConfig, conn);
- return mDriverConfig;
+ MDriver existingDriverConfig = handler.findDriver(conn);
+ if (existingDriverConfig == null) {
+ handler.registerDriver(mDriver, conn);
+ return mDriver;
} else {
// We're currently not serializing version into repository
// so let's just compare the structure to see if we need upgrade.
- if(!mDriverConfig.equals(result)) {
+ if(!mDriver.equals(existingDriverConfig)) {
if (autoUpgrade) {
- upgradeDriverConfig(mDriverConfig);
- return mDriverConfig;
+ upgradeDriver(mDriver);
+ return mDriver;
} else {
throw new SqoopException(RepositoryError.JDBCREPO_0026,
- "DriverConfig: " + mDriverConfig.getPersistenceId());
+ "DriverConfig: " + mDriver.getPersistenceId());
}
}
- return result;
+ return existingDriverConfig;
}
}
});
@@ -664,11 +664,11 @@ public class JdbcRepository extends Repository {
}
- protected void updateDriverConfig(final MDriverConfig mDriverConfig, RepositoryTransaction tx) {
+ protected void updateDriver(final MDriver mDriver, RepositoryTransaction tx) {
doWithConnection(new DoWithConnection() {
@Override
public Object doIt(Connection conn) throws Exception {
- handler.updateDriverConfig(mDriverConfig, conn);
+ handler.updateDriver(mDriver, conn);
return null;
}
}, (JdbcRepositoryTransaction) tx);
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryHandler.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryHandler.java b/core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryHandler.java
index a743491..97de893 100644
--- a/core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryHandler.java
+++ b/core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryHandler.java
@@ -23,7 +23,7 @@ import java.util.List;
import org.apache.sqoop.model.MLink;
import org.apache.sqoop.model.MConnector;
-import org.apache.sqoop.model.MDriverConfig;
+import org.apache.sqoop.model.MDriver;
import org.apache.sqoop.model.MJob;
import org.apache.sqoop.model.MSubmission;
@@ -113,11 +113,11 @@ public abstract class JdbcRepositoryHandler {
* which may not have changed). After this operation the repository is
* guaranteed to only have the new forms specified in this object.
*
- * @param mDriverConfig The new data to be inserted into the repository for
+ * @param mDriver The new data to be inserted into the repository for
* the driverConfig.
* @param conn JDBC link for querying repository
*/
- public abstract void updateDriverConfig(MDriverConfig mDriverConfig, Connection conn);
+ public abstract void updateDriver(MDriver mDriver, Connection conn);
/**
@@ -127,7 +127,7 @@ public abstract class JdbcRepositoryHandler {
* @return null if driverConfig are not yet present in repository or
* loaded representation.
*/
- public abstract MDriverConfig findDriverConfig(Connection conn);
+ public abstract MDriver findDriver(Connection conn);
/**
* Register driver config in repository.
@@ -138,7 +138,7 @@ public abstract class JdbcRepositoryHandler {
* @param driverConfig Driver config that should be registered.
* @param conn JDBC link for querying repository.
*/
- public abstract void registerDriverConfig(MDriverConfig driverConfig, Connection conn);
+ public abstract void registerDriver(MDriver driverConfig, Connection conn);
/**
* Return true if repository tables exists and are suitable for use.
@@ -243,7 +243,7 @@ public abstract class JdbcRepositoryHandler {
*
* @param linkId Link id
* @param conn Connection to the repository
- * @return Deserialized form of the link that is saved in repository
+ * @return Deserialized config of the link that is saved in repository
*/
public abstract MLink findLink(long linkId, Connection conn);
@@ -323,7 +323,7 @@ public abstract class JdbcRepositoryHandler {
*
* @param jobId Job id
* @param conn Connection to the repository
- * @return Deserialized form of the job that is present in the repository
+ * @return Deserialized config of the job that is present in the repository
*/
public abstract MJob findJob(long jobId, Connection conn);
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/core/src/main/java/org/apache/sqoop/repository/Repository.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/repository/Repository.java b/core/src/main/java/org/apache/sqoop/repository/Repository.java
index ea1608a..95c7a4d 100644
--- a/core/src/main/java/org/apache/sqoop/repository/Repository.java
+++ b/core/src/main/java/org/apache/sqoop/repository/Repository.java
@@ -28,18 +28,21 @@ import org.apache.sqoop.connector.ConnectorManager;
import org.apache.sqoop.connector.spi.RepositoryUpgrader;
import org.apache.sqoop.connector.spi.SqoopConnector;
import org.apache.sqoop.driver.Driver;
-import org.apache.sqoop.model.FormUtils;
-import org.apache.sqoop.model.MConnectionForms;
+import org.apache.sqoop.json.DriverBean;
+import org.apache.sqoop.model.ConfigUtils;
+import org.apache.sqoop.model.MConfig;
import org.apache.sqoop.model.MConnector;
+import org.apache.sqoop.model.MDriver;
import org.apache.sqoop.model.MDriverConfig;
-import org.apache.sqoop.model.MForm;
+import org.apache.sqoop.model.MFromConfig;
import org.apache.sqoop.model.MJob;
-import org.apache.sqoop.model.MJobForms;
import org.apache.sqoop.model.MLink;
+import org.apache.sqoop.model.MLinkConfig;
import org.apache.sqoop.model.MPersistableEntity;
import org.apache.sqoop.model.MSubmission;
+import org.apache.sqoop.model.MToConfig;
import org.apache.sqoop.utils.ClassUtils;
-import org.apache.sqoop.validation.Validation;
+import org.apache.sqoop.validation.ConfigValidator;
import org.apache.sqoop.validation.Validator;
@@ -76,15 +79,26 @@ public abstract class Repository {
/**
* Registers given connector in the repository and return registered
- * variant. This method might return an exception in case that
- * given connector are already registered with different structure.
+ * variant. This method might return an exception in case that
+ * given connector are already registered with different structure
*
* @param mConnector the connector to be registered
- * autoupgrade whether to upgrade driver config automatically
+ * @param autoUpgrade whether to upgrade driver config automatically
* @return Registered connector structure
*/
public abstract MConnector registerConnector(MConnector mConnector, boolean autoUpgrade);
+ /**
+ * Registers given driver and its config in the repository and return registered
+ * variant. This method might return an exception in case that the
+ * given driverConfig are already registered with different structure
+ *
+ * @param mDriverConfig driverConfig to be registered
+ * @param autoUpgrade whether to upgrade driverConfig automatically
+ * @return Registered connector structure
+ */
+ public abstract MDriver registerDriver(MDriver mDriverConfig, boolean autoUpgrade);
+
/**
* Search for connector with given name in repository.
*
@@ -103,18 +117,6 @@ public abstract class Repository {
*/
public abstract List<MConnector> findConnectors();
-
- /**
- * Registers given driverConfig in the repository and return registered
- * variant. This method might return an exception in case that the
- * given driverConfig are already registered with different structure.
- *
- * @param mDriverConfig driverConfig to be registered
- * autoupgrade whether to upgrade driverConfig automatically
- * @return Registered connector structure
- */
- public abstract MDriverConfig registerDriverConfig(MDriverConfig mDriverConfig, boolean autoUpgrade);
-
/**
* Save given link to repository. This link must not be already
* present in the repository otherwise exception will be thrown.
@@ -164,7 +166,7 @@ public abstract class Repository {
* Find link with given id in repository.
*
* @param id Link id
- * @return Deserialized form of the link that is saved in repository
+ * @return Deserialized config of the link that is saved in repository
*/
public abstract MLink findLink(long id);
@@ -184,7 +186,7 @@ public abstract class Repository {
public abstract void createJob(MJob job);
/**
- * Update given job metadata in repository. This object must already be saved
+ * Update given job entity in repository. This object must already be saved
* in repository otherwise exception will be thrown.
*
* @param job Job object that should be updated in the repository
@@ -192,7 +194,7 @@ public abstract class Repository {
public abstract void updateJob(MJob job);
/**
- * Update given job metadata in repository. This object must already be saved
+ * Update given job entity in repository. This object must already be saved
* in repository otherwise exception will be thrown.
*
* @param job Job object that should be updated in the repository
@@ -204,7 +206,7 @@ public abstract class Repository {
public abstract void updateJob(MJob job, RepositoryTransaction tx);
/**
- * Enable or disable job with given id from metadata repository
+ * Enable or disable job with given id from entity repository
*
* @param id Job object that is going to be enabled or disabled
* @param enabled Enable or disable
@@ -212,7 +214,7 @@ public abstract class Repository {
public abstract void enableJob(long id, boolean enabled);
/**
- * Delete job with given id from metadata repository.
+ * Delete job with given id from entity repository.
*
* @param id Job id that should be removed
*/
@@ -222,7 +224,7 @@ public abstract class Repository {
* Find job object with given id.
*
* @param id Job id
- * @return Deserialized form of job loaded from repository
+ * @return Deserialized config of job loaded from repository
*/
public abstract MJob findJob(long id);
@@ -288,8 +290,7 @@ public abstract class Repository {
* @param connectorID Connector ID whose links should be fetched
* @return List of MLink that use <code>connectorID</code>.
*/
- public abstract List<MLink> findLinksForConnector(long
- connectorID);
+ public abstract List<MLink> findLinksForConnector(long connectorID);
/**
* Retrieve jobs which use the given link.
@@ -297,17 +298,16 @@ public abstract class Repository {
* @param connectorID Connector ID whose jobs should be fetched
* @return List of MJobs that use <code>linkID</code>.
*/
- public abstract List<MJob> findJobsForConnector(long
- connectorID);
+ public abstract List<MJob> findJobsForConnector(long connectorID);
/**
* Update the connector with the new data supplied in the
- * <tt>newConnector</tt>. Also Update all forms associated with this
- * connector in the repository with the forms specified in
+ * <tt>newConnector</tt>. Also Update all configs associated with this
+ * connector in the repository with the configs specified in
* <tt>mConnector</tt>. <tt>mConnector </tt> must
- * minimally have the connectorID and all required forms (including ones
+ * minimally have the connectorID and all required configs (including ones
* which may not have changed). After this operation the repository is
- * guaranteed to only have the new forms specified in this object.
+ * guaranteed to only have the new configs specified in this object.
*
* @param newConnector The new data to be inserted into the repository for
* this connector.
@@ -319,22 +319,22 @@ public abstract class Repository {
protected abstract void updateConnector(MConnector newConnector, RepositoryTransaction tx);
/**
- * Update the driverConfig with the new data supplied in the
- * <tt>mDriverConfig</tt>. Also Update all forms associated with the driverConfig
- * in the repository with the forms specified in
+ * Update the driver with the new data supplied in the
+ * <tt>mDriverConfig</tt>. Also Update all configs associated with the driverConfig
+ * in the repository with the configs specified in
* <tt>mDriverConfig</tt>. <tt>mDriverConfig </tt> must
- * minimally have the connectorID and all required forms (including ones
+ * minimally have the connectorID and all required configs (including ones
* which may not have changed). After this operation the repository is
- * guaranteed to only have the new forms specified in this object.
+ * guaranteed to only have the new configs specified in this object.
*
- * @param mDriverConfig The new data to be inserted into the repository for
+ * @param mDriver The new data to be inserted into the repository for
* the driverConfig.
* @param tx The repository transaction to use to push the data to the
* repository. If this is null, a new transaction will be created.
* method will not call begin, commit,
* rollback or close on this transaction.
*/
- protected abstract void updateDriverConfig(MDriverConfig mDriverConfig, RepositoryTransaction tx);
+ protected abstract void updateDriver(MDriver mDriver, RepositoryTransaction tx);
/**
* Delete all inputs for a job
@@ -365,6 +365,13 @@ public abstract class Repository {
}
}
+ private void deleteJobs(List<MJob> jobs, RepositoryTransaction tx) {
+ for (MJob job : jobs) {
+ deleteJobInputs(job.getPersistenceId(), tx);
+ }
+ }
+
+
/**
* Upgrade the connector with the same {@linkplain MConnector#uniqueName}
* in the repository with values from <code>newConnector</code>.
@@ -377,7 +384,7 @@ public abstract class Repository {
* upgraded.
*/
public final void upgradeConnector(MConnector oldConnector, MConnector newConnector) {
- LOG.info("Upgrading metadata for connector: " + oldConnector.getUniqueName());
+ LOG.info("Upgrading connector: " + oldConnector.getUniqueName());
long connectorID = oldConnector.getPersistenceId();
newConnector.setPersistenceId(connectorID);
/* Algorithms:
@@ -385,8 +392,8 @@ public abstract class Repository {
* 2. Get all links associated with the connector.
* 3. Get all jobs associated with the connector.
* 4. Delete the inputs for all of the jobs and links (in that order)
- * 5. Remove all inputs and forms associated with the connector, and
- * register the new forms and inputs.
+ * 5. Remove all inputs and configs associated with the connector, and
+ * register the new configs and inputs.
* 6. Create new links and jobs with connector part being the ones
* returned by the upgrader.
* 7. Validate new links and jobs with connector's validator
@@ -401,85 +408,63 @@ public abstract class Repository {
ConnectorManager.getInstance().getConnector(newConnector
.getUniqueName());
- Validator validator = connector.getValidator();
-
+ Validator connectorConfigValidator = connector.getConfigValidator();
boolean upgradeSuccessful = true;
-
RepositoryUpgrader upgrader = connector.getRepositoryUpgrader();
- List<MLink> links = findLinksForConnector(
- connectorID);
- List<MJob> jobs = findJobsForConnector(connectorID);
+ List<MLink> linksByConnector = findLinksForConnector(connectorID);
+ List<MJob> jobsByConnector = findJobsForConnector(connectorID);
// -- BEGIN TXN --
tx = getTransaction();
tx.begin();
- deletelinksAndJobs(links, jobs, tx);
+ deletelinksAndJobs(linksByConnector, jobsByConnector, tx);
updateConnector(newConnector, tx);
- for (MLink link : links) {
- // Make a new copy of the forms from the connector,
- // else the values will get set in the forms in the connector for
- // each link.
- List<MForm> forms = newConnector.getConnectionForms().clone(false).getForms();
- MConnectionForms newlinkForms = new MConnectionForms(forms);
- upgrader.upgrade(link.getConnectorPart(), newlinkForms);
- MLink newlink = new MLink(link, newlinkForms, link.getFrameworkPart());
-
- // Transform form structures to objects for validations
+ for (MLink oldLink : linksByConnector) {
+ // Make a new copy of the configs
+ List<MConfig> linkConfig = newConnector.getLinkConfig().clone(false).getConfigs();
+ MLinkConfig newLinkConfig = new MLinkConfig(linkConfig);
+ MLinkConfig oldLinkConfig = oldLink.getConnectorLinkConfig();
+ upgrader.upgrade(oldLinkConfig, newLinkConfig);
+
+ MLink newlink = new MLink(oldLink, newLinkConfig);
+
Object newConfigurationObject = ClassUtils.instantiate(connector.getLinkConfigurationClass());
- FormUtils.fromForms(newlink.getConnectorPart().getForms(), newConfigurationObject);
+ ConfigUtils.fromConfigs(newlink.getConnectorLinkConfig().getConfigs(), newConfigurationObject);
- Validation validation = validator.validateLink(newConfigurationObject);
- if (validation.getStatus().canProceed()) {
+ ConfigValidator configValidator = connectorConfigValidator.validateConfigForLink(newConfigurationObject);
+ if (configValidator.getStatus().canProceed()) {
updateLink(newlink, tx);
} else {
- logInvalidModelObject("link", newlink, validation);
+ logInvalidModelObject("link", newlink, configValidator);
upgradeSuccessful = false;
}
}
- for (MJob job : jobs) {
- // Make a new copy of the forms from the connector,
- // else the values will get set in the forms in the connector for
+ for (MJob job : jobsByConnector) {
+ // Make a new copy of the configs
+ // else the values will get set in the configs in the connector for
// each job.
- List<MForm> fromForms = newConnector.getJobForms(Direction.FROM).clone(false).getForms();
- List<MForm> toForms = newConnector.getJobForms(Direction.TO).clone(false).getForms();
+ List<MConfig> fromConfig = newConnector.getConfig(Direction.FROM).clone(false).getConfigs();
+ List<MConfig> toConfig = newConnector.getConfig(Direction.TO).clone(false).getConfigs();
- // New FROM direction forms, old TO direction forms.
+ // New FROM direction configs, old TO direction configs.
if (job.getConnectorId(Direction.FROM) == newConnector.getPersistenceId()) {
- MJobForms newFromJobForms = new MJobForms(fromForms);
- MJobForms oldToJobForms = job.getConnectorPart(Direction.TO);
- upgrader.upgrade(job.getConnectorPart(Direction.FROM), newFromJobForms);
- MJob newJob = new MJob(job, newFromJobForms, oldToJobForms, job.getFrameworkPart());
- updateJob(newJob, tx);
+ MFromConfig newFromConfig = new MFromConfig(fromConfig);
+ MFromConfig oldFromCOnfig = job.getFromJobConfig();
+ upgrader.upgrade(oldFromCOnfig, newFromConfig);
- // Transform form structures to objects for validations
-// Object newFromConfigurationObject = ClassUtils.instantiate(connector.getJobConfigurationClass(Direction.FROM));
-// FormUtils.fromForms(newJob.getConnectorPart(Direction.FROM).getForms(), newFromConfigurationObject);
-// Validation fromValidation = validator.validateJob(newFromConfigurationObject);
-// if (fromValidation.getStatus().canProceed()) {
-// updateJob(newJob, tx);
-// } else {
-// logInvalidModelObject("job", newJob, fromValidation);
-// upgradeSuccessful = false;
-// }
+ MToConfig oldToConfig = job.getToJobConfig();
+ MJob newJob = new MJob(job, newFromConfig, oldToConfig, job.getDriverConfig());
+ updateJob(newJob, tx);
}
- // Old FROM direction forms, new TO direction forms.
+ // Old FROM direction configs, new TO direction configs.
if (job.getConnectorId(Direction.TO) == newConnector.getPersistenceId()) {
- MJobForms oldFromJobForms = job.getConnectorPart(Direction.FROM);
- MJobForms newToJobForms = new MJobForms(toForms);
- upgrader.upgrade(job.getConnectorPart(Direction.TO), newToJobForms);
- MJob newJob = new MJob(job, oldFromJobForms, newToJobForms, job.getFrameworkPart());
- updateJob(newJob, tx);
- // Transform form structures to objects for validations
-// Object newToConfigurationObject = ClassUtils.instantiate(connector.getJobConfigurationClass(Direction.TO));
-// FormUtils.fromForms(newJob.getConnectorPart(Direction.TO).getForms(), newToConfigurationObject);
-// Validation toValidation = validator.validateJob(newToConfigurationObject);
-// if (toValidation.getStatus().canProceed()) {
-// updateJob(newJob, tx);
-// } else {
-// logInvalidModelObject("job", newJob, toValidation);
-// upgradeSuccessful = false;
-// }
+ MToConfig oldToConfig = job.getToJobConfig();
+ MToConfig newToConfig = new MToConfig(toConfig);
+ upgrader.upgrade(oldToConfig, newToConfig);
+ MFromConfig oldFromConfig = job.getFromJobConfig();
+ MJob newJob = new MJob(job, oldFromConfig, newToConfig, job.getDriverConfig());
+ updateJob(newJob, tx);
}
}
@@ -506,60 +491,35 @@ public abstract class Repository {
}
}
- public final void upgradeDriverConfig(MDriverConfig driverConfig) {
- LOG.info("Upgrading driver config");
+ public final void upgradeDriver(MDriver driver) {
+ LOG.info("Upgrading driver");
RepositoryTransaction tx = null;
try {
- RepositoryUpgrader upgrader = Driver.getInstance()
+ RepositoryUpgrader driverConfigUpgrader = Driver.getInstance()
.getDriverConfigRepositoryUpgrader();
- List<MLink> links = findLinks();
List<MJob> jobs = findJobs();
Validator validator = Driver.getInstance().getValidator();
-
boolean upgradeSuccessful = true;
// -- BEGIN TXN --
tx = getTransaction();
tx.begin();
- deletelinksAndJobs(links, jobs, tx);
- updateDriverConfig(driverConfig, tx);
- for (MLink link : links) {
- // Make a new copy of the forms from the connector,
- // else the values will get set in the forms in the connector for
- // each link.
- // @TODO(Abe): From/To link forms.
- List<MForm> forms = driverConfig.getConnectionForms().clone(false).getForms();
- MConnectionForms newlinkForms = new MConnectionForms(forms);
- upgrader.upgrade(link.getFrameworkPart(), newlinkForms);
- MLink newlink = new MLink(link, link.getConnectorPart(), newlinkForms);
-
- // Transform form structures to objects for validations
- Object newConfigurationObject = ClassUtils.instantiate(Driver.getInstance().getLinkConfigurationClass());
- FormUtils.fromForms(newlink.getFrameworkPart().getForms(), newConfigurationObject);
-
- Validation validation = validator.validateLink(newConfigurationObject);
- if (validation.getStatus().canProceed()) {
- updateLink(newlink, tx);
- } else {
- logInvalidModelObject("link", newlink, validation);
- upgradeSuccessful = false;
- }
- }
+ deleteJobs(jobs, tx);
+ updateDriver(driver, tx);
+
for (MJob job : jobs) {
- // Make a new copy of the forms from the framework,
- // else the values will get set in the forms in the connector for
- // each link.
- List<MForm> forms = driverConfig.getJobForms().clone(false).getForms();
- MJobForms newJobForms = new MJobForms(forms);
- upgrader.upgrade(job.getFrameworkPart(), newJobForms);
- MJob newJob = new MJob(job, job.getConnectorPart(Direction.FROM), job.getConnectorPart(Direction.TO), newJobForms);
-
- // Transform form structures to objects for validations
- Object newConfigurationObject = ClassUtils.instantiate(Driver.getInstance().getJobConfigurationClass());
- FormUtils.fromForms(newJob.getFrameworkPart().getForms(), newConfigurationObject);
-
- Validation validation = validator.validateJob(newConfigurationObject);
+ // Make a new copy of the configs
+ MDriverConfig driverConfig = driver.getDriverConfig().clone(false);
+ MDriver newDriver = new MDriver(driverConfig, DriverBean.CURRENT_DRIVER_VERSION);
+ driverConfigUpgrader.upgrade(job.getDriverConfig(), newDriver.getDriverConfig());
+ MJob newJob = new MJob(job, job.getFromJobConfig(), job.getToJobConfig(), newDriver.getDriverConfig());
+
+ // Transform config structures to objects for validations
+ Object newConfigurationObject = ClassUtils.instantiate(Driver.getInstance().getDriverConfigurationGroupClass());
+ ConfigUtils.fromConfigs(newJob.getDriverConfig().getConfigs(), newConfigurationObject);
+
+ ConfigValidator validation = validator.validateConfigForJob(newConfigurationObject);
if (validation.getStatus().canProceed()) {
updateJob(newJob, tx);
} else {
@@ -587,14 +547,14 @@ public abstract class Repository {
if(tx != null) {
tx.close();
}
- LOG.info("Driver config upgrade finished");
+ LOG.info("Driver upgrade finished");
}
}
- private void logInvalidModelObject(String objectType, MPersistableEntity entity, Validation validation) {
+ private void logInvalidModelObject(String objectType, MPersistableEntity entity, ConfigValidator validation) {
LOG.error("Upgrader created invalid " + objectType + " with id" + entity.getPersistenceId());
- for(Map.Entry<Validation.FormInput, Validation.Message> entry : validation.getMessages().entrySet()) {
+ for(Map.Entry<ConfigValidator.ConfigInput, ConfigValidator.Message> entry : validation.getMessages().entrySet()) {
LOG.error("\t" + entry.getKey() + ": " + entry.getValue());
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/core/src/main/java/org/apache/sqoop/repository/RepositoryManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/repository/RepositoryManager.java b/core/src/main/java/org/apache/sqoop/repository/RepositoryManager.java
index ae7be82..c2f8505 100644
--- a/core/src/main/java/org/apache/sqoop/repository/RepositoryManager.java
+++ b/core/src/main/java/org/apache/sqoop/repository/RepositoryManager.java
@@ -118,7 +118,7 @@ public class RepositoryManager implements Reconfigurable {
provider.initialize(context);
if(!immutableRepository) {
- LOG.info("Creating or upgrading on disk structures if necessary");
+ LOG.info("Creating or update respository internals at bootup");
provider.getRepository().createOrUpdateInternals();
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/core/src/main/resources/driver-config.properties
----------------------------------------------------------------------
diff --git a/core/src/main/resources/driver-config.properties b/core/src/main/resources/driver-config.properties
index 9ec5d9e..78c3b38 100644
--- a/core/src/main/resources/driver-config.properties
+++ b/core/src/main/resources/driver-config.properties
@@ -19,12 +19,12 @@
# Throttling From
#
-throttling.label = Throttling resources
-throttling.help = Set throttling boundaries to not overload your systems
+throttthrottlingConfigling.label = Throttling resources
+throttlingConfig.help = Set throttling boundaries to not overload your systems
-throttling.extractors.label = Extractors
-throttling.extractors.help = Number of extractors that Sqoop will use
+throttlingConfig.numExtractors.label = Extractors
+throttlingConfig.numExtractors.help = Number of extractors that Sqoop will use
-throttling.loaders.label = Loaders
-throttling.loaders.help = Number of loaders that Sqoop will use
+throttlingConfig.numLoaders.label = Loaders
+throttlingConfig.numLoaders.help = Number of loaders that Sqoop will use
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/core/src/test/java/org/apache/sqoop/driver/TestDriverConfigUpgrader.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/sqoop/driver/TestDriverConfigUpgrader.java b/core/src/test/java/org/apache/sqoop/driver/TestDriverConfigUpgrader.java
index 9c39d23..dc4e8c8 100644
--- a/core/src/test/java/org/apache/sqoop/driver/TestDriverConfigUpgrader.java
+++ b/core/src/test/java/org/apache/sqoop/driver/TestDriverConfigUpgrader.java
@@ -18,16 +18,19 @@
*/
package org.apache.sqoop.driver;
-import org.apache.sqoop.driver.DriverConfigUpgrader;
-import org.apache.sqoop.model.*;
-import org.junit.Before;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
import java.util.LinkedList;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import org.apache.sqoop.model.MConfig;
+import org.apache.sqoop.model.MConfigList;
+import org.apache.sqoop.model.MInput;
+import org.apache.sqoop.model.MIntegerInput;
+import org.apache.sqoop.model.MStringInput;
+import org.junit.Before;
+import org.junit.Test;
/**
*/
@@ -39,35 +42,14 @@ public class TestDriverConfigUpgrader {
public void initializeUpgrader() {
upgrader = new DriverConfigUpgrader();
}
-
- /**
- * We take the same forms on input and output and we
- * expect that all values will be correctly transferred.
- */
- @Test
- public void testConnectionUpgrade() {
- MConnectionForms original = connection1();
- MConnectionForms target = connection1();
-
- original.getStringInput("f1.s1").setValue("A");
- original.getStringInput("f1.s2").setValue("B");
- original.getIntegerInput("f1.i").setValue(3);
-
- upgrader.upgrade(original, target);
-
- assertEquals("A", target.getStringInput("f1.s1").getValue());
- assertEquals("B", target.getStringInput("f1.s2").getValue());
- assertEquals(3, (long)target.getIntegerInput("f1.i").getValue());
- }
-
/**
- * We take the same forms on input and output and we
+ * We take the same configs on input and output and we
* expect that all values will be correctly transferred.
*/
@Test
- public void testJobUpgrade() {
- MJobForms original = job1();
- MJobForms target = job1();
+ public void testJobConfigTyeUpgrade() {
+ MConfigList original = job();
+ MConfigList target = job();
original.getStringInput("f1.s1").setValue("A");
original.getStringInput("f1.s2").setValue("B");
@@ -85,8 +67,8 @@ public class TestDriverConfigUpgrader {
*/
@Test
public void testNonExistingInput() {
- MConnectionForms original = connection1();
- MConnectionForms target = connection2();
+ MConfigList original = job1();
+ MConfigList target = job2();
original.getStringInput("f1.s1").setValue("A");
original.getStringInput("f1.s2").setValue("B");
@@ -104,9 +86,9 @@ public class TestDriverConfigUpgrader {
* therefore is missing in the original.
*/
@Test
- public void testNonExistingForm() {
- MConnectionForms original = connection1();
- MConnectionForms target = connection3();
+ public void testNonExistingConfig() {
+ MConfigList original = job1();
+ MConfigList target = job3();
original.getStringInput("f1.s1").setValue("A");
original.getStringInput("f1.s2").setValue("B");
@@ -119,25 +101,25 @@ public class TestDriverConfigUpgrader {
assertNull(target.getIntegerInput("f2.i").getValue());
}
- MJobForms job1() {
- return new MJobForms(forms1());
+ MConfigList job() {
+ return new MConfigList(configs1());
}
- MConnectionForms connection1() {
- return new MConnectionForms(forms1());
+ MConfigList job1() {
+ return new MConfigList(configs1());
}
- MConnectionForms connection2() {
- return new MConnectionForms(forms2());
+ MConfigList job2() {
+ return new MConfigList(configs2());
}
- MConnectionForms connection3() {
- return new MConnectionForms(forms3());
+ MConfigList job3() {
+ return new MConfigList(configs3());
}
- List<MForm> forms1() {
- List<MForm> list = new LinkedList<MForm>();
- list.add(new MForm("f1", inputs1("f1")));
+ List<MConfig> configs1() {
+ List<MConfig> list = new LinkedList<MConfig>();
+ list.add(new MConfig("f1", inputs1("f1")));
return list;
}
@@ -149,9 +131,9 @@ public class TestDriverConfigUpgrader {
return list;
}
- List<MForm> forms2() {
- List<MForm> list = new LinkedList<MForm>();
- list.add(new MForm("f1", inputs2("f1")));
+ List<MConfig> configs2() {
+ List<MConfig> list = new LinkedList<MConfig>();
+ list.add(new MConfig("f1", inputs2("f1")));
return list;
}
@@ -163,9 +145,9 @@ public class TestDriverConfigUpgrader {
return list;
}
- List<MForm> forms3() {
- List<MForm> list = new LinkedList<MForm>();
- list.add(new MForm("f2", inputs1("f2")));
+ List<MConfig> configs3() {
+ List<MConfig> list = new LinkedList<MConfig>();
+ list.add(new MConfig("f2", inputs1("f2")));
return list;
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/sqoop/blob/f63c080d/core/src/test/java/org/apache/sqoop/driver/TestJobManager.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/sqoop/driver/TestJobManager.java b/core/src/test/java/org/apache/sqoop/driver/TestJobManager.java
index aa3af89..3b475c6 100644
--- a/core/src/test/java/org/apache/sqoop/driver/TestJobManager.java
+++ b/core/src/test/java/org/apache/sqoop/driver/TestJobManager.java
@@ -20,6 +20,13 @@ package org.apache.sqoop.driver;
import java.util.Arrays;
import java.util.List;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
import org.apache.sqoop.common.Direction;
import org.apache.sqoop.common.SqoopException;
import org.apache.sqoop.connector.ConnectorManager;
@@ -34,13 +41,6 @@ import org.apache.sqoop.request.HttpEventContext;
import org.junit.Before;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
public class TestJobManager {
private JobManager jobManager;
private SqoopConnector sqoopConnectorMock;
@@ -99,7 +99,7 @@ public class TestJobManager {
@Test
public void testGetLink() {
- MLink testLink = new MLink(123l, null, null);
+ MLink testLink = new MLink(123l, null);
testLink.setEnabled(true);
MLink mConnectionSpy = org.mockito.Mockito.spy(testLink);
when(repositoryManagerMock.getRepository()).thenReturn(jdbcRepoMock);
@@ -111,7 +111,7 @@ public class TestJobManager {
@Test
public void testDisabledLink() {
- MLink testConnection = new MLink(123l, null, null);
+ MLink testConnection = new MLink(123l, null);
testConnection.setPersistenceId(1234);
testConnection.setEnabled(false);
SqoopException exception = new SqoopException(DriverError.DRIVER_0010, "Connection id: "