Repository: ambari Updated Branches: refs/heads/trunk 8932e6472 -> fedcbb8a5
AMBARI-6361. Component status cannot be changed from INSTALL_FAIL to Disabled state. (Jayush Luniya via mahadev) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/fedcbb8a Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/fedcbb8a Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/fedcbb8a Branch: refs/heads/trunk Commit: fedcbb8a51be3a12ce4dcf2a7ec0f49f37552bb2 Parents: 8932e64 Author: Mahadev Konar <[email protected]> Authored: Mon Jul 14 14:36:39 2014 -0700 Committer: Mahadev Konar <[email protected]> Committed: Mon Jul 14 14:36:39 2014 -0700 ---------------------------------------------------------------------- .../AmbariManagementControllerImpl.java | 1 + .../org/apache/ambari/server/state/State.java | 1 + .../svccomphost/ServiceComponentHostImpl.java | 15 +++-- .../AmbariManagementControllerTest.java | 5 +- .../svccomphost/ServiceComponentHostTest.java | 61 ++++++++++++++++++++ pom.xml | 5 +- 6 files changed, 80 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/fedcbb8a/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 2d4b7e1..7d49c1b 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 @@ -2225,6 +2225,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle break; case DISABLED: if (oldState == State.INSTALLED || + oldState == State.INSTALL_FAILED || oldState == State.UNKNOWN) { return true; } http://git-wip-us.apache.org/repos/asf/ambari/blob/fedcbb8a/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 835b751..78af13f 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 @@ -173,6 +173,7 @@ public enum State { } case DISABLED: if (startState == State.INSTALLED + || startState == State.INSTALL_FAILED || startState == State.UNKNOWN) { return true; } http://git-wip-us.apache.org/repos/asf/ambari/blob/fedcbb8a/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 65176ba..3ee3078 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 @@ -340,15 +340,20 @@ public class ServiceComponentHostImpl implements ServiceComponentHost { State.DISABLED, ServiceComponentHostEventType.HOST_SVCCOMP_DISABLE, new ServiceComponentHostOpCompletedTransition()) + .addTransition(State.UNKNOWN, + State.DISABLED, + ServiceComponentHostEventType.HOST_SVCCOMP_DISABLE, + new ServiceComponentHostOpCompletedTransition()) + .addTransition(State.INSTALL_FAILED, + State.DISABLED, + ServiceComponentHostEventType.HOST_SVCCOMP_DISABLE, + new ServiceComponentHostOpCompletedTransition()) + .addTransition(State.DISABLED, State.INSTALLED, ServiceComponentHostEventType.HOST_SVCCOMP_RESTORE, new ServiceComponentHostOpCompletedTransition()) - - .addTransition(State.UNKNOWN, - State.DISABLED, - ServiceComponentHostEventType.HOST_SVCCOMP_DISABLE, - new ServiceComponentHostOpCompletedTransition()) + .installTopology(); http://git-wip-us.apache.org/repos/asf/ambari/blob/fedcbb8a/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 5097fd9..c5473fa 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 @@ -36,6 +36,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.lang.reflect.Type; +import java.net.ConnectException; import java.net.MalformedURLException; import java.net.UnknownHostException; import java.text.MessageFormat; @@ -8137,7 +8138,9 @@ public class AmbariManagementControllerTest { try { controller.updateRespositories(requests); } catch (Exception e) { - assertTrue(e.getMessage().contains(UnknownHostException.class.getName())); + String exceptionMsg = e.getMessage(); + assertTrue(exceptionMsg.contains(UnknownHostException.class.getName()) + || exceptionMsg.contains(ConnectException.class.getName())); } // reset repo http://git-wip-us.apache.org/repos/asf/ambari/blob/fedcbb8a/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 1581022..0101352 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 @@ -19,6 +19,7 @@ package org.apache.ambari.server.state.svccomphost; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import javax.persistence.EntityManager; @@ -217,6 +218,9 @@ public class ServiceComponentHostTest { case HOST_SVCCOMP_OP_RESTART: return new ServiceComponentHostOpRestartedEvent( impl.getServiceComponentName(), impl.getHostName(), timestamp); + case HOST_SVCCOMP_DISABLE: + return new ServiceComponentHostDisableEvent( + impl.getServiceComponentName(), impl.getHostName(), timestamp); case HOST_SVCCOMP_WIPEOUT: return new ServiceComponentHostWipeoutEvent( impl.getServiceComponentName(), impl.getHostName(), timestamp); @@ -611,6 +615,63 @@ public class ServiceComponentHostTest { impl.getState()); } + @Test + public void TestDisableInVariousStates() throws AmbariException, + InvalidStateTransitionException { + ServiceComponentHost sch = + createNewServiceComponentHost("HDFS", "DATANODE", "h1", false); + ServiceComponentHostImpl impl = (ServiceComponentHostImpl) sch; + + // Test valid states in which host component can be disabled + long timestamp = 0; + HashSet<State> validStates = new HashSet<State>(); + validStates.add(State.INSTALLED); + validStates.add(State.INSTALL_FAILED); + validStates.add(State.UNKNOWN); + validStates.add(State.DISABLED); + for (State state : validStates) + { + sch.setState(state); + ServiceComponentHostEvent disableEvent = createEvent( + impl, ++timestamp, ServiceComponentHostEventType.HOST_SVCCOMP_DISABLE); + impl.handleEvent(disableEvent); + // TODO: At present operation timestamps are not getting updated. + Assert.assertEquals(-1, impl.getLastOpStartTime()); + Assert.assertEquals(-1, impl.getLastOpLastUpdateTime()); + Assert.assertEquals(-1, impl.getLastOpEndTime()); + Assert.assertEquals(State.DISABLED, impl.getState()); + } + + // Test invalid states in which host component cannot be disabled + HashSet<State> invalidStates = new HashSet<State>(); + invalidStates.add(State.INIT); + invalidStates.add(State.INSTALLING); + invalidStates.add(State.STARTING); + invalidStates.add(State.STARTED); + invalidStates.add(State.STOPPING); + invalidStates.add(State.UNINSTALLING); + invalidStates.add(State.UNINSTALLED); + invalidStates.add(State.UPGRADING); + + for(State state : invalidStates) + { + sch.setState(state); + ServiceComponentHostEvent disableEvent = createEvent( + impl, ++timestamp, ServiceComponentHostEventType.HOST_SVCCOMP_DISABLE); + boolean exceptionThrown = false; + try { + impl.handleEvent(disableEvent); + } catch (Exception e) { + exceptionThrown = true; + } + Assert.assertTrue("Exception not thrown on invalid event", exceptionThrown); + // TODO: At present operation timestamps are not getting updated. + Assert.assertEquals(-1, impl.getLastOpStartTime()); + Assert.assertEquals(-1, impl.getLastOpLastUpdateTime()); + Assert.assertEquals(-1, impl.getLastOpEndTime()); + } + } + @Test public void testCanBeRemoved() throws Exception{ ServiceComponentHostImpl impl = (ServiceComponentHostImpl) http://git-wip-us.apache.org/repos/asf/ambari/blob/fedcbb8a/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 218bbfc..dddc6e5 100644 --- a/pom.xml +++ b/pom.xml @@ -173,7 +173,7 @@ <exclude>derby.log</exclude> <exclude>CHANGES.txt</exclude> <exclude>pass.txt</exclude> - <exclude>contrib/addons/test/dataServices/jmx/data/cluster_configuration.json.nohbase</exclude> + <exclude>contrib/addons/test/dataServices/jmx/data/cluster_configuration.json.nohbase</exclude> <exclude>contrib/ambari-scom/msi/src/GUI_Ambari.sln</exclude> <exclude>version</exclude> <!--IDE and GIT files--> @@ -222,7 +222,8 @@ <exclude>contrib/views/*/.classpath</exclude> <exclude>contrib/views/*/.project</exclude> <exclude>contrib/views/*/.settings/**</exclude> - + <exclude>contrib/views/jobs/src/main/resources/ui/**</exclude> + <!--Velocity log --> <exclude>**/velocity.log*</exclude> </excludes>
