You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ds...@apache.org on 2017/12/19 16:15:10 UTC
[1/3] ambari git commit: AMBARI-22428 Update db schema to use
service_id instead of service_name (requests part) (dsen)
Repository: ambari
Updated Branches:
refs/heads/branch-feature-AMBARI-14714 61f02394c -> 68c62212c
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/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 43d464f..34bbb8c 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
@@ -1699,8 +1699,8 @@ public class AmbariManagementControllerTest {
new ServiceComponentHostRequest(clusterFoo, "SG2", "HDFS", "NAMENODE", host2, null)
);
controller.createHostComponents(requests);
- fail("Expected failure for dup requests");
- } catch (DuplicateResourceException e) {
+ fail("Expected failure for wrong service requests as the SG1 service group doesn't exist on cluster");
+ } catch (IllegalArgumentException e) {
// Expected
}
@@ -2718,7 +2718,7 @@ public class AmbariManagementControllerTest {
createServiceComponentHost(cluster1, serviceGroupName, serviceName, componentName2, host2, null);
RequestOperationLevel level = new RequestOperationLevel(
- Resource.Type.HostComponent, cluster1, null, null, null);
+ Resource.Type.HostComponent, cluster1, null, null, null, null);
// Install
installService(cluster1, serviceGroupName, serviceName, false, false);
@@ -2737,7 +2737,7 @@ public class AmbariManagementControllerTest {
put("excluded_hosts", host2);
put("align_maintenance_state", "true");
}};
- RequestResourceFilter resourceFilter = new RequestResourceFilter("HBASE", "HBASE_MASTER", null);
+ RequestResourceFilter resourceFilter = new RequestResourceFilter(serviceGroupName, "HBASE", "HBASE_MASTER", null);
List<RequestResourceFilter> resourceFilters = new ArrayList<>();
resourceFilters.add(resourceFilter);
@@ -2779,7 +2779,7 @@ public class AmbariManagementControllerTest {
put("slave_type", "HBASE_REGIONSERVER");
put("align_maintenance_state", "true");
}};
- resourceFilter = new RequestResourceFilter("HBASE", "HBASE_MASTER", null);
+ resourceFilter = new RequestResourceFilter(serviceGroupName, "HBASE", "HBASE_MASTER", null);
ArrayList<RequestResourceFilter> filters = new ArrayList<>();
filters.add(resourceFilter);
request = new ExecuteActionRequest(cluster1, "DECOMMISSION", null,
@@ -3848,7 +3848,8 @@ public class AmbariManagementControllerTest {
RepositoryVersionEntity repositoryVersion = repositoryVersion206;
- ServiceGroup serviceGroup = cluster.addServiceGroup("CORE");
+ String serviceGroupName = "CORE";
+ ServiceGroup serviceGroup = cluster.addServiceGroup(serviceGroupName);
Service hdfs = cluster.addService(serviceGroup, "HDFS", "HDFS", repositoryVersion);
Service mapred = cluster.addService(serviceGroup, "YARN", "YARN", repositoryVersion);
@@ -3868,10 +3869,10 @@ public class AmbariManagementControllerTest {
ActionDefinition a1 = new ActionDefinition(actionDef1, ActionType.SYSTEM,
- "test,[optional1]", "", "", "Does file exist", TargetHostType.SPECIFIC, Short.valueOf("100"), null);
+ "test,[optional1]", serviceGroupName, "", "", "Does file exist", TargetHostType.SPECIFIC, Short.valueOf("100"), null);
controller.getAmbariMetaInfo().addActionDefinition(a1);
controller.getAmbariMetaInfo().addActionDefinition(new ActionDefinition(
- actionDef2, ActionType.SYSTEM, "", "HDFS", "DATANODE", "Does file exist",
+ actionDef2, ActionType.SYSTEM, "", serviceGroupName, "HDFS", "DATANODE", "Does file exist",
TargetHostType.ALL, Short.valueOf("1000"), null));
Map<String, String> params = new HashMap<String, String>() {{
@@ -3884,7 +3885,7 @@ public class AmbariManagementControllerTest {
requestProperties.put("datanode", "abc");
ArrayList<String> hosts = new ArrayList<String>() {{add(host1);}};
- RequestResourceFilter resourceFilter = new RequestResourceFilter("HDFS", "DATANODE", hosts);
+ RequestResourceFilter resourceFilter = new RequestResourceFilter(serviceGroupName, "HDFS", "DATANODE", hosts);
List<RequestResourceFilter> resourceFilters = new ArrayList<>();
resourceFilters.add(resourceFilter);
@@ -3934,7 +3935,7 @@ public class AmbariManagementControllerTest {
Assert.assertEquals("1800", cmd.getCommandParams().get("command_timeout"));
resourceFilters.clear();
- resourceFilter = new RequestResourceFilter("HDFS", "", null);
+ resourceFilter = new RequestResourceFilter(serviceGroupName, "HDFS", "", null);
resourceFilters.add(resourceFilter);
actionRequest = new ExecuteActionRequest(cluster1, null, actionDef2, resourceFilters, null, params, false);
response = controller.createAction(actionRequest, requestProperties);
@@ -3970,7 +3971,7 @@ public class AmbariManagementControllerTest {
hosts = new ArrayList<String>() {{add(host3);}};
resourceFilters.clear();
- resourceFilter = new RequestResourceFilter("HDFS", "", hosts);
+ resourceFilter = new RequestResourceFilter(serviceGroupName, "HDFS", "", hosts);
resourceFilters.add(resourceFilter);
actionRequest = new ExecuteActionRequest(cluster1, null, actionDef1, resourceFilters, null, params, false);
@@ -4005,7 +4006,8 @@ public class AmbariManagementControllerTest {
RepositoryVersionEntity repositoryVersion = repositoryVersion207;
- ServiceGroup serviceGroup = cluster.addServiceGroup("CORE");
+ String serviceGroupName = "CORE";
+ ServiceGroup serviceGroup = cluster.addServiceGroup(serviceGroupName);
Service hdfs = cluster.addService(serviceGroup, "HDFS", "HDFS", repositoryVersion);
hdfs.addServiceComponent(Role.HDFS_CLIENT.name());
@@ -4038,6 +4040,7 @@ public class AmbariManagementControllerTest {
put("test", "test");
}};
RequestResourceFilter resourceFilter = new RequestResourceFilter(
+ serviceGroupName,
"HDFS",
"HDFS_CLIENT",
Arrays.asList(host1));
@@ -4109,7 +4112,8 @@ public class AmbariManagementControllerTest {
cluster.addDesiredConfig("_test", Collections.singleton(config1));
cluster.addDesiredConfig("_test", Collections.singleton(config2));
- ServiceGroup serviceGroup = cluster.addServiceGroup("CORE");
+ String serviceGroupName = "CORE";
+ ServiceGroup serviceGroup = cluster.addServiceGroup(serviceGroupName);
Service hdfs = cluster.addService(serviceGroup, "HDFS", "HDFS", repositoryVersion);
Service hive = cluster.addService(serviceGroup, "HIVE", "HIVE", repositoryVersion);
@@ -4127,7 +4131,7 @@ public class AmbariManagementControllerTest {
put("test", "test");
}};
- RequestResourceFilter resourceFilter = new RequestResourceFilter("HDFS", null, null);
+ RequestResourceFilter resourceFilter = new RequestResourceFilter(serviceGroupName, "HDFS", null, null);
ExecuteActionRequest actionRequest = new ExecuteActionRequest(cluster1, "NON_EXISTENT_CHECK", params, false);
actionRequest.getResourceFilters().add(resourceFilter);
@@ -4149,7 +4153,7 @@ public class AmbariManagementControllerTest {
//actionRequest = new ExecuteActionRequest(cluster1, "DECOMMISSION", "HDFS", params);
//expectActionCreationErrorWithMessage(actionRequest, requestProperties, "Unsupported action DECOMMISSION for Service: HDFS and Component: null");
- resourceFilter = new RequestResourceFilter("HDFS", "HDFS_CLIENT", null);
+ resourceFilter = new RequestResourceFilter(serviceGroupName, "HDFS", "HDFS_CLIENT", null);
List<RequestResourceFilter> resourceFilters = new ArrayList<>();
resourceFilters.add(resourceFilter);
@@ -4159,19 +4163,19 @@ public class AmbariManagementControllerTest {
"Unsupported action DECOMMISSION for Service: HDFS and Component: HDFS_CLIENT");
resourceFilters.clear();
- resourceFilter = new RequestResourceFilter("HDFS", null, null);
+ resourceFilter = new RequestResourceFilter(serviceGroupName, "HDFS", null, null);
resourceFilters.add(resourceFilter);
actionRequest = new ExecuteActionRequest(cluster1, null, "DECOMMISSION_DATANODE", resourceFilters, null, params, false);
expectActionCreationErrorWithMessage(actionRequest, requestProperties,
"Action DECOMMISSION_DATANODE does not exist");
resourceFilters.clear();
- resourceFilter = new RequestResourceFilter("YARN", "RESOURCEMANAGER", null);
+ resourceFilter = new RequestResourceFilter(serviceGroupName, "YARN", "RESOURCEMANAGER", null);
resourceFilters.add(resourceFilter);
actionRequest = new ExecuteActionRequest(cluster1, "DECOMMISSION", null, resourceFilters, null, params, false);
expectActionCreationErrorWithMessage(actionRequest, requestProperties,
- "Service not found, clusterName=" + cluster1 + ", serviceName=YARN");
+ "Service not found, clusterName=" + cluster1 + ", serviceGroupName=CORE, serviceName=YARN");
Map<String, String> params2 = new HashMap<String, String>() {{
put("included_hosts", "h1,h2");
@@ -4179,7 +4183,7 @@ public class AmbariManagementControllerTest {
}};
resourceFilters.clear();
- resourceFilter = new RequestResourceFilter("HDFS", "NAMENODE", null);
+ resourceFilter = new RequestResourceFilter(serviceGroupName, "HDFS", "NAMENODE", null);
resourceFilters.add(resourceFilter);
actionRequest = new ExecuteActionRequest(cluster1, "DECOMMISSION", null, resourceFilters, null, params2, false);
@@ -4192,7 +4196,7 @@ public class AmbariManagementControllerTest {
put("slave_type", "HDFS_CLIENT");
}};
resourceFilters.clear();
- resourceFilter = new RequestResourceFilter("HDFS", "NAMENODE", null);
+ resourceFilter = new RequestResourceFilter(serviceGroupName, "HDFS", "NAMENODE", null);
resourceFilters.add(resourceFilter);
actionRequest = new ExecuteActionRequest(cluster1, "DECOMMISSION", null, resourceFilters, null, params2, false);
@@ -4202,7 +4206,7 @@ public class AmbariManagementControllerTest {
List<String> hosts = new ArrayList<>();
hosts.add("h6");
resourceFilters.clear();
- resourceFilter = new RequestResourceFilter("HDFS", "NAMENODE", hosts);
+ resourceFilter = new RequestResourceFilter(serviceGroupName, "HDFS", "NAMENODE", hosts);
resourceFilters.add(resourceFilter);
actionRequest = new ExecuteActionRequest(cluster1, "DECOMMISSION", null, resourceFilters, null, params2, false);
@@ -4214,7 +4218,7 @@ public class AmbariManagementControllerTest {
put("excluded_hosts", host1);
}};
resourceFilters.clear();
- resourceFilter = new RequestResourceFilter("HDFS", "NAMENODE", null);
+ resourceFilter = new RequestResourceFilter(serviceGroupName, "HDFS", "NAMENODE", null);
resourceFilters.add(resourceFilter);
actionRequest = new ExecuteActionRequest(cluster1, "DECOMMISSION", null, resourceFilters, null, params2, false);
@@ -4235,23 +4239,23 @@ public class AmbariManagementControllerTest {
String actionDef4 = getUniqueName();
controller.getAmbariMetaInfo().addActionDefinition(new ActionDefinition(
- actionDef1, ActionType.SYSTEM, "test,dirName", "", "", "Does file exist",
+ actionDef1, ActionType.SYSTEM, "test,dirName", "", "", "", "Does file exist",
TargetHostType.SPECIFIC, Short.valueOf("100"), null));
controller.getAmbariMetaInfo().addActionDefinition(new ActionDefinition(
- actionDef2, ActionType.SYSTEM, "", "HDFS", "DATANODE", "Does file exist",
+ actionDef2, ActionType.SYSTEM, "", serviceGroupName, "HDFS", "DATANODE", "Does file exist",
TargetHostType.ANY, Short.valueOf("100"), null));
controller.getAmbariMetaInfo().addActionDefinition(new ActionDefinition(
- "update_repo", ActionType.SYSTEM, "", "HDFS", "DATANODE", "Does file exist",
+ "update_repo", ActionType.SYSTEM, "", serviceGroupName, "HDFS", "DATANODE", "Does file exist",
TargetHostType.ANY, Short.valueOf("100"), null));
controller.getAmbariMetaInfo().addActionDefinition(new ActionDefinition(
- actionDef3, ActionType.SYSTEM, "", "MAPREDUCE", "MAPREDUCE_CLIENT", "Does file exist",
+ actionDef3, ActionType.SYSTEM, "", serviceGroupName, "MAPREDUCE", "MAPREDUCE_CLIENT", "Does file exist",
TargetHostType.ANY, Short.valueOf("100"), null));
controller.getAmbariMetaInfo().addActionDefinition(new ActionDefinition(
- actionDef4, ActionType.SYSTEM, "", "HIVE", "", "Does file exist",
+ actionDef4, ActionType.SYSTEM, "", serviceGroupName, "HIVE", "", "Does file exist",
TargetHostType.ANY, Short.valueOf("100"), null));
actionRequest = new ExecuteActionRequest(cluster1, null, actionDef1, null, null, null, false);
@@ -4268,7 +4272,7 @@ public class AmbariManagementControllerTest {
"Action " + actionDef1 + " requires explicit target host(s)");
resourceFilters.clear();
- resourceFilter = new RequestResourceFilter("HIVE", null, null);
+ resourceFilter = new RequestResourceFilter(serviceGroupName, "HIVE", null, null);
resourceFilters.add(resourceFilter);
actionRequest = new ExecuteActionRequest(cluster1, null, actionDef2, resourceFilters, null, params, false);
@@ -4276,7 +4280,7 @@ public class AmbariManagementControllerTest {
"Action " + actionDef2 + " targets service HIVE that does not match with expected HDFS");
resourceFilters.clear();
- resourceFilter = new RequestResourceFilter("HDFS", "HDFS_CLIENT", null);
+ resourceFilter = new RequestResourceFilter(serviceGroupName, "HDFS", "HDFS_CLIENT", null);
resourceFilters.add(resourceFilter);
actionRequest = new ExecuteActionRequest(cluster1, null, actionDef2, resourceFilters, null, params, false);
@@ -4284,7 +4288,7 @@ public class AmbariManagementControllerTest {
"Action " + actionDef2 + " targets component HDFS_CLIENT that does not match with expected DATANODE");
resourceFilters.clear();
- resourceFilter = new RequestResourceFilter("HDFS2", "HDFS_CLIENT", null);
+ resourceFilter = new RequestResourceFilter(serviceGroupName, "HDFS2", "HDFS_CLIENT", null);
resourceFilters.add(resourceFilter);
actionRequest = new ExecuteActionRequest(cluster1, null, actionDef1, resourceFilters, null, params, false);
@@ -4292,7 +4296,7 @@ public class AmbariManagementControllerTest {
"Service not found, clusterName=" + cluster1 + ", serviceName=HDFS2");
resourceFilters.clear();
- resourceFilter = new RequestResourceFilter("HDFS", "HDFS_CLIENT2", null);
+ resourceFilter = new RequestResourceFilter(serviceGroupName, "HDFS", "HDFS_CLIENT2", null);
resourceFilters.add(resourceFilter);
actionRequest = new ExecuteActionRequest(cluster1, null, actionDef1, resourceFilters, null, params, false);
@@ -4300,7 +4304,7 @@ public class AmbariManagementControllerTest {
"ServiceComponent not found, clusterName=" + cluster1 + ", serviceGroupName=CORE, serviceName=HDFS, serviceType=HDFS, serviceComponentName=HDFS_CLIENT2");
resourceFilters.clear();
- resourceFilter = new RequestResourceFilter("", "HDFS_CLIENT2", null);
+ resourceFilter = new RequestResourceFilter("", "", "HDFS_CLIENT2", null);
resourceFilters.add(resourceFilter);
actionRequest = new ExecuteActionRequest(cluster1, null, actionDef1, resourceFilters, null, params, false);
@@ -4308,7 +4312,7 @@ public class AmbariManagementControllerTest {
"Action " + actionDef1 + " targets component HDFS_CLIENT2 without specifying the target service");
resourceFilters.clear();
- resourceFilter = new RequestResourceFilter("", "", null);
+ resourceFilter = new RequestResourceFilter("", "", "", null);
resourceFilters.add(resourceFilter);
// targets a service that is not a member of the stack (e.g. MR not in HDP-2)
@@ -4319,20 +4323,20 @@ public class AmbariManagementControllerTest {
hosts = new ArrayList<>();
hosts.add("h6");
resourceFilters.clear();
- resourceFilter = new RequestResourceFilter("HDFS", "", hosts);
+ resourceFilter = new RequestResourceFilter(serviceGroupName, "HDFS", "", hosts);
resourceFilters.add(resourceFilter);
actionRequest = new ExecuteActionRequest(cluster1, null, actionDef2, resourceFilters, null, params, false);
expectActionCreationErrorWithMessage(actionRequest, requestProperties,
- "Request specifies host h6 but it is not a valid host based on the target service=HDFS and component=DATANODE");
+ "Request specifies host h6 but it is not a valid host based on the target serviceGroup=CORE, service=HDFS and component=DATANODE");
resourceFilters.clear();
- resourceFilter = new RequestResourceFilter("HIVE", "", null);
+ resourceFilter = new RequestResourceFilter(serviceGroupName, "HIVE", "", null);
resourceFilters.add(resourceFilter);
actionRequest = new ExecuteActionRequest(cluster1, null, actionDef4, resourceFilters, null, params, false);
expectActionCreationErrorWithMessage(actionRequest, requestProperties,
- "Suitable hosts not found, component=, service=HIVE, cluster=" + cluster1 + ", actionName=" + actionDef4);
+ "Suitable hosts not found, component=, service=HIVE, serviceGroup=CORE, cluster=" + cluster1 + ", actionName=" + actionDef4);
}
@@ -4391,7 +4395,7 @@ public class AmbariManagementControllerTest {
put("test", "test");
}};
ExecuteActionRequest actionRequest = new ExecuteActionRequest(cluster1, Role.HDFS_SERVICE_CHECK.name(), params, false);
- RequestResourceFilter resourceFilter = new RequestResourceFilter("HDFS", null, null);
+ RequestResourceFilter resourceFilter = new RequestResourceFilter("CORE", "HDFS", null, null);
actionRequest.getResourceFilters().add(resourceFilter);
Map<String, String> requestProperties = new HashMap<>();
@@ -4436,7 +4440,7 @@ public class AmbariManagementControllerTest {
assertEquals(requestProperties.get(REQUEST_CONTEXT_PROPERTY), response.getRequestContext());
actionRequest = new ExecuteActionRequest(cluster1, Role.MAPREDUCE_SERVICE_CHECK.name(), null, false);
- resourceFilter = new RequestResourceFilter("MAPREDUCE", null, null);
+ resourceFilter = new RequestResourceFilter("CORE", "MAPREDUCE", null, null);
actionRequest.getResourceFilters().add(resourceFilter);
injector.getInstance(ActionMetadata.class).addServiceCheckAction("MAPREDUCE");
@@ -5582,7 +5586,7 @@ public class AmbariManagementControllerTest {
}
Assert.assertEquals("Expect only one service check.", 1, commandCount);
- RequestResourceFilter resourceFilter = new RequestResourceFilter("HDFS", null, null);
+ RequestResourceFilter resourceFilter = new RequestResourceFilter(serviceGroupName, "HDFS", null, null);
ExecuteActionRequest actionRequest = new ExecuteActionRequest(cluster1, Role.HDFS_SERVICE_CHECK.name(), null, false);
actionRequest.getResourceFilters().add(resourceFilter);
Map<String, String> requestProperties = new HashMap<>();
@@ -5814,7 +5818,7 @@ public class AmbariManagementControllerTest {
createServiceComponentHost(cluster1, serviceGroupName, serviceName, componentName3, host2, null);
RequestOperationLevel level = new RequestOperationLevel(
- Resource.Type.HostComponent, cluster1, null, null, null);
+ Resource.Type.HostComponent, cluster1, null, null, null, null);
// Install
installService(cluster1, serviceGroupName, serviceName, false, false);
@@ -5845,7 +5849,7 @@ public class AmbariManagementControllerTest {
put("excluded_hosts", host2);
put("align_maintenance_state", "true");
}};
- RequestResourceFilter resourceFilter = new RequestResourceFilter("HDFS", "NAMENODE", null);
+ RequestResourceFilter resourceFilter = new RequestResourceFilter(serviceGroupName, "HDFS", "NAMENODE", null);
ArrayList<RequestResourceFilter> filters = new ArrayList<>();
filters.add(resourceFilter);
ExecuteActionRequest request = new ExecuteActionRequest(cluster1,
@@ -5877,7 +5881,7 @@ public class AmbariManagementControllerTest {
put("excluded_hosts", host1);
put("align_maintenance_state", "true");
}};
- resourceFilter = new RequestResourceFilter("HDFS", "NAMENODE", null);
+ resourceFilter = new RequestResourceFilter(serviceGroupName, "HDFS", "NAMENODE", null);
filters = new ArrayList<>();
filters.add(resourceFilter);
@@ -5921,7 +5925,7 @@ public class AmbariManagementControllerTest {
put("included_hosts", host1 + " , " + host2);
put("align_maintenance_state", "true");
}};
- resourceFilter = new RequestResourceFilter("HDFS", "NAMENODE", null);
+ resourceFilter = new RequestResourceFilter(serviceGroupName, "HDFS", "NAMENODE", null);
filters = new ArrayList<>();
filters.add(resourceFilter);
request = new ExecuteActionRequest(cluster1, "DECOMMISSION", null,
@@ -6003,7 +6007,7 @@ public class AmbariManagementControllerTest {
String action1 = getUniqueName();
controller.getAmbariMetaInfo().addActionDefinition(new ActionDefinition(
- action1, ActionType.SYSTEM, "", "HDFS", "", "Some custom action.",
+ action1, ActionType.SYSTEM, "", "CORE", "HDFS", "", "Some custom action.",
TargetHostType.ALL, Short.valueOf("10010"), null));
Map<String, String> params = new HashMap<String, String>() {{
@@ -6015,10 +6019,10 @@ public class AmbariManagementControllerTest {
List<RequestResourceFilter> resourceFilters = new ArrayList<>();
List<String> hosts = Arrays.asList(host2);
- RequestResourceFilter resourceFilter1 = new RequestResourceFilter("HDFS", "DATANODE", hosts);
+ RequestResourceFilter resourceFilter1 = new RequestResourceFilter("CORE", "HDFS", "DATANODE", hosts);
hosts = Arrays.asList(host1);
- RequestResourceFilter resourceFilter2 = new RequestResourceFilter("HDFS", "NAMENODE", hosts);
+ RequestResourceFilter resourceFilter2 = new RequestResourceFilter("CORE", "HDFS", "NAMENODE", hosts);
resourceFilters.add(resourceFilter1);
resourceFilters.add(resourceFilter2);
@@ -6111,10 +6115,10 @@ public class AmbariManagementControllerTest {
// Test multiple restarts
List<RequestResourceFilter> resourceFilters = new ArrayList<>();
- RequestResourceFilter resourceFilter = new RequestResourceFilter("HDFS",
+ RequestResourceFilter resourceFilter = new RequestResourceFilter("CORE", "HDFS",
Role.DATANODE.name(), Arrays.asList(host1, host2));
resourceFilters.add(resourceFilter);
- resourceFilter = new RequestResourceFilter("YARN",
+ resourceFilter = new RequestResourceFilter("CORE", "YARN",
Role.RESOURCEMANAGER.name(), Arrays.asList(host2));
resourceFilters.add(resourceFilter);
@@ -6185,7 +6189,7 @@ public class AmbariManagementControllerTest {
// Test service checks - specific host
resourceFilters.clear();
- resourceFilter = new RequestResourceFilter("HDFS", null,
+ resourceFilter = new RequestResourceFilter("CORE", "HDFS", null,
Arrays.asList(host1));
resourceFilters.add(resourceFilter);
request = new ExecuteActionRequest(cluster1, Role.HDFS_SERVICE_CHECK.name(),
@@ -6641,7 +6645,7 @@ public class AmbariManagementControllerTest {
put("test", "test");
put("excluded_hosts", host1);
}};
- RequestResourceFilter resourceFilter = new RequestResourceFilter("HDFS", "NAMENODE", null);
+ RequestResourceFilter resourceFilter = new RequestResourceFilter(serviceGroupName, "HDFS", "NAMENODE", null);
ExecuteActionRequest request = new ExecuteActionRequest(cluster1, "DECOMMISSION", params, false);
request.getResourceFilters().add(resourceFilter);
@@ -7470,7 +7474,7 @@ public class AmbariManagementControllerTest {
RoleCommand.START,
new ServiceComponentHostStartEvent(Role.HBASE_MASTER.toString(),
hostName1, System.currentTimeMillis()),
- cluster1, "HBASE", false, false);
+ cluster1, "CORE", "HBASE", false, false);
stages.add(stageFactory.createNew(requestId1, "/a2", cluster1, clusterId, context,
"", ""));
@@ -7478,7 +7482,7 @@ public class AmbariManagementControllerTest {
stages.get(1).addHostRoleExecutionCommand(hostName1, Role.HBASE_CLIENT,
RoleCommand.START,
new ServiceComponentHostStartEvent(Role.HBASE_CLIENT.toString(),
- hostName1, System.currentTimeMillis()), cluster1, "HBASE", false, false);
+ hostName1, System.currentTimeMillis()), cluster1, "CORE", "HBASE", false, false);
stages.add(stageFactory.createNew(requestId1, "/a3", cluster1, clusterId, context,
"", ""));
@@ -7486,7 +7490,7 @@ public class AmbariManagementControllerTest {
stages.get(2).addHostRoleExecutionCommand(hostName1, Role.HBASE_CLIENT,
RoleCommand.START,
new ServiceComponentHostStartEvent(Role.HBASE_CLIENT.toString(),
- hostName1, System.currentTimeMillis()), cluster1, "HBASE", false, false);
+ hostName1, System.currentTimeMillis()), cluster1, "CORE", "HBASE", false, false);
Request request = new Request(stages, "", clusters);
actionDB.persistActions(request);
@@ -7498,7 +7502,7 @@ public class AmbariManagementControllerTest {
stages.get(0).addHostRoleExecutionCommand(hostName1, Role.HBASE_CLIENT,
RoleCommand.START,
new ServiceComponentHostStartEvent(Role.HBASE_CLIENT.toString(),
- hostName1, System.currentTimeMillis()), cluster1, "HBASE", false, false);
+ hostName1, System.currentTimeMillis()), cluster1, "CORE", "HBASE", false, false);
stages.add(stageFactory.createNew(requestId2, "/a5", cluster1, clusterId, context,
"", ""));
@@ -7506,7 +7510,7 @@ public class AmbariManagementControllerTest {
stages.get(1).addHostRoleExecutionCommand(hostName1, Role.HBASE_CLIENT,
RoleCommand.START,
new ServiceComponentHostStartEvent(Role.HBASE_CLIENT.toString(),
- hostName1, System.currentTimeMillis()), cluster1, "HBASE", false, false);
+ hostName1, System.currentTimeMillis()), cluster1, "CORE", "HBASE", false, false);
request = new Request(stages, "", clusters);
actionDB.persistActions(request);
@@ -8333,7 +8337,7 @@ public class AmbariManagementControllerTest {
amc.createHostComponents(componentHostRequests);
- RequestResourceFilter resourceFilter = new RequestResourceFilter("HDFS", null, null);
+ RequestResourceFilter resourceFilter = new RequestResourceFilter(serviceGroupName, "HDFS", null, null);
ExecuteActionRequest ar = new ExecuteActionRequest(clusterName, Role.HDFS_SERVICE_CHECK.name(), null, false);
ar.getResourceFilters().add(resourceFilter);
amc.createAction(ar, null);
@@ -9752,7 +9756,7 @@ public class AmbariManagementControllerTest {
String action1 = getUniqueName();
ambariMetaInfo.addActionDefinition(new ActionDefinition(action1, ActionType.SYSTEM,
- "", "", "", "action def description", TargetHostType.ANY,
+ "", "", "", "", "action def description", TargetHostType.ANY,
Short.valueOf("60"), null));
Map<String, String> requestProperties = new HashMap<>();
@@ -9763,7 +9767,7 @@ public class AmbariManagementControllerTest {
// !!! target single host
List<String> hosts = Arrays.asList(hostname1);
- RequestResourceFilter resourceFilter = new RequestResourceFilter(null, null, hosts);
+ RequestResourceFilter resourceFilter = new RequestResourceFilter(null, null, null, hosts);
List<RequestResourceFilter> resourceFilters = new ArrayList<>();
resourceFilters.add(resourceFilter);
@@ -9798,7 +9802,7 @@ public class AmbariManagementControllerTest {
// !!! target two hosts
hosts = Arrays.asList(hostname1, hostname2);
- resourceFilter = new RequestResourceFilter(null, null, hosts);
+ resourceFilter = new RequestResourceFilter(null, null, null, hosts);
resourceFilters = new ArrayList<>();
resourceFilters.add(resourceFilter);
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/test/java/org/apache/ambari/server/controller/BackgroundCustomCommandExecutionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/BackgroundCustomCommandExecutionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/BackgroundCustomCommandExecutionTest.java
index 2bae41d..38d46ed 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/BackgroundCustomCommandExecutionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/BackgroundCustomCommandExecutionTest.java
@@ -146,7 +146,7 @@ public class BackgroundCustomCommandExecutionTest {
ExecuteActionRequest actionRequest = new ExecuteActionRequest("c1",
"REBALANCEHDFS", new HashMap<>(), false);
- actionRequest.getResourceFilters().add(new RequestResourceFilter("HDFS", "NAMENODE",Collections.singletonList("c6401")));
+ actionRequest.getResourceFilters().add(new RequestResourceFilter("CORE", "HDFS", "NAMENODE",Collections.singletonList("c6401")));
controller.createAction(actionRequest, requestProperties);
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/test/java/org/apache/ambari/server/controller/MaintenanceStateHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/MaintenanceStateHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/MaintenanceStateHelperTest.java
index fec463c..b836e99 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/MaintenanceStateHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/MaintenanceStateHelperTest.java
@@ -68,7 +68,7 @@ public class MaintenanceStateHelperTest {
Cluster cluster = createMock(Cluster.class);
Method isOperationAllowed = MaintenanceStateHelper.class.getDeclaredMethod(
"isOperationAllowed", new Class[]{Cluster.class, Type.class,
- String.class, String.class, String.class});
+ String.class, String.class, String.class, String.class});
MaintenanceStateHelper maintenanceStateHelper =
createMockBuilder(MaintenanceStateHelper.class)
.withConstructor(injector)
@@ -80,11 +80,11 @@ public class MaintenanceStateHelperTest {
expect(level.getLevel()).andReturn(Type.Cluster);
expect(maintenanceStateHelper.isOperationAllowed(
anyObject(Cluster.class), anyObject(Type.class),
- anyObject(String.class),
+ anyObject(String.class), anyObject(String.class),
anyObject(String.class), anyObject(String.class))).andStubReturn(true);
// Case when level is defined
replay(cluster, maintenanceStateHelper, level);
- maintenanceStateHelper.isOperationAllowed(cluster, level, filter, "service", "component", "hostname");
+ maintenanceStateHelper.isOperationAllowed(cluster, level, filter, "core", "service", "component", "hostname");
verify(maintenanceStateHelper, level);
maintenanceStateHelper =
@@ -97,11 +97,11 @@ public class MaintenanceStateHelperTest {
expect(maintenanceStateHelper.guessOperationLevel(anyObject(RequestResourceFilter.class))).andReturn(Type.Cluster);
expect(maintenanceStateHelper.isOperationAllowed(
anyObject(Cluster.class), anyObject(Type.class),
- anyObject(String.class),
+ anyObject(String.class), anyObject(String.class),
anyObject(String.class), anyObject(String.class))).andStubReturn(true);
// Case when level is not defined
replay(maintenanceStateHelper);
- maintenanceStateHelper.isOperationAllowed(cluster, null, filter, "service", "component", "hostname");
+ maintenanceStateHelper.isOperationAllowed(cluster, null, filter, "core", "service", "component", "hostname");
verify(maintenanceStateHelper);
}
@@ -443,25 +443,25 @@ public class MaintenanceStateHelperTest {
Assert.assertEquals(Resource.Type.Cluster, maintenanceStateHelper.guessOperationLevel(null));
- RequestResourceFilter resourceFilter = new RequestResourceFilter(null, null, null);
+ RequestResourceFilter resourceFilter = new RequestResourceFilter(null, null, null, null);
Assert.assertEquals(Resource.Type.Cluster, maintenanceStateHelper.guessOperationLevel(resourceFilter));
- resourceFilter = new RequestResourceFilter("HDFS", null, null);
+ resourceFilter = new RequestResourceFilter("core", "HDFS", null, null);
Assert.assertEquals(Resource.Type.Service, maintenanceStateHelper.guessOperationLevel(resourceFilter));
- resourceFilter = new RequestResourceFilter("HDFS", "NAMENODE", null);
+ resourceFilter = new RequestResourceFilter("core", "HDFS", "NAMENODE", null);
Assert.assertEquals(Resource.Type.Service, maintenanceStateHelper.guessOperationLevel(resourceFilter));
ArrayList<String> hosts = new ArrayList<>();
hosts.add("host1");
hosts.add("host2");
- resourceFilter = new RequestResourceFilter("HDFS", null, hosts);
+ resourceFilter = new RequestResourceFilter("core", "HDFS", null, hosts);
Assert.assertEquals(Resource.Type.Cluster, maintenanceStateHelper.guessOperationLevel(resourceFilter));
- resourceFilter = new RequestResourceFilter(null, null, hosts);
+ resourceFilter = new RequestResourceFilter(null, null, null, hosts);
Assert.assertEquals(Resource.Type.Host, maintenanceStateHelper.guessOperationLevel(resourceFilter));
- resourceFilter = new RequestResourceFilter("HDFS", "NAMENODE", hosts);
+ resourceFilter = new RequestResourceFilter("core", "HDFS", "NAMENODE", hosts);
Assert.assertEquals(Resource.Type.HostComponent, maintenanceStateHelper.guessOperationLevel(resourceFilter));
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ActionResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ActionResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ActionResourceProviderTest.java
index ef56f9d..aa4b1df 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ActionResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ActionResourceProviderTest.java
@@ -98,13 +98,13 @@ public class ActionResourceProviderTest {
List<ActionDefinition> allDefinition = new ArrayList<>();
allDefinition.add(new ActionDefinition(
- "a1", ActionType.SYSTEM, "fileName", "HDFS", "DATANODE", "Does file exist", TargetHostType.ANY,
+ "a1", ActionType.SYSTEM, "fileName", "core", "HDFS", "DATANODE", "Does file exist", TargetHostType.ANY,
Short.valueOf("100"), null));
allDefinition.add(new ActionDefinition(
- "a2", ActionType.SYSTEM, "fileName", "HDFS", "DATANODE", "Does file exist", TargetHostType.ANY,
+ "a2", ActionType.SYSTEM, "fileName", "core", "HDFS", "DATANODE", "Does file exist", TargetHostType.ANY,
Short.valueOf("100"), null));
allDefinition.add(new ActionDefinition(
- "a3", ActionType.SYSTEM, "fileName", "HDFS", "DATANODE", "Does file exist", TargetHostType.ANY,
+ "a3", ActionType.SYSTEM, "fileName", "core", "HDFS", "DATANODE", "Does file exist", TargetHostType.ANY,
Short.valueOf("100"), null));
Set<ActionResponse> allResponse = new HashSet<>();
@@ -113,7 +113,7 @@ public class ActionResourceProviderTest {
}
ActionDefinition namedDefinition = new ActionDefinition(
- "a1", ActionType.SYSTEM, "fileName", "HDFS", "DATANODE", "Does file exist", TargetHostType.ANY,
+ "a1", ActionType.SYSTEM, "fileName", "core", "HDFS", "DATANODE", "Does file exist", TargetHostType.ANY,
Short.valueOf("100"), null);
Set<ActionResponse> nameResponse = new HashSet<>();
@@ -140,6 +140,7 @@ public class ActionResourceProviderTest {
propertyIds.add(ActionResourceProvider.TARGET_COMPONENT_PROPERTY_ID);
propertyIds.add(ActionResourceProvider.TARGET_HOST_PROPERTY_ID);
propertyIds.add(ActionResourceProvider.TARGET_SERVICE_PROPERTY_ID);
+ propertyIds.add(ActionResourceProvider.TARGET_SERVICE_GROUP_PROPERTY_ID);
// create the request
@@ -156,10 +157,11 @@ public class ActionResourceProviderTest {
String description = (String) resource.getPropertyValue(ActionResourceProvider.DESCRIPTION_PROPERTY_ID);
String inputs = (String) resource.getPropertyValue(ActionResourceProvider.INPUTS_PROPERTY_ID);
String comp = (String) resource.getPropertyValue(ActionResourceProvider.TARGET_COMPONENT_PROPERTY_ID);
+ String serviceGroup = (String) resource.getPropertyValue(ActionResourceProvider.TARGET_SERVICE_GROUP_PROPERTY_ID);
String svc = (String) resource.getPropertyValue(ActionResourceProvider.TARGET_SERVICE_PROPERTY_ID);
String host = (String) resource.getPropertyValue(ActionResourceProvider.TARGET_HOST_PROPERTY_ID);
Assert.assertTrue(allResponse.contains(new ActionResponse(actionName, actionType,
- inputs, svc, comp, description, host, defaultTimeout)));
+ inputs, serviceGroup, svc, comp, description, host, defaultTimeout)));
}
// get actions named a1
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/test/java/org/apache/ambari/server/stageplanner/TestStagePlanner.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/stageplanner/TestStagePlanner.java b/ambari-server/src/test/java/org/apache/ambari/server/stageplanner/TestStagePlanner.java
index ae3b316..33dd488 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/stageplanner/TestStagePlanner.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/stageplanner/TestStagePlanner.java
@@ -121,10 +121,10 @@ public class TestStagePlanner {
Stage stage = StageUtils.getATestStage(1, 1, "host1", "", "");
stage.addHostRoleExecutionCommand("host2", Role.HBASE_MASTER,
RoleCommand.START, new ServiceComponentHostStartEvent("HBASE_MASTER",
- "host2", now), "cluster1", "HBASE", false, false);
+ "host2", now), "cluster1", "core", "HBASE", false, false);
stage.addHostRoleExecutionCommand("host3", Role.ZOOKEEPER_SERVER,
RoleCommand.START, new ServiceComponentHostStartEvent("ZOOKEEPER_SERVER",
- "host3", now), "cluster1", "ZOOKEEPER", false, false);
+ "host3", now), "cluster1", "core", "ZOOKEEPER", false, false);
log.info("Build and ready to detect circular dependencies - short chain");
rg.build(stage);
boolean exceptionThrown = false;
@@ -160,13 +160,13 @@ public class TestStagePlanner {
Stage stage = StageUtils.getATestStage(1, 1, "host1", "", "");
stage.addHostRoleExecutionCommand("host2", Role.HBASE_MASTER,
RoleCommand.STOP, new ServiceComponentHostStartEvent("HBASE_MASTER",
- "host2", now), "cluster1", "HBASE", false, false);
+ "host2", now), "cluster1", "core", "HBASE", false, false);
stage.addHostRoleExecutionCommand("host3", Role.ZOOKEEPER_SERVER,
RoleCommand.STOP, new ServiceComponentHostStartEvent("ZOOKEEPER_SERVER",
- "host3", now), "cluster1", "ZOOKEEPER", false, false);
+ "host3", now), "cluster1", "core", "ZOOKEEPER", false, false);
stage.addHostRoleExecutionCommand("host2", Role.RESOURCEMANAGER,
RoleCommand.STOP, new ServiceComponentHostStartEvent("RESOURCEMANAGER",
- "host4", now), "cluster1", "YARN", false, false);
+ "host4", now), "cluster1", "core", "YARN", false, false);
log.info("Build and ready to detect circular dependencies - long chain");
rg.build(stage);
@@ -200,13 +200,13 @@ public class TestStagePlanner {
Stage stage = StageUtils.getATestStage(1, 1, "host1", "", "");
stage.addHostRoleExecutionCommand("host2", Role.HBASE_MASTER,
RoleCommand.UPGRADE, new ServiceComponentHostStartEvent("HBASE_MASTER",
- "host2", now), "cluster1", "HBASE", false, false);
+ "host2", now), "cluster1", "core", "HBASE", false, false);
stage.addHostRoleExecutionCommand("host3", Role.ZOOKEEPER_SERVER,
RoleCommand.UPGRADE, new ServiceComponentHostStartEvent("ZOOKEEPER_SERVER",
- "host3", now), "cluster1", "ZOOKEEPER", false, false);
+ "host3", now), "cluster1", "core", "ZOOKEEPER", false, false);
stage.addHostRoleExecutionCommand("host2", Role.HBASE_REGIONSERVER,
RoleCommand.UPGRADE, new ServiceComponentHostStartEvent("HBASE_REGIONSERVER",
- "host4", now), "cluster1", "HBASE", false, false);
+ "host4", now), "cluster1", "core", "HBASE", false, false);
log.info("Build and ready to detect circular dependencies - long chain");
rg.build(stage);
@@ -240,13 +240,13 @@ public class TestStagePlanner {
Stage stage = StageUtils.getATestStage(1, 1, "host1", "", "");
stage.addHostRoleExecutionCommand("host2", Role.HBASE_MASTER,
RoleCommand.STOP, new ServiceComponentHostStartEvent("HBASE_MASTER",
- "host2", now), "cluster1", "HBASE", false, false);
+ "host2", now), "cluster1", "core", "HBASE", false, false);
stage.addHostRoleExecutionCommand("host3", Role.ZOOKEEPER_SERVER,
RoleCommand.STOP, new ServiceComponentHostStartEvent("ZOOKEEPER_SERVER",
- "host3", now), "cluster1", "ZOOKEEPER", false, false);
+ "host3", now), "cluster1", "core", "ZOOKEEPER", false, false);
stage.addHostRoleExecutionCommand("host2", Role.HBASE_REGIONSERVER,
RoleCommand.STOP, new ServiceComponentHostStartEvent("HBASE_REGIONSERVER",
- "host4", now), "cluster1", "HBASE", false, false);
+ "host4", now), "cluster1", "core", "HBASE", false, false);
log.info("Build and ready to detect circular dependencies");
rg.build(stage);
boolean exceptionThrown = false;
@@ -280,10 +280,10 @@ public class TestStagePlanner {
Stage stage = StageUtils.getATestStage(1, 1, "host1", "", "");
stage.addHostRoleExecutionCommand("host2", Role.HBASE_MASTER,
RoleCommand.START, new ServiceComponentHostStartEvent("HBASE_MASTER",
- "host2", now), "cluster1", "HBASE", false, false);
+ "host2", now), "cluster1", "core", "HBASE", false, false);
stage.addHostRoleExecutionCommand("host3", Role.ZOOKEEPER_SERVER,
RoleCommand.START, new ServiceComponentHostStartEvent("ZOOKEEPER_SERVER",
- "host3", now), "cluster1", "ZOOKEEPER", false, false);
+ "host3", now), "cluster1", "core", "ZOOKEEPER", false, false);
log.info(stage.toString());
rg.build(stage);
@@ -375,37 +375,37 @@ public class TestStagePlanner {
Stage stage = StageUtils.getATestStage(1, 1, "host1", "", "");
stage.addHostRoleExecutionCommand("host11", Role.SECONDARY_NAMENODE,
RoleCommand.START, new ServiceComponentHostStartEvent("SECONDARY_NAMENODE",
- "host11", now), "cluster1", "HDFS", false, false);
+ "host11", now), "cluster1", "core", "HDFS", false, false);
stage.addHostRoleExecutionCommand("host2", Role.HBASE_MASTER,
RoleCommand.START, new ServiceComponentHostStartEvent("HBASE_MASTER",
- "host2", now), "cluster1", "HBASE", false, false);
+ "host2", now), "cluster1", "core", "HBASE", false, false);
stage.addHostRoleExecutionCommand("host3", Role.ZOOKEEPER_SERVER,
RoleCommand.START, new ServiceComponentHostStartEvent("ZOOKEEPER_SERVER",
- "host3", now), "cluster1", "ZOOKEEPER", false, false);
+ "host3", now), "cluster1", "core", "ZOOKEEPER", false, false);
stage.addHostRoleExecutionCommand("host4", Role.DATANODE,
RoleCommand.START, new ServiceComponentHostStartEvent("DATANODE",
- "host4", now), "cluster1", "HDFS", false, false);
+ "host4", now), "cluster1", "core", "HDFS", false, false);
stage.addHostRoleExecutionCommand("host4", Role.HBASE_REGIONSERVER,
RoleCommand.START, new ServiceComponentHostStartEvent("HBASE_REGIONSERVER",
- "host4", now), "cluster1", "HBASE", false, false);
+ "host4", now), "cluster1", "core", "HBASE", false, false);
stage.addHostRoleExecutionCommand("host4", Role.TASKTRACKER,
RoleCommand.START, new ServiceComponentHostStartEvent("TASKTRACKER",
- "host4", now), "cluster1", "MAPREDUCE", false, false);
+ "host4", now), "cluster1", "core", "MAPREDUCE", false, false);
stage.addHostRoleExecutionCommand("host5", Role.JOBTRACKER,
RoleCommand.START, new ServiceComponentHostStartEvent("JOBTRACKER",
- "host5", now), "cluster1", "MAPREDUCE", false, false);
+ "host5", now), "cluster1", "core", "MAPREDUCE", false, false);
stage.addHostRoleExecutionCommand("host6", Role.OOZIE_SERVER,
RoleCommand.START, new ServiceComponentHostStartEvent("OOZIE_SERVER",
- "host6", now), "cluster1", "OOZIE", false, false);
+ "host6", now), "cluster1", "core", "OOZIE", false, false);
stage.addHostRoleExecutionCommand("host7", Role.WEBHCAT_SERVER,
RoleCommand.START, new ServiceComponentHostStartEvent("WEBHCAT_SERVER",
- "host7", now), "cluster1", "WEBHCAT", false, false);
+ "host7", now), "cluster1", "core", "WEBHCAT", false, false);
stage.addHostRoleExecutionCommand("host4", Role.GANGLIA_MONITOR,
RoleCommand.START, new ServiceComponentHostStartEvent("GANGLIA_MONITOR",
- "host4", now), "cluster1", "GANGLIA", false, false);
+ "host4", now), "cluster1", "core", "GANGLIA", false, false);
stage.addHostRoleExecutionCommand("host9", Role.GANGLIA_SERVER,
RoleCommand.START, new ServiceComponentHostStartEvent("GANGLIA_SERVER",
- "host9", now), "cluster1", "GANGLIA", false, false);
+ "host9", now), "cluster1", "core", "GANGLIA", false, false);
log.info(stage.toString());
rg.build(stage);
@@ -428,37 +428,37 @@ public class TestStagePlanner {
Stage stage = StageUtils.getATestStage(1, 1, "host1", "", "");
stage.addHostRoleExecutionCommand("host11", Role.SECONDARY_NAMENODE,
RoleCommand.START, new ServiceComponentHostStartEvent("SECONDARY_NAMENODE",
- "host11", now), "cluster1", "HDFS", false, false);
+ "host11", now), "cluster1", "core", "HDFS", false, false);
stage.addHostRoleExecutionCommand("host2", Role.HBASE_MASTER,
RoleCommand.START, new ServiceComponentHostStartEvent("HBASE_MASTER",
- "host2", now), "cluster1", "HBASE", false, false);
+ "host2", now), "cluster1", "core", "HBASE", false, false);
stage.addHostRoleExecutionCommand("host3", Role.ZOOKEEPER_SERVER,
RoleCommand.START, new ServiceComponentHostStartEvent("ZOOKEEPER_SERVER",
- "host3", now), "cluster1", "ZOOKEEPER", false, false);
+ "host3", now), "cluster1", "core", "ZOOKEEPER", false, false);
stage.addHostRoleExecutionCommand("host4", Role.DATANODE,
RoleCommand.START, new ServiceComponentHostStartEvent("DATANODE",
- "host4", now), "cluster1", "HDFS", false, false);
+ "host4", now), "cluster1", "core", "HDFS", false, false);
stage.addHostRoleExecutionCommand("host4", Role.HBASE_REGIONSERVER,
RoleCommand.START, new ServiceComponentHostStartEvent("HBASE_REGIONSERVER",
- "host4", now), "cluster1", "HBASE", false, false);
+ "host4", now), "cluster1", "core", "HBASE", false, false);
stage.addHostRoleExecutionCommand("host4", Role.TASKTRACKER,
RoleCommand.START, new ServiceComponentHostStartEvent("TASKTRACKER",
- "host4", now), "cluster1", "MAPREDUCE", false, false);
+ "host4", now), "cluster1", "core", "MAPREDUCE", false, false);
stage.addHostRoleExecutionCommand("host5", Role.JOBTRACKER,
RoleCommand.START, new ServiceComponentHostStartEvent("JOBTRACKER",
- "host5", now), "cluster1", "MAPREDUCE", false, false);
+ "host5", now), "cluster1", "core", "MAPREDUCE", false, false);
stage.addHostRoleExecutionCommand("host6", Role.OOZIE_SERVER,
RoleCommand.START, new ServiceComponentHostStartEvent("OOZIE_SERVER",
- "host6", now), "cluster1", "OOZIE", false, false);
+ "host6", now), "cluster1", "core", "OOZIE", false, false);
stage.addHostRoleExecutionCommand("host7", Role.WEBHCAT_SERVER,
RoleCommand.START, new ServiceComponentHostStartEvent("WEBHCAT_SERVER",
- "host7", now), "cluster1", "WEBHCAT", false, false);
+ "host7", now), "cluster1", "core", "WEBHCAT", false, false);
stage.addHostRoleExecutionCommand("host4", Role.GANGLIA_MONITOR,
RoleCommand.START, new ServiceComponentHostStartEvent("GANGLIA_MONITOR",
- "host4", now), "cluster1", "GANGLIA", false, false);
+ "host4", now), "cluster1", "core", "GANGLIA", false, false);
stage.addHostRoleExecutionCommand("host9", Role.GANGLIA_SERVER,
RoleCommand.START, new ServiceComponentHostStartEvent("GANGLIA_SERVER",
- "host9", now), "cluster1", "GANGLIA", false, false);
+ "host9", now), "cluster1", "core", "GANGLIA", false, false);
log.info(stage.toString());
rg.build(stage);
log.info(rg.stringifyGraph());
[3/3] ambari git commit: AMBARI-22428 Update db schema to use
service_id instead of service_name (requests part) (dsen)
Posted by ds...@apache.org.
AMBARI-22428 Update db schema to use service_id instead of service_name (requests part) (dsen)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/68c62212
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/68c62212
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/68c62212
Branch: refs/heads/branch-feature-AMBARI-14714
Commit: 68c62212c7e72a410fbe975921b51f4e601c4483
Parents: 61f0239
Author: Dmytro Sen <ds...@apache.org>
Authored: Tue Dec 19 18:14:38 2017 +0200
Committer: Dmytro Sen <ds...@apache.org>
Committed: Tue Dec 19 18:14:38 2017 +0200
----------------------------------------------------------------------
.../ambari/server/ServiceNotFoundException.java | 7 +
.../ambari/server/actionmanager/Request.java | 4 +
.../ambari/server/actionmanager/Stage.java | 6 +-
.../ambari/server/agent/ExecutionCommand.java | 11 ++
.../controller/ActionExecutionContext.java | 8 +-
.../ambari/server/controller/ActionRequest.java | 16 ++-
.../server/controller/ActionResponse.java | 13 +-
.../controller/AmbariActionExecutionHelper.java | 20 ++-
.../AmbariCustomCommandExecutionHelper.java | 78 ++++++-----
.../AmbariManagementControllerImpl.java | 129 +++++++++++--------
.../controller/DeleteIdentityHandler.java | 3 +-
.../server/controller/KerberosHelperImpl.java | 10 +-
.../controller/MaintenanceStateHelper.java | 14 +-
.../internal/ActionResourceProvider.java | 5 +
.../ClusterStackVersionResourceProvider.java | 2 +-
.../HostStackVersionResourceProvider.java | 2 +-
.../internal/RequestOperationLevel.java | 15 ++-
.../internal/RequestResourceFilter.java | 13 +-
.../internal/RequestResourceProvider.java | 26 +++-
.../internal/UpgradeResourceProvider.java | 9 +-
.../server/customactions/ActionDefinition.java | 15 ++-
.../customactions/ActionDefinitionManager.java | 13 +-
.../customactions/ActionDefinitionSpec.java | 10 ++
.../ambari/server/metadata/ActionMetadata.java | 8 +-
.../entities/RequestOperationLevelEntity.java | 12 ++
.../entities/RequestResourceFilterEntity.java | 12 ++
.../apache/ambari/server/state/StackInfo.java | 2 +-
.../server/state/cluster/ClusterImpl.java | 2 +-
.../apache/ambari/server/utils/StageUtils.java | 2 +-
.../main/resources/Ambari-DDL-Derby-CREATE.sql | 2 +
.../main/resources/Ambari-DDL-MySQL-CREATE.sql | 2 +
.../main/resources/Ambari-DDL-Oracle-CREATE.sql | 2 +
.../resources/Ambari-DDL-Postgres-CREATE.sql | 2 +
.../resources/Ambari-DDL-SQLAnywhere-CREATE.sql | 2 +
.../resources/Ambari-DDL-SQLServer-CREATE.sql | 2 +
.../ExecutionCommandWrapperTest.java | 2 +-
.../actionmanager/TestActionDBAccessorImpl.java | 18 +--
.../server/actionmanager/TestActionManager.java | 6 +-
.../actionmanager/TestActionScheduler.java | 110 ++++++++--------
.../ambari/server/actionmanager/TestStage.java | 4 +-
.../server/agent/DummyHeartbeatConstants.java | 1 +
.../server/agent/HeartbeatProcessorTest.java | 4 +-
.../server/agent/HeartbeatTestHelper.java | 3 +-
.../server/agent/TestHeartbeatHandler.java | 2 +-
.../server/controller/ActionRequestTest.java | 3 +-
.../server/controller/ActionResponseTest.java | 4 +-
.../AmbariCustomCommandExecutionHelperTest.java | 52 ++++----
.../AmbariManagementControllerTest.java | 124 +++++++++---------
.../BackgroundCustomCommandExecutionTest.java | 2 +-
.../controller/MaintenanceStateHelperTest.java | 22 ++--
.../internal/ActionResourceProviderTest.java | 12 +-
.../server/stageplanner/TestStagePlanner.java | 70 +++++-----
52 files changed, 571 insertions(+), 347 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/main/java/org/apache/ambari/server/ServiceNotFoundException.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/ServiceNotFoundException.java b/ambari-server/src/main/java/org/apache/ambari/server/ServiceNotFoundException.java
index d374b74..4cb9fa7 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/ServiceNotFoundException.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/ServiceNotFoundException.java
@@ -27,6 +27,13 @@ public class ServiceNotFoundException extends ObjectNotFoundException {
+ ", serviceName=" + serviceName);
}
+ public ServiceNotFoundException(String clusterName, String serviceGroupName, String serviceName) {
+ super("Service not found"
+ + ", clusterName=" + clusterName
+ + ", serviceGroupName=" + serviceGroupName
+ + ", serviceName=" + serviceName);
+ }
+
public ServiceNotFoundException(String clusterName, Long serviceId) {
super("Service not found"
+ ", clusterName=" + clusterName
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Request.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Request.java b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Request.java
index eb4143f..78b5bab 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Request.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Request.java
@@ -256,6 +256,7 @@ public class Request {
List<RequestResourceFilterEntity> filterEntities = new ArrayList<>();
for (RequestResourceFilter resourceFilter : resourceFilters) {
RequestResourceFilterEntity filterEntity = new RequestResourceFilterEntity();
+ filterEntity.setServiceGroupName(resourceFilter.getServiceGroupName());
filterEntity.setServiceName(resourceFilter.getServiceName());
filterEntity.setComponentName(resourceFilter.getComponentName());
filterEntity.setHosts(resourceFilter.getHostNames() != null ?
@@ -275,6 +276,7 @@ public class Request {
RequestOperationLevelEntity operationLevelEntity = new RequestOperationLevelEntity();
operationLevelEntity.setLevel(operationLevel.getLevel().toString());
operationLevelEntity.setClusterName(operationLevel.getClusterName());
+ operationLevelEntity.setServiceGroupName(operationLevel.getServiceGroupName());
operationLevelEntity.setServiceName(operationLevel.getServiceName());
operationLevelEntity.setHostComponentName(operationLevel.getHostComponentName());
operationLevelEntity.setHostId(hostId);
@@ -436,6 +438,7 @@ public class Request {
for (RequestResourceFilterEntity resourceFilterEntity : resourceFilterEntities) {
RequestResourceFilter resourceFilter =
new RequestResourceFilter(
+ resourceFilterEntity.getServiceGroupName(),
resourceFilterEntity.getServiceName(),
resourceFilterEntity.getComponentName(),
getHostsList(resourceFilterEntity.getHosts()));
@@ -465,6 +468,7 @@ public class Request {
level = new RequestOperationLevel(
Resource.Type.valueOf(operationLevelEntity.getLevel()),
operationLevelEntity.getClusterName(),
+ operationLevelEntity.getServiceGroupName(),
operationLevelEntity.getServiceName(),
operationLevelEntity.getHostComponentName(),
hostName);
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/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 b88275a..3dfa5a3 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
@@ -397,7 +397,7 @@ public class Stage {
* This should be called only once for a host-role for a given stage.
*/
public synchronized void addHostRoleExecutionCommand(String host, Role role, RoleCommand command,
- ServiceComponentHostEvent event, String clusterName, String serviceName, boolean retryAllowed,
+ ServiceComponentHostEvent event, String clusterName, String serviceGroupName, String serviceName, boolean retryAllowed,
boolean autoSkipFailure) {
boolean isHostRoleCommandAutoSkippable = autoSkipFailure && supportsAutoSkipOnFailure
@@ -406,6 +406,7 @@ public class Stage {
ExecutionCommandWrapper commandWrapper = addGenericExecutionCommand(clusterName, host, role,
command, event, retryAllowed, isHostRoleCommandAutoSkippable);
+ commandWrapper.getExecutionCommand().setServiceGroupName(serviceGroupName);
commandWrapper.getExecutionCommand().setServiceName(serviceName);
}
@@ -415,7 +416,7 @@ public class Stage {
* This should be called only once for a host-role for a given stage.
*/
public synchronized void addHostRoleExecutionCommand(Host host, Role role, RoleCommand command,
- ServiceComponentHostEvent event, Cluster cluster, String serviceName, boolean retryAllowed,
+ ServiceComponentHostEvent event, Cluster cluster, String serviceGroupName, String serviceName, boolean retryAllowed,
boolean autoSkipFailure) {
boolean isHostRoleCommandAutoSkippable = autoSkipFailure && supportsAutoSkipOnFailure
@@ -424,6 +425,7 @@ public class Stage {
ExecutionCommandWrapper commandWrapper = addGenericExecutionCommand(cluster, host, role,
command, event, retryAllowed, isHostRoleCommandAutoSkippable);
+ commandWrapper.getExecutionCommand().setServiceGroupName(serviceGroupName);
commandWrapper.getExecutionCommand().setServiceName(serviceName);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java
index 977ff93..d22942f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java
@@ -105,6 +105,9 @@ public class ExecutionCommand extends AgentCommand {
@SerializedName("commandParams")
private Map<String, String> commandParams = new HashMap<>();
+ @SerializedName("serviceGroupName")
+ private String serviceGroupName;
+
@SerializedName("serviceName")
private String serviceName;
@@ -361,6 +364,14 @@ public class ExecutionCommand extends AgentCommand {
this.serviceName = serviceName;
}
+ public String getServiceGroupName() {
+ return serviceGroupName;
+ }
+
+ public void setServiceGroupName(String serviceGroupName) {
+ this.serviceGroupName = serviceGroupName;
+ }
+
public String getServiceType() {
return serviceType;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionExecutionContext.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionExecutionContext.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionExecutionContext.java
index e94defc..5334b7c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionExecutionContext.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionExecutionContext.java
@@ -40,6 +40,7 @@ public class ActionExecutionContext {
private Map<String, String> parameters;
private TargetHostType targetType;
private Short timeout;
+ private String expectedServiceGroupName;
private String expectedServiceName;
private String expectedComponentName;
private boolean hostsInMaintenanceModeExcluded = true;
@@ -61,7 +62,7 @@ public class ActionExecutionContext {
public ActionExecutionContext(String clusterName, String actionName,
List<RequestResourceFilter> resourceFilters,
Map<String, String> parameters, TargetHostType targetType,
- Short timeout, String expectedServiceName,
+ Short timeout, String expectedServiceGroupName, String expectedServiceName,
String expectedComponentName) {
this.clusterName = clusterName;
@@ -70,6 +71,7 @@ public class ActionExecutionContext {
this.parameters = parameters;
this.targetType = targetType;
this.timeout = timeout;
+ this.expectedServiceGroupName = expectedServiceGroupName;
this.expectedServiceName = expectedServiceName;
this.expectedComponentName = expectedComponentName;
}
@@ -126,6 +128,10 @@ public class ActionExecutionContext {
this.operationLevel = operationLevel;
}
+ public String getExpectedServiceGroupName() {
+ return expectedServiceGroupName;
+ }
+
public String getExpectedServiceName() {
return expectedServiceName;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionRequest.java
index e20e289..93404ae 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionRequest.java
@@ -29,6 +29,7 @@ public class ActionRequest {
static final String ACTION_TYPE = "action_type";
static final String INPUTS = "inputs";
static final String TARGET_SERVICE = "target_service";
+ static final String TARGET_SERVICE_GROUP = "target_service_group";
static final String TARGET_COMPONENT = "target_component";
static final String DESCRIPTION = "description";
static final String TARGET_TYPE = "target_type";
@@ -37,6 +38,7 @@ public class ActionRequest {
private String actionName; //CRUD
private String actionType; //C
private String inputs; //C
+ private String targetServiceGroup; //C
private String targetService; //C
private String targetComponent; //C
private String description; //CU
@@ -45,11 +47,12 @@ public class ActionRequest {
public ActionRequest(
String actionName, String actionType, String inputs,
- String targetService, String targetComponent, String description, String targetType,
+ String targetServiceGroup, String targetService, String targetComponent, String description, String targetType,
String defaultTimeout) {
setActionName(actionName);
setActionType(actionType);
setInputs(inputs);
+ setTargetServiceGroup(targetServiceGroup);
setTargetService(targetService);
setTargetComponent(targetComponent);
setDescription(description);
@@ -63,7 +66,7 @@ public class ActionRequest {
* @return
*/
public static ActionRequest getAllRequest() {
- return new ActionRequest(null, null, null, null, null, null, null, null);
+ return new ActionRequest(null, null, null, null,null, null, null, null, null);
}
@ApiModelProperty(name = ACTION_NAME)
@@ -102,6 +105,15 @@ public class ActionRequest {
this.targetService = targetService;
}
+ @ApiModelProperty(name = TARGET_SERVICE_GROUP)
+ public String getTargetServiceGroup() {
+ return targetServiceGroup;
+ }
+
+ public void setTargetServiceGroup(String targetServiceGroup) {
+ this.targetServiceGroup = targetServiceGroup;
+ }
+
@ApiModelProperty(name = TARGET_COMPONENT)
public String getTargetComponent() {
return targetComponent;
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionResponse.java
index 10af495..d21f41e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionResponse.java
@@ -28,6 +28,7 @@ public class ActionResponse {
private String actionName;
private String actionType;
private String inputs;
+ private String targetServiceGroup;
private String targetService;
private String targetComponent;
private String description;
@@ -35,11 +36,12 @@ public class ActionResponse {
private String defaultTimeout;
public ActionResponse(String actionName, String actionType, String inputs,
- String targetService, String targetComponent, String description, String targetType,
+ String targetServiceGroup, String targetService, String targetComponent, String description, String targetType,
String defaultTimeout) {
setActionName(actionName);
setActionType(actionType);
setInputs(inputs);
+ setTargetServiceGroup(targetServiceGroup);
setTargetService(targetService);
setTargetComponent(targetComponent);
setDescription(description);
@@ -83,6 +85,15 @@ public class ActionResponse {
this.targetService = targetService;
}
+ @ApiModelProperty(name = ActionRequest.TARGET_SERVICE_GROUP)
+ public String getTargetServiceGroup() {
+ return targetServiceGroup;
+ }
+
+ public void setTargetServiceGroup(String targetServiceGroup) {
+ this.targetServiceGroup = targetServiceGroup;
+ }
+
@ApiModelProperty(name = ActionRequest.TARGET_COMPONENT)
public String getTargetComponent() {
return targetComponent;
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
index 7c80b6e..a46e2c4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
@@ -279,6 +279,7 @@ public class AmbariActionExecutionHelper {
// List of host to select from
Set<String> candidateHosts = new HashSet<>();
+ final String serviceGroupName = actionContext.getExpectedServiceGroupName();
final String serviceName = actionContext.getExpectedServiceName();
final String componentName = actionContext.getExpectedComponentName();
@@ -291,9 +292,11 @@ public class AmbariActionExecutionHelper {
if (null != cluster) {
// StackId stackId = cluster.getCurrentStackVersion();
+// TODO add service group null checks when the UI is updated
+// if (serviceGroupName != null && !serviceGroupName.isEmpty()) {
if (serviceName != null && !serviceName.isEmpty()) {
if (componentName != null && !componentName.isEmpty()) {
- Service service = cluster.getService(serviceName);
+ Service service = cluster.getService(serviceGroupName, serviceName);
ServiceComponent component = service.getServiceComponent(componentName);
StackId stackId = component.getDesiredStackId();
@@ -308,8 +311,8 @@ public class AmbariActionExecutionHelper {
LOG.error("Did not find service {} and component {} in stack {}.", serviceName, componentName, stackId.getStackName());
}
} else {
- for (String component : cluster.getService(serviceName).getServiceComponents().keySet()) {
- Map<String, ServiceComponentHost> componentHosts = cluster.getService(serviceName)
+ for (String component : cluster.getService(serviceGroupName, serviceName).getServiceComponents().keySet()) {
+ Map<String, ServiceComponentHost> componentHosts = cluster.getService(serviceGroupName, serviceName)
.getServiceComponent(component).getServiceComponentHosts();
candidateHosts.addAll(componentHosts.keySet());
}
@@ -328,7 +331,7 @@ public class AmbariActionExecutionHelper {
throws AmbariException {
return ! maintenanceStateHelper.isOperationAllowed(
cluster, actionContext.getOperationLevel(),
- resourceFilter, serviceName, componentName, hostname);
+ resourceFilter, serviceGroupName, serviceName, componentName, hostname);
}
}
);
@@ -343,7 +346,7 @@ public class AmbariActionExecutionHelper {
// If request did not specify hosts and there exists no host
if (resourceFilter.getHostNames().isEmpty() && candidateHosts.isEmpty()) {
throw new AmbariException("Suitable hosts not found, component="
- + componentName + ", service=" + serviceName
+ + componentName + ", service=" + serviceName + ", serviceGroup=" + serviceGroupName
+ ((null == cluster) ? "" : ", cluster=" + cluster.getClusterName() + ", ")
+ "actionName=" + actionContext.getActionName());
}
@@ -355,7 +358,7 @@ public class AmbariActionExecutionHelper {
if (!candidateHosts.contains(hostname)) {
throw new AmbariException("Request specifies host " + hostname +
" but it is not a valid host based on the " +
- "target service=" + serviceName + " and component=" + componentName);
+ "target serviceGroup=" + serviceGroupName + ", service=" + serviceName + " and component=" + componentName);
}
}
}
@@ -397,7 +400,7 @@ public class AmbariActionExecutionHelper {
RoleCommand.ACTIONEXECUTE,
new ServiceComponentHostOpInProgressEvent(actionContext.getActionName(), hostName,
System.currentTimeMillis()),
- clusterName, serviceName, actionContext.isRetryAllowed(),
+ clusterName, serviceGroupName, serviceName, actionContext.isRetryAllowed(),
actionContext.isFailureAutoSkipped());
Map<String, String> commandParams = new TreeMap<>();
@@ -449,6 +452,9 @@ public class AmbariActionExecutionHelper {
execCmd.setConfigurationTags(configTags);
+ execCmd.setServiceGroupName(serviceGroupName == null || serviceGroupName.isEmpty() ?
+ resourceFilter.getServiceGroupName() : serviceGroupName);
+
execCmd.setServiceName(serviceName == null || serviceName.isEmpty() ?
resourceFilter.getServiceName() : serviceName);
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
index 537886f..9c88425 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
@@ -186,7 +186,7 @@ public class AmbariCustomCommandExecutionHelper {
}
private Boolean isValidCustomCommand(String clusterName,
- String serviceName, String componentName, String commandName)
+ String serviceGroupName, String serviceName, String componentName, String commandName)
throws AmbariException {
if (componentName == null) {
@@ -194,7 +194,7 @@ public class AmbariCustomCommandExecutionHelper {
}
Cluster cluster = clusters.getCluster(clusterName);
- Service service = cluster.getService(serviceName);
+ Service service = cluster.getService(serviceGroupName, serviceName);
ServiceComponent component = service.getServiceComponent(componentName);
StackId stackId = component.getDesiredStackId();
@@ -210,6 +210,7 @@ public class AmbariCustomCommandExecutionHelper {
actionExecutionContext, RequestResourceFilter resourceFilter)
throws AmbariException {
String clusterName = actionExecutionContext.getClusterName();
+ String serviceGroupName = resourceFilter.getServiceGroupName();
String serviceName = resourceFilter.getServiceName();
String componentName = resourceFilter.getComponentName();
String commandName = actionExecutionContext.getActionName();
@@ -218,12 +219,13 @@ public class AmbariCustomCommandExecutionHelper {
return false;
}
- return isValidCustomCommand(clusterName, serviceName, componentName, commandName);
+ return isValidCustomCommand(clusterName, serviceGroupName, serviceName, componentName, commandName);
}
private Boolean isValidCustomCommand(ExecuteActionRequest actionRequest,
RequestResourceFilter resourceFilter) throws AmbariException {
String clusterName = actionRequest.getClusterName();
+ String serviceGroupName = resourceFilter.getServiceGroupName();
String serviceName = resourceFilter.getServiceName();
String componentName = resourceFilter.getComponentName();
String commandName = actionRequest.getCommandName();
@@ -232,7 +234,7 @@ public class AmbariCustomCommandExecutionHelper {
return false;
}
- return isValidCustomCommand(clusterName, serviceName, componentName, commandName);
+ return isValidCustomCommand(clusterName, serviceGroupName, serviceName, componentName, commandName);
}
private String getReadableCustomCommandDetail(ActionExecutionContext
@@ -266,6 +268,7 @@ public class AmbariCustomCommandExecutionHelper {
private void addCustomCommandAction(final ActionExecutionContext actionExecutionContext,
final RequestResourceFilter resourceFilter, Stage stage, Map<String, String> additionalCommandParams,
String commandDetail, Map<String, String> requestParams) throws AmbariException {
+ final String serviceGroupName = resourceFilter.getServiceGroupName();
final String serviceName = resourceFilter.getServiceName();
final String componentName = resourceFilter.getComponentName();
final String commandName = actionExecutionContext.getActionName();
@@ -286,7 +289,7 @@ public class AmbariCustomCommandExecutionHelper {
throws AmbariException {
return !maintenanceStateHelper.isOperationAllowed(
cluster, actionExecutionContext.getOperationLevel(),
- resourceFilter, serviceName, componentName, hostname);
+ resourceFilter, serviceGroupName, serviceName, componentName, hostname);
}
}
);
@@ -317,7 +320,7 @@ public class AmbariCustomCommandExecutionHelper {
throw new AmbariException(message);
}
- Service service = cluster.getService(serviceName);
+ Service service = cluster.getService(serviceGroupName, serviceName);
StackId stackId = service.getDesiredStackId();
AmbariMetaInfo ambariMetaInfo = managementController.getAmbariMetaInfo();
@@ -339,7 +342,7 @@ public class AmbariCustomCommandExecutionHelper {
stage.addHostRoleExecutionCommand(hostName, Role.valueOf(componentName),
RoleCommand.CUSTOM_COMMAND,
new ServiceComponentHostOpInProgressEvent(componentName, hostName, nowTimestamp),
- cluster.getClusterName(), serviceName, retryAllowed, autoSkipFailure);
+ cluster.getClusterName(), serviceGroupName, serviceName, retryAllowed, autoSkipFailure);
Map<String, Map<String, String>> configurations =
new TreeMap<>();
@@ -562,9 +565,11 @@ public class AmbariCustomCommandExecutionHelper {
String clusterName = actionExecutionContext.getClusterName();
final Cluster cluster = clusters.getCluster(clusterName);
- final String componentName = actionMetadata.getClient(resourceFilter.getServiceName());
+ final String serviceGroupName = resourceFilter.getServiceGroupName();
final String serviceName = resourceFilter.getServiceName();
- String smokeTestRole = actionMetadata.getServiceCheckAction(serviceName);
+ Service service = cluster.getService(serviceGroupName, serviceName);
+ final String componentName = actionMetadata.getClient(service.getServiceType());
+ String smokeTestRole = actionMetadata.getServiceCheckAction(service.getServiceType());
if (null == smokeTestRole) {
smokeTestRole = actionExecutionContext.getActionName();
}
@@ -573,7 +578,7 @@ public class AmbariCustomCommandExecutionHelper {
final Map<String, ServiceComponentHost> serviceHostComponents;
if (componentName != null) {
- serviceHostComponents = cluster.getService(serviceName).getServiceComponent(componentName).getServiceComponentHosts();
+ serviceHostComponents = cluster.getService(serviceGroupName, serviceName).getServiceComponent(componentName).getServiceComponentHosts();
if (serviceHostComponents.isEmpty()) {
throw new AmbariException(MessageFormat.format("No hosts found for service: {0}, component: {1} in cluster: {2}",
@@ -598,7 +603,7 @@ public class AmbariCustomCommandExecutionHelper {
}
} else {
// TODO: This code branch looks unreliable (taking random component, should prefer the clients)
- Map<String, ServiceComponent> serviceComponents = cluster.getService(serviceName).getServiceComponents();
+ Map<String, ServiceComponent> serviceComponents = cluster.getService(serviceGroupName, serviceName).getServiceComponents();
// Filter components without any HOST
Iterator<String> serviceComponentNameIterator = serviceComponents.keySet().iterator();
@@ -661,7 +666,7 @@ public class AmbariCustomCommandExecutionHelper {
long nowTimestamp = System.currentTimeMillis();
Map<String, String> actionParameters = actionExecutionContext.getParameters();
- addServiceCheckAction(stage, preferredHostName, smokeTestRole, nowTimestamp, serviceName, componentName,
+ addServiceCheckAction(stage, preferredHostName, smokeTestRole, nowTimestamp, serviceGroupName, serviceName, componentName,
actionParameters, actionExecutionContext.isRetryAllowed(),
actionExecutionContext.isFailureAutoSkipped());
}
@@ -712,7 +717,7 @@ public class AmbariCustomCommandExecutionHelper {
* by service check.
*/
public void addServiceCheckAction(Stage stage, String hostname, String smokeTestRole,
- long nowTimestamp, String serviceName, String componentName,
+ long nowTimestamp, String serviceGroupName, String serviceName, String componentName,
Map<String, String> actionParameters, boolean retryAllowed, boolean autoSkipFailure)
throws AmbariException {
@@ -734,7 +739,7 @@ public class AmbariCustomCommandExecutionHelper {
stage.addHostRoleExecutionCommand(hostname, Role.valueOf(smokeTestRole),
RoleCommand.SERVICE_CHECK,
new ServiceComponentHostOpInProgressEvent(componentName, hostname, nowTimestamp),
- cluster.getClusterName(), serviceName, retryAllowed, autoSkipFailure);
+ cluster.getClusterName(), serviceGroupName, serviceName, retryAllowed, autoSkipFailure);
HostRoleCommand hrc = stage.getHostRoleCommand(hostname, smokeTestRole);
if (hrc != null) {
@@ -856,6 +861,7 @@ public class AmbariCustomCommandExecutionHelper {
String clusterName = actionExecutionContext.getClusterName();
final Cluster cluster = clusters.getCluster(clusterName);
+ final String serviceGroupName = resourceFilter.getServiceGroupName();
final String serviceName = resourceFilter.getServiceName();
String masterCompType = resourceFilter.getComponentName();
List<String> hosts = resourceFilter.getHostNames();
@@ -883,7 +889,7 @@ public class AmbariCustomCommandExecutionHelper {
"as well as exclusion. Hosts: " + cloneSet);
}
- Service service = cluster.getService(serviceName);
+ Service service = cluster.getService(serviceGroupName, serviceName);
if (service == null) {
throw new AmbariException("Specified service " + serviceName +
" is not a valid/deployed service.");
@@ -956,7 +962,7 @@ public class AmbariCustomCommandExecutionHelper {
} else {
return !maintenanceStateHelper.isOperationAllowed(
cluster, actionExecutionContext.getOperationLevel(),
- resourceFilter, serviceName, slaveCompType, hostname);
+ resourceFilter, serviceGroupName, serviceName, slaveCompType, hostname);
}
}
};
@@ -1040,7 +1046,7 @@ public class AmbariCustomCommandExecutionHelper {
(actionExecutionContext, filteredIncludedHosts, listOfExcludedHosts);
for (String hostName : masterSchs.keySet()) {
- RequestResourceFilter commandFilter = new RequestResourceFilter(serviceName,
+ RequestResourceFilter commandFilter = new RequestResourceFilter(serviceGroupName, serviceName,
masterComponent.getName(), Collections.singletonList(hostName));
List<RequestResourceFilter> resourceFilters = new ArrayList<>();
resourceFilters.add(commandFilter);
@@ -1118,17 +1124,27 @@ public class AmbariCustomCommandExecutionHelper {
}
for (RequestResourceFilter resourceFilter : resourceFilters) {
- if (resourceFilter.getServiceName() == null
+ if (
+ //TODO uncomment for service group filter validation. Null checks
+// resourceFilter.getServiceGroupName() == null
+// || resourceFilter.getServiceGroupName().isEmpty()
+// ||
+ resourceFilter.getServiceName() == null
|| resourceFilter.getServiceName().isEmpty()
|| actionRequest.getCommandName() == null
|| actionRequest.getCommandName().isEmpty()) {
throw new AmbariException("Invalid resource filter : " + "cluster = "
- + actionRequest.getClusterName() + ", service = "
+ + actionRequest.getClusterName() + ", service group = "
+ + resourceFilter.getServiceGroupName() + ", service = "
+ resourceFilter.getServiceName() + ", command = "
+ actionRequest.getCommandName());
}
+ //can't be null, exception will be thrown if cluster or service is not found
+ Service service = clusters.getCluster(actionRequest.getClusterName()).
+ getService(resourceFilter.getServiceGroupName(), resourceFilter.getServiceName());
- if (!isServiceCheckCommand(actionRequest.getCommandName(), resourceFilter.getServiceName())
+ String serviceType = service.getServiceType();
+ if (!isServiceCheckCommand(actionRequest.getCommandName(), serviceType)
&& !isValidCustomCommand(actionRequest, resourceFilter)) {
throw new AmbariException(
"Unsupported action " + actionRequest.getCommandName() +
@@ -1200,9 +1216,10 @@ public class AmbariCustomCommandExecutionHelper {
RequestOperationLevel operationLevel = actionExecutionContext.getOperationLevel();
if (operationLevel != null) {
String clusterName = operationLevel.getClusterName();
+ String serviceGroupName = operationLevel.getServiceGroupName();
String serviceName = operationLevel.getServiceName();
- if (isTopologyRefreshRequired(actionName, clusterName, serviceName)) {
+ if (isTopologyRefreshRequired(actionName, clusterName, serviceGroupName, serviceName)) {
extraParams.put(KeyNames.REFRESH_TOPOLOGY, "True");
}
}
@@ -1335,23 +1352,24 @@ public class AmbariCustomCommandExecutionHelper {
*
* @param actionName the action name (i.e. START, RESTART)
* @param clusterName the cluster name
+ * @param serviceGroupName the service group name
* @param serviceName the service name
*
* @return true if a topology refresh is required for the action
*/
- public boolean isTopologyRefreshRequired(String actionName, String clusterName, String serviceName)
+ public boolean isTopologyRefreshRequired(String actionName, String clusterName, String serviceGroupName, String serviceName)
throws AmbariException {
if (actionName.equals(START_COMMAND_NAME) || actionName.equals(RESTART_COMMAND_NAME)) {
Cluster cluster = clusters.getCluster(clusterName);
StackId stackId = null;
+ String serviceType = null;
+// TODO add service group null checks when the UI is updated
+// if (serviceGroupName != null) {
if (serviceName != null) {
- try {
- Service service = cluster.getService(serviceName);
- stackId = service.getDesiredStackId();
- } catch (AmbariException e) {
- LOG.debug("Could not load service {}, skipping topology check", serviceName);
- }
+ Service service = cluster.getService(serviceGroupName, serviceName);
+ stackId = service.getDesiredStackId();
+ serviceType = service.getServiceType();
}
if (stackId == null) {
@@ -1362,7 +1380,7 @@ public class AmbariCustomCommandExecutionHelper {
StackInfo stack = ambariMetaInfo.getStack(stackId.getStackName(), stackId.getStackVersion());
if (stack != null) {
- ServiceInfo serviceInfo = stack.getService(serviceName);
+ ServiceInfo serviceInfo = stack.getService(serviceType);
if (serviceInfo != null) {
// if there is a chance that this action was triggered by a change in rack info then we want to
@@ -1382,7 +1400,7 @@ public class AmbariCustomCommandExecutionHelper {
RequestResourceFilter resourceFilter){
try {
Cluster cluster = clusters.getCluster(actionExecutionContext.getClusterName());
- Service service = cluster.getService(resourceFilter.getServiceName());
+ Service service = cluster.getService(resourceFilter.getServiceGroupName(), resourceFilter.getServiceName());
return service.getServiceComponent(resourceFilter.getComponentName());
} catch (Exception e) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/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 41d1bf2..8bd2f0c 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
@@ -674,7 +674,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
Service s;
try {
- s = cluster.getService(request.getServiceName());
+ s = cluster.getService(request.getServiceGroupName(), request.getServiceName());
} catch (ServiceNotFoundException e) {
throw new IllegalArgumentException(
"The service[" + request.getServiceName() + "] associated with the component[" +
@@ -2256,7 +2256,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
return null;
}
- private Set<String> getServicesForSmokeTests(Cluster cluster,
+ private Set<Service> getServicesForSmokeTests(Cluster cluster,
Map<State, List<Service>> changedServices,
Map<String, Map<State, List<ServiceComponentHost>>> changedScHosts,
boolean runSmokeTest) throws AmbariException {
@@ -2266,7 +2266,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
// are not in a Maintenance state.
Resource.Type opLvl = Resource.Type.Cluster;
- Set<String> smokeTestServices = new HashSet<>();
+ Set<Service> smokeTestServices = new HashSet<>();
// Adding smoke checks for changed services
if (changedServices != null) {
@@ -2277,14 +2277,14 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
for (Service s : entry.getValue()) {
if (runSmokeTest && (State.INSTALLED == s.getDesiredState() &&
maintenanceStateHelper.isOperationAllowed(opLvl, s))) {
- smokeTestServices.add(s.getName());
+ smokeTestServices.add(s);
}
}
}
}
// Adding smoke checks for changed host components
- Map<String, Map<String, Integer>> changedComponentCount =
+ Map<Long, Map<String, Integer>> changedComponentCount =
new HashMap<>();
for (Map<State, List<ServiceComponentHost>> stateScHostMap :
changedScHosts.values()) {
@@ -2300,17 +2300,17 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
if (! maintenanceStateHelper.isOperationAllowed(opLvl, sch)) {
continue;
}
- if (!changedComponentCount.containsKey(sch.getServiceName())) {
- changedComponentCount.put(sch.getServiceName(), new HashMap<>());
+ if (!changedComponentCount.containsKey(sch.getServiceId())) {
+ changedComponentCount.put(sch.getServiceId(), new HashMap<>());
}
- if (!changedComponentCount.get(sch.getServiceName())
+ if (!changedComponentCount.get(sch.getServiceId())
.containsKey(sch.getServiceComponentName())) {
- changedComponentCount.get(sch.getServiceName())
+ changedComponentCount.get(sch.getServiceId())
.put(sch.getServiceComponentName(), 1);
} else {
- Integer i = changedComponentCount.get(sch.getServiceName())
+ Integer i = changedComponentCount.get(sch.getServiceId())
.get(sch.getServiceComponentName());
- changedComponentCount.get(sch.getServiceName())
+ changedComponentCount.get(sch.getServiceId())
.put(sch.getServiceComponentName(), ++i);
}
}
@@ -2319,19 +2319,19 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
// Add service checks for any changed master component hosts or if
// more then one component has been changed for a service
- for (Entry<String, Map<String, Integer>> entry :
+ for (Entry<Long, Map<String, Integer>> entry :
changedComponentCount.entrySet()) {
- String serviceName = entry.getKey();
- Service s = cluster.getService(serviceName);
+ Long serviceId = entry.getKey();
+ Service s = cluster.getService(serviceId);
// smoke test service if more than one component is started
if (runSmokeTest && (entry.getValue().size() > 1) &&
maintenanceStateHelper.isOperationAllowed(opLvl, s)) {
- smokeTestServices.add(serviceName);
+ smokeTestServices.add(cluster.getService(serviceId));
continue;
}
for (String componentName :
- changedComponentCount.get(serviceName).keySet()) {
- ServiceComponent sc = cluster.getService(serviceName).
+ changedComponentCount.get(serviceId).keySet()) {
+ ServiceComponent sc = cluster.getService(serviceId).
getServiceComponent(componentName);
StackId stackId = sc.getDesiredStackId();
ComponentInfo compInfo = ambariMetaInfo.getComponent(
@@ -2341,7 +2341,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
// op lvl handling for service component
// is the same as for service
maintenanceStateHelper.isOperationAllowed(opLvl, s)) {
- smokeTestServices.add(serviceName);
+ smokeTestServices.add(cluster.getService(serviceId));
}
// FIXME if master check if we need to run a smoke test for the master
}
@@ -2463,10 +2463,11 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
)
throws AmbariException {
+ String serviceGroupName = scHost.getServiceGroupName();
String serviceName = scHost.getServiceName();
stage.addHostRoleExecutionCommand(scHost.getHost(),
- Role.valueOf(scHost.getServiceComponentName()), roleCommand, event, cluster, serviceName, false, skipFailure);
+ Role.valueOf(scHost.getServiceComponentName()), roleCommand, event, cluster, serviceGroupName, serviceName, false, skipFailure);
String componentName = scHost.getServiceComponentName();
String hostname = scHost.getHostName();
@@ -2477,6 +2478,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
Map<String, Service> services = cluster.getServices();
Map<String, ServiceInfo> servicesMap = new HashMap<>();
for(String clusterServiceName : services.keySet() ){
+ //TODO fix matainfo
servicesMap.put(clusterServiceName, ambariMetaInfo.getService(services.get(clusterServiceName)));
}
StackId stackId = scHost.getServiceComponent().getDesiredStackId();
@@ -2497,7 +2499,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
execCmd.setConfigurationTags(configTags);
// Get the value of credential store enabled from the DB
- Service clusterService = cluster.getService(serviceName);
+ Service clusterService = cluster.getService(serviceGroupName, serviceName);
execCmd.setCredentialStoreEnabled(String.valueOf(clusterService.isCredentialStoreEnabled()));
ServiceComponent component = clusterService.getServiceComponent(componentName);
@@ -2581,7 +2583,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
retryEnabled = commandMayBeRetried;
}
}
- LOG.info("Auto retry setting for {}-{} on {} is retryEnabled={} and retryMaxTime={}", serviceName, componentName, scHost.getHostName(), retryEnabled, retryMaxTime);
+ LOG.info("Auto retry setting for {}-{}-{} on {} is retryEnabled={} and retryMaxTime={}", serviceGroupName, serviceName, componentName, scHost.getHostName(), retryEnabled, retryMaxTime);
}
commandParams.put(MAX_DURATION_OF_RETRIES, Integer.toString(retryMaxTime));
commandParams.put(COMMAND_RETRY_ENABLED, Boolean.toString(retryEnabled));
@@ -2590,8 +2592,8 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
scriptCommandTimeout = String.valueOf(script.getTimeout());
}
} else {
- String message = String.format("Component %s of service %s has no " +
- "command script defined", componentName, serviceName);
+ String message = String.format("Component %s of service %s of % service group has no " +
+ "command script defined", componentName, serviceName, serviceGroupName);
throw new AmbariException(message);
}
}
@@ -2616,7 +2618,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
}
String clusterName = cluster.getClusterName();
- if (customCommandExecutionHelper.isTopologyRefreshRequired(roleCommand.name(), clusterName, serviceName)) {
+ if (customCommandExecutionHelper.isTopologyRefreshRequired(roleCommand.name(), clusterName, serviceGroupName, serviceName)) {
commandParams.put(ExecutionCommand.KeyNames.REFRESH_TOPOLOGY, "True");
}
StageUtils.useAmbariJdkInCommandParams(commandParams, configs);
@@ -2833,7 +2835,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
new ActionExecutionContext(actionRequest.getClusterName(),
actionRequest.getActionName(), actionRequest.getResourceFilters(),
actionRequest.getParameters(), actionDef.getTargetType(),
- actionDef.getDefaultTimeout(), actionDef.getTargetService(),
+ actionDef.getDefaultTimeout(), actionDef.getTargetServiceGroup(), actionDef.getTargetService(),
actionDef.getTargetComponent());
actionExecutionContext.setOperationLevel(operationLevel);
return actionExecutionContext;
@@ -2876,7 +2878,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
DatabaseType databaseType = configs.getDatabaseType();
// smoke test any service that goes from installed to started
- Set<String> smokeTestServices = getServicesForSmokeTests(cluster,
+ Set<Service> smokeTestServices = getServicesForSmokeTests(cluster,
changedServices, changedScHosts, runSmokeTest);
if (reconfigureClients) {
@@ -3241,26 +3243,26 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
}
}
- for (String serviceName : smokeTestServices) { // Creates smoke test commands
- Service s = cluster.getService(serviceName);
+ for (Service service : smokeTestServices) { // Creates smoke test commands
// find service component host
- ServiceComponent component = getClientComponentForRunningAction(cluster, s);
+ ServiceComponent component = getClientComponentForRunningAction(cluster, service);
String componentName = component != null ? component.getName() : null;
- String clientHost = getClientHostForRunningAction(cluster, s, component);
- String smokeTestRole = actionMetadata.getServiceCheckAction(serviceName);
+ String clientHost = getClientHostForRunningAction(cluster, service, component);
+ String smokeTestRole = actionMetadata.getServiceCheckAction(service.getServiceType());
if (clientHost == null || smokeTestRole == null) {
LOG.info("Nothing to do for service check as could not find role or"
+ " or host to run check on"
+ ", clusterName=" + cluster.getClusterName()
- + ", serviceName=" + serviceName
+ + ", serviceGroupName=" + service.getServiceGroupName()
+ + ", serviceName=" + service.getName()
+ ", clientHost=" + clientHost
+ ", serviceCheckRole=" + smokeTestRole);
continue;
}
customCommandExecutionHelper.addServiceCheckAction(stage, clientHost, smokeTestRole,
- nowTimestamp, serviceName, componentName, null, false, false);
+ nowTimestamp, service.getServiceGroupName(), service.getName(), componentName, null, false, false);
}
RoleCommandOrder rco = getRoleCommandOrder(cluster);
@@ -3506,7 +3508,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
}
//keep 2 maps for simpler maintenance
- Map<String, String> serviceMasterForDecommissionMap = new HashMap<>();
+ Map<String, Map<String, String>> serviceGroupServiceMasterForDecommissionMap = new HashMap<>();
Map<String, Set<String>> masterSlaveHostsMap = new HashMap<>();
for (Map<State, List<ServiceComponentHost>> stateScHostMap :
changedScHosts.values()) {
@@ -3518,6 +3520,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
//Create map for include/exclude files refresh
if (masterToSlaveMappingForDecom.containsValue(componentName) &&
sch.getState() == State.INIT && newState == State.INSTALLED) {
+ String serviceGroupName = sch.getServiceGroupName();
String serviceName = sch.getServiceName();
String masterComponentName = null;
for (Entry<String, String> entrySet : masterToSlaveMappingForDecom.entrySet()) {
@@ -3527,8 +3530,9 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
}
try {
//Filter services whose masters are not started
- if (isServiceComponentStartedOnAnyHost(cluster, serviceName, masterComponentName)) {
- serviceMasterForDecommissionMap.put(serviceName, masterComponentName);
+ if (isServiceComponentStartedOnAnyHost(cluster, serviceGroupName, serviceName, masterComponentName)) {
+ serviceGroupServiceMasterForDecommissionMap.putIfAbsent(serviceGroupName, new HashMap<>());
+ serviceGroupServiceMasterForDecommissionMap.get(serviceGroupName).put(serviceName, masterComponentName);
masterSlaveHostsMap.putIfAbsent(masterComponentName, new HashSet<>());
masterSlaveHostsMap.get(masterComponentName).add(sch.getHostName());
} else {
@@ -3546,7 +3550,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
}
try {
- createAndExecuteRefreshIncludeExcludeFilesActionForMasters(serviceMasterForDecommissionMap, masterSlaveHostsMap, cluster.getClusterName(), false);
+ createAndExecuteRefreshIncludeExcludeFilesActionForMasters(serviceGroupServiceMasterForDecommissionMap, masterSlaveHostsMap, cluster.getClusterName(), false);
} catch (AmbariException e) {
LOG.error("Exception during refresh include exclude files action : ", e);
}
@@ -3558,8 +3562,8 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
}
}
- private boolean isServiceComponentStartedOnAnyHost(Cluster cluster, String serviceName, String masterComponentName) throws AmbariException {
- Service service = cluster.getService(serviceName);
+ private boolean isServiceComponentStartedOnAnyHost(Cluster cluster, String serviceGroupName, String serviceName, String masterComponentName) throws AmbariException {
+ Service service = cluster.getService(serviceGroupName, serviceName);
ServiceComponent serviceComponent = service.getServiceComponent(masterComponentName);
Map<String, ServiceComponentHost> schMap = serviceComponent.getServiceComponentHosts();
for (ServiceComponentHost sch : schMap.values()) {
@@ -3793,7 +3797,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
}
//keep 2 maps for simpler maintenance
- Map<String, Map<String, String>> clusterServiceMasterForDecommissionMap = new HashMap<>();
+ Map<String, Map<String, Map<String, String>>> clusterServiceGroupServiceMasterForDecommissionMap = new HashMap<>();
Map<String, Map<String, Set<String>>> clusterMasterSlaveHostsMap = new HashMap<>();
for (Entry<ServiceComponent, Set<ServiceComponentHost>> entry : safeToRemoveSCHs.entrySet()) {
for (ServiceComponentHost componentHost : entry.getValue()) {
@@ -3810,15 +3814,21 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
masterComponentName = entrySet.getKey();
}
}
- if (clusterServiceMasterForDecommissionMap.containsKey(componentHost.getClusterName())) {
- clusterServiceMasterForDecommissionMap.get(componentHost.getClusterName()).put(componentHost.getServiceName(), masterComponentName);
+ String clusterName = componentHost.getClusterName();
+ String serviceGroupName = componentHost.getServiceGroupName();
+ String serviceName = componentHost.getServiceName();
+ if (clusterServiceGroupServiceMasterForDecommissionMap.containsKey(clusterName)) {
+ Map<String, Map<String, String>> serviceGroupServiceMasterMap = clusterServiceGroupServiceMasterForDecommissionMap.get(clusterName);
+ serviceGroupServiceMasterMap.putIfAbsent(serviceGroupName, new HashMap<>());
+ serviceGroupServiceMasterMap.get(serviceGroupName).put(serviceName, masterComponentName);
Map<String, Set<String>> masterSlaveMap = clusterMasterSlaveHostsMap.get(componentHost.getClusterName());
masterSlaveMap.putIfAbsent(masterComponentName, new HashSet<>());
masterSlaveMap.get(masterComponentName).add(componentHost.getHostName());
} else {
- Map<String, String> serviceMasterMap = new HashMap<>();
- serviceMasterMap.put(componentHost.getServiceName(), masterComponentName);
- clusterServiceMasterForDecommissionMap.put(componentHost.getClusterName(), serviceMasterMap);
+ Map<String, Map<String, String>> serviceGroupServiceMasterMap = new HashMap<>();
+ serviceGroupServiceMasterMap.putIfAbsent(serviceGroupName, new HashMap<>());
+ serviceGroupServiceMasterMap.get(serviceGroupName).put(serviceName, masterComponentName);
+ clusterServiceGroupServiceMasterForDecommissionMap.put(clusterName, serviceGroupServiceMasterMap);
Map<String, Set<String>> masterSlaveHostsMap = new HashMap<>();
masterSlaveHostsMap.put(masterComponentName, new HashSet<>(Collections.singletonList(componentHost.getHostName())));
@@ -3832,8 +3842,8 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
}
}
- for (String cluster : clusterServiceMasterForDecommissionMap.keySet()) {
- createAndExecuteRefreshIncludeExcludeFilesActionForMasters(clusterServiceMasterForDecommissionMap.get(cluster), clusterMasterSlaveHostsMap.get(cluster), cluster, true);
+ for (String cluster : clusterServiceGroupServiceMasterForDecommissionMap.keySet()) {
+ createAndExecuteRefreshIncludeExcludeFilesActionForMasters(clusterServiceGroupServiceMasterForDecommissionMap.get(cluster), clusterMasterSlaveHostsMap.get(cluster), cluster, true);
}
//Do not break behavior for existing clients where delete request contains only 1 host component.
@@ -3885,20 +3895,24 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
/**
* Creates and triggers an action to update include and exclude files for the master components depending on current cluster topology and components state
- * @param serviceMasterMap
+ * @param serviceGroupServiceMasterMap
* @param masterSlaveHostsMap
*@param clusterName @throws AmbariException
*/
- private void createAndExecuteRefreshIncludeExcludeFilesActionForMasters(Map<String, String> serviceMasterMap, Map<String, Set<String>> masterSlaveHostsMap, String clusterName, boolean isDecommission) throws AmbariException {
+ private void createAndExecuteRefreshIncludeExcludeFilesActionForMasters(Map<String, Map<String, String>> serviceGroupServiceMasterMap, Map<String, Set<String>> masterSlaveHostsMap, String clusterName, boolean isDecommission) throws AmbariException {
//Clear include/exclude files or draining list except HBASE
- serviceMasterMap.remove(Service.Type.HBASE.toString());
+ serviceGroupServiceMasterMap.remove(Service.Type.HBASE.toString());
//exit if empty
- if (serviceMasterMap.isEmpty()) {
+ if (serviceGroupServiceMasterMap.isEmpty()) {
return;
}
- LOG.debug("Refresh include/exclude files action will be executed for " + serviceMasterMap);
+ LOG.debug("Refresh include/exclude files action will be executed for " + serviceGroupServiceMasterMap);
HashMap<String, String> requestProperties = new HashMap<>();
- requestProperties.put("context", "Update Include/Exclude Files for " + serviceMasterMap.keySet().toString());
+ if (serviceGroupServiceMasterMap.size() == 1) {
+ requestProperties.put("context", "Update Include/Exclude Files for " + serviceGroupServiceMasterMap.get(serviceGroupServiceMasterMap.keySet().iterator().next()).keySet());
+ } else {
+ requestProperties.put("context", "Update Include/Exclude Files for " + serviceGroupServiceMasterMap);
+ }
HashMap<String, String> params = new HashMap<>();
params.put(AmbariCustomCommandExecutionHelper.UPDATE_FILES_ONLY, String.valueOf(isDecommission));
@@ -3911,9 +3925,12 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
params.put(AmbariCustomCommandExecutionHelper.IS_ADD_OR_DELETE_SLAVE_REQUEST, "true");
//Create filter for command
- List<RequestResourceFilter> resourceFilters = new ArrayList<>(serviceMasterMap.size());
- for (String serviceName : serviceMasterMap.keySet()) {
- resourceFilters.add(new RequestResourceFilter(serviceName, serviceMasterMap.get(serviceName), null));
+ List<RequestResourceFilter> resourceFilters = new ArrayList<>(serviceGroupServiceMasterMap.size());
+ for (String serviceGroupName : serviceGroupServiceMasterMap.keySet()) {
+ for (String serviceName : serviceGroupServiceMasterMap.get(serviceGroupName).keySet()) {
+ resourceFilters.add(new RequestResourceFilter(serviceGroupName, serviceName,
+ serviceGroupServiceMasterMap.get(serviceGroupName).get(serviceName), null));
+ }
}
//Create request for command
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/main/java/org/apache/ambari/server/controller/DeleteIdentityHandler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/DeleteIdentityHandler.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/DeleteIdentityHandler.java
index cc84ce2..01ddf5b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/DeleteIdentityHandler.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/DeleteIdentityHandler.java
@@ -146,7 +146,8 @@ class DeleteIdentityHandler {
Map<String, String> requestParams = new HashMap<>();
List<RequestResourceFilter> requestResourceFilters = new ArrayList<>();
- RequestResourceFilter reqResFilter = new RequestResourceFilter("KERBEROS", "KERBEROS_CLIENT", new ArrayList<>(hostFilter));
+ //TODO figure kerberos service group if any
+ RequestResourceFilter reqResFilter = new RequestResourceFilter("", "KERBEROS", "KERBEROS_CLIENT", new ArrayList<>(hostFilter));
requestResourceFilters.add(reqResFilter);
ActionExecutionContext actionExecContext = new ActionExecutionContext(
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java
index ab85aa1..de048da 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java
@@ -3621,7 +3621,7 @@ public class KerberosHelperImpl implements KerberosHelper {
ActionExecutionContext exec = new ActionExecutionContext(
cluster.getClusterName(),
"DISABLE_SECURITY",
- singletonList(new RequestResourceFilter(service.getName(), component.getName(), singletonList(firstHost))),
+ singletonList(new RequestResourceFilter(service.getServiceGroupName(), service.getName(), component.getName(), singletonList(firstHost))),
Collections.emptyMap());
customCommandExecutionHelper.addExecutionCommandsToStage(exec, stage, Collections.emptyMap(), null);
}
@@ -3653,7 +3653,7 @@ public class KerberosHelperImpl implements KerberosHelper {
ActionExecutionContext exec = new ActionExecutionContext(
cluster.getClusterName(),
"STOP",
- singletonList(new RequestResourceFilter(zookeeper.getName(), component.getName(), new ArrayList<>(hosts))),
+ singletonList(new RequestResourceFilter(zookeeper.getServiceGroupName(), zookeeper.getName(), component.getName(), new ArrayList<>(hosts))),
Collections.emptyMap());
customCommandExecutionHelper.addExecutionCommandsToStage(exec, stage, Collections.emptyMap(), null);
}
@@ -3688,7 +3688,8 @@ public class KerberosHelperImpl implements KerberosHelper {
if (!hostsToUpdate.isEmpty()) {
Map<String, String> requestParams = new HashMap<>();
List<RequestResourceFilter> requestResourceFilters = new ArrayList<>();
- RequestResourceFilter reqResFilter = new RequestResourceFilter("KERBEROS", "KERBEROS_CLIENT", hostsToUpdate);
+ //TODO figure kerberos service group if any
+ RequestResourceFilter reqResFilter = new RequestResourceFilter("", "KERBEROS", "KERBEROS_CLIENT", hostsToUpdate);
requestResourceFilters.add(reqResFilter);
ActionExecutionContext actionExecContext = new ActionExecutionContext(
@@ -3792,7 +3793,8 @@ public class KerberosHelperImpl implements KerberosHelper {
private List<RequestResourceFilter> createRequestResourceFilters(List<String> hostsToInclude) {
List<RequestResourceFilter> requestResourceFilters = new ArrayList<>();
- RequestResourceFilter reqResFilter = new RequestResourceFilter(Service.Type.KERBEROS.name(), Role.KERBEROS_CLIENT.name(), hostsToInclude);
+ //TODO figure kerberos service group if any
+ RequestResourceFilter reqResFilter = new RequestResourceFilter("", Service.Type.KERBEROS.name(), Role.KERBEROS_CLIENT.name(), hostsToInclude);
requestResourceFilters.add(reqResFilter);
return requestResourceFilters;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/main/java/org/apache/ambari/server/controller/MaintenanceStateHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/MaintenanceStateHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/MaintenanceStateHelper.java
index 1ffe841..f65ce79 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/MaintenanceStateHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/MaintenanceStateHelper.java
@@ -65,6 +65,8 @@ public class MaintenanceStateHelper {
* operation level (can be null)
* @param reqFilter
* request resource filter for operation (can't be null)
+ * @param serviceGroupName
+ * service group name (can be null)
* @param serviceName
* service name (can be null)
* @param componentName
@@ -76,7 +78,7 @@ public class MaintenanceStateHelper {
*/
public boolean isOperationAllowed(Cluster cluster,
RequestOperationLevel levelObj, RequestResourceFilter reqFilter,
- String serviceName, String componentName, String hostname)
+ String serviceGroupName, String serviceName, String componentName, String hostname)
throws AmbariException {
Resource.Type level;
if (levelObj == null) {
@@ -84,7 +86,7 @@ public class MaintenanceStateHelper {
} else {
level = levelObj.getLevel();
}
- return isOperationAllowed(cluster, level, serviceName, componentName,
+ return isOperationAllowed(cluster, level, serviceGroupName, serviceName, componentName,
hostname);
}
@@ -93,6 +95,8 @@ public class MaintenanceStateHelper {
* cluster for request
* @param level
* operation level (can't be null)
+ * @param serviceGroupName
+ * service group name (can be null)
* @param serviceName
* service name (can be null)
* @param componentName
@@ -103,10 +107,12 @@ public class MaintenanceStateHelper {
* target's maintenance status).
*/
boolean isOperationAllowed(Cluster cluster, Resource.Type level,
- String serviceName, String componentName, String hostname)
+ String serviceGroupName, String serviceName, String componentName, String hostname)
throws AmbariException {
+// serviceGroupName != null && !serviceGroupName.isEmpty() &&
+// TODO add service group null checks when the UI is updated
if (serviceName != null && !serviceName.isEmpty()) {
- Service service = cluster.getService(serviceName);
+ Service service = cluster.getService(serviceGroupName, serviceName);
if (componentName != null && !componentName.isEmpty()) {
ServiceComponentHost sch = service.getServiceComponent(componentName).getServiceComponentHost(
hostname);
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ActionResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ActionResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ActionResourceProvider.java
index 290931555..fa073d8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ActionResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ActionResourceProvider.java
@@ -56,6 +56,8 @@ public class ActionResourceProvider extends AbstractControllerResourceProvider {
.getPropertyId("Actions", "action_type");
public static final String INPUTS_PROPERTY_ID = PropertyHelper
.getPropertyId("Actions", "inputs");
+ public static final String TARGET_SERVICE_GROUP_PROPERTY_ID = PropertyHelper
+ .getPropertyId("Actions", "target_service_group");
public static final String TARGET_SERVICE_PROPERTY_ID = PropertyHelper
.getPropertyId("Actions", "target_service");
public static final String TARGET_COMPONENT_PROPERTY_ID = PropertyHelper
@@ -130,6 +132,8 @@ public class ActionResourceProvider extends AbstractControllerResourceProvider {
response.getActionType(), requestedIds);
setResourceProperty(resource, INPUTS_PROPERTY_ID,
response.getInputs(), requestedIds);
+ setResourceProperty(resource, TARGET_SERVICE_GROUP_PROPERTY_ID,
+ response.getTargetServiceGroup(), requestedIds);
setResourceProperty(resource, TARGET_SERVICE_PROPERTY_ID,
response.getTargetService(), requestedIds);
setResourceProperty(resource, TARGET_COMPONENT_PROPERTY_ID,
@@ -157,6 +161,7 @@ public class ActionResourceProvider extends AbstractControllerResourceProvider {
(String) properties.get(ACTION_NAME_PROPERTY_ID),
(String) properties.get(ACTION_TYPE_PROPERTY_ID),
(String) properties.get(INPUTS_PROPERTY_ID),
+ (String) properties.get(TARGET_SERVICE_GROUP_PROPERTY_ID),
(String) properties.get(TARGET_SERVICE_PROPERTY_ID),
(String) properties.get(TARGET_COMPONENT_PROPERTY_ID),
(String) properties.get(DESCRIPTION_PROPERTY_ID),
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
index 8b70737..8431da2 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
@@ -729,7 +729,7 @@ public class ClusterStackVersionResourceProvider extends AbstractControllerResou
osFamily, servicesOnHost);
// add host to this stage
- RequestResourceFilter filter = new RequestResourceFilter(null, null,
+ RequestResourceFilter filter = new RequestResourceFilter(null, null, null,
Collections.singletonList(host.getHostName()));
ActionExecutionContext actionContext = new ActionExecutionContext(cluster.getClusterName(),
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStackVersionResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStackVersionResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStackVersionResourceProvider.java
index 5058758..a341dca 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStackVersionResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStackVersionResourceProvider.java
@@ -438,7 +438,7 @@ public class HostStackVersionResourceProvider extends AbstractControllerResource
osFamily, servicesOnHost);
// Create custom action
- RequestResourceFilter filter = new RequestResourceFilter(null, null,
+ RequestResourceFilter filter = new RequestResourceFilter(null, null, null,
Collections.singletonList(hostName));
ActionExecutionContext actionContext = new ActionExecutionContext(
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestOperationLevel.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestOperationLevel.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestOperationLevel.java
index ed43722..0fec7bc 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestOperationLevel.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestOperationLevel.java
@@ -46,6 +46,7 @@ public class RequestOperationLevel {
// Identifiers of properties as they appear at request properties
public static final String OPERATION_LEVEL_ID = "operation_level/level";
public static final String OPERATION_CLUSTER_ID = "operation_level/cluster_name";
+ public static final String OPERATION_SERVICE_GROUP_ID = "operation_level/service_group_name";
public static final String OPERATION_SERVICE_ID = "operation_level/service_name";
public static final String OPERATION_HOSTCOMPONENT_ID = "operation_level/hostcomponent_name";
public static final String OPERATION_HOST_NAME = "operation_level/host_name";
@@ -81,10 +82,11 @@ public class RequestOperationLevel {
}
public RequestOperationLevel(Resource.Type level, String clusterName,
- String serviceName, String hostComponentName,
+ String serviceGroupName, String serviceName, String hostComponentName,
String hostName) {
this.level = level;
this.clusterName = clusterName;
+ this.serviceGroupName = serviceGroupName;
this.serviceName = serviceName;
this.hostComponentName = hostComponentName;
this.hostName = hostName;
@@ -114,6 +116,7 @@ public class RequestOperationLevel {
throw new IllegalArgumentException(message);
}
this.clusterName = requestInfoProperties.get(OPERATION_CLUSTER_ID);
+ this.serviceGroupName = requestInfoProperties.get(OPERATION_SERVICE_GROUP_ID);
this.serviceName = requestInfoProperties.get(OPERATION_SERVICE_ID);
this.hostComponentName =
requestInfoProperties.get(OPERATION_HOSTCOMPONENT_ID);
@@ -135,6 +138,12 @@ public class RequestOperationLevel {
private String clusterName;
/**
+ * Source service group for request. Specified for Service-level
+ * and HostComponent-level requests.
+ */
+ private String serviceGroupName;
+
+ /**
* Source service for request. Specified for Service-level
* and HostComponent-level requests.
*/
@@ -173,6 +182,10 @@ public class RequestOperationLevel {
return hostName;
}
+ public String getServiceGroupName() {
+ return serviceGroupName;
+ }
+
@Override
public String toString() {
return "RequestOperationLevel{" +
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceFilter.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceFilter.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceFilter.java
index e6ae97f..7c04a8a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceFilter.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceFilter.java
@@ -25,6 +25,7 @@ import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;
public class RequestResourceFilter implements ApiModel {
+ private String serviceGroupName;
private String serviceName;
private String componentName;
private final List<String> hostNames = new ArrayList<>();
@@ -33,7 +34,8 @@ public class RequestResourceFilter implements ApiModel {
}
- public RequestResourceFilter(String serviceName, String componentName, List<String> hostNames) {
+ public RequestResourceFilter(String serviceGroupName, String serviceName, String componentName, List<String> hostNames) {
+ this.serviceGroupName = serviceGroupName;
this.serviceName = serviceName;
this.componentName = componentName;
if (hostNames != null) {
@@ -42,6 +44,12 @@ public class RequestResourceFilter implements ApiModel {
}
@JsonSerialize(include = JsonSerialize.Inclusion.NON_EMPTY)
+ @JsonProperty("service_group_name")
+ public String getServiceGroupName() {
+ return serviceGroupName;
+ }
+
+ @JsonSerialize(include = JsonSerialize.Inclusion.NON_EMPTY)
@JsonProperty("service_name")
public String getServiceName() {
return serviceName;
@@ -62,7 +70,8 @@ public class RequestResourceFilter implements ApiModel {
@Override
public String toString() {
return "RequestResourceFilter{" +
- "serviceName='" + serviceName + '\'' +
+ "serviceGroupName='" + serviceGroupName + '\'' +
+ ", serviceName='" + serviceName + '\'' +
", componentName='" + componentName + '\'' +
", hostNames=" + hostNames +
'}';
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java
index 26e3b86..9a9f5f8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java
@@ -20,6 +20,7 @@ package org.apache.ambari.server.controller.internal;
import static org.apache.ambari.server.controller.internal.HostComponentResourceProvider.HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID;
import static org.apache.ambari.server.controller.internal.HostComponentResourceProvider.HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID;
import static org.apache.ambari.server.controller.internal.HostComponentResourceProvider.HOST_COMPONENT_HOST_NAME_PROPERTY_ID;
+import static org.apache.ambari.server.controller.internal.HostComponentResourceProvider.HOST_COMPONENT_SERVICE_GROUP_NAME_PROPERTY_ID;
import static org.apache.ambari.server.controller.internal.HostComponentResourceProvider.HOST_COMPONENT_SERVICE_NAME_PROPERTY_ID;
import java.util.ArrayList;
@@ -127,6 +128,7 @@ public class RequestResourceProvider extends AbstractControllerResourceProvider
public static final String REQUEST_PENDING_HOST_REQUEST_COUNT_ID = REQUESTS + "/pending_host_request_count";
public static final String COMMAND_ID = "command";
public static final String SERVICE_ID = "service_name";
+ public static final String SERVICE_GROUP_ID = "service_group_name";
public static final String COMPONENT_ID = "component_name";
public static final String HOSTS_ID = "hosts"; // This is actually a list of hosts
public static final String HOSTS_PREDICATE = "hosts_predicate";
@@ -507,6 +509,7 @@ public class RequestResourceProvider extends AbstractControllerResourceProvider
List<RequestResourceFilter> resourceFilterList = new ArrayList<>();
+ String serviceGroupName = (String) resourceMap.get(SERVICE_GROUP_ID);
String serviceName = (String) resourceMap.get(SERVICE_ID);
String componentName = (String) resourceMap.get(COMPONENT_ID);
String hostsPredicate = (String) resourceMap.get(HOSTS_PREDICATE);
@@ -517,7 +520,7 @@ public class RequestResourceProvider extends AbstractControllerResourceProvider
for (String hostName : ((String) hostListStr).split(",")) {
hostList.add(hostName.trim());
}
- resourceFilterList.add(new RequestResourceFilter(serviceName, componentName, hostList));
+ resourceFilterList.add(new RequestResourceFilter(serviceGroupName, serviceName, componentName, hostList));
} else if (hostsPredicate != null) {
// Parse the predicate as key=value and apply to the ResourceProvider predicate
Predicate filterPredicate;
@@ -553,10 +556,11 @@ public class RequestResourceProvider extends AbstractControllerResourceProvider
for (Resource resource : resources) {
String hostnameStr = (String) resource.getPropertyValue(HOST_COMPONENT_HOST_NAME_PROPERTY_ID);
if (hostnameStr != null) {
+ String computedServiceGroupName = (String) resource.getPropertyValue(HOST_COMPONENT_SERVICE_GROUP_NAME_PROPERTY_ID);
String computedServiceName = (String) resource.getPropertyValue(HOST_COMPONENT_SERVICE_NAME_PROPERTY_ID);
String computedComponentName = (String) resource.getPropertyValue(HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID);
ServiceComponentTuple duple =
- new ServiceComponentTuple(computedServiceName, computedComponentName);
+ new ServiceComponentTuple(computedServiceGroupName, computedServiceName, computedComponentName);
if (!dupleListMap.containsKey(duple)) {
hostList = new ArrayList<>();
@@ -570,6 +574,7 @@ public class RequestResourceProvider extends AbstractControllerResourceProvider
if (!dupleListMap.isEmpty()) {
for (Map.Entry<ServiceComponentTuple, List<String>> entry : dupleListMap.entrySet()) {
resourceFilterList.add(new RequestResourceFilter(
+ entry.getKey().getServiceGroupName(),
entry.getKey().getServiceName(),
entry.getKey().getComponentName(),
entry.getValue()
@@ -583,7 +588,7 @@ public class RequestResourceProvider extends AbstractControllerResourceProvider
", hostPredicate" + " = " + hostsPredicate, e);
}
} else {
- resourceFilterList.add(new RequestResourceFilter(serviceName, componentName, hostList));
+ resourceFilterList.add(new RequestResourceFilter(serviceGroupName, serviceName, componentName, hostList));
}
return resourceFilterList;
@@ -593,14 +598,20 @@ public class RequestResourceProvider extends AbstractControllerResourceProvider
* Represent a map key as a ServiceComponent
*/
class ServiceComponentTuple {
+ final String serviceGroupName;
final String serviceName;
final String componentName;
- ServiceComponentTuple(String serviceName, String componentName) {
+ ServiceComponentTuple(String serviceGroupName, String serviceName, String componentName) {
+ this.serviceGroupName = serviceGroupName;
this.serviceName = serviceName;
this.componentName = componentName;
}
+ public String getServiceGroupName() {
+ return serviceGroupName;
+ }
+
public String getServiceName() {
return serviceName;
}
@@ -620,6 +631,10 @@ public class RequestResourceProvider extends AbstractControllerResourceProvider
ServiceComponentTuple that = (ServiceComponentTuple) o;
+ if (serviceGroupName != null ? !serviceGroupName.equals(that.serviceGroupName) : that.serviceGroupName != null) {
+ return false;
+ }
+
if (serviceName != null ? !serviceName.equals(that.serviceName) : that.serviceName != null) {
return false;
}
@@ -629,7 +644,8 @@ public class RequestResourceProvider extends AbstractControllerResourceProvider
@Override
public int hashCode() {
- int result = serviceName != null ? serviceName.hashCode() : 0;
+ int result = serviceGroupName != null ? serviceGroupName.hashCode() : 0;
+ result = 31 * result + (serviceName != null ? serviceName.hashCode() : 0);
result = 31 * result + (componentName != null ? componentName.hashCode() : 0);
return result;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/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 bab5369..99742d4 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
@@ -1055,7 +1055,8 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
// add each host to this stage
- RequestResourceFilter filter = new RequestResourceFilter(serviceName, componentName,
+ //TODO pass service group name once upgrade is fixed
+ RequestResourceFilter filter = new RequestResourceFilter("", serviceName, componentName,
new ArrayList<>(wrapper.getHosts()));
ActionExecutionContext actionContext = new ActionExecutionContext(cluster.getClusterName(),
@@ -1119,7 +1120,8 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
for (TaskWrapper tw : wrapper.getTasks()) {
// add each host to this stage
- filters.add(new RequestResourceFilter(tw.getService(), tw.getComponent(),
+ //TODO pass service group name once upgrade is fixed
+ filters.add(new RequestResourceFilter("", tw.getService(), tw.getComponent(),
new ArrayList<>(tw.getHosts())));
}
@@ -1190,7 +1192,8 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
List<RequestResourceFilter> filters = new ArrayList<>();
for (TaskWrapper tw : wrapper.getTasks()) {
- filters.add(new RequestResourceFilter(tw.getService(), "", Collections.emptyList()));
+ //TODO pass service group name once upgrade is fixed
+ filters.add(new RequestResourceFilter("", tw.getService(), "", Collections.emptyList()));
}
Cluster cluster = context.getCluster();
[2/3] ambari git commit: AMBARI-22428 Update db schema to use
service_id instead of service_name (requests part) (dsen)
Posted by ds...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/main/java/org/apache/ambari/server/customactions/ActionDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/customactions/ActionDefinition.java b/ambari-server/src/main/java/org/apache/ambari/server/customactions/ActionDefinition.java
index 369ef64..896ae53 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/customactions/ActionDefinition.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/customactions/ActionDefinition.java
@@ -33,6 +33,7 @@ public class ActionDefinition {
private ActionType actionType;
private String inputs;
private String targetService;
+ private String targetServiceGroup;
private String targetComponent;
private String description;
private TargetHostType targetType;
@@ -45,6 +46,7 @@ public class ActionDefinition {
* @param actionName The name of the action
* @param actionType The type fo the action
* @param inputs Expected input of the action
+ * @param targetServiceGroup Target service group type (e.g. HDFS)
* @param targetService Target service type (e.g. HDFS)
* @param targetComponent Target component type (e.g. DATANODE)
* @param description Short description of the action
@@ -53,11 +55,12 @@ public class ActionDefinition {
* @param permissions A set of permissions to use when verifiying authorization to execute this action
*/
public ActionDefinition(String actionName, ActionType actionType, String inputs,
- String targetService, String targetComponent, String description,
+ String targetServiceGroup, String targetService, String targetComponent, String description,
TargetHostType targetType, Short defaultTimeout, Set<RoleAuthorization> permissions) {
setActionName(actionName);
setActionType(actionType);
setInputs(inputs);
+ setTargetServiceGroup(targetServiceGroup);
setTargetService(targetService);
setTargetComponent(targetComponent);
setDescription(description);
@@ -98,6 +101,14 @@ public class ActionDefinition {
this.targetService = targetService;
}
+ public String getTargetServiceGroup() {
+ return targetServiceGroup;
+ }
+
+ public void setTargetServiceGroup(String targetServiceGroup) {
+ this.targetServiceGroup = targetServiceGroup;
+ }
+
public String getTargetComponent() {
return targetComponent;
}
@@ -140,7 +151,7 @@ public class ActionDefinition {
public ActionResponse convertToResponse() {
return new ActionResponse(getActionName(), getActionType().name(), getInputs(),
- getTargetService(), getTargetComponent(), getDescription(), getTargetType().name(),
+ getTargetServiceGroup(), getTargetService(), getTargetComponent(), getDescription(), getTargetType().name(),
getDefaultTimeout().toString());
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/main/java/org/apache/ambari/server/customactions/ActionDefinitionManager.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/customactions/ActionDefinitionManager.java b/ambari-server/src/main/java/org/apache/ambari/server/customactions/ActionDefinitionManager.java
index dde2647..a0b51a4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/customactions/ActionDefinitionManager.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/customactions/ActionDefinitionManager.java
@@ -126,7 +126,7 @@ public class ActionDefinitionManager {
}
actionDefinitionMap.put(ad.getActionName(), new ActionDefinition(ad.getActionName(), actionType,
- ad.getInputs(), ad.getTargetService(), ad.getTargetComponent(), ad.getDescription(), targetType, defaultTimeout,
+ ad.getInputs(), ad.getTargetServiceGroup(), ad.getTargetService(), ad.getTargetComponent(), ad.getDescription(), targetType, defaultTimeout,
translatePermissions(ad.getPermissions())));
LOG.info("Added custom action definition for " + ad.getActionName());
} else {
@@ -156,9 +156,14 @@ public class ActionDefinitionManager {
return false;
}
- if (ad.getTargetService() == null || ad.getTargetService().isEmpty()) {
- if (ad.getTargetComponent() != null && !ad.getTargetComponent().isEmpty()) {
- reason.append("Target component cannot be specified unless target service is specified");
+ if (ad.getTargetServiceGroup() == null || ad.getTargetServiceGroup().isEmpty()) {
+ if (ad.getTargetService() == null || ad.getTargetService().isEmpty()) {
+ if (ad.getTargetComponent() != null && !ad.getTargetComponent().isEmpty()) {
+ reason.append("Target component cannot be specified unless target service is specified");
+ return false;
+ }
+ } else {
+ reason.append("Target service cannot be specified unless target service group is specified");
return false;
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/main/java/org/apache/ambari/server/customactions/ActionDefinitionSpec.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/customactions/ActionDefinitionSpec.java b/ambari-server/src/main/java/org/apache/ambari/server/customactions/ActionDefinitionSpec.java
index d96b516..bf3a152 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/customactions/ActionDefinitionSpec.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/customactions/ActionDefinitionSpec.java
@@ -22,6 +22,7 @@ public class ActionDefinitionSpec {
private String actionName;
private String actionType;
private String inputs;
+ private String targetServiceGroup;
private String targetService;
private String targetComponent;
private String description;
@@ -93,6 +94,14 @@ public class ActionDefinitionSpec {
this.targetService = targetService;
}
+ public String getTargetServiceGroup() {
+ return targetServiceGroup;
+ }
+
+ public void setTargetServiceGroup(String targetServiceGroup) {
+ this.targetServiceGroup = targetServiceGroup;
+ }
+
public String getPermissions() {
return permissions;
}
@@ -139,6 +148,7 @@ public class ActionDefinitionSpec {
.append(" actionType: ").append(actionType)
.append(" inputs: ").append(inputs)
.append(" description: ").append(description)
+ .append(" targetServiceGroup: ").append(targetServiceGroup)
.append(" targetService: ").append(targetService)
.append(" targetComponent: ").append(targetComponent)
.append(" defaultTimeout: ").append(defaultTimeout)
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/main/java/org/apache/ambari/server/metadata/ActionMetadata.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/metadata/ActionMetadata.java b/ambari-server/src/main/java/org/apache/ambari/server/metadata/ActionMetadata.java
index 33dc0e8..6b91651 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/metadata/ActionMetadata.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/metadata/ActionMetadata.java
@@ -94,12 +94,12 @@ public class ActionMetadata {
}
}
- public String getClient(String serviceName) {
- return serviceClients.get(serviceName.toLowerCase());
+ public String getClient(String serviceType) {
+ return serviceClients.get(serviceType.toLowerCase());
}
- public String getServiceCheckAction(String serviceName) {
- return serviceCheckActions.get(serviceName.toLowerCase());
+ public String getServiceCheckAction(String serviceType) {
+ return serviceCheckActions.get(serviceType.toLowerCase());
}
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RequestOperationLevelEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RequestOperationLevelEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RequestOperationLevelEntity.java
index a7cd0d0..0f2a120 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RequestOperationLevelEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RequestOperationLevelEntity.java
@@ -74,6 +74,10 @@ public class RequestOperationLevelEntity {
@Basic
private String clusterName;
+ @Column(name = "service_group_name")
+ @Basic
+ private String serviceGroupName;
+
@Column(name = "service_name")
@Basic
private String serviceName;
@@ -102,6 +106,14 @@ public class RequestOperationLevelEntity {
this.clusterName = clusterName;
}
+ public String getServiceGroupName() {
+ return serviceGroupName;
+ }
+
+ public void setServiceGroupName(String serviceGroupName) {
+ this.serviceGroupName = serviceGroupName;
+ }
+
public String getServiceName() {
return serviceName;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RequestResourceFilterEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RequestResourceFilterEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RequestResourceFilterEntity.java
index 9597db1..4a6ef4c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RequestResourceFilterEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RequestResourceFilterEntity.java
@@ -51,6 +51,10 @@ public class RequestResourceFilterEntity {
@Column(name = "request_id", nullable = false, insertable = true, updatable = true)
private Long requestId;
+ @Column(name = "service_group_name")
+ @Basic
+ private String serviceGroupName;
+
@Column(name = "service_name")
@Basic
private String serviceName;
@@ -114,4 +118,12 @@ public class RequestResourceFilterEntity {
public void setRequestEntity(RequestEntity request) {
this.requestEntity = request;
}
+
+ public String getServiceGroupName() {
+ return serviceGroupName;
+ }
+
+ public void setServiceGroupName(String serviceGroupName) {
+ this.serviceGroupName = serviceGroupName;
+ }
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/main/java/org/apache/ambari/server/state/StackInfo.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/StackInfo.java b/ambari-server/src/main/java/org/apache/ambari/server/state/StackInfo.java
index 9db7fd6..1ce6b74 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/StackInfo.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/StackInfo.java
@@ -62,7 +62,7 @@ public class StackInfo implements Comparable<StackInfo>, Validable {
private Map<String, Map<String, Map<String, String>>> configTypes;
// Gets information from stacks/<stack-name>/<version>/settings.xml
- private List<PropertyInfo> stackSettings;
+ private List<PropertyInfo> stackSettings = new ArrayList<>();
private Map<String, Map<String, Map<String, String>>> stackSettingsConfigTypes;
private Map<String, UpgradePack> upgradePacks;
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
index 9d76845..a811c5e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
@@ -1129,7 +1129,7 @@ public class ClusterImpl implements Cluster {
}
if (null == service) {
- throw new ServiceNotFoundException(getClusterName(), serviceName);
+ throw new ServiceNotFoundException(getClusterName(), serviceGroupName, serviceName);
}
return service;
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/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 b6287e6..8a12df9 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
@@ -222,7 +222,7 @@ public class StageUtils {
long now = System.currentTimeMillis();
s.addHostRoleExecutionCommand(hostname, Role.NAMENODE, RoleCommand.INSTALL,
new ServiceComponentHostInstallEvent("NAMENODE", hostname, now, "HDP-1.2.0"), "cluster1",
- "HDFS", false, false);
+ "core", "HDFS", false, false);
ExecutionCommand execCmd = s.getExecutionCommandWrapper(hostname, "NAMENODE").getExecutionCommand();
execCmd.setRequestAndStage(s.getRequestId(), s.getStageId());
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
index 4cef9da..8ca2359 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
@@ -501,6 +501,7 @@ CREATE TABLE role_success_criteria (
CREATE TABLE requestresourcefilter (
filter_id BIGINT NOT NULL,
request_id BIGINT NOT NULL,
+ service_group_name VARCHAR(255),
service_name VARCHAR(255),
component_name VARCHAR(255),
hosts BLOB,
@@ -512,6 +513,7 @@ CREATE TABLE requestoperationlevel (
request_id BIGINT NOT NULL,
level_name VARCHAR(255),
cluster_name VARCHAR(255),
+ service_group_name VARCHAR(255),
service_name VARCHAR(255),
host_component_name VARCHAR(255),
host_id BIGINT DEFAULT 0,
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/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 02849d0..8bfc7eb 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
@@ -520,6 +520,7 @@ CREATE TABLE role_success_criteria (
CREATE TABLE requestresourcefilter (
filter_id BIGINT NOT NULL,
request_id BIGINT NOT NULL,
+ service_group_name VARCHAR(255),
service_name VARCHAR(255),
component_name VARCHAR(255),
hosts LONGBLOB,
@@ -531,6 +532,7 @@ CREATE TABLE requestoperationlevel (
request_id BIGINT NOT NULL,
level_name VARCHAR(255),
cluster_name VARCHAR(255),
+ service_group_name VARCHAR(255),
service_name VARCHAR(255),
host_component_name VARCHAR(255),
host_id BIGINT NULL, -- unlike most host_id columns, this one allows NULLs because the request can be at the service level
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/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 65a1b94..0168af8 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
@@ -499,6 +499,7 @@ CREATE TABLE role_success_criteria (
CREATE TABLE requestresourcefilter (
filter_id NUMBER(19) NOT NULL,
request_id NUMBER(19) NOT NULL,
+ service_group_name VARCHAR2(255),
service_name VARCHAR2(255),
component_name VARCHAR2(255),
hosts BLOB,
@@ -510,6 +511,7 @@ CREATE TABLE requestoperationlevel (
request_id NUMBER(19) NOT NULL,
level_name VARCHAR2(255),
cluster_name VARCHAR2(255),
+ service_group_name VARCHAR2(255),
service_name VARCHAR2(255),
host_component_name VARCHAR2(255),
host_id NUMBER(19) NULL, -- unlike most host_id columns, this one allows NULLs because the request can be at the service level
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/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 d310014..1ebc0ee 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
@@ -471,6 +471,7 @@ CREATE TABLE role_success_criteria (
CREATE TABLE requestresourcefilter (
filter_id BIGINT NOT NULL,
request_id BIGINT NOT NULL,
+ service_group_name VARCHAR(255),
service_name VARCHAR(255),
component_name VARCHAR(255),
hosts BYTEA,
@@ -482,6 +483,7 @@ CREATE TABLE requestoperationlevel (
request_id BIGINT NOT NULL,
level_name VARCHAR(255),
cluster_name VARCHAR(255),
+ service_group_name VARCHAR(255),
service_name VARCHAR(255),
host_component_name VARCHAR(255),
host_id BIGINT NULL, -- unlike most host_id columns, this one allows NULLs because the request can be at the service level
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
index a510898..dc4bafd 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
@@ -497,6 +497,7 @@ CREATE TABLE role_success_criteria (
CREATE TABLE requestresourcefilter (
filter_id NUMERIC(19) NOT NULL,
request_id NUMERIC(19) NOT NULL,
+ service_group_name VARCHAR(255),
service_name VARCHAR(255),
component_name VARCHAR(255),
hosts IMAGE,
@@ -508,6 +509,7 @@ CREATE TABLE requestoperationlevel (
request_id NUMERIC(19) NOT NULL,
level_name VARCHAR(255),
cluster_name VARCHAR(255),
+ service_group_name VARCHAR(255),
service_name VARCHAR(255),
host_component_name VARCHAR(255),
host_id NUMERIC(19) NULL, -- unlike most host_id columns, this one allows NULLs because the request can be at the service level
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
index 1ff1acc..8bef24f 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
@@ -503,6 +503,7 @@ CREATE TABLE role_success_criteria (
CREATE TABLE requestresourcefilter (
filter_id BIGINT NOT NULL,
request_id BIGINT NOT NULL,
+ service_group_name VARCHAR(255),
service_name VARCHAR(255),
component_name VARCHAR(255),
hosts VARBINARY(MAX),
@@ -514,6 +515,7 @@ CREATE TABLE requestoperationlevel (
request_id BIGINT NOT NULL,
level_name VARCHAR(255),
cluster_name VARCHAR(255),
+ service_group_name VARCHAR(255),
service_name VARCHAR(255),
host_component_name VARCHAR(255),
host_id BIGINT NULL, -- unlike most host_id columns, this one allows NULLs because the request can be at the service level
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/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 b674234..dc3b9ac 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
@@ -164,7 +164,7 @@ public class ExecutionCommandWrapperTest {
s.addHostRoleExecutionCommand(hostName, Role.NAMENODE,
RoleCommand.START,
new ServiceComponentHostStartEvent(Role.NAMENODE.toString(),
- hostName, System.currentTimeMillis()), clusterName, "HDFS", false, false);
+ hostName, System.currentTimeMillis()), clusterName, "core", "HDFS", false, false);
List<Stage> stages = new ArrayList<>();
stages.add(s);
Request request = new Request(stages, "clusterHostInfo", clusters);
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/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 94799cc..3c6a0be 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
@@ -572,23 +572,23 @@ public class TestActionDBAccessorImpl {
s.addHostRoleExecutionCommand("host1", Role.HBASE_MASTER,
RoleCommand.START,
new ServiceComponentHostStartEvent(Role.HBASE_MASTER.toString(),
- "host1", System.currentTimeMillis()), "cluster1", "HBASE", false, false);
+ "host1", System.currentTimeMillis()), "cluster1", "core", "HBASE", false, false);
s.addHostRoleExecutionCommand("host2", Role.HBASE_MASTER,
RoleCommand.START,
new ServiceComponentHostStartEvent(Role.HBASE_MASTER.toString(),
- "host2", System.currentTimeMillis()), "cluster1", "HBASE", false, false);
+ "host2", System.currentTimeMillis()), "cluster1", "core", "HBASE", false, false);
s.addHostRoleExecutionCommand(
"host3",
Role.HBASE_REGIONSERVER,
RoleCommand.START,
new ServiceComponentHostStartEvent(Role.HBASE_REGIONSERVER
- .toString(), "host3", System.currentTimeMillis()), "cluster1", "HBASE", false, false);
+ .toString(), "host3", System.currentTimeMillis()), "cluster1", "core", "HBASE", false, false);
s.addHostRoleExecutionCommand(
"host4",
Role.HBASE_REGIONSERVER,
RoleCommand.START,
new ServiceComponentHostStartEvent(Role.HBASE_REGIONSERVER
- .toString(), "host4", System.currentTimeMillis()), "cluster1", "HBASE", false, false);
+ .toString(), "host4", System.currentTimeMillis()), "cluster1", "core", "HBASE", false, false);
List<Stage> stages = new ArrayList<>();
stages.add(s);
s.getOrderedHostRoleCommands().get(0).setStatus(HostRoleStatus.PENDING);
@@ -700,7 +700,7 @@ public class TestActionDBAccessorImpl {
clusters.addHost(host);
s.addHostRoleExecutionCommand("host" + i, Role.HBASE_MASTER,
- RoleCommand.START, null, "cluster1", "HBASE", false, false);
+ RoleCommand.START, null, "cluster1", "core", "HBASE", false, false);
}
List<Stage> stages = new ArrayList<>();
@@ -786,13 +786,13 @@ public class TestActionDBAccessorImpl {
s.addHostRoleExecutionCommand(hostname, Role.HBASE_MASTER,
RoleCommand.START,
new ServiceComponentHostStartEvent(Role.HBASE_MASTER.toString(),
- hostname, System.currentTimeMillis()), "cluster1", "HBASE", retryAllowed, false);
+ hostname, System.currentTimeMillis()), "cluster1", "core", "HBASE", retryAllowed, false);
s.addHostRoleExecutionCommand(
hostname,
Role.HBASE_REGIONSERVER,
RoleCommand.START,
new ServiceComponentHostStartEvent(Role.HBASE_REGIONSERVER
- .toString(), hostname, System.currentTimeMillis()), "cluster1", "HBASE", false, false);
+ .toString(), hostname, System.currentTimeMillis()), "cluster1", "core", "HBASE", false, false);
return s;
}
@@ -804,10 +804,10 @@ public class TestActionDBAccessorImpl {
s.addHostRoleExecutionCommand(hostname, Role.valueOf(actionName),
RoleCommand.ACTIONEXECUTE,
new ServiceComponentHostStartEvent(Role.HBASE_MASTER.toString(),
- hostname, System.currentTimeMillis()), "cluster1", "HBASE", false, false);
+ hostname, System.currentTimeMillis()), "cluster1", "core", "HBASE", false, false);
List<Stage> stages = new ArrayList<>();
stages.add(s);
- final RequestResourceFilter resourceFilter = new RequestResourceFilter("HBASE", "HBASE_MASTER", null);
+ final RequestResourceFilter resourceFilter = new RequestResourceFilter("core", "HBASE", "HBASE_MASTER", null);
List<RequestResourceFilter> resourceFilters = new
ArrayList<RequestResourceFilter>() {{ add(resourceFilter); }};
Request request = new Request(stages, "", clusters);
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/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 386a1c8..fe35456 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
@@ -225,7 +225,7 @@ public class TestActionManager {
s.addHostRoleExecutionCommand(hostname, Role.HBASE_MASTER,
RoleCommand.START,
new ServiceComponentHostStartEvent(Role.HBASE_MASTER.toString(),
- hostname, System.currentTimeMillis()), "cluster1", "HBASE", false, false);
+ hostname, System.currentTimeMillis()), "cluster1", "core", "HBASE", false, false);
List<Stage> stages = new ArrayList<>();
stages.add(s);
Request request = new Request(stages, "clusterHostInfo", clusters);
@@ -238,11 +238,11 @@ public class TestActionManager {
s.addHostRoleExecutionCommand(hostname, Role.HBASE_MASTER,
RoleCommand.START,
new ServiceComponentHostStartEvent(Role.HBASE_MASTER.toString(),
- hostname, System.currentTimeMillis()), "cluster1", "HBASE", false, false);
+ hostname, System.currentTimeMillis()), "cluster1", "core", "HBASE", false, false);
s.addHostRoleExecutionCommand(hostname, Role.HBASE_REGIONSERVER,
RoleCommand.START,
new ServiceComponentHostStartEvent(Role.HBASE_REGIONSERVER.toString(),
- hostname, System.currentTimeMillis()), "cluster1", "HBASE", false, false);
+ hostname, System.currentTimeMillis()), "cluster1", "core", "HBASE", false, false);
List<Stage> stages = new ArrayList<>();
stages.add(s);
Request request = new Request(stages, "clusterHostInfo", clusters);
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/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 de622a7..a79edcc 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
@@ -416,7 +416,7 @@ public class TestActionScheduler {
"{\"host_param\":\"param_value\"}", "{\"stage_param\":\"param_value\"}");
s.addHostRoleExecutionCommand(hostname, Role.SECONDARY_NAMENODE, RoleCommand.INSTALL,
new ServiceComponentHostInstallEvent("SECONDARY_NAMENODE", hostname, System.currentTimeMillis(), "HDP-1.2.0"),
- "cluster1", "HDFS", false, false);
+ "cluster1", "core", "HDFS", false, false);
s.setHostRoleStatus(hostname, "SECONDARY_NAMENODE", HostRoleStatus.IN_PROGRESS);
List<Stage> stages = Collections.singletonList(s);
@@ -592,9 +592,9 @@ public class TestActionScheduler {
final Stage stage = stageFactory.createNew(1, "/tmp", "cluster1", 1L, "stageWith2Tasks",
"{\"command_param\":\"param_value\"}", "{\"host_param\":\"param_value\"}");
addInstallTaskToStage(stage, hostname1, "cluster1", Role.DATANODE,
- RoleCommand.INSTALL, Service.Type.HDFS, 1);
+ RoleCommand.INSTALL, "core", Service.Type.HDFS, 1);
addInstallTaskToStage(stage, hostname2, "cluster1", Role.NAMENODE,
- RoleCommand.INSTALL, Service.Type.HDFS, 2);
+ RoleCommand.INSTALL, "core", Service.Type.HDFS, 2);
final List<Stage> stages = Collections.singletonList(stage);
ActionDBAccessor db = mock(ActionDBAccessor.class);
@@ -816,16 +816,16 @@ public class TestActionScheduler {
List<Stage> stages = new ArrayList<>();
Stage stage01 = createStage(clusterName, 0, 1);
- addTask(stage01, Stage.INTERNAL_HOSTNAME, clusterName, Role.AMBARI_SERVER_ACTION, RoleCommand.ACTIONEXECUTE, "AMBARI", 1);
+ addTask(stage01, Stage.INTERNAL_HOSTNAME, clusterName, Role.AMBARI_SERVER_ACTION, RoleCommand.ACTIONEXECUTE, null,"AMBARI", 1);
Stage stage11 = createStage("cluster1", 1, 1);
- addTask(stage11, hostname1, clusterName, Role.KERBEROS_CLIENT, RoleCommand.CUSTOM_COMMAND, "KERBEROS", 2);
+ addTask(stage11, hostname1, clusterName, Role.KERBEROS_CLIENT, RoleCommand.CUSTOM_COMMAND, "core", "KERBEROS", 2);
Stage stage02 = createStage("cluster1", 0, 2);
- addTask(stage02, Stage.INTERNAL_HOSTNAME, clusterName, Role.AMBARI_SERVER_ACTION, RoleCommand.ACTIONEXECUTE, "AMBARI", 3);
+ addTask(stage02, Stage.INTERNAL_HOSTNAME, clusterName, Role.AMBARI_SERVER_ACTION, RoleCommand.ACTIONEXECUTE, null, "AMBARI", 3);
Stage stage12 = createStage("cluster1", 1, 2);
- addTask(stage12, hostname2, clusterName, Role.KERBEROS_CLIENT, RoleCommand.CUSTOM_COMMAND, "KERBEROS", 4);
+ addTask(stage12, hostname2, clusterName, Role.KERBEROS_CLIENT, RoleCommand.CUSTOM_COMMAND, "core", "KERBEROS", 4);
stages.add(stage01);
stages.add(stage11);
@@ -1222,23 +1222,23 @@ public class TestActionScheduler {
firstStageInProgressPerRequest.add(
getStageWithSingleTask(
hostname1, "cluster1", Role.DATANODE,
- RoleCommand.START, Service.Type.HDFS, 1, 1, 1));
+ RoleCommand.START, "core", Service.Type.HDFS, 1, 1, 1));
// Stage with the same hostname, should not be scheduled
firstStageInProgressPerRequest.add(
getStageWithSingleTask(
hostname1, "cluster1", Role.GANGLIA_MONITOR,
- RoleCommand.START, Service.Type.GANGLIA, 2, 2, 2));
+ RoleCommand.START, "core", Service.Type.GANGLIA, 2, 2, 2));
firstStageInProgressPerRequest.add(
getStageWithSingleTask(
hostname2, "cluster1", Role.DATANODE,
- RoleCommand.START, Service.Type.HDFS, 3, 3, 3));
+ RoleCommand.START, "core", Service.Type.HDFS, 3, 3, 3));
firstStageInProgressPerRequest.add(
getStageWithSingleTask(
hostname3, "cluster1", Role.DATANODE,
- RoleCommand.START, Service.Type.HDFS, 4, 4, 4));
+ RoleCommand.START, "core", Service.Type.HDFS, 4, 4, 4));
ActionDBAccessor db = mock(ActionDBAccessor.class);
HostRoleCommandDAO hostRoleCommandDAOMock = mock(HostRoleCommandDAO.class);
@@ -1308,7 +1308,7 @@ public class TestActionScheduler {
List<Stage> stages = new ArrayList<>();
Stage stage = getStageWithSingleTask(
hostname1, "cluster1", Role.HIVE_CLIENT,
- RoleCommand.INSTALL, Service.Type.HIVE, 1, 1, 1);
+ RoleCommand.INSTALL, "core", Service.Type.HIVE, 1, 1, 1);
Map<String, String> hiveSite = new TreeMap<>();
hiveSite.put("javax.jdo.option.ConnectionPassword", "password");
hiveSite.put("hive.server2.thrift.port", "10000");
@@ -1321,22 +1321,22 @@ public class TestActionScheduler {
stages.add( // Stage with the same hostname, should not be scheduled
getStageWithSingleTask(
hostname1, "cluster1", Role.GANGLIA_MONITOR,
- RoleCommand.START, Service.Type.GANGLIA, 2, 2, 2));
+ RoleCommand.START, "core", Service.Type.GANGLIA, 2, 2, 2));
stages.add(
getStageWithSingleTask(
hostname2, "cluster1", Role.HIVE_CLIENT,
- RoleCommand.INSTALL, Service.Type.HIVE, 3, 3, 3));
+ RoleCommand.INSTALL, "core", Service.Type.HIVE, 3, 3, 3));
stages.add(
getStageWithSingleTask(
hostname3, "cluster1", Role.DATANODE,
- RoleCommand.START, Service.Type.HDFS, 4, 4, 4));
+ RoleCommand.START, "core", Service.Type.HDFS, 4, 4, 4));
stages.add( // Stage with the same request id, should not be scheduled
getStageWithSingleTask(
hostname4, "cluster1", Role.GANGLIA_MONITOR,
- RoleCommand.START, Service.Type.GANGLIA, 5, 5, 4));
+ RoleCommand.START, "core", Service.Type.GANGLIA, 5, 5, 4));
ActionDBAccessor db = mock(ActionDBAccessor.class);
HostRoleCommandDAO hostRoleCommandDAOMock = mock(HostRoleCommandDAO.class);
@@ -1384,7 +1384,7 @@ public class TestActionScheduler {
ServiceComponentHost sch = mock(ServiceComponentHost.class);
UnitOfWork unitOfWork = mock(UnitOfWork.class);
when(fsm.getCluster(anyString())).thenReturn(oneClusterMock);
- when(oneClusterMock.getService(anyString())).thenReturn(serviceObj);
+ when(oneClusterMock.getService(anyString(), anyString())).thenReturn(serviceObj);
when(serviceObj.getServiceComponent(anyString())).thenReturn(scomp);
when(scomp.getServiceComponentHost(anyString())).thenReturn(sch);
when(serviceObj.getCluster()).thenReturn(oneClusterMock);
@@ -1401,19 +1401,19 @@ public class TestActionScheduler {
Stage backgroundStage = null;
stages.add(//stage with background command
backgroundStage = getStageWithSingleTask(
- hostname1, "cluster1", Role.NAMENODE, RoleCommand.CUSTOM_COMMAND, "REBALANCEHDFS", Service.Type.HDFS, 1, 1, 1));
+ hostname1, "cluster1", Role.NAMENODE, RoleCommand.CUSTOM_COMMAND, "REBALANCEHDFS", "core", Service.Type.HDFS, 1, 1, 1));
Assert.assertEquals(AgentCommandType.BACKGROUND_EXECUTION_COMMAND ,backgroundStage.getExecutionCommands(hostname1).get(0).getExecutionCommand().getCommandType());
stages.add( // Stage with the same hostname, should be scheduled
getStageWithSingleTask(
hostname1, "cluster1", Role.GANGLIA_MONITOR,
- RoleCommand.START, Service.Type.GANGLIA, 2, 2, 2));
+ RoleCommand.START, "core", Service.Type.GANGLIA, 2, 2, 2));
stages.add(
getStageWithSingleTask(
hostname2, "cluster1", Role.DATANODE,
- RoleCommand.START, Service.Type.HDFS, 3, 3, 3));
+ RoleCommand.START, "core", Service.Type.HDFS, 3, 3, 3));
ActionDBAccessor db = mock(ActionDBAccessor.class);
@@ -1471,13 +1471,13 @@ public class TestActionScheduler {
stages.add(
getStageWithSingleTask(
- hostname, "cluster1", Role.NAMENODE, RoleCommand.UPGRADE, Service.Type.HDFS, 1, 1, 1));
+ hostname, "cluster1", Role.NAMENODE, RoleCommand.UPGRADE, "core", Service.Type.HDFS, 1, 1, 1));
List<Stage> firstStageInProgress = Collections.singletonList(stages.get(0));
stages.add(
getStageWithSingleTask(
- hostname, "cluster1", Role.DATANODE, RoleCommand.UPGRADE, Service.Type.HDFS, 2, 2, 1));
+ hostname, "cluster1", Role.DATANODE, RoleCommand.UPGRADE, "core", Service.Type.HDFS, 2, 2, 1));
Host host = mock(Host.class);
when(fsm.getHost(anyString())).thenReturn(host);
@@ -1638,25 +1638,25 @@ public class TestActionScheduler {
"testRequestFailureBasedOnSuccessFactor", "", "");
stage.setStageId(1);
- addHostRoleExecutionCommand(now, stage, Role.SQOOP, Service.Type.SQOOP,
+ addHostRoleExecutionCommand(now, stage, Role.SQOOP, "core", Service.Type.SQOOP,
RoleCommand.INSTALL, host1, "cluster1");
- addHostRoleExecutionCommand(now, stage, Role.OOZIE_CLIENT, Service.Type.OOZIE,
+ addHostRoleExecutionCommand(now, stage, Role.OOZIE_CLIENT, "core", Service.Type.OOZIE,
RoleCommand.INSTALL, host1, "cluster1");
- addHostRoleExecutionCommand(now, stage, Role.MAPREDUCE_CLIENT, Service.Type.MAPREDUCE,
+ addHostRoleExecutionCommand(now, stage, Role.MAPREDUCE_CLIENT, "core", Service.Type.MAPREDUCE,
RoleCommand.INSTALL, host1, "cluster1");
- addHostRoleExecutionCommand(now, stage, Role.HBASE_CLIENT, Service.Type.HBASE,
+ addHostRoleExecutionCommand(now, stage, Role.HBASE_CLIENT, "core", Service.Type.HBASE,
RoleCommand.INSTALL, host1, "cluster1");
- addHostRoleExecutionCommand(now, stage, Role.GANGLIA_MONITOR, Service.Type.GANGLIA,
+ addHostRoleExecutionCommand(now, stage, Role.GANGLIA_MONITOR, "core", Service.Type.GANGLIA,
RoleCommand.INSTALL, host1, "cluster1");
- addHostRoleExecutionCommand(now, stage, Role.HBASE_CLIENT, Service.Type.HBASE,
+ addHostRoleExecutionCommand(now, stage, Role.HBASE_CLIENT, "core", Service.Type.HBASE,
RoleCommand.INSTALL, host2, "cluster1");
- addHostRoleExecutionCommand(now, stage, Role.GANGLIA_MONITOR, Service.Type.GANGLIA,
+ addHostRoleExecutionCommand(now, stage, Role.GANGLIA_MONITOR, "core", Service.Type.GANGLIA,
RoleCommand.INSTALL, host2, "cluster1");
final List<Stage> stages = Collections.singletonList(stage);
@@ -1806,11 +1806,11 @@ public class TestActionScheduler {
}
}
- private void addHostRoleExecutionCommand(long now, Stage stage, Role role, Service.Type service,
+ private void addHostRoleExecutionCommand(long now, Stage stage, Role role, String serviceGroup, Service.Type service,
RoleCommand command, String host, String cluster) {
stage.addHostRoleExecutionCommand(host, role, command,
new ServiceComponentHostInstallEvent(role.toString(), host, now, "HDP-0.2"),
- cluster, service.toString(), false, false);
+ cluster, serviceGroup, service.toString(), false, false);
stage.getExecutionCommandWrapper(host,
role.toString()).getExecutionCommand();
}
@@ -1839,19 +1839,19 @@ public class TestActionScheduler {
stage.setStageId(1);
stage.addHostRoleExecutionCommand("host1", Role.DATANODE, RoleCommand.UPGRADE,
new ServiceComponentHostUpgradeEvent(Role.DATANODE.toString(), "host1", now, "HDP-0.2"),
- "cluster1", Service.Type.HDFS.toString(), false, false);
+ "cluster1", "core", Service.Type.HDFS.toString(), false, false);
stage.getExecutionCommandWrapper("host1",
Role.DATANODE.toString()).getExecutionCommand();
stage.addHostRoleExecutionCommand("host2", Role.DATANODE, RoleCommand.UPGRADE,
new ServiceComponentHostUpgradeEvent(Role.DATANODE.toString(), "host2", now, "HDP-0.2"),
- "cluster1", Service.Type.HDFS.toString(), false, false);
+ "cluster1", "core", Service.Type.HDFS.toString(), false, false);
stage.getExecutionCommandWrapper("host2",
Role.DATANODE.toString()).getExecutionCommand();
stage.addHostRoleExecutionCommand("host3", Role.DATANODE, RoleCommand.UPGRADE,
new ServiceComponentHostUpgradeEvent(Role.DATANODE.toString(), "host3", now, "HDP-0.2"),
- "cluster1", Service.Type.HDFS.toString(), false, false);
+ "cluster1", "core", Service.Type.HDFS.toString(), false, false);
stage.getExecutionCommandWrapper("host3",
Role.DATANODE.toString()).getExecutionCommand();
@@ -1864,7 +1864,7 @@ public class TestActionScheduler {
stages.add(
getStageWithSingleTask(
- "host1", "cluster1", Role.HDFS_CLIENT, RoleCommand.UPGRADE, Service.Type.HDFS, 4, 2, 1));
+ "host1", "cluster1", Role.HDFS_CLIENT, RoleCommand.UPGRADE, "core", Service.Type.HDFS, 4, 2, 1));
ActionDBAccessor db = mock(ActionDBAccessor.class);
HostRoleCommandDAO hostRoleCommandDAOMock = mock(HostRoleCommandDAO.class);
@@ -1992,10 +1992,10 @@ public class TestActionScheduler {
}
private Stage addTask(Stage stage, String hostname, String clusterName, Role role,
- RoleCommand roleCommand, String serviceName, int taskId) {
+ RoleCommand roleCommand, String serviceGroupName, String serviceName, int taskId) {
stage.addHostRoleExecutionCommand(hostname, role, roleCommand,
new ServiceComponentHostUpgradeEvent(role.toString(), hostname, System.currentTimeMillis(), "HDP-0.2"),
- clusterName, serviceName, false, false);
+ clusterName, serviceGroupName, serviceName, false, false);
stage.getExecutionCommandWrapper(hostname,
role.toString()).getExecutionCommand();
stage.getOrderedHostRoleCommands().get(0).setTaskId(taskId);
@@ -2003,16 +2003,16 @@ public class TestActionScheduler {
}
private Stage getStageWithSingleTask(String hostname, String clusterName, Role role,
- RoleCommand roleCommand, Service.Type service, int taskId,
+ RoleCommand roleCommand, String serviceGroupName, Service.Type service, int taskId,
int stageId, int requestId) {
Stage stage = createStage(clusterName, stageId, requestId);
- return addTask(stage, hostname, clusterName, role, roleCommand, service.name(), taskId);
+ return addTask(stage, hostname, clusterName, role, roleCommand, serviceGroupName, service.name(), taskId);
}
private Stage getStageWithSingleTask(String hostname, String clusterName, Role role, RoleCommand roleCommand,
- String customCommandName, Service.Type service, int taskId, int stageId, int requestId) {
- Stage stage = getStageWithSingleTask(hostname, clusterName, role, roleCommand, service, taskId, stageId, requestId);
+ String customCommandName, String serviceGroupName, Service.Type service, int taskId, int stageId, int requestId) {
+ Stage stage = getStageWithSingleTask(hostname, clusterName, role, roleCommand, serviceGroupName, service, taskId, stageId, requestId);
HostRoleCommand cmd = stage.getHostRoleCommand(hostname, role.name());
if (cmd != null) {
@@ -2025,12 +2025,12 @@ public class TestActionScheduler {
private void addInstallTaskToStage(Stage stage, String hostname,
String clusterName, Role role,
- RoleCommand roleCommand, Service.Type service,
+ RoleCommand roleCommand, String serviceGroup, Service.Type service,
int taskId) {
stage.addHostRoleExecutionCommand(hostname, role, roleCommand,
new ServiceComponentHostInstallEvent(role.toString(), hostname,
- System.currentTimeMillis(), "HDP-0.2"), clusterName, service.toString(), false, false);
+ System.currentTimeMillis(), "HDP-0.2"), clusterName, serviceGroup, service.toString(), false, false);
ExecutionCommand command = stage.getExecutionCommandWrapper
(hostname, role.toString()).getExecutionCommand();
command.setTaskId(taskId);
@@ -2204,9 +2204,9 @@ public class TestActionScheduler {
Stage stage1 = stageFactory.createNew(1, "/tmp", "cluster1", 1L, "stageWith2Tasks",
"", "");
addInstallTaskToStage(stage1, hostname1, "cluster1", Role.HBASE_MASTER,
- RoleCommand.INSTALL, Service.Type.HBASE, 1);
+ RoleCommand.INSTALL, "core", Service.Type.HBASE, 1);
addInstallTaskToStage(stage1, hostname1, "cluster1", Role.HBASE_REGIONSERVER,
- RoleCommand.INSTALL, Service.Type.HBASE, 2);
+ RoleCommand.INSTALL, "core", Service.Type.HBASE, 2);
final List<Stage> stages = Collections.singletonList(stage1);
ActionDBAccessor db = mock(ActionDBAccessor.class);
@@ -2385,7 +2385,7 @@ public class TestActionScheduler {
int datanodeCmdTaskId = 3;
Stage stageWithTask = getStageWithSingleTask(
- hostname, "cluster1", Role.SECONDARY_NAMENODE, RoleCommand.START,
+ hostname, "cluster1", Role.SECONDARY_NAMENODE, RoleCommand.START, "core",
Service.Type.HDFS, secondaryNamenodeCmdTaskId, 1, (int) requestId);
// complete the first stage
@@ -2393,7 +2393,7 @@ public class TestActionScheduler {
allStages.add(stageWithTask);
stageWithTask = getStageWithSingleTask(
- hostname, "cluster1", Role.NAMENODE, RoleCommand.START,
+ hostname, "cluster1", Role.NAMENODE, RoleCommand.START, "core",
Service.Type.HDFS, namenodeCmdTaskId, 2, (int) requestId);
tasksInProgress.addAll(stageWithTask.getOrderedHostRoleCommands());
@@ -2402,7 +2402,7 @@ public class TestActionScheduler {
allStages.add(stageWithTask);
stageWithTask = getStageWithSingleTask(
- hostname, "cluster1", Role.DATANODE, RoleCommand.START,
+ hostname, "cluster1", Role.DATANODE, RoleCommand.START, "core",
Service.Type.HDFS, datanodeCmdTaskId, 3, (int) requestId);
tasksInProgress.addAll(stageWithTask.getOrderedHostRoleCommands());
@@ -2583,19 +2583,19 @@ public class TestActionScheduler {
int namenodeCmdTaskId = 1;
Stage request1Stage1 = getStageWithSingleTask(hostname1, "cluster1", Role.NAMENODE,
- RoleCommand.START,
+ RoleCommand.START, "core",
Service.Type.HDFS, namenodeCmdTaskId, 1, (int) requestId1);
Stage request1Stage2 = getStageWithSingleTask(hostname1, "cluster1", Role.DATANODE,
- RoleCommand.START,
+ RoleCommand.START, "core",
Service.Type.HDFS, 2, 2, (int) requestId1);
Stage request2Stage1 = getStageWithSingleTask(hostname2, "cluster1", Role.DATANODE,
- RoleCommand.STOP, // Exclusive
+ RoleCommand.STOP, "core",// Exclusive
Service.Type.HDFS, 3, 3, (int) requestId2);
Stage request3Stage1 = getStageWithSingleTask(hostname3, "cluster1", Role.DATANODE,
- RoleCommand.START,
+ RoleCommand.START, "core",
Service.Type.HDFS, 4, 4, (int) requestId3);
firstStageInProgressByRequest.add(request1Stage1);
@@ -2857,13 +2857,13 @@ public class TestActionScheduler {
final List<Stage> stages = new ArrayList<>();
final List<Stage> firstStageInProgress = new ArrayList<>();
stages.add(stage = getStageWithSingleTask(hostname1, "cluster1", Role.NAMENODE,
- RoleCommand.STOP, Service.Type.HDFS, 1, 1, 1));
+ RoleCommand.STOP, "core", Service.Type.HDFS, 1, 1, 1));
addInstallTaskToStage(stage, hostname1, "cluster1", Role.HBASE_MASTER, RoleCommand.INSTALL,
- Service.Type.HBASE, 1);
+ "core", Service.Type.HBASE, 1);
stages.add(stage2 = getStageWithSingleTask(hostname1, "cluster1", Role.DATANODE,
- RoleCommand.STOP, Service.Type.HDFS, 1, 1, 1));
+ RoleCommand.STOP, "core", Service.Type.HDFS, 1, 1, 1));
// !!! this is the test; make the stages skippable so that when their
// commands fail, the entire request is not aborted
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/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 180b273..f4ad41e 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
@@ -62,9 +62,9 @@ public class TestStage {
public void testTaskTimeout() {
Stage s = StageUtils.getATestStage(1, 1, "h1", "{\"host_param\":\"param_value\"}", "{\"stage_param\":\"param_value\"}");
s.addHostRoleExecutionCommand("h1", Role.DATANODE, RoleCommand.INSTALL,
- null, "c1", "HDFS", false, false);
+ null, "c1", "core", "HDFS", false, false);
s.addHostRoleExecutionCommand("h1", Role.HBASE_MASTER, RoleCommand.INSTALL,
- null, "c1", "HBASE", false, false);
+ null, "c1", "core", "HBASE", false, false);
for (ExecutionCommandWrapper wrapper : s.getExecutionCommands("h1")) {
Map<String, String> commandParams = new TreeMap<>();
commandParams.put(ExecutionCommand.KeyNames.COMMAND_TIMEOUT, "600");
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/test/java/org/apache/ambari/server/agent/DummyHeartbeatConstants.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/agent/DummyHeartbeatConstants.java b/ambari-server/src/test/java/org/apache/ambari/server/agent/DummyHeartbeatConstants.java
index 69980dc..ce585b9 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/agent/DummyHeartbeatConstants.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/agent/DummyHeartbeatConstants.java
@@ -40,6 +40,7 @@ public interface DummyHeartbeatConstants {
String HDFS = "HDFS";
String HBASE = "HBASE";
+ String CORE_SERVICE_GROUP = "core";
String DATANODE = Role.DATANODE.name();
String NAMENODE = Role.NAMENODE.name();
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatProcessorTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatProcessorTest.java b/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatProcessorTest.java
index b7b3e46..bc5a50a 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatProcessorTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatProcessorTest.java
@@ -887,11 +887,11 @@ public class HeartbeatProcessorTest {
s.addHostRoleExecutionCommand(DummyHostname1, Role.DATANODE, RoleCommand.UPGRADE,
new ServiceComponentHostUpgradeEvent(Role.DATANODE.toString(),
DummyHostname1, System.currentTimeMillis(), "HDP-1.3.0"),
- DummyCluster, "HDFS", false, false);
+ DummyCluster, "core", "HDFS", false, false);
s.addHostRoleExecutionCommand(DummyHostname1, Role.NAMENODE, RoleCommand.INSTALL,
new ServiceComponentHostInstallEvent(Role.NAMENODE.toString(),
DummyHostname1, System.currentTimeMillis(), "HDP-1.3.0"),
- DummyCluster, "HDFS", false, false);
+ DummyCluster, "core", "HDFS", false, false);
List<Stage> stages = new ArrayList<>();
stages.add(s);
Request request = new Request(stages, "clusterHostInfo", clusters);
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatTestHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatTestHelper.java b/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatTestHelper.java
index 7302896..0b66434 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatTestHelper.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatTestHelper.java
@@ -17,6 +17,7 @@
*/
package org.apache.ambari.server.agent;
+import static org.apache.ambari.server.agent.DummyHeartbeatConstants.CORE_SERVICE_GROUP;
import static org.apache.ambari.server.agent.DummyHeartbeatConstants.DummyCluster;
import static org.apache.ambari.server.agent.DummyHeartbeatConstants.DummyHostname1;
import static org.apache.ambari.server.agent.DummyHeartbeatConstants.DummyOSRelease;
@@ -225,7 +226,7 @@ public class HeartbeatTestHelper {
s.addHostRoleExecutionCommand(DummyHostname1, Role.HBASE_MASTER,
RoleCommand.START,
new ServiceComponentHostStartEvent(Role.HBASE_MASTER.toString(),
- DummyHostname1, System.currentTimeMillis()), DummyCluster, HBASE, false, false);
+ DummyHostname1, System.currentTimeMillis()), DummyCluster, CORE_SERVICE_GROUP, HBASE, false, false);
List<Stage> stages = new ArrayList<>();
stages.add(s);
Request request = new Request(stages, "clusterHostInfo", clusters);
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/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 ba57449..d6fe9c4 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
@@ -865,7 +865,7 @@ public class TestHeartbeatHandler {
s.addHostRoleExecutionCommand(DummyHostname1, Role.DATANODE, RoleCommand.INSTALL,
new ServiceComponentHostInstallEvent(Role.DATANODE.toString(),
DummyHostname1, System.currentTimeMillis(), "HDP-1.3.0"),
- DummyCluster, "HDFS", false, false);
+ DummyCluster, "core", "HDFS", false, false);
List<Stage> stages = new ArrayList<>();
stages.add(s);
Request request = new Request(stages, "clusterHostInfo", clusters);
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/test/java/org/apache/ambari/server/controller/ActionRequestTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/ActionRequestTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/ActionRequestTest.java
index 3ce95cf..52fa7da 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/ActionRequestTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/ActionRequestTest.java
@@ -26,11 +26,12 @@ public class ActionRequestTest {
@Test
public void testBasicGetAndSet() {
ActionRequest adr1 =
- new ActionRequest("a1", "SYSTEM", "fileName", "HDFS", "DATANODE", "Desc1", "Any", "100");
+ new ActionRequest("a1", "SYSTEM", "fileName", "core","HDFS", "DATANODE", "Desc1", "Any", "100");
Assert.assertEquals("a1", adr1.getActionName());
Assert.assertEquals("SYSTEM", adr1.getActionType());
Assert.assertEquals("fileName", adr1.getInputs());
+ Assert.assertEquals("core", adr1.getTargetServiceGroup());
Assert.assertEquals("HDFS", adr1.getTargetService());
Assert.assertEquals("DATANODE", adr1.getTargetComponent());
Assert.assertEquals("Desc1", adr1.getDescription());
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/test/java/org/apache/ambari/server/controller/ActionResponseTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/ActionResponseTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/ActionResponseTest.java
index 371b163..9ce794b 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/ActionResponseTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/ActionResponseTest.java
@@ -25,7 +25,7 @@ public class ActionResponseTest {
@Test
public void testBasicGetAndSet() {
ActionResponse r1 =
- new ActionResponse("a1", "SYSTEM", "fileName", "HDFS", "DATANODE", "Desc1", "Any", "100");
+ new ActionResponse("a1", "SYSTEM", "fileName", "core", "HDFS", "DATANODE", "Desc1", "Any", "100");
Assert.assertEquals("a1", r1.getActionName());
Assert.assertEquals("SYSTEM", r1.getActionType());
@@ -39,7 +39,7 @@ public class ActionResponseTest {
@Test
public void testToString() {
- ActionResponse r = new ActionResponse(null, null, null, null, null, null, null, null);
+ ActionResponse r = new ActionResponse(null, null, null, null, null, null, null, null, null);
r.toString();
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/68c62212/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java
index a3eb3c1..e6ead28 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java
@@ -216,7 +216,7 @@ public class AmbariCustomCommandExecutionHelperTest {
put("forceRefreshConfigTagsBeforeExecution", "true");
}
}, false);
- actionRequest.getResourceFilters().add(new RequestResourceFilter("YARN", "RESOURCEMANAGER", Collections.singletonList("c1-c6401")));
+ actionRequest.getResourceFilters().add(new RequestResourceFilter("CORE", "YARN", "RESOURCEMANAGER", Collections.singletonList("c1-c6401")));
EasyMock.replay(hostRoleCommand, actionManager, configHelper);
@@ -247,6 +247,7 @@ public class AmbariCustomCommandExecutionHelperTest {
{
put("context" , "Restart all components for GANGLIA");
put("operation_level/level", "SERVICE");
+ put("operation_level/service_group_name", "CORE");
put("operation_level/service_name", "GANGLIA");
put("operation_level/cluster_name", "c1");
}
@@ -255,11 +256,11 @@ public class AmbariCustomCommandExecutionHelperTest {
ExecuteActionRequest actionRequest = new ExecuteActionRequest(
"c1", "RESTART", null,
Arrays.asList(
- new RequestResourceFilter("GANGLIA", "GANGLIA_SERVER", Collections.singletonList("c1-c6401")),
- new RequestResourceFilter("GANGLIA", "GANGLIA_MONITOR", Collections.singletonList("c1-c6401")),
- new RequestResourceFilter("GANGLIA", "GANGLIA_MONITOR", Collections.singletonList("c1-c6402"))
+ new RequestResourceFilter("CORE", "GANGLIA", "GANGLIA_SERVER", Collections.singletonList("c1-c6401")),
+ new RequestResourceFilter("CORE", "GANGLIA", "GANGLIA_MONITOR", Collections.singletonList("c1-c6401")),
+ new RequestResourceFilter("CORE", "GANGLIA", "GANGLIA_MONITOR", Collections.singletonList("c1-c6402"))
),
- new RequestOperationLevel(Resource.Type.Service, "c1", "GANGLIA", null, null),
+ new RequestOperationLevel(Resource.Type.Service, "c1", "CORE", "GANGLIA", null, null),
new HashMap<>(), false);
EasyMock.replay(hostRoleCommand, actionManager, configHelper);
@@ -284,6 +285,7 @@ public class AmbariCustomCommandExecutionHelperTest {
{
put("context", "Restart all components for GANGLIA");
put("operation_level/level", "SERVICE");
+ put("operation_level/service_group_name", "CORE");
put("operation_level/service_name", "GANGLIA");
put("operation_level/cluster_name", "c1");
}
@@ -291,10 +293,10 @@ public class AmbariCustomCommandExecutionHelperTest {
ExecuteActionRequest actionRequest = new ExecuteActionRequest("c1", "RESTART", null,
Arrays.asList(
- new RequestResourceFilter("GANGLIA", "GANGLIA_SERVER", Collections.singletonList("c1-c6401")),
- new RequestResourceFilter("GANGLIA", "GANGLIA_MONITOR", Collections.singletonList("c1-c6401")),
- new RequestResourceFilter("GANGLIA", "GANGLIA_MONITOR", Collections.singletonList("c1-c6402"))),
- new RequestOperationLevel(Resource.Type.Service, "c1", "GANGLIA", null, null),
+ new RequestResourceFilter("CORE", "GANGLIA", "GANGLIA_SERVER", Collections.singletonList("c1-c6401")),
+ new RequestResourceFilter("CORE", "GANGLIA", "GANGLIA_MONITOR", Collections.singletonList("c1-c6401")),
+ new RequestResourceFilter("CORE", "GANGLIA", "GANGLIA_MONITOR", Collections.singletonList("c1-c6402"))),
+ new RequestOperationLevel(Resource.Type.Service, "c1", "CORE", "GANGLIA", null, null),
new HashMap<>(), false);
EasyMock.replay(hostRoleCommand, actionManager, configHelper);
@@ -321,6 +323,7 @@ public class AmbariCustomCommandExecutionHelperTest {
{
put("context", "Restart all components for GANGLIA");
put("operation_level/level", "SERVICE");
+ put("operation_level/service_group_name", "CORE");
put("operation_level/service_name", "GANGLIA");
put("operation_level/cluster_name", "c1");
}
@@ -328,10 +331,10 @@ public class AmbariCustomCommandExecutionHelperTest {
ExecuteActionRequest actionRequest = new ExecuteActionRequest("c1", "RESTART", null,
Arrays.asList(
- new RequestResourceFilter("GANGLIA", "GANGLIA_SERVER", Collections.singletonList("c1-c6401")),
- new RequestResourceFilter("GANGLIA", "GANGLIA_MONITOR", Collections.singletonList("c1-c6401")),
- new RequestResourceFilter("GANGLIA", "GANGLIA_MONITOR", Collections.singletonList("c1-c6402"))),
- new RequestOperationLevel(Resource.Type.Host, "c1", "GANGLIA", null, null),
+ new RequestResourceFilter("CORE", "GANGLIA", "GANGLIA_SERVER", Collections.singletonList("c1-c6401")),
+ new RequestResourceFilter("CORE", "GANGLIA", "GANGLIA_MONITOR", Collections.singletonList("c1-c6401")),
+ new RequestResourceFilter("CORE", "GANGLIA", "GANGLIA_MONITOR", Collections.singletonList("c1-c6402"))),
+ new RequestOperationLevel(Resource.Type.Host, "c1", "CORE", "GANGLIA", null, null),
new HashMap<>(), false);
EasyMock.replay(hostRoleCommand, actionManager, configHelper);
@@ -366,6 +369,7 @@ public class AmbariCustomCommandExecutionHelperTest {
{
put("context", "Service Check ZooKeeper");
put("operation_level/level", "SERVICE");
+ put("operation_level/service_group_name", "CORE");
put("operation_level/service_name", "ZOOKEEPER");
put("operation_level/cluster_name", "c1");
}
@@ -374,10 +378,10 @@ public class AmbariCustomCommandExecutionHelperTest {
// create the service check on the host in MM
ExecuteActionRequest actionRequest = new ExecuteActionRequest("c1",
"ZOOKEEPER_QUORUM_SERVICE_CHECK",
- null, Collections.singletonList(new RequestResourceFilter("ZOOKEEPER", "ZOOKEEPER_CLIENT",
+ null, Collections.singletonList(new RequestResourceFilter("CORE", "ZOOKEEPER", "ZOOKEEPER_CLIENT",
Collections.singletonList("c6402"))),
- new RequestOperationLevel(Resource.Type.Service, "c1", "ZOOKEEPER", null, null),
+ new RequestOperationLevel(Resource.Type.Service, "c1", "CORE", "ZOOKEEPER", null, null),
new HashMap<>(), false);
EasyMock.replay(hostRoleCommand, actionManager, configHelper);
@@ -414,10 +418,10 @@ public class AmbariCustomCommandExecutionHelperTest {
// create the service check on the host in MM, passing in null for the
// component name
ExecuteActionRequest actionRequest = new ExecuteActionRequest("c1",
- "ZOOKEEPER_QUORUM_SERVICE_CHECK", null, Collections.singletonList(new RequestResourceFilter("ZOOKEEPER", null,
+ "ZOOKEEPER_QUORUM_SERVICE_CHECK", null, Collections.singletonList(new RequestResourceFilter("CORE", "ZOOKEEPER", null,
Collections.singletonList("c6402"))),
- new RequestOperationLevel(Resource.Type.Service, "c1", "ZOOKEEPER", null, null),
+ new RequestOperationLevel(Resource.Type.Service, "c1", "CORE", "ZOOKEEPER", null, null),
new HashMap<>(), false);
EasyMock.replay(hostRoleCommand, actionManager, configHelper);
@@ -431,7 +435,7 @@ public class AmbariCustomCommandExecutionHelperTest {
AmbariCustomCommandExecutionHelper ambariCustomCommandExecutionHelper = injector.getInstance(AmbariCustomCommandExecutionHelper.class);
List<RequestResourceFilter> requestResourceFilter = new ArrayList<RequestResourceFilter>() {{
- add(new RequestResourceFilter("FLUME", null, null));
+ add(new RequestResourceFilter("CORE", "FLUME", null, null));
}};
ActionExecutionContext actionExecutionContext = new ActionExecutionContext("c1", "SERVICE_CHECK", requestResourceFilter);
Stage stage = EasyMock.niceMock(Stage.class);
@@ -452,7 +456,7 @@ public class AmbariCustomCommandExecutionHelperTest {
// There are multiple hosts with ZK Client.
List<RequestResourceFilter> requestResourceFilter = new ArrayList<RequestResourceFilter>() {{
- add(new RequestResourceFilter("ZOOKEEPER", "ZOOKEEPER_CLIENT", Arrays.asList(new String[]{"c1-c6401"})));
+ add(new RequestResourceFilter("CORE", "ZOOKEEPER", "ZOOKEEPER_CLIENT", Arrays.asList(new String[]{"c1-c6401"})));
}};
ActionExecutionContext actionExecutionContext = new ActionExecutionContext("c1", "SERVICE_CHECK", requestResourceFilter);
Stage stage = EasyMock.niceMock(Stage.class);
@@ -503,7 +507,7 @@ public class AmbariCustomCommandExecutionHelperTest {
// There are multiple hosts with ZK Client.
List<RequestResourceFilter> requestResourceFilter = new ArrayList<RequestResourceFilter>() {{
- add(new RequestResourceFilter("ZOOKEEPER", "ZOOKEEPER_CLIENT", null));
+ add(new RequestResourceFilter("CORE", "ZOOKEEPER", "ZOOKEEPER_CLIENT", null));
}};
ActionExecutionContext actionExecutionContext = new ActionExecutionContext("c1", "SERVICE_CHECK", requestResourceFilter);
Stage stage = EasyMock.niceMock(Stage.class);
@@ -530,9 +534,9 @@ public class AmbariCustomCommandExecutionHelperTest {
createClusterFixture("c2", new StackId("HDP-2.1.1"), "2.1.1.0-1234", "c2");
- Assert.assertTrue(helper.isTopologyRefreshRequired("START", "c2", "HDFS"));
- Assert.assertTrue(helper.isTopologyRefreshRequired("RESTART", "c2", "HDFS"));
- Assert.assertFalse(helper.isTopologyRefreshRequired("STOP", "c2", "HDFS"));
+ Assert.assertTrue(helper.isTopologyRefreshRequired("START", "c2", "CORE", "HDFS"));
+ Assert.assertTrue(helper.isTopologyRefreshRequired("RESTART", "c2", "CORE", "HDFS"));
+ Assert.assertFalse(helper.isTopologyRefreshRequired("STOP", "c2", "CORE", "HDFS"));
}
@Test
@@ -550,7 +554,7 @@ public class AmbariCustomCommandExecutionHelperTest {
put("forceRefreshConfigTags", "capacity-scheduler");
}
}, false);
- actionRequest.getResourceFilters().add(new RequestResourceFilter("YARN", "RESOURCEMANAGER", Collections.singletonList("c1-c6401")));
+ actionRequest.getResourceFilters().add(new RequestResourceFilter("CORE", "YARN", "RESOURCEMANAGER", Collections.singletonList("c1-c6401")));
EasyMock.replay(hostRoleCommand, actionManager, configHelper);
ambariManagementController.createAction(actionRequest, requestProperties);