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/28 19:38:36 UTC
git commit: SQOOP-1439: Sqoop2: Validations: Remove all references to
the original Validation infastructure
Repository: sqoop
Updated Branches:
refs/heads/sqoop2 9a1135d47 -> a203e7726
SQOOP-1439: Sqoop2: Validations: Remove all references to the original Validation infastructure
(Jarek Jarcec Cecho 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/a203e772
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/a203e772
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/a203e772
Branch: refs/heads/sqoop2
Commit: a203e77264d2ba89b962c38baf10bceead06877e
Parents: 9a1135d
Author: Abraham Elmahrek <ab...@elmahrek.com>
Authored: Tue Oct 28 10:57:21 2014 -0700
Committer: Abraham Elmahrek <ab...@elmahrek.com>
Committed: Tue Oct 28 11:37:58 2014 -0700
----------------------------------------------------------------------
.../apache/sqoop/json/JobValidationBean.java | 166 --------------
.../apache/sqoop/json/LinkValidationBean.java | 129 -----------
.../org/apache/sqoop/model/ConfigUtils.java | 40 ----
.../sqoop/validation/ConfigValidator.java | 228 -------------------
.../apache/sqoop/json/TestValidationBean.java | 160 -------------
.../apache/sqoop/validation/TestValidation.java | 149 ------------
.../connector/jdbc/GenericJdbcConnector.java | 8 -
.../connector/jdbc/GenericJdbcValidator.java | 125 ----------
.../sqoop/connector/hdfs/HdfsConnector.java | 15 --
.../sqoop/connector/hdfs/HdfsValidator.java | 75 ------
.../java/org/apache/sqoop/driver/Driver.java | 12 -
.../sqoop/driver/DriverConfigValidator.java | 45 ----
.../sqoop/connector/spi/SqoopConnector.java | 8 -
.../org/apache/sqoop/validation/Validator.java | 55 -----
14 files changed, 1215 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a203e772/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
deleted file mode 100644
index 9e78fe9..0000000
--- a/common/src/main/java/org/apache/sqoop/json/JobValidationBean.java
+++ /dev/null
@@ -1,166 +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.common.DirectionError;
-import org.apache.sqoop.common.SqoopException;
-import org.apache.sqoop.validation.Status;
-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 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 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 ConfigValidator fromConfigValidation;
- private ConfigValidator toConfigValidation;
- private ConfigValidator driverConfigValidation;
-
- // For "extract"
- public JobValidationBean(ConfigValidator fromConnector, ConfigValidator framework, ConfigValidator toConnector) {
- this();
-
- this.fromConfigValidation = fromConnector;
- this.toConfigValidation = toConnector;
- this.driverConfigValidation = framework;
- }
-
- // For "restore"
- public JobValidationBean() {
- id = null;
- }
-
- public ConfigValidator getConnectorValidation(Direction type) {
- switch(type) {
- case FROM:
- return fromConfigValidation;
-
- case TO:
- return toConfigValidation;
-
- default:
- throw new SqoopException(DirectionError.DIRECTION_0000, "Direction: " + type);
- }
- }
-
- public ConfigValidator getFrameworkValidation() {
- return driverConfigValidation;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public Long getId() {
- return id;
- }
-
- @SuppressWarnings("unchecked")
- public JSONObject extract(boolean skipSensitive) {
- JSONObject object = new JSONObject();
- JSONObject jobObject = new JSONObject();
-
- // Optionally transfer id
- if(id != null) {
- object.put(ID, id);
- }
-
- 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(ConfigValidator validation) {
- JSONObject object = new JSONObject();
-
- object.put(STATUS, validation.getStatus().name());
-
- JSONObject jsonMessages = new JSONObject();
- Map<ConfigValidator.ConfigInput, ConfigValidator.Message> messages = validation.getMessages();
-
- 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());
- jsonMessages.put(entry.getKey(), jsonEntry);
- }
-
- object.put(MESSAGES, jsonMessages);
-
- return object;
- }
-
- @Override
- public void restore(JSONObject jsonObject) {
- // Optional and accepting NULLs
- id = (Long) jsonObject.get(ID);
-
- JSONObject jobJsonObject = (JSONObject)jsonObject.get(JOB);
-
- fromConfigValidation = restoreValidation(
- (JSONObject)jobJsonObject.get(FROM));
- toConfigValidation = restoreValidation(
- (JSONObject)jobJsonObject.get(TO));
- driverConfigValidation = restoreValidation(
- (JSONObject)jobJsonObject.get(DRIVER));
- }
-
- public ConfigValidator restoreValidation(JSONObject jsonObject) {
-
- JSONObject jsonMessages = (JSONObject) jsonObject.get(MESSAGES);
- Map<ConfigValidator.ConfigInput, ConfigValidator.Message> messages
- = new HashMap<ConfigValidator.ConfigInput, ConfigValidator.Message>();
-
- for(Object key : jsonMessages.keySet()) {
- JSONObject jsonMessage = (JSONObject) jsonMessages.get(key);
-
- Status status = Status.valueOf((String) jsonMessage.get(STATUS));
- String stringMessage = (String) jsonMessage.get(MESSAGE);
-
- ConfigValidator.Message message
- = new ConfigValidator.Message(status, stringMessage);
-
- messages.put(new ConfigValidator.ConfigInput((String)key), message);
- }
-
- Status status = Status.valueOf((String) jsonObject.get(STATUS));
-
- return new ConfigValidator(status, messages);
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a203e772/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
deleted file mode 100644
index 682f63b..0000000
--- a/common/src/main/java/org/apache/sqoop/json/LinkValidationBean.java
+++ /dev/null
@@ -1,129 +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.validation.Status;
-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 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 STATUS = "status";
- private static final String MESSAGE = "message";
- private static final String MESSAGES = "messages";
-
- private Long id;
- private ConfigValidator linkConfigValidation;
-
- // For "extract"
- public LinkValidationBean(ConfigValidator linkConfigValidator) {
- this();
-
- this.linkConfigValidation = linkConfigValidator;
- }
-
- // For "restore"
- public LinkValidationBean() {
- id = null;
- }
-
- public ConfigValidator getLinkConfigValidator() {
- return linkConfigValidation;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public Long getId() {
- return id;
- }
-
- @SuppressWarnings("unchecked")
- public JSONObject extract(boolean skipSensitive) {
- JSONObject object = new JSONObject();
-
- // Optionally transfer id
- if(id != null) {
- object.put(ID, id);
- }
- object.put(LinkBean.LINK_CONFIG, extractValidation(linkConfigValidation));
- return object;
- }
-
- @SuppressWarnings("unchecked")
- private JSONObject extractValidation(ConfigValidator validation) {
- JSONObject object = new JSONObject();
-
- object.put(STATUS, validation.getStatus().name());
-
- JSONObject jsonMessages = new JSONObject();
- Map<ConfigValidator.ConfigInput, ConfigValidator.Message> messages = validation.getMessages();
-
- 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());
- jsonMessages.put(entry.getKey(), jsonEntry);
- }
-
- object.put(MESSAGES, jsonMessages);
-
- return object;
- }
-
- @Override
- public void restore(JSONObject jsonObject) {
- // Optional and accepting NULLs
- id = (Long) jsonObject.get(ID);
-
- linkConfigValidation = restoreValidation(
- (JSONObject)jsonObject.get(LinkBean.LINK_CONFIG));
- }
-
- public ConfigValidator restoreValidation(JSONObject jsonObject) {
- JSONObject jsonMessages = (JSONObject) jsonObject.get(MESSAGES);
- Map<ConfigValidator.ConfigInput, ConfigValidator.Message> messages
- = new HashMap<ConfigValidator.ConfigInput, ConfigValidator.Message>();
-
- for(Object key : jsonMessages.keySet()) {
- JSONObject jsonMessage = (JSONObject) jsonMessages.get(key);
-
- Status status = Status.valueOf((String) jsonMessage.get(STATUS));
- String stringMessage = (String) jsonMessage.get(MESSAGE);
-
- ConfigValidator.Message message
- = new ConfigValidator.Message(status, stringMessage);
-
- messages.put(new ConfigValidator.ConfigInput((String)key), message);
- }
-
- Status status = Status.valueOf((String) jsonObject.get(STATUS));
-
- return new ConfigValidator(status, messages);
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a203e772/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
index 923a943..40db6f4 100644
--- a/common/src/main/java/org/apache/sqoop/model/ConfigUtils.java
+++ b/common/src/main/java/org/apache/sqoop/model/ConfigUtils.java
@@ -22,8 +22,6 @@ import org.apache.sqoop.common.SqoopException;
import org.apache.sqoop.utils.ClassUtils;
import org.apache.sqoop.validation.ConfigValidationRunner;
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;
@@ -318,44 +316,6 @@ public class ConfigUtils {
}
/**
- * 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
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a203e772/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
deleted file mode 100644
index eac789e..0000000
--- a/common/src/main/java/org/apache/sqoop/validation/ConfigValidator.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;
-
-/**
- * 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/a203e772/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
deleted file mode 100644
index fc5b21d..0000000
--- a/common/src/test/java/org/apache/sqoop/json/TestValidationBean.java
+++ /dev/null
@@ -1,160 +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 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.json.simple.JSONObject;
-import org.json.simple.JSONValue;
-import org.junit.Test;
-
-/**
- *
- */
-public class TestValidationBean {
-
- @Test
- public void testJobValidationBeanSerialization() {
- // Serialize it to JSON object
- JobValidationBean bean = new JobValidationBean(
- getValidation(Status.FINE),
- getValidation(Status.UNACCEPTABLE),
- getValidation(Status.FINE)
- );
- JSONObject json = bean.extract(false);
-
- // "Move" it across network in text config
- String string = json.toJSONString();
-
- // Retrieved transferred object
- JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
- JobValidationBean retrievedBean = new JobValidationBean();
- retrievedBean.restore(retrievedJson);
-
- assertNull(retrievedBean.getId());
-
- ConfigValidator.ConfigInput fa = new ConfigValidator.ConfigInput("c", "i");
- ConfigValidator.ConfigInput fb = new ConfigValidator.ConfigInput("c2", "i2");
-
- ConfigValidator fromConnector = retrievedBean.getConnectorValidation(Direction.FROM);
- assertEquals(Status.FINE, fromConnector.getStatus());
- assertEquals(2, fromConnector.getMessages().size());
- assertTrue(fromConnector.getMessages().containsKey(fa));
- assertEquals(new ConfigValidator.Message(Status.FINE, "d"),
- fromConnector.getMessages().get(fa));
-
- ConfigValidator toConnector = retrievedBean.getConnectorValidation(Direction.TO);
- assertEquals(Status.FINE, toConnector.getStatus());
- assertEquals(2, toConnector.getMessages().size());
- assertTrue(toConnector.getMessages().containsKey(fa));
- assertEquals(new ConfigValidator.Message(Status.FINE, "d"),
- toConnector.getMessages().get(fa));
-
- ConfigValidator framework = retrievedBean.getFrameworkValidation();
- assertEquals(Status.UNACCEPTABLE, framework.getStatus());
- assertEquals(2, framework.getMessages().size());
- assertTrue(framework.getMessages().containsKey(fb));
- assertEquals(new ConfigValidator.Message(Status.UNACCEPTABLE, "c"),
- framework.getMessages().get(fb));
- }
-
- @Test
- public void testJobValidationBeanId() {
- // Serialize it to JSON object
- JobValidationBean jobValidatioBean = new JobValidationBean(
- getValidation(Status.FINE),
- getValidation(Status.FINE),
- getValidation(Status.FINE)
- );
- jobValidatioBean.setId((long) 10);
- JSONObject json = jobValidatioBean.extract(false);
-
- // "Move" it across network in text config
- String string = json.toJSONString();
-
- // Retrieved transferred object
- JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
- JobValidationBean retrievedBean = new JobValidationBean();
- retrievedBean.restore(retrievedJson);
-
- assertEquals((Long)(long) 10, retrievedBean.getId());
- }
-
- @Test
- public void testLinkValidationBeanSerialization() {
- // Serialize it to JSON object
- LinkValidationBean bean = new LinkValidationBean(
- getValidation(Status.FINE));
- JSONObject json = bean.extract(false);
-
- // "Move" it across network in text config
- String string = json.toJSONString();
-
- // Retrieved transferred object
- JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
- LinkValidationBean retrievedBean = new LinkValidationBean();
- retrievedBean.restore(retrievedJson);
-
- assertNull(retrievedBean.getId());
-
- 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(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)
- );
- bean.setId((long) 10);
- JSONObject json = bean.extract(false);
-
- // "Move" it across network in text config
- String string = json.toJSONString();
-
- // Retrieved transferred object
- JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
- LinkValidationBean retrievedBean = new LinkValidationBean();
- retrievedBean.restore(retrievedJson);
-
- assertEquals((Long)(long) 10, retrievedBean.getId());
- }
-
- public ConfigValidator getValidation(Status status) {
- Map<ConfigValidator.ConfigInput, ConfigValidator.Message> messages = new HashMap<ConfigValidator.ConfigInput, ConfigValidator.Message>();
-
- 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 ConfigValidator(status, messages);
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a203e772/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
deleted file mode 100644
index 16a8bbe..0000000
--- a/common/src/test/java/org/apache/sqoop/validation/TestValidation.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.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.ConfigValidator.ConfigInput;
-import org.apache.sqoop.validation.ConfigValidator.Message;
-import org.junit.Test;
-
-/**
- * Test class for org.apache.sqoop.validation.Validation
- */
-public class TestValidation {
-
- /**
- * Initialization test
- */
- @Test
- public void testInitialization() {
- /* Check initialization with 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 */
- 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<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<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<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);
- 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());
- }
-
- /**
- * Test for Validation.ForInput
- */
- public void testConfigInput() {
- ConfigValidator.ConfigInput fi = new ConfigValidator.ConfigInput("test\\.test");
- assertNotNull(fi);
-
- /* Passing null */
- try {
- new ConfigValidator.ConfigInput(null);
- fail("Assert error is expected");
- } catch (AssertionError e) {
- assertTrue(true);
- }
-
- /* Passing empty and check exception messages */
- try {
- new ConfigValidator.ConfigInput("");
- fail("SqoopException is expected");
- } catch (SqoopException e) {
- assertEquals(ConfigValidationError.VALIDATION_0003.getMessage(), e
- .getErrorCode().getMessage());
- }
-
- /* Passing value and check */
- ConfigValidator.ConfigInput fi2 = new ConfigValidator.ConfigInput("config\\.input");
- assertEquals("config\\", fi2.getConfig());
- assertEquals("input", fi2.getInput());
-
- /* Check equals */
- ConfigValidator.ConfigInput fiOne = new ConfigValidator.ConfigInput("config\\.input");
- ConfigValidator.ConfigInput fiTwo = new ConfigValidator.ConfigInput("config\\.input");
- assertEquals(fiOne, fiTwo);
-
- /* toString() method check */
- assertEquals("config\\.input", fiOne.toString());
-
- // Checking null as input field (config validation)
- ConfigValidator.ConfigInput fi3 = new ConfigInput("config");
- assertEquals("config", fi3.getConfig());
- assertNull(fi3.getInput());
- assertEquals("config", fi3.toString());
-
- }
-
- /**
- * Test for Validation.Message
- */
- public void testMessage() {
- /* Passing null */
- ConfigValidator.Message msg1 = new ConfigValidator.Message(null, null);
- assertNull(msg1.getStatus());
- assertNull(msg1.getMessage());
-
- /* Passing values */
- ConfigValidator.Message msg2 = new ConfigValidator.Message(Status.FINE, "sqoop");
- assertEquals(Status.FINE, msg2.getStatus());
- assertEquals("sqoop", msg2.getMessage());
-
- /* Check for equal */
- ConfigValidator.Message msg3 = new ConfigValidator.Message(Status.FINE, "sqoop");
- assertEquals(msg2, msg3);
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a203e772/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 3a6621a..c233ed5 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
@@ -29,12 +29,9 @@ import org.apache.sqoop.connector.spi.ConnectorConfigurableUpgrader;
import org.apache.sqoop.job.etl.From;
import org.apache.sqoop.job.etl.To;
import org.apache.sqoop.connector.spi.SqoopConnector;
-import org.apache.sqoop.validation.Validator;
public class GenericJdbcConnector extends SqoopConnector {
- private static GenericJdbcValidator genericJdbcValidator = new GenericJdbcValidator();
-
private static final From FROM = new From(
GenericJdbcFromInitializer.class,
GenericJdbcPartitioner.class,
@@ -94,11 +91,6 @@ public class GenericJdbcConnector extends SqoopConnector {
}
@Override
- public Validator getConfigValidator() {
- return genericJdbcValidator;
- }
-
- @Override
public ConnectorConfigurableUpgrader getConfigurableUpgrader() {
return new GenericJdbcConnectorUpgrader();
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a203e772/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
deleted file mode 100644
index 93989a4..0000000
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcValidator.java
+++ /dev/null
@@ -1,125 +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.connector.jdbc;
-
-import org.apache.sqoop.common.SqoopException;
-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.ConfigValidator;
-import org.apache.sqoop.validation.Validator;
-
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
-/**
- * Validator to ensure that user is supplying valid input
- */
-public class GenericJdbcValidator extends Validator {
-
- @Override
- public ConfigValidator validateConfigForLink(Object configuration) {
- ConfigValidator validation = new ConfigValidator(LinkConfiguration.class);
- LinkConfiguration linkConfig = (LinkConfiguration)configuration;
-
- if(linkConfig.linkConfig.jdbcDriver == null) {
- validation.addMessage(Status.UNACCEPTABLE, "link", "jdbcDriver", "Driver can't be empty");
- } else {
- try {
- Class.forName(linkConfig.linkConfig.jdbcDriver);
- } catch (ClassNotFoundException e) {
- validation.addMessage(Status.UNACCEPTABLE, "link", "jdbcDriver", "Can't load specified driver");
- }
- }
-
- if(linkConfig.linkConfig.connectionString == null) {
- validation.addMessage(Status.UNACCEPTABLE, "link", "connectionString", "JDBC URL can't be empty");
- } 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(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());
- }
-
- // Return final validation object
- return validation;
- }
-
- @Override
- public ConfigValidator validateConfigForJob(Object jobConfiguration) {
- if (jobConfiguration instanceof FromJobConfiguration) {
- return validateFromJobConfiguration((FromJobConfiguration)jobConfiguration);
- } else if (jobConfiguration instanceof ToJobConfiguration) {
- return validateToJobConfiguration((ToJobConfiguration)jobConfiguration);
- } else {
- throw new SqoopException(GenericJdbcConnectorError.GENERIC_JDBC_CONNECTOR_0020,
- "Configuration object for unknown direction.");
- }
- }
-
- 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");
- }
- if(configuration.toJobConfig.tableName != null && configuration.toJobConfig.sql != null) {
- validation.addMessage(Status.UNACCEPTABLE, "toJobConfig", "Both table name and SQL cannot be specified");
- }
- if(configuration.toJobConfig.tableName == null &&
- configuration.toJobConfig.stageTableName != null) {
- validation.addMessage(Status.UNACCEPTABLE, "toJobConfig",
- "Stage table name cannot be specified without specifying table name");
- }
- if(configuration.toJobConfig.stageTableName == null &&
- configuration.toJobConfig.clearStageTable != null) {
- validation.addMessage(Status.UNACCEPTABLE, "toJobConfig",
- "Clear stage table cannot be specified without specifying name of " +
- "the stage table.");
- }
-
- return validation;
- }
-
- 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");
- }
- if(configuration.fromJobConfig.tableName != null && configuration.fromJobConfig.sql != null) {
- validation.addMessage(Status.UNACCEPTABLE, "fromJobConfig", "Both table name and SQL cannot be specified");
- }
- if(configuration.fromJobConfig.schemaName != null && configuration.fromJobConfig.sql != null) {
- validation.addMessage(Status.UNACCEPTABLE, "fromJobConfig", "Both schema name and SQL cannot be specified");
- }
-
- if(configuration.fromJobConfig.sql != null && !configuration.fromJobConfig.sql.contains(GenericJdbcConnectorConstants.SQL_CONDITIONS_TOKEN)) {
- validation.addMessage(Status.UNACCEPTABLE, "fromJobConfig", "sql", "SQL statement must contain placeholder for auto generated "
- + "conditions - " + GenericJdbcConnectorConstants.SQL_CONDITIONS_TOKEN);
- }
-
- return validation;
- }
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a203e772/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 1640f80..f70142d 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
@@ -31,7 +31,6 @@ import org.apache.sqoop.connector.spi.ConnectorConfigurableUpgrader;
import org.apache.sqoop.connector.spi.SqoopConnector;
import org.apache.sqoop.job.etl.From;
import org.apache.sqoop.job.etl.To;
-import org.apache.sqoop.validation.Validator;
public class HdfsConnector extends SqoopConnector {
@@ -46,8 +45,6 @@ public class HdfsConnector extends SqoopConnector {
HdfsLoader.class,
HdfsToDestroyer.class);
- private static final HdfsValidator hdfsValidator = new HdfsValidator();
-
/**
* {@inheritDoc}
*
@@ -114,18 +111,6 @@ public class HdfsConnector extends 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.
- *
- * @return Validator object
- */
- @Override
- public Validator getConfigValidator() {
- return hdfsValidator;
- }
-
- /**
* Returns an {@linkplain org.apache.sqoop.connector.spi.ConnectorConfigurableUpgrader} object that can upgrade the
* connection and job configs.
*
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a203e772/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
deleted file mode 100644
index b995efd..0000000
--- a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsValidator.java
+++ /dev/null
@@ -1,75 +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.connector.hdfs;
-
-import org.apache.sqoop.connector.hdfs.configuration.*;
-import org.apache.sqoop.validation.Status;
-import org.apache.sqoop.validation.ConfigValidator;
-import org.apache.sqoop.validation.Validator;
-
-/**
- * Validate configuration objects
- */
-public class HdfsValidator extends Validator {
-
- @Override
- public ConfigValidator validateConfigForJob(Object jobConfiguration) {
- return super.validateConfigForJob(jobConfiguration);
- }
-
- @SuppressWarnings("unused")
- private ConfigValidator validateFromJob(Object jobConfiguration) {
- ConfigValidator validation = new ConfigValidator(FromJobConfiguration.class);
- FromJobConfiguration configuration = (FromJobConfiguration)jobConfiguration;
- validateInputConfig(validation, configuration.fromJobConfig);
- return validation;
- }
-
- @SuppressWarnings("unused")
- private ConfigValidator validateToJob(Object jobConfiguration) {
- ConfigValidator validation = new ConfigValidator(ToJobConfiguration.class);
- ToJobConfiguration configuration = (ToJobConfiguration)jobConfiguration;
- validateOutputConfig(validation, configuration.toJobConfig);
- return validation;
- }
-
- 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 validateOutputConfig(ConfigValidator validation, ToJobConfig outputConfig) {
- if(outputConfig.outputDirectory == null || outputConfig.outputDirectory.isEmpty()) {
- validation.addMessage(Status.UNACCEPTABLE, "output", "outputDirectory", "Output directory is empty");
- }
- 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 " + outputConfig.compression + " is being used.");
- }
- 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/a203e772/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 ce0b471..8d490dd 100644
--- a/core/src/main/java/org/apache/sqoop/driver/Driver.java
+++ b/core/src/main/java/org/apache/sqoop/driver/Driver.java
@@ -33,7 +33,6 @@ import org.apache.sqoop.model.MConfig;
import org.apache.sqoop.model.MDriver;
import org.apache.sqoop.model.MDriverConfig;
import org.apache.sqoop.repository.RepositoryManager;
-import org.apache.sqoop.validation.Validator;
/**
* Sqoop driver that manages the job lifecyle
@@ -97,11 +96,6 @@ public class Driver implements Reconfigurable {
private MDriver mDriver;
/**
- * Validator instance
- */
- private final Validator driverValidator;
-
- /**
* Driver config upgrader instance
*/
private final DriverUpgrader driverUpgrader;
@@ -120,8 +114,6 @@ public class Driver implements Reconfigurable {
List<MConfig> driverConfig = ConfigUtils.toConfigs(getDriverJobConfigurationClass());
mDriver = new MDriver(new MDriverConfig(driverConfig), DriverBean.CURRENT_DRIVER_VERSION);
- // Build validator
- driverValidator = new DriverConfigValidator();
// Build upgrader
driverUpgrader = new DriverUpgrader();
}
@@ -146,10 +138,6 @@ public class Driver implements Reconfigurable {
LOG.trace("Begin Driver destroy");
}
- public Validator getValidator() {
- return driverValidator;
- }
-
public DriverUpgrader getConfigurableUpgrader() {
return driverUpgrader;
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a203e772/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
deleted file mode 100644
index d9eb182..0000000
--- a/core/src/main/java/org/apache/sqoop/driver/DriverConfigValidator.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.driver;
-
-import org.apache.sqoop.driver.configuration.JobConfiguration;
-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(JobConfiguration.class);
- JobConfiguration conf = (JobConfiguration)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/a203e772/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 6ca6c18..ff6392e 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
@@ -27,7 +27,6 @@ import org.apache.sqoop.connector.idf.CSVIntermediateDataFormat;
import org.apache.sqoop.connector.idf.IntermediateDataFormat;
import org.apache.sqoop.job.etl.From;
import org.apache.sqoop.job.etl.To;
-import org.apache.sqoop.validation.Validator;
/**
* Service provider interface for Sqoop Connectors.
@@ -80,13 +79,6 @@ public abstract class SqoopConnector {
public abstract To getTo();
/**
- * Returns validation object that Sqoop can use to validate user
- * supplied configs before accepting them. This object will be used both link and job configs
- * @return Validator object
- */
- public abstract Validator getConfigValidator();
-
- /**
* Returns an {@linkplain ConnectorConfigurableUpgrader} object that can upgrade the
* configs related to the link and job
* @return RespositoryUpgrader object
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a203e772/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
deleted file mode 100644
index 2909905..0000000
--- a/spi/src/main/java/org/apache/sqoop/validation/Validator.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.validation;
-
-
-/**
- * Link and Job config validator.
- *
- * This class should be extended by connector to provide configuration
- * validation for link and job configuration objects.
- */
-public class Validator {
-
- /**
- * Validate link configuration object.
- *
- * @param linkConfiguration link config object to be validated
- * @return Validation status
- */
- public ConfigValidator validateConfigForLink(Object linkConfiguration) {
- return new ConfigValidator(EmptyClass.class);
- }
-
- /**
- * Validate configuration object for job .
- *
- * @param jobConfiguration Job config to be validated
- * @return Validation status
- */
- public ConfigValidator validateConfigForJob(Object jobConfiguration) {
- return new ConfigValidator(EmptyClass.class);
- }
-
- /**
- * Private class with no properties to properly create dump validation
- * objects.
- */
- private class EmptyClass {
- }
-}