You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sqoop.apache.org by ch...@apache.org on 2013/02/06 22:55:54 UTC
git commit: SQOOP-866: Introduce framework validations
Updated Branches:
refs/heads/sqoop2 25c785a4a -> 687e13050
SQOOP-866: Introduce framework validations
(Jarcec Cecho via Cheolsoo Park)
Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/687e1305
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/687e1305
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/687e1305
Branch: refs/heads/sqoop2
Commit: 687e13050c49d1b9d64b90c81f0ad2fc46d59adc
Parents: 25c785a
Author: Cheolsoo Park <ch...@apache.org>
Authored: Wed Feb 6 13:55:22 2013 -0800
Committer: Cheolsoo Park <ch...@apache.org>
Committed: Wed Feb 6 13:55:22 2013 -0800
----------------------------------------------------------------------
.../apache/sqoop/framework/FrameworkManager.java | 2 +-
.../apache/sqoop/framework/FrameworkValidator.java | 74 +++++++++++++++
2 files changed, 75 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/sqoop/blob/687e1305/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java b/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java
index 60c8f86..6aab2db 100644
--- a/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java
+++ b/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java
@@ -215,7 +215,7 @@ public class FrameworkManager {
mFramework = new MFramework(connectionForms, jobForms);
// Build validator
- validator = new Validator();
+ validator = new FrameworkValidator();
}
public synchronized void initialize() {
http://git-wip-us.apache.org/repos/asf/sqoop/blob/687e1305/core/src/main/java/org/apache/sqoop/framework/FrameworkValidator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/framework/FrameworkValidator.java b/core/src/main/java/org/apache/sqoop/framework/FrameworkValidator.java
new file mode 100644
index 0000000..6f9a6fc
--- /dev/null
+++ b/core/src/main/java/org/apache/sqoop/framework/FrameworkValidator.java
@@ -0,0 +1,74 @@
+/**
+ * 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.framework;
+
+import org.apache.sqoop.framework.configuration.ConnectionConfiguration;
+import org.apache.sqoop.framework.configuration.ExportJobConfiguration;
+import org.apache.sqoop.framework.configuration.ImportJobConfiguration;
+import org.apache.sqoop.model.MJob;
+import org.apache.sqoop.validation.Status;
+import org.apache.sqoop.validation.Validation;
+import org.apache.sqoop.validation.Validator;
+
+/**
+ * Validate framework configuration objects
+ */
+public class FrameworkValidator extends Validator {
+
+ @Override
+ public Validation validateConnection(Object connectionConfiguration) {
+ Validation validation = new Validation(ConnectionConfiguration.class);
+ // No validation on connection object
+ return validation;
+ }
+
+
+ @Override
+ public Validation validateJob(MJob.Type type, Object jobConfiguration) {
+ switch(type) {
+ case IMPORT:
+ return validateImportJob(jobConfiguration);
+ case EXPORT:
+ return validateExportJob(jobConfiguration);
+ default:
+ return super.validateJob(type, jobConfiguration);
+ }
+ }
+
+ private Validation validateExportJob(Object jobConfiguration) {
+ Validation validation = new Validation(ExportJobConfiguration.class);
+ ExportJobConfiguration configuration = (ExportJobConfiguration)jobConfiguration;
+
+ if(configuration.input.inputDirectory == null || configuration.input.inputDirectory.isEmpty()) {
+ validation.addMessage(Status.UNACCEPTABLE, "input", "inputDirectory", "Input directory is empty");
+ }
+
+ return validation;
+ }
+
+ private Validation validateImportJob(Object jobConfiguration) {
+ Validation validation = new Validation(ImportJobConfiguration.class);
+ ImportJobConfiguration configuration = (ImportJobConfiguration)jobConfiguration;
+
+ if(configuration.output.outputDirectory == null || configuration.output.outputDirectory.isEmpty()) {
+ validation.addMessage(Status.UNACCEPTABLE, "output", "outputDirectory", "Input directory is empty");
+ }
+
+ return validation;
+ }
+}