You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2014/10/08 00:52:31 UTC
[03/51] [partial] AMBARI-7621. Import initial contribution for Ambari
support on Windows to branch-windows-dev. (Jayush Luniya and Florian Barca
via yusaku)
http://git-wip-us.apache.org/repos/asf/ambari/blob/7e28d1e3/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestStageContainer.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestStageContainer.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestStageContainer.java
index 512ea14..e8b9adf 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestStageContainer.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestStageContainer.java
@@ -18,7 +18,6 @@
package org.apache.ambari.server.controller.internal;
-import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.RoleCommand;
import org.apache.ambari.server.actionmanager.ActionManager;
import org.apache.ambari.server.actionmanager.HostRoleCommand;
@@ -170,7 +169,7 @@ public class RequestStageContainer {
/**
* Persist the stages.
*/
- public void persist() throws AmbariException {
+ public void persist() {
if (!stages.isEmpty()) {
Request request = requestFactory.createNewFromStages(stages);
if (request != null && request.getStages()!= null && !request.getStages().isEmpty()) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/7e28d1e3/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ResourceImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ResourceImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ResourceImpl.java
index 6f963c9..15fb961 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ResourceImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ResourceImpl.java
@@ -21,8 +21,10 @@ package org.apache.ambari.server.controller.internal;
import org.apache.ambari.server.controller.spi.Resource;
import org.apache.ambari.server.controller.utilities.PropertyHelper;
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
/**
* Simple resource implementation.
@@ -37,15 +39,14 @@ public class ResourceImpl implements Resource {
/**
* The map of property maps keyed by property category.
*/
- private final Map<String, Map<String, Object>> propertiesMap =
- Collections.synchronizedMap(new TreeMap<String, Map<String, Object>>());
+ private final Map<String, Map<String, Object>> propertiesMap = new TreeMap<String, Map<String, Object>>();
// ----- Constructors ------------------------------------------------------
/**
* Create a resource of the given type.
*
- * @param type the resource type
+ * @param type the resource type
*/
public ResourceImpl(Type type) {
this.type = type;
@@ -54,7 +55,7 @@ public class ResourceImpl implements Resource {
/**
* Copy constructor
*
- * @param resource the resource to copy
+ * @param resource the resource to copy
*/
public ResourceImpl(Resource resource) {
this(resource, null);
@@ -64,8 +65,8 @@ public class ResourceImpl implements Resource {
* Construct a resource from the given resource, setting only the properties
* that are found in the given set of property and category ids.
*
- * @param resource the resource to copy
- * @param propertyIds the set of requested property and category ids
+ * @param resource the resource to copy
+ * @param propertyIds the set of requested property and category ids
*/
public ResourceImpl(Resource resource, Set<String> propertyIds) {
this.type = resource.getType();
@@ -105,7 +106,7 @@ public class ResourceImpl implements Resource {
Map<String, Object> properties = propertiesMap.get(categoryKey);
if (properties == null) {
- properties = Collections.synchronizedMap(new TreeMap<String, Object>());
+ properties = new TreeMap<String, Object>();
propertiesMap.put(categoryKey, properties);
}
properties.put(PropertyHelper.getPropertyName(id), value);
http://git-wip-us.apache.org/repos/asf/ambari/blob/7e28d1e3/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceConfigVersionResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceConfigVersionResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceConfigVersionResourceProvider.java
deleted file mode 100644
index f055375..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceConfigVersionResourceProvider.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ambari.server.controller.internal;
-
-
-import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.controller.AmbariManagementController;
-import org.apache.ambari.server.controller.ConfigurationResponse;
-import org.apache.ambari.server.controller.ServiceConfigVersionRequest;
-import org.apache.ambari.server.controller.ServiceConfigVersionResponse;
-import org.apache.ambari.server.controller.spi.*;
-import org.apache.ambari.server.controller.utilities.PropertyHelper;
-
-import java.util.*;
-
-public class ServiceConfigVersionResourceProvider extends
- AbstractControllerResourceProvider {
- public static final String SERVICE_CONFIG_VERSION_CLUSTER_NAME_PROPERTY_ID = PropertyHelper.getPropertyId(null, "cluster_name");
- public static final String SERVICE_CONFIG_VERSION_PROPERTY_ID = PropertyHelper.getPropertyId(null, "service_config_version");
- public static final String SERVICE_CONFIG_VERSION_SERVICE_NAME_PROPERTY_ID = PropertyHelper.getPropertyId(null, "service_name");
- public static final String SERVICE_CONFIG_VERSION_CREATE_TIME_PROPERTY_ID = PropertyHelper.getPropertyId(null, "createtime");
- public static final String SERVICE_CONFIG_VERSION_USER_PROPERTY_ID = PropertyHelper.getPropertyId(null, "user");
- public static final String SERVICE_CONFIG_VERSION_NOTE_PROPERTY_ID = PropertyHelper.getPropertyId(null, "service_config_version_note");
- public static final String SERVICE_CONFIG_VERSION_GROUP_ID_PROPERTY_ID = PropertyHelper.getPropertyId(null, "group_id");
- public static final String SERVICE_CONFIG_VERSION_GROUP_NAME_PROPERTY_ID = PropertyHelper.getPropertyId(null, "group_name");
- public static final String SERVICE_CONFIG_VERSION_IS_CURRENT_PROPERTY_ID = PropertyHelper.getPropertyId(null, "is_current");
- public static final String SERVICE_CONFIG_VERSION_HOSTS_PROPERTY_ID = PropertyHelper.getPropertyId(null, "hosts");
- public static final String SERVICE_CONFIG_VERSION_CONFIGURATIONS_PROPERTY_ID = PropertyHelper.getPropertyId(null, "configurations");
-
- /**
- * The primary key property ids for the service config version resource type.
- */
- private static Set<String> pkPropertyIds =
- new HashSet<String>(Arrays.asList(new String[]{
- SERVICE_CONFIG_VERSION_CLUSTER_NAME_PROPERTY_ID,
- SERVICE_CONFIG_VERSION_SERVICE_NAME_PROPERTY_ID}));
-
-
- // ----- Constructors ------------------------------------------------------
-
- /**
- * Constructor
- *
- * @param propertyIds the property ids supported by this provider
- * @param keyPropertyIds the key properties for this provider
- * @param managementController the associated management controller
- */
- ServiceConfigVersionResourceProvider(Set<String> propertyIds,
- Map<Resource.Type, String> keyPropertyIds,
- AmbariManagementController managementController) {
-
- super(propertyIds, keyPropertyIds, managementController);
- }
-
-
- @Override
- protected Set<String> getPKPropertyIds() {
- return pkPropertyIds;
- }
-
- @Override
- public RequestStatus createResources(Request request) throws SystemException, UnsupportedPropertyException, ResourceAlreadyExistsException, NoSuchParentResourceException {
- throw new UnsupportedOperationException("Cannot explicitly create service config version");
- }
-
- @Override
- public Set<Resource> getResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
- final Set<ServiceConfigVersionRequest> requests = new HashSet<ServiceConfigVersionRequest>();
- for (Map<String, Object> properties : getPropertyMaps(predicate)) {
- requests.add(createRequest(properties));
- }
-
- Set<ServiceConfigVersionResponse> responses = getResources(new Command<Set<ServiceConfigVersionResponse>>() {
- @Override
- public Set<ServiceConfigVersionResponse> invoke() throws AmbariException {
- return getManagementController().getServiceConfigVersions(requests);
- }
- });
-
- Set<Resource> resources = new HashSet<Resource>();
- for (ServiceConfigVersionResponse response : responses) {
- Resource resource = new ResourceImpl(Resource.Type.ServiceConfigVersion);
- resource.setProperty(SERVICE_CONFIG_VERSION_CLUSTER_NAME_PROPERTY_ID, response.getClusterName());
- resource.setProperty(SERVICE_CONFIG_VERSION_SERVICE_NAME_PROPERTY_ID, response.getServiceName());
- resource.setProperty(SERVICE_CONFIG_VERSION_USER_PROPERTY_ID, response.getUserName());
- resource.setProperty(SERVICE_CONFIG_VERSION_PROPERTY_ID, response.getVersion());
- resource.setProperty(SERVICE_CONFIG_VERSION_CREATE_TIME_PROPERTY_ID, response.getCreateTime());
- resource.setProperty(SERVICE_CONFIG_VERSION_CONFIGURATIONS_PROPERTY_ID,
- convertToSubResources(response.getClusterName(), response.getConfigurations()));
- resource.setProperty(SERVICE_CONFIG_VERSION_NOTE_PROPERTY_ID, response.getNote());
- resource.setProperty(SERVICE_CONFIG_VERSION_GROUP_ID_PROPERTY_ID, response.getGroupId());
- resource.setProperty(SERVICE_CONFIG_VERSION_GROUP_NAME_PROPERTY_ID, response.getGroupName());
- resource.setProperty(SERVICE_CONFIG_VERSION_HOSTS_PROPERTY_ID, response.getHosts());
- resource.setProperty(SERVICE_CONFIG_VERSION_IS_CURRENT_PROPERTY_ID, response.getIsCurrent());
-
- resources.add(resource);
- }
- return resources;
- }
-
- @Override
- public RequestStatus updateResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
- throw new UnsupportedOperationException("Cannot update service config version");
- }
-
- @Override
- public RequestStatus deleteResources(Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
- throw new UnsupportedOperationException("Cannot delete service config version");
- }
-
- @Override
- public Set<String> checkPropertyIds(Set<String> propertyIds) {
- propertyIds = super.checkPropertyIds(propertyIds);
-
- if (propertyIds.isEmpty()) {
- return propertyIds;
- }
- Set<String> unsupportedProperties = new HashSet<String>();
-
- for (String propertyId : propertyIds) {
-
- if (!propertyId.equals("cluster_name") && !propertyId.equals("service_config_version") &&
- !propertyId.equals("service_name") && !propertyId.equals("createtime") &&
- !propertyId.equals("appliedtime") && !propertyId.equals("user") &&
- !propertyId.equals("service_config_version_note") &&
- !propertyId.equals("group_id") &&
- !propertyId.equals("group_name") &&
- !propertyId.equals("is_current") &&
- !propertyId.equals("hosts")) {
-
- unsupportedProperties.add(propertyId);
-
- }
- }
- return unsupportedProperties;
- }
-
-
- private ServiceConfigVersionRequest createRequest(Map<String, Object> properties) {
- String clusterName = (String) properties.get(SERVICE_CONFIG_VERSION_CLUSTER_NAME_PROPERTY_ID);
- String serviceName = (String) properties.get(SERVICE_CONFIG_VERSION_SERVICE_NAME_PROPERTY_ID);
- String user = (String) properties.get(SERVICE_CONFIG_VERSION_USER_PROPERTY_ID);
- Object versionObject = properties.get(SERVICE_CONFIG_VERSION_PROPERTY_ID);
- Long version = versionObject == null ? null : Long.valueOf(versionObject.toString());
-
- return new ServiceConfigVersionRequest(clusterName, serviceName, version, null, null, user);
- }
-
- private List<Map<String, Object>> convertToSubResources(final String clusterName, List<ConfigurationResponse> configs) {
- List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
- for (final ConfigurationResponse config : configs) {
- Map<String, Object> configMap = new LinkedHashMap<String, Object>();
- configMap.put("Config", new HashMap<String, String>(){{put("cluster_name", clusterName);}});
- configMap.put("type", config.getType());
- configMap.put("tag", config.getVersionTag());
- configMap.put("version", config.getVersion());
- configMap.put("properties", new TreeMap(config.getConfigs()));
- configMap.put("properties_attributes", config.getConfigAttributes());
- result.add(configMap);
- }
-
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/7e28d1e3/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java
index 31c6c37..21dcdc8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java
@@ -21,7 +21,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import java.util.EnumMap;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
@@ -30,12 +29,13 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import com.google.inject.Inject;
+
import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.ClusterNotFoundException;
import org.apache.ambari.server.DuplicateResourceException;
import org.apache.ambari.server.ObjectNotFoundException;
import org.apache.ambari.server.ParentObjectNotFoundException;
-import org.apache.ambari.server.RoleCommand;
import org.apache.ambari.server.ServiceNotFoundException;
import org.apache.ambari.server.api.services.AmbariMetaInfo;
import org.apache.ambari.server.controller.AmbariManagementController;
@@ -57,10 +57,10 @@ import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException;
import org.apache.ambari.server.controller.spi.SystemException;
import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
import org.apache.ambari.server.controller.utilities.PropertyHelper;
-import org.apache.ambari.server.metadata.RoleCommandOrder;
import org.apache.ambari.server.state.Cluster;
import org.apache.ambari.server.state.Clusters;
import org.apache.ambari.server.state.ComponentInfo;
+import org.apache.ambari.server.state.Host;
import org.apache.ambari.server.state.MaintenanceState;
import org.apache.ambari.server.state.Service;
import org.apache.ambari.server.state.ServiceComponent;
@@ -95,9 +95,6 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider
private static final String QUERY_PARAMETERS_RECONFIGURE_CLIENT =
"params/reconfigure_client";
- private static final String QUERY_PARAMETERS_START_DEPENDENCIES =
- "params/start_dependencies";
-
private static Set<String> pkPropertyIds =
new HashSet<String>(Arrays.asList(new String[]{
SERVICE_CLUSTER_NAME_PROPERTY_ID,
@@ -203,11 +200,7 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider
RequestStatusResponse response = null;
if (requestStages != null) {
- try {
- requestStages.persist();
- } catch (AmbariException e) {
- throw new SystemException(e.getMessage(), e);
- }
+ requestStages.persist();
response = requestStages.getRequestStatusResponse();
}
notifyUpdate(Resource.Type.Service, request, predicate);
@@ -295,11 +288,7 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider
LOG.info("Starting all services");
doUpdateResources(requestStages, startRequest, startPredicate);
notifyUpdate(Resource.Type.Service, startRequest, startPredicate);
- try {
- requestStages.persist();
- } catch (AmbariException e) {
- throw new SystemException(e.getMessage(), e);
- }
+ requestStages.persist();
return requestStages.getRequestStatusResponse();
} catch (NoSuchResourceException e) {
@@ -328,14 +317,11 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider
final boolean reconfigureClients = !"false".equals(getQueryParameterValue(
QUERY_PARAMETERS_RECONFIGURE_CLIENT, predicate));
- final boolean startDependencies = "true".equals(getQueryParameterValue(
- QUERY_PARAMETERS_START_DEPENDENCIES, predicate));
-
requestStages = modifyResources(new Command<RequestStageContainer>() {
@Override
public RequestStageContainer invoke() throws AmbariException {
return updateServices(stages, requests, request.getRequestInfoProperties(),
- runSmokeTest, reconfigureClients, startDependencies);
+ runSmokeTest, reconfigureClients);
}
});
}
@@ -561,7 +547,7 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider
// Update services based on the given requests.
protected synchronized RequestStageContainer updateServices(RequestStageContainer requestStages, Set<ServiceRequest> requests,
Map<String, String> requestProperties, boolean runSmokeTest,
- boolean reconfigureClients, boolean startDependencies) throws AmbariException {
+ boolean reconfigureClients) throws AmbariException {
AmbariManagementController controller = getManagementController();
@@ -571,9 +557,9 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider
}
Map<State, List<Service>> changedServices
- = new EnumMap<State, List<Service>>(State.class);
+ = new HashMap<State, List<Service>>();
Map<State, List<ServiceComponent>> changedComps =
- new EnumMap<State, List<ServiceComponent>>(State.class);
+ new HashMap<State, List<ServiceComponent>>();
Map<String, Map<State, List<ServiceComponentHost>>> changedScHosts =
new HashMap<String, Map<State, List<ServiceComponentHost>>>();
Collection<ServiceComponentHost> ignoredScHosts =
@@ -597,10 +583,8 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider
}
Clusters clusters = controller.getClusters();
-
- // We don't expect batch requests for different clusters, that's why
- // nothing bad should happen if value is overwritten few times
- String maintenanceCluster = null;
+ AmbariMetaInfo ambariMetaInfo = controller.getAmbariMetaInfo();
+ Set<String> maintenanceClusters = new HashSet<String>();
for (ServiceRequest request : requests) {
if (request.getClusterName() == null
@@ -656,7 +640,8 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider
"maintenance state to one of " + EnumSet.of(MaintenanceState.OFF, MaintenanceState.ON));
} else {
s.setMaintenanceState(newMaint);
- maintenanceCluster = cluster.getClusterName();
+
+ maintenanceClusters.add(cluster.getClusterName());
}
}
}
@@ -699,27 +684,128 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider
// TODO should we check whether all servicecomponents and
// servicecomponenthosts are in the required desired state?
- updateServiceComponents(requestStages, changedComps, changedScHosts,
- ignoredScHosts, reqOpLvl, s, newState);
- }
+ for (ServiceComponent sc : s.getServiceComponents().values()) {
+ State oldScState = sc.getDesiredState();
+ if (newState != oldScState) {
+ if (sc.isClientComponent() &&
+ !newState.isValidClientComponentState()) {
+ continue;
+ }
+ if (!State.isValidDesiredStateTransition(oldScState, newState)) {
+ throw new AmbariException("Invalid transition for"
+ + " servicecomponent"
+ + ", clusterName=" + cluster.getClusterName()
+ + ", clusterId=" + cluster.getClusterId()
+ + ", serviceName=" + sc.getServiceName()
+ + ", componentName=" + sc.getName()
+ + ", currentDesiredState=" + oldScState
+ + ", newDesiredState=" + newState);
+ }
+ if (!changedComps.containsKey(newState)) {
+ changedComps.put(newState, new ArrayList<ServiceComponent>());
+ }
+ changedComps.get(newState).add(sc);
+ }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Handling update to ServiceComponent"
+ + ", clusterName=" + request.getClusterName()
+ + ", serviceName=" + s.getName()
+ + ", componentName=" + sc.getName()
+ + ", currentDesiredState=" + oldScState
+ + ", newDesiredState=" + newState);
+ }
- if (startDependencies && changedServices.containsKey(State.STARTED)) {
- HashSet<Service> depServices = new HashSet<Service>();
- for (Service service : changedServices.get(State.STARTED)) {
- RoleCommandOrder rco = controller.getRoleCommandOrder(service.getCluster());
- Set<Service> dependencies = rco.getTransitiveServices(service, RoleCommand.START);
- for (Service dependency: dependencies) {
- if (!changedServices.get(State.STARTED).contains(dependency)){
- depServices.add(dependency);
+ for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
+ State oldSchState = sch.getState();
+ if (oldSchState == State.DISABLED || oldSchState == State.UNKNOWN) {
+ //Ignore host components updates in this state
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Ignoring ServiceComponentHost"
+ + ", clusterName=" + request.getClusterName()
+ + ", serviceName=" + s.getName()
+ + ", componentName=" + sc.getName()
+ + ", hostname=" + sch.getHostName()
+ + ", currentState=" + oldSchState
+ + ", newDesiredState=" + newState);
+ }
+ continue;
+ }
+
+ if (newState == oldSchState) {
+ ignoredScHosts.add(sch);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Ignoring ServiceComponentHost"
+ + ", clusterName=" + request.getClusterName()
+ + ", serviceName=" + s.getName()
+ + ", componentName=" + sc.getName()
+ + ", hostname=" + sch.getHostName()
+ + ", currentState=" + oldSchState
+ + ", newDesiredState=" + newState);
+ }
+ continue;
}
+
+ if (! maintenanceStateHelper.isOperationAllowed(reqOpLvl, sch)) {
+ ignoredScHosts.add(sch);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Ignoring ServiceComponentHost"
+ + ", clusterName=" + request.getClusterName()
+ + ", serviceName=" + s.getName()
+ + ", componentName=" + sc.getName()
+ + ", hostname=" + sch.getHostName());
+ }
+ continue;
+ }
+
+ if (sc.isClientComponent() &&
+ !newState.isValidClientComponentState()) {
+ continue;
+ }
+ /**
+ * This is hack for now wherein we don't fail if the
+ * sch is in INSTALL_FAILED
+ */
+ if (! isValidStateTransition(requestStages, oldSchState, newState, sch)) {
+ String error = "Invalid transition for"
+ + " servicecomponenthost"
+ + ", clusterName=" + cluster.getClusterName()
+ + ", clusterId=" + cluster.getClusterId()
+ + ", serviceName=" + sch.getServiceName()
+ + ", componentName=" + sch.getServiceComponentName()
+ + ", hostname=" + sch.getHostName()
+ + ", currentState=" + oldSchState
+ + ", newDesiredState=" + newState;
+ StackId sid = cluster.getDesiredStackVersion();
+
+ if ( ambariMetaInfo.getComponentCategory(
+ sid.getStackName(), sid.getStackVersion(), sc.getServiceName(),
+ sch.getServiceComponentName()).isMaster()) {
+ throw new AmbariException(error);
+ } else {
+ LOG.warn("Ignoring: " + error);
+ continue;
+ }
+ }
+ if (!changedScHosts.containsKey(sc.getName())) {
+ changedScHosts.put(sc.getName(),
+ new HashMap<State, List<ServiceComponentHost>>());
+ }
+ if (!changedScHosts.get(sc.getName()).containsKey(newState)) {
+ changedScHosts.get(sc.getName()).put(newState,
+ new ArrayList<ServiceComponentHost>());
+ }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Handling update to ServiceComponentHost"
+ + ", clusterName=" + request.getClusterName()
+ + ", serviceName=" + s.getName()
+ + ", componentName=" + sc.getName()
+ + ", hostname=" + sch.getHostName()
+ + ", currentState=" + oldSchState
+ + ", newDesiredState=" + newState);
+ }
+ changedScHosts.get(sc.getName()).get(newState).add(sch);
}
}
- for (Service service : depServices) {
- updateServiceComponents(requestStages, changedComps, changedScHosts,
- ignoredScHosts, reqOpLvl, service, State.STARTED);
- changedServices.get(State.STARTED).add(service);
- }
-
}
if (seenNewStates.size() > 1) {
@@ -728,9 +814,9 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider
+ " changes for a set of services at the same time");
}
- if (maintenanceCluster != null) {
+ if (maintenanceClusters.size() > 0) {
try {
- maintenanceStateHelper.createRequests(controller, requestProperties, maintenanceCluster);
+ maintenanceStateHelper.createRequests(controller, requestProperties, maintenanceClusters);
} catch (Exception e) {
LOG.warn("Could not send maintenance state to Nagios (" + e.getMessage() + ")");
}
@@ -743,142 +829,6 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider
ignoredScHosts, runSmokeTest, reconfigureClients);
}
- private void updateServiceComponents(RequestStageContainer requestStages,
- Map<State, List<ServiceComponent>> changedComps,
- Map<String, Map<State, List<ServiceComponentHost>>> changedScHosts,
- Collection<ServiceComponentHost> ignoredScHosts,
- Resource.Type reqOpLvl,
- Service service, State newState)
- throws AmbariException {
-
- Cluster cluster = service.getCluster();
- AmbariManagementController controller = getManagementController();
- AmbariMetaInfo ambariMetaInfo = controller.getAmbariMetaInfo();
-
- for (ServiceComponent sc : service.getServiceComponents().values()) {
- State oldScState = sc.getDesiredState();
- if (newState != oldScState) {
- if (sc.isClientComponent() &&
- !newState.isValidClientComponentState()) {
- continue;
- }
- if (!State.isValidDesiredStateTransition(oldScState, newState)) {
- throw new AmbariException("Invalid transition for"
- + " servicecomponent"
- + ", clusterName=" + cluster.getClusterName()
- + ", clusterId=" + cluster.getClusterId()
- + ", serviceName=" + sc.getServiceName()
- + ", componentName=" + sc.getName()
- + ", currentDesiredState=" + oldScState
- + ", newDesiredState=" + newState);
- }
- if (!changedComps.containsKey(newState)) {
- changedComps.put(newState, new ArrayList<ServiceComponent>());
- }
- changedComps.get(newState).add(sc);
- }
- if (LOG.isDebugEnabled()) {
- LOG.debug("Handling update to ServiceComponent"
- + ", clusterName=" + cluster.getClusterName()
- + ", serviceName=" + service.getName()
- + ", componentName=" + sc.getName()
- + ", currentDesiredState=" + oldScState
- + ", newDesiredState=" + newState);
- }
-
- for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
- State oldSchState = sch.getState();
- if (oldSchState == State.DISABLED || oldSchState == State.UNKNOWN) {
- //Ignore host components updates in this state
- if (LOG.isDebugEnabled()) {
- LOG.debug("Ignoring ServiceComponentHost"
- + ", clusterName=" + cluster.getClusterName()
- + ", serviceName=" + service.getName()
- + ", componentName=" + sc.getName()
- + ", hostname=" + sch.getHostName()
- + ", currentState=" + oldSchState
- + ", newDesiredState=" + newState);
- }
- continue;
- }
- //
- if (newState == oldSchState) {
- ignoredScHosts.add(sch);
- if (LOG.isDebugEnabled()) {
- LOG.debug("Ignoring ServiceComponentHost"
- + ", clusterName=" + cluster.getClusterName()
- + ", serviceName=" + service.getName()
- + ", componentName=" + sc.getName()
- + ", hostname=" + sch.getHostName()
- + ", currentState=" + oldSchState
- + ", newDesiredState=" + newState);
- }
- continue;
- }
-
- if (! maintenanceStateHelper.isOperationAllowed(reqOpLvl, sch)) {
- ignoredScHosts.add(sch);
- if (LOG.isDebugEnabled()) {
- LOG.debug("Ignoring ServiceComponentHost"
- + ", clusterName=" + cluster.getClusterName()
- + ", serviceName=" + service.getName()
- + ", componentName=" + sc.getName()
- + ", hostname=" + sch.getHostName());
- }
- continue;
- }
-
- if (sc.isClientComponent() &&
- !newState.isValidClientComponentState()) {
- continue;
- }
- /**
- * This is hack for now wherein we don't fail if the
- * sch is in INSTALL_FAILED
- */
- if (! isValidStateTransition(requestStages, oldSchState, newState, sch)) {
- String error = "Invalid transition for"
- + " servicecomponenthost"
- + ", clusterName=" + cluster.getClusterName()
- + ", clusterId=" + cluster.getClusterId()
- + ", serviceName=" + sch.getServiceName()
- + ", componentName=" + sch.getServiceComponentName()
- + ", hostname=" + sch.getHostName()
- + ", currentState=" + oldSchState
- + ", newDesiredState=" + newState;
- StackId sid = cluster.getDesiredStackVersion();
-
- if ( ambariMetaInfo.getComponentCategory(
- sid.getStackName(), sid.getStackVersion(), sc.getServiceName(),
- sch.getServiceComponentName()).isMaster()) {
- throw new AmbariException(error);
- } else {
- LOG.warn("Ignoring: " + error);
- continue;
- }
- }
- if (!changedScHosts.containsKey(sc.getName())) {
- changedScHosts.put(sc.getName(),
- new EnumMap<State, List<ServiceComponentHost>>(State.class));
- }
- if (!changedScHosts.get(sc.getName()).containsKey(newState)) {
- changedScHosts.get(sc.getName()).put(newState,
- new ArrayList<ServiceComponentHost>());
- }
- if (LOG.isDebugEnabled()) {
- LOG.debug("Handling update to ServiceComponentHost"
- + ", clusterName=" + cluster.getClusterName()
- + ", serviceName=" + service.getName()
- + ", componentName=" + sc.getName()
- + ", hostname=" + sch.getHostName()
- + ", currentState=" + oldSchState
- + ", newDesiredState=" + newState);
- }
- changedScHosts.get(sc.getName()).get(newState).add(sch);
- }
- }
- }
-
// Delete services based on the given set of requests
protected RequestStatusResponse deleteServices(Set<ServiceRequest> request)
throws AmbariException {
@@ -981,13 +931,11 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider
State masterState = null;
State clientState = null;
State otherState = null;
- State maxMMState = null; // The worst state among components in MM
boolean hasDisabled = false;
boolean hasMaster = false;
boolean hasOther = false;
boolean hasClient = false;
- boolean hasMM = false;
for (ServiceComponentHostResponse hostComponentResponse : hostComponentResponses ) {
ComponentInfo componentInfo = ambariMetaInfo.getComponentCategory(stackId.getStackName(),
@@ -996,58 +944,36 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider
if (componentInfo != null) {
State state = getHostComponentState(hostComponentResponse);
- // Components in MM should not affect service status,
- // so we tend to ignore them
- boolean isInMaintenance = ! MaintenanceState.OFF.toString().
- equals(hostComponentResponse.getMaintenanceState());
if (state.equals(State.DISABLED)) {
hasDisabled = true;
- }
-
- if (isInMaintenance & !componentInfo.isClient()) {
- hasMM = true;
- if ( maxMMState == null || state.ordinal() > maxMMState.ordinal()) {
- maxMMState = state;
- }
- }
-
- if (componentInfo.isMaster()) {
- if (state.equals(State.STARTED) || ! isInMaintenance) {
- // We rely on master's state to determine service state
- hasMaster = true;
- }
-
- if (! state.equals(State.STARTED) &&
- ! isInMaintenance && // Ignore status of MM component
- ( masterState == null || state.ordinal() > masterState.ordinal())) {
- masterState = state;
- }
- } else if (componentInfo.isClient()) {
- hasClient = true;
- if (!state.equals(State.INSTALLED) &&
- (clientState == null || state.ordinal() > clientState.ordinal())) {
- clientState = state;
- }
} else {
- if (state.equals(State.STARTED) || ! isInMaintenance) {
- // We rely on slaves's state to determine service state
- hasOther = true;
- }
- if (! state.equals(State.STARTED) &&
- ! isInMaintenance && // Ignore status of MM component
- ( otherState == null || state.ordinal() > otherState.ordinal())) {
- otherState = state;
+ if (componentInfo.isMaster()) {
+ hasMaster = true;
+ if(!state.equals(State.STARTED) &&
+ ( masterState == null || state.ordinal() > masterState.ordinal())) {
+ masterState = state;
+ }
+ } else if (componentInfo.isClient()) {
+ hasClient = true;
+ if (!state.equals(State.INSTALLED) &&
+ (clientState == null || state.ordinal() > clientState.ordinal())) {
+ clientState = state;
+ }
+ } else {
+ hasOther = true;
+ if (otherState == null || state.ordinal() > otherState.ordinal()) {
+ otherState = state;
+ }
}
}
}
}
return hasMaster ? masterState == null ? State.STARTED : masterState :
- hasOther ? otherState == null ? State.STARTED : otherState :
+ hasOther ? otherState :
hasClient ? clientState == null ? State.INSTALLED : clientState :
- hasDisabled ? State.DISABLED :
- hasMM ? maxMMState : State.UNKNOWN;
+ hasDisabled ? State.DISABLED : State.UNKNOWN;
}
} catch (AmbariException e) {
LOG.error("Can't determine service state.", e);
http://git-wip-us.apache.org/repos/asf/ambari/blob/7e28d1e3/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackAdvisorResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackAdvisorResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackAdvisorResourceProvider.java
deleted file mode 100644
index 6ae557d..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackAdvisorResourceProvider.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ambari.server.controller.internal;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-
-import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorHelper;
-import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorRequest;
-import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorRequest.StackAdvisorRequestBuilder;
-import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorRequest.StackAdvisorRequestType;
-import org.apache.ambari.server.controller.AmbariManagementController;
-import org.apache.ambari.server.controller.spi.Request;
-import org.apache.ambari.server.controller.spi.Resource.Type;
-import org.apache.ambari.server.controller.utilities.PropertyHelper;
-
-import com.google.inject.Inject;
-
-/**
- * Abstract superclass for recommendations and validations.
- */
-public abstract class StackAdvisorResourceProvider extends ReadOnlyResourceProvider {
-
- protected static final String STACK_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("Versions",
- "stack_name");
- protected static final String STACK_VERSION_PROPERTY_ID = PropertyHelper.getPropertyId(
- "Versions", "stack_version");
-
- private static final String HOST_PROPERTY = "hosts";
- private static final String SERVICES_PROPERTY = "services";
-
- private static final String BLUEPRINT_HOST_GROUPS_PROPERTY = "recommendations/blueprint/host_groups";
- private static final String BINDING_HOST_GROUPS_PROPERTY = "recommendations/blueprint_cluster_binding/host_groups";
-
- private static final String BLUEPRINT_HOST_GROUPS_NAME_PROPERTY = "name";
- private static final String BLUEPRINT_HOST_GROUPS_COMPONENTS_PROPERTY = "components";
- private static final String BLUEPRINT_HOST_GROUPS_COMPONENTS_NAME_PROPERTY = "name";
-
- private static final String BINDING_HOST_GROUPS_NAME_PROPERTY = "name";
- private static final String BINDING_HOST_GROUPS_HOSTS_PROPERTY = "hosts";
- private static final String BINDING_HOST_GROUPS_HOSTS_NAME_PROPERTY = "fqdn";
-
- protected static StackAdvisorHelper saHelper;
-
- @Inject
- public static void init(StackAdvisorHelper instance) {
- saHelper = instance;
- }
-
- protected StackAdvisorResourceProvider(Set<String> propertyIds, Map<Type, String> keyPropertyIds,
- AmbariManagementController managementController) {
- super(propertyIds, keyPropertyIds, managementController);
- }
-
- protected abstract String getRequestTypePropertyId();
-
- @SuppressWarnings("unchecked")
- protected StackAdvisorRequest prepareStackAdvisorRequest(Request request) {
- try {
- String stackName = (String) getRequestProperty(request, STACK_NAME_PROPERTY_ID);
- String stackVersion = (String) getRequestProperty(request, STACK_VERSION_PROPERTY_ID);
- StackAdvisorRequestType requestType = StackAdvisorRequestType
- .fromString((String) getRequestProperty(request, getRequestTypePropertyId()));
-
- /*
- * ClassCastException will occur if hosts or services are empty in the
- * request.
- *
- * @see JsonRequestBodyParser for arrays parsing
- */
- List<String> hosts = (List<String>) getRequestProperty(request, HOST_PROPERTY);
- List<String> services = (List<String>) getRequestProperty(request, SERVICES_PROPERTY);
- Map<String, Set<String>> hgComponentsMap = calculateHostGroupComponentsMap(request);
- Map<String, Set<String>> hgHostsMap = calculateHostGroupHostsMap(request);
- Map<String, Set<String>> componentHostsMap = calculateComponentHostsMap(hgComponentsMap,
- hgHostsMap);
- Map<String, Map<String, Map<String, String>>> configurations = calculateConfigurations(request);
-
- StackAdvisorRequest saRequest = StackAdvisorRequestBuilder.forStack(stackName, stackVersion)
- .ofType(requestType).forHosts(hosts).forServices(services)
- .forHostComponents(hgComponentsMap).forHostsGroupBindings(hgHostsMap)
- .withComponentHostsMap(componentHostsMap).withConfigurations(configurations).build();
-
- return saRequest;
- } catch (Exception e) {
- LOG.warn("Error occured during preparation of stack advisor request", e);
- Response response = Response.status(Status.BAD_REQUEST)
- .entity(String.format("Request body is not correct, error: %s", e.getMessage())).build();
- // TODO: Hosts and services must not be empty
- throw new WebApplicationException(response);
- }
- }
-
- /**
- * Will prepare host-group names to components names map from the
- * recommendation blueprint host groups.
- *
- * @param request stack advisor request
- * @return host-group to components map
- */
- @SuppressWarnings("unchecked")
- private Map<String, Set<String>> calculateHostGroupComponentsMap(Request request) {
- Set<Map<String, Object>> hostGroups = (Set<Map<String, Object>>) getRequestProperty(request,
- BLUEPRINT_HOST_GROUPS_PROPERTY);
- Map<String, Set<String>> map = new HashMap<String, Set<String>>();
- if (hostGroups != null) {
- for (Map<String, Object> hostGroup : hostGroups) {
- String hostGroupName = (String) hostGroup.get(BLUEPRINT_HOST_GROUPS_NAME_PROPERTY);
-
- Set<Map<String, Object>> componentsSet = (Set<Map<String, Object>>) hostGroup
- .get(BLUEPRINT_HOST_GROUPS_COMPONENTS_PROPERTY);
-
- Set<String> components = new HashSet<String>();
- for (Map<String, Object> component : componentsSet) {
- components.add((String) component.get(BLUEPRINT_HOST_GROUPS_COMPONENTS_NAME_PROPERTY));
- }
-
- map.put(hostGroupName, components);
- }
- }
-
- return map;
- }
-
- /**
- * Will prepare host-group names to hosts names map from the recommendation
- * binding host groups.
- *
- * @param request stack advisor request
- * @return host-group to hosts map
- */
- @SuppressWarnings("unchecked")
- private Map<String, Set<String>> calculateHostGroupHostsMap(Request request) {
- Set<Map<String, Object>> bindingHostGroups = (Set<Map<String, Object>>) getRequestProperty(
- request, BINDING_HOST_GROUPS_PROPERTY);
- Map<String, Set<String>> map = new HashMap<String, Set<String>>();
- if (bindingHostGroups != null) {
- for (Map<String, Object> hostGroup : bindingHostGroups) {
- String hostGroupName = (String) hostGroup.get(BINDING_HOST_GROUPS_NAME_PROPERTY);
-
- Set<Map<String, Object>> hostsSet = (Set<Map<String, Object>>) hostGroup
- .get(BINDING_HOST_GROUPS_HOSTS_PROPERTY);
-
- Set<String> hosts = new HashSet<String>();
- for (Map<String, Object> host : hostsSet) {
- hosts.add((String) host.get(BINDING_HOST_GROUPS_HOSTS_NAME_PROPERTY));
- }
-
- map.put(hostGroupName, hosts);
- }
- }
-
- return map;
- }
-
- protected static final String CONFIGURATIONS_PROPERTY_ID = "recommendations/blueprint/configurations/";
-
- protected Map<String, Map<String, Map<String, String>>> calculateConfigurations(Request request) {
- Map<String, Map<String, Map<String, String>>> configurations = new HashMap<String, Map<String, Map<String, String>>>();
- Map<String, Object> properties = request.getProperties().iterator().next();
- for (String property : properties.keySet()) {
- if (property.startsWith(CONFIGURATIONS_PROPERTY_ID)) {
- try {
- String propertyEnd = property.substring(CONFIGURATIONS_PROPERTY_ID.length()); // mapred-site/properties/yarn.app.mapreduce.am.resource.mb
- String[] propertyPath = propertyEnd.split("/"); // length == 3
- String siteName = propertyPath[0];
- String propertiesProperty = propertyPath[1];
- String propertyName = propertyPath[2];
-
- Map<String, Map<String, String>> siteMap = configurations.get(siteName);
- if (siteMap == null) {
- siteMap = new HashMap<String, Map<String, String>>();
- configurations.put(siteName, siteMap);
- }
-
- Map<String, String> propertiesMap = siteMap.get(propertiesProperty);
- if (propertiesMap == null) {
- propertiesMap = new HashMap<String, String>();
- siteMap.put(propertiesProperty, propertiesMap);
- }
-
- String value = properties.get(property).toString();
- propertiesMap.put(propertyName, value);
- } catch (Exception e) {
- LOG.debug(String.format("Error handling configuration property, name = %s", property), e);
- // do nothing
- }
- }
- }
- return configurations;
- }
-
- @SuppressWarnings("unchecked")
- private Map<String, Set<String>> calculateComponentHostsMap(Map<String, Set<String>> hostGroups,
- Map<String, Set<String>> bindingHostGroups) {
- /*
- * ClassCastException may occur in case of body inconsistency: property
- * missed, etc.
- */
-
- Map<String, Set<String>> componentHostsMap = new HashMap<String, Set<String>>();
- if (null != bindingHostGroups && null != hostGroups) {
- for (Map.Entry<String, Set<String>> hgComponents : hostGroups.entrySet()) {
- String hgName = hgComponents.getKey();
- Set<String> components = hgComponents.getValue();
-
- Set<String> hosts = bindingHostGroups.get(hgName);
- for (String component : components) {
- Set<String> componentHosts = componentHostsMap.get(component);
- if (componentHosts == null) { // if was not initialized
- componentHosts = new HashSet<String>();
- componentHostsMap.put(component, componentHosts);
- }
- componentHosts.addAll(hosts);
- }
- }
- }
-
- return componentHostsMap;
- }
-
- protected Object getRequestProperty(Request request, String propertyName) {
- for (Map<String, Object> propertyMap : request.getProperties()) {
- if (propertyMap.containsKey(propertyName)) {
- return propertyMap.get(propertyName);
- }
- }
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/7e28d1e3/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackConfigurationResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackConfigurationResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackConfigurationResourceProvider.java
index 4abf3d2..4aa56f0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackConfigurationResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackConfigurationResourceProvider.java
@@ -59,9 +59,6 @@ public class StackConfigurationResourceProvider extends
public static final String PROPERTY_DESCRIPTION_PROPERTY_ID = PropertyHelper
.getPropertyId("StackConfigurations", "property_description");
-
- public static final String PROPERTY_PROPERTY_TYPE_PROPERTY_ID = PropertyHelper
- .getPropertyId("StackConfigurations", "property_type");
public static final String PROPERTY_TYPE_PROPERTY_ID = PropertyHelper
.getPropertyId("StackConfigurations", "type");
@@ -128,18 +125,11 @@ public class StackConfigurationResourceProvider extends
setResourceProperty(resource, PROPERTY_DESCRIPTION_PROPERTY_ID,
response.getPropertyDescription(), requestedIds);
- setResourceProperty(resource, PROPERTY_PROPERTY_TYPE_PROPERTY_ID,
- response.getPropertyType(), requestedIds);
-
setResourceProperty(resource, PROPERTY_TYPE_PROPERTY_ID,
response.getType(), requestedIds);
- setDefaultPropertiesAttributes(resource, requestedIds);
-
- for (Map.Entry<String, String> attribute : response.getPropertyAttributes().entrySet()) {
- setResourceProperty(resource, PropertyHelper.getPropertyId("StackConfigurations", attribute.getKey()),
- attribute.getValue(), requestedIds);
- }
+ setResourceProperty(resource, PROPERTY_FINAL_PROPERTY_ID,
+ response.isFinal(), requestedIds);
resources.add(resource);
}
@@ -147,15 +137,6 @@ public class StackConfigurationResourceProvider extends
return resources;
}
- /**
- * Set default values for properties attributes before applying original ones
- * to prevent absence in case of empty attributes map
- */
- private void setDefaultPropertiesAttributes(Resource resource, Set<String> requestedIds) {
- setResourceProperty(resource, PROPERTY_FINAL_PROPERTY_ID,
- "false", requestedIds);
- }
-
private StackConfigurationRequest getRequest(Map<String, Object> properties) {
return new StackConfigurationRequest(
(String) properties.get(STACK_NAME_PROPERTY_ID),
http://git-wip-us.apache.org/repos/asf/ambari/blob/7e28d1e3/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProvider.java
index 32411e9..51c7565 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProvider.java
@@ -35,7 +35,6 @@ import org.apache.ambari.server.controller.ganglia.GangliaHostProvider;
import org.apache.ambari.server.controller.ganglia.GangliaPropertyProvider;
import org.apache.ambari.server.controller.jmx.JMXHostProvider;
import org.apache.ambari.server.controller.jmx.JMXPropertyProvider;
-import org.apache.ambari.server.controller.metrics.MetricsHostProvider;
import org.apache.ambari.server.controller.spi.Predicate;
import org.apache.ambari.server.controller.spi.PropertyProvider;
import org.apache.ambari.server.controller.spi.Request;
@@ -57,71 +56,57 @@ import com.google.inject.Injector;
* This class analyzes a service's metrics to determine if additional
* metrics should be fetched. It's okay to maintain state here since these
* are done per-request.
+ *
*/
public class StackDefinedPropertyProvider implements PropertyProvider {
private static final Logger LOG = LoggerFactory.getLogger(StackDefinedPropertyProvider.class);
-
+
@Inject
private static Clusters clusters = null;
@Inject
private static AmbariMetaInfo metaInfo = null;
- @Inject
- private static Injector injector = null;
-
-
+
private Resource.Type type = null;
private String clusterNamePropertyId = null;
private String hostNamePropertyId = null;
private String componentNamePropertyId = null;
- private String resourceStatePropertyId = null;
+ private String jmxStatePropertyId = null;
private ComponentSSLConfiguration sslConfig = null;
private StreamProvider streamProvider = null;
private JMXHostProvider jmxHostProvider;
private GangliaHostProvider gangliaHostProvider;
private PropertyProvider defaultJmx = null;
private PropertyProvider defaultGanglia = null;
-
- private final MetricsHostProvider metricsHostProvider;
-
- /**
- * PropertyHelper/AbstractPropertyProvider expect map of maps,
- * that's why we wrap metrics into map
- */
- public static final String WRAPPED_METRICS_KEY = "WRAPPED_METRICS_KEY";
-
+
@Inject
public static void init(Injector injector) {
clusters = injector.getInstance(Clusters.class);
metaInfo = injector.getInstance(AmbariMetaInfo.class);
- StackDefinedPropertyProvider.injector = injector;
}
-
+
public StackDefinedPropertyProvider(Resource.Type type,
JMXHostProvider jmxHostProvider,
GangliaHostProvider gangliaHostProvider,
- MetricsHostProvider metricsHostProvider,
StreamProvider streamProvider,
String clusterPropertyId,
String hostPropertyId,
String componentPropertyId,
- String resourceStatePropertyId,
+ String jmxStatePropertyId,
PropertyProvider defaultJmxPropertyProvider,
PropertyProvider defaultGangliaPropertyProvider
- ) {
-
- this.metricsHostProvider = metricsHostProvider;
-
+ ) {
+
if (null == clusterPropertyId)
throw new NullPointerException("Cluster name property id cannot be null");
if (null == componentPropertyId)
throw new NullPointerException("Component name property id cannot be null");
-
+
this.type = type;
-
+
clusterNamePropertyId = clusterPropertyId;
hostNamePropertyId = hostPropertyId;
componentNamePropertyId = componentPropertyId;
- this.resourceStatePropertyId = resourceStatePropertyId;
+ this.jmxStatePropertyId = jmxStatePropertyId;
this.jmxHostProvider = jmxHostProvider;
this.gangliaHostProvider = gangliaHostProvider;
sslConfig = ComponentSSLConfiguration.instance();
@@ -129,34 +114,34 @@ public class StackDefinedPropertyProvider implements PropertyProvider {
defaultJmx = defaultJmxPropertyProvider;
defaultGanglia = defaultGangliaPropertyProvider;
}
-
-
+
+
@Override
public Set<Resource> populateResources(Set<Resource> resources,
Request request, Predicate predicate) throws SystemException {
// only arrange for one instance of Ganglia and JMX instantiation
- Map<String, Map<String, PropertyInfo>> gangliaMap = new HashMap<String, Map<String, PropertyInfo>>();
+ Map<String, Map<String, PropertyInfo>> gangliaMap = new HashMap<String, Map<String,PropertyInfo>>();
Map<String, Map<String, PropertyInfo>> jmxMap = new HashMap<String, Map<String, PropertyInfo>>();
List<PropertyProvider> additional = new ArrayList<PropertyProvider>();
-
+
try {
for (Resource r : resources) {
String clusterName = r.getPropertyValue(clusterNamePropertyId).toString();
String componentName = r.getPropertyValue(componentNamePropertyId).toString();
-
+
Cluster cluster = clusters.getCluster(clusterName);
StackId stack = cluster.getDesiredStackVersion();
String svc = metaInfo.getComponentToService(stack.getStackName(),
stack.getStackVersion(), componentName);
-
+
List<MetricDefinition> defs = metaInfo.getMetrics(
stack.getStackName(), stack.getStackVersion(), svc, componentName, type.name());
-
+
if (null == defs || 0 == defs.size())
continue;
-
+
for (MetricDefinition m : defs) {
if (m.getType().equals("ganglia")) {
gangliaMap.put(componentName, getPropertyInfo(m));
@@ -164,20 +149,12 @@ public class StackDefinedPropertyProvider implements PropertyProvider {
jmxMap.put(componentName, getPropertyInfo(m));
} else {
PropertyProvider pp = getDelegate(m);
- if(pp == null) {
- pp = getDelegate(m,
- streamProvider, metricsHostProvider,
- clusterNamePropertyId, hostNamePropertyId,
- componentNamePropertyId, resourceStatePropertyId);
- }
- if(pp != null) {
+ if (null != pp)
additional.add(pp);
- }
-
}
}
}
-
+
if (gangliaMap.size() > 0) {
GangliaPropertyProvider gpp = type.equals (Resource.Type.Component) ?
new GangliaComponentPropertyProvider(gangliaMap,
@@ -186,23 +163,22 @@ public class StackDefinedPropertyProvider implements PropertyProvider {
new GangliaHostComponentPropertyProvider(gangliaMap,
streamProvider, sslConfig, gangliaHostProvider,
clusterNamePropertyId, hostNamePropertyId, componentNamePropertyId);
-
+
gpp.populateResources(resources, request, predicate);
} else {
defaultGanglia.populateResources(resources, request, predicate);
}
-
+
if (jmxMap.size() > 0) {
JMXPropertyProvider jpp = new JMXPropertyProvider(jmxMap, streamProvider,
- jmxHostProvider, metricsHostProvider,
- clusterNamePropertyId, hostNamePropertyId,
- componentNamePropertyId, resourceStatePropertyId);
-
+ jmxHostProvider, clusterNamePropertyId, hostNamePropertyId,
+ componentNamePropertyId, jmxStatePropertyId, Collections.singleton("STARTED"));
+
jpp.populateResources(resources, request, predicate);
} else {
defaultJmx.populateResources(resources, request, predicate);
}
-
+
for (PropertyProvider pp : additional) {
pp.populateResources(resources, request, predicate);
}
@@ -211,7 +187,7 @@ public class StackDefinedPropertyProvider implements PropertyProvider {
e.printStackTrace();
throw new SystemException("Error loading deferred resources", e);
}
-
+
return resources;
}
@@ -219,134 +195,59 @@ public class StackDefinedPropertyProvider implements PropertyProvider {
public Set<String> checkPropertyIds(Set<String> propertyIds) {
return Collections.emptySet();
}
-
+
/**
* @param def the metric definition
- * @return the converted Map required for JMX or Ganglia execution.
- * Format: <metric name, property info>
+ * @return the converted Map required for JMX or Ganglia execution
*/
- private Map<String, PropertyInfo> getPropertyInfo(MetricDefinition def) {
+ private Map<String, PropertyInfo> getPropertyInfo(MetricDefinition def) {
Map<String, PropertyInfo> defs = new HashMap<String, PropertyInfo>();
-
- for (Entry<String, Metric> entry : def.getMetrics().entrySet()) {
+
+ for (Entry<String,Metric> entry : def.getMetrics().entrySet()) {
Metric metric = entry.getValue();
defs.put(entry.getKey(), new PropertyInfo(
metric.getName(), metric.isTemporal(), metric.isPointInTime()));
}
-
+
return defs;
}
-
+
/**
- * @param definition metric definition for a component and resource type combination
+ * @param the metric definition for a component and resource type combination
* @return the custom property provider
*/
private PropertyProvider getDelegate(MetricDefinition definition) {
- try {
- Class<?> clz = Class.forName(definition.getType());
-
- // singleton/factory
- try {
- Method m = clz.getMethod("getInstance", Map.class, Map.class);
- Object o = m.invoke(null, definition.getProperties(), definition.getMetrics());
- return PropertyProvider.class.cast(o);
- } catch (Exception e) {
- LOG.info("Could not load singleton or factory method for type '" +
- definition.getType());
- }
-
- // try maps constructor
- try {
- Constructor<?> ct = clz.getConstructor(Map.class, Map.class);
- Object o = ct.newInstance(definition.getProperties(), definition.getMetrics());
- return PropertyProvider.class.cast(o);
- } catch (Exception e) {
- LOG.info("Could not find contructor for type '" +
- definition.getType());
- }
-
- // just new instance
- return PropertyProvider.class.cast(clz.newInstance());
-
- } catch (Exception e) {
- LOG.error("Could not load class " + definition.getType());
- return null;
- }
- }
-
- /**
- *
- * @param definition the metric definition for a component
- * @param streamProvider the stream provider
- * @param metricsHostProvider the metrics host provider
- * @param clusterNamePropertyId the cluster name property id
- * @param hostNamePropertyId the host name property id
- * @param componentNamePropertyId the component name property id
- * @param statePropertyId the state property id
- * @return the custom property provider
- */
-
- private PropertyProvider getDelegate(MetricDefinition definition,
- StreamProvider streamProvider,
- MetricsHostProvider metricsHostProvider,
- String clusterNamePropertyId,
- String hostNamePropertyId,
- String componentNamePropertyId,
- String statePropertyId) {
- Map<String, PropertyInfo> metrics = getPropertyInfo(definition);
- HashMap<String, Map<String, PropertyInfo>> componentMetrics =
- new HashMap<String, Map<String, PropertyInfo>>();
- componentMetrics.put(WRAPPED_METRICS_KEY, metrics);
-
- try {
- Class<?> clz = Class.forName(definition.getType());
- // singleton/factory
try {
- /*
- * Interface for singleton/factory method invocation TBD
- * when implementing the first real use
- */
- Method m = clz.getMethod("getInstance", Map.class, Map.class);
- Object o = m.invoke(
- definition.getProperties(), componentMetrics,
- streamProvider, clusterNamePropertyId, hostNamePropertyId,
- componentNamePropertyId, statePropertyId);
- return PropertyProvider.class.cast(o);
- } catch (Exception e) {
- LOG.info("Could not load singleton or factory method for type '" +
- definition.getType());
- }
+ Class<?> clz = Class.forName(definition.getType());
+
+ // singleton/factory
+ try {
+ Method m = clz.getMethod("getInstance", Map.class, Map.class);
+ Object o = m.invoke(null, definition.getProperties(), definition.getMetrics());
+ return PropertyProvider.class.cast(o);
+ } catch (Exception e) {
+ LOG.info("Could not load singleton or factory method for type '" +
+ definition.getType());
+ }
+
+ // try maps constructor
+ try {
+ Constructor<?> ct = clz.getConstructor(Map.class, Map.class);
+ Object o = ct.newInstance(definition.getProperties(), definition.getMetrics());
+ return PropertyProvider.class.cast(o);
+ } catch (Exception e) {
+ LOG.info("Could not find contructor for type '" +
+ definition.getType());
+ }
+
+ // just new instance
+ return PropertyProvider.class.cast(clz.newInstance());
- // try maps constructor
- try {
- /*
- * Warning: this branch is already used, that's why please adjust
- * all implementations when modifying constructor interface
- */
- Constructor<?> ct = clz.getConstructor(Injector.class, Map.class,
- Map.class, StreamProvider.class, MetricsHostProvider.class,
- String.class, String.class, String.class, String.class);
- Object o = ct.newInstance(
- injector,
- definition.getProperties(), componentMetrics,
- streamProvider, metricsHostProvider,
- clusterNamePropertyId, hostNamePropertyId,
- componentNamePropertyId, statePropertyId);
- return PropertyProvider.class.cast(o);
} catch (Exception e) {
- LOG.info("Could not find contructor for type '" +
- definition.getType());
+ LOG.error("Could not load class " + definition.getType());
+ return null;
}
-
- // just new instance
- return PropertyProvider.class.cast(clz.newInstance());
-
- } catch (Exception e) {
- LOG.error("Could not load class " + definition.getType());
- return null;
- }
-
-
}
+
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/7e28d1e3/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackLevelConfigurationResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackLevelConfigurationResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackLevelConfigurationResourceProvider.java
deleted file mode 100644
index 1055626..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackLevelConfigurationResourceProvider.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package org.apache.ambari.server.controller.internal;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.controller.AmbariManagementController;
-import org.apache.ambari.server.controller.StackConfigurationResponse;
-import org.apache.ambari.server.controller.StackLevelConfigurationRequest;
-import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
-import org.apache.ambari.server.controller.spi.NoSuchResourceException;
-import org.apache.ambari.server.controller.spi.Predicate;
-import org.apache.ambari.server.controller.spi.Request;
-import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.controller.spi.Resource.Type;
-import org.apache.ambari.server.controller.spi.SystemException;
-import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
-import org.apache.ambari.server.controller.utilities.PropertyHelper;
-
-public class StackLevelConfigurationResourceProvider extends
- ReadOnlyResourceProvider {
-
- public static final String STACK_NAME_PROPERTY_ID = PropertyHelper
- .getPropertyId("StackLevelConfigurations", "stack_name");
-
- public static final String STACK_VERSION_PROPERTY_ID = PropertyHelper
- .getPropertyId("StackLevelConfigurations", "stack_version");
-
- public static final String PROPERTY_NAME_PROPERTY_ID = PropertyHelper
- .getPropertyId("StackLevelConfigurations", "property_name");
-
- public static final String PROPERTY_VALUE_PROPERTY_ID = PropertyHelper
- .getPropertyId("StackLevelConfigurations", "property_value");
-
- public static final String PROPERTY_DESCRIPTION_PROPERTY_ID = PropertyHelper
- .getPropertyId("StackLevelConfigurations", "property_description");
-
- public static final String PROPERTY_PROPERTY_TYPE_PROPERTY_ID = PropertyHelper
- .getPropertyId("StackConfigurations", "property_type");
-
- public static final String PROPERTY_TYPE_PROPERTY_ID = PropertyHelper
- .getPropertyId("StackLevelConfigurations", "type");
-
- public static final String PROPERTY_FINAL_PROPERTY_ID = PropertyHelper
- .getPropertyId("StackLevelConfigurations", "final");
-
-
- private static Set<String> pkPropertyIds = new HashSet<String>(
- Arrays.asList(new String[] { STACK_NAME_PROPERTY_ID,
- STACK_VERSION_PROPERTY_ID, PROPERTY_NAME_PROPERTY_ID }));
-
- protected StackLevelConfigurationResourceProvider(Set<String> propertyIds,
- Map<Type, String> keyPropertyIds,
- AmbariManagementController managementController) {
- super(propertyIds, keyPropertyIds, managementController);
- }
-
-
- @Override
- public Set<Resource> getResources(Request request, Predicate predicate)
- throws SystemException, UnsupportedPropertyException,
- NoSuchResourceException, NoSuchParentResourceException {
-
- final Set<StackLevelConfigurationRequest> requests = new HashSet<StackLevelConfigurationRequest>();
-
- if (predicate == null) {
- requests.add(getRequest(Collections.<String, Object>emptyMap()));
- } else {
- for (Map<String, Object> propertyMap : getPropertyMaps(predicate)) {
- requests.add(getRequest(propertyMap));
- }
- }
-
- Set<String> requestedIds = getRequestPropertyIds(request, predicate);
-
- Set<StackConfigurationResponse> responses = getResources(new Command<Set<StackConfigurationResponse>>() {
- @Override
- public Set<StackConfigurationResponse> invoke() throws AmbariException {
- return getManagementController().getStackLevelConfigurations(requests);
- }
- });
-
- Set<Resource> resources = new HashSet<Resource>();
-
- for (StackConfigurationResponse response : responses) {
- Resource resource = new ResourceImpl(Resource.Type.StackLevelConfiguration);
-
- setResourceProperty(resource, STACK_NAME_PROPERTY_ID,
- response.getStackName(), requestedIds);
-
- setResourceProperty(resource, STACK_VERSION_PROPERTY_ID,
- response.getStackVersion(), requestedIds);
-
- setResourceProperty(resource, PROPERTY_NAME_PROPERTY_ID,
- response.getPropertyName(), requestedIds);
-
- setResourceProperty(resource, PROPERTY_VALUE_PROPERTY_ID,
- response.getPropertyValue(), requestedIds);
-
- setResourceProperty(resource, PROPERTY_DESCRIPTION_PROPERTY_ID,
- response.getPropertyDescription(), requestedIds);
-
- setResourceProperty(resource, PROPERTY_PROPERTY_TYPE_PROPERTY_ID,
- response.getPropertyType(), requestedIds);
-
- setResourceProperty(resource, PROPERTY_TYPE_PROPERTY_ID,
- response.getType(), requestedIds);
-
- setDefaultPropertiesAttributes(resource, requestedIds);
-
- for (Map.Entry<String, String> attribute : response.getPropertyAttributes().entrySet()) {
- setResourceProperty(resource, PropertyHelper.getPropertyId("StackLevelConfigurations", attribute.getKey()),
- attribute.getValue(), requestedIds);
- }
-
- resources.add(resource);
- }
-
- return resources;
- }
-
- /**
- * Set default values for properties attributes before applying original ones
- * to prevent absence in case of empty attributes map
- */
- private void setDefaultPropertiesAttributes(Resource resource, Set<String> requestedIds) {
- setResourceProperty(resource, PROPERTY_FINAL_PROPERTY_ID,
- "false", requestedIds);
- }
-
- private StackLevelConfigurationRequest getRequest(Map<String, Object> properties) {
- return new StackLevelConfigurationRequest(
- (String) properties.get(STACK_NAME_PROPERTY_ID),
- (String) properties.get(STACK_VERSION_PROPERTY_ID),
- (String) properties.get(PROPERTY_NAME_PROPERTY_ID));
- }
-
- @Override
- protected Set<String> getPKPropertyIds() {
- return pkPropertyIds;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/7e28d1e3/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceComponentResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceComponentResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceComponentResourceProvider.java
index 1f23773..86d0455 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceComponentResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceComponentResourceProvider.java
@@ -18,55 +18,51 @@
package org.apache.ambari.server.controller.internal;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.controller.AmbariManagementController;
import org.apache.ambari.server.controller.StackServiceComponentRequest;
import org.apache.ambari.server.controller.StackServiceComponentResponse;
-import org.apache.ambari.server.controller.spi.*;
+import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
+import org.apache.ambari.server.controller.spi.NoSuchResourceException;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.Resource;
import org.apache.ambari.server.controller.spi.Resource.Type;
+import org.apache.ambari.server.controller.spi.SystemException;
+import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
import org.apache.ambari.server.controller.utilities.PropertyHelper;
import org.apache.ambari.server.state.AutoDeployInfo;
-import java.util.*;
-
public class StackServiceComponentResourceProvider extends
ReadOnlyResourceProvider {
- private static final String STACK_NAME_PROPERTY_ID = PropertyHelper.getPropertyId(
- "StackServiceComponents", "stack_name");
-
- private static final String STACK_VERSION_PROPERTY_ID = PropertyHelper.getPropertyId(
- "StackServiceComponents", "stack_version");
-
- private static final String SERVICE_NAME_PROPERTY_ID = PropertyHelper.getPropertyId(
- "StackServiceComponents", "service_name");
-
- private static final String COMPONENT_NAME_PROPERTY_ID = PropertyHelper.getPropertyId(
- "StackServiceComponents", "component_name");
-
- private static final String COMPONENT_DISPLAY_NAME_PROPERTY_ID = PropertyHelper.getPropertyId(
- "StackServiceComponents", "display_name");
-
- private static final String COMPONENT_CATEGORY_PROPERTY_ID = PropertyHelper.getPropertyId(
- "StackServiceComponents", "component_category");
-
- private static final String IS_CLIENT_PROPERTY_ID = PropertyHelper.getPropertyId(
- "StackServiceComponents", "is_client");
-
- private static final String IS_MASTER_PROPERTY_ID = PropertyHelper.getPropertyId(
- "StackServiceComponents", "is_master");
-
- private static final String CARDINALITY_ID = PropertyHelper.getPropertyId(
- "StackServiceComponents", "cardinality");
+ protected static final String STACK_NAME_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackServiceComponents", "stack_name");
+ protected static final String STACK_VERSION_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackServiceComponents", "stack_version");
+ protected static final String SERVICE_NAME_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackServiceComponents", "service_name");
+ protected static final String COMPONENT_NAME_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackServiceComponents", "component_name");
+ protected static final String COMPONENT_CATEGORY_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackServiceComponents", "component_category");
+ protected static final String IS_CLIENT_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackServiceComponents", "is_client");
+ protected static final String IS_MASTER_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackServiceComponents", "is_master");
+ protected static final String CARDINALITY_ID = PropertyHelper
+ .getPropertyId("StackServiceComponents", "cardinality");
+ protected static final String AUTO_DEPLOY_ENABLED_ID = PropertyHelper
+ .getPropertyId("auto_deploy", "enabled");
+ protected static final String AUTO_DEPLOY_LOCATION_ID = PropertyHelper
+ .getPropertyId("auto_deploy", "location");
- private static final String CUSTOM_COMMANDS_PROPERTY_ID = PropertyHelper.getPropertyId(
- "StackServiceComponents", "custom_commands");
-
- private static final String AUTO_DEPLOY_ENABLED_ID = PropertyHelper.getPropertyId(
- "auto_deploy", "enabled");
-
- private static final String AUTO_DEPLOY_LOCATION_ID = PropertyHelper.getPropertyId(
- "auto_deploy", "location");
private static Set<String> pkPropertyIds = new HashSet<String>(
Arrays.asList(new String[] { STACK_NAME_PROPERTY_ID,
@@ -110,34 +106,28 @@ public class StackServiceComponentResourceProvider extends
setResourceProperty(resource, STACK_NAME_PROPERTY_ID,
response.getStackName(), requestedIds);
-
+
setResourceProperty(resource, STACK_VERSION_PROPERTY_ID,
response.getStackVersion(), requestedIds);
-
+
setResourceProperty(resource, SERVICE_NAME_PROPERTY_ID,
response.getServiceName(), requestedIds);
-
+
setResourceProperty(resource, COMPONENT_NAME_PROPERTY_ID,
response.getComponentName(), requestedIds);
-
- setResourceProperty(resource, COMPONENT_DISPLAY_NAME_PROPERTY_ID,
- response.getComponentDisplayName(), requestedIds);
-
+
setResourceProperty(resource, COMPONENT_CATEGORY_PROPERTY_ID,
response.getComponentCategory(), requestedIds);
-
+
setResourceProperty(resource, IS_CLIENT_PROPERTY_ID,
response.isClient(), requestedIds);
-
+
setResourceProperty(resource, IS_MASTER_PROPERTY_ID,
response.isMaster(), requestedIds);
setResourceProperty(resource, CARDINALITY_ID,
response.getCardinality(), requestedIds);
- setResourceProperty(resource, CUSTOM_COMMANDS_PROPERTY_ID,
- response.getCustomCommands(), requestedIds);
-
AutoDeployInfo autoDeployInfo = response.getAutoDeploy();
if (autoDeployInfo != null) {
setResourceProperty(resource, AUTO_DEPLOY_ENABLED_ID,
http://git-wip-us.apache.org/repos/asf/ambari/blob/7e28d1e3/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceResourceProvider.java
index 1296ba1..21546e4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceResourceProvider.java
@@ -19,50 +19,48 @@
package org.apache.ambari.server.controller.internal;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.controller.AmbariManagementController;
import org.apache.ambari.server.controller.StackServiceRequest;
import org.apache.ambari.server.controller.StackServiceResponse;
-import org.apache.ambari.server.controller.spi.*;
+import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
+import org.apache.ambari.server.controller.spi.NoSuchResourceException;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.Resource;
import org.apache.ambari.server.controller.spi.Resource.Type;
+import org.apache.ambari.server.controller.spi.SystemException;
+import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
import org.apache.ambari.server.controller.utilities.PropertyHelper;
-import java.util.*;
-
public class StackServiceResourceProvider extends ReadOnlyResourceProvider {
- protected static final String SERVICE_NAME_PROPERTY_ID = PropertyHelper.getPropertyId(
- "StackServices", "service_name");
-
- public static final String STACK_NAME_PROPERTY_ID = PropertyHelper.getPropertyId(
- "StackServices", "stack_name");
-
- public static final String STACK_VERSION_PROPERTY_ID = PropertyHelper.getPropertyId(
- "StackServices", "stack_version");
+ protected static final String SERVICE_NAME_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackServices", "service_name");
- private static final String SERVICE_DISPLAY_NAME_PROPERTY_ID = PropertyHelper.getPropertyId(
- "StackServices", "display_name");
+ public static final String STACK_NAME_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackServices", "stack_name");
- private static final String USER_NAME_PROPERTY_ID = PropertyHelper.getPropertyId(
- "StackServices", "user_name");
+ public static final String STACK_VERSION_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackServices", "stack_version");
- private static final String COMMENTS_PROPERTY_ID = PropertyHelper.getPropertyId(
- "StackServices", "comments");
+ private static final String USER_NAME_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackServices", "user_name");
- private static final String VERSION_PROPERTY_ID = PropertyHelper.getPropertyId(
- "StackServices", "service_version");
+ private static final String COMMENTS_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackServices", "comments");
- private static final String CONFIG_TYPES = PropertyHelper.getPropertyId(
- "StackServices", "config_types");
+ private static final String VERSION_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackServices", "service_version");
- private static final String REQUIRED_SERVICES_ID = PropertyHelper.getPropertyId(
- "StackServices", "required_services");
-
- private static final String SERVICE_CHECK_SUPPORTED_PROPERTY_ID = PropertyHelper.getPropertyId(
- "StackServices", "service_check_supported");
-
- private static final String CUSTOM_COMMANDS_PROPERTY_ID = PropertyHelper.getPropertyId(
- "StackServices", "custom_commands");
+ private static final String CONFIG_TYPES = PropertyHelper
+ .getPropertyId("StackServices", "config_types");
private static Set<String> pkPropertyIds = new HashSet<String>(
Arrays.asList(new String[] { STACK_NAME_PROPERTY_ID,
@@ -112,29 +110,17 @@ public class StackServiceResourceProvider extends ReadOnlyResourceProvider {
setResourceProperty(resource, SERVICE_NAME_PROPERTY_ID,
response.getServiceName(), requestedIds);
- setResourceProperty(resource, SERVICE_DISPLAY_NAME_PROPERTY_ID,
- response.getServiceDisplayName(), requestedIds);
-
setResourceProperty(resource, USER_NAME_PROPERTY_ID,
response.getUserName(), requestedIds);
setResourceProperty(resource, COMMENTS_PROPERTY_ID,
response.getComments(), requestedIds);
-
+
setResourceProperty(resource, VERSION_PROPERTY_ID,
response.getServiceVersion(), requestedIds);
-
+
setResourceProperty(resource, CONFIG_TYPES,
response.getConfigTypes(), requestedIds);
-
- setResourceProperty(resource, REQUIRED_SERVICES_ID,
- response.getRequiredServices(), requestedIds);
-
- setResourceProperty(resource, SERVICE_CHECK_SUPPORTED_PROPERTY_ID,
- response.isServiceCheckSupported(), requestedIds);
-
- setResourceProperty(resource, CUSTOM_COMMANDS_PROPERTY_ID,
- response.getCustomCommands(), requestedIds);
resources.add(resource);
}