From: <st...@us...> - 2009-10-29 17:39:49
|
Revision: 8004 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=8004&view=rev Author: steve_l Date: 2009-10-29 17:39:37 +0000 (Thu, 29 Oct 2009) Log Message: ----------- SFOS-1310 fixing role information to propagate, adding page to list them Modified Paths: -------------- trunk/core/components/cloudfarmer/site/WEB-INF/struts-config.xml trunk/core/components/cloudfarmer/site/WEB-INF/tiles-defs.xml trunk/core/components/cloudfarmer/site/index.jsp trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/api/ClusterNode.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/AbstractClusterAction.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/ClusterListHostsInRoleAction.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/deploy/components.sf trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/model/cluster/DynamicSmartFrogClusterController.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/model/cluster/HostInstance.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/model/cluster/HostInstanceList.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/common/AbstractFarmNodeClusterFarmer.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/mock/MockClusterFarmerImpl.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/mock/components.sf trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/cluster/ClusterWebappTest.java trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/cluster/components.sf trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/workflow/WorkflowWebappTest.java trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/workflow/components.sf trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/mock/MockFarmerUnitTest.java Added Paths: ----------- trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/cluster_list_in_role.jsp trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/cluster/testClusterView.sf trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/workflow/testWorkflowView.sf Modified: trunk/core/components/cloudfarmer/site/WEB-INF/struts-config.xml =================================================================== --- trunk/core/components/cloudfarmer/site/WEB-INF/struts-config.xml 2009-10-29 16:47:42 UTC (rev 8003) +++ trunk/core/components/cloudfarmer/site/WEB-INF/struts-config.xml 2009-10-29 17:39:37 UTC (rev 8004) @@ -162,6 +162,7 @@ <forward name="failure" path="portlet.mombasa.cluster.error"/> <forward name="bindFailure" path="portlet.mombasa.cluster.bindFailure"/> </action> + <action path="/mombasa-portlet/cluster/add" type="org.smartfrog.services.cloudfarmer.client.web.actions.cluster.ClusterAddNodeAction"> <forward name="add.dynamic.node" path="portlet.mombasa.cluster.add_dynamic.success" redirect="true"/> Modified: trunk/core/components/cloudfarmer/site/WEB-INF/tiles-defs.xml =================================================================== --- trunk/core/components/cloudfarmer/site/WEB-INF/tiles-defs.xml 2009-10-29 16:47:42 UTC (rev 8003) +++ trunk/core/components/cloudfarmer/site/WEB-INF/tiles-defs.xml 2009-10-29 17:39:37 UTC (rev 8004) @@ -129,9 +129,9 @@ <definition name="portlet.mombasa.cluster.list.in.role.success" extends="portlet.mombasa.cluster.list"> <put name="title" value="Hosts in Role"/> + <put name="content" value="/html/mombasa-portlet/cluster/cluster_list_in_role.jsp"/> </definition> - <definition name="portlet.mombasa.cluster.add.success" extends="portlet.mombasa.cluster.text"> <put name="title" value="Add a host"/> <put name="text" value="TODO"/> Copied: trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/cluster_list_in_role.jsp (from rev 7995, trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/cluster_list.jsp) =================================================================== --- trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/cluster_list_in_role.jsp (rev 0) +++ trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/cluster_list_in_role.jsp 2009-10-29 17:39:37 UTC (rev 8004) @@ -0,0 +1,77 @@ +<%-- +/** (C) Copyright 2009 Hewlett-Packard Development Company, LP + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +For more information: www.smartfrog.org + +*/ +--%> +<%@ include file="/html/mombasa-portlet/cluster/init.jsp" %> + +<tiles:useAttribute id="text" name="text" classname="java.lang.String" ignore="true"/> + +<div> +<%= text %> +</div> +<div> +Total humber of hosts in role <bean:write name="role" /> : <bean:write name="hostcount"/> +</div> +<table border="0"> + <tr bgcolor="grey"> + <th>Hostname</th> + <th style="padding-left: 10px;"></th> + <th>Application</th> + <th style="padding-left: 10px;"></th> + <th>Role</th> + <th style="padding-left: 10px;"></th> + <th>Description</th> + </tr> + <logic:iterate id="host" + name="hosts" + property="list" + type="org.smartfrog.services.cloudfarmer.client.web.model.cluster.HostInstance"> + <tr> + <td> + <html:link action="/mombasa-portlet/cluster/viewhost" + paramId="hostid" paramName="host" paramProperty="id"> + <bean:write name="host" property="hostname"/> + </html:link> + </td> + <td style="padding-left: 10px;"></td> + <td><bean:write name="host" property="application"/></td> + <td style="padding-left: 10px;"></td> + <td> + <logic:notEmpty name="host" property="role"> + <bean:write name="host" property="role"/> + </logic:notEmpty> + </td> + <td style="padding-left: 10px;"></td> + <td> + <logic:notEmpty name="host" property="application"> + <logic:notEmpty name="host" property="application.description"> + <bean:write name="host" property="application.description"/> + </logic:notEmpty> + </logic:notEmpty> + </td> + </tr> + </logic:iterate> +</table> + + + + + + Modified: trunk/core/components/cloudfarmer/site/index.jsp =================================================================== --- trunk/core/components/cloudfarmer/site/index.jsp 2009-10-29 16:47:42 UTC (rev 8003) +++ trunk/core/components/cloudfarmer/site/index.jsp 2009-10-29 17:39:37 UTC (rev 8004) @@ -11,13 +11,13 @@ Mombasa is the way to see the elephants <h2>Cluster</h2> <ul> - <li><a href="/html/mombasa-portlet/cluster/cluster_nav.jsp">Cluster Links</a></li> + <li><a href="/mombasa-portlet/cluster/view.do">Cluster Links</a></li> <li><a href="/mombasa-portlet/cluster/list.do">List the cluster</a></li> </ul> <h2>Workflow</h2> <ul> - <li><a href="/html/mombasa-portlet/nav.jsp">Workflow Links</a></li> + <li><a href="/mombasa-portlet/view.do">Workflow Links</a></li> <li><a href="/mombasa-portlet/workflowList.do">List the workflow</a></li> </ul> Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/api/ClusterNode.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/api/ClusterNode.java 2009-10-29 16:47:42 UTC (rev 8003) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/api/ClusterNode.java 2009-10-29 17:39:37 UTC (rev 8004) @@ -131,6 +131,15 @@ this.externalHostname = externalHostname; } + /** + * check for being in a role; the node role can be null + * @param roleToCheck the non-null role to check + * @return true iff the two role strings are equal + */ + public boolean isInRole(String roleToCheck) { + return roleToCheck.equals(role); + } + public String getRole() { return role; } Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/AbstractClusterAction.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/AbstractClusterAction.java 2009-10-29 16:47:42 UTC (rev 8003) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/AbstractClusterAction.java 2009-10-29 17:39:37 UTC (rev 8004) @@ -177,6 +177,10 @@ */ protected void addHostAttributes(HttpServletRequest request, ClusterController controller) { HostInstanceList hosts = controller.getHosts(); + addHostAttributes(request, hosts); + } + + protected void addHostAttributes(HttpServletRequest request, HostInstanceList hosts) { request.setAttribute(ATTR_HOSTS, hosts); request.setAttribute(ATTR_HOSTCOUNT, hosts.size()); } Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/ClusterListHostsInRoleAction.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/ClusterListHostsInRoleAction.java 2009-10-29 16:47:42 UTC (rev 8003) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/ClusterListHostsInRoleAction.java 2009-10-29 17:39:37 UTC (rev 8004) @@ -73,7 +73,7 @@ //get the values addClusterAttributes(request, controller); HostInstanceList hosts = hostsInRole(request, controller); - request.setAttribute(ATTR_HOSTS, hosts); + addHostAttributes(request, hosts); return success(mapping); } catch (Exception e) { return failure(request, mapping, "Failed to list roles and hosts :" + e, e); Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/deploy/components.sf =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/deploy/components.sf 2009-10-29 16:47:42 UTC (rev 8003) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/deploy/components.sf 2009-10-29 17:39:37 UTC (rev 8004) @@ -143,8 +143,8 @@ //struts actions; will only work if JSP and struts are happy - - workflowList ( actionRoot ++ "workflowList.do"); + workflowView (actionRoot ++ "view.do"); + workflowList (actionRoot ++ "workflowList.do"); submitMRJob (actionRoot ++ "submitMRJob/view.do"); //http://localhost:8081/mombasa-portlet/submitTool/view.do submitTool (actionRoot ++ "submitTool/view.do"); @@ -160,16 +160,16 @@ */ ClusterActions extends StrutsActions { cluster "/mombasa-portlet/cluster/"; - - add ( cluster ++ "add.do"); - admin ( cluster ++ "admin.do"); - list ( cluster ++ "list.do"); + view (cluster ++ "view.do"); + add (cluster ++ "add.do"); + admin (cluster ++ "admin.do"); + list (cluster ++ "list.do"); ///mombasa-portlet/cluster/listbyRole - listRoles ( cluster ++ "listRoles.do"); - listInRole ( cluster ++ "listInRole.do"); - terminate ( cluster ++ "terminate.do"); - change_manager ( cluster ++ "change_manager.do"); - viewhost ( cluster ++ "viewhost.do"); + listRoles (cluster ++ "listRoles.do"); + listInRole (cluster ++ "listInRole.do"); + terminate (cluster ++ "terminate.do"); + change_manager (cluster ++ "change_manager.do"); + viewhost (cluster ++ "viewhost.do"); } Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/model/cluster/DynamicSmartFrogClusterController.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/model/cluster/DynamicSmartFrogClusterController.java 2009-10-29 16:47:42 UTC (rev 8003) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/model/cluster/DynamicSmartFrogClusterController.java 2009-10-29 17:39:37 UTC (rev 8004) @@ -207,11 +207,9 @@ public HostInstanceList createHosts(String role, int min, int max) throws IOException, SmartFrogException { ClusterNode[] clusterNodes = farmer.create(role, min, max); - HostInstanceList newHostList = new HostInstanceList(clusterNodes.length); + HostInstanceList newHostList = new HostInstanceList(clusterNodes); synchronized (this) { - for (ClusterNode node : clusterNodes) { - HostInstance instance = new HostInstance(node.getId(), node.getHostname(), true); - newHostList.add(instance); + for(HostInstance instance:newHostList) { addHostInstance(instance); } } Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/model/cluster/HostInstance.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/model/cluster/HostInstance.java 2009-10-29 16:47:42 UTC (rev 8003) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/model/cluster/HostInstance.java 2009-10-29 17:39:37 UTC (rev 8004) @@ -93,6 +93,7 @@ return "HostInstance{" + "id='" + id + '\'' + ", hostname='" + hostname + '\'' + + ", role='" + role + '\'' + ", canDelete=" + canDelete + '}'; } Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/model/cluster/HostInstanceList.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/model/cluster/HostInstanceList.java 2009-10-29 16:47:42 UTC (rev 8003) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/model/cluster/HostInstanceList.java 2009-10-29 17:39:37 UTC (rev 8004) @@ -19,6 +19,8 @@ */ package org.smartfrog.services.cloudfarmer.client.web.model.cluster; +import org.smartfrog.services.cloudfarmer.api.ClusterNode; + import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -40,6 +42,12 @@ super(c); } + public HostInstanceList(ClusterNode[] clusterNodes) { + super(clusterNodes.length); + importNodes(clusterNodes); + } + + /** * for struts integration * @return list of host instances @@ -48,10 +56,15 @@ return this; } + /** + * Get a list of all hosts in a role + * @param role role to search for + * @return the list of hosts in that role, may be empty + */ public List<HostInstance> getListInRole(String role) { List<HostInstance> results = new ArrayList<HostInstance>(); for (HostInstance instance : this) { - if (instance.isMaster()) { + if (role.equals(instance.getRole())) { results.add(instance); } } @@ -66,4 +79,13 @@ return null; } } + + public void importNodes(ClusterNode[] clusterNodes) { + synchronized (this) { + for (ClusterNode node : clusterNodes) { + HostInstance instance = new HostInstance(node.getId(), node, true); + add(instance); + } + } + } } Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/common/AbstractFarmNodeClusterFarmer.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/common/AbstractFarmNodeClusterFarmer.java 2009-10-29 16:47:42 UTC (rev 8003) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/common/AbstractFarmNodeClusterFarmer.java 2009-10-29 17:39:37 UTC (rev 8004) @@ -24,7 +24,6 @@ import org.smartfrog.services.cloudfarmer.api.NoClusterSpaceException; import org.smartfrog.services.cloudfarmer.api.Range; import org.smartfrog.services.cloudfarmer.api.UnsupportedClusterRoleException; -import org.smartfrog.services.cloudfarmer.server.common.AbstractClusterFarmer; import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.common.SmartFrogRuntimeException; @@ -44,21 +43,10 @@ public abstract class AbstractFarmNodeClusterFarmer extends AbstractClusterFarmer { protected Map<String, FarmNode> nodeFarm; - public AbstractFarmNodeClusterFarmer() throws RemoteException { + protected AbstractFarmNodeClusterFarmer() throws RemoteException { } /** - * Resolve the cluster limit - * - * @throws SmartFrogException - * @throws RemoteException - */ - @Override - public synchronized void sfStart() throws SmartFrogException, RemoteException { - super.sfStart(); - } - - /** * Build the node farm * * @throws RemoteException network problems @@ -294,11 +282,21 @@ } /** - * {@inheritDoc} - * + * Check for the cluster being available before working with it, throw something if it + * is not considered live * @throws IOException IO/network problems * @throws SmartFrogException other problems */ + protected void checkClusterAvailable() throws IOException, SmartFrogException{ + + } + + /** + * {@inheritDoc} + * + * @throws IOException IO/network problems + * @throws SmartFrogException other problems + */ @Override public synchronized ClusterNode[] create(String role, int min, int max) throws IOException, SmartFrogException { validateClusterRange(min, max); @@ -311,6 +309,7 @@ if (info == null) { throw new UnsupportedClusterRoleException(role, this); } + checkClusterAvailable(); //get the number of nodes already in that role int nodesInRole = nodesInRole(role); Range roleRange = info.getRoleSize(); Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/mock/MockClusterFarmerImpl.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/mock/MockClusterFarmerImpl.java 2009-10-29 16:47:42 UTC (rev 8003) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/mock/MockClusterFarmerImpl.java 2009-10-29 17:39:37 UTC (rev 8004) @@ -26,11 +26,13 @@ import org.smartfrog.services.cloudfarmer.server.common.AbstractFarmNodeClusterFarmer; import org.smartfrog.services.cloudfarmer.server.common.FarmNode; import org.smartfrog.sfcore.common.SmartFrogException; +import org.smartfrog.sfcore.common.SmartFrogDeploymentException; import org.smartfrog.sfcore.reference.HereReferencePart; import org.smartfrog.sfcore.reference.Reference; import java.rmi.RemoteException; import java.util.HashMap; +import java.io.IOException; /** * This is a mock cluster, very simple. A counter tracks the number of machines allocated, and whenever you ask for new @@ -40,18 +42,23 @@ public class MockClusterFarmerImpl extends AbstractFarmNodeClusterFarmer implements ClusterFarmer { - private String domain = "internal"; - private String externalDomain = "external"; - /** * {@value} */ public static final String ATTR_DOMAIN = "domain"; + /** * {@value} */ public static final String ATTR_EXTERNAL_DOMAIN = "externalDomain"; + /** + * {@value} + */ + public static final String ATTR_AVAILABLE = "available"; + private String domain = "internal"; + private String externalDomain = "external"; + private boolean available = true; public MockClusterFarmerImpl() throws RemoteException { } @@ -66,6 +73,7 @@ super.sfStart(); domain = sfResolve(ATTR_DOMAIN, "", true); externalDomain = sfResolve(ATTR_EXTERNAL_DOMAIN, "", true); + available = sfResolve(ATTR_AVAILABLE, true, true); resolveClusterLimit(); sfLog().info("Creating Farmer with a limit of " + clusterLimit); buildRoleMap(); @@ -125,5 +133,21 @@ roleInfoMap.put(role, roleInfo); } + /** + * {@inheritDoc} + */ + @Override + public boolean isFarmerAvailable() throws IOException, SmartFrogException { + return available; + } + /** + * {@inheritDoc} + */ + @Override + protected void checkClusterAvailable() throws IOException, SmartFrogException { + if(!available) { + throw new SmartFrogDeploymentException("Cluster is not available"); + } + } } Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/mock/components.sf =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/mock/components.sf 2009-10-29 16:47:42 UTC (rev 8003) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/mock/components.sf 2009-10-29 17:39:37 UTC (rev 8004) @@ -51,4 +51,7 @@ //delay per node nodeStartupDelayMilliseconds 0; + + //is the cluster actually available + available true; } Modified: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/cluster/ClusterWebappTest.java =================================================================== --- trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/cluster/ClusterWebappTest.java 2009-10-29 16:47:42 UTC (rev 8003) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/cluster/ClusterWebappTest.java 2009-10-29 17:39:37 UTC (rev 8004) @@ -16,6 +16,10 @@ expectSuccessfulTestRunOrSkip(FILES, "testClusterList"); } + public void testClusterView() throws Throwable { + expectSuccessfulTestRunOrSkip(FILES, "testClusterView"); + } + public void testClusterListRoles() throws Throwable { expectSuccessfulTestRunOrSkip(FILES, "testClusterListRoles"); } @@ -23,6 +27,7 @@ public void listInRole() throws Throwable { expectSuccessfulTestRunOrSkip(FILES, "testClusterListInRole"); } + public void testClusterAdd() throws Throwable { expectSuccessfulTestRunOrSkip(FILES, "testClusterAdd"); } Modified: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/cluster/components.sf =================================================================== --- trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/cluster/components.sf 2009-10-29 16:47:42 UTC (rev 8003) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/cluster/components.sf 2009-10-29 17:39:37 UTC (rev 8004) @@ -48,6 +48,10 @@ tests:wait:queries [ ["role", role] ]; } +testClusterView extends testForPage { + page ClusterActions:view; +} + testClusterAdmin extends testForPage { page ClusterActions:admin; } Copied: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/cluster/testClusterView.sf (from rev 8001, trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/cluster/testClusterListInRole.sf) =================================================================== --- trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/cluster/testClusterView.sf (rev 0) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/cluster/testClusterView.sf 2009-10-29 17:39:37 UTC (rev 8004) @@ -0,0 +1,22 @@ +/** (C) Copyright 2009 Hewlett-Packard Development Company, LP + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + For more information: www.smartfrog.org + + */ +#include "/org/smartfrog/services/cloudfarmer/test/client/web/cluster/components.sf" + +sfConfig extends testClusterView; \ No newline at end of file Modified: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/workflow/WorkflowWebappTest.java =================================================================== --- trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/workflow/WorkflowWebappTest.java 2009-10-29 16:47:42 UTC (rev 8003) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/workflow/WorkflowWebappTest.java 2009-10-29 17:39:37 UTC (rev 8004) @@ -16,6 +16,10 @@ expectSuccessfulTestRunOrSkip(FILES, "testWebappHappy"); } + public void testWorkflowView() throws Throwable { + expectSuccessfulTestRunOrSkip(FILES, "testWorkflowView"); + } + public void testWorkflowList() throws Throwable { expectSuccessfulTestRunOrSkip(FILES, "testWorkflowList"); } Modified: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/workflow/components.sf =================================================================== --- trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/workflow/components.sf 2009-10-29 16:47:42 UTC (rev 8003) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/workflow/components.sf 2009-10-29 17:39:37 UTC (rev 8004) @@ -28,6 +28,9 @@ page WorkflowActions:webappHappy; } +testWorkflowView extends testForPage { + page WorkflowActions:workflowView; +} testWorkflowList extends testForPage { page WorkflowActions:workflowList; @@ -51,4 +54,5 @@ testWorkflowServerHappy extends testForPage { page WorkflowActions:workflowServerHappy; -} \ No newline at end of file +} + Copied: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/workflow/testWorkflowView.sf (from rev 7995, trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/workflow/testWorkflowList.sf) =================================================================== --- trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/workflow/testWorkflowView.sf (rev 0) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/workflow/testWorkflowView.sf 2009-10-29 17:39:37 UTC (rev 8004) @@ -0,0 +1,22 @@ +/** (C) Copyright 2009 Hewlett-Packard Development Company, LP + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + For more information: www.smartfrog.org + + */ +#include "/org/smartfrog/services/cloudfarmer/test/client/web/workflow/components.sf" + +sfConfig extends testWorkflowView; \ No newline at end of file Modified: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/mock/MockFarmerUnitTest.java =================================================================== --- trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/mock/MockFarmerUnitTest.java 2009-10-29 16:47:42 UTC (rev 8003) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/mock/MockFarmerUnitTest.java 2009-10-29 17:39:37 UTC (rev 8004) @@ -6,9 +6,12 @@ import org.smartfrog.services.cloudfarmer.api.NoClusterSpaceException; import org.smartfrog.services.cloudfarmer.api.UnsupportedClusterRoleException; import org.smartfrog.services.cloudfarmer.server.mock.MockClusterFarmerImpl; +import org.smartfrog.services.cloudfarmer.client.web.model.cluster.HostInstanceList; +import org.smartfrog.services.cloudfarmer.client.web.model.cluster.HostInstance; import org.smartfrog.sfcore.common.SmartFrogException; import java.io.IOException; +import java.util.List; /** * This walks the mock farmer through its life @@ -34,7 +37,7 @@ worker.setRoleSize(1, 100); addTestRoles(); } - + private void assertInRole(ClusterNode node, String role) { assertNotNull(node); assertEquals(role, node.getRole()); @@ -140,11 +143,49 @@ listed = farmer.list(role); assertEquals("Expected to find " + expected + " nodes of role '" + role + "' but got " + listed.length, expected, listed.length); - for (int i=0; i< expected; i++) { + for (int i = 0; i < expected; i++) { ClusterNode node = listed[i]; - assertEquals(" Node " + i + " with value "+node +" is not a "+role, role, node.getRole()); + assertEquals(" Node " + i + " with value " + node + " is not a " + role, role, node.getRole()); } return listed; } + /** + * Test that the list of roles works + * @throws Throwable on failure + */ + public void testListReturnsRoles() throws Throwable { + int clusterSize = 3; + ClusterNode[] clusterNodes = createSmallHadoopCluster(clusterSize); + int workers = 0; + int masters = 0; + for (ClusterNode cn : clusterNodes) { + if (cn.isInRole(MASTER)) masters++; + if (cn.isInRole(WORKER)) workers++; + } + assertEquals("One master", 1, masters); + assertEquals("workers", clusterSize, workers); + } + + private ClusterNode[] createSmallHadoopCluster(int clusterSize) throws IOException, SmartFrogException { + ClusterNode[] first = farmer.create(MASTER, 1, 1); + assertEquals(1, first.length); + assertInRole(first[0], MASTER); + ClusterNode[] nodes = farmer.create(WORKER, clusterSize, clusterSize); + assertEquals(clusterSize, nodes.length); + ClusterNode[] clusterNodes = farmer.list(); + return clusterNodes; + } + + public void testHostInstanceListPropagatesRoles() throws Throwable { + int clusterSize = 3; + ClusterNode[] clusterNodes = createSmallHadoopCluster(clusterSize); + HostInstanceList hil= new HostInstanceList(clusterNodes); + List<HostInstance> masters = hil.getListInRole(MASTER); + List<HostInstance> workers = hil.getListInRole(WORKER); + assertEquals(clusterSize, workers.size()); + assertEquals(1, masters.size()); + + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |