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/10/25 22:27:06 UTC
svn commit: r1188890 - in /incubator/ambari/trunk: ./
client/src/main/java/org/apache/ambari/client/
client/src/main/java/org/apache/ambari/common/rest/entities/
controller/src/main/java/org/apache/ambari/controller/
controller/src/main/java/org/apache...
Author: vgogate
Date: Tue Oct 25 20:27:05 2011
New Revision: 1188890
URL: http://svn.apache.org/viewvc?rev=1188890&view=rev
Log:
AMBARI-101
Modified:
incubator/ambari/trunk/CHANGES.txt
incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/NodeList.java
incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/ClusterState.java
incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/Node.java
incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/NodeState.java
incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Cluster.java
incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Clusters.java
incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/HeartbeatHandler.java
incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Nodes.java
incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/ClusterResource.java
incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/NodesResource.java
Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1188890&r1=1188889&r2=1188890&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Tue Oct 25 20:27:05 2011
@@ -2,6 +2,8 @@ Ambari Change log
Release 0.1.0 - unreleased
+ AMBARI-101. Remove clusterID and use cluster name as unique ID for the cluster(vgogate)
+
AMBARI-100. Fixes the heartbeat to take into account install/uninstall
of components (ddas)
Modified: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/NodeList.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/NodeList.java?rev=1188890&r1=1188889&r2=1188890&view=diff
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/NodeList.java (original)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/client/NodeList.java Tue Oct 25 20:27:05 2011
@@ -164,7 +164,7 @@ public class NodeList extends Command {
System.out.println("[NAME]\t[LAST HEARTBEAT TIME]\t[NODE_SERVICES]\t[CLUSTER_ID]\n");
for (Node node : nodes ) {
String clusterID = "";
- if (node.getNodeState().getClusterID() != null) clusterID = node.getNodeState().getClusterID();
+ if (node.getNodeState().getClusterName() != null) clusterID = node.getNodeState().getClusterName();
System.out.println("["+node.getName()+"]\t"+
"["+node.getNodeState().getLastHeartbeatTime()+"]\t"+
"["+node.getNodeState().getNodeServers()+"]\t"+
Modified: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/ClusterState.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/ClusterState.java?rev=1188890&r1=1188889&r2=1188890&view=diff
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/ClusterState.java (original)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/ClusterState.java Tue Oct 25 20:27:05 2011
@@ -64,6 +64,22 @@ public class ClusterState {
@XmlAttribute
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar lastUpdateTime;
+ @XmlAttribute(required = true)
+ protected boolean markForDeletionWhenInAttic = false;
+
+ /**
+ * @return the markForDeletionWhenInAttic
+ */
+ public boolean isMarkForDeletionWhenInAttic() {
+ return markForDeletionWhenInAttic;
+ }
+
+ /**
+ * @param markForDeletionWhenInAttic the markForDeletionWhenInAttic to set
+ */
+ public void setMarkForDeletionWhenInAttic(boolean markForDeletionWhenInAttic) {
+ this.markForDeletionWhenInAttic = markForDeletionWhenInAttic;
+ }
/**
* @return the creationTime
Modified: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/Node.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/Node.java?rev=1188890&r1=1188889&r2=1188890&view=diff
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/Node.java (original)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/Node.java Tue Oct 25 20:27:05 2011
@@ -66,8 +66,8 @@ public class Node {
/*
* Reserving node for cluster is done by associating cluster name w/ node
*/
- public void reserveNodeForCluster (String clusterID, Boolean agentInstalled) {
- this.getNodeState().setClusterID(clusterID);
+ public void reserveNodeForCluster (String clusterName, Boolean agentInstalled) {
+ this.getNodeState().setClusterName(clusterName);
this.getNodeState().setAgentInstalled(agentInstalled);
this.getNodeState().setAllocatedToCluster(true);
}
Modified: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/NodeState.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/NodeState.java?rev=1188890&r1=1188889&r2=1188890&view=diff
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/NodeState.java (original)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/NodeState.java Tue Oct 25 20:27:05 2011
@@ -33,7 +33,7 @@ import javax.xml.datatype.XMLGregorianCa
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "NodeState", propOrder = {
- "clusterID",
+ "clusterName",
"allocatedToCluster",
"lastHeartbeatTime",
"agentInstalled",
@@ -52,8 +52,22 @@ public class NodeState {
*
*/
@XmlElement
- protected String clusterID;
+ protected String clusterName;
+ /**
+ * @return the clusterName
+ */
+ public String getClusterName() {
+ return clusterName;
+ }
+
+ /**
+ * @param clusterName the clusterName to set
+ */
+ public void setClusterName(String clusterName) {
+ this.clusterName = clusterName;
+ }
+
@XmlElement
protected Boolean agentInstalled = true;
@@ -152,19 +166,5 @@ public class NodeState {
public void setNodeServers(List<NodeServer> nodeServers) {
this.nodeServers = nodeServers;
}
-
- /**
- * @return the clusterID
- */
- public String getClusterID() {
- return clusterID;
- }
-
- /**
- * @param clusterID the clusterID to set
- */
- public void setClusterID(String clusterID) {
- this.clusterID = clusterID;
- }
}
Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Cluster.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Cluster.java?rev=1188890&r1=1188889&r2=1188890&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Cluster.java (original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Cluster.java Tue Oct 25 20:27:05 2011
@@ -33,7 +33,6 @@ import org.apache.ambari.components.impl
public class Cluster {
- protected String ID;
/*
* Latest revision of cluster definition
*/
@@ -56,19 +55,6 @@ public class Cluster {
private final Map<String, ComponentPlugin> plugins =
new HashMap<String, ComponentPlugin>();
- /**
- * @return the iD
- */
- public String getID() {
- return ID;
- }
-
- /**
- * @param iD the iD to set
- */
- public void setID(String iD) {
- ID = iD;
- }
/**
* @return the clusterDefinition
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=1188890&r1=1188889&r2=1188890&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 Tue Oct 25 20:27:05 2011
@@ -46,17 +46,6 @@ public class Clusters {
*/
protected ConcurrentHashMap<String, Cluster> operational_clusters = new ConcurrentHashMap<String, Cluster>();
- /*
- * Operational clusters ID to name map
- */
- protected ConcurrentHashMap<String, String> operational_clusters_id_to_name = new ConcurrentHashMap<String, String>();
-
- /*
- * List of clusters to be deleted when they get into ATTIC state
- * When cluster state is switched to ATTIC, if it is present in the tobe_deleted_list,
- * it should be deleted from the persistence list and inmemory list.
- */
- ConcurrentHashMap<String, String> tobe_deleted_clusters = new ConcurrentHashMap<String, String>();
private static Clusters ClustersTypeRef=null;
@@ -189,8 +178,6 @@ public class Clusters {
x.getLatestClusterDefinition().setName(new_name);
this.operational_clusters.remove(clusterName);
this.operational_clusters.put(new_name, x);
- this.operational_clusters_id_to_name.remove(x.getID());
- this.operational_clusters_id_to_name.put(x.getID(), new_name);
}
}
@@ -238,7 +225,6 @@ public class Clusters {
} else {
clsState.setState(ClusterDefinition.GOAL_STATE_INACTIVE);
}
- cls.setID(UUID.randomUUID().toString());
cls.addClusterDefinition(cdef);
cls.setClusterState(clsState);
@@ -257,7 +243,7 @@ public class Clusters {
*/
if (cdef.getNodes() != null
&& !cdef.getGoalState().equals(ClusterDefinition.GOAL_STATE_ATTIC)) {
- updateClusterNodesReservation (cls.getID(), cdef);
+ updateClusterNodesReservation (cls.getName(), cdef);
}
/*
@@ -284,7 +270,6 @@ public class Clusters {
// Add the cluster to the list, after definition is persisted
this.operational_clusters.put(cdef.getName(), cls);
- this.operational_clusters_id_to_name.put(cls.getID(), cdef.getName());
/*
* Activate the cluster if the goal state is ACTIVE
@@ -292,7 +277,7 @@ public class Clusters {
*/
if(cdef.getGoalState().equals(ClusterDefinition.GOAL_STATE_ACTIVE)) {
org.apache.ambari.resource.statemachine.ClusterFSM cs =
- StateMachineInvoker.createCluster(cls.getID(),cdef,cls.getClusterState());
+ StateMachineInvoker.createCluster(cls.getName(),cdef,cls.getClusterState());
}
}
return cdef;
@@ -391,7 +376,7 @@ public class Clusters {
/*
* Update the nodes associated with cluster
*/
- private synchronized void updateClusterNodesReservation (String clusterID, ClusterDefinition clsDef) throws Exception {
+ private synchronized void updateClusterNodesReservation (String clusterName, ClusterDefinition clsDef) throws Exception {
ConcurrentHashMap<String, Node> all_nodes = Nodes.getInstance().getNodes();
List<String> cluster_node_range = new ArrayList<String>();
@@ -403,8 +388,8 @@ public class Clusters {
*/
List<String> nodes_currently_allocated_to_cluster = new ArrayList<String>();
for (Node n : Nodes.getInstance().getNodes().values()) {
- if ( n.getNodeState().getClusterID() != null &&
- n.getNodeState().getClusterID().equals(clusterID)) {
+ if ( n.getNodeState().getClusterName() != null &&
+ n.getNodeState().getClusterName().equals(clusterName)) {
nodes_currently_allocated_to_cluster.add(n.getName());
}
}
@@ -420,7 +405,7 @@ public class Clusters {
List<String> preallocatedhosts = new ArrayList<String>();
for (String n : nodes_to_allocate) {
if (all_nodes.containsKey(n) &&
- (all_nodes.get(n).getNodeState().getClusterID() != null ||
+ (all_nodes.get(n).getNodeState().getClusterName() != null ||
all_nodes.get(n).getNodeState().getAllocatedToCluster()
)
) {
@@ -447,7 +432,7 @@ public class Clusters {
if (all_nodes.containsKey(node_name)) {
// Set the cluster name in the node
synchronized (all_nodes.get(node_name)) {
- all_nodes.get(node_name).reserveNodeForCluster(clusterID, true);
+ all_nodes.get(node_name).reserveNodeForCluster(clusterName, true);
}
} else {
Date epoch = new Date(0);
@@ -456,7 +441,7 @@ public class Clusters {
/*
* TODO: Set agentInstalled = true, unless controller uses SSH to setup the agent
*/
- node.reserveNodeForCluster(clusterID, true);
+ node.reserveNodeForCluster(clusterName, true);
}
}
@@ -478,8 +463,7 @@ public class Clusters {
* This function disassociate the node from the cluster. The clsuterID associated w/
* cluster will be reset by heart beat when node reports all clean.
*/
- public synchronized void releaseClusterNodes (String clusterID) throws Exception {
- String clusterName = this.getClusterByID(clusterID).getLatestClusterDefinition().getName();
+ public synchronized void releaseClusterNodes (String clusterName) throws Exception {
for (Node clusterNode : Nodes.getInstance().getClusterNodes (clusterName, "", "")) {
clusterNode.releaseNodeFromCluster();
}
@@ -517,7 +501,7 @@ public class Clusters {
for (String host : specified_node_range) {
if (Nodes.getInstance().getNodes().get(host).getNodeState().getNodeRoleNames() == null) {
Nodes.getInstance().getNodes().get(host).getNodeState().setNodeRoleNames((new ArrayList<String>()));
- String cid = Nodes.getInstance().getNodes().get(host).getNodeState().getClusterID();
+ String cid = Nodes.getInstance().getNodes().get(host).getNodeState().getClusterName();
Nodes.getInstance().getNodes().get(host).getNodeState().getNodeRoleNames().add(getDefaultRoleName(cid));
}
}
@@ -652,7 +636,7 @@ public class Clusters {
* Update the nodes reservation and node to roles association
*/
if (updateNodesReservation) {
- updateClusterNodesReservation (cls.getID(), c);
+ updateClusterNodesReservation (cls.getName(), c);
}
if (updateNodeToRolesAssociation) {
updateNodeToRolesAssociation(newcd.getNodes(), c.getRoleToNodes());
@@ -672,7 +656,7 @@ public class Clusters {
* Invoke state machine event
*/
ClusterFSM clusterFSM = StateMachineInvoker.
- getStateMachineClusterInstance(cls.getID());
+ getStateMachineClusterInstance(cls.getName());
if(c.getGoalState().equals(ClusterState.CLUSTER_STATE_ACTIVE)) {
clusterFSM.activate();
} else if(c.getGoalState().
@@ -705,7 +689,11 @@ public class Clusters {
cdf.setName(clusterName);
cdf.setGoalState(ClusterState.CLUSTER_STATE_ATTIC);
updateCluster(clusterName, cdf, false);
- this.tobe_deleted_clusters.put(clusterName, "null");
+ /* Update cluster state, mark it "to be deleted" when gets to ATTIC state
+ * TODO: PERSIST the new flag in the cluster state
+ */
+ cls.getClusterState().setMarkForDeletionWhenInAttic(true);
+
}
}
}
@@ -719,28 +707,6 @@ public class Clusters {
return this.operational_clusters.get(clusterName);
}
- /*
- * Get the cluster by ID
- */
- public Cluster getClusterByID(String clusterID) {
- String clusterName = this.operational_clusters_id_to_name.get(clusterID);
- if (clusterName != null) {
- return this.getClusterByName(clusterName);
- } else {
- return null;
- }
- }
-
- /*
- * Get cluster ID given cluster Name
- */
- public String getClusterIDByName (String clusterName) {
- if (this.operational_clusters.containsKey(clusterName)) {
- return this.operational_clusters.get(clusterName).getID();
- } else {
- return null;
- }
- }
/*
* Get the latest cluster definition
@@ -840,8 +806,8 @@ public class Clusters {
* has no specific role to nodes association specified in the cluster definition
* Throw exception if node is not associated to with any cluster
*/
- public String getDefaultRoleName(String clusterID) throws Exception {
- Cluster c = Clusters.getInstance().getClusterByID(clusterID);
+ public String getDefaultRoleName(String clusterName) throws Exception {
+ Cluster c = Clusters.getInstance().getClusterByName(clusterName);
// TODO: find the default role from the clsuter blueprint
return "slaves-role";
}
Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/HeartbeatHandler.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/HeartbeatHandler.java?rev=1188890&r1=1188889&r2=1188890&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/HeartbeatHandler.java (original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/HeartbeatHandler.java Tue Oct 25 20:27:05 2011
@@ -72,18 +72,18 @@ public class HeartbeatHandler {
String hostname = heartbeat.getHostname();
Date heartbeatTime = new Date(System.currentTimeMillis());
- String clusterId = null;
+ String clusterName = null;
long clusterRev = 0L;
Nodes.getInstance().checkAndUpdateNode(hostname, heartbeatTime);
List<Action> allActions = new ArrayList<Action>();
- clusterId = Nodes.getInstance().getNode(hostname)
- .getNodeState().getClusterID();
- if (clusterId != null) {
+ clusterName = Nodes.getInstance().getNode(hostname)
+ .getNodeState().getClusterName();
+ if (clusterName != null) {
clusterRev = Clusters.getInstance().
- getClusterByID(clusterId).getLatestRevision();
+ getClusterByName(clusterName).getLatestRevision();
}
ComponentAndRoleStates componentStates =
@@ -104,14 +104,14 @@ public class HeartbeatHandler {
//check whether this node is out-of-sync w.r.t what's running &
//installed, or is it compatible
if (!isCompatible(clusterIdAndRev.getClusterId(),
- clusterIdAndRev.getRevision(), clusterId, clusterRev)) {
+ clusterIdAndRev.getRevision(), clusterName, clusterRev)) {
createStopAndUninstallActions(componentStates, allActions,
clusterIdAndRev, true);
continue;
}
//get the cluster object corresponding to the clusterId
Cluster cluster = Clusters.getInstance()
- .getClusterByID(clusterIdAndRev.getClusterId());
+ .getClusterByName(clusterIdAndRev.getClusterId());
//get the state machine reference to the cluster
ClusterFSM clusterFsm = StateMachineInvoker
.getStateMachineClusterInstance(clusterIdAndRev.getClusterId());
@@ -151,20 +151,20 @@ public class HeartbeatHandler {
//send action for creating dir structure
Action action = new Action();
action.setKind(Kind.CREATE_STRUCTURE_ACTION);
- fillDetailsAndAddAction(action, allActions, clusterId,
+ fillDetailsAndAddAction(action, allActions, clusterName,
clusterRev, service.getServiceName(),
role.getRoleName());
//send action for installing the role
action = plugin.install(cluster.getName(),
role.getRoleName());
- fillDetailsAndAddAction(action, allActions, clusterId,
+ fillDetailsAndAddAction(action, allActions, clusterName,
clusterRev, service.getServiceName(),
role.getRoleName());
//send action for configuring
- action = plugin.configure(clusterId, role.getRoleName());
- fillDetailsAndAddAction(action, allActions, clusterId,
+ action = plugin.configure(clusterName, role.getRoleName());
+ fillDetailsAndAddAction(action, allActions, clusterName,
clusterRev, service.getServiceName(),
role.getRoleName());
continue;
@@ -179,7 +179,7 @@ public class HeartbeatHandler {
//TODO: keep track of retries (via checkActionResults)
Action action =
plugin.startServer(cluster.getName(), role.getRoleName());
- fillDetailsAndAddAction(action, allActions, clusterId,
+ fillDetailsAndAddAction(action, allActions, clusterName,
clusterRev, service.getServiceName(),
role.getRoleName());
}
@@ -203,7 +203,7 @@ public class HeartbeatHandler {
}
if (roleServerRunning) {
//TODO: keep track of retries (via checkActionResults)
- addAction(getStopRoleAction(clusterId,
+ addAction(getStopRoleAction(clusterName,
clusterRev,
role.getAssociatedService().getServiceName(),
role.getRoleName()), allActions);
@@ -219,7 +219,7 @@ public class HeartbeatHandler {
.equals(ClusterState.CLUSTER_STATE_ATTIC)) {
Action action = plugin.uninstall(cluster.getName(),
role.getRoleName());
- fillDetailsAndAddAction(action, allActions, clusterId,
+ fillDetailsAndAddAction(action, allActions, clusterName,
clusterRev,
role.getAssociatedService().getServiceName(),
role.getRoleName());
@@ -532,7 +532,7 @@ public class HeartbeatHandler {
for (AgentRoleState agentRoleState : agentRoleStates) {
componentServers.recordRoleState(heartbeat.getHostname(),agentRoleState);
Cluster c = Clusters.getInstance().
- getClusterByID(agentRoleState.getClusterId());
+ getClusterByName(agentRoleState.getClusterId());
clustersNodeBelongsTo.add(c);
}
checkActionResults(heartbeat, componentServers);
Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Nodes.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Nodes.java?rev=1188890&r1=1188889&r2=1188890&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Nodes.java (original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/Nodes.java Tue Oct 25 20:27:05 2011
@@ -110,10 +110,6 @@ public class Nodes {
list.add(this.nodes.get(host));
}
}
- if (list.isEmpty()) {
- String msg = "No nodes found!";
- throw new WebApplicationException((new ExceptionResponse(msg, Response.Status.NO_CONTENT)).get());
- }
return list;
}
Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/ClusterResource.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/ClusterResource.java?rev=1188890&r1=1188889&r2=1188890&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/ClusterResource.java (original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/ClusterResource.java Tue Oct 25 20:27:05 2011
@@ -53,14 +53,13 @@ import org.apache.ambari.controller.Node
public class ClusterResource {
/**
- * Get the information of specified Hadoop cluster. Information includes Cluster definition
- * and the cluster state
+ * Get the information of a specified Hadoop Cluster. Information includes Cluster definition
+ * and the cluster state.
*
- * @response.representation.200.doc Get the definition & current state of the specified
- * Hadoop cluster
+ * @response.representation.200.doc Get the definition & current state of the specified Hadoop cluster
* @response.representation.200.mediaType application/json
* @response.representation.404.doc Specified cluster does not exist
- * @response.representation.200.doc.example
+ * @response.representation.200.example ClusterInformation {@link http://www.apple.com/}
{
"definition":{
"@name":"blue.dev.Cluster123",
@@ -118,9 +117,8 @@ public class ClusterResource {
* @response.representation.200.mediaType application/json
* @response.representation.400.doc Bad request (See "ErrorMessage" in the response
* http header describing specific error condition).
- * @response.representgation.404.doc Cluster does not exist
- *
- * @response.representation.example
+ * @response.representation.404.doc Cluster does not exist
+ * @response.representation.200.example
{
"definition":{
"@name":"blue.dev.Cluster123",
@@ -192,7 +190,7 @@ public class ClusterResource {
@PUT
@Consumes({"application/json", "application/xml"})
@Path(value = "/rename")
- public void updateClusterDefinition(
+ public void renameCluster(
@PathParam("clusterName") String clusterName,
@DefaultValue("") @QueryParam("new_name") String new_name) throws Exception {
try {
@@ -246,10 +244,8 @@ public class ClusterResource {
* "ATTIC" : Only cluster definition is available. No nodes are
* reserved for the cluster in this state.
* @response.representation.200.mediaType application/json
- * @response.representgation.404.doc Cluster does not exist
- * @response.representation.200.example
- *
- {
+ * @response.representation.404.doc Cluster does not exist
+ * @response.representation.200.example {
"state":{
"@state":"ATTIC",
"@creationTime":"2011-10-20T11:35:06.687-07:00",
@@ -342,7 +338,13 @@ public class ClusterResource {
@DefaultValue("") @QueryParam("role") String role,
@DefaultValue("") @QueryParam("alive") String alive) throws Exception {
try {
- return Nodes.getInstance().getClusterNodes(clusterName, role, alive);
+ List<Node> list = Nodes.getInstance().getClusterNodes(clusterName, role, alive);
+
+ if (list.isEmpty()) {
+ String msg = "No nodes found!";
+ throw new WebApplicationException((new ExceptionResponse(msg, Response.Status.NO_CONTENT)).get());
+ }
+ return list;
}catch (WebApplicationException we) {
throw we;
}catch (Exception e) {
@@ -441,7 +443,7 @@ public class ClusterResource {
@Path(value = "/blueprint")
@GET
@Produces({"application/json", "application/xml"})
- public Blueprint getBlueprint (@PathParam("clusterName") String clusterName,
+ public Blueprint getClusterBlueprint (@PathParam("clusterName") String clusterName,
@DefaultValue("true") @QueryParam("expanded") boolean expanded) throws Exception {
try {
return Clusters.getInstance().getClusterBlueprint(clusterName, expanded);
Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/NodesResource.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/NodesResource.java?rev=1188890&r1=1188889&r2=1188890&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/NodesResource.java (original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/rest/resources/NodesResource.java Tue Oct 25 20:27:05 2011
@@ -51,7 +51,7 @@ public class NodesResource {
*/
@GET
@Produces({"application/json", "application/xml"})
- public List<Node> getNodes (@DefaultValue("") @QueryParam("allocated") String allocated,
+ public List<Node> getNodesList (@DefaultValue("") @QueryParam("allocated") String allocated,
@DefaultValue("") @QueryParam("alive") String alive) throws Exception {
try {
return Nodes.getInstance().getNodesByState(allocated, alive);