You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@falcon.apache.org by sr...@apache.org on 2014/01/29 08:04:01 UTC

[2/2] git commit: FALCON-281 Design Action Interface. Contributed by Srikanth Sundarrajan

FALCON-281 Design Action Interface. Contributed by Srikanth Sundarrajan


Project: http://git-wip-us.apache.org/repos/asf/incubator-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-falcon/commit/0d185522
Tree: http://git-wip-us.apache.org/repos/asf/incubator-falcon/tree/0d185522
Diff: http://git-wip-us.apache.org/repos/asf/incubator-falcon/diff/0d185522

Branch: refs/heads/master
Commit: 0d1855229cec9eb0b4c20b5b45b9ebe8b2eb15bd
Parents: 4ffdaef
Author: srikanth.sundarrajan <sr...@apache.org>
Authored: Wed Jan 29 12:33:49 2014 +0530
Committer: srikanth.sundarrajan <sr...@apache.org>
Committed: Wed Jan 29 12:33:49 2014 +0530

----------------------------------------------------------------------
 CHANGES.txt                                     |   2 +
 addons/designer/core/pom.xml                    |   5 +
 .../falcon/designer/primitive/Action.java       | 104 +++++++++++++++++++
 3 files changed, 111 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/0d185522/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 3ca68e5..bad5d5f 100755
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -5,6 +5,8 @@ Trunk (Unreleased)
   INCOMPATIBLE CHANGES
 
   NEW FEATURES
+    FALCON-281 Design Action Interface. (Srikanth Sundarrajan)
+
     FALCON-259 Design Transformation Interface. (Srikanth Sundarrajan)
 
     FALCON-26 Pipeline Monitor addition. (Suhas Vasu via Shwetha GS)

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/0d185522/addons/designer/core/pom.xml
----------------------------------------------------------------------
diff --git a/addons/designer/core/pom.xml b/addons/designer/core/pom.xml
index e5dc36d..1678862 100644
--- a/addons/designer/core/pom.xml
+++ b/addons/designer/core/pom.xml
@@ -47,6 +47,11 @@
             <groupId>net.sourceforge.findbugs</groupId>
             <artifactId>jsr305</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+        </dependency>
     </dependencies>
 
 </project>

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/0d185522/addons/designer/core/src/main/java/org/apache/falcon/designer/primitive/Action.java
----------------------------------------------------------------------
diff --git a/addons/designer/core/src/main/java/org/apache/falcon/designer/primitive/Action.java b/addons/designer/core/src/main/java/org/apache/falcon/designer/primitive/Action.java
new file mode 100644
index 0000000..c40e462
--- /dev/null
+++ b/addons/designer/core/src/main/java/org/apache/falcon/designer/primitive/Action.java
@@ -0,0 +1,104 @@
+/**
+ * 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.falcon.designer.primitive;
+
+import org.apache.commons.lang.NotImplementedException;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import java.net.URI;
+import java.util.Map;
+
+/**
+ * Actions are components of flows. They encapsulate an atomic
+ * execution unit in a flow. If an action is dependent on another
+ * action, then the action wont be started unless the preceding
+ * action is entirely complete.
+ *
+ * Few examples of Actions are
+ *   1. SSH Action, which executes a shell command on a remote host
+ *   2. Data Transform Action, which executes a collection of data transformation
+ *      as a single logical unit
+ *
+ * There are no restrictions imposed on an Action with respect to the input
+ * or the output such as in a Transformation.
+ */
+public abstract class Action extends Primitive {
+
+    protected final String type;
+
+    protected Action(@Nonnull String type) {
+        this.type = type;
+    }
+
+    @Nonnull
+    public String getType() {
+        return type;
+    }
+
+    /**
+     * Indicates whether this action has any output or not. If this function
+     * returns true, then {@link Action#outputKeys()} and {@link Action#outputFile()} ()}
+     * needs to be implemented by the concrete class.
+     *
+     * @return - True if the action has output that any downstream control or action
+     * can consume, false otherwise.
+     */
+    public abstract boolean hasOutput();
+
+    /**
+     * Are the keys that the action chooses to expose to the external world that
+     * can either be used to manage the flow control or be used as an input in a subsequent
+     * action within the context of a flow. Each key that may be output by this
+     * action would have to declared along with its return type {@link java.sql.Types}.
+     *
+     * If an action output key isn't white listed through this with a specific type,
+     * then default type is assumed {@link java.sql.Types#VARCHAR}. All output keys
+     * are nullable. If null the flow control can assume default values (which may vary
+     * depending on the data type. For ex: VARCHAR(""), NUMERIC(0), DATETIME(CURRENTTIME))
+     *
+     * @return - Output key name and its corresponding data type. If the output key
+     * doesn't conform to this data type, the flow may fail at runtime or may safely assume
+     * default value. The behavior is left to the implementation of the flow compiler
+     * and scheduler.
+     */
+    @Nullable
+    public Map<String, Integer> outputKeys() {
+        if (hasOutput()) {
+            throw new NotImplementedException(getClass() + "::outputKeys()");
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * Returns a file name as URI that can be mapped to generic hadoop file system
+     * implementation.
+     *
+     * @return - Fully qualified file name uri as understood by the hadoop file system.
+     */
+    @Nullable
+    public URI outputFile() {
+        if (hasOutput()) {
+            throw new NotImplementedException(getClass() + "::outputFile()");
+        } else {
+            return null;
+        }
+    }
+}