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/09/30 02:51:01 UTC
svn commit: r1177471 - in
/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller:
Nodes.java rest/resources/ClusterResource.java
Author: vgogate
Date: Fri Sep 30 00:51:01 2011
New Revision: 1177471
URL: http://svn.apache.org/viewvc?rev=1177471&view=rev
Log:
AMBARI-20
Modified:
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
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=1177471&r1=1177470&r2=1177471&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 Fri Sep 30 00:51:01 2011
@@ -95,7 +95,7 @@ public class Nodes {
if (!n.getNodeState().getNodeRoleNames().contains(roleName)) { continue; }
}
- // TODO: If heartbeat is null
+ // TODO: If heartbeat is null? It is set to epoch during node initialization.
GregorianCalendar cal = new GregorianCalendar();
cal.setTime(new Date());
@@ -105,6 +105,10 @@ 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=1177471&r1=1177470&r2=1177471&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 Fri Sep 30 00:51:01 2011
@@ -198,7 +198,7 @@ public class ClusterResource {
* <p>
*
* @param clusterName Name of the cluster; Each cluster is identified w/ unique name
- * @param roleName Optionally specify the role name to get the nodes associated with the service role
+ * @param role Optionally specify the role name to get the nodes associated with the service role
* @param alive Boolean value to specify, if nodes to be returned are alive or dead or both (if alive is set to null)
* @return List of nodes
* @throws Exception throws Exception
@@ -207,8 +207,14 @@ public class ClusterResource {
@GET
@Produces({"application/json", "application/xml"})
public List<Node> getNodes (@PathParam("clusterName") String clusterName,
- @DefaultValue("") @QueryParam("roleName") String roleName,
- @DefaultValue("") @QueryParam("alive") boolean alive) throws Exception {
- return Nodes.getInstance().getClusterNodes(clusterName, roleName, alive);
+ @DefaultValue("") @QueryParam("role") String role,
+ @DefaultValue("") @QueryParam("alive") boolean alive) throws Exception {
+ try {
+ return Nodes.getInstance().getClusterNodes(clusterName, role, alive);
+ }catch (WebApplicationException we) {
+ throw we;
+ }catch (Exception e) {
+ throw new WebApplicationException((new ExceptionResponse(e)).get());
+ }
}
}