You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ja...@apache.org on 2014/12/22 20:11:35 UTC
ambari git commit: AMBARI-8855. Fix Kerberos-related tasks to show
friendly names in UI ops list. (robert levas via jaimin)
Repository: ambari
Updated Branches:
refs/heads/trunk 623d2f2cf -> c11100587
AMBARI-8855. Fix Kerberos-related tasks to show friendly names in UI ops list. (robert levas via jaimin)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/c1110058
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/c1110058
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/c1110058
Branch: refs/heads/trunk
Commit: c11100587d8d3334320836acbe53eddb9ee9d317
Parents: 623d2f2
Author: Jaimin Jetly <ja...@hortonworks.com>
Authored: Mon Dec 22 11:11:10 2014 -0800
Committer: Jaimin Jetly <ja...@hortonworks.com>
Committed: Mon Dec 22 11:11:10 2014 -0800
----------------------------------------------------------------------
.../ambari/server/actionmanager/Stage.java | 29 +++++--
.../server/controller/KerberosHelper.java | 79 ++++++++++----------
.../internal/UpgradeResourceProvider.java | 2 +-
.../actionmanager/TestActionDBAccessorImpl.java | 2 +-
.../actionmanager/TestActionScheduler.java | 3 +-
.../serveraction/ServerActionExecutorTest.java | 4 +-
6 files changed, 67 insertions(+), 52 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/c1110058/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 4922fa5..57fadf7 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
@@ -315,23 +315,25 @@ public class Stage {
* @param event a ServiceComponentHostServerActionEvent
* @param commandParams a Map of String to String data used to pass to the action - this may be
* empty or null if no data is relevant
+ * @param commandDetail a String declaring a descriptive name to pass to the action - null or an
+ * empty string indicates no value is to be set
* @param timeout an Integer declaring the timeout for this action - if null, a default
- * timeout will be used
*/
public synchronized void addServerActionCommand(String actionName, Role role, RoleCommand command,
- String clusterName, ServiceComponentHostServerActionEvent event,
- @Nullable Map<String, String> commandParams,
- @Nullable Integer timeout) {
+ String clusterName, ServiceComponentHostServerActionEvent event,
+ @Nullable Map<String, String> commandParams,
+ @Nullable String commandDetail,
+ @Nullable Integer timeout) {
addServerActionCommand(actionName, role, command,
- clusterName, StageUtils.getHostName(), event, commandParams, timeout);
+ clusterName, StageUtils.getHostName(), event, commandParams, commandDetail, timeout);
}
/**
* THIS METHOD IS TO WORKAROUND A BUG! The assumption of the framework
* is that the Ambari Server is installed on a host WITHIN the cluster, which
* is not always true. This method adds a host parameter.
- *
+ * <p/>
* Creates server-side execution command.
* <p/>
* The action name for this command is expected to be the classname of a
@@ -346,12 +348,15 @@ public class Stage {
* @param event a ServiceComponentHostServerActionEvent
* @param commandParams a Map of String to String data used to pass to the action - this may be
* empty or null if no data is relevant
+ * @param commandDetail a String declaring a descriptive name to pass to the action - null or an
+ * empty string indicates no value is to be set
* @param timeout an Integer declaring the timeout for this action - if null, a default
- * timeout will be used
*/
public synchronized void addServerActionCommand(String actionName, Role role, RoleCommand command,
- String clusterName, String hostName, ServiceComponentHostServerActionEvent event,
+ String clusterName, String hostName,
+ ServiceComponentHostServerActionEvent event,
@Nullable Map<String, String> commandParams,
+ @Nullable String commandDetail,
@Nullable Integer timeout) {
ExecutionCommandWrapper commandWrapper = addGenericExecutionCommand(clusterName, hostName, role, command, event);
ExecutionCommand cmd = commandWrapper.getExecutionCommand();
@@ -368,6 +373,14 @@ public class Stage {
Map<String, String> roleParams = new HashMap<String, String>();
roleParams.put(ServerAction.ACTION_NAME, actionName);
cmd.setRoleParams(roleParams);
+
+ if(commandDetail != null) {
+ HostRoleCommand hostRoleCommand = getHostRoleCommand(hostName, role.toString());
+ if (hostRoleCommand != null) {
+ hostRoleCommand.setCommandDetail(commandDetail);
+ hostRoleCommand.setCustomCommandName(actionName);
+ }
+ }
}
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/c1110058/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelper.java
index fb19bd5..0ca40ab 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelper.java
@@ -425,14 +425,14 @@ public class KerberosHelper {
Stage stage = createServerActionStage(++lastStageId,
cluster,
requestStageContainer.getId(),
- "Finalize Operations",
+ "Process Kerberos Operations",
clusterHostInfoJson,
"{}",
hostParamsJson,
FinalizeKerberosServerAction.class,
event,
commandParameters,
- 300);
+ "Finalize Operations", 300);
RoleGraph roleGraph = new RoleGraph(roleCommandOrder);
roleGraph.build(stage);
@@ -741,15 +741,17 @@ public class KerberosHelper {
* @param event The relevant ServiceComponentHostServerActionEvent
* @param commandParameters a Map of command parameters to attach to the task added to the new
* stage
- * @param timeout the timeout for the task/action
- * @return a newly created Stage
+ * @param commandDetail a String declaring a descriptive name to pass to the action - null or an
+ * empty string indicates no value is to be set
+ * @param timeout the timeout for the task/action @return a newly created Stage
*/
private Stage createServerActionStage(long id, Cluster cluster, long requestId,
String requestContext, String clusterHostInfo,
String commandParams, String hostParams,
Class<? extends ServerAction> actionClass,
ServiceComponentHostServerActionEvent event,
- Map<String, String> commandParameters, Integer timeout) {
+ Map<String, String> commandParameters, String commandDetail,
+ Integer timeout) {
Stage stage = createNewStage(id, cluster, requestId, requestContext, clusterHostInfo, commandParams, hostParams);
stage.addServerActionCommand(actionClass.getName(),
@@ -758,6 +760,7 @@ public class KerberosHelper {
cluster.getClusterName(),
event,
commandParameters,
+ commandDetail,
timeout);
return stage;
@@ -991,13 +994,14 @@ public class KerberosHelper {
stage = createServerActionStage(++stageId,
cluster,
requestStageContainer.getId(),
- "Create Principals",
+ "Process Kerberos Operations",
clusterHostInfoJson,
"{}",
hostParamsJson,
CreatePrincipalsServerAction.class,
event,
commandParameters,
+ "Create Principals",
1200);
roleGraph = new RoleGraph(roleCommandOrder);
@@ -1009,13 +1013,14 @@ public class KerberosHelper {
stage = createServerActionStage(++stageId,
cluster,
requestStageContainer.getId(),
- "Create Keytabs",
+ "Process Kerberos Operations",
clusterHostInfoJson,
"{}",
hostParamsJson,
CreateKeytabFilesServerAction.class,
event,
commandParameters,
+ "Create Keytabs",
1200);
roleGraph = new RoleGraph(roleCommandOrder);
@@ -1023,27 +1028,25 @@ public class KerberosHelper {
requestStageContainer.addStages(roleGraph.getStages());
// Create stage to distribute keytabs
-
- List<RequestResourceFilter> requestResourceFilters = new ArrayList<RequestResourceFilter>();
- RequestResourceFilter reqResFilter = new RequestResourceFilter("KERBEROS", "KERBEROS_CLIENT", updateHosts);
- requestResourceFilters.add(reqResFilter);
-
stage = createNewStage(++stageId,
- cluster,
- requestStageContainer.getId(),
- "Distribute Keytabs",
- clusterHostInfoJson,
- StageUtils.getGson().toJson(commandParameters),
- hostParamsJson);
-
- Map<String, String> requestParams = new HashMap<String, String>();
-
- ActionExecutionContext actionExecContext = new ActionExecutionContext(
- cluster.getClusterName(),
- "SET_KEYTAB",
- requestResourceFilters,
- requestParams);
- if (!updateHosts.isEmpty()) {
+ cluster,
+ requestStageContainer.getId(),
+ "Process Kerberos Operations",
+ clusterHostInfoJson,
+ StageUtils.getGson().toJson(commandParameters),
+ hostParamsJson);
+
+ if (!updateHosts.isEmpty()) {
+ Map<String, String> requestParams = new HashMap<String, String>();
+ List<RequestResourceFilter> requestResourceFilters = new ArrayList<RequestResourceFilter>();
+ RequestResourceFilter reqResFilter = new RequestResourceFilter("KERBEROS", "KERBEROS_CLIENT", updateHosts);
+ requestResourceFilters.add(reqResFilter);
+
+ ActionExecutionContext actionExecContext = new ActionExecutionContext(
+ cluster.getClusterName(),
+ "SET_KEYTAB",
+ requestResourceFilters,
+ requestParams);
customCommandExecutionHelper.addExecutionCommandsToStage(actionExecContext, stage, requestParams);
}
@@ -1052,18 +1055,18 @@ public class KerberosHelper {
requestStageContainer.addStages(roleGraph.getStages());
// Create stage to update configurations of services
-
stage = createServerActionStage(++stageId,
- cluster,
- requestStageContainer.getId(),
- "Update Service Configurations",
- clusterHostInfoJson,
- "{}",
- hostParamsJson,
- UpdateKerberosConfigsServerAction.class,
- event,
- commandParameters,
- 1200);
+ cluster,
+ requestStageContainer.getId(),
+ "Process Kerberos Operations",
+ clusterHostInfoJson,
+ "{}",
+ hostParamsJson,
+ UpdateKerberosConfigsServerAction.class,
+ event,
+ commandParameters,
+ "Update Service Configurations",
+ 1200);
roleGraph = new RoleGraph(roleCommandOrder);
roleGraph.build(stage);
http://git-wip-us.apache.org/repos/asf/ambari/blob/c1110058/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
index fa39c97..efc3713 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
@@ -674,7 +674,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
RoleCommand.EXECUTE,
cluster.getClusterName(), host,
new ServiceComponentHostServerActionEvent(StageUtils.getHostName(), System.currentTimeMillis()),
- commandParams, 1200);
+ commandParams, null, 1200);
request.addStages(Collections.singletonList(stage));
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/c1110058/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 a756275..7e4f850 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
@@ -581,7 +581,7 @@ public class TestActionDBAccessorImpl {
Stage s = new Stage(requestId, "/a/b", "cluster1", 1L, "action db accessor test",
"", "commandParamsStage", "hostParamsStage");
s.setStageId(stageId);
- s.addServerActionCommand(serverActionName, Role.AMBARI_SERVER_ACTION, RoleCommand.ACTIONEXECUTE, clusterName, null, null, 300);
+ s.addServerActionCommand(serverActionName, Role.AMBARI_SERVER_ACTION, RoleCommand.ACTIONEXECUTE, clusterName, null, null, "command details", 300);
List<Stage> stages = new ArrayList<Stage>();
stages.add(s);
final RequestResourceFilter resourceFilter = new RequestResourceFilter("AMBARI", "SERVER", Arrays.asList(hostname));
http://git-wip-us.apache.org/repos/asf/ambari/blob/c1110058/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 8ce4ff2..edbb71d 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
@@ -65,7 +65,6 @@ import org.apache.ambari.server.utils.StageUtils;
import org.easymock.Capture;
import org.easymock.EasyMock;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
@@ -770,7 +769,7 @@ public class TestActionScheduler {
RoleCommand.EXECUTE, "cluster1",
new ServiceComponentHostServerActionEvent(serverHostname, System.currentTimeMillis()),
payload,
- timeout);
+ null, timeout);
return stage;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/c1110058/ambari-server/src/test/java/org/apache/ambari/server/serveraction/ServerActionExecutorTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/ServerActionExecutorTest.java b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/ServerActionExecutorTest.java
index 4bd0d18..96c0539 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/ServerActionExecutorTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/ServerActionExecutorTest.java
@@ -99,7 +99,7 @@ public class ServerActionExecutorTest {
RoleCommand.EXECUTE,
"cluster1", SERVER_HOST_NAME,
new ServiceComponentHostServerActionEvent(StageUtils.getHostName(), System.currentTimeMillis()),
- Collections.<String, String>emptyMap(), 1200);
+ Collections.<String, String>emptyMap(), null, 1200);
final List<Stage> stages = new ArrayList<Stage>() {
{
@@ -289,7 +289,7 @@ public class ServerActionExecutorTest {
stage.addServerActionCommand(MockServerAction.class.getName(), Role.AMBARI_SERVER_ACTION,
RoleCommand.EXECUTE, "cluster1",
new ServiceComponentHostServerActionEvent(SERVER_HOST_NAME, System.currentTimeMillis()),
- payload, timeout);
+ payload, "command detail", timeout);
return stage;
}