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:32 UTC
[2/3] AMBARI-4752. Rename MAINTENANCE and PassiveState (ncole)
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"));
+ }
+
+}