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:31 UTC
[1/3] AMBARI-4752. Rename MAINTENANCE and PassiveState (ncole)
Repository: ambari
Updated Branches:
refs/heads/trunk 77de4b96c -> e1f4f2e8b
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/test/java/org/apache/ambari/server/controller/PassiveStateHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/PassiveStateHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/PassiveStateHelperTest.java
deleted file mode 100644
index 6a86182..0000000
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/PassiveStateHelperTest.java
+++ /dev/null
@@ -1,203 +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 static org.easymock.EasyMock.capture;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.ambari.server.state.Cluster;
-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 org.easymock.Capture;
-import org.easymock.EasyMock;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * Tests the PassiveAlertHelper class
- */
-public class PassiveStateHelperTest {
-
- @Test
- public void testService() throws Exception {
- testService(PassiveState.PASSIVE);
- testService(PassiveState.ACTIVE);
- }
-
- @Test
- public void testHost() throws Exception {
- testHost(PassiveState.PASSIVE);
- testHost(PassiveState.ACTIVE);
- }
-
- @Test
- public void testHostComponent() throws Exception {
- testHostComponent(PassiveState.PASSIVE);
- testHostComponent(PassiveState.ACTIVE);
- }
-
- private void testHostComponent(PassiveState state) throws Exception {
- AmbariManagementController amc = createMock(AmbariManagementController.class);
- Capture<ExecuteActionRequest> earCapture = new Capture<ExecuteActionRequest>();
- Capture<Map<String, String>> rpCapture = new Capture<Map<String, String>>();
- expect(amc.createAction(capture(earCapture), capture(rpCapture))).andReturn(null);
-
- Cluster cluster = createMock(Cluster.class);
- expect(cluster.getClusterName()).andReturn("c1").anyTimes();
-
- ServiceComponentHost sch = createMock(ServiceComponentHost.class);
- expect(sch.getClusterName()).andReturn("c1");
- expect(sch.getPassiveState()).andReturn(state);
- expect(sch.getServiceName()).andReturn("HDFS");
- expect(sch.getServiceComponentName()).andReturn("NAMENODE").anyTimes();
- expect(sch.getHostName()).andReturn("h1");
-
- replay(amc, cluster, sch);
-
- Map<String, String> map = new HashMap<String, String>();
- map.put("context", "abc");
- PassiveStateHelper.createRequests(amc, map,
- Collections.singleton(sch.getClusterName()));
-
- ExecuteActionRequest ear = earCapture.getValue();
- map = rpCapture.getValue();
-
- Assert.assertEquals("nagios_update_ignore", ear.getActionName());
- Assert.assertEquals("ACTIONEXECUTE", ear.getCommandName());
- Assert.assertEquals("NAGIOS", ear.getServiceName());
- Assert.assertEquals("NAGIOS_SERVER", ear.getComponentName());
- Assert.assertEquals("c1", ear.getClusterName());
- Assert.assertTrue(map.containsKey("context"));
- }
-
- private void testHost(PassiveState state) throws Exception {
- AmbariManagementController amc = createMock(AmbariManagementController.class);
- Capture<ExecuteActionRequest> earCapture = new Capture<ExecuteActionRequest>();
- Capture<Map<String, String>> rpCapture = new Capture<Map<String, String>>();
- expect(amc.createAction(capture(earCapture), capture(rpCapture))).andReturn(null);
-
- Cluster cluster = createMock(Cluster.class);
-
- Service service = createMock(Service.class);
-
- ServiceComponent sc1 = createMock(ServiceComponent.class);
- ServiceComponent sc2 = createMock(ServiceComponent.class);
- expect(sc1.isClientComponent()).andReturn(Boolean.FALSE).anyTimes();
- expect(sc2.isClientComponent()).andReturn(Boolean.TRUE).anyTimes();
-
- ServiceComponentHost sch1 = createMock(ServiceComponentHost.class);
- Map<String, ServiceComponentHost> schMap = new HashMap<String, ServiceComponentHost>();
- schMap.put("h1", sch1);
- expect(sch1.getHostName()).andReturn("h1");
- expect(sch1.getServiceName()).andReturn("HDFS").anyTimes();
- expect(sch1.getServiceComponentName()).andReturn("NAMENODE").anyTimes();
-
- List<ServiceComponentHost> schList = new ArrayList<ServiceComponentHost>(schMap.values());
-
- expect(cluster.getClusterName()).andReturn("c1").anyTimes();
- expect(cluster.getService("HDFS")).andReturn(service).anyTimes();
- expect(cluster.getClusterId()).andReturn(Long.valueOf(1L));
- expect(cluster.getServiceComponentHosts("h1")).andReturn(schList);
- expect(service.getServiceComponent("NAMENODE")).andReturn(sc1);
-
- Host host = createMock(Host.class);
- expect(host.getHostName()).andReturn("h1").anyTimes();
- expect(host.getPassiveState(1L)).andReturn(state);
-
- replay(amc, cluster, service, sch1, host);
-
- Map<String, String> map = new HashMap<String, String>();
- map.put("context", "abc");
- PassiveStateHelper.createRequests(amc, map,
- Collections.singleton(cluster.getClusterName()));
-
- ExecuteActionRequest ear = earCapture.getValue();
- rpCapture.getValue();
-
- Assert.assertEquals("nagios_update_ignore", ear.getActionName());
- Assert.assertEquals("ACTIONEXECUTE", ear.getCommandName());
- Assert.assertEquals("NAGIOS", ear.getServiceName());
- Assert.assertEquals("NAGIOS_SERVER", ear.getComponentName());
- Assert.assertEquals("c1", ear.getClusterName());
- Assert.assertTrue(map.containsKey("context"));
- }
-
-
- private void testService(PassiveState state) throws Exception {
- AmbariManagementController amc = createMock(AmbariManagementController.class);
- Capture<ExecuteActionRequest> earCapture = new Capture<ExecuteActionRequest>();
- Capture<Map<String, String>> rpCapture = new Capture<Map<String, String>>();
- expect(amc.createAction(capture(earCapture), capture(rpCapture))).andReturn(null);
-
- Cluster cluster = createMock(Cluster.class);
- Service service = createMock(Service.class);
-
- ServiceComponent sc1 = createMock(ServiceComponent.class);
- ServiceComponent sc2 = createMock(ServiceComponent.class);
- expect(sc1.isClientComponent()).andReturn(Boolean.FALSE).anyTimes();
- expect(sc2.isClientComponent()).andReturn(Boolean.TRUE).anyTimes();
-
- ServiceComponentHost sch1 = createMock(ServiceComponentHost.class);
- Map<String, ServiceComponentHost> schMap = new HashMap<String, ServiceComponentHost>();
- schMap.put("h1", sch1);
- expect(sch1.getHostName()).andReturn("h1");
- expect(sch1.getServiceName()).andReturn("HDFS");
- expect(sch1.getServiceComponentName()).andReturn("NAMENODE");
-
- expect(sc1.getServiceComponentHosts()).andReturn(schMap);
-
- Map<String, ServiceComponent> scMap = new HashMap<String, ServiceComponent>();
- scMap.put("NAMENODE", sc1);
- scMap.put("HDFS_CLIENT", sc2);
-
- expect(cluster.getClusterName()).andReturn("c1");
- expect(service.getCluster()).andReturn(cluster);
- expect(service.getServiceComponents()).andReturn(scMap);
- expect(service.getPassiveState()).andReturn(state);
- expect(service.getName()).andReturn("HDFS");
-
- replay(amc, cluster, service, sc1, sc2, sch1);
-
- Map<String, String> map = new HashMap<String, String>();
- map.put("context", "abc");
- PassiveStateHelper.createRequests(amc, map,
- Collections.singleton("c1"));
-
- ExecuteActionRequest ear = earCapture.getValue();
- map = rpCapture.getValue();
-
- Assert.assertEquals("nagios_update_ignore", ear.getActionName());
- Assert.assertEquals("ACTIONEXECUTE", ear.getCommandName());
- Assert.assertEquals("NAGIOS", ear.getServiceName());
- Assert.assertEquals("NAGIOS_SERVER", ear.getComponentName());
- Assert.assertEquals("c1", ear.getClusterName());
- Assert.assertTrue(map.containsKey("context"));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
index be5d4cb..4c48db5 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
@@ -60,7 +60,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.ServiceComponentFactory;
@@ -239,8 +239,8 @@ public class ComponentResourceProviderTest {
// set expectations
expect(managementController.getClusters()).andReturn(clusters).anyTimes();
expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo).anyTimes();
- expect(managementController.getEffectivePassiveState(
- capture(new Capture<ServiceComponentHost>()))).andReturn(PassiveState.ACTIVE).anyTimes();
+ expect(managementController.getEffectiveMaintenanceState(
+ capture(new Capture<ServiceComponentHost>()))).andReturn(MaintenanceState.OFF).anyTimes();
expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes();
expect(cluster.getDesiredStackVersion()).andReturn(stackId);
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java
index 5082dce..9f68b0a 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java
@@ -669,7 +669,7 @@ public class ServiceResourceProviderTest {
}
@Test
- public void testDefaultServiceState_MAINTENANCE() throws Exception{
+ public void testDefaultServiceState_DISABLED() throws Exception{
AmbariManagementController managementController = createMock(AmbariManagementController.class);
Clusters clusters = createNiceMock(Clusters.class);
Cluster cluster = createNiceMock(Cluster.class);
@@ -677,7 +677,7 @@ public class ServiceResourceProviderTest {
StackId stackId = createNiceMock(StackId.class);
ComponentInfo componentInfo = createNiceMock(ComponentInfo.class);
- ServiceComponentHostResponse shr1 = new ServiceComponentHostResponse("C1", "MAPREDUCE", "JOBTRACKER", "Host100", "MAINTENANCE", "", null, null, null);
+ ServiceComponentHostResponse shr1 = new ServiceComponentHostResponse("C1", "MAPREDUCE", "JOBTRACKER", "Host100", "DISABLED", "", null, null, null);
ServiceComponentHostResponse shr2 = new ServiceComponentHostResponse("C1", "MAPREDUCE", "MAPREDUCE_CLIENT", "Host100", "STARTED", "", null, null, null);
ServiceComponentHostResponse shr3 = new ServiceComponentHostResponse("C1", "MAPREDUCE", "TASKTRACKER", "Host100", "STARTED", "", null, null, null);
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceTest.java
index 066f4c4..493291d 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceTest.java
@@ -285,7 +285,7 @@ public class ServiceTest {
}
@Test
- public void testServicePassive() throws Exception {
+ public void testServiceMaintenance() throws Exception {
String serviceName = "HDFS";
Service s = serviceFactory.createNew(cluster, serviceName);
cluster.addService(s);
@@ -297,15 +297,15 @@ public class ServiceTest {
ClusterServiceDAO dao = injector.getInstance(ClusterServiceDAO.class);
ClusterServiceEntity entity = dao.findByClusterAndServiceNames(clusterName, serviceName);
Assert.assertNotNull(entity);
- Assert.assertEquals(PassiveState.ACTIVE, entity.getServiceDesiredStateEntity().getPassiveState());
- Assert.assertEquals(PassiveState.ACTIVE, service.getPassiveState());
+ Assert.assertEquals(MaintenanceState.OFF, entity.getServiceDesiredStateEntity().getMaintenanceState());
+ Assert.assertEquals(MaintenanceState.OFF, service.getMaintenanceState());
- service.setPassiveState(PassiveState.PASSIVE);
- Assert.assertEquals(PassiveState.PASSIVE, service.getPassiveState());
+ service.setMaintenanceState(MaintenanceState.ON);
+ Assert.assertEquals(MaintenanceState.ON, service.getMaintenanceState());
entity = dao.findByClusterAndServiceNames(clusterName, serviceName);
Assert.assertNotNull(entity);
- Assert.assertEquals(PassiveState.PASSIVE, entity.getServiceDesiredStateEntity().getPassiveState());
+ Assert.assertEquals(MaintenanceState.ON, entity.getServiceDesiredStateEntity().getMaintenanceState());
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/test/java/org/apache/ambari/server/state/host/HostTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/host/HostTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/host/HostTest.java
index 50ef1ad..0cdf431 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/host/HostTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/host/HostTest.java
@@ -51,7 +51,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.StackId;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -414,7 +414,7 @@ public class HostTest {
}
@Test
- public void testHostPassive() throws Exception {
+ public void testHostMaintenance() throws Exception {
AmbariMetaInfo metaInfo = injector.getInstance(AmbariMetaInfo.class);
metaInfo.init();
@@ -433,14 +433,14 @@ public class HostTest {
HostEntity entity = hostDAO.findByName("h1");
HostStateEntity stateEntity = entity.getHostStateEntity();
- Assert.assertNull(stateEntity.getPassiveState());
- Assert.assertEquals(PassiveState.ACTIVE, host.getPassiveState(c1.getClusterId()));
+ Assert.assertNull(stateEntity.getMaintenanceState());
+ Assert.assertEquals(MaintenanceState.OFF, host.getMaintenanceState(c1.getClusterId()));
- host.setPassiveState(c1.getClusterId(), PassiveState.PASSIVE);
+ host.setMaintenanceState(c1.getClusterId(), MaintenanceState.ON);
entity = hostDAO.findByName("h1");
stateEntity = entity.getHostStateEntity();
- Assert.assertNotNull(stateEntity.getPassiveState());
- Assert.assertEquals(PassiveState.PASSIVE, host.getPassiveState(c1.getClusterId()));
+ Assert.assertNotNull(stateEntity.getMaintenanceState());
+ Assert.assertEquals(MaintenanceState.ON, host.getMaintenanceState(c1.getClusterId()));
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostTest.java
index 6046bb8..1a46442 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostTest.java
@@ -39,7 +39,7 @@ import org.apache.ambari.server.state.Config;
import org.apache.ambari.server.state.ConfigFactory;
import org.apache.ambari.server.state.Host;
import org.apache.ambari.server.state.HostConfig;
-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;
@@ -802,7 +802,7 @@ public class ServiceComponentHostTest {
}
@Test
- public void testPassive() throws Exception {
+ public void testMaintenance() throws Exception {
String stackVersion="HDP-2.0.6";
String clusterName = "c2";
String hostName = "h3";
@@ -830,14 +830,14 @@ public class ServiceComponentHostTest {
HostComponentDesiredStateDAO dao = injector.getInstance(HostComponentDesiredStateDAO.class);
HostComponentDesiredStateEntity entity = dao.findByPK(pk);
- Assert.assertEquals(PassiveState.ACTIVE, entity.getPassiveState());
- Assert.assertEquals(PassiveState.ACTIVE, sch1.getPassiveState());
+ Assert.assertEquals(MaintenanceState.OFF, entity.getMaintenanceState());
+ Assert.assertEquals(MaintenanceState.OFF, sch1.getMaintenanceState());
- sch1.setPassiveState(PassiveState.PASSIVE);
- Assert.assertEquals(PassiveState.PASSIVE, sch1.getPassiveState());
+ sch1.setMaintenanceState(MaintenanceState.ON);
+ Assert.assertEquals(MaintenanceState.ON, sch1.getMaintenanceState());
entity = dao.findByPK(pk);
- Assert.assertEquals(PassiveState.PASSIVE, entity.getPassiveState());
+ Assert.assertEquals(MaintenanceState.ON, entity.getMaintenanceState());
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/test/python/TestUpgradeScript_HDP2.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestUpgradeScript_HDP2.py b/ambari-server/src/test/python/TestUpgradeScript_HDP2.py
index 262ccb0..dcad96c 100644
--- a/ambari-server/src/test/python/TestUpgradeScript_HDP2.py
+++ b/ambari-server/src/test/python/TestUpgradeScript_HDP2.py
@@ -183,11 +183,11 @@ class TestUpgradeHDP2Script(TestCase):
"MAPREDUCE_CLIENT": ["c6401"]}
UpgradeHelper_HDP2.main()
expected_curl_calls = [
- call(False, "-u", "admin:admin", '-H', 'X-Requested-By: ambari', "-X", "PUT", "-d", """{"HostRoles": {"state": "MAINTENANCE"}}""",
+ call(False, "-u", "admin:admin", '-H', 'X-Requested-By: ambari', "-X", "PUT", "-d", """{"HostRoles": {"state": "DISABLED"}}""",
"http://localhost:8080/api/v1/clusters/c1/hosts/c6401/host_components/TASKTRACKER"),
- call(False, "-u", "admin:admin", '-H', 'X-Requested-By: ambari', "-X", "PUT", "-d", """{"HostRoles": {"state": "MAINTENANCE"}}""",
+ call(False, "-u", "admin:admin", '-H', 'X-Requested-By: ambari', "-X", "PUT", "-d", """{"HostRoles": {"state": "DISABLED"}}""",
"http://localhost:8080/api/v1/clusters/c1/hosts/c6402/host_components/TASKTRACKER"),
- call(False, "-u", "admin:admin", '-H', 'X-Requested-By: ambari', "-X", "PUT", "-d", """{"HostRoles": {"state": "MAINTENANCE"}}""",
+ call(False, "-u", "admin:admin", '-H', 'X-Requested-By: ambari', "-X", "PUT", "-d", """{"HostRoles": {"state": "DISABLED"}}""",
"http://localhost:8080/api/v1/clusters/c1/hosts/c6401/host_components/JOBTRACKER"),
call(False, "-u", "admin:admin", '-H', 'X-Requested-By: ambari', "-X", "DELETE",
"http://localhost:8080/api/v1/clusters/c1/services/MAPREDUCE")]
[2/3] AMBARI-4752. Rename MAINTENANCE and PassiveState (ncole)
Posted by nc...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostDisableEvent.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostDisableEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostDisableEvent.java
new file mode 100644
index 0000000..fa61940
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostDisableEvent.java
@@ -0,0 +1,29 @@
+/*
+ * 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.svccomphost;
+
+import org.apache.ambari.server.state.ServiceComponentHostEvent;
+import org.apache.ambari.server.state.ServiceComponentHostEventType;
+
+public class ServiceComponentHostDisableEvent extends ServiceComponentHostEvent {
+ public ServiceComponentHostDisableEvent(String serviceComponentName, String hostName, long opTimestamp) {
+ super(ServiceComponentHostEventType.HOST_SVCCOMP_DISABLE,
+ serviceComponentName, hostName, opTimestamp);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
index c041843..2e1480c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
@@ -45,7 +45,7 @@ import org.apache.ambari.server.state.Host;
import org.apache.ambari.server.state.HostComponentAdminState;
import org.apache.ambari.server.state.HostConfig;
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.ServiceComponent;
import org.apache.ambari.server.state.ServiceComponentHost;
import org.apache.ambari.server.state.ServiceComponentHostEvent;
@@ -329,21 +329,21 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
new ServiceComponentHostOpStartedTransition())
.addTransition(State.INSTALLED,
- State.MAINTENANCE,
- ServiceComponentHostEventType.HOST_SVCCOMP_MAINTENANCE,
+ State.DISABLED,
+ ServiceComponentHostEventType.HOST_SVCCOMP_DISABLE,
new ServiceComponentHostOpCompletedTransition())
- .addTransition(State.MAINTENANCE,
- State.MAINTENANCE,
- ServiceComponentHostEventType.HOST_SVCCOMP_MAINTENANCE,
+ .addTransition(State.DISABLED,
+ State.DISABLED,
+ ServiceComponentHostEventType.HOST_SVCCOMP_DISABLE,
new ServiceComponentHostOpCompletedTransition())
- .addTransition(State.MAINTENANCE,
+ .addTransition(State.DISABLED,
State.INSTALLED,
ServiceComponentHostEventType.HOST_SVCCOMP_RESTORE,
new ServiceComponentHostOpCompletedTransition())
.addTransition(State.UNKNOWN,
- State.MAINTENANCE,
- ServiceComponentHostEventType.HOST_SVCCOMP_MAINTENANCE,
+ State.DISABLED,
+ ServiceComponentHostEventType.HOST_SVCCOMP_DISABLE,
new ServiceComponentHostOpCompletedTransition())
.installTopology();
@@ -1383,12 +1383,12 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
}
@Override
- public void setPassiveState(PassiveState state) {
+ public void setMaintenanceState(MaintenanceState state) {
clusterGlobalLock.readLock().lock();
try {
writeLock.lock();
try {
- desiredStateEntity.setPassiveState(state);
+ desiredStateEntity.setMaintenanceState(state);
saveIfPersisted();
} finally {
writeLock.unlock();
@@ -1399,12 +1399,12 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
}
@Override
- public PassiveState getPassiveState() {
+ public MaintenanceState getMaintenanceState() {
clusterGlobalLock.readLock().lock();
try {
readLock.lock();
try {
- return desiredStateEntity.getPassiveState();
+ return desiredStateEntity.getMaintenanceState();
} finally {
readLock.unlock();
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostMaintenanceEvent.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostMaintenanceEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostMaintenanceEvent.java
deleted file mode 100644
index f503593..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostMaintenanceEvent.java
+++ /dev/null
@@ -1,29 +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.svccomphost;
-
-import org.apache.ambari.server.state.ServiceComponentHostEvent;
-import org.apache.ambari.server.state.ServiceComponentHostEventType;
-
-public class ServiceComponentHostMaintenanceEvent extends ServiceComponentHostEvent {
- public ServiceComponentHostMaintenanceEvent(String serviceComponentName, String hostName, long opTimestamp) {
- super(ServiceComponentHostEventType.HOST_SVCCOMP_MAINTENANCE,
- serviceComponentName, hostName, opTimestamp);
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog150.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog150.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog150.java
index 86bbef3..f104259 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog150.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog150.java
@@ -1,41 +1,38 @@
package org.apache.ambari.server.upgrade;
-import com.google.inject.Inject;
-import com.google.inject.Injector;
+import java.io.File;
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.TypedQuery;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Expression;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+
import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.actionmanager.HostRoleStatus;
import org.apache.ambari.server.configuration.Configuration;
import org.apache.ambari.server.orm.DBAccessor.DBColumnInfo;
import org.apache.ambari.server.orm.dao.ClusterDAO;
import org.apache.ambari.server.orm.dao.ClusterStateDAO;
-import org.apache.ambari.server.orm.dao.HostComponentDesiredStateDAO;
import org.apache.ambari.server.orm.dao.HostComponentStateDAO;
import org.apache.ambari.server.orm.dao.HostRoleCommandDAO;
-import org.apache.ambari.server.orm.dao.ServiceComponentDesiredStateDAO;
-import org.apache.ambari.server.orm.dao.ServiceDesiredStateDAO;
import org.apache.ambari.server.orm.entities.ClusterEntity;
import org.apache.ambari.server.orm.entities.ClusterStateEntity;
-import org.apache.ambari.server.orm.entities.HostComponentDesiredStateEntity;
import org.apache.ambari.server.orm.entities.HostComponentStateEntity;
import org.apache.ambari.server.orm.entities.HostRoleCommandEntity;
-import org.apache.ambari.server.orm.entities.ServiceComponentDesiredStateEntity;
-import org.apache.ambari.server.orm.entities.ServiceDesiredStateEntity;
import org.apache.ambari.server.state.State;
import org.eclipse.persistence.jpa.JpaEntityManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.persistence.EntityManager;
-import javax.persistence.TypedQuery;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Expression;
-import javax.persistence.criteria.Predicate;
-import javax.persistence.criteria.Root;
-import java.io.File;
-import java.io.IOException;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
+
+import com.google.inject.Inject;
+import com.google.inject.Injector;
public class UpgradeCatalog150 extends AbstractUpgradeCatalog {
private static final Logger LOG = LoggerFactory.getLogger(UpgradeCatalog150.class);
@@ -208,9 +205,9 @@ public class UpgradeCatalog150 extends AbstractUpgradeCatalog {
// ========================================================================
// Add columns
- dbAccessor.addColumn("hostcomponentdesiredstate", new DBColumnInfo("passive_state", String.class, 32, "ACTIVE", false));
- dbAccessor.addColumn("servicedesiredstate", new DBColumnInfo("passive_state", String.class, 32, "ACTIVE", false));
- dbAccessor.addColumn("hoststate", new DBColumnInfo("passive_state", String.class, 512, null, true));
+ dbAccessor.addColumn("hostcomponentdesiredstate", new DBColumnInfo("maintenance_state", String.class, 32, "OFF", false));
+ dbAccessor.addColumn("servicedesiredstate", new DBColumnInfo("maintenance_state", String.class, 32, "OFF", false));
+ dbAccessor.addColumn("hoststate", new DBColumnInfo("maintenance_state", String.class, 512, null, true));
dbAccessor.addColumn("hostcomponentdesiredstate", new DBColumnInfo("admin_state", String.class, 32, null, true));
dbAccessor.addColumn("hosts", new DBColumnInfo("ph_cpu_count", Integer.class, 32, null, true));
dbAccessor.addColumn("clusterstate", new DBColumnInfo("current_stack_version", String.class, 255, null, false));
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/python/UpgradeHelper_HDP2.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/UpgradeHelper_HDP2.py b/ambari-server/src/main/python/UpgradeHelper_HDP2.py
index 3253b98..13d5c31 100644
--- a/ambari-server/src/main/python/UpgradeHelper_HDP2.py
+++ b/ambari-server/src/main/python/UpgradeHelper_HDP2.py
@@ -706,7 +706,7 @@ def delete_mr(options):
SERVICE_URL_FORMAT = URL_FORMAT + '/services/MAPREDUCE'
COMPONENT_URL_FORMAT = URL_FORMAT + '/hosts/{2}/host_components/{3}'
NON_CLIENTS = ["JOBTRACKER", "TASKTRACKER"]
- PUT_IN_MAINTENANCE = """{"HostRoles": {"state": "MAINTENANCE"}}"""
+ PUT_IN_DISABLED = """{"HostRoles": {"state": "DISABLED"}}"""
hostmapping = read_mapping()
for key, value in hostmapping.items():
@@ -716,7 +716,7 @@ def delete_mr(options):
AUTH_FORMAT.format(options.user, options.password),
'-H', 'X-Requested-By: ambari',
'-X', 'PUT', '-d',
- PUT_IN_MAINTENANCE,
+ PUT_IN_DISABLED,
COMPONENT_URL_FORMAT.format(options.hostname, options.clustername, host, key))
retcode, errdata = validate_response(response, False)
if not retcode == 0:
@@ -1153,4 +1153,4 @@ if __name__ == "__main__":
main()
except (KeyboardInterrupt, EOFError):
print("\nAborting ... Keyboard Interrupt.")
- sys.exit(1)
\ No newline at end of file
+ sys.exit(1)
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
index ae6888a..2e97b08 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
@@ -30,12 +30,12 @@ CREATE TABLE clusters (cluster_id BIGINT NOT NULL, cluster_info VARCHAR(255) NOT
CREATE TABLE clusterconfig (version_tag VARCHAR(255) NOT NULL, type_name VARCHAR(255) NOT NULL, cluster_id BIGINT NOT NULL, config_data LONGTEXT NOT NULL, create_timestamp BIGINT NOT NULL, PRIMARY KEY (version_tag, type_name, cluster_id));
CREATE TABLE clusterservices (service_name VARCHAR(255) NOT NULL, cluster_id BIGINT NOT NULL, service_enabled INTEGER NOT NULL, PRIMARY KEY (service_name, cluster_id));
CREATE TABLE clusterstate (cluster_id BIGINT NOT NULL, current_cluster_state VARCHAR(255) NOT NULL, current_stack_version VARCHAR(255) NOT NULL, PRIMARY KEY (cluster_id));
-CREATE TABLE hostcomponentdesiredstate (cluster_id BIGINT NOT NULL, component_name VARCHAR(255) NOT NULL, desired_stack_version VARCHAR(255) NOT NULL, desired_state VARCHAR(255) NOT NULL, host_name VARCHAR(255) NOT NULL, service_name VARCHAR(255) NOT NULL, admin_state VARCHAR(32), passive_state VARCHAR(32) NOT NULL DEFAULT 'ACTIVE', PRIMARY KEY (cluster_id, component_name, host_name, service_name));
+CREATE TABLE hostcomponentdesiredstate (cluster_id BIGINT NOT NULL, component_name VARCHAR(255) NOT NULL, desired_stack_version VARCHAR(255) NOT NULL, desired_state VARCHAR(255) NOT NULL, host_name VARCHAR(255) NOT NULL, service_name VARCHAR(255) NOT NULL, admin_state VARCHAR(32), maintenance_state VARCHAR(32) NOT NULL DEFAULT 'ACTIVE', PRIMARY KEY (cluster_id, component_name, host_name, service_name));
CREATE TABLE hostcomponentstate (cluster_id BIGINT NOT NULL, component_name VARCHAR(255) NOT NULL, current_stack_version VARCHAR(255) NOT NULL, current_state VARCHAR(255) NOT NULL, host_name VARCHAR(255) NOT NULL, service_name VARCHAR(255) NOT NULL, PRIMARY KEY (cluster_id, component_name, host_name, service_name));
CREATE TABLE hosts (host_name VARCHAR(255) NOT NULL, cpu_count INTEGER NOT NULL, cpu_info VARCHAR(255) NOT NULL, discovery_status VARCHAR(2000) NOT NULL, host_attributes LONGTEXT NOT NULL, ipv4 VARCHAR(255), ipv6 VARCHAR(255), last_registration_time BIGINT NOT NULL, os_arch VARCHAR(255) NOT NULL, os_info VARCHAR(1000) NOT NULL, os_type VARCHAR(255) NOT NULL, ph_cpu_count INTEGER, public_host_name VARCHAR(255), rack_info VARCHAR(255) NOT NULL, total_mem BIGINT NOT NULL, PRIMARY KEY (host_name));
-CREATE TABLE hoststate (agent_version VARCHAR(255) NOT NULL, available_mem BIGINT NOT NULL, current_state VARCHAR(255) NOT NULL, health_status VARCHAR(255), host_name VARCHAR(255) NOT NULL, time_in_state BIGINT NOT NULL, passive_state VARCHAR(512), PRIMARY KEY (host_name));
+CREATE TABLE hoststate (agent_version VARCHAR(255) NOT NULL, available_mem BIGINT NOT NULL, current_state VARCHAR(255) NOT NULL, health_status VARCHAR(255), host_name VARCHAR(255) NOT NULL, time_in_state BIGINT NOT NULL, maintenance_state VARCHAR(512), PRIMARY KEY (host_name));
CREATE TABLE servicecomponentdesiredstate (component_name VARCHAR(255) NOT NULL, cluster_id BIGINT NOT NULL, desired_stack_version VARCHAR(255) NOT NULL, desired_state VARCHAR(255) NOT NULL, service_name VARCHAR(255) NOT NULL, PRIMARY KEY (component_name, cluster_id, service_name));
-CREATE TABLE servicedesiredstate (cluster_id BIGINT NOT NULL, desired_host_role_mapping INTEGER NOT NULL, desired_stack_version VARCHAR(255) NOT NULL, desired_state VARCHAR(255) NOT NULL, service_name VARCHAR(255) NOT NULL, passive_state VARCHAR(32) NOT NULL DEFAULT 'ACTIVE', PRIMARY KEY (cluster_id, service_name));
+CREATE TABLE servicedesiredstate (cluster_id BIGINT NOT NULL, desired_host_role_mapping INTEGER NOT NULL, desired_stack_version VARCHAR(255) NOT NULL, desired_state VARCHAR(255) NOT NULL, service_name VARCHAR(255) NOT NULL, maintenance_state VARCHAR(32) NOT NULL DEFAULT 'ACTIVE', PRIMARY KEY (cluster_id, service_name));
CREATE TABLE roles (role_name VARCHAR(255) NOT NULL, PRIMARY KEY (role_name));
CREATE TABLE users (user_id INTEGER, create_time TIMESTAMP DEFAULT NOW(), ldap_user INTEGER NOT NULL DEFAULT 0, user_name VARCHAR(255) NOT NULL, user_password VARCHAR(255), PRIMARY KEY (user_id));
CREATE TABLE execution_command (task_id BIGINT NOT NULL, command LONGBLOB, PRIMARY KEY (task_id));
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
index 1bf4305..e0e6927 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
@@ -20,12 +20,12 @@ CREATE TABLE clusters (cluster_id NUMBER(19) NOT NULL, cluster_info VARCHAR2(255
CREATE TABLE clusterconfig (version_tag VARCHAR2(255) NOT NULL, type_name VARCHAR2(255) NOT NULL, cluster_id NUMBER(19) NOT NULL, config_data CLOB NOT NULL, create_timestamp NUMBER(19) NOT NULL, PRIMARY KEY (version_tag, type_name, cluster_id));
CREATE TABLE clusterservices (service_name VARCHAR2(255) NOT NULL, cluster_id NUMBER(19) NOT NULL, service_enabled NUMBER(10) NOT NULL, PRIMARY KEY (service_name, cluster_id));
CREATE TABLE clusterstate (cluster_id NUMBER(19) NOT NULL, current_cluster_state VARCHAR2(255) NULL, current_stack_version VARCHAR2(255) NULL, PRIMARY KEY (cluster_id));
-CREATE TABLE hostcomponentdesiredstate (cluster_id NUMBER(19) NOT NULL, component_name VARCHAR2(255) NOT NULL, desired_stack_version VARCHAR2(255) NULL, desired_state VARCHAR2(255) NOT NULL, host_name VARCHAR2(255) NOT NULL, service_name VARCHAR2(255) NOT NULL, admin_state VARCHAR2(32) NULL, passive_state VARCHAR2(32) NOT NULL, PRIMARY KEY (cluster_id, component_name, host_name, service_name));
+CREATE TABLE hostcomponentdesiredstate (cluster_id NUMBER(19) NOT NULL, component_name VARCHAR2(255) NOT NULL, desired_stack_version VARCHAR2(255) NULL, desired_state VARCHAR2(255) NOT NULL, host_name VARCHAR2(255) NOT NULL, service_name VARCHAR2(255) NOT NULL, admin_state VARCHAR2(32) NULL, maintenance_state VARCHAR2(32) NOT NULL, PRIMARY KEY (cluster_id, component_name, host_name, service_name));
CREATE TABLE hostcomponentstate (cluster_id NUMBER(19) NOT NULL, component_name VARCHAR2(255) NOT NULL, current_stack_version VARCHAR2(255) NOT NULL, current_state VARCHAR2(255) NOT NULL, host_name VARCHAR2(255) NOT NULL, service_name VARCHAR2(255) NOT NULL, PRIMARY KEY (cluster_id, component_name, host_name, service_name));
CREATE TABLE hosts (host_name VARCHAR2(255) NOT NULL, cpu_count INTEGER NOT NULL, cpu_info VARCHAR2(255) NULL, discovery_status VARCHAR2(2000) NULL, host_attributes CLOB NULL, ipv4 VARCHAR2(255) NULL, ipv6 VARCHAR2(255) NULL, last_registration_time INTEGER NOT NULL, os_arch VARCHAR2(255) NULL, os_info VARCHAR2(1000) NULL, os_type VARCHAR2(255) NULL, ph_cpu_count INTEGER NOT NULL, public_host_name VARCHAR2(255) NULL, rack_info VARCHAR2(255) NOT NULL, total_mem INTEGER NOT NULL, PRIMARY KEY (host_name));
-CREATE TABLE hoststate (agent_version VARCHAR2(255) NULL, available_mem NUMBER(19) NOT NULL, current_state VARCHAR2(255) NOT NULL, health_status VARCHAR2(255) NULL, host_name VARCHAR2(255) NOT NULL, time_in_state NUMBER(19) NOT NULL, passive_state VARCHAR2(512), PRIMARY KEY (host_name));
+CREATE TABLE hoststate (agent_version VARCHAR2(255) NULL, available_mem NUMBER(19) NOT NULL, current_state VARCHAR2(255) NOT NULL, health_status VARCHAR2(255) NULL, host_name VARCHAR2(255) NOT NULL, time_in_state NUMBER(19) NOT NULL, maintenance_state VARCHAR2(512), PRIMARY KEY (host_name));
CREATE TABLE servicecomponentdesiredstate (component_name VARCHAR2(255) NOT NULL, cluster_id NUMBER(19) NOT NULL, desired_stack_version VARCHAR2(255) NULL, desired_state VARCHAR2(255) NOT NULL, service_name VARCHAR2(255) NOT NULL, PRIMARY KEY (component_name, cluster_id, service_name));
-CREATE TABLE servicedesiredstate (cluster_id NUMBER(19) NOT NULL, desired_host_role_mapping NUMBER(10) NOT NULL, desired_stack_version VARCHAR2(255) NULL, desired_state VARCHAR2(255) NOT NULL, service_name VARCHAR2(255) NOT NULL, passive_state VARCHAR2(32) NOT NULL, PRIMARY KEY (cluster_id, service_name));
+CREATE TABLE servicedesiredstate (cluster_id NUMBER(19) NOT NULL, desired_host_role_mapping NUMBER(10) NOT NULL, desired_stack_version VARCHAR2(255) NULL, desired_state VARCHAR2(255) NOT NULL, service_name VARCHAR2(255) NOT NULL, maintenance_state VARCHAR2(32) NOT NULL, PRIMARY KEY (cluster_id, service_name));
CREATE TABLE roles (role_name VARCHAR2(255) NOT NULL, PRIMARY KEY (role_name));
CREATE TABLE users (user_id NUMBER(10) NOT NULL, create_time TIMESTAMP NULL, ldap_user NUMBER(10) DEFAULT 0, user_name VARCHAR2(255) NULL, user_password VARCHAR2(255) NULL, PRIMARY KEY (user_id));
CREATE TABLE execution_command (task_id NUMBER(19) NOT NULL, command BLOB NULL, PRIMARY KEY (task_id));
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
index 22e9630..60462e2 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
@@ -43,7 +43,7 @@ GRANT ALL PRIVILEGES ON TABLE ambari.clusterservices TO :username;
CREATE TABLE ambari.clusterstate (cluster_id BIGINT NOT NULL, current_cluster_state VARCHAR(255) NOT NULL, current_stack_version VARCHAR(255) NOT NULL, PRIMARY KEY (cluster_id));
GRANT ALL PRIVILEGES ON TABLE ambari.clusterstate TO :username;
-CREATE TABLE ambari.hostcomponentdesiredstate (cluster_id BIGINT NOT NULL, component_name VARCHAR(255) NOT NULL, desired_stack_version VARCHAR(255) NOT NULL, desired_state VARCHAR(255) NOT NULL, host_name VARCHAR(255) NOT NULL, service_name VARCHAR(255) NOT NULL, admin_state VARCHAR(32), passive_state VARCHAR(32) NOT NULL, PRIMARY KEY (cluster_id, component_name, host_name, service_name));
+CREATE TABLE ambari.hostcomponentdesiredstate (cluster_id BIGINT NOT NULL, component_name VARCHAR(255) NOT NULL, desired_stack_version VARCHAR(255) NOT NULL, desired_state VARCHAR(255) NOT NULL, host_name VARCHAR(255) NOT NULL, service_name VARCHAR(255) NOT NULL, admin_state VARCHAR(32), maintenance_state VARCHAR(32) NOT NULL, PRIMARY KEY (cluster_id, component_name, host_name, service_name));
GRANT ALL PRIVILEGES ON TABLE ambari.hostcomponentdesiredstate TO :username;
CREATE TABLE ambari.hostcomponentstate (cluster_id BIGINT NOT NULL, component_name VARCHAR(255) NOT NULL, current_stack_version VARCHAR(255) NOT NULL, current_state VARCHAR(255) NOT NULL, host_name VARCHAR(255) NOT NULL, service_name VARCHAR(255) NOT NULL, PRIMARY KEY (cluster_id, component_name, host_name, service_name));
@@ -52,13 +52,13 @@ GRANT ALL PRIVILEGES ON TABLE ambari.hostcomponentstate TO :username;
CREATE TABLE ambari.hosts (host_name VARCHAR(255) NOT NULL, cpu_count INTEGER NOT NULL, ph_cpu_count INTEGER, cpu_info VARCHAR(255) NOT NULL, discovery_status VARCHAR(2000) NOT NULL, host_attributes VARCHAR(20000) NOT NULL, ipv4 VARCHAR(255), ipv6 VARCHAR(255), public_host_name VARCHAR(255), last_registration_time BIGINT NOT NULL, os_arch VARCHAR(255) NOT NULL, os_info VARCHAR(1000) NOT NULL, os_type VARCHAR(255) NOT NULL, rack_info VARCHAR(255) NOT NULL, total_mem BIGINT NOT NULL, PRIMARY KEY (host_name));
GRANT ALL PRIVILEGES ON TABLE ambari.hosts TO :username;
-CREATE TABLE ambari.hoststate (agent_version VARCHAR(255) NOT NULL, available_mem BIGINT NOT NULL, current_state VARCHAR(255) NOT NULL, health_status VARCHAR(255), host_name VARCHAR(255) NOT NULL, time_in_state BIGINT NOT NULL, passive_state VARCHAR(512), PRIMARY KEY (host_name));
+CREATE TABLE ambari.hoststate (agent_version VARCHAR(255) NOT NULL, available_mem BIGINT NOT NULL, current_state VARCHAR(255) NOT NULL, health_status VARCHAR(255), host_name VARCHAR(255) NOT NULL, time_in_state BIGINT NOT NULL, maintenance_state VARCHAR(512), PRIMARY KEY (host_name));
GRANT ALL PRIVILEGES ON TABLE ambari.hoststate TO :username;
CREATE TABLE ambari.servicecomponentdesiredstate (component_name VARCHAR(255) NOT NULL, cluster_id BIGINT NOT NULL, desired_stack_version VARCHAR(255) NOT NULL, desired_state VARCHAR(255) NOT NULL, service_name VARCHAR(255) NOT NULL, PRIMARY KEY (component_name, cluster_id, service_name));
GRANT ALL PRIVILEGES ON TABLE ambari.servicecomponentdesiredstate TO :username;
-CREATE TABLE ambari.servicedesiredstate (cluster_id BIGINT NOT NULL, desired_host_role_mapping INTEGER NOT NULL, desired_stack_version VARCHAR(255) NOT NULL, desired_state VARCHAR(255) NOT NULL, service_name VARCHAR(255) NOT NULL, passive_state VARCHAR(32) NOT NULL, PRIMARY KEY (cluster_id, service_name));
+CREATE TABLE ambari.servicedesiredstate (cluster_id BIGINT NOT NULL, desired_host_role_mapping INTEGER NOT NULL, desired_stack_version VARCHAR(255) NOT NULL, desired_state VARCHAR(255) NOT NULL, service_name VARCHAR(255) NOT NULL, maintenance_state VARCHAR(32) NOT NULL, PRIMARY KEY (cluster_id, service_name));
GRANT ALL PRIVILEGES ON TABLE ambari.servicedesiredstate TO :username;
CREATE TABLE ambari.roles (role_name VARCHAR(255) NOT NULL, PRIMARY KEY (role_name));
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/resources/Ambari-DDL-Postgres-REMOTE-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-REMOTE-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-REMOTE-CREATE.sql
index 3cbfe3b..2481b5b 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-REMOTE-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-REMOTE-CREATE.sql
@@ -24,12 +24,12 @@ CREATE TABLE ambari.clusterconfig (version_tag VARCHAR(255) NOT NULL, type_name
CREATE TABLE ambari.clusterconfigmapping (cluster_id bigint NOT NULL, type_name VARCHAR(255) NOT NULL, version_tag VARCHAR(255) NOT NULL, create_timestamp BIGINT NOT NULL, selected INTEGER NOT NULL DEFAULT 0, user_name VARCHAR(255) NOT NULL DEFAULT '_db', PRIMARY KEY (cluster_id, type_name, create_timestamp));
CREATE TABLE ambari.clusterservices (service_name VARCHAR(255) NOT NULL, cluster_id BIGINT NOT NULL, service_enabled INTEGER NOT NULL, PRIMARY KEY (service_name, cluster_id));
CREATE TABLE ambari.clusterstate (cluster_id BIGINT NOT NULL, current_cluster_state VARCHAR(255) NOT NULL, current_stack_version VARCHAR(255) NOT NULL, PRIMARY KEY (cluster_id));
-CREATE TABLE ambari.hostcomponentdesiredstate (cluster_id BIGINT NOT NULL, component_name VARCHAR(255) NOT NULL, desired_stack_version VARCHAR(255) NOT NULL, desired_state VARCHAR(255) NOT NULL, host_name VARCHAR(255) NOT NULL, service_name VARCHAR(255) NOT NULL, passive_state VARCHAR(32) NOT NULL, PRIMARY KEY (cluster_id, component_name, host_name, service_name));
+CREATE TABLE ambari.hostcomponentdesiredstate (cluster_id BIGINT NOT NULL, component_name VARCHAR(255) NOT NULL, desired_stack_version VARCHAR(255) NOT NULL, desired_state VARCHAR(255) NOT NULL, host_name VARCHAR(255) NOT NULL, service_name VARCHAR(255) NOT NULL, maintenance_state VARCHAR(32) NOT NULL, PRIMARY KEY (cluster_id, component_name, host_name, service_name));
CREATE TABLE ambari.hostcomponentstate (cluster_id BIGINT NOT NULL, component_name VARCHAR(255) NOT NULL, current_stack_version VARCHAR(255) NOT NULL, current_state VARCHAR(255) NOT NULL, host_name VARCHAR(255) NOT NULL, service_name VARCHAR(255) NOT NULL, PRIMARY KEY (cluster_id, component_name, host_name, service_name));
CREATE TABLE ambari.hosts (host_name VARCHAR(255) NOT NULL, cpu_count INTEGER NOT NULL, ph_cpu_count INTEGER, cpu_info VARCHAR(255) NOT NULL, discovery_status VARCHAR(2000) NOT NULL, host_attributes VARCHAR(20000) NOT NULL, ipv4 VARCHAR(255), ipv6 VARCHAR(255), public_host_name VARCHAR(255), last_registration_time BIGINT NOT NULL, os_arch VARCHAR(255) NOT NULL, os_info VARCHAR(1000) NOT NULL, os_type VARCHAR(255) NOT NULL, rack_info VARCHAR(255) NOT NULL, total_mem BIGINT NOT NULL, PRIMARY KEY (host_name));
-CREATE TABLE ambari.hoststate (agent_version VARCHAR(255) NOT NULL, available_mem BIGINT NOT NULL, current_state VARCHAR(255) NOT NULL, health_status VARCHAR(255), host_name VARCHAR(255) NOT NULL, time_in_state BIGINT NOT NULL, passive_state VARCHAR(512) PRIMARY KEY (host_name));
+CREATE TABLE ambari.hoststate (agent_version VARCHAR(255) NOT NULL, available_mem BIGINT NOT NULL, current_state VARCHAR(255) NOT NULL, health_status VARCHAR(255), host_name VARCHAR(255) NOT NULL, time_in_state BIGINT NOT NULL, maintenance_state VARCHAR(512) PRIMARY KEY (host_name));
CREATE TABLE ambari.servicecomponentdesiredstate (component_name VARCHAR(255) NOT NULL, cluster_id BIGINT NOT NULL, desired_stack_version VARCHAR(255) NOT NULL, desired_state VARCHAR(255) NOT NULL, service_name VARCHAR(255) NOT NULL, PRIMARY KEY (component_name, cluster_id, service_name));
-CREATE TABLE ambari.servicedesiredstate (cluster_id BIGINT NOT NULL, desired_host_role_mapping INTEGER NOT NULL, desired_stack_version VARCHAR(255) NOT NULL, desired_state VARCHAR(255) NOT NULL, service_name VARCHAR(255) NOT NULL, passive_state VARCHAR(32) NOT NULL, PRIMARY KEY (cluster_id, service_name));
+CREATE TABLE ambari.servicedesiredstate (cluster_id BIGINT NOT NULL, desired_host_role_mapping INTEGER NOT NULL, desired_stack_version VARCHAR(255) NOT NULL, desired_state VARCHAR(255) NOT NULL, service_name VARCHAR(255) NOT NULL, maintenance_state VARCHAR(32) NOT NULL, PRIMARY KEY (cluster_id, service_name));
CREATE TABLE ambari.roles (role_name VARCHAR(255) NOT NULL, PRIMARY KEY (role_name));
CREATE TABLE ambari.users (user_id INTEGER, ldap_user INTEGER NOT NULL DEFAULT 0, user_name VARCHAR(255) NOT NULL, create_time TIMESTAMP DEFAULT NOW(), user_password VARCHAR(255), PRIMARY KEY (user_id), UNIQUE (ldap_user, user_name));
CREATE TABLE ambari.execution_command (command bytea, task_id BIGINT NOT NULL, PRIMARY KEY (task_id));
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/resources/properties.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/properties.json b/ambari-server/src/main/resources/properties.json
index 254edc1..270353b 100644
--- a/ambari-server/src/main/resources/properties.json
+++ b/ambari-server/src/main/resources/properties.json
@@ -11,7 +11,7 @@
"ServiceInfo/service_name",
"ServiceInfo/cluster_name",
"ServiceInfo/state",
- "ServiceInfo/passive_state",
+ "ServiceInfo/maintenance_state",
"Services/description",
"Services/display_name",
"Services/attributes",
@@ -38,7 +38,7 @@
"Hosts/host_health_report",
"Hosts/public_host_name",
"Hosts/host_state",
- "Hosts/passive_state",
+ "Hosts/maintenance_state",
"Hosts/desired_configs",
"_"
],
@@ -67,7 +67,7 @@
"HostRoles/nagios_alerts",
"HostRoles/stale_configs",
"HostRoles/desired_admin_state",
- "HostRoles/passive_state",
+ "HostRoles/maintenance_state",
"_"
],
"Configuration":[
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/main/resources/scripts/relocate_host_components.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/scripts/relocate_host_components.py b/ambari-server/src/main/resources/scripts/relocate_host_components.py
index f9b71a0..1b9ad1e 100644
--- a/ambari-server/src/main/resources/scripts/relocate_host_components.py
+++ b/ambari-server/src/main/resources/scripts/relocate_host_components.py
@@ -40,7 +40,7 @@ START_ON_RELOCATE = False
# Supported Actions
RELOCATE_ACTION = 'relocate'
-ALLOWED_ACTUAL_STATES_FOR_RELOCATE = [ 'INIT', 'UNKNOWN', 'MAINTENANCE', 'UNINSTALLED' ]
+ALLOWED_ACTUAL_STATES_FOR_RELOCATE = [ 'INIT', 'UNKNOWN', 'DISABLED', 'UNINSTALLED' ]
ALLOWED_HOST_STATUS_FOR_RELOCATE = [ 'HEALTHY' ]
STATUS_WAIT_TIMEOUT = 120 # seconds
STATUS_CHECK_INTERVAL = 10 # seconds
@@ -129,7 +129,7 @@ class AmbariResource:
# Put host component in Maintenance state
self.updateHostComponentStatus(self.old_hostname, self.componentName,
- "Maintenance", "MAINTENANCE")
+ "Disable", "DISABLED")
# Delete current host component
self.deleteHostComponent(self.old_hostname, self.componentName)
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
----------------------------------------------------------------------
diff --git 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
index 12aab4f..490df5e 100644
--- 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
@@ -71,7 +71,7 @@ import org.apache.ambari.server.state.Clusters;
import org.apache.ambari.server.state.Host;
import org.apache.ambari.server.state.HostHealthStatus;
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.ServiceComponentHost;
import org.apache.ambari.server.state.StackId;
@@ -1389,9 +1389,9 @@ public class TestHeartbeatHandler {
handler.handleHeartBeat(hb2);
assertEquals(HostHealthStatus.HealthStatus.ALERT.name(), hostObject.getStatus());
- // mark the installed DN as passive
+ // mark the installed DN as maintenance
hdfs.getServiceComponent(DATANODE).getServiceComponentHost(
- DummyHostname1).setPassiveState(PassiveState.PASSIVE);
+ DummyHostname1).setMaintenanceState(MaintenanceState.ON);
HeartBeat hb2a = new HeartBeat();
hb2a.setResponseId(2);
hb2a.setNodeStatus(new HostStatus(Status.HEALTHY, DummyHostStatus));
@@ -1414,7 +1414,7 @@ public class TestHeartbeatHandler {
assertEquals(HostHealthStatus.HealthStatus.HEALTHY.name(), hostObject.getStatus());
hdfs.getServiceComponent(DATANODE).getServiceComponentHost(
- DummyHostname1).setPassiveState(PassiveState.ACTIVE);
+ DummyHostname1).setMaintenanceState(MaintenanceState.OFF);
//Some masters are down
HeartBeat hb3 = new HeartBeat();
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java b/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java
index 260baf2..f5c24ea 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java
@@ -18,7 +18,6 @@
package org.apache.ambari.server.agent;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.eq;
@@ -48,8 +47,8 @@ import org.apache.ambari.server.state.ServiceComponentHost;
import org.apache.ambari.server.state.StackId;
import org.apache.ambari.server.state.State;
import org.apache.ambari.server.state.fsm.InvalidStateTransitionException;
+import org.apache.ambari.server.state.svccomphost.ServiceComponentHostDisableEvent;
import org.apache.ambari.server.state.svccomphost.ServiceComponentHostInstallEvent;
-import org.apache.ambari.server.state.svccomphost.ServiceComponentHostMaintenanceEvent;
import org.apache.ambari.server.state.svccomphost.ServiceComponentHostOpSucceededEvent;
import org.apache.ambari.server.state.svccomphost.ServiceComponentHostStartedEvent;
import org.junit.After;
@@ -441,8 +440,8 @@ public class TestHeartbeatMonitor {
sch.handleEvent(new ServiceComponentHostOpSucceededEvent(sch.getServiceComponentName(),
sch.getHostName(), System.currentTimeMillis()));
- // maintenance
- sch.handleEvent(new ServiceComponentHostMaintenanceEvent(sch.getServiceComponentName(),
+ // disabled
+ sch.handleEvent(new ServiceComponentHostDisableEvent(sch.getServiceComponentName(),
sch.getHostName(), System.currentTimeMillis()));
}
}
@@ -474,7 +473,7 @@ public class TestHeartbeatMonitor {
else if (sc.isClientComponent())
assertEquals(sch.getServiceComponentName(), State.INIT, sch.getState());
else if (sch.getServiceComponentName().equals("SECONDARY_NAMENODE"))
- assertEquals(sch.getServiceComponentName(), State.MAINTENANCE,
+ assertEquals(sch.getServiceComponentName(), State.DISABLED,
sch.getState());
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
index 272b510..c99bfa1 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
@@ -48,7 +48,7 @@ import org.apache.ambari.server.api.services.AmbariMetaInfo;
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.MaintenanceState;
import org.apache.ambari.server.state.Service;
import org.apache.ambari.server.state.ServiceComponent;
import org.apache.ambari.server.state.ServiceComponentHost;
@@ -281,8 +281,8 @@ public class AmbariManagementControllerImplTest {
ServiceComponentHost componentHost = createNiceMock(ServiceComponentHost.class);
ServiceComponentHostResponse response = createNiceMock(ServiceComponentHostResponse.class);
- PassiveStateHelper passiveHelper = createNiceMock(PassiveStateHelper.class);
- expect(passiveHelper.getEffectiveState(componentHost)).andReturn(PassiveState.ACTIVE).anyTimes();
+ MaintenanceStateHelper maintHelper = createNiceMock(MaintenanceStateHelper.class);
+ expect(maintHelper.getEffectiveState(componentHost)).andReturn(MaintenanceState.OFF).anyTimes();
// requests
ServiceComponentHostRequest request1 = new ServiceComponentHostRequest(
@@ -296,7 +296,7 @@ public class AmbariManagementControllerImplTest {
injector.injectMembers(capture(controllerCapture));
expect(injector.getInstance(Gson.class)).andReturn(null);
- expect(injector.getInstance(PassiveStateHelper.class)).andReturn(passiveHelper);
+ expect(injector.getInstance(MaintenanceStateHelper.class)).andReturn(maintHelper);
// getHostComponent
expect(clusters.getCluster("cluster1")).andReturn(cluster);
@@ -314,7 +314,7 @@ public class AmbariManagementControllerImplTest {
expect(componentHost.convertToResponse()).andReturn(response);
// replay mocks
- replay(passiveHelper, injector, clusters, cluster, host, response, stack,
+ replay(maintHelper, injector, clusters, cluster, host, response, stack,
metaInfo, service, component, componentHost);
//test
@@ -420,9 +420,9 @@ public class AmbariManagementControllerImplTest {
ServiceComponentHost componentHost2 = createNiceMock(ServiceComponentHost.class);
ServiceComponentHostResponse response1 = createNiceMock(ServiceComponentHostResponse.class);
ServiceComponentHostResponse response2 = createNiceMock(ServiceComponentHostResponse.class);
- PassiveStateHelper passiveStateHelper = createNiceMock(PassiveStateHelper.class);
- expect(passiveStateHelper.getEffectiveState(capture(new Capture<ServiceComponentHost>())
- )).andReturn(PassiveState.ACTIVE).anyTimes();
+ MaintenanceStateHelper stateHelper = createNiceMock(MaintenanceStateHelper.class);
+ expect(stateHelper.getEffectiveState(capture(new Capture<ServiceComponentHost>())
+ )).andReturn(MaintenanceState.OFF).anyTimes();
// requests
ServiceComponentHostRequest request1 = new ServiceComponentHostRequest(
@@ -444,7 +444,7 @@ public class AmbariManagementControllerImplTest {
// constructor init
injector.injectMembers(capture(controllerCapture));
expect(injector.getInstance(Gson.class)).andReturn(null);
- expect(injector.getInstance(PassiveStateHelper.class)).andReturn(passiveStateHelper).anyTimes();
+ expect(injector.getInstance(MaintenanceStateHelper.class)).andReturn(stateHelper).anyTimes();
// getHostComponent
@@ -477,7 +477,7 @@ public class AmbariManagementControllerImplTest {
expect(componentHost2.convertToResponse()).andReturn(response2);
// replay mocks
- replay(passiveStateHelper, injector, clusters, cluster, host, stack,
+ replay(stateHelper, injector, clusters, cluster, host, stack,
metaInfo, service, component, component2, component3, componentHost1,
componentHost2, response1, response2);
@@ -521,9 +521,9 @@ public class AmbariManagementControllerImplTest {
ServiceComponentHost componentHost2 = createNiceMock(ServiceComponentHost.class);
ServiceComponentHostResponse response1 = createNiceMock(ServiceComponentHostResponse.class);
ServiceComponentHostResponse response2 = createNiceMock(ServiceComponentHostResponse.class);
- PassiveStateHelper passiveHelper = createNiceMock(PassiveStateHelper.class);
- expect(passiveHelper.getEffectiveState(capture(
- new Capture<ServiceComponentHost>()))).andReturn(PassiveState.ACTIVE).anyTimes();
+ MaintenanceStateHelper maintHelper = createNiceMock(MaintenanceStateHelper.class);
+ expect(maintHelper.getEffectiveState(capture(
+ new Capture<ServiceComponentHost>()))).andReturn(MaintenanceState.OFF).anyTimes();
// requests
ServiceComponentHostRequest request1 = new ServiceComponentHostRequest(
@@ -545,7 +545,7 @@ public class AmbariManagementControllerImplTest {
// constructor init
injector.injectMembers(capture(controllerCapture));
expect(injector.getInstance(Gson.class)).andReturn(null);
- expect(injector.getInstance(PassiveStateHelper.class)).andReturn(passiveHelper).anyTimes();
+ expect(injector.getInstance(MaintenanceStateHelper.class)).andReturn(maintHelper).anyTimes();
// getHostComponent
expect(clusters.getCluster("cluster1")).andReturn(cluster).times(3);
@@ -575,7 +575,7 @@ public class AmbariManagementControllerImplTest {
expect(componentHost2.convertToResponse()).andReturn(response2);
// replay mocks
- replay(passiveHelper, injector, clusters, cluster, host, stack, metaInfo,
+ replay(maintHelper, injector, clusters, cluster, host, stack, metaInfo,
service, component, component2, component3, componentHost1,
componentHost2, response1, response2);
@@ -621,9 +621,9 @@ public class AmbariManagementControllerImplTest {
ServiceComponentHostResponse response1 = createNiceMock(ServiceComponentHostResponse.class);
ServiceComponentHostResponse response2 = createNiceMock(ServiceComponentHostResponse.class);
- PassiveStateHelper passiveHelper = createNiceMock(PassiveStateHelper.class);
- expect(passiveHelper.getEffectiveState(capture(
- new Capture<ServiceComponentHost>()))).andReturn(PassiveState.ACTIVE).anyTimes();
+ MaintenanceStateHelper maintHelper = createNiceMock(MaintenanceStateHelper.class);
+ expect(maintHelper.getEffectiveState(capture(
+ new Capture<ServiceComponentHost>()))).andReturn(MaintenanceState.OFF).anyTimes();
// requests
ServiceComponentHostRequest request1 = new ServiceComponentHostRequest(
@@ -645,7 +645,7 @@ public class AmbariManagementControllerImplTest {
// constructor init
injector.injectMembers(capture(controllerCapture));
expect(injector.getInstance(Gson.class)).andReturn(null);
- expect(injector.getInstance(PassiveStateHelper.class)).andReturn(passiveHelper).anyTimes();
+ expect(injector.getInstance(MaintenanceStateHelper.class)).andReturn(maintHelper).anyTimes();
// getHostComponent
expect(clusters.getCluster("cluster1")).andReturn(cluster).times(3);
@@ -676,7 +676,7 @@ public class AmbariManagementControllerImplTest {
expect(componentHost2.convertToResponse()).andReturn(response2);
// replay mocks
- replay(passiveHelper, injector, clusters, cluster, host, stack, metaInfo,
+ replay(maintHelper, injector, clusters, cluster, host, stack, metaInfo,
service, service2, component, component2, component3, componentHost1,
componentHost2, response1, response2);
@@ -721,9 +721,9 @@ public class AmbariManagementControllerImplTest {
ServiceComponentHost componentHost2 = createNiceMock(ServiceComponentHost.class);
ServiceComponentHostResponse response1 = createNiceMock(ServiceComponentHostResponse.class);
ServiceComponentHostResponse response2 = createNiceMock(ServiceComponentHostResponse.class);
- PassiveStateHelper passiveHelper = createNiceMock(PassiveStateHelper.class);
- expect(passiveHelper.getEffectiveState(
- capture(new Capture<ServiceComponentHost>()))).andReturn(PassiveState.ACTIVE).anyTimes();
+ MaintenanceStateHelper maintHelper = createNiceMock(MaintenanceStateHelper.class);
+ expect(maintHelper.getEffectiveState(
+ capture(new Capture<ServiceComponentHost>()))).andReturn(MaintenanceState.OFF).anyTimes();
// requests
ServiceComponentHostRequest request1 = new ServiceComponentHostRequest(
@@ -745,7 +745,7 @@ public class AmbariManagementControllerImplTest {
// constructor init
injector.injectMembers(capture(controllerCapture));
expect(injector.getInstance(Gson.class)).andReturn(null);
- expect(injector.getInstance(PassiveStateHelper.class)).andReturn(passiveHelper).anyTimes();
+ expect(injector.getInstance(MaintenanceStateHelper.class)).andReturn(maintHelper).anyTimes();
// getHostComponent
expect(clusters.getCluster("cluster1")).andReturn(cluster).times(3);
@@ -772,7 +772,7 @@ public class AmbariManagementControllerImplTest {
expect(componentHost2.convertToResponse()).andReturn(response2);
// replay mocks
- replay(passiveHelper, injector, clusters, cluster, host, stack, metaInfo,
+ replay(maintHelper, injector, clusters, cluster, host, stack, metaInfo,
service, service2, component, component2, component3, componentHost1,
componentHost2, response1, response2);
@@ -929,9 +929,9 @@ public class AmbariManagementControllerImplTest {
ServiceComponentHost componentHost2 = createNiceMock(ServiceComponentHost.class);
ServiceComponentHostResponse response1 = createNiceMock(ServiceComponentHostResponse.class);
ServiceComponentHostResponse response2 = createNiceMock(ServiceComponentHostResponse.class);
- PassiveStateHelper passiveHelper = createNiceMock(PassiveStateHelper.class);
- expect(passiveHelper.getEffectiveState(
- capture(new Capture<ServiceComponentHost>()))).andReturn(PassiveState.ACTIVE).anyTimes();
+ MaintenanceStateHelper maintHelper = createNiceMock(MaintenanceStateHelper.class);
+ expect(maintHelper.getEffectiveState(
+ capture(new Capture<ServiceComponentHost>()))).andReturn(MaintenanceState.OFF).anyTimes();
// requests
ServiceComponentHostRequest request1 = new ServiceComponentHostRequest(
@@ -950,7 +950,7 @@ public class AmbariManagementControllerImplTest {
// constructor init
injector.injectMembers(capture(controllerCapture));
expect(injector.getInstance(Gson.class)).andReturn(null);
- expect(injector.getInstance(PassiveStateHelper.class)).andReturn(passiveHelper).anyTimes();
+ expect(injector.getInstance(MaintenanceStateHelper.class)).andReturn(maintHelper).anyTimes();
// getHostComponent
expect(clusters.getCluster("cluster1")).andReturn(cluster);
@@ -969,7 +969,7 @@ public class AmbariManagementControllerImplTest {
expect(componentHost2.convertToResponse()).andReturn(response2);
// replay mocks
- replay(passiveHelper, injector, clusters, cluster, response1, response2,
+ replay(maintHelper, injector, clusters, cluster, response1, response2,
stack, metaInfo, service, component, componentHost1, componentHost2);
//test
@@ -1011,9 +1011,9 @@ public class AmbariManagementControllerImplTest {
ServiceComponentHostResponse response1 = createNiceMock(ServiceComponentHostResponse.class);
ServiceComponentHostResponse response2 = createNiceMock(ServiceComponentHostResponse.class);
ServiceComponentHostResponse response3 = createNiceMock(ServiceComponentHostResponse.class);
- PassiveStateHelper passiveHelper = createNiceMock(PassiveStateHelper.class);
- expect(passiveHelper.getEffectiveState(
- capture(new Capture<ServiceComponentHost>()))).andReturn(PassiveState.ACTIVE).anyTimes();
+ MaintenanceStateHelper maintHelper = createNiceMock(MaintenanceStateHelper.class);
+ expect(maintHelper.getEffectiveState(
+ capture(new Capture<ServiceComponentHost>()))).andReturn(MaintenanceState.OFF).anyTimes();
// requests
ServiceComponentHostRequest request1 = new ServiceComponentHostRequest(
@@ -1036,7 +1036,7 @@ public class AmbariManagementControllerImplTest {
// constructor init
injector.injectMembers(capture(controllerCapture));
expect(injector.getInstance(Gson.class)).andReturn(null);
- expect(injector.getInstance(PassiveStateHelper.class)).andReturn(passiveHelper).anyTimes();
+ expect(injector.getInstance(MaintenanceStateHelper.class)).andReturn(maintHelper).anyTimes();
// getHostComponent
expect(clusters.getCluster("cluster1")).andReturn(cluster);
@@ -1056,7 +1056,7 @@ public class AmbariManagementControllerImplTest {
expect(componentHost3.convertToResponse()).andReturn(response3);
// replay mocks
- replay(passiveHelper, injector, clusters, cluster, response1, response2,
+ replay(maintHelper, injector, clusters, cluster, response1, response2,
response3, stack, metaInfo, service1, service2, component1, component2,
componentHost1, componentHost2, componentHost3);
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
index 5ee94c7..dc4c5a5 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
@@ -95,7 +95,7 @@ import org.apache.ambari.server.state.ConfigImpl;
import org.apache.ambari.server.state.Host;
import org.apache.ambari.server.state.HostComponentAdminState;
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.RepositoryInfo;
import org.apache.ambari.server.state.Service;
import org.apache.ambari.server.state.ServiceComponent;
@@ -2363,7 +2363,7 @@ public class AmbariManagementControllerTest {
Assert.assertNotNull(storedTasks);
Assert.assertEquals(1, storedTasks.size());
Assert.assertEquals(HostComponentAdminState.DECOMMISSIONED, scHost.getComponentAdminState());
- Assert.assertEquals(PassiveState.PASSIVE, scHost.getPassiveState());
+ Assert.assertEquals(MaintenanceState.ON, scHost.getMaintenanceState());
HostRoleCommand command = storedTasks.get(0);
Assert.assertTrue("DECOMMISSION, Excluded: h2".equals(command.getCommandDetail()));
Assert.assertTrue("DECOMMISSION".equals(command.getCustomCommandName()));
@@ -2401,7 +2401,7 @@ public class AmbariManagementControllerTest {
Assert.assertNotNull(storedTasks);
Assert.assertEquals(1, storedTasks.size());
Assert.assertEquals(HostComponentAdminState.DECOMMISSIONED, scHost.getComponentAdminState());
- Assert.assertEquals(PassiveState.PASSIVE, scHost.getPassiveState());
+ Assert.assertEquals(MaintenanceState.ON, scHost.getMaintenanceState());
cInfo = execCmd.getClusterHostInfo();
Assert.assertTrue(cInfo.containsKey("decom_hbase_rs_hosts"));
command = storedTasks.get(0);
@@ -2428,7 +2428,7 @@ public class AmbariManagementControllerTest {
Assert.assertNotNull(storedTasks);
Assert.assertEquals(1, storedTasks.size());
Assert.assertEquals(HostComponentAdminState.INSERVICE, scHost.getComponentAdminState());
- Assert.assertEquals(PassiveState.PASSIVE, scHost.getPassiveState());
+ Assert.assertEquals(MaintenanceState.ON, scHost.getMaintenanceState());
command = storedTasks.get(0);
Assert.assertTrue("DECOMMISSION, Included: h2".equals(command.getCommandDetail()));
Assert.assertTrue("DECOMMISSION".equals(command.getCustomCommandName()));
@@ -5975,7 +5975,7 @@ public class AmbariManagementControllerTest {
Assert.assertNotNull(execCmd.getConfigurationTags().get("hdfs-site"));
Assert.assertEquals(1, storedTasks.size());
Assert.assertEquals(HostComponentAdminState.DECOMMISSIONED, scHost.getComponentAdminState());
- Assert.assertEquals(PassiveState.PASSIVE, scHost.getPassiveState());
+ Assert.assertEquals(MaintenanceState.ON, scHost.getMaintenanceState());
HostRoleCommand command = storedTasks.get(0);
Assert.assertEquals(Role.NAMENODE, command.getRole());
Assert.assertEquals(RoleCommand.CUSTOM_COMMAND, command.getRoleCommand());
@@ -6006,7 +6006,7 @@ public class AmbariManagementControllerTest {
Assert.assertNotNull(storedTasks);
Assert.assertEquals(1, storedTasks.size());
Assert.assertEquals(HostComponentAdminState.DECOMMISSIONED, scHost.getComponentAdminState());
- Assert.assertEquals(PassiveState.PASSIVE, scHost.getPassiveState());
+ Assert.assertEquals(MaintenanceState.ON, scHost.getMaintenanceState());
cInfo = execCmd.getClusterHostInfo();
Assert.assertTrue(cInfo.containsKey("decom_dn_hosts"));
Assert.assertEquals("0,1", cInfo.get("decom_dn_hosts").iterator().next());
@@ -6042,7 +6042,7 @@ public class AmbariManagementControllerTest {
Assert.assertNotNull(storedTasks);
scHost = s.getServiceComponent("DATANODE").getServiceComponentHost("h2");
Assert.assertEquals(HostComponentAdminState.INSERVICE, scHost.getComponentAdminState());
- Assert.assertEquals(PassiveState.ACTIVE, scHost.getPassiveState());
+ Assert.assertEquals(MaintenanceState.OFF, scHost.getMaintenanceState());
execCmd = storedTasks.get(0).getExecutionCommandWrapper
().getExecutionCommand();
Assert.assertNotNull(storedTasks);
@@ -6064,7 +6064,7 @@ public class AmbariManagementControllerTest {
// Slave components will have admin state as INSERVICE even if the state in DB is null
scHost.setComponentAdminState(null);
Assert.assertEquals(HostComponentAdminState.INSERVICE, scHost.getComponentAdminState());
- Assert.assertEquals(PassiveState.ACTIVE, scHost.getPassiveState());
+ Assert.assertEquals(MaintenanceState.OFF, scHost.getMaintenanceState());
}
@Test
@@ -8001,7 +8001,7 @@ public class AmbariManagementControllerTest {
sc3.getServiceComponentHosts().values().iterator().next().setState(State.INSTALL_FAILED);
ServiceComponent sc4 = s2.getServiceComponent(componentName4);
sc4.getServiceComponentHosts().values().iterator().next().setDesiredState(State.INSTALLED);
- sc4.getServiceComponentHosts().values().iterator().next().setState(State.MAINTENANCE);
+ sc4.getServiceComponentHosts().values().iterator().next().setState(State.DISABLED);
ServiceComponent sc5 = s2.getServiceComponent(componentName5);
sc5.getServiceComponentHosts().values().iterator().next().setState(State.INSTALLED);
ServiceComponent sc6 = s2.getServiceComponent(componentName6);
@@ -8082,9 +8082,9 @@ public class AmbariManagementControllerTest {
}
Set<ServiceComponentHostRequest> schRequests = new HashSet<ServiceComponentHostRequest>();
- // maintenance HC for non-clients
- schRequests.add(new ServiceComponentHostRequest(clusterName, serviceName, componentName1, host1, "MAINTENANCE"));
- schRequests.add(new ServiceComponentHostRequest(clusterName, serviceName, componentName2, host1, "MAINTENANCE"));
+ // disable HC for non-clients
+ schRequests.add(new ServiceComponentHostRequest(clusterName, serviceName, componentName1, host1, "DISABLED"));
+ schRequests.add(new ServiceComponentHostRequest(clusterName, serviceName, componentName2, host1, "DISABLED"));
controller.updateHostComponents(schRequests, new HashMap<String,String>(), false);
// delete HC
@@ -8266,8 +8266,8 @@ public class AmbariManagementControllerTest {
sch.handleEvent(new ServiceComponentHostStoppedEvent (sch.getServiceComponentName(), sch.getHostName(), System.currentTimeMillis()));
schRequests.clear();
- // maintenance HC, DN was already stopped
- schRequests.add(new ServiceComponentHostRequest(clusterName, serviceName, componentName1, host1, "MAINTENANCE"));
+ // disable HC, DN was already stopped
+ schRequests.add(new ServiceComponentHostRequest(clusterName, serviceName, componentName1, host1, "DISABLED"));
controller.updateHostComponents(schRequests, new HashMap<String,String>(), false);
// delete HC
@@ -8495,7 +8495,7 @@ public class AmbariManagementControllerTest {
}
@Test
- public void testMaintenanceAndDeleteStates() throws Exception {
+ public void testDisableAndDeleteStates() throws Exception {
Map<String,String> mapRequestProps = new HashMap<String, String>();
Injector injector = Guice.createInjector(new AbstractModule() {
@Override
@@ -8623,11 +8623,11 @@ public class AmbariManagementControllerTest {
}
componentHostRequests.clear();
- componentHostRequests.add(new ServiceComponentHostRequest("c1", null, "NAMENODE", "host1", "MAINTENANCE"));
+ componentHostRequests.add(new ServiceComponentHostRequest("c1", null, "NAMENODE", "host1", "DISABLED"));
amc.updateHostComponents(componentHostRequests, mapRequestProps, true);
- Assert.assertEquals(State.MAINTENANCE, componentHost.getState());
+ Assert.assertEquals(State.DISABLED, componentHost.getState());
componentHostRequests.clear();
componentHostRequests.add(new ServiceComponentHostRequest("c1", null, "NAMENODE", "host1", "INSTALLED"));
@@ -8637,11 +8637,11 @@ public class AmbariManagementControllerTest {
Assert.assertEquals(State.INSTALLED, componentHost.getState());
componentHostRequests.clear();
- componentHostRequests.add(new ServiceComponentHostRequest("c1", null, "NAMENODE", "host1", "MAINTENANCE"));
+ componentHostRequests.add(new ServiceComponentHostRequest("c1", null, "NAMENODE", "host1", "DISABLED"));
amc.updateHostComponents(componentHostRequests, mapRequestProps, true);
- Assert.assertEquals(State.MAINTENANCE, componentHost.getState());
+ Assert.assertEquals(State.DISABLED, componentHost.getState());
componentHostRequests.clear();
componentHostRequests.add(new ServiceComponentHostRequest("c1", null, "NAMENODE", "host2", null));
@@ -8706,26 +8706,26 @@ public class AmbariManagementControllerTest {
}
assertNotNull(sch);
- // make maintenance
+ // make disabled
componentHostRequests.clear();
- componentHostRequests.add(new ServiceComponentHostRequest("c1", null, "DATANODE", "host2", "MAINTENANCE"));
+ componentHostRequests.add(new ServiceComponentHostRequest("c1", null, "DATANODE", "host2", "DISABLED"));
amc.updateHostComponents(componentHostRequests, mapRequestProps, false);
- org.junit.Assert.assertEquals(State.MAINTENANCE, sch.getState());
+ org.junit.Assert.assertEquals(State.DISABLED, sch.getState());
- // ServiceComponentHost remains in maintenance after service stop
+ // ServiceComponentHost remains in disabled after service stop
assertEquals(sch.getServiceComponentName(),"DATANODE");
serviceRequests.clear();
serviceRequests.add(new ServiceRequest("c1", "HDFS", "INSTALLED"));
ServiceResourceProviderTest.updateServices(amc, serviceRequests,
mapRequestProps, true, false);
- assertEquals(State.MAINTENANCE, sch.getState());
+ assertEquals(State.DISABLED, sch.getState());
- // ServiceComponentHost remains in maintenance after service start
+ // ServiceComponentHost remains in disabled after service start
serviceRequests.clear();
serviceRequests.add(new ServiceRequest("c1", "HDFS", "STARTED"));
ServiceResourceProviderTest.updateServices(amc, serviceRequests,
mapRequestProps, true, false);
- assertEquals(State.MAINTENANCE, sch.getState());
+ assertEquals(State.DISABLED, sch.getState());
// confirm delete
componentHostRequests.clear();
@@ -9150,7 +9150,7 @@ public class AmbariManagementControllerTest {
}
@Test
- public void testPassiveStates() throws Exception {
+ public void testMaintenanceState() throws Exception {
String clusterName = "c1";
createCluster(clusterName);
clusters.getCluster(clusterName)
@@ -9194,133 +9194,133 @@ public class AmbariManagementControllerTest {
// test updating a service
ServiceRequest sr = new ServiceRequest(clusterName, serviceName, null);
- sr.setPassiveState(PassiveState.PASSIVE.name());
+ sr.setMaintenanceState(MaintenanceState.ON.name());
ServiceResourceProviderTest.updateServices(controller, Collections.singleton(sr),
requestProperties, false, false);
- Assert.assertEquals(PassiveState.PASSIVE, service.getPassiveState());
+ Assert.assertEquals(MaintenanceState.ON, service.getMaintenanceState());
// check the host components implied state vs desired state
for (ServiceComponent sc : service.getServiceComponents().values()) {
for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
- Assert.assertEquals(PassiveState.IMPLIED,
- controller.getEffectivePassiveState(sch));
- Assert.assertEquals(PassiveState.ACTIVE, sch.getPassiveState());
+ Assert.assertEquals(MaintenanceState.IMPLIED,
+ controller.getEffectiveMaintenanceState(sch));
+ Assert.assertEquals(MaintenanceState.OFF, sch.getMaintenanceState());
}
}
// reset
- sr.setPassiveState(PassiveState.ACTIVE.name());
+ sr.setMaintenanceState(MaintenanceState.OFF.name());
ServiceResourceProviderTest.updateServices(controller, Collections.singleton(sr),
requestProperties, false, false);
- Assert.assertEquals(PassiveState.ACTIVE, service.getPassiveState());
+ Assert.assertEquals(MaintenanceState.OFF, service.getMaintenanceState());
// check the host components implied state vs desired state
for (ServiceComponent sc : service.getServiceComponents().values()) {
for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
- Assert.assertEquals(PassiveState.ACTIVE,
- controller.getEffectivePassiveState(sch));
- Assert.assertEquals(PassiveState.ACTIVE, sch.getPassiveState());
+ Assert.assertEquals(MaintenanceState.OFF,
+ controller.getEffectiveMaintenanceState(sch));
+ Assert.assertEquals(MaintenanceState.OFF, sch.getMaintenanceState());
}
}
// passivate a host
HostRequest hr = new HostRequest(host1, clusterName, requestProperties);
- hr.setPassiveState(PassiveState.PASSIVE.name());
+ hr.setMaintenanceState(MaintenanceState.ON.name());
HostResourceProviderTest.updateHosts(controller, Collections.singleton(hr),
new HashMap<String, String>());
Host host = hosts.get(host1);
- Assert.assertEquals(PassiveState.PASSIVE, host.getPassiveState(cluster.getClusterId()));
+ Assert.assertEquals(MaintenanceState.ON, host.getMaintenanceState(cluster.getClusterId()));
// check the host components implied state vs desired state, only for affected hosts
for (ServiceComponent sc : service.getServiceComponents().values()) {
for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
- PassiveState implied = controller.getEffectivePassiveState(sch);
+ MaintenanceState implied = controller.getEffectiveMaintenanceState(sch);
if (sch.getHostName().equals(host1)) {
- Assert.assertEquals(PassiveState.IMPLIED, implied);
+ Assert.assertEquals(MaintenanceState.IMPLIED, implied);
} else {
- Assert.assertEquals(PassiveState.ACTIVE, implied);
+ Assert.assertEquals(MaintenanceState.OFF, implied);
}
- Assert.assertEquals(PassiveState.ACTIVE, sch.getPassiveState());
+ Assert.assertEquals(MaintenanceState.OFF, sch.getMaintenanceState());
}
}
// reset
- hr.setPassiveState(PassiveState.ACTIVE.name());
+ hr.setMaintenanceState(MaintenanceState.OFF.name());
HostResourceProviderTest.updateHosts(controller, Collections.singleton(hr),
new HashMap<String, String>());
host = hosts.get(host1);
- Assert.assertEquals(PassiveState.ACTIVE, host.getPassiveState(cluster.getClusterId()));
+ Assert.assertEquals(MaintenanceState.OFF, host.getMaintenanceState(cluster.getClusterId()));
// check the host components active state vs desired state
for (ServiceComponent sc : service.getServiceComponents().values()) {
for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
- Assert.assertEquals(PassiveState.ACTIVE,
- controller.getEffectivePassiveState(sch));
- Assert.assertEquals(PassiveState.ACTIVE, sch.getPassiveState());
+ Assert.assertEquals(MaintenanceState.OFF,
+ controller.getEffectiveMaintenanceState(sch));
+ Assert.assertEquals(MaintenanceState.OFF, sch.getMaintenanceState());
}
}
// passivate several hosts
HostRequest hr1 = new HostRequest(host1, clusterName, requestProperties);
- hr1.setPassiveState(PassiveState.PASSIVE.name());
+ hr1.setMaintenanceState(MaintenanceState.ON.name());
HostRequest hr2 = new HostRequest(host2, clusterName, requestProperties);
- hr2.setPassiveState(PassiveState.PASSIVE.name());
+ hr2.setMaintenanceState(MaintenanceState.ON.name());
Set<HostRequest> set = new HashSet<HostRequest>();
set.add(hr1);
set.add(hr2);
HostResourceProviderTest.updateHosts(controller, set, new HashMap<String, String>());
host = hosts.get(host1);
- Assert.assertEquals(PassiveState.PASSIVE, host.getPassiveState(cluster.getClusterId()));
+ Assert.assertEquals(MaintenanceState.ON, host.getMaintenanceState(cluster.getClusterId()));
host = hosts.get(host2);
- Assert.assertEquals(PassiveState.PASSIVE, host.getPassiveState(cluster.getClusterId()));
+ Assert.assertEquals(MaintenanceState.ON, host.getMaintenanceState(cluster.getClusterId()));
// reset
hr1 = new HostRequest(host1, clusterName, requestProperties);
- hr1.setPassiveState(PassiveState.ACTIVE.name());
+ hr1.setMaintenanceState(MaintenanceState.OFF.name());
hr2 = new HostRequest(host2, clusterName, requestProperties);
- hr2.setPassiveState(PassiveState.ACTIVE.name());
+ hr2.setMaintenanceState(MaintenanceState.OFF.name());
set = new HashSet<HostRequest>();
set.add(hr1);
set.add(hr2);
HostResourceProviderTest.updateHosts(controller, set, new HashMap<String, String>());
host = hosts.get(host1);
- Assert.assertEquals(PassiveState.ACTIVE, host.getPassiveState(cluster.getClusterId()));
+ Assert.assertEquals(MaintenanceState.OFF, host.getMaintenanceState(cluster.getClusterId()));
host = hosts.get(host2);
- Assert.assertEquals(PassiveState.ACTIVE, host.getPassiveState(cluster.getClusterId()));
+ Assert.assertEquals(MaintenanceState.OFF, host.getMaintenanceState(cluster.getClusterId()));
// only do one SCH
ServiceComponentHost targetSch = service.getServiceComponent(
componentName2).getServiceComponentHosts().get(host2);
Assert.assertNotNull(targetSch);
- targetSch.setPassiveState(PassiveState.PASSIVE);
+ targetSch.setMaintenanceState(MaintenanceState.ON);
// check the host components active state vs desired state
- Assert.assertEquals(PassiveState.PASSIVE, controller.getEffectivePassiveState(targetSch));
+ Assert.assertEquals(MaintenanceState.ON, controller.getEffectiveMaintenanceState(targetSch));
// update the service
- service.setPassiveState(PassiveState.PASSIVE);
- Assert.assertEquals(PassiveState.PASSIVE, controller.getEffectivePassiveState(targetSch));
+ service.setMaintenanceState(MaintenanceState.ON);
+ Assert.assertEquals(MaintenanceState.ON, controller.getEffectiveMaintenanceState(targetSch));
// make SCH active
- targetSch.setPassiveState(PassiveState.ACTIVE);
- Assert.assertEquals(PassiveState.IMPLIED, controller.getEffectivePassiveState(targetSch));
+ targetSch.setMaintenanceState(MaintenanceState.OFF);
+ Assert.assertEquals(MaintenanceState.IMPLIED, controller.getEffectiveMaintenanceState(targetSch));
// update the service
- service.setPassiveState(PassiveState.ACTIVE);
- Assert.assertEquals(PassiveState.ACTIVE, controller.getEffectivePassiveState(targetSch));
+ service.setMaintenanceState(MaintenanceState.OFF);
+ Assert.assertEquals(MaintenanceState.OFF, controller.getEffectiveMaintenanceState(targetSch));
host = hosts.get(host2);
// update host
- host.setPassiveState(cluster.getClusterId(), PassiveState.PASSIVE);
- Assert.assertEquals(PassiveState.IMPLIED, controller.getEffectivePassiveState(targetSch));
+ host.setMaintenanceState(cluster.getClusterId(), MaintenanceState.ON);
+ Assert.assertEquals(MaintenanceState.IMPLIED, controller.getEffectiveMaintenanceState(targetSch));
- targetSch.setPassiveState(PassiveState.PASSIVE);
- Assert.assertEquals(PassiveState.PASSIVE, controller.getEffectivePassiveState(targetSch));
+ targetSch.setMaintenanceState(MaintenanceState.ON);
+ Assert.assertEquals(MaintenanceState.ON, controller.getEffectiveMaintenanceState(targetSch));
// check the host components active state vs desired state
for (ServiceComponent sc : service.getServiceComponents().values()) {
@@ -9428,7 +9428,7 @@ public class AmbariManagementControllerTest {
}
Service service2 = cluster.getService(serviceName2);
- service2.setPassiveState(PassiveState.PASSIVE);
+ service2.setMaintenanceState(MaintenanceState.ON);
Set<ServiceRequest> srs = new HashSet<ServiceRequest>();
srs.add(new ServiceRequest(clusterName, serviceName1, State.INSTALLED.name()));
@@ -9448,7 +9448,7 @@ public class AmbariManagementControllerTest {
Assert.assertEquals(State.INSTALLED, service.getDesiredState());
}
- service2.setPassiveState(PassiveState.ACTIVE);
+ service2.setMaintenanceState(MaintenanceState.OFF);
ServiceResourceProviderTest.updateServices(controller, srs, requestProperties, false, false);
for (Service service : cluster.getServices().values()) {
Assert.assertEquals(State.INSTALLED, service.getDesiredState());
@@ -9459,7 +9459,7 @@ public class AmbariManagementControllerTest {
// test host
Host h1 = clusters.getHost(host1);
- h1.setPassiveState(cluster.getClusterId(), PassiveState.PASSIVE);
+ h1.setMaintenanceState(cluster.getClusterId(), MaintenanceState.ON);
srs = new HashSet<ServiceRequest>();
srs.add(new ServiceRequest(clusterName, serviceName1, State.INSTALLED.name()));
@@ -9471,10 +9471,10 @@ public class AmbariManagementControllerTest {
Assert.assertFalse(sts.getHostName().equals(host1));
}
- h1.setPassiveState(cluster.getClusterId(), PassiveState.ACTIVE);
+ h1.setMaintenanceState(cluster.getClusterId(), MaintenanceState.OFF);
startService(clusterName, serviceName2, false, false);
- service2.setPassiveState(PassiveState.PASSIVE);
+ service2.setMaintenanceState(MaintenanceState.ON);
ServiceRequest sr = new ServiceRequest(clusterName, serviceName2, State.INSTALLED.name());
rsr = ServiceResourceProviderTest.updateServices(controller,
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f4f2e8/ambari-server/src/test/java/org/apache/ambari/server/controller/MaintenanceStateHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/MaintenanceStateHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/MaintenanceStateHelperTest.java
new file mode 100644
index 0000000..3f46ce0
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/MaintenanceStateHelperTest.java
@@ -0,0 +1,213 @@
+/**
+ * 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 static org.easymock.EasyMock.capture;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+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 org.easymock.Capture;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Tests the {@link MaintenanceStateHelper} class
+ */
+public class MaintenanceStateHelperTest {
+
+ @Test
+ public void testService() throws Exception {
+ testService(MaintenanceState.ON);
+ testService(MaintenanceState.OFF);
+ }
+
+ @Test
+ public void testHost() throws Exception {
+ testHost(MaintenanceState.ON);
+ testHost(MaintenanceState.OFF);
+ }
+
+ @Test
+ public void testHostComponent() throws Exception {
+ testHostComponent(MaintenanceState.ON);
+ testHostComponent(MaintenanceState.OFF);
+ }
+
+ private void testHostComponent(MaintenanceState state) throws Exception {
+ AmbariManagementController amc = createMock(AmbariManagementController.class);
+ Capture<ExecuteActionRequest> earCapture = new Capture<ExecuteActionRequest>();
+ Capture<Map<String, String>> rpCapture = new Capture<Map<String, String>>();
+ expect(amc.createAction(capture(earCapture), capture(rpCapture))).andReturn(null);
+
+ Clusters clusters = createMock(Clusters.class);
+ Cluster cluster = createMock(Cluster.class);
+ expect(amc.getClusters()).andReturn(clusters).anyTimes();
+ expect(clusters.getClusterById(1L)).andReturn(cluster);
+ expect(cluster.getClusterName()).andReturn("c1").anyTimes();
+
+ ServiceComponentHost sch = createMock(ServiceComponentHost.class);
+ expect(sch.getClusterName()).andReturn("c1");
+ expect(sch.getClusterId()).andReturn(1L);
+ expect(sch.getMaintenanceState()).andReturn(state);
+ expect(sch.getServiceName()).andReturn("HDFS");
+ expect(sch.getServiceComponentName()).andReturn("NAMENODE").anyTimes();
+ expect(sch.getHostName()).andReturn("h1");
+
+ replay(amc, clusters, cluster, sch);
+
+ Map<String, String> map = new HashMap<String, String>();
+ map.put("context", "abc");
+ MaintenanceStateHelper.createRequests(amc, map,
+ Collections.singleton(sch.getClusterName()));
+
+ ExecuteActionRequest ear = earCapture.getValue();
+ map = rpCapture.getValue();
+
+ Assert.assertEquals("nagios_update_ignore", ear.getActionName());
+ Assert.assertEquals("ACTIONEXECUTE", ear.getCommandName());
+ Assert.assertEquals("NAGIOS", ear.getServiceName());
+ Assert.assertEquals("NAGIOS_SERVER", ear.getComponentName());
+ Assert.assertEquals("c1", ear.getClusterName());
+ Assert.assertTrue(map.containsKey("context"));
+ }
+
+ private void testHost(MaintenanceState state) throws Exception {
+ AmbariManagementController amc = createMock(AmbariManagementController.class);
+ Capture<ExecuteActionRequest> earCapture = new Capture<ExecuteActionRequest>();
+ Capture<Map<String, String>> rpCapture = new Capture<Map<String, String>>();
+ expect(amc.createAction(capture(earCapture), capture(rpCapture))).andReturn(null);
+
+ Clusters clusters = createMock(Clusters.class);
+ Cluster cluster = createMock(Cluster.class);
+ Service service = createMock(Service.class);
+
+ ServiceComponent sc1 = createMock(ServiceComponent.class);
+ ServiceComponent sc2 = createMock(ServiceComponent.class);
+ expect(sc1.isClientComponent()).andReturn(Boolean.FALSE).anyTimes();
+ expect(sc2.isClientComponent()).andReturn(Boolean.TRUE).anyTimes();
+
+ ServiceComponentHost sch1 = createMock(ServiceComponentHost.class);
+ Map<String, ServiceComponentHost> schMap = new HashMap<String, ServiceComponentHost>();
+ schMap.put("h1", sch1);
+ expect(sch1.getHostName()).andReturn("h1");
+ expect(sch1.getServiceName()).andReturn("HDFS").anyTimes();
+ expect(sch1.getServiceComponentName()).andReturn("NAMENODE").anyTimes();
+
+ List<ServiceComponentHost> schList = new ArrayList<ServiceComponentHost>(schMap.values());
+
+ expect(amc.getClusters()).andReturn(clusters).anyTimes();
+ expect(clusters.getClusterById(1L)).andReturn(cluster);
+ expect(cluster.getClusterName()).andReturn("c1").anyTimes();
+ expect(cluster.getService("HDFS")).andReturn(service).anyTimes();
+ expect(cluster.getClusterId()).andReturn(Long.valueOf(1L));
+ expect(cluster.getServiceComponentHosts("h1")).andReturn(schList);
+ expect(service.getServiceComponent("NAMENODE")).andReturn(sc1);
+
+ Host host = createMock(Host.class);
+ expect(host.getHostName()).andReturn("h1").anyTimes();
+ expect(host.getMaintenanceState(1L)).andReturn(state);
+
+ replay(amc, clusters, cluster, service, sch1, host);
+
+ Map<String, String> map = new HashMap<String, String>();
+ map.put("context", "abc");
+ MaintenanceStateHelper.createRequests(amc, map,
+ Collections.singleton(cluster.getClusterName()));
+
+ ExecuteActionRequest ear = earCapture.getValue();
+ rpCapture.getValue();
+
+ Assert.assertEquals("nagios_update_ignore", ear.getActionName());
+ Assert.assertEquals("ACTIONEXECUTE", ear.getCommandName());
+ Assert.assertEquals("NAGIOS", ear.getServiceName());
+ Assert.assertEquals("NAGIOS_SERVER", ear.getComponentName());
+ Assert.assertEquals("c1", ear.getClusterName());
+ Assert.assertTrue(map.containsKey("context"));
+ }
+
+
+ private void testService(MaintenanceState state) throws Exception {
+ AmbariManagementController amc = createMock(AmbariManagementController.class);
+ Capture<ExecuteActionRequest> earCapture = new Capture<ExecuteActionRequest>();
+ Capture<Map<String, String>> rpCapture = new Capture<Map<String, String>>();
+ expect(amc.createAction(capture(earCapture), capture(rpCapture))).andReturn(null);
+
+ Clusters clusters = createMock(Clusters.class);
+ Cluster cluster = createMock(Cluster.class);
+ Service service = createMock(Service.class);
+
+ ServiceComponent sc1 = createMock(ServiceComponent.class);
+ ServiceComponent sc2 = createMock(ServiceComponent.class);
+ expect(sc1.isClientComponent()).andReturn(Boolean.FALSE).anyTimes();
+ expect(sc2.isClientComponent()).andReturn(Boolean.TRUE).anyTimes();
+
+ ServiceComponentHost sch1 = createMock(ServiceComponentHost.class);
+ Map<String, ServiceComponentHost> schMap = new HashMap<String, ServiceComponentHost>();
+ schMap.put("h1", sch1);
+ expect(sch1.getHostName()).andReturn("h1");
+ expect(sch1.getServiceName()).andReturn("HDFS");
+ expect(sch1.getServiceComponentName()).andReturn("NAMENODE");
+
+ expect(sc1.getServiceComponentHosts()).andReturn(schMap);
+
+ Map<String, ServiceComponent> scMap = new HashMap<String, ServiceComponent>();
+ scMap.put("NAMENODE", sc1);
+ scMap.put("HDFS_CLIENT", sc2);
+
+ expect(amc.getClusters()).andReturn(clusters).anyTimes();
+ expect(clusters.getClusterById(1L)).andReturn(cluster);
+ expect(cluster.getClusterName()).andReturn("c1");
+ expect(cluster.getClusterId()).andReturn(1L);
+ expect(service.getCluster()).andReturn(cluster);
+ expect(service.getServiceComponents()).andReturn(scMap);
+ expect(service.getMaintenanceState()).andReturn(state);
+ expect(service.getName()).andReturn("HDFS");
+
+ replay(amc, clusters, cluster, service, sc1, sc2, sch1);
+
+ Map<String, String> map = new HashMap<String, String>();
+ map.put("context", "abc");
+ MaintenanceStateHelper.createRequests(amc, map,
+ Collections.singleton("c1"));
+
+ ExecuteActionRequest ear = earCapture.getValue();
+ map = rpCapture.getValue();
+
+ Assert.assertEquals("nagios_update_ignore", ear.getActionName());
+ Assert.assertEquals("ACTIONEXECUTE", ear.getCommandName());
+ Assert.assertEquals("NAGIOS", ear.getServiceName());
+ Assert.assertEquals("NAGIOS_SERVER", ear.getComponentName());
+ Assert.assertEquals("c1", ear.getClusterName());
+ Assert.assertTrue(map.containsKey("context"));
+ }
+
+}
[3/3] git commit: AMBARI-4752. Rename MAINTENANCE and PassiveState
(ncole)
Posted by nc...@apache.org.
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();
}