You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by od...@apache.org on 2013/11/13 21:57:53 UTC
git commit: AMBARI-3762. Running into heap space issue while adding
~900 hosts. (odiachenko)
Updated Branches:
refs/heads/trunk eef606b1e -> 708e59d9b
AMBARI-3762. Running into heap space issue while adding ~900 hosts. (odiachenko)
Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/708e59d9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/708e59d9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/708e59d9
Branch: refs/heads/trunk
Commit: 708e59d9b3f26f3d31d2bd4a9b5f2c2bfcd17af3
Parents: eef606b
Author: Oleksandr Diachenko <od...@hortonworks.com>
Authored: Wed Nov 13 22:57:19 2013 +0200
Committer: Oleksandr Diachenko <od...@hortonworks.com>
Committed: Wed Nov 13 22:57:42 2013 +0200
----------------------------------------------------------------------
.../server/actionmanager/ActionScheduler.java | 9 +++++
.../ambari/server/actionmanager/Stage.java | 15 ++++++---
.../server/actionmanager/StageFactory.java | 2 +-
.../AmbariManagementControllerImpl.java | 35 ++++++++++----------
.../ambari/server/orm/entities/StageEntity.java | 15 +++++++++
.../ambari/server/stageplanner/RoleGraph.java | 2 +-
.../apache/ambari/server/utils/StageUtils.java | 14 +++-----
.../main/resources/Ambari-DDL-MySQL-CREATE.sql | 2 +-
.../main/resources/Ambari-DDL-Oracle-CREATE.sql | 2 +-
.../resources/Ambari-DDL-Postgres-CREATE.sql | 2 +-
.../upgrade/ddl/Ambari-DDL-Oracle-UPGRADE.sql | 27 +++++++++++++++
.../ddl/Ambari-DDL-Postgres-UPGRADE-1.3.0.sql | 18 ++++++++++
.../ExecutionCommandWrapperTest.java | 2 +-
.../actionmanager/TestActionDBAccessorImpl.java | 5 ++-
.../server/actionmanager/TestActionManager.java | 4 +--
.../actionmanager/TestActionScheduler.java | 29 +++++++++++-----
.../ambari/server/actionmanager/TestStage.java | 11 +++---
.../server/agent/TestHeartbeatHandler.java | 2 +-
.../AmbariManagementControllerTest.java | 12 ++++---
.../ambari/server/utils/TestStageUtils.java | 4 +--
20 files changed, 147 insertions(+), 65 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/708e59d9/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java
index 803f7f3..22ed44e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java
@@ -17,6 +17,7 @@
*/
package org.apache.ambari.server.actionmanager;
+import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -41,9 +42,11 @@ import org.apache.ambari.server.state.ServiceComponent;
import org.apache.ambari.server.state.ServiceComponentHost;
import org.apache.ambari.server.state.fsm.InvalidStateTransitionException;
import org.apache.ambari.server.state.svccomphost.ServiceComponentHostOpFailedEvent;
+import org.apache.ambari.server.utils.StageUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.reflect.TypeToken;
import com.google.inject.persist.UnitOfWork;
/**
@@ -438,6 +441,12 @@ class ActionScheduler implements Runnable {
LOG.debug("Scheduling command: "+cmd.toString()+" for host: "+hostname);
/** change the hostname in the command for the host itself **/
cmd.setHostname(hostsMap.getHostMap(hostname));
+
+
+ Type type = new TypeToken<Map<String, List<String>>>() {}.getType();
+ Map<String, List<String>> clusterHostInfo = StageUtils.getGson().fromJson(s.getClusterHostInfo(), type);
+ cmd.setClusterHostInfo(clusterHostInfo);
+
actionQueue.enqueue(hostname, cmd);
db.hostRoleScheduled(s, hostname, roleStr);
}
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/708e59d9/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Stage.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Stage.java b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Stage.java
index 7def25c..cee8812 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Stage.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Stage.java
@@ -17,7 +17,6 @@
*/
package org.apache.ambari.server.actionmanager;
-import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -25,14 +24,12 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
-import com.google.gson.reflect.TypeToken;
import org.apache.ambari.server.Role;
import org.apache.ambari.server.RoleCommand;
import org.apache.ambari.server.agent.ExecutionCommand;
import org.apache.ambari.server.orm.dao.HostDAO;
import org.apache.ambari.server.orm.dao.HostRoleCommandDAO;
import org.apache.ambari.server.orm.dao.StageDAO;
-import org.apache.ambari.server.orm.entities.HostEntity;
import org.apache.ambari.server.orm.entities.HostRoleCommandEntity;
import org.apache.ambari.server.orm.entities.RoleSuccessCriteriaEntity;
import org.apache.ambari.server.orm.entities.StageEntity;
@@ -58,6 +55,11 @@ public class Stage {
private long stageId = -1;
private final String logDir;
private final String requestContext;
+ private final String clusterHostInfo;
+
+ public String getClusterHostInfo() {
+ return clusterHostInfo;
+ }
private int taskTimeout = -1;
private int perTaskTimeFactor = 60000;
@@ -73,11 +75,12 @@ public class Stage {
@AssistedInject
public Stage(@Assisted long requestId, @Assisted("logDir") String logDir, @Assisted("clusterName") String clusterName,
- @Assisted("requestContext") @Nullable String requestContext) {
+ @Assisted("requestContext") @Nullable String requestContext, @Assisted("clusterHostInfo") String clusterHostInfo) {
this.requestId = requestId;
this.logDir = logDir;
this.clusterName = clusterName;
this.requestContext = requestContext == null ? "" : requestContext;
+ this.clusterHostInfo = clusterHostInfo;
}
/**
@@ -100,6 +103,7 @@ public class Stage {
logDir = stageEntity.getLogInfo();
clusterName = stageEntity.getCluster().getClusterName();
requestContext = stageEntity.getRequestContext();
+ clusterHostInfo = stageEntity.getClusterHostInfo();
Map<String, List<HostRoleCommandEntity>> hostCommands = hostRoleCommandDAO.findSortedCommandsByStage(stageEntity);
@@ -134,6 +138,7 @@ public class Stage {
stageEntity.setRequestContext(requestContext);
stageEntity.setHostRoleCommands(new ArrayList<HostRoleCommandEntity>());
stageEntity.setRoleSuccessCriterias(new ArrayList<RoleSuccessCriteriaEntity>());
+ stageEntity.setClusterHostInfo(clusterHostInfo);
for (Role role : successFactors.keySet()) {
RoleSuccessCriteriaEntity roleSuccessCriteriaEntity = new RoleSuccessCriteriaEntity();
@@ -199,6 +204,7 @@ public class Stage {
cmd.setCommandId(this.getActionId());
cmd.setRole(role.name());
cmd.setRoleCommand(command);
+
Map<String, HostRoleCommand> hrcMap = this.hostRoleCommands.get(host);
if (hrcMap == null) {
hrcMap = new TreeMap<String, HostRoleCommand>();
@@ -476,6 +482,7 @@ public class Stage {
builder.append("clusterName="+clusterName+"\n");
builder.append("logDir=" + logDir+"\n");
builder.append("requestContext="+requestContext+"\n");
+ builder.append("clusterHostInfo="+clusterHostInfo+"\n");
builder.append("Success Factors:\n");
for (Role r : successFactors.keySet()) {
builder.append(" role: "+r+", factor: "+successFactors.get(r)+"\n");
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/708e59d9/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/StageFactory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/StageFactory.java b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/StageFactory.java
index 59c1f9d..3086072 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/StageFactory.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/StageFactory.java
@@ -24,7 +24,7 @@ import org.apache.ambari.server.orm.entities.StageEntity;
public interface StageFactory {
Stage createNew(long requestId, @Assisted("logDir") String logDir, @Assisted("clusterName") String clusterName,
- @Assisted("requestContext") String requestContext);
+ @Assisted("requestContext") String requestContext, @Assisted("clusterHostInfo") String clusterHostInfo);
Stage createExisting(String actionId);
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/708e59d9/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
index 1fc1222..ef5c372 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
@@ -535,9 +535,9 @@ public class AmbariManagementControllerImpl implements
}
}
- private Stage createNewStage(Cluster cluster, long requestId, String requestContext) {
+ private Stage createNewStage(Cluster cluster, long requestId, String requestContext, String clusterHostInfo) {
String logDir = BASE_LOG_DIR + File.pathSeparator + requestId;
- return stageFactory.createNew(requestId, logDir, cluster.getClusterName(), requestContext);
+ return stageFactory.createNew(requestId, logDir, cluster.getClusterName(), requestContext, clusterHostInfo);
}
private void createHostAction(Cluster cluster,
@@ -546,8 +546,7 @@ public class AmbariManagementControllerImpl implements
Map<String, Map<String, String>> configTags,
RoleCommand command,
Map<String, String> commandParams,
- ServiceComponentHostEvent event,
- Map<String, List<String>> clusterHostInfo) throws AmbariException {
+ ServiceComponentHostEvent event) throws AmbariException {
stage.addHostRoleExecutionCommand(scHost.getHostName(), Role.valueOf(scHost
.getServiceComponentName()), command,
@@ -556,9 +555,6 @@ public class AmbariManagementControllerImpl implements
ExecutionCommand execCmd = stage.getExecutionCommandWrapper(scHost.getHostName(),
scHost.getServiceComponentName()).getExecutionCommand();
- // Generate cluster host info
- execCmd.setClusterHostInfo(clusterHostInfo);
-
Host host = clusters.getHost(scHost.getHostName());
// Hack - Remove passwords from configs
@@ -1145,7 +1141,13 @@ public class AmbariManagementControllerImpl implements
// FIXME cannot work with a single stage
// multiple stages may be needed for reconfigure
long stageId = 0;
- Stage stage = createNewStage(cluster, requestId, requestContext);
+ Map<String, List<String>> clusterHostInfo = StageUtils.getClusterHostInfo(
+ clusters.getHostsForCluster(cluster.getClusterName()), cluster, hostsMap, injector);
+
+
+ String clusterHostInfoJson = StageUtils.getGson().toJson(clusterHostInfo);
+
+ Stage stage = createNewStage(cluster, requestId, requestContext, clusterHostInfoJson);
stage.setStageId(stageId);
Set<String> hostnames = new HashSet<String>();
@@ -1159,8 +1161,6 @@ public class AmbariManagementControllerImpl implements
//HACK
String jobtrackerHost = getJobTrackerHost(cluster);
- Map<String, List<String>> clusterHostInfo = StageUtils.getClusterHostInfo(
- clusters.getHostsForCluster(cluster.getClusterName()), cluster, hostsMap, injector);
for (String compName : changedScHosts.keySet()) {
for (State newState : changedScHosts.get(compName).keySet()) {
for (ServiceComponentHost scHost :
@@ -1307,7 +1307,7 @@ public class AmbariManagementControllerImpl implements
}
createHostAction(cluster, stage, scHost, configurations, configTags,
- roleCommand, requestParameters, event, clusterHostInfo);
+ roleCommand, requestParameters, event);
}
}
}
@@ -2267,10 +2267,6 @@ public class AmbariManagementControllerImpl implements
params.put("jdk_location", this.jdkResourceUrl);
params.put("stack_version", cluster.getDesiredStackVersion().getStackVersion());
execCmd.setHostLevelParams(params);
-
- // Generate cluster host info
- execCmd.setClusterHostInfo(
- StageUtils.getClusterHostInfo(clusters.getHostsForCluster(clusterName), cluster, hostsMap, injector));
}
private void addDecommissionDatanodeAction(
@@ -2372,9 +2368,15 @@ public class AmbariManagementControllerImpl implements
}
clusterName = actionRequest.getClusterName();
+
+ Cluster cluster = clusters.getCluster(clusterName);
+
+ Map<String, List<String>> clusterHostInfoMap = StageUtils.getClusterHostInfo(clusters.getHostsForCluster(cluster.getClusterName()), cluster, hostsMap, injector);
+ String clusterHostInfo = StageUtils.getGson().toJson(clusterHostInfoMap);
+
Stage stage = stageFactory.createNew(actionManager.getNextRequestId(),
- logDir, clusterName, requestContext);
+ logDir, clusterName, requestContext, clusterHostInfo);
stage.setStageId(0);
LOG.info("Received a createAction request"
@@ -2395,7 +2397,6 @@ public class AmbariManagementControllerImpl implements
throw new AmbariException("Unsupported action " + actionRequest.getCommandName());
}
- Cluster cluster = clusters.getCluster(clusterName);
RoleCommandOrder rco = this.getRoleCommandOrder(cluster);
RoleGraph rg = new RoleGraph(rco);
rg.build(stage);
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/708e59d9/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity.java
index 7baa946..c042dd0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity.java
@@ -47,6 +47,19 @@ public class StageEntity {
@Column(name = "request_context")
@Basic
private String requestContext = "";
+
+ @Column(name = "cluster_host_info")
+ @Basic
+ private byte[] clusterHostInfo;
+
+
+ public String getClusterHostInfo() {
+ return clusterHostInfo == null ? new String() : new String(clusterHostInfo);
+ }
+
+ public void setClusterHostInfo(String clusterHostInfo) {
+ this.clusterHostInfo = clusterHostInfo.getBytes();
+ }
@ManyToOne(cascade = {CascadeType.MERGE})
@JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id")
@@ -111,6 +124,7 @@ public class StageEntity {
if (logInfo != null ? !logInfo.equals(that.logInfo) : that.logInfo != null) return false;
if (requestId != null ? !requestId.equals(that.requestId) : that.requestId != null) return false;
if (stageId != null ? !stageId.equals(that.stageId) : that.stageId != null) return false;
+ if (clusterHostInfo != null ? !clusterHostInfo.equals(that.clusterHostInfo) : that.clusterHostInfo != null) return false;
return !(requestContext != null ? !requestContext.equals(that.requestContext) : that.requestContext != null);
}
@@ -121,6 +135,7 @@ public class StageEntity {
result = 31 * result + (requestId != null ? requestId.hashCode() : 0);
result = 31 * result + (stageId != null ? stageId.hashCode() : 0);
result = 31 * result + (logInfo != null ? logInfo.hashCode() : 0);
+ result = 31 * result + (clusterHostInfo != null ? clusterHostInfo.hashCode() : 0);
result = 31 * result + (requestContext != null ? requestContext.hashCode() : 0);
return result;
}
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/708e59d9/ambari-server/src/main/java/org/apache/ambari/server/stageplanner/RoleGraph.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/stageplanner/RoleGraph.java b/ambari-server/src/main/java/org/apache/ambari/server/stageplanner/RoleGraph.java
index 0d2b520..67b6855 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/stageplanner/RoleGraph.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/stageplanner/RoleGraph.java
@@ -133,7 +133,7 @@ public class RoleGraph {
Stage newStage = new Stage(origStage.getRequestId(),
origStage.getLogDir(), origStage.getClusterName(),
- origStage.getRequestContext());
+ origStage.getRequestContext(), origStage.getClusterHostInfo());
newStage.setSuccessFactors(origStage.getSuccessFactors());
for (RoleGraphNode rgn : stageGraphNodes) {
for (String host : rgn.getHosts()) {
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/708e59d9/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java b/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java
index 34ef328..d6523b0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java
@@ -42,7 +42,6 @@ import org.apache.ambari.server.agent.ExecutionCommand;
import org.apache.ambari.server.configuration.Configuration;
import org.apache.ambari.server.controller.HostsMap;
import org.apache.ambari.server.state.Cluster;
-import org.apache.ambari.server.state.Clusters;
import org.apache.ambari.server.state.Host;
import org.apache.ambari.server.state.ServiceComponent;
import org.apache.ambari.server.state.svccomphost.ServiceComponentHostInstallEvent;
@@ -125,33 +124,30 @@ public class StageUtils {
return requestStageIds;
}
- public static Stage getATestStage(long requestId, long stageId) {
+ public static Stage getATestStage(long requestId, long stageId, String clusterHostInfo) {
String hostname;
try {
hostname = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
hostname = "host-dummy";
}
- return getATestStage(requestId, stageId, hostname);
+ return getATestStage(requestId, stageId, hostname, clusterHostInfo);
}
//For testing only
- public static Stage getATestStage(long requestId, long stageId, String hostname) {
- Stage s = new Stage(requestId, "/tmp", "cluster1", "context");
+ public static Stage getATestStage(long requestId, long stageId, String hostname, String clusterHostInfo) {
+
+ Stage s = new Stage(requestId, "/tmp", "cluster1", "context", clusterHostInfo);
s.setStageId(stageId);
long now = System.currentTimeMillis();
- String filename = null;
s.addHostRoleExecutionCommand(hostname, Role.NAMENODE, RoleCommand.INSTALL,
new ServiceComponentHostInstallEvent("NAMENODE", hostname, now, "HDP-1.2.0"),
"cluster1", "HDFS");
ExecutionCommand execCmd = s.getExecutionCommandWrapper(hostname, "NAMENODE").getExecutionCommand();
execCmd.setCommandId(s.getActionId());
- Map<String, List<String>> clusterHostInfo = new TreeMap<String, List<String>>();
List<String> slaveHostList = new ArrayList<String>();
slaveHostList.add(hostname);
slaveHostList.add("host2");
- clusterHostInfo.put("slave_hosts", slaveHostList);
- execCmd.setClusterHostInfo(clusterHostInfo);
Map<String, String> hdfsSite = new TreeMap<String, String>();
hdfsSite.put("dfs.block.size", "2560000000");
Map<String, Map<String, String>> configurations =
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/708e59d9/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
index 1767ff9..8a2d2d7 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
@@ -41,7 +41,7 @@ CREATE TABLE users (user_id INTEGER NOT NULL, create_time TIMESTAMP DEFAULT NOW(
CREATE TABLE execution_command (task_id BIGINT NOT NULL, command LONGBLOB, PRIMARY KEY (task_id));
CREATE TABLE host_role_command (task_id BIGINT NOT NULL, attempt_count SMALLINT NOT NULL, event LONGTEXT NOT NULL, exitcode INTEGER NOT NULL, host_name VARCHAR(255) NOT NULL, last_attempt_time BIGINT NOT NULL, request_id BIGINT NOT NULL, role VARCHAR(255), role_command VARCHAR(255), stage_id BIGINT NOT NULL, start_time BIGINT NOT NULL, status VARCHAR(255), std_error LONGBLOB, std_out LONGBLOB, PRIMARY KEY (task_id));
CREATE TABLE role_success_criteria (role VARCHAR(255) NOT NULL, request_id BIGINT NOT NULL, stage_id BIGINT NOT NULL, success_factor DOUBLE NOT NULL, PRIMARY KEY (role, request_id, stage_id));
-CREATE TABLE stage (stage_id BIGINT NOT NULL, request_id BIGINT NOT NULL, cluster_id BIGINT, log_info VARCHAR(255) NOT NULL, request_context VARCHAR(255), PRIMARY KEY (stage_id, request_id));
+CREATE TABLE stage (stage_id BIGINT NOT NULL, request_id BIGINT NOT NULL, cluster_id BIGINT, log_info VARCHAR(255) NOT NULL, request_context VARCHAR(255), cluster_host_info LONGBLOB, PRIMARY KEY (stage_id, request_id));
CREATE TABLE key_value_store (`key` VARCHAR(255) NOT NULL, `value` LONGTEXT, PRIMARY KEY (`key`));
CREATE TABLE clusterconfigmapping (type_name VARCHAR(255) NOT NULL, create_timestamp BIGINT NOT NULL, cluster_id BIGINT NOT NULL, selected INTEGER NOT NULL, version_tag VARCHAR(255) NOT NULL, user_name VARCHAR(255) NOT NULL DEFAULT '_db', PRIMARY KEY (type_name, create_timestamp, cluster_id));
CREATE TABLE hostconfigmapping (create_timestamp BIGINT NOT NULL, host_name VARCHAR(255) NOT NULL, cluster_id BIGINT NOT NULL, type_name VARCHAR(255) NOT NULL, selected INTEGER NOT NULL, service_name VARCHAR(255), version_tag VARCHAR(255) NOT NULL, user_name VARCHAR(255) NOT NULL DEFAULT '_db', PRIMARY KEY (create_timestamp, host_name, cluster_id, type_name));
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/708e59d9/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
index d09aec5..92dc010 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
@@ -31,7 +31,7 @@ CREATE TABLE users (user_id NUMBER(10) NOT NULL, create_time TIMESTAMP NULL, lda
CREATE TABLE execution_command (task_id NUMBER(19) NOT NULL, command BLOB NULL, PRIMARY KEY (task_id));
CREATE TABLE host_role_command (task_id NUMBER(19) NOT NULL, attempt_count NUMBER(5) NOT NULL, event CLOB NULL, exitcode NUMBER(10) NOT NULL, host_name VARCHAR2(255) NOT NULL, last_attempt_time NUMBER(19) NOT NULL, request_id NUMBER(19) NOT NULL, role VARCHAR2(255) NULL, role_command VARCHAR2(255) NULL, stage_id NUMBER(19) NOT NULL, start_time NUMBER(19) NOT NULL, status VARCHAR2(255) NULL, std_error BLOB NULL, std_out BLOB NULL, PRIMARY KEY (task_id));
CREATE TABLE role_success_criteria (role VARCHAR2(255) NOT NULL, request_id NUMBER(19) NOT NULL, stage_id NUMBER(19) NOT NULL, success_factor NUMBER(19,4) NOT NULL, PRIMARY KEY (role, request_id, stage_id));
-CREATE TABLE stage (stage_id NUMBER(19) NOT NULL, request_id NUMBER(19) NOT NULL, cluster_id NUMBER(19) NULL, log_info VARCHAR2(255) NULL, request_context VARCHAR2(255) NULL, PRIMARY KEY (stage_id, request_id));
+CREATE TABLE stage (stage_id NUMBER(19) NOT NULL, request_id NUMBER(19) NOT NULL, cluster_id NUMBER(19) NULL, log_info VARCHAR2(255) NULL, request_context VARCHAR2(255) NULL, cluster_host_info BLOB NOT NULL, PRIMARY KEY (stage_id, request_id));
CREATE TABLE key_value_store ("key" VARCHAR2(255) NOT NULL, "value" CLOB NULL, PRIMARY KEY ("key"));
CREATE TABLE clusterconfigmapping (type_name VARCHAR2(255) NOT NULL, create_timestamp NUMBER(19) NOT NULL, cluster_id NUMBER(19) NOT NULL, selected NUMBER(10) NOT NULL, version_tag VARCHAR2(255) NOT NULL, user_name VARCHAR(255) DEFAULT '_db', PRIMARY KEY (type_name, create_timestamp, cluster_id));
CREATE TABLE hostconfigmapping (create_timestamp NUMBER(19) NOT NULL, host_name VARCHAR2(255) NOT NULL, cluster_id NUMBER(19) NOT NULL, type_name VARCHAR2(255) NOT NULL, selected NUMBER(10) NOT NULL, service_name VARCHAR2(255) NULL, version_tag VARCHAR2(255) NOT NULL, user_name VARCHAR(255) DEFAULT '_db', PRIMARY KEY (create_timestamp, host_name, cluster_id, type_name));
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/708e59d9/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
index 3ac5451..2992376 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
@@ -76,7 +76,7 @@ GRANT ALL PRIVILEGES ON TABLE ambari.host_role_command TO :username;
CREATE TABLE ambari.role_success_criteria (role VARCHAR(255) NOT NULL, request_id BIGINT NOT NULL, stage_id BIGINT NOT NULL, success_factor FLOAT NOT NULL, PRIMARY KEY (role, request_id, stage_id));
GRANT ALL PRIVILEGES ON TABLE ambari.role_success_criteria TO :username;
-CREATE TABLE ambari.stage (stage_id BIGINT NOT NULL, request_id BIGINT NOT NULL, cluster_id BIGINT NOT NULL, log_info VARCHAR(255) NOT NULL, request_context VARCHAR(255), PRIMARY KEY (stage_id, request_id));
+CREATE TABLE ambari.stage (stage_id BIGINT NOT NULL, request_id BIGINT NOT NULL, cluster_id BIGINT NOT NULL, log_info VARCHAR(255) NOT NULL, request_context VARCHAR(255), cluster_host_info BYTEA NOT NULL, PRIMARY KEY (stage_id, request_id));
GRANT ALL PRIVILEGES ON TABLE ambari.stage TO :username;
CREATE TABLE ambari.ClusterHostMapping (cluster_id BIGINT NOT NULL, host_name VARCHAR(255) NOT NULL, PRIMARY KEY (cluster_id, host_name));
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/708e59d9/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Oracle-UPGRADE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Oracle-UPGRADE.sql b/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Oracle-UPGRADE.sql
index 2495bd7..881c1ca 100644
--- a/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Oracle-UPGRADE.sql
+++ b/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Oracle-UPGRADE.sql
@@ -23,6 +23,8 @@ ALTER TABLE clusterconfigmapping ADD (user_name VARCHAR2 (255) DEFAULT '_db');
ALTER TABLE hostconfigmapping ADD (user_name VARCHAR2 (255) DEFAULT '_db');
+ALTER TABLE stage ADD (cluster_host_info BLOB DEFAULT NULL);
+
-- DML
--Upgrade version to current
UPDATE metainfo SET "metainfo_key" = 'version', "metainfo_value" = '${ambariVersion}';
@@ -45,4 +47,29 @@ ALTER TABLE ambari.confgroupclusterconfigmapping ADD CONSTRAINT FK_confgroupclus
ALTER TABLE ambari.configgrouphostmapping ADD CONSTRAINT FK_configgrouphostmapping_configgroup_id FOREIGN KEY (config_group_id) REFERENCES ambari.configgroup (group_id);
ALTER TABLE ambari.configgrouphostmapping ADD CONSTRAINT FK_configgrouphostmapping_host_name FOREIGN KEY (host_name) REFERENCES ambari.hosts (host_name);
+
+UPDATE
+ stage sd
+SET
+ (sd.cluster_host_info) =
+ (
+ SELECT DISTINCT
+ (dbms_lob.substr(ec.command, dbms_lob.instr(ec.command,
+ '636f6e66696775726174696f6e73') - dbms_lob.instr(ec.command,
+ '636c7573746572486f7374496e666f') - 19, dbms_lob.instr(ec.command,
+ '636c7573746572486f7374496e666f') + 17) )
+ FROM
+ execution_command ec ,
+ host_role_command hrc,
+ stage ss
+ WHERE
+ ec.task_id = hrc.task_id
+ AND hrc.stage_id = ss.stage_id
+ AND hrc.request_id = ss.request_id
+ AND ss.stage_id = sd.stage_id
+ AND ss.request_id = sd.request_id
+ );
+
+ALTER TABLE stage MODIFY (cluster_host_info NOT NULL);
+
commit;
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/708e59d9/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.3.0.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.3.0.sql b/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.3.0.sql
index 86dac17..c016d96 100644
--- a/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.3.0.sql
+++ b/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.3.0.sql
@@ -71,6 +71,7 @@ ALTER TABLE ambari.hostconfigmapping ADD CONSTRAINT FK_hostconfigmapping_host_na
--updating stage table
ALTER TABLE ambari.stage ADD COLUMN request_context VARCHAR(255);
+ALTER TABLE ambari.stage ADD COLUMN cluster_host_info BYTEA;
-- portability changes for MySQL/Oracle support
ALTER TABLE ambari.hostcomponentdesiredconfigmapping rename to hcdesiredconfigmapping;
@@ -131,3 +132,20 @@ ALTER TABLE ambari.confgroupclusterconfigmapping ADD CONSTRAINT FK_confgroupclus
ALTER TABLE ambari.configgrouphostmapping ADD CONSTRAINT FK_configgrouphostmapping_configgroup_id FOREIGN KEY (config_group_id) REFERENCES ambari.configgroup (group_id);
ALTER TABLE ambari.configgrouphostmapping ADD CONSTRAINT FK_configgrouphostmapping_host_name FOREIGN KEY (host_name) REFERENCES ambari.hosts (host_name);
+
+--Move cluster host info for old execution commands to stage table
+UPDATE ambari.stage sd
+ SET
+ cluster_host_info = substring(ec.command, position('clusterHostInfo' in ec.command) + 17, position('configurations' in ec.command) - position('clusterHostInfo' in ec.command) - 19)
+ FROM
+ ambari.execution_command ec,
+ ambari.host_role_command hrc,
+ ambari.stage ss
+ WHERE ec.task_id = hrc.task_id
+ AND hrc.stage_id = ss.stage_id
+ AND hrc.request_id = ss.request_id
+ AND sd.cluster_host_info IS NULL;
+
+--Set cluster_host_info column mandatory
+ALTER TABLE ambari.stage ALTER COLUMN cluster_host_info SET NOT NULL;
+
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/708e59d9/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperTest.java
index 36941e3..62e3c88 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperTest.java
@@ -152,7 +152,7 @@ public class ExecutionCommandWrapperTest {
private static void createTask(ActionDBAccessor db, long requestId, long stageId, String hostName, String clusterName) {
- Stage s = new Stage(requestId, "/var/log", clusterName, "execution command wrapper test");
+ Stage s = new Stage(requestId, "/var/log", clusterName, "execution command wrapper test", "clusterHostInfo");
s.setStageId(stageId);
s.addHostRoleExecutionCommand(hostName, Role.NAMENODE,
RoleCommand.START,
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/708e59d9/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java
index f101a64..b0bd728 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java
@@ -18,7 +18,6 @@
package org.apache.ambari.server.actionmanager;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import com.google.inject.persist.UnitOfWork;
@@ -227,7 +226,7 @@ public class TestActionDBAccessorImpl {
@Test
public void testAbortRequest() throws AmbariException {
- Stage s = new Stage(requestId, "/a/b", "cluster1", "action db accessor test");
+ Stage s = new Stage(requestId, "/a/b", "cluster1", "action db accessor test", "clusterHostInfo");
s.setStageId(stageId);
clusters.addHost("host2");
@@ -282,7 +281,7 @@ public class TestActionDBAccessorImpl {
private void populateActionDB(ActionDBAccessor db, String hostname,
long requestId, long stageId) {
- Stage s = new Stage(requestId, "/a/b", "cluster1", "action db accessor test");
+ Stage s = new Stage(requestId, "/a/b", "cluster1", "action db accessor test", "clusterHostInfo");
s.setStageId(stageId);
s.addHostRoleExecutionCommand(hostname, Role.HBASE_MASTER,
RoleCommand.START,
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/708e59d9/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionManager.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionManager.java b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionManager.java
index d51047f..d465b59 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionManager.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionManager.java
@@ -27,7 +27,6 @@ import static org.junit.Assert.assertSame;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.List;
import com.google.inject.persist.UnitOfWork;
@@ -51,7 +50,6 @@ import org.junit.Ignore;
import org.junit.Test;
import com.google.inject.Guice;
-import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.persist.PersistService;
@@ -157,7 +155,7 @@ public class TestActionManager {
}
private void populateActionDB(ActionDBAccessor db, String hostname) {
- Stage s = new Stage(requestId, "/a/b", "cluster1", "action manager test");
+ Stage s = new Stage(requestId, "/a/b", "cluster1", "action manager test", "clusterHostInfo");
s.setStageId(stageId);
s.addHostRoleExecutionCommand(hostname, Role.HBASE_MASTER,
RoleCommand.START,
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/708e59d9/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
index dff78af..a5776a6 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
@@ -24,11 +24,13 @@ import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import com.google.common.reflect.TypeToken;
import com.google.inject.persist.UnitOfWork;
import junit.framework.Assert;
@@ -52,7 +54,6 @@ import org.apache.ambari.server.state.ServiceComponentHost;
import org.apache.ambari.server.state.svccomphost.ServiceComponentHostInstallEvent;
import org.apache.ambari.server.state.svccomphost.ServiceComponentHostUpgradeEvent;
import org.apache.ambari.server.utils.StageUtils;
-import org.easymock.EasyMock;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -60,6 +61,10 @@ import org.slf4j.LoggerFactory;
public class TestActionScheduler {
private static final Logger log = LoggerFactory.getLogger(TestActionScheduler.class);
+ private static final String CLUSTER_HOST_INFO = "{all_hosts=[c6403.ambari.apache.org," +
+ " c6401.ambari.apache.org, c6402.ambari.apache.org], slave_hosts=[c6403.ambari.apache.org," +
+ " c6401.ambari.apache.org, c6402.ambari.apache.org]}";
+;
/**
* This test sends a new action to the action scheduler and verifies that the action
@@ -67,6 +72,10 @@ public class TestActionScheduler {
*/
@Test
public void testActionSchedule() throws Exception {
+
+ Type type = new TypeToken<Map<String, List<String>>>() {}.getType();
+ Map<String, List<String>> clusterHostInfo = StageUtils.getGson().fromJson(CLUSTER_HOST_INFO, type);
+
ActionQueue aq = new ActionQueue();
Clusters fsm = mock(Clusters.class);
Cluster oneClusterMock = mock(Cluster.class);
@@ -87,7 +96,7 @@ public class TestActionScheduler {
ActionDBAccessor db = mock(ActionDBAccessorImpl.class);
List<Stage> stages = new ArrayList<Stage>();
- Stage s = StageUtils.getATestStage(1, 977, hostname);
+ Stage s = StageUtils.getATestStage(1, 977, hostname, CLUSTER_HOST_INFO);
stages.add(s);
when(db.getStagesInProgress()).thenReturn(stages);
@@ -102,11 +111,13 @@ public class TestActionScheduler {
List<AgentCommand> ac = waitForQueueSize(hostname, aq, 1);
assertTrue(ac.get(0) instanceof ExecutionCommand);
assertEquals("1-977", ((ExecutionCommand) (ac.get(0))).getCommandId());
+ assertEquals(clusterHostInfo, ((ExecutionCommand) (ac.get(0))).getClusterHostInfo());
//The action status has not changed, it should be queued again.
ac = waitForQueueSize(hostname, aq, 1);
assertTrue(ac.get(0) instanceof ExecutionCommand);
assertEquals("1-977", ((ExecutionCommand) (ac.get(0))).getCommandId());
+ assertEquals(clusterHostInfo, ((ExecutionCommand) (ac.get(0))).getClusterHostInfo());
//Now change the action status
s.setHostRoleStatus(hostname, "NAMENODE", HostRoleStatus.COMPLETED);
@@ -158,7 +169,7 @@ public class TestActionScheduler {
ActionDBAccessor db = new ActionDBInMemoryImpl();
List<Stage> stages = new ArrayList<Stage>();
- Stage s = StageUtils.getATestStage(1, 977, hostname);
+ Stage s = StageUtils.getATestStage(1, 977, hostname, CLUSTER_HOST_INFO);
stages.add(s);
db.persistActions(stages);
@@ -199,7 +210,7 @@ public class TestActionScheduler {
ActionDBAccessor db = new ActionDBInMemoryImpl();
List<Stage> stages = new ArrayList<Stage>();
- Stage s = StageUtils.getATestStage(1, 977, hostname);
+ Stage s = StageUtils.getATestStage(1, 977, hostname, CLUSTER_HOST_INFO);
stages.add(s);
db.persistActions(stages);
@@ -280,7 +291,7 @@ public class TestActionScheduler {
private static Stage getStageWithServerAction(long requestId, long stageId, String hostName,
Map<String, String> payload, String requestContext) {
- Stage stage = new Stage(requestId, "/tmp", "cluster1", requestContext);
+ Stage stage = new Stage(requestId, "/tmp", "cluster1", requestContext, CLUSTER_HOST_INFO);
stage.setStageId(stageId);
long now = System.currentTimeMillis();
stage.addServerActionCommand(ServerAction.Command.FINALIZE_UPGRADE, Role.AMBARI_SERVER_ACTION,
@@ -366,7 +377,7 @@ public class TestActionScheduler {
List<Stage> stages = new ArrayList<Stage>();
long now = System.currentTimeMillis();
- Stage stage = new Stage(1, "/tmp", "cluster1", "testRequestFailureBasedOnSuccessFactor");
+ Stage stage = new Stage(1, "/tmp", "cluster1", "testRequestFailureBasedOnSuccessFactor", CLUSTER_HOST_INFO);
stage.setStageId(1);
addHostRoleExecutionCommand(now, stage, Role.SQOOP, Service.Type.SQOOP,
@@ -494,7 +505,7 @@ public class TestActionScheduler {
List<Stage> stages = new ArrayList<Stage>();
long now = System.currentTimeMillis();
- Stage stage = new Stage(1, "/tmp", "cluster1", "testRequestFailureBasedOnSuccessFactor");
+ Stage stage = new Stage(1, "/tmp", "cluster1", "testRequestFailureBasedOnSuccessFactor", CLUSTER_HOST_INFO);
stage.setStageId(1);
stage.addHostRoleExecutionCommand("host1", Role.DATANODE, RoleCommand.UPGRADE,
new ServiceComponentHostUpgradeEvent(Role.DATANODE.toString(), "host1", now, "HDP-0.2"),
@@ -564,7 +575,7 @@ public class TestActionScheduler {
private Stage getStageWithSingleTask(String hostname, String clusterName, Role role,
RoleCommand roleCommand, Service.Type service, int taskId,
int stageId, int requestId) {
- Stage stage = new Stage(requestId, "/tmp", clusterName, "getStageWithSingleTask");
+ Stage stage = new Stage(requestId, "/tmp", clusterName, "getStageWithSingleTask", CLUSTER_HOST_INFO);
stage.setStageId(stageId);
stage.addHostRoleExecutionCommand(hostname, role, roleCommand,
new ServiceComponentHostUpgradeEvent(role.toString(), hostname, System.currentTimeMillis(), "HDP-0.2"),
@@ -577,7 +588,7 @@ public class TestActionScheduler {
@Test
public void testSuccessFactors() {
- Stage s = StageUtils.getATestStage(1, 1);
+ Stage s = StageUtils.getATestStage(1, 1, CLUSTER_HOST_INFO);
assertEquals(new Float(0.5), new Float(s.getSuccessFactor(Role.DATANODE)));
assertEquals(new Float(0.5), new Float(s.getSuccessFactor(Role.TASKTRACKER)));
assertEquals(new Float(0.5), new Float(s.getSuccessFactor(Role.GANGLIA_MONITOR)));
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/708e59d9/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestStage.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestStage.java b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestStage.java
index 511d20e..6f74d0a 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestStage.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestStage.java
@@ -17,22 +17,20 @@
*/
package org.apache.ambari.server.actionmanager;
-import static org.easymock.EasyMock.createNiceMock;
import static org.junit.Assert.*;
-import com.google.inject.*;
import org.apache.ambari.server.Role;
import org.apache.ambari.server.RoleCommand;
-import org.apache.ambari.server.controller.HostsMap;
-import org.apache.ambari.server.orm.entities.*;
import org.apache.ambari.server.utils.StageUtils;
import org.junit.Test;
public class TestStage {
+ private static final String CLUSTER_HOST_INFO = "cluster_host_info";
+
@Test
public void testTaskTimeout() {
- Stage s = StageUtils.getATestStage(1, 1, "h1");
+ Stage s = StageUtils.getATestStage(1, 1, "h1", CLUSTER_HOST_INFO);
s.addHostRoleExecutionCommand("h1", Role.DATANODE, RoleCommand.INSTALL,
null, "c1", "HDFS");
s.addHostRoleExecutionCommand("h1", Role.HBASE_MASTER, RoleCommand.INSTALL,
@@ -43,8 +41,9 @@ public class TestStage {
@Test
public void testGetRequestContext() {
- Stage stage = new Stage(1, "/logDir", "c1", "My Context");
+ Stage stage = new Stage(1, "/logDir", "c1", "My Context", CLUSTER_HOST_INFO);
assertEquals("My Context", stage.getRequestContext());
+ assertEquals(CLUSTER_HOST_INFO, stage.getClusterHostInfo());
}
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/708e59d9/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java b/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
index a3389f1..5763065 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
@@ -448,7 +448,7 @@ public class TestHeartbeatHandler {
}
private void populateActionDB(ActionDBAccessor db, String DummyHostname1) {
- Stage s = new Stage(requestId, "/a/b", DummyCluster, "heartbeat handler test");
+ Stage s = new Stage(requestId, "/a/b", DummyCluster, "heartbeat handler test", "clusterHostInfo");
s.setStageId(stageId);
String filename = null;
s.addHostRoleExecutionCommand(DummyHostname1, Role.HBASE_MASTER,
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/708e59d9/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
index b5aa668..3e8448c 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
@@ -153,6 +153,8 @@ public class AmbariManagementControllerTest {
private static final String REQUEST_CONTEXT_PROPERTY = "context";
+ private static final String CLUSTER_HOST_INFO = "clusterHostInfo";
+
private AmbariManagementController controller;
private Clusters clusters;
private ActionDBAccessor actionDB;
@@ -6815,7 +6817,7 @@ public class AmbariManagementControllerTest {
List<Stage> stages = new ArrayList<Stage>();
- stages.add(new Stage(requestId1, "/a1", clusterName, context));
+ stages.add(new Stage(requestId1, "/a1", clusterName, context, CLUSTER_HOST_INFO));
stages.get(0).setStageId(1);
stages.get(0).addHostRoleExecutionCommand(hostName1, Role.HBASE_MASTER,
RoleCommand.START,
@@ -6823,14 +6825,14 @@ public class AmbariManagementControllerTest {
hostName1, System.currentTimeMillis()),
clusterName, "HBASE");
- stages.add(new Stage(requestId1, "/a2", clusterName, context));
+ stages.add(new Stage(requestId1, "/a2", clusterName, context, CLUSTER_HOST_INFO));
stages.get(1).setStageId(2);
stages.get(1).addHostRoleExecutionCommand(hostName1, Role.HBASE_CLIENT,
RoleCommand.START,
new ServiceComponentHostStartEvent(Role.HBASE_CLIENT.toString(),
hostName1, System.currentTimeMillis()), clusterName, "HBASE");
- stages.add(new Stage(requestId1, "/a3", clusterName, context));
+ stages.add(new Stage(requestId1, "/a3", clusterName, context, CLUSTER_HOST_INFO));
stages.get(2).setStageId(3);
stages.get(2).addHostRoleExecutionCommand(hostName1, Role.HBASE_CLIENT,
RoleCommand.START,
@@ -6838,14 +6840,14 @@ public class AmbariManagementControllerTest {
hostName1, System.currentTimeMillis()), clusterName, "HBASE");
- stages.add(new Stage(requestId2, "/a4", clusterName, context));
+ stages.add(new Stage(requestId2, "/a4", clusterName, context, CLUSTER_HOST_INFO));
stages.get(3).setStageId(4);
stages.get(3).addHostRoleExecutionCommand(hostName1, Role.HBASE_CLIENT,
RoleCommand.START,
new ServiceComponentHostStartEvent(Role.HBASE_CLIENT.toString(),
hostName1, System.currentTimeMillis()), clusterName, "HBASE");
- stages.add(new Stage(requestId2, "/a5", clusterName, context));
+ stages.add(new Stage(requestId2, "/a5", clusterName, context, CLUSTER_HOST_INFO));
stages.get(4).setStageId(5);
stages.get(4).addHostRoleExecutionCommand(hostName1, Role.HBASE_CLIENT,
RoleCommand.START,
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/708e59d9/ambari-server/src/test/java/org/apache/ambari/server/utils/TestStageUtils.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/utils/TestStageUtils.java b/ambari-server/src/test/java/org/apache/ambari/server/utils/TestStageUtils.java
index 11c0a61..516069a 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/utils/TestStageUtils.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/utils/TestStageUtils.java
@@ -168,8 +168,8 @@ public class TestStageUtils {
@Test
public void testJasonToExecutionCommand() throws JsonGenerationException,
JsonMappingException, JAXBException, IOException {
- Stage s = StageUtils.getATestStage(1, 2, "host1");
- ExecutionCommand cmd = s.getExecutionCommands("host1").get(0).getExecutionCommand();
+ Stage s = StageUtils.getATestStage(1, 2, "host1", "clusterHostInfo");
+ ExecutionCommand cmd = s.getExecutionCommands("host1").get(0).getExecutionCommand();
cmd.setConfigurationTags(new HashMap<String, Map<String,String>>() {{
put("global", new HashMap<String, String>() {{ put("tag", "version1"); }});
}});