FALCON-927 Refactoring of entity helpers in falcon-regression. Contributed by 
Ruslan Ostafiychuk


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

Branch: refs/heads/master
Commit: 9520370a25eeb3621db9f48e72f40302993650dd
Parents: 4f2b524
Author: Ruslan Ostafiychuk <rostafiyc...@apache.org>
Authored: Wed Dec 3 09:07:59 2014 +0200
Committer: Ruslan Ostafiychuk <rostafiyc...@apache.org>
Committed: Wed Dec 3 11:29:45 2014 +0200

----------------------------------------------------------------------
 falcon-regression/CHANGES.txt                   |   2 +
 .../core/helpers/ClusterEntityHelperImpl.java   | 126 ----
 .../regression/core/helpers/ColoHelper.java     |  16 +-
 .../core/helpers/DataEntityHelperImpl.java      |  45 --
 .../core/helpers/FalconClientBuilder.java       | 177 ++++++
 .../core/helpers/ProcessEntityHelperImpl.java   |  41 --
 .../helpers/entity/AbstractEntityHelper.java    | 603 ++++++++++++++++++
 .../helpers/entity/ClusterEntityHelper.java     | 125 ++++
 .../helpers/entity/EntityHelperFactory.java     |  40 ++
 .../core/helpers/entity/FeedEntityHelper.java   |  44 ++
 .../helpers/entity/ProcessEntityHelper.java     |  40 ++
 .../core/interfaces/EntityHelperFactory.java    |  43 --
 .../core/interfaces/FalconClientBuilder.java    | 177 ------
 .../core/interfaces/IEntityManagerHelper.java   | 604 -------------------
 .../regression/core/supportClasses/Brother.java |   4 +-
 .../regression/core/util/CleanupUtil.java       |  14 +-
 .../regression/core/util/InstanceUtil.java      |   8 +-
 .../falcon/regression/core/util/Util.java       |  12 +-
 .../org/apache/falcon/request/BaseRequest.java  |   6 +-
 .../falcon/regression/FeedResumeTest.java       |   4 +-
 .../regression/entity/ListEntitiesTest.java     |  14 +-
 .../regression/lineage/EntitySummaryTest.java   |   6 +-
 .../regression/prism/PrismFeedDeleteTest.java   |   8 +-
 .../prism/PrismProcessDeleteTest.java           |   8 +-
 .../regression/security/ClusterAclTest.java     |   4 +-
 .../falcon/regression/security/EntityOp.java    |  26 +-
 .../falcon/regression/security/FeedAclTest.java |   4 +-
 .../regression/security/ProcessAclTest.java     |   4 +-
 28 files changed, 1100 insertions(+), 1105 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/9520370a/falcon-regression/CHANGES.txt
----------------------------------------------------------------------
diff --git a/falcon-regression/CHANGES.txt b/falcon-regression/CHANGES.txt
index ffcb6b5..52d4388 100644
--- a/falcon-regression/CHANGES.txt
+++ b/falcon-regression/CHANGES.txt
@@ -33,6 +33,8 @@ Trunk (Unreleased)
    via Samarth Gupta)
 
   IMPROVEMENTS
+   FALCON-927 Refactoring of entity helpers in falcon-regression (Ruslan 
Ostafiychuk)
+
    FALCON-928 Use falcon's checkstyle for falcon regression code (Raghav Kumar 
Gautam)
 
    FALCON-909 Remove names of the contributors from xmls and code (Ruslan 
Ostafiychuk)

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/9520370a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/ClusterEntityHelperImpl.java
----------------------------------------------------------------------
diff --git 
a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/ClusterEntityHelperImpl.java
 
