You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2016/02/24 16:08:34 UTC
[47/50] [abbrv] ambari git commit: Merge branch 'trunk' into
branch-dev-patch-upgrade
Merge branch 'trunk' into branch-dev-patch-upgrade
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/e06d95d1
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e06d95d1
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e06d95d1
Branch: refs/heads/trunk
Commit: e06d95d1b779da2762e46de6c8d72a3523498401
Parents: cbef0c1 083ac6d
Author: Nate Cole <nc...@hortonworks.com>
Authored: Tue Feb 23 16:21:20 2016 -0500
Committer: Nate Cole <nc...@hortonworks.com>
Committed: Tue Feb 23 16:21:20 2016 -0500
----------------------------------------------------------------------
.../loginActivities/LoginMessageMainCtrl.js | 51 +-
.../ui/admin-web/app/scripts/i18n.config.js | 4 +-
.../app/views/loginActivities/loginMessage.html | 14 +-
.../src/main/repo/install_ambari_tarball.py | 2 +-
ambari-server/conf/unix/ca.config | 3 +-
ambari-server/conf/unix/install-helper.sh | 28 +-
ambari-server/conf/unix/log4j.properties | 3 +-
ambari-server/pom.xml | 1 +
.../ambari/server/agent/HeartBeatHandler.java | 550 +------
.../ambari/server/agent/HeartbeatMonitor.java | 6 +
.../ambari/server/agent/HeartbeatProcessor.java | 773 +++++++++
.../api/services/ActiveWidgetLayoutService.java | 10 +-
.../api/services/UserAuthorizationService.java | 4 +-
.../api/services/UserPrivilegeService.java | 3 +-
.../ambari/server/api/services/UserService.java | 3 +-
.../server/configuration/Configuration.java | 23 +-
.../ambari/server/controller/AmbariServer.java | 6 +-
.../ambari/server/orm/dao/HostVersionDAO.java | 78 +-
.../server/orm/entities/HostVersionEntity.java | 9 +
.../encryption/MasterKeyServiceImpl.java | 3 +-
.../server/state/cluster/ClusterImpl.java | 6 +-
.../svccomphost/ServiceComponentHostImpl.java | 72 +-
.../apache/ambari/server/utils/AmbariPath.java | 39 +
.../src/main/package/deb/control/postinst | 2 +-
.../src/main/package/deb/control/preinst | 22 +-
.../src/main/package/deb/control/prerm | 2 +-
.../src/main/package/rpm/postinstall.sh | 10 +-
.../src/main/package/rpm/posttrans_server.sh | 10 +-
.../src/main/package/rpm/preinstall.sh | 19 +-
ambari-server/src/main/package/rpm/preremove.sh | 6 +-
.../server/agent/HeartbeatProcessorTest.java | 1290 +++++++++++++++
.../server/agent/HeartbeatTestHelper.java | 229 +++
.../server/agent/TestHeartbeatHandler.java | 1488 ++----------------
.../services/ActiveWidgetLayoutServiceTest.java | 76 +
.../services/UserAuthorizationServiceTest.java | 12 +
.../api/services/UserPrivilegeServiceTest.java | 13 +
.../server/api/services/UserServiceTest.java | 71 +
.../resourceManager/step3_controller.js | 2 +-
.../main/admin/kerberos/step4_controller.js | 3 +-
.../main/admin/serviceAccounts_controller.js | 5 +-
.../controllers/main/service/info/configs.js | 32 +-
ambari-web/app/controllers/wizard.js | 1 -
.../app/controllers/wizard/step7_controller.js | 66 +-
.../configs/stack_config_properties_mapper.js | 4 +-
.../common/kdc_credentials_controller_mixin.js | 2 +-
ambari-web/app/models/stack_service.js | 15 +-
ambari-web/app/router.js | 11 +-
ambari-web/app/utils.js | 1 +
ambari-web/app/utils/config.js | 187 +--
ambari-web/app/utils/configs/theme/theme.js | 103 ++
.../configs/widgets/config_widget_view.js | 2 +-
.../admin/kerberos/step4_controller_test.js | 9 +-
.../test/controllers/wizard/step7_test.js | 7 +-
ambari-web/test/utils/config_test.js | 126 +-
54 files changed, 3149 insertions(+), 2368 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/e06d95d1/ambari-admin/src/main/resources/ui/admin-web/app/scripts/i18n.config.js
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/e06d95d1/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
----------------------------------------------------------------------
diff --cc ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
index a4136ee,ba14446..a13b421
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
@@@ -339,448 -286,7 +286,6 @@@ public class HeartBeatHandler
host.setRecoveryReport(recoveryReport);
}
- protected void processHostStatus(HeartBeat heartbeat, String hostname) throws AmbariException {
-
- Host host = clusterFsm.getHost(hostname);
- HealthStatus healthStatus = host.getHealthStatus().getHealthStatus();
-
- if (!healthStatus.equals(HostHealthStatus.HealthStatus.UNKNOWN)) {
-
- List<ComponentStatus> componentStatuses = heartbeat.getComponentStatus();
- //Host status info could be calculated only if agent returned statuses in heartbeat
- //Or, if a command is executed that can change component status
- boolean calculateHostStatus = false;
- String clusterName = null;
- if (componentStatuses.size() > 0) {
- calculateHostStatus = true;
- for (ComponentStatus componentStatus : componentStatuses) {
- clusterName = componentStatus.getClusterName();
- break;
- }
- }
-
- if (!calculateHostStatus) {
- List<CommandReport> reports = heartbeat.getReports();
- for (CommandReport report : reports) {
- if (RoleCommand.ACTIONEXECUTE.toString().equals(report.getRoleCommand())) {
- continue;
- }
-
- String service = report.getServiceName();
- if (actionMetadata.getActions(service.toLowerCase()).contains(report.getRole())) {
- continue;
- }
- if (report.getStatus().equals("COMPLETED")) {
- calculateHostStatus = true;
- clusterName = report.getClusterName();
- break;
- }
- }
- }
-
- if (calculateHostStatus) {
- //Use actual component status to compute the host status
- int masterCount = 0;
- int mastersRunning = 0;
- int slaveCount = 0;
- int slavesRunning = 0;
-
- StackId stackId;
- Cluster cluster = clusterFsm.getCluster(clusterName);
- stackId = cluster.getDesiredStackVersion();
-
- MaintenanceStateHelper psh = injector.getInstance(MaintenanceStateHelper.class);
-
- List<ServiceComponentHost> scHosts = cluster.getServiceComponentHosts(heartbeat.getHostname());
- for (ServiceComponentHost scHost : scHosts) {
- ComponentInfo componentInfo =
- ambariMetaInfo.getComponent(stackId.getStackName(),
- stackId.getStackVersion(), scHost.getServiceName(),
- scHost.getServiceComponentName());
-
- String status = scHost.getState().name();
-
- String category = componentInfo.getCategory();
-
- if (MaintenanceState.OFF == psh.getEffectiveState(scHost, host)) {
- if (category.equals("MASTER")) {
- ++masterCount;
- if (status.equals("STARTED")) {
- ++mastersRunning;
- }
- } else if (category.equals("SLAVE")) {
- ++slaveCount;
- if (status.equals("STARTED")) {
- ++slavesRunning;
- }
- }
- }
- }
-
- if (masterCount == mastersRunning && slaveCount == slavesRunning) {
- healthStatus = HealthStatus.HEALTHY;
- } else if (masterCount > 0 && mastersRunning < masterCount) {
- healthStatus = HealthStatus.UNHEALTHY;
- } else {
- healthStatus = HealthStatus.ALERT;
- }
-
- host.setStatus(healthStatus.name());
- host.persist();
- }
-
- //If host doesn't belong to any cluster
- if ((clusterFsm.getClustersForHost(host.getHostName())).size() == 0) {
- healthStatus = HealthStatus.HEALTHY;
- host.setStatus(healthStatus.name());
- host.persist();
- }
- }
- }
-
- protected void processCommandReports(
- HeartBeat heartbeat, String hostname, Clusters clusterFsm, long now)
- throws AmbariException {
- List<CommandReport> reports = heartbeat.getReports();
-
- // Cache HostRoleCommand entities because we will need them few times
- List<Long> taskIds = new ArrayList<Long>();
- for (CommandReport report : reports) {
- taskIds.add(report.getTaskId());
- }
- Collection<HostRoleCommand> commands = actionManager.getTasks(taskIds);
-
- Iterator<HostRoleCommand> hostRoleCommandIterator = commands.iterator();
- for (CommandReport report : reports) {
-
- Long clusterId = null;
- if (report.getClusterName() != null) {
- try {
- Cluster cluster = clusterFsm.getCluster(report.getClusterName());
- clusterId = Long.valueOf(cluster.getClusterId());
- } catch (AmbariException e) {
- }
- }
-
- LOG.debug("Received command report: " + report);
- // Fetch HostRoleCommand that corresponds to a given task ID
- HostRoleCommand hostRoleCommand = hostRoleCommandIterator.next();
- HostEntity hostEntity = hostDAO.findByName(hostname);
- if (hostEntity == null) {
- LOG.error("Received a command report and was unable to retrieve HostEntity for hostname = " + hostname);
- continue;
- }
-
- // Send event for final command reports for actions
- if (RoleCommand.valueOf(report.getRoleCommand()) == RoleCommand.ACTIONEXECUTE &&
- HostRoleStatus.valueOf(report.getStatus()).isCompletedState()) {
- ActionFinalReportReceivedEvent event = new ActionFinalReportReceivedEvent(
- clusterId, hostname, report, false);
- ambariEventPublisher.publish(event);
- }
-
- // Skip sending events for command reports for ABORTed commands
- if (hostRoleCommand.getStatus() == HostRoleStatus.ABORTED) {
- continue;
- }
- if (hostRoleCommand.getStatus() == HostRoleStatus.QUEUED &&
- report.getStatus().equals("IN_PROGRESS")) {
- hostRoleCommand.setStartTime(now);
- }
-
- // If the report indicates the keytab file was successfully transferred to a host or removed
- // from a host, record this for future reference
- if (Service.Type.KERBEROS.name().equalsIgnoreCase(report.getServiceName()) &&
- Role.KERBEROS_CLIENT.name().equalsIgnoreCase(report.getRole()) &&
- RoleCommand.CUSTOM_COMMAND.name().equalsIgnoreCase(report.getRoleCommand()) &&
- RequestExecution.Status.COMPLETED.name().equalsIgnoreCase(report.getStatus())) {
-
- String customCommand = report.getCustomCommand();
-
- boolean adding = "SET_KEYTAB".equalsIgnoreCase(customCommand);
- if (adding || "REMOVE_KEYTAB".equalsIgnoreCase(customCommand)) {
- WriteKeytabsStructuredOut writeKeytabsStructuredOut;
- try {
- writeKeytabsStructuredOut = gson.fromJson(report.getStructuredOut(), WriteKeytabsStructuredOut.class);
- } catch (JsonSyntaxException ex) {
- //Json structure was incorrect do nothing, pass this data further for processing
- writeKeytabsStructuredOut = null;
- }
-
- if (writeKeytabsStructuredOut != null) {
- Map<String, String> keytabs = writeKeytabsStructuredOut.getKeytabs();
- if (keytabs != null) {
- for (Map.Entry<String, String> entry : keytabs.entrySet()) {
- String principal = entry.getKey();
- if (!kerberosPrincipalHostDAO.exists(principal, hostEntity.getHostId())) {
- if (adding) {
- kerberosPrincipalHostDAO.create(principal, hostEntity.getHostId());
- } else if ("_REMOVED_".equalsIgnoreCase(entry.getValue())) {
- kerberosPrincipalHostDAO.remove(principal, hostEntity.getHostId());
- }
- }
- }
- }
- }
- }
- }
-
- //pass custom START, STOP and RESTART
- if (RoleCommand.ACTIONEXECUTE.toString().equals(report.getRoleCommand()) ||
- (RoleCommand.CUSTOM_COMMAND.toString().equals(report.getRoleCommand()) &&
- !("RESTART".equals(report.getCustomCommand()) ||
- "START".equals(report.getCustomCommand()) ||
- "STOP".equals(report.getCustomCommand())))) {
- continue;
- }
-
- Cluster cl = clusterFsm.getCluster(report.getClusterName());
- String service = report.getServiceName();
- if (service == null || service.isEmpty()) {
- throw new AmbariException("Invalid command report, service: " + service);
- }
- if (actionMetadata.getActions(service.toLowerCase()).contains(report.getRole())) {
- LOG.debug(report.getRole() + " is an action - skip component lookup");
- } else {
- try {
- Service svc = cl.getService(service);
- ServiceComponent svcComp = svc.getServiceComponent(report.getRole());
- ServiceComponentHost scHost = svcComp.getServiceComponentHost(hostname);
- String schName = scHost.getServiceComponentName();
-
- if (report.getStatus().equals(HostRoleStatus.COMPLETED.toString())) {
-
- // Reading component version if it is present
- if (StringUtils.isNotBlank(report.getStructuredOut())) {
- ComponentVersionStructuredOut structuredOutput = null;
- try {
- structuredOutput = gson.fromJson(report.getStructuredOut(), ComponentVersionStructuredOut.class);
- } catch (JsonSyntaxException ex) {
- //Json structure for component version was incorrect
- //do nothing, pass this data further for processing
- }
-
- String newVersion = structuredOutput == null ? null : structuredOutput.version;
-
- HostComponentVersionAdvertisedEvent event = new HostComponentVersionAdvertisedEvent(cl, scHost, newVersion);
- versionEventPublisher.publish(event);
- }
-
- // Updating stack version, if needed (this is not actually for express/rolling upgrades!)
- if (scHost.getState().equals(State.UPGRADING)) {
- scHost.setStackVersion(scHost.getDesiredStackVersion());
- } else if ((report.getRoleCommand().equals(RoleCommand.START.toString()) ||
- (report.getRoleCommand().equals(RoleCommand.CUSTOM_COMMAND.toString()) &&
- ("START".equals(report.getCustomCommand()) ||
- "RESTART".equals(report.getCustomCommand()))))
- && null != report.getConfigurationTags()
- && !report.getConfigurationTags().isEmpty()) {
- LOG.info("Updating applied config on service " + scHost.getServiceName() +
- ", component " + scHost.getServiceComponentName() + ", host " + scHost.getHostName());
- scHost.updateActualConfigs(report.getConfigurationTags());
- scHost.setRestartRequired(false);
- }
- // Necessary for resetting clients stale configs after starting service
- if ((RoleCommand.INSTALL.toString().equals(report.getRoleCommand()) ||
- (RoleCommand.CUSTOM_COMMAND.toString().equals(report.getRoleCommand()) &&
- "INSTALL".equals(report.getCustomCommand()))) && svcComp.isClientComponent()){
- scHost.updateActualConfigs(report.getConfigurationTags());
- scHost.setRestartRequired(false);
- }
- if (RoleCommand.CUSTOM_COMMAND.toString().equals(report.getRoleCommand()) &&
- !("START".equals(report.getCustomCommand()) ||
- "STOP".equals(report.getCustomCommand()))) {
- //do not affect states for custom commands except START and STOP
- //lets status commands to be responsible for this
- continue;
- }
-
- if (RoleCommand.START.toString().equals(report.getRoleCommand()) ||
- (RoleCommand.CUSTOM_COMMAND.toString().equals(report.getRoleCommand()) &&
- "START".equals(report.getCustomCommand()))) {
- scHost.handleEvent(new ServiceComponentHostStartedEvent(schName,
- hostname, now));
- scHost.setRestartRequired(false);
- } else if (RoleCommand.STOP.toString().equals(report.getRoleCommand()) ||
- (RoleCommand.CUSTOM_COMMAND.toString().equals(report.getRoleCommand()) &&
- "STOP".equals(report.getCustomCommand()))) {
- scHost.handleEvent(new ServiceComponentHostStoppedEvent(schName,
- hostname, now));
- } else {
- scHost.handleEvent(new ServiceComponentHostOpSucceededEvent(schName,
- hostname, now));
- }
- } else if (report.getStatus().equals("FAILED")) {
-
- if (StringUtils.isNotBlank(report.getStructuredOut())) {
- try {
- ComponentVersionStructuredOut structuredOutput = gson.fromJson(report.getStructuredOut(), ComponentVersionStructuredOut.class);
-
- if (null != structuredOutput.upgradeDirection) {
- // TODO: backward compatibility: now state is set to FAILED also during downgrade
- scHost.setUpgradeState(UpgradeState.FAILED);
- }
- } catch (JsonSyntaxException ex) {
- LOG.warn("Structured output was found, but not parseable: {}", report.getStructuredOut());
- }
- }
-
- LOG.warn("Operation failed - may be retried. Service component host: "
- + schName + ", host: " + hostname + " Action id" + report.getActionId());
- if (actionManager.isInProgressCommand(report)) {
- scHost.handleEvent(new ServiceComponentHostOpFailedEvent
- (schName, hostname, now));
- } else {
- LOG.info("Received report for a command that is no longer active. " + report);
- }
- } else if (report.getStatus().equals("IN_PROGRESS")) {
- scHost.handleEvent(new ServiceComponentHostOpInProgressEvent(schName,
- hostname, now));
- }
- } catch (ServiceComponentNotFoundException scnex) {
- LOG.warn("Service component not found ", scnex);
- } catch (InvalidStateTransitionException ex) {
- if (LOG.isDebugEnabled()) {
- LOG.warn("State machine exception.", ex);
- } else {
- LOG.warn("State machine exception. " + ex.getMessage());
- }
- }
- }
- }
-
- //Update state machines from reports
- actionManager.processTaskResponse(hostname, reports, commands);
- }
-
- protected void processStatusReports(HeartBeat heartbeat,
- String hostname,
- Clusters clusterFsm)
- throws AmbariException {
- Set<Cluster> clusters = clusterFsm.getClustersForHost(hostname);
- for (Cluster cl : clusters) {
- for (ComponentStatus status : heartbeat.componentStatus) {
- if (status.getClusterName().equals(cl.getClusterName())) {
- try {
- Service svc = cl.getService(status.getServiceName());
-
- String componentName = status.getComponentName();
- if (svc.getServiceComponents().containsKey(componentName)) {
- ServiceComponent svcComp = svc.getServiceComponent(
- componentName);
- ServiceComponentHost scHost = svcComp.getServiceComponentHost(
- hostname);
- State prevState = scHost.getState();
- State liveState = State.valueOf(State.class, status.getStatus());
- if (prevState.equals(State.INSTALLED)
- || prevState.equals(State.STARTED)
- || prevState.equals(State.STARTING)
- || prevState.equals(State.STOPPING)
- || prevState.equals(State.UNKNOWN)) {
- scHost.setState(liveState); //TODO direct status set breaks state machine sometimes !!!
- if (!prevState.equals(liveState)) {
- LOG.info("State of service component " + componentName
- + " of service " + status.getServiceName()
- + " of cluster " + status.getClusterName()
- + " has changed from " + prevState + " to " + liveState
- + " at host " + hostname);
- }
- }
-
- SecurityState prevSecurityState = scHost.getSecurityState();
- SecurityState currentSecurityState = SecurityState.valueOf(status.getSecurityState());
- if((prevSecurityState != currentSecurityState)) {
- if(prevSecurityState.isEndpoint()) {
- scHost.setSecurityState(currentSecurityState);
- LOG.info(String.format("Security of service component %s of service %s of cluster %s " +
- "has changed from %s to %s on host %s",
- componentName, status.getServiceName(), status.getClusterName(), prevSecurityState,
- currentSecurityState, hostname));
- }
- else {
- LOG.debug(String.format("Security of service component %s of service %s of cluster %s " +
- "has changed from %s to %s on host %s but will be ignored since %s is a " +
- "transitional state",
- componentName, status.getServiceName(), status.getClusterName(),
- prevSecurityState, currentSecurityState, hostname, prevSecurityState));
- }
- }
-
- if (null != status.getStackVersion() && !status.getStackVersion().isEmpty()) {
- scHost.setStackVersion(gson.fromJson(status.getStackVersion(), StackId.class));
- }
-
- if (null != status.getConfigTags()) {
- scHost.updateActualConfigs(status.getConfigTags());
- }
-
- Map<String, Object> extra = status.getExtra();
- if (null != extra && !extra.isEmpty()) {
- try {
- if (extra.containsKey("processes")) {
- @SuppressWarnings("unchecked")
- List<Map<String, String>> list = (List<Map<String, String>>) extra.get("processes");
- scHost.setProcesses(list);
- }
- if (extra.containsKey("version")) {
- String version = extra.get("version").toString();
-
- HostComponentVersionAdvertisedEvent event = new HostComponentVersionAdvertisedEvent(cl, scHost, version);
- versionEventPublisher.publish(event);
- }
-
- } catch (Exception e) {
- LOG.error("Could not access extra JSON for " +
- scHost.getServiceComponentName() + " from " +
- scHost.getHostName() + ": " + status.getExtra() +
- " (" + e.getMessage() + ")");
- }
- }
-
- this.heartbeatMonitor.getAgentRequests()
- .setExecutionDetailsRequest(hostname, componentName, status.getSendExecCmdDet());
- } else {
- // TODO: What should be done otherwise?
- }
- } catch (ServiceNotFoundException e) {
- LOG.warn("Received a live status update for a non-initialized"
- + " service"
- + ", clusterName=" + status.getClusterName()
- + ", serviceName=" + status.getServiceName());
- // FIXME ignore invalid live update and continue for now?
- continue;
- } catch (ServiceComponentNotFoundException e) {
- LOG.warn("Received a live status update for a non-initialized"
- + " servicecomponent"
- + ", clusterName=" + status.getClusterName()
- + ", serviceName=" + status.getServiceName()
- + ", componentName=" + status.getComponentName());
- // FIXME ignore invalid live update and continue for now?
- continue;
- } catch (ServiceComponentHostNotFoundException e) {
- LOG.warn("Received a live status update for a non-initialized"
- + " service"
- + ", clusterName=" + status.getClusterName()
- + ", serviceName=" + status.getServiceName()
- + ", componentName=" + status.getComponentName()
- + ", hostname=" + hostname);
- // FIXME ignore invalid live update and continue for now?
- continue;
- } catch (RuntimeException e) {
- LOG.warn("Received a live status with invalid payload"
- + " service"
- + ", clusterName=" + status.getClusterName()
- + ", serviceName=" + status.getServiceName()
- + ", componentName=" + status.getComponentName()
- + ", hostname=" + hostname
- + ", error=" + e.getMessage());
- continue;
- }
- }
- }
- }
- }
--
/**
* Adds commands from action queue to a heartbeat response.
*/
http://git-wip-us.apache.org/repos/asf/ambari/blob/e06d95d1/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
----------------------------------------------------------------------
diff --cc ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
index 221b83d,1cb935b..c63d043
--- a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
@@@ -43,9 -34,10 +43,10 @@@ import org.apache.ambari.server.orm.ent
import org.apache.ambari.server.security.ClientSecurityType;
import org.apache.ambari.server.security.authorization.LdapServerProperties;
import org.apache.ambari.server.security.authorization.jwt.JwtAuthenticationProperties;
+import org.apache.ambari.server.security.encryption.CertificateUtils;
import org.apache.ambari.server.security.encryption.CredentialProvider;
import org.apache.ambari.server.state.stack.OsFamily;
-import org.apache.ambari.server.security.encryption.CertificateUtils;
+ import org.apache.ambari.server.utils.AmbariPath;
import org.apache.ambari.server.utils.Parallel;
import org.apache.ambari.server.utils.ShellCommandUtil;
import org.apache.commons.io.FileUtils;
http://git-wip-us.apache.org/repos/asf/ambari/blob/e06d95d1/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/e06d95d1/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/e06d95d1/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
----------------------------------------------------------------------
diff --cc ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
index b6d51af,c62352a..e29e23e
--- a/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
@@@ -2366,160 -1394,7 +1394,6 @@@ public class TestHeartbeatHandler
return componentStatus1;
}
- private HeartBeatHandler getHeartBeatHandler(ActionManager am, ActionQueue aq)
- throws InvalidStateTransitionException, AmbariException {
- HeartBeatHandler handler = new HeartBeatHandler(clusters, aq, am, injector);
- Register reg = new Register();
- HostInfo hi = new HostInfo();
- hi.setHostName(DummyHostname1);
- hi.setOS(DummyOs);
- hi.setOSRelease(DummyOSRelease);
- reg.setHostname(DummyHostname1);
- reg.setResponseId(0);
- reg.setHardwareProfile(hi);
- reg.setAgentVersion(metaInfo.getServerVersion());
- handler.handleRegistration(reg);
- return handler;
- }
-
- private Cluster getDummyCluster()
- throws AmbariException {
- StackEntity stackEntity = stackDAO.find(HDP_22_STACK.getStackName(), HDP_22_STACK.getStackVersion());
- org.junit.Assert.assertNotNull(stackEntity);
-
- // Create the cluster
- ResourceTypeEntity resourceTypeEntity = new ResourceTypeEntity();
- resourceTypeEntity.setId(ResourceType.CLUSTER.getId());
- resourceTypeEntity.setName(ResourceType.CLUSTER.name());
- resourceTypeEntity = resourceTypeDAO.merge(resourceTypeEntity);
-
- ResourceEntity resourceEntity = new ResourceEntity();
- resourceEntity.setResourceType(resourceTypeEntity);
-
- ClusterEntity clusterEntity = new ClusterEntity();
- clusterEntity.setClusterName(DummyCluster);
- clusterEntity.setClusterInfo("test_cluster_info1");
- clusterEntity.setResource(resourceEntity);
- clusterEntity.setDesiredStack(stackEntity);
-
- clusterDAO.create(clusterEntity);
-
- StackId stackId = new StackId(DummyStackId);
-
- Cluster cluster = clusters.getCluster(DummyCluster);
-
- cluster.setDesiredStackVersion(stackId);
- cluster.setCurrentStackVersion(stackId);
- helper.getOrCreateRepositoryVersion(stackId, stackId.getStackVersion());
- cluster.createClusterVersion(stackId, stackId.getStackVersion(), "admin",
- RepositoryVersionState.INSTALLING);
-
- Set<String> hostNames = new HashSet<String>(){{
- add(DummyHostname1);
- }};
-
- Map<String, String> hostAttributes = new HashMap<String, String>();
- hostAttributes.put("os_family", "redhat");
- hostAttributes.put("os_release_version", "6.3");
-
- List<HostEntity> hostEntities = new ArrayList<HostEntity>();
- for(String hostName : hostNames) {
- clusters.addHost(hostName);
- Host host = clusters.getHost(hostName);
- host.setHostAttributes(hostAttributes);
- host.persist();
-
- HostEntity hostEntity = hostDAO.findByName(hostName);
- Assert.assertNotNull(hostEntity);
- hostEntities.add(hostEntity);
- }
- clusterEntity.setHostEntities(hostEntities);
- clusters.mapHostsToCluster(hostNames, DummyCluster);
-
- return cluster;
- }
-
- @Test
- @SuppressWarnings("unchecked")
- public void testCommandStatusProcesses() throws Exception {
- Cluster cluster = getDummyCluster();
- Service hdfs = cluster.addService(HDFS);
- hdfs.persist();
- hdfs.addServiceComponent(DATANODE).persist();
- hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
- hdfs.getServiceComponent(DATANODE).getServiceComponentHost(DummyHostname1).setState(State.STARTED);
-
- ActionQueue aq = new ActionQueue();
-
- HeartBeat hb = new HeartBeat();
- hb.setTimestamp(System.currentTimeMillis());
- hb.setResponseId(0);
- hb.setHostname(DummyHostname1);
- hb.setNodeStatus(new HostStatus(Status.HEALTHY, DummyHostStatus));
- hb.setReports(new ArrayList<CommandReport>());
-
- List<Map<String, String>> procs = new ArrayList<Map<String, String>>();
- Map<String, String> proc1info = new HashMap<String, String>();
- proc1info.put("name", "a");
- proc1info.put("status", "RUNNING");
- procs.add(proc1info);
-
- Map<String, String> proc2info = new HashMap<String, String>();
- proc2info.put("name", "b");
- proc2info.put("status", "NOT_RUNNING");
- procs.add(proc2info);
-
- Map<String, Object> extra = new HashMap<String, Object>();
- extra.put("processes", procs);
-
- ArrayList<ComponentStatus> componentStatuses = new ArrayList<ComponentStatus>();
- ComponentStatus componentStatus1 = new ComponentStatus();
- componentStatus1.setClusterName(DummyCluster);
- componentStatus1.setServiceName(HDFS);
- componentStatus1.setMessage(DummyHostStatus);
- componentStatus1.setStatus(State.STARTED.name());
- componentStatus1.setSecurityState(SecurityState.UNSECURED.name());
- componentStatus1.setComponentName(DATANODE);
-
- componentStatus1.setExtra(extra);
- componentStatuses.add(componentStatus1);
- hb.setComponentStatus(componentStatuses);
-
- final HostRoleCommand command = hostRoleCommandFactory.create(DummyHostname1,
- Role.DATANODE, null, null);
-
- ActionManager am = getMockActionManager();
- expect(am.getTasks(anyObject(List.class))).andReturn(
- new ArrayList<HostRoleCommand>() {{
- add(command);
- }}).anyTimes();
- replay(am);
-
- HeartBeatHandler handler = getHeartBeatHandler(am, aq);
- handler.handleHeartBeat(hb);
- ServiceComponentHost sch = hdfs.getServiceComponent(DATANODE).getServiceComponentHost(DummyHostname1);
-
- Assert.assertEquals(Integer.valueOf(2), Integer.valueOf(sch.getProcesses().size()));
-
- hb = new HeartBeat();
- hb.setTimestamp(System.currentTimeMillis());
- hb.setResponseId(1);
- hb.setHostname(DummyHostname1);
- hb.setNodeStatus(new HostStatus(Status.HEALTHY, DummyHostStatus));
- hb.setReports(new ArrayList<CommandReport>());
-
- componentStatus1 = new ComponentStatus();
- componentStatus1.setClusterName(DummyCluster);
- componentStatus1.setServiceName(HDFS);
- componentStatus1.setMessage(DummyHostStatus);
- componentStatus1.setStatus(State.STARTED.name());
- componentStatus1.setSecurityState(SecurityState.UNSECURED.name());
- componentStatus1.setComponentName(DATANODE);
- hb.setComponentStatus(Collections.singletonList(componentStatus1));
-
- handler.handleHeartBeat(hb);
- }
--
@Test
@SuppressWarnings("unchecked")
public void testCommandStatusProcesses_empty() throws Exception {