From: <st...@us...> - 2010-01-14 17:09:28
|
Revision: 8140 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=8140&view=rev Author: steve_l Date: 2010-01-14 17:09:20 +0000 (Thu, 14 Jan 2010) Log Message: ----------- SFOS-1409 added support for direct role creation. Does not work perfectly Modified Paths: -------------- trunk/core/components/cloudfarmer/site/WEB-INF/tiles-defs.xml 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 trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/cluster_list_roles.jsp trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/create_role_instance.jsp trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/template.jsp 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/AbstractStrutsAction.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/ClusterRequestAttributes.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/CreateRoleInstanceAction.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/CreateRoleInstanceProcessAction.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/forms/cluster/ClusterCreateRoleInstanceForm.java Added Paths: ----------- trunk/core/components/cloudfarmer/site/html/mombasa-portlet/style.css Modified: trunk/core/components/cloudfarmer/site/WEB-INF/tiles-defs.xml =================================================================== --- trunk/core/components/cloudfarmer/site/WEB-INF/tiles-defs.xml 2010-01-14 16:59:19 UTC (rev 8139) +++ trunk/core/components/cloudfarmer/site/WEB-INF/tiles-defs.xml 2010-01-14 17:09:20 UTC (rev 8140) @@ -222,7 +222,7 @@ <definition name="portlet.mombasa.cluster.host_terminate.success" extends="portlet.mombasa.cluster.text"> <put name="title" value="Shut down the host"/> - <put name="text" value="This is not yet implemented"/> + <put name="text" value="The host has been terminated"/> </definition> <definition name="portlet.mombasa.cluster.diagnostics.success" extends="portlet.mombasa.cluster"> Modified: trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/cluster_list.jsp =================================================================== --- trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/cluster_list.jsp 2010-01-14 16:59:19 UTC (rev 8139) +++ trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/cluster_list.jsp 2010-01-14 17:09:20 UTC (rev 8140) @@ -33,10 +33,10 @@ <th style="padding-left: 10px;"></th> <th>Hostname</th> <th style="padding-left: 10px;"></th> + <th>Role</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" @@ -58,14 +58,14 @@ </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><bean:write name="host" property="application"/></td> + <td style="padding-left: 10px;"></td> <td> <logic:notEmpty name="host" property="application"> <logic:notEmpty name="host" property="application.description"> @@ -85,7 +85,7 @@ <td style="padding-left: 10px;"></td> <td><bean:write name="hostcount"/></td> </tr> - <tr > +<%-- <tr > <td>Master</td> <td style="padding-left: 10px;"></td> <td> @@ -93,12 +93,14 @@ <bean:write name="cluster.master.hostname"/> </logic:notEmpty> </td> - </tr> + </tr> --%> +<%-- <tr > <td>Controller</td> <td style="padding-left: 10px;"></td> <td><bean:write name="cluster.controller" property="description"/></td> </tr> +--%> Modified: trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/cluster_list_in_role.jsp =================================================================== --- trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/cluster_list_in_role.jsp 2010-01-14 16:59:19 UTC (rev 8139) +++ trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/cluster_list_in_role.jsp 2010-01-14 17:09:20 UTC (rev 8140) @@ -68,6 +68,15 @@ </td> </tr> </logic:iterate> + <tr> + <td> + <html:link action="/mombasa-portlet/cluster/create_role_instance" + paramId="role" paramName="role" > + Add + <bean:write name="role" /> + </html:link> + </td> + </tr> </table> Modified: trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/cluster_list_roles.jsp =================================================================== --- trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/cluster_list_roles.jsp 2010-01-14 16:59:19 UTC (rev 8139) +++ trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/cluster_list_roles.jsp 2010-01-14 17:09:20 UTC (rev 8140) @@ -36,6 +36,8 @@ <th>Size</th> <th style="padding-left: 10px;"></th> <th>Recommended</th> + <th style="padding-left: 10px;"></th> + <th>Add</th> </tr> <logic:iterate id="role" name="cluster.controller" @@ -58,6 +60,7 @@ <td> <html:link action="/mombasa-portlet/cluster/create_role_instance" paramId="role" paramName="role" paramProperty="name"> + Add <bean:write name="role" property="name"/> </html:link> </td> Modified: trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/create_role_instance.jsp =================================================================== --- trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/create_role_instance.jsp 2010-01-14 16:59:19 UTC (rev 8139) +++ trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/create_role_instance.jsp 2010-01-14 17:09:20 UTC (rev 8140) @@ -1,4 +1,4 @@ -76<%-- +<%-- /** (C) Copyright 2009 Hewlett-Packard Development Company, LP This library is free software; you can redistribute it and/or @@ -21,12 +21,19 @@ --%> <%@ include file="/html/mombasa-portlet/cluster/init.jsp" %> +<%-- +<tiles:useAttribute id="roleInfo" + name="roleInfo" + classname="org.smartfrog.services.cloudfarmer.api.ClusterRoleInfo " + /> +--%> + <html:form action="/mombasa-portlet/cluster/create_role_instance/process" method="post" focus="minNodes"> - <p>Add Hosts in Role "<bean:write name="clusterCreateRoleInstanceForm" property="role"/>" </p> + <p>Add Hosts in Role "<bean:write name="role" />" </p> <table border="0" cellpadding="0" cellspacing="0"> <tr> @@ -41,14 +48,14 @@ <tr> <td> - Maximum of workers + Maximum number of machines to create </td> <td style="padding-left: 10px;"></td> <td> - <html:text name="clusterCreateRoleInstanceForm" property="minNodes" size="23"/> + <html:text name="clusterCreateRoleInstanceForm" property="maxNodes" size="23"/> </td> </tr> - + <%--<html:hidden name="clusterCreateRoleInstanceForm" property="role" value="${role}"/>--%> <tr> <td> <html:submit> Modified: trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/template.jsp =================================================================== --- trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/template.jsp 2010-01-14 16:59:19 UTC (rev 8139) +++ trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/template.jsp 2010-01-14 17:09:20 UTC (rev 8140) @@ -19,6 +19,7 @@ */ --%><%@ include file="/html/mombasa-portlet/cluster/init.jsp" %> +<jsp:include page="/html/mombasa-portlet/header.jsp"/> <tiles:useAttribute id="content" name="content" classname="java.lang.String" ignore="true"/> <tiles:useAttribute id="title" name="title" classname="java.lang.String" ignore="true"/> <h2><%= title %></h2> Added: trunk/core/components/cloudfarmer/site/html/mombasa-portlet/style.css =================================================================== --- trunk/core/components/cloudfarmer/site/html/mombasa-portlet/style.css (rev 0) +++ trunk/core/components/cloudfarmer/site/html/mombasa-portlet/style.css 2010-01-14 17:09:20 UTC (rev 8140) @@ -0,0 +1,3 @@ +body { + font: 12pt arial, helvetica, sans-serif; +} 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 2010-01-14 16:59:19 UTC (rev 8139) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/AbstractClusterAction.java 2010-01-14 17:09:20 UTC (rev 8140) @@ -29,6 +29,7 @@ import org.smartfrog.services.cloudfarmer.client.web.model.cluster.ClusterControllerFactory; import org.smartfrog.services.cloudfarmer.client.web.model.cluster.HostInstance; import org.smartfrog.services.cloudfarmer.client.web.model.cluster.HostInstanceList; +import org.smartfrog.services.cloudfarmer.api.ClusterRoleInfo; import org.smartfrog.sfcore.common.SmartFrogException; import javax.servlet.http.HttpServletRequest; @@ -160,7 +161,7 @@ } /** - * Add the {@link #ATTR_HOSTS} and {@link #ATTR_HOSTCOUNT} attributes + * Get the host list then add the {@link #ATTR_HOSTS} and {@link #ATTR_HOSTCOUNT} attributes * * @param request request to manipulate * @param controller controller to work from @@ -170,17 +171,38 @@ addHostAttributes(request, hosts); } + /** + * Add the {@link #ATTR_HOSTS} and {@link #ATTR_HOSTCOUNT} attributes + * @param request request to manipulate + * @param hosts list of hosts + */ protected void addHostAttributes(HttpServletRequest request, HostInstanceList hosts) { request.setAttribute(ATTR_HOSTS, hosts); request.setAttribute(ATTR_HOSTCOUNT, hosts.size()); } + /** + * Add info about the master and the hosts + * @param request request to manipulate + * @param controller controller to work from + */ protected void addClusterAttributes(HttpServletRequest request, ClusterController controller) { addMasterAttributes(request, controller); addHostAttributes(request, controller); } /** + * Add info about the master and the hosts + * + * @param request request to manipulate + * @param roleInfo role information + */ + protected void addRoleAttributes(HttpServletRequest request, ClusterRoleInfo roleInfo) { + request.setAttribute(ATTR_ROLE, roleInfo.getName()); + request.setAttribute(ATTR_ROLEINFO, roleInfo); + } + + /** * The time to wait for a machine * TODO, drive this from configuration properties * @return the timeout in milliseconds Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/AbstractStrutsAction.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/AbstractStrutsAction.java 2010-01-14 16:59:19 UTC (rev 8139) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/AbstractStrutsAction.java 2010-01-14 17:09:20 UTC (rev 8140) @@ -34,6 +34,9 @@ import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import java.rmi.ConnectException; +import java.util.Map; +import java.util.Enumeration; +import java.lang.reflect.Array; /** * Created 02-Oct-2009 12:57:12 @@ -154,15 +157,48 @@ } + protected String listParameters(HttpServletRequest request) { + Map map = request.getParameterMap(); + StringBuilder buffer = new StringBuilder(); + for (Object key:map.keySet()) { + buffer.append(key); + buffer.append('='); + Object value = request.getParameter(key.toString()); + buffer.append(value); + buffer.append('\n'); + } + return buffer.toString(); + } + + protected String listAttributes(HttpServletRequest request) { + StringBuilder buffer = new StringBuilder(); + Enumeration names = request.getAttributeNames(); + while (names.hasMoreElements()) { + String key = (String) names.nextElement(); + Object value = request.getAttribute(key); + buffer.append(key); + buffer.append('='); + buffer.append(value); + buffer.append('\n'); + } + return buffer.toString(); + } + + protected void logParameters(HttpServletRequest request) { + log.info("Request Parameters: \n"+listParameters(request)); + log.info("Request Attributes: \n" + listAttributes(request)); + + } + /** - * Convert a param to an attribute; return the trimmed value which must not be empty - * - * @param request request name - * @param parameter name to retrieve on - * @param attributeName name to set for the attribute - * @return the value or null if not found and required==false - * @throws BadParameterException the parameter is bad or missing - */ + * Convert a param to an attribute; return the trimmed value which must not be empty + * + * @param request request name + * @param parameter name to retrieve on + * @param attributeName name to set for the attribute + * @return the value or null if not found and required==false + * @throws BadParameterException the parameter is bad or missing + */ protected static String parameterToNonEmptyStringAttribute(HttpServletRequest request, String parameter, String attributeName) throws BadParameterException { Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/ClusterRequestAttributes.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/ClusterRequestAttributes.java 2010-01-14 16:59:19 UTC (rev 8139) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/ClusterRequestAttributes.java 2010-01-14 17:09:20 UTC (rev 8140) @@ -93,9 +93,15 @@ * {@value} */ String ATTR_ROLE = "role"; + /** * {@value} */ + String ATTR_ROLEINFO = "roleInfo"; + + /** + * {@value} + */ String FARMER_DESCRIPTION = "farmer.description"; /** * {@value} Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/CreateRoleInstanceAction.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/CreateRoleInstanceAction.java 2010-01-14 16:59:19 UTC (rev 8139) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/CreateRoleInstanceAction.java 2010-01-14 17:09:20 UTC (rev 8140) @@ -24,6 +24,7 @@ import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.smartfrog.services.cloudfarmer.client.web.model.cluster.ClusterController; +import org.smartfrog.services.cloudfarmer.api.ClusterRoleInfo; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -63,7 +64,16 @@ HttpServletResponse response, ClusterController controller) throws Exception { addMasterAttributes(request, controller); - + String role = parameterToAttribute(request, ATTR_ROLE, ATTR_ROLE, false); + if (isEmptyOrNull(role)) { + return failure(request, mapping, "No role provided"); + } + controller.refreshRoleList(); + ClusterRoleInfo roleInfo = controller.getRole(role); + if (roleInfo == null) { + return failure(request, mapping, "Role " + role + " is not available"); + } + addRoleAttributes(request, roleInfo); if (controller.canCreateHost()) { return success(mapping); } else { Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/CreateRoleInstanceProcessAction.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/CreateRoleInstanceProcessAction.java 2010-01-14 16:59:19 UTC (rev 8139) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/CreateRoleInstanceProcessAction.java 2010-01-14 17:09:20 UTC (rev 8140) @@ -61,8 +61,11 @@ HttpServletResponse response, ClusterController controller) throws Exception { ClusterCreateRoleInstanceForm form = (ClusterCreateRoleInstanceForm) aform; try { - String role = form.getRole(); + String role; + //role = parameterToAttribute(request, ATTR_ROLE, ATTR_ROLE, false); + role = form.getRole(); if (isEmptyOrNull(role)) { + logParameters(request); return failure(request, mapping, "No role provided"); } ClusterRoleInfo roleInfo = controller.getRole(role); @@ -70,7 +73,7 @@ return failure(request, mapping, "Role " + role + " is not available"); } HostInstanceList hil = controller.lookupHostsByRole(role); - log.info("Creating nodes of role " + role + "in range [" + form.getMinNodes() + "-" + + log.info("Creating nodes of role \"" + role + "\" in range [" + form.getMinNodes() + "-" + form.getMaxNodes() + "]"); ClusterAllocationHandler handler = new ClusterAllocationHandler(controller); Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/forms/cluster/ClusterCreateRoleInstanceForm.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/forms/cluster/ClusterCreateRoleInstanceForm.java 2010-01-14 16:59:19 UTC (rev 8139) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/forms/cluster/ClusterCreateRoleInstanceForm.java 2010-01-14 17:09:20 UTC (rev 8140) @@ -74,9 +74,18 @@ super.reset(actionMapping, request); minNodes = 1; maxNodes = 1; - //role = ""; + + Object rolename = request.getAttribute(AttributeNames.ATTR_ROLE); + log.info("Resetting create instance form to role " + rolename); + if (rolename != null) { + String s = rolename.toString().trim(); + if (!s.isEmpty()) { + role = s; + } + } } + @Override public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors actionErrors = super.validate(mapping, request); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |