From: <hel...@us...> - 2008-07-30 10:54:06
|
Revision: 6852 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=6852&view=rev Author: helgemahrt Date: 2008-07-30 10:54:02 +0000 (Wed, 30 Jul 2008) Log Message: ----------- SFOS-404 Corrected inappropriate naming and placement of the class. Modified Paths: -------------- trunk/core/components/vmware/src/org/smartfrog/services/vmware/VMWareMessageListener.java Added Paths: ----------- trunk/core/components/xmpp/src/org/smartfrog/services/xmpp/XMPPEventFilter.java Removed Paths: ------------- trunk/core/components/vmware/src/org/smartfrog/services/vmware/VMWareMessageFilter.java Deleted: trunk/core/components/vmware/src/org/smartfrog/services/vmware/VMWareMessageFilter.java =================================================================== --- trunk/core/components/vmware/src/org/smartfrog/services/vmware/VMWareMessageFilter.java 2008-07-29 09:50:57 UTC (rev 6851) +++ trunk/core/components/vmware/src/org/smartfrog/services/vmware/VMWareMessageFilter.java 2008-07-30 10:54:02 UTC (rev 6852) @@ -1,45 +0,0 @@ -/** (C) Copyright 2007 Hewlett-Packard Development Company, LP - -Disclaimer of Warranty - -The Software is provided "AS IS," without a warranty of any kind. ALL -EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, -INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE HEREBY -EXCLUDED. SmartFrog is not a Hewlett-Packard Product. The Software has -not undergone complete testing and may contain errors and defects. It -may not function properly and is subject to change or withdrawal at -any time. The user must assume the entire risk of using the -Software. No support or maintenance is provided with the Software by -Hewlett-Packard. Do not install the Software if you are not accustomed -to using experimental software. - -Limitation of Liability - -TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL HEWLETT-PACKARD -OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR -FOR SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, -HOWEVER CAUSED REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF -OR RELATED TO THE FURNISHING, PERFORMANCE, OR USE OF THE SOFTWARE, OR -THE INABILITY TO USE THE SOFTWARE, EVEN IF HEWLETT-PACKARD HAS BEEN -ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. FURTHERMORE, SINCE THE -SOFTWARE IS PROVIDED WITHOUT CHARGE, YOU AGREE THAT THERE HAS BEEN NO -BARGAIN MADE FOR ANY ASSUMPTIONS OF LIABILITY OR DAMAGES BY -HEWLETT-PACKARD FOR ANY REASON WHATSOEVER, RELATING TO THE SOFTWARE OR -ITS MEDIA, AND YOU HEREBY WAIVE ANY CLAIM IN THIS REGARD. - -*/ -package org.smartfrog.services.vmware; - -import org.jivesoftware.smack.packet.Packet; -import org.smartfrog.services.xmpp.MessageFilter; -import org.smartfrog.services.xmpp.XMPPEventExtension; - -public class VMWareMessageFilter extends MessageFilter { - - public boolean accept(Packet packet) { - return (packet.getExtension(XMPPEventExtension.rootElement, - XMPPEventExtension.namespace) instanceof XMPPEventExtension); - } - -} Modified: trunk/core/components/vmware/src/org/smartfrog/services/vmware/VMWareMessageListener.java =================================================================== --- trunk/core/components/vmware/src/org/smartfrog/services/vmware/VMWareMessageListener.java 2008-07-29 09:50:57 UTC (rev 6851) +++ trunk/core/components/vmware/src/org/smartfrog/services/vmware/VMWareMessageListener.java 2008-07-30 10:54:02 UTC (rev 6852) @@ -34,11 +34,7 @@ import org.jivesoftware.smack.filter.PacketFilter; import org.jivesoftware.smack.packet.Packet; -import org.smartfrog.services.xmpp.LocalXmppPacketHandler; -import org.smartfrog.services.xmpp.MonitoringConstants; -import org.smartfrog.services.xmpp.XMPPEventExtension; -import org.smartfrog.services.xmpp.XmppListener; -import org.smartfrog.services.xmpp.XmppListenerImpl; +import org.smartfrog.services.xmpp.*; import org.smartfrog.sfcore.common.SmartFrogDeploymentException; import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.prim.Prim; @@ -145,7 +141,7 @@ * @return a filter that only accepts messages in the vmware namespace */ public PacketFilter getFilter() { - return new VMWareMessageFilter(); + return new XMPPEventFilter(); } private boolean isManagerLive() { Copied: trunk/core/components/xmpp/src/org/smartfrog/services/xmpp/XMPPEventFilter.java (from rev 6851, trunk/core/components/vmware/src/org/smartfrog/services/vmware/VMWareMessageFilter.java) =================================================================== --- trunk/core/components/xmpp/src/org/smartfrog/services/xmpp/XMPPEventFilter.java (rev 0) +++ trunk/core/components/xmpp/src/org/smartfrog/services/xmpp/XMPPEventFilter.java 2008-07-30 10:54:02 UTC (rev 6852) @@ -0,0 +1,45 @@ +/** (C) Copyright 2007 Hewlett-Packard Development Company, LP + +Disclaimer of Warranty + +The Software is provided "AS IS," without a warranty of any kind. ALL +EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, +INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE HEREBY +EXCLUDED. SmartFrog is not a Hewlett-Packard Product. The Software has +not undergone complete testing and may contain errors and defects. It +may not function properly and is subject to change or withdrawal at +any time. The user must assume the entire risk of using the +Software. No support or maintenance is provided with the Software by +Hewlett-Packard. Do not install the Software if you are not accustomed +to using experimental software. + +Limitation of Liability + +TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL HEWLETT-PACKARD +OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR +FOR SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, +HOWEVER CAUSED REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF +OR RELATED TO THE FURNISHING, PERFORMANCE, OR USE OF THE SOFTWARE, OR +THE INABILITY TO USE THE SOFTWARE, EVEN IF HEWLETT-PACKARD HAS BEEN +ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. FURTHERMORE, SINCE THE +SOFTWARE IS PROVIDED WITHOUT CHARGE, YOU AGREE THAT THERE HAS BEEN NO +BARGAIN MADE FOR ANY ASSUMPTIONS OF LIABILITY OR DAMAGES BY +HEWLETT-PACKARD FOR ANY REASON WHATSOEVER, RELATING TO THE SOFTWARE OR +ITS MEDIA, AND YOU HEREBY WAIVE ANY CLAIM IN THIS REGARD. + +*/ +package org.smartfrog.services.xmpp; + +import org.jivesoftware.smack.packet.Packet; +import org.smartfrog.services.xmpp.MessageFilter; +import org.smartfrog.services.xmpp.XMPPEventExtension; + +public class XMPPEventFilter extends MessageFilter { + + public boolean accept(Packet packet) { + return (packet.getExtension(XMPPEventExtension.rootElement, + XMPPEventExtension.namespace) instanceof XMPPEventExtension); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2008-11-27 13:27:37
|
Revision: 7193 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7193&view=rev Author: steve_l Date: 2008-11-27 13:27:34 +0000 (Thu, 27 Nov 2008) Log Message: ----------- SFOS-1033 Move to Jetty 6.1.14 -and deal with a hadoop that has done so Modified Paths: -------------- trunk/core/components/hadoop/build.xml trunk/core/components/jetty/ivy.xml trunk/core/components/libraries.properties Modified: trunk/core/components/hadoop/build.xml =================================================================== --- trunk/core/components/hadoop/build.xml 2008-11-27 13:26:41 UTC (rev 7192) +++ trunk/core/components/hadoop/build.xml 2008-11-27 13:27:34 UTC (rev 7193) @@ -83,14 +83,27 @@ </fail> </target> - <target name="copy-hadoop" depends="ivy-retrieve" + <target name="copy-hadoop" depends="ivy-retrieve,ivy-report" description="copy the hadoop JAR where it needs to go to be kept under SCM"> <fail> <condition><equals arg1="${hadoop.version}" arg2="latest.integration"/> </condition> You need a proper hadoop.version number and not ${hadoop.version} </fail> - <property name="hadoop.target.dir" location="../../antbuild/repository/org.apache.hadoop/hadoop-core/${hadoop.version}" /> + <property name="hadoop.target.dir" + location="${core.dir}/antbuild/repository/org.apache.hadoop/hadoop-core/${hadoop.version}" /> <mkdir dir="${hadoop.target.dir}" /> - <copy todir="${hadoop.target.dir}" file="build/ivy/lib/redist/hadoop-core-${hadoop.version}.jar"/> + <property name="hadoop.artifact.name" + value="hadoop-core-${hadoop.version}.jar" /> + <property name="hadoop.artifact" + location="build/ivy/lib/redist/${hadoop.artifact.name}" /> + <fail> + <condition><not><available file="${hadoop.artifact}" /></not></condition> + Missing File: "${hadoop.artifact}" + This could be due to the hadoop version expected "${hadoop.version}" not + matching what is being built locally + </fail> + <copy todir="${hadoop.target.dir}" file="${hadoop.artifact}"/> + <echo>Copied ${hadoop.artifact}</echo> </target> + </project> \ No newline at end of file Modified: trunk/core/components/jetty/ivy.xml =================================================================== --- trunk/core/components/jetty/ivy.xml 2008-11-27 13:26:41 UTC (rev 7192) +++ trunk/core/components/jetty/ivy.xml 2008-11-27 13:27:34 UTC (rev 7193) @@ -94,6 +94,11 @@ name="jsp-api-2.1" rev="${jetty.version}" conf="jsp->master"/> + <dependency org="commons-el" + name="commons-el" + rev="${commons-el.version}" + conf="jetty->master"/> + <!--this is the compiler stage--> <dependency org="org.smartfrog" name="sf-ant" rev="latest.integration" Modified: trunk/core/components/libraries.properties =================================================================== --- trunk/core/components/libraries.properties 2008-11-27 13:26:41 UTC (rev 7192) +++ trunk/core/components/libraries.properties 2008-11-27 13:27:34 UTC (rev 7193) @@ -96,9 +96,9 @@ #hadoop artifacts commons-cli.version=2.0-SNAPSHOT -hadoop.version=0.20.0-alpha-2 -hadoop.jetty.version=5.1.4 -hadoop.servlet-api.version=2.4 -hadoop.tomcat.version=5.5.12 -hadoop.jasper.version=${hadoop.tomcat.version} -hadoop.jsp-api.version=${hadoop.tomcat.version} +hadoop.version=0.20.0-alpha-3 +#hadoop.jetty.version=5.1.4 +#hadoop.servlet-api.version=2.4 +#hadoop.tomcat.version=5.5.12 +#hadoop.jasper.version=${hadoop.tomcat.version} +#hadoop.jsp-api.version=${hadoop.tomcat.version} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-01-28 17:42:38
|
Revision: 7320 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7320&view=rev Author: steve_l Date: 2009-01-28 17:42:31 +0000 (Wed, 28 Jan 2009) Log Message: ----------- SFOS-1090 Move Hadoop service lifecycle from "terminated" to close; update state diagrams SFOS-788 SFOS-780 write component to submit jobs to a Hadoop cluster Modified Paths: -------------- trunk/core/components/hadoop/build.xml trunk/core/components/hadoop/src/org/apache/hadoop/hdfs/server/namenode/ExtNameNode.java trunk/core/components/hadoop/src/org/apache/hadoop/mapred/ExtJobTracker.java trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/ClusterStatusCheckerImpl.java trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/HadoopComponentImpl.java trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/HadoopServiceImpl.java trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/dfs/DfsClusterBoundImpl.java trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/dfs/DfsListDirImpl.java trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/submitter/SubmitterImpl.java trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/submitter/submitter.sf trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/tracker/JobTrackerImpl.java trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/conf/ManagedConfiguration.java trunk/core/components/hadoop/test/log4j.properties trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/components.sf trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/components.sf trunk/core/components/libraries.properties Added Paths: ----------- trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/ForkedJobSubmissionTest.java trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/JobSubmissionTest.java trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/testJobSubmission.sf trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/testJobSubmissionForked.sf trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/testLocalJobTracker.sf Removed Paths: ------------- trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/TaskTrackerTest.java trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/testLocalJobTracker.sf Modified: trunk/core/components/hadoop/build.xml =================================================================== --- trunk/core/components/hadoop/build.xml 2009-01-28 17:38:43 UTC (rev 7319) +++ trunk/core/components/hadoop/build.xml 2009-01-28 17:42:31 UTC (rev 7320) @@ -79,6 +79,10 @@ for JSP support in the test classpath ${toString:tests.run.classpath} </fail> + + + <property name="test.work.dir" location="${test.dir}/work" /> + <mkdir dir="${test.work.dir}" /> </target> <target name="copy-hadoop" depends="ivy-retrieve,ivy-report" Modified: trunk/core/components/hadoop/src/org/apache/hadoop/hdfs/server/namenode/ExtNameNode.java =================================================================== --- trunk/core/components/hadoop/src/org/apache/hadoop/hdfs/server/namenode/ExtNameNode.java 2009-01-28 17:38:43 UTC (rev 7319) +++ trunk/core/components/hadoop/src/org/apache/hadoop/hdfs/server/namenode/ExtNameNode.java 2009-01-28 17:42:31 UTC (rev 7320) @@ -112,7 +112,7 @@ * @return true if we have stopped */ public boolean isStopped() { - return getServiceState() == ServiceState.TERMINATED; + return getServiceState() == ServiceState.CLOSED; } /** Modified: trunk/core/components/hadoop/src/org/apache/hadoop/mapred/ExtJobTracker.java =================================================================== --- trunk/core/components/hadoop/src/org/apache/hadoop/mapred/ExtJobTracker.java 2009-01-28 17:38:43 UTC (rev 7319) +++ trunk/core/components/hadoop/src/org/apache/hadoop/mapred/ExtJobTracker.java 2009-01-28 17:42:31 UTC (rev 7320) @@ -64,7 +64,8 @@ } /** - * This service terminates itself by stopping the {@link JobEndNotifier} and then closing down the job tracker + * This service terminates itself by stopping the {@link JobEndNotifier} + * and then closing down the job tracker * * @throws IOException exceptions which will be logged */ Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/ClusterStatusCheckerImpl.java =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/ClusterStatusCheckerImpl.java 2009-01-28 17:38:43 UTC (rev 7319) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/ClusterStatusCheckerImpl.java 2009-01-28 17:42:31 UTC (rev 7320) @@ -24,7 +24,6 @@ import org.apache.hadoop.mapred.ClusterStatus; import org.apache.hadoop.mapred.JobClient; import org.apache.hadoop.mapred.JobTracker; -import org.apache.hadoop.conf.Configuration; import org.smartfrog.services.hadoop.components.HadoopCluster; import org.smartfrog.services.hadoop.components.submitter.SubmitterImpl; import org.smartfrog.services.hadoop.conf.HadoopConfiguration; @@ -117,7 +116,7 @@ return client; } try { - ManagedConfiguration conf = ManagedConfiguration.createConfiguration(this, true, false); + ManagedConfiguration conf = ManagedConfiguration.createConfiguration(this, false, false, true); sfLog().info("Connecting to " + jobTracker); client = new JobClient(conf); return client; @@ -148,6 +147,12 @@ } } + private void maybeDumpConfiguration(ManagedConfiguration conf) { + if(sfLog().isDebugEnabled()) { + sfLog().debug(conf.dump()); + } + } + /** * Check the cluster status * @@ -168,8 +173,10 @@ String impl = "fs." + uri.getScheme() + ".impl"; String classname = conf.get(impl); if(classname == null) { + maybeDumpConfiguration(conf); throw new SFHadoopException("File system " + uri + " will not load " - +" - no configuration mapping for " + impl, + +" - no configuration mapping for " + impl + +" in "+ conf.dump(), this, conf); } Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/HadoopComponentImpl.java =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/HadoopComponentImpl.java 2009-01-28 17:38:43 UTC (rev 7319) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/HadoopComponentImpl.java 2009-01-28 17:42:31 UTC (rev 7320) @@ -87,7 +87,7 @@ * @throws SmartFrogResolutionException resolution failure * @throws RemoteException network problems */ protected ManagedConfiguration createConfiguration(Prim target) throws SmartFrogException, RemoteException { - return ManagedConfiguration.createConfiguration(target, true, false); + return ManagedConfiguration.createConfiguration(target, true, false, false); } @@ -100,7 +100,7 @@ */ protected ManagedConfiguration createClusterAttrConfiguration() throws SmartFrogException, RemoteException { - return ManagedConfiguration.createConfiguration(this, true, true); + return ManagedConfiguration.createConfiguration(this, true, true, false); /* Prim target = sfResolve(targetAttribute, (Prim) null, true); if (target == null) { Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/HadoopServiceImpl.java =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/HadoopServiceImpl.java 2009-01-28 17:38:43 UTC (rev 7319) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/HadoopServiceImpl.java 2009-01-28 17:42:31 UTC (rev 7320) @@ -29,7 +29,6 @@ import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.common.SmartFrogLivenessException; import org.smartfrog.sfcore.common.SmartFrogResolutionException; -import org.smartfrog.sfcore.common.SmartFrogLifecycleException; import org.smartfrog.sfcore.prim.Liveness; import org.smartfrog.sfcore.prim.TerminationRecord; import org.smartfrog.sfcore.reference.Reference; @@ -93,8 +92,8 @@ @Override protected synchronized void sfTerminateWith(TerminationRecord status) { super.sfTerminateWith(status); - sfLog().info("Initiating " + getServiceName() + " termination" - + " deployerThread=" + deployerThread + " service=" + service); + sfLog().info("Initiating " + getServiceName() + " termination;" + + " serviceThread=" + deployerThread + " service=" + service); terminationInitiated = true; try { terminateDeployerThread(); @@ -194,7 +193,7 @@ } sfLog().info("waiting for thread to finish"); if (deployer.waitForThreadTermination(SHUTDOWN_DELAY)) { - sfLog().warn("Deployer thread did not terminate within the specified shutdown delay; " + sfLog().warn("Hadoop Service thread did not terminate within the expected shutdown period: " + "service is " + getService()); } } @@ -260,7 +259,7 @@ //@Override public void onStateChange(Service hadoopService, Service.ServiceState oldState, Service.ServiceState newState) { - if (newState == Service.ServiceState.TERMINATED && !terminationInitiated) { + if (newState == Service.ServiceState.CLOSED && !terminationInitiated) { TerminationRecord tr; Throwable thrown = hadoopService.getFailureCause(); if (expectNodeTermination) { @@ -309,7 +308,7 @@ "Service has Failed: " + serviceStatus, service.getFailureCause(), this); - case TERMINATED: + case CLOSED: throw new SmartFrogLivenessException( "Service has Terminated: " + serviceStatus, service.getFailureCause(), this); Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/dfs/DfsClusterBoundImpl.java =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/dfs/DfsClusterBoundImpl.java 2009-01-28 17:38:43 UTC (rev 7319) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/dfs/DfsClusterBoundImpl.java 2009-01-28 17:42:31 UTC (rev 7320) @@ -81,7 +81,7 @@ * @throws RemoteException network problems */ public ManagedConfiguration createConfiguration() throws SmartFrogException, RemoteException { - return ManagedConfiguration.createConfiguration(this, true, true); + return ManagedConfiguration.createConfiguration(this, true, true, false); } /** Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/dfs/DfsListDirImpl.java =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/dfs/DfsListDirImpl.java 2009-01-28 17:38:43 UTC (rev 7319) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/dfs/DfsListDirImpl.java 2009-01-28 17:42:31 UTC (rev 7320) @@ -68,9 +68,15 @@ @Override protected void performDfsOperation(DistributedFileSystem fileSystem, ManagedConfiguration conf) throws Exception { Path path = getPath(); + if (path==null) { + throw new SmartFrogLivenessException("No path for the DfsListDir operation", this); + } try { long size = 0; - FileStatus[] stats = fileSystem.listStatus(getPath()); + FileStatus[] stats = fileSystem.listStatus(path); + if (stats == null) { + throw new SmartFrogLivenessException("Path not found in the remote filesystem: " + path, this); + } StringBuilder builder = new StringBuilder(); for (FileStatus file : stats) { size += file.getLen(); @@ -88,12 +94,14 @@ if (count < minFileCount) { throw new SmartFrogLivenessException( "File count " + count + " is below the minFileCount value of " + minFileCount - + "\n" + builder.toString()); + + "\n" + builder.toString(), + this); } if (maxFileCount > -1 && count > maxFileCount) { throw new SmartFrogLivenessException( "File count " + count + " is above the maxFileCount value of " + minFileCount - + "\n" + builder.toString()); + + "\n" + builder.toString(), + this); } } catch (IOException e) { Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/submitter/SubmitterImpl.java =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/submitter/SubmitterImpl.java 2009-01-28 17:38:43 UTC (rev 7319) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/submitter/SubmitterImpl.java 2009-01-28 17:42:31 UTC (rev 7320) @@ -95,7 +95,7 @@ String outputDir = validateOrResolve(ConfigurationAttributes.MAPRED_OUTPUT_DIR, Job.ATTR_OUTPUT_DIR); validateOrResolve(ConfigurationAttributes.MAPRED_WORKING_DIR, Job.ATTR_WORKING_DIR); validateOrResolve(ConfigurationAttributes.MAPRED_LOCAL_DIR, Job.ATTR_LOCAL_DIR); - validateOrResolve(ConfigurationAttributes.MAPRED_JOB_SPLIT_FILE, ConfigurationAttributes.MAPRED_JOB_SPLIT_FILE); +// validateOrResolve(ConfigurationAttributes.MAPRED_JOB_SPLIT_FILE, ConfigurationAttributes.MAPRED_JOB_SPLIT_FILE); if (deleteOutputDirOnStartup) { @@ -123,7 +123,7 @@ /** - * Handle notifications of termination + * Handle notifications of termination by (maybe) terminating the running job * * @param status termination status of sender * @param comp sender of termination @@ -144,8 +144,13 @@ } } + /** + * Terminate any running job; leaves {@link #runningJob} null. + * @throws IOException for any problems terminating the job + */ public synchronized void terminateJob() throws IOException { if (runningJob != null) { + sfLog().info("Terminating job " + jobID); try { runningJob.killJob(); } finally { @@ -185,7 +190,8 @@ } catch (IOException e) { SFHadoopException fault = new SFHadoopException(ERROR_FAILED_TO_START_JOB + jobTracker + ": " + e, - e, SubmitterImpl.this); + e, + SubmitterImpl.this); fault.addConfiguration(jobConf); throw fault; } @@ -194,10 +200,14 @@ /** * Override point: the termination message * - * @return {@link #WORKER_THREAD_COMPLETED} or {@link #WORKER_THREAD_FAILED} depending on the outcome + * @return Job information */ protected String getTerminationMessage() { - return "Submitted job " + jobID + " and URL " + jobURL; + if (jobID != null) { + return "Submitted job " + jobID + " and URL " + jobURL; + } else { + return "Failed to submit a job"; + } } } @@ -221,7 +231,8 @@ + " has " + (succeeded ? " succeeded" : "failed"); sfLog().info(message); if (terminateWhenJobFinishes) { - TerminationRecord record = succeeded ? TerminationRecord.normal(message, getName()) : + TerminationRecord record = succeeded ? + TerminationRecord.normal(message, getName()) : TerminationRecord.abnormal(message, getName()); new ComponentHelper(this).targetForTermination(record, false, false); } Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/submitter/submitter.sf =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/submitter/submitter.sf 2009-01-28 17:38:43 UTC (rev 7319) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/submitter/submitter.sf 2009-01-28 17:42:31 UTC (rev 7320) @@ -55,5 +55,5 @@ terminateJob true; terminateWhenJobFinishes true; //this disables an auto terminate after submitting - sfShouldTerminate true; + sfShouldTerminate false; } \ No newline at end of file Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/tracker/JobTrackerImpl.java =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/tracker/JobTrackerImpl.java 2009-01-28 17:38:43 UTC (rev 7319) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/tracker/JobTrackerImpl.java 2009-01-28 17:42:31 UTC (rev 7320) @@ -212,6 +212,9 @@ } } finally { sfLog().info("Exiting JobTracker worker thread; service is " + hadoopService); + if(hadoopService!=null && hadoopService.isTerminated()) { + sfLog().warn("Service does not consider itself terminated yet"); + } //terminateService(hadoopService); } } Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/conf/ManagedConfiguration.java =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/conf/ManagedConfiguration.java 2009-01-28 17:38:43 UTC (rev 7319) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/conf/ManagedConfiguration.java 2009-01-28 17:42:31 UTC (rev 7320) @@ -601,21 +601,22 @@ * @param useClusterReferenceFirst if set, resolve {@link ClusterBound#ATTR_CLUSTER} from the source and use that * first. * @param clusterRequired if set, the cluster attribute must resolve. + * @param loadDefaults flag to say "load the default values" * @return the new element * @throws SmartFrogException for any failure to resolve all the attributes * @throws RemoteException network problems. These are always passed up */ public static ManagedConfiguration createConfiguration(Prim source, boolean useClusterReferenceFirst, - boolean clusterRequired) + boolean clusterRequired, boolean loadDefaults) throws SmartFrogException, RemoteException { - ManagedConfiguration conf = new ManagedConfiguration(source); + ManagedConfiguration conf = new ManagedConfiguration(loadDefaults, source); if (useClusterReferenceFirst) { //pull in the cluster if requested Prim clusterSource = source.sfResolve(REF_CLUSTER, (Prim) null, clusterRequired); if (clusterSource != null) { //if we have a cluster source, use it - conf.copyProperties(source, new ManagedConfiguration(clusterSource)); + conf.copyProperties(source, new ManagedConfiguration(loadDefaults, clusterSource)); //createConfiguration(source, clusterSource); } } Modified: trunk/core/components/hadoop/test/log4j.properties =================================================================== --- trunk/core/components/hadoop/test/log4j.properties 2009-01-28 17:38:43 UTC (rev 7319) +++ trunk/core/components/hadoop/test/log4j.properties 2009-01-28 17:42:31 UTC (rev 7320) @@ -44,7 +44,13 @@ # All audit events are logged at INFO level # log4j.logger.org.apache.hadoop.fs.FSNamesystem.audit=WARN +log4j.logger.org.apache.hadoop.hdfs.server.namenode.FSNamesystem=WARN +#Crank back some of the log info +log4j.logger.org.apache.hadoop.hdfs.server.datanode.DataNode.clienttrace=WARN +log4j.logger.org.apache.hadoop.hdfs.StateChange=WARN + + # Custom Logging levels #log4j.logger.org.apache.hadoop.mapred.JobTracker=DEBUG @@ -54,4 +60,5 @@ # Jets3t library log4j.logger.org.jets3t.service.impl.rest.httpclient.RestS3Service=ERROR -log4j.logger.org.smartfrog.services.hadoop=DEBUG \ No newline at end of file +log4j.logger.org.smartfrog.services.hadoop=DEBUG + Modified: trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/components.sf =================================================================== --- trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/components.sf 2009-01-28 17:38:43 UTC (rev 7319) +++ trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/components.sf 2009-01-28 17:42:31 UTC (rev 7320) @@ -261,15 +261,49 @@ testDirIn (testDir ++ "/in"); testDirOut (testDir ++ "/out"); testDirWorking (testDir ++ "/working"); - testFile (testDirIn ++ "/test.csv"); + testFile (testDirIn ++ "/in.txt"); + inputFileDFS testFile; + outputFileDFS ( testDirOut ++ "/in.txt"); + LocalDataDir PROPERTY test.work.dir; + inputFileLocal (LocalDataDir ++ "/in.txt") + outputFileLocal (LocalDataDir ++ "/out.txt") + inputFile extends TextFile { + filename inputFileLocal; + createParentDirs true; + sfShouldTerminate true; + text ##1,one,un,ein +2,two,deux,zwei +3,three,trois,drei +4,four,quatre,vier +5,five,cinq,funf#; + } - files extends FileCreation { + + CopyDataIn extends DfsCopyFileIn { cluster LAZY PARENT:cluster; + source inputFileLocal; dest testFile; + sfShouldTerminate true; } - MRCompound extends Compound { + SourceExists extends DfsPathExistsWorkflow { + cluster LAZY PARENT:cluster; + path inputFileDFS; + } + + lsIn extends DfsListDir { + cluster LAZY PARENT:cluster; + path testDirIn; + } + + mkOutputDir extends DfsCreateDir { + cluster LAZY PARENT:cluster; + path testDirOut; + } + + + MRCompound extends Parallel { job extends TestJob { //this is the job information jobTracker LAZY PARENT:PARENT:jobTracker; @@ -279,7 +313,8 @@ mapred.output.dir testDirOut; mapred.working.dir testDirWorking; mapred.local.dir (testDir ++ "/local"); - mapred.job.split.file (testDir ++ "/split"); + mapred.mapper.new-api true; + //mapred.job.split.file (testDir ++ "/split"); mapred.job.tracker jobTracker:mapred.job.tracker; keep.failed.task.files true; filename ""; @@ -291,17 +326,32 @@ submission extends BlockingJobSubmitter { //get our settings from ourselves. job LAZY PARENT:job; + mapred.mapper.new-api true; cluster LAZY PARENT:PARENT:cluster; fileRequired false; } - sleep extends Delay { - //cleanup delay - time 1000; - } + } + s1 extends Sleep; + + lsOut extends DfsListDir { + cluster LAZY PARENT:cluster; + path testDirOut; } + ResultExists extends DfsPathExistsWorkflow { + cluster LAZY PARENT:cluster; + path outputFileDFS; + } + + CopyDataOut extends DfsCopyFileOut { + cluster LAZY PARENT:cluster; + source outputFileDFS; + dest outputFileLocal; + sfShouldTerminate true; + } + } Added: trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/ForkedJobSubmissionTest.java =================================================================== --- trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/ForkedJobSubmissionTest.java (rev 0) +++ trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/ForkedJobSubmissionTest.java 2009-01-28 17:42:31 UTC (rev 7320) @@ -0,0 +1,43 @@ +/* (C) Copyright 2008 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 + +*/ +package org.smartfrog.services.hadoop.test.system.local.tracker; + +import org.smartfrog.services.hadoop.test.system.local.namenode.HadoopTestBase; + +/** + * + * Created 20-May-2008 17:35:13 + * + */ + +public class ForkedJobSubmissionTest extends HadoopTestBase { + public static final String PACKAGE = "/org/smartfrog/services/hadoop/test/system/local/tracker/"; + + public ForkedJobSubmissionTest(String name) { + super(name); + } + + public void testJobSubmissionForked() throws Throwable { + enablePortCheck(); + checkTaskTracker(); + expectSuccessfulTestRunOrSkip(PACKAGE, "testJobSubmissionForked"); + } + +} \ No newline at end of file Copied: trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/JobSubmissionTest.java (from rev 7271, trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/TaskTrackerTest.java) =================================================================== --- trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/JobSubmissionTest.java (rev 0) +++ trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/JobSubmissionTest.java 2009-01-28 17:42:31 UTC (rev 7320) @@ -0,0 +1,43 @@ +/* (C) Copyright 2008 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 + +*/ +package org.smartfrog.services.hadoop.test.system.local.tracker; + +import org.smartfrog.services.hadoop.test.system.local.namenode.HadoopTestBase; + +/** + * + * Created 20-May-2008 17:35:13 + * + */ + +public class JobSubmissionTest extends HadoopTestBase { + public static final String PACKAGE = "/org/smartfrog/services/hadoop/test/system/local/tracker/"; + + public JobSubmissionTest(String name) { + super(name); + } + + public void testJobSubmission() throws Throwable { + enablePortCheck(); + checkTaskTracker(); + expectSuccessfulTestRunOrSkip(PACKAGE, "testJobSubmission"); + } + +} \ No newline at end of file Deleted: trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/TaskTrackerTest.java =================================================================== --- trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/TaskTrackerTest.java 2009-01-28 17:38:43 UTC (rev 7319) +++ trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/TaskTrackerTest.java 2009-01-28 17:42:31 UTC (rev 7320) @@ -1,43 +0,0 @@ -/* (C) Copyright 2008 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 - -*/ -package org.smartfrog.services.hadoop.test.system.local.tracker; - -import org.smartfrog.services.hadoop.test.system.local.namenode.HadoopTestBase; - -/** - * - * Created 20-May-2008 17:35:13 - * - */ - -public class TaskTrackerTest extends HadoopTestBase { - public static final String PACKAGE = "/org/smartfrog/services/hadoop/test/system/local/tracker/"; - - public TaskTrackerTest(String name) { - super(name); - } - - public void testLocalTaskTracker() throws Throwable { - enablePortCheck(); - checkTaskTracker(); - expectSuccessfulTestRunOrSkip(PACKAGE, "testLocalTaskTracker"); - } - -} \ No newline at end of file Modified: trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/components.sf =================================================================== --- trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/components.sf 2009-01-28 17:38:43 UTC (rev 7319) +++ trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/components.sf 2009-01-28 17:42:31 UTC (rev 7320) @@ -43,7 +43,7 @@ /** * Test the local node */ -testLocalTaskTracker extends ExpectDeploy { +testJobSubmission extends ExpectDeploy { description "bring up a Task Tracker"; action extends LocalClusterCompound { @@ -88,9 +88,9 @@ -testLocalTaskTrackerForked extends testLocalTaskTracker { - action:namenode:sfProcessName "testDataNodeForkedProcess-namenode"; - action:datanode:sfProcessName "testDataNodeForkedProcess"; - action:clusterActions:then:jobTracker:sfProcessName "testLocalJobTrackerForked-jobtracker"; - action:clusterActions:then:taskTracker:sfProcessName "testLocalJobTrackerForked-taskTracker"; +testJobSubmissionForked extends testJobSubmission { + action:namenode:sfProcessName "testJobSubmission-namenode"; + action:datanode:sfProcessName "testJobSubmission-datanode"; + action:clusterActions:then:jobTracker:sfProcessName "testJobSubmission-jobtracker"; + action:clusterActions:then:taskTracker:sfProcessName "testJobSubmission-taskTracker"; } Copied: trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/testJobSubmission.sf (from rev 7271, trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/testLocalJobTracker.sf) =================================================================== --- trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/testJobSubmission.sf (rev 0) +++ trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/testJobSubmission.sf 2009-01-28 17:42:31 UTC (rev 7320) @@ -0,0 +1,29 @@ +/* (C) Copyright 2008 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/hadoop/test/system/local/tracker/components.sf" + + +/** + * Test case + */ +sfConfig extends testJobSubmission { +} \ No newline at end of file Added: trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/testJobSubmissionForked.sf =================================================================== --- trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/testJobSubmissionForked.sf (rev 0) +++ trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/testJobSubmissionForked.sf 2009-01-28 17:42:31 UTC (rev 7320) @@ -0,0 +1,29 @@ +/* (C) Copyright 2008 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/hadoop/test/system/local/tracker/components.sf" + + +/** + * Test case + */ +sfConfig extends testJobSubmissionForked { +} \ No newline at end of file Deleted: trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/testLocalJobTracker.sf =================================================================== --- trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/testLocalJobTracker.sf 2009-01-28 17:38:43 UTC (rev 7319) +++ trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/testLocalJobTracker.sf 2009-01-28 17:42:31 UTC (rev 7320) @@ -1,29 +0,0 @@ -/* (C) Copyright 2008 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/hadoop/test/system/local/tracker/components.sf" - - -/** - * Test case - */ -sfConfig extends testLocalJobTracker { -} \ No newline at end of file Copied: trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/testLocalJobTracker.sf (from rev 7271, trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/testLocalJobTrackerForked.sf) =================================================================== --- trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/testLocalJobTracker.sf (rev 0) +++ trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/testLocalJobTracker.sf 2009-01-28 17:42:31 UTC (rev 7320) @@ -0,0 +1,28 @@ +/* (C) Copyright 2008 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/hadoop/test/system/local/tracker/components.sf" + + +/** + * Test case + */ +sfConfig testLocalJobTracker; \ No newline at end of file Property changes on: trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/testLocalJobTracker.sf ___________________________________________________________________ Added: svn:mergeinfo + Modified: trunk/core/components/libraries.properties =================================================================== --- trunk/core/components/libraries.properties 2009-01-28 17:38:43 UTC (rev 7319) +++ trunk/core/components/libraries.properties 2009-01-28 17:42:31 UTC (rev 7320) @@ -97,7 +97,7 @@ #hadoop artifacts commons-cli.version=2.0-SNAPSHOT -hadoop.version=0.21.0-alpha-2 +hadoop.version=0.21.0-alpha-6 #hadoop.jetty.version=5.1.4 #hadoop.servlet-api.version=2.4 #hadoop.tomcat.version=5.5.12 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-02-19 18:33:39
|
Revision: 7407 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7407&view=rev Author: steve_l Date: 2009-02-19 18:33:33 +0000 (Thu, 19 Feb 2009) Log Message: ----------- SFOS-14 groovy scripting support. with tests for Groovy and javascript Modified Paths: -------------- trunk/core/components/groovy/ivy.xml trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScriptingImpl.java trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/ScriptHelper.java trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/components.sf trunk/core/components/groovy/src/org/smartfrog/services/scripting/js/components.sf trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/groovy/components.sf trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/javax/components.sf trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/components.sf trunk/core/components/libraries.properties trunk/core/components/scripting/src/org/smartfrog/services/scripting/RemoteScriptPrim.java trunk/core/components/scripting/test/org/smartfrog/test/system/components/scripting/ScriptingTest.java Added Paths: ----------- trunk/core/components/groovy/.svnignore trunk/core/components/groovy/src/org/smartfrog/services/scripting/groovy/ trunk/core/components/groovy/src/org/smartfrog/services/scripting/groovy/components.sf trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScript.java trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScriptingConditionImpl.java trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/RemoteCompiledScript.java trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/Variables.java trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/groovy/GroovyTest.java trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/groovy/hello.groovy trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/groovy/testInlineLifecycle.sf trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/groovy/testInlineLifecycleTerminating.sf trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/groovy/testResourceTerminating.sf trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/JavascriptTest.java trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/hello.js trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/testInlineLifecycle.sf trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/testInlineLifecycleTerminating.sf trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/testResourceTerminating.sf Copied: trunk/core/components/groovy/.svnignore (from rev 7404, trunk/core/components/scripting/.svnignore) =================================================================== --- trunk/core/components/groovy/.svnignore (rev 0) +++ trunk/core/components/groovy/.svnignore 2009-02-19 18:33:33 UTC (rev 7407) @@ -0,0 +1,14 @@ +build +dist +build.properties +runtime.properties +common.properties +*.jpx +*.ipr +*.iml +*.iws +.classpath +.project + + +version.properties Modified: trunk/core/components/groovy/ivy.xml =================================================================== --- trunk/core/components/groovy/ivy.xml 2009-02-19 18:30:21 UTC (rev 7406) +++ trunk/core/components/groovy/ivy.xml 2009-02-19 18:33:33 UTC (rev 7407) @@ -15,22 +15,24 @@ </configurations> --> <configurations defaultconfmapping="default"> - <conf name="default" extends="master,runtime" - description="default configuration contains artifacts and runtime dependencies"/> + <conf name="default" extends="master,runtime" + description="default configuration contains artifacts and runtime dependencies"/> <conf name="build" visibility="private" - description="artifacts needed to build the application"/> - <conf name="compile" visibility="private" - description="artifacts needed to compile the application"/> + description="artifacts needed to build the application"/> + <conf name="compile" visibility="private" extends="runtime" + description="artifacts needed to compile the application"/> <conf name="daemon" visibility="private" - description="the classpath needed to run smartfrog daemons"/> + description="the classpath needed to run smartfrog daemons"/> <conf name="test" extends="default,compile" - description="the classpath needed to run tests"/> + description="the classpath needed to run tests"/> <conf name="master" description="contains the artifact but no dependencies"/> - <conf name="redist" description="redistributals excluding smartfrog artifacts"/> + <conf name="redist" description="redistributals excluding smartfrog artifacts" + extends="groovy"/> <conf name="runtime" description="runtime but not the artifact" - extends="redist" /> + extends="redist"/> <conf name="documentation" - description="all documentation artifacts"/> + description="all documentation artifacts"/> + <conf name="groovy" description="contains the groovy JARs"/> </configurations> <publications> @@ -62,6 +64,11 @@ <dependency org="org.codehaus.groovy" name="groovy-all-minimal" rev="${groovy.version}" - conf="compile->default;redist->default"/> + conf="groovy->default"/> + <dependency org="com.sun.script" + name="groovy-engine" + rev="${groovy-engine.version}" + conf="groovy->default"/> + </dependencies> </ivy-module> \ No newline at end of file Copied: trunk/core/components/groovy/src/org/smartfrog/services/scripting/groovy/components.sf (from rev 7404, trunk/core/components/groovy/src/org/smartfrog/services/scripting/js/components.sf) =================================================================== --- trunk/core/components/groovy/src/org/smartfrog/services/scripting/groovy/components.sf (rev 0) +++ trunk/core/components/groovy/src/org/smartfrog/services/scripting/groovy/components.sf 2009-02-19 18:33:33 UTC (rev 7407) @@ -0,0 +1,33 @@ +/* (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/scripting/javax/components.sf" + +Groovy extends JavaxScripting { + language GROOVY; +} + +GroovyWorkflow extends JavaxScriptingWorkflow { + language GROOVY; +} + +GroovyCondition extends JavaxScriptingCondition { + language GROOVY; +} + Added: trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScript.java =================================================================== --- trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScript.java (rev 0) +++ trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScript.java 2009-02-19 18:33:33 UTC (rev 7407) @@ -0,0 +1,39 @@ +/* (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 + + */ + +package org.smartfrog.services.scripting.javax; + +import org.smartfrog.services.scripting.RemoteScriptPrim; + +/** + * extras for the javax scripting supporting + */ +public interface JavaxScript extends RemoteScriptPrim { + + + String ATTR_SF_DEPLOY_RESOURCE = "sfDeployResource"; + String ATTR_SF_START_RESOURCE = "sfStartResource"; + String ATTR_SF_PING_RESOURCE = "sfPingResource"; + String ATTR_SF_TERMINATE_WITH_RESOURCE = "sfTerminateWithResource"; + String ATTR_SF_CONDITION_RESOURCE = "sfConditionResource"; + String ATTR_SF_CONDITION_CODE = "sfConditionCode"; + String ATTR_COMPILE="compile"; + +} Added: trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScriptingConditionImpl.java =================================================================== --- trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScriptingConditionImpl.java (rev 0) +++ trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScriptingConditionImpl.java 2009-02-19 18:33:33 UTC (rev 7407) @@ -0,0 +1,46 @@ +/* (C) Copyright 2008 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 + + */ + + +package org.smartfrog.services.scripting.javax; + +import org.smartfrog.sfcore.workflow.conditional.Condition; +import org.smartfrog.sfcore.common.SmartFrogException; + +import java.rmi.RemoteException; + +/** + * + */ +public class JavaxScriptingConditionImpl extends JavaxScriptingImpl implements Condition { + + public JavaxScriptingConditionImpl() throws RemoteException { + } + + public boolean evaluate() throws RemoteException, SmartFrogException { + Object result = resolveAndEvaluate(ATTR_SF_CONDITION_RESOURCE,ATTR_SF_CONDITION_CODE); + if(!(result instanceof Boolean)) { + throw new SmartFrogException("Return value is not a boolean:"+result); + + } else { + return ((Boolean)result); + } + } +} Modified: trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScriptingImpl.java =================================================================== --- trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScriptingImpl.java 2009-02-19 18:30:21 UTC (rev 7406) +++ trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScriptingImpl.java 2009-02-19 18:33:33 UTC (rev 7407) @@ -1,4 +1,4 @@ -/** (C) Copyright 1998-2004 Hewlett-Packard Development Company, LP +/** (C) Copyright 1998-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 @@ -21,41 +21,27 @@ package org.smartfrog.services.scripting.javax; import org.smartfrog.sfcore.common.SmartFrogException; -import org.smartfrog.sfcore.common.SmartFrogResolutionException; import org.smartfrog.sfcore.common.SmartFrogLifecycleException; -import org.smartfrog.sfcore.prim.Prim; +import org.smartfrog.sfcore.common.SmartFrogLivenessException; import org.smartfrog.sfcore.prim.PrimImpl; import org.smartfrog.sfcore.prim.TerminationRecord; -import org.smartfrog.sfcore.security.SFClassLoader; -import org.smartfrog.services.scripting.RemoteScriptPrim; +import org.smartfrog.sfcore.utils.ComponentHelper; import javax.script.ScriptException; -import java.io.InputStreamReader; -import java.io.Reader; -import java.io.StringReader; import java.rmi.RemoteException; -import java.util.Enumeration; /** * ScriptPrimImpl is a SmartFrog component which allows the user to write bits of java code in the description. * BeansShell is used to interpret them. It also implements the RemoteBSH which allows bsh scripts to be remotely * executed */ -public class JavaxScriptingImpl - extends PrimImpl - implements Prim, RemoteScriptPrim { +public class JavaxScriptingImpl extends PrimImpl implements JavaxScript { /** * The Beanshell interpreter */ private ScriptHelper scriptHelper; - public ScriptHelper.LoadedEngine interpreter; + private ScriptHelper.LoadedEngine engine; - /** - * The location of the code - */ - private String sfScriptCodeBase = ""; - public static final String SCRIPT_PRIM = "prim"; - public static final String SCRIPT_STATUS = "status"; public static final String ERROR_EVAL = "There was an error in evaluating the script:"; /** @@ -63,7 +49,6 @@ * @throws RemoteException superclass trouble */ public JavaxScriptingImpl() throws RemoteException { - super(); } @@ -79,46 +64,37 @@ * phases.</li> * <li> If the 'sfDeployCode' is present the deploy script is evaluated.</li> */ + @Override public void sfDeploy() throws SmartFrogException, RemoteException { super.sfDeploy(); String language = sfResolve(ATTR_LANGUAGE, "", true); scriptHelper = new ScriptHelper(this); - interpreter = scriptHelper.createEngine(language); - try { - interpreter.set(SCRIPT_PRIM, this); - boolean attAsVar = sfResolve(ATTR_ATTRIBUTES_AS_VARIABLES, false, true); - - if (attAsVar) { - // go through all the attributes and bind them in the interpreter. - for (Enumeration e = sfContext().keys(); e.hasMoreElements();) { - String attName = (String) e.nextElement(); - interpreter.set(attName, sfContext().get(attName)); - } - } - sfScriptCodeBase = sfResolve(ATTR_SF_SCRIPT_CODE_BASE, "", true); - String sfDeployCodeSource = sfScriptCodeBase + sfResolve(ATTR_SF_DEPLOY_CODE); - interpreter.eval(getScript(sfDeployCodeSource)); - } catch (ScriptException e) { - throw SmartFrogLifecycleException.forward(ERROR_EVAL + e, - e, this); - } - + engine = scriptHelper.createEngine(language); + engine.bindAttributes(); + resolveAndEvaluate(ATTR_SF_DEPLOY_RESOURCE, ATTR_SF_DEPLOY_CODE); } /** - * Start phase : execute the code described with the 'sfStartCode' attribute. + * Start phase : execute the startup code, then maybe begin the termination phase * - * @throws Exception if the start phase fails. + * @throws SmartFrogException startup failure + * @throws RemoteException remote failure */ + @Override public void sfStart() throws SmartFrogException, RemoteException { super.sfStart(); + resolveAndEvaluate(ATTR_SF_START_RESOURCE, ATTR_SF_START_CODE); + new ComponentHelper(this).sfSelfDetachAndOrTerminate(null,null,sfCompleteName(),null); + } + + @Override + public void sfPing(Object source) throws SmartFrogLivenessException, RemoteException { + super.sfPing(source); try { - String sfStartCodeSource = sfScriptCodeBase + - sfResolve(ATTR_SF_START_CODE); - interpreter.eval(getScript(sfStartCodeSource)); - } catch (ScriptException e2) { - throw SmartFrogLifecycleException.forward(ERROR_EVAL + e2.getMessage(), - e2, this); + engine.resolveAndEvaluate(ATTR_SF_PING_RESOURCE, ATTR_SF_PING_CODE); + } catch (Exception e) { + throw (SmartFrogLivenessException) + SmartFrogLivenessException.forward(ERROR_EVAL + e, e); } } @@ -128,13 +104,11 @@ * * @param status the TerminationRecord for this phase. */ + @Override public void sfTerminateWith(TerminationRecord status) { try { - String sfTerminateWithCodeSource = sfScriptCodeBase + - sfResolve(ATTR_SF_TERMINATE_WITH_CODE); - interpreter.set(SCRIPT_STATUS, status); - interpreter.eval(getScript(sfTerminateWithCodeSource)); - } catch (SmartFrogResolutionException e) { + engine.resolveAndEvaluate(ATTR_SF_TERMINATE_WITH_RESOURCE, ATTR_SF_TERMINATE_WITH_CODE); + } catch (SmartFrogException e) { sfLog().ignore(e); } catch (RemoteException e) { sfLog().error(e); @@ -144,7 +118,24 @@ super.sfTerminateWith(status); } + /** + * Resolve the attributes, evaluate the code, convert Scripting Exceptions into SmartFrog ones + * @param resource resource attribute to look for + * @param inline inline source attribute to look for + * @return the return value of the evaluation + * @throws SmartFrogException if the resolution or the script fails + * @throws RemoteException network problems + */ + protected Object resolveAndEvaluate(String resource, String inline) throws SmartFrogException, RemoteException { + try { + return engine.resolveAndEvaluate(resource, inline); + } catch (ScriptException e) { + throw SmartFrogLifecycleException.forward(ERROR_EVAL + e, + e, this); + } + } + /** * Bind an object to a name in the beanshell interpreter. * @@ -154,7 +145,7 @@ public synchronized void setRemote(String name, Object obj) throws SmartFrogException, RemoteException { try { - interpreter.set(name, obj); + engine.set(name, obj); } catch (Throwable thr) { throw SmartFrogException.forward(thr); @@ -172,24 +163,11 @@ public synchronized Object eval(String script) throws SmartFrogException, RemoteException { try { - return interpreter.eval(script); + return engine.eval(script); } catch (ScriptException e) { throw new SmartFrogException(e, this); } } - /** - * Interpret the string passed as a value in the ScriptPrimImpl description. If it's a file, return a reader on this - * file. If it's the script itself, a reader on the string. - * - * @param script the String describing either the script or its URL. - * @return a Reader on the script. - */ - public Reader getScript(String script) { - try { - return new InputStreamReader(SFClassLoader.getResourceAsStream(script)); - } catch (Exception ignored) { - return new StringReader(script); - } - } + } \ No newline at end of file Added: trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/RemoteCompiledScript.java =================================================================== --- trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/RemoteCompiledScript.java (rev 0) +++ trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/RemoteCompiledScript.java 2009-02-19 18:33:33 UTC (rev 7407) @@ -0,0 +1,30 @@ +/* (C) Copyright 2008 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 + + */ + +package org.smartfrog.services.scripting.javax; + +import java.rmi.Remote; + +/** + * + */ +public interface RemoteCompiledScript extends Remote { + +} Modified: trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/ScriptHelper.java =================================================================== --- trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/ScriptHelper.java 2009-02-19 18:30:21 UTC (rev 7406) +++ trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/ScriptHelper.java 2009-02-19 18:33:33 UTC (rev 7407) @@ -20,6 +20,9 @@ package org.smartfrog.services.scripting.javax; import org.smartfrog.sfcore.prim.PrimImpl; +import org.smartfrog.sfcore.utils.ComponentHelper; +import org.smartfrog.sfcore.common.SmartFrogException; +import org.smartfrog.sfcore.common.SmartFrogLifecycleException; import javax.script.ScriptEngineManager; import javax.script.ScriptEngine; @@ -27,6 +30,10 @@ import javax.script.ScriptException; import javax.script.CompiledScript; import java.io.Reader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Enumeration; +import java.rmi.RemoteException; /** * Anything to help with script engine work @@ -35,23 +42,44 @@ public class ScriptHelper { private PrimImpl owner; + private ComponentHelper compHelper; private ScriptEngineManager manager; + public static final String ERROR_NO_ENGINE = "Failed to load a scripting engine for the language "; public ScriptHelper(PrimImpl owner) { this.owner = owner; + compHelper = new ComponentHelper(owner); manager = new ScriptEngineManager(); } - LoadedEngine createEngine(String language) { + public LoadedEngine createEngine(String language) throws SmartFrogLifecycleException { ScriptEngine engine = manager.getEngineByName(language); + if(engine==null) { + throw new SmartFrogLifecycleException(ERROR_NO_ENGINE + +language); + } return new LoadedEngine(language, engine); } /** - * Represents a loaded engine + * Load a resource + * @param resource resource to load + * @return a reader for that resource + * @throws SmartFrogException if the resource can not be found + * @throws RemoteException for network problems */ - public static class LoadedEngine { + public Reader loadResource(String resource) throws SmartFrogException, RemoteException { + InputStream inputStream = compHelper.loadResource(resource); + return new InputStreamReader(inputStream); + } + + + /** + * Represents a loaded engine, has some helper methods + */ + public class LoadedEngine { + public ScriptEngine engine; public String language; private boolean isJavaFX; @@ -79,7 +107,7 @@ */ public void set(String name, Object value) { if (isJavaFX) { - engine.put(name + ":" + value.getClass().getName(), value); + engine.put(name + ':' + value.getClass().getName(), value); } else { engine.put(name, value); } @@ -93,6 +121,11 @@ return engine.eval(reader); } + public Object evalResource(String resource) throws ScriptException, SmartFrogException, RemoteException { + Reader reader = loadResource(resource); + return eval(reader); + } + public boolean canCompile() { return engine instanceof Compilable; } @@ -107,13 +140,61 @@ return getCompilable().compile(reader); } + + public Object compileResource(String resource) throws ScriptException, SmartFrogException, RemoteException { + Reader reader = loadResource(resource); + return compile(reader); + } + private Compilable getCompilable() { return ((Compilable)engine); } + /** + * Bind the attributes of the owner to the script context. + */ + public void bindAttributes() { + set(Variables.PRIM, owner); + set(Variables.SELF, owner); + set(Variables.LOG, owner.sfLog()); + // go through all the attributes and bind them in the interpreter. + for (Enumeration e = owner.sfContext().keys(); e.hasMoreElements();) { + String attName = (String) e.nextElement(); + set(attName, owner.sfContext().get(attName)); + } + } + /** + * Resolve the resource and inline attributes (both of which must be present), + * <ol> + * <li>If the resource attribute resolves to a non-empty string, then the attribute + * {@link JavaxScript#ATTR_SF_SCRIPT_CODE_BASE} is resolved and prepended to the resource + * attribute; the resource is then loaded and executed</li> + * <li>If the inline attribute resolves to a non-empty string, it is evaluated</li> + * </ol> + * @param attrResource name of an attribute that should resolve to a resource + * @param attrInline name of an an attribute containing an inline string + * @return the result of the evaluation, or null if neither got evaluated + * @throws SmartFrogException Failure to load the resource, resolve attributes + * @throws RemoteException network problems + * @throws ScriptException if the script failed + */ + public Object resolveAndEvaluate(String attrResource, String attrInline) throws SmartFrogException, + RemoteException, ScriptException { + String resourceName = owner.sfResolve(attrResource, "", true); + String inline = owner.sfResolve(attrInline, "", true); + + if(!resourceName.isEmpty()) { + String codebase = owner.sfResolve(JavaxScript.ATTR_SF_SCRIPT_CODE_BASE,"",true); + return evalResource(codebase+resourceName); + } else if(!inline.isEmpty()) { + return eval(inline); + } else { + return null; + } + } } } Added: trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/Variables.java =================================================================== --- trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/Variables.java (rev 0) +++ trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/Variables.java 2009-02-19 18:33:33 UTC (rev 7407) @@ -0,0 +1,32 @@ +/* (C) Copyright 2008 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 + + */ + +package org.smartfrog.services.scripting.javax; + +/** + * + */ +public interface Variables { + + String PRIM = "prim"; + String STATUS = "status"; + String SELF = "self"; + String LOG = "log"; +} Modified: trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/components.sf =================================================================== --- trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/components.sf 2009-02-19 18:30:21 UTC (rev 7406) +++ trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/components.sf 2009-02-19 18:33:33 UTC (rev 7407) @@ -18,20 +18,49 @@ */ -#include "org/smartfrog/functions.sf" +#include "/org/smartfrog/components.sf" -JavaxScripting extends Prim { - sfClass "org.smartfrog.services.scripting.javax.JavaxScriptPrimImpl"; +/** + * Scripting engine; + * + * the resource attributes are read before the code ones; if both are empty strings then + * that specific phase is a no-op + */ +JavaxScripting extends WorkflowPrim { + sfClass "org.smartfrog.services.scripting.javax.JavaxScriptingImpl"; language ""; + sfScriptCodeBase ""; - attributesAsVariables true; + + + sfDeployResource ""; sfDeployCode ""; + + sfStartResource ""; sfStartCode ""; + + sfPingResource ""; sfPingCode ""; + + sfTerminateWithResource ""; sfTerminateWithCode ""; + JAVASCRIPT "javascript"; JAVAFX "fx"; - GROOVY "Groovy"; + GROOVY "groovy"; -} \ No newline at end of file +} + +/** + * this component will terminate after the start operation + */ +JavaxScriptingWorkflow extends JavaxScripting { + sfShouldTerminate true; +} + +JavaxScriptingCondition extends JavaxScripting { + sfClass "org.smartfrog.services.scripting.javax.JavaxScriptingConditionImpl"; + sfConditionResource ""; + sfConditionCode ""; +} Modified: trunk/core/components/groovy/src/org/smartfrog/services/scripting/js/components.sf =================================================================== --- trunk/core/components/groovy/src/org/smartfrog/services/scripting/js/components.sf 2009-02-19 18:30:21 UTC (rev 7406) +++ trunk/core/components/groovy/src/org/smartfrog/services/scripting/js/components.sf 2009-02-19 18:33:33 UTC (rev 7407) @@ -22,3 +22,12 @@ JavaScript extends JavaxScripting { language JAVASCRIPT; } + +JavaScriptWorkflow extends JavaxScriptingWorkflow { + language JAVASCRIPT; +} + +JavaScriptCondition extends JavaxScriptingCondition { + language JAVASCRIPT; +} + Added: trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/groovy/GroovyTest.java =================================================================== --- trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/groovy/GroovyTest.java (rev 0) +++ trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/groovy/GroovyTest.java 2009-02-19 18:33:33 UTC (rev 7407) @@ -0,0 +1,48 @@ +/* (C) Copyright 2008 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 + + */ + + +package org.smartfrog.test.system.services.scripting.groovy; + +import org.smartfrog.test.DeployingTestBase; + +/** + * + */ +public class GroovyTest extends DeployingTestBase { + + public static final String PACKAGE= "/org/smartfrog/test/system/services/scripting/groovy/"; + + public GroovyTest(String name) { + super(name); + } + + public void testInlineLifecycle() throws Throwable { + expectSuccessfulTestRun(PACKAGE, "testInlineLifecycle"); + } + + public void testInlineLifecycleTerminating() throws Throwable { + expectSuccessfulTestRun(PACKAGE, "testInlineLifecycleTerminating"); + } + + public void testResourceTerminating() throws Throwable { + expectSuccessfulTestRun(PACKAGE, "testResourceTerminating"); + } +} \ No newline at end of file Modified: trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/groovy/components.sf =================================================================== --- trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/groovy/components.sf 2009-02-19 18:30:21 UTC (rev 7406) +++ trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/groovy/components.sf 2009-02-19 18:33:33 UTC (rev 7407) @@ -17,10 +17,56 @@ For more information: www.smartfrog.org */ -#include "/org/smartfrog/services/filesystem/components.sf" +#include "/org/smartfrog/services/scripting/groovy/components.sf" #include "/org/smartfrog/services/assertions/components.sf" -#include "/org/smartfrog/services/os/java/components.sf" +#include "/org/smartfrog/services/scripting/js/components.sf" -sfConfig extends Compound { +scriptbase "/org/smartfrog/test/system/services/scripting/groovy/"; +hello "hello.groovy"; + + +LifecycleInlineWorkflow extends GroovyWorkflow { + sfScriptCodeBase scriptbase; + sfDeployCode ## + log.info "deploy" + #; + + sfStartCode ## + log.info "start" + #; + + sfPingCode ## + log.info 'ping' + #; + + sfTerminateWithCode "log.info 'terminated'"; } + +HelloOnStartup extends LifecycleInlineWorkflow { + sfStartResource hello; +} + +testInlineLifecycle extends ExpectDeploy { + + action extends LifecycleInlineWorkflow { + sfShouldTerminate false; + } + + tests extends Sequence { + +} +} + +testInlineLifecycleTerminating extends ExpectTerminate { + + action extends LifecycleInlineWorkflow { + } +} + + +testResourceTerminating extends ExpectTerminate { + + action extends HelloOnStartup { + } +} Added: trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/groovy/hello.groovy =================================================================== --- trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/groovy/hello.groovy (rev 0) +++ trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/groovy/hello.groovy 2009-02-19 18:33:33 UTC (rev 7407) @@ -0,0 +1 @@ +log.info "hello from Groovy" \ No newline at end of file Added: trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/groovy/testInlineLifecycle.sf =================================================================== --- trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/groovy/testInlineLifecycle.sf (rev 0) +++ trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/groovy/testInlineLifecycle.sf 2009-02-19 18:33:33 UTC (rev 7407) @@ -0,0 +1,29 @@ +/* (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/test/system/services/scripting/groovy/components.sf" + + + + +sfConfig testInlineLifecycle; + + + + Added: trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/groovy/testInlineLifecycleTerminating.sf =================================================================== --- trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/groovy/testInlineLifecycleTerminating.sf (rev 0) +++ trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/groovy/testInlineLifecycleTerminating.sf 2009-02-19 18:33:33 UTC (rev 7407) @@ -0,0 +1,29 @@ +/* (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/test/system/services/scripting/groovy/components.sf" + + + + +sfConfig testInlineLifecycleTerminating; + + + + Added: trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/groovy/testResourceTerminating.sf =================================================================== --- trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/groovy/testResourceTerminating.sf (rev 0) +++ trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/groovy/testResourceTerminating.sf 2009-02-19 18:33:33 UTC (rev 7407) @@ -0,0 +1,29 @@ +/* (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/test/system/services/scripting/groovy/components.sf" + + + + +sfConfig testResourceTerminating; + + + + Modified: trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/javax/components.sf =================================================================== --- trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/javax/components.sf 2009-02-19 18:30:21 UTC (rev 7406) +++ trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/javax/components.sf 2009-02-19 18:33:33 UTC (rev 7407) @@ -17,10 +17,7 @@ For more information: www.smartfrog.org */ -#include "/org/smartfrog/services/filesystem/components.sf" #include "/org/smartfrog/services/assertions/components.sf" -#include "/org/smartfrog/services/os/java/components.sf" +#include "/org/smartfrog/services/scripting/js/components.sf" -sfConfig extends Compound { -} Added: trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/JavascriptTest.java =================================================================== --- trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/JavascriptTest.java (rev 0) +++ trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/JavascriptTest.java 2009-02-19 18:33:33 UTC (rev 7407) @@ -0,0 +1,48 @@ +/* (C) Copyright 2008 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 + + */ + + +package org.smartfrog.test.system.services.scripting.js; + +import org.smartfrog.test.DeployingTestBase; + +/** + * + */ +public class JavascriptTest extends DeployingTestBase { + + public static final String PACKAGE="/org/smartfrog/test/system/services/scripting/js/"; + + public JavascriptTest(String name) { + super(name); + } + + public void testInlineLifecycle() throws Throwable { + expectSuccessfulTestRun(PACKAGE, "testInlineLifecycle"); + } + + public void testInlineLifecycleTerminating() throws Throwable { + expectSuccessfulTestRun(PACKAGE, "testInlineLifecycleTerminating"); + } + + public void testResourceTerminating() throws Throwable { + expectSuccessfulTestRun(PACKAGE, "testResourceTerminating"); + } +} Modified: trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/components.sf =================================================================== --- trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/components.sf 2009-02-19 18:30:21 UTC (rev 7406) +++ trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/components.sf 2009-02-19 18:33:33 UTC (rev 7407) @@ -17,10 +17,63 @@ For more information: www.smartfrog.org */ -#include "/org/smartfrog/services/filesystem/components.sf" #include "/org/smartfrog/services/assertions/components.sf" -#include "/org/smartfrog/services/os/java/components.sf" +#include "/org/smartfrog/services/scripting/js/components.sf" -sfConfig extends Compound { +scriptbase "/org/smartfrog/test/system/services/scripting/js/"; +hello "hello.js"; + + +LifecycleInlineWorkflow extends JavaScriptWorkflow { + sfScriptCodeBase scriptbase; + sfDeployCode ## + log.info("deploy"); + #; + + sfStartCode ## + log.info("start"); + #; + + sfPingCode ## + log.info("ping"); + #; + + sfTerminateWithCode + ## + log.info("terminated"); + #; } + +HelloOnStartup extends LifecycleInlineWorkflow { + sfStartResource hello; +} + +testInlineLifecycle extends ExpectDeploy { + + action extends LifecycleInlineWorkflow { + sfShouldTerminate false; + } + + tests extends Sequence { + +} +} + +testInlineLifecycleTerminating extends ExpectTerminate { + + action extends LifecycleInlineWorkflow { + } +} + + +testResourceTerminating extends ExpectTerminate { + + action extends HelloOnStartup { + } +} + + + + + Added: trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/hello.js =================================================================== --- trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/hello.js (rev 0) +++ trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/hello.js 2009-02-19 18:33:33 UTC (rev 7407) @@ -0,0 +1 @@ + log.info("hello from JavaScript"); Added: trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/testInlineLifecycle.sf =================================================================== --- trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/testInlineLifecycle.sf (rev 0) +++ trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/testInlineLifecycle.sf 2009-02-19 18:33:33 UTC (rev 7407) @@ -0,0 +1,29 @@ +/* (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/test/system/services/scripting/js/components.sf" + + + + +sfConfig testInlineLifecycle; + + + + Added: trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/testInlineLifecycleTerminating.sf =================================================================== --- trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/testInlineLifecycleTerminating.sf (rev 0) +++ trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/testInlineLifecycleTerminating.sf 2009-02-19 18:33:33 UTC (rev 7407) @@ -0,0 +1,29 @@ +/* (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/test/system/services/scripting/js/components.sf" + + + + +sfConfig testInlineLifecycleTerminating; + + + + Copied: trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/testResourceTerminating.sf (from rev 7404, trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/components.sf) =================================================================== --- trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/testResourceTerminating.sf (rev 0) +++ trunk/core/components/groovy/test/org/smartfrog/test/system/services/scripting/js/testResourceTerminating.sf 2009-02-19 18:33:33 UTC (rev 7407) @@ -0,0 +1,29 @@ +/* (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/test/system/services/scripting/js/components.sf" + + + + +sfConfig testResourceTerminating; + + + + Modified: trunk/core/components/libraries.properties =================================================================== --- trunk/core/components/libraries.properties 2009-02-19 18:30:21 UTC (rev 7406) +++ trunk/core/components/libraries.properties 2009-02-19 18:33:33 UTC (rev 7407) @@ -96,6 +96,9 @@ xmldb.version=20030701 xmldb-xupdate.version=20040205 +#scripting engines +groovy-engine.version=20080808 + #hadoop artifacts commons-cli.version=2.0-SNAPSHOT hadoop.version=0.21.0-alpha-4 Modified: trunk/core/components/scripting/src/org/smartfrog/services/scripting/RemoteScriptPrim.java =================================================================== --- trunk/core/components/scripting/src/org/smartfrog/services/scripting/RemoteScriptPrim.java 2009-02-19 18:30:21 UTC (rev 7406) +++ trunk/core/components/scripting/src/org/smartfrog/services/scripting/RemoteScriptPrim.java 2009-02-19 18:33:33 UTC (rev 7407) @@ -34,7 +34,7 @@ extends Remote { String ATTR_SF_DEPLOY_CODE = "sfDeployCode"; String ATTR_SF_START_CODE = "sfStartCode"; - String ATTR_PING_CODE = "sfPingCode"; + String ATTR_SF_PING_CODE = "sfPingCode"; String ATTR_SF_TERMINATE_WITH_CODE = "sfTerminateWithCode"; String ATTR_PORT = "port"; String ATTR_SF_SCRIPT_CODE_BASE = "sfScriptCodeBase"; Modified: trunk/core/components/scripting/test/org/smartfrog/test/system/components/scripting/ScriptingTest.java =================================================================== --- trunk/core/components/scripting/test/org/smartfrog/test/system/components/scripting/ScriptingTest.java 2009-02-19 18:30:21 UTC (rev 7406) +++ trunk/core/components/scripting/test/org/smartfrog/test/system/components/scripting/ScriptingTest.java 2009-02-19 18:33:33 UTC (rev 7407) @@ -39,9 +39,7 @@ /** * JUnit test class for test cases related to "Scripting" component */ -public class ScriptingTest - - extends SmartFrogTestBase { +public class ScriptingTest extends SmartFrogTestBase { private static final String FILES = "org/smartfrog/test/system/components/scripting/"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-02-23 13:38:07
|
Revision: 7412 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7412&view=rev Author: steve_l Date: 2009-02-23 13:37:16 +0000 (Mon, 23 Feb 2009) Log Message: ----------- SFOS-14: changing where filename gets printed in the build Modified Paths: -------------- trunk/core/components/groovy/build.xml trunk/core/components/scripting/build.xml Modified: trunk/core/components/groovy/build.xml =================================================================== --- trunk/core/components/groovy/build.xml 2009-02-23 13:36:24 UTC (rev 7411) +++ trunk/core/components/groovy/build.xml 2009-02-23 13:37:16 UTC (rev 7412) @@ -44,13 +44,10 @@ <!--available file="../../common.xml" property="root.dir" value="../.."/--> <import file="${root.dir}/common.xml"/> + <echo message="==================================================================="/> + <echo message="= ${ant.project.name}"/> - <target name="init" depends="common.init"> - <echo message="==================================================================="/> - <echo message="= ${ant.project.name}"/> - </target> - </project> <!-- End of file --> Modified: trunk/core/components/scripting/build.xml =================================================================== --- trunk/core/components/scripting/build.xml 2009-02-23 13:36:24 UTC (rev 7411) +++ trunk/core/components/scripting/build.xml 2009-02-23 13:37:16 UTC (rev 7412) @@ -1,7 +1,7 @@ <?xml version="1.0"?> <!-- -/** (C) Copyright 1998-2007 Hewlett-Packard Development Company, LP +/** (C) Copyright 1998-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 @@ -45,10 +45,8 @@ <import file="${root.dir}/common.xml"/> - <target name="init" depends="common.init"> - <echo message="==================================================================="/> - <echo message="= ${ant.project.name}"/> - </target> + <echo message="==================================================================="/> + <echo message="= ${ant.project.name}"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-02-26 19:14:20
|
Revision: 7422 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7422&view=rev Author: steve_l Date: 2009-02-26 19:13:35 +0000 (Thu, 26 Feb 2009) Log Message: ----------- SFOS-1130 Prototype JAX-RS front-end for a long-haul API and client to go with Added Paths: ----------- trunk/core/components/restapi/ trunk/core/components/restapi/src/ trunk/core/components/restapi/src/org/ trunk/core/components/restapi/src/org/smartfrog/ trunk/core/components/restapi/src/org/smartfrog/services/ trunk/core/components/restapi/src/org/smartfrog/services/restapi/ trunk/core/components/restapi/src/org/smartfrog/services/restapi/jersey/ trunk/core/components/restapi/src/org/smartfrog/services/restapi/jersey/Java6HttpServerImpl.java trunk/core/components/restapi/src/org/smartfrog/services/restapi/jersey/components.sf trunk/core/components/restapi/src/org/smartfrog/services/restapi/resources/ trunk/core/components/restapi/src/org/smartfrog/services/restapi/resources/AbstractRestResource.java trunk/core/components/restapi/src/org/smartfrog/services/restapi/resources/ComponentState.java trunk/core/components/restapi/src/org/smartfrog/services/restapi/resources/Manager.java trunk/core/components/restapi/web/ trunk/core/components/restapi/web/WEB-INF/ trunk/core/components/restapi/web/WEB-INF/web.xml trunk/core/components/restapi/web/index.jsp Added: trunk/core/components/restapi/src/org/smartfrog/services/restapi/jersey/Java6HttpServerImpl.java =================================================================== --- trunk/core/components/restapi/src/org/smartfrog/services/restapi/jersey/Java6HttpServerImpl.java (rev 0) +++ trunk/core/components/restapi/src/org/smartfrog/services/restapi/jersey/Java6HttpServerImpl.java 2009-02-26 19:13:35 UTC (rev 7422) @@ -0,0 +1,95 @@ +/* (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 + + */ + + +package org.smartfrog.services.restapi.jersey; + +import org.smartfrog.sfcore.prim.PrimImpl; +import org.smartfrog.sfcore.prim.TerminationRecord; +import org.smartfrog.sfcore.common.SmartFrogException; +import org.smartfrog.sfcore.common.SmartFrogDeploymentException; +import org.smartfrog.sfcore.utils.ComponentHelper; + +import java.rmi.RemoteException; +import java.io.IOException; +import java.lang.reflect.Method; +import java.lang.reflect.InvocationTargetException; + +import com.sun.net.httpserver.HttpServer; +import com.sun.jersey.api.container.httpserver.HttpServerFactory; + +/** + * Component that represents a Jser + */ +public class Java6HttpServerImpl extends PrimImpl { + + private HttpServer server; + public static final String ATTR_PORT = "port"; + public static final String ATTR_HOST = "host"; + public static final String ATTR_PROTOCOL = "protocol"; + public static final String ATTR_FACTORY_CLASS = "factoryClass"; + + public Java6HttpServerImpl() throws RemoteException { + } + + @Override + public synchronized void sfStart() + throws SmartFrogException, RemoteException { + super.sfStart(); + int port = sfResolve(ATTR_PORT, 0, true); + String host = sfResolve(ATTR_HOST, "", true); + String protocol = sfResolve(ATTR_PROTOCOL, "", true); + String serverURL = protocol + "://" + host + ":" + port + "/"; + sfLog().info("Starting Java6 server on " + serverURL); + String factoryClassName = sfResolve(ATTR_FACTORY_CLASS, "", true); + ComponentHelper helper = new ComponentHelper(this); + Class factoryClass = helper.loadClass(factoryClassName); + Method createMethod = null; + try { + createMethod = factoryClass.getMethod("create", String.class); + } catch (NoSuchMethodException e) { + throw new SmartFrogDeploymentException("No method 'create(String)' in class " + factoryClassName); + } + try { + createMethod.invoke(null, serverURL); + } catch (InvocationTargetException e) { + Throwable thrown = e; + if (e.getCause() != null) { + thrown = e.getCause(); + } + throw new SmartFrogDeploymentException("Could not start the server on " + + serverURL + ": " + thrown, thrown); + + } catch (IllegalAccessException e) { + throw new SmartFrogDeploymentException("Could not start the server on " + + serverURL + ": " + e, e); + } + server.start(); + } + + @Override + protected void sfTerminateWith(TerminationRecord status) { + super.sfTerminateWith(status); + if (server != null) { + server.stop(0); + server = null; + } + } +} Property changes on: trunk/core/components/restapi/src/org/smartfrog/services/restapi/jersey/Java6HttpServerImpl.java ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/core/components/restapi/src/org/smartfrog/services/restapi/jersey/components.sf =================================================================== --- trunk/core/components/restapi/src/org/smartfrog/services/restapi/jersey/components.sf (rev 0) +++ trunk/core/components/restapi/src/org/smartfrog/services/restapi/jersey/components.sf 2009-02-26 19:13:35 UTC (rev 7422) @@ -0,0 +1,42 @@ +/* (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 + + */ + +/** + * This is the minimal HTTP server that ships with Java6. + * It is not a servlet engine and has minimal compatibility with the mainstream + * Java web servers, hence it is not declared in the same component hierarchy + */ + +Java6HttpServer extends Prim { + sfClass "org.smartfrog.services.restapi.jersey.Java6HttpServerImpl"; + host "localhost"; + port 8080; + HTTP "http"; + HTTPS "https"; + protocol HTTP; + factoryClass TBD; +} + +/** + * The jersey server has its own factory + */ +JerseyHttpServer extends Java6HttpServer { + factoryClass "com.sun.jersey.api.container.httpserver.HttpServerFactory"; +} \ No newline at end of file Property changes on: trunk/core/components/restapi/src/org/smartfrog/services/restapi/jersey/components.sf ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/core/components/restapi/src/org/smartfrog/services/restapi/resources/AbstractRestResource.java =================================================================== --- trunk/core/components/restapi/src/org/smartfrog/services/restapi/resources/AbstractRestResource.java (rev 0) +++ trunk/core/components/restapi/src/org/smartfrog/services/restapi/resources/AbstractRestResource.java 2009-02-26 19:13:35 UTC (rev 7422) @@ -0,0 +1,35 @@ +/* (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 + + */ + + +package org.smartfrog.services.restapi.resources; + +import org.smartfrog.sfcore.processcompound.ProcessCompound; +import org.smartfrog.sfcore.processcompound.SFProcess; + +/** + * + */ +public abstract class AbstractRestResource { + + ProcessCompound getProcessCompound() { + return SFProcess.getProcessCompound(); + } +} Added: trunk/core/components/restapi/src/org/smartfrog/services/restapi/resources/ComponentState.java =================================================================== --- trunk/core/components/restapi/src/org/smartfrog/services/restapi/resources/ComponentState.java (rev 0) +++ trunk/core/components/restapi/src/org/smartfrog/services/restapi/resources/ComponentState.java 2009-02-26 19:13:35 UTC (rev 7422) @@ -0,0 +1,44 @@ +/* (C) Copyright 2008 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 + + */ + + +package org.smartfrog.services.restapi.resources; + +import javax.ws.rs.GET; +import javax.ws.rs.Produces; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; + +// The Java class will be hosted at the URI path "/helloworld" +/** + * + */ +@Path("/components/{path:.+}\"") +public class ComponentState extends AbstractRestResource { + + // The Java method will process HTTP GET requests + @GET + // The Java method will produce content identified by the MIME Media type "text/plain" + @Produces("text/plain") + public String getState(@PathParam("path") String path) { + // Return some cliched textual content + return "undefined"; + } +} Property changes on: trunk/core/components/restapi/src/org/smartfrog/services/restapi/resources/ComponentState.java ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/core/components/restapi/src/org/smartfrog/services/restapi/resources/Manager.java =================================================================== --- trunk/core/components/restapi/src/org/smartfrog/services/restapi/resources/Manager.java (rev 0) +++ trunk/core/components/restapi/src/org/smartfrog/services/restapi/resources/Manager.java 2009-02-26 19:13:35 UTC (rev 7422) @@ -0,0 +1,102 @@ +/* (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 + + */ + + +package org.smartfrog.services.restapi.resources; + +import org.smartfrog.sfcore.processcompound.ProcessCompound; +import org.smartfrog.sfcore.prim.Prim; +import org.smartfrog.sfcore.prim.Liveness; + +import javax.ws.rs.Path; +import javax.ws.rs.GET; +import javax.ws.rs.Produces; +import javax.ws.rs.PathParam; +import javax.ws.rs.PUT; +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.core.UriInfo; +import javax.ws.rs.core.Context; +import java.util.List; +import java.util.Enumeration; +import java.util.ArrayList; +import java.rmi.RemoteException; + +/** + * + */ +@Path("/manager/{application}") +public class Manager extends AbstractRestResource { + + // The Java method will process HTTP GET requests + @GET + // The Java method will produce content identified by the MIME Media type "text/plain" + @Produces("application/xml") + public String getAsXML(@PathParam("application") String application) { + // Return some cliched textual content + return "<undefined/>"; + } + + @GET + @Produces("application/json") + public String getAsJSON(@PathParam("application") String application) { + // Return some cliched textual content + return "undefined"; + } + + @GET + @Produces("application/x-smartfrog") + public String getAsSmartFrog(@PathParam("application") String application) { + // Return some cliched textual content + return "undefined"; + } + + @PUT + @Consumes("application/x-smartfrog") + @Produces("application/json") + public String put(String message, + @PathParam("application") String application, + @Context UriInfo context) { + ProcessCompound process = getProcessCompound(); + //TODO + + + return("deployed"); + } + + List<Prim> getListOfApplications() throws RemoteException { + ProcessCompound process = getProcessCompound(); + Enumeration<Liveness> children = process.sfChildren(); + List<Prim> applications = new ArrayList<Prim>(); + while (children.hasMoreElements()) { + Liveness liveness = children.nextElement(); + applications.add((Prim) liveness); + } + return applications; + } + +/* + @POST + @Consumes("application/x-smartfrog") + public String doPost2(FormURLEncodedProperties formData) { + } +*/ + +} Property changes on: trunk/core/components/restapi/src/org/smartfrog/services/restapi/resources/Manager.java ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/core/components/restapi/web/WEB-INF/web.xml =================================================================== --- trunk/core/components/restapi/web/WEB-INF/web.xml (rev 0) +++ trunk/core/components/restapi/web/WEB-INF/web.xml 2009-02-26 19:13:35 UTC (rev 7422) @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<web-app xmlns="http://java.sun.com/xml/ns/javaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee + http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" + version="2.5"> + +<servlet> +<servlet-name>ServletAdaptor</servlet-name> +<servlet-class>com.sun.jersey.impl.container.servlet.ServletAdaptor</servlet-class> +<load-on-startup>1</load-on-startup> +</servlet><servlet-mapping> <servlet-name>ServletAdaptor</servlet-name> <url-pattern>/resources/*</url-pattern> </servlet-mapping><session-config> <session-timeout>30</session-timeout> </session-config><welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list></web-app> Property changes on: trunk/core/components/restapi/web/WEB-INF/web.xml ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/core/components/restapi/web/index.jsp =================================================================== --- trunk/core/components/restapi/web/index.jsp (rev 0) +++ trunk/core/components/restapi/web/index.jsp 2009-02-26 19:13:35 UTC (rev 7422) @@ -0,0 +1,12 @@ +<%-- + Created by IntelliJ IDEA. + User: slo + Date: 26-Feb-2009 + Time: 11:29:02 + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<html> + <head><title>Simple jsp page</title></head> + <body>Place your content here</body> +</html> \ No newline at end of file Property changes on: trunk/core/components/restapi/web/index.jsp ___________________________________________________________________ Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-03-03 17:55:23
|
Revision: 7440 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7440&view=rev Author: steve_l Date: 2009-03-03 17:55:22 +0000 (Tue, 03 Mar 2009) Log Message: ----------- style updates Modified Paths: -------------- trunk/core/components/www/doc/www_readme.sxw trunk/core/components/xml/doc/xml_readme.sxw Modified: trunk/core/components/www/doc/www_readme.sxw =================================================================== (Binary files differ) Modified: trunk/core/components/xml/doc/xml_readme.sxw =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-05-27 17:06:00
|
Revision: 7613 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7613&view=rev Author: steve_l Date: 2009-05-27 17:05:11 +0000 (Wed, 27 May 2009) Log Message: ----------- SFOS-1207 move to the new hadoop version and adapt to its changes Modified Paths: -------------- trunk/core/components/hadoop/build.xml trunk/core/components/hadoop/src/org/apache/hadoop/hdfs/server/datanode/ExtDataNode.java trunk/core/components/hadoop/src/org/apache/hadoop/util/NodeUtils.java trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/HadoopComponentImpl.java trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/datanode/DatanodeImpl.java trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/other/components.sf trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/conf/ManagedConfiguration.java trunk/core/components/libraries.properties Modified: trunk/core/components/hadoop/build.xml =================================================================== --- trunk/core/components/hadoop/build.xml 2009-05-27 15:45:37 UTC (rev 7612) +++ trunk/core/components/hadoop/build.xml 2009-05-27 17:05:11 UTC (rev 7613) @@ -94,7 +94,14 @@ </target> - <target name="copy-hadoop" depends="ivy-retrieve,ivy-report" + <target name="ready-to-copy-hadoop" depends="ivy-retrieve,ivy-report"> + <echo> + hadoop.dir=${hadoop.dir} + hadoop.version=${hadoop.version} + </echo> + </target> + + <target name="copy-hadoop" depends="ready-to-copy-hadoop" description="copy the hadoop JAR where it needs to go to be kept under SCM"> <fail> <condition><equals arg1="${hadoop.version}" arg2="latest.integration"/> </condition> Modified: trunk/core/components/hadoop/src/org/apache/hadoop/hdfs/server/datanode/ExtDataNode.java =================================================================== --- trunk/core/components/hadoop/src/org/apache/hadoop/hdfs/server/datanode/ExtDataNode.java 2009-05-27 15:45:37 UTC (rev 7612) +++ trunk/core/components/hadoop/src/org/apache/hadoop/hdfs/server/datanode/ExtDataNode.java 2009-05-27 17:05:11 UTC (rev 7613) @@ -101,21 +101,11 @@ } public InetSocketAddress getHttpAddress(Configuration conf) { - String address = - NetUtils.getServerAddress(conf, - DFS_DATANODE_INFO_BIND_ADDRESS, - DFS_DATANODE_INFO_BIND_PORT, - DFS_DATANODE_HTTP_ADDRESS); - return NetUtils.createSocketAddr(address); + return NodeUtils.resolveAddress(conf, DFS_DATANODE_INFO_BIND_ADDRESS); } public InetSocketAddress getIpcAddress(Configuration conf) { - String address = - NetUtils.getServerAddress(conf, - DFS_DATANODE_BIND_ADDRESS, - DFS_DATANODE_PORT, - DFS_DATANODE_ADDRESS); - return NetUtils.createSocketAddr(address); + return NodeUtils.resolveAddress(conf, DFS_DATANODE_BIND_ADDRESS); } /** Modified: trunk/core/components/hadoop/src/org/apache/hadoop/util/NodeUtils.java =================================================================== --- trunk/core/components/hadoop/src/org/apache/hadoop/util/NodeUtils.java 2009-05-27 15:45:37 UTC (rev 7612) +++ trunk/core/components/hadoop/src/org/apache/hadoop/util/NodeUtils.java 2009-05-27 17:05:11 UTC (rev 7613) @@ -20,6 +20,8 @@ package org.apache.hadoop.util; import org.smartfrog.services.hadoop.core.BindingTuple; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.net.NetUtils; import java.net.InetSocketAddress; @@ -51,4 +53,20 @@ String stringValue = buffer.toString(); return stringValue; } + + + /** + * Resolve an address from an attribute of a configuration + * @param conf the configuration + * @param attribute the attribute + * @return the socket address + * @throws IllegalArgumentException if the address attribute is missing + */ + public static InetSocketAddress resolveAddress(Configuration conf, String attribute) { + String address = conf.get(attribute); + if (address == null) { + throw new IllegalArgumentException("No value for " + attribute); + } + return NetUtils.createSocketAddr(address); + } } Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/HadoopComponentImpl.java =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/HadoopComponentImpl.java 2009-05-27 15:45:37 UTC (rev 7612) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/HadoopComponentImpl.java 2009-05-27 17:05:11 UTC (rev 7613) @@ -192,10 +192,7 @@ */ protected InetSocketAddress resolveAddress(ManagedConfiguration configuration, String addressAttribute) throws SmartFrogResolutionException, RemoteException { - InetSocketAddress socketAddress = configuration.bindToNetwork(addressAttribute, - "stubOldAddressNameShouldNotResolve", - "stubOldAddressPortShouldNotResolve"); - return socketAddress; + return configuration.bindToNetwork(addressAttribute); } protected PortEntry resolvePortEntry(ManagedConfiguration configuration,String addressAttribute) @@ -203,15 +200,4 @@ return new PortEntry(addressAttribute, resolveAddress(configuration, addressAttribute)); } - - protected PortEntry resolvePortEntry(ManagedConfiguration configuration, String addressAttribute, - String bindAddressName, String bindAddressPort) - throws SmartFrogResolutionException, RemoteException { - InetSocketAddress socketAddress = configuration.bindToNetwork(addressAttribute, - bindAddressName, - bindAddressPort); - return new PortEntry(addressAttribute,socketAddress); - } - - } Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/datanode/DatanodeImpl.java =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/datanode/DatanodeImpl.java 2009-05-27 15:45:37 UTC (rev 7612) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/datanode/DatanodeImpl.java 2009-05-27 17:05:11 UTC (rev 7613) @@ -91,12 +91,8 @@ throws SmartFrogResolutionException, RemoteException { List<PortEntry> ports = super.buildPortList(conf); ports.add(resolvePortEntry(conf, DFS_DATANODE_HTTPS_ADDRESS)); - ports.add(resolvePortEntry(conf, DFS_DATANODE_ADDRESS, - DFS_DATANODE_BIND_ADDRESS, - DFS_DATANODE_PORT)); - ports.add(resolvePortEntry(conf, DFS_DATANODE_HTTP_ADDRESS, - DFS_DATANODE_INFO_BIND_ADDRESS, - DFS_DATANODE_INFO_BIND_PORT)); + ports.add(resolvePortEntry(conf, DFS_DATANODE_ADDRESS)); + ports.add(resolvePortEntry(conf, DFS_DATANODE_HTTP_ADDRESS)); ports.add(resolvePortEntry(conf, DFS_DATANODE_IPC_ADDRESS)); return ports; } Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/other/components.sf =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/other/components.sf 2009-05-27 15:45:37 UTC (rev 7612) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/other/components.sf 2009-05-27 17:05:11 UTC (rev 7613) @@ -49,7 +49,7 @@ message "Failed to load a JSP class. These may not have been compiled in correctly"; sfShouldTerminate true; - nn_jsphelper "org.apache.hadoop.hdfs.server.namenode.JspHelper"; + nn_jsphelper "org.apache.hadoop.hdfs.server.common.JspHelper"; nn_dfshealth "org.apache.hadoop.hdfs.server.namenode.dfshealth_jsp"; nn_dfsnodelist"org.apache.hadoop.hdfs.server.namenode.dfsnodelist_jsp"; dn_browseBlock "org.apache.hadoop.hdfs.server.datanode.browseBlock_jsp"; @@ -150,7 +150,7 @@ "org.apache.hadoop.hdfs.protocol.FSConstants", "org.apache.hadoop.hdfs.protocol.LocatedBlock", "org.apache.hadoop.hdfs.protocol.LocatedBlocks", - "org.apache.hadoop.hdfs.protocol.UnregisteredDatanodeException", + "org.apache.hadoop.hdfs.protocol.UnregisteredNodeException", "org.apache.hadoop.hdfs.server.common.GenerationStamp", "org.apache.hadoop.hdfs.server.common.HdfsConstants$StartupOption", "org.apache.hadoop.hdfs.server.common.Storage", @@ -204,7 +204,6 @@ "org.apache.hadoop.hdfs.protocol.DatanodeInfo", "org.apache.hadoop.hdfs.protocol.FSConstants", "org.apache.hadoop.hdfs.protocol.LocatedBlock", - "org.apache.hadoop.hdfs.protocol.UnregisteredDatanodeException", "org.apache.hadoop.hdfs.server.common.HdfsConstants", "org.apache.hadoop.hdfs.server.common.GenerationStamp", "org.apache.hadoop.hdfs.server.common.IncorrectVersionException", Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/conf/ManagedConfiguration.java =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/conf/ManagedConfiguration.java 2009-05-27 15:45:37 UTC (rev 7612) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/conf/ManagedConfiguration.java 2009-05-27 17:05:11 UTC (rev 7613) @@ -486,19 +486,13 @@ * Bind to a network address; something like "0.0.0.0:50030" is expected. * * @param addressName the property for the address - * @param bindAddressName old style hostname - * @param bindAddressPort old style host port * @return the host/port binding * @throws IllegalArgumentException if the arguments are bad - * @throws SmartFrogResolutionException if the address does not resolve + * @throws SmartFrogResolutionException if the addressName is not in the configuration */ - public InetSocketAddress bindToNetwork(String addressName, String bindAddressName, String bindAddressPort) + public InetSocketAddress bindToNetwork(String addressName) throws SmartFrogResolutionException { - String infoAddr = - NetUtils.getServerAddress(this, - bindAddressName, - bindAddressPort, - addressName); + String infoAddr = get(addressName, null); if (infoAddr == null) { throw new SmartFrogResolutionException("Failed to resolve " + addressName); } Modified: trunk/core/components/libraries.properties =================================================================== --- trunk/core/components/libraries.properties 2009-05-27 15:45:37 UTC (rev 7612) +++ trunk/core/components/libraries.properties 2009-05-27 17:05:11 UTC (rev 7613) @@ -101,7 +101,7 @@ #hadoop artifacts commons-cli.version=2.0-SNAPSHOT -hadoop.version=0.21.0-alpha-10 +hadoop.version=0.21.0-alpha-11 #hadoop.jetty.version=5.1.4 #hadoop.servlet-api.version=2.4 #hadoop.tomcat.version=5.5.12 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-06-08 10:36:35
|
Revision: 7630 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7630&view=rev Author: steve_l Date: 2009-06-08 10:33:38 +0000 (Mon, 08 Jun 2009) Log Message: ----------- SFOS-1216 some code is using Log.error(Object) and passing in an exception, causing the stack trace to get lost Modified Paths: -------------- trunk/core/components/emailer/src/org/smartfrog/services/email/EmailerImpl.java trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScriptingImpl.java trunk/core/components/quartz/src/org/smartfrog/services/quartz/monitor/MonitorImpl.java trunk/core/components/scripting/src/org/smartfrog/services/scripting/ScriptPrimImpl.java trunk/core/components/vmware/src/org/smartfrog/services/vmware/VMWareCommunicator.java trunk/core/components/vmware/src/org/smartfrog/services/vmware/VMWareServerManager.java trunk/core/components/www/src/org/smartfrog/services/www/dbc/DeployByCopyServerImpl.java trunk/core/components/xunit/src/org/smartfrog/services/sfunit/SFUnitTestSuiteImpl.java Modified: trunk/core/components/emailer/src/org/smartfrog/services/email/EmailerImpl.java =================================================================== --- trunk/core/components/emailer/src/org/smartfrog/services/email/EmailerImpl.java 2009-06-04 12:50:18 UTC (rev 7629) +++ trunk/core/components/emailer/src/org/smartfrog/services/email/EmailerImpl.java 2009-06-08 10:33:38 UTC (rev 7630) @@ -182,9 +182,9 @@ try { sendConfiguredMessage(); } catch (SmartFrogException e) { - log.error(e); + log.error(e, e); } catch (RemoteException e) { - log.error(e); + log.error(e, e); } } super.sfTerminateWith(tr); Modified: trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScriptingImpl.java =================================================================== --- trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScriptingImpl.java 2009-06-04 12:50:18 UTC (rev 7629) +++ trunk/core/components/groovy/src/org/smartfrog/services/scripting/javax/JavaxScriptingImpl.java 2009-06-08 10:33:38 UTC (rev 7630) @@ -109,11 +109,11 @@ try { engine.resolveAndEvaluate(ATTR_SF_TERMINATE_WITH_RESOURCE, ATTR_SF_TERMINATE_WITH_CODE); } catch (SmartFrogException e) { - sfLog().ignore(e); + sfLog().ignore(e, e); } catch (RemoteException e) { - sfLog().error(e); + sfLog().error(e, e); } catch (ScriptException e) { - sfLog().error(e); + sfLog().error(e, e); } super.sfTerminateWith(status); } Modified: trunk/core/components/quartz/src/org/smartfrog/services/quartz/monitor/MonitorImpl.java =================================================================== --- trunk/core/components/quartz/src/org/smartfrog/services/quartz/monitor/MonitorImpl.java 2009-06-04 12:50:18 UTC (rev 7629) +++ trunk/core/components/quartz/src/org/smartfrog/services/quartz/monitor/MonitorImpl.java 2009-06-08 10:33:38 UTC (rev 7630) @@ -261,7 +261,7 @@ } } } catch (Exception e) { - log.error(e); + log.error(e, e); } finally { FileSystem.close(pErr); FileSystem.close(pOut); Modified: trunk/core/components/scripting/src/org/smartfrog/services/scripting/ScriptPrimImpl.java =================================================================== --- trunk/core/components/scripting/src/org/smartfrog/services/scripting/ScriptPrimImpl.java 2009-06-04 12:50:18 UTC (rev 7629) +++ trunk/core/components/scripting/src/org/smartfrog/services/scripting/ScriptPrimImpl.java 2009-06-08 10:33:38 UTC (rev 7630) @@ -211,7 +211,7 @@ catch (SmartFrogResolutionException rex) { } catch (Exception e) { - sfLog().error(e); + sfLog().error(e, e); } super.sfTerminateWith(status); } Modified: trunk/core/components/vmware/src/org/smartfrog/services/vmware/VMWareCommunicator.java =================================================================== --- trunk/core/components/vmware/src/org/smartfrog/services/vmware/VMWareCommunicator.java 2009-06-04 12:50:18 UTC (rev 7629) +++ trunk/core/components/vmware/src/org/smartfrog/services/vmware/VMWareCommunicator.java 2009-06-08 10:33:38 UTC (rev 7630) @@ -265,7 +265,7 @@ try { reconnect(); } catch (SmartFrogException e) { - log.error(e); + log.error(e, e); } } Modified: trunk/core/components/vmware/src/org/smartfrog/services/vmware/VMWareServerManager.java =================================================================== --- trunk/core/components/vmware/src/org/smartfrog/services/vmware/VMWareServerManager.java 2009-06-04 12:50:18 UTC (rev 7629) +++ trunk/core/components/vmware/src/org/smartfrog/services/vmware/VMWareServerManager.java 2009-06-08 10:33:38 UTC (rev 7630) @@ -652,7 +652,7 @@ try { ps.waitFor(); } catch (InterruptedException e) { - sfLog().error(e); + sfLog().error(e, e); } Runtime.getRuntime().exec("net.exe stop \"VMware Authorization Service\""); } else { @@ -678,7 +678,7 @@ try { ps.waitFor(); } catch (InterruptedException e) { - sfLog().error(e); + sfLog().error(e, e); } Runtime.getRuntime().exec("net.exe start \"VMware Registration Service\""); } else { Modified: trunk/core/components/www/src/org/smartfrog/services/www/dbc/DeployByCopyServerImpl.java =================================================================== --- trunk/core/components/www/src/org/smartfrog/services/www/dbc/DeployByCopyServerImpl.java 2009-06-04 12:50:18 UTC (rev 7629) +++ trunk/core/components/www/src/org/smartfrog/services/www/dbc/DeployByCopyServerImpl.java 2009-06-08 10:33:38 UTC (rev 7630) @@ -378,7 +378,7 @@ queuedFile.execute(DeployByCopyServerImpl.this); } catch (SmartFrogDeploymentException e) { //log the error. which is stored in the queuedFile - sfLog().error(e); + sfLog().error(e, e); } } thread=null; Modified: trunk/core/components/xunit/src/org/smartfrog/services/sfunit/SFUnitTestSuiteImpl.java =================================================================== --- trunk/core/components/xunit/src/org/smartfrog/services/sfunit/SFUnitTestSuiteImpl.java 2009-06-04 12:50:18 UTC (rev 7629) +++ trunk/core/components/xunit/src/org/smartfrog/services/sfunit/SFUnitTestSuiteImpl.java 2009-06-08 10:33:38 UTC (rev 7630) @@ -266,9 +266,9 @@ try { sfRemoveChild(comp); } catch (SmartFrogRuntimeException e) { - sfLog().error(e); + sfLog().error(e, e); } catch (RemoteException e) { - sfLog().error(e); + sfLog().error(e, e); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-06-26 21:22:32
|
Revision: 7739 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7739&view=rev Author: steve_l Date: 2009-06-26 21:22:30 +0000 (Fri, 26 Jun 2009) Log Message: ----------- SFOS-1130 Prototype JAX-RS front-end for a long-haul API and client to go with Modified Paths: -------------- trunk/core/components/jetty/src/org/smartfrog/services/jetty/jetty-core.sf trunk/core/components/longhaul/build.xml trunk/core/components/longhaul/ivy.xml trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/AppEndpoint.java trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/EndpointBase.java Added Paths: ----------- trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/common/ trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/common/HtmlUtils.java trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/common/LifecycleStates.java trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/Applications.java trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/LonghaulRestServer.java trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/components.sf trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/jaxrs.sf Modified: trunk/core/components/jetty/src/org/smartfrog/services/jetty/jetty-core.sf =================================================================== --- trunk/core/components/jetty/src/org/smartfrog/services/jetty/jetty-core.sf 2009-06-26 20:59:44 UTC (rev 7738) +++ trunk/core/components/jetty/src/org/smartfrog/services/jetty/jetty-core.sf 2009-06-26 21:22:30 UTC (rev 7739) @@ -217,7 +217,7 @@ } -JettyHttpServer extends Compound { +CoreJettyHttpServer extends Compound { port AbstractConnector:port; host AbstractConnector:host; @@ -233,4 +233,9 @@ } -} \ No newline at end of file +} + +/** + * this name gest stamped on in jetty-complete + */ +JettyHttpServer extends CoreJettyHttpServer; \ No newline at end of file Modified: trunk/core/components/longhaul/build.xml =================================================================== --- trunk/core/components/longhaul/build.xml 2009-06-26 20:59:44 UTC (rev 7738) +++ trunk/core/components/longhaul/build.xml 2009-06-26 21:22:30 UTC (rev 7739) @@ -33,6 +33,7 @@ <property name="root.dir" location="../../" /> <property name="ivy.enabled" value="true"/> <property name="system.tests" value="false"/> + <property name="deploy.sf" value="org/smartfrog/services/longhaul/server/components.sf" /> <!-- Import common stuff --> <!--available file="../../common.xml" property="root.dir" value="../.."/--> Modified: trunk/core/components/longhaul/ivy.xml =================================================================== --- trunk/core/components/longhaul/ivy.xml 2009-06-26 20:59:44 UTC (rev 7738) +++ trunk/core/components/longhaul/ivy.xml 2009-06-26 21:22:30 UTC (rev 7739) @@ -51,6 +51,7 @@ changing="true" rev="latest.integration" conf="build->default"/> + <dependency org="org.smartfrog" name="sf-testharness" changing="true" @@ -60,8 +61,19 @@ <dependency org="com.sun.jersey" name="jersey-server" rev="${jersey.version}" - conf="compile,runtime,daemon->default" + conf="redist->default" /> + <dependency org="org.smartfrog" + name="sf-www" + changing="true" + rev="latest.integration" + conf="compile,runtime,daemon,test->default"/> + <dependency org="org.smartfrog" + name="sf-jetty" + changing="true" + rev="latest.integration" + conf="runtime,daemon->default"/> + </dependencies> </ivy-module> \ No newline at end of file Added: trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/common/HtmlUtils.java =================================================================== --- trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/common/HtmlUtils.java (rev 0) +++ trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/common/HtmlUtils.java 2009-06-26 21:22:30 UTC (rev 7739) @@ -0,0 +1,26 @@ +/** (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 + + */ +package org.smartfrog.services.longhaul.common; + +/** + * + */ +public class HtmlUtils { +} Added: trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/common/LifecycleStates.java =================================================================== --- trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/common/LifecycleStates.java (rev 0) +++ trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/common/LifecycleStates.java 2009-06-26 21:22:30 UTC (rev 7739) @@ -0,0 +1,31 @@ +/** (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 + + */ +package org.smartfrog.services.longhaul.common; + +/** + * + */ +public enum LifecycleStates { + undefined, + instantiated, + initialized, + failed, + terminated +} \ No newline at end of file Modified: trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/AppEndpoint.java =================================================================== --- trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/AppEndpoint.java 2009-06-26 20:59:44 UTC (rev 7738) +++ trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/AppEndpoint.java 2009-06-26 21:22:30 UTC (rev 7739) @@ -1,3 +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 + + */ package org.smartfrog.services.longhaul.server; import javax.ws.rs.GET; @@ -5,24 +24,21 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; -import org.smartfrog.SFSystem; -import org.smartfrog.sfcore.processcompound.ProcessCompound; - @Path("/applications/{application}") public class AppEndpoint extends EndpointBase { - - + public AppEndpoint() { - + } @GET @Produces("text/smartfrog") + @Path("/applications/{application}") public String getSystem(@PathParam("application") String application) { - - return ""; - } + return ""; + } + } Added: trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/Applications.java =================================================================== --- trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/Applications.java (rev 0) +++ trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/Applications.java 2009-06-26 21:22:30 UTC (rev 7739) @@ -0,0 +1,93 @@ +/** (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 + + */ +package org.smartfrog.services.longhaul.server; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.PathParam; +import java.rmi.RemoteException; +import java.util.List; + +/** + * List the applications that are running + */ +@Path("/applications/") +public class Applications extends EndpointBase { + + @GET + @Produces("text/plain") + public String doGetAsText() throws RemoteException { + List<ChildApplication> children = getApplications(); + StringBuilder builder=new StringBuilder(); + for(ChildApplication child:children) { + builder.append(child.key).append("\n"); + } + return builder.toString(); + } + + @GET + @Produces("text/json") + public String doGetAsJSON() throws RemoteException { + List<ChildApplication> children = getApplications(); + StringBuilder builder=new StringBuilder(); + builder.append("applications {\n"); + for(ChildApplication child:children) { + builder.append(" ") + .append(child.key) + .append(" ; ") + .append("\n"); + } + builder.append("}"); + return builder.toString(); + } + + + @GET + @Produces("text/html") + public String doGetAsHtml() throws RemoteException { + List<ChildApplication> children = getApplications(); + StringBuilder builder=new StringBuilder(); + builder.append("<html><head><title>Applications</title></head>\n"); + builder.append("<body>"); + builder.append("<span>Applications</span>"); + for(ChildApplication child:children) { + builder.append("<span>") + .append("<a href=\"").append(child.getSafename()).append("\"/>") + .append(child.key) + .append("</a>") + .append("</span>\n"); + } + builder.append("</body>"); + return builder.toString(); + + } + + + @GET + @Produces("text/smartfrog") + @Path("/{application}/") + public String getSystem(@PathParam("application") String application) { + + return ""; + + } + +} Modified: trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/EndpointBase.java =================================================================== --- trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/EndpointBase.java 2009-06-26 20:59:44 UTC (rev 7738) +++ trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/EndpointBase.java 2009-06-26 21:22:30 UTC (rev 7739) @@ -1,18 +1,36 @@ -/** - * +/** (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 + */ + package org.smartfrog.services.longhaul.server; -import java.rmi.RemoteException; - -import javax.ws.rs.Path; - import org.smartfrog.sfcore.common.SmartFrogCoreKeys; -import org.smartfrog.sfcore.common.SmartFrogException; -import org.smartfrog.sfcore.common.SmartFrogResolutionException; +import org.smartfrog.sfcore.prim.Liveness; +import org.smartfrog.sfcore.prim.Prim; import org.smartfrog.sfcore.processcompound.ProcessCompound; import org.smartfrog.sfcore.processcompound.SFProcess; +import java.rmi.RemoteException; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; + /** * @@ -20,25 +38,98 @@ public abstract class EndpointBase { - static ProcessCompound root; - + private static ProcessCompound rootProcess; + public EndpointBase() { - bindToRootProcess(); + bindToRootProcess(); } - static synchronized void bindToRootProcess() { - if(root==null) { - try { - ProcessCompound localProcess = SFProcess.getProcessCompound(); - root = SFProcess.getRootLocator().getRootProcessCompound(null, - ((Number) localProcess.sfResolveHere(SmartFrogCoreKeys.SF_ROOT_LOCATOR_PORT, false)).intValue()); - } catch (Exception e) { - //log and continue - } - } + static synchronized void bindToRootProcess() { + if (rootProcess == null) { + try { + ProcessCompound localProcess = SFProcess.getProcessCompound(); + rootProcess = localProcess; +/* + rootProcess = SFProcess.getRootLocator().getRootProcessCompound(null, + ((Number) localProcess + .sfResolveHere(SmartFrogCoreKeys.SF_ROOT_LOCATOR_PORT, false)).intValue()); +*/ + } catch (Exception e) { + //log and continue + } + } } - - - - + + + /** + * Get the root process, assuming we are bound + * @return the process + */ + public static ProcessCompound getRootProcess() { + return rootProcess; + } + + /** + * Get a list of child applications and keys + * @return a list of child applications and keys + * @throws RemoteException on network trouble + */ + public List<ChildApplication> getApplications() throws RemoteException { + List<ChildApplication> apps = new ArrayList<ChildApplication>(); + ProcessCompound root = getRootProcess(); + Enumeration<Liveness> children = root.sfChildren(); + while (children.hasMoreElements()) { + Liveness liveness = children.nextElement(); + Object key = root.sfAttributeKeyFor(liveness); + ChildApplication childApp = new ChildApplication(key, (Prim) liveness); + apps.add(childApp); + } + return apps; + } + + + /** + * Create a temporary file and register the file as an attachment + * @param extension extension to give it + * @return the new file + * @throws java.io.IOException if the file wont be created. + */ +/* public FileEntry createNewTempFile(String extension) throws IOException { + AddedFilestore filestore = getFilestore(); + FileEntry entry = filestore.createNewFile("file", extension); + addAttachment(entry); + return entry; + }*/ + + /** + * Add the attachment in the attachments table + * @param entry new file entry + */ +/* public synchronized void addAttachment(FileEntry entry) { + attachments.add(entry); + }*/ + + protected static class ChildApplication { + Object key; + String safename; + Prim application; + + public ChildApplication(Object key, Prim application) { + this.key = key; + this.safename = key.toString(); + this.application = application; + } + + public Object getKey() { + return key; + } + + public String getSafename() { + return safename; + } + + public Prim getApplication() { + return application; + } + } } Added: trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/LonghaulRestServer.java =================================================================== --- trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/LonghaulRestServer.java (rev 0) +++ trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/LonghaulRestServer.java 2009-06-26 21:22:30 UTC (rev 7739) @@ -0,0 +1,30 @@ +package org.smartfrog.services.longhaul.server; + +import javax.ws.rs.core.Application; +import java.util.HashSet; +import java.util.Set; + +/** + * This application defines the rest server + */ +public class LonghaulRestServer extends Application { + + /** {@inheritDoc */ + @Override + public Set<Class<?>> getClasses() { + return null; + /* + Set<Class<?>> classes = new HashSet<Class<?>>(); + classes.add(Applications.class); + return classes;*/ + } + + + /** {@inheritDoc */ + @Override + public Set<Object> getSingletons() { + Set<Object> singletons = new HashSet<Object>(); + singletons.add(new Applications()); + return singletons; + } +} Added: trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/components.sf =================================================================== --- trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/components.sf (rev 0) +++ trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/components.sf 2009-06-26 21:22:30 UTC (rev 7739) @@ -0,0 +1,56 @@ +/** (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/jetty/jetty-core.sf" +#include "/org/smartfrog/services/longhaul/server/jaxrs.sf" + + /** + * you need to deploy this to jetty or another servlet context to run it + */ +LonghaulRestServer extends JaxRSServlet { + name "LongHaul"; + ApplicationClassname "org.smartfrog.services.longhaul.server.LonghaulRestServer"; +} + +/** + * test with http://localhost:8080/applications/ + */ +RestServer extends CoreJettyHttpServer { + home "."; + + server:jettyhome home; + + servlets extends ServletContext { + server LAZY PARENT:server; + resourceBase "/"; + contextPath "/"; + } + + longhaulServer extends LonghaulRestServer { + context LAZY servlets; + } + + +} + +sfConfig extends RestServer { + +} + \ No newline at end of file Added: trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/jaxrs.sf =================================================================== --- trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/jaxrs.sf (rev 0) +++ trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/jaxrs.sf 2009-06-26 21:22:30 UTC (rev 7739) @@ -0,0 +1,41 @@ +/** (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 + + */ + + /* + This contains the servlet for JAXRS + see: + http://wikis.sun.com/display/Jersey/Overview+of+JAX-RS+1.0+Features + + */ + + +JaxRSServlet extends Servlet { + //order of initialisation; -1 means on demand. + className JERSEY_JAXRS_SERVLET; + initOrder -1; + ApplicationClassname TBD; + pathSpec "/"; + + JAVAX_WS_RS_APPLICATION "javax.ws.rs.Application"; + JERSEY_JAXRS_SERVLET "com.sun.jersey.spi.container.servlet.ServletContainer"; + initParams [ + [JAVAX_WS_RS_APPLICATION,ApplicationClassname ] + ]; +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-07-02 22:59:17
|
Revision: 7771 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7771&view=rev Author: steve_l Date: 2009-07-02 22:59:03 +0000 (Thu, 02 Jul 2009) Log Message: ----------- SFOS-905 Move from direct inherited configuration to a "Cluster" CD that defines the cluster Modified Paths: -------------- trunk/core/components/hadoop/build.xml trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/ClusterStatusCheckerImpl.java trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/HadoopComponentImpl.java trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/clusternode.sf trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/datanode/datanode.sf trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/hadoopconfiguration.sf trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/namenode/components.sf trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/namenode/namenode.sf trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/tracker/jobtracker.sf trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/conf/ClusterBound.java trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/conf/components.sf trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/core/SFHadoopException.java trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/examples/cluster-driven.sf trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/examples/lightweight.sf trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/examples/options.sf trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/examples/testjob.sf trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/examples/waitforservices.sf trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/conf/components.sf trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/clusterconf/components.sf trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/components.sf trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/Applications.java trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/EndpointBase.java Added Paths: ----------- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/conf/hostnames.sf trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/examples/healthchecks.sf trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/clusterconf/ClusterDrivenFilesystemTest.java trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/clusterconf/ClusterDrivenJobSubmitTest.java trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/clusterconf/testClusteredJobSubmit.sf trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/clusterconf/testClusteredJobTracker.sf Modified: trunk/core/components/hadoop/build.xml =================================================================== --- trunk/core/components/hadoop/build.xml 2009-07-02 22:57:32 UTC (rev 7770) +++ trunk/core/components/hadoop/build.xml 2009-07-02 22:59:03 UTC (rev 7771) @@ -36,6 +36,8 @@ <!--we are a component --> <property name="is.component" value="true"/> <property name="ivy.enabled" value="true"/> + <!-- tests are on--> + <!--<property name="system.tests" value="true"/>--> <property name="junit.timeout" value="12000000"/> <!--time for a single test to execute--> <property name="test.timeout.execute" value="120000"/> Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/ClusterStatusCheckerImpl.java =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/ClusterStatusCheckerImpl.java 2009-07-02 22:57:32 UTC (rev 7770) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/ClusterStatusCheckerImpl.java 2009-07-02 22:59:03 UTC (rev 7771) @@ -214,14 +214,14 @@ throw new SFHadoopException("Job Tracker at " + jobtracker + " is not running. It is in the state " + state, this); } - result.append("Job tracker is in state " + status); + result.append("Job tracker is in state ").append(status); } checkRange(minActiveMapTasks, maxActiveMapTasks, status.getMapTasks(), "map task"); checkRange(minActiveReduceTasks, maxActiveReduceTasks, status.getReduceTasks(), "reduce task"); checkMax(maxSupportedMapTasks, status.getMaxMapTasks(), "supported max map task"); checkMax(maxSupportedReduceTasks, status.getMaxReduceTasks(), "supported max reduce task"); - result.append(" Map Tasks = "+ status.getMapTasks()); - result.append(" Reduce Tasks = " + status.getReduceTasks()); + result.append(" Map Tasks = ").append(status.getMapTasks()); + result.append(" Reduce Tasks = ").append(status.getReduceTasks()); return result.toString(); } catch (IOException e) { throw new SFHadoopException("Cannot connect to" + jobtracker, e, this); @@ -262,7 +262,7 @@ * @throws RemoteException for network problems * @throws SmartFrogException for any other problem */ - //@Override + @Override public boolean evaluate() throws RemoteException, SmartFrogException { boolean live; String description; Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/HadoopComponentImpl.java =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/HadoopComponentImpl.java 2009-07-02 22:57:32 UTC (rev 7770) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/HadoopComponentImpl.java 2009-07-02 22:59:03 UTC (rev 7771) @@ -53,7 +53,7 @@ if (sfLog().isDebugEnabled()) { ManagedConfiguration configuration; configuration = createConfiguration(); - sfLog().debug(configuration.dump()); + debugDumpConfiguration(configuration); } } @@ -86,8 +86,9 @@ * @return the target configuration * @throws SmartFrogResolutionException resolution failure * @throws RemoteException network problems */ - protected ManagedConfiguration createConfiguration(Prim target) throws SmartFrogException, RemoteException { - return ManagedConfiguration.createConfiguration(target, true, false, false); + private ManagedConfiguration createConfiguration(Prim target) throws SmartFrogException, RemoteException { + boolean clusterRequired = sfResolve(ATTR_CLUSTER_REQUIRED, false, false); + return ManagedConfiguration.createConfiguration(target, true, clusterRequired, false); } Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/clusternode.sf =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/clusternode.sf 2009-07-02 22:57:32 UTC (rev 7770) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/clusternode.sf 2009-07-02 22:59:03 UTC (rev 7771) @@ -35,10 +35,10 @@ /** * This is a cluster node where the configuration comes from - * referenced attribute "cluster"; there are no other defaults + * referenced attribute "cluster"; there are no defaults */ ClusteredNode extends Prim { name "ClusteredNode"; + clusterRequired false; node.enabled true; - //cluster TBD; } \ No newline at end of file Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/datanode/datanode.sf =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/datanode/datanode.sf 2009-07-02 22:57:32 UTC (rev 7770) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/datanode/datanode.sf 2009-07-02 22:59:03 UTC (rev 7771) @@ -22,15 +22,14 @@ * A datanode represents a worker in the farm */ -DataNodeWithCluster extends ClusteredFileSystemNode { - name DataNode:name; - sfClass DataNode:sfClass; -} - -DataNode extends FileSystemNode { +ClusteredDataNode extends ClusteredFileSystemNode { name "DataNode" sfClass "org.smartfrog.services.hadoop.components.datanode.DatanodeImpl"; +} +DataNode extends ClusteredDataNode, FileSystemNode { + + //hadoop configuration values below dfs.balance.bandwidthPerSec (1024 * 1024); Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/hadoopconfiguration.sf =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/hadoopconfiguration.sf 2009-07-02 22:57:32 UTC (rev 7770) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/hadoopconfiguration.sf 2009-07-02 22:59:03 UTC (rev 7771) @@ -38,13 +38,15 @@ */ #include "/org/smartfrog/components.sf" +#include "/org/smartfrog/services/hadoop/conf/hostnames.sf" + /** * This is a hadoop configuration * Its values come from the hadoop source, and the file hadoop-default.xml, which is inside * hadoop-core.jar */ -HadoopConfiguration extends Prim { +HadoopConfiguration extends Prim, HadoopHostnameConfiguration { //Smartfrog custom properties smartfrog.dump.conf false; @@ -87,44 +89,7 @@ */ dfs.data.dir (hadoop.tmp.dir ++ "/dfs/data"); - /** - * hostnames - */ - LOCALHOST "127.0.0.1"; - ALL_ZEROS "0.0.0.0"; - ANY_HOST ALL_ZEROS; - ANY_PORT "0"; - DEFAULT_HOSTNAME LOCALHOST; - /** - The address where the datanode server will listen to. - If the port is 0 then the server will start on a free port. - */ - DFS_DATANODE_ADDRESS_DEFAULT_PORT "50010"; - DFS_DATANODE_DEFAULT_HOSTNAME DEFAULT_HOSTNAME; - dfs.datanode.hostname DFS_DATANODE_DEFAULT_HOSTNAME; - dfs.datanode.port DFS_DATANODE_ADDRESS_DEFAULT_PORT; - dfs.datanode.address (dfs.datanode.hostname ++ ":" ++ dfs.datanode.port); - - /** - The datanode http server address and port. - If the port is 0 then the server will start on a free port. - */ - DFS_DATANODE_HTTP_DEFAULT_PORT "50075"; - dfs.datanode.http.port DFS_DATANODE_HTTP_DEFAULT_PORT; - dfs.datanode.http.address (dfs.datanode.hostname ++ ":" ++ dfs.datanode.http.port); - - DFS_DATANODE_HTTPS_PORT "50475"; - dfs.datanode.https.port DFS_DATANODE_HTTPS_PORT; - dfs.datanode.https.address (dfs.datanode.hostname ++ ":" ++ dfs.datanode.https.port); - - /** - The datanode ipc server address and port. - If the port is 0 then the server will start on a free port. - */ - DFS_DATANODE_IPC_DEFAULT_PORT "50020"; - dfs.datanode.ipc.port DFS_DATANODE_IPC_DEFAULT_PORT; - dfs.datanode.ipc.address (dfs.datanode.hostname ++ ":" ++ dfs.datanode.ipc.port); /** The name of the Network Interface from which a data node should @@ -178,20 +143,8 @@ dfs.hosts.exclude ""; - /** - The address and the base port where the dfs namenode web ui will listen on. - If the port is 0 then the server will start on a free port. - */ - DFS_HTTP_DEFAULT_PORT "50070"; - DFS_HTTPS_DEFAULT_PORT "50470"; - DFS_HOSTNAME DEFAULT_HOSTNAME; - dfs.hostname DFS_HOSTNAME; - dfs.http.port DFS_HTTP_DEFAULT_PORT; - dfs.https.port DFS_HTTPS_DEFAULT_PORT; + - dfs.http.address (dfs.hostname ++ ":" ++ dfs.http.port); - dfs.https.address (dfs.hostname ++ ":" ++ dfs.https.port); - /** The logging level for dfs namenode. @@ -296,16 +249,6 @@ /** - The secondary namenode http server address and port. - If the port is 0 then the server will start on a free port. - */ - DFS_SECONDARY_HTTP_DEFAULT_PORT "50090"; - DFS_SECONDARY_HOSTNAME DEFAULT_HOSTNAME; - dfs.secondary.hostname DFS_SECONDARY_HOSTNAME; - dfs.secondary.http.port DFS_SECONDARY_HTTP_DEFAULT_PORT; - dfs.secondary.http.address (dfs.secondary.hostname ++ ":" ++ dfs.secondary.http.port); - - /** The user account used by the web interface. Syntax: USERNAME,GROUP1,GROUP2, ... */ @@ -808,18 +751,6 @@ /** - The host and port that the MapReduce job tracker runs - at. If "local", then jobs are run in-process as a single map - and reduce task. - */ - MAPRED_JOB_TRACKER_DEFAULT_PORT "8012"; - //mapred.job.tracker ("localhost:" ++ MAPRED_JOB_TRACKER_DEFAULT_PORT); - MAPRED_JOB_TRACKER_HOSTNAME DEFAULT_HOSTNAME; - mapred.job.tracker.hostname MAPRED_JOB_TRACKER_HOSTNAME; - mapred.job.tracker.port MAPRED_JOB_TRACKER_DEFAULT_PORT; - mapred.job.tracker (mapred.job.tracker.hostname ++ ":" ++ mapred.job.tracker.port); - - /** The maximum number of complete jobs per user to keep around before delegating them to the job history. */ @@ -831,16 +762,10 @@ */ mapred.job.tracker.handler.count 10; - /** - The job tracker http server address and port the server will listen on. - If the port is 0 then the server will start on a free port. - */ - MAPRED_JOB_TRACKER_HTTP_DEFAULT_PORT "50030"; - mapred.job.tracker.http.port MAPRED_JOB_TRACKER_HTTP_DEFAULT_PORT; //mapred.job.tracker ("localhost:" ++ MAPRED_JOB_TRACKER_DEFAULT_PORT); - mapred.job.tracker.http.address (mapred.job.tracker.hostname ++ ":" ++ mapred.job.tracker.http.port); + /** Indicates if persistency of job status information is active or not. @@ -1072,30 +997,13 @@ */ mapred.tasktracker.reduce.tasks.minimum 2; - /** - The interface and port that task tracker server listens on. - Since it is only connected to by the tasks, it uses the local interface. - EXPERT ONLY. Should only be changed if your host does not have the loopback - interface.*/ - mapred.task.tracker.report.hostname LOCALHOST; - mapred.task.tracker.report.port ANY_PORT; - mapred.task.tracker.report.address (mapred.task.tracker.report.hostname ++ ":" ++ mapred.task.tracker.report.port); - + /** The number of worker threads that for the http server. This is used for map output fetching */ tasktracker.http.threads 40; - /** - The task tracker http server address and port. - If the port is 0 then the server will start on a free port. - */ - MAPRED_TASK_TRACKER_HOSTNAME DEFAULT_HOSTNAME; - mapred.task.tracker.hostname MAPRED_TASK_TRACKER_HOSTNAME; - MAPRED_TASK_TRACKER_HTTP_DEFAULT_PORT "50060"; - mapred.task.tracker.http.port MAPRED_TASK_TRACKER_HTTP_DEFAULT_PORT; - mapred.task.tracker.http.address (mapred.task.tracker.hostname ++ ":" ++ mapred.task.tracker.http.port); /** @@ -1187,7 +1095,7 @@ * Used to describe the priority of the running job. * */ -JobPriority extends NULL{ +JobPriority extends NULL { VeryHigh "VERY_HIGH"; High "HIGH"; Normal "NORMAL"; Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/namenode/components.sf =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/namenode/components.sf 2009-07-02 22:57:32 UTC (rev 7770) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/namenode/components.sf 2009-07-02 22:59:03 UTC (rev 7771) @@ -25,36 +25,18 @@ ClusteredNameDirNode extends ClusteredFileSystemNode { //name directory: a List of directories nameDirectories TBD; + } NameDirNode extends ClusteredNameDirNode, FileSystemNode { } -/** - * Extend NameDirNode with dataDirectories and a log directory - */ -ClusteredNameDataLogNode extends ClusteredNameDirNode { - //the data directories, again a list of directories - dataDirectories TBD; - //log directory - logDir TBD; -} -/** - * Extend NameDirNode with dataDirectories and a log directory - */ -NameDataLogNode extends ClusteredNameDataLogNode, FileSystemNode { -} - - - - - #include "/org/smartfrog/services/hadoop/components/namenode/format.sf" #include "/org/smartfrog/services/hadoop/components/namenode/namenode.sf" Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/namenode/namenode.sf =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/namenode/namenode.sf 2009-07-02 22:57:32 UTC (rev 7770) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/namenode/namenode.sf 2009-07-02 22:59:03 UTC (rev 7771) @@ -18,7 +18,31 @@ */ + + /** + * Extend NameDirNode with dataDirectories and a log directory + */ +ClusteredNameNode extends ClusteredNameDirNode { + sfClass "org.smartfrog.services.hadoop.components.namenode.NamenodeImpl"; + name "NameNode"; + + //the data directories, again a list of directories + dataDirectories TBD; + + //log directory + logDir TBD; + + //check the name node is live when we ping the component + checkRunning true; + //should we expect the node to terminate itself + expectNodeTermination false; + sfShouldTerminate false; + +} + + +/** * A name node is one of the most critical part of an HDFS cluster; it is * the directory server. * -deploy it onto high quality storage @@ -35,10 +59,8 @@ */ -NameNode extends NameDataLogNode { - sfClass "org.smartfrog.services.hadoop.components.namenode.NamenodeImpl"; - name "NameNode"; +NameNode extends ClusteredNameNode, FileSystemNode { //startup mode dfs.namenode.startup ACTION_REGULAR; @@ -80,19 +102,5 @@ dfs.safemode.extension 0; - - - //check the name node is live when we ping the component - checkRunning true; - //should we expect the node to terminate itself - expectNodeTermination false; - sfShouldTerminate false; } -NameNodeWithCluster extends ClusteredNameDataLogNode { - name NameNode:name; - sfClass NameNode:sfClass; - checkRunning NameNode:checkRunning; - expectNodeTermination NameNode:expectNodeTermination ; - sfShouldTerminate NameNode:sfShouldTerminate; -} \ No newline at end of file Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/tracker/jobtracker.sf =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/tracker/jobtracker.sf 2009-07-02 22:57:32 UTC (rev 7770) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/tracker/jobtracker.sf 2009-07-02 22:59:03 UTC (rev 7771) @@ -30,6 +30,6 @@ */ } -JobTracker extends InlineConfiguredNode, ClusteredJobTracker { +JobTracker extends ClusteredJobTracker, InlineConfiguredNode{ } \ No newline at end of file Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/conf/ClusterBound.java =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/conf/ClusterBound.java 2009-07-02 22:57:32 UTC (rev 7770) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/conf/ClusterBound.java 2009-07-02 22:59:03 UTC (rev 7771) @@ -31,4 +31,5 @@ * {@value} */ String ATTR_CLUSTER = "cluster"; + String ATTR_CLUSTER_REQUIRED = "clusterRequired" ; } Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/conf/components.sf =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/conf/components.sf 2009-07-02 22:57:32 UTC (rev 7770) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/conf/components.sf 2009-07-02 22:59:03 UTC (rev 7771) @@ -18,6 +18,7 @@ */ #include "/org/smartfrog/components.sf" +#include "/org/smartfrog/services/hadoop/conf/hostnames.sf" /** * This file defines SF components to work with Hadoop configuration files @@ -54,6 +55,9 @@ conf.load.defaults true; } +HadoopConfigurationWithHostnameSetup extends DefaultHadoopConfiguration, HadoopHostnameConfiguration { + +} /** * A component to verify that expected components match what is expected */ Added: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/conf/hostnames.sf =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/conf/hostnames.sf (rev 0) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/conf/hostnames.sf 2009-07-02 22:59:03 UTC (rev 7771) @@ -0,0 +1,130 @@ +/* (C) Copyright 2008-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 + +*/ + +/** + * This is where all the hostnames are worked out. It is kept separate and merged in where needed + */ +HadoopHostnameConfiguration extends { + +/** + * hostnames + */ + LOCALHOST "127.0.0.1"; + ALL_ZEROS "0.0.0.0"; + ANY_HOST ALL_ZEROS; + ANY_PORT "0"; + DEFAULT_HOSTNAME LOCALHOST; + /** + The address where the datanode server will listen to. + If the port is 0 then the server will start on a free port. + */ + DFS_DATANODE_ADDRESS_DEFAULT_PORT "50010"; + DFS_DATANODE_DEFAULT_HOSTNAME DEFAULT_HOSTNAME; + dfs.datanode.hostname DFS_DATANODE_DEFAULT_HOSTNAME; + dfs.datanode.port DFS_DATANODE_ADDRESS_DEFAULT_PORT; + dfs.datanode.address (dfs.datanode.hostname ++ ":" ++ dfs.datanode.port); + + + /** + The datanode http server address and port. + If the port is 0 then the server will start on a free port. + */ + DFS_DATANODE_HTTP_DEFAULT_PORT "50075"; + dfs.datanode.http.port DFS_DATANODE_HTTP_DEFAULT_PORT; + dfs.datanode.http.address (dfs.datanode.hostname ++ ":" ++ dfs.datanode.http.port); + + DFS_DATANODE_HTTPS_PORT "50475"; + dfs.datanode.https.port DFS_DATANODE_HTTPS_PORT; + dfs.datanode.https.address (dfs.datanode.hostname ++ ":" ++ dfs.datanode.https.port); + + /** + The datanode ipc server address and port. + If the port is 0 then the server will start on a free port. + */ + DFS_DATANODE_IPC_DEFAULT_PORT "50020"; + dfs.datanode.ipc.port DFS_DATANODE_IPC_DEFAULT_PORT; + dfs.datanode.ipc.address (dfs.datanode.hostname ++ ":" ++ dfs.datanode.ipc.port); + /** + The address and the base port where the dfs namenode web ui will listen on. + If the port is 0 then the server will start on a free port. + */ + DFS_HTTP_DEFAULT_PORT "50070"; + DFS_HTTPS_DEFAULT_PORT "50470"; + DFS_HOSTNAME DEFAULT_HOSTNAME; + dfs.hostname DFS_HOSTNAME; + dfs.http.port DFS_HTTP_DEFAULT_PORT; + dfs.https.port DFS_HTTPS_DEFAULT_PORT; + + dfs.http.address (dfs.hostname ++ ":" ++ dfs.http.port); + dfs.https.address (dfs.hostname ++ ":" ++ dfs.https.port); + + + /** + The secondary namenode http server address and port. + If the port is 0 then the server will start on a free port. + */ + DFS_SECONDARY_HTTP_DEFAULT_PORT "50090"; + DFS_SECONDARY_HOSTNAME DEFAULT_HOSTNAME; + dfs.secondary.hostname DFS_SECONDARY_HOSTNAME; + dfs.secondary.http.port DFS_SECONDARY_HTTP_DEFAULT_PORT; + dfs.secondary.http.address (dfs.secondary.hostname ++ ":" ++ dfs.secondary.http.port); + + /** + The host and port that the MapReduce job tracker runs + at. If "local", then jobs are run in-process as a single map + and reduce task. + */ + MAPRED_JOB_TRACKER_DEFAULT_PORT "8012"; + + MAPRED_JOB_TRACKER_HOSTNAME DEFAULT_HOSTNAME; + mapred.job.tracker.hostname MAPRED_JOB_TRACKER_HOSTNAME; + mapred.job.tracker.port MAPRED_JOB_TRACKER_DEFAULT_PORT; + mapred.job.tracker (mapred.job.tracker.hostname ++ ":" ++ mapred.job.tracker.port); + + /** + The job tracker http server address and port the server will listen on. + If the port is 0 then the server will start on a free port. + */ + MAPRED_JOB_TRACKER_HTTP_DEFAULT_PORT "50030"; + mapred.job.tracker.http.port MAPRED_JOB_TRACKER_HTTP_DEFAULT_PORT; + //mapred.job.tracker ("localhost:" ++ MAPRED_JOB_TRACKER_DEFAULT_PORT); + mapred.job.tracker.http.address (mapred.job.tracker.hostname ++ ":" ++ mapred.job.tracker.http.port); + + + /** + The interface and port that task tracker server listens on. + Since it is only connected to by the tasks, it uses the local interface. + EXPERT ONLY. Should only be changed if your host does not have the loopback + interface.*/ + mapred.task.tracker.report.hostname LOCALHOST; + mapred.task.tracker.report.port ANY_PORT; + mapred.task.tracker.report.address (mapred.task.tracker.report.hostname ++ ":" ++ mapred.task.tracker.report.port); + + + /** + The task tracker http server address and port. + If the port is 0 then the server will start on a free port. + */ + MAPRED_TASK_TRACKER_HOSTNAME DEFAULT_HOSTNAME; + mapred.task.tracker.hostname MAPRED_TASK_TRACKER_HOSTNAME; + MAPRED_TASK_TRACKER_HTTP_DEFAULT_PORT "50060"; + mapred.task.tracker.http.port MAPRED_TASK_TRACKER_HTTP_DEFAULT_PORT; + mapred.task.tracker.http.address (mapred.task.tracker.hostname ++ ":" ++ mapred.task.tracker.http.port); +} \ No newline at end of file Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/core/SFHadoopException.java =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/core/SFHadoopException.java 2009-07-02 22:57:32 UTC (rev 7770) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/core/SFHadoopException.java 2009-07-02 22:59:03 UTC (rev 7771) @@ -89,6 +89,7 @@ * * @param message exception message * @param sfObject The Component that has encountered the exception + * @param conf the configuration at the time */ public SFHadoopException(String message, Prim sfObject, ManagedConfiguration conf) { super(message, sfObject); @@ -124,6 +125,7 @@ * @param message message * @param cause exception causing this exception * @param sfObject The Component that has encountered the exception + * @param conf the configuration at the time */ public SFHadoopException(String message, Throwable cause, Prim sfObject, ManagedConfiguration conf) { super(message, cause, sfObject); @@ -166,6 +168,10 @@ @SuppressWarnings("unchecked") public static SFHadoopException forward(String message, MultiException multiExcept, Prim sfObject, ManagedConfiguration conf) { + if(multiExcept == null) { + //no value, hand off to the other handler + return forward(message,(Throwable)null, sfObject, conf); + } List<Throwable> exceptions = (List < Throwable >) multiExcept.getThrowables(); int exCount = exceptions.size(); if (exCount == 1) { Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/examples/cluster-driven.sf =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/examples/cluster-driven.sf 2009-07-02 22:57:32 UTC (rev 7770) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/examples/cluster-driven.sf 2009-07-02 22:59:03 UTC (rev 7771) @@ -23,48 +23,71 @@ * the hadoop XML files */ -#include "/org/smartfrog/services/hadoop/components/components.sf" -#include "/org/smartfrog/services/hadoop/examples/options.sf" +//#include "/org/smartfrog/services/hadoop/components/components.sf" +//#include "/org/smartfrog/services/hadoop/examples/options.sf" -LightweightClusterConf extends DefaultHadoopConfiguration { +LightweightCluster extends Hostnames, HadoopConfigurationWithHostnameSetup { fs.default.name FS.DEFAULT.NAME; - mapred.job.tracker.handler.count HandlerThreads; - tasktracker.http.threads ClientHandlerThreads; - mapred.task.tracker.connect.timeout IPC_CONNECT_TIMEOUT; - dfs.heartbeat.interval 1; - dfs.datanode.handler.count ClientHandlerThreads; namenodeURL NAME_NODE_URL; datanodeURL DATA_NODE_URL ; hostaddress LOCALHOST; - ANY_PORT "0"; + //dfs.hostname hostaddress; - dfs.datanode.hostname hostaddress; - dfs.datanode.port ANY_PORT; + dfs.blockreport.intervalMsec DFS_BLOCKREPORT_INTERVALMSEC; + dfs.blockreport.initialDelay DFS_BLOCKREPORT_INITIALDELAY; + dfs.datanode.hostname Hostnames:dfs.datanode.hostname; + dfs.datanode.handler.count ClientHandlerThreads; dfs.datanode.http.port ANY_PORT; dfs.datanode.https.port ANY_PORT; dfs.datanode.ipc.port ANY_PORT; - dfs.blockreport.intervalMsec 10000; - dfs.blockreport.initialDelay 0; + dfs.heartbeat.interval 1; + //these properties set the HTTP ports. The NN gets its IPC port from the fs.default.name URL + //dfs.hostname hostname; + dfs.http.address namenodeURL; + dfs.http.port NameNodeHttpPort; + dfs.https.port NameNodeHttpPort; + dfs.replication DFS.REPLICATION; + + dfs.namenode.handler.count HandlerThreads; dfs.namenode.startup NameNode:ACTION_FORMAT; dfs.permissions false; - dfs.http.address namenodeURL; - dfs.permissions false; - mapred.job.tracker.hostname hostaddress; + + ipc.client.connect.max.retries LIGHTWEIGHT_MAX_RETRIES; + + mapred.job.reuse.jvm.num.tasks JVM_REUSE_COUNT; + mapred.job.tracker.handler.count HandlerThreads; + mapred.job.tracker.hostname Hostnames:mapred.job.tracker.hostname; mapred.job.tracker.http.hostname hostaddress; mapred.job.tracker.http.port ANY_PORT; mapred.task.tracker.hostname hostaddress; mapred.task.tracker.http.port ANY_PORT; + mapred.task.tracker.connect.timeout IPC_CONNECT_TIMEOUT; + tasktracker.http.threads ClientHandlerThreads; + + smartfrog.dump.conf DUMP_CONF; } + + +LogDirCompound extends Compound { + + enabled true; + + + logDir extends TempDir { + + } + +} + /** * The cluster compound takes the conf and adds some temp directories */ -ClusterCompound extends Compound { +DataDirCompound extends LogDirCompound { - conf extends LightweightClusterConf; logDir extends TempDir { @@ -80,18 +103,21 @@ } -NameNodeClusterCompound extends ClusterCompound { +NameNodeClusterCompound extends DataDirCompound { description "A name node"; - namenode extends NameNodeWithCluster { - cluster LAZY PARENT:conf; + service extends ClusteredNameNode { + clusterRequired true; + service.enabled PARENT:enabled; + cluster LAZY PARENT:cluster; dataDir LAZY PARENT:dataDir; dataDirectories [dataDir]; nameDirectory LAZY PARENT:nameDir; nameDirectories [nameDirectory]; logDir LAZY PARENT:logDir; + testModeDeleteDirectories TEST_MODE; minWorkerCount 0; } } @@ -99,17 +125,91 @@ /** * Creates a namenode */ -DataNodeClusterCompound extends NameNodeClusterCompound { +DataNodeClusterCompound extends DataDirCompound { description "A data node bound to a temporary directory"; localDataDir extends TempDir { } - datanode extends DataNodeWithCluster { - cluster LAZY PARENT:conf; + service extends ClusteredDataNode { + clusterRequired true; + cluster LAZY PARENT:cluster; + service.enabled PARENT:enabled; dataDirectories [LAZY localDataDir]; logDir LAZY PARENT:logDir; } } + +JobTrackerClusterCompound extends DataDirCompound { + service extends ClusteredJobTracker { + clusterRequired true; + cluster LAZY PARENT:cluster; + service.enabled PARENT:enabled; + dataDir LAZY PARENT:ATTRIB dataDir; + dataDirectories [dataDir]; + nameDir LAZY PARENT:ATTRIB nameDir; + nameDirectories [nameDir]; + logDir LAZY PARENT:ATTRIB logDir; + } +} + + +/** + * This is a task tracker + */ + + +TaskTrackerClusterCompound extends LogDirCompound { + + description "A compound with a task tracker"; + + service extends ClusteredTaskTracker { + clusterRequired true; + cluster LAZY PARENT:cluster; + service.enabled PARENT:enabled; + } +} + +/** + * This is a configured cluster. What's interesting about it is how + * the services run in master or slave mode (both on by default); + * these can be tuned to switch nodes between master or slave + * based on run-time decisions + */ +ConfiguredHdfsCluster extends Compound { + + //two flags which control whether or not the node is live or not + master true; + slave true; + + //this defines the cluster for everything + + cluster extends LightweightCluster; + + namenode extends NameNodeClusterCompound { + enabled master; + cluster LAZY PARENT:cluster; + } + datanode extends DataNodeClusterCompound { + enabled slave; + cluster LAZY PARENT:cluster; + } + + +} + +ConfiguredCluster extends ConfiguredHdfsCluster { + + jobtracker extends JobTrackerClusterCompound { + enabled master; + cluster LAZY PARENT:cluster; + } + tasktracker extends TaskTrackerClusterCompound { + enabled slave; + cluster LAZY PARENT:cluster; + } + +} + Copied: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/examples/healthchecks.sf (from rev 7753, trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/examples/lightweight.sf) =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/examples/healthchecks.sf (rev 0) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/examples/healthchecks.sf 2009-07-02 22:59:03 UTC (rev 7771) @@ -0,0 +1,40 @@ +/* (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 + +*/ + + +HealthCheck extends Sequence { + description "a sequence to deploy on startup to check health of the system"; + checkJava6PlusClassesPresent CheckJava6PlusClassesPresent; + checkJspHelperClasses CheckJspHelperClasses; + checkNamenodeJspClasses CheckNamenodeJspClasses; + checkJobtrackerJspClasses CheckJobtrackerJspClasses; + checkDatanodeJspClasses CheckDatanodeJspClasses; + checkJspClassesPresent HadoopJspClasses; + checkPolicyPermissions extends CheckPolicyPermissionsAddSupported; +} + +LiveHealthCheck extends Compound { + description "something to deploy to check the ongoing health of the system"; + checkPolicyPermissions extends CheckPolicyPermissionsAddSupported { + sfShouldTerminate false; + } + + +} Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/examples/lightweight.sf =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/examples/lightweight.sf 2009-07-02 22:57:32 UTC (rev 7770) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/examples/lightweight.sf 2009-07-02 22:59:03 UTC (rev 7771) @@ -27,16 +27,10 @@ #include "/org/smartfrog/services/hadoop/components/components.sf" #include "/org/smartfrog/services/hadoop/examples/options.sf" #include "/org/smartfrog/services/utils/security/components.sf" +#include "/org/smartfrog/services/hadoop/examples/healthchecks.sf" -Hostnames extends { - ALL_ZEROS JobTracker:ALL_ZEROS; - dfs.datanode.hostname ALL_ZEROS; - mapred.job.tracker.hostname ALL_ZEROS; - mapred.task.tracker.hostname ALL_ZEROS; -} - LightweightJobTracker extends JobTracker { smartfrog.dump.conf DUMP_CONF; fs.default.name FS.DEFAULT.NAME; @@ -80,9 +74,8 @@ dfs.datanode.port DataNodePort; dfs.datanode.ipc.port DataNodeIpcPort; - - dfs.blockreport.intervalMsec 10000; - dfs.blockreport.initialDelay 0; + dfs.blockreport.intervalMsec DFS_BLOCKREPORT_INTERVALMSEC; + dfs.blockreport.initialDelay DFS_BLOCKREPORT_INITIALDELAY; testModeDeleteDirectories TEST_MODE; } @@ -213,36 +206,8 @@ tasktracker extends LightweightTaskTracker { fs.default.name PARENT:ATTRIB fs.default.name; mapred.job.tracker LAZY PARENT:ATTRIB mapred.job.tracker; - //yes, this is milliseconds. But there is a sleep involved too - // mapred.task.tracker.connect.timeout ORPHAN_CONNECT_TIMEOUT; - //"ipc.client.connect.max.retries" - //ipc.client.connect.max.retries ORPHAN_CONNECT_MAX_RETRIES; - } } -/** - * This is a sequence to check the system is well - */ - -HealthCheck extends Sequence { - description "a sequence to deploy on startup to check health of the system"; - checkJava6PlusClassesPresent CheckJava6PlusClassesPresent; - checkJspHelperClasses CheckJspHelperClasses; - checkNamenodeJspClasses CheckNamenodeJspClasses; - checkJobtrackerJspClasses CheckJobtrackerJspClasses; - checkDatanodeJspClasses CheckDatanodeJspClasses; - checkJspClassesPresent HadoopJspClasses; - checkPolicyPermissions extends CheckPolicyPermissionsAddSupported; -} - -LiveHealthCheck extends Compound { - description "something to deploy to check the ongoing health of the system"; - checkPolicyPermissions extends CheckPolicyPermissionsAddSupported { - sfShouldTerminate false; - } - - -} Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/examples/options.sf =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/examples/options.sf 2009-07-02 22:57:32 UTC (rev 7770) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/examples/options.sf 2009-07-02 22:59:03 UTC (rev 7771) @@ -48,6 +48,8 @@ LOCALHOST "localhost"; IP_V4_LOCALHOST "127.0.0.1"; ANY_HOST ALL_ZEROS; +ANY_PORT "0"; + FS.DEFAULT.NAME ("hdfs://" ++ LOCALHOST ++ ":" ++ NameNodeIpcPort ); NAME_NODE_URL ("http://" ++ LOCALHOST ++ ":" ++ NameNodeHttpPort ); DATA_NODE_URL ("http://" ++ LOCALHOST ++ ":" ++ DataNodeHttpPort ); @@ -67,7 +69,18 @@ CLUSTER_POLL_INTERVAL 200; CLUSTER_SHUTDOWN_TIMEOUT 10000; + +DFS_BLOCKREPORT_INTERVALMSEC 10000; +DFS_BLOCKREPORT_INITIALDELAY 10000; + JOB_EXECUTE_TIMEOUT 60000; DFS.REPLICATION 1; //for mapred.job.reuse.jvm.num.tasks -JVM_REUSE_COUNT -1; \ No newline at end of file +JVM_REUSE_COUNT -1; + +Hostnames extends { + ALL_ZEROS JobTracker:ALL_ZEROS; + dfs.datanode.hostname ALL_ZEROS; + mapred.job.tracker.hostname ALL_ZEROS; + mapred.task.tracker.hostname ALL_ZEROS; +} Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/examples/testjob.sf =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/examples/testjob.sf 2009-07-02 22:57:32 UTC (rev 7770) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/examples/testjob.sf 2009-07-02 22:59:03 UTC (rev 7771) @@ -124,8 +124,6 @@ * A sequence of operations on a cluster */ FileSystemTestSequence extends FileSystemLiveSequence { - - rootDirExists extends DfsDirExistsWorkflow { cluster LAZY PARENT:cluster; path "/"; @@ -145,9 +143,10 @@ verbose true; } - rootDirHasOneEntry extends rootDirExists { + /** this used to check for exactly 1 file, but as some workers create a tmp dir, this doesnt work + all the time */ + rootDirHasAtLeastOneEntry extends rootDirExists { minFileCount 1; - maxFileCount minFileCount; minTotalFileSize assertFileExists:minSize; } Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/examples/waitforservices.sf =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/examples/waitforservices.sf 2009-07-02 22:57:32 UTC (rev 7770) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/examples/waitforservices.sf 2009-07-02 22:59:03 UTC (rev 7771) @@ -43,6 +43,7 @@ jobtrackerLive false; name "WaitForFilesystemLive"; condition extends ClusterStatusCondition { + serviceDescription ("waiting for " ++ mapred.job.tracker); mapred.job.tracker PARENT:service:mapred.job.tracker; } } Modified: trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/conf/components.sf =================================================================== --- trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/conf/components.sf 2009-07-02 22:57:32 UTC (rev 7770) +++ trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/conf/components.sf 2009-07-02 22:59:03 UTC (rev 7771) @@ -135,7 +135,7 @@ testFloatingPointValue extends testDefaultConf { - description "test that values are read and attributes set from them"; + description "test that floating point values can be read"; action:conf.required ["io.sort.record.percent"]; Added: trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/clusterconf/ClusterDrivenFilesystemTest.java =================================================================== --- trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/clusterconf/ClusterDrivenFilesystemTest.java (rev 0) +++ trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/clusterconf/ClusterDrivenFilesystemTest.java 2009-07-02 22:59:03 UTC (rev 7771) @@ -0,0 +1,21 @@ +package org.smartfrog.services.hadoop.test.system.local.clusterconf; + +import org.smartfrog.services.hadoop.test.system.local.namenode.HadoopTestBase; + +/** + * + */ +public class ClusterDrivenFilesystemTest extends HadoopTestBase { + public static final String PACKAGE = "/org/smartfrog/services/hadoop/test/system/local/clusterconf/"; + + public ClusterDrivenFilesystemTest(String name) { + super(name); + } + + public void testClusteredJobTracker() throws Throwable { + checkMapRedCluster(); + expectSuccessfulTestRunOrSkip(PACKAGE, "testClusteredJobTracker"); + enableFailOnPortCheck(); + } + +} \ No newline at end of file Added: trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/clusterconf/ClusterDrivenJobSubmitTest.java =================================================================== --- trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/clusterconf/ClusterDrivenJobSubmitTest.java (rev 0) +++ trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/clusterconf/ClusterDrivenJobSubmitTest.java 2009-07-02 22:59:03 UTC (rev 7771) @@ -0,0 +1,21 @@ +package org.smartfrog.services.hadoop.test.system.local.clusterconf; + +import org.smartfrog.services.hadoop.test.system.local.namenode.HadoopTestBase; + +/** + * + */ +public class ClusterDrivenJobSubmitTest extends HadoopTestBase { + public static final String PACKAGE = "/org/smartfrog/services/hadoop/test/system/local/clusterconf/"; + + public ClusterDrivenJobSubmitTest(String name) { + super(name); + } + + + public void testClusteredJobSubmit() throws Throwable { + checkMapRedCluster(); + expectSuccessfulTestRunOrSkip(PACKAGE, "testClusteredJobSubmit"); + enableFailOnPortCheck(); + } +} Modified: trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/clusterconf/components.sf =================================================================== --- trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/clusterconf/components.sf 2009-07-02 22:57:32 UTC (rev 7770) +++ trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/clusterconf/components.sf 2009-07-02 22:59:03 UTC (rev 7771) @@ -24,7 +24,7 @@ testFilesystemOverride extends TestCompound { - action extends LightweightClusterConf { + action extends LightweightCluster { } @@ -40,7 +40,7 @@ testFilesystemOverrideValue extends TestCompound { action extends Compound { - cluster extends LightweightClusterConf { + cluster extends LightweightCluster { } checker extends ServiceValueChecker { @@ -68,19 +68,58 @@ - action extends DataNodeClusterCompound { + action extends ConfiguredHdfsCluster { } tests extends FileSystemTestSequence { - namenode LAZY action:namenode; - datanode LAZY action:datanode; + namenode LAZY action:namenode:service; + datanode LAZY action:datanode:service; } } +testClusteredJobTracker extends ExpectDeploy { + description "bring up a filesystem"; + action extends ConfiguredCluster { + } + + + tests extends FileSystemTestSequence { + namenode LAZY action:namenode:service; + datanode LAZY action:datanode:service; + jobtracker LAZY action:jobtracker:service; + } + + +} + +testClusteredJobSubmit extends ExpectDeploy { + description "bring up a filesystem and submit work"; + + + + action extends ConfiguredCluster { + + } + + + tests extends MapReduceTestSequence { + cluster namenode; + namenode LAZY action:namenode:service; + datanode LAZY action:datanode:service; + jobtracker LAZY action:jobtracker:service; + } + + + +} + + + + Added: trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/clusterconf/testClusteredJobSubmit.sf =================================================================== --- trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/clusterconf/testClusteredJobSubmit.sf (rev 0) +++ trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/clusterconf/testClusteredJobSubmit.sf 2009-07-02 22:59:03 UTC (rev 7771) @@ -0,0 +1,28 @@ +/* (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/hadoop/test/system/local/clusterconf/components.sf" + + +/** + * Test case + */ +sfConfig testClusteredJobSubmit ; \ No newline at end of file Copied: trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/clusterconf/testClusteredJobTracker.sf (from rev 7753, trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/clusterconf/testClusteredFilesystem.sf) =================================================================== --- trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/clusterconf/testClusteredJobTracker.sf (rev 0) +++ trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/clusterconf/testClusteredJobTracker.sf 2009-07-02 22:59:03 UTC (rev 7771) @@ -0,0 +1,28 @@ +/* (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/hadoop/test/system/local/clusterconf/components.sf" + + +/** + * Test case + */ +sfConfig testClusteredJobTracker ; \ No newline at end of file Modified: trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/components.sf =================================================================== --- trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/components.sf 2009-07-02 22:57:32 UTC (rev 7770) +++ trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/local/tracker/components.sf 2009-07-02 22:59:03 UTC (rev 7771) @@ -60,7 +60,6 @@ } tests extends MapReduceTestSequence { - //s extends Sleep; jobtracker LAZY PARENT:action:jobtracker; cluster LAZY PARENT:action:cluster; datanode LAZY PARENT:action:datanode; @@ -78,7 +77,6 @@ } tests extends JobTrackerSequence { - //s extends Sleep; jobtracker LAZY PARENT:action:jobtracker; cluster LAZY PARENT:action:cluster; datanode LAZY PARENT:action:datanode; Modified: trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/Applications.java =================================================================== --- trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/Applications.java 2009-07-02 22:57:32 UTC (rev 7770) +++ trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/Applications.java 2009-07-02 22:59:03 UTC (rev 7771) @@ -19,6 +19,9 @@ */ package org.smartfrog.services.longhaul.server; +import org.smartfrog.sfcore.prim.Prim; +import org.smartfrog.sfcore.common.SmartFrogException; + import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; @@ -80,12 +83,34 @@ @GET + @Produces("text/plain") + @Path("/{application}/") + public String getApplicationAsText(@PathParam("application") String application) + throws SmartFrogException, RemoteException { + Prim child = lookupApplication(application); + StringBuilder response = new StringBuilder(); + response.append(child.sfDiagnosticsReport().toString()); + return response.toString(); + } + + @GET @Produces("text/smartfrog") @Path("/{application}/") - public String getSystem(@PathParam("application") String application) { + public String getApplicationAsSF(@PathParam("application") String application) + throws SmartFrogException, RemoteException { + Prim child = lookupApplication(application); + StringBuilder response = new StringBuilder(); + response.append(child.sfDiagnosticsReport().toString()); + return response.toString(); + } - return ""; - + @GET + @Produces("text/json") + @Path("/{application}/") + public String getApplicationAsJSON(@PathParam("application") String application) + throws SmartFrogException, RemoteException { + Prim child = lookupApplication(application); + StringBuilder response = new StringBuilder(); + return response.toString(); } - } Modified: trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/EndpointBase.java =================================================================== --- trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/EndpointBase.java 2009-07-02 22:57:32 UTC (rev 7770) +++ trunk/core/components/longhaul/src/org/smartfrog/services/longhaul/server/EndpointBase.java 2009-07-02 22:59:03 UTC (rev 7771) @@ -20,6 +20,8 @@ package org.smartfrog.services.longhaul.server; +import org.smartfrog.sfcore.common.SmartFrogException; +import org.smartfrog.sfcore.common.SmartFrogResolutionException; import org.smartfrog.sfcore.prim.Liveness; import org.smartfrog.sfcore.prim.Prim; import org.smartfrog.sfcore.processcompound.ProcessCompound; @@ -90,6 +92,17 @@ } + public Prim lookupApplication(String name) throws RemoteException, SmartFrogException { + ProcessCompound root = getRootProcess(); + Object resolved = root.sfResolveHere(name); + if(!(resolved instanceof Prim)) { + throw new SmartFrogResolutionException("The attribute "+name+" does not refer to an application" + + " but to " + resolved); + } + Prim child = (Prim) resolved; + return child; + } + /** * Create a temporary file and register the file as an attachment * @param extension extension to give it This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-08-27 17:06:36
|
Revision: 7819 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7819&view=rev Author: steve_l Date: 2009-08-27 17:05:43 +0000 (Thu, 27 Aug 2009) Log Message: ----------- SFOS-1270 Move ping() logic out of Hadoop code and into the SF extension classes; updated docs and diagrams Modified Paths: -------------- trunk/core/components/atom/atom.iml trunk/core/components/hadoop/doc/architecture.vsd trunk/core/components/hadoop/doc/hadoop-lifecycle.sxw trunk/core/components/hadoop/src/org/apache/hadoop/hdfs/server/datanode/ExtDataNode.java trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/HadoopService.java trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/HadoopServiceImpl.java trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/other/MockServiceImpl.java trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/core/SFHadoopException.java trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/internals/TestPingableMockService.java trunk/core/components/libraries.properties Removed Paths: ------------- trunk/core/components/rpmtools/src/org/smartfrog/services/rpm/dirload/ Property Changed: ---------------- trunk/core/components/ec2/ trunk/core/components/jetty/ trunk/core/components/www/ trunk/core/components/xunit/ Modified: trunk/core/components/atom/atom.iml =================================================================== --- trunk/core/components/atom/atom.iml 2009-08-26 16:54:11 UTC (rev 7818) +++ trunk/core/components/atom/atom.iml 2009-08-27 17:05:43 UTC (rev 7819) @@ -1,6 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <module relativePaths="true" type="JAVA_MODULE" version="4"> - <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="true"> + <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false"> + <output url="file://$MODULE_DIR$/build/classes" /> + <output-test url="file://$MODULE_DIR$/build/test/classes" /> <exclude-output /> <content url="file://$MODULE_DIR$"> <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> @@ -15,7 +17,11 @@ <orderEntry type="module" module-name="jetty" /> <orderEntry type="library" exported="" name="JDom" level="application" /> <orderEntry type="library" exported="" name="rome-0.8" level="application" /> - <orderEntryProperties /> </component> + <component name="copyright"> + <Base> + <setting name="state" value="2" /> + </Base> + </component> </module> Property changes on: trunk/core/components/ec2 ___________________________________________________________________ Added: svn:ignore + .project .classpath Modified: trunk/core/components/hadoop/doc/architecture.vsd =================================================================== (Binary files differ) Modified: trunk/core/components/hadoop/doc/hadoop-lifecycle.sxw =================================================================== (Binary files differ) Modified: trunk/core/components/hadoop/src/org/apache/hadoop/hdfs/server/datanode/ExtDataNode.java =================================================================== --- trunk/core/components/hadoop/src/org/apache/hadoop/hdfs/server/datanode/ExtDataNode.java 2009-08-26 16:54:11 UTC (rev 7818) +++ trunk/core/components/hadoop/src/org/apache/hadoop/hdfs/server/datanode/ExtDataNode.java 2009-08-27 17:05:43 UTC (rev 7819) @@ -80,9 +80,10 @@ * Start our parent and the worker thread * * @throws IOException if necessary + * @throws InterruptedException if the thread was interrupted on startup */ @Override - public void innerStart() throws IOException { + public void innerStart() throws IOException, InterruptedException { try { super.innerStart(); } catch (BindException e) { Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/HadoopService.java =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/HadoopService.java 2009-08-26 16:54:11 UTC (rev 7818) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/HadoopService.java 2009-08-27 17:05:43 UTC (rev 7819) @@ -21,6 +21,7 @@ import org.apache.hadoop.util.Service; import org.smartfrog.services.hadoop.conf.ClusterBound; +import org.smartfrog.services.hadoop.core.ServicePingStatus; import java.io.IOException; import java.rmi.Remote; @@ -64,7 +65,7 @@ * @throws RemoteException for RMI problems * @throws IOException for pinging problems */ - Service.ServiceStatus pingService() throws IOException; + ServicePingStatus pingService() throws IOException; /** * Gets the description of a service Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/HadoopServiceImpl.java =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/HadoopServiceImpl.java 2009-08-26 16:54:11 UTC (rev 7818) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/cluster/HadoopServiceImpl.java 2009-08-27 17:05:43 UTC (rev 7819) @@ -27,6 +27,8 @@ import org.smartfrog.services.hadoop.core.SFHadoopException; import org.smartfrog.services.hadoop.core.ServiceInfo; import org.smartfrog.services.hadoop.core.ServiceStateChangeHandler; +import org.smartfrog.services.hadoop.core.ServicePingStatus; +import org.smartfrog.services.hadoop.core.Pingable; import org.smartfrog.sfcore.common.*; import org.smartfrog.sfcore.prim.Liveness; import org.smartfrog.sfcore.prim.Prim; @@ -306,8 +308,8 @@ deployer.ping(true); } Service hadoopService = getService(); - Service.ServiceStatus serviceStatus = pingService(); - if (hadoopService != null) { + ServicePingStatus serviceStatus = pingService(); + if (hadoopService != null && serviceStatus != null) { List<Throwable> throwables = serviceStatus.getThrowables(); //look for failure exceptions first if (!throwables.isEmpty()) { @@ -447,13 +449,17 @@ /** * {@inheritDoc} */ - public Service.ServiceStatus pingService() throws IOException { + public ServicePingStatus pingService() throws IOException { Service hadoop = getService(); - if (hadoop == null || !(hadoop instanceof ServiceInfo)) { + if (hadoop == null ){ return null; + } + if (!(hadoop instanceof Pingable)) { + ServicePingStatus status = new ServicePingStatus(hadoop); + return status; } else { - ServiceInfo si =(ServiceInfo) hadoop; - return si.ping(); + Pingable pingable =(Pingable) hadoop; + return pingable.ping(); } } @@ -758,6 +764,7 @@ /** * Terminate if we are abnormal */ + @SuppressWarnings({"ThrowableResultOfMethodCallIgnored"}) protected void terminateIFFAbnormal() { boolean isNormal = getThrown() == null; if (!isNormal) { Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/other/MockServiceImpl.java =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/other/MockServiceImpl.java 2009-08-26 16:54:11 UTC (rev 7818) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/components/other/MockServiceImpl.java 2009-08-27 17:05:43 UTC (rev 7819) @@ -21,6 +21,7 @@ import org.apache.hadoop.util.MockService; import org.apache.hadoop.util.Service; +import org.apache.hadoop.PingableMockService; import org.smartfrog.services.hadoop.components.HadoopCluster; import org.smartfrog.services.hadoop.components.cluster.HadoopServiceImpl; import org.smartfrog.services.hadoop.conf.ManagedConfiguration; @@ -72,7 +73,7 @@ * @throws SmartFrogException */ protected Service createTheService(ManagedConfiguration configuration) throws IOException, SmartFrogException { - MockService service = new MockService(); + PingableMockService service = new PingableMockService(); service.setFailOnStart(configuration.getBoolean(ATTR_FAIL_ON_START,false)); service.setFailOnPing(configuration.getBoolean(ATTR_FAIL_ON_PING, false)); service.setFailOnClose(configuration.getBoolean(ATTR_FAIL_ON_CLOSE, false)); Modified: trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/core/SFHadoopException.java =================================================================== --- trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/core/SFHadoopException.java 2009-08-26 16:54:11 UTC (rev 7818) +++ trunk/core/components/hadoop/src/org/smartfrog/services/hadoop/core/SFHadoopException.java 2009-08-27 17:05:43 UTC (rev 7819) @@ -137,7 +137,7 @@ * @param status the status object * @param owner the owning Prim (can be null) */ - public SFHadoopException(Service.ServiceStatus status, Prim owner) { + public SFHadoopException(ServicePingStatus status, Prim owner) { super(status.toString(), owner); List<Throwable> causes = status.getThrowables(); if (!causes.isEmpty()) { Modified: trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/internals/TestPingableMockService.java =================================================================== --- trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/internals/TestPingableMockService.java 2009-08-26 16:54:11 UTC (rev 7818) +++ trunk/core/components/hadoop/test/org/smartfrog/services/hadoop/test/system/internals/TestPingableMockService.java 2009-08-27 17:05:43 UTC (rev 7819) @@ -57,7 +57,7 @@ super.tearDown(); } - private void start() throws IOException { + private void start() throws IOException, InterruptedException { service.start(); } Property changes on: trunk/core/components/jetty ___________________________________________________________________ Modified: svn:ignore - jetty.iml build dist version.properties + jetty.iml build dist version.properties .project .classpath Modified: trunk/core/components/libraries.properties =================================================================== --- trunk/core/components/libraries.properties 2009-08-26 16:54:11 UTC (rev 7818) +++ trunk/core/components/libraries.properties 2009-08-27 17:05:43 UTC (rev 7819) @@ -102,7 +102,7 @@ groovy-engine.version=20080808 #hadoop artifacts -hadoop.version=0.21.0-alpha-13 +hadoop.version=0.21.0-alpha-14 #hadoop.jetty.version=5.1.4 #hadoop.servlet-api.version=2.4 #hadoop.tomcat.version=5.5.12 Property changes on: trunk/core/components/www ___________________________________________________________________ Modified: svn:ignore - build dist *.iml version.properties + build dist *.iml version.properties .project .classpath Property changes on: trunk/core/components/xunit ___________________________________________________________________ Added: svn:ignore + .externalToolBuilders .project .classpath This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-09-22 16:55:09
|
Revision: 7872 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7872&view=rev Author: steve_l Date: 2009-09-22 16:55:01 +0000 (Tue, 22 Sep 2009) Log Message: ----------- SFOS-1294 Move some of the jetty test .sf files into the sf-jetty JAR. Modified Paths: -------------- trunk/core/components/ec2/test/org/smartfrog/services/restlet/test/system/testwar/components.sf trunk/core/components/jetty/src/org/smartfrog/services/jetty/examples/war/components.sf trunk/core/components/jetty/src/org/smartfrog/services/jetty/examples/war/waitforpages.sf trunk/core/components/jetty/test/org/smartfrog/services/www/jetty/test/system/components.sf trunk/core/components/jetty/test/org/smartfrog/services/www/jetty/test/system/testwar/components.sf Modified: trunk/core/components/ec2/test/org/smartfrog/services/restlet/test/system/testwar/components.sf =================================================================== --- trunk/core/components/ec2/test/org/smartfrog/services/restlet/test/system/testwar/components.sf 2009-09-22 16:17:28 UTC (rev 7871) +++ trunk/core/components/ec2/test/org/smartfrog/services/restlet/test/system/testwar/components.sf 2009-09-22 16:55:01 UTC (rev 7872) @@ -19,7 +19,7 @@ */ #include "/org/smartfrog/services/jetty/components.sf"; -#include "/org/smartfrog/services/filesystem/file.sf" +#include "/org/smartfrog/services/jetty/examples/war/components.sf" #include "/org/smartfrog/services/restlet/test/system/testwar/ports.sf" #include "/org/smartfrog/services/restlet/test/system/components.sf" @@ -29,6 +29,7 @@ */ +/* LocalJettyServer extends Compound { sfSyncTerminate true; @@ -38,9 +39,6 @@ //integrate logging with smartfrog logging extends IntegrateJettyLogging; - /* - this is the jetty server itself - */ server extends CoreJettyServer { jettyhome PARENT:jettyhome; @@ -93,30 +91,16 @@ } } - waitForPage extends WaitForPage { - fetchErrorText true; - checkOnLiveness true; - checkFrequency waitForInterval; - timeout waitForTimeout; - } - waitForAnyHttpResponse extends waitForPage { - maximumResponseCode 404; - minimumResponseCode 200; - } - waitForOK extends waitForPage { - maximumResponseCode HttpCodes:OK; - minimumResponseCode maximumResponseCode; - } +*/ - WarTest extends TestCompound { testTimeout test.timeout; - contextPath TestWarServer:contextPath; - port TestWarServer:port; + contextPath JettyWarServer:contextPath; + port JettyWarServer:port; - action extends TestWarServer { + action extends JettyWarServer { contextPath PARENT:contextPath; port PARENT:port; } @@ -124,7 +108,7 @@ tests extends Sequence { //this is the base liveness check - wait extends waitForOK { + wait extends waitForPageOK { port PARENT:PARENT:action:port; page PARENT:PARENT:action:contextPath; } Modified: trunk/core/components/jetty/src/org/smartfrog/services/jetty/examples/war/components.sf =================================================================== --- trunk/core/components/jetty/src/org/smartfrog/services/jetty/examples/war/components.sf 2009-09-22 16:17:28 UTC (rev 7871) +++ trunk/core/components/jetty/src/org/smartfrog/services/jetty/examples/war/components.sf 2009-09-22 16:55:01 UTC (rev 7872) @@ -42,12 +42,6 @@ } - RunFailingTests extends IsPropertySet { - property "run.failing.tests"; - } - - - JettyWarServer extends LocalJettyServer { description ("A jetty server with the war deployed to " ++ contextPath); @@ -66,25 +60,9 @@ - /** - * deploy into a new process - */ + - JettyServerFilesystemWar extends Compound { - description ("A jetty server with the war deployed to " ++ context:contextPath ++ " as a filesystem"); - - server LocalJettyServer; - - context extends FilesystemWar { - contextPath "/filesystemwar"; - server LAZY PARENT:server:server; - } - - } - - - JettyServerOnChannels extends JettyWarServer { server JettyOnNIO; } Modified: trunk/core/components/jetty/src/org/smartfrog/services/jetty/examples/war/waitforpages.sf =================================================================== --- trunk/core/components/jetty/src/org/smartfrog/services/jetty/examples/war/waitforpages.sf 2009-09-22 16:17:28 UTC (rev 7871) +++ trunk/core/components/jetty/src/org/smartfrog/services/jetty/examples/war/waitforpages.sf 2009-09-22 16:55:01 UTC (rev 7872) @@ -35,6 +35,7 @@ * a component to wait for a page and fail if it is not found */ +#include "/org/smartfrog/services/jetty/examples/ports.sf" waitForPage extends WaitForPage { @@ -44,7 +45,7 @@ timeout waitForTimeout; } -waitForPageOK extends WaitForPage { +waitForPageOK extends waitForPage { maximumResponseCode HttpCodes:OK; minimumResponseCode HttpCodes:OK; } Modified: trunk/core/components/jetty/test/org/smartfrog/services/www/jetty/test/system/components.sf =================================================================== --- trunk/core/components/jetty/test/org/smartfrog/services/www/jetty/test/system/components.sf 2009-09-22 16:17:28 UTC (rev 7871) +++ trunk/core/components/jetty/test/org/smartfrog/services/www/jetty/test/system/components.sf 2009-09-22 16:55:01 UTC (rev 7872) @@ -39,13 +39,6 @@ } - -FilesystemWar extends WebApplication { - contextPath "/"; - filename ROOT:test.demo.webapp; -} - - FilesystemWarAsServletContext extends JettyServletContext { contextPath "/"; resourceBase ROOT:test.demo.webapp; Modified: trunk/core/components/jetty/test/org/smartfrog/services/www/jetty/test/system/testwar/components.sf =================================================================== --- trunk/core/components/jetty/test/org/smartfrog/services/www/jetty/test/system/testwar/components.sf 2009-09-22 16:17:28 UTC (rev 7871) +++ trunk/core/components/jetty/test/org/smartfrog/services/www/jetty/test/system/testwar/components.sf 2009-09-22 16:55:01 UTC (rev 7872) @@ -42,9 +42,35 @@ TestWarServer extends JettyWarServer ; + + FilesystemWar extends WebApplication { + contextPath "/"; + filename ROOT:test.demo.webapp; + } + + + + /** + * deploy into a new process + */ + + JettyServerFilesystemWar extends Compound { + description ("A jetty server with the war deployed to " ++ context:contextPath ++ " as a filesystem"); + + server LocalJettyServer; + + + context extends FilesystemWar { + contextPath "/filesystemwar"; + server LAZY PARENT:server:server; + } + + } + + tcp27 extends JettyServerFilesystemWar; WarTest extends JettyTestCompound { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-10-01 16:17:22
|
Revision: 7907 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7907&view=rev Author: steve_l Date: 2009-10-01 16:17:11 +0000 (Thu, 01 Oct 2009) Log Message: ----------- Sub-task SFOS-1307 SFOS-1300 Move the EC2 cluster farmer to the cloudfarmer component Modified Paths: -------------- trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/EC2FarmerOfflineTest.java trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/components.sf trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/testFarmHasRoles.sf trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/testFarmLacksRole.sf trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/testMasterLacksImageID.sf trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/online/components.sf trunk/core/components/ec2/build.xml trunk/core/components/ec2/ivy.xml trunk/core/components/ec2/src/org/smartfrog/services/amazon/ec2/EC2ComponentImpl.java Added Paths: ----------- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/EC2ClusterFarmer.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/EC2ClusterFarmerImpl.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/EC2ClusterRole.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/RoleBinding.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/components.sf trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/components.sf trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/online/ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/online/EC2FarmerOnlineTest.java trunk/core/components/ec2/src/org/smartfrog/services/amazon/ec2/EC2Utils.java Removed Paths: ------------- trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/FarmerTest.java trunk/core/components/ec2/src/org/smartfrog/services/amazon/farmer/EC2ClusterFarmer.java trunk/core/components/ec2/src/org/smartfrog/services/amazon/farmer/EC2ClusterFarmerImpl.java trunk/core/components/ec2/src/org/smartfrog/services/amazon/farmer/EC2ClusterRole.java trunk/core/components/ec2/src/org/smartfrog/services/amazon/farmer/RoleBinding.java trunk/core/components/ec2/src/org/smartfrog/services/amazon/farmer/components.sf trunk/core/components/ec2/test/org/smartfrog/services/amazon/ec2farmer/test/offline/EC2FarmerOfflineTest.java trunk/core/components/ec2/test/org/smartfrog/services/amazon/ec2farmer/test/offline/FarmerTest.java trunk/core/components/ec2/test/org/smartfrog/services/amazon/ec2farmer/test/offline/components.sf trunk/core/components/ec2/test/org/smartfrog/services/amazon/ec2farmer/test/offline/testFarmHasRoles.sf trunk/core/components/ec2/test/org/smartfrog/services/amazon/ec2farmer/test/offline/testFarmLacksRole.sf trunk/core/components/ec2/test/org/smartfrog/services/amazon/ec2farmer/test/offline/testMasterLacksImageID.sf trunk/core/components/ec2/test/org/smartfrog/services/amazon/ec2farmer/test/online/components.sf Copied: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/EC2ClusterFarmer.java (from rev 7896, trunk/core/components/ec2/src/org/smartfrog/services/amazon/farmer/EC2ClusterFarmer.java) =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/EC2ClusterFarmer.java (rev 0) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/EC2ClusterFarmer.java 2009-10-01 16:17:11 UTC (rev 7907) @@ -0,0 +1,38 @@ +/* (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 + +*/ +package org.smartfrog.services.cloudfarmer.server.ec2; + +import org.smartfrog.services.amazon.ec2.EC2Component; +import org.smartfrog.services.cloudfarmer.api.ClusterFarmer; + +/** + * Created 16-Sep-2009 16:06:06 + */ + + +public interface EC2ClusterFarmer extends ClusterFarmer, EC2Component { + + String ATTR_ROLES = "roles"; + /** + * This is there to stop users accidentally running up large bills. If <0, it means ignore + */ + String ATTR_CLUSTER_LIMIT = "clusterLimit"; + +} Copied: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/EC2ClusterFarmerImpl.java (from rev 7896, trunk/core/components/ec2/src/org/smartfrog/services/amazon/farmer/EC2ClusterFarmerImpl.java) =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/EC2ClusterFarmerImpl.java (rev 0) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/EC2ClusterFarmerImpl.java 2009-10-01 16:17:11 UTC (rev 7907) @@ -0,0 +1,447 @@ +/* (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 + +*/ +package org.smartfrog.services.cloudfarmer.server.ec2; + +import com.xerox.amazonws.ec2.EC2Exception; +import com.xerox.amazonws.ec2.LaunchConfiguration; +import com.xerox.amazonws.ec2.ReservationDescription; +import org.smartfrog.services.amazon.ec2.EC2ComponentImpl; +import org.smartfrog.services.amazon.ec2.EC2Instance; +import org.smartfrog.services.amazon.ec2.SmartFrogEC2Exception; +import org.smartfrog.services.amazon.ec2.EC2Utils; +import org.smartfrog.services.cloudfarmer.server.AbstractClusterFarmer; +import org.smartfrog.services.cloudfarmer.api.ClusterNode; +import org.smartfrog.services.cloudfarmer.api.NoClusterSpaceException; +import org.smartfrog.sfcore.common.SmartFrogException; +import org.smartfrog.sfcore.common.SmartFrogResolutionException; +import org.smartfrog.sfcore.prim.Prim; +import org.smartfrog.sfcore.reference.Reference; + +import java.io.IOException; +import java.rmi.RemoteException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; + +/** + * This class implements an EC2 cluster farmer. + */ +public class EC2ClusterFarmerImpl extends EC2ComponentImpl implements EC2ClusterFarmer, EC2Instance { + private static final List<String> EMPTY_STRING_LIST = new ArrayList<String>(0); + private int clusterLimit = 10; + private int nodeCount = 0; + protected Prim roles; + public static final String ERROR_NO_VALID_IMAGE_ID = "No valid imageID for role "; + private HashMap<String, RoleBinding> roleBindings; + + + public EC2ClusterFarmerImpl() throws RemoteException { + } + + + @Override + public synchronized void sfStart() throws SmartFrogException, RemoteException { + super.sfStart(); + //start the children + synchCreateChildren(); + //now look at the settings + clusterLimit = sfResolve(ATTR_CLUSTER_LIMIT, clusterLimit, true); + sfLog().info("Creating EC2farmer with a limit of " + clusterLimit); + roles = sfResolve(ATTR_ROLES, roles, true); + roleBindings = new HashMap<String, RoleBinding>(); + buildRoleBindings(); + } + + /** + * {@inheritDoc} + * + * @throws IOException IO/network problems + * @throws SmartFrogException other problems + */ + @Override + public ClusterNode[] create(String role, int min, int max) throws IOException, SmartFrogException { + List<ClusterNode> nodes = createNodes(role, min, max); + return nodes.toArray(new ClusterNode[nodes.size()]); + } + + /** + * Create the nodelist + * @param role instance role + * @param min min# to create + * @param max max# to create; must be equal to or greater than the min value + * @return a list of created nodes, size between the min and max values + * @throws IOException IO/network problems + * @throws SmartFrogException other problems + */ + private List<ClusterNode> createNodes(String role, int min, int max) throws SmartFrogException, IOException { + AbstractClusterFarmer.validateClusterRange(min, max); + int limit = addNodes(min, max); + LaunchConfiguration launch = createLaunchConfigFromRole(role); + launch.setMaxCount(limit); + launch.setMinCount(min); + List<ClusterNode> nodes = new ArrayList<ClusterNode>(limit); + try { + ReservationDescription reservation = getEc2binding().runInstances(launch); + for (ReservationDescription.Instance instance : reservation.getInstances()) { + nodes.add(createFromReservationInstance(instance)); + } + } catch (EC2Exception e) { + throw new SmartFrogEC2Exception(e, this); + } + return nodes; + } + + /** + * Release a number of nodes + * + * @param number to release + * @return the number actually released, which may be less than that passed in + */ + private synchronized int releaseNodes(int number) { + nodeCount -= number; + if (nodeCount < 0) { + nodeCount = 0; + } + return nodeCount; + } + + /** + * Add the number of nodes + * + * @param min number of nodes to allocate + * @param max the number to add + * @return the number actually added. This may be less, if the count is > the limit + * @throws NoClusterSpaceException there is no room in the cluster + */ + private synchronized int addNodes(int min, int max) throws NoClusterSpaceException { + int newCount = nodeCount + max; + + if (newCount > clusterLimit) { + max = clusterLimit - newCount; + newCount = clusterLimit; + if (max < min) { + throw new NoClusterSpaceException("Local cluster limit is blocking this operation"); + } + } + + nodeCount = newCount; + return max; + } + + + /** + * {@inheritDoc} + * + * @throws IOException IO/network problems + * @throws SmartFrogException other problems + */ + @Override + public int deleteAll() throws IOException, SmartFrogException { + try { + List<ClusterNode> nodes = listInstances(EMPTY_STRING_LIST); + List<String> ids = createIdList(nodes); + getEc2binding().terminateInstances(ids); + int deleted = nodes.size(); + releaseNodes(deleted); + return deleted; + } catch (EC2Exception e) { + throw new SmartFrogEC2Exception(e, this); + } + } + + /** + * {@inheritDoc} + * + * @throws IOException IO/network problems + * @throws SmartFrogException other problems + */ + @Override + public void delete(String id) throws IOException, SmartFrogException { + delete(new String[]{id}); + } + + /** + * {@inheritDoc} + * + * @throws IOException IO/network problems + * @throws SmartFrogException other problems + */ + @Override + public void delete(String[] nodes) throws IOException, SmartFrogException { + try { + getEc2binding().terminateInstances(nodes); + releaseNodes(nodes.length); + } catch (EC2Exception e) { + throw new SmartFrogEC2Exception(e, this); + } + } + + /** + * {@inheritDoc} + * + * @throws IOException IO/network problems + * @throws SmartFrogException other problems + */ + @Override + public void delete(ClusterNode[] nodes) throws IOException, SmartFrogException { + try { + List<String> ids = createIdList(nodes); + getEc2binding().terminateInstances(ids); + releaseNodes(nodes.length); + } catch (EC2Exception e) { + throw new SmartFrogEC2Exception(e, this); + } + } + + /** + * {@inheritDoc} + * + * @throws IOException IO/network problems + * @throws SmartFrogException other problems + */ + @Override + public int deleteAllInRole(String role) throws IOException, SmartFrogException { + return 0; + } + + /** + * {@inheritDoc} + * + * @throws IOException IO/network problems + * @throws SmartFrogException other problems + */ + @Override + public ClusterNode[] list() throws IOException, SmartFrogException { + try { + return listInstancesToArray(EMPTY_STRING_LIST); + } catch (EC2Exception e) { + throw new SmartFrogEC2Exception(e, this); + } + } + + /** + * Take a list of instances and get their details (slow), then return an array of the results + * + * @param instanceIDs instance strings + * @return the possibly empty list + * @throws EC2Exception on failures + */ + private ClusterNode[] listInstancesToArray(List<String> instanceIDs) throws EC2Exception { + List<ClusterNode> nodes = listInstances(instanceIDs); + return nodes.toArray(new ClusterNode[nodes.size()]); + } + + /** + * Take a list of instances and get their details (slow), then return list of the results + * + * @param instanceIDs instance strings + * @return the possibly empty list + * @throws EC2Exception on failures + */ + private List<ClusterNode> listInstances(List<String> instanceIDs) throws EC2Exception { + List<ReservationDescription> reservations = getEc2binding().describeInstances(instanceIDs); + List<ClusterNode> nodes = new ArrayList<ClusterNode>(reservations.size()); + for (ReservationDescription reservation : reservations) { + for (ReservationDescription.Instance instance : reservation.getInstances()) { + nodes.add(createFromReservationInstance(instance)); + } + } + return nodes; + } + + /** + * Create a cluster node from a reservation instance + * + * @param instance instance to work from + * @return the node + */ + private static ClusterNode createFromReservationInstance(ReservationDescription.Instance instance) { + ClusterNode node = new ClusterNode(); + node.setId(instance.getInstanceId()); + node.setHostname(instance.getPrivateDnsName()); + node.setExternallyVisible(true); + node.setExternalHostname(instance.getDnsName()); + node.setDetails(instance.toString()); + return node; + } + + /** + * {@inheritDoc} + * + * @throws IOException IO/network problems + * @throws SmartFrogException other problems + */ + @Override + public ClusterNode[] list(String role) throws IOException, SmartFrogException { + return new ClusterNode[0]; + } + + /** + * {@inheritDoc} + * + * @throws IOException IO/network problems + * @throws SmartFrogException other problems + */ + @Override + public ClusterNode lookup(String id) throws IOException, SmartFrogException { + try { + List<ReservationDescription> list = getEc2binding().describeInstances(new String[]{id}); + if (list.isEmpty()) { + return null; + } + List<ReservationDescription.Instance> instances = list.get(0).getInstances(); + if (instances.isEmpty()) { + return null; + } + return createFromReservationInstance(instances.get(0)); + } catch (EC2Exception e) { + throw new SmartFrogEC2Exception(e, this); + } + } + + /** + * {@inheritDoc} + * + * @throws IOException IO/network problems + * @throws SmartFrogException other problems + */ + @Override + public ClusterNode lookupByHostname(String hostname) throws IOException, SmartFrogException { + return null; + } + + /** + * Create a list of IDs from a node list + * + * @param nodes nodes to work on + * @return a list of all the IDs in the nodes + */ + private List<String> createIdList(List<ClusterNode> nodes) { + List<String> ids = new ArrayList<String>(nodes.size()); + for (ClusterNode node : nodes) { + ids.add(node.getId()); + } + return ids; + } + + /** + * Create a list of IDs from a node list + * + * @param nodes nodes to work on + * @return a list of all the IDs in the nodes + */ + private List<String> createIdList(ClusterNode[] nodes) { + List<String> ids = new ArrayList<String>(nodes.length); + for (ClusterNode node : nodes) { + ids.add(node.getId()); + } + return ids; + } + + + + + /** + * {@inheritDoc} + * + * @return a possibly empty list of role names + * @throws IOException IO/network problems + * @throws SmartFrogException other problems + */ + @Override + public String[] listAvailableRoles() throws IOException, SmartFrogException { + //get the component containing the roles + + //and build a list of all that is a CD itself + List<String> rolelist = new ArrayList<String>(); + Iterator attrs = roles.sfAttributes(); + while (attrs.hasNext()) { + Object key = attrs.next(); + String role = key.toString(); + Object value = roles.sfResolve(new Reference(role), true); + if (value instanceof Prim) { + Prim targetRole = (Prim) value; + LaunchConfiguration launch = createLaunchConfiguration(role, targetRole); + String configString = EC2Utils.convertToString(launch); + sfLog().info("Role " + role + " " + configString); + rolelist.add(role); + } else { + sfLog().debug("Ignoring roles attribute " + role + " which maps to " + value); + } + } + return rolelist.toArray(new String[rolelist.size()]); + } + + /** + * Look up a role, create a launch config from it + * + * @param role role to look up + * @return the role + * @throws RemoteException IO/network problems + * @throws SmartFrogException other problems + */ + private LaunchConfiguration createLaunchConfigFromRole(String role) + throws SmartFrogException, RemoteException { + Prim targetRole = resolveRole(role); + return createLaunchConfiguration(role, targetRole); + } + + private LaunchConfiguration createLaunchConfiguration(String role, Prim targetRole) + throws SmartFrogResolutionException, RemoteException { + sfLog().info("Creating a Launch config from " + targetRole); + LaunchConfiguration lc = EC2ClusterRole.createLaunchConfiguration(role, targetRole); + return lc; + } + + private Prim resolveRole(String role) throws SmartFrogResolutionException, RemoteException { + return roles.sfResolve(role, (Prim) null, true); + } + + /** + * {@inheritDoc} + * + * @return the number of roles + * @throws IOException IO/network problems + * @throws SmartFrogException other problems + */ + public int buildRoleBindings() throws RemoteException, SmartFrogException { + + //and build a list of all that is a CD itself + Iterator attrs = roles.sfAttributes(); + while (attrs.hasNext()) { + Object key = attrs.next(); + String role = key.toString(); + Object value = roles.sfResolve(new Reference(role), true); + if (value instanceof Prim) { + Prim targetRole = (Prim) value; + LaunchConfiguration launch = createLaunchConfiguration(role, targetRole); + RoleBinding binding = new RoleBinding(role, targetRole, launch); + roleBindings.put(role, binding); + sfLog().info(binding.toString()); + + } else { + sfLog().debug("Ignoring roles attribute " + role + " which maps to " + value); + } + } + return roleBindings.size(); + } + +} Copied: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/EC2ClusterRole.java (from rev 7896, trunk/core/components/ec2/src/org/smartfrog/services/amazon/farmer/EC2ClusterRole.java) =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/EC2ClusterRole.java (rev 0) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/EC2ClusterRole.java 2009-10-01 16:17:11 UTC (rev 7907) @@ -0,0 +1,75 @@ +/* (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 + +*/ +package org.smartfrog.services.cloudfarmer.server.ec2; + +import com.xerox.amazonws.ec2.InstanceType; +import com.xerox.amazonws.ec2.LaunchConfiguration; +import org.smartfrog.services.amazon.ec2.EC2Instance; +import org.smartfrog.services.amazon.ec2.EC2Utils; +import org.smartfrog.sfcore.common.SmartFrogException; +import org.smartfrog.sfcore.common.SmartFrogResolutionException; +import org.smartfrog.sfcore.prim.Prim; +import org.smartfrog.sfcore.prim.PrimImpl; +import org.smartfrog.sfcore.reference.Reference; +import org.smartfrog.sfcore.utils.ListUtils; + +import java.rmi.RemoteException; +import java.util.Vector; + +/** + * Created 29-Sep-2009 11:37:58 + */ + +public class EC2ClusterRole extends PrimImpl implements EC2Instance { + public static final String ERROR_NO_VALID_IMAGE_ID = "No valid imageID for role "; + + public EC2ClusterRole() throws RemoteException { + } + + @Override + public void sfStart() throws SmartFrogException, RemoteException { + super.sfStart(); + LaunchConfiguration lc = createLaunchConfiguration("none", this); + } + + + public static LaunchConfiguration createLaunchConfiguration(String role, Prim targetRole) + throws SmartFrogResolutionException, RemoteException { + String imageID = targetRole.sfResolve(ATTR_IMAGE_ID, "", true); + String zone = targetRole.sfResolve(ATTR_AVAILABILITY_ZONE, "", true); + String keyName = targetRole.sfResolve(ATTR_KEY_NAME, "", true); + String userData = targetRole.sfResolve(ATTR_USER_DATA, "", true); + InstanceType size = InstanceType.getTypeFromString(targetRole.sfResolve(ATTR_INSTANCE_TYPE, "", true)); + Vector<String> groups = ListUtils.resolveStringList(targetRole, new Reference(ATTR_SECURITY_GROUP), true); + LaunchConfiguration lc = new LaunchConfiguration(imageID.trim()); + lc.setConfigName(role); + lc.setAvailabilityZone(zone); + lc.setInstanceType(size); + lc.setKeyName(keyName); + lc.setSecurityGroup(groups); + lc.setUserData(userData.getBytes()); + if (lc.getImageId().isEmpty()) { + throw new SmartFrogResolutionException(ERROR_NO_VALID_IMAGE_ID + role + " " + EC2Utils.convertToString(lc) + + ("- raw image ID :'" + imageID + "'")); + } + return lc; + } + +} Copied: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/RoleBinding.java (from rev 7896, trunk/core/components/ec2/src/org/smartfrog/services/amazon/farmer/RoleBinding.java) =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/RoleBinding.java (rev 0) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/RoleBinding.java 2009-10-01 16:17:11 UTC (rev 7907) @@ -0,0 +1,76 @@ +/* (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 + +*/ +package org.smartfrog.services.cloudfarmer.server.ec2; + +import com.xerox.amazonws.ec2.LaunchConfiguration; +import org.smartfrog.services.amazon.ec2.InstanceList; +import org.smartfrog.services.amazon.ec2.EC2Utils; +import org.smartfrog.sfcore.prim.Prim; + +/** + * This is the binding of roles that is created at deploy time; it can be used to remember which instances are mapped where + */ + +public class RoleBinding { + + private String role; + private LaunchConfiguration launchConfig; + private String description; + private Prim source; + private InstanceList instances; + + + public RoleBinding(String role, Prim source, LaunchConfiguration launchConfig) { + this.role = role; + this.source = source; + this.launchConfig = launchConfig; + description = EC2Utils.convertToString(launchConfig); + instances = new InstanceList(); + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + public LaunchConfiguration getLaunchConfig() { + return launchConfig; + } + + public void setLaunchConfig(LaunchConfiguration launchConfig) { + this.launchConfig = launchConfig; + } + + public Prim getSource() { + return source; + } + + public void setSource(Prim source) { + this.source = source; + } + + @Override + public String toString() { + return "Role "+ role + " " + description; + } +} Copied: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/components.sf (from rev 7896, trunk/core/components/ec2/src/org/smartfrog/services/amazon/farmer/components.sf) =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/components.sf (rev 0) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/components.sf 2009-10-01 16:17:11 UTC (rev 7907) @@ -0,0 +1,108 @@ +/* (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/amazon/ec2/components.sf" +#include "/org/smartfrog/services/cloudfarmer/server/components.sf" + + +/** + * The cluster farmer implements the ClusterFarmer interface, and so lets trusted callers + * create machines of a specific role. + + Conceptual Model + - the farmer is deployed, it brings up models in a role. It can be set to delete all deployed nodes when terminated, + or to leave them running (more robust, but can rack up bills) + - for every role, define an AMI string, instance type and any user data + +Roles are inserted in an undeployed bit of the system, just plain data. That's so we can have some basic image definitions + + */ + + +/** + * just something that is used to configure the farmer + */ + +EC2ClusterRole extends EC2ImageSizes, EC2AvailabilityZones, Prim { + sfClass "org.smartfrog.services.cloudfarmer.server.ec2.EC2ClusterRole"; + + //the string value of the machine image to deploy. This must resolve before an attempt + //to deploy a machine of the given role can work + imageID TBD; + + //instance types + instanceType SIZE_SMALL; + + //user data. This is going to change before long + userData ""; + + //name of the key to use for SSH from the list of key pairs + keyName ""; + + // where the image should live + availabilityZone ZONE_US_EAST_1A; + + // a list of string names + securityGroup []; + +} + +/** + * This is our cluster farmer. + * Its exact functionality will evolve over time + */ + +EC2ClusterFarmer extends AwsAuthorizedService { + sfClass "org.smartfrog.services.cloudfarmer.server.ec2.EC2ClusterFarmerImpl" + + /** + * This is there to stop users accidentally running up large bills. If <0, it means ignore + */ + + clusterLimit 10; + + /** + * constant to ignore all cluster limits + */ + NO_CLUSTER_LIMIT -1; + + /** + * Should the farmer recycle old instances given out. + * For dev and test yes, but bear in mind that the machine may be in an unknown state. + * When recycling, the old image is rebooted and left alone until needed + */ + recycle true; + + /** + should you delete instances when terminating? + For HA systems the answer MUST BE no, leave them up, somehow the next instance will rebind. + For test and dev systems, that can run up a large bill + */ + deleteInstancesOnTermination true; + + /** + roles go under here. Each one should have all the attributes of an EC2ClusterRole, so that you can + create a cluster instance from the + */ + roles extends Compound { + + } + +} \ No newline at end of file Added: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/components.sf =================================================================== --- trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/components.sf (rev 0) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/components.sf 2009-10-01 16:17:11 UTC (rev 7907) @@ -0,0 +1,171 @@ +/* (C) Copyright 2008 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/components.sf" +#include "/org/smartfrog/services/passwords/components.sf" +#include "/org/smartfrog/services/amazon/workflow/components.sf" + +bucket "smartfrogtest"; +login OPTIONAL("") PROPERTY test.awsid; +password OPTIONAL("") PROPERTY test.awskey; +timeout 10; + +bucketHost (bucket ++ ".s3.amazonaws.com"); + + +test.awsid "test.awsid"; +test.awskey "test.awskey"; +test.ec2.image.id "ami-26b6534f"; +test.sleep.delay 1000; +test.ec2.startup.delay 30000; + + +/** + * turn the AWS key into a password + */ + +AwsPassword extends PropertyPassword { + id login; + property test.awskey; +} + +/* + * Our AWS condition + */ + +IsAwsEnabled extends IsPropertyTrue { + property test.awsid; +} + + + +IsEC2EnabledSet extends IsPropertyTrue { + property "test.ec2.enabled"; +} + + +IsS3EnabledSet extends IsPropertyTrue { + property "test.s3.enabled"; +} + +IsEC2InstancesSet extends IsPropertyTrue { + property "test.ec2.instances.enabled"; +} + + +IsEC2FarmerSet extends IsPropertyTrue { + property "test.ec2.farmer.enabled"; +} + + + +IsEC2Enabled extends And { + ec2 extends IsEC2EnabledSet; + aws extends IsAwsEnabled; +} + +IsEC2InstancesEnabled extends IsEC2Enabled { + ec2instances extends IsEC2InstancesSet; +} + +IsEC2FarmerEnabled extends IsEC2Enabled { + ec2farmer extends IsEC2FarmerSet; +} + + +IsS3Enabled extends And { + ec2 extends IsS3EnabledSet; + aws extends IsAwsEnabled; +} + + +/** + A test on AWS + */ + +ExpectDeployOnAWS extends ExpectDeploy { + + description "test against the AWS servers; requires test.awsid to be set with a login" + + condition extends IsAwsEnabled ; + sfShouldTerminate true; + +} + +/** + A test on AWS + */ + +ExpectDeployFailureOnAWS extends ExpectDeployFailure { + + description ExpectDeployOnAWS:description; + + condition extends IsAwsEnabled ; + +} + +ExpectDeployOnEC2 extends ExpectDeploy { + + description "test deploy on the EC2 servers; requires test.awsid to be set with a login and test.ec2.enabled to set to something" + + condition extends IsEC2Enabled ; + sfShouldTerminate true; + +} + + +ExpectDeployInstanceOnEC2 extends ExpectDeployOnEC2 { + description "A test deploying if instances are enabled"; + condition extends IsEC2InstancesEnabled; +} + +ExpectDeployFarmerOnEC2 extends ExpectDeployOnEC2 { + description "A test deploying if the ec2.farmer tests are enabled"; + condition extends IsEC2FarmerEnabled; +} + + +/** + A test on AWS + */ + +ExpectDeployFailureOnEC2 extends ExpectDeployFailure { + + description ExpectDeployOnEC2:description; + + condition extends IsEC2Enabled ; +} + +ExpectDeployInstanceFailureOnEC2 extends ExpectDeployFailure { + + description ExpectDeployOnEC2:description; + + condition extends IsEC2InstancesEnabled ; + +} + +ExpectDeployFarmerFailureOnEC2 extends ExpectDeployFailure { + + description ExpectDeployFarmerOnEC2:description; + + condition extends IsEC2FarmerEnabled ; + +} + + Modified: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/EC2FarmerOfflineTest.java =================================================================== --- trunk/core/components/ec2/test/org/smartfrog/services/amazon/ec2farmer/test/offline/EC2FarmerOfflineTest.java 2009-10-01 12:18:27 UTC (rev 7896) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/EC2FarmerOfflineTest.java 2009-10-01 16:17:11 UTC (rev 7907) @@ -1,4 +1,4 @@ -package org.smartfrog.services.amazon.ec2farmer.test.offline; +package org.smartfrog.services.cloudfarmer.test.ec2.offline; import org.smartfrog.test.DeployingTestBase; @@ -6,7 +6,7 @@ * */ public class EC2FarmerOfflineTest extends DeployingTestBase { - public static final String FILES = "/org/smartfrog/services/amazon/ec2farmer/test/offline"; + public static final String FILES = "/org/smartfrog/services/cloudfarmer/test/ec2/offline"; public EC2FarmerOfflineTest(String name) { super(name); Deleted: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/FarmerTest.java =================================================================== --- trunk/core/components/ec2/test/org/smartfrog/services/amazon/ec2farmer/test/offline/FarmerTest.java 2009-10-01 12:18:27 UTC (rev 7896) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/FarmerTest.java 2009-10-01 16:17:11 UTC (rev 7907) @@ -1,26 +0,0 @@ -package org.smartfrog.services.amazon.ec2farmer.test.offline; - -import org.smartfrog.test.DeployingTestBase; - -/** - * - */ -public class FarmerTest extends DeployingTestBase { - public static final String FILES = "/org/smartfrog/services/amazon/ec2farmer/test/online"; - - public FarmerTest(String name) { - super(name); - } - - public void testFarmHasRoles() throws Throwable { - expectSuccessfulTestRunOrSkip(FILES, "testFarmHasRoles"); - } - - public void testFarmLacksRole() throws Throwable { - expectSuccessfulTestRunOrSkip(FILES, "testFarmLacksRole"); - } - - public void testMasterLacksImageID() throws Throwable { - expectSuccessfulTestRunOrSkip(FILES, "testMasterLacksImageID"); - } -} \ No newline at end of file Modified: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/components.sf =================================================================== --- trunk/core/components/ec2/test/org/smartfrog/services/amazon/ec2farmer/test/offline/components.sf 2009-10-01 12:18:27 UTC (rev 7896) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/components.sf 2009-10-01 16:17:11 UTC (rev 7907) @@ -18,10 +18,8 @@ */ #include "/org/smartfrog/services/assertions/components.sf" -#include "/org/smartfrog/services/farmer/components.sf" -#include "/org/smartfrog/services/amazon/farmer/components.sf" +#include "/org/smartfrog/services/cloudfarmer/test/ec2/components.sf" - BaseFarmer extends EC2ClusterFarmer { clusterLimit 4; Modified: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/testFarmHasRoles.sf =================================================================== --- trunk/core/components/ec2/test/org/smartfrog/services/amazon/ec2farmer/test/offline/testFarmHasRoles.sf 2009-10-01 12:18:27 UTC (rev 7896) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/testFarmHasRoles.sf 2009-10-01 16:17:11 UTC (rev 7907) @@ -17,6 +17,6 @@ For more information: www.smartfrog.org */ -#include "/org/smartfrog/services/amazon/ec2farmer/test/offline/components.sf" +#include "/org/smartfrog/services/cloudfarmer/test/ec2/offline/components.sf" sfConfig extends testFarmHasRoles; Modified: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/testFarmLacksRole.sf =================================================================== --- trunk/core/components/ec2/test/org/smartfrog/services/amazon/ec2farmer/test/offline/testFarmLacksRole.sf 2009-10-01 12:18:27 UTC (rev 7896) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/testFarmLacksRole.sf 2009-10-01 16:17:11 UTC (rev 7907) @@ -17,6 +17,6 @@ For more information: www.smartfrog.org */ -#include "/org/smartfrog/services/amazon/ec2farmer/test/offline/components.sf" +#include "/org/smartfrog/services/cloudfarmer/test/ec2/offline/components.sf" sfConfig extends testFarmLacksRole; Modified: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/testMasterLacksImageID.sf =================================================================== --- trunk/core/components/ec2/test/org/smartfrog/services/amazon/ec2farmer/test/offline/testMasterLacksImageID.sf 2009-10-01 12:18:27 UTC (rev 7896) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/testMasterLacksImageID.sf 2009-10-01 16:17:11 UTC (rev 7907) @@ -17,6 +17,6 @@ For more information: www.smartfrog.org */ -#include "/org/smartfrog/services/amazon/ec2farmer/test/offline/components.sf" +#include "/org/smartfrog/services/cloudfarmer/test/ec2/offline/components.sf" sfConfig extends testMasterLacksImageID; Added: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/online/EC2FarmerOnlineTest.java =================================================================== --- trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/online/EC2FarmerOnlineTest.java (rev 0) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/online/EC2FarmerOnlineTest.java 2009-10-01 16:17:11 UTC (rev 7907) @@ -0,0 +1,18 @@ +package org.smartfrog.services.cloudfarmer.test.ec2.online; + +import org.smartfrog.test.DeployingTestBase; + +/** + * + */ +public class EC2FarmerOnlineTest extends DeployingTestBase { + public static final String FILES = "/org/smartfrog/services/cloudfarmer/test/ec2/online/"; + + public EC2FarmerOnlineTest(String name) { + super(name); + } + + public void testNothing() throws Throwable { + + } +} \ No newline at end of file Modified: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/online/components.sf =================================================================== --- trunk/core/components/ec2/test/org/smartfrog/services/amazon/ec2farmer/test/online/components.sf 2009-10-01 12:18:27 UTC (rev 7896) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/online/components.sf 2009-10-01 16:17:11 UTC (rev 7907) @@ -18,10 +18,8 @@ */ #include "/org/smartfrog/services/assertions/components.sf" -#include "/org/smartfrog/services/farmer/components.sf" -#include "/org/smartfrog/services/amazon/farmer/components.sf" +#include "/org/smartfrog/services/cloudfarmer/test/ec2/components.sf" - BaseFarmer extends EC2ClusterFarmer { clusterLimit 4; Modified: trunk/core/components/ec2/build.xml =================================================================== --- trunk/core/components/ec2/build.xml 2009-10-01 16:12:54 UTC (rev 7906) +++ trunk/core/components/ec2/build.xml 2009-10-01 16:17:11 UTC (rev 7907) @@ -47,10 +47,8 @@ <property name="test.timeout.execute" value="120000" /> <property name="test.timeout.startup" value="${test.timeout.execute}" /> <!--<property name="application.name" value="ec2" />--> - <property name="mockfarmer.sf" value="org/smartfrog/services/farmer/example.sf" /> -<!-- <property name="deploy.sf" value="${mockfarmer.sf}" />--> <echo message="==================================================================="/> <echo message="= ${ant.project.name}"/> @@ -93,12 +91,5 @@ </fail> </target> - <target name="farmer" depends="ready-to-deploy" - description="Deploy a mock farm manager" > - <property name="mockfarmer.sf" value="org/smartfrog/services/farmer/example.sf" /> - <deploy> - <application name="farmer" - descriptor="/${mockfarmer.sf}"/> - </deploy> - </target> + </project> \ No newline at end of file Modified: trunk/core/components/ec2/ivy.xml =================================================================== --- trunk/core/components/ec2/ivy.xml 2009-10-01 16:12:54 UTC (rev 7906) +++ trunk/core/components/ec2/ivy.xml 2009-10-01 16:17:11 UTC (rev 7907) @@ -132,14 +132,6 @@ conf="restlet->default"/> <!--Typica - when internal, the spec was - - <dependency org="typica" - name="typica" - changing="true" - rev="${typica.version}" - conf="typica->default"/> - --> <dependency org="com.google.code.typica" name="typica" Modified: trunk/core/components/ec2/src/org/smartfrog/services/amazon/ec2/EC2ComponentImpl.java =================================================================== --- trunk/core/components/ec2/src/org/smartfrog/services/amazon/ec2/EC2ComponentImpl.java 2009-10-01 16:12:54 UTC (rev 7906) +++ trunk/core/components/ec2/src/org/smartfrog/services/amazon/ec2/EC2ComponentImpl.java 2009-10-01 16:17:11 UTC (rev 7907) @@ -23,7 +23,6 @@ import com.xerox.amazonws.ec2.TerminatingInstanceDescription; import com.xerox.amazonws.ec2.LaunchConfiguration; import org.smartfrog.services.amazon.workflow.CompletableWork; -import org.smartfrog.services.amazon.farmer.EC2ClusterRole; import org.smartfrog.services.passwords.PasswordHelper; import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.common.SmartFrogExtractedException; @@ -227,7 +226,7 @@ * @param launch the configuration */ protected void logLaunchConfiguration(LaunchConfiguration launch) { - String configString = EC2ClusterRole.convertToString(launch); + String configString = EC2Utils.convertToString(launch); sfLog().info(configString); } Added: trunk/core/components/ec2/src/org/smartfrog/services/amazon/ec2/EC2Utils.java =================================================================== --- trunk/core/components/ec2/src/org/smartfrog/services/amazon/ec2/EC2Utils.java (rev 0) +++ trunk/core/components/ec2/src/org/smartfrog/services/amazon/ec2/EC2Utils.java 2009-10-01 16:17:11 UTC (rev 7907) @@ -0,0 +1,48 @@ +/* (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 + +*/ +package org.smartfrog.services.amazon.ec2; + +import com.xerox.amazonws.ec2.LaunchConfiguration; + +/** + * EC2 utils + */ + +public final class EC2Utils { + + private EC2Utils() { + } + + /** + * Stringify a launch config for printing + * @param launch the configuration + * @return a string form + */ + public static String convertToString(LaunchConfiguration launch) { + StringBuilder sb = new StringBuilder(); + sb.append("Launch configuration:"); + sb.append(" imageID='").append(launch.getImageId()).append('\''); + sb.append(" instanceSize='").append(launch.getInstanceType()).append('\''); + sb.append(" keyName='").append(launch.getKeyName()).append('\''); + sb.append(" availabilityZone='").append(launch.getAvailabilityZone()).append('\''); + String configString = sb.toString(); + return configString; + } +} Deleted: trunk/core/components/ec2/src/org/smartfrog/services/amazon/farmer/EC2ClusterFarmer.java =================================================================== --- trunk/core/components/ec2/src/org/smartfrog/services/amazon/farmer/EC2ClusterFarmer.java 2009-10-01 16:12:54 UTC (rev 7906) +++ trunk/core/components/ec2/src/org/smartfrog/services/amazon/farmer/EC2ClusterFarmer.java 2009-10-01 16:17:11 UTC (rev 7907) @@ -1,38 +0,0 @@ -/* (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 - -*/ -package org.smartfrog.services.amazon.farmer; - -import org.smartfrog.services.amazon.ec2.EC2Component; -import org.smartfrog.services.farmer.ClusterFarmer; - -/** - * Created 16-Sep-2009 16:06:06 - */ - - -public interface EC2ClusterFarmer extends ClusterFarmer, EC2Component { - - String ATTR_ROLES = "roles"; - /** - * This is there to stop users accidentally running up large bills. If <0, it means ignore - */ - String ATTR_CLUSTER_LIMIT = "clusterLimit"; - -} Deleted: trunk/core/components/ec2/src/org/smartfrog/services/amazon/farmer/EC2ClusterFarmerImpl.java =================================================================== --- trunk/core/components/ec2/src/org/smartfrog/services/amazon/farmer/EC2ClusterFarmerImpl.java 2009-10-01 16:12:54 UTC (rev 7906) +++ trunk/core/components/ec2/src/org/smartfrog/services/amazon/farmer/EC2ClusterFarmerImpl.java 2009-10-01 16:17:11 UTC (rev 7907) @@ -1,446 +0,0 @@ -/* (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 - -*/ -package org.smartfrog.services.amazon.farmer; - -import com.xerox.amazonws.ec2.EC2Exception; -import com.xerox.amazonws.ec2.LaunchConfiguration; -import com.xerox.amazonws.ec2.ReservationDescription; -import org.smartfrog.services.amazon.ec2.EC2ComponentImpl; -import org.smartfrog.services.amazon.ec2.EC2Instance; -import org.smartfrog.services.amazon.ec2.SmartFrogEC2Exception; -import org.smartfrog.services.farmer.AbstractClusterFarmer; -import org.smartfrog.services.farmer.ClusterNode; -import org.smartfrog.services.farmer.NoClusterSpaceException; -import org.smartfrog.sfcore.common.SmartFrogException; -import org.smartfrog.sfcore.common.SmartFrogResolutionException; -import org.smartfrog.sfcore.prim.Prim; -import org.smartfrog.sfcore.reference.Reference; - -import java.io.IOException; -import java.rmi.RemoteException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; - -/** - * This class implements an EC2 cluster farmer. - */ -public class EC2ClusterFarmerImpl extends EC2ComponentImpl implements EC2ClusterFarmer, EC2Instance { - private static final List<String> EMPTY_STRING_LIST = new ArrayList<String>(0); - private int clusterLimit = 10; - private int nodeCount = 0; - protected Prim roles; - public static final String ERROR_NO_VALID_IMAGE_ID = "No valid imageID for role "; - private HashMap<String, RoleBinding> roleBindings; - - - public EC2ClusterFarmerImpl() throws RemoteException { - } - - - @Override - public synchronized void sfStart() throws SmartFrogException, RemoteException { - super.sfStart(); - //start the children - synchCreateChildren(); - //now look at the settings - clusterLimit = sfResolve(ATTR_CLUSTER_LIMIT, clusterLimit, true); - sfLog().info("Creating EC2farmer with a limit of " + clusterLimit); - roles = sfResolve(ATTR_ROLES, roles, true); - roleBindings = new HashMap<String, RoleBinding>(); - buildRoleBindings(); - } - - /** - * {@inheritDoc} - * - * @throws IOException IO/network problems - * @throws SmartFrogException other problems - */ - @Override - public ClusterNode[] create(String role, int min, int max) throws IOException, SmartFrogException { - List<ClusterNode> nodes = createNodes(role, min, max); - return nodes.toArray(new ClusterNode[nodes.size()]); - } - - /** - * Create the nodelist - * @param role instance role - * @param min min# to create - * @param max max# to create; must be equal to or greater than the min value - * @return a list of created nodes, size between the min and max values - * @throws IOException IO/network problems - * @throws SmartFrogException other problems - */ - private List<ClusterNode> createNodes(String role, int min, int max) throws SmartFrogException, IOException { - AbstractClusterFarmer.validateClusterRange(min, max); - int limit = addNodes(min, max); - LaunchConfiguration launch = createLaunchConfigFromRole(role); - launch.setMaxCount(limit); - launch.setMinCount(min); - List<ClusterNode> nodes = new ArrayList<ClusterNode>(limit); - try { - ReservationDescription reservation = getEc2binding().runInstances(launch); - for (ReservationDescription.Instance instance : reservation.getInstances()) { - nodes.add(createFromReservationInstance(instance)); - } - } catch (EC2Exception e) { - throw new SmartFrogEC2Exception(e, this); - } - return nodes; - } - - /** - * Release a number of nodes - * - * @param number to release - * @return the number actually released, which may be less than that passed in - */ - private synchronized int releaseNodes(int number) { - nodeCount -= number; - if (nodeCount < 0) { - nodeCount = 0; - } - return nodeCount; - } - - /** - * Add the number of nodes - * - * @param min number of nodes to allocate - * @param max the number to add - * @return the number actually added. This may be less, if the count is > the limit - * @throws NoClusterSpaceException there is no room in the cluster - */ - private synchronized int addNodes(int min, int max) throws NoClusterSpaceException { - int newCount = nodeCount + max; - - if (newCount > clusterLimit) { - max = clusterLimit - newCount; - newCount = clusterLimit; - if (max < min) { - throw new NoClusterSpaceException("Local cluster limit is blocking this operation"); - } - } - - nodeCount = newCount; - return max; - } - - - /** - * {@inheritDoc} - * - * @throws IOException IO/network problems - * @throws SmartFrogException other problems - */ - @Override - public int deleteAll() throws IOException, SmartFrogException { - try { - List<ClusterNode> nodes = listInstances(EMPTY_STRING_LIST); - List<String> ids = createIdList(nodes); - getEc2binding().terminateInstances(ids); - int deleted = nodes.size(); - releaseNodes(deleted); - return deleted; - } catch (EC2Exception e) { - throw new SmartFrogEC2Exception(e, this); - } - } - - /** - * {@inheritDoc} - * - * @throws IOException IO/network problems - * @throws SmartFrogException other problems - */ - @Override - public void delete(String id) throws IOException, SmartFrogException { - delete(new String[]{id}); - } - - /** - * {@inheritDoc} - * - * @throws IOException IO/network problems - * @throws SmartFrogException other problems - */ - @Override - public void delete(String[] nodes) throws IOException, SmartFrogException { - try { - getEc2binding().terminateInstances(nodes); - releaseNodes(nodes.length); - } catch (EC2Exception e) { - throw new SmartFrogEC2Exception(e, this); - } - } - - /** - * {@inheritDoc} - * - * @throws IOException IO/network problems - * @throws SmartFrogException other problems - */ - @Override - public void delete(ClusterNode[] nodes) throws IOException, SmartFrogException { - try { - List<String> ids = createIdList(nodes); - getEc2binding().terminateInstances(ids); - releaseNodes(nodes.length); - } catch (EC2Exception e) { - throw new SmartFrogEC2Exception(e, this); - } - } - - /** - * {@inheritDoc} - * - * @throws IOException IO/network problems - * @throws SmartFrogException other problems - */ - @Override - public int deleteAllInRole(String role) throws IOException, SmartFrogException { - return 0; - } - - /** - * {@inheritDoc} - * - * @throws IOException IO/network problems - * @throws SmartFrogException other problems - */ - @Override - public ClusterNode[] list() throws IOException, SmartFrogException { - try { - return listInstancesToArray(EMPTY_STRING_LIST); - } catch (EC2Exception e) { - throw new SmartFrogEC2Exception(e, this); - } - } - - /** - * Take a list of instances and get their details (slow), then return an array of the results - * - * @param instanceIDs instance strings - * @return the possibly empty list - * @throws EC2Exception on failures - */ - private ClusterNode[] listInstancesToArray(List<String> instanceIDs) throws EC2Exception { - List<ClusterNode> nodes = listInstances(instanceIDs); - return nodes.toArray(new ClusterNode[nodes.size()]); - } - - /** - * Take a list of instances and get their details (slow), then return list of the results - * - * @param instanceIDs instance strings - * @return the possibly empty list - * @throws EC2Exception on failures - */ - private List<ClusterNode> listInstances(List<String> instanceIDs) throws EC2Exception { - List<ReservationDescription> reservations = getEc2binding().descr... [truncated message content] |
From: <st...@us...> - 2009-10-03 10:12:22
|
Revision: 7901 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7901&view=rev Author: steve_l Date: 2009-10-01 12:46:13 +0000 (Thu, 01 Oct 2009) Log Message: ----------- SFOS-1300 Create CloudFarmer component with client and server for working with resource manager Added Paths: ----------- trunk/core/components/cloudfarmer/ trunk/core/components/cloudfarmer/src/ trunk/core/components/cloudfarmer/src/org/ trunk/core/components/cloudfarmer/src/org/smartfrog/ trunk/core/components/cloudfarmer/src/org/smartfrog/services/ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/interface/ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/manual/ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/mock/ trunk/core/components/cloudfarmer/test/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-10-29 14:47:35
|
Revision: 7997 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7997&view=rev Author: steve_l Date: 2009-10-29 14:46:34 +0000 (Thu, 29 Oct 2009) Log Message: ----------- SFOS-1347 Servlet contexts (especialy Jetty) to have an attributes CD Modified Paths: -------------- trunk/core/components/jetty/src/org/smartfrog/services/jetty/JettyHelper.java trunk/core/components/jetty/src/org/smartfrog/services/jetty/contexts/JettyServletContextIntf.java trunk/core/components/jetty/src/org/smartfrog/services/jetty/contexts/delegates/DelegateServletContext.java trunk/core/components/www/src/org/smartfrog/services/www/HttpAttributes.java trunk/core/components/www/src/org/smartfrog/services/www/ServletContextIntf.java trunk/core/components/www/src/org/smartfrog/services/www/webapplication.sf Modified: trunk/core/components/jetty/src/org/smartfrog/services/jetty/JettyHelper.java =================================================================== --- trunk/core/components/jetty/src/org/smartfrog/services/jetty/JettyHelper.java 2009-10-29 13:26:12 UTC (rev 7996) +++ trunk/core/components/jetty/src/org/smartfrog/services/jetty/JettyHelper.java 2009-10-29 14:46:34 UTC (rev 7997) @@ -26,7 +26,6 @@ import org.mortbay.jetty.Server; import org.mortbay.jetty.handler.HandlerCollection; import org.mortbay.jetty.servlet.Context; -import org.smartfrog.services.jetty.contexts.JettyServletContextIntf; import org.smartfrog.services.www.ApplicationServerContext; import org.smartfrog.services.www.WebApplicationHelper; import org.smartfrog.sfcore.common.SmartFrogException; @@ -130,83 +129,8 @@ } - /** - * for servlets: get the servlet context. - * - * @param mandatory set this to true if you want an exception if there is no context - * @return context, or null if there is not one found - * @throws SmartFrogException In case of error while deploying - * @throws RemoteException In case of network/rmi error - */ - public Context getServletContext(boolean mandatory) - throws SmartFrogException, RemoteException { - - Context jettyContext = null; - - Prim contextImpl = findServletContext(); - if (contextImpl != null) { - jettyContext = new WrappedJettyServletContext().resolve(contextImpl, - JettyServletContextIntf.ATTR_CONTEXT, - mandatory); - } else if (mandatory) { - throw new SmartFrogResolutionException( - "Could not locate " - + - JettyServletContextIntf.ATTR_CONTEXT, contextImpl); - } - return jettyContext; - } - - /** - * Extract the servlet context - * - * @param prim the prim to use - * @return the context or null - * @throws SmartFrogResolutionException if the attribute is the wrong type - * @throws RemoteException network trouble - */ - private Context extractServletContext(Prim prim) throws SmartFrogResolutionException, RemoteException { - Object wrapper = prim.sfResolve(JettyServletContextIntf.ATTR_CONTEXT); - if (wrapper == null) { - return null; - } - if (!(wrapper instanceof WrappedJettyServletContext)) { - throw new SmartFrogResolutionException( - "Wrong instance type on " - + JettyServletContextIntf.ATTR_CONTEXT - + " found " + wrapper, - prim); - } - WrappedJettyServletContext wrappedContext = (WrappedJettyServletContext) wrapper; - return wrappedContext.getInstance(); - } - - - private static class WrappedJettyServletContext extends WrappedInstance<Context> { - private WrappedJettyServletContext(Context object) { - super(object); - } - - private WrappedJettyServletContext() { - } - - } - - /** - * Find the servlet context. This is done by resolving the owner and looking for its server attribute - * - * @return the owner server, null if there is no server, - * @throws RemoteException network trouble - * @throws SmartFrogResolutionException failure to resolve - */ - public Prim findServletContext() throws RemoteException, SmartFrogResolutionException { - return getOwner().sfResolve(ApplicationServerContext.ATTR_SERVER, (Prim) null, false); - } - - - /** * add a Connector to the server * * @param connector a listener Modified: trunk/core/components/jetty/src/org/smartfrog/services/jetty/contexts/JettyServletContextIntf.java =================================================================== --- trunk/core/components/jetty/src/org/smartfrog/services/jetty/contexts/JettyServletContextIntf.java 2009-10-29 13:26:12 UTC (rev 7996) +++ trunk/core/components/jetty/src/org/smartfrog/services/jetty/contexts/JettyServletContextIntf.java 2009-10-29 14:46:34 UTC (rev 7997) @@ -29,14 +29,5 @@ public interface JettyServletContextIntf extends ServletContextIntf { - /** - * secret context. - * This is the attribute that is used to dynamically patch up with the - * the jetty context. only for intra-jetty implementation use, no stability - * guarantees, etc, etc. - * {@value} - */ - String ATTR_CONTEXT = "_context"; - } Modified: trunk/core/components/jetty/src/org/smartfrog/services/jetty/contexts/delegates/DelegateServletContext.java =================================================================== --- trunk/core/components/jetty/src/org/smartfrog/services/jetty/contexts/delegates/DelegateServletContext.java 2009-10-29 13:26:12 UTC (rev 7996) +++ trunk/core/components/jetty/src/org/smartfrog/services/jetty/contexts/delegates/DelegateServletContext.java 2009-10-29 14:46:34 UTC (rev 7997) @@ -50,10 +50,12 @@ import org.smartfrog.sfcore.logging.LogFactory; import org.smartfrog.sfcore.prim.Prim; import org.smartfrog.sfcore.reference.Reference; +import org.smartfrog.sfcore.componentdescription.ComponentDescription; import java.io.IOException; import java.rmi.RemoteException; import java.util.Map; +import java.util.Iterator; /** * This is a helper servlet context; it gets stuff delegated to it. It is remotable, but not a Prim-derived class. @@ -183,8 +185,21 @@ if (contextHandler == null) { throw new SmartFrogLifecycleException("Cannot start " + this + " as the server is not yet deployed"); } + contextHandler.addHandler(handlerSet); + + //now read in the options + //apply initialisation params from the context + ComponentDescription optionsCD = owner.sfResolve(ATTR_OPTIONS, (ComponentDescription) null, true); + org.smartfrog.sfcore.common.Context optionsContext = optionsCD.sfContext(); + Iterator iterator = optionsContext.sfAttributes(); + while (iterator.hasNext()) { + Object key = iterator.next(); + Object value = optionsContext.get(key); + ctx.setAttribute(key.toString(), value.toString()); + } + + log.info("Starting Jetty servlet context"); - contextHandler.addHandler(handlerSet); handlerLifecycle.start(); if(log.isInfoEnabled()) { dumpHandlers(getServerContextHandler().getHandlers()); @@ -343,8 +358,8 @@ if (handler.isStarted()) { handler.stop(); } - } catch (Exception ignore) { - log.info(ignore); + } catch (Exception e) { + log.info(e); } //remove the handler getHandlers().removeHandler(handler); Modified: trunk/core/components/www/src/org/smartfrog/services/www/HttpAttributes.java =================================================================== --- trunk/core/components/www/src/org/smartfrog/services/www/HttpAttributes.java 2009-10-29 13:26:12 UTC (rev 7996) +++ trunk/core/components/www/src/org/smartfrog/services/www/HttpAttributes.java 2009-10-29 14:46:34 UTC (rev 7997) @@ -96,9 +96,14 @@ String ATTR_LOGRESPONSE = "logResponse"; /** {@value} */ String ATTR_AUTH_REQUIRED = "authenticationRequired"; + /** {@value} */ int HTTP_PORT = 80; + /** {@value} */ int HTTPS_PORT = 443; + /** choose the port from the protocol: {@value} */ int CHOOSE_PORT = 0; + /** {@value} */ String HTTP = "http"; + /** {@value} */ String HTTPS = "https"; } Modified: trunk/core/components/www/src/org/smartfrog/services/www/ServletContextIntf.java =================================================================== --- trunk/core/components/www/src/org/smartfrog/services/www/ServletContextIntf.java 2009-10-29 13:26:12 UTC (rev 7996) +++ trunk/core/components/www/src/org/smartfrog/services/www/ServletContextIntf.java 2009-10-29 14:46:34 UTC (rev 7997) @@ -48,6 +48,11 @@ String ATTR_HOST_ADDRESS = "ipaddr"; /** + * Initial options for the context + */ + String ATTR_OPTIONS = "options"; + + /** * Add a mime mapping * * @param extension extension to map (no '.') Modified: trunk/core/components/www/src/org/smartfrog/services/www/webapplication.sf =================================================================== --- trunk/core/components/www/src/org/smartfrog/services/www/webapplication.sf 2009-10-29 13:26:12 UTC (rev 7996) +++ trunk/core/components/www/src/org/smartfrog/services/www/webapplication.sf 2009-10-29 14:46:34 UTC (rev 7997) @@ -133,10 +133,16 @@ //url path on server contextPath extends String; + + //CD of options + options extends Compulsory; } //implementation class sfClass "org.smartfrog.services.www.context.ServletContextImpl"; + + //CD of options + options extends DATA { }; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-11-14 20:34:02
|
Revision: 8041 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=8041&view=rev Author: steve_l Date: 2009-11-14 20:33:08 +0000 (Sat, 14 Nov 2009) Log Message: ----------- SFOS-1359 add a "remote smartfrog daemon service to cloudfarmer Modified Paths: -------------- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/deployment/NodeDeploymentOverSSHFactory.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/deployment/components.sf trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/deployment/components.sf trunk/core/components/persistence/build.xml trunk/core/components/ssh/src/org/smartfrog/services/ssh/AbstractSSHComponent.java Added Paths: ----------- trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/deployment/LocalDeployRMITest.java trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/deployment/LocalDeploySSHTest.java Removed Paths: ------------- trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/deployment/LocalhostFarmerTest.java Property Changed: ---------------- trunk/core/components/persistence/build.xml Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/deployment/NodeDeploymentOverSSHFactory.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/deployment/NodeDeploymentOverSSHFactory.java 2009-11-13 18:40:29 UTC (rev 8040) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/deployment/NodeDeploymentOverSSHFactory.java 2009-11-14 20:33:08 UTC (rev 8041) @@ -32,11 +32,14 @@ public static final String ATTR_DEST_DIR = "destDir"; public static final String ATTR_LOG_LEVEL = "logLevel"; public static final String ATTR_TEMP_FILE_PREFIX = "tempfilePrefix"; + public static final String ATTR_KEEP_FILES = "keepFiles"; protected int outputLogLevel; protected int counter = 0; protected String tempfilePrefix; + protected boolean keepFiles = false; + public NodeDeploymentOverSSHFactory() throws RemoteException { } @@ -56,6 +59,7 @@ } tempfilePrefix = sfResolve(ATTR_TEMP_FILE_PREFIX, "", true); outputLogLevel = sfResolve(ATTR_LOG_LEVEL, LogLevel.LOG_LEVEL_INFO, true); + keepFiles = sfResolve(ATTR_KEEP_FILES, keepFiles, true); try { jschInstance = createJschInstance(); } catch (JSchException e) { @@ -80,12 +84,17 @@ * @throws JSchException connection problems */ public synchronized Session demandCreateSession(String host) throws JSchException { - return createSession(jschInstance, host, getPort()); + Session newSession = createSession(jschInstance, host, getPort()); + newSession.setTimeout(getTimeout()); + newSession.connect(getConnectTimeout()); + return newSession; } /** - * SSH based deployment, assumes deploy-by-copy to a specified destdir, uses a given login <p/> This is an inner + * SSH based deployment, assumes deploy-by-copy to a specified destdir, uses a given login + * <p/> + * This is an inner * class and it uses the parent to do the work */ final class NodeDeploymentOverSSH extends AbstractNodeDeployment implements NodeDeploymentService { @@ -121,18 +130,26 @@ String connectionDetails = hostname + ":" + getPort(); Session session = null; try { + log.info("Deploying application "+ name + " to " + connectionDetails); session = demandCreateSession(hostname); sshExec(session, "mkdir -p " + destDir, false); ScpTo scp = new ScpTo(sfLog()); //copy up the temp files scp.doCopy(session, destFiles, sourceFiles); - sshExec(session, "sfStart " + "localhost" + " " + name + " " + desttempfile, false); - localtempfile.delete(); + String sshCommand = "sfStart " + "localhost" + " " + name + " " + desttempfile; + log.info("executing: " + sshCommand); + sshExec(session, sshCommand, true); + if(!keepFiles) { + sshExec(session, "rm " + desttempfile, true); + } } catch (JSchException e) { log.error("Failed to upload to " + connectionDetails + " : " + e, e); throw forward(e, connectionDetails); } finally { endSession(session); + if(!keepFiles) { + localtempfile.delete(); + } } } Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/deployment/components.sf =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/deployment/components.sf 2009-11-13 18:40:29 UTC (rev 8040) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/deployment/components.sf 2009-11-14 20:33:08 UTC (rev 8041) @@ -55,6 +55,10 @@ //passwordProvider TBD; user LAZY PROPERTY user.name; + //this is something you can turn on for debugging; it stops the files being deleted + //at either end + keepFiles false; + } /** Copied: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/deployment/LocalDeployRMITest.java (from rev 8038, trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/deployment/LocalhostFarmerTest.java) =================================================================== --- trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/deployment/LocalDeployRMITest.java (rev 0) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/deployment/LocalDeployRMITest.java 2009-11-14 20:33:08 UTC (rev 8041) @@ -0,0 +1,40 @@ +/* (C) Copyright 2007 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 + +*/ +package org.smartfrog.services.cloudfarmer.test.deployment; + +import org.smartfrog.test.DeployingTestBase; + +/** + * Created 30-Nov-2007 16:46:45 + */ + +public class LocalDeployRMITest extends DeployingTestBase { + public static final String FILES = "/org/smartfrog/services/cloudfarmer/test/deployment/"; + + public LocalDeployRMITest(String name) { + super(name); + } + + public void testLocalhostDeployCompoundOverRMI() throws Throwable { + expectSuccessfulTestRunOrSkip(FILES, "testLocalhostDeployCompoundOverRMI"); + } + + +} Copied: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/deployment/LocalDeploySSHTest.java (from rev 8038, trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/deployment/LocalhostFarmerTest.java) =================================================================== --- trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/deployment/LocalDeploySSHTest.java (rev 0) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/deployment/LocalDeploySSHTest.java 2009-11-14 20:33:08 UTC (rev 8041) @@ -0,0 +1,39 @@ +/* (C) Copyright 2007 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 + +*/ +package org.smartfrog.services.cloudfarmer.test.deployment; + +import org.smartfrog.test.DeployingTestBase; + +/** + * Created 30-Nov-2007 16:46:45 + */ + +public class LocalDeploySSHTest extends DeployingTestBase { + public static final String FILES = "/org/smartfrog/services/cloudfarmer/test/deployment/"; + + public LocalDeploySSHTest(String name) { + super(name); + } + + public void testLocalhostDeployCompoundOverSSH() throws Throwable { + expectSuccessfulTestRunOrSkip(FILES, "testLocalhostDeployCompoundOverSSH"); + } + +} Deleted: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/deployment/LocalhostFarmerTest.java =================================================================== --- trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/deployment/LocalhostFarmerTest.java 2009-11-13 18:40:29 UTC (rev 8040) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/deployment/LocalhostFarmerTest.java 2009-11-14 20:33:08 UTC (rev 8041) @@ -1,43 +0,0 @@ -/* (C) Copyright 2007 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 - -*/ -package org.smartfrog.services.cloudfarmer.test.deployment; - -import org.smartfrog.test.DeployingTestBase; - -/** - * Created 30-Nov-2007 16:46:45 - */ - -public class LocalhostFarmerTest extends DeployingTestBase { - public static final String FILES = "/org/smartfrog/services/cloudfarmer/test/deployment/"; - - public LocalhostFarmerTest(String name) { - super(name); - } - - public void testLocalhostDeployCompoundOverRMI() throws Throwable { - expectSuccessfulTestRunOrSkip(FILES, "testLocalhostDeployCompoundOverRMI"); - } - - public void testLocalhostDeployCompoundOverSSH() throws Throwable { - expectSuccessfulTestRunOrSkip(FILES, "testLocalhostDeployCompoundOverSSH"); - } - -} \ No newline at end of file Modified: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/deployment/components.sf =================================================================== --- trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/deployment/components.sf 2009-11-13 18:40:29 UTC (rev 8040) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/deployment/components.sf 2009-11-14 20:33:08 UTC (rev 8041) @@ -23,15 +23,15 @@ DeployMaster extends WorkflowFarmCustomer { - role "master"; - toDeploy extends DATA { - sfClass Compound:sfClass; - "this is the toplevel application"; - } - min 1; - expected 1; - deleteOnTerminate false; - } + role "master"; + toDeploy extends DATA { + sfClass Compound:sfClass; + description "this is the toplevel application"; + } + min 1; + expected 1; + deleteOnTerminate false; +} @@ -64,4 +64,4 @@ action extends TestLocalhostClusterSSH; tests:master:toDeployName "overSSH"; -} \ No newline at end of file +} Modified: trunk/core/components/persistence/build.xml =================================================================== --- trunk/core/components/persistence/build.xml 2009-11-13 18:40:29 UTC (rev 8040) +++ trunk/core/components/persistence/build.xml 2009-11-14 20:33:08 UTC (rev 8041) @@ -1,54 +1,54 @@ -<?xml version="1.0"?> -<!-- -/** (C) Copyright 1998-2007 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 - -*/ ---><project name="persistence" default="default"> - <description>Build file for Solid woodfrog storage.</description> - <!-- override point --> - <property file="build.properties"/> - <property name="root.dir" location="../.."/> <!-- see build.properties for over-ride --> - - <property name="ivy.enabled" value="true" /> - <property name="javac.java.version" value="1.5" /> - <property name="is.component" value="true" /> - <property name="system.tests" value="true"/> - <property name="javadoc.packages" value="org.smartfrog.services.persistence.*"/> - <property name="javadoc.package.name" value="persistence"/> - <property file="${root.dir}/common.properties"/> - - <!-- this is an extra set of properties you can use outside SVN trees --> - <property file="${user.home}/.ant/smartfrog.properties"/> - - <!-- now read in environment settings --> - <property environment="env" /> - <!-- read these after the env settings --> - <echo> root.dir = ${root.dir}</echo> - <property file="${root.dir}/build.properties"/> - <property name="smartfrog.artifact.version" value="latest.integration" /> - - <!-- Import common stuff --> - <import file="${root.dir}/common.xml"/> - - <!-- ========================================================== --> - <!-- ========================================================== --> - <target name="init" - depends="init-standard-output-dirs,use-smartfrog-tasks,use-smartfrog-testharness"> - </target> - </project> +<?xml version="1.0"?> +<!-- +/** (C) Copyright 1998-2007 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 + +*/ +--><project name="persistence" default="default"> + <description>Build file for Solid woodfrog storage.</description> + <!-- override point --> + <property file="build.properties"/> + <property name="root.dir" location="../.."/> <!-- see build.properties for over-ride --> + + <property name="ivy.enabled" value="true" /> + <property name="javac.java.version" value="1.5" /> + <property name="is.component" value="true" /> + <property name="system.tests" value="true"/> + <property name="javadoc.packages" value="org.smartfrog.services.persistence.*"/> + <property name="javadoc.package.name" value="persistence"/> + <property file="${root.dir}/common.properties"/> + + <!-- this is an extra set of properties you can use outside SVN trees --> + <property file="${user.home}/.ant/smartfrog.properties"/> + + <!-- now read in environment settings --> + <property environment="env" /> + <!-- read these after the env settings --> + <echo> root.dir = ${root.dir}</echo> + <property file="${root.dir}/build.properties"/> + <property name="smartfrog.artifact.version" value="latest.integration" /> + + <!-- Import common stuff --> + <import file="${root.dir}/common.xml"/> + + <!-- ========================================================== --> + <!-- ========================================================== --> + <target name="init" + depends="init-standard-output-dirs,use-smartfrog-tasks,use-smartfrog-testharness"> + </target> + </project> Property changes on: trunk/core/components/persistence/build.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/core/components/ssh/src/org/smartfrog/services/ssh/AbstractSSHComponent.java =================================================================== --- trunk/core/components/ssh/src/org/smartfrog/services/ssh/AbstractSSHComponent.java 2009-11-13 18:40:29 UTC (rev 8040) +++ trunk/core/components/ssh/src/org/smartfrog/services/ssh/AbstractSSHComponent.java 2009-11-14 20:33:08 UTC (rev 8041) @@ -110,6 +110,10 @@ return timeout; } + public int getConnectTimeout() { + return connectTimeout; + } + public String getHost() { return host; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-12-02 15:57:43
|
Revision: 8079 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=8079&view=rev Author: steve_l Date: 2009-12-02 15:57:30 +0000 (Wed, 02 Dec 2009) Log Message: ----------- SFOS-1327 Add tests for Mombasa webapps Modified Paths: -------------- trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/cluster_nav.jsp trunk/core/components/cloudfarmer/site/html/mombasa-portlet/nav.jsp trunk/core/components/junit/ivy.xml trunk/core/components/junit/src/org/smartfrog/services/junit/junit3/JUnit3TestSuiteImpl.java trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/AbstractTestSuite.java trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/TestSuite.java trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/testsuite.sf Added Paths: ----------- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/WebTestCase.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/cluster/ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/cluster/ClusterAnchors.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/cluster/MombasaClusterWebTestCase.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/cluster/components.sf trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/workflow/ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/workflow/WorkflowAnchors.java trunk/core/components/junit/src/org/smartfrog/services/junit/junit3/TestCaseWithContext.java Modified: trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/cluster_nav.jsp =================================================================== --- trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/cluster_nav.jsp 2009-12-02 13:08:21 UTC (rev 8078) +++ trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/cluster_nav.jsp 2009-12-02 15:57:30 UTC (rev 8079) @@ -28,19 +28,19 @@ <tr> <td> <html:link - action="/mombasa-portlet/cluster/list">List Hosts</html:link> + action="/mombasa-portlet/cluster/list" name="listHosts">List Hosts</html:link> </td> <td> <html:link - action="/mombasa-portlet/cluster/listRoles">List Roles</html:link> + action="/mombasa-portlet/cluster/listRoles" name="listRoles">List Roles</html:link> </td> <td> <html:link - action="/mombasa-portlet/cluster/add">Add a Host</html:link> + action="/mombasa-portlet/cluster/add" name="add">Add a Host</html:link> </td> <td> <html:link - action="/mombasa-portlet/cluster/admin">Administration</html:link> + action="/mombasa-portlet/cluster/admin" name="admin">Administration</html:link> </td> </tr> </table> Modified: trunk/core/components/cloudfarmer/site/html/mombasa-portlet/nav.jsp =================================================================== --- trunk/core/components/cloudfarmer/site/html/mombasa-portlet/nav.jsp 2009-12-02 13:08:21 UTC (rev 8078) +++ trunk/core/components/cloudfarmer/site/html/mombasa-portlet/nav.jsp 2009-12-02 15:57:30 UTC (rev 8079) @@ -26,23 +26,23 @@ <table border="0" width="100%"> <tr> <td> - <html:link action="/mombasa-portlet/workflowList">List Workflows</html:link> + <html:link action="/mombasa-portlet/workflowList" name="workflowList">List Workflows</html:link> </td> <td> <html:link - action="/mombasa-portlet/submitMRJob/view">Queue a MapReduce Job</html:link> + action="/mombasa-portlet/submitMRJob/view" name="submitMRJob">Queue a MapReduce Job</html:link> </td> <td> <html:link - action="/mombasa-portlet/submitTool/view">Queue a Tool Job</html:link> + action="/mombasa-portlet/submitTool/view" name="submitTool">Queue a Tool Job</html:link> </td> <td> <html:link - action="/mombasa-portlet/queueWorkflow/view">Queue a Workflow</html:link> + action="/mombasa-portlet/queueWorkflow/view" name="queueWorkflow">Queue a Workflow</html:link> </td> <td> <html:link - action="/mombasa-portlet/workflowAdmin/view">Administration</html:link> + action="/mombasa-portlet/workflowAdmin/view" name="workflowAdmin">Administration</html:link> </td> </tr> </table> Added: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/WebTestCase.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/WebTestCase.java (rev 0) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/WebTestCase.java 2009-12-02 15:57:30 UTC (rev 8079) @@ -0,0 +1,66 @@ +/* (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 + +*/ +package org.smartfrog.services.cloudfarmer.client.web.htmlunit; + +import junit.framework.TestCase; +import org.smartfrog.services.xunit.base.TestContextInjector; +import org.smartfrog.services.junit.junit3.TestCaseWithContext; +import com.gargoylesoftware.htmlunit.WebClient; + +/** + * Base class for all web test cases; they take their URL from a system/context property + * + * These tests are expected to be deployed and run against different targets, hence they are included in the + * Main distributable, and their pattern *TestCase is designed to not be picked up by the *Test pattern. + */ + +public abstract class WebTestCase extends TestCaseWithContext { + + /** {@value} */ + public static final String TEST_WEB_URL ="test.web.url"; + + + protected WebTestCase(String name) { + super(name); + } + + /** + * Get a required property, asserts it is not null + * @param key key to look for + * @return the value + */ + public String getRequiredProperty(String key) { + String s = getProperty(key, null); + assertNotNull("No entry for " + key, s); + return s; + } + + protected String getClusterURL() { + return getProperty(TEST_WEB_URL + "/cluster", ""); + } + + protected String getWorkflowURL() { + return getProperty(TEST_WEB_URL + "/workflow", ""); + } + + protected WebClient getWebClient() { + return new WebClient(); + } +} Added: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/cluster/ClusterAnchors.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/cluster/ClusterAnchors.java (rev 0) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/cluster/ClusterAnchors.java 2009-12-02 15:57:30 UTC (rev 8079) @@ -0,0 +1,54 @@ +/* (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 + +*/ +package org.smartfrog.services.cloudfarmer.client.web.htmlunit.cluster; + +/** + * Created 02-Dec-2009 13:00:27 + */ + + +public interface ClusterAnchors { + + /* + action="/mombasa-portlet/cluster/list" name="listHosts">List Hosts</html:link> + </td> + <td> + <html:link + action="/mombasa-portlet/cluster/listRoles" name="listRoles">List Roles</html:link> + </td> + <td> + <html:link + action="/mombasa-portlet/cluster/add" name="add">Add a Host</html:link> + </td> + <td> + <html:link + action="/mombasa-portlet/cluster/admin" name="admin">Administration</html:link> + */ + + String LIST_HOSTS ="listHosts"; + /** {@value} */ + String LIST_ROLES = "listRoles"; + /** {@value} */ + String ADD_HOST="add"; + /** {@value} */ + String ADMIN="admin"; + /** {@value} */ + //String=""; +} Added: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/cluster/MombasaClusterWebTestCase.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/cluster/MombasaClusterWebTestCase.java (rev 0) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/cluster/MombasaClusterWebTestCase.java 2009-12-02 15:57:30 UTC (rev 8079) @@ -0,0 +1,61 @@ +/* (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 + +*/ +package org.smartfrog.services.cloudfarmer.client.web.htmlunit.cluster; + +import org.smartfrog.services.cloudfarmer.client.web.htmlunit.WebTestCase; +import com.gargoylesoftware.htmlunit.WebClient; +import com.gargoylesoftware.htmlunit.Page; +import com.gargoylesoftware.htmlunit.html.HtmlPage; +import com.gargoylesoftware.htmlunit.html.HtmlAnchor; + +import java.io.IOException; + +/** + * Created 30-Nov-2009 14:16:41 + */ + +public class MombasaClusterWebTestCase extends WebTestCase implements ClusterAnchors { + private static final String ANCHOR_WORKFLOW_LIST = "workflowList"; + + public MombasaClusterWebTestCase(String name) { + super(name); + } + + public void testRootPageListHosts() throws Throwable { + HtmlPage rootPage = getRootPage(); + HtmlAnchor workflowList = rootPage.getAnchorByName(LIST_HOSTS); + } + + public void testRootPageListRoles() throws Throwable { + HtmlPage rootPage = getRootPage(); + HtmlAnchor workflowList = rootPage.getAnchorByName(LIST_ROLES); + } + + public void testRootPageAdd() throws Throwable { + HtmlPage rootPage = getRootPage(); + HtmlAnchor workflowList = rootPage.getAnchorByName(ADD_HOST); + } + + protected HtmlPage getRootPage() throws IOException { + WebClient browser = getWebClient(); + HtmlPage clusterPage = browser.getPage(getClusterURL()); + return clusterPage; + } +} Added: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/cluster/components.sf =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/cluster/components.sf (rev 0) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/cluster/components.sf 2009-12-02 15:57:30 UTC (rev 8079) @@ -0,0 +1,29 @@ +/* (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 + +*/ + +MombasaClusterTestSuite extends MombasaWebTestSuite { + + package "org.smartfrog.services.cloudfarmer.client.web.htmlunit.cluster"; + + classes [ + "MombasaClusterWebTestCase" + ]; + +} Added: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/workflow/WorkflowAnchors.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/workflow/WorkflowAnchors.java (rev 0) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/workflow/WorkflowAnchors.java 2009-12-02 15:57:30 UTC (rev 8079) @@ -0,0 +1,29 @@ +/* (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 + +*/ +package org.smartfrog.services.cloudfarmer.client.web.htmlunit.workflow; + +/** + * Created 02-Dec-2009 12:59:23 + */ + + +public interface WorkflowAnchors { + String ANCHOR_WORKFLOW_LIST = "workflowList"; +} Modified: trunk/core/components/junit/ivy.xml =================================================================== --- trunk/core/components/junit/ivy.xml 2009-12-02 13:08:21 UTC (rev 8078) +++ trunk/core/components/junit/ivy.xml 2009-12-02 15:57:30 UTC (rev 8079) @@ -55,7 +55,7 @@ <dependency org="org.smartfrog" name="sf-xunit" changing="true" rev="latest.integration" - conf="compile->master;runtime->default"/> + conf="compile->master;runtime->default"/> <dependency org="junit" name="junit" rev="${junit3.version}" Modified: trunk/core/components/junit/src/org/smartfrog/services/junit/junit3/JUnit3TestSuiteImpl.java =================================================================== --- trunk/core/components/junit/src/org/smartfrog/services/junit/junit3/JUnit3TestSuiteImpl.java 2009-12-02 13:08:21 UTC (rev 8078) +++ trunk/core/components/junit/src/org/smartfrog/services/junit/junit3/JUnit3TestSuiteImpl.java 2009-12-02 15:57:30 UTC (rev 8079) @@ -35,6 +35,7 @@ import org.smartfrog.sfcore.common.SmartFrogResolutionException; import org.smartfrog.sfcore.logging.Log; import org.smartfrog.sfcore.utils.ListUtils; +import org.smartfrog.sfcore.reference.Reference; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -53,9 +54,6 @@ public class JUnit3TestSuiteImpl extends AbstractTestSuite implements JUnitTestSuite, junit.framework.TestListener { - /** our log */ - private Log log; - /** List of classes to test */ private List<String> classes; @@ -91,6 +89,7 @@ + ATTR_SYSPROPS; /** {@value } */ private static final String SUITE_METHOD_NAME = "suite"; + /** {@value } */ public static final String WARN_IGNORING_REMOTE_FAULT = "Ignoring remote fault"; public JUnit3TestSuiteImpl() throws RemoteException { @@ -108,7 +107,6 @@ public synchronized void sfStart() throws SmartFrogException, RemoteException { super.sfStart(); - log=sfLog(); readConfiguration(); } @@ -135,37 +133,8 @@ singleTest = sfResolve(ATTR_SINGLE_TEST, singleTest, false); //properties. extract the list, flatten it and bind to sysproperties - List propList = (List) sfResolve(ATTR_SYSPROPS, - (List) null, - false); - //TODO: represent as tuples + sysproperties = ListUtils.resolveProperties(this, new Reference(ATTR_SYSPROPS), true); - if (propList != null && !propList.isEmpty()) { - List<String> properties = ListUtils.flattenStringList(propList, ATTR_SYSPROPS); - String[] values = new String[0]; - values = properties.toArray(values); - int len = values.length; - if ((len % 2) != 0) { - //build up an error message with as much data as we can include - StringBuffer valuesBuffer = new StringBuffer(" ["); - for (int i = 0; i < len; i++) { - valuesBuffer.append(values[i]); - valuesBuffer.append(' '); - } - valuesBuffer.append(']'); - throw new SmartFrogInitException(ERROR_UNEVEN_PROPERTIES + valuesBuffer); - } - - // system properties - sysproperties = new Properties(); - - for (int i = 0; i < len; i += 2) { - String key = values[i]; - String value = values[i + 1]; - sysproperties.setProperty(key, value); - } - } - //package attribute names a package packageValue = sfResolve(ATTR_PACKAGE, packageValue, false); if (packageValue == null) { @@ -213,7 +182,7 @@ || singleTest.equals(fullname); if (add && testClasses.get(fullname) == null) { - log.debug("adding test " + fullname); + sfLog().debug("adding test " + fullname); testClasses.put(fullname, fullname); } } @@ -229,7 +198,7 @@ } private void log(String message) { - log.info(message); + sfLog().info(message); } @@ -254,7 +223,7 @@ public boolean runTests() throws RemoteException, SmartFrogException { - log.info("Running junit3 test suite " + suitename); + sfLog().info("Running junit3 test suite " + suitename); checkConfigured(); //bind to our listener TestListenerLog testLog = null; @@ -273,11 +242,8 @@ } //copy any system properties over - if (sysproperties != null) { - Utils.applySysProperties(sysproperties); + Utils.applySysProperties(sysproperties); - } - // set up our context HashMap<String, Object> context = new HashMap<String, Object>(); context.put(TestContextInjector.ATTR_PRIM, this); @@ -296,7 +262,7 @@ throw SmartFrogException.forward(e); } if (Thread.currentThread().isInterrupted()) { - log.error("Interrupted test thread"); + sfLog().error("Interrupted test thread"); failed = true; } updateResultAttributes(false); @@ -440,7 +406,7 @@ private void injectTestContext(Test test, HashMap<String, Object> context) { if (test instanceof TestContextInjector) { TestContextInjector tci = (TestContextInjector) test; - tci.setTestContext(context); + tci.setTestContext((HashMap<String, Object>) context.clone()); } else if (test instanceof TestSuite) { injectTestContext((TestSuite) test, context); } @@ -476,7 +442,7 @@ * @param e exception */ private void IgnoreRemoteFault(Exception e) { - log.warn(WARN_IGNORING_REMOTE_FAULT, e); + sfLog().warn(WARN_IGNORING_REMOTE_FAULT, e); } /** Added: trunk/core/components/junit/src/org/smartfrog/services/junit/junit3/TestCaseWithContext.java =================================================================== --- trunk/core/components/junit/src/org/smartfrog/services/junit/junit3/TestCaseWithContext.java (rev 0) +++ trunk/core/components/junit/src/org/smartfrog/services/junit/junit3/TestCaseWithContext.java 2009-12-02 15:57:30 UTC (rev 8079) @@ -0,0 +1,104 @@ +/* (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 + +*/ +package org.smartfrog.services.junit.junit3; + +import junit.framework.TestCase; +import org.smartfrog.services.xunit.base.TestContextInjector; + +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +/** + * This is a test case with context. + * + * This design is intended to work inside SmartFrog or outside; it creates a stub context which can be overwritten + * by {@link TestContextInjector#setTestContext(HashMap)} when the SF test runner forces a context + */ + +public abstract class TestCaseWithContext extends TestCase implements TestContextInjector { + + protected Map<String, Object> testContext = new HashMap<String, Object>(); + protected boolean contextSet; + + protected Properties properties = new Properties(); + + protected TestCaseWithContext(String name) { + super(name); + } + + /** + * Get the test context + * + * @return the current test context or null + */ + public Map<String, Object> getTestContext() { + return testContext; + } + + /** + * {@inheritDoc} + * + * @param testContext the test context + */ + @Override + public void setTestContext(HashMap<String, Object> testContext) { + this.testContext = testContext; + contextSet = true; + //set the properties, with a bit of contingency planning + properties = (Properties) getContextEntry(TestContextInjector.ATTR_PROPERTIES); + if (properties == null) { + properties = new Properties(); + } + } + + /** + * Get any entry in the test case context + * + * @param key key to search for + * @return the entry or null for no match + */ + public Object getContextEntry(String key) { + return testContext.get(key); + } + + /** + * Get a string property. First the context properties used, then the System properties + * + * @param key key to look for + * @param defVal default value + * @return a discovered property, or the default values + */ + public String getProperty(String key, String defVal) { + String result = properties.getProperty(key, null); + return result != null ? result : + System.getProperty(key, defVal); + } + + /** + * Set a property + * + * @param key property key + * @param value value + */ + public void setProperty(String key, String value) { + properties.setProperty(key, value); + } +} Modified: trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/AbstractTestSuite.java =================================================================== --- trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/AbstractTestSuite.java 2009-12-02 13:08:21 UTC (rev 8078) +++ trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/AbstractTestSuite.java 2009-12-02 15:57:30 UTC (rev 8079) @@ -32,12 +32,10 @@ import java.rmi.RemoteException; /** - * This is an abstract base class for test suites. - * Its key feature is that it provides a thread local context variable that can be used to retrieve the current - * context of a running test. + * This is an abstract base class for test suites. Its key feature is that it provides a thread local context variable + * that can be used to retrieve the current context of a running test. * - * Because it extends ConditionCompound, it has the event workflow lifecycle - * created 10-Oct-2006 11:39:29 + * Because it extends ConditionCompound, it has the event workflow lifecycle created 10-Oct-2006 11:39:29 */ public abstract class AbstractTestSuite extends ConditionCompound implements TestSuite { @@ -60,16 +58,14 @@ protected ComponentHelper helper; /** - * Error Text - * </p> - * {@value} + * Error Text </p> {@value} */ - public static final String ERROR_OVERWRITING_CONTEXT = "Overwriting an existing thread-local configuration context.\n" - +"Multiple thread runners may be active in the same thread\n" - +"or the tests are themselves deploying tests."; + public static final String ERROR_OVERWRITING_CONTEXT = + "Overwriting an existing thread-local configuration context.\n" + + "Multiple thread runners may be active in the same thread\n" + + "or the tests are themselves deploying tests."; /** - * Error Text - * {@value} + * Error Text {@value} */ public static final String ERROR_OVERWRITING_SELF = "The component is overwriting its own configuration"; @@ -79,6 +75,7 @@ /** * {@inheritDoc} + * * @return false */ @Override @@ -93,7 +90,7 @@ * @return true */ @Override - protected boolean onEvaluateNoCondition() { + protected boolean onEvaluateNoCondition() { return true; } @@ -142,21 +139,21 @@ * bind to the configuration. A null parameter means 'stop binding' * * @param configuration config to bind to - * @throws RemoteException on network trouble + * @throws RemoteException on network trouble * @throws SmartFrogException for other problems */ public void bind(RunnerConfiguration configuration) throws RemoteException, SmartFrogException { - boolean overwriting=false; - boolean overwritingourselves=false; - synchronized(getConfigurationContext()) { + boolean overwriting = false; + boolean overwritingourselves = false; + synchronized (getConfigurationContext()) { RunnerConfiguration current = getConfigurationContext().get(); - if(current !=null && configuration!=null) { - overwriting=true; - overwritingourselves= current == configuration; + if (current != null && configuration != null) { + overwriting = true; + overwritingourselves = current == configuration; } getConfigurationContext().set(configuration); //set or reset the test suite context - if(configuration!=null) { + if (configuration != null) { if (getTestSuiteContext().get() != null) { overwriting = true; } @@ -170,7 +167,7 @@ //warn that something got overwritten. It is probably harmless, but can //cause interesting behaviour sfLog().info(ERROR_OVERWRITING_CONTEXT); - if(overwritingourselves) { + if (overwritingourselves) { sfLog().info(ERROR_OVERWRITING_SELF); } } @@ -186,6 +183,7 @@ /** * Get the thread local configuration. + * * @return the configuration (may be null) */ public static RunnerConfiguration getConfiguration() { @@ -194,6 +192,7 @@ /** * Get the thread local test suite + * * @return the configuration (may be null) */ public static Prim getTestSuite() { @@ -203,10 +202,11 @@ /** * Decide whether or not to skip the suite; report it if true - * @see #reportSkippedTestSuite() + * * @return true if the test is to be skipped - * @throws RemoteException network trouble + * @throws RemoteException network trouble * @throws SmartFrogException other problems + * @see #reportSkippedTestSuite() */ protected boolean maybeSkipTestSuite() throws RemoteException, SmartFrogException { if (!evaluate()) { @@ -219,15 +219,17 @@ /** * Report a skipped test - * @throws RemoteException network trouble + * + * @throws RemoteException network trouble * @throws SmartFrogException other problems */ - protected void reportSkippedTestSuite () throws RemoteException, SmartFrogException { + protected void reportSkippedTestSuite() throws RemoteException, SmartFrogException { //TODO: any reporting } /** * Get the test listener factory from this configuration + * * @return the test listener factory */ protected TestListenerFactory getTestListenerFactory() { @@ -256,10 +258,11 @@ /** * Create a new listener from the current factory. + * * @param suiteName name of the suite * @return a new listener * @throws SmartFrogException if needed - * @throws RemoteException on network trouble + * @throws RemoteException on network trouble */ protected TestListener listen(String suiteName) throws RemoteException, SmartFrogException { TestListenerFactory listenerFactory = getTestListenerFactory(); @@ -273,11 +276,11 @@ } /** - * write all our state to the results order it so that we set the finished - * last + * write all our state to the results order it so that we set the finished last + * * @param finished finished flag * @throws SmartFrogRuntimeException if needed - * @throws RemoteException on network trouble + * @throws RemoteException on network trouble */ protected void updateResultAttributes(boolean finished) throws SmartFrogRuntimeException, RemoteException { @@ -286,17 +289,19 @@ /** * Get the current configuration; create it if needed + * * @return the configuration context thread local */ private static synchronized ThreadLocal<RunnerConfiguration> getConfigurationContext() { - if(configurationContext==null) { - configurationContext=new ThreadLocal<RunnerConfiguration>(); + if (configurationContext == null) { + configurationContext = new ThreadLocal<RunnerConfiguration>(); } return configurationContext; } /** * Get the current test suite context; create it if needed + * * @return the test suite context thread local */ private static synchronized ThreadLocal<Prim> getTestSuiteContext() { Modified: trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/TestSuite.java =================================================================== --- trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/TestSuite.java 2009-12-02 13:08:21 UTC (rev 8078) +++ trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/TestSuite.java 2009-12-02 15:57:30 UTC (rev 8079) @@ -21,12 +21,12 @@ import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.workflow.conditional.Conditional; + import java.rmi.RemoteException; /** - * A test suite is anything that is testable. It extends Conditional as all - * test suites are inherently conditional. + * A test suite is anything that is testable. It extends Conditional as all test suites are inherently conditional. * 15-Apr-2004 11:51:51 */ @@ -35,14 +35,12 @@ /** - * Non-marked up text description - * {@value} + * Non-marked up text description {@value} */ public String ATTR_DESCRIPTION = "description"; /** - * A list of URLs to link to - * {@value} + * A list of URLs to link to {@value} */ public String ATTR_LINKS = "links"; @@ -52,35 +50,30 @@ public String ATTR_NAME = "name"; /** - * list in name, value pairs [[name,value],[n2,v2]] - * {@value} + * list in name, value pairs [[name,value],[n2,v2]] {@value} */ - public String ATTR_SYSPROPS="properties"; + public String ATTR_SYSPROPS = "properties"; /** - * A list of text tags to describe the test suite - * {@value} + * A list of text tags to describe the test suite {@value} */ public String ATTR_TAGS = "tags"; /** - * A list of URLs to track back on - * {@value} + * A list of URLs to track back on {@value} */ public String ATTR_TRACKBACKS = "trackbacks"; /** - * A list of issues, such as defect IDs - * {@value} + * A list of issues, such as defect IDs {@value} */ public String ATTR_ISSUES = "issues"; /** - * The name of another test suite that must have succeeded - * before this test runs. If this component failed to deploy or - * succeed, then this test suite is skipped. + * The name of another test suite that must have succeeded before this test runs. If this component failed to deploy + * or succeed, then this test suite is skipped. */ public String ATTR_MUST_SUCCEED = "mustSucceed"; @@ -88,7 +81,7 @@ * bind to the configuration. A null parameter means 'stop binding' * * @param configuration configuration to bind to - * @throws RemoteException for network problems + * @throws RemoteException for network problems * @throws SmartFrogException for other problems */ void bind(RunnerConfiguration configuration) throws RemoteException, @@ -96,11 +89,12 @@ /** * run the tests + * * @return true if they worked - * @throws RemoteException for network problems - * @throws SmartFrogException for other problems + * @throws RemoteException for network problems + * @throws SmartFrogException for other problems * @throws InterruptedException if the thread got interrupted while the tests were running */ - boolean runTests() throws RemoteException, SmartFrogException,InterruptedException; + boolean runTests() throws RemoteException, SmartFrogException, InterruptedException; } Modified: trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/testsuite.sf =================================================================== --- trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/testsuite.sf 2009-12-02 13:08:21 UTC (rev 8078) +++ trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/testsuite.sf 2009-12-02 15:57:30 UTC (rev 8079) @@ -23,7 +23,7 @@ description "a condition to evaluate to decide whether to run this test or not"; } - properties extends OptionalVector { + properties extends Vector { description "list of properties to pass to the test suite as name, value pairs [[name,value],[n2,v2]]"; } tags extends OptionalVector{ @@ -55,6 +55,7 @@ issues []; tags []; trackbacks []; + properties []; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-12-02 16:45:13
|
Revision: 8081 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=8081&view=rev Author: steve_l Date: 2009-12-02 16:45:03 +0000 (Wed, 02 Dec 2009) Log Message: ----------- SFOS-1327 Add tests for Mombasa webapps Modified Paths: -------------- trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/antxml/components.sf Added Paths: ----------- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/components.sf trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/htmlunit/ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/htmlunit/HtmlUnitTest.java trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/htmlunit/components.sf trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/htmlunit/testClusterWebapp.sf Added: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/components.sf =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/components.sf (rev 0) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/components.sf 2009-12-02 16:45:03 UTC (rev 8081) @@ -0,0 +1,33 @@ +/* (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/junit/junit3/components.sf" + +MombasaWebTestSuite extends JUnit3TestSuite { + + test.web.url TBD; + + properties [ + ["test.web.url",test.web.url] + ] + + +} + +#include "/org/smartfrog/services/cloudfarmer/client/web/htmlunit/cluster/components.sf" Copied: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/htmlunit/HtmlUnitTest.java (from rev 8073, trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/webapp/JettyWebappTest.java) =================================================================== --- trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/htmlunit/HtmlUnitTest.java (rev 0) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/htmlunit/HtmlUnitTest.java 2009-12-02 16:45:03 UTC (rev 8081) @@ -0,0 +1,20 @@ +package org.smartfrog.services.cloudfarmer.test.client.web.htmlunit; + +import org.smartfrog.test.DeployingTestBase; + +/** + * + */ +public class HtmlUnitTest extends DeployingTestBase { + public static final String FILES = "/org/smartfrog/services/cloudfarmer/test/client/web/htmlunit/"; + + public HtmlUnitTest(String name) { + super(name); + } + + public void testClusterWebapp() throws Throwable { + expectSuccessfulTestRunOrSkip(FILES, "testClusterWebapp"); + } + + +} \ No newline at end of file Added: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/htmlunit/components.sf =================================================================== --- trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/htmlunit/components.sf (rev 0) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/htmlunit/components.sf 2009-12-02 16:45:03 UTC (rev 8081) @@ -0,0 +1,54 @@ +/* (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/components.sf" +#include "/org/smartfrog/services/cloudfarmer/client/web/htmlunit/components.sf" +#include "/org/smartfrog/services/xunit/listeners/antxml/components.sf" +#include "/org/smartfrog/services/xunit/base/components.sf" + + +HtmlUnitTests extends ExpectJettyServerDeployed { + + test.data.dir PROPERTY test.data.dir; + + testSuite TBD; + test.web.url TBD; + + tests extends TestRunner { + + + + properties [ + ["test.web.url",test.web.url] + ] + + + listener extends AntXmlTestListener { + outputDirectory PARENT:ATTRIB test.data.dir; + } + + JUnitTestSuite testSuite; + } + +} + +testClusterWebapp extends HtmlUnitTests { + description "Test the cluster application"; + testSuite extends MombasaClusterTestSuite; +} Added: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/htmlunit/testClusterWebapp.sf =================================================================== --- trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/htmlunit/testClusterWebapp.sf (rev 0) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/htmlunit/testClusterWebapp.sf 2009-12-02 16:45:03 UTC (rev 8081) @@ -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/htmlunit/components.sf" + +sfConfig extends testClusterWebapp ; \ No newline at end of file Modified: trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/antxml/components.sf =================================================================== --- trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/antxml/components.sf 2009-12-02 16:44:28 UTC (rev 8080) +++ trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/antxml/components.sf 2009-12-02 16:45:03 UTC (rev 8081) @@ -23,6 +23,7 @@ * adds ant XML output */ #include "/org/smartfrog/services/xunit/listeners/xml/components.sf" +#include "/org/smartfrog/services/xunit/listeners/html/components.sf" /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-12-10 17:11:18
|
Revision: 8088 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=8088&view=rev Author: steve_l Date: 2009-12-10 17:11:07 +0000 (Thu, 10 Dec 2009) Log Message: ----------- SFOS-557 tests are outputting in junit XSL compatible form Modified Paths: -------------- 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/htmlunit/WebTestCase.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/components.sf trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/examples/ec2_hadoop_farmer.sf trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/htmlunit/components.sf trunk/core/components/junit/src/org/smartfrog/services/junit/junit3/JUnit3TestSuiteImpl.java trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/TestRunnerImpl.java trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/antxml/AntXmlListener.java trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/antxml/AntXmlTestListenerComponent.java trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/html/OneHostHtmlListener.java trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/xml/AbstractXmlListenerComponent.java trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/xml/FileListener.java trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/xml/OneHostXMLListener.java trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/xml/XmlListenerFactory.java trunk/core/components/xunit/src/org/smartfrog/services/xunit/serial/TestInfo.java trunk/core/components/xunit/src/org/smartfrog/services/xunit/serial/ThrowableTraceInfo.java 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-12-10 15:44:48 UTC (rev 8087) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/deploy/components.sf 2009-12-10 17:11:07 UTC (rev 8088) @@ -56,11 +56,11 @@ //this is for commons logging, which allows the struts code to use the commons logging API //and not be restricted to running under SF only //commonsLogging extends BindCommonsLogging; + host CoreJettyServer:ANY_HOST; server extends CoreJettyServer { - port PARENT:port; - + host PARENT:host server "jetty"; } @@ -75,7 +75,10 @@ listener extends JettySocketConnector { port PARENT:port; + host PARENT:host server LAZY PARENT:server; + //we want IPv4 only + allowIPv6 false; } servlets extends ServletContext { Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/WebTestCase.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/WebTestCase.java 2009-12-10 15:44:48 UTC (rev 8087) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/WebTestCase.java 2009-12-10 17:11:07 UTC (rev 8088) @@ -53,11 +53,11 @@ } protected String getClusterURL() { - return getProperty(TEST_WEB_URL + "/cluster", ""); + return getRequiredProperty(TEST_WEB_URL) + "/cluster"; } protected String getWorkflowURL() { - return getProperty(TEST_WEB_URL + "/workflow", ""); + return getRequiredProperty(TEST_WEB_URL) + "/workflow"; } protected WebClient getWebClient() { Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/components.sf =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/components.sf 2009-12-10 15:44:48 UTC (rev 8087) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/components.sf 2009-12-10 17:11:07 UTC (rev 8088) @@ -113,4 +113,5 @@ deploymentFactory extends NodeDeploymentUnsupportedFactory { } -} \ No newline at end of file +} + Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/examples/ec2_hadoop_farmer.sf =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/examples/ec2_hadoop_farmer.sf 2009-12-10 15:44:48 UTC (rev 8087) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/examples/ec2_hadoop_farmer.sf 2009-12-10 17:11:07 UTC (rev 8088) @@ -32,8 +32,6 @@ EC2HadoopRoles extends Compound { - - master extends EC2ClusterRole { description "Hadoop Namenode and Job Tracker"; min 1; @@ -64,7 +62,6 @@ } - } Modified: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/htmlunit/components.sf =================================================================== --- trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/htmlunit/components.sf 2009-12-10 15:44:48 UTC (rev 8087) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/htmlunit/components.sf 2009-12-10 17:11:07 UTC (rev 8088) @@ -28,27 +28,28 @@ test.data.dir PROPERTY test.data.dir; testSuite TBD; - test.web.url TBD; - - tests extends TestRunner { + test.web.url "http://localhost:8081/"; + properties [ + ["test.web.url",test.web.url] + ] - - properties [ - ["test.web.url",test.web.url] - ] - + tests extends TestRunner { + description ("HtmlUnit tests against " ++ test.web.url); + sfShouldTerminate true; - listener extends AntXmlTestListener { - outputDirectory PARENT:ATTRIB test.data.dir; - } - - JUnitTestSuite testSuite; + listener extends AntXmlTestListener { + outputDirectory PARENT:ATTRIB test.data.dir; + } + + JUnitTestSuite testSuite; } } testClusterWebapp extends HtmlUnitTests { description "Test the cluster application"; - testSuite extends MombasaClusterTestSuite; + testSuite extends MombasaClusterTestSuite { + test.web.url PARENT:ATTRIB test.web.url; + } } Modified: trunk/core/components/junit/src/org/smartfrog/services/junit/junit3/JUnit3TestSuiteImpl.java =================================================================== --- trunk/core/components/junit/src/org/smartfrog/services/junit/junit3/JUnit3TestSuiteImpl.java 2009-12-10 15:44:48 UTC (rev 8087) +++ trunk/core/components/junit/src/org/smartfrog/services/junit/junit3/JUnit3TestSuiteImpl.java 2009-12-10 17:11:07 UTC (rev 8088) @@ -33,7 +33,6 @@ import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.common.SmartFrogInitException; import org.smartfrog.sfcore.common.SmartFrogResolutionException; -import org.smartfrog.sfcore.logging.Log; import org.smartfrog.sfcore.utils.ListUtils; import org.smartfrog.sfcore.reference.Reference; @@ -580,17 +579,19 @@ public static TestInfo createTestInfo(Test test, Throwable fault) { TestInfo testInfo = new TestInfo(fault); String classname = test.getClass().getName(); + String testname = classname; String text; if (test instanceof TestCase) { //TestCase information is extracted specially TestCase testCase = (TestCase) test; text = testCase.getName(); + testname = text; } else { //any other kind of test has no name, just //a string value text = test.toString(); } - testInfo.setName(classname); + testInfo.setName(testname); testInfo.setText(text); return testInfo; } Modified: trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/TestRunnerImpl.java =================================================================== --- trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/TestRunnerImpl.java 2009-12-10 15:44:48 UTC (rev 8087) +++ trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/TestRunnerImpl.java 2009-12-10 17:11:07 UTC (rev 8088) @@ -201,6 +201,7 @@ * @throws SmartFrogException failure deploying compound or sub-component * @throws RemoteException In case of Remote/nework error */ + @Override public synchronized void sfDeploy() throws SmartFrogException, RemoteException { super.sfDeploy(); @@ -234,7 +235,7 @@ shouldTerminate, false); listenerPrim = sfResolve(ATTR_LISTENER, - (Prim) configuration.getListenerFactory(), + (Prim) null, true); if (!(listenerPrim instanceof TestListenerFactory)) { throw new SmartFrogException("The attribute " + @@ -279,7 +280,7 @@ sendEvent(new TestStartedEvent(this)); skipped = true; updateFlags(false); - String message = "Skipping test run " + getName(); + String message = getName() + " skipping test run " + description; sfLog().info(message); //send a test started event //followed by a the closing results @@ -331,9 +332,10 @@ public synchronized void sfTerminateWith(TerminationRecord status) { sendEvent(new TerminatedEvent(this, status)); super.sfTerminateWith(status); - WorkflowThread thread = getWorker(); - thread.requestTerminationWithInterrupt(); - WorkflowThread.requestThreadTerminationWithInterrupt(thread); + WorkflowThread.requestThreadTerminationWithInterrupt(getWorker()); + if(listenerPrim != null) { + //do anything with the listener? + } } /** @@ -384,6 +386,7 @@ TerminationRecord record = createTerminationRecord(); sendEvent(createTestCompletedEvent(record)); + //the workflow thread handles the inner work //now look at our termination actions /* if (shouldTerminate) { Modified: trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/antxml/AntXmlListener.java =================================================================== --- trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/antxml/AntXmlListener.java 2009-12-10 15:44:48 UTC (rev 8087) +++ trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/antxml/AntXmlListener.java 2009-12-10 17:11:07 UTC (rev 8088) @@ -26,6 +26,7 @@ import nu.xom.Element; import nu.xom.Serializer; import org.smartfrog.services.xunit.listeners.xml.FileListener; +import org.smartfrog.services.xunit.listeners.xml.XmlListenerFactory; import org.smartfrog.services.xunit.serial.LogEntry; import org.smartfrog.services.xunit.serial.Statistics; import org.smartfrog.services.xunit.serial.TestInfo; @@ -44,6 +45,7 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; +import java.util.HashMap; /** @@ -91,8 +93,16 @@ * This is built up as we go along */ private Element root, stdout, stderr; + + protected XmlListenerFactory owner; + private SimpleDateFormat dateFormat; + /** + * log failed tests so we don't log them more than once + */ + private HashMap<String, TestInfo> failedTests = new HashMap<String, TestInfo>(); + public AntXmlListener(String hostname, File destFile, @@ -109,11 +119,20 @@ /** + * {@inheritDoc} + */ + @Override + public void setOwner(XmlListenerFactory owner) { + this.owner = owner; + } + + /** * get the filename of this * * @return the filename used * @throws RemoteException network trouble */ + @Override public String getFilename() throws RemoteException { return destFile.getAbsolutePath(); } @@ -124,11 +143,12 @@ * @throws IOException for IO trouble * @throws RemoteException network trouble */ + @Override public synchronized void open() throws IOException { - root = new Element(TESTSUITES); + root = new Element(TESTSUITE); document = new Document(root); stdout = new Element(SYSTEM_OUT); - stderr = new Element(SYSTEM_OUT); + stderr = new Element(SYSTEM_ERR); maybeAddAttribute(root, HOSTNAME, hostname); maybeAddAttribute(root, ATTR_NAME, suitename); dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); @@ -138,8 +158,11 @@ String timestamp = dateFormat.format(startTime); maybeAddAttribute(root, TIMESTAMP, timestamp); log.info("logging to " + destFile); + logMessage("logging to" + destFile); touchDestFile(); } + + /** * close the file. This call must be harmless if the file is already closed @@ -147,21 +170,27 @@ * @throws IOException IO trouble * @throws RemoteException network trouble */ + @Override public synchronized void close() throws IOException { if (document == null) { return; } //this is where we actually save the file to disk. try { + logError("Test finished"); log.info("Creating the XML report file " + destFile); buildRootAttributes(); addLogEntries(); save(); + document = null; } finally { //cleanup document = null; stdout = null; stderr = null; + if (owner != null) { + owner.unregisterInstance(this); + } } } @@ -204,6 +233,7 @@ * @return true iff we are building up a document * @throws RemoteException network trouble */ + @Override public boolean isOpen() throws RemoteException { return document != null; } @@ -257,8 +287,19 @@ * @throws RemoteException network problems * @throws SmartFrogException other problems */ + @Override public void endSuite() throws RemoteException, SmartFrogException { finishTime = new Date(System.currentTimeMillis()); + try { + close(); + } catch (RemoteException e) { + throw e; + } catch (IOException e) { + throw SmartFrogException.forward(e); + } finally { + //anything else? + } + } /** @@ -268,6 +309,7 @@ * @throws RemoteException network problems * @throws SmartFrogException other problems */ + @Override public void startTest(TestInfo test) throws RemoteException, SmartFrogException { stats.incTestsStarted(); @@ -280,6 +322,7 @@ * @throws RemoteException network problems * @throws SmartFrogException other problems */ + @Override public void addError(TestInfo test) throws RemoteException, SmartFrogException { stats.incErrors(); @@ -293,9 +336,11 @@ * @throws RemoteException network problems * @throws SmartFrogException other problems */ + @Override public void addFailure(TestInfo test) throws RemoteException, SmartFrogException { stats.incFailures(); + addFailedTest(test); recordResult(FAILURE, test); } @@ -306,19 +351,41 @@ * @throws RemoteException network problems * @throws SmartFrogException other problems */ + @Override public void endTest(TestInfo test) throws RemoteException, SmartFrogException { stats.incTestsRun(); - recordResult("end", test); + if(!isFailedTest(test)) { + recordResult("end", test); + } } + protected void addFailedTest(TestInfo test) { + failedTests.put(test.getName(), test); + } + + protected boolean isFailedTest(TestInfo test) { + return failedTests.get(test.getName())!=null; + } + + protected void logMessage(String text) { + LogEntry entry = new LogEntry(LogEntry.LOG_LEVEL_STDOUT, text); + log(entry); + } + + protected void logError(String text) { + LogEntry entry = new LogEntry(LogEntry.LOG_LEVEL_STDERR, text); + log(entry); + } + /** - * Log an event - * - * @param event what happened - * @throws RemoteException on network trouble - */ - public void log(LogEntry event) throws RemoteException { + * Log an event + * + * @param event what happened + * @throws RemoteException on network trouble + */ + @Override + public void log(LogEntry event) { String text = event.logString(); Element target; target = (event.getLevel() == LogEntry.LOG_LEVEL_STDERR) ? stderr : stdout; @@ -347,9 +414,9 @@ */ private Element addElement(Element parent, String name, String text) { Element nested = new Element(name); - nested.appendChild(text); + parent.appendChild(nested); if (text != null) { - parent.appendChild(nested); + nested.appendChild(text); } return nested; } @@ -473,7 +540,8 @@ //process the fault ThrowableTraceInfo fault = test.getFault(); if (fault != null) { - Element thrown = addElement(testcase, type, fault.toString()); + String stackTrace = fault.getStackString(); + Element thrown = addElement(testcase, type, stackTrace); maybeAddAttribute(thrown, ATTR_MESSAGE, fault.getMessage()); Modified: trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/antxml/AntXmlTestListenerComponent.java =================================================================== --- trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/antxml/AntXmlTestListenerComponent.java 2009-12-10 15:44:48 UTC (rev 8087) +++ trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/antxml/AntXmlTestListenerComponent.java 2009-12-10 17:11:07 UTC (rev 8088) @@ -66,6 +66,7 @@ public class AntXmlTestListenerComponent extends AbstractXmlListenerComponent implements XmlListenerFactory { + /** * construct a base interface Modified: trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/html/OneHostHtmlListener.java =================================================================== --- trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/html/OneHostHtmlListener.java 2009-12-10 15:44:48 UTC (rev 8087) +++ trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/html/OneHostHtmlListener.java 2009-12-10 17:11:07 UTC (rev 8088) @@ -66,6 +66,7 @@ * * @throws IOException IO trouble */ + @Override protected synchronized void writeDocumentHeader() throws IOException { writeln(XML_DECLARATION); //a strict HTML 1.1 document @@ -113,6 +114,7 @@ * @throws IOException IO trouble */ + @Override protected synchronized void writeDocumentTail() throws IOException { writeSummary(); exit("body"); @@ -187,6 +189,7 @@ * @param event event * @throws RemoteException network trouble */ + @Override public void log(LogEntry event) throws RemoteException { String type = style(event); @@ -248,6 +251,7 @@ * @param test test * @return xml variant */ + @Override protected String toXML(String tag, TestInfo test) { StringBuilder body = new StringBuilder(); enter(body, "div", style("testblock")); @@ -279,6 +283,7 @@ * @param fault fault cause * @return empty string if fault is null, else an xml declaration */ + @Override protected String toXML(ThrowableTraceInfo fault) { String result; if (fault == null) { Modified: trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/xml/AbstractXmlListenerComponent.java =================================================================== --- trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/xml/AbstractXmlListenerComponent.java 2009-12-10 15:44:48 UTC (rev 8087) +++ trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/xml/AbstractXmlListenerComponent.java 2009-12-10 17:11:07 UTC (rev 8088) @@ -36,6 +36,8 @@ import java.rmi.RemoteException; import java.util.Date; import java.util.HashMap; +import java.util.List; +import java.util.LinkedList; /** * An abstract base class for XML Listeners @@ -55,6 +57,10 @@ protected String suffix = ".xml"; protected String prefix = ""; private boolean useProcessname; + /** + * Here are the instances + */ + private List<FileListener> instances = new LinkedList<FileListener>(); protected AbstractXmlListenerComponent() throws RemoteException { } @@ -78,7 +84,7 @@ /** * thread-safe accessor to the suite-file mapping - * + * @param hostname host name to look up * @param suitename suite to lookup * @return absolute path of the output file, or null for no mapping. */ @@ -164,6 +170,41 @@ } /** + * + * register an instance in the instance list + * @param instance new instance + */ + protected void registerInstance(FileListener instance) { + instances.add(instance); + } + + /** + * Close and Unregister a listener instance. Harmless if the instance is not registered + * + * @param instance instance to unregister + * @throws RemoteException network problems + */ + @Override + public void unregisterInstance(FileListener instance) throws RemoteException { + if (instance != null) { + boolean removed; + synchronized (this) { + removed = instances.remove(instance); + } + if(removed) { + try { + instance.close(); + } catch (IOException e) { + log.error(e); + } catch (SmartFrogException e) { + log.error(e); + } + } + } + } + + + /** * Start listening to a test suite * * @param suite the test suite that is about to run. May be null, especially during testing. @@ -209,19 +250,23 @@ destpath); } + FileListener fileListener = null; try { Date start = new Date(timestamp); - FileListener fileLog; - fileLog = createNewSingleHostListener(hostname, + fileListener = createNewSingleHostListener(hostname, destFile, processname, suitename, start); - fileLog.open(); - return fileLog; + fileListener.setOwner(this); + registerInstance(fileListener); + fileListener.open(); + return fileListener; } catch (RemoteException e) { + unregisterInstance(fileListener); throw e; } catch (IOException e) { + unregisterInstance(fileListener); throw SmartFrogException.forward("Failed to open ", e); } } Modified: trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/xml/FileListener.java =================================================================== --- trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/xml/FileListener.java 2009-12-10 15:44:48 UTC (rev 8087) +++ trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/xml/FileListener.java 2009-12-10 17:11:07 UTC (rev 8088) @@ -40,7 +40,15 @@ */ String ATTR_FILE = "file"; + /** + * Define the owner; listeners should tell this when they are closed + * @param owner owning instance + * @throws RemoteException network trouble + */ + void setOwner(XmlListenerFactory owner) throws RemoteException; + + /** * get the filename of this * * @return the filename used Modified: trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/xml/OneHostXMLListener.java =================================================================== --- trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/xml/OneHostXMLListener.java 2009-12-10 15:44:48 UTC (rev 8087) +++ trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/xml/OneHostXMLListener.java 2009-12-10 17:11:07 UTC (rev 8088) @@ -73,8 +73,8 @@ protected OutputStream outstream = null; protected Writer out = null; + protected XmlListenerFactory owner; - protected int testCount, errorCount, failureCount; /** @@ -99,7 +99,7 @@ * Listen to stuff coming from a single host. opens the file for future messages * * @param hostname hostname of the (possibly remote system) - * @param processname + * @param processname process name * @param suitename name of the test suite * @param destFile destination file * @param startTime timestamp (in UTC) of the start of the tests @@ -117,6 +117,7 @@ this.suitename = suitename; this.startTime = startTime; this.preamble = preamble; + tests = new HashMap<String, TestInfo>(); } @@ -126,6 +127,7 @@ * * @throws Throwable */ + @Override protected void finalize() throws Throwable { assert outstream == null : ERROR_OUTPUT_FILE_OPEN; assert out == null : ERROR_OUTPUT_FILE_OPEN; @@ -133,10 +135,19 @@ } /** + * {@inheritDoc} + */ + @Override + public void setOwner(XmlListenerFactory owner){ + this.owner = owner; + } + + /** * open the file for writing * * @throws IOException */ + @Override public synchronized void open() throws IOException { assert !isOpen() : "file is already open"; destFile.getParentFile().mkdirs(); @@ -147,6 +158,10 @@ flush(); } + /** + * Override point: write out the document header + * @throws IOException IO problems + */ protected synchronized void writeDocumentHeader() throws IOException { out.write(XML_DECLARATION); out.write("\n"); @@ -169,6 +184,7 @@ * * @throws IOException IO trouble */ + @Override public synchronized void close() throws IOException { if (!isOpen()) { //harmless to close an already closed file. @@ -190,6 +206,9 @@ out = null; outstream = null; destFile = null; + if (owner != null) { + owner.unregisterInstance(this); + } } /** @@ -222,6 +241,7 @@ * * @return true iff the file is not null */ + @Override public boolean isOpen() { return out != null; } @@ -242,6 +262,7 @@ * * @return a string representation of the object. */ + @Override public String toString() { return destFile != null ? destFile.toString() : super.toString(); } @@ -253,18 +274,23 @@ * * @throws SmartFrogException containing a nested IOException */ - public synchronized void endSuite() throws SmartFrogException { + @Override + public synchronized void endSuite() throws SmartFrogException, RemoteException { try { close(); - tests = null; + } catch (RemoteException e) { + throw e; } catch (IOException e) { throw SmartFrogException.forward(e); + } finally { + tests = null; } } /** * An error occurred. */ + @Override public synchronized void addError(TestInfo test) { errorCount++; tests.put(test.getText(), test); @@ -273,6 +299,7 @@ /** * A failure occurred. */ + @Override public synchronized void addFailure(TestInfo test) { failureCount++; tests.put(test.getText(), test); @@ -281,6 +308,7 @@ /** * A test ended. */ + @Override public synchronized void endTest(TestInfo test) throws SmartFrogException { testCount++; TestInfo cached = tests.get(test.getText()); @@ -301,6 +329,7 @@ /** * A test started. */ + @Override public void startTest(TestInfo test) { //do nothing } @@ -311,6 +340,7 @@ * @param event * @throws RemoteException */ + @Override public void log(LogEntry event) throws RemoteException { String tag = "log-" + event.levelToText(); String attrs; @@ -329,6 +359,7 @@ * * @param tag element name * @param test test result to log + * @throws SmartFrogException IO problems */ protected synchronized void add(String tag, TestInfo test) throws SmartFrogException { String entry = toXML(tag, test); @@ -350,6 +381,8 @@ * @param tag element name * @param attrs attributes (can be null) * @param body text body (can be null) + * @param escape should the XML be escaped? + * @throws IOException on a failure to write something */ protected synchronized void write(String tag, String attrs, @@ -541,6 +574,7 @@ * @param that other instance * @return true for a match */ + @Override public boolean equals(Object that) { if (this == that) { return true; @@ -560,6 +594,7 @@ * * @return a hash code */ + @Override public int hashCode() { return destFile.toString().hashCode(); } @@ -569,6 +604,7 @@ * * @return the filename used */ + @Override public String getFilename() { return destFile.getAbsolutePath(); } Modified: trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/xml/XmlListenerFactory.java =================================================================== --- trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/xml/XmlListenerFactory.java 2009-12-10 15:44:48 UTC (rev 8087) +++ trunk/core/components/xunit/src/org/smartfrog/services/xunit/listeners/xml/XmlListenerFactory.java 2009-12-10 17:11:07 UTC (rev 8088) @@ -83,7 +83,13 @@ * @return name of output file, or null for no match * @throws RemoteException network problems */ - public String lookupFilename(String hostname, + String lookupFilename(String hostname, String suitename) throws RemoteException; + /** + * Unregister a listener instance. Harmless if the instance is not registered + * @param instance instance to unregister + * @throws RemoteException network problems + */ + void unregisterInstance(FileListener instance) throws RemoteException; } Modified: trunk/core/components/xunit/src/org/smartfrog/services/xunit/serial/TestInfo.java =================================================================== --- trunk/core/components/xunit/src/org/smartfrog/services/xunit/serial/TestInfo.java 2009-12-10 15:44:48 UTC (rev 8087) +++ trunk/core/components/xunit/src/org/smartfrog/services/xunit/serial/TestInfo.java 2009-12-10 17:11:07 UTC (rev 8088) @@ -383,11 +383,14 @@ public String getDetails() { StringBuilder buffer = new StringBuilder(); buffer.append(getName()); - buffer.append("\nOutcome : " + getOutcome()); - buffer.append("\nDuration: " + getDuration()); - buffer.append("\nOn hostname: " + getHostname() + " PID " + getProcessName()); + buffer.append("\nOutcome : ").append(getOutcome()); + buffer.append("\nDuration: ").append(getDuration()); + buffer.append("\nOn host: ").append(getHostname()); + if(getProcessName()!=null) { + buffer.append(" PID ").append(getProcessName()); + } if(getDescription()!=null) { - buffer.append("\ndescription : " + getDescription()); + buffer.append("\ndescription : ").append(getDescription()); } return buffer.toString(); } Modified: trunk/core/components/xunit/src/org/smartfrog/services/xunit/serial/ThrowableTraceInfo.java =================================================================== --- trunk/core/components/xunit/src/org/smartfrog/services/xunit/serial/ThrowableTraceInfo.java 2009-12-10 15:44:48 UTC (rev 8087) +++ trunk/core/components/xunit/src/org/smartfrog/services/xunit/serial/ThrowableTraceInfo.java 2009-12-10 17:11:07 UTC (rev 8088) @@ -168,7 +168,7 @@ /** * Equality test. * Uses the classname and message. - * @param that + * @param that the other instance * @return true if there is a match */ public boolean equals(Object that) { @@ -226,11 +226,36 @@ return "uninitialized"; } String location; - if (stack != null && stack.length > 0 && stack[0] != null) { + if (hasStack()) { location = "@" + stack[0].toString(); } else { location = ""; } return classname + "::" + message + " " + location; } + + /** + * Does this exception have a stack? + * @return true if there is a non-empty stack + */ + public boolean hasStack() { + return stack != null && stack.length > 0 && stack[0] != null; + } + + /** + * Get the stack as a string + * @return the stack, or "" if ther eis no stack + */ + public String getStackString() { + if(!hasStack()) { + return ""; + } + StringBuilder builder = new StringBuilder(stack.length * 80); + for (StackTraceElement elt: stack) { + builder.append("at "); + builder.append(elt.toString()); + builder.append('\n'); + } + return builder.toString(); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2009-12-14 17:19:52
|
Revision: 8091 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=8091&view=rev Author: steve_l Date: 2009-12-14 17:17:57 +0000 (Mon, 14 Dec 2009) Log Message: ----------- SFOS-1396 add propertySet nested property set for test contexts Modified Paths: -------------- trunk/core/components/junit/src/org/smartfrog/services/junit/junit3/JUnit3TestSuiteImpl.java trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/TestListenerFactory.java trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/TestRunner.java trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/TestSuite.java trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/testsuite.sf Modified: trunk/core/components/junit/src/org/smartfrog/services/junit/junit3/JUnit3TestSuiteImpl.java =================================================================== --- trunk/core/components/junit/src/org/smartfrog/services/junit/junit3/JUnit3TestSuiteImpl.java 2009-12-11 17:07:30 UTC (rev 8090) +++ trunk/core/components/junit/src/org/smartfrog/services/junit/junit3/JUnit3TestSuiteImpl.java 2009-12-14 17:17:57 UTC (rev 8091) @@ -35,6 +35,7 @@ import org.smartfrog.sfcore.common.SmartFrogResolutionException; import org.smartfrog.sfcore.utils.ListUtils; import org.smartfrog.sfcore.reference.Reference; +import org.smartfrog.sfcore.componentdescription.ComponentDescription; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -43,6 +44,7 @@ import java.util.HashMap; import java.util.List; import java.util.Properties; +import java.util.Iterator; /** @@ -134,6 +136,11 @@ //properties. extract the list, flatten it and bind to sysproperties sysproperties = ListUtils.resolveProperties(this, new Reference(ATTR_SYSPROPS), true); + //now pull in the propertySet + ComponentDescription propSet = null; + propSet = sfResolve(ATTR_PROPERTY_SET, propSet, true); + CDtoProperties(sysproperties, propSet); + //package attribute names a package packageValue = sfResolve(ATTR_PACKAGE, packageValue, false); if (packageValue == null) { @@ -154,6 +161,23 @@ log("Running JUnit3 test suite " + suitename + " on host " + getHostname()); } + + public static Properties CDtoProperties(ComponentDescription cd) throws SmartFrogResolutionException { + Properties props = new Properties(); + CDtoProperties(props, cd); + return props; + } + + private static void CDtoProperties(Properties props, ComponentDescription cd) throws SmartFrogResolutionException { + Iterator iterator = cd.sfAttributes(); + while (iterator.hasNext()) { + Object key = iterator.next(); + Object value = cd.sfResolveHere(key); + props.put(key.toString(), value.toString()); + } + } + + /** * build the list of classes to run. At this point the list is already flat. If the user has asked for a single * test, so {@link #singleTest} is not null, then only tests that end with that pattern are tested. @@ -333,7 +357,7 @@ tests = extractTest(clazz); injectTestContext(tests, context); } catch (Throwable e) { - //couldnt set up the tests, so we catch the exception and create a failure + //couldn't set up the tests, so we catch the exception and create a failure //test that reports the outcome tests = new Warning(classname, e); } @@ -377,7 +401,9 @@ + " in class " + clazz, e); } catch (InvocationTargetException e) { throw new SmartFrogInitException("Exception in " + SUITE_METHOD_NAME - + " in class " + clazz, e.getCause()); + + " in class " + clazz + + " : " + e.toString(), + e.getCause()); } } Modified: trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/TestListenerFactory.java =================================================================== --- trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/TestListenerFactory.java 2009-12-11 17:07:30 UTC (rev 8090) +++ trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/TestListenerFactory.java 2009-12-14 17:17:57 UTC (rev 8091) @@ -33,6 +33,9 @@ public interface TestListenerFactory extends Remote { + /** + * Listener name: {@value} + */ final String ATTR_NAME = "name"; /** Modified: trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/TestRunner.java =================================================================== --- trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/TestRunner.java 2009-12-11 17:07:30 UTC (rev 8090) +++ trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/TestRunner.java 2009-12-14 17:17:57 UTC (rev 8091) @@ -99,6 +99,11 @@ TestListenerFactory getListenerFactory() throws RemoteException; + /** + * Set the listener factory + * @param listener the new listener factory + * @throws RemoteException if it could not be set + */ void setListenerFactory(TestListenerFactory listener) throws RemoteException; /** @@ -106,6 +111,7 @@ * * @return true if the tests were started * @throws RemoteException network problems + * @throws SmartFrogException other problems */ boolean startTests() throws RemoteException, SmartFrogException; Modified: trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/TestSuite.java =================================================================== --- trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/TestSuite.java 2009-12-11 17:07:30 UTC (rev 8090) +++ trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/TestSuite.java 2009-12-14 17:17:57 UTC (rev 8091) @@ -37,45 +37,50 @@ /** * Non-marked up text description {@value} */ - public String ATTR_DESCRIPTION = "description"; + String ATTR_DESCRIPTION = "description"; /** * A list of URLs to link to {@value} */ - public String ATTR_LINKS = "links"; + String ATTR_LINKS = "links"; /** * {@value} */ - public String ATTR_NAME = "name"; + String ATTR_NAME = "name"; /** * list in name, value pairs [[name,value],[n2,v2]] {@value} */ - public String ATTR_SYSPROPS = "properties"; + String ATTR_SYSPROPS = "properties"; /** + * properties as a nested CD: {@value} + */ + String ATTR_PROPERTY_SET = "propertySet"; + + /** * A list of text tags to describe the test suite {@value} */ - public String ATTR_TAGS = "tags"; + String ATTR_TAGS = "tags"; /** * A list of URLs to track back on {@value} */ - public String ATTR_TRACKBACKS = "trackbacks"; + String ATTR_TRACKBACKS = "trackbacks"; /** * A list of issues, such as defect IDs {@value} */ - public String ATTR_ISSUES = "issues"; + String ATTR_ISSUES = "issues"; /** * The name of another test suite that must have succeeded before this test runs. If this component failed to deploy * or succeed, then this test suite is skipped. */ - public String ATTR_MUST_SUCCEED = "mustSucceed"; + String ATTR_MUST_SUCCEED = "mustSucceed"; /** * bind to the configuration. A null parameter means 'stop binding' Modified: trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/testsuite.sf =================================================================== --- trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/testsuite.sf 2009-12-11 17:07:30 UTC (rev 8090) +++ trunk/core/components/xunit/src/org/smartfrog/services/xunit/base/testsuite.sf 2009-12-14 17:17:57 UTC (rev 8091) @@ -24,8 +24,12 @@ } properties extends Vector { - description "list of properties to pass to the test suite as name, value pairs [[name,value],[n2,v2]]"; + description "list of properties to pass to the test suite as name, value pairs [[name,value],[n2,v2]]"; } + + propertySet extends Optional { + description "CD containing properties to pass to the test suite as name, value "; + } tags extends OptionalVector{ description "A list of text tags to describe the test suite"; } @@ -56,6 +60,7 @@ tags []; trackbacks []; properties []; + propertySet extends DATA { }; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2010-01-08 15:44:45
|
Revision: 8123 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=8123&view=rev Author: steve_l Date: 2010-01-08 15:44:34 +0000 (Fri, 08 Jan 2010) Log Message: ----------- SFOS-1408 Move EC2 cloudfarmer implementation to ec2 component Modified Paths: -------------- trunk/core/components/cloudfarmer/ivy.xml trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/deploy/components.sf trunk/core/components/ec2/ivy.xml Removed Paths: ------------- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/EC2ClusterFarmer.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/EC2ClusterFarmerImpl.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/EC2ClusterRole.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/RoleBinding.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/components.sf trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/examples/ec2_hadoop_farmer.sf trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/components.sf trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/EC2FarmerOfflineTest.java trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/components.sf trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/testFarmHasRoles.sf trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/testFarmLacksRole.sf trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/testMasterLacksImageID.sf trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/online/EC2FarmerOnlineTest.java trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/online/components.sf Modified: trunk/core/components/cloudfarmer/ivy.xml =================================================================== --- trunk/core/components/cloudfarmer/ivy.xml 2010-01-07 12:09:48 UTC (rev 8122) +++ trunk/core/components/cloudfarmer/ivy.xml 2010-01-08 15:44:34 UTC (rev 8123) @@ -20,13 +20,12 @@ <conf name="build" visibility="private" description="artifacts needed to build the application"/> <conf name="compile" visibility="private" - extends="redist,webapp,ec2" + extends="redist,webapp" description="artifacts needed to compile the application"/> - <conf name="daemon" visibility="private" extends="default,compile,webapp,ec2,hadoop" + <conf name="daemon" visibility="private" extends="default,compile,webapp,hadoop" description="the classpath needed to run smartfrog daemons"/> <conf name="test" extends="daemon" description="the classpath needed to run tests"/> - <conf name="ec2" description="contains EC2 support"/> <conf name="webapp" description="the web gui"/> <conf name="hadoop" description="Hadoop deployment"/> <conf name="master" description="contains the artifact but no dependencies"/> @@ -120,14 +119,6 @@ changing="true" conf="build->default"/> - - <!--EC2 support--> - <dependency org="org.smartfrog" - name="sf-ec2" - changing="true" - rev="latest.integration" - conf="ec2->default"/> - <!--SSH deployment--> <dependency org="org.smartfrog" name="sf-ssh" 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 2010-01-07 12:09:48 UTC (rev 8122) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/deploy/components.sf 2010-01-08 15:44:34 UTC (rev 8123) @@ -38,12 +38,17 @@ /** * Deploy a compound containing jetty and servlets + * This is always forked */ StrutsOnJetty extends Compound { //we always run this in its own JVM, as Jasper is trouble otherwise sfProcessName "StrutsOnJettyPS"; + //and crank back the liveness factor; this deals with slow startup pain + sfLivenessFactor 10; + + //port to use port 8081; sfSyncTerminate true; //set to true to keep JSP pages, do more debugging and logging etc. Deleted: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/EC2ClusterFarmer.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/EC2ClusterFarmer.java 2010-01-07 12:09:48 UTC (rev 8122) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/EC2ClusterFarmer.java 2010-01-08 15:44:34 UTC (rev 8123) @@ -1,33 +0,0 @@ -/* (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 - -*/ -package org.smartfrog.services.cloudfarmer.server.ec2; - -import org.smartfrog.services.amazon.ec2.EC2Component; -import org.smartfrog.services.cloudfarmer.api.ClusterFarmer; - -/** - * Created 16-Sep-2009 16:06:06 - */ - - -public interface EC2ClusterFarmer extends ClusterFarmer, EC2Component { - - -} Deleted: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/EC2ClusterFarmerImpl.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/EC2ClusterFarmerImpl.java 2010-01-07 12:09:48 UTC (rev 8122) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/EC2ClusterFarmerImpl.java 2010-01-08 15:44:34 UTC (rev 8123) @@ -1,539 +0,0 @@ -/* (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 - -*/ -package org.smartfrog.services.cloudfarmer.server.ec2; - -import com.xerox.amazonws.ec2.EC2Exception; -import com.xerox.amazonws.ec2.LaunchConfiguration; -import com.xerox.amazonws.ec2.ReservationDescription; -import org.smartfrog.services.amazon.ec2.EC2ComponentImpl; -import org.smartfrog.services.amazon.ec2.EC2Instance; -import org.smartfrog.services.amazon.ec2.SmartFrogEC2Exception; -import org.smartfrog.services.cloudfarmer.api.ClusterNode; -import org.smartfrog.services.cloudfarmer.api.ClusterRoleInfo; -import org.smartfrog.services.cloudfarmer.api.NoClusterSpaceException; -import org.smartfrog.services.cloudfarmer.api.NodeDeploymentServiceFactory; -import org.smartfrog.services.cloudfarmer.api.NodeDeploymentService; -import org.smartfrog.services.cloudfarmer.server.common.AbstractClusterFarmer; -import org.smartfrog.sfcore.common.SmartFrogException; -import org.smartfrog.sfcore.common.SmartFrogResolutionException; -import org.smartfrog.sfcore.prim.Prim; -import org.smartfrog.sfcore.reference.Reference; - -import java.io.IOException; -import java.rmi.RemoteException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -/** - * This class implements an EC2 cluster farmer. - */ -public class EC2ClusterFarmerImpl extends EC2ComponentImpl implements EC2ClusterFarmer, EC2Instance { - public static final String ERROR_NO_VALID_IMAGE_ID = "No valid imageID for role "; - - private static final List<String> EMPTY_STRING_LIST = new ArrayList<String>(0); - private int clusterLimit = 10; - private int nodeCount = 0; - protected Prim roles; - protected Map<String, ClusterRoleInfo> roleInfoMap; - private List<EC2ClusterRole> clusterRoleList; - private HashMap<String, RoleBinding> roleBindings; - private NodeDeploymentServiceFactory deploymentFactory; - - public EC2ClusterFarmerImpl() throws RemoteException { - } - - - /** - * {@inheritDoc} - * - * @throws RemoteException IO/network problems - * @throws SmartFrogException other problems - */ - @Override - public synchronized void sfStart() throws SmartFrogException, RemoteException { - super.sfStart(); - //start the children - synchCreateChildren(); - //now look at the settings - clusterLimit = sfResolve(ATTR_CLUSTER_LIMIT, clusterLimit, true); - sfLog().info("Creating EC2farmer with a limit of " + clusterLimit); - roles = sfResolve(ATTR_ROLES, roles, true); - roleBindings = new HashMap<String, RoleBinding>(); - deploymentFactory = (NodeDeploymentServiceFactory) sfResolve(ATTR_DEPLOYMENT_FACTORY, (Prim) null, true); - buildRoleBindings(); - } - - /** - * {@inheritDoc} - * - * @throws IOException IO/network problems - * @throws SmartFrogException other problems - */ - @Override - public ClusterNode[] create(String role, int min, int max) throws IOException, SmartFrogException { - List<ClusterNode> nodes = createNodes(role, min, max); - return nodes.toArray(new ClusterNode[nodes.size()]); - } - - /** - * Create the nodelist - * - * @param role instance role - * @param min min# to create - * @param max max# to create; must be equal to or greater than the min value - * @return a list of created nodes, size between the min and max values - * @throws IOException IO/network problems - * @throws SmartFrogException other problems - */ - private List<ClusterNode> createNodes(String role, int min, int max) throws SmartFrogException, IOException { - AbstractClusterFarmer.validateClusterRange(min, max); - int limit = addNodes(min, max); - LaunchConfiguration launch = createLaunchConfigFromRole(role); - launch.setMaxCount(limit); - launch.setMinCount(min); - List<ClusterNode> nodes = new ArrayList<ClusterNode>(limit); - try { - ReservationDescription reservation = getEc2binding().runInstances(launch); - for (ReservationDescription.Instance instance : reservation.getInstances()) { - nodes.add(createFromReservationInstance(instance)); - } - } catch (EC2Exception e) { - throw new SmartFrogEC2Exception(e, this); - } - return nodes; - } - - /** - * Release a number of nodes - * - * @param number to release - * @return the number actually released, which may be less than that passed in - */ - private synchronized int releaseNodes(int number) { - nodeCount -= number; - if (nodeCount < 0) { - nodeCount = 0; - } - return nodeCount; - } - - /** - * Add the number of nodes - * - * @param min number of nodes to allocate - * @param max the number to add - * @return the number actually added. This may be less, if the count is > the limit - * @throws NoClusterSpaceException there is no room in the cluster - */ - private synchronized int addNodes(int min, int max) throws NoClusterSpaceException { - int newCount = nodeCount + max; - - if (newCount > clusterLimit) { - max = clusterLimit - newCount; - newCount = clusterLimit; - if (max < min) { - throw new NoClusterSpaceException("Local cluster limit is blocking this operation"); - } - } - - nodeCount = newCount; - return max; - } - - - /** - * {@inheritDoc} - * - * @throws IOException IO/network problems - * @throws SmartFrogException other problems - */ - @Override - public int deleteAll() throws IOException, SmartFrogException { - try { - List<ClusterNode> nodes = listInstances(EMPTY_STRING_LIST); - List<String> ids = createIdList(nodes); - getEc2binding().terminateInstances(ids); - int deleted = nodes.size(); - releaseNodes(deleted); - return deleted; - } catch (EC2Exception e) { - throw new SmartFrogEC2Exception(e, this); - } - } - - /** - * {@inheritDoc} - * - * @throws IOException IO/network problems - * @throws SmartFrogException other problems - */ - @Override - public void delete(String id) throws IOException, SmartFrogException { - delete(new String[]{id}); - } - - /** - * {@inheritDoc} - * - * @throws IOException IO/network problems - * @throws SmartFrogException other problems - */ - @Override - public void delete(String[] nodes) throws IOException, SmartFrogException { - try { - getEc2binding().terminateInstances(nodes); - releaseNodes(nodes.length); - } catch (EC2Exception e) { - throw new SmartFrogEC2Exception(e, this); - } - } - - /** - * {@inheritDoc} - * - * @throws IOException IO/network problems - * @throws SmartFrogException other problems - */ - @Override - public void delete(ClusterNode[] nodes) throws IOException, SmartFrogException { - try { - List<String> ids = createIdList(nodes); - getEc2binding().terminateInstances(ids); - releaseNodes(nodes.length); - } catch (EC2Exception e) { - throw new SmartFrogEC2Exception(e, this); - } - } - - /** - * {@inheritDoc} - * - * @throws IOException IO/network problems - * @throws SmartFrogException other problems - */ - @Override - public int deleteAllInRole(String role) throws IOException, SmartFrogException { - return 0; - } - - /** - * {@inheritDoc} - * - * @throws IOException IO/network problems - * @throws SmartFrogException other problems - */ - @Override - public ClusterNode[] list() throws IOException, SmartFrogException { - try { - return listInstancesToArray(EMPTY_STRING_LIST); - } catch (EC2Exception e) { - throw new SmartFrogEC2Exception(e, this); - } - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isFarmerAvailable() throws IOException, SmartFrogException { - return true; - } - - /** - * Take a list of instances and get their details (slow), then return an array of the results - * - * @param instanceIDs instance strings - * @return the possibly empty list - * @throws EC2Exception on failures - */ - private ClusterNode[] listInstancesToArray(List<String> instanceIDs) throws EC2Exception { - List<ClusterNode> nodes = listInstances(instanceIDs); - return nodes.toArray(new ClusterNode[nodes.size()]); - } - - /** - * Take a list of instances and get their details (slow), then return list of the results - * - * @param instanceIDs instance strings - * @return the possibly empty list - * @throws EC2Exception on failures - */ - private List<ClusterNode> listInstances(List<String> instanceIDs) throws EC2Exception { - List<ReservationDescription> reservations = getEc2binding().describeInstances(instanceIDs); - List<ClusterNode> nodes = new ArrayList<ClusterNode>(reservations.size()); - for (ReservationDescription reservation : reservations) { - for (ReservationDescription.Instance instance : reservation.getInstances()) { - nodes.add(createFromReservationInstance(instance)); - } - } - return nodes; - } - - /** - * Create a cluster node from a reservation instance - * - * @param instance instance to work from - * @return the node - */ - private static ClusterNode createFromReservationInstance(ReservationDescription.Instance instance) { - ClusterNode node = new ClusterNode(); - node.setId(instance.getInstanceId()); - node.setHostname(instance.getPrivateDnsName()); - node.setExternallyVisible(true); - node.setExternalHostname(instance.getDnsName()); - node.setDetails(instance.toString()); - return node; - } - - /** - * {@inheritDoc} - * - * @throws IOException IO/network problems - * @throws SmartFrogException other problems - */ - @Override - public ClusterNode[] list(String role) throws IOException, SmartFrogException { - return new ClusterNode[0]; - } - - /** - * {@inheritDoc} - * - * @throws IOException IO/network problems - * @throws SmartFrogException other problems - */ - @Override - public ClusterNode lookup(String id) throws IOException, SmartFrogException { - try { - List<ReservationDescription> list = getEc2binding().describeInstances(new String[]{id}); - if (list.isEmpty()) { - return null; - } - List<ReservationDescription.Instance> instances = list.get(0).getInstances(); - if (instances.isEmpty()) { - return null; - } - return createFromReservationInstance(instances.get(0)); - } catch (EC2Exception e) { - throw new SmartFrogEC2Exception(e, this); - } - } - - /** - * {@inheritDoc} - * - * @throws IOException IO/network problems - * @throws SmartFrogException other problems - */ - @Override - public ClusterNode lookupByHostname(String hostname) throws IOException, SmartFrogException { - return null; - } - - /** - * Create a list of IDs from a node list - * - * @param nodes nodes to work on - * @return a list of all the IDs in the nodes - */ - private List<String> createIdList(List<ClusterNode> nodes) { - List<String> ids = new ArrayList<String>(nodes.size()); - for (ClusterNode node : nodes) { - ids.add(node.getId()); - } - return ids; - } - - /** - * Create a list of IDs from a node list - * - * @param nodes nodes to work on - * @return a list of all the IDs in the nodes - */ - private List<String> createIdList(ClusterNode[] nodes) { - List<String> ids = new ArrayList<String>(nodes.length); - for (ClusterNode node : nodes) { - ids.add(node.getId()); - } - return ids; - } - - - /** - * {@inheritDoc} - * - * @return a possibly empty list of role names - * @throws IOException IO/network problems - * @throws SmartFrogException other problems - */ - @Override - public String[] listAvailableRoles() throws IOException, SmartFrogException { - - return roleBindings.keySet().toArray(new String[roleBindings.size()]); - } - - /** - * {@inheritDoc} - * - * @return a possibly empty list of roles - * @throws IOException IO/network problems - * @throws SmartFrogException other problems - */ - @Override - public ClusterRoleInfo[] listClusterRoles() throws IOException, SmartFrogException { - return roleInfoMap.values().toArray(new ClusterRoleInfo[roleInfoMap.size()]); - } - - /** - * Look up a role, create a launch config from it - * - * @param role role to look up - * @return the role - * @throws RemoteException IO/network problems - * @throws SmartFrogException other problems - */ - private LaunchConfiguration createLaunchConfigFromRole(String role) - throws SmartFrogException, RemoteException { - Prim targetRole = resolveRole(role); - return createLaunchConfiguration(role, targetRole); - } - - /** - * build the role bindings - * - * @return the number of roles - * @throws RemoteException IO/network problems - * @throws SmartFrogException other problems - */ - private int buildRoleBindings() throws RemoteException, SmartFrogException { - - clusterRoleList = new ArrayList<EC2ClusterRole>(); - roleInfoMap = new HashMap<String, ClusterRoleInfo>(); - Iterator attrs = roles.sfAttributes(); - while (attrs.hasNext()) { - Object key = attrs.next(); - String roleName = key.toString(); - Reference roleRef = new Reference(roleName); - Object value = roles.sfResolve(roleRef, true); - if (value instanceof EC2ClusterRole) { - EC2ClusterRole targetRole = (EC2ClusterRole) value; - roleInfoMap.put(roleName, targetRole.resolveRoleInfo(roleName)); - LaunchConfiguration launch = createLaunchConfiguration(roleName, targetRole); - RoleBinding binding = new RoleBinding(roleName, targetRole, launch); - roleBindings.put(roleName, binding); - sfLog().info(binding.toString()); - } else { - if (value instanceof Prim) { - throw new SmartFrogResolutionException(roleRef, - sfCompleteName, - "Expected a component implementing EC2ClusterRole", - value); - } else { - sfLog().debug("Ignoring roles attribute " + roleName + " which maps to " + value); - } - } - } - return roleBindings.size(); - } - - /** - * Create a launch configuration; this is logged - * - * @param role role to create - * @param targetRole the component containing the target roled - * @return a launch config - * @throws RemoteException IO/network problems - * @throws SmartFrogResolutionException problems creating the launch config - */ - private LaunchConfiguration createLaunchConfiguration(String role, Prim targetRole) - throws SmartFrogResolutionException, RemoteException { - sfLog().info("Creating a Launch config from " + targetRole); - LaunchConfiguration lc = EC2ClusterRole.createLaunchConfiguration(role, targetRole); - return lc; - } - - - /** - * Look up a role under the roles compound/CD - * - * @param role role to create - * @return the prim at the far end - * @throws RemoteException IO/network problems - * @throws SmartFrogResolutionException problems creating the launch config - */ - private Prim resolveRole(String role) throws SmartFrogResolutionException, RemoteException { - return roles.sfResolve(role, (Prim) null, true); - } - - - /** - * {@inheritDoc} - */ - @Override - public String getDescription() throws IOException, SmartFrogException { - return "EC2 Cloud Farmer"; - } - - /** - * {@inheritDoc} - */ - @Override - public String getDiagnosticsText() throws IOException, SmartFrogException { - return getDescription() - + "\nclusterLimit:" + clusterLimit - + "\nnodeCount:" + nodeCount - + "\nEC2 user ID:" + getId(); - } - - /** - * {@inheritDoc} - */ - @Override - public void startCluster() throws IOException, SmartFrogException { - - } - - /** - * {@inheritDoc} - */ - @Override - public void stopCluster() throws IOException, SmartFrogException { - deleteAll(); - } - - /** - * {@inheritDoc} - */ - @Override - public void releaseAllResources() throws IOException, SmartFrogException { - stopCluster(); - } - - /** - * {@inheritDoc} <p/> This is implemented by handing off to any declared deployment factory - */ - @Override - public NodeDeploymentService createNodeDeploymentService(ClusterNode node) throws IOException, SmartFrogException { - return deploymentFactory.createInstance(node); - } -} Deleted: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/EC2ClusterRole.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/EC2ClusterRole.java 2010-01-07 12:09:48 UTC (rev 8122) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/EC2ClusterRole.java 2010-01-08 15:44:34 UTC (rev 8123) @@ -1,88 +0,0 @@ -/* (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 - -*/ -package org.smartfrog.services.cloudfarmer.server.ec2; - -import com.xerox.amazonws.ec2.InstanceType; -import com.xerox.amazonws.ec2.LaunchConfiguration; -import org.smartfrog.services.amazon.ec2.EC2Instance; -import org.smartfrog.services.amazon.ec2.EC2Utils; -import org.smartfrog.services.cloudfarmer.server.common.ClusterRoleImpl; -import org.smartfrog.sfcore.common.SmartFrogException; -import org.smartfrog.sfcore.common.SmartFrogResolutionException; -import org.smartfrog.sfcore.prim.Prim; -import org.smartfrog.sfcore.reference.Reference; -import org.smartfrog.sfcore.utils.ListUtils; - -import java.rmi.RemoteException; -import java.util.Vector; - -/** - * Created 29-Sep-2009 11:37:58 - */ - -public class EC2ClusterRole extends ClusterRoleImpl implements EC2Instance { - public static final String ERROR_NO_VALID_IMAGE_ID = "No valid imageID for role "; - - public EC2ClusterRole() throws RemoteException { - } - - /** - * extends the parent's startup actions by creating a launch configuration - * @throws SmartFrogException SF problems - * @throws RemoteException network problems - */ - @Override - public void sfStart() throws SmartFrogException, RemoteException { - super.sfStart(); - LaunchConfiguration lc = createLaunchConfiguration("none", this); - } - - - /** - * Create an EC2 launch configuration from a target role - * @param role role name - * @param targetRole the prim defining the role. It is not required that this is an instance of EC2ClusterRole - * @return the launch configuration - * @throws SmartFrogResolutionException resolution problems - * @throws RemoteException network problems - */ - public static LaunchConfiguration createLaunchConfiguration(String role, Prim targetRole) - throws SmartFrogResolutionException, RemoteException { - String imageID = targetRole.sfResolve(ATTR_IMAGE_ID, "", true); - String zone = targetRole.sfResolve(ATTR_AVAILABILITY_ZONE, "", true); - String keyName = targetRole.sfResolve(ATTR_KEY_NAME, "", true); - String userData = targetRole.sfResolve(ATTR_USER_DATA, "", true); - InstanceType size = InstanceType.getTypeFromString(targetRole.sfResolve(ATTR_INSTANCE_TYPE, "", true)); - Vector<String> groups = ListUtils.resolveStringList(targetRole, new Reference(ATTR_SECURITY_GROUP), true); - LaunchConfiguration lc = new LaunchConfiguration(imageID.trim()); - lc.setConfigName(role); - lc.setAvailabilityZone(zone); - lc.setInstanceType(size); - lc.setKeyName(keyName); - lc.setSecurityGroup(groups); - lc.setUserData(userData.getBytes()); - if (lc.getImageId().isEmpty()) { - throw new SmartFrogResolutionException(ERROR_NO_VALID_IMAGE_ID + role + " " + EC2Utils.convertToString(lc) - + ("- raw image ID :'" + imageID + "'")); - } - return lc; - } - -} Deleted: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/RoleBinding.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/RoleBinding.java 2010-01-07 12:09:48 UTC (rev 8122) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/RoleBinding.java 2010-01-08 15:44:34 UTC (rev 8123) @@ -1,77 +0,0 @@ -/* (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 - -*/ -package org.smartfrog.services.cloudfarmer.server.ec2; - -import com.xerox.amazonws.ec2.LaunchConfiguration; -import org.smartfrog.services.amazon.ec2.EC2Utils; -import org.smartfrog.services.amazon.ec2.InstanceList; -import org.smartfrog.sfcore.prim.Prim; - -/** - * This is the binding of roles that is created at deploy time; it can be used to remember which instances are mapped - * where - */ - -public class RoleBinding { - - private String role; - private LaunchConfiguration launchConfig; - private String description; - private Prim source; - private InstanceList instances; - - - public RoleBinding(String role, Prim source, LaunchConfiguration launchConfig) { - this.role = role; - this.source = source; - this.launchConfig = launchConfig; - description = EC2Utils.convertToString(launchConfig); - instances = new InstanceList(); - } - - public String getRole() { - return role; - } - - public void setRole(String role) { - this.role = role; - } - - public LaunchConfiguration getLaunchConfig() { - return launchConfig; - } - - public void setLaunchConfig(LaunchConfiguration launchConfig) { - this.launchConfig = launchConfig; - } - - public Prim getSource() { - return source; - } - - public void setSource(Prim source) { - this.source = source; - } - - @Override - public String toString() { - return "Role " + role + " " + description; - } -} Deleted: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/components.sf =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/components.sf 2010-01-07 12:09:48 UTC (rev 8122) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/ec2/components.sf 2010-01-08 15:44:34 UTC (rev 8123) @@ -1,117 +0,0 @@ -/* (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/amazon/ec2/components.sf" -#include "/org/smartfrog/services/cloudfarmer/server/components.sf" - - - -/** - * The cluster farmer implements the ClusterFarmer interface, and so lets trusted callers - * create machines of a specific role. - - Conceptual Model - - the farmer is deployed, it brings up models in a role. It can be set to delete all deployed nodes when terminated, - or to leave them running (more robust, but can rack up bills) - - for every role, define an AMI string, instance type and any user data - -Roles are inserted in an undeployed bit of the system, just plain data. That's so we can have some basic image definitions - - */ - - -/** - * just something that is used to configure the farmer - */ - -EC2ClusterRole extends EC2ImageSizes, EC2AvailabilityZones, ClusterRole { - sfClass "org.smartfrog.services.cloudfarmer.server.ec2.EC2ClusterRole"; - - //the string value of the machine image to deploy. This must resolve before an attempt - //to deploy a machine of the given role can work - imageID TBD; - - //instance types - instanceType SIZE_SMALL; - - //user data. This is going to change before long - userData ""; - - //name of the key to use for SSH from the list of key pairs - keyName ""; - - // where the image should live - availabilityZone ZONE_US_EAST_1A; - - // a list of string names - securityGroup []; - -} - -/** - * This is our cluster farmer. - * Its exact functionality will evolve over time - */ - -EC2ClusterFarmer extends AwsAuthorizedService { - sfClass "org.smartfrog.services.cloudfarmer.server.ec2.EC2ClusterFarmerImpl" - - /** - * This is there to stop users accidentally running up large bills. If <0, it means ignore - */ - - clusterLimit 10; - - /** - * constant to ignore all cluster limits - */ - NO_CLUSTER_LIMIT -1; - - /** - * Should the farmer recycle old instances given out. - * For dev and test yes, but bear in mind that the machine may be in an unknown state. - * When recycling, the old image is rebooted and left alone until needed - */ - recycle true; - - /** - should you delete instances when terminating? - For HA systems the answer MUST BE no, leave them up, somehow the next instance will rebind. - For test and dev systems, that can run up a large bill - */ - deleteInstancesOnTermination true; - - /** - roles go under here. Each one should have all the attributes of an EC2ClusterRole, so that you can - create a cluster instance from the - */ - roles extends Compound { - - } - - - /** - * Deployments fail unless you set up a proper configuration service - */ - deploymentFactory extends NodeDeploymentUnsupportedFactory { - - } -} - Deleted: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/examples/ec2_hadoop_farmer.sf =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/examples/ec2_hadoop_farmer.sf 2010-01-07 12:09:48 UTC (rev 8122) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/examples/ec2_hadoop_farmer.sf 2010-01-08 15:44:34 UTC (rev 8123) @@ -1,70 +0,0 @@ -/* (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/server/ec2/components.sf" - - -/** - * This example is driven from - test.image.id ID of an AWS image - */ - -test.image.id PROPERTY test.image.id; -test.awsid PROPERTY test.awsid; -test.awskey PROPERTY test.awskey; -timeout 10; - -EC2HadoopRoles extends Compound { - - master extends EC2ClusterRole { - description "Hadoop Namenode and Job Tracker"; - min 1; - max 1; - imageID test.image.id; - } - - worker extends EC2ClusterRole { - description "Worker nodes are Datanodes and TaskTrackers"; - min 1; - recommendedMin 3; - imageID test.image.id; - } -} - -EC2HadoopFarmer extends EC2ClusterFarmer { - id test.awsid; - key test.awskey; - - roles extends EC2HadoopRoles { - - } - - /** - * Mock deployments - */ - deploymentFactory extends MockNodeDeploymentFactory { - - } - -} - - - - -sfConfig extends EC2HadoopFarmer; \ No newline at end of file Deleted: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/components.sf =================================================================== --- trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/components.sf 2010-01-07 12:09:48 UTC (rev 8122) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/components.sf 2010-01-08 15:44:34 UTC (rev 8123) @@ -1,171 +0,0 @@ -/* (C) Copyright 2008 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/components.sf" -#include "/org/smartfrog/services/passwords/components.sf" -#include "/org/smartfrog/services/amazon/workflow/components.sf" - -bucket "smartfrogtest"; -login OPTIONAL("") PROPERTY test.awsid; -password OPTIONAL("") PROPERTY test.awskey; -timeout 10; - -bucketHost (bucket ++ ".s3.amazonaws.com"); - - -test.awsid "test.awsid"; -test.awskey "test.awskey"; -test.ec2.image.id "ami-26b6534f"; -test.sleep.delay 1000; -test.ec2.startup.delay 30000; - - -/** - * turn the AWS key into a password - */ - -AwsPassword extends PropertyPassword { - id login; - property test.awskey; -} - -/* - * Our AWS condition - */ - -IsAwsEnabled extends IsPropertyTrue { - property test.awsid; -} - - - -IsEC2EnabledSet extends IsPropertyTrue { - property "test.ec2.enabled"; -} - - -IsS3EnabledSet extends IsPropertyTrue { - property "test.s3.enabled"; -} - -IsEC2InstancesSet extends IsPropertyTrue { - property "test.ec2.instances.enabled"; -} - - -IsEC2FarmerSet extends IsPropertyTrue { - property "test.ec2.farmer.enabled"; -} - - - -IsEC2Enabled extends And { - ec2 extends IsEC2EnabledSet; - aws extends IsAwsEnabled; -} - -IsEC2InstancesEnabled extends IsEC2Enabled { - ec2instances extends IsEC2InstancesSet; -} - -IsEC2FarmerEnabled extends IsEC2Enabled { - ec2farmer extends IsEC2FarmerSet; -} - - -IsS3Enabled extends And { - ec2 extends IsS3EnabledSet; - aws extends IsAwsEnabled; -} - - -/** - A test on AWS - */ - -ExpectDeployOnAWS extends ExpectDeploy { - - description "test against the AWS servers; requires test.awsid to be set with a login" - - condition extends IsAwsEnabled ; - sfShouldTerminate true; - -} - -/** - A test on AWS - */ - -ExpectDeployFailureOnAWS extends ExpectDeployFailure { - - description ExpectDeployOnAWS:description; - - condition extends IsAwsEnabled ; - -} - -ExpectDeployOnEC2 extends ExpectDeploy { - - description "test deploy on the EC2 servers; requires test.awsid to be set with a login and test.ec2.enabled to set to something" - - condition extends IsEC2Enabled ; - sfShouldTerminate true; - -} - - -ExpectDeployInstanceOnEC2 extends ExpectDeployOnEC2 { - description "A test deploying if instances are enabled"; - condition extends IsEC2InstancesEnabled; -} - -ExpectDeployFarmerOnEC2 extends ExpectDeployOnEC2 { - description "A test deploying if the ec2.farmer tests are enabled"; - condition extends IsEC2FarmerEnabled; -} - - -/** - A test on AWS - */ - -ExpectDeployFailureOnEC2 extends ExpectDeployFailure { - - description ExpectDeployOnEC2:description; - - condition extends IsEC2Enabled ; -} - -ExpectDeployInstanceFailureOnEC2 extends ExpectDeployFailure { - - description ExpectDeployOnEC2:description; - - condition extends IsEC2InstancesEnabled ; - -} - -ExpectDeployFarmerFailureOnEC2 extends ExpectDeployFailure { - - description ExpectDeployFarmerOnEC2:description; - - condition extends IsEC2FarmerEnabled ; - -} - - Deleted: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/EC2FarmerOfflineTest.java =================================================================== --- trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/EC2FarmerOfflineTest.java 2010-01-07 12:09:48 UTC (rev 8122) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/EC2FarmerOfflineTest.java 2010-01-08 15:44:34 UTC (rev 8123) @@ -1,26 +0,0 @@ -package org.smartfrog.services.cloudfarmer.test.ec2.offline; - -import org.smartfrog.test.DeployingTestBase; - -/** - * - */ -public class EC2FarmerOfflineTest extends DeployingTestBase { - public static final String FILES = "/org/smartfrog/services/cloudfarmer/test/ec2/offline"; - - public EC2FarmerOfflineTest(String name) { - super(name); - } - - public void testFarmHasRoles() throws Throwable { - expectSuccessfulTestRunOrSkip(FILES, "testFarmHasRoles"); - } - - public void testFarmLacksRole() throws Throwable { - expectSuccessfulTestRunOrSkip(FILES, "testFarmLacksRole"); - } - - public void testMasterLacksImageID() throws Throwable { - expectSuccessfulTestRunOrSkip(FILES, "testMasterLacksImageID"); - } -} Deleted: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/components.sf =================================================================== --- trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/components.sf 2010-01-07 12:09:48 UTC (rev 8122) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/components.sf 2010-01-08 15:44:34 UTC (rev 8123) @@ -1,219 +0,0 @@ -/* (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.p - -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/assertions/components.sf" -#include "/org/smartfrog/services/cloudfarmer/test/ec2/components.sf" - -BaseFarmer extends EC2ClusterFarmer { - - clusterLimit 4; - id ""; - key ""; - - } - -Farmer extends BaseFarmer { - - clusterLimit 4; - id ""; - key ""; - roles extends Compound { - - - worker extends EC2ClusterRole { - imageID "ami-0236"; - instanceType SIZE_LARGE; - availabilityZone ZONE_US_EAST_1B; - } - - master extends EC2ClusterRole { - imageID "ami-0234"; - instanceType SIZE_LARGE; - availabilityZone ZONE_US_EAST_1B; - securityGroup ["undefined"]; - } - - - } - - } - -ExpectFarmerDeploy extends ExpectDeploy { - - action Farmer; - - -} - -testFarmHasRoles extends ExpectFarmerDeploy { - - tests extends Sequence { - - - master extends FarmSupportsRoleWorkflow { - //this is the farmer - farmer LAZY action; - role "master"; - } - - worker extends FarmSupportsRoleWorkflow { - //this is the farmer - farmer LAZY action; - role "worker"; - } - - - } -} - - -testFarmLacksRole extends ExpectDeployFailure { - - description "create a mock cluster, and, in parallel, a test for a role that isn't supported" - - action extends Parallel { - farmer BaseFarmer ; - - master extends FarmSupportsRole { - farmer LAZY action:farmer; - role "server"; - } - } -} - - - -testMasterLacksImageID extends ExpectDeployFailure { - - description "create a mock cluster, and, in parallel, a test for a role that lacks an ID" - - action extends Parallel { - - farmer extends Farmer { - roles:master:imageID ""; - } - - - master extends FarmSupportsRole { - farmer LAZY action:farmer; - role "server"; - } - } -} - - -testFarmCreate extends ExpectFarmerDeploy { - - tests extends Sequence { - - - master extends WorkflowFarmCustomer { - //this is the farmer - farmer LAZY action; - role "master"; - min 1; - expected 1; - } - - worker extends WorkflowFarmCustomer { - //this is the farmer - farmer LAZY action; - role "worker"; - min 10; - expected 10; - } - - worker2 extends WorkflowFarmCustomer { - //this is the farmer - farmer LAZY action; - role "worker"; - min 10; - expected 10; - } - - } -} - - -testFarmCreateBounded extends ExpectFarmerDeploy { - - tests extends Sequence { - - - master extends WorkflowFarmCustomer { - //this is the farmer - farmer LAZY action; - role "master"; - min 1; - max 100; - expected farmer:clusterLimit; - } - } -} - -testFarmCreateNoRoom extends ExpectDeployFailure { - - description "create a mock cluster, and, in parallel, a farm customer that demands too many items" - - action extends Parallel { - farmer Farmer; - - master extends WorkflowFarmCustomer { - farmer LAZY action:farmer; - role "master"; - min 100; - max 100; - } - } -} - - -testFarmCreateNoRole extends ExpectDeployFailure { - - description "create a mock cluster, and, in parallel, a farm customer that tries to create something of an unknown role" - - action extends Parallel { - farmer Farmer; - - master extends WorkflowFarmCustomer { - farmer LAZY action:farmer; - role "server"; - min 1; - max 10; - } - } -} - - -testFarmCreateNegativeNumber extends ExpectDeployFailure { - - description "create a mock cluster, and, in parallel, a farm customer that demands less than 0 nodes" - - action extends Parallel { - farmer Farmer; - - master extends WorkflowFarmCustomer { - farmer LAZY action:farmer; - role "master"; - min -10; - max 10; - } - } -} - Deleted: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/testFarmHasRoles.sf =================================================================== --- trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/testFarmHasRoles.sf 2010-01-07 12:09:48 UTC (rev 8122) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/testFarmHasRoles.sf 2010-01-08 15:44:34 UTC (rev 8123) @@ -1,22 +0,0 @@ -/* (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/ec2/offline/components.sf" - -sfConfig extends testFarmHasRoles; Deleted: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/testFarmLacksRole.sf =================================================================== --- trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/testFarmLacksRole.sf 2010-01-07 12:09:48 UTC (rev 8122) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/testFarmLacksRole.sf 2010-01-08 15:44:34 UTC (rev 8123) @@ -1,22 +0,0 @@ -/* (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/ec2/offline/components.sf" - -sfConfig extends testFarmLacksRole; Deleted: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/testMasterLacksImageID.sf =================================================================== --- trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/testMasterLacksImageID.sf 2010-01-07 12:09:48 UTC (rev 8122) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/offline/testMasterLacksImageID.sf 2010-01-08 15:44:34 UTC (rev 8123) @@ -1,22 +0,0 @@ -/* (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/ec2/offline/components.sf" - -sfConfig extends testMasterLacksImageID; Deleted: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/online/EC2FarmerOnlineTest.java =================================================================== --- trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/online/EC2FarmerOnlineTest.java 2010-01-07 12:09:48 UTC (rev 8122) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/online/EC2FarmerOnlineTest.java 2010-01-08 15:44:34 UTC (rev 8123) @@ -1,18 +0,0 @@ -package org.smartfrog.services.cloudfarmer.test.ec2.online; - -import org.smartfrog.test.DeployingTestBase; - -/** - * - */ -public class EC2FarmerOnlineTest extends DeployingTestBase { - public static final String FILES = "/org/smartfrog/services/cloudfarmer/test/ec2/online/"; - - public EC2FarmerOnlineTest(String name) { - super(name); - } - - public void testNothing() throws Throwable { - - } -} \ No newline at end of file Deleted: trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/online/components.sf =================================================================== --- trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/online/components.sf 2010-01-07 12:09:48 UTC (rev 8122) +++ trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/ec2/online/components.sf 2010-01-08 15:44:34 UTC (rev 8123) @@ -1,219 +0,0 @@ -/* (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.p - -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/assertions/components.sf" -#include "/org/smartfrog/services/cloudfarmer/test/ec2/components.sf" - -BaseFarmer extends EC2ClusterFarmer { - - clusterLimit 4; - id ""; - key ""; - - } - -Farmer extends BaseFarmer { - - clusterLimit 4; - id ""; - key ""; - roles extends Compound { - - - worker extends EC2ClusterRole { - imageID "ami-0236"; - instanceType SIZE_LARGE; - availabilityZone ZONE_US_EAST_1B; - } - - master extends EC2ClusterRole { - imageID "ami-0234"; - instanceType SIZE_LARGE; - availabilityZone ZONE_US_EAST_1B; - securityGroup ["undefined"]; - } - - - } - - } - -ExpectFarmerDeploy extends ExpectDeploy { - - action Farmer; - - -} - -testFarmHasRoles extends ExpectFarmerDeploy { - - tests extends Sequence { - - - master extends FarmSupportsRoleWorkflow { - //this is the farmer - farmer LAZY action; - role "master"; - } - - worker extends FarmSupportsRoleWorkflow { - //this is the farmer - farmer LAZY action; - role "worker"; - } - - - } -} - - -testFarmLacksRole extends ExpectDeployFailure { - - description "create a mock cluster, and, in parallel, a test for a role that isn't supported" - - action extends Parallel { - farmer BaseFarmer ; - - master extends FarmSupportsRole { - farmer LAZY action:farmer; - role "server"; - } - } -} - - - -testMasterLacksImageID extends ExpectDeployFailure { - - description "create a mock cluster, and, in parallel, a test for a role that lacks an ID" - - action extends Parallel { - - farmer extends Farmer { - roles:master:imageID ""; - } - - - master extends FarmSupportsRole { - farmer LAZY action:farmer; - role "server"; - } - } -} - - -testFarmCreate extends ExpectFarmerDeploy { - - tests extends Sequence { - - - master extends WorkflowFarmCustomer { - //this is the farmer - farmer LAZY action; - role "master"; - min 1; - expected 1; - } - - worker extends WorkflowFarmCustomer { - //this is the farmer - farmer LAZY action; - role "worker"; - min 10; - expected 10; - } - - worker2 extends WorkflowFarmCustomer { - //this is the farmer - farmer LAZY action; - role "worker"; - min 10; - expected 10; - } - - } -} - - -testFarmCreateBounded extends ExpectFarmerDeploy { - - tests extends Sequence { - - - master extends WorkflowFarmCustomer { - //this is the farmer - farmer LAZY action; - role "master"; - min 1; - max 100; - expected farmer:clusterLimit; - } - } -} - -testFarmCreateNoRoom extends ExpectDeployFailure { - - description "create a mock cluster, and, in parallel, a farm customer that demands too many items" - - action extends Parallel { - farmer Farmer; - - master extends WorkflowFarmCustomer { - farmer LAZY action:farmer; - role "master"; - min 100; - max 100; - } - } -} - - -testFarmCreateNoRole extends ExpectDeployFailure { - - description "create a mock cluster, and, in parallel, a farm customer that tries to create something of an unknown role" - - action extends Parallel { - farmer Farmer; - - master extends WorkflowFarmCustomer { - farmer LAZY action:farmer; - role "server"; - min 1; - max 10; - } - } -} - - -testFarmCreateNegativeNumber extends ExpectDeployFailure { - - description "create a mock cluster, and, in parallel, a farm customer that demands less than 0 nodes" - - action extends Parallel { - farmer Farmer; - - master extends WorkflowFarmCustomer { - farmer LAZY action:farmer; - role "master"; - min -10; - max 10; - } - } -} - Modified: trunk/core/components/ec2/ivy.xml =================================================================== --- trunk/core/components/ec2/ivy.xml 2010-01-07 12:09:48 UTC (rev 8122) +++ trunk/core/components/ec2/ivy.xml 2010-01-08 15:44:34 UTC (rev 8123) @@ -77,7 +77,15 @@ rev="latest.integration" conf="test->default"/> + <dependency org="org.smartfrog" + name="sf-cloudfarmer" + changing="true" + rev="latest.integration" + conf="daemon,compile->default;runtime->runtime;redist->r... [truncated message content] |
From: <st...@us...> - 2010-01-11 17:25:19
|
Revision: 8128 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=8128&view=rev Author: steve_l Date: 2010-01-11 17:25:07 +0000 (Mon, 11 Jan 2010) Log Message: ----------- SFOS-1409 Make Cloudfarmer independent of Hadoop Modified Paths: -------------- trunk/core/components/cloudfarmer/build.xml trunk/core/components/cloudfarmer/doc/acm_cloudfarmer_paper.doc trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/cluster_add_named.jsp trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster_portlet.jsp trunk/core/components/cloudfarmer/site/html/mombasa-portlet/workflow_admin.jsp trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/api/ClusterFarmer.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/api/NodeDeploymentServiceFactory.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/common/BaseRemoteDaemon.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/ClusterAddDynamicNodeProcessAction.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/ClusterDeleteNodeProcessAction.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/ClusterDiagnosticsAction.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/actions/cluster/ClusterListRolesAction.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/workflow/QueueAnyWorkflowProcessAction.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/workflow/WorkflowBindToRemoteServerAction.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/workflow/WorkflowListAction.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/clusters/masterworker/hadoop/descriptions/TemplateNames.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/forms/AbstractMombasaActionForm.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/forms/cluster/ClusterAddDynamicForm.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/forms/cluster/ClusterAddNamedNodeForm.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/forms/cluster/ClusterChangeManagerForm.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/forms/cluster/ClusterCreateActionForm.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/forms/workflow/AbstractQueueJobActionForm.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/htmlunit/cluster/MombasaClusterWebTestCase.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/model/cluster/ClusterController.java 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/HadoopCluster.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/client/web/model/cluster/PhysicalClusterController.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/model/workflow/Workflow.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/common/AbstractClusterFarmer.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/common/AbstractFarmNodeClusterFarmer.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/deployment/AbstractNodeDeployment.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/deployment/NodeDeploymentOverRMIFactory.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/deployment/NodeDeploymentOverSSHFactory.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/deployment/NodeDeploymentUnsupportedFactory.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/deployment/components.sf trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/mock/MockNodeDeploymentFactory.java trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/client/web/model/HostCreationUnitTest.java trunk/core/components/cloudfarmer/test/org/smartfrog/services/cloudfarmer/test/mock/MockFarmerUnitTest.java trunk/core/components/ec2/build.xml trunk/core/components/ec2/src/org/smartfrog/services/cloudfarmer/server/ec2/EC2ClusterFarmerImpl.java Added Paths: ----------- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/clusters/ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/clusters/ClusterAllocationHandler.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/clusters/masterworker/ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/clusters/masterworker/MasterWorkerAllocationHandler.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/clusters/masterworker/MasterWorkerRoles.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/clusters/masterworker/hadoop/ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/clusters/masterworker/hadoop/HadoopAllocationHandler.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/server/common/ClusterFarmerUtils.java Removed Paths: ------------- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/clusters/masterworker/hadoop/HadoopDeploymentCallback.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/clusters/masterworker/hadoop/HadoopRoles.java trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/hadoop/ Modified: trunk/core/components/cloudfarmer/build.xml =================================================================== --- trunk/core/components/cloudfarmer/build.xml 2010-01-11 15:45:17 UTC (rev 8127) +++ trunk/core/components/cloudfarmer/build.xml 2010-01-11 17:25:07 UTC (rev 8128) @@ -24,17 +24,10 @@ --> <description> - Amazon EC2/S3 support. - - For testing, edit build.properties to add the secret login details for an AWS account - test.awsid = id - test.awskey = secret key - test.ec2.enabled to true for EC2 work - - test.ec2.instances.enabled tests that create instances - test.ec2.farmer.enabled= tests that create a farmer and instances through it - test.s3.enabled tests that go up against S3 - + This provides + * the base CloudFarmer API and the mock and manual implementations. + * the web, SF component and ant clients + Other CloudFarmer implementations are with the back ends </description> <!-- Modified: trunk/core/components/cloudfarmer/doc/acm_cloudfarmer_paper.doc =================================================================== (Binary files differ) Modified: trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/cluster_add_named.jsp =================================================================== --- trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/cluster_add_named.jsp 2010-01-11 15:45:17 UTC (rev 8127) +++ trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster/cluster_add_named.jsp 2010-01-11 17:25:07 UTC (rev 8128) @@ -42,7 +42,7 @@ <tr> <td> - Hadoop worker + Worker </td> <td style="padding-left: 10px;"></td> <td> @@ -52,7 +52,7 @@ <tr> <td> - Hadoop master + Master </td> <td style="padding-left: 10px;"></td> <td> Modified: trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster_portlet.jsp =================================================================== --- trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster_portlet.jsp 2010-01-11 15:45:17 UTC (rev 8127) +++ trunk/core/components/cloudfarmer/site/html/mombasa-portlet/cluster_portlet.jsp 2010-01-11 17:25:07 UTC (rev 8128) @@ -26,7 +26,7 @@ <jsp:include page="/html/mombasa-portlet/header.jsp"/> <div> -From the Hadoop Workflow Manager, you can manage +From the Workflow Manager, you can manage existing workflows, and queue new MapReduce jobs. </div> Modified: trunk/core/components/cloudfarmer/site/html/mombasa-portlet/workflow_admin.jsp =================================================================== --- trunk/core/components/cloudfarmer/site/html/mombasa-portlet/workflow_admin.jsp 2010-01-11 15:45:17 UTC (rev 8127) +++ trunk/core/components/cloudfarmer/site/html/mombasa-portlet/workflow_admin.jsp 2010-01-11 17:25:07 UTC (rev 8128) @@ -24,7 +24,7 @@ <jsp:include page="/html/mombasa-portlet/header.jsp"/> <h2> - Hadoop Workflow Administration + Workflow Administration </h2> <logic:messagesPresent> Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/api/ClusterFarmer.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/api/ClusterFarmer.java 2010-01-11 15:45:17 UTC (rev 8127) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/api/ClusterFarmer.java 2010-01-11 17:25:07 UTC (rev 8128) @@ -237,7 +237,16 @@ */ public void stopCluster() throws IOException, SmartFrogException; + /** + * query the deployment service for being present. + * @return false if the service is not defined, or it says it is not functioning + * @throws IOException IO problems + * @throws SmartFrogException Other problems + */ + public boolean isDeploymentServiceAvailable() throws IOException, SmartFrogException; + + /** * Create a node deployment service for the specific node * @param node node to deploy to * @return a deployment service Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/api/NodeDeploymentServiceFactory.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/api/NodeDeploymentServiceFactory.java 2010-01-11 15:45:17 UTC (rev 8127) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/api/NodeDeploymentServiceFactory.java 2010-01-11 17:25:07 UTC (rev 8128) @@ -28,4 +28,11 @@ */ public String getDiagnosticsText() throws IOException, SmartFrogException; + /** + * Test for node deployment being supported <i>at all</i> + * @return true if Node deployment instances can be created, false otherwise + * @throws IOException Network and other IO problems + * @throws SmartFrogException SmartFrog problems + */ + public boolean isNodeDeploymentSupported() throws IOException, SmartFrogException; } Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/common/BaseRemoteDaemon.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/common/BaseRemoteDaemon.java 2010-01-11 15:45:17 UTC (rev 8127) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/common/BaseRemoteDaemon.java 2010-01-11 17:25:07 UTC (rev 8128) @@ -1,7 +1,7 @@ package org.smartfrog.services.cloudfarmer.client.common; import org.smartfrog.services.cloudfarmer.api.ClusterFarmer; -import org.smartfrog.services.cloudfarmer.client.web.hadoop.descriptions.TemplateNames; +import org.smartfrog.services.cloudfarmer.client.web.clusters.masterworker.hadoop.descriptions.TemplateNames; import org.smartfrog.services.cloudfarmer.client.web.model.workflow.Workflow; import org.smartfrog.services.cloudfarmer.client.web.model.workflow.WorkflowList; import org.smartfrog.services.cloudfarmer.server.deployment.NodeDeploymentOverRMI; 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-11 15:45:17 UTC (rev 8127) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/AbstractStrutsAction.java 2010-01-11 17:25:07 UTC (rev 8128) @@ -31,8 +31,8 @@ import org.smartfrog.sfcore.logging.Log; import org.smartfrog.sfcore.logging.LogFactory; +import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; -import javax.servlet.ServletContext; import java.rmi.ConnectException; /** Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/ClusterAddDynamicNodeProcessAction.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/ClusterAddDynamicNodeProcessAction.java 2010-01-11 15:45:17 UTC (rev 8127) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/ClusterAddDynamicNodeProcessAction.java 2010-01-11 17:25:07 UTC (rev 8128) @@ -23,13 +23,14 @@ import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; +import org.smartfrog.services.cloudfarmer.client.web.clusters.masterworker.MasterWorkerRoles; +import org.smartfrog.services.cloudfarmer.client.web.clusters.masterworker.MasterWorkerAllocationHandler; import org.smartfrog.services.cloudfarmer.client.web.forms.cluster.ClusterAddDynamicForm; +import org.smartfrog.services.cloudfarmer.client.web.clusters.masterworker.hadoop.HadoopAllocationHandler; import org.smartfrog.services.cloudfarmer.client.web.model.cluster.ClusterController; +import org.smartfrog.services.cloudfarmer.client.web.model.cluster.HostInstance; import org.smartfrog.services.cloudfarmer.client.web.model.cluster.RoleAllocationRequest; import org.smartfrog.services.cloudfarmer.client.web.model.cluster.RoleAllocationRequestList; -import org.smartfrog.services.cloudfarmer.client.web.model.cluster.HostInstance; -import org.smartfrog.services.cloudfarmer.client.web.hadoop.HadoopDeploymentCallback; -import org.smartfrog.services.cloudfarmer.client.web.hadoop.HadoopRoles; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -61,19 +62,19 @@ ClusterAddDynamicForm form = (ClusterAddDynamicForm) aform; try { log.info("Creating workers in range [" + form.getMinWorkers() + "-" + form.getMaxWorkers() + "]"); - HadoopDeploymentCallback handler = new HadoopDeploymentCallback(controller); + MasterWorkerAllocationHandler handler = new HadoopAllocationHandler(controller); //add a master automatically RoleAllocationRequestList requests = new RoleAllocationRequestList(2); HostInstance master = controller.getMaster(); if (master == null) { log.info("Creating a master node"); - requests.add(new RoleAllocationRequest(HadoopRoles.MASTER, 0, 1, 1, null)); + requests.add(new RoleAllocationRequest(MasterWorkerRoles.MASTER, 0, 1, 1, null)); handler.setCreatingMaster(true); } else { handler.setCreatingMaster(false); handler.setMaster(master); } - RoleAllocationRequest workers = new RoleAllocationRequest(HadoopRoles.WORKER, + RoleAllocationRequest workers = new RoleAllocationRequest(MasterWorkerRoles.WORKER, -1, form.getMinWorkers(), form.getMaxWorkers(), Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/ClusterDeleteNodeProcessAction.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/ClusterDeleteNodeProcessAction.java 2010-01-11 15:45:17 UTC (rev 8127) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/ClusterDeleteNodeProcessAction.java 2010-01-11 17:25:07 UTC (rev 8128) @@ -31,8 +31,7 @@ /** - * Submit a job to the workflow server. Some devious tricks are paid with overloaded methods, as whichever form is - * received, it is routed over to the daemon to handle + * Delete a node */ @SuppressWarnings({"RefusedBequest"}) public class ClusterDeleteNodeProcessAction extends AbstractClusterAction { Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/ClusterDiagnosticsAction.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/ClusterDiagnosticsAction.java 2010-01-11 15:45:17 UTC (rev 8127) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/ClusterDiagnosticsAction.java 2010-01-11 17:25:07 UTC (rev 8128) @@ -19,9 +19,9 @@ */ package org.smartfrog.services.cloudfarmer.client.web.actions.cluster; +import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; -import org.apache.struts.action.ActionForm; import org.smartfrog.services.cloudfarmer.client.web.model.cluster.ClusterController; import javax.servlet.http.HttpServletRequest; 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 2010-01-11 15:45:17 UTC (rev 8127) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/ClusterListHostsInRoleAction.java 2010-01-11 17:25:07 UTC (rev 8128) @@ -19,12 +19,12 @@ */ package org.smartfrog.services.cloudfarmer.client.web.actions.cluster; +import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; -import org.apache.struts.action.ActionForm; +import org.smartfrog.services.cloudfarmer.client.web.exceptions.BadParameterException; import org.smartfrog.services.cloudfarmer.client.web.model.cluster.ClusterController; import org.smartfrog.services.cloudfarmer.client.web.model.cluster.HostInstanceList; -import org.smartfrog.services.cloudfarmer.client.web.exceptions.BadParameterException; import org.smartfrog.sfcore.common.SmartFrogException; import javax.servlet.http.HttpServletRequest; Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/ClusterListRolesAction.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/ClusterListRolesAction.java 2010-01-11 15:45:17 UTC (rev 8127) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/cluster/ClusterListRolesAction.java 2010-01-11 17:25:07 UTC (rev 8128) @@ -19,9 +19,9 @@ */ package org.smartfrog.services.cloudfarmer.client.web.actions.cluster; +import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; -import org.apache.struts.action.ActionForm; import org.smartfrog.services.cloudfarmer.client.web.model.cluster.ClusterController; import javax.servlet.http.HttpServletRequest; Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/workflow/QueueAnyWorkflowProcessAction.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/workflow/QueueAnyWorkflowProcessAction.java 2010-01-11 15:45:17 UTC (rev 8127) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/workflow/QueueAnyWorkflowProcessAction.java 2010-01-11 17:25:07 UTC (rev 8128) @@ -20,14 +20,14 @@ package org.smartfrog.services.cloudfarmer.client.web.actions.workflow; -import org.smartfrog.services.cloudfarmer.client.web.model.RemoteDaemon; -import org.smartfrog.services.cloudfarmer.client.web.model.workflow.Workflow; -import org.smartfrog.services.cloudfarmer.client.web.forms.workflow.AbstractQueueJobActionForm; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; +import org.smartfrog.services.cloudfarmer.client.web.actions.cluster.AbstractMombasaAction; import org.smartfrog.services.cloudfarmer.client.web.exceptions.ParseFailedException; -import org.smartfrog.services.cloudfarmer.client.web.actions.cluster.AbstractMombasaAction; +import org.smartfrog.services.cloudfarmer.client.web.forms.workflow.AbstractQueueJobActionForm; +import org.smartfrog.services.cloudfarmer.client.web.model.RemoteDaemon; +import org.smartfrog.services.cloudfarmer.client.web.model.workflow.Workflow; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/workflow/WorkflowBindToRemoteServerAction.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/workflow/WorkflowBindToRemoteServerAction.java 2010-01-11 15:45:17 UTC (rev 8127) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/workflow/WorkflowBindToRemoteServerAction.java 2010-01-11 17:25:07 UTC (rev 8128) @@ -20,10 +20,10 @@ package org.smartfrog.services.cloudfarmer.client.web.actions.workflow; -import org.smartfrog.services.cloudfarmer.client.web.model.RemoteDaemon; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; +import org.smartfrog.services.cloudfarmer.client.web.model.RemoteDaemon; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/workflow/WorkflowListAction.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/workflow/WorkflowListAction.java 2010-01-11 15:45:17 UTC (rev 8127) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/actions/workflow/WorkflowListAction.java 2010-01-11 17:25:07 UTC (rev 8128) @@ -20,11 +20,11 @@ package org.smartfrog.services.cloudfarmer.client.web.actions.workflow; -import org.smartfrog.services.cloudfarmer.client.web.model.RemoteDaemon; -import org.smartfrog.services.cloudfarmer.client.web.model.workflow.WorkflowList; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; +import org.smartfrog.services.cloudfarmer.client.web.model.RemoteDaemon; +import org.smartfrog.services.cloudfarmer.client.web.model.workflow.WorkflowList; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; Added: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/clusters/ClusterAllocationHandler.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/clusters/ClusterAllocationHandler.java (rev 0) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/clusters/ClusterAllocationHandler.java 2010-01-11 17:25:07 UTC (rev 8128) @@ -0,0 +1,217 @@ +/* (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 + +*/ +package org.smartfrog.services.cloudfarmer.client.web.clusters; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.smartfrog.services.cloudfarmer.api.LocalSmartFrogDescriptor; +import org.smartfrog.services.cloudfarmer.api.NodeDeploymentService; +import org.smartfrog.services.cloudfarmer.client.web.model.cluster.ClusterAllocationCompleted; +import org.smartfrog.services.cloudfarmer.client.web.model.cluster.ClusterController; +import org.smartfrog.services.cloudfarmer.client.web.model.cluster.DynamicSmartFrogClusterController; +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.client.web.model.cluster.RoleAllocationRequestList; +import org.smartfrog.sfcore.common.SmartFrogException; + +import java.io.IOException; + +/** + * Created 11-Jan-2010 16:01:08 + */ + +public abstract class ClusterAllocationHandler implements ClusterAllocationCompleted { + protected static final Log LOG = LogFactory.getLog(ClusterAllocationHandler.class); + protected ClusterController controller; + protected String status; + protected Throwable thrown; + + protected boolean deploymentRequired = false; + + protected ClusterAllocationHandler( + ClusterController controller) { + this.controller = controller; + } + + public String getStatus() { + return status; + } + + public Throwable getThrown() { + return thrown; + } + + public void resetThrown() { + thrown = null; + } + + public boolean isDeploymentRequired() { + return deploymentRequired; + } + + public void setDeploymentRequired(boolean deploymentRequired) { + this.deploymentRequired = deploymentRequired; + } + + /** + * {@inheritDoc} + */ + @Override + public void farmerAvailabilityFailure(boolean timedOut, long timeout, Throwable exception, Object extraData) + throws IOException, SmartFrogException { + StringBuilder text = new StringBuilder(); + text.append("Farmer is not available:\n"); + if (timedOut) { + text.append("connection timed out\n"); + } + if (exception != null) { + text.append(exception.toString()); + } + status = text.toString(); + thrown = exception; + LOG.error(status, thrown); + } + + /** + * Deploy an application to a specific host + * @param instance host instance + * @param name application name + * @param descriptor SF descriptor + * @return true if something was deployed, false if there was no deployment service up and running + * and it was not required + * @throws SmartFrogException deployment problems + * @throws IOException IO problems + */ + protected boolean deployApplication(HostInstance instance, String name, LocalSmartFrogDescriptor descriptor) + throws SmartFrogException, IOException { + try { + if(!isDeploymentSupported()) { + if (deploymentRequired) { + throw new SmartFrogException("The deployment service is not available"); + } else { + return false; + } + } + NodeDeploymentService deploymentService = createNodeDeploymentService(instance); + deploymentService.deployApplication(name, descriptor.getComponentDescription()); + return true; + } catch (Throwable e) { + logAndRethrow(e); + return false; + } + } + + + /** + * Catch, log and rethrow any exception + * @param throwable + * @throws IOException + * @throws SmartFrogException + */ + protected void logAndRethrow(Throwable throwable) throws IOException, SmartFrogException { + LOG.error(throwable); + if (throwable instanceof SmartFrogException) { + throw (SmartFrogException) throwable; + } + if (throwable instanceof IOException) { + throw (IOException) throwable; + } + throw new SmartFrogException(throwable); + } + + + /** + * Test for deployment being supported + * @return true iff deployment is supported + * @throws SmartFrogException something failed + * @throws IOException IO/RMI trouble + */ + protected boolean isDeploymentSupported() throws SmartFrogException, IOException { + if (controller instanceof DynamicSmartFrogClusterController) { + return false; + } + DynamicSmartFrogClusterController clusterController = getSfController(); + return clusterController.isFarmerAvailable() && clusterController.getFarmer().isDeploymentServiceAvailable(); + } + + /** + * Create a node deployment service + * @param instance host instance + * @return a deployment service bound to that instance + * @throws SmartFrogException problems bringing up an instance + * @throws IOException IO Problems + */ + private NodeDeploymentService createNodeDeploymentService(HostInstance instance) + throws SmartFrogException, IOException { + try { + DynamicSmartFrogClusterController sfcontroller = getSfController(); + NodeDeploymentService deploymentService = sfcontroller.createNodeDeploymentService(instance); + return deploymentService; + } catch (Throwable e) { + logAndRethrow(e); + return null; + } + } + + /** + * Get the smartfrog controller. + * @return the controller cast to an SF controller + * @throws ClassCastException if the controller is not a cloudfarmer implementation + */ + protected DynamicSmartFrogClusterController getSfController() { + return (DynamicSmartFrogClusterController) controller; + } + + /** + * {@inheritDoc} + */ + @Override + public void allocationSucceeded(RoleAllocationRequestList requests, HostInstanceList hosts, Object extraData) + throws IOException, SmartFrogException { + //this is where the cluster gets rolled out + } + + /** + * {@inheritDoc} + */ + @Override + public void allocationFailed(RoleAllocationRequestList requests, HostInstanceList hosts, Throwable failureCause, + Object extraData) throws IOException, SmartFrogException { + StringBuilder text = new StringBuilder(); + text.append("Allocation failed ").append(failureCause); + status = text.toString(); + thrown = failureCause; + LOG.error(status, thrown); + } + + /** + * Parse a SmartFrog resource. any failue is passed up + * @param resource resource to parse + * @return the parsed resource + * @throws SmartFrogException if parsing failed + */ + protected LocalSmartFrogDescriptor parseResource(String resource) throws SmartFrogException { + //load the CD -so that any binding problem shows up early + LocalSmartFrogDescriptor localApp = new LocalSmartFrogDescriptor(); + localApp.parseResource(resource); + localApp.throwParseExceptionIfNeeded(); + return localApp; + } +} Added: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/clusters/masterworker/MasterWorkerAllocationHandler.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/clusters/masterworker/MasterWorkerAllocationHandler.java (rev 0) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/clusters/masterworker/MasterWorkerAllocationHandler.java 2010-01-11 17:25:07 UTC (rev 8128) @@ -0,0 +1,150 @@ +/* (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 + +*/ +package org.smartfrog.services.cloudfarmer.client.web.clusters.masterworker; + +import org.smartfrog.services.cloudfarmer.api.LocalSmartFrogDescriptor; +import org.smartfrog.services.cloudfarmer.client.web.clusters.ClusterAllocationHandler; +import org.smartfrog.services.cloudfarmer.client.web.model.cluster.ClusterController; +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.client.web.model.cluster.RoleAllocationRequest; +import org.smartfrog.sfcore.common.SmartFrogDeploymentException; +import org.smartfrog.sfcore.common.SmartFrogException; + +import java.io.IOException; + +/** + * Created 11-Jan-2010 16:09:50 + */ + +public abstract class MasterWorkerAllocationHandler extends ClusterAllocationHandler implements MasterWorkerRoles { + protected boolean creatingMaster; + protected HostInstance master; + + protected MasterWorkerAllocationHandler(ClusterController controller) { + super(controller); + } + + public boolean isCreatingMaster() { + return creatingMaster; + } + + public void setCreatingMaster(boolean creatingMaster) { + this.creatingMaster = creatingMaster; + } + + public HostInstance getMaster() { + return master; + } + + public void setMaster(HostInstance master) { + this.master = master; + } + + /** + * This is where roles are installed + * {@inheritDoc} + */ + @Override + public void allocationRequestSucceeded(RoleAllocationRequest request, HostInstanceList newhosts) + throws IOException, SmartFrogException { + String role = request.getRole(); + if (MASTER.equals(role)) { + masterAllocationRequestSucceeded(request, newhosts); + } else if (WORKER.equals(role)) { + workerAllocationRequestSucceeded(request, newhosts); + } + } + + /** + * Bind the system properties then load the application + * @param resource resource to load + * @return a descriptor bonded to the master + * @throws IOException IO problems + * @throws SmartFrogException other problems + */ + protected LocalSmartFrogDescriptor loadSFApp(String resource) throws IOException, SmartFrogException { + ///set the binding values + bindSystemProperties(); + return parseResource(resource); + } + + + /** + * Perform any system property setup ready to load the SF application + */ + protected void bindSystemProperties() { + System.setProperty(BINDING_MASTER_HOSTNAME, master.getHostname()); + } + + /** + * Handle a master allocation request by pushing out the master configuration + * + * @param request the request that just succeeded + * @param newhosts the new hosts + * @throws IOException IO problems + * @throws SmartFrogException other problems + */ + protected void masterAllocationRequestSucceeded(RoleAllocationRequest request, HostInstanceList newhosts) + throws IOException, SmartFrogException { + master = newhosts.getMaster(); + String resource = getMasterResourceName(); + if (resource != null && !resource.isEmpty()) { + LocalSmartFrogDescriptor descriptor = loadSFApp(resource); + deployApplication(master, request.getRole(), descriptor); + } + + } + + /** + * Handle a master allocation request by pushing out the worker configuration + * + * @param request the request that just succeeded + * @param newhosts the new hosts + * @throws IOException IO problems + * @throws SmartFrogException other problems + */ + protected void workerAllocationRequestSucceeded(RoleAllocationRequest request, HostInstanceList newhosts) + throws IOException, SmartFrogException { + //we'd better have a non-null master here + if (master == null) { + throw new SmartFrogDeploymentException("Cannot bring up worker nodes without a master node"); + } + String resource = getWorkerResourceName(); + if (resource != null && !resource.isEmpty()) { + LocalSmartFrogDescriptor descriptor = loadSFApp(resource); + for (HostInstance host : newhosts) { + deployApplication(host, request.getRole(), descriptor); + } + } + } + + /** + * Get the resource to load for the master + * @return the resource or null + */ + protected abstract String getMasterResourceName(); + + /** + * Get the resource or null + * @return the resource + */ + protected abstract String getWorkerResourceName(); +} Added: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/clusters/masterworker/MasterWorkerRoles.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/clusters/masterworker/MasterWorkerRoles.java (rev 0) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/clusters/masterworker/MasterWorkerRoles.java 2010-01-11 17:25:07 UTC (rev 8128) @@ -0,0 +1,37 @@ +/* (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 + +*/ +package org.smartfrog.services.cloudfarmer.client.web.clusters.masterworker; + +/** + * Created 18-Nov-2009 16:30:13 + */ + + +public interface MasterWorkerRoles { + /** + * This is the hostname of the master, which hosts both the NN and JT binding.master.hostname PROPERTY + * binding.master.hostname; + */ + String BINDING_MASTER_HOSTNAME = "binding.master.hostname"; + /** {@value} */ + String MASTER = "master"; + /** {@value} */ + String WORKER = "worker"; +} Added: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/clusters/masterworker/hadoop/HadoopAllocationHandler.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/clusters/masterworker/hadoop/HadoopAllocationHandler.java (rev 0) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/clusters/masterworker/hadoop/HadoopAllocationHandler.java 2010-01-11 17:25:07 UTC (rev 8128) @@ -0,0 +1,76 @@ +/* (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 + +*/ +package org.smartfrog.services.cloudfarmer.client.web.clusters.masterworker.hadoop; + +import org.smartfrog.services.cloudfarmer.client.web.clusters.masterworker.MasterWorkerAllocationHandler; +import org.smartfrog.services.cloudfarmer.client.web.clusters.masterworker.hadoop.descriptions.TemplateNames; +import org.smartfrog.services.cloudfarmer.client.web.model.cluster.ClusterController; + + +/** + * Created 18-Nov-2009 15:44:39 + */ + +public class HadoopAllocationHandler extends MasterWorkerAllocationHandler implements TemplateNames { + + private int taskSlots; + + + public HadoopAllocationHandler(ClusterController controller) { + super(controller); + setDeploymentRequired(true); + } + + + public int getTaskSlots() { + return taskSlots; + } + + public void setTaskSlots(int taskSlots) { + this.taskSlots = taskSlots; + } + + + /** + * Perform any system property setup ready to load the SF application + */ + protected void bindSystemProperties() { + super.bindSystemProperties(); + System.setProperty(BINDING_TASKTRACKER_SLOTS, "" + getTaskSlots()); + } + + /** + * {@inheritDoc} + * @return the resource {@link TemplateNames#HADOOP_MASTER_SF} + */ + @Override + protected String getMasterResourceName() { + return TemplateNames.HADOOP_MASTER_SF; + } + + /** + * {@inheritDoc} + * @return the resource {@link TemplateNames#HADOOP_WORKER_SF} + */ + @Override + protected String getWorkerResourceName() { + return TemplateNames.HADOOP_WORKER_SF; + } +} Deleted: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/clusters/masterworker/hadoop/HadoopDeploymentCallback.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/hadoop/HadoopDeploymentCallback.java 2010-01-08 19:15:00 UTC (rev 8124) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/clusters/masterworker/hadoop/HadoopDeploymentCallback.java 2010-01-11 17:25:07 UTC (rev 8128) @@ -1,253 +0,0 @@ -/* (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 - -*/ -package org.smartfrog.services.cloudfarmer.client.web.hadoop; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.smartfrog.services.cloudfarmer.api.LocalSmartFrogDescriptor; -import org.smartfrog.services.cloudfarmer.api.NodeDeploymentService; -import org.smartfrog.services.cloudfarmer.client.web.hadoop.descriptions.TemplateNames; -import org.smartfrog.services.cloudfarmer.client.web.model.cluster.ClusterAllocationCompleted; -import org.smartfrog.services.cloudfarmer.client.web.model.cluster.ClusterController; -import org.smartfrog.services.cloudfarmer.client.web.model.cluster.DynamicSmartFrogClusterController; -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.client.web.model.cluster.RoleAllocationRequest; -import org.smartfrog.services.cloudfarmer.client.web.model.cluster.RoleAllocationRequestList; -import org.smartfrog.sfcore.common.SmartFrogDeploymentException; -import org.smartfrog.sfcore.common.SmartFrogException; - -import java.io.IOException; - - -/** - * Created 18-Nov-2009 15:44:39 - */ - -public class HadoopDeploymentCallback implements ClusterAllocationCompleted, HadoopRoles, TemplateNames { - - private static final Log LOG = LogFactory.getLog(HadoopDeploymentCallback.class); - private ClusterController controller; - private boolean creatingMaster; - private String status; - private Throwable thrown; - private HostInstance master; - private int taskSlots; - - - public HadoopDeploymentCallback(ClusterController controller) { - this.controller = controller; - } - - public boolean isCreatingMaster() { - return creatingMaster; - } - - public void setCreatingMaster(boolean creatingMaster) { - this.creatingMaster = creatingMaster; - } - - public HostInstance getMaster() { - return master; - } - - public void setMaster(HostInstance master) { - this.master = master; - } - - public String getStatus() { - return status; - } - - - public Throwable getThrown() { - return thrown; - } - - public void resetThrown() { - thrown = null; - } - - public int getTaskSlots() { - return taskSlots; - } - - public void setTaskSlots(int taskSlots) { - this.taskSlots = taskSlots; - } - - /** - * {@inheritDoc} - */ - @Override - public void farmerAvailabilityFailure(boolean timedOut, long timeout, Throwable exception, Object extraData) - throws IOException, SmartFrogException { - StringBuilder text = new StringBuilder(); - text.append("Farmer is not available:\n"); - if (timedOut) { - text.append("connection timed out\n"); - } - if (exception != null) { - text.append(exception.toString()); - } - status = text.toString(); - thrown = exception; - LOG.error(status, thrown); - } - - /** - * {@inheritDoc} - */ - @Override - public void allocationSucceeded(RoleAllocationRequestList requests, HostInstanceList hosts, Object extraData) - throws IOException, SmartFrogException { - //this is where the cluster gets rolled out - } - - /** - * {@inheritDoc} - */ - @Override - public void allocationFailed(RoleAllocationRequestList requests, HostInstanceList hosts, Throwable failureCause, - Object extraData) throws IOException, SmartFrogException { - StringBuilder text = new StringBuilder(); - text.append("Allocation failed ").append(failureCause); - status = text.toString(); - thrown = failureCause; - LOG.error(status, thrown); - } - - /** - * This is where roles are installed - * {@inheritDoc} - */ - @Override - public void allocationRequestSucceeded(RoleAllocationRequest request, HostInstanceList newhosts) - throws IOException, SmartFrogException { - String role = request.getRole(); - if (MASTER.equals(role)) { - masterAllocationRequestSucceeded(request, newhosts); - } else if (WORKER.equals(role)) { - workerAllocationRequestSucceeded(request, newhosts); - } - } - - /** - * Handle a master allocation request by pushing out the master configuration - * - * @param request the request that just succeeded - * @param newhosts the new hosts - * @throws IOException IO problems - * @throws SmartFrogException other problems - */ - private void masterAllocationRequestSucceeded(RoleAllocationRequest request, HostInstanceList newhosts) - throws IOException, SmartFrogException { - master = newhosts.getMaster(); - LocalSmartFrogDescriptor descriptor = loadSFApp(HADOOP_MASTER_SF); - deployApplication(master, request.getRole(), descriptor); - - } - - /** - * Handle a master allocation request by pushing out the worker configuration - * - * @param request the request that just succeeded - * @param newhosts the new hosts - * @throws IOException IO problems - * @throws SmartFrogException other problems - */ - private void workerAllocationRequestSucceeded(RoleAllocationRequest request, HostInstanceList newhosts) - throws IOException, SmartFrogException { - //we'd better have a non-null master here - if (master == null) { - throw new SmartFrogDeploymentException("Cannot bring up worker nodes without a master node"); - } - LocalSmartFrogDescriptor descriptor = loadSFApp(HADOOP_MASTER_SF); - for (HostInstance host:newhosts) { - deployApplication(host, request.getRole(), descriptor); - } - } - - /** - * Deploy an application to a specific host - * @param instance host instance - * @param name application name - * @param descriptor SF descriptor - * @throws SmartFrogException deployment problems - * @throws IOException IO problems - */ - private void deployApplication(HostInstance instance, String name, LocalSmartFrogDescriptor descriptor) - throws SmartFrogException, IOException { - try { - NodeDeploymentService deploymentService = createNodeDeploymentService(instance); - deploymentService.deployApplication(name, descriptor.getComponentDescription()); - } catch (SmartFrogException e) { - LOG.error(e); - throw e; - } catch (IOException e) { - LOG.error(e); - throw e; - } catch (Throwable e) { - LOG.error(e); - throw new SmartFrogException(e); - } - - } - - /** - * Create a node deployment service - * @param instance host instance - * @return a deployment service bound to that instance - * @throws SmartFrogException problems bringing up an instance - * @throws IOException IO Problems - */ - private NodeDeploymentService createNodeDeploymentService(HostInstance instance) - throws SmartFrogException, IOException { - try { - DynamicSmartFrogClusterController sfcontroller = (DynamicSmartFrogClusterController) controller; - NodeDeploymentService deploymentService = sfcontroller.createNodeDeploymentService(instance); - return deploymentService; - } catch (SmartFrogException e) { - LOG.error(e); - throw e; - } catch (IOException e) { - LOG.error(e); - throw e; - } - } - - /** - * @param resource resource to load - * @return a descriptor bonded to the master - * @throws IOException IO problems - * @throws SmartFrogException other problems - */ - protected LocalSmartFrogDescriptor loadSFApp(String resource) throws IOException, SmartFrogException { - ///set the binding values - System.setProperty(BINDING_MASTER_HOSTNAME, master.getHostname()); - System.setProperty(BINDING_TASKTRACKER_SLOTS, "" + getTaskSlots()); - - //load the CD -so that any binding problem shows up early - LocalSmartFrogDescriptor localApp = new LocalSmartFrogDescriptor(); - localApp.parseResource(resource); - localApp.throwParseExceptionIfNeeded(); - return localApp; - } -} Deleted: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/clusters/masterworker/hadoop/HadoopRoles.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/hadoop/HadoopRoles.java 2010-01-08 19:15:00 UTC (rev 8124) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/clusters/masterworker/hadoop/HadoopRoles.java 2010-01-11 17:25:07 UTC (rev 8128) @@ -1,32 +0,0 @@ -/* (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 - -*/ -package org.smartfrog.services.cloudfarmer.client.web.hadoop; - -/** - * Created 18-Nov-2009 16:30:13 - */ - - -public interface HadoopRoles { - /** {@value} */ - String MASTER = "master"; - /** {@value} */ - String WORKER = "worker"; -} Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/clusters/masterworker/hadoop/descriptions/TemplateNames.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/hadoop/descriptions/TemplateNames.java 2010-01-08 19:15:00 UTC (rev 8124) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/clusters/masterworker/hadoop/descriptions/TemplateNames.java 2010-01-11 17:25:07 UTC (rev 8128) @@ -20,20 +20,18 @@ -package org.smartfrog.services.cloudfarmer.client.web.hadoop.descriptions; +package org.smartfrog.services.cloudfarmer.client.web.clusters.masterworker.hadoop.descriptions; +import org.smartfrog.services.cloudfarmer.client.web.clusters.masterworker.MasterWorkerRoles; + /** * Define the names of various resource templates. These are all things to deploy And the properties to set */ -public interface TemplateNames { +public interface TemplateNames extends MasterWorkerRoles { - /** - * This is the hostname of the master, which hosts both the NN and JT binding.master.hostname PROPERTY - * binding.master.hostname; - */ - String BINDING_MASTER_HOSTNAME = "binding.master.hostname"; + /** * The number of slots for a tasktracker binding.tasktracker.slots IPROPERTY binding.tasktracker.slots; @@ -75,5 +73,8 @@ */ String FARMER_PATH = "farmer"; + /** + * Default # of task slots in a cluster, {@value} + */ int TASK_SLOTS = 4; } Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/forms/AbstractMombasaActionForm.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/forms/AbstractMombasaActionForm.java 2010-01-11 15:45:17 UTC (rev 8127) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/forms/AbstractMombasaActionForm.java 2010-01-11 17:25:07 UTC (rev 8128) @@ -20,13 +20,13 @@ package org.smartfrog.services.cloudfarmer.client.web.forms; -import org.smartfrog.services.cloudfarmer.client.web.forms.cluster.AttributeNames; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMessage; import org.apache.struts.upload.FormFile; +import org.smartfrog.services.cloudfarmer.client.web.forms.cluster.AttributeNames; public abstract class AbstractMombasaActionForm extends ActionForm implements AttributeNames { protected final Log log = LogFactory.getLog("org.smartfrog.services.cloudfarmer.client.web.action." + getActionName()); Modified: trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/forms/cluster/ClusterAddDynamicForm.java =================================================================== --- trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/forms/cluster/ClusterAddDynamicForm.java 2010-01-11 15:45:17 UTC (rev 8127) +++ trunk/core/components/cloudfarmer/src/org/smartfrog/services/cloudfarmer/client/web/forms/cluster/ClusterAddDynamicForm.java 2010-01-11 17:25:07 UTC (rev 8128) @@ -21,16 +21,16 @@ package org.smartfrog.services.cloudfarmer.client.web.forms.cluster; -import org.smartfrog.services.cloudfarmer.client.web.model.cluster.ClusterController; -import org.smartfrog.services.cloudfarmer.client.web.forms.AbstractMombasaActionForm; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionMapping; import org.smartfrog.services.cloudfarmer.client.web.actions.cluster.AbstractClusterAction; +import org.smartfrog.services.cloudfarmer.client.web.forms.AbstractMombasaActionForm; +import org.smartfrog.services.cloudfarmer.client.web.model.cluster.ClusterController; import javax.servlet.http.HttpServletRequest; /** - * @author slo + * Form for adding a node on a dynamic cluster */ public class ClusterAddDynamicForm extends AbstractMombasaActio... [truncated message content] |
From: <st...@us...> - 2010-01-12 12:48:56
|
Revision: 8132 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=8132&view=rev Author: steve_l Date: 2010-01-12 12:48:43 +0000 (Tue, 12 Jan 2010) Log Message: ----------- SFOS-1408 moving the ec2 build file bits Modified Paths: -------------- trunk/core/components/cloudfarmer/build.xml trunk/core/components/ec2/build.xml trunk/core/components/ec2/src/org/smartfrog/services/cloudfarmer/server/ec2/EC2ClusterFarmerImpl.java Modified: trunk/core/components/cloudfarmer/build.xml =================================================================== --- trunk/core/components/cloudfarmer/build.xml 2010-01-12 12:47:33 UTC (rev 8131) +++ trunk/core/components/cloudfarmer/build.xml 2010-01-12 12:48:43 UTC (rev 8132) @@ -84,12 +84,6 @@ <target name="ready-to-test" depends="common.ready-to-test"> <echo level="verbose"> - test.ec2.enabled=${test.ec2.enabled} - test.ec2.instances.enabled=${test.ec2.instances.enabled} - test.ec2.farmer.enabled=${test.ec2.farmer.enabled} - test.s3.enabled=${test.s3.enabled} - - test.awsid=${test.awsid} system.tests=${system.tests} </echo> </target> @@ -138,13 +132,6 @@ </deploy> </target> - <target name="ec2farmer" depends="ready-to-deploy" - description="Deploy an EC2 farmer" > - <deploy> - <application name="farmer" - descriptor="/org/smartfrog/services/cloudfarmer/server/examples/ec2_hadoop_farmer.sf"/> - </deploy> - </target> <target name="forkedcluster" depends="ready-to-deploy" description="Deploy a forked Hadoop cluster against a local farmer" > Modified: trunk/core/components/ec2/build.xml =================================================================== --- trunk/core/components/ec2/build.xml 2010-01-12 12:47:33 UTC (rev 8131) +++ trunk/core/components/ec2/build.xml 2010-01-12 12:48:43 UTC (rev 8132) @@ -90,6 +90,14 @@ Not found: ${test.testwar.war} </fail> </target> - + <target name="ec2farmer" depends="ready-to-deploy" + description="Deploy an EC2 farmer" > + <deploy> + <application name="farmer" + descriptor="/org/smartfrog/services/cloudfarmer/server/examples/ec2_hadoop_farmer.sf"/> + </deploy> + </target> + + </project> \ No newline at end of file Modified: trunk/core/components/ec2/src/org/smartfrog/services/cloudfarmer/server/ec2/EC2ClusterFarmerImpl.java =================================================================== --- trunk/core/components/ec2/src/org/smartfrog/services/cloudfarmer/server/ec2/EC2ClusterFarmerImpl.java 2010-01-12 12:47:33 UTC (rev 8131) +++ trunk/core/components/ec2/src/org/smartfrog/services/cloudfarmer/server/ec2/EC2ClusterFarmerImpl.java 2010-01-12 12:48:43 UTC (rev 8132) @@ -28,12 +28,12 @@ import org.smartfrog.services.cloudfarmer.api.ClusterNode; import org.smartfrog.services.cloudfarmer.api.ClusterRoleInfo; import org.smartfrog.services.cloudfarmer.api.NoClusterSpaceException; +import org.smartfrog.services.cloudfarmer.api.NodeDeploymentService; import org.smartfrog.services.cloudfarmer.api.NodeDeploymentServiceFactory; -import org.smartfrog.services.cloudfarmer.api.NodeDeploymentService; import org.smartfrog.services.cloudfarmer.server.common.ClusterFarmerUtils; +import org.smartfrog.sfcore.common.SmartFrogDeploymentException; import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.common.SmartFrogResolutionException; -import org.smartfrog.sfcore.common.SmartFrogDeploymentException; import org.smartfrog.sfcore.prim.Prim; import org.smartfrog.sfcore.reference.Reference; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2010-01-18 15:49:05
|
Revision: 8149 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=8149&view=rev Author: steve_l Date: 2010-01-18 15:48:59 +0000 (Mon, 18 Jan 2010) Log Message: ----------- SFOS-1413 rpm not building. Better exclusion of Avro's dependencies. Modified Paths: -------------- trunk/core/components/hadoop/ivy.xml trunk/core/components/libraries.properties Modified: trunk/core/components/hadoop/ivy.xml =================================================================== --- trunk/core/components/hadoop/ivy.xml 2010-01-18 14:45:53 UTC (rev 8148) +++ trunk/core/components/hadoop/ivy.xml 2010-01-18 15:48:59 UTC (rev 8149) @@ -117,6 +117,8 @@ conf="hadoop-core->default"> <exclude org="org.mortbay.jetty"/> <exclude org="net.sf.kosmosfs"/> + <exclude org="com.thoughtworks.paranamer"/> + <exclude org="org.slf4j"/> </dependency> <dependency org="org.apache.hadoop" name="hadoop-hdfs" @@ -125,6 +127,8 @@ conf="hadoop-core->default"> <exclude org="org.mortbay.jetty"/> <exclude org="net.sf.kosmosfs"/> + <exclude org="com.thoughtworks.paranamer"/> + <exclude org="org.slf4j"/> </dependency> <dependency org="org.apache.hadoop" name="hadoop-mapred" @@ -133,6 +137,8 @@ conf="hadoop-core->default"> <exclude org="org.mortbay.jetty"/> <exclude org="net.sf.kosmosfs"/> + <exclude org="com.thoughtworks.paranamer"/> + <exclude org="org.slf4j"/> </dependency> <!-- client CLI. May also be used on the server to pass stuff to forked processes--> @@ -153,7 +159,11 @@ <dependency org="org.apache.hadoop" name="avro" rev="${avro.version}" - conf="redist->default"/> + conf="redist->default"> + <exclude org="com.thoughtworks.paranamer" /> + <exclude org="org.slf4j"/> + <exclude org="org.mortbay.jetty"/> + </dependency> <!-- used in Configuration now--> <dependency org="org.codehaus.jackson" name="jackson-mapper-asl" Modified: trunk/core/components/libraries.properties =================================================================== --- trunk/core/components/libraries.properties 2010-01-18 14:45:53 UTC (rev 8148) +++ trunk/core/components/libraries.properties 2010-01-18 15:48:59 UTC (rev 8149) @@ -69,7 +69,7 @@ rome.version=0.9 quartz.version=1.5.2 servletapi.version=2.5 -slf4j.version=1.5.2 +slf4j.version=1.5.8 smack.version=2.2.1 stax.version=1.2.0 stax-api.version=1.0.1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |