You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ma...@apache.org on 2012/10/24 08:37:25 UTC
svn commit: r1401567 [1/2] - in /incubator/ambari/branches/AMBARI-666: ./
ambari-server/src/main/java/org/apache/ambari/server/actionmanager/
ambari-server/src/main/java/org/apache/ambari/server/agent/
ambari-server/src/main/java/org/apache/ambari/serv...
Author: mahadev
Date: Wed Oct 24 06:37:23 2012
New Revision: 1401567
URL: http://svn.apache.org/viewvc?rev=1401567&view=rev
Log:
AMBARI-903. Various fixes for config handling integration. (Hitesh Shah via mahadev)
Added:
incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
Modified:
incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ConfigurationService.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/Request.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/serializers/JsonSerializer.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/util/TreeNodeImpl.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ganglia/GangliaPropertyProvider.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ResourceProvider.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterServiceDAO.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/SignCertResponse.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AmbariLdapAuthoritiesPopulator.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AmbariLocalUserDetailsService.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AuthorizationHelper.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/stageplanner/RoleGraph.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Clusters.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/utils/JaxbMapKeyMapAdapter.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionManager.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/api/handlers/ReadHandlerTest.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/api/services/serializers/JsonSerializerTest.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/JMXPropertyProviderTest.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/jmx/TestHostMappingProvider.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/LdapServerPropertiesTest.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/stageplanner/TestStagePlanner.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceComponentTest.java
incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostTest.java
Modified: incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt (original)
+++ incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt Wed Oct 24 06:37:23 2012
@@ -12,6 +12,9 @@ AMBARI-666 branch (unreleased changes)
NEW FEATURES
+ AMBARI-903. Various fixes for config handling integration. (Hitesh Shah via
+ mahadev)
+
AMBARI-900. Add configuration mapping support. (Nate Cole via mahadev)
AMBARI-895. Need name consistency for metrics. (Tom Beerbower via mahadev)
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java Wed Oct 24 06:37:23 2012
@@ -39,7 +39,7 @@ import org.slf4j.LoggerFactory;
@Singleton
public class ActionDBAccessorImpl implements ActionDBAccessor {
- private static final Logger log = LoggerFactory.getLogger(ActionDBAccessorImpl.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ActionDBAccessorImpl.class);
@Inject
private ClusterDAO clusterDAO;
@@ -95,7 +95,7 @@ public class ActionDBAccessorImpl implem
public void abortOperation(long requestId) {
Collection<HostRoleStatus> sourceStatuses = Arrays.asList(HostRoleStatus.QUEUED, HostRoleStatus.IN_PROGRESS, HostRoleStatus.PENDING);
int result = hostRoleCommandDAO.updateStatusByRequestId(requestId, HostRoleStatus.ABORTED, sourceStatuses);
- log.info("Aborted {} commands", result);
+ LOG.info("Aborted {} commands", result);
}
/* (non-Javadoc)
@@ -117,7 +117,11 @@ public class ActionDBAccessorImpl implem
@Override
public List<Stage> getStagesInProgress() {
List<Stage> stages = new ArrayList<Stage>();
- for (StageEntity stageEntity : stageDAO.findByCommandStatuses(Arrays.asList(HostRoleStatus.IN_PROGRESS))) {
+ List<HostRoleStatus> statuses = new ArrayList<HostRoleStatus>();
+ statuses.add(HostRoleStatus.PENDING);
+ statuses.add(HostRoleStatus.QUEUED);
+ statuses.add(HostRoleStatus.IN_PROGRESS);
+ for (StageEntity stageEntity : stageDAO.findByCommandStatuses(statuses)) {
stages.add(stageFactory.createExisting(stageEntity));
}
return stages;
@@ -129,6 +133,10 @@ public class ActionDBAccessorImpl implem
@Override
@Transactional
public void persistActions(List<Stage> stages) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Adding stages to DB, stageCount=" + stages.size());
+ }
+
for (Stage stage : stages) {
StageEntity stageEntity = stage.constructNewPersistenceEntity();
Cluster cluster;
@@ -149,7 +157,7 @@ public class ActionDBAccessorImpl implem
HostEntity hostEntity = hostDAO.findByName(hostRoleCommandEntity.getHostName());
if (hostEntity == null) {
- log.error("Host {} doesn't exists in database", hostRoleCommandEntity.getHostName());
+ LOG.error("Host {} doesn't exists in database", hostRoleCommandEntity.getHostName());
throw new RuntimeException("Host '"+hostRoleCommandEntity.getHostName()+"' doesn't exists in database");
}
hostEntity.getHostRoleCommandEntities().add(hostRoleCommandEntity);
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java Wed Oct 24 06:37:23 2012
@@ -81,7 +81,10 @@ public class HeartBeatHandler {
LOG.info("Heartbeat received from host " + heartbeat.getHostname()
+ " responseId=" + heartbeat.getResponseId());
Host hostObject = clusterFsm.getHost(hostname);
+
long now = System.currentTimeMillis();
+ hostObject.refresh();
+
try {
if (heartbeat.getNodeStatus().getStatus()
.equals(HostStatus.Status.HEALTHY)) {
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ConfigurationService.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ConfigurationService.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ConfigurationService.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ConfigurationService.java Wed Oct 24 06:37:23 2012
@@ -60,7 +60,7 @@ public class ConfigurationService extend
public Response getConfigurations(@Context HttpHeaders headers, @Context UriInfo ui) {
return handleRequest(headers, null, ui, Request.Type.GET,
createResourceDefinition(null, null, m_clusterName));
- }
+ }
/**
* Handles URL: /clusters/{clusterId}/configurations. The body should contain:
@@ -85,11 +85,11 @@ public class ConfigurationService extend
@PUT
@Produces("text/plain")
public Response createConfigurations(String body,@Context HttpHeaders headers, @Context UriInfo ui) {
-
+
return handleRequest(headers, body, ui, Request.Type.PUT,
createResourceDefinition(null, null, m_clusterName));
- }
-
+ }
+
/**
* Create a service resource definition.
*
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/Request.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/Request.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/Request.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/Request.java Wed Oct 24 06:37:23 2012
@@ -24,10 +24,8 @@ import org.apache.ambari.server.controll
import org.apache.ambari.server.controller.spi.PropertyId;
import org.apache.ambari.server.controller.spi.TemporalInfo;
-import java.net.URI;
import java.util.List;
import java.util.Map;
-import java.util.Set;
/**
* Provides information on the current request.
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/serializers/JsonSerializer.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/serializers/JsonSerializer.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/serializers/JsonSerializer.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/serializers/JsonSerializer.java Wed Oct 24 06:37:23 2012
@@ -21,7 +21,6 @@ package org.apache.ambari.server.api.ser
import org.apache.ambari.server.api.services.Result;
import org.apache.ambari.server.controller.spi.Resource;
import org.apache.ambari.server.api.util.TreeNode;
-import org.apache.log4j.Category;
import org.codehaus.jackson.JsonFactory;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.util.DefaultPrettyPrinter;
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/util/TreeNodeImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/util/TreeNodeImpl.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/util/TreeNodeImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/util/TreeNodeImpl.java Wed Oct 24 06:37:23 2012
@@ -20,7 +20,6 @@ package org.apache.ambari.server.api.uti
import java.util.Collection;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
/**
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java Wed Oct 24 06:37:23 2012
@@ -600,9 +600,21 @@ public class AmbariManagementControllerI
request.getComponentName());
Host host = clusters.getHost(request.getHostname());
Set<Cluster> mappedClusters =
- clusters.getClustersForHost(host.getHostName());
+ clusters.getClustersForHost(request.getHostname());
boolean validCluster = false;
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Looking to match host to cluster"
+ + ", hostnameViaReg=" + host.getHostName()
+ + ", hostname=" + request.getHostname()
+ + ", clusterName=" + request.getClusterName()
+ + ", hostClusterMapCount=" + mappedClusters.size());
+ }
for (Cluster mappedCluster : mappedClusters) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Host belongs to cluster"
+ + ", hostname=" + request.getHostname()
+ + ", clusterName=" + mappedCluster.getClusterName());
+ }
if (mappedCluster.getClusterName().equals(
request.getClusterName())) {
validCluster = true;
@@ -727,7 +739,7 @@ public class AmbariManagementControllerI
cluster.addDesiredConfig(config);
- // TODO
+ // TODO fix return value
return null;
}
@@ -750,6 +762,7 @@ public class AmbariManagementControllerI
scHost.getServiceName());
ExecutionCommand execCmd = stage.getExecutionCommand(scHost.getHostName(),
scHost.getServiceComponentName());
+
// Generate cluster host info
// TODO fix - use something from somewhere to generate this at some point
Map<String, List<String>> clusterHostInfo =
@@ -762,13 +775,21 @@ public class AmbariManagementControllerI
execCmd.setClusterHostInfo(clusterHostInfo);
// TODO do something from configs here
- Map<String, String> hdfsSite = new TreeMap<String, String>();
- hdfsSite.put("fs.default.name", "hdfs://localhost:50070");
- hdfsSite.put("dfs.block.size", "2560000000");
- hdfsSite.put("magic_config_string", "magic_blah");
Map<String, Map<String, String>> configurations =
new TreeMap<String, Map<String, String>>();
- configurations.put("hdfs-site", hdfsSite);
+ for (Config config : configs.values()) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Attaching configs to execution command"
+ + ", configType=" + config.getType()
+ + ", configVersionTag=" + config.getVersionTag()
+ + ", clusterName=" + scHost.getClusterName()
+ + ", serviceName=" + scHost.getServiceName()
+ + ", componentName=" + scHost.getServiceComponentName()
+ + ", hostname=" + scHost.getHostName());
+ }
+ configurations.put(config.getType(),
+ config.getProperties());
+ }
execCmd.setConfigurations(configurations);
Map<String, String> params = new TreeMap<String, String>();
@@ -807,6 +828,9 @@ public class AmbariManagementControllerI
}
response.add(c.convertToResponse());
}
+ StringBuilder builder = new StringBuilder();
+ clusters.debugDump(builder);
+ LOG.info("Cluster State for cluster " + builder.toString());
return response;
}
@@ -1067,12 +1091,12 @@ public class AmbariManagementControllerI
} else {
// !!! all configuration
Collection<Config> all = cluster.getAllConfigs();
-
+
for (Config config : all) {
ConfigurationResponse response = new ConfigurationResponse(
cluster.getClusterName(), config.getType(), config.getVersionTag(),
new HashMap<String, String>());
-
+
responses.add(response);
}
}
@@ -1135,8 +1159,6 @@ public class AmbariManagementControllerI
// verify all configs
// verify all required components
- // TODO order hostcomponents to determine stages
-
// TODO lets continue hacking
long nowTimestamp = System.currentTimeMillis();
@@ -1151,7 +1173,8 @@ public class AmbariManagementControllerI
for (State newState : changedScHosts.get(compName).keySet()) {
for (ServiceComponentHost scHost :
changedScHosts.get(compName).get(newState)) {
- Map<String, Config> configs = null;
+ // FIXME file configs with appropriate configs for this
+ // scHost instance if action is install or start
RoleCommand roleCommand;
State oldSchState = scHost.getDesiredState();
ServiceComponentHostEvent event;
@@ -1177,7 +1200,7 @@ public class AmbariManagementControllerI
+ ", serviceName=" + scHost.getServiceName()
+ ", componentName=" + scHost.getServiceComponentName()
+ ", hostname=" + scHost.getHostName()
- + ", oldDesiredState=" + oldSchState
+ + ", currentDesiredState=" + oldSchState
+ ", newDesiredState" + newState);
}
break;
@@ -1195,7 +1218,7 @@ public class AmbariManagementControllerI
+ ", serviceName=" + scHost.getServiceName()
+ ", componentName=" + scHost.getServiceComponentName()
+ ", hostname=" + scHost.getHostName()
- + ", oldDesiredState=" + oldSchState
+ + ", currentDesiredState=" + oldSchState
+ ", newDesiredState" + newState);
}
break;
@@ -1211,6 +1234,8 @@ public class AmbariManagementControllerI
+ ", hostname=" + scHost.getHostName()
+ ", roleCommand=" + roleCommand.name());
}
+
+ Map<String, Config> configs = scHost.getDesiredConfigs();
createHostAction(stage, scHost, configs, roleCommand,
nowTimestamp, event);
}
@@ -1255,6 +1280,9 @@ public class AmbariManagementControllerI
+ ", clusterName=" + cluster.getClusterName()
+ ", requestId=" + requestId
+ ", stagesCount=" + stages.size());
+ for (Stage stagetmp: stages) {
+ LOG.debug("Stage tmp dump: " + stagetmp.toString());
+ }
}
actionManager.sendActions(stages);
@@ -1282,6 +1310,102 @@ public class AmbariManagementControllerI
return false;
}
+ private void safeToUpdateConfigsForServiceComponentHost(
+ ServiceComponentHost sch,
+ State currentDesiredState, State newDesiredState)
+ throws AmbariException {
+ if (currentDesiredState == State.STARTED) {
+ throw new AmbariException("Changing of configs not supported"
+ + " in STARTED state"
+ + ", clusterName=" + sch.getClusterName()
+ + ", serviceName=" + sch.getServiceName()
+ + ", componentName=" + sch.getServiceComponentName()
+ + ", hostname=" + sch.getHostName()
+ + ", currentDesiredState=" + currentDesiredState
+ + ", newDesiredState" + newDesiredState);
+ }
+
+ if (newDesiredState != null) {
+ if (!(newDesiredState == State.INIT
+ || newDesiredState == State.INSTALLED
+ || newDesiredState == State.STARTED)) {
+ throw new AmbariException("Changing of configs not supported"
+ + " for this transition"
+ + ", clusterName=" + sch.getClusterName()
+ + ", serviceName=" + sch.getServiceName()
+ + ", componentName=" + sch.getServiceComponentName()
+ + ", hostname=" + sch.getHostName()
+ + ", currentDesiredState=" + currentDesiredState
+ + ", newDesiredState" + newDesiredState);
+ }
+ }
+ }
+
+ private void safeToUpdateConfigsForServiceComponent(
+ ServiceComponent sc,
+ State currentDesiredState, State newDesiredState)
+ throws AmbariException {
+ if (currentDesiredState == State.STARTED) {
+ throw new AmbariException("Changing of configs not supported"
+ + " in STARTED state"
+ + ", clusterName=" + sc.getClusterName()
+ + ", serviceName=" + sc.getServiceName()
+ + ", componentName=" + sc.getName()
+ + ", currentDesiredState=" + currentDesiredState
+ + ", newDesiredState" + newDesiredState);
+ }
+
+ if (newDesiredState != null) {
+ if (!(newDesiredState == State.INIT
+ || newDesiredState == State.INSTALLED
+ || newDesiredState == State.STARTED)) {
+ throw new AmbariException("Changing of configs not supported"
+ + " for this transition"
+ + ", clusterName=" + sc.getClusterName()
+ + ", serviceName=" + sc.getServiceName()
+ + ", componentName=" + sc.getName()
+ + ", currentDesiredState=" + currentDesiredState
+ + ", newDesiredState" + newDesiredState);
+ }
+ }
+ for (ServiceComponentHost sch :
+ sc.getServiceComponentHosts().values()) {
+ safeToUpdateConfigsForServiceComponentHost(sch,
+ sch.getDesiredState(), newDesiredState);
+ }
+ }
+
+ private void safeToUpdateConfigsForService(Service service,
+ State currentDesiredState, State newDesiredState)
+ throws AmbariException {
+ if (currentDesiredState == State.STARTED) {
+ throw new AmbariException("Changing of configs not supported"
+ + " in STARTED state"
+ + ", clusterName=" + service.getCluster().getClusterName()
+ + ", serviceName=" + service.getName()
+ + ", currentDesiredState=" + currentDesiredState
+ + ", newDesiredState" + newDesiredState);
+ }
+
+ if (newDesiredState != null) {
+ if (!(newDesiredState == State.INIT
+ || newDesiredState == State.INSTALLED
+ || newDesiredState == State.STARTED)) {
+ throw new AmbariException("Changing of configs not supported"
+ + " for this transition"
+ + ", clusterName=" + service.getCluster().getClusterName()
+ + ", serviceName=" + service.getName()
+ + ", currentDesiredState=" + currentDesiredState
+ + ", newDesiredState" + newDesiredState);
+ }
+ }
+
+ for (ServiceComponent component :
+ service.getServiceComponents().values()) {
+ safeToUpdateConfigsForServiceComponent(component,
+ component.getDesiredState(), newDesiredState);
+ }
+ }
@Override
public synchronized TrackActionResponse updateServices(Set<ServiceRequest> requests)
@@ -1345,30 +1469,41 @@ public class AmbariManagementControllerI
// FIXME validate valid services
Cluster cluster = clusters.getCluster(request.getClusterName());
Service s = cluster.getService(request.getServiceName());
+ State oldState = s.getDesiredState();
+ State newState = null;
+ if (request.getDesiredState() != null) {
+ newState = State.valueOf(request.getDesiredState());
+ if (!newState.isValidDesiredState()) {
+ // FIXME fix with appropriate exception
+ throw new AmbariException("Invalid desired state");
+ }
+ }
if (request.getConfigVersions() != null) {
- Map<String, Config> updated = new HashMap<String, Config>();
-
- for (Entry<String,String> entry : request.getConfigVersions().entrySet()) {
- Config config = cluster.getDesiredConfig(entry.getKey(), entry.getValue());
- if (null != config) {
- updated.put(config.getType(), config);
- }
-
- if (0 != updated.size()) {
- s.updateDesiredConfigs(updated);
- s.persist();
+ // validate whether changing configs is allowed
+ // FIXME this will need to change for cascading updates
+ // need to check all components and hostcomponents for correct state
+ safeToUpdateConfigsForService(s, oldState, newState);
+
+ for (Entry<String,String> entry :
+ request.getConfigVersions().entrySet()) {
+ Config config = cluster.getDesiredConfig(
+ entry.getKey(), entry.getValue());
+ if (null == config) {
+ // throw error for invalid config
+ throw new AmbariException("Trying to update service with"
+ + " invalid configs"
+ + ", clusterName=" + cluster.getClusterName()
+ + ", clusterId=" + cluster.getClusterId()
+ + ", serviceName=" + s.getName()
+ + ", invalidConfigType=" + entry.getKey()
+ + ", invalidConfigTag=" + entry.getValue());
}
-
}
-
- // TODO handle config updates
- // handle recursive updates to all components and hostcomponents
- // if different from old desired configs, trigger relevant actions
}
- if (request.getDesiredState() == null
- || request.getDesiredState().isEmpty()) {
+
+ if (newState == null) {
if (LOG.isDebugEnabled()) {
LOG.debug("Nothing to do for new updateService request"
+ ", clusterName=" + request.getClusterName()
@@ -1378,15 +1513,8 @@ public class AmbariManagementControllerI
continue;
}
- State newState = State.valueOf(request.getDesiredState());
- if (!newState.isValidDesiredState()) {
- // FIXME fix with appropriate exception
- throw new AmbariException("Invalid desired state");
- }
-
seenNewStates.add(newState);
- State oldState = s.getDesiredState();
if (newState != oldState) {
if (!isValidTransition(oldState, newState)) {
// FIXME throw correct error
@@ -1394,7 +1522,7 @@ public class AmbariManagementControllerI
+ ", clusterName=" + cluster.getClusterName()
+ ", clusterId=" + cluster.getClusterId()
+ ", serviceName=" + s.getName()
- + ", oldDesiredState=" + oldState
+ + ", currentDesiredState=" + oldState
+ ", newDesiredState" + newState);
}
@@ -1404,6 +1532,7 @@ public class AmbariManagementControllerI
changedServices.get(newState).add(s);
}
+
// should we check whether all servicecomponents and
// servicecomponenthosts are in the required desired state?
// For now, checking as no live state comparison
@@ -1426,7 +1555,7 @@ public class AmbariManagementControllerI
+ ", clusterId=" + cluster.getClusterId()
+ ", serviceName=" + sc.getServiceName()
+ ", componentName=" + sc.getName()
- + ", oldDesiredState=" + oldScState
+ + ", currentDesiredState=" + oldScState
+ ", newDesiredState" + newState);
}
if (!changedComps.containsKey(newState)) {
@@ -1439,7 +1568,7 @@ public class AmbariManagementControllerI
+ ", clusterName=" + request.getClusterName()
+ ", serviceName=" + s.getName()
+ ", componentName=" + sc.getName()
- + ", oldDesiredState=" + oldScState
+ + ", currentDesiredState=" + oldScState
+ ", newDesiredState=" + newState);
}
for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()){
@@ -1451,7 +1580,7 @@ public class AmbariManagementControllerI
+ ", serviceName=" + s.getName()
+ ", componentName=" + sc.getName()
+ ", hostname=" + sch.getHostName()
- + ", oldDesiredState=" + oldSchState
+ + ", currentDesiredState=" + oldSchState
+ ", newDesiredState=" + newState);
}
continue;
@@ -1468,7 +1597,7 @@ public class AmbariManagementControllerI
+ ", serviceName=" + sch.getServiceName()
+ ", componentName=" + sch.getServiceComponentName()
+ ", hostname=" + sch.getHostName()
- + ", oldDesiredState=" + oldSchState
+ + ", currentDesiredState=" + oldSchState
+ ", newDesiredState" + newState);
}
if (!changedScHosts.containsKey(sc.getName())) {
@@ -1485,7 +1614,7 @@ public class AmbariManagementControllerI
+ ", serviceName=" + s.getName()
+ ", componentName=" + sc.getName()
+ ", hostname=" + sch.getHostName()
- + ", oldDesiredState=" + oldSchState
+ + ", currentDesiredState=" + oldSchState
+ ", newDesiredState=" + newState);
}
changedScHosts.get(sc.getName()).get(newState).add(sch);
@@ -1499,7 +1628,26 @@ public class AmbariManagementControllerI
+ " for a set of services at the same time");
}
- // TODO fix dup handling for multiple services in requests
+ for (ServiceRequest request : requests) {
+ Cluster cluster = clusters.getCluster(request.getClusterName());
+ Service s = cluster.getService(request.getServiceName());
+ if (request.getConfigVersions() != null) {
+ Map<String, Config> updated = new HashMap<String, Config>();
+
+ for (Entry<String,String> entry : request.getConfigVersions().entrySet()) {
+ Config config = cluster.getDesiredConfig(entry.getKey(), entry.getValue());
+ updated.put(config.getType(), config);
+ if (!updated.isEmpty()) {
+ s.updateDesiredConfigs(updated);
+ s.persist();
+ }
+
+ // FIXME delete relevant config types at component
+ // and hostcomponent level
+ // handle recursive updates to all components and hostcomponents
+ }
+ }
+ }
Cluster cluster = clusters.getCluster(clusterNames.iterator().next());
@@ -1585,19 +1733,19 @@ public class AmbariManagementControllerI
if (request.getConfigVersions() != null) {
Map<String, Config> updated = new HashMap<String, Config>();
-
+
for (Entry<String,String> entry : request.getConfigVersions().entrySet()) {
Config config = cluster.getDesiredConfig(entry.getKey(), entry.getValue());
if (null != config) {
updated.put(config.getType(), config);
}
-
+
if (0 != updated.size()) {
sc.updateDesiredConfigs(updated);
sc.persist();
}
}
-
+
// TODO handle config updates
// handle recursive updates to all components and hostcomponents
// if different from old desired configs, trigger relevant actions
@@ -1638,7 +1786,7 @@ public class AmbariManagementControllerI
+ ", clusterId=" + cluster.getClusterId()
+ ", serviceName=" + sc.getServiceName()
+ ", componentName=" + sc.getName()
- + ", oldDesiredState=" + oldScState
+ + ", currentDesiredState=" + oldScState
+ ", newDesiredState" + newState);
}
if (!changedComps.containsKey(newState)) {
@@ -1649,7 +1797,7 @@ public class AmbariManagementControllerI
+ ", clusterName=" + request.getClusterName()
+ ", serviceName=" + s.getName()
+ ", componentName=" + sc.getName()
- + ", oldDesiredState=" + oldScState
+ + ", currentDesiredState=" + oldScState
+ ", newDesiredState=" + newState);
}
changedComps.get(newState).add(sc);
@@ -1668,7 +1816,7 @@ public class AmbariManagementControllerI
+ ", serviceName=" + s.getName()
+ ", componentName=" + sc.getName()
+ ", hostname=" + sch.getHostName()
- + ", oldDesiredState=" + oldSchState
+ + ", currentDesiredState=" + oldSchState
+ ", newDesiredState=" + newState);
}
continue;
@@ -1681,7 +1829,7 @@ public class AmbariManagementControllerI
+ ", serviceName=" + sch.getServiceName()
+ ", componentName=" + sch.getServiceComponentName()
+ ", hostname=" + sch.getHostName()
- + ", oldDesiredState=" + oldSchState
+ + ", currentDesiredState=" + oldSchState
+ ", newDesiredState" + newState);
}
if (!changedScHosts.containsKey(sc.getName())) {
@@ -1698,7 +1846,7 @@ public class AmbariManagementControllerI
+ ", serviceName=" + s.getName()
+ ", componentName=" + sc.getName()
+ ", hostname=" + sch.getHostName()
- + ", oldDesiredState=" + oldSchState
+ + ", currentDesiredState=" + oldSchState
+ ", newDesiredState=" + newState);
}
changedScHosts.get(sc.getName()).get(newState).add(sch);
@@ -1842,19 +1990,19 @@ public class AmbariManagementControllerI
if (request.getConfigVersions() != null) {
Map<String, Config> updated = new HashMap<String, Config>();
-
+
for (Entry<String,String> entry : request.getConfigVersions().entrySet()) {
Config config = cluster.getDesiredConfig(entry.getKey(), entry.getValue());
if (null != config) {
updated.put(config.getType(), config);
}
-
+
if (0 != updated.size()) {
sch.updateDesiredConfigs(updated);
sch.persist();
}
}
-
+
// TODO handle config updates
// handle recursive updates to all components and hostcomponents
// if different from old desired configs, trigger relevant actions
@@ -1895,7 +2043,7 @@ public class AmbariManagementControllerI
+ ", serviceName=" + s.getName()
+ ", componentName=" + sc.getName()
+ ", hostname=" + sch.getHostName()
- + ", oldDesiredState=" + oldSchState
+ + ", currentDesiredState=" + oldSchState
+ ", newDesiredState=" + newState);
}
continue;
@@ -1909,7 +2057,7 @@ public class AmbariManagementControllerI
+ ", serviceName=" + sch.getServiceName()
+ ", componentName=" + sch.getServiceComponentName()
+ ", hostname=" + sch.getHostName()
- + ", oldDesiredState=" + oldSchState
+ + ", currentDesiredState=" + oldSchState
+ ", newDesiredState" + newState);
}
if (!changedScHosts.containsKey(sc.getName())) {
@@ -1926,7 +2074,7 @@ public class AmbariManagementControllerI
+ ", serviceName=" + s.getName()
+ ", componentName=" + sc.getName()
+ ", hostname=" + sch.getHostName()
- + ", oldDesiredState=" + oldSchState
+ + ", currentDesiredState=" + oldSchState
+ ", newDesiredState=" + newState);
}
changedScHosts.get(sc.getName()).get(newState).add(sch);
@@ -1960,26 +2108,12 @@ public class AmbariManagementControllerI
}
LOG.info("Received a delete cluster request"
+ ", clusterName=" + request.getClusterName());
- Cluster cluster = clusters.getCluster(request.getClusterName());
- if (!cluster.getServices().isEmpty()) {
- // FIXME should we be looking at live state of all components and
- // host components?
- boolean nonDeletableService = false;
- for (Service service : cluster.getServices().values()) {
- if (!service.canBeRemoved()) {
- nonDeletableService = true;
- LOG.warn("Found non removable service when trying to delete cluster"
- + ", clusterName=" + request.getClusterName()
- + ", serviceName=" + service.getName());
- }
- }
- if (nonDeletableService) {
- throw new AmbariException("Cannot delete cluster as it has services"
- + " that cannot be deleted");
- }
+ if (request.getHostNames() != null) {
+ // FIXME treat this as removing a host from a cluster?
+ } else {
+ // deleting whole cluster
+ clusters.deleteCluster(request.getClusterName());
}
- cluster.deleteAllServices();
- clusters.deleteCluster(request.getClusterName());
}
@Override
@@ -2020,7 +2154,7 @@ public class AmbariManagementControllerI
public void getOperations(Set<OperationRequest> request)
throws AmbariException {
// TODO Auto-generated method stub
-
+
}
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ganglia/GangliaPropertyProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ganglia/GangliaPropertyProvider.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ganglia/GangliaPropertyProvider.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ganglia/GangliaPropertyProvider.java Wed Oct 24 06:37:23 2012
@@ -19,7 +19,6 @@
package org.apache.ambari.server.controller.ganglia;
import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.controller.internal.TemporalInfoImpl;
import org.apache.ambari.server.controller.spi.*;
import org.apache.ambari.server.controller.utilities.PropertyHelper;
import org.apache.ambari.server.controller.utilities.StreamProvider;
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ResourceProvider.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ResourceProvider.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ResourceProvider.java Wed Oct 24 06:37:23 2012
@@ -19,7 +19,6 @@ package org.apache.ambari.server.control
import org.apache.ambari.server.AmbariException;
-import java.util.List;
import java.util.Map;
import java.util.Set;
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterServiceDAO.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterServiceDAO.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterServiceDAO.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterServiceDAO.java Wed Oct 24 06:37:23 2012
@@ -21,7 +21,6 @@ package org.apache.ambari.server.orm.dao
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.persist.Transactional;
-import org.apache.ambari.server.orm.entities.ClusterEntity;
import org.apache.ambari.server.orm.entities.ClusterServiceEntity;
import org.apache.ambari.server.orm.entities.ClusterServiceEntityPK;
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/SignCertResponse.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/SignCertResponse.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/SignCertResponse.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/SignCertResponse.java Wed Oct 24 06:37:23 2012
@@ -24,10 +24,6 @@ import javax.xml.bind.annotation.XmlElem
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
-import org.apache.commons.logging.Log;
-
-
-
/**
*
* Sign certificate response data model.
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AmbariLdapAuthoritiesPopulator.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AmbariLdapAuthoritiesPopulator.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AmbariLdapAuthoritiesPopulator.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AmbariLdapAuthoritiesPopulator.java Wed Oct 24 06:37:23 2012
@@ -30,7 +30,6 @@ import org.springframework.ldap.core.Dir
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.ldap.userdetails.LdapAuthoritiesPopulator;
-import javax.persistence.NoResultException;
import java.util.Collection;
/**
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AmbariLocalUserDetailsService.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AmbariLocalUserDetailsService.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AmbariLocalUserDetailsService.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AmbariLocalUserDetailsService.java Wed Oct 24 06:37:23 2012
@@ -22,21 +22,14 @@ import com.google.inject.Injector;
import org.apache.ambari.server.configuration.Configuration;
import org.apache.ambari.server.orm.dao.RoleDAO;
import org.apache.ambari.server.orm.dao.UserDAO;
-import org.apache.ambari.server.orm.entities.RoleEntity;
import org.apache.ambari.server.orm.entities.UserEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.security.core.GrantedAuthority;
-import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
-import org.springframework.security.ldap.userdetails.LdapUserDetailsService;
-import javax.persistence.NoResultException;
-import java.util.ArrayList;
-import java.util.List;
public class AmbariLocalUserDetailsService implements UserDetailsService {
private static final Logger log = LoggerFactory.getLogger(AmbariLocalUserDetailsService.class);
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AuthorizationHelper.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AuthorizationHelper.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AuthorizationHelper.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/AuthorizationHelper.java Wed Oct 24 06:37:23 2012
@@ -25,7 +25,6 @@ import org.springframework.security.core
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import java.util.Set;
@Singleton
/**
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/stageplanner/RoleGraph.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/stageplanner/RoleGraph.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/stageplanner/RoleGraph.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/stageplanner/RoleGraph.java Wed Oct 24 06:37:23 2012
@@ -29,18 +29,18 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class RoleGraph {
-
+
private static Log LOG = LogFactory.getLog(RoleGraph.class);
-
+
Map<String, RoleGraphNode> graph = null;
private RoleCommandOrder roleDependencies;
private Stage initialStage = null;
private boolean sameHostOptimization = true;
-
+
public RoleGraph(RoleCommandOrder rd) {
this.roleDependencies = rd;
}
-
+
/**
* Given a stage builds a DAG of all execution commands within the stage.
*/
@@ -83,7 +83,7 @@ public class RoleGraph {
}
}
}
-
+
/**
* Returns a list of stages that need to be executed one after another
* to execute the DAG generated in the last {@link #build(Stage)} call.
@@ -102,7 +102,7 @@ public class RoleGraph {
}
}
Stage aStage = getStageFromGraphNodes(initialStage, firstStageNodes);
- aStage.setStageId(initialStageId++);
+ aStage.setStageId(++initialStageId);
stageList.add(aStage);
//Remove first stage nodes from the graph, we know that none of
//these nodes have an incoming edges.
@@ -140,7 +140,7 @@ public class RoleGraph {
}
return newStage;
}
-
+
public String stringifyGraph() {
StringBuilder builder = new StringBuilder();
builder.append("Graph:\n");
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java Wed Oct 24 06:37:23 2012
@@ -87,7 +87,7 @@ public interface Cluster {
public void addDesiredConfig(Config config);
public Collection<Config> getAllConfigs();
-
+
public ClusterResponse convertToResponse() throws AmbariException;
public void refresh();
@@ -99,4 +99,6 @@ public interface Cluster {
public void deleteAllServices() throws AmbariException;
public void deleteService(String serviceName) throws AmbariException;
+
+ public boolean canBeRemoved();
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Clusters.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Clusters.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Clusters.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Clusters.java Wed Oct 24 06:37:23 2012
@@ -103,6 +103,6 @@ public interface Clusters {
public Map<String, Host> getHostsForCluster(String clusterName)
throws AmbariException;
- public void deleteCluster(String clusterName);
+ public void deleteCluster(String clusterName) throws AmbariException;
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java Wed Oct 24 06:37:23 2012
@@ -75,4 +75,10 @@ public interface Service {
* @return
*/
public boolean canBeRemoved();
+
+ public void removeAllComponents() throws AmbariException;
+
+ public void deleteServiceComponent(String componentName)
+ throws AmbariException;
+
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java Wed Oct 24 06:37:23 2012
@@ -70,4 +70,11 @@ public interface ServiceComponent {
public boolean isClientComponent();
+ public boolean canBeRemoved();
+
+ public void removeAllServiceComponentHosts() throws AmbariException;
+
+ public void removeServiceComponentHosts(String hostname)
+ throws AmbariException;
+
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java Wed Oct 24 06:37:23 2012
@@ -106,4 +106,6 @@ public interface ServiceComponentHost {
void refresh();
public void debugDump(StringBuilder sb);
+
+ public boolean canBeRemoved();
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java Wed Oct 24 06:37:23 2012
@@ -70,7 +70,7 @@ public class ServiceComponentImpl implem
private final boolean isClientComponent;
private void init() {
- // TODO
+ // TODO load during restart
// initialize from DB
}
@@ -122,7 +122,7 @@ public class ServiceComponentImpl implem
hostComponents.put(hostComponentStateEntity.getComponentName(),
serviceComponentHostFactory.createExisting(this, hostComponentStateEntity, hostComponentDesiredStateEntity));
}
-
+
for (ComponentConfigMappingEntity entity : desiredStateEntity.getComponentConfigMappingEntities()) {
desiredConfigs.put(entity.getConfigType(), entity.getVersionTag());
}
@@ -264,6 +264,14 @@ public class ServiceComponentImpl implem
map.put(entry.getKey(), config);
}
}
+
+ Map<String, Config> svcConfigs = service.getDesiredConfigs();
+ for (Entry<String, Config> entry : svcConfigs.entrySet()) {
+ if (!map.containsKey(entry.getKey())) {
+ map.put(entry.getKey(), entry.getValue());
+ }
+ }
+
return Collections.unmodifiableMap(map);
}
@@ -277,7 +285,7 @@ public class ServiceComponentImpl implem
newEntity.setConfigType(entry.getKey());
newEntity.setVersionTag(entry.getValue().getVersionTag());
newEntity.setTimestamp(Long.valueOf(new java.util.Date().getTime()));
-
+
if (!desiredStateEntity.getComponentConfigMappingEntities().contains(newEntity)) {
newEntity.setServiceComponentDesiredStateEntity(desiredStateEntity);
desiredStateEntity.getComponentConfigMappingEntities().add(newEntity);
@@ -289,7 +297,7 @@ public class ServiceComponentImpl implem
}
}
}
-
+
this.desiredConfigs.put(entry.getKey(), entry.getValue().getVersionTag());
}
}
@@ -409,5 +417,69 @@ public class ServiceComponentImpl implem
return this.isClientComponent;
}
+ @Override
+ public synchronized boolean canBeRemoved() {
+ State state = getDesiredState();
+ if (state != State.INIT
+ && state != State.UNINSTALLED) {
+ return false;
+ }
+
+ boolean safeToRemove = true;
+ for (ServiceComponentHost sch : hostComponents.values()) {
+ if (!sch.canBeRemoved()) {
+ safeToRemove = false;
+ LOG.warn("Found non removable hostcomponent when trying to"
+ + " delete service component"
+ + ", clusterName=" + getClusterName()
+ + ", serviceName=" + getServiceName()
+ + ", componentName=" + getName()
+ + ", hostname=" + sch.getHostName());
+ break;
+ }
+ }
+ return safeToRemove;
+ }
+
+ @Override
+ public synchronized void removeAllServiceComponentHosts() throws AmbariException {
+ LOG.info("Deleting all servicecomponenthosts for component"
+ + ", clusterName=" + getClusterName()
+ + ", serviceName=" + getServiceName()
+ + ", componentName=" + getName());
+ for (ServiceComponentHost sch : hostComponents.values()) {
+ if (!sch.canBeRemoved()) {
+ throw new AmbariException("Found non removable hostcomponent "
+ + " when trying to delete"
+ + " all hostcomponents from servicecomponent"
+ + ", clusterName=" + getClusterName()
+ + ", serviceName=" + getServiceName()
+ + ", componentName=" + getName()
+ + ", hostname=" + sch.getHostName());
+ }
+ }
+ hostComponents.clear();
+ // FIXME update DB
+ }
+
+ @Override
+ public synchronized void removeServiceComponentHosts(String hostname)
+ throws AmbariException {
+ ServiceComponentHost sch = getServiceComponentHost(hostname);
+ LOG.info("Deleting servicecomponenthost for cluster"
+ + ", clusterName=" + getClusterName()
+ + ", serviceName=" + getServiceName()
+ + ", componentName=" + getName()
+ + ", hostname=" + sch.getHostName());
+ if (!sch.canBeRemoved()) {
+ throw new AmbariException("Could not delete hostcomponent from cluster"
+ + ", clusterName=" + getClusterName()
+ + ", serviceName=" + getServiceName()
+ + ", componentName=" + getName()
+ + ", hostname=" + sch.getHostName());
+ }
+ hostComponents.remove(hostname);
+ // FIXME update DB
+ }
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java Wed Oct 24 06:37:23 2012
@@ -79,7 +79,7 @@ public class ServiceImpl implements Serv
private ServiceComponentFactory serviceComponentFactory;
private void init() {
-
+ // TODO load from DB during restart?
}
@AssistedInject
@@ -114,7 +114,7 @@ public class ServiceImpl implements Serv
this.desiredConfigs = new HashMap<String, String>();
this.components = new HashMap<String, ServiceComponent>();
-
+
this.configs = new HashMap<String, Config>();
if (!serviceEntity.getServiceComponentDesiredStateEntities().isEmpty()) {
@@ -123,12 +123,12 @@ public class ServiceImpl implements Serv
serviceComponentFactory.createExisting(this, serviceComponentDesiredStateEntity));
}
}
-
+
for (ServiceConfigMappingEntity mappingEntity : serviceEntity.getServiceConfigMappings()) {
desiredConfigs.put(mappingEntity.getConfigType(), mappingEntity.getVersionTag());
}
-
-
+
+
persisted = true;
}
@@ -235,11 +235,18 @@ public class ServiceImpl implements Serv
Config config = cluster.getDesiredConfig(entry.getKey(), entry.getValue());
if (null != config) {
map.put(entry.getKey(), config);
+ } else {
+ // FIXME this is an error - should throw a proper exception
+ throw new RuntimeException("Found an invalid config"
+ + ", clusterName=" + getCluster().getClusterName()
+ + ", serviceName=" + getName()
+ + ", configType=" + entry.getKey()
+ + ", configVersionTag=" + entry.getValue());
}
}
return Collections.unmodifiableMap(map);
}
-
+
@Override
public synchronized void updateDesiredConfigs(Map<String, Config> configs) {
@@ -250,7 +257,7 @@ public class ServiceImpl implements Serv
newEntity.setServiceName(getName());
newEntity.setVersionTag(entry.getValue().getVersionTag());
newEntity.setTimestamp(Long.valueOf(new java.util.Date().getTime()));
-
+
if (!serviceEntity.getServiceConfigMappings().contains(newEntity)) {
newEntity.setServiceConfigEntity(serviceEntity);
serviceEntity.getServiceConfigMappings().add(newEntity);
@@ -262,10 +269,10 @@ public class ServiceImpl implements Serv
}
}
}
-
+
this.desiredConfigs.put(entry.getKey(), entry.getValue().getVersionTag());
}
-
+
}
@Override
@@ -288,8 +295,13 @@ public class ServiceImpl implements Serv
}
private synchronized Map<String, String> getConfigVersions() {
+ Map<String, Config> configMaps = getDesiredConfigs();
Map<String, String> configVersions = new HashMap<String, String>();
- // FIXME config impl required
+ if (configMaps != null) {
+ for (Map.Entry<String, Config> entry: configMaps.entrySet()) {
+ configVersions.put(entry.getKey(), entry.getValue().getVersionTag());
+ }
+ }
return configVersions;
}
@@ -316,7 +328,9 @@ public class ServiceImpl implements Serv
+ ", clusterId=" + cluster.getClusterId()
+ ", desiredStackVersion=" + getDesiredStackVersion()
+ ", desiredState=" + getDesiredState().toString()
+ + ", configs = " + getConfigVersions()
+ ", components=[ ");
+
boolean first = true;
for(ServiceComponent sc : components.values()) {
if (!first) {
@@ -376,8 +390,67 @@ public class ServiceImpl implements Serv
}
@Override
- public boolean canBeRemoved() {
- // TODO Auto-generated method stub
- return false;
+ public synchronized boolean canBeRemoved() {
+ State state = getDesiredState();
+ if (state != State.INIT
+ && state != State.UNINSTALLED) {
+ return false;
+ }
+
+ boolean safeToRemove = true;
+ for (ServiceComponent sc : components.values()) {
+ if (!sc.canBeRemoved()) {
+ safeToRemove = false;
+ LOG.warn("Found non removable component when trying to delete service"
+ + ", clusterName=" + cluster.getClusterName()
+ + ", serviceName=" + getName()
+ + ", componentName=" + sc.getName());
+ break;
+ }
+ }
+ return safeToRemove;
+ }
+
+ @Override
+ public synchronized void removeAllComponents() throws AmbariException {
+ LOG.info("Deleting all components for service"
+ + ", clusterName=" + cluster.getClusterName()
+ + ", serviceName=" + getName());
+ // FIXME check dependencies from meta layer
+ for (ServiceComponent component : components.values()) {
+ if (!component.canBeRemoved()) {
+ throw new AmbariException("Found non removable component when trying to"
+ + " delete all components from service"
+ + ", clusterName=" + cluster.getClusterName()
+ + ", serviceName=" + getName()
+ + ", componentName=" + component.getName());
+ }
+ }
+ for (ServiceComponent component : components.values()) {
+ component.removeAllServiceComponentHosts();
+ }
+ components.clear();
+ // FIXME update DB
}
+
+ @Override
+ public synchronized void deleteServiceComponent(String componentName)
+ throws AmbariException {
+ ServiceComponent component = getServiceComponent(componentName);
+ LOG.info("Deleting servicecomponent for cluster"
+ + ", clusterName=" + cluster.getClusterName()
+ + ", serviceName=" + getName()
+ + ", componentName=" + componentName);
+ // FIXME check dependencies from meta layer
+ if (!component.canBeRemoved()) {
+ throw new AmbariException("Could not delete component from cluster"
+ + ", clusterName=" + cluster.getClusterName()
+ + ", serviceName=" + getName()
+ + ", componentName=" + componentName);
+ }
+ component.removeAllServiceComponentHosts();
+ components.remove(componentName);
+ // FIXME update DB
+ }
+
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java Wed Oct 24 06:37:23 2012
@@ -354,7 +354,7 @@ public class ClusterImpl implements Clus
configs.get(config.getType()).put(config.getVersionTag(), config);
}
-
+
public synchronized Collection<Config> getAllConfigs() {
List<Config> list = new ArrayList<Config>();
for (Entry<String,Map<String,Config>> entry : configs.entrySet()) {
@@ -398,12 +398,53 @@ public class ClusterImpl implements Clus
}
@Override
- public void deleteAllServices() throws AmbariException {
- // TODO Auto-generated method stub
+ public synchronized void deleteAllServices() throws AmbariException {
+ LOG.info("Deleting all services for cluster"
+ + ", clusterName=" + getClusterName());
+ for (Service service : services.values()) {
+ if (!service.canBeRemoved()) {
+ throw new AmbariException("Found non removable service when trying to"
+ + " all services from cluster"
+ + ", clusterName=" + getClusterName()
+ + ", serviceName=" + service.getName());
+ }
+ }
+ for (Service service : services.values()) {
+ service.removeAllComponents();
+ }
+ services.clear();
+ // FIXME update DB
}
@Override
- public void deleteService(String serviceName) throws AmbariException {
- // TODO Auto-generated method stub
+ public synchronized void deleteService(String serviceName)
+ throws AmbariException {
+ Service service = getService(serviceName);
+ LOG.info("Deleting service for cluster"
+ + ", clusterName=" + getClusterName()
+ + ", serviceName=" + service.getName());
+ // FIXME check dependencies from meta layer
+ if (!service.canBeRemoved()) {
+ throw new AmbariException("Could not delete service from cluster"
+ + ", clusterName=" + getClusterName()
+ + ", serviceName=" + service.getName());
+ }
+ service.removeAllComponents();
+ services.remove(serviceName);
+ // FIXME update DB
+ }
+
+ @Override
+ public boolean canBeRemoved() {
+ boolean safeToRemove = true;
+ for (Service service : services.values()) {
+ if (!service.canBeRemoved()) {
+ safeToRemove = false;
+ LOG.warn("Found non removable service"
+ + ", clusterName=" + getClusterName()
+ + ", serviceName=" + service.getName());
+ }
+ }
+ return safeToRemove;
}
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java Wed Oct 24 06:37:23 2012
@@ -165,6 +165,11 @@ public class ClustersImpl implements Clu
if (!hostClusterMap.containsKey(hostname)) {
getHost(hostname);
}
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Looking up clusters for hostname"
+ + ", hostname=" + hostname
+ + ", mappedClusters=" + hostClusterMap.get(hostname).size());
+ }
return Collections.unmodifiableSet(hostClusterMap.get(hostname));
}
@@ -221,7 +226,7 @@ public class ClustersImpl implements Clu
@Override
public synchronized void mapHostToCluster(String hostname,
String clusterName) throws AmbariException {
- ClusterImpl cluster = (ClusterImpl) getCluster(clusterName);
+ Cluster cluster = getCluster(clusterName);
HostImpl host = (HostImpl) getHost(hostname);
if (!hostClusterMap.containsKey(hostname)) {
@@ -295,8 +300,16 @@ public class ClustersImpl implements Clu
}
@Override
- public void deleteCluster(String clusterName) {
- // TODO Auto-generated method stub
+ public synchronized void deleteCluster(String clusterName)
+ throws AmbariException {
+ Cluster cluster = getCluster(clusterName);
+ if (!cluster.canBeRemoved()) {
+ throw new AmbariException("Could not delete cluster"
+ + ", clusterName=" + clusterName);
+ }
+ cluster.deleteAllServices();
+ clusters.remove(clusterName);
+ // FIXME update DB
}
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java Wed Oct 24 06:37:23 2012
@@ -296,10 +296,10 @@ public class HostImpl implements Host {
public void importHostInfo(HostInfo hostInfo) {
try {
writeLock.lock();
- if (hostInfo.getHostName() != null
- && !hostInfo.getHostName().isEmpty()
- && !hostInfo.getHostName().equals(getHostName())) {
- setHostName(hostInfo.getHostName());
+ if (hostInfo.getFQDN() != null
+ && !hostInfo.getFQDN().isEmpty()
+ && !hostInfo.getFQDN().equals(getHostName())) {
+ setHostName(hostInfo.getFQDN());
}
if (hostInfo.getIPAddress() != null
&& !hostInfo.getIPAddress().isEmpty()) {
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java Wed Oct 24 06:37:23 2012
@@ -490,13 +490,13 @@ public class ServiceComponentHostImpl im
LOG.error("Host '{}' was not found", stateEntity.getHostName());
throw new RuntimeException(e);
}
-
+
desiredConfigs = new HashMap<String, String>();
-
+
for (HostComponentConfigMappingEntity entity : desiredStateEntity.getHostComponentConfigMappingEntities()) {
desiredConfigs.put(entity.getConfigType(), entity.getVersionTag());
}
-
+
persisted = true;
}
@@ -674,7 +674,7 @@ public class ServiceComponentHostImpl im
public Map<String, Config> getConfigs() {
try {
readLock.lock();
-
+
return Collections.unmodifiableMap(configs);
}
finally {
@@ -684,7 +684,7 @@ public class ServiceComponentHostImpl im
@Override
public void updateConfigs(Map<String, Config> configs) {
-
+
try {
writeLock.lock();
@@ -744,10 +744,9 @@ public class ServiceComponentHostImpl im
@Override
public Map<String, Config> getDesiredConfigs() {
+ Map<String, Config> map = new HashMap<String, Config>();
try {
readLock.lock();
-
- Map<String, Config> map = new HashMap<String, Config>();
for (Entry<String, String> entry : desiredConfigs.entrySet()) {
Config config = clusters.getClusterById(getClusterId()).getDesiredConfig(
entry.getKey(), entry.getValue());
@@ -755,7 +754,6 @@ public class ServiceComponentHostImpl im
map.put(entry.getKey(), config);
}
}
- return Collections.unmodifiableMap(map);
}
catch (AmbariException e) {
// TODO do something
@@ -764,13 +762,21 @@ public class ServiceComponentHostImpl im
finally {
readLock.unlock();
}
+ // do a union with component level configs
+ Map<String, Config> compConfigs = serviceComponent.getDesiredConfigs();
+ for (Entry<String, Config> entry : compConfigs.entrySet()) {
+ if (!map.containsKey(entry.getKey())) {
+ map.put(entry.getKey(), entry.getValue());
+ }
+ }
+ return Collections.unmodifiableMap(map);
}
@Override
public void updateDesiredConfigs(Map<String, Config> configs) {
try {
writeLock.lock();
-
+
for (Entry<String,Config> entry : configs.entrySet()) {
HostComponentConfigMappingEntity newEntity = new HostComponentConfigMappingEntity();
newEntity.setClusterId(desiredStateEntity.getClusterId());
@@ -780,7 +786,7 @@ public class ServiceComponentHostImpl im
newEntity.setConfigType(entry.getKey());
newEntity.setVersionTag(entry.getValue().getVersionTag());
newEntity.setTimestamp(Long.valueOf(new java.util.Date().getTime()));
-
+
if (!desiredStateEntity.getHostComponentConfigMappingEntities().contains(newEntity)) {
newEntity.setHostComponentDesiredStateEntity(desiredStateEntity);
desiredStateEntity.getHostComponentConfigMappingEntities().add(newEntity);
@@ -792,10 +798,10 @@ public class ServiceComponentHostImpl im
}
}
}
-
+
this.desiredConfigs.put(entry.getKey(), entry.getValue().getVersionTag());
- }
-
+ }
+
}
finally {
writeLock.unlock();
@@ -962,4 +968,20 @@ public class ServiceComponentHostImpl im
}
}
+ @Override
+ public synchronized boolean canBeRemoved() {
+ try {
+ readLock.lock();
+ State desiredState = getDesiredState();
+ State liveState = getState();
+ if ((desiredState == State.INIT || desiredState == State.UNINSTALLED)
+ && (liveState == State.INIT || liveState == State.UNINSTALLED)) {
+ return true;
+ }
+ } finally {
+ readLock.unlock();
+ }
+ return false;
+ }
+
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/utils/JaxbMapKeyMapAdapter.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/utils/JaxbMapKeyMapAdapter.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/utils/JaxbMapKeyMapAdapter.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/utils/JaxbMapKeyMapAdapter.java Wed Oct 24 06:37:23 2012
@@ -17,8 +17,6 @@
*/
package org.apache.ambari.server.utils;
-import java.util.ArrayList;
-import java.util.List;
import java.util.Map;
import java.util.TreeMap;
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionManager.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionManager.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionManager.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionManager.java Wed Oct 24 06:37:23 2012
@@ -33,7 +33,6 @@ import org.apache.ambari.server.agent.Co
import org.apache.ambari.server.orm.GuiceJpaInitializer;
import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
import org.apache.ambari.server.state.Clusters;
-import org.apache.ambari.server.state.cluster.ClustersImpl;
import org.apache.ambari.server.state.svccomphost.ServiceComponentHostStartEvent;
import org.apache.ambari.server.utils.StageUtils;
import org.junit.After;
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java Wed Oct 24 06:37:23 2012
@@ -22,13 +22,11 @@ import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import javax.ws.rs.core.Application;
import javax.ws.rs.core.MediaType;
import junit.framework.Assert;
import org.apache.ambari.server.actionmanager.ActionManager;
-import org.apache.ambari.server.agent.rest.AgentJackSonJsonProvider;
import org.apache.ambari.server.agent.rest.AgentResource;
import org.apache.ambari.server.state.Clusters;
import org.apache.ambari.server.state.cluster.ClustersImpl;
@@ -47,12 +45,9 @@ import com.sun.jersey.api.client.WebReso
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.api.json.JSONConfiguration;
-import com.sun.jersey.server.wadl.generators.ApplicationDocs;
import com.sun.jersey.spi.container.servlet.ServletContainer;
-import com.sun.jersey.test.framework.AppDescriptor;
import com.sun.jersey.test.framework.JerseyTest;
import com.sun.jersey.test.framework.WebAppDescriptor;
-import com.sun.jersey.test.framework.spi.container.TestContainer;
public class AgentResourceTest extends JerseyTest {
static String PACKAGE_NAME = "org.apache.ambari.server.agent.rest";
@@ -61,13 +56,13 @@ public class AgentResourceTest extends J
ActionManager actionManager;
Injector injector;
protected Client client;
-
+
public AgentResourceTest() {
super(new WebAppDescriptor.Builder(PACKAGE_NAME).servletClass(ServletContainer.class)
.initParam("com.sun.jersey.api.json.POJOMappingFeature", "true")
.build());
}
-
+
public class MockModule extends AbstractModule {
RegistrationResponse response = new RegistrationResponse();
@@ -118,7 +113,7 @@ public class AgentResourceTest extends J
json.put("hostname", "dummyHost");
return json;
}
-
+
@Test
public void agentRegistration() throws UniformInterfaceException, JSONException {
RegistrationResponse response;
@@ -141,7 +136,7 @@ public class AgentResourceTest extends J
WebResource webResource = client.resource("http://localhost:9998/heartbeat/dummyhost");
response = webResource.type(MediaType.APPLICATION_JSON)
.post(HeartBeatResponse.class, createDummyHeartBeat());
- LOG.info("Returned from Server: "
+ LOG.info("Returned from Server: "
+ " responseid=" + response.getResponseId());
Assert.assertEquals(response.getResponseId(), 0L);
}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java Wed Oct 24 06:37:23 2012
@@ -32,9 +32,7 @@ import org.apache.ambari.server.orm.InMe
import org.apache.ambari.server.state.Clusters;
import org.apache.ambari.server.state.Host;
import org.apache.ambari.server.state.HostState;
-import org.apache.ambari.server.state.cluster.ClustersImpl;
import org.apache.ambari.server.state.fsm.InvalidStateTransitionException;
-import org.apache.ambari.server.state.host.HostImpl;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/api/handlers/ReadHandlerTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/api/handlers/ReadHandlerTest.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/api/handlers/ReadHandlerTest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/api/handlers/ReadHandlerTest.java Wed Oct 24 06:37:23 2012
@@ -30,9 +30,7 @@ import org.junit.Test;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Map;
-import java.util.Set;
import static org.easymock.EasyMock.*;
import static org.junit.Assert.assertSame;
Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java?rev=1401567&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java Wed Oct 24 06:37:23 2012
@@ -0,0 +1,79 @@
+/**
+ * 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.api.services;
+
+import org.apache.ambari.server.state.ServiceInfo;
+import org.junit.Test;
+import org.junit.Before;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+
+
+public class AmbariMetaInfoTest {
+
+ private AmbariMetaInfo ambariMetaInfo = null;
+
+ @Before
+ public void before() throws Exception {
+ ambariMetaInfo = new AmbariMetaInfo();
+ }
+
+ /**
+ * Method: getSupportedConfigs(String stackName, String version, String serviceName)
+ */
+ @Test
+ public void testGetSupportedConfigs() throws Exception {
+
+ Map<String, Map<String, String>> configsAll = ambariMetaInfo.getSupportedConfigs("HDP", "0.1", "HDFS");
+ Set<String> filesKeys = configsAll.keySet();
+ for (String file : filesKeys) {
+ Map<String, String> configs = configsAll.get(file);
+ Set<String> propertyKeys = configs.keySet();
+ assertNotNull(propertyKeys);
+ assertNotSame(propertyKeys.size(), 0);
+ }
+ }
+
+ /**
+ * Method: getServiceInfo(String stackName, String version, String serviceName)
+ */
+ @Test
+ public void testGetServiceInfo() throws Exception {
+ ServiceInfo si = ambariMetaInfo.getServiceInfo("HDP","0.1", "HDFS");
+ assertNotNull(si);
+ }
+
+ /**
+ * Method: getSupportedServices(String stackName, String version)
+ */
+ @Test
+ public void testGetSupportedServices() throws Exception {
+ List<ServiceInfo> services = ambariMetaInfo.getSupportedServices("HDP","0.1");
+ assertNotNull(services);
+ assertNotSame(services.size(), 0);
+
+ }
+
+
+}
Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/api/services/serializers/JsonSerializerTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/api/services/serializers/JsonSerializerTest.java?rev=1401567&r1=1401566&r2=1401567&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/api/services/serializers/JsonSerializerTest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/api/services/serializers/JsonSerializerTest.java Wed Oct 24 06:37:23 2012
@@ -18,21 +18,11 @@
package org.apache.ambari.server.api.services.serializers;
-import org.apache.ambari.server.api.services.Result;
-import org.junit.Test;
-
-import javax.ws.rs.core.UriInfo;
-
-import static org.easymock.EasyMock.*;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
/**
* JSONSerializer unit tests
*/
public class JsonSerializerTest {
- //todo: unit test serializer
+ // FIXME unit test serializer
// @Test
// public void testSerialize() throws Exception {
// Result result = createMock(Result.class);