Map<String, Object> installProperties = new HashMap<String, Object>();
installProperties.put(SERVICE_SERVICE_STATE_PROPERTY_ID, "INSTALLED");
Map<String, String> requestInfo = new HashMap<String, String>();
requestInfo.put("context", "Install and start all services");
Request installRequest = new RequestImpl(null, Collections.singleton(installProperties), requestInfo, null);
Predicate statePredicate = new EqualsPredicate<String>(SERVICE_SERVICE_STATE_PROPERTY_ID, "INIT");
Predicate clusterPredicate = new EqualsPredicate<String>(SERVICE_CLUSTER_NAME_PROPERTY_ID, clusterName);
Predicate installPredicate = new AndPredicate(statePredicate, clusterPredicate);
final Request startRequest;
Predicate startPredicate;
try {
LOG.info("Installing all services");
requestStages = doUpdateResources(null, installRequest, installPredicate);
notifyUpdate(Resource.Type.Service, installRequest, installPredicate);
Map<String, Object> startProperties = new HashMap<String, Object>();
startProperties.put(SERVICE_SERVICE_STATE_PROPERTY_ID, "STARTED");
startRequest = new RequestImpl(null, Collections.singleton(startProperties), requestInfo, null);
Predicate installedStatePredicate = new EqualsPredicate<String>(SERVICE_SERVICE_STATE_PROPERTY_ID, "INSTALLED");
Predicate serviceClusterPredicate = new EqualsPredicate<String>(SERVICE_CLUSTER_NAME_PROPERTY_ID, clusterName);
startPredicate = new AndPredicate(installedStatePredicate, serviceClusterPredicate);
LOG.info("Starting all services");
doUpdateResources(requestStages, startRequest, startPredicate);
notifyUpdate(Resource.Type.Service, startRequest, startPredicate);