AmbariCustomCommandExecutionHelper { private ServiceComponent getServiceComponent ( ActionExecutionContext actionExecutionContext, RequestResourceFilter resourceFilter){ try { Cluster cluster = clusters.getCluster(actionExecutionContext.getClusterName()); Service service = cluster.getService(resourceFilter.getServiceName()); return service.getServiceComponent(resourceFilter.getComponentName()); } catch (Exception e) { LOG.debug(String.format( "Unknown error appears during getting service component: %s", e.getMessage())); } return null; }  void addServiceCheckAction(Stage stage, String hostname, String smokeTestRole,
      long nowTimestamp, String serviceName, String componentName,
      Map<String, String> actionParameters, boolean retryAllowed, boolean autoSkipFailure); void validateAction(ExecuteActionRequest actionRequest); void addExecutionCommandsToStage(ActionExecutionContext actionExecutionContext,
      Stage stage, Map<String, String> requestParams); String getRepoInfo(Cluster cluster, Host host); String getRepoInfo(Cluster cluster, String hostOSType, String hostOSFamily, String hostName); ExecuteCommandJson getCommandJson(ActionExecutionContext actionExecContext,
      Cluster cluster, StackId stackId); boolean isTopologyRefreshRequired(String actionName, String clusterName, String serviceName); static final Map<String, String> masterToSlaveMappingForDecom; final static String DECOM_INCLUDED_HOSTS; final static String DECOM_EXCLUDED_HOSTS; final static String DECOM_SLAVE_COMPONENT; final static String HBASE_MARK_DRAINING_ONLY; final static String UPDATE_EXCLUDE_FILE_ONLY; final static int MIN_STRICT_SERVICE_CHECK_TIMEOUT; static final String DECOMMISSION_COMMAND_NAME; }
@Test public void testHostsFilterUnhealthyComponent() throws Exception { clusters.getCluster("c1").getService("GANGLIA").getServiceComponent( "GANGLIA_MONITOR").getServiceComponentHost("c1-c6402").setState(State.UNKNOWN); Map<String, String> requestProperties = new HashMap<String, String>() { { put("context", "Restart all components for GANGLIA"); put("operation_level/level", "SERVICE"); put("operation_level/service_name", "GANGLIA"); put("operation_level/cluster_name", "c1"); } }; 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 HashMap<String, String>(), false); EasyMock.replay(hostRoleCommand, actionManager, configHelper); ambariManagementController.createAction(actionRequest, requestProperties); Request request = requestCapture.getValue(); Assert.assertNotNull(request); Assert.assertNotNull(request.getStages()); Assert.assertEquals(1, request.getStages().size()); Stage stage = request.getStages().iterator().next(); Assert.assertEquals(1, stage.getHostRoleCommands().size()); }