b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/ClusterEntityHelperImpl.java
deleted file mode 100644
index 4e31f55..0000000
--- 
a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/ClusterEntityHelperImpl.java
+++ /dev/null
@@ -1,126 +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.falcon.regression.core.helpers;
-
-import org.apache.falcon.regression.core.interfaces.IEntityManagerHelper;
-import org.apache.falcon.regression.core.response.ServiceResponse;
-import org.apache.falcon.regression.core.util.Util;
-import org.apache.falcon.resource.InstancesResult;
-import org.apache.falcon.resource.InstancesSummaryResult;
-
-import java.io.IOException;
-import java.net.URISyntaxException;
-
-/** Helper class to work with cluster endpoints of a colo. */
-public class ClusterEntityHelperImpl extends IEntityManagerHelper {
-
-
-    private static final String INVALID_ERR = "Not Valid for Cluster Entity";
-
-    public ClusterEntityHelperImpl(String prefix) {
-        super(prefix);
-    }
-
-    public String getEntityType() {
-        return "cluster";
-    }
-
-    public String getEntityName(String entity) {
-        return Util.readEntityName(entity);
-    }
-
-    public ServiceResponse getStatus(String data, String user) {
-        throw new UnsupportedOperationException(INVALID_ERR);
-    }
-
-    public ServiceResponse resume(String data, String user) {
-        throw new UnsupportedOperationException(INVALID_ERR);
-    }
-
-    public ServiceResponse schedule(String data, String user) {
-        throw new UnsupportedOperationException(INVALID_ERR);
-    }
-
-    public ServiceResponse submitAndSchedule(String data, String user) {
-        throw new UnsupportedOperationException(INVALID_ERR);
-    }
-
-    public ServiceResponse suspend(String data, String user) {
-        throw new UnsupportedOperationException(INVALID_ERR);
-    }
-
-    @Override
-    public InstancesResult getRunningInstance(String name, String user) {
-        throw new UnsupportedOperationException(INVALID_ERR);
-    }
-
-    @Override
-    public InstancesResult getProcessInstanceStatus(
-        String readEntityName, String params, String user) {
-        throw new UnsupportedOperationException(INVALID_ERR);
-    }
-
-
-    public InstancesResult getProcessInstanceSuspend(
-        String readEntityName, String params, String user) {
-        throw new UnsupportedOperationException(INVALID_ERR);
-    }
-
-    @Override
-    public ServiceResponse update(String oldEntity, String newEntity, String 
user) {
-        throw new UnsupportedOperationException(INVALID_ERR);
-    }
-
-    @Override
-    public ServiceResponse update(String oldEntity, String newEntity, String 
updateTime,
-                                  String user) throws IOException {
-        throw new UnsupportedOperationException(INVALID_ERR);
-    }
-
-    @Override
-    public InstancesResult getProcessInstanceKill(String readEntityName,
-                                                         String string, String 
user) {
-        throw new UnsupportedOperationException(INVALID_ERR);
-    }
-
-    @Override
-    public InstancesResult getProcessInstanceRerun(
-        String readEntityName, String string, String user) {
-        throw new UnsupportedOperationException(INVALID_ERR);
-    }
-
-    @Override
-    public InstancesResult getProcessInstanceResume(
-        String readEntityName, String string, String user) {
-        throw new UnsupportedOperationException(INVALID_ERR);
-    }
-
-    @Override
-    public InstancesSummaryResult getInstanceSummary(String readEntityName,
-                                                     String string
-    ) throws
-        IOException, URISyntaxException {
-        throw new UnsupportedOperationException(INVALID_ERR);
-    }
-
-    @Override
-    public ServiceResponse getListByPipeline(String pipeline){
-        throw new UnsupportedOperationException(INVALID_ERR);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/9520370a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/ColoHelper.java
----------------------------------------------------------------------
diff --git 
a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/ColoHelper.java
 
b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/ColoHelper.java
index 3a3ddce..4528cb9 100644
--- 
a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/ColoHelper.java
+++ 
b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/ColoHelper.java
@@ -19,14 +19,14 @@
 package org.apache.falcon.regression.core.helpers;
 
 import org.apache.falcon.entity.v0.EntityType;
-import org.apache.falcon.regression.core.interfaces.EntityHelperFactory;
-import org.apache.falcon.regression.core.interfaces.IEntityManagerHelper;
+import org.apache.falcon.regression.core.helpers.entity.AbstractEntityHelper;
+import org.apache.falcon.regression.core.helpers.entity.EntityHelperFactory;
 
 /** Helper class to work with a colo. */
 public class ColoHelper {
-    private final IEntityManagerHelper clusterHelper;
-    private final IEntityManagerHelper processHelper;
-    private final IEntityManagerHelper feedHelper;
+    private final AbstractEntityHelper clusterHelper;
+    private final AbstractEntityHelper processHelper;
+    private final AbstractEntityHelper feedHelper;
     private String prefix;
 
     public ColoHelper(String prefix) {
@@ -36,15 +36,15 @@ public class ColoHelper {
         feedHelper = EntityHelperFactory.getEntityHelper(EntityType.FEED, 
prefix);
     }
 
-    public IEntityManagerHelper getClusterHelper() {
+    public AbstractEntityHelper getClusterHelper() {
         return clusterHelper;
     }
 
-    public IEntityManagerHelper getFeedHelper() {
+    public AbstractEntityHelper getFeedHelper() {
         return feedHelper;
     }
 
-    public IEntityManagerHelper getProcessHelper() {
+    public AbstractEntityHelper getProcessHelper() {
         return processHelper;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/9520370a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/DataEntityHelperImpl.java
----------------------------------------------------------------------
diff --git 
a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/DataEntityHelperImpl.java
 
b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/DataEntityHelperImpl.java
deleted file mode 100644
index 79c3b9c..0000000
--- 
a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/DataEntityHelperImpl.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.falcon.regression.core.helpers;
-
-import org.apache.falcon.regression.core.interfaces.IEntityManagerHelper;
-import org.apache.falcon.regression.core.response.ServiceResponse;
-import org.apache.falcon.regression.core.util.Util;
-
-/** Helper class to work with feed endpoints of a colo. */
-public class DataEntityHelperImpl extends IEntityManagerHelper {
-
-    public DataEntityHelperImpl(String prefix) {
-        super(prefix);
-    }
-
-    public String getEntityType() {
-        return "feed";
-    }
-
-    public String getEntityName(String entity) {
-        return Util.readEntityName(entity);
-    }
-
-    @Override
-    public ServiceResponse getListByPipeline(String pipeline){
-        throw new UnsupportedOperationException("Not valid for Feed Entity.");
-    }
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/9520370a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/FalconClientBuilder.java
----------------------------------------------------------------------
diff --git 
a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/FalconClientBuilder.java
 
b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/FalconClientBuilder.java
new file mode 100644
index 0000000..a5d2046
--- /dev/null
+++ 
b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/FalconClientBuilder.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.falcon.regression.core.helpers;
+
+import org.apache.commons.exec.CommandLine;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.builder.Builder;
+import org.apache.falcon.regression.core.enumsAndConstants.MerlinConstants;
+import org.apache.falcon.regression.core.util.Config;
+import org.apache.falcon.regression.core.util.OSUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * FalconClientBuilder is to be used for launching falcon client command.
+ */
+public final class FalconClientBuilder implements Builder<CommandLine> {
+    private final String user;
+    private final CommandLine commandLine;
+    private final List<String> args;
+    private final SuType suType;
+
+    private enum SuType {
+        /**
+         * Takes care of switching user on linux. Current implemented through 
sudo.
+         */
+        LIN_SUDO {
+            @Override
+            public CommandLine getCommandLine(String forUser) {
+                return CommandLine.parse("sudo").addArgument("-u")
+                    .addArgument(forUser).addArgument(FALCON_CLIENT_BINARY);
+            }
+            @Override
+            public void addArgsToCommandLine(CommandLine cmdLine, List<String> 
arguments) {
+                for (String arg : arguments) {
+                    cmdLine.addArgument(arg);
+                }
+            }
+        },
+        /**
+         * Takes care of switching user on windows. Needs to be implemented.
+         */
+        WIN_SU {
+            @Override
+            public CommandLine getCommandLine(String forUser) {
+                return CommandLine.parse(OSUtil.WIN_SU_BINARY)
+                    .addArgument("-u").addArgument(forUser)
+                    
.addArgument("-p").addArgument(MerlinConstants.getPasswordForUser(forUser))
+                    .addArgument(FALCON_CLIENT_BINARY);
+            }
+            @Override
+            public void addArgsToCommandLine(CommandLine cmdLine, List<String> 
arguments) {
+                String lastArg = StringUtils.join(arguments, " ");
+                cmdLine.addArgument(lastArg, true);
+            }
+        },
+        /**
+         * Takes care of the case where no user switch is required.
+         */
+        NONE {
+            @Override
+            public CommandLine getCommandLine(String forUser) {
+                return CommandLine.parse(FALCON_CLIENT_BINARY);
+            }
+            @Override
+            public void addArgsToCommandLine(CommandLine cmdLine, List<String> 
arguments) {
+                for (String arg : arguments) {
+                    cmdLine.addArgument(arg);
+                }
+            }
+        };
+
+        private static final String FALCON_CLIENT_BINARY =
+                Config.getProperty("falcon.client.binary", "falcon");
+        public abstract void addArgsToCommandLine(CommandLine cmdLine, 
List<String> arguments);
+        public abstract CommandLine getCommandLine(String forUser);
+    }
+
+    private FalconClientBuilder(String user) {
+        this.user = user;
+        args = new ArrayList<String>();
+        if (user == null) {
+            suType = SuType.NONE;
+            commandLine = suType.getCommandLine(null);
+        } else {
+            if (OSUtil.IS_WINDOWS) {
+                suType = SuType.WIN_SU;
+                commandLine = suType.getCommandLine(user);
+            } else {
+                suType = SuType.LIN_SUDO;
+                //attempting sudo su - root -c "falcon admin -version"
+                commandLine = suType.getCommandLine(user);
+            }
+        }
+    }
+
+    /**
+     * Get an instance of FalconClientBuilder.
+     * @return instance of FalconClientBuilder
+     */
+    public static FalconClientBuilder getBuilder() {
+        return new FalconClientBuilder(null);
+    }
+
+    /**
+     * Get an instance of FalconClientBuilder for the given user. It would do 
commandline
+     * construction in a way that the final command is run as given user.
+     * @return instance of FalconClientBuilder
+     */
+    public static FalconClientBuilder getBuilder(String user) {
+        return new FalconClientBuilder(user);
+    }
+
+    /**
+     * Add the given argument.
+     * @param arg argument to be added to builder
+     * @return this
+     */
+    private FalconClientBuilder addArg(String arg) {
+        args.add(arg);
+        return this;
+    }
+
+    /**
+     * Create submit command.
+     * @param entityType type of the entity
+     * @param fileName file containing the entity to be submitted
+     * @return this
+     */
+    public FalconClientBuilder getSubmitCommand(String entityType, String 
fileName) {
+        addArg("entity").addArg("-submit");
+        addArg("-type").addArg(entityType);
+        addArg("-file").addArg(fileName);
+        return this;
+    }
+
+    /**
+     * Create delete command.
+     * @param entityType type of the entity
+     * @param entityName name of the entity to be deleted
+     * @return this
+     */
+    public FalconClientBuilder getDeleteCommand(String entityType, String 
entityName) {
+        addArg("entity").addArg("-delete");
+        addArg("-type").addArg(entityType);
+        addArg("-name").addArg(entityName);
+        return this;
+    }
+
+
+    /**
+     * Build the CommandLine object for this FalconClientBuilder.
+     * @return instance of CommandLine object
+     */
+    @Override
+    public CommandLine build() {
+        suType.addArgsToCommandLine(commandLine, args);
+        return new CommandLine(commandLine);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/9520370a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/ProcessEntityHelperImpl.java
----------------------------------------------------------------------
diff --git 
a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/ProcessEntityHelperImpl.java
 
b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/ProcessEntityHelperImpl.java
deleted file mode 100644
index e86caaf..0000000
--- 
a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/ProcessEntityHelperImpl.java
+++ /dev/null
@@ -1,41 +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.falcon.regression.core.helpers;
-
-import org.apache.falcon.regression.core.interfaces.IEntityManagerHelper;
-import org.apache.falcon.regression.core.util.Util;
-
-/** Helper class to work with process endpoints of a colo. */
-public class ProcessEntityHelperImpl extends IEntityManagerHelper {
-
-    public ProcessEntityHelperImpl(String prefix) {
-        super(prefix);
-    }
-
-    public String getEntityType() {
-        return "process";
-    }
-
-    public String getEntityName(String entity) {
-        return Util.getProcessName(entity);
-    }
-
-}
-
-

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/9520370a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/entity/AbstractEntityHelper.java
----------------------------------------------------------------------
diff --git 
a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/entity/AbstractEntityHelper.java
 
b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/entity/AbstractEntityHelper.java
new file mode 100644
index 0000000..d5dec6e
--- /dev/null
+++ 
b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/entity/AbstractEntityHelper.java
@@ -0,0 +1,603 @@
+/**
+ * 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.regression.core.helpers.entity;
+
+import com.jcraft.jsch.JSchException;
+import org.apache.commons.exec.CommandLine;
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.apache.falcon.regression.core.helpers.FalconClientBuilder;
+import org.apache.falcon.regression.core.response.ServiceResponse;
+import org.apache.falcon.regression.core.supportClasses.ExecResult;
+import org.apache.falcon.regression.core.util.Config;
+import org.apache.falcon.regression.core.util.ExecUtil;
+import org.apache.falcon.regression.core.util.FileUtil;
+import org.apache.falcon.regression.core.util.HCatUtil;
+import org.apache.falcon.regression.core.util.InstanceUtil;
+import org.apache.falcon.regression.core.util.OSUtil;
+import org.apache.falcon.regression.core.util.OozieUtil;
+import org.apache.falcon.regression.core.util.Util;
+import org.apache.falcon.regression.core.util.Util.URLS;
+import org.apache.falcon.resource.InstancesResult;
+import org.apache.falcon.resource.InstancesSummaryResult;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import 
org.apache.hadoop.security.authentication.client.AuthenticationException;
+import org.apache.commons.lang.StringUtils;
+import org.apache.hive.hcatalog.api.HCatClient;
+import org.apache.hive.hcatalog.common.HCatException;
+import org.apache.log4j.Logger;
+import org.apache.oozie.client.AuthOozieClient;
+import org.testng.Assert;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.util.List;
+
+/** Abstract class for helper classes. */
+public abstract class AbstractEntityHelper {
+
+    public static final boolean AUTHENTICATE = setAuthenticate();
+
+    private static final Logger LOGGER = 
Logger.getLogger(AbstractEntityHelper.class);
+
+    protected static final String CLIENT_LOCATION = OSUtil.RESOURCES
+        + OSUtil.getPath("IvoryClient", "IvoryCLI.jar");
+    protected static final String BASE_COMMAND = "java -jar " + 
CLIENT_LOCATION;
+
+    private static boolean setAuthenticate() {
+        String value = Config.getProperty("isAuthenticationSet");
+        value = (null == value) ? "true" : value;
+        return !value.equalsIgnoreCase("false");
+    }
+
+    public String getActiveMQ() {
+        return activeMQ;
+    }
+
+    public String getHadoopLocation() {
+        return hadoopLocation;
+    }
+
+    public String getHadoopURL() {
+        return hadoopURL;
+    }
+
+    public String getClusterReadonly() {
+        return clusterReadonly;
+    }
+
+    public String getClusterWrite() {
+        return clusterWrite;
+    }
+
+    public String getHostname() {
+        return hostname;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public String getStoreLocation() {
+        return storeLocation;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public String getHCatEndpoint() {
+        return hcatEndpoint;
+    }
+
+    protected HCatClient hCatClient;
+
+    public HCatClient getHCatClient() {
+        if (null == this.hCatClient) {
+            try {
+                this.hCatClient = HCatUtil.getHCatClient(hcatEndpoint, 
hiveMetaStorePrincipal);
+            } catch (HCatException e) {
+                Assert.fail("Unable to create hCatClient because of 
exception:\n"
+                    + ExceptionUtils.getStackTrace(e));
+            }
+        }
+        return this.hCatClient;
+    }
+
+    //basic properties
+    protected String qaHost;
+
+    public String getQaHost() {
+        return qaHost;
+    }
+
+    protected String hostname = "";
+    protected String username = "";
+    protected String password = "";
+    protected String hadoopLocation = "";
+    protected String hadoopURL = "";
+    protected String clusterReadonly = "";
+    protected String clusterWrite = "";
+    private String oozieURL = "";
+    protected String activeMQ = "";
+    protected String storeLocation = "";
+    protected String hadoopGetCommand = "";
+    protected String colo;
+    protected String allColo;
+    protected String coloName;
+    protected String serviceStartCmd;
+    protected String serviceStopCmd;
+    protected String serviceStatusCmd;
+    protected String hcatEndpoint = "";
+
+    public String getNamenodePrincipal() {
+        return namenodePrincipal;
+    }
+
+    public String getHiveMetaStorePrincipal() {
+        return hiveMetaStorePrincipal;
+    }
+
+    protected String namenodePrincipal;
+    protected String hiveMetaStorePrincipal;
+
+    public AuthOozieClient getOozieClient() {
+        if (null == this.oozieClient) {
+            this.oozieClient = OozieUtil.getClient(this.oozieURL);
+        }
+        return this.oozieClient;
+    }
+
+    protected AuthOozieClient oozieClient;
+
+    public FileSystem getHadoopFS() throws IOException {
+        if (null == this.hadoopFS) {
+            Configuration conf = new Configuration();
+            conf.set("fs.default.name", "hdfs://" + this.hadoopURL);
+            this.hadoopFS = FileSystem.get(conf);
+        }
+        return this.hadoopFS;
+    }
+
+    protected FileSystem hadoopFS;
+
+    public String getIdentityFile() {
+        return identityFile;
+    }
+
+    protected String identityFile;
+
+    protected String serviceStatusMsg;
+
+    public String getServiceUser() {
+        return serviceUser;
+    }
+
+    public String getServiceStopCmd() {
+        return serviceStopCmd;
+    }
+
+    public String getServiceStartCmd() {
+        return serviceStartCmd;
+    }
+
+    protected String serviceUser;
+
+    public String getColo() {
+        return colo;
+    }
+
+    public String getColoName() {
+        return coloName;
+    }
+
+    public AbstractEntityHelper(String prefix) {
+        if ((null == prefix) || prefix.isEmpty()) {
+            prefix = "";
+        } else {
+            prefix += ".";
+        }
+        this.qaHost = Config.getProperty(prefix + "qa_host");
+        this.hostname = Config.getProperty(prefix + "ivory_hostname");
+        this.username = Config.getProperty(prefix + "username", 
System.getProperty("user.name"));
+        this.password = Config.getProperty(prefix + "password", "");
+        this.hadoopLocation = Config.getProperty(prefix + "hadoop_location");
+        this.hadoopURL = Config.getProperty(prefix + "hadoop_url");
+        this.hcatEndpoint = Config.getProperty(prefix + "hcat_endpoint");
+        this.clusterReadonly = Config.getProperty(prefix + "cluster_readonly");
+        this.clusterWrite = Config.getProperty(prefix + "cluster_write");
+        this.oozieURL = Config.getProperty(prefix + "oozie_url");
+        this.activeMQ = Config.getProperty(prefix + "activemq_url");
+        this.storeLocation = Config.getProperty(prefix + "storeLocation");
+        this.hadoopGetCommand = hadoopLocation + "  fs -cat hdfs://" + 
hadoopURL
+                + "/projects/ivory/staging/ivory/workflows/process";
+        this.allColo = "?colo=" + Config.getProperty(prefix + "colo", "*");
+        this.colo = (!Config.getProperty(prefix + "colo", "").isEmpty()) ? 
"?colo=" + Config
+            .getProperty(prefix + "colo") : "";
+        this.coloName = this.colo.contains("=") ? this.colo.split("=")[1] : "";
+        this.serviceStartCmd =
+            Config.getProperty(prefix + "service_start_cmd", 
"/etc/init.d/tomcat6 start");
+        this.serviceStopCmd = Config.getProperty(prefix + "service_stop_cmd",
+            "/etc/init.d/tomcat6 stop");
+        this.serviceUser = Config.getProperty(prefix + "service_user", null);
+        this.serviceStatusMsg = Config.getProperty(prefix + 
"service_status_msg",
+            "Tomcat servlet engine is running with pid");
+        this.serviceStatusCmd =
+            Config.getProperty(prefix + "service_status_cmd", 
"/etc/init.d/tomcat6 status");
+        this.identityFile = Config.getProperty(prefix + "identityFile",
+            System.getProperty("user.home") + "/.ssh/id_rsa");
+        this.hadoopFS = null;
+        this.oozieClient = null;
+        this.namenodePrincipal = Config.getProperty(prefix + 
"namenode.kerberos.principal", "none");
+        this.hiveMetaStorePrincipal = Config.getProperty(
+                prefix + "hive.metastore.kerberos.principal", "none");
+    }
+
+    public abstract String getEntityType();
+
+    public abstract String getEntityName(String entity);
+
+    protected String createUrl(String... parts) {
+        return StringUtils.join(parts, "/");
+    }
+
+    public ServiceResponse listEntities()
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        return listEntities(null, null);
+    }
+
+    public ServiceResponse listEntities(String params, String user)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        LOGGER.info("fetching " + getEntityType() + " list");
+        String url = createUrl(this.hostname + URLS.LIST_URL.getValue(),
+            getEntityType() + colo);
+        if (StringUtils.isNotEmpty(params)){
+            url += colo.isEmpty() ? "?" + params : "&" + params;
+        }
+        return Util.sendRequest(createUrl(url), "get", null, user);
+    }
+
+    public ServiceResponse listAllEntities(String params, String user)
+        throws AuthenticationException, IOException, URISyntaxException, 
InterruptedException {
+        return listEntities((params == null ? "" : params + '&')
+            + "numResults=" + Integer.MAX_VALUE, user);
+    }
+
+    public ServiceResponse submitEntity(String data)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        return submitEntity(data, null);
+    }
+
+    public ServiceResponse submitEntity(String data, String user)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        LOGGER.info("Submitting " + getEntityType() + ": \n" + 
Util.prettyPrintXml(data));
+        return Util.sendRequest(createUrl(this.hostname + 
URLS.SUBMIT_URL.getValue(),
+            getEntityType() + colo), "post", data, user);
+    }
+
+    public ServiceResponse schedule(String processData)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        return schedule(processData, null);
+    }
+
+    public ServiceResponse schedule(String processData, String user)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        return Util.sendRequest(createUrl(this.hostname + 
URLS.SCHEDULE_URL.getValue(),
+            getEntityType(), getEntityName(processData) + colo), "post", user);
+    }
+
+    public ServiceResponse submitAndSchedule(String data)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        return submitAndSchedule(data, null);
+    }
+
+    public ServiceResponse submitAndSchedule(String data, String user)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        LOGGER.info("Submitting " + getEntityType() + ": \n" + 
Util.prettyPrintXml(data));
+        return Util.sendRequest(createUrl(this.hostname + 
URLS.SUBMIT_AND_SCHEDULE_URL.getValue(),
+            getEntityType()), "post", data, user);
+    }
+
+    public ServiceResponse deleteByName(String entityName, String user)
+        throws AuthenticationException, IOException, URISyntaxException, 
InterruptedException {
+        return Util.sendRequest(createUrl(this.hostname + 
URLS.DELETE_URL.getValue(),
+            getEntityType(), entityName + colo), "delete", user);
+    }
+
+    public ServiceResponse delete(String data)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        return delete(data, null);
+    }
+
+    public ServiceResponse delete(String data, String user)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        return Util.sendRequest(createUrl(this.hostname + 
URLS.DELETE_URL.getValue(),
+            getEntityType(), getEntityName(data) + colo), "delete", user);
+    }
+
+    public ServiceResponse suspend(String data)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        return suspend(data, null);
+    }
+
+    public ServiceResponse suspend(String data, String user)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        return Util.sendRequest(createUrl(this.hostname + 
URLS.SUSPEND_URL.getValue(),
+            getEntityType(), getEntityName(data) + colo), "post", user);
+    }
+
+    public ServiceResponse resume(String data)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        return resume(data, null);
+    }
+
+    public ServiceResponse resume(String data, String user)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        return Util.sendRequest(createUrl(this.hostname + 
URLS.RESUME_URL.getValue(),
+            getEntityType(), getEntityName(data) + colo), "post", user);
+    }
+
+    public ServiceResponse getStatus(String data)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        return getStatus(data, null);
+    }
+
+    public ServiceResponse getStatus(String data, String user)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        return Util.sendRequest(createUrl(this.hostname + 
URLS.STATUS_URL.getValue(),
+            getEntityType(), getEntityName(data) + colo), "get", user);
+    }
+
+    public ServiceResponse getEntityDefinition(String data)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        return getEntityDefinition(data, null);
+    }
+
+    public ServiceResponse getEntityDefinition(String data, String user)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        return Util.sendRequest(createUrl(this.hostname + 
URLS.GET_ENTITY_DEFINITION.getValue(),
+            getEntityType(), getEntityName(data) + colo), "get", user);
+    }
+
+    public ServiceResponse getEntityDependencies(String data, String user)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        return Util.sendRequest(createUrl(this.hostname + 
URLS.DEPENDENCIES.getValue(),
+            getEntityType(), getEntityName(data) + colo), "get", user);
+    }
+
+    public InstancesResult getRunningInstance(String name)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        return getRunningInstance(name, null);
+    }
+
+    public InstancesResult getRunningInstance(String name, String user)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        String url = createUrl(this.hostname + 
URLS.INSTANCE_RUNNING.getValue(), getEntityType(),
+            name + allColo);
+        return (InstancesResult) InstanceUtil.sendRequestProcessInstance(url, 
user);
+    }
+
+    public InstancesResult getProcessInstanceStatus(String entityName, String 
params)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        return getProcessInstanceStatus(entityName, params, null);
+    }
+
+    public InstancesResult getProcessInstanceStatus(
+        String entityName, String params, String user)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        String url = createUrl(this.hostname + 
URLS.INSTANCE_STATUS.getValue(), getEntityType(),
+            entityName, "");
+        return (InstancesResult) InstanceUtil
+            .createAndSendRequestProcessInstance(url, params, allColo, user);
+    }
+
+    public InstancesResult getProcessInstanceSuspend(
+        String readEntityName, String params)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        return getProcessInstanceSuspend(readEntityName, params, null);
+    }
+
+    public InstancesResult getProcessInstanceSuspend(
+        String entityName, String params, String user)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        String url = createUrl(this.hostname + 
URLS.INSTANCE_SUSPEND.getValue(), getEntityType(),
+            entityName, "");
+        return (InstancesResult) InstanceUtil
+            .createAndSendRequestProcessInstance(url, params, allColo, user);
+    }
+
+    public ServiceResponse update(String oldEntity, String newEntity)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        return update(oldEntity, newEntity, null);
+    }
+
+    public ServiceResponse update(String oldEntity, String newEntity, String 
user)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        LOGGER.info("Updating " + getEntityType() + ": \n" + 
Util.prettyPrintXml(oldEntity));
+        LOGGER.info("To " + getEntityType() + ": \n" + 
Util.prettyPrintXml(newEntity));
+        String url = createUrl(this.hostname + URLS.UPDATE.getValue(), 
getEntityType(),
+            getEntityName(oldEntity));
+        return Util.sendRequest(url + colo, "post", newEntity, user);
+    }
+
+    public ServiceResponse update(String oldEntity, String newEntity, String 
updateTime,
+                                  String user)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        LOGGER.info("Updating " + getEntityType() + ": \n" + 
Util.prettyPrintXml(oldEntity));
+        LOGGER.info("To " + getEntityType() + ": \n" + 
Util.prettyPrintXml(newEntity));
+        String url = this.hostname + URLS.UPDATE.getValue() + "/" + 
getEntityType() + "/"
+            + Util.readEntityName(oldEntity);
+        String urlPart = colo == null || colo.isEmpty() ? "?" : colo + "&";
+        return Util.sendRequest(url + urlPart + "effective=" + updateTime, 
"post",
+            newEntity, user);
+    }
+
+    public InstancesResult getProcessInstanceKill(String readEntityName, 
String params)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        return getProcessInstanceKill(readEntityName, params, null);
+    }
+
+    public InstancesResult getProcessInstanceKill(String entityName, String 
params,
+                                                         String user)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        String url = createUrl(this.hostname + URLS.INSTANCE_KILL.getValue(), 
getEntityType(),
+            entityName, "");
+        return (InstancesResult) InstanceUtil
+            .createAndSendRequestProcessInstance(url, params, allColo, user);
+    }
+
+    public InstancesResult getProcessInstanceRerun(String entityName, String 
params)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        return getProcessInstanceRerun(entityName, params, null);
+    }
+
+    public InstancesResult getProcessInstanceRerun(String entityName, String 
params,
+                                                          String user)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        String url = createUrl(this.hostname + URLS.INSTANCE_RERUN.getValue(), 
getEntityType(),
+            entityName, "");
+        return (InstancesResult) InstanceUtil
+            .createAndSendRequestProcessInstance(url, params, allColo, user);
+    }
+
+    public InstancesResult getProcessInstanceResume(String entityName, String 
params)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        return getProcessInstanceResume(entityName, params, null);
+    }
+
+    public InstancesResult getProcessInstanceResume(String entityName, String 
params,
+                                                           String user)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        String url = createUrl(this.hostname + 
URLS.INSTANCE_RESUME.getValue(), getEntityType(),
+            entityName, "");
+        return (InstancesResult) InstanceUtil
+            .createAndSendRequestProcessInstance(url, params, allColo, user);
+    }
+
+    public InstancesSummaryResult getInstanceSummary(String entityName, String 
params)
+        throws IOException, URISyntaxException, AuthenticationException, 
InterruptedException {
+        String url = createUrl(this.hostname + 
URLS.INSTANCE_SUMMARY.getValue(), getEntityType(),
+            entityName, "");
+        return (InstancesSummaryResult) InstanceUtil
+            .createAndSendRequestProcessInstance(url, params, allColo, null);
+    }
+
+    public String list() {
+        return ExecUtil.executeCommandGetOutput(
+            BASE_COMMAND + " entity -list -url " + this.hostname + " -type " + 
getEntityType());
+    }
+
+    public String getDependencies(String entityName) {
+        return ExecUtil.executeCommandGetOutput(
+            BASE_COMMAND + " entity -dependency -url " + this.hostname + " 
-type "
+                + getEntityType() + " -name " + entityName);
+    }
+
+    public List<String> getArchiveInfo() throws IOException, JSchException {
+        return Util.getStoreInfo(this, "/archive/" + 
getEntityType().toUpperCase());
+    }
+
+    public List<String> getStoreInfo() throws IOException, JSchException {
+        return Util.getStoreInfo(this, "/" + getEntityType().toUpperCase());
+    }
+
+    public InstancesResult getInstanceParams(String entityName, String params)
+        throws AuthenticationException, IOException, URISyntaxException, 
InterruptedException {
+        String url = createUrl(this.hostname + 
URLS.INSTANCE_PARAMS.getValue(), getEntityType(),
+            entityName, "");
+        return (InstancesResult) InstanceUtil
+            .createAndSendRequestProcessInstance(url, params, allColo, null);
+    }
+
+    /**
+     * Lists all entities which are tagged by a given pipeline.
+     * @param pipeline filter
+     * @return service response
+     * @throws AuthenticationException
+     * @throws IOException
+     * @throws URISyntaxException
+     */
+    public ServiceResponse getListByPipeline(String pipeline)
+        throws AuthenticationException, IOException, URISyntaxException, 
InterruptedException {
+        String url = createUrl(this.hostname + URLS.LIST_URL.getValue() + "/" 
+ getEntityType());
+        url += "?filterBy=PIPELINES:" + pipeline;
+        return Util.sendRequest(url, "get", null, null);
+    }
+
+    /**
+     * Submit an entity through falcon client.
+     * @param entityStr string of the entity to be submitted
+     * @throws IOException
+     */
+    public ExecResult clientSubmit(final String entityStr) throws IOException {
+        LOGGER.info("Submitting " + getEntityType() + " through falcon client: 
\n"
+            + Util.prettyPrintXml(entityStr));
+        final String fileName = FileUtil.writeEntityToFile(entityStr);
+        final CommandLine commandLine = FalconClientBuilder.getBuilder()
+                .getSubmitCommand(getEntityType(), fileName).build();
+        return ExecUtil.executeCommand(commandLine);
+    }
+
+    /**
+     * Delete an entity through falcon client.
+     * @param entityStr string of the entity to be submitted
+     * @throws IOException
+     */
+    public ExecResult clientDelete(final String entityStr, String user) throws 
IOException {
+        final String entityName = getEntityName(entityStr);
+        LOGGER.info("Deleting " + getEntityType() + ": " + entityName);
+        final CommandLine commandLine = FalconClientBuilder.getBuilder(user)
+                .getDeleteCommand(getEntityType(), entityName).build();
+        return ExecUtil.executeCommand(commandLine);
+    }
+
+
+    /**
+     * Retrieves entities summary.
+     * @param clusterName compulsory parameter for request
+     * @param params list of optional parameters
+     * @return entity summary along with its instances.
+     */
+    public ServiceResponse getEntitySummary(String clusterName, String params)
+        throws AuthenticationException, IOException, URISyntaxException, 
InterruptedException {
+        String url = createUrl(this.hostname + URLS.ENTITY_SUMMARY.getValue(),
+            getEntityType()) +"?cluster=" + clusterName;
+        if (StringUtils.isNotEmpty(params)) {
+            url += "&" + params;
+        }
+        return Util.sendRequest(url, "get", null, null);
+    }
+
+    /**
+     * Get list of all instances of a given entity.
+     * @param entityName entity name
+     * @param params list of optional parameters
+     * @param user user name
+     * @return response
+     */
+    public InstancesResult listInstances(String entityName, String params, 
String user)
+        throws AuthenticationException, IOException, URISyntaxException, 
InterruptedException {
+        String url = createUrl(this.hostname + URLS.INSTANCE_LIST.getValue(), 
getEntityType(),
+            entityName + colo);
+        if (StringUtils.isNotEmpty(params)) {
+            url += colo.isEmpty() ? "?" + params : "&" + params;
+        }
+        return (InstancesResult) InstanceUtil.sendRequestProcessInstance(url, 
user);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/9520370a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/entity/ClusterEntityHelper.java
----------------------------------------------------------------------
diff --git 
a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/entity/ClusterEntityHelper.java
 
b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/entity/ClusterEntityHelper.java
new file mode 100644
index 0000000..4ea6728
--- /dev/null
+++ 
b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/entity/ClusterEntityHelper.java
@@ -0,0 +1,125 @@
+/**
+ * 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.regression.core.helpers.entity;
+
+import org.apache.falcon.regression.core.response.ServiceResponse;
+import org.apache.falcon.regression.core.util.Util;
+import org.apache.falcon.resource.InstancesResult;
+import org.apache.falcon.resource.InstancesSummaryResult;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+
+/** Helper class to work with cluster endpoints of a colo. */
+public class ClusterEntityHelper extends AbstractEntityHelper {
+
+
+    private static final String INVALID_ERR = "Not Valid for Cluster Entity";
+
+    public ClusterEntityHelper(String prefix) {
+        super(prefix);
+    }
+
+    public String getEntityType() {
+        return "cluster";
+    }
+
+    public String getEntityName(String entity) {
+        return Util.readEntityName(entity);
+    }
+
+    public ServiceResponse getStatus(String data, String user) {
+        throw new UnsupportedOperationException(INVALID_ERR);
+    }
+
+    public ServiceResponse resume(String data, String user) {
+        throw new UnsupportedOperationException(INVALID_ERR);
+    }
+
+    public ServiceResponse schedule(String data, String user) {
+        throw new UnsupportedOperationException(INVALID_ERR);
+    }
+
+    public ServiceResponse submitAndSchedule(String data, String user) {
+        throw new UnsupportedOperationException(INVALID_ERR);
+    }
+
+    public ServiceResponse suspend(String data, String user) {
+        throw new UnsupportedOperationException(INVALID_ERR);
+    }
+
+    @Override
+    public InstancesResult getRunningInstance(String name, String user) {
+        throw new UnsupportedOperationException(INVALID_ERR);
+    }
+
+    @Override
+    public InstancesResult getProcessInstanceStatus(
+        String readEntityName, String params, String user) {
+        throw new UnsupportedOperationException(INVALID_ERR);
+    }
+
+
+    public InstancesResult getProcessInstanceSuspend(
+        String readEntityName, String params, String user) {
+        throw new UnsupportedOperationException(INVALID_ERR);
+    }
+
+    @Override
+    public ServiceResponse update(String oldEntity, String newEntity, String 
user) {
+        throw new UnsupportedOperationException(INVALID_ERR);
+    }
+
+    @Override
+    public ServiceResponse update(String oldEntity, String newEntity, String 
updateTime,
+                                  String user) throws IOException {
+        throw new UnsupportedOperationException(INVALID_ERR);
+    }
+
+    @Override
+    public InstancesResult getProcessInstanceKill(String readEntityName,
+                                                         String string, String 
user) {
+        throw new UnsupportedOperationException(INVALID_ERR);
+    }
+
+    @Override
+    public InstancesResult getProcessInstanceRerun(
+        String readEntityName, String string, String user) {
+        throw new UnsupportedOperationException(INVALID_ERR);
+    }
+
+    @Override
+    public InstancesResult getProcessInstanceResume(
+        String readEntityName, String string, String user) {
+        throw new UnsupportedOperationException(INVALID_ERR);
+    }
+
+    @Override
+    public InstancesSummaryResult getInstanceSummary(String readEntityName,
+                                                     String string
+    ) throws
+        IOException, URISyntaxException {
+        throw new UnsupportedOperationException(INVALID_ERR);
+    }
+
+    @Override
+    public ServiceResponse getListByPipeline(String pipeline){
+        throw new UnsupportedOperationException(INVALID_ERR);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/9520370a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/entity/EntityHelperFactory.java
----------------------------------------------------------------------
diff --git 
a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/entity/EntityHelperFactory.java
 
b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/entity/EntityHelperFactory.java
new file mode 100644
index 0000000..7b62656
--- /dev/null
+++ 
b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/entity/EntityHelperFactory.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.falcon.regression.core.helpers.entity;
+
+import org.apache.falcon.entity.v0.EntityType;
+
+/** Factory class to create helper objects. */
+public final class EntityHelperFactory {
+    private EntityHelperFactory() {
+    }
+
+    public static AbstractEntityHelper getEntityHelper(EntityType type, String 
prefix) {
+        switch (type) {
+        case FEED:
+            return new FeedEntityHelper(prefix);
+        case CLUSTER:
+            return new ClusterEntityHelper(prefix);
+        case PROCESS:
+            return new ProcessEntityHelper(prefix);
+        default:
+            return null;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/9520370a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/entity/FeedEntityHelper.java
----------------------------------------------------------------------
diff --git 
a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/entity/FeedEntityHelper.java
 
b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/entity/FeedEntityHelper.java
new file mode 100644
index 0000000..437f997
--- /dev/null
+++ 
b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/entity/FeedEntityHelper.java
@@ -0,0 +1,44 @@
+/**
+ * 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.regression.core.helpers.entity;
+
+import org.apache.falcon.regression.core.response.ServiceResponse;
+import org.apache.falcon.regression.core.util.Util;
+
+/** Helper class to work with feed endpoints of a colo. */
+public class FeedEntityHelper extends AbstractEntityHelper {
+
+    public FeedEntityHelper(String prefix) {
+        super(prefix);
+    }
+
+    public String getEntityType() {
+        return "feed";
+    }
+
+    public String getEntityName(String entity) {
+        return Util.readEntityName(entity);
+    }
+
+    @Override
+    public ServiceResponse getListByPipeline(String pipeline){
+        throw new UnsupportedOperationException("Not valid for Feed Entity.");
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/9520370a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/entity/ProcessEntityHelper.java
----------------------------------------------------------------------
diff --git 
a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/entity/ProcessEntityHelper.java
 
b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/entity/ProcessEntityHelper.java
new file mode 100644
index 0000000..57f2320
--- /dev/null
+++ 
b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/helpers/entity/ProcessEntityHelper.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.falcon.regression.core.helpers.entity;
+
+import org.apache.falcon.regression.core.util.Util;
+
+/** Helper class to work with process endpoints of a colo. */
+public class ProcessEntityHelper extends AbstractEntityHelper {
+
+    public ProcessEntityHelper(String prefix) {
+        super(prefix);
+    }
+
+    public String getEntityType() {
+        return "process";
+    }
+
+    public String getEntityName(String entity) {
+        return Util.getProcessName(entity);
+    }
+
+}
+
+

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/9520370a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/interfaces/EntityHelperFactory.java
----------------------------------------------------------------------
diff --git 
a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/interfaces/EntityHelperFactory.java
 
b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/interfaces/EntityHelperFactory.java
deleted file mode 100644
index fe57927..0000000
--- 
a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/interfaces/EntityHelperFactory.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.falcon.regression.core.interfaces;
-
-import org.apache.falcon.entity.v0.EntityType;
-import org.apache.falcon.regression.core.helpers.ClusterEntityHelperImpl;
-import org.apache.falcon.regression.core.helpers.DataEntityHelperImpl;
-import org.apache.falcon.regression.core.helpers.ProcessEntityHelperImpl;
-
-/** Factory class to create helper objects. */
-public final class EntityHelperFactory {
-    private EntityHelperFactory() {
-    }
-
-    public static IEntityManagerHelper getEntityHelper(EntityType type, String 
prefix) {
-        switch (type) {
-        case FEED:
-            return new DataEntityHelperImpl(prefix);
-        case CLUSTER:
-            return new ClusterEntityHelperImpl(prefix);
-        case PROCESS:
-            return new ProcessEntityHelperImpl(prefix);
-        default:
-            return null;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/9520370a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/interfaces/FalconClientBuilder.java
----------------------------------------------------------------------
diff --git 
a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/interfaces/FalconClientBuilder.java
 
b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/interfaces/FalconClientBuilder.java
deleted file mode 100644
index 393541c..0000000
--- 
a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/interfaces/FalconClientBuilder.java
+++ /dev/null
@@ -1,177 +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.falcon.regression.core.interfaces;
-
-import org.apache.commons.exec.CommandLine;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang3.builder.Builder;
-import org.apache.falcon.regression.core.enumsAndConstants.MerlinConstants;
-import org.apache.falcon.regression.core.util.Config;
-import org.apache.falcon.regression.core.util.OSUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * FalconClientBuilder is to be used for launching falcon client command.
- */
-public final class FalconClientBuilder implements Builder<CommandLine> {
-    private final String user;
-    private final CommandLine commandLine;
-    private final List<String> args;
-    private final SuType suType;
-
-    private enum SuType {
-        /**
-         * Takes care of switching user on linux. Current implemented through 
sudo.
-         */
-        LIN_SUDO {
-            @Override
-            public CommandLine getCommandLine(String forUser) {
-                return CommandLine.parse("sudo").addArgument("-u")
-                    .addArgument(forUser).addArgument(FALCON_CLIENT_BINARY);
-            }
-            @Override
-            public void addArgsToCommandLine(CommandLine cmdLine, List<String> 
arguments) {
-                for (String arg : arguments) {
-                    cmdLine.addArgument(arg);
-                }
-            }
-        },
-        /**
-         * Takes care of switching user on windows. Needs to be implemented.
-         */
-        WIN_SU {
-            @Override
-            public CommandLine getCommandLine(String forUser) {
-                return CommandLine.parse(OSUtil.WIN_SU_BINARY)
-                    .addArgument("-u").addArgument(forUser)
-                    
.addArgument("-p").addArgument(MerlinConstants.getPasswordForUser(forUser))
-                    .addArgument(FALCON_CLIENT_BINARY);
-            }
-            @Override
-            public void addArgsToCommandLine(CommandLine cmdLine, List<String> 
arguments) {
-                String lastArg = StringUtils.join(arguments, " ");
-                cmdLine.addArgument(lastArg, true);
-            }
-        },
-        /**
-         * Takes care of the case where no user switch is required.
-         */
-        NONE {
-            @Override
-            public CommandLine getCommandLine(String forUser) {
-                return CommandLine.parse(FALCON_CLIENT_BINARY);
-            }
-            @Override
-            public void addArgsToCommandLine(CommandLine cmdLine, List<String> 
arguments) {
-                for (String arg : arguments) {
-                    cmdLine.addArgument(arg);
-                }
-            }
-        };
-
-        private static final String FALCON_CLIENT_BINARY =
-                Config.getProperty("falcon.client.binary", "falcon");
-        public abstract void addArgsToCommandLine(CommandLine cmdLine, 
List<String> arguments);
-        public abstract CommandLine getCommandLine(String forUser);
-    }
-
-    private FalconClientBuilder(String user) {
-        this.user = user;
-        args = new ArrayList<String>();
-        if (user == null) {
-            suType = SuType.NONE;
-            commandLine = suType.getCommandLine(null);
-        } else {
-            if (OSUtil.IS_WINDOWS) {
-                suType = SuType.WIN_SU;
-                commandLine = suType.getCommandLine(user);
-            } else {
-                suType = SuType.LIN_SUDO;
-                //attempting sudo su - root -c "falcon admin -version"
-                commandLine = suType.getCommandLine(user);
-            }
-        }
-    }
-
-    /**
-     * Get an instance of FalconClientBuilder.
-     * @return instance of FalconClientBuilder
-     */
-    public static FalconClientBuilder getBuilder() {
-        return new FalconClientBuilder(null);
-    }
-
-    /**
-     * Get an instance of FalconClientBuilder for the given user. It would do 
commandline
-     * construction in a way that the final command is run as given user.
-     * @return instance of FalconClientBuilder
-     */
-    public static FalconClientBuilder getBuilder(String user) {
-        return new FalconClientBuilder(user);
-    }
-
-    /**
-     * Add the given argument.
-     * @param arg argument to be added to builder
-     * @return this
-     */
-    private FalconClientBuilder addArg(String arg) {
-        args.add(arg);
-        return this;
-    }
-
-    /**
-     * Create submit command.
-     * @param entityType type of the entity
-     * @param fileName file containing the entity to be submitted
-     * @return this
-     */
-    public FalconClientBuilder getSubmitCommand(String entityType, String 
fileName) {
-        addArg("entity").addArg("-submit");
-        addArg("-type").addArg(entityType);
-        addArg("-file").addArg(fileName);
-        return this;
-    }
-
-    /**
-     * Create delete command.
-     * @param entityType type of the entity
-     * @param entityName name of the entity to be deleted
-     * @return this
-     */
-    public FalconClientBuilder getDeleteCommand(String entityType, String 
entityName) {
-        addArg("entity").addArg("-delete");
-        addArg("-type").addArg(entityType);
-        addArg("-name").addArg(entityName);
-        return this;
-    }
-
-
-    /**
-     * Build the CommandLine object for this FalconClientBuilder.
-     * @return instance of CommandLine object
-     */
-    @Override
-    public CommandLine build() {
-        suType.addArgsToCommandLine(commandLine, args);
-        return new CommandLine(commandLine);
-    }
-}

Reply via email to