You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@falcon.apache.org by ro...@apache.org on 2014/12/03 10:34:23 UTC
[1/2] incubator-falcon git commit: FALCON-927 Refactoring of entity
helpers in falcon-regression. Contributed by Ruslan Ostafiychuk
Repository: incubator-falcon
Updated Branches:
refs/heads/master 4f2b524d9 -> 9520370a2
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/IEntityManagerHelper.java
----------------------------------------------------------------------
diff --git a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/interfaces/IEntityManagerHelper.java b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/interfaces/IEntityManagerHelper.java
deleted file mode 100644
index 7eab15c..0000000
--- a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/interfaces/IEntityManagerHelper.java
+++ /dev/null
@@ -1,604 +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 com.jcraft.jsch.JSchException;
-import org.apache.commons.exec.CommandLine;
-import org.apache.commons.lang.exception.ExceptionUtils;
-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 IEntityManagerHelper {
-
- public static final boolean AUTHENTICATE = setAuthenticate();
-
- private static final Logger LOGGER = Logger.getLogger(IEntityManagerHelper.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 IEntityManagerHelper(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
- * @return
- * @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
- * @return
- * @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/supportClasses/Brother.java
----------------------------------------------------------------------
diff --git a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/supportClasses/Brother.java b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/supportClasses/Brother.java
index 5d2708a..4330bff 100755
--- a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/supportClasses/Brother.java
+++ b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/supportClasses/Brother.java
@@ -21,7 +21,7 @@ package org.apache.falcon.regression.core.supportClasses;
import org.apache.falcon.entity.v0.EntityType;
import org.apache.falcon.regression.core.bundle.Bundle;
import org.apache.falcon.regression.core.helpers.ColoHelper;
-import org.apache.falcon.regression.core.interfaces.IEntityManagerHelper;
+import org.apache.falcon.regression.core.helpers.entity.AbstractEntityHelper;
import org.apache.falcon.regression.core.response.ServiceResponse;
import org.apache.falcon.regression.core.util.Util.URLS;
import org.testng.TestNGException;
@@ -39,7 +39,7 @@ public class Brother extends Thread {
return output;
}
- private IEntityManagerHelper entityManagerHelper;
+ private AbstractEntityHelper entityManagerHelper;
public Brother(String threadName, String operation, EntityType entityType, ThreadGroup tGroup,
Bundle b, ColoHelper p, URLS url) {
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/9520370a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/util/CleanupUtil.java
----------------------------------------------------------------------
diff --git a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/util/CleanupUtil.java b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/util/CleanupUtil.java
index 8cc6121..ef58b36 100644
--- a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/util/CleanupUtil.java
+++ b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/util/CleanupUtil.java
@@ -20,7 +20,7 @@ package org.apache.falcon.regression.core.util;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.falcon.regression.core.helpers.ColoHelper;
-import org.apache.falcon.regression.core.interfaces.IEntityManagerHelper;
+import org.apache.falcon.regression.core.helpers.entity.AbstractEntityHelper;
import org.apache.falcon.regression.core.response.ServiceResponse;
import org.apache.falcon.resource.EntityList;
import org.apache.hadoop.security.authentication.client.AuthenticationException;
@@ -62,11 +62,11 @@ public final class CleanupUtil {
return getAllEntitiesOfOneType(prism.getClusterHelper(), null);
}
- public static List<String> getAllEntitiesOfOneType(IEntityManagerHelper iEntityManagerHelper,
+ public static List<String> getAllEntitiesOfOneType(AbstractEntityHelper entityManagerHelper,
String user)
throws IOException, URISyntaxException, AuthenticationException, JAXBException,
InterruptedException {
- final EntityList entityList = getEntitiesResultOfOneType(iEntityManagerHelper, user);
+ final EntityList entityList = getEntitiesResultOfOneType(entityManagerHelper, user);
List<String> clusters = new ArrayList<String>();
for (EntityList.EntityElement entity : entityList.getElements()) {
clusters.add(entity.name);
@@ -75,10 +75,10 @@ public final class CleanupUtil {
}
private static EntityList getEntitiesResultOfOneType(
- IEntityManagerHelper iEntityManagerHelper, String user)
+ AbstractEntityHelper entityManagerHelper, String user)
throws IOException, URISyntaxException, AuthenticationException, JAXBException,
InterruptedException {
- final ServiceResponse clusterResponse = iEntityManagerHelper.listAllEntities(null, user);
+ final ServiceResponse clusterResponse = entityManagerHelper.listAllEntities(null, user);
JAXBContext jc = JAXBContext.newInstance(EntityList.class);
Unmarshaller u = jc.createUnmarshaller();
return (EntityList) u.unmarshal(
@@ -120,7 +120,7 @@ public final class CleanupUtil {
}
public static void cleanAllProcessesQuietly(ColoHelper prism,
- IEntityManagerHelper entityManagerHelper) {
+ AbstractEntityHelper entityManagerHelper) {
try {
final List<String> processes = getAllProcesses(prism);
for (String process : processes) {
@@ -143,7 +143,7 @@ public final class CleanupUtil {
cleanAllClustersQuietly(prism);
}
- public static void deleteQuietly(IEntityManagerHelper helper, String feed) {
+ public static void deleteQuietly(AbstractEntityHelper helper, String feed) {
try {
helper.delete(feed);
} catch (Exception e) {
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/9520370a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/util/InstanceUtil.java
----------------------------------------------------------------------
diff --git a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/util/InstanceUtil.java b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/util/InstanceUtil.java
index fcef570..4f9bd9d 100644
--- a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/util/InstanceUtil.java
+++ b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/util/InstanceUtil.java
@@ -35,7 +35,7 @@ import org.apache.falcon.regression.core.bundle.Bundle;
import org.apache.falcon.regression.core.enumsAndConstants.MerlinConstants;
import org.apache.falcon.regression.core.enumsAndConstants.ResponseErrors;
import org.apache.falcon.regression.core.helpers.ColoHelper;
-import org.apache.falcon.regression.core.interfaces.IEntityManagerHelper;
+import org.apache.falcon.regression.core.helpers.entity.AbstractEntityHelper;
import org.apache.falcon.resource.APIResult;
import org.apache.falcon.resource.InstancesResult;
import org.apache.falcon.resource.InstancesSummaryResult;
@@ -428,7 +428,7 @@ public final class InstanceUtil {
* @throws OozieClientException
*/
public static List<CoordinatorJob> getBundleCoordinators(String bundleID,
- IEntityManagerHelper helper)
+ AbstractEntityHelper helper)
throws OozieClientException {
OozieClient localOozieClient = helper.getOozieClient();
BundleJob bundleInfo = localOozieClient.getBundleJobInfo(bundleID);
@@ -587,7 +587,7 @@ public final class InstanceUtil {
* Retrieves replication coordinatorID from bundle of coordinators.
*/
public static List<String> getReplicationCoordID(String bundlID,
- IEntityManagerHelper helper)
+ AbstractEntityHelper helper)
throws OozieClientException {
List<CoordinatorJob> coords = InstanceUtil.getBundleCoordinators(bundlID, helper);
List<String> replicationCoordID = new ArrayList<String>();
@@ -706,7 +706,7 @@ public final class InstanceUtil {
return feedElement.toString();
}
- public static int checkIfFeedCoordExist(IEntityManagerHelper helper,
+ public static int checkIfFeedCoordExist(AbstractEntityHelper helper,
String feedName, String coordType) throws OozieClientException {
LOGGER.info("feedName: " + feedName);
int numberOfCoord = 0;
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/9520370a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/util/Util.java
----------------------------------------------------------------------
diff --git a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/util/Util.java b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/util/Util.java
index be28344..0c12410 100644
--- a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/util/Util.java
+++ b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/regression/core/util/Util.java
@@ -37,7 +37,7 @@ import org.apache.falcon.entity.v0.feed.LocationType;
import org.apache.falcon.entity.v0.feed.Property;
import org.apache.falcon.entity.v0.process.Process;
import org.apache.falcon.regression.core.helpers.ColoHelper;
-import org.apache.falcon.regression.core.interfaces.IEntityManagerHelper;
+import org.apache.falcon.regression.core.helpers.entity.AbstractEntityHelper;
import org.apache.falcon.regression.core.response.ServiceResponse;
import org.apache.falcon.regression.core.supportClasses.JmsMessageConsumer;
import org.apache.falcon.resource.APIResult;
@@ -171,7 +171,7 @@ public final class Util {
* @throws IOException
* @throws JSchException
*/
- public static List<String> getStoreInfo(IEntityManagerHelper helper, String subPath)
+ public static List<String> getStoreInfo(AbstractEntityHelper helper, String subPath)
throws IOException, JSchException {
if (helper.getStoreLocation().startsWith("hdfs:")) {
return HadoopUtil.getAllFilesHDFS(helper.getHadoopFS(),
@@ -390,7 +390,7 @@ public final class Util {
* @throws IOException
* @throws JSchException
*/
- public static void shutDownService(IEntityManagerHelper helper)
+ public static void shutDownService(AbstractEntityHelper helper)
throws IOException, JSchException {
ExecUtil.runRemoteScriptAsSudo(helper.getQaHost(), helper.getUsername(),
helper.getPassword(), helper.getServiceStopCmd(),
@@ -406,7 +406,7 @@ public final class Util {
* @throws AuthenticationException
* @throws URISyntaxException
*/
- public static void startService(IEntityManagerHelper helper)
+ public static void startService(AbstractEntityHelper helper)
throws IOException, JSchException, AuthenticationException, URISyntaxException,
InterruptedException {
ExecUtil.runRemoteScriptAsSudo(helper.getQaHost(), helper.getUsername(),
@@ -435,7 +435,7 @@ public final class Util {
* @throws AuthenticationException
* @throws URISyntaxException
*/
- public static void restartService(IEntityManagerHelper helper)
+ public static void restartService(AbstractEntityHelper helper)
throws IOException, JSchException, AuthenticationException, URISyntaxException,
InterruptedException {
LOGGER.info("restarting service for: " + helper.getQaHost());
@@ -737,7 +737,7 @@ public final class Util {
JAXBException,
IOException, URISyntaxException, AuthenticationException, InterruptedException {
EntityType type = getEntityType(entity);
- IEntityManagerHelper helper;
+ AbstractEntityHelper helper;
if (EntityType.PROCESS == type) {
helper = cluster.getProcessHelper();
} else if (EntityType.FEED == type) {
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/9520370a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/request/BaseRequest.java
----------------------------------------------------------------------
diff --git a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/request/BaseRequest.java b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/request/BaseRequest.java
index 0fc01ef..0ee1e4a 100644
--- a/falcon-regression/merlin-core/src/main/java/org/apache/falcon/request/BaseRequest.java
+++ b/falcon-regression/merlin-core/src/main/java/org/apache/falcon/request/BaseRequest.java
@@ -19,7 +19,7 @@
package org.apache.falcon.request;
import org.apache.commons.net.util.TrustManagerUtils;
-import org.apache.falcon.regression.core.interfaces.IEntityManagerHelper;
+import org.apache.falcon.regression.core.helpers.entity.AbstractEntityHelper;
import org.apache.falcon.security.FalconAuthorizationToken;
import org.apache.hadoop.security.authentication.client.AuthenticatedURL;
import org.apache.hadoop.security.authentication.client.AuthenticationException;
@@ -148,7 +148,7 @@ public class BaseRequest {
/*get the token and add it to the header.
works in secure and un secure mode.*/
AuthenticatedURL.Token token;
- if (IEntityManagerHelper.AUTHENTICATE) {
+ if (AbstractEntityHelper.AUTHENTICATE) {
token = FalconAuthorizationToken.getToken(user, uri.getScheme(),
uri.getHost(), uri.getPort());
request.addHeader(RequestKeys.COOKIE, RequestKeys.AUTH_COOKIE_EQ + token);
@@ -178,7 +178,7 @@ public class BaseRequest {
Header[] wwwAuthHeaders = response.getHeaders(RequestKeys.WWW_AUTHENTICATE);
if (wwwAuthHeaders != null && wwwAuthHeaders.length != 0
&& wwwAuthHeaders[0].getValue().trim().startsWith(RequestKeys.NEGOTIATE)) {
- if (IEntityManagerHelper.AUTHENTICATE) {
+ if (AbstractEntityHelper.AUTHENTICATE) {
token = FalconAuthorizationToken.getToken(user, uri.getScheme(),
uri.getHost(), uri.getPort(), true);
request.removeHeaders(RequestKeys.COOKIE);
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/9520370a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/FeedResumeTest.java
----------------------------------------------------------------------
diff --git a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/FeedResumeTest.java b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/FeedResumeTest.java
index bb629b8..669c4fa 100644
--- a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/FeedResumeTest.java
+++ b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/FeedResumeTest.java
@@ -22,7 +22,7 @@ package org.apache.falcon.regression;
import org.apache.falcon.entity.v0.EntityType;
import org.apache.falcon.regression.core.bundle.Bundle;
import org.apache.falcon.regression.core.helpers.ColoHelper;
-import org.apache.falcon.regression.core.interfaces.IEntityManagerHelper;
+import org.apache.falcon.regression.core.helpers.entity.AbstractEntityHelper;
import org.apache.falcon.regression.core.response.ServiceResponse;
import org.apache.falcon.regression.core.util.AssertUtil;
import org.apache.falcon.regression.core.util.BundleUtil;
@@ -45,7 +45,7 @@ import java.lang.reflect.Method;
@Test(groups = "embedded")
public class FeedResumeTest extends BaseTestClass {
- private final IEntityManagerHelper feedHelper = prism.getFeedHelper();
+ private final AbstractEntityHelper feedHelper = prism.getFeedHelper();
private String feed;
private ColoHelper cluster = servers.get(0);
private OozieClient clusterOC = serverOC.get(0);
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/9520370a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/entity/ListEntitiesTest.java
----------------------------------------------------------------------
diff --git a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/entity/ListEntitiesTest.java b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/entity/ListEntitiesTest.java
index 1586f76..3ab375d 100644
--- a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/entity/ListEntitiesTest.java
+++ b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/entity/ListEntitiesTest.java
@@ -24,7 +24,7 @@ import org.apache.falcon.regression.Entities.ClusterMerlin;
import org.apache.falcon.regression.Entities.FeedMerlin;
import org.apache.falcon.regression.Entities.ProcessMerlin;
import org.apache.falcon.regression.core.bundle.Bundle;
-import org.apache.falcon.regression.core.interfaces.IEntityManagerHelper;
+import org.apache.falcon.regression.core.helpers.entity.AbstractEntityHelper;
import org.apache.falcon.regression.core.util.AssertUtil;
import org.apache.falcon.regression.core.util.BundleUtil;
import org.apache.falcon.regression.core.util.CleanupUtil;
@@ -120,7 +120,7 @@ public class ListEntitiesTest extends BaseTestClass {
* Testing orderBy parameter. Entities should be ordered by name when orderBy=name.
*/
@Test(dataProvider = "getHelpers")
- public void listEntitiesWithOrderBy(IEntityManagerHelper helper)
+ public void listEntitiesWithOrderBy(AbstractEntityHelper helper)
throws AuthenticationException, IOException, URISyntaxException, InterruptedException {
EntityElement[] entities =
@@ -135,7 +135,7 @@ public class ListEntitiesTest extends BaseTestClass {
* Filter entities by status (SUBMITTED or RUNNING).
*/
@Test(dataProvider = "getHelpers")
- public void listEntitiesWithFilterByStatus(IEntityManagerHelper helper)
+ public void listEntitiesWithFilterByStatus(AbstractEntityHelper helper)
throws AuthenticationException, IOException, URISyntaxException, InterruptedException {
String[] statuses = helper.getEntityType().equalsIgnoreCase("cluster")
? new String[]{"SUBMITTED"} : new String[]{"SUBMITTED", "RUNNING"};
@@ -169,7 +169,7 @@ public class ListEntitiesTest extends BaseTestClass {
* Testing offset parameter. Checking number of entities and order.
*/
@Test(dataProvider = "getHelpers")
- public void listEntitiesWithOffset(IEntityManagerHelper helper)
+ public void listEntitiesWithOffset(AbstractEntityHelper helper)
throws AuthenticationException, IOException, URISyntaxException, InterruptedException {
EntityElement[] allEntities =
@@ -198,7 +198,7 @@ public class ListEntitiesTest extends BaseTestClass {
* Testing numResults parameter. Checking number of entities and order.
*/
@Test(dataProvider = "getHelpers")
- public void listEntitiesWithNumResults(IEntityManagerHelper helper)
+ public void listEntitiesWithNumResults(AbstractEntityHelper helper)
throws AuthenticationException, IOException, URISyntaxException, InterruptedException {
EntityElement[] allEntities =
@@ -222,7 +222,7 @@ public class ListEntitiesTest extends BaseTestClass {
* Get list of entities with tag.
*/
@Test(dataProvider = "getHelpers")
- public void listEntitiesWithTags(IEntityManagerHelper helper)
+ public void listEntitiesWithTags(AbstractEntityHelper helper)
throws AuthenticationException, IOException, URISyntaxException, InterruptedException {
EntityElement[] allEntities =
@@ -258,7 +258,7 @@ public class ListEntitiesTest extends BaseTestClass {
* Testing list entities API with custom filter.
*/
@Test(dataProvider = "getHelpers")
- public void listEntitiesWithCustomFilter(IEntityManagerHelper helper)
+ public void listEntitiesWithCustomFilter(AbstractEntityHelper helper)
throws AuthenticationException, IOException, URISyntaxException, InterruptedException {
EntityElement[] entities = helper.listEntities(
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/9520370a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/lineage/EntitySummaryTest.java
----------------------------------------------------------------------
diff --git a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/lineage/EntitySummaryTest.java b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/lineage/EntitySummaryTest.java
index 1546886..39d1e52 100644
--- a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/lineage/EntitySummaryTest.java
+++ b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/lineage/EntitySummaryTest.java
@@ -27,7 +27,7 @@ import org.apache.falcon.regression.Entities.FeedMerlin;
import org.apache.falcon.regression.Entities.ProcessMerlin;
import org.apache.falcon.regression.core.bundle.Bundle;
import org.apache.falcon.regression.core.helpers.ColoHelper;
-import org.apache.falcon.regression.core.interfaces.IEntityManagerHelper;
+import org.apache.falcon.regression.core.helpers.entity.AbstractEntityHelper;
import org.apache.falcon.regression.core.util.AssertUtil;
import org.apache.falcon.regression.core.util.BundleUtil;
import org.apache.falcon.regression.core.util.CleanupUtil;
@@ -188,7 +188,7 @@ public class EntitySummaryTest extends BaseTestClass {
throws AuthenticationException, IOException, URISyntaxException, JAXBException,
OozieClientException, InterruptedException {
String entityName = Util.readEntityName(entity);
- IEntityManagerHelper helper;
+ AbstractEntityHelper helper;
List<String> names = new ArrayList<String>();
for (int i = 1; i <= 7; i++) {
String uniqueName = entityName + i;
@@ -245,7 +245,7 @@ public class EntitySummaryTest extends BaseTestClass {
String clusterName)
throws AuthenticationException, IOException, URISyntaxException, InterruptedException {
InstancesResult r;
- IEntityManagerHelper helper;
+ AbstractEntityHelper helper;
if (entityType == EntityType.FEED) {
helper = prism.getFeedHelper();
} else {
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/9520370a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/prism/PrismFeedDeleteTest.java
----------------------------------------------------------------------
diff --git a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/prism/PrismFeedDeleteTest.java b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/prism/PrismFeedDeleteTest.java
index 33fea84..b3924db 100644
--- a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/prism/PrismFeedDeleteTest.java
+++ b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/prism/PrismFeedDeleteTest.java
@@ -25,7 +25,7 @@ import org.apache.falcon.entity.v0.EntityType;
import org.apache.falcon.entity.v0.feed.ActionType;
import org.apache.falcon.entity.v0.feed.ClusterType;
import org.apache.falcon.regression.core.helpers.ColoHelper;
-import org.apache.falcon.regression.core.interfaces.IEntityManagerHelper;
+import org.apache.falcon.regression.core.helpers.entity.AbstractEntityHelper;
import org.apache.falcon.regression.core.response.ServiceResponse;
import org.apache.falcon.regression.core.util.AssertUtil;
import org.apache.falcon.regression.core.util.BundleUtil;
@@ -1079,9 +1079,9 @@ public class PrismFeedDeleteTest extends BaseTestClass {
}
public HashMap<String, List<String>> getSystemState(EntityType entityType) throws Exception {
- IEntityManagerHelper prismHelper = prism.getClusterHelper();
- IEntityManagerHelper server1Helper = cluster1.getClusterHelper();
- IEntityManagerHelper server2Helper = cluster2.getClusterHelper();
+ AbstractEntityHelper prismHelper = prism.getClusterHelper();
+ AbstractEntityHelper server1Helper = cluster1.getClusterHelper();
+ AbstractEntityHelper server2Helper = cluster2.getClusterHelper();
if (entityType == EntityType.FEED) {
prismHelper = prism.getFeedHelper();
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/9520370a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/prism/PrismProcessDeleteTest.java
----------------------------------------------------------------------
diff --git a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/prism/PrismProcessDeleteTest.java b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/prism/PrismProcessDeleteTest.java
index 3291d6d..421be1e 100644
--- a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/prism/PrismProcessDeleteTest.java
+++ b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/prism/PrismProcessDeleteTest.java
@@ -21,7 +21,7 @@ package org.apache.falcon.regression.prism;
import org.apache.falcon.entity.v0.EntityType;
import org.apache.falcon.regression.core.bundle.Bundle;
import org.apache.falcon.regression.core.helpers.ColoHelper;
-import org.apache.falcon.regression.core.interfaces.IEntityManagerHelper;
+import org.apache.falcon.regression.core.helpers.entity.AbstractEntityHelper;
import org.apache.falcon.regression.core.util.AssertUtil;
import org.apache.falcon.regression.core.util.BundleUtil;
import org.apache.falcon.regression.core.util.OSUtil;
@@ -940,9 +940,9 @@ public class PrismProcessDeleteTest extends BaseTestClass {
}
public HashMap<String, List<String>> getSystemState(EntityType entityType) throws Exception {
- IEntityManagerHelper prizm = prism.getClusterHelper();
- IEntityManagerHelper ua1 = cluster2.getClusterHelper();
- IEntityManagerHelper ua2 = cluster1.getClusterHelper();
+ AbstractEntityHelper prizm = prism.getClusterHelper();
+ AbstractEntityHelper ua1 = cluster2.getClusterHelper();
+ AbstractEntityHelper ua2 = cluster1.getClusterHelper();
if (entityType == EntityType.FEED) {
prizm = prism.getFeedHelper();
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/9520370a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/security/ClusterAclTest.java
----------------------------------------------------------------------
diff --git a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/security/ClusterAclTest.java b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/security/ClusterAclTest.java
index 7b561e5..00d5b7d 100644
--- a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/security/ClusterAclTest.java
+++ b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/security/ClusterAclTest.java
@@ -21,7 +21,7 @@ package org.apache.falcon.regression.security;
import org.apache.falcon.regression.core.bundle.Bundle;
import org.apache.falcon.regression.core.enumsAndConstants.MerlinConstants;
import org.apache.falcon.regression.core.helpers.ColoHelper;
-import org.apache.falcon.regression.core.interfaces.IEntityManagerHelper;
+import org.apache.falcon.regression.core.helpers.entity.AbstractEntityHelper;
import org.apache.falcon.regression.core.response.ServiceResponse;
import org.apache.falcon.regression.core.util.AssertUtil;
import org.apache.falcon.regression.core.util.BundleUtil;
@@ -53,7 +53,7 @@ public class ClusterAclTest extends BaseTestClass {
private String baseTestDir = baseHDFSDir + "/ClusterAclTest";
private String aggregateWorkflowDir = baseTestDir + "/aggregator";
private String feedInputPath = baseTestDir + "/input" + MINUTE_DATE_PATTERN;
- private final IEntityManagerHelper clusterHelper = prism.getClusterHelper();
+ private final AbstractEntityHelper clusterHelper = prism.getClusterHelper();
private String clusterString;
@BeforeClass(alwaysRun = true)
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/9520370a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/security/EntityOp.java
----------------------------------------------------------------------
diff --git a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/security/EntityOp.java b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/security/EntityOp.java
index 334b51a..ad069de 100644
--- a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/security/EntityOp.java
+++ b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/security/EntityOp.java
@@ -18,7 +18,7 @@
package org.apache.falcon.regression.security;
-import org.apache.falcon.regression.core.interfaces.IEntityManagerHelper;
+import org.apache.falcon.regression.core.helpers.entity.AbstractEntityHelper;
import org.apache.falcon.regression.core.response.ServiceResponse;
import org.apache.falcon.regression.core.util.AssertUtil;
import org.apache.falcon.regression.core.util.CleanupUtil;
@@ -38,7 +38,7 @@ import java.util.List;
enum EntityOp {
status() {
@Override
- public boolean executeAs(String user, IEntityManagerHelper helper, String data) {
+ public boolean executeAs(String user, AbstractEntityHelper helper, String data) {
final ServiceResponse response;
try {
response = helper.getStatus(data, user);
@@ -60,7 +60,7 @@ enum EntityOp {
},
dependency() {
@Override
- public boolean executeAs(String user, IEntityManagerHelper helper, String data) {
+ public boolean executeAs(String user, AbstractEntityHelper helper, String data) {
final ServiceResponse response;
try {
response = helper.getEntityDependencies(data, user);
@@ -82,7 +82,7 @@ enum EntityOp {
},
listing() {
@Override
- public boolean executeAs(String user, IEntityManagerHelper helper, String data) {
+ public boolean executeAs(String user, AbstractEntityHelper helper, String data) {
final String entityName = Util.readEntityName(data);
final List<String> entities;
try {
@@ -109,7 +109,7 @@ enum EntityOp {
},
definition() {
@Override
- public boolean executeAs(String user, IEntityManagerHelper helper, String data) {
+ public boolean executeAs(String user, AbstractEntityHelper helper, String data) {
final ServiceResponse response;
try {
response = helper.getEntityDefinition(data, user);
@@ -131,7 +131,7 @@ enum EntityOp {
},
delete() {
@Override
- public boolean executeAs(String user, IEntityManagerHelper helper, String data) {
+ public boolean executeAs(String user, AbstractEntityHelper helper, String data) {
final ServiceResponse response;
try {
response = helper.delete(data, user);
@@ -153,7 +153,7 @@ enum EntityOp {
},
update() {
@Override
- public boolean executeAs(String user, IEntityManagerHelper helper, String data) {
+ public boolean executeAs(String user, AbstractEntityHelper helper, String data) {
final ServiceResponse response;
try {
response = helper.update(data, data, user);
@@ -175,7 +175,7 @@ enum EntityOp {
},
schedule() {
@Override
- public boolean executeAs(String user, IEntityManagerHelper helper, String data) {
+ public boolean executeAs(String user, AbstractEntityHelper helper, String data) {
final ServiceResponse response;
try {
response = helper.schedule(data, user);
@@ -197,7 +197,7 @@ enum EntityOp {
},
submit() {
@Override
- public boolean executeAs(String user, IEntityManagerHelper helper, String data) {
+ public boolean executeAs(String user, AbstractEntityHelper helper, String data) {
final ServiceResponse response;
try {
response = helper.submitEntity(data, user);
@@ -219,7 +219,7 @@ enum EntityOp {
},
submitAndSchedule() {
@Override
- public boolean executeAs(String user, IEntityManagerHelper helper, String data) {
+ public boolean executeAs(String user, AbstractEntityHelper helper, String data) {
final ServiceResponse response;
try {
response = helper.submitAndSchedule(data, user);
@@ -241,7 +241,7 @@ enum EntityOp {
},
suspend() {
@Override
- public boolean executeAs(String user, IEntityManagerHelper helper, String data) {
+ public boolean executeAs(String user, AbstractEntityHelper helper, String data) {
final ServiceResponse response;
try {
response = helper.suspend(data, user);
@@ -263,7 +263,7 @@ enum EntityOp {
},
resume() {
@Override
- public boolean executeAs(String user, IEntityManagerHelper helper, String data) {
+ public boolean executeAs(String user, AbstractEntityHelper helper, String data) {
final ServiceResponse response;
try {
response = helper.resume(data, user);
@@ -285,5 +285,5 @@ enum EntityOp {
};
private static Logger logger = Logger.getLogger(EntityOp.class);
- public abstract boolean executeAs(String user, IEntityManagerHelper helper, String data);
+ public abstract boolean executeAs(String user, AbstractEntityHelper helper, String data);
}
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/9520370a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/security/FeedAclTest.java
----------------------------------------------------------------------
diff --git a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/security/FeedAclTest.java b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/security/FeedAclTest.java
index 8996923..74275ab 100644
--- a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/security/FeedAclTest.java
+++ b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/security/FeedAclTest.java
@@ -22,7 +22,7 @@ import org.apache.falcon.regression.Entities.FeedMerlin;
import org.apache.falcon.regression.core.bundle.Bundle;
import org.apache.falcon.regression.core.enumsAndConstants.MerlinConstants;
import org.apache.falcon.regression.core.helpers.ColoHelper;
-import org.apache.falcon.regression.core.interfaces.IEntityManagerHelper;
+import org.apache.falcon.regression.core.helpers.entity.AbstractEntityHelper;
import org.apache.falcon.regression.core.util.AssertUtil;
import org.apache.falcon.regression.core.util.BundleUtil;
import org.apache.falcon.regression.core.util.HadoopUtil;
@@ -54,7 +54,7 @@ public class FeedAclTest extends BaseTestClass {
private String baseTestDir = baseHDFSDir + "/FeedAclTest";
private String aggregateWorkflowDir = baseTestDir + "/aggregator";
private String feedInputPath = baseTestDir + "/input" + MINUTE_DATE_PATTERN;
- private final IEntityManagerHelper feedHelper = prism.getFeedHelper();
+ private final AbstractEntityHelper feedHelper = prism.getFeedHelper();
private String feedString;
@BeforeClass(alwaysRun = true)
http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/9520370a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/security/ProcessAclTest.java
----------------------------------------------------------------------
diff --git a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/security/ProcessAclTest.java b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/security/ProcessAclTest.java
index 7d1213e..f5fcdee 100644
--- a/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/security/ProcessAclTest.java
+++ b/falcon-regression/merlin/src/test/java/org/apache/falcon/regression/security/ProcessAclTest.java
@@ -22,7 +22,7 @@ import org.apache.falcon.regression.Entities.ProcessMerlin;
import org.apache.falcon.regression.core.bundle.Bundle;
import org.apache.falcon.regression.core.enumsAndConstants.MerlinConstants;
import org.apache.falcon.regression.core.helpers.ColoHelper;
-import org.apache.falcon.regression.core.interfaces.IEntityManagerHelper;
+import org.apache.falcon.regression.core.helpers.entity.AbstractEntityHelper;
import org.apache.falcon.regression.core.util.AssertUtil;
import org.apache.falcon.regression.core.util.BundleUtil;
import org.apache.falcon.regression.core.util.HadoopUtil;
@@ -57,7 +57,7 @@ public class ProcessAclTest extends BaseTestClass {
private String baseTestDir = baseHDFSDir + "/ProcessAclTest";
private String aggregateWorkflowDir = baseTestDir + "/aggregator";
private String feedInputPath = baseTestDir + "/input" + MINUTE_DATE_PATTERN;
- private final IEntityManagerHelper processHelper = prism.getProcessHelper();
+ private final AbstractEntityHelper processHelper = prism.getProcessHelper();
private String processString;
@BeforeClass(alwaysRun = true)
[2/2] incubator-falcon git commit: FALCON-927 Refactoring of entity
helpers in falcon-regression. Contributed by Ruslan Ostafiychuk
Posted by ro...@apache.org.
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 <ro...@apache.org>
Authored: Wed Dec 3 09:07:59 2014 +0200
Committer: Ruslan Ostafiychuk <ro...@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);
- }
-}