You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by vg...@apache.org on 2011/12/21 03:46:52 UTC
svn commit: r1221573 - in /incubator/ambari/trunk: ./
controller/src/main/java/org/apache/ambari/controller/
controller/src/main/java/org/apache/ambari/controller/rest/resources/
controller/src/main/java/org/apache/ambari/resource/statemachine/ control...
Author: vgogate
Date: Wed Dec 21 02:46:52 2011
New Revision: 1221573
URL: http://svn.apache.org/viewvc?rev=1221573&view=rev
Log:
AMBARI-170. Update the cluster state after state machine transitions it to final ACTIVE/INACTIVE state
Modified:
incubator/ambari/trunk/CHANGES.txt
incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Clusters.java
incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/ContextProvider.java
incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/resource/statemachine/ClusterFSM.java
incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/resource/statemachine/ClusterImpl.java
incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/resource/statemachine/FSMDriver.java
incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/resource/statemachine/FSMDriverInterface.java
incubator/ambari/trunk/controller/src/test/java/org/apache/ambari/controller/TestFSMDriverImpl.java
incubator/ambari/trunk/controller/src/test/java/org/apache/ambari/controller/TestHeartbeat.java
Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1221573&r1=1221572&r2=1221573&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Wed Dec 21 02:46:52 2011
@@ -2,6 +2,8 @@ Ambari Change log
Release 0.1.0 - unreleased
+ AMBARI-170. Update the cluster state after state machine transitions it to final ACTIVE/INACTIVE state (vgogate)
+
AMBARI-168. trim the white spaces from host names returned through getHostnamesFromRageExpressions (vgogate)
AMBARI-163. Addresses failure handling in FSM. ((thejas via ddas)
Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Clusters.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Clusters.java?rev=1221573&r1=1221572&r2=1221573&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Clusters.java (original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Clusters.java Wed Dec 21 02:46:52 2011
@@ -338,7 +338,7 @@ public class Clusters {
} else if(c.getGoalState().equals(ClusterState.CLUSTER_STATE_INACTIVE)) {
fsmDriver.stopCluster(cls.getName());
} else if(c.getGoalState().equals(ClusterState.CLUSTER_STATE_ATTIC)) {
- fsmDriver.deleteCluster(cls.getName());
+ fsmDriver.stopCluster(cls.getName());
}
return cls.getClusterDefinition(-1);
Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/ContextProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/ContextProvider.java?rev=1221573&r1=1221572&r2=1221573&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/ContextProvider.java (original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/ContextProvider.java Wed Dec 21 02:46:52 2011
@@ -32,6 +32,8 @@ import com.sun.jersey.api.json.JSONJAXBC
public class ContextProvider implements ContextResolver<JAXBContext> {
private final JAXBContext context;
+ private Class<?>[] types = { };
+ /*
private Class<?>[] types = { ClusterDefinition.class,
ClusterInformation.class,
ClusterState.class,
@@ -49,7 +51,7 @@ public class ContextProvider implements
RoleToNodes.class,
Stack.class,
StackInformation.class
- };
+ }; */
public ContextProvider() throws JAXBException {
this.context = new JSONJAXBContext(JSONConfiguration.natural().build(),
Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/resource/statemachine/ClusterFSM.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/resource/statemachine/ClusterFSM.java?rev=1221573&r1=1221572&r2=1221573&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/resource/statemachine/ClusterFSM.java (original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/resource/statemachine/ClusterFSM.java Wed Dec 21 02:46:52 2011
@@ -23,7 +23,6 @@ import java.util.Map;
public interface ClusterFSM {
public List<ServiceFSM> getServices();
public Map<String, String> getServiceStates();
- public void terminate();
public String getClusterState();
public void activate();
public void deactivate();
Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/resource/statemachine/ClusterImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/resource/statemachine/ClusterImpl.java?rev=1221573&r1=1221572&r2=1221573&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/resource/statemachine/ClusterImpl.java (original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/resource/statemachine/ClusterImpl.java Wed Dec 21 02:46:52 2011
@@ -19,6 +19,7 @@ package org.apache.ambari.resource.state
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Date;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Iterator;
@@ -28,12 +29,14 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
+import org.apache.ambari.common.rest.entities.ClusterState;
import org.apache.ambari.common.state.MultipleArcTransition;
import org.apache.ambari.common.state.SingleArcTransition;
import org.apache.ambari.common.state.StateMachine;
import org.apache.ambari.common.state.StateMachineFactory;
import org.apache.ambari.components.ComponentPlugin;
import org.apache.ambari.controller.Cluster;
+import org.apache.ambari.controller.Util;
import org.apache.ambari.event.EventHandler;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -86,6 +89,7 @@ public class ClusterImpl implements Clus
.installTopology();
private List<ServiceFSM> services;
+ private Cluster cls;
private StateMachine<ClusterStateFSM, ClusterEventType, ClusterEvent>
stateMachine;
private Lock readLock;
@@ -114,6 +118,7 @@ public class ClusterImpl implements Clus
serviceImpls.add(serviceImpl);
}
}
+ this.cls = cluster;
this.services = serviceImpls;
}
@@ -204,6 +209,7 @@ public class ClusterImpl implements Clus
ServiceEventType.STOP, service));
return ClusterStateFSM.STOPPING;
}
+ operand.updateClusterState(ClusterState.CLUSTER_STATE_INACTIVE);
return ClusterStateFSM.INACTIVE;
}
@@ -221,6 +227,7 @@ public class ClusterImpl implements Clus
ServiceEventType.START, service));
return ClusterStateFSM.STARTING;
}
+ operand.updateClusterState(ClusterState.CLUSTER_STATE_ACTIVE);
return ClusterStateFSM.ACTIVE;
}
@@ -246,11 +253,21 @@ public class ClusterImpl implements Clus
stateMachineInvoker.getAMBARIEventHandler().handle(
new ClusterEvent(ClusterEventType.STOP, this));
}
-
- @Override
- public void terminate() {
- stateMachineInvoker.getAMBARIEventHandler().handle(
- new ClusterEvent(ClusterEventType.RELEASE_NODES, this));
+
+ private void updateClusterState (String x) {
+ try {
+ ClusterState cs = this.cls.getClusterState();
+ cs.setLastUpdateTime(Util.getXMLGregorianCalendar(new Date()));
+ cs.setState(x);
+ this.cls.updateClusterState(cs);
+ } catch (Exception e) {
+ /*
+ * TODO: Handle the exception correctly. Should we bring down the controller?
+ */
+ System.out.println ("Unbale to update/persist the cluster state change. Shutting down the controller!");
+ e.printStackTrace();
+ System.exit(-1);
+ }
}
}
Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/resource/statemachine/FSMDriver.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/resource/statemachine/FSMDriver.java?rev=1221573&r1=1221572&r2=1221573&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/resource/statemachine/FSMDriver.java (original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/resource/statemachine/FSMDriver.java Wed Dec 21 02:46:52 2011
@@ -53,14 +53,6 @@ public class FSMDriver implements FSMDri
}
}
@Override
- public void deleteCluster(String clusterId) {
- ClusterFSM clusterFSM = clusters.remove(clusterId);
- if (clusterFSM != null) {
- clusterFSM.deactivate();
- clusterFSM.terminate();
- }
- }
- @Override
public String getClusterState(String clusterId,
long clusterDefinitionRev) {
ClusterFSM clusterFSM = clusters.get(clusterId);
Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/resource/statemachine/FSMDriverInterface.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/resource/statemachine/FSMDriverInterface.java?rev=1221573&r1=1221572&r2=1221573&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/resource/statemachine/FSMDriverInterface.java (original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/resource/statemachine/FSMDriverInterface.java Wed Dec 21 02:46:52 2011
@@ -33,8 +33,6 @@ public interface FSMDriverInterface {
public void stopCluster(String clusterId);
- public void deleteCluster(String clusterId);
-
public ClusterFSM getFSMClusterInstance(String clusterId);
public String getClusterState(String clusterId,
Modified: incubator/ambari/trunk/controller/src/test/java/org/apache/ambari/controller/TestFSMDriverImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/test/java/org/apache/ambari/controller/TestFSMDriverImpl.java?rev=1221573&r1=1221572&r2=1221573&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/test/java/org/apache/ambari/controller/TestFSMDriverImpl.java (original)
+++ incubator/ambari/trunk/controller/src/test/java/org/apache/ambari/controller/TestFSMDriverImpl.java Wed Dec 21 02:46:52 2011
@@ -50,12 +50,6 @@ class TestFSMDriverImpl implements FSMDr
}
@Override
- public void deleteCluster(String clusterId) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
public ClusterFSM getFSMClusterInstance(String clusterId) {
return clusterFsm;
}
Modified: incubator/ambari/trunk/controller/src/test/java/org/apache/ambari/controller/TestHeartbeat.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/test/java/org/apache/ambari/controller/TestHeartbeat.java?rev=1221573&r1=1221572&r2=1221573&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/test/java/org/apache/ambari/controller/TestHeartbeat.java (original)
+++ incubator/ambari/trunk/controller/src/test/java/org/apache/ambari/controller/TestHeartbeat.java Wed Dec 21 02:46:52 2011
@@ -396,12 +396,6 @@ public class TestHeartbeat {
}
@Override
- public void terminate() {
- // TODO Auto-generated method stub
-
- }
-
- @Override
public String getClusterState() {
// TODO Auto-generated method stub
return null;