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 2014/02/24 20:22:33 UTC
[3/3] git commit: AMBARI-4752. Rename MAINTENANCE and PassiveState
(ncole)
AMBARI-4752. Rename MAINTENANCE and PassiveState (ncole)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/e1f4f2e8
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e1f4f2e8
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e1f4f2e8
Branch: refs/heads/trunk
Commit: e1f4f2e8b062f36f1db623423b682dd0019b0f19
Parents: 77de4b9
Author: Nate Cole <nc...@hortonworks.com>
Authored: Wed Feb 19 16:42:50 2014 -0500
Committer: Nate Cole <nc...@hortonworks.com>
Committed: Mon Feb 24 14:02:11 2014 -0500
----------------------------------------------------------------------
.../ambari/server/agent/HeartBeatHandler.java | 8 +-
.../ambari/server/agent/HeartbeatMonitor.java | 2 +-
.../controller/AmbariActionExecutionHelper.java | 2 +-
.../AmbariCustomCommandExecutionHelper.java | 14 +-
.../controller/AmbariManagementController.java | 11 +-
.../AmbariManagementControllerImpl.java | 49 +++--
.../ambari/server/controller/HostRequest.java | 10 +-
.../ambari/server/controller/HostResponse.java | 16 +-
.../controller/MaintenanceStateHelper.java | 158 ++++++++++++++
.../server/controller/PassiveStateHelper.java | 150 -------------
.../controller/ServiceComponentHostRequest.java | 14 +-
.../ServiceComponentHostResponse.java | 14 +-
.../server/controller/ServiceRequest.java | 15 +-
.../server/controller/ServiceResponse.java | 11 +-
.../internal/ComponentResourceProvider.java | 10 +-
.../internal/HostComponentResourceProvider.java | 33 ++-
.../internal/HostResourceProvider.java | 38 ++--
.../internal/ServiceResourceProvider.java | 53 ++---
.../HostComponentDesiredStateEntity.java | 14 +-
.../server/orm/entities/HostStateEntity.java | 27 ++-
.../orm/entities/ServiceDesiredStateEntity.java | 14 +-
.../org/apache/ambari/server/state/Host.java | 8 +-
.../ambari/server/state/MaintenanceState.java | 37 ++++
.../ambari/server/state/PassiveState.java | 37 ----
.../org/apache/ambari/server/state/Service.java | 10 +-
.../server/state/ServiceComponentHost.java | 8 +-
.../server/state/ServiceComponentHostEvent.java | 4 +-
.../state/ServiceComponentHostEventType.java | 6 +-
.../apache/ambari/server/state/ServiceImpl.java | 10 +-
.../org/apache/ambari/server/state/State.java | 10 +-
.../ambari/server/state/host/HostImpl.java | 40 ++--
.../ServiceComponentHostDisableEvent.java | 29 +++
.../svccomphost/ServiceComponentHostImpl.java | 26 +--
.../ServiceComponentHostMaintenanceEvent.java | 29 ---
.../server/upgrade/UpgradeCatalog150.java | 43 ++--
.../src/main/python/UpgradeHelper_HDP2.py | 6 +-
.../main/resources/Ambari-DDL-MySQL-CREATE.sql | 6 +-
.../main/resources/Ambari-DDL-Oracle-CREATE.sql | 6 +-
.../resources/Ambari-DDL-Postgres-CREATE.sql | 6 +-
.../Ambari-DDL-Postgres-REMOTE-CREATE.sql | 6 +-
.../src/main/resources/properties.json | 6 +-
.../scripts/relocate_host_components.py | 4 +-
.../server/agent/TestHeartbeatHandler.java | 8 +-
.../server/agent/TestHeartbeatMonitor.java | 9 +-
.../AmbariManagementControllerImplTest.java | 70 +++---
.../AmbariManagementControllerTest.java | 146 ++++++-------
.../controller/MaintenanceStateHelperTest.java | 213 +++++++++++++++++++
.../controller/PassiveStateHelperTest.java | 203 ------------------
.../internal/ComponentResourceProviderTest.java | 6 +-
.../internal/ServiceResourceProviderTest.java | 4 +-
.../apache/ambari/server/state/ServiceTest.java | 12 +-
.../ambari/server/state/host/HostTest.java | 14 +-
.../svccomphost/ServiceComponentHostTest.java | 14 +-
.../src/test/python/TestUpgradeScript_HDP2.py | 6 +-
54 files changed, 862 insertions(+), 843 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
----------------------------------------------------------------------
diff --git 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
index 7754025..0044c8e 100644
--- 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
@@ -31,7 +31,7 @@ import org.apache.ambari.server.ServiceNotFoundException;
import org.apache.ambari.server.actionmanager.ActionManager;
import org.apache.ambari.server.api.services.AmbariMetaInfo;
import org.apache.ambari.server.configuration.Configuration;
-import org.apache.ambari.server.controller.PassiveStateHelper;
+import org.apache.ambari.server.controller.MaintenanceStateHelper;
import org.apache.ambari.server.metadata.ActionMetadata;
import org.apache.ambari.server.state.AgentVersion;
import org.apache.ambari.server.state.Cluster;
@@ -41,7 +41,7 @@ import org.apache.ambari.server.state.Host;
import org.apache.ambari.server.state.HostHealthStatus;
import org.apache.ambari.server.state.HostHealthStatus.HealthStatus;
import org.apache.ambari.server.state.HostState;
-import org.apache.ambari.server.state.PassiveState;
+import org.apache.ambari.server.state.MaintenanceState;
import org.apache.ambari.server.state.Service;
import org.apache.ambari.server.state.ServiceComponent;
import org.apache.ambari.server.state.ServiceComponentHost;
@@ -245,7 +245,7 @@ public class HeartBeatHandler {
Cluster cluster = clusterFsm.getCluster(clusterName);
stackId = cluster.getDesiredStackVersion();
- PassiveStateHelper psh = injector.getInstance(PassiveStateHelper.class);
+ MaintenanceStateHelper psh = injector.getInstance(MaintenanceStateHelper.class);
List<ServiceComponentHost> scHosts = cluster.getServiceComponentHosts(heartbeat.getHostname());
for (ServiceComponentHost scHost : scHosts) {
@@ -258,7 +258,7 @@ public class HeartBeatHandler {
String category = componentInfo.getCategory();
- if (PassiveState.ACTIVE == psh.getEffectiveState(scHost)) {
+ if (MaintenanceState.OFF == psh.getEffectiveState(scHost)) {
if (category.equals("MASTER")) {
++masterCount;
if (status.equals("STARTED")) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatMonitor.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatMonitor.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatMonitor.java
index a339784..7452a7b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatMonitor.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatMonitor.java
@@ -134,7 +134,7 @@ public class HeartbeatMonitor implements Runnable {
!sch.getState().equals(State.INSTALLING) &&
!sch.getState().equals(State.INSTALL_FAILED) &&
!sch.getState().equals(State.UNINSTALLED) &&
- !sch.getState().equals(State.MAINTENANCE)) {
+ !sch.getState().equals(State.DISABLED)) {
LOG.warn("Setting component state to UNKNOWN for component " + sc.getName() + " on " + host);
sch.setState(State.UNKNOWN);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
index 2552aa6..74aa1fd 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
@@ -325,7 +325,7 @@ public class AmbariActionExecutionHelper {
// cluster passive map
execCmd.setPassiveInfo(
- PassiveStateHelper.getPassiveHostComponents(clusters, cluster));
+ MaintenanceStateHelper.getMaintenanceHostCompoments(clusters, cluster));
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
index 7da9a9f..ba42cc5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
@@ -37,7 +37,7 @@ import org.apache.ambari.server.state.ComponentInfo;
import org.apache.ambari.server.state.ConfigHelper;
import org.apache.ambari.server.state.Host;
import org.apache.ambari.server.state.HostComponentAdminState;
-import org.apache.ambari.server.state.PassiveState;
+import org.apache.ambari.server.state.MaintenanceState;
import org.apache.ambari.server.state.RepositoryInfo;
import org.apache.ambari.server.state.Service;
import org.apache.ambari.server.state.ServiceComponent;
@@ -566,16 +566,16 @@ public class AmbariCustomCommandExecutionHelper {
sch.setComponentAdminState(HostComponentAdminState.DECOMMISSIONED);
listOfExcludedHosts.add(sch.getHostName());
if (alignMtnState) {
- sch.setPassiveState(PassiveState.PASSIVE);
+ sch.setMaintenanceState(MaintenanceState.ON);
}
- LOG.info("Decommissioning " + slaveCompType + " and marking it PASSIVE on " + sch.getHostName());
+ LOG.info("Decommissioning " + slaveCompType + " and marking Maintenance=ON on " + sch.getHostName());
}
if (includedHosts.contains(sch.getHostName())) {
sch.setComponentAdminState(HostComponentAdminState.INSERVICE);
if (alignMtnState) {
- sch.setPassiveState(PassiveState.ACTIVE);
+ sch.setMaintenanceState(MaintenanceState.OFF);
}
- LOG.info("Recommissioning " + slaveCompType + " and marking it ACTIVE on " + sch.getHostName());
+ LOG.info("Recommissioning " + slaveCompType + " and marking Maintenance=OFF on " + sch.getHostName());
}
}
@@ -787,8 +787,8 @@ public class AmbariCustomCommandExecutionHelper {
Map<String, String> roleParams = new TreeMap<String, String>();
execCmd.setRoleParams(roleParams);
-
- execCmd.setPassiveInfo(PassiveStateHelper.getPassiveHostComponents(clusters, cluster));
+
+ execCmd.setPassiveInfo(MaintenanceStateHelper.getMaintenanceHostCompoments(clusters, cluster));
}
private String getRepoInfo(Cluster cluster, Host host) throws AmbariException {
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
index 2063f88..03ddaa6 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
@@ -24,7 +24,7 @@ import org.apache.ambari.server.api.services.AmbariMetaInfo;
import org.apache.ambari.server.scheduler.ExecutionScheduleManager;
import org.apache.ambari.server.state.Cluster;
import org.apache.ambari.server.state.Clusters;
-import org.apache.ambari.server.state.PassiveState;
+import org.apache.ambari.server.state.MaintenanceState;
import org.apache.ambari.server.state.Service;
import org.apache.ambari.server.state.ServiceComponent;
import org.apache.ambari.server.state.ServiceComponentFactory;
@@ -526,13 +526,12 @@ public interface AmbariManagementController {
public String getJobTrackerHost(Cluster cluster);
/**
- * Gets the effective passive state for a host component
- * @param cluster the cluster
- * @param service the service
+ * Gets the effective maintenance state for a host component
* @param sch the service component host
- * @return the passive state
+ * @return the maintenance state
* @throws AmbariException
*/
- public PassiveState getEffectivePassiveState(ServiceComponentHost sch) throws AmbariException;
+ public MaintenanceState getEffectiveMaintenanceState(ServiceComponentHost sch)
+ throws AmbariException;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
index 6ab0ca9..9d51027 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
@@ -71,7 +71,7 @@ import org.apache.ambari.server.state.ConfigHelper;
import org.apache.ambari.server.state.Host;
import org.apache.ambari.server.state.HostState;
import org.apache.ambari.server.state.OperatingSystemInfo;
-import org.apache.ambari.server.state.PassiveState;
+import org.apache.ambari.server.state.MaintenanceState;
import org.apache.ambari.server.state.PropertyInfo;
import org.apache.ambari.server.state.RepositoryInfo;
import org.apache.ambari.server.state.Service;
@@ -89,7 +89,7 @@ import org.apache.ambari.server.state.configgroup.ConfigGroupFactory;
import org.apache.ambari.server.state.fsm.InvalidStateTransitionException;
import org.apache.ambari.server.state.scheduler.RequestExecutionFactory;
import org.apache.ambari.server.state.svccomphost.ServiceComponentHostInstallEvent;
-import org.apache.ambari.server.state.svccomphost.ServiceComponentHostMaintenanceEvent;
+import org.apache.ambari.server.state.svccomphost.ServiceComponentHostDisableEvent;
import org.apache.ambari.server.state.svccomphost.ServiceComponentHostRestoreEvent;
import org.apache.ambari.server.state.svccomphost.ServiceComponentHostStartEvent;
import org.apache.ambari.server.state.svccomphost.ServiceComponentHostStopEvent;
@@ -734,7 +734,7 @@ public class AmbariManagementControllerImpl implements
if (filterBasedConfigStaleness && r.isStaleConfig() != staleConfig) {
continue;
}
- r.setPassiveState(getEffectivePassiveState(sch).name());
+ r.setMaintenanceState(getEffectiveMaintenanceState(sch).name());
response.add(r);
} catch (ServiceComponentHostNotFoundException e) {
if (request.getServiceName() != null && request.getComponentName() != null) {
@@ -767,7 +767,7 @@ public class AmbariManagementControllerImpl implements
continue;
}
- r.setPassiveState(getEffectivePassiveState(sch).name());
+ r.setMaintenanceState(getEffectiveMaintenanceState(sch).name());
response.add(r);
}
}
@@ -777,11 +777,11 @@ public class AmbariManagementControllerImpl implements
}
@Override
- public PassiveState getEffectivePassiveState(ServiceComponentHost sch)
+ public MaintenanceState getEffectiveMaintenanceState(ServiceComponentHost sch)
throws AmbariException {
- PassiveStateHelper psh = injector.getInstance(PassiveStateHelper.class);
+ MaintenanceStateHelper msh = injector.getInstance(MaintenanceStateHelper.class);
- return psh.getEffectiveState(sch);
+ return msh.getEffectiveState(sch);
}
@@ -1452,7 +1452,6 @@ public class AmbariManagementControllerImpl implements
Map<ServiceComponentHost, State> directTransitionScHosts = new HashMap<ServiceComponentHost, State>();
Set<String> maintenanceClusters = new HashSet<String>();
-
for (ServiceComponentHostRequest request : requests) {
validateServiceComponentHostRequest(request);
@@ -1517,21 +1516,21 @@ public class AmbariManagementControllerImpl implements
}
}
- if (null != request.getPassiveState()) {
- PassiveStateHelper psh = injector.getInstance(PassiveStateHelper.class);
+ if (null != request.getMaintenanceState()) {
+ MaintenanceStateHelper psh = injector.getInstance(MaintenanceStateHelper.class);
- PassiveState newPassive = PassiveState.valueOf(request.getPassiveState());
- PassiveState oldPassive = psh.getEffectiveState(sch);
+ MaintenanceState newMaint = MaintenanceState.valueOf(request.getMaintenanceState());
+ MaintenanceState oldMaint = psh.getEffectiveState(sch);
- if (newPassive != oldPassive) {
+ if (newMaint != oldMaint) {
if (sc.isClientComponent()) {
throw new IllegalArgumentException("Invalid arguments, cannot set " +
- "passive state on a client component");
- } else if (newPassive.equals(PassiveState.IMPLIED)) {
+ "maintenance state on a client component");
+ } else if (newMaint.equals(MaintenanceState.IMPLIED)) {
throw new IllegalArgumentException("Invalid arguments, can only set " +
- "passive state to one of " + EnumSet.of(PassiveState.ACTIVE, PassiveState.PASSIVE));
+ "maintenance state to one of " + EnumSet.of(MaintenanceState.OFF, MaintenanceState.ON));
} else {
- sch.setPassiveState(newPassive);
+ sch.setMaintenanceState(newMaint);
maintenanceClusters.add(sch.getClusterName());
}
@@ -1634,8 +1633,8 @@ public class AmbariManagementControllerImpl implements
ServiceComponentHostEvent event;
componentHost.setDesiredState(newState);
switch (newState) {
- case MAINTENANCE:
- event = new ServiceComponentHostMaintenanceEvent(
+ case DISABLED:
+ event = new ServiceComponentHostDisableEvent(
componentHost.getServiceComponentName(),
componentHost.getHostName(),
timestamp);
@@ -1659,10 +1658,10 @@ public class AmbariManagementControllerImpl implements
if (maintenanceClusters.size() > 0) {
try {
- PassiveStateHelper.createRequests(this, requestProperties,
+ MaintenanceStateHelper.createRequests(this, requestProperties,
maintenanceClusters);
} catch (Exception e) {
- LOG.warn("Could not send passive status to Nagios (" + e.getMessage() + ")");
+ LOG.warn("Could not send maintenance status to Nagios (" + e.getMessage() + ")");
}
}
@@ -1714,11 +1713,11 @@ public class AmbariManagementControllerImpl implements
private boolean isDirectTransition(State oldState, State newState) {
switch (newState) {
case INSTALLED:
- if (oldState == State.MAINTENANCE) {
+ if (oldState == State.DISABLED) {
return true;
}
break;
- case MAINTENANCE:
+ case DISABLED:
if (oldState == State.INSTALLED ||
oldState == State.UNKNOWN) {
return true;
@@ -1834,13 +1833,13 @@ public class AmbariManagementControllerImpl implements
+ ", request=" + request);
}
- // Only allow removing master/slave components in MAINTENANCE/UNKNOWN/INSTALL_FAILED/INIT state without stages
+ // Only allow removing master/slave components in DISABLED/UNKNOWN/INSTALL_FAILED/INIT state without stages
// generation.
// Clients may be removed without a state check.
if (!component.isClientComponent() &&
!componentHost.getState().isRemovableState()) {
throw new AmbariException("To remove master or slave components they must be in " +
- "MAINTENANCE/INIT/INSTALLED/INSTALL_FAILED/UNKNOWN state. Current=" + componentHost.getState() + ".");
+ "DISABLED/INIT/INSTALLED/INSTALL_FAILED/UNKNOWN state. Current=" + componentHost.getState() + ".");
}
if (!safeToRemoveSCHs.containsKey(component)) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/controller/HostRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/HostRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/HostRequest.java
index 398b3a7..f3668c1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/HostRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/HostRequest.java
@@ -29,7 +29,7 @@ public class HostRequest {
private Map<String, String> hostAttributes; // CREATE/UPDATE
private String rackInfo;
private ConfigurationRequest desiredConfig; // UPDATE
- private String passiveState; // UPDATE
+ private String maintenanceState; // UPDATE
public HostRequest(String hostname, String clusterName, Map<String, String> hostAttributes) {
this.hostname = hostname;
@@ -85,12 +85,12 @@ public class HostRequest {
return desiredConfig;
}
- public void setPassiveState(String state) {
- passiveState = state;
+ public void setMaintenanceState(String state) {
+ maintenanceState = state;
}
- public String getPassiveState() {
- return passiveState;
+ public String getMaintenanceState() {
+ return maintenanceState;
}
public String toString() {
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/controller/HostResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/HostResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/HostResponse.java
index 97bc7b7..35d1ca7 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/HostResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/HostResponse.java
@@ -29,7 +29,7 @@ import org.apache.ambari.server.state.AgentVersion;
import org.apache.ambari.server.state.DesiredConfig;
import org.apache.ambari.server.state.HostConfig;
import org.apache.ambari.server.state.HostHealthStatus;
-import org.apache.ambari.server.state.PassiveState;
+import org.apache.ambari.server.state.MaintenanceState;
public class HostResponse {
@@ -145,7 +145,7 @@ public class HostResponse {
*/
private String status;
- private PassiveState passiveState = null;
+ private MaintenanceState maintenanceState = null;
public HostResponse(String hostname, String clusterName,
String ipv4, String ipv6, int cpuCount, int phCpuCount, String osArch, String osType,
@@ -523,16 +523,16 @@ public class HostResponse {
}
/**
- * @param state
+ * @param state the maintenance state
*/
- public void setPassiveState(PassiveState state) {
- passiveState = state;
+ public void setMaintenanceState(MaintenanceState state) {
+ maintenanceState = state;
}
/**
- * @return the passive state
+ * @return the maintenance state
*/
- public PassiveState getPassiveState() {
- return passiveState;
+ public MaintenanceState getMaintenanceState() {
+ return maintenanceState;
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/controller/MaintenanceStateHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/MaintenanceStateHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/MaintenanceStateHelper.java
new file mode 100644
index 0000000..5251b3d
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/MaintenanceStateHelper.java
@@ -0,0 +1,158 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.controller;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.HostNotFoundException;
+import org.apache.ambari.server.RoleCommand;
+import org.apache.ambari.server.state.Cluster;
+import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.Host;
+import org.apache.ambari.server.state.MaintenanceState;
+import org.apache.ambari.server.state.Service;
+import org.apache.ambari.server.state.ServiceComponent;
+import org.apache.ambari.server.state.ServiceComponentHost;
+
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+
+/**
+ * Used to help manage maintenance state checks.
+ */
+public class MaintenanceStateHelper {
+ private static final String NAGIOS_SERVICE = "NAGIOS";
+ private static final String NAGIOS_COMPONENT = "NAGIOS_SERVER";
+ private static final String NAGIOS_ACTION_NAME = "nagios_update_ignore";
+
+ @Inject
+ private Clusters clusters;
+
+ @Inject
+ public MaintenanceStateHelper(Injector injector) {
+ injector.injectMembers(this);
+ }
+
+ /**
+ * Gets the effective state for a HostComponents
+ * @param sch the host component
+ * @return the maintenance state
+ * @throws AmbariException
+ */
+ public MaintenanceState getEffectiveState(ServiceComponentHost sch) throws AmbariException {
+ Cluster cluster = clusters.getCluster(sch.getClusterName());
+ Service service = cluster.getService(sch.getServiceName());
+
+ Map<String, Host> map = clusters.getHostsForCluster(cluster.getClusterName());
+ if (null == map)
+ return MaintenanceState.OFF;
+
+ Host host = clusters.getHostsForCluster(cluster.getClusterName()).get(sch.getHostName());
+ if (null == host) // better not
+ throw new HostNotFoundException(cluster.getClusterName(), sch.getHostName());
+
+ return getEffectiveState(cluster.getClusterId(), service, host, sch);
+ }
+
+ /**
+ * @param clusterId the cluster id
+ * @param service the service
+ * @param host the host
+ * @param sch the host component
+ * @return the effective maintenance state
+ */
+ private static MaintenanceState getEffectiveState(long clusterId, Service service,
+ Host host, ServiceComponentHost sch) {
+ if (MaintenanceState.ON == sch.getMaintenanceState())
+ return MaintenanceState.ON;
+
+ if (MaintenanceState.OFF != service.getMaintenanceState() ||
+ MaintenanceState.OFF != host.getMaintenanceState(clusterId))
+ return MaintenanceState.IMPLIED;
+
+ return sch.getMaintenanceState();
+ }
+
+ /**
+ * @param clusters the collection of clusters
+ * @param cluster the specific cluster to check
+ * @return a property map of all host components that are in a
+ * maintenance state (either {@link MaintenanceState#ON} or
+ * {@link MaintenanceState#IMPLIED})
+ */
+ public static Set<Map<String, String>> getMaintenanceHostCompoments(Clusters clusters,
+ Cluster cluster) throws AmbariException {
+
+ Set<Map<String, String>> set = new HashSet<Map<String, String>>();
+
+ for (Service service : cluster.getServices().values()) {
+ for (ServiceComponent sc : service.getServiceComponents().values()) {
+ if (sc.isClientComponent())
+ continue;
+
+ for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
+ Host host = clusters.getHostsForCluster(
+ cluster.getClusterName()).get(sch.getHostName());
+
+ if (MaintenanceState.OFF != getEffectiveState(cluster.getClusterId(),
+ service, host, sch)) {
+ Map<String, String> map = new HashMap<String, String>();
+ map.put("host", sch.getHostName());
+ map.put("service", sch.getServiceName());
+ map.put("component", sch.getServiceComponentName());
+ set.add(map);
+ }
+ }
+ }
+ }
+
+ return set;
+ }
+
+ /**
+ * Creates the requests to send to the clusters
+ * @param amc the controller
+ * @param requestProperties the request properties
+ * @param clusterNames the names of all the clusters to update
+ * @return the response
+ * @throws AmbariException
+ */
+ public static RequestStatusResponse createRequests(AmbariManagementController amc,
+ Map<String, String> requestProperties, Set<String> clusterNames) throws AmbariException {
+
+ Map<String, String> params = new HashMap<String, String>();
+
+ // return the first one, just like amc.createStages()
+ RequestStatusResponse response = null;
+
+ for (String clusterName : clusterNames) {
+ ExecuteActionRequest actionRequest = new ExecuteActionRequest(
+ clusterName, RoleCommand.ACTIONEXECUTE.name(),
+ NAGIOS_ACTION_NAME, NAGIOS_SERVICE, NAGIOS_COMPONENT, null, params);
+
+ if (null == response)
+ response = amc.createAction(actionRequest, requestProperties);
+ }
+ return response;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/controller/PassiveStateHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/PassiveStateHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/PassiveStateHelper.java
deleted file mode 100644
index 1709fb0..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/PassiveStateHelper.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.ambari.server.controller;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.HostNotFoundException;
-import org.apache.ambari.server.RoleCommand;
-import org.apache.ambari.server.state.Cluster;
-import org.apache.ambari.server.state.Clusters;
-import org.apache.ambari.server.state.Host;
-import org.apache.ambari.server.state.PassiveState;
-import org.apache.ambari.server.state.Service;
-import org.apache.ambari.server.state.ServiceComponent;
-import org.apache.ambari.server.state.ServiceComponentHost;
-
-import com.google.inject.Inject;
-import com.google.inject.Injector;
-
-/**
- * Used to help manage passive state checks.
- */
-public class PassiveStateHelper {
- private static final String NAGIOS_SERVICE = "NAGIOS";
- private static final String NAGIOS_COMPONENT = "NAGIOS_SERVER";
- private static final String NAGIOS_ACTION_NAME = "nagios_update_ignore";
-
- @Inject
- private Clusters clusters;
-
- @Inject
- public PassiveStateHelper(Injector injector) {
- injector.injectMembers(this);
- }
-
- /**
- * Gets the effective state for a HostComponents
- * @param sch the host component
- * @return the passive state
- * @throws AmbariException
- */
- public PassiveState getEffectiveState(ServiceComponentHost sch) throws AmbariException {
- Cluster cluster = clusters.getCluster(sch.getClusterName());
- Service service = cluster.getService(sch.getServiceName());
-
- Map<String, Host> map = clusters.getHostsForCluster(cluster.getClusterName());
- if (null == map)
- return PassiveState.ACTIVE;
-
- Host host = clusters.getHostsForCluster(cluster.getClusterName()).get(sch.getHostName());
- if (null == host) // better not
- throw new HostNotFoundException(cluster.getClusterName(), sch.getHostName());
-
- return getEffectiveState(cluster.getClusterId(), service, host, sch);
- }
-
- private static PassiveState getEffectiveState(long clusterId, Service service,
- Host host, ServiceComponentHost sch) {
- if (PassiveState.PASSIVE == sch.getPassiveState())
- return PassiveState.PASSIVE;
-
- if (PassiveState.ACTIVE != service.getPassiveState() ||
- PassiveState.ACTIVE != host.getPassiveState(clusterId))
- return PassiveState.IMPLIED;
-
- return sch.getPassiveState();
- }
-
- /**
- * @param cluster
- * @return
- */
- public static Set<Map<String, String>> getPassiveHostComponents(Clusters clusters,
- Cluster cluster) throws AmbariException {
-
- Set<Map<String, String>> set = new HashSet<Map<String, String>>();
-
- for (Service service : cluster.getServices().values()) {
- for (ServiceComponent sc : service.getServiceComponents().values()) {
- if (sc.isClientComponent())
- continue;
-
- for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
- Host host = clusters.getHostsForCluster(
- cluster.getClusterName()).get(sch.getHostName());
-
- if (PassiveState.ACTIVE != getEffectiveState(cluster.getClusterId(),
- service, host, sch)) {
- Map<String, String> map = new HashMap<String, String>();
- map.put("host", sch.getHostName());
- map.put("service", sch.getServiceName());
- map.put("component", sch.getServiceComponentName());
- set.add(map);
- }
- }
- }
- }
-
- return set;
- }
-
- /**
- * Creates the requests to send to the clusters
- * @param amc the controller
- * @param requestProperties the request properties
- * @param clusterNames the names of all the clusters to update
- * @return the response
- * @throws AmbariException
- */
- public static RequestStatusResponse createRequests(AmbariManagementController amc,
- Map<String, String> requestProperties, Set<String> clusterNames) throws AmbariException {
-
- Map<String, String> params = new HashMap<String, String>();
-
- // return the first one, just like amc.createStages()
- RequestStatusResponse response = null;
-
- for (String clusterName : clusterNames) {
- ExecuteActionRequest actionRequest = new ExecuteActionRequest(
- clusterName, RoleCommand.ACTIONEXECUTE.name(),
- NAGIOS_ACTION_NAME, NAGIOS_SERVICE, NAGIOS_COMPONENT, null, params);
-
- if (null == response)
- response = amc.createAction(actionRequest, requestProperties);
- }
-
- return response;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostRequest.java
index 0891560..d9c7928 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostRequest.java
@@ -30,7 +30,7 @@ public class ServiceComponentHostRequest {
private String desiredStackId; // UPDATE
private String staleConfig; // GET - predicate
private String adminState; // GET - predicate
- private String passiveState; // UPDATE
+ private String maintenanceState; // UPDATE
public ServiceComponentHostRequest(String clusterName,
String serviceName,
@@ -173,16 +173,16 @@ public class ServiceComponentHostRequest {
}
/**
- * @param state the passive state
+ * @param state the maintenance state
*/
- public void setPassiveState(String state) {
- passiveState = state;
+ public void setMaintenanceState(String state) {
+ maintenanceState = state;
}
/**
- * @return the passive state
+ * @return the maintenance state
*/
- public String getPassiveState() {
- return passiveState;
+ public String getMaintenanceState() {
+ return maintenanceState;
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostResponse.java
index 2777f3f..434274f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostResponse.java
@@ -37,7 +37,7 @@ public class ServiceComponentHostResponse {
private String desiredState;
private boolean staleConfig = false;
private String adminState = null;
- private String passiveState = null;
+ private String maintenanceState = null;
public ServiceComponentHostResponse(String clusterName, String serviceName,
@@ -254,17 +254,17 @@ public class ServiceComponentHostResponse {
}
/**
- * @return the passive state
+ * @return the maintenance state
*/
- public String getPassiveState() {
- return passiveState;
+ public String getMaintenanceState() {
+ return maintenanceState;
}
/**
- * @param state the passive state
+ * @param state the maintenance state
*/
- public void setPassiveState(String state) {
- passiveState = state;
+ public void setMaintenanceState(String state) {
+ maintenanceState = state;
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceRequest.java
index d98e7a1..eb874b5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceRequest.java
@@ -24,7 +24,7 @@ public class ServiceRequest {
private String clusterName; // REF
private String serviceName; // GET/CREATE/UPDATE/DELETE
private String desiredState; // CREATE/UPDATE
- private String passiveState; // UPDATE
+ private String maintenanceState; // UPDATE
public ServiceRequest(String clusterName, String serviceName,
String desiredState) {
@@ -76,14 +76,17 @@ public class ServiceRequest {
}
/**
- * @param state the new passive state
+ * @param state the new maintenance state
*/
- public void setPassiveState(String state) {
- passiveState = state;
+ public void setMaintenanceState(String state) {
+ maintenanceState = state;
}
- public String getPassiveState() {
- return passiveState;
+ /**
+ * @return the maintenance state
+ */
+ public String getMaintenanceState() {
+ return maintenanceState;
}
public String toString() {
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceResponse.java
index 99cb100..c4881b8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceResponse.java
@@ -18,7 +18,6 @@
package org.apache.ambari.server.controller;
-import org.apache.ambari.server.state.PassiveState;
public class ServiceResponse {
@@ -27,7 +26,7 @@ public class ServiceResponse {
private String serviceName;
private String desiredStackVersion;
private String desiredState;
- private String passiveState;
+ private String maintenanceState;
public ServiceResponse(Long clusterId, String clusterName,
String serviceName,
@@ -134,12 +133,12 @@ public class ServiceResponse {
return true;
}
- public void setPassiveState(String state) {
- passiveState = state;
+ public void setMaintenanceState(String state) {
+ maintenanceState = state;
}
- public String getPassiveState() {
- return passiveState;
+ public String getMaintenanceState() {
+ return maintenanceState;
}
@Override
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
index 600691d..37bb0de 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
@@ -49,7 +49,7 @@ import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
import org.apache.ambari.server.state.Cluster;
import org.apache.ambari.server.state.Clusters;
import org.apache.ambari.server.state.ComponentInfo;
-import org.apache.ambari.server.state.PassiveState;
+import org.apache.ambari.server.state.MaintenanceState;
import org.apache.ambari.server.state.Service;
import org.apache.ambari.server.state.ServiceComponent;
import org.apache.ambari.server.state.ServiceComponentFactory;
@@ -708,7 +708,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
State oldSchState = sch.getState();
- if (oldSchState == State.MAINTENANCE || oldSchState == State.UNKNOWN) {
+ if (oldSchState == State.DISABLED || oldSchState == State.UNKNOWN) {
if (LOG.isDebugEnabled()) {
LOG.debug("Ignoring ServiceComponentHost"
+ ", clusterName=" + request.getClusterName()
@@ -736,15 +736,15 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
}
// do not update or alter any HC that is not active
- PassiveState schPassive = controller.getEffectivePassiveState(sch);
- if (PassiveState.ACTIVE != schPassive) {
+ MaintenanceState schMaint = controller.getEffectiveMaintenanceState(sch);
+ if (MaintenanceState.OFF != schMaint) {
if (LOG.isDebugEnabled()) {
LOG.debug("Ignoring ServiceComponentHost"
+ ", clusterName=" + request.getClusterName()
+ ", serviceName=" + s.getName()
+ ", componentName=" + sc.getName()
+ ", hostname=" + sch.getHostName()
- + ", passive=" + schPassive);
+ + ", maintenance=" + schMaint);
}
continue;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
index c2ca857..89d53ae 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
@@ -17,9 +17,12 @@
*/
package org.apache.ambari.server.controller.internal;
-import com.google.inject.assistedinject.Assisted;
-import com.google.inject.assistedinject.AssistedInject;
-import com.google.inject.persist.Transactional;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.configuration.ComponentSSLConfiguration;
@@ -38,14 +41,10 @@ import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException;
import org.apache.ambari.server.controller.spi.SystemException;
import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
import org.apache.ambari.server.controller.utilities.PropertyHelper;
-import org.apache.ambari.server.state.PassiveState;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
+import com.google.inject.assistedinject.Assisted;
+import com.google.inject.assistedinject.AssistedInject;
+import com.google.inject.persist.Transactional;
/**
* Resource provider for host component resources.
@@ -77,8 +76,8 @@ public class HostComponentResourceProvider extends AbstractControllerResourcePro
= PropertyHelper.getPropertyId("HostRoles", "stale_configs");
protected static final String HOST_COMPONENT_DESIRED_ADMIN_STATE_PROPERTY_ID
= PropertyHelper.getPropertyId("HostRoles", "desired_admin_state");
- protected static final String HOST_COMPONENT_PASSIVE_STATE_PROPERTY_ID
- = "HostRoles/passive_state";
+ protected static final String HOST_COMPONENT_MAINTENANCE_STATE_PROPERTY_ID
+ = "HostRoles/maintenance_state";
//Component name mappings
private static final Map<String, PropertyProvider> HOST_COMPONENT_PROPERTIES_PROVIDER = new HashMap<String, PropertyProvider>();
@@ -203,9 +202,9 @@ public class HostComponentResourceProvider extends AbstractControllerResourcePro
response.getAdminState(), requestedIds);
}
- if (null != response.getPassiveState()) {
- setResourceProperty(resource, HOST_COMPONENT_PASSIVE_STATE_PROPERTY_ID,
- response.getPassiveState(), requestedIds);
+ if (null != response.getMaintenanceState()) {
+ setResourceProperty(resource, HOST_COMPONENT_MAINTENANCE_STATE_PROPERTY_ID,
+ response.getMaintenanceState(), requestedIds);
}
String componentName = (String) resource.getPropertyValue(HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID);
@@ -319,9 +318,9 @@ public class HostComponentResourceProvider extends AbstractControllerResourcePro
properties.get(HOST_COMPONENT_DESIRED_ADMIN_STATE_PROPERTY_ID).toString());
}
- Object o = properties.get(HOST_COMPONENT_PASSIVE_STATE_PROPERTY_ID);
+ Object o = properties.get(HOST_COMPONENT_MAINTENANCE_STATE_PROPERTY_ID);
if (null != o) {
- serviceComponentHostRequest.setPassiveState (o.toString());
+ serviceComponentHostRequest.setMaintenanceState (o.toString());
}
return serviceComponentHostRequest;
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java
index 5a0c2a9..6a45da9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java
@@ -37,7 +37,7 @@ import org.apache.ambari.server.controller.AmbariManagementController;
import org.apache.ambari.server.controller.ConfigurationRequest;
import org.apache.ambari.server.controller.HostRequest;
import org.apache.ambari.server.controller.HostResponse;
-import org.apache.ambari.server.controller.PassiveStateHelper;
+import org.apache.ambari.server.controller.MaintenanceStateHelper;
import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
import org.apache.ambari.server.controller.spi.NoSuchResourceException;
import org.apache.ambari.server.controller.spi.Predicate;
@@ -53,7 +53,7 @@ import org.apache.ambari.server.state.Clusters;
import org.apache.ambari.server.state.Config;
import org.apache.ambari.server.state.DesiredConfig;
import org.apache.ambari.server.state.Host;
-import org.apache.ambari.server.state.PassiveState;
+import org.apache.ambari.server.state.MaintenanceState;
import org.apache.ambari.server.state.ServiceComponentHost;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -101,8 +101,8 @@ public class HostResourceProvider extends AbstractControllerResourceProvider {
protected static final String HOST_HOST_STATUS_PROPERTY_ID =
PropertyHelper.getPropertyId("Hosts", "host_status");
- protected static final String HOST_PASSIVE_STATE_PROPERTY_ID =
- PropertyHelper.getPropertyId("Hosts", "passive_state");
+ protected static final String HOST_MAINTENANCE_STATE_PROPERTY_ID =
+ PropertyHelper.getPropertyId("Hosts", "maintenance_state");
protected static final String HOST_HOST_HEALTH_REPORT_PROPERTY_ID =
PropertyHelper.getPropertyId("Hosts", "host_health_report");
@@ -230,9 +230,9 @@ public class HostResourceProvider extends AbstractControllerResourceProvider {
response.getDesiredHostConfigs(), requestedIds);
// only when a cluster request
- if (null != response.getPassiveState()) {
- setResourceProperty(resource, HOST_PASSIVE_STATE_PROPERTY_ID,
- response.getPassiveState(), requestedIds);
+ if (null != response.getMaintenanceState()) {
+ setResourceProperty(resource, HOST_MAINTENANCE_STATE_PROPERTY_ID,
+ response.getMaintenanceState(), requestedIds);
}
resources.add(resource);
@@ -322,9 +322,9 @@ public class HostResourceProvider extends AbstractControllerResourceProvider {
hostRequest.setPublicHostName((String) properties.get(HOST_PUBLIC_NAME_PROPERTY_ID));
hostRequest.setRackInfo((String) properties.get(HOST_RACK_INFO_PROPERTY_ID));
- Object o = properties.get(HOST_PASSIVE_STATE_PROPERTY_ID);
+ Object o = properties.get(HOST_MAINTENANCE_STATE_PROPERTY_ID);
if (null != o)
- hostRequest.setPassiveState(o.toString());
+ hostRequest.setMaintenanceState(o.toString());
ConfigurationRequest cr = getConfigurationRequest("Hosts", properties);
@@ -498,7 +498,7 @@ public class HostResourceProvider extends AbstractControllerResourceProvider {
r.setClusterName(clusterName);
r.setDesiredHostConfigs(h.getDesiredHostConfigs(cluster));
- r.setPassiveState(h.getPassiveState(cluster.getClusterId()));
+ r.setMaintenanceState(h.getMaintenanceState(cluster.getClusterId()));
response.add(r);
} else if (hostName != null) {
@@ -530,7 +530,7 @@ public class HostResourceProvider extends AbstractControllerResourceProvider {
AmbariManagementController controller = getManagementController();
Clusters clusters = controller.getClusters();
Set<String> maintenanceClusters = new HashSet<String>();
-
+
for (HostRequest request : requests) {
if (request.getHostname() == null
|| request.getHostname().isEmpty()) {
@@ -567,16 +567,16 @@ public class HostResourceProvider extends AbstractControllerResourceProvider {
h.setPublicHostName(request.getPublicHostName());
}
- if (null != request.getClusterName() && null != request.getPassiveState()) {
+ if (null != request.getClusterName() && null != request.getMaintenanceState()) {
Cluster c = clusters.getCluster(request.getClusterName());
- PassiveState newState = PassiveState.valueOf(request.getPassiveState());
- PassiveState oldState = h.getPassiveState(c.getClusterId());
+ MaintenanceState newState = MaintenanceState.valueOf(request.getMaintenanceState());
+ MaintenanceState oldState = h.getMaintenanceState(c.getClusterId());
if (!newState.equals(oldState)) {
- if (newState.equals(PassiveState.IMPLIED)) {
+ if (newState.equals(MaintenanceState.IMPLIED)) {
throw new IllegalArgumentException("Invalid arguments, can only set " +
- "passive state to one of " + EnumSet.of(PassiveState.ACTIVE, PassiveState.PASSIVE));
+ "maintenance state to one of " + EnumSet.of(MaintenanceState.OFF, MaintenanceState.ON));
} else {
- h.setPassiveState(c.getClusterId(), newState);
+ h.setMaintenanceState(c.getClusterId(), newState);
maintenanceClusters.add(c.getClusterName());
}
@@ -624,10 +624,10 @@ public class HostResourceProvider extends AbstractControllerResourceProvider {
if (maintenanceClusters.size() > 0) {
try {
- PassiveStateHelper.createRequests(controller, requestProperties,
+ MaintenanceStateHelper.createRequests(controller, requestProperties,
maintenanceClusters);
} catch (Exception e) {
- LOG.warn("Could not send passive status to Nagios (" + e.getMessage() + ")");
+ LOG.warn("Could not send maintenance status to Nagios (" + e.getMessage() + ")");
}
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java
index 608d8e5..204d14c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java
@@ -37,7 +37,7 @@ import org.apache.ambari.server.ParentObjectNotFoundException;
import org.apache.ambari.server.ServiceNotFoundException;
import org.apache.ambari.server.api.services.AmbariMetaInfo;
import org.apache.ambari.server.controller.AmbariManagementController;
-import org.apache.ambari.server.controller.PassiveStateHelper;
+import org.apache.ambari.server.controller.MaintenanceStateHelper;
import org.apache.ambari.server.controller.RequestStatusResponse;
import org.apache.ambari.server.controller.ServiceComponentHostRequest;
import org.apache.ambari.server.controller.ServiceComponentHostResponse;
@@ -56,7 +56,7 @@ import org.apache.ambari.server.controller.utilities.PropertyHelper;
import org.apache.ambari.server.state.Cluster;
import org.apache.ambari.server.state.Clusters;
import org.apache.ambari.server.state.ComponentInfo;
-import org.apache.ambari.server.state.PassiveState;
+import org.apache.ambari.server.state.MaintenanceState;
import org.apache.ambari.server.state.Service;
import org.apache.ambari.server.state.ServiceComponent;
import org.apache.ambari.server.state.ServiceComponentHost;
@@ -81,7 +81,7 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider
protected static final String SERVICE_CLUSTER_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("ServiceInfo", "cluster_name");
protected static final String SERVICE_SERVICE_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("ServiceInfo", "service_name");
protected static final String SERVICE_SERVICE_STATE_PROPERTY_ID = PropertyHelper.getPropertyId("ServiceInfo", "state");
- protected static final String SERVICE_PASSIVE_STATE_PROPERTY_ID = PropertyHelper.getPropertyId("ServiceInfo", "passive_state");
+ protected static final String SERVICE_MAINTENANCE_STATE_PROPERTY_ID = PropertyHelper.getPropertyId("ServiceInfo", "maintenance_state");
//Parameters from the predicate
private static final String QUERY_PARAMETERS_RUN_SMOKE_TEST_ID =
@@ -176,8 +176,8 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider
setResourceProperty(resource, SERVICE_SERVICE_STATE_PROPERTY_ID,
calculateServiceState(response.getClusterName(), response.getServiceName()),
requestedIds);
- setResourceProperty(resource, SERVICE_PASSIVE_STATE_PROPERTY_ID,
- response.getPassiveState(), requestedIds);
+ setResourceProperty(resource, SERVICE_MAINTENANCE_STATE_PROPERTY_ID,
+ response.getMaintenanceState(), requestedIds);
resources.add(resource);
}
return resources;
@@ -277,9 +277,9 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider
(String) properties.get(SERVICE_SERVICE_NAME_PROPERTY_ID),
(String) properties.get(SERVICE_SERVICE_STATE_PROPERTY_ID));
- Object o = properties.get(SERVICE_PASSIVE_STATE_PROPERTY_ID);
+ Object o = properties.get(SERVICE_MAINTENANCE_STATE_PROPERTY_ID);
if (null != o)
- svcRequest.setPassiveState(o.toString());
+ svcRequest.setMaintenanceState(o.toString());
return svcRequest;
}
@@ -505,6 +505,7 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider
Map<String, Set<String>> serviceNames = new HashMap<String, Set<String>>();
Set<State> seenNewStates = new HashSet<State>();
+
Clusters clusters = controller.getClusters();
AmbariMetaInfo ambariMetaInfo = controller.getAmbariMetaInfo();
Set<String> maintenanceClusters = new HashSet<String>();
@@ -553,14 +554,14 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider
}
}
- if (null != request.getPassiveState()) {
- PassiveState newPassive = PassiveState.valueOf(request.getPassiveState());
- if (newPassive != s.getPassiveState()) {
- if (newPassive.equals(PassiveState.IMPLIED)) {
+ if (null != request.getMaintenanceState()) {
+ MaintenanceState newMaint = MaintenanceState.valueOf(request.getMaintenanceState());
+ if (newMaint != s.getMaintenanceState()) {
+ if (newMaint.equals(MaintenanceState.IMPLIED)) {
throw new IllegalArgumentException("Invalid arguments, can only set " +
- "passive state to one of " + EnumSet.of(PassiveState.ACTIVE, PassiveState.PASSIVE));
+ "maintenance state to one of " + EnumSet.of(MaintenanceState.OFF, MaintenanceState.ON));
} else {
- s.setPassiveState(newPassive);
+ s.setMaintenanceState(newMaint);
maintenanceClusters.add(cluster.getClusterName());
}
@@ -577,9 +578,9 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider
continue;
}
- if (requests.size() > 1 && PassiveState.ACTIVE != s.getPassiveState()) {
+ if (requests.size() > 1 && MaintenanceState.OFF != s.getMaintenanceState()) {
LOG.info("Operations cannot be applied to service " + s.getName() +
- " in the passive state of " + s.getPassiveState());
+ " in the maintenance state of " + s.getMaintenanceState());
continue;
}
@@ -638,7 +639,7 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider
}
for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()){
State oldSchState = sch.getState();
- if (oldSchState == State.MAINTENANCE || oldSchState == State.UNKNOWN) {
+ if (oldSchState == State.DISABLED || oldSchState == State.UNKNOWN) {
//Ignore host components updates in this state
if (LOG.isDebugEnabled()) {
LOG.debug("Ignoring ServiceComponentHost"
@@ -666,12 +667,12 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider
continue;
}
- PassiveState schPassive = controller.getEffectivePassiveState(sch);
- if (PassiveState.PASSIVE == schPassive ||
- (requests.size() > 1 && PassiveState.ACTIVE != schPassive)) {
+ MaintenanceState schMaint = controller.getEffectiveMaintenanceState(sch);
+ if (MaintenanceState.ON == schMaint ||
+ (requests.size() > 1 && MaintenanceState.OFF != schMaint)) {
ignoredScHosts.add(sch);
if (LOG.isDebugEnabled()) {
- LOG.debug("Ignoring " + schPassive + " ServiceComponentHost"
+ LOG.debug("Ignoring " + schMaint + " ServiceComponentHost"
+ ", clusterName=" + request.getClusterName()
+ ", serviceName=" + s.getName()
+ ", componentName=" + sc.getName()
@@ -738,12 +739,12 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider
+ " changes for a set of services at the same time");
}
- if (maintenanceClusters.size() > -0) {
+ if (maintenanceClusters.size() > 0) {
try {
- PassiveStateHelper.createRequests(controller, requestProperties,
+ MaintenanceStateHelper.createRequests(controller, requestProperties,
maintenanceClusters);
} catch (Exception e) {
- LOG.warn("Could not send passive status to Nagios (" + e.getMessage() + ")");
+ LOG.warn("Could not send maintenance state to Nagios (" + e.getMessage() + ")");
}
}
@@ -830,7 +831,7 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider
State state = getHostComponentState(hostComponentResponse);
switch (state) {
case STARTED:
- case MAINTENANCE:
+ case DISABLED:
break;
default:
return state;
@@ -900,7 +901,7 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider
switch (state) {
case STARTED:
- case MAINTENANCE:
+ case DISABLED:
if (isNameNode) {
++nameNodeActiveCount;
}
@@ -964,7 +965,7 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider
switch (state) {
case STARTED:
- case MAINTENANCE:
+ case DISABLED:
String componentName = hostComponentResponse.getComponentName();
if (componentName.equals("HBASE_MASTER")) {
++hBaseMasterActiveCount;
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java
index ed9da4b..8b29852 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java
@@ -20,7 +20,7 @@ package org.apache.ambari.server.orm.entities;
import javax.persistence.*;
import org.apache.ambari.server.state.HostComponentAdminState;
-import org.apache.ambari.server.state.PassiveState;
+import org.apache.ambari.server.state.MaintenanceState;
import org.apache.ambari.server.state.State;
import static org.apache.commons.lang.StringUtils.defaultString;
@@ -71,8 +71,8 @@ public class HostComponentDesiredStateEntity {
private HostEntity hostEntity;
@Enumerated(value = EnumType.STRING)
- @Column(name="passive_state", nullable = false, insertable = true, updatable = true)
- private PassiveState passiveState = PassiveState.ACTIVE;
+ @Column(name="maintenance_state", nullable = false, insertable = true, updatable = true)
+ private MaintenanceState maintenanceState = MaintenanceState.OFF;
public Long getClusterId() {
return clusterId;
@@ -131,12 +131,12 @@ public class HostComponentDesiredStateEntity {
this.adminState = attribute;
}
- public PassiveState getPassiveState() {
- return passiveState;
+ public MaintenanceState getMaintenanceState() {
+ return maintenanceState;
}
- public void setPassiveState(PassiveState state) {
- passiveState = state;
+ public void setMaintenanceState(MaintenanceState state) {
+ maintenanceState = state;
}
@Override
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostStateEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostStateEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostStateEntity.java
index a535222..5d5a1e8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostStateEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostStateEntity.java
@@ -18,13 +18,18 @@
package org.apache.ambari.server.orm.entities;
-import org.apache.ambari.server.state.HostState;
-import org.apache.ambari.server.state.PassiveState;
-import org.apache.commons.lang.StringUtils;
+import static org.apache.commons.lang.StringUtils.defaultString;
-import javax.persistence.*;
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToOne;
-import static org.apache.commons.lang.StringUtils.defaultString;
+import org.apache.ambari.server.state.HostState;
@javax.persistence.Table(name = "hoststate")
@Entity
@@ -54,8 +59,8 @@ public class HostStateEntity {
@Enumerated(value = EnumType.STRING)
private HostState currentState = HostState.INIT;
- @Column(name="passive_state", nullable = true, insertable = true, updatable = true)
- private String passiveState = null;
+ @Column(name="maintenance_state", nullable = true, insertable = true, updatable = true)
+ private String maintenanceState = null;
@OneToOne
@@ -110,12 +115,12 @@ public class HostStateEntity {
this.currentState = currentState;
}
- public String getPassiveState() {
- return passiveState;
+ public String getMaintenanceState() {
+ return maintenanceState;
}
- public void setPassiveState(String state) {
- passiveState = state;
+ public void setMaintenanceState(String state) {
+ maintenanceState = state;
}
@Override
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceDesiredStateEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceDesiredStateEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceDesiredStateEntity.java
index 3457934..a74b021 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceDesiredStateEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceDesiredStateEntity.java
@@ -18,7 +18,7 @@
package org.apache.ambari.server.orm.entities;
-import org.apache.ambari.server.state.PassiveState;
+import org.apache.ambari.server.state.MaintenanceState;
import org.apache.ambari.server.state.State;
import org.apache.commons.lang.StringUtils;
@@ -49,9 +49,9 @@ public class ServiceDesiredStateEntity {
@Basic
private String desiredStackVersion = "";
- @Column(name = "passive_state", nullable = false, insertable = true, updatable = true)
+ @Column(name = "maintenance_state", nullable = false, insertable = true, updatable = true)
@Enumerated(value = EnumType.STRING)
- private PassiveState passiveState = PassiveState.ACTIVE;
+ private MaintenanceState maintenanceState = MaintenanceState.OFF;
@OneToOne
@@ -102,12 +102,12 @@ public class ServiceDesiredStateEntity {
this.desiredStackVersion = desiredStackVersion;
}
- public PassiveState getPassiveState() {
- return passiveState;
+ public MaintenanceState getMaintenanceState() {
+ return maintenanceState;
}
- public void setPassiveState(PassiveState state) {
- passiveState = state;
+ public void setMaintenanceState(MaintenanceState state) {
+ maintenanceState = state;
}
@Override
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/state/Host.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/Host.java b/ambari-server/src/main/java/org/apache/ambari/server/state/Host.java
index 491356f..f61e46c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/Host.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/Host.java
@@ -331,15 +331,15 @@ public interface Host {
public Map<String, HostConfig> getDesiredHostConfigs(Cluster cluster) throws AmbariException;
/**
- * Sets the passive state for the host.
+ * Sets the maintenance state for the host.
* @param clusterId the cluster id
* @param state the state
*/
- public void setPassiveState(long clusterId, PassiveState state);
+ public void setMaintenanceState(long clusterId, MaintenanceState state);
/**
* @param clusterId the cluster id
- * @return the passive state
+ * @return the maintenance state
*/
- public PassiveState getPassiveState(long clusterId);
+ public MaintenanceState getMaintenanceState(long clusterId);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/state/MaintenanceState.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/MaintenanceState.java b/ambari-server/src/main/java/org/apache/ambari/server/state/MaintenanceState.java
new file mode 100644
index 0000000..36fea40
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/MaintenanceState.java
@@ -0,0 +1,37 @@
+/**
+ * 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.state;
+
+/**
+ * Indicates when a Service or Host participates in automated opererations, and
+ * if alerts are enabled.
+ */
+public enum MaintenanceState {
+ /**
+ * All group-targeted commands are available. Alerts enabled.
+ */
+ OFF,
+ /**
+ * Target was explicitly put into maintenance state. Alerts disabled.
+ */
+ ON,
+ /**
+ * Target is in maintenance, implied by a parent target.
+ */
+ IMPLIED
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/state/PassiveState.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/PassiveState.java b/ambari-server/src/main/java/org/apache/ambari/server/state/PassiveState.java
deleted file mode 100644
index e7f2d2a..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/PassiveState.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.ambari.server.state;
-
-/**
- * Indicates when a Service or Host participates in automated opererations, and
- * if alerts are enabled.
- */
-public enum PassiveState {
- /**
- * All group-targeted commands are available. Alerts enabled.
- */
- ACTIVE,
- /**
- * Target was actively put into passive state. Alerts disabled.
- */
- PASSIVE,
- /**
- * Target is passive, implied by a parent target.
- */
- IMPLIED
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java b/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java
index d3d8fd2..8701ff1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java
@@ -90,15 +90,15 @@ public interface Service {
ReadWriteLock getClusterGlobalLock();
/**
- * Sets the passive state for the service
- * @param state the status
+ * Sets the maintenance state for the service
+ * @param state the state
*/
- public void setPassiveState(PassiveState state);
+ public void setMaintenanceState(MaintenanceState state);
/**
- * @return the passive state
+ * @return the maintenance state
*/
- public PassiveState getPassiveState();
+ public MaintenanceState getMaintenanceState();
public enum Type {
HDFS,
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java
index cff1861..82ee296 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java
@@ -115,14 +115,14 @@ public interface ServiceComponentHost {
public HostState getHostState();
/**
- * @param state the passive state
+ * @param state the maintenance state
*/
- public void setPassiveState(PassiveState state);
+ public void setMaintenanceState(MaintenanceState state);
/**
- * @return the passive state
+ * @return the maintenance state
*/
- public PassiveState getPassiveState();
+ public MaintenanceState getMaintenanceState();
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHostEvent.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHostEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHostEvent.java
index 64dfe08..78590fc 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHostEvent.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHostEvent.java
@@ -118,8 +118,8 @@ public abstract class ServiceComponentHostEvent
return new ServiceComponentHostWipeoutEvent(serviceComponentName, hostName, opTimestamp);
case HOST_SVCCOMP_UPGRADE:
return new ServiceComponentHostUpgradeEvent(serviceComponentName, hostName, opTimestamp, stackId);
- case HOST_SVCCOMP_MAINTENANCE:
- return new ServiceComponentHostMaintenanceEvent(serviceComponentName, hostName, opTimestamp);
+ case HOST_SVCCOMP_DISABLE:
+ return new ServiceComponentHostDisableEvent(serviceComponentName, hostName, opTimestamp);
case HOST_SVCCOMP_RESTORE:
return new ServiceComponentHostRestoreEvent(serviceComponentName, hostName, opTimestamp);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHostEventType.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHostEventType.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHostEventType.java
index 77ed810..b43ac9c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHostEventType.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHostEventType.java
@@ -68,11 +68,11 @@ public enum ServiceComponentHostEventType {
*/
HOST_SVCCOMP_UPGRADE,
/**
- * Putting host component into maintenance state
+ * Putting host component into disabled state
*/
- HOST_SVCCOMP_MAINTENANCE,
+ HOST_SVCCOMP_DISABLE,
/**
- * Recovering host component from maintenance state
+ * Recovering host component from disable state
*/
HOST_SVCCOMP_RESTORE
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
index f8b3785..1225160 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
@@ -385,7 +385,7 @@ public class ServiceImpl implements Service {
getDesiredStackVersion().getStackId(),
getDesiredState().toString());
- r.setPassiveState(getPassiveState().name());
+ r.setMaintenanceState(getMaintenanceState().name());
return r;
} finally {
readWriteLock.readLock().unlock();
@@ -652,12 +652,12 @@ public class ServiceImpl implements Service {
}
@Override
- public void setPassiveState(PassiveState state) {
+ public void setMaintenanceState(MaintenanceState state) {
clusterGlobalLock.readLock().lock();
try {
try {
readWriteLock.writeLock().lock();
- serviceDesiredStateEntity.setPassiveState(state);
+ serviceDesiredStateEntity.setMaintenanceState(state);
saveIfPersisted();
} finally {
readWriteLock.writeLock().unlock();
@@ -668,8 +668,8 @@ public class ServiceImpl implements Service {
}
@Override
- public PassiveState getPassiveState() {
- return serviceDesiredStateEntity.getPassiveState();
+ public MaintenanceState getMaintenanceState() {
+ return serviceDesiredStateEntity.getMaintenanceState();
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/state/State.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/State.java b/ambari-server/src/main/java/org/apache/ambari/server/state/State.java
index 91d2a85..835b751 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/State.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/State.java
@@ -68,7 +68,7 @@ public enum State {
/**
* Disabled master's backup state
*/
- MAINTENANCE,
+ DISABLED,
/**
* State could not be determined.
*/
@@ -85,7 +85,7 @@ public enum State {
case INSTALLED:
case STARTED:
case UNINSTALLED:
- case MAINTENANCE:
+ case DISABLED:
return true;
default:
return false;
@@ -121,7 +121,7 @@ public enum State {
case INSTALL_FAILED:
case UNINSTALLED:
case UNKNOWN:
- case MAINTENANCE:
+ case DISABLED:
return true;
default:
return false;
@@ -148,7 +148,7 @@ public enum State {
|| startState == State.UPGRADING
|| startState == State.STOPPING
|| startState == State.UNKNOWN
- || startState == State.MAINTENANCE) {
+ || startState == State.DISABLED) {
return true;
}
break;
@@ -171,7 +171,7 @@ public enum State {
|| startState == State.WIPING_OUT) {
return true;
}
- case MAINTENANCE:
+ case DISABLED:
if (startState == State.INSTALLED
|| startState == State.UNKNOWN) {
return true;
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
index 4ffb369..d151e8b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
@@ -52,7 +52,7 @@ import org.apache.ambari.server.state.HostEventType;
import org.apache.ambari.server.state.HostHealthStatus;
import org.apache.ambari.server.state.HostHealthStatus.HealthStatus;
import org.apache.ambari.server.state.HostState;
-import org.apache.ambari.server.state.PassiveState;
+import org.apache.ambari.server.state.MaintenanceState;
import org.apache.ambari.server.state.configgroup.ConfigGroup;
import org.apache.ambari.server.state.fsm.InvalidStateTransitionException;
import org.apache.ambari.server.state.fsm.SingleArcTransition;
@@ -93,8 +93,8 @@ public class HostImpl implements Host {
private static final Type hostAttributesType =
new TypeToken<Map<String, String>>() {}.getType();
- private static final Type passiveMapType =
- new TypeToken<Map<Long, PassiveState>>() {}.getType();
+ private static final Type maintMapType =
+ new TypeToken<Map<Long, MaintenanceState>>() {}.getType();
ReadWriteLock rwLock;
private final Lock readLock;
@@ -115,7 +115,7 @@ public class HostImpl implements Host {
private Integer currentPingPort = null;
private final StateMachine<HostState, HostEventType, HostEvent> stateMachine;
- private Map<Long, PassiveState> passiveMap = null;
+ private Map<Long, MaintenanceState> maintMap = null;
@@ -1230,32 +1230,32 @@ public class HostImpl implements Host {
return findSelectedByType;
}
- private void ensurePassiveMap() {
- if (null == passiveMap) {
- String entity = hostStateEntity.getPassiveState();
+ private void ensureMaintMap() {
+ if (null == maintMap) {
+ String entity = hostStateEntity.getMaintenanceState();
if (null == entity) {
- passiveMap = new HashMap<Long, PassiveState>();
+ maintMap = new HashMap<Long, MaintenanceState>();
} else {
try {
- passiveMap = gson.fromJson(entity, passiveMapType);
+ maintMap = gson.fromJson(entity, maintMapType);
} catch (Exception e) {
- passiveMap = new HashMap<Long, PassiveState>();
+ maintMap = new HashMap<Long, MaintenanceState>();
}
}
}
}
@Override
- public void setPassiveState(long clusterId, PassiveState state) {
+ public void setMaintenanceState(long clusterId, MaintenanceState state) {
try {
writeLock.lock();
- ensurePassiveMap();
+ ensureMaintMap();
- passiveMap.put(Long.valueOf(clusterId), state);
- String json = gson.toJson(passiveMap, passiveMapType);
+ maintMap.put(Long.valueOf(clusterId), state);
+ String json = gson.toJson(maintMap, maintMapType);
- hostStateEntity.setPassiveState(json);
+ hostStateEntity.setMaintenanceState(json);
saveIfPersisted();
} finally {
writeLock.unlock();
@@ -1263,18 +1263,18 @@ public class HostImpl implements Host {
}
@Override
- public PassiveState getPassiveState(long clusterId) {
+ public MaintenanceState getMaintenanceState(long clusterId) {
try {
readLock.lock();
- ensurePassiveMap();
+ ensureMaintMap();
Long id = Long.valueOf(clusterId);
- if (!passiveMap.containsKey(id))
- passiveMap.put(id, PassiveState.ACTIVE);
+ if (!maintMap.containsKey(id))
+ maintMap.put(id, MaintenanceState.OFF);
- return passiveMap.get(id);
+ return maintMap.get(id);
} finally {
readLock.unlock();
}