You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by dd...@apache.org on 2011/10/31 07:44:56 UTC
svn commit: r1195350 - in /incubator/ambari/trunk: ./
controller/src/main/java/org/apache/ambari/controller/
controller/src/main/resources/org/apache/ambari/acd/
Author: ddas
Date: Mon Oct 31 06:44:56 2011
New Revision: 1195350
URL: http://svn.apache.org/viewvc?rev=1195350&view=rev
Log:
AMBARI-117. If some install action is sent in a heartbeat response, the latter should also include the dependent components' installs.
Modified:
incubator/ambari/trunk/CHANGES.txt
incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/HeartbeatHandler.java
incubator/ambari/trunk/controller/src/main/resources/org/apache/ambari/acd/hadoop-common-0.1.0.acd
incubator/ambari/trunk/controller/src/main/resources/org/apache/ambari/acd/hadoop-hdfs-0.1.0.acd
Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1195350&r1=1195349&r2=1195350&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Mon Oct 31 06:44:56 2011
@@ -2,6 +2,9 @@ Ambari Change log
Release 0.1.0 - unreleased
+ AMBARI-117. If some install action is sent in a heartbeat response, the
+ latter should also include the dependent components' installs. (ddas)
+
AMBARI-115. Fixed connection error handling for agent. (Eric Yang)
AMBARI-114. Fix issues in XMLComponentDefinition (ddas)
Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/HeartbeatHandler.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/HeartbeatHandler.java?rev=1195350&r1=1195349&r2=1195350&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/HeartbeatHandler.java (original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/HeartbeatHandler.java Mon Oct 31 06:44:56 2011
@@ -129,7 +129,6 @@ public class HeartbeatHandler {
//inspectAgentState, maybe we can avoid the following for loop.
for (ServiceFSM service : clusterServices) {
List<RoleFSM> roles = service.getRoles();
-
for (RoleFSM role : roles) {
boolean nodePlayingRole =
nodePlayingRole(hostname, role.getRoleName());
@@ -159,12 +158,12 @@ public class HeartbeatHandler {
//check whether the agent should start any server
if (role.shouldStart()) {
if (!roleInstalled) {
- createInstallAction(clusterIdAndRev, cluster.getName(),
+ createInstallAction(clusterIdAndRev, cluster,
service.getServiceName(), role.getRoleName(), plugin,
allActions);
continue;
}
- if (role.getRoleName().equals("-client")) { //TODO: have a good place to define this
+ if (role.getRoleName().contains("-client")) { //TODO: have a good place to define this
//Client roles are special cases. They don't have any active servers
//but should be considered active when installed. Setting the
//boolean to true ensures that the FSM gets an event (albeit a fake one).
@@ -204,13 +203,16 @@ public class HeartbeatHandler {
}
}
}
- //check/create the special component/service-level
- //actions (like safemode check)
- checkAndCreateActions(cluster, clusterFsm,clusterIdAndRev, newNode,
- service, heartbeat, allActions, componentStates);
}
+ //check/create the special component/service-level
+ //actions (like safemode check). Only once per component.
+ checkAndCreateActions(cluster, clusterFsm, clusterIdAndRev, newNode,
+ service, heartbeat, allActions, componentStates);
+ }
+ if (!newNode) {
+ createStopAndUninstallActions(componentStates, allActions,
+ clusterIdAndRev, false);
}
- createStopAndUninstallActions(componentStates, allActions, clusterIdAndRev, false);
}
}
ControllerResponse r = new ControllerResponse();
@@ -232,7 +234,7 @@ public class HeartbeatHandler {
}
private void createInstallAction(ClusterNameAndRev clusterIdAndRev,
- String cluster, String component, String role, ComponentPlugin plugin,
+ Cluster cluster, String component, String role, ComponentPlugin plugin,
List<Action> allActions) throws IOException {
String clusterId = clusterIdAndRev.getClusterName();
long clusterRev = clusterIdAndRev.getRevision();
@@ -240,11 +242,14 @@ public class HeartbeatHandler {
Action action = new Action();
action.setKind(Kind.CREATE_STRUCTURE_ACTION);
fillDetailsAndAddAction(action, allActions, clusterId,
- clusterRev, component,
- role);
+ clusterRev, component, role);
//action for installing the role
- action = plugin.install(cluster, role);
+ //also, go over all the dependencies and get their client role-install
+ //actions
+ fillActionsForDependentComponents(clusterIdAndRev, cluster, component,
+ allActions);
+ action = plugin.install(cluster.getName(), role);
fillDetailsAndAddAction(action, allActions, clusterId,
clusterRev, component, role);
@@ -254,6 +259,26 @@ public class HeartbeatHandler {
clusterRev, component, role);
}
+ private void fillActionsForDependentComponents(ClusterNameAndRev clusterIdAndRev,
+ Cluster cluster, String reqdComp,
+ List<Action> allActions) throws IOException {
+ ComponentPlugin reqPlugin = cluster.getComponentDefinition(reqdComp);
+ String[] reqdComps = reqPlugin.getRequiredComponents();
+ if (reqdComps == null || reqdComps.length == 0) {
+ //TODO: take care of components like Pig. Should Pig also have a client
+ //role?
+ String clientRole = reqdComp + "-client";
+ Action action = reqPlugin.install(cluster.getName(), clientRole);
+ fillDetailsAndAddAction(action, allActions, cluster.getName(),
+ clusterIdAndRev.getRevision(), reqdComp, clientRole);
+ return;
+ }
+ for (String comp : reqdComps) {
+ fillActionsForDependentComponents(clusterIdAndRev, cluster, comp,
+ allActions);
+ }
+ }
+
private void createStopAndUninstallActions(ComponentAndRoleStates componentAndRoleStates,
List<Action> allActions, ClusterNameAndRev clusterIdAndRev, boolean forceUninstall) {
Map<String,
@@ -645,7 +670,7 @@ public class HeartbeatHandler {
if (newNode ||
!installedOrStartedComponents.isRoleInstalled(clusterIdAndRev,
role)) {
- createInstallAction(clusterIdAndRev, cluster.getName(),
+ createInstallAction(clusterIdAndRev, cluster,
service.getServiceName(), role, plugin,
allActions);
}
Modified: incubator/ambari/trunk/controller/src/main/resources/org/apache/ambari/acd/hadoop-common-0.1.0.acd
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/resources/org/apache/ambari/acd/hadoop-common-0.1.0.acd?rev=1195350&r1=1195349&r2=1195350&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/resources/org/apache/ambari/acd/hadoop-common-0.1.0.acd (original)
+++ incubator/ambari/trunk/controller/src/main/resources/org/apache/ambari/acd/hadoop-common-0.1.0.acd Mon Oct 31 06:44:56 2011
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<component provides="hadoop-common" package="hadoop-${version}.tar.gz"
+<component provides="common" package="hadoop-${version}.tar.gz"
user="root">
<configure>
<![CDATA[
Modified: incubator/ambari/trunk/controller/src/main/resources/org/apache/ambari/acd/hadoop-hdfs-0.1.0.acd
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/resources/org/apache/ambari/acd/hadoop-hdfs-0.1.0.acd?rev=1195350&r1=1195349&r2=1195350&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/resources/org/apache/ambari/acd/hadoop-hdfs-0.1.0.acd (original)
+++ incubator/ambari/trunk/controller/src/main/resources/org/apache/ambari/acd/hadoop-hdfs-0.1.0.acd Mon Oct 31 06:44:56 2011
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<component provides="hdfs" user="root">
- <requires name="hadoop-common"/>
+ <requires name="common"/>
<roles name="namenode"/>
<roles name="secondarynamenode"/>
<roles name="datanode"/>
@@ -18,6 +18,11 @@ if role == "datanode":
ambari_component.copyXml('hadoop/hdfs-site', opts)
]]>
</configure>
+ <install>
+<![CDATA[
+print "TO BE DONE"
+]]>
+ </install>
<start>
<![CDATA[
import os