virtualcommons-svn Mailing List for Virtual Commons Experiment Software (Page 80)
Status: Beta
Brought to you by:
alllee
You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
(21) |
Aug
(31) |
Sep
(6) |
Oct
(15) |
Nov
(2) |
Dec
(9) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(4) |
Feb
(6) |
Mar
(12) |
Apr
(52) |
May
(14) |
Jun
(19) |
Jul
(81) |
Aug
(115) |
Sep
(36) |
Oct
(88) |
Nov
(46) |
Dec
(58) |
2010 |
Jan
(52) |
Feb
(55) |
Mar
(48) |
Apr
(15) |
May
(5) |
Jun
(38) |
Jul
(27) |
Aug
(24) |
Sep
(28) |
Oct
(1) |
Nov
(2) |
Dec
(29) |
2011 |
Jan
(87) |
Feb
(39) |
Mar
(63) |
Apr
(42) |
May
(26) |
Jun
(53) |
Jul
(23) |
Aug
(43) |
Sep
(37) |
Oct
(25) |
Nov
(4) |
Dec
(7) |
2012 |
Jan
(73) |
Feb
(79) |
Mar
(62) |
Apr
(28) |
May
(12) |
Jun
(2) |
Jul
(9) |
Aug
(1) |
Sep
(8) |
Oct
|
Nov
(3) |
Dec
(3) |
2013 |
Jan
(8) |
Feb
(16) |
Mar
(38) |
Apr
(74) |
May
(62) |
Jun
(15) |
Jul
(49) |
Aug
(19) |
Sep
(9) |
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(25) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <al...@us...> - 2008-07-26 05:19:06
|
Revision: 7 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=7&view=rev Author: alllee Date: 2008-07-26 05:19:15 +0000 (Sat, 26 Jul 2008) Log Message: ----------- removing last references to csan Modified Paths: -------------- foraging/trunk/build.properties.example Modified: foraging/trunk/build.properties.example =================================================================== --- foraging/trunk/build.properties.example 2008-07-25 23:47:59 UTC (rev 6) +++ foraging/trunk/build.properties.example 2008-07-26 05:19:15 UTC (rev 7) @@ -5,15 +5,16 @@ # the experiment server. server.address=libai.la.asu.edu -# the absolute path of where you would like to deploy the csan 2d files +# the absolute path of where you would like to deploy the experiment JNLP and +# jar files # (should be accessible / mounted by the webserver) -web.dir=/var/www/html/csan/ +web.dir=/var/www/html/foraging/ -# The URL that maps to the path above. If you don't mind using csan as part -# of the URL you can just set the server.url and leave this property blank -# since the build.xml that loads this properties file sets the codebase url to -# the ${server.url} + "/csan" by default. -codebase.url=http://libai.la.asu.edu/csan +# The URL that maps to the path above. If you don't mind using "foraging" as +# part of the URL you can just set the server.address and leave this property +# blank since the build.xml that loads this properties file sets the codebase +# url to the ${server.address} + "/foraging" by default. +codebase.url=http://libai.la.asu.edu/foraging # set to whatever port you want the Java experiment server to run on (this is # *not* the webserver port, this is the experiment server port used to This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@as...> - 2008-07-26 00:29:26
|
Author: alllee Date: Fri Jul 25 17:29:54 2008 New Revision: 7 Modified: foraging/trunk/build.properties.example Log: removing last few references to csan Modified: foraging/trunk/build.properties.example ============================================================================== --- foraging/trunk/build.properties.example (original) +++ foraging/trunk/build.properties.example Fri Jul 25 17:29:54 2008 @@ -7,13 +7,13 @@ # the absolute path of where you would like to deploy the csan 2d files # (should be accessible / mounted by the webserver) -web.dir=/var/www/html/csan/ +web.dir=/var/www/html/foraging/ # The URL that maps to the path above. If you don't mind using csan as part # of the URL you can just set the server.url and leave this property blank # since the build.xml that loads this properties file sets the codebase url to # the ${server.url} + "/csan" by default. -codebase.url=http://libai.la.asu.edu/csan +codebase.url=http://libai.la.asu.edu/foraging # set to whatever port you want the Java experiment server to run on (this is # *not* the webserver port, this is the experiment server port used to |
Author: alllee Date: Fri Jul 25 16:47:59 2008 New Revision: 6 Modified: csidex/trunk/pom.xml csidex/trunk/src/main/java/edu/asu/commons/experiment/Persister.java foraging/trunk/build.properties.example foraging/trunk/build.xml foraging/trunk/src/main/resources/configuration/asu-experiments/2d-abstract/round0.xml foraging/trunk/src/main/resources/configuration/asu-experiments/2d-abstract/server.xml foraging/trunk/src/main/resources/configuration/asu-experiments/2d-forestry/round0.xml foraging/trunk/src/main/resources/configuration/asu-experiments/2d-forestry/server.xml foraging/trunk/src/main/resources/configuration/asu-experiments/abstract-2d/round0.xml foraging/trunk/src/main/resources/configuration/asu-experiments/abstract-2d/server.xml foraging/trunk/src/main/resources/configuration/asu-experiments/forestry-2d/round0.xml foraging/trunk/src/main/resources/configuration/asu-experiments/forestry-2d/server.xml foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/server.xml foraging/trunk/src/main/resources/configuration/indiana-experiments/round0.xml foraging/trunk/src/main/resources/configuration/indiana-experiments/server.xml foraging/trunk/src/main/resources/configuration/round0.xml foraging/trunk/src/main/resources/configuration/server.xml foraging/trunk/src/main/resources/web/index.html Log: fixing csidex pom default references to maven changing SERVER_URL to SERVER_ADDRESS, need to propagate to documentation Modified: csidex/trunk/pom.xml ============================================================================== --- csidex/trunk/pom.xml (original) +++ csidex/trunk/pom.xml Fri Jul 25 16:47:59 2008 @@ -20,9 +20,9 @@ </repository> </repositories> <packaging>jar</packaging> - <version>1.0-SNAPSHOT</version> + <version>0.1</version> <name>csidex</name> - <url>http://maven.apache.org</url> + <url>http://commons.asu.edu/csidex</url> <dependencies> <dependency> <groupId>junit</groupId> @@ -53,5 +53,4 @@ </plugin> </plugins> </build> - </project> Modified: csidex/trunk/src/main/java/edu/asu/commons/experiment/Persister.java ============================================================================== --- csidex/trunk/src/main/java/edu/asu/commons/experiment/Persister.java (original) +++ csidex/trunk/src/main/java/edu/asu/commons/experiment/Persister.java Fri Jul 25 16:47:59 2008 @@ -52,8 +52,6 @@ // private final XStream xstream = new XStream(); // private PrintWriter xmlPrintWriter; - - private XmlSet xmlSet; private boolean xmlEnabled; // private boolean usingEventChannel; Modified: foraging/trunk/build.properties.example ============================================================================== --- foraging/trunk/build.properties.example (original) +++ foraging/trunk/build.properties.example Fri Jul 25 16:47:59 2008 @@ -3,7 +3,7 @@ # server name, set this to the IP address or domain name that will be running # the experiment server. -server.url=csid.asu.edu +server.address=libai.la.asu.edu # the absolute path of where you would like to deploy the csan 2d files # (should be accessible / mounted by the webserver) Modified: foraging/trunk/build.xml ============================================================================== --- foraging/trunk/build.xml (original) +++ foraging/trunk/build.xml Fri Jul 25 16:47:59 2008 @@ -60,10 +60,11 @@ <property name='web.dir' value='/var/www/carllab/${ant.project.name}'/> <property name='server.port' value='16001'/> <property name='server.xml' value='server.xml'/> - <property name='codebase.url' value='http://${server.url}/${ant.project.name}'/> + <property name='codebase.url' value='http://${server.address}/${ant.project.name}'/> <property name='client.class' value='edu.asu.commons.foraging.client.ForagingClient'/> <property name='facilitator.class' value='edu.asu.commons.foraging.facilitator.Facilitator'/> <property name='server.class' value='edu.asu.commons.foraging.server.ForagingServer'/> + <property name='framework.jar' value='csidex.jar'/> <property name='dist.dir' value='dist' /> @@ -77,7 +78,7 @@ <property name="javadoc.dir" value="docs/javadoc"/> <property name="javadoc.private.dir" value="docs/private"/> - <property name='lib.dir' value='lib'/> + <property name='lib.dir' value='lib/default'/> <!-- Set up the CLASSPATH, includes all jars in the lib directory and all built files for both the main project @@ -95,12 +96,12 @@ <target name="help"> <echo> NOTE: At minimum you will need to modify the default web.dir and - server.url properties in the build.properties file before invoking deploy + server.address properties in the build.properties file before invoking deploy or build-all. Currently deploying to ${web.dir} with a web address of ${codebase.url}. - Experiment server will start on ${server.url}, listening on port ${server.port}. + Experiment server will start on ${server.address}, listening on port ${server.port}. Available targets: compile - Compile all the source code and tests. @@ -127,27 +128,32 @@ <include name='facilitator.jar'/> </fileset> <fileset dir='${lib.dir}'> - <include name='csidex.jar'/> + <include name='${framework.jar}'/> + </fileset> + <fileset dir='${resources.dir}/web'> + <include name='index.html'/> </fileset> </copy> <!-- copy images --> <copy todir='${web.dir}/images' overwrite='true'> - <fileset dir='images'/> + <fileset dir='${resources.dir}/images'/> </copy> <!-- copy client and facilitator JNLP descriptor files, replacing url/main class tokens. --> - <copy file='web/client.jnlp' todir='${web.dir}' overwrite='true'> + <copy file='${resources.dir}/web/client.jnlp' todir='${web.dir}' overwrite='true'> <filterset> <filter token='CODEBASE_URL' value='${codebase.url}'/> <filter token='MAIN_CLASS' value='${client.class}'/> + <filter token='FRAMEWORK_JAR' value='${framework.jar}'/> </filterset> </copy> - <copy file='web/facilitator.jnlp' todir='${web.dir}' overwrite='true'> + <copy file='${resources.dir}/web/facilitator.jnlp' todir='${web.dir}' overwrite='true'> <filterset> <filter token='CODEBASE_URL' value='${codebase.url}'/> <filter token='MAIN_CLASS' value='${facilitator.class}'/> + <filter token='FRAMEWORK_JAR' value='${framework.jar}'/> </filterset> </copy> <chmod dir='${web.dir}' perm='664' type='file' includes='**'/> @@ -198,7 +204,7 @@ <chmod file='${dist.dir}/${jar.name}' perm='664'/> </target> <!-- Prepare for a build by creating appropriate directories --> - <target name="prepare" depends='clean, resolve'> + <target name="prepare" depends='resolve'> <mkdir dir="${build.dir}"/> <mkdir dir="${test.build.dir}"/> <mkdir dir='${dist.dir}'/> @@ -209,6 +215,8 @@ <delete dir="${build.dir}"/> <delete dir="${test.build.dir}"/> <delete dir='${dist.dir}'/> + <delete file='server.jar'/> + </target> <!-- Compile project source files --> @@ -226,7 +234,7 @@ <copy todir='${build.dir}/conf'> <fileset dir='${conf.dir}'/> <filterset> - <filter token='SERVER_URL' value='${server.url}'/> + <filter token='SERVER_ADDRESS' value='${server.address}'/> <filter token='PORT_NUMBER' value='${server.port}'/> <filter token='CODEBASE_URL' value='${codebase.url}'/> </filterset> Modified: foraging/trunk/src/main/resources/configuration/asu-experiments/2d-abstract/round0.xml ============================================================================== --- foraging/trunk/src/main/resources/configuration/asu-experiments/2d-abstract/round0.xml (original) +++ foraging/trunk/src/main/resources/configuration/asu-experiments/2d-abstract/round0.xml Fri Jul 25 16:47:59 2008 @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="resource-width">14</entry> <entry key="resource-depth">14</entry> @@ -112,7 +112,7 @@ </entry> <entry key="welcome-instructions"> <![CDATA[ -<h3>Welcome to the CARL Lab</h3> +<h3>Welcome</h3> <p> Welcome. You have already earned 5 dollars for showing up at this experiment. You can earn more, up to a maximum of 40 dollars, by participating in this Modified: foraging/trunk/src/main/resources/configuration/asu-experiments/2d-abstract/server.xml ============================================================================== --- foraging/trunk/src/main/resources/configuration/asu-experiments/2d-abstract/server.xml (original) +++ foraging/trunk/src/main/resources/configuration/asu-experiments/2d-abstract/server.xml Fri Jul 25 16:47:59 2008 @@ -2,7 +2,7 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> <comment>CSAN XML-ized experiment round configuration</comment> -<entry key="hostname">@SERVER_URL@</entry> +<entry key="hostname">@SERVER_ADDRESS@</entry> <entry key="port">@PORT_NUMBER@</entry> <entry key="round0">round0.xml</entry> <entry key="round1">round1.xml</entry> Modified: foraging/trunk/src/main/resources/configuration/asu-experiments/2d-forestry/round0.xml ============================================================================== --- foraging/trunk/src/main/resources/configuration/asu-experiments/2d-forestry/round0.xml (original) +++ foraging/trunk/src/main/resources/configuration/asu-experiments/2d-forestry/round0.xml Fri Jul 25 16:47:59 2008 @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="resource-width">14</entry> <entry key="resource-depth">14</entry> @@ -112,7 +112,7 @@ </entry> <entry key="welcome-instructions"> <![CDATA[ -<h3>Welcome to the CARL Lab</h3> +<h3>Welcome</h3> <p> Welcome. You have already earned 5 dollars for showing up at this experiment. You can earn more, up to a maximum of 40 dollars, by participating in this Modified: foraging/trunk/src/main/resources/configuration/asu-experiments/2d-forestry/server.xml ============================================================================== --- foraging/trunk/src/main/resources/configuration/asu-experiments/2d-forestry/server.xml (original) +++ foraging/trunk/src/main/resources/configuration/asu-experiments/2d-forestry/server.xml Fri Jul 25 16:47:59 2008 @@ -2,7 +2,7 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> <comment>CSAN XML-ized experiment round configuration</comment> -<entry key="hostname">@SERVER_URL@</entry> +<entry key="hostname">@SERVER_ADDRESS@</entry> <entry key="port">@PORT_NUMBER@</entry> <entry key="round0">round0.xml</entry> <entry key="round1">round1.xml</entry> Modified: foraging/trunk/src/main/resources/configuration/asu-experiments/abstract-2d/round0.xml ============================================================================== --- foraging/trunk/src/main/resources/configuration/asu-experiments/abstract-2d/round0.xml (original) +++ foraging/trunk/src/main/resources/configuration/asu-experiments/abstract-2d/round0.xml Fri Jul 25 16:47:59 2008 @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="practice-round">true</entry> <entry key='resource-width'>8</entry> <entry key='resource-depth'>8</entry> @@ -96,7 +96,7 @@ <entry key="welcome-instructions"> <![CDATA[ -<h3>Welcome to the CARL Lab</h3> +<h3>Welcome</h3> <p> Welcome. You have already earned 5 dollars for showing up at this experiment. You can earn more, up to a maximum of 40 dollars, by participating in this Modified: foraging/trunk/src/main/resources/configuration/asu-experiments/abstract-2d/server.xml ============================================================================== --- foraging/trunk/src/main/resources/configuration/asu-experiments/abstract-2d/server.xml (original) +++ foraging/trunk/src/main/resources/configuration/asu-experiments/abstract-2d/server.xml Fri Jul 25 16:47:59 2008 @@ -2,7 +2,7 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> <comment>CSAN XML-ized experiment round configuration</comment> -<entry key="hostname">@SERVER_URL@</entry> +<entry key="hostname">@SERVER_ADDRESS@</entry> <entry key="port">@PORT_NUMBER@</entry> <entry key="round0">round0.xml</entry> <entry key="round1">round1.xml</entry> Modified: foraging/trunk/src/main/resources/configuration/asu-experiments/forestry-2d/round0.xml ============================================================================== --- foraging/trunk/src/main/resources/configuration/asu-experiments/forestry-2d/round0.xml (original) +++ foraging/trunk/src/main/resources/configuration/asu-experiments/forestry-2d/round0.xml Fri Jul 25 16:47:59 2008 @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="practice-round">true</entry> <entry key='resource-width'>8</entry> <entry key='resource-depth'>8</entry> @@ -95,7 +95,7 @@ <entry key="welcome-instructions"> <![CDATA[ -<h3>Welcome to the CARL Lab</h3> +<h3>Welcome</h3> <p> Welcome. You have already earned 5 dollars for showing up at this experiment. You can earn more, up to a maximum of 40 dollars, by participating in this Modified: foraging/trunk/src/main/resources/configuration/asu-experiments/forestry-2d/server.xml ============================================================================== --- foraging/trunk/src/main/resources/configuration/asu-experiments/forestry-2d/server.xml (original) +++ foraging/trunk/src/main/resources/configuration/asu-experiments/forestry-2d/server.xml Fri Jul 25 16:47:59 2008 @@ -2,7 +2,7 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> <comment>CSAN XML-ized experiment round configuration</comment> -<entry key="hostname">@SERVER_URL@</entry> +<entry key="hostname">@SERVER_ADDRESS@</entry> <entry key="port">@PORT_NUMBER@</entry> <entry key="round0">round0.xml</entry> <entry key="round1">round1.xml</entry> Modified: foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/server.xml ============================================================================== --- foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/server.xml (original) +++ foraging/trunk/src/main/resources/configuration/indiana-experiments/chat-sanction-open-access/server.xml Fri Jul 25 16:47:59 2008 @@ -2,7 +2,7 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> <comment>Costly Sanctioning XML-ized experiment round configuration</comment> -<entry key="hostname">@SERVER_URL@</entry> +<entry key="hostname">@SERVER_ADDRESS@</entry> <entry key="port">@PORT_NUMBER@</entry> <entry key="round0">round0.xml</entry> <entry key="round1">round1.xml</entry> Modified: foraging/trunk/src/main/resources/configuration/indiana-experiments/round0.xml ============================================================================== --- foraging/trunk/src/main/resources/configuration/indiana-experiments/round0.xml (original) +++ foraging/trunk/src/main/resources/configuration/indiana-experiments/round0.xml Fri Jul 25 16:47:59 2008 @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="resource-width">13</entry> <entry key="resource-depth">13</entry> <entry key="practice-round">true</entry> @@ -108,7 +108,7 @@ </entry> <entry key="welcome-instructions"> <![CDATA[ -<h3>Welcome to the CARL Lab</h3> +<h3>Welcome</h3> <p> Welcome. You have already earned 5 dollars for showing up at this experiment. You can earn more, up to a maximum of 40 dollars, by participating in this Modified: foraging/trunk/src/main/resources/configuration/indiana-experiments/server.xml ============================================================================== --- foraging/trunk/src/main/resources/configuration/indiana-experiments/server.xml (original) +++ foraging/trunk/src/main/resources/configuration/indiana-experiments/server.xml Fri Jul 25 16:47:59 2008 @@ -2,7 +2,7 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> <comment>Costly Sanctioning XML-ized experiment round configuration</comment> -<entry key="hostname">@SERVER_URL@</entry> +<entry key="hostname">@SERVER_ADDRESS@</entry> <entry key="port">@PORT_NUMBER@</entry> <entry key="round0">round0.xml</entry> <entry key="round1">round1.xml</entry> Modified: foraging/trunk/src/main/resources/configuration/round0.xml ============================================================================== --- foraging/trunk/src/main/resources/configuration/round0.xml (original) +++ foraging/trunk/src/main/resources/configuration/round0.xml Fri Jul 25 16:47:59 2008 @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> -<comment>CSAN XML-ized experiment round configuration</comment> +<comment>Foraging XML-ized experiment round configuration</comment> <entry key="resource-width">14</entry> <entry key="resource-depth">14</entry> @@ -112,7 +112,7 @@ </entry> <entry key="welcome-instructions"> <![CDATA[ -<h3>Welcome to the CARL Lab</h3> +<h3>Welcome</h3> <p> Welcome. You have already earned 5 dollars for showing up at this experiment. You can earn more, up to a maximum of 40 dollars, by participating in this Modified: foraging/trunk/src/main/resources/configuration/server.xml ============================================================================== --- foraging/trunk/src/main/resources/configuration/server.xml (original) +++ foraging/trunk/src/main/resources/configuration/server.xml Fri Jul 25 16:47:59 2008 @@ -2,7 +2,7 @@ <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> <comment>CSAN XML-ized experiment round configuration</comment> -<entry key="hostname">@SERVER_URL@</entry> +<entry key="hostname">@SERVER_ADDRESS@</entry> <entry key="port">@PORT_NUMBER@</entry> <entry key="round0">round0.xml</entry> <entry key="round1">round1.xml</entry> Modified: foraging/trunk/src/main/resources/web/index.html ============================================================================== --- foraging/trunk/src/main/resources/web/index.html (original) +++ foraging/trunk/src/main/resources/web/index.html Fri Jul 25 16:47:59 2008 @@ -1,7 +1,7 @@ <html> <head> <META HTTP-EQUIV="Refresh" CONTENT="5;URL=client.jnlp"> -<title>CARL Experiment</title> +<title>Virtual Commons Experiment Client</title> </head> <body> <p> |
From: <al...@as...> - 2008-07-25 23:01:27
|
Author: alllee Date: Fri Jul 25 16:01:53 2008 New Revision: 5 Added: foraging/trunk/src/main/resources/web/ foraging/trunk/src/main/resources/web/client.jnlp foraging/trunk/src/main/resources/web/facilitator.jnlp foraging/trunk/src/main/resources/web/index.html Log: foraging web resources/JNLP files Added: foraging/trunk/src/main/resources/web/client.jnlp ============================================================================== --- (empty file) +++ foraging/trunk/src/main/resources/web/client.jnlp Fri Jul 25 16:01:53 2008 @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- JNLP File for CSAN 2D Client --> +<jnlp spec="1.6+" codebase="@CODEBASE_URL@" href="client.jnlp"> + <information> + <title>Virtual Commons Experiment</title> + <vendor>The Virtual Commons, Center for the Study of Institutional Diversity, School of Human Evolution and Social Change, Dr. Marco Janssen, Allen Lee, Deepali Bhagvat</vendor> + <homepage href="http://commons.asu.edu"/> + <description>An experiment brought to you courtesy of The Virtual Commons - http://commons.asu.edu</description> + </information> + <offline-allowed /> + <resources> + <j2se version="1.6+"/> + <jar href="client.jar"/> + <jar href='@FRAMEWORK_JAR@'/> + <property name="sun.java2d.noddraw" value="true"/> + <extension name="jogl" href="http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl.jnlp"/> + </resources> + <application-desc main-class="@MAIN_CLASS@"/> +</jnlp> + Added: foraging/trunk/src/main/resources/web/facilitator.jnlp ============================================================================== --- (empty file) +++ foraging/trunk/src/main/resources/web/facilitator.jnlp Fri Jul 25 16:01:53 2008 @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- JNLP File for CSAN 2D Facilitator --> +<jnlp spec="1.6+" codebase="@CODEBASE_URL@" href="facilitator.jnlp"> + <information> + <title>Virtual Commons Experiment</title> + <vendor>The Virtual Commons, Center for the Study of Institutional Diversity, School of Human Evolution and Social Change, Dr. Marco Janssen, Allen Lee, Deepali Bhagvat</vendor> + <homepage href="http://commons.asu.edu"/> + <description>Foraging 2D facilitator interface to control the Foraging 2D experiment.</description> + <icon href="commons.gif"/> + </information> + <offline-allowed /> + <resources> + <j2se version="1.6+"/> + <jar href="facilitator.jar"/> + <jar href='@FRAMEWORK_JAR@'/> + </resources> + <application-desc main-class="@MAIN_CLASS@"/> +</jnlp> + Added: foraging/trunk/src/main/resources/web/index.html ============================================================================== --- (empty file) +++ foraging/trunk/src/main/resources/web/index.html Fri Jul 25 16:01:53 2008 @@ -0,0 +1,13 @@ +<html> +<head> +<META HTTP-EQUIV="Refresh" CONTENT="5;URL=client.jnlp"> +<title>CARL Experiment</title> +</head> +<body> +<p> +Automatically starting the client. Please <a href='javascript:void()' +onclick='window.close()'>close</a> this window after the client +loads. NOTE: <b>Do not reload or refresh</b> this window. +</p> +</body> +</html> |
From: <al...@as...> - 2008-07-25 22:49:46
|
Author: alllee Date: Fri Jul 25 15:50:10 2008 New Revision: 3 Added: foraging/trunk/build.properties.example foraging/trunk/build.xml foraging/trunk/ivy.xml foraging/trunk/ivysettings.xml foraging/trunk/pom.xml Log: adding initial revision of foraging build files (for maven2 and ivy) Added: foraging/trunk/build.properties.example ============================================================================== --- (empty file) +++ foraging/trunk/build.properties.example Fri Jul 25 15:50:10 2008 @@ -0,0 +1,23 @@ +# Any custom build properties set here will override the defaults provided in +# the build.xml file. + +# server name, set this to the IP address or domain name that will be running +# the experiment server. +server.url=csid.asu.edu + +# the absolute path of where you would like to deploy the csan 2d files +# (should be accessible / mounted by the webserver) +web.dir=/var/www/html/csan/ + +# The URL that maps to the path above. If you don't mind using csan as part +# of the URL you can just set the server.url and leave this property blank +# since the build.xml that loads this properties file sets the codebase url to +# the ${server.url} + "/csan" by default. +codebase.url=http://libai.la.asu.edu/csan + +# set to whatever port you want the Java experiment server to run on (this is +# *not* the webserver port, this is the experiment server port used to +# communicate with the individual experiment clients) +server.port=16001 + + Added: foraging/trunk/build.xml ============================================================================== --- (empty file) +++ foraging/trunk/build.xml Fri Jul 25 15:50:10 2008 @@ -0,0 +1,331 @@ +<!-- $Id: build.xml 330 2008-02-13 05:31:26Z alllee $ + vim:sts=2:sw=2: + Version: $Revision: 330 $ + --> +<project xmlns:ivy='antlib:org.apache.ivy.ant' name="foraging" default="build-all" basedir="."> + + <!-- ensure ivy availability --> + <!-- + <path id='ivy.lib.path'> + <fileset dir='lib/ivy' includes='*.jar'/> + </path> + <taskdef resource='org/apache/ivy/ant/antlib.xml' + uri='antlib:org.apache.ivy.ant' + classpathref='ivy.lib.path'/> + --> + <property name="ivy.install.version" value="2.0.0-beta1" /> + <condition property="ivy.home" value="${env.IVY_HOME}"> + <isset property="env.IVY_HOME" /> + </condition> + <property name="ivy.home" value="${user.home}/.ant" /> + <property name="ivy.jar.dir" value="${ivy.home}/lib" /> + <property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" /> + + <target name="download-ivy" unless="offline"> + + <mkdir dir="${ivy.jar.dir}"/> + <!-- download Ivy from web site so that it can be used even without any special installation --> + <get src="http://www.apache.org/dist/ant/ivy/${ivy.install.version}/ivy.jar" + dest="${ivy.jar.file}" usetimestamp="true"/> + </target> + + <target name="init-ivy" depends="download-ivy"> + <!-- try to load ivy here from ivy home, in case the user has not already dropped + it into ant's lib dir (note that the latter copy will always take precedence). + We will not fail as long as local lib dir exists (it may be empty) and + ivy is in at least one of ant's lib dir or the local lib dir. --> + <path id="ivy.lib.path"> + <fileset dir="${ivy.jar.dir}" includes="*.jar"/> + + </path> + <taskdef resource="org/apache/ivy/ant/antlib.xml" + uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/> + </target> + + <target name='resolve' description='--> retrieve dependencies with ivy'> + <ivy:retrieve pattern='${lib.dir}/[conf]/[artifact].[ext]'/> + </target> + + <!-- Load all properties from the build.properties file, + then try to define defaults for all the properties. + The property definitions in the build.properties file + will have precedence. + --> + <property file="build.properties" /> + <!-- default compilation properties --> + <property name='src.dir' value='src/main/java'/> + <property name='build.dir' value='target'/> + + <!-- default web & deployment properties --> + <property name='web.dir' value='/var/www/carllab/${ant.project.name}'/> + <property name='server.port' value='16001'/> + <property name='server.xml' value='server.xml'/> + <property name='codebase.url' value='http://${server.url}/${ant.project.name}'/> + <property name='client.class' value='edu.asu.commons.foraging.client.ForagingClient'/> + <property name='facilitator.class' value='edu.asu.commons.foraging.facilitator.Facilitator'/> + <property name='server.class' value='edu.asu.commons.foraging.server.ForagingServer'/> + + <property name='dist.dir' value='dist' /> + + <property name='resources.dir' value='src/main/resources'/> + <property name='conf.dir' value='${resources.dir}/configuration'/> + + <!-- test properties --> + <property name="test.src.dir" value="src/test/java"/> + <property name="test.build.dir" value="target/test-classes"/> + <property name="test.results.dir" value="target/surefire-reports" /> + + <property name="javadoc.dir" value="docs/javadoc"/> + <property name="javadoc.private.dir" value="docs/private"/> + <property name='lib.dir' value='lib'/> + + <!-- Set up the CLASSPATH, includes all jars in the lib + directory and all built files for both the main project + and the tests --> + <path id="project.classpath"> + <pathelement location="." /> + <fileset dir="${lib.dir}"> + <include name="**/*.jar" /> + </fileset> + <pathelement location="${build.dir}" /> + <pathelement location="${test.build.dir}" /> + <pathelement location='${resources.dir}' /> + </path> + + <target name="help"> + <echo> + NOTE: At minimum you will need to modify the default web.dir and + server.url properties in the build.properties file before invoking deploy + or build-all. + + Currently deploying to ${web.dir} with a web address of ${codebase.url}. + + Experiment server will start on ${server.url}, listening on port ${server.port}. + + Available targets: + compile - Compile all the source code and tests. + clean - Remove all compiled source and test classes. + docs - Create JavaDoc documentation for all source code. + test - Run all JUnit in the test source tree. + build-all - builds the client, server, and facilitator jars. + deploy - invokes build-all and then copies the client and facilitator jars to ${web.dir} + </echo> + </target> + + <target name='build-all' depends='facilitator-jar, client-jar, server-jar, compile, clean'/> + +<!-- deploys the client jar to the appropriate webapps directory. --> + <target name='deploy' depends='build-all'> + <mkdir dir='${web.dir}'/> + <!-- + copy client jar, facilitator jar, and csidex.jar to web deployment + directory + --> + <copy todir='${web.dir}' overwrite='true'> + <fileset dir='${dist.dir}'> + <include name='client.jar'/> + <include name='facilitator.jar'/> + </fileset> + <fileset dir='${lib.dir}'> + <include name='csidex.jar'/> + </fileset> + </copy> + <!-- copy images --> + <copy todir='${web.dir}/images' overwrite='true'> + <fileset dir='images'/> + </copy> + <!-- + copy client and facilitator JNLP descriptor files, replacing + url/main class tokens. + --> + <copy file='web/client.jnlp' todir='${web.dir}' overwrite='true'> + <filterset> + <filter token='CODEBASE_URL' value='${codebase.url}'/> + <filter token='MAIN_CLASS' value='${client.class}'/> + </filterset> + </copy> + <copy file='web/facilitator.jnlp' todir='${web.dir}' overwrite='true'> + <filterset> + <filter token='CODEBASE_URL' value='${codebase.url}'/> + <filter token='MAIN_CLASS' value='${facilitator.class}'/> + </filterset> + </copy> + <chmod dir='${web.dir}' perm='664' type='file' includes='**'/> + <chmod dir='${web.dir}' perm='775' type='dir' includes='**'/> + </target> + + <target name='client-jar' depends='server-jar'> + <antcall target='build-jar'> + <param name='main.class' value='${client.class}'/> + <param name='jar.name' value='client.jar'/> + </antcall> + </target> + + <target name='facilitator-jar' depends='client-jar'> + <antcall target='build-jar'> + <param name='main.class' value='${facilitator.class}'/> + <param name='jar.name' value='facilitator.jar'/> + </antcall> + </target> + + + <target name='server-jar' depends='compile'> + <antcall target='build-jar'> + <param name='main.class' value='${server.class}'/> + <param name='jar.name' value='server.jar'/> + </antcall> + <move file='dist/server.jar' tofile='server.jar'/> + </target> + + <target name='build-jar'> + <pathconvert property='manifest.classpath' pathsep=' '> + <path refid='project.classpath'/> + </pathconvert> + <chmod dir='${build.dir}' perm='a+rx' type='dir' includes='**'/> + <chmod dir='${build.dir}' perm='a+r' type='file' includes='**'/> + <manifest file='manifest.mf'> + <attribute name="Main-Class" value="${main.class}"/> + <attribute name='Class-Path' value='${manifest.classpath}'/> + </manifest> + <jar destfile='${dist.dir}/${jar.name}' manifest='manifest.mf'> + <fileset dir='${build.dir}'> + <include name='edu/asu/commons/**'/> + <include name='data/**'/> + <include name='conf/**'/> + <include name='images/**'/> + </fileset> + </jar> + <chmod file='${dist.dir}/${jar.name}' perm='664'/> + </target> + <!-- Prepare for a build by creating appropriate directories --> + <target name="prepare" depends='clean, resolve'> + <mkdir dir="${build.dir}"/> + <mkdir dir="${test.build.dir}"/> + <mkdir dir='${dist.dir}'/> + </target> + + <!-- Clean up build by deleting build directories --> + <target name="clean"> + <delete dir="${build.dir}"/> + <delete dir="${test.build.dir}"/> + <delete dir='${dist.dir}'/> + </target> + + <!-- Compile project source files --> + <target name='compile' depends="prepare"> + <javac srcdir="${src.dir}" + destdir="${build.dir}" + debug="on" + optimize="off" + deprecation="on" + source="1.6" + > + <compilerarg value='-Xlint:unchecked'/> + <classpath refid="project.classpath" /> + </javac> + <copy todir='${build.dir}/conf'> + <fileset dir='${conf.dir}'/> + <filterset> + <filter token='SERVER_URL' value='${server.url}'/> + <filter token='PORT_NUMBER' value='${server.port}'/> + <filter token='CODEBASE_URL' value='${codebase.url}'/> + </filterset> + </copy> + <copy todir='${build.dir}/data'> + <fileset dir='${resources.dir}/data'/> + </copy> + <copy todir='${build.dir}/images'> + <fileset dir='${resources.dir}/images'/> + </copy> + </target> + + <target name='profile' depends='test'> + <java jar='${project.profiler}' classpathref='project.classpath' fork='true'> + <arg value='${hprof.file}'/> + </java> + <!-- do something like java -jar PerfAnal.jar <hprof.txt> --> + </target> + + <!-- Build project documentation --> + <target name="docs"> + <javadoc sourcepath="${src.dir}" + destdir="${javadoc.dir}" + packagenames="*" + source="1.6" + classpathref='project.classpath' + link='http://java.sun.com/javase/6/docs/api/ + http://commons.asu.edu/src/csidex/api' + overview="${src.dir}/overview.html" /> + </target> + + <!-- RUN TARGETS --> + <target name='client' depends='compile'> + <java classname='${client.class}' + classpathref='project.classpath' + fork='yes'/> + </target> + + <target name='fac' depends='compile'> + <java classname='${facilitator.class}' + classpathref='project.classpath' + fork='yes'/> + </target> + + <target name='deploy-server' depends='deploy, server' /> + + <target name='server' depends='compile'> + <java classname='${server.class}' classpathref='project.classpath' fork='yes'> + <jvmarg value="-server"/> + </java> + </target> + + + <!-- Build private-level documentation --> + <target name="private-docs"> + <javadoc sourcepath="${src.dir}" + destdir="${javadoc.private.dir}" + packagenames="*" + link="http://java.sun.com/j2se/1.4/docs/api/" + source="1.4" + access="private"/> + </target> + + <!-- Compile Tests --> + <target name="compile-tests" depends="compile"> + <javac srcdir="${test.src.dir}" + destdir="${test.build.dir}" + source="1.5" + debug="on"> + <!-- <compilerarg value='-Xlint:unchecked'/> --> + <classpath refid="project.classpath" /> + </javac> + </target> + + <!-- Run Tests --> + <target name="test" depends="compile-tests"> + <delete dir="${test.results.dir}"/> + <mkdir dir="${test.results.dir}"/> + <junit fork="yes" haltonfailure="yes" printsummary="yes"> + <classpath refid="project.classpath" /> + <batchtest todir="${test.results.dir}" > + <formatter usefile="no" type="plain" /> + <formatter type="xml" /> + <fileset dir="${test.build.dir}"> + <include name="**/*Test.class" /> + </fileset> + </batchtest> + </junit> + </target> + + <!-- Run Test on GUI --> + <target name="guitest" depends="compile-tests"> + <java fork="yes" classname="junit.swingui.TestRunner" taskname="JUnit" failonerror="true" dir="${basedir}"> + <jvmarg value="-Djunit.test.path=${test.build.dir}" /> + <sysproperty key="basedir" value="${basedir}" /> + <classpath> + <path refid="project.classpath" /> + </classpath> + </java> + </target> + +</project> Added: foraging/trunk/ivy.xml ============================================================================== --- (empty file) +++ foraging/trunk/ivy.xml Fri Jul 25 15:50:10 2008 @@ -0,0 +1,18 @@ +<?xml version="1.0"?> +<!-- +vim:sts=2:sw=2: +--> +<ivy-module version="2.0"> + <info organisation="edu.asu.commons" module="foraging"/> + <dependencies> + <dependency org='junit' name='junit' rev='4.4'/> + <dependency org='com.thoughtworks.xstream' name='xstream' rev='1.3' transitive='false'/> + <dependency org='xpp3' name='xpp3' rev='1.1.4c' transitive='false' /> + <dependency org="edu.asu.commons" name="csidex" rev="0.1"/> + <dependency org='net.java.dev.jogl' name='jogl' rev='1.1.1'/> + <dependency org='net.java.dev.jogl' name='gluegen-rt' rev='1.1.1'/> + </dependencies> +</ivy-module> + + + Added: foraging/trunk/ivysettings.xml ============================================================================== --- (empty file) +++ foraging/trunk/ivysettings.xml Fri Jul 25 15:50:10 2008 @@ -0,0 +1,14 @@ +<?xml version="1.0"?> +<!-- +vim:sts=2:sw=2: +--> +<ivysettings> + <settings defaultResolver="csid-archiva" checkUpToDate="false"/> + <resolvers> + <ibiblio name='csid-archiva' m2compatible='true' root='http://csid.asu.edu:8080/archiva/repository/internal'/> + <filesystem name="internal"> + <ivy pattern="${repository.dir}/[module]/ivy-[revision].xml"/> + <artifact pattern="${repository.dir}/[module]/[artifact]-[revision].[ext]"/> + </filesystem> + </resolvers> +</ivysettings> Added: foraging/trunk/pom.xml ============================================================================== --- (empty file) +++ foraging/trunk/pom.xml Fri Jul 25 15:50:10 2008 @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +vim:sts=2:sw=2 +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>edu.asu.commons</groupId> + <artifactId>foraging</artifactId> + <packaging>jar</packaging> + <version>1.0-SNAPSHOT</version> + <name>foraging</name> + <url>http://commons.asu.edu/foraging</url> + <repositories> + <repository> + <id>csid.asu.edu</id> + <name>CSID Maven2 repository</name> + <url>http://csid.asu.edu:8080/archiva/repository/internal</url> + </repository> + <repository> + <id>java.net</id> + <name>java.net</name> + <url>http://download.java.net/maven/2</url> + <layout>default</layout> + </repository> + </repositories> + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.4</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>edu.asu.commons</groupId> + <artifactId>csidex</artifactId> + <version>0.1</version> + </dependency> + <dependency> + <groupId>net.java.dev.jogl</groupId> + <artifactId>jogl</artifactId> + <version>1.1.1</version> + </dependency> + <dependency> + <groupId>net.java.dev.jogl</groupId> + <artifactId>gluegen-rt</artifactId> + <version>1.1.1</version> + </dependency> + </dependencies> + <build> + <finalName>foraging</finalName> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.5</source> + <target>1.5</target> + </configuration> + </plugin> + </plugins> + </build> +</project> |
From: <al...@as...> - 2008-07-24 17:53:23
|
Author: alllee Date: Thu Jul 24 10:53:45 2008 New Revision: 2 Added: foraging/ - copied from r1, /csan/ irrigation/ - copied from r1, /irri/ vcweb/ vcweb/branches/ vcweb/tags/ vcweb/trunk/ Removed: csan/ irri/ Log: renaming concrete experiments |
Author: alllee Date: Wed Jul 23 15:15:18 2008 New Revision: 1 Added: csan/ csan/branches/ csan/tags/ csan/trunk/ csidex/ csidex/branches/ csidex/tags/ csidex/trunk/ csidex/trunk/pom.xml csidex/trunk/src/ csidex/trunk/src/main/ csidex/trunk/src/main/java/ csidex/trunk/src/main/java/edu/ csidex/trunk/src/main/java/edu/asu/ csidex/trunk/src/main/java/edu/asu/commons/ csidex/trunk/src/main/java/edu/asu/commons/client/ csidex/trunk/src/main/java/edu/asu/commons/client/BaseClient.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/command/ csidex/trunk/src/main/java/edu/asu/commons/command/Command.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/command/OrderedCommand.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/conf/ csidex/trunk/src/main/java/edu/asu/commons/conf/ConfigurationAssistant.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/conf/ExperimentConfiguration.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/conf/ExperimentRoundParameters.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/conf/PersistenceType.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/ csidex/trunk/src/main/java/edu/asu/commons/event/AbortExperimentRequest.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/AbstractEvent.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/AbstractPersistableEvent.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/AndEventConstraint.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/BeginExperimentRequest.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/BeginRoundRequest.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/ChatEvent.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/ChatRequest.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/ClientErrorMessageEvent.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/ClientMessageEvent.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/ClientRequest.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/ConfigurationEvent.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/EndExperimentRequest.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/EndRoundRequest.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/Event.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/EventChannel.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/EventChannelFactory.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/EventConstraint.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/EventConstraintChannel.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/EventGenerator.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/EventHandler.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/EventHandlingModule.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/EventInstanceofConstraint.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/EventProcessor.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/EventTypeChannel.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/EventTypeProcessor.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/ExperimentUpdateEvent.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/FacilitatorRegistrationRequest.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/FacilitatorRequest.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/OrEventConstraint.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/PersistableEvent.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/RegistrationEvent.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/event/SetConfigurationEvent.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/experiment/ csidex/trunk/src/main/java/edu/asu/commons/experiment/AbstractExperiment.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/experiment/DataModel.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/experiment/Experiment.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/experiment/Persister.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/experiment/SaveFileProcessor.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/experiment/SavedExperimentData.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/experiment/SavedRoundData.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/experiment/StateMachine.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/facilitator/ csidex/trunk/src/main/java/edu/asu/commons/facilitator/BaseFacilitator.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/net/ csidex/trunk/src/main/java/edu/asu/commons/net/AbstractDispatcher.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/net/AbstractServerDispatcher.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/net/ClientDispatcher.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/net/ClientReadyEvent.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/net/ClientSocketDispatcher.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/net/Dispatcher.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/net/DispatcherFactory.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/net/Identifier.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/net/NioDispatcher.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/net/ServerDispatcher.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/net/ServerSocketDispatcher.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/net/SocketDispatcherWorker.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/net/SocketIdentifier.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/net/Worker.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/net/WorkerFactory.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/net/WorkerPool.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/net/event/ csidex/trunk/src/main/java/edu/asu/commons/net/event/ClientReadyEvent.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/net/event/ConnectionEvent.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/net/event/DisconnectionEvent.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/net/event/DisconnectionRequest.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/util/ csidex/trunk/src/main/java/edu/asu/commons/util/Duration.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/util/HtmlEditorPane.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/util/ResourceLoader.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/util/TimePoint.java (contents, props changed) csidex/trunk/src/main/java/edu/asu/commons/util/Utils.java (contents, props changed) csidex/trunk/src/test/ csidex/trunk/src/test/java/ csidex/trunk/src/test/java/edu/ csidex/trunk/src/test/java/edu/asu/ csidex/trunk/src/test/java/edu/asu/commons/ csidex/trunk/src/test/java/edu/asu/commons/conf/ csidex/trunk/src/test/java/edu/asu/commons/conf/ConfigurationTest.java (contents, props changed) csidex/trunk/src/test/java/edu/asu/commons/event/ csidex/trunk/src/test/java/edu/asu/commons/event/EventConstraintChannelTest.java (contents, props changed) csidex/trunk/src/test/java/edu/asu/commons/event/EventTypeChannelTest.java (contents, props changed) csidex/trunk/src/test/java/edu/asu/commons/util/ csidex/trunk/src/test/java/edu/asu/commons/util/UtilsTest.java (contents, props changed) irri/ irri/branches/ irri/tags/ irri/trunk/ Log: Creating initial virtualcommons' svn structure. Each subproject has its own subdirectory with its own trunk/tags/branches/etc. The csidex subproject is the core of the virtual commons and is a dependency for the other subprojects. Already converted to maven 2, still need to convert csan and irrigation to maven2 as well. Added: csidex/trunk/pom.xml ============================================================================== --- (empty file) +++ csidex/trunk/pom.xml Wed Jul 23 15:15:18 2008 @@ -0,0 +1,57 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<!-- +vim:sts=2:sw=2 +--> + <modelVersion>4.0.0</modelVersion> + <groupId>edu.asu.commons</groupId> + <artifactId>csidex</artifactId> + <repositories> + <repository> + <id>csid.asu.edu</id> + <name>CSID Maven2 repository</name> + <url>http://csid.asu.edu:8080/archiva/repository/internal</url> + </repository> + <repository> + <id>java.net</id> + <name>java.net</name> + <url>http://download.java.net/maven/2</url> + <layout>default</layout> + </repository> + </repositories> + <packaging>jar</packaging> + <version>1.0-SNAPSHOT</version> + <name>csidex</name> + <url>http://maven.apache.org</url> + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.4</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>com.thoughtworks.xstream</groupId> + <artifactId>xstream</artifactId> + <version>1.3</version> + </dependency> + <dependency> + <groupId>xpp3</groupId> + <artifactId>xpp3</artifactId> + <version>1.1.4c</version> + </dependency> + </dependencies> + <build> + <finalName>csidex</finalName> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.5</source> + <target>1.5</target> + </configuration> + </plugin> + </plugins> + </build> + +</project> Added: csidex/trunk/src/main/java/edu/asu/commons/client/BaseClient.java ============================================================================== --- (empty file) +++ csidex/trunk/src/main/java/edu/asu/commons/client/BaseClient.java Wed Jul 23 15:15:18 2008 @@ -0,0 +1,102 @@ +package edu.asu.commons.client; + +import edu.asu.commons.conf.ExperimentConfiguration; +import edu.asu.commons.conf.ExperimentRoundParameters; +import edu.asu.commons.event.Event; +import edu.asu.commons.event.EventChannel; +import edu.asu.commons.event.EventChannelFactory; +import edu.asu.commons.event.EventProcessor; +import edu.asu.commons.net.ClientDispatcher; +import edu.asu.commons.net.DispatcherFactory; +import edu.asu.commons.net.Identifier; +import edu.asu.commons.net.event.DisconnectionRequest; + +/** + * $ Id$ + * + * + * @author <a href='mailto:All...@as...'>Allen Lee</a> + * @version $Revision$ + */ +public abstract class BaseClient<E extends ExperimentConfiguration<? extends ExperimentRoundParameters<E>>> { + + private final ClientDispatcher dispatcher; + + private final EventChannel channel; + + private Identifier id; + + private E serverConfiguration; + + public BaseClient(E configuration) { + this( configuration, EventChannelFactory.create() ); + } + + public BaseClient(E configuration, EventChannel channel) { + this(configuration, channel, DispatcherFactory.getInstance().createClientDispatcher(channel)); + } + + public BaseClient(E configuration, EventChannel channel, ClientDispatcher dispatcher) { + if (configuration == null) { + throw new NullPointerException("Null experiment configuration disallowed"); + } + if (channel == null) { + throw new NullPointerException("Null event channel disallowed"); + } + if (dispatcher == null) { + throw new NullPointerException("Null client dispatcher disallowed"); + } + this.serverConfiguration = configuration; + this.channel = channel; + this.dispatcher = dispatcher; + } + // FIXME: figure out a better way to copy over the configuration for integrating multiple clients.. + public BaseClient(BaseClient<E> client) { + this(client.serverConfiguration, client.channel, client.dispatcher); + this.id = client.id; + } + + protected void initializeEventProcessors() { } + protected void postConnect() { } + + public void connect() { + initializeEventProcessors(); + id = dispatcher.connect(serverConfiguration.getServerAddress()); + if (id == null) { + throw new RuntimeException("Could not connect to server: <" + + serverConfiguration.getServerAddress() + + "> is probably down."); + } + postConnect(); + } + + public void transmit(Event event) { + dispatcher.transmit(event); + } + + public void disconnect() { + transmit(new DisconnectionRequest(id)); + channel.remove(this); + } + + public ClientDispatcher getDispatcher() { + return dispatcher; + } + + public Identifier getId() { + return id; + } + + public EventChannel getEventChannel() { + return channel; + } + + protected void setId(Identifier id) { + this.id = id; + } + + protected void addEventProcessor(EventProcessor<? extends Event> processor) { + channel.add(this, processor); + } + +} Added: csidex/trunk/src/main/java/edu/asu/commons/command/Command.java ============================================================================== --- (empty file) +++ csidex/trunk/src/main/java/edu/asu/commons/command/Command.java Wed Jul 23 15:15:18 2008 @@ -0,0 +1,14 @@ +package edu.asu.commons.command; + + +/** + * $Id$ + * + * A serializable command. Intended for use with an AbstractExperiment that wants easier synchronization. + * + * @version $Rev$ + * @author Allen Lee + */ +public interface Command { + public void execute(); +} Added: csidex/trunk/src/main/java/edu/asu/commons/command/OrderedCommand.java ============================================================================== --- (empty file) +++ csidex/trunk/src/main/java/edu/asu/commons/command/OrderedCommand.java Wed Jul 23 15:15:18 2008 @@ -0,0 +1,23 @@ +package edu.asu.commons.command; + +public abstract class OrderedCommand implements Command { + + private volatile static long hash = 0; + + private final long creationTime = System.nanoTime(); + + private final long ordinal = hash++; + + public int compareTo(OrderedCommand command) { + int comparison = compare(creationTime, command.creationTime); + if (comparison == 0) { + return compare(ordinal, command.ordinal); + } + return comparison; + } + + private int compare(long a, long b) { + return (a > b) ? 1 : (a == b) ? 0 : -1; + } + +} Added: csidex/trunk/src/main/java/edu/asu/commons/conf/ConfigurationAssistant.java ============================================================================== --- (empty file) +++ csidex/trunk/src/main/java/edu/asu/commons/conf/ConfigurationAssistant.java Wed Jul 23 15:15:18 2008 @@ -0,0 +1,113 @@ +package edu.asu.commons.conf; + +import java.io.IOException; +import java.io.InputStream; +import java.io.Serializable; +import java.util.Properties; + +import edu.asu.commons.util.ResourceLoader; + +/** + * $Id$ + * + * Provides convenience methods to read configuration properties from a java.util.Properties + * instance. + * + * @author <a href='All...@as...'>Allen Lee</a> + * @version $Revision$ + */ +public class ConfigurationAssistant implements Serializable { + + private static final long serialVersionUID = -9093022080387404606L; + + private final Properties properties; + + public ConfigurationAssistant() { + this(new Properties()); + } + + public ConfigurationAssistant(Properties properties) { + this.properties = properties; + } + + public Properties getProperties() { + return properties; + } + + public void loadProperties(String resource) { + InputStream stream = ResourceLoader.toInputStream(resource); + try { + properties.loadFromXML(stream); + } + catch (IOException e) { + // FIXME: try to load them manually, not via loadFromXML? + e.printStackTrace(); + throw new IllegalArgumentException("Couldn't load properties via loadFromXML - resource: " + + resource + " - stream: " + stream, e); + } + } + + public String getProperty(String key) { + return getStringProperty(key, ""); + } + + public String getProperty(String key, String defaultValue) { + return getStringProperty(key, defaultValue); + } + + public String getStringProperty(String key) { + return getStringProperty(key, ""); + } + + public String getStringProperty(String key, String defaultValue) { + if (properties.containsKey(key)) { + return properties.getProperty(key); + } + return defaultValue; + } + + public int getIntProperty(String key) { + return getIntProperty(key, 0); + } + + public int getIntProperty(String key, int defaultValue) { + if (properties.containsKey(key)) { + try { + return Integer.parseInt(properties.getProperty(key)); + } + catch (NumberFormatException fallthrough) {} + } + return defaultValue; + } + + public boolean getBooleanProperty(String key) { + return getBooleanProperty(key, false); + } + + public boolean getBooleanProperty(String key, boolean defaultValue) { + if (properties.containsKey(key)) { + return "true".equals(properties.getProperty(key)); + } + return defaultValue; + } + + public double getDoubleProperty(String key) { + return getDoubleProperty(key, 0.0d); + } + + public double getDoubleProperty(String key, double defaultValue) { + if (properties.containsKey(key)) { + try { + return Double.parseDouble(properties.getProperty(key)); + } + catch (NumberFormatException fallthrough) { + // FIXME: should log a warning + } + } + return defaultValue; + } + + public void setProperty(String key, String value) { + properties.setProperty(key, value); + } +} Added: csidex/trunk/src/main/java/edu/asu/commons/conf/ExperimentConfiguration.java ============================================================================== --- (empty file) +++ csidex/trunk/src/main/java/edu/asu/commons/conf/ExperimentConfiguration.java Wed Jul 23 15:15:18 2008 @@ -0,0 +1,196 @@ +package edu.asu.commons.conf; + +import java.io.Serializable; +import java.net.InetSocketAddress; +import java.util.ArrayList; +import java.util.List; + +/** + * $Id$ + * + * All experiment server configurations should follow this contract. + * + * @author <a href='mailto:All...@as...'>Allen Lee</a> + * @version $Revision$ + */ + +public interface ExperimentConfiguration<T extends ExperimentRoundParameters> extends Serializable { + + public List<T> getAllParameters(); + public void setAllParameters(List<T> allParameters); + public T getCurrentParameters(); + public int getNumberOfRounds(); + public T nextRound(); + + public String getServerName(); + public void setServerName(String serverName); + + public int getServerPort(); + public void setServerPort(int serverPort); + + public String getFacilitatorInstructions(); + + public InetSocketAddress getServerAddress(); + + public String getPersistenceDirectory(); + + public PersistenceType getPersistenceType(); + + public boolean isFirstRound(); + public boolean isLastRound(); + + public static abstract class Base<E extends ExperimentRoundParameters> implements ExperimentConfiguration<E> { + + private final static long serialVersionUID = 1679614060238100147L; + public static String defaultConfigurationDirectory; + + private final static String DEFAULT_CONF_DIR = "conf/"; + private final static String CONFIGURATION_DIRECTORY_KEY = "conf.dir"; + private final static String DEFAULT_SERVER_CONFIGURATION_FILENAME = "server.xml"; + + static { + try { + String dir = System.getProperty(CONFIGURATION_DIRECTORY_KEY); + if (dir == null || dir.equals("")) { + defaultConfigurationDirectory = DEFAULT_CONF_DIR; + } + else { + defaultConfigurationDirectory = dir; + } + } + catch (SecurityException ignored) { + defaultConfigurationDirectory = DEFAULT_CONF_DIR; + } + } + + private int currentRoundIndex = 0; + protected final ConfigurationAssistant assistant; + protected final List<E> allParameters = new ArrayList<E>(); + protected String configurationDirectory; + + public Base() { + this(defaultConfigurationDirectory); + } + + public Base(String configurationDirectory) { + if (configurationDirectory == null) { + configurationDirectory = ""; + } + else { + if (! configurationDirectory.endsWith("/")) { + configurationDirectory = configurationDirectory.concat("/"); + } + } + this.configurationDirectory = configurationDirectory; + assistant = new ConfigurationAssistant(); + loadServerProperties(); + } + + protected abstract E createConfiguration(String roundConfigurationResource); + /** + * Override if you want to use a different server configuration file. + */ + protected String getServerConfigurationFilename() { + return DEFAULT_SERVER_CONFIGURATION_FILENAME; + } + + private void loadServerProperties() { + String configurationResource = getConfigurationDirectory() + getServerConfigurationFilename(); + assistant.loadProperties(configurationResource); + loadParameters(); + } + + private void loadParameters() { + for (int roundNumber = 0; roundNumber < getNumberOfRounds(); roundNumber++) { + String roundConfigurationResource = getConfigurationDirectory() + getRoundParametersFile(roundNumber); + if (roundConfigurationResource == null || "".equals(roundConfigurationResource)) { + System.err.println("invalid experiment: " + roundNumber); + continue; + } + E configuration = createConfiguration(roundConfigurationResource); + configuration.setParentConfiguration(this); + allParameters.add(configuration); + } + } + + public InetSocketAddress getServerAddress() { + return new InetSocketAddress(getServerName(), getServerPort()); + } + public int getServerPort() { + return assistant.getIntProperty("port", 23732); + } + public String getServerName() { + return assistant.getStringProperty("hostname", "localhost"); + } + public void setServerName(String serverName) { + assistant.setProperty("hostname", serverName); + } + public void setServerPort(int serverPort) { + assistant.setProperty("port", String.valueOf(serverPort)); + } + + public String getRoundParametersFile(int roundNumber) { + return assistant.getStringProperty("round" + roundNumber); + } + + public int getNumberOfRounds() { + return assistant.getIntProperty("number-of-rounds", 0); + } + + public String getFacilitatorInstructions() { + return assistant.getStringProperty("facilitator-instructions", + "No facilitator instructions available."); + } + + public List<E> getAllParameters() { + return allParameters; + } + + public void setAllParameters(List<E> incomingParameters) { + allParameters.clear(); + allParameters.addAll(incomingParameters); + currentRoundIndex = 0; + } + + public int getCurrentRoundNumber() { + return currentRoundIndex; + } + + public E getCurrentParameters() { + return allParameters.get(currentRoundIndex); + } + + public boolean isFirstRound() { + return currentRoundIndex == 0; + } + + public boolean isLastRound() { + return currentRoundIndex == (getNumberOfRounds() - 1); + } + /** + * Returns the next round configuration. + * If we're at the last round, returns the last round configuration. + */ + public E nextRound() { + if (isLastRound()) { + return getCurrentParameters(); + } + return allParameters.get(++currentRoundIndex); + } + + public String getConfigurationDirectory() { + return configurationDirectory; + } + + public String getPersistenceDirectory() { + return assistant.getStringProperty("save-dir", "experiment-data"); + } + + public PersistenceType getPersistenceType() { + String persistenceType = assistant.getStringProperty("persistence-type", "BINARY"); + return PersistenceType.valueOf(persistenceType); + } + + } + +} Added: csidex/trunk/src/main/java/edu/asu/commons/conf/ExperimentRoundParameters.java ============================================================================== --- (empty file) +++ csidex/trunk/src/main/java/edu/asu/commons/conf/ExperimentRoundParameters.java Wed Jul 23 15:15:18 2008 @@ -0,0 +1,141 @@ +package edu.asu.commons.conf; + +import java.io.PrintStream; +import java.io.Serializable; +import java.util.Properties; + +import edu.asu.commons.util.Duration; + +/** + * $Id$ + * + * Per-round experimental parameters for a given Experiment server instance. + * + * FIXME: add Base class. + * + * @author <a href='al...@cs...'>Allen Lee</a> + * @version $Revision$ + */ + +public interface ExperimentRoundParameters<T extends ExperimentConfiguration> extends Serializable { + + public String getInstructions(); + + public T getParentConfiguration(); + public void setParentConfiguration(T configuration); + + public Duration getRoundDuration(); + + public int getRoundNumber(); + +// public Properties getProperties(); + + public static abstract class Base<E extends ExperimentConfiguration> implements ExperimentRoundParameters<E> { + private static final long serialVersionUID = -7904104481473406817L; + private final ConfigurationAssistant assistant = new ConfigurationAssistant(); + private final String resource; + private E parentConfiguration; + + public Base() { + this.resource = null; + } + + public Base(String resource) { + if (resource == null || "".equals(resource)) { + throw new IllegalArgumentException("null or empty resource name: " + + resource); + } + this.resource = resource; + assistant.loadProperties(resource); + } + + public int getRoundNumber() { + return getParentConfiguration().getAllParameters().indexOf(this); + } + + protected ConfigurationAssistant getConfigurationAssistant() { + return assistant; + } + + public void report() { + report(System.err); + } + + public void report(PrintStream stream) { + assistant.getProperties().list(stream); + } + + public String getResourceFilename() { + return resource; + } + + public E getParentConfiguration() { + return parentConfiguration; + } + + public Duration getRoundDuration() { + return Duration.create(assistant.getIntProperty("duration", 240)); + } + + public void setParentConfiguration(E parentConfiguration) { + this.parentConfiguration = parentConfiguration; + } + + public boolean getBooleanProperty(String key, boolean defaultValue) { + return assistant.getBooleanProperty(key, defaultValue); + } + + public boolean getBooleanProperty(String key) { + return assistant.getBooleanProperty(key); + } + + public double getDoubleProperty(String key, double defaultValue) { + return assistant.getDoubleProperty(key, defaultValue); + } + + public double getDoubleProperty(String key) { + return assistant.getDoubleProperty(key); + } + + public int getIntProperty(String key, int defaultValue) { + return assistant.getIntProperty(key, defaultValue); + } + + public int getIntProperty(String key) { + return assistant.getIntProperty(key); + } + + public Properties getProperties() { + return assistant.getProperties(); + } + + public String getStringProperty(String key, String defaultValue) { + return assistant.getStringProperty(key, defaultValue); + } + + public String getStringProperty(String key) { + return assistant.getStringProperty(key); + } + + public void setProperty(String key, String value) { + assistant.setProperty(key, value); + } + + public String getProperty(String key, String defaultValue) { + return assistant.getProperty(key, defaultValue); + } + + public String getProperty(String key) { + return assistant.getProperty(key); + } + public boolean isFirstRound() { + return parentConfiguration.isFirstRound(); + } + public boolean isLastRound() { + return parentConfiguration.isLastRound(); + } + + + } + +} Added: csidex/trunk/src/main/java/edu/asu/commons/conf/PersistenceType.java ============================================================================== --- (empty file) +++ csidex/trunk/src/main/java/edu/asu/commons/conf/PersistenceType.java Wed Jul 23 15:15:18 2008 @@ -0,0 +1,9 @@ +package edu.asu.commons.conf; + +public enum PersistenceType { + ALL, XML, BINARY; + + public boolean isXmlEnabled() { + return this == ALL || this == XML; + } +} Added: csidex/trunk/src/main/java/edu/asu/commons/event/AbortExperimentRequest.java ============================================================================== --- (empty file) +++ csidex/trunk/src/main/java/edu/asu/commons/event/AbortExperimentRequest.java Wed Jul 23 15:15:18 2008 @@ -0,0 +1,29 @@ +package edu.asu.commons.event; + +import edu.asu.commons.net.Identifier; + + +/** + * $Id$ + * + * Request used to signal the server that the game should be aborted. Should + * employ some intelligent something or other on the server + * side to prevent evul h4x0rs from aborting the game over and over. + * + * @author Allen Lee + * @version $Revision$ + */ + +public class AbortExperimentRequest extends AbstractEvent { + + private static final long serialVersionUID = -7113964603025019120L; + + public AbortExperimentRequest(Identifier id) { + super(id); + } + + public String toString() { + return "Abort experiment initiated by: " + id; + } + +} Added: csidex/trunk/src/main/java/edu/asu/commons/event/AbstractEvent.java ============================================================================== --- (empty file) +++ csidex/trunk/src/main/java/edu/asu/commons/event/AbstractEvent.java Wed Jul 23 15:15:18 2008 @@ -0,0 +1,60 @@ +package edu.asu.commons.event; + +import edu.asu.commons.net.Identifier; + +/** + * $Id$ + * + * Abstract base class providing convenience methods for accessing the creation + * time and Identifier for an Event. + * + * @author <a href='mailto:al...@cs...'>Allen Lee</a> + * @version $Revision$ + */ + +public abstract class AbstractEvent implements Event { + + private final static long serialVersionUID = -3443360054002127621L; + + protected Identifier id; + protected long creationTime; + private final String message; + + public AbstractEvent() { + this(Identifier.NULL); + } + + public AbstractEvent(Identifier id) { + this(id, null); + } + + public AbstractEvent(Identifier id, String message) { + if (id == null) { + throw new NullPointerException("Cannot create an AbstractEvent with " + + "a null Identifier"); + } + this.id = id; + // FIXME: switch to System.currentTimeNanos() once we become Java 1.5 + // compliant. + this.creationTime = System.currentTimeMillis(); + this.message = message; + } + + /** + * Returns the event's identifier + */ + public Identifier getId() { + return id; + } + + public String toString() { + if (message == null) { + return getClass() + " id [" + id + "], creation time [ " + creationTime + "]"; + } + return message; + } + + public long getCreationTime() { + return creationTime; + } +} Added: csidex/trunk/src/main/java/edu/asu/commons/event/AbstractPersistableEvent.java ============================================================================== --- (empty file) +++ csidex/trunk/src/main/java/edu/asu/commons/event/AbstractPersistableEvent.java Wed Jul 23 15:15:18 2008 @@ -0,0 +1,54 @@ +package edu.asu.commons.event; + +import edu.asu.commons.net.Identifier; + + +/** + * $Id$ + * + * Base class that provides uniqueness with respect to the time-ordered stream + * of Events originating from a single place. + * + * @author <a href='mailto:All...@as...'>Allen Lee</a> + * @version $Revision$ + */ +public abstract class AbstractPersistableEvent extends AbstractEvent +implements PersistableEvent, Comparable<AbstractPersistableEvent> { + + private static long classCounter = 0; + + private final long ordinal; + + public AbstractPersistableEvent(Identifier id) { + super(id); + synchronized (AbstractPersistableEvent.class) { + ordinal = classCounter++; + } + } + /** + * This method is used to establish a total ordering as per the Comparable + * interface. + */ + public int compareTo(AbstractPersistableEvent e) { + if (e == null) { + throw new IllegalArgumentException("Cannot compare to a null event"); + } + // System.currentTimeMillis() is not fine-grained enough to distinguish + // between two Event creation times occasionally, hence the use of the + // ordinal to help impose a total ordering across all persistable events. + int comparison = compare(getCreationTime(), e.getCreationTime()); + if (comparison == 0) { + return compare(ordinal, e.ordinal); + } + return comparison; + + } + + private int compare(long a, long b) { + return (a > b) ? 1 : (a == b) ? 0 : -1; + } + + public final void timestamp() { + super.creationTime = System.currentTimeMillis(); + } +} Added: csidex/trunk/src/main/java/edu/asu/commons/event/AndEventConstraint.java ============================================================================== --- (empty file) +++ csidex/trunk/src/main/java/edu/asu/commons/event/AndEventConstraint.java Wed Jul 23 15:15:18 2008 @@ -0,0 +1,46 @@ +package edu.asu.commons.event; + + +/** + * $Id$ + * + * This class composes two event constraints using the logical AND operator. + * It accepts all Events satisfying both the first event constraint and the + * second, in that order and is short-circuiting. + * + * @author <a href='mailto:al...@cs...'>Allen Lee</a> + * @version $Revision$ + */ + +public class AndEventConstraint implements EventConstraint { + +// private final List<EventConstraint> constraints; + + private final EventConstraint first; + private final EventConstraint second; + + public AndEventConstraint(EventConstraint first, EventConstraint second) { + this.first = first; + this.second = second; + } + + public boolean accepts(Event event) { + return first.accepts(event) && second.accepts(event); + } + +// public AndEventConstraint(List<EventConstraint> constraints) { +// if (constraints == null) { +// throw new IllegalArgumentException("constraints shouldn't be null"); +// } +// this.constraints = constraints; +// } +// +// public boolean accepts(Event event) { +// for (EventConstraint constraint : constraints) { +// if (! constraint.accepts(event)) { +// return false; +// } +// } +// return true; +// } +} Added: csidex/trunk/src/main/java/edu/asu/commons/event/BeginExperimentRequest.java ============================================================================== --- (empty file) +++ csidex/trunk/src/main/java/edu/asu/commons/event/BeginExperimentRequest.java Wed Jul 23 15:15:18 2008 @@ -0,0 +1,28 @@ +package edu.asu.commons.event; + +import edu.asu.commons.net.Identifier; + +/** + * $Id$ + * + * Used by the facilitator to signal that we are done collecting clients and + * ready to start the next experiment. + * + * + * @author Allen Lee + * @version $Revision$ + */ + +public class BeginExperimentRequest extends AbstractEvent { + + private static final long serialVersionUID = -1853850747915213143L; + + public BeginExperimentRequest(Identifier id) { + super(id); + } + + public String toString() { + return "Begin experiment initiated by: " + id; + } + +} Added: csidex/trunk/src/main/java/edu/asu/commons/event/BeginRoundRequest.java ============================================================================== --- (empty file) +++ csidex/trunk/src/main/java/edu/asu/commons/event/BeginRoundRequest.java Wed Jul 23 15:15:18 2008 @@ -0,0 +1,28 @@ +package edu.asu.commons.event; + +import edu.asu.commons.net.Identifier; + +/** + * $Id$ + * + * Used by the facilitator to signal that we are done collecting clients and + * ready to start the next experiment. + * + * + * @author Allen Lee + * @version $Revision$ + */ + +public class BeginRoundRequest extends AbstractEvent { + + private static final long serialVersionUID = -1853850747915213143L; + + public BeginRoundRequest(Identifier id) { + super(id); + } + + public String toString() { + return "Begin experiment initiated by: " + id; + } + +} Added: csidex/trunk/src/main/java/edu/asu/commons/event/ChatEvent.java ============================================================================== --- (empty file) +++ csidex/trunk/src/main/java/edu/asu/commons/event/ChatEvent.java Wed Jul 23 15:15:18 2008 @@ -0,0 +1,55 @@ +package edu.asu.commons.event; + +import edu.asu.commons.net.Identifier; + + + +/** + * $Id$ + * + * Sent from the server to a client target (with Identifier getId()) from the client identified by getSource(). + * Essentially the same as a ChatRequest, but with permuted instance fields. + * + * @author <a href='All...@as...'>Allen Lee</a> + * @version $Revision$ + */ + +public class ChatEvent extends AbstractEvent { + + private static final long serialVersionUID = 475300882222383637L; + + private final String message; + + private Identifier source; + + private boolean addressedToAll; + + public ChatEvent(Identifier id, String message, Identifier source) { + super(id); + this.message = message; + this.source = source; + } + + public ChatEvent(Identifier id, String message, Identifier source, boolean addressedToAll) { + super(id); + this.message = message; + this.source = source; + this.addressedToAll = addressedToAll; + } + + public Identifier getSource() { + return source; + } + + public Identifier getTarget() { + return isAddressedToAll() ? Identifier.ALL : id; + } + + public String toString() { + return message; + } + + public boolean isAddressedToAll() { + return addressedToAll; + } +} Added: csidex/trunk/src/main/java/edu/asu/commons/event/ChatRequest.java ============================================================================== --- (empty file) +++ csidex/trunk/src/main/java/edu/asu/commons/event/ChatRequest.java Wed Jul 23 15:15:18 2008 @@ -0,0 +1,48 @@ +package edu.asu.commons.event; + +import edu.asu.commons.net.Identifier; + +/** + * $Id$ + * + * Sent from a client to the server signaling that the client wants to talk to a different client identified by getTarget(). + * + * @author <a href='All...@as...'>Allen Lee</a> + * @version $Revision$ + */ + +public class ChatRequest extends AbstractPersistableEvent implements ClientRequest { + + private static final long serialVersionUID = 475300882222383637L; + + private final Identifier target; + private final String message; + + /** + * A communication event with a target of Identifier.ALL is broadcast to all group participants. + * @param source + * @param message + */ + public ChatRequest(Identifier id, String message, Identifier target) { + super(id); + this.message = message; + this.target = target; + } + + // copy constructor for server-side timestamping + public ChatRequest(ChatRequest request) { + this(request.getId(), request.toString(), request.getTarget()); + } + + public Identifier getSource() { + return id; + } + + public Identifier getTarget() { + return target; + } + + public String toString() { + return message; + } +} Added: csidex/trunk/src/main/java/edu/asu/commons/event/ClientErrorMessageEvent.java ============================================================================== --- (empty file) +++ csidex/trunk/src/main/java/edu/asu/commons/event/ClientErrorMessageEvent.java Wed Jul 23 15:15:18 2008 @@ -0,0 +1,33 @@ +package edu.asu.commons.event; + +import edu.asu.commons.net.Identifier; + + + +/** + * $Id$ + * + * A message from the server to the client indicating some kind of error occurred. + * There does not always need to be a wrapped Exception. + * + * @author <a href='mailto:All...@as...'>Allen Lee</a> + * @version $Revision$ + */ + +public class ClientErrorMessageEvent extends AbstractEvent { + + private static final long serialVersionUID = 3561105311719978543L; + + private final Throwable throwable; + + public ClientErrorMessageEvent(Identifier id, Throwable throwable) { + super(id, throwable.getMessage()); + this.throwable = throwable; + } + + public Throwable getThrowable() { + return throwable; + } + +} + Added: csidex/trunk/src/main/java/edu/asu/commons/event/ClientMessageEvent.java ============================================================================== --- (empty file) +++ csidex/trunk/src/main/java/edu/asu/commons/event/ClientMessageEvent.java Wed Jul 23 15:15:18 2008 @@ -0,0 +1,26 @@ +package edu.asu.commons.event; + +import edu.asu.commons.net.Identifier; + + + +/** + * $Id$ + * + * A message from the server to the client indicating some kind of error occurred. + * There does not always need to be a wrapped Exception. + * + * @author <a href='mailto:All...@as...'>Allen Lee</a> + * @version $Revision$ + */ + +public class ClientMessageEvent extends AbstractEvent { + + private static final long serialVersionUID = -2213276291145127929L; + + public ClientMessageEvent(Identifier id, String message) { + super(id, message); + } + +} + Added: csidex/trunk/src/main/java/edu/asu/commons/event/ClientRequest.java ============================================================================== --- (empty file) +++ csidex/trunk/src/main/java/edu/asu/commons/event/ClientRequest.java Wed Jul 23 15:15:18 2008 @@ -0,0 +1,13 @@ +package edu.asu.commons.event; + +/** + * $Id$ + * + * Marker interface for requests originating from the Client. + * + * @author <a href='All...@as...'>Allen Lee</a> + * @version $Revision$ + */ +public interface ClientRequest extends Event { + +} Added: csidex/trunk/src/main/java/edu/asu/commons/event/ConfigurationEvent.java ============================================================================== --- (empty file) +++ csidex/trunk/src/main/java/edu/asu/commons/event/ConfigurationEvent.java Wed Jul 23 15:15:18 2008 @@ -0,0 +1,22 @@ +package edu.asu.commons.event; + +import edu.asu.commons.conf.ExperimentConfiguration; +import edu.asu.commons.net.Identifier; + + +public class ConfigurationEvent<T extends ExperimentConfiguration<?>> extends AbstractEvent { + + private static final long serialVersionUID = 1153572405897631171L; + + private final T configuration; + + public ConfigurationEvent(Identifier id, T configuration) { + super(id); + this.configuration = configuration; + } + + public T getConfiguration() { + return configuration; + } + +} Added: csidex/trunk/src/main/java/edu/asu/commons/event/EndExperimentRequest.java ============================================================================== --- (empty file) +++ csidex/trunk/src/main/java/edu/asu/commons/event/EndExperimentRequest.java Wed Jul 23 15:15:18 2008 @@ -0,0 +1,26 @@ +package edu.asu.commons.event; + +import edu.asu.commons.net.Identifier; + +/** + * $Id$ + * + * Used by the facilitator to signal that we want to reset the experiment to its initial state. + * + * @author Allen Lee + * @version $Revision$ + */ + +public class EndExperimentRequest extends AbstractEvent { + + private static final long serialVersionUID = -5738727407426476168L; + + public EndExperimentRequest(Identifier id) { + super(id); + } + + public String toString() { + return "End experiment initiated by: " + id; + } + +} Added: csidex/trunk/src/main/java/edu/asu/commons/event/EndRoundRequest.java ============================================================================== --- (empty file) +++ csidex/trunk/src/main/java/edu/asu/commons/event/EndRoundRequest.java Wed Jul 23 15:15:18 2008 @@ -0,0 +1,23 @@ +package edu.asu.commons.event; + +import edu.asu.commons.net.Identifier; + +/** + * $Id$ + * + * Marker event used by client to signal server that the game should be aborted. + * Should employ some intelligent something or other on the server side to + * prevent evul h4x0rs from aborting the game over and over. + * + * @author Allen Lee + * @version $Revision$ + */ + +public class EndRoundRequest extends AbstractEvent implements FacilitatorRequest { + + private static final long serialVersionUID = -7113964603025019120L; + + public EndRoundRequest(Identifier id) { + super(id, "Abort round initiated by: " + id); + } +} Added: csidex/trunk/src/main/java/edu/asu/commons/event/Event.java ============================================================================== --- (empty file) +++ csidex/trunk/src/main/java/edu/asu/commons/event/Event.java Wed Jul 23 15:15:18 2008 @@ -0,0 +1,22 @@ +package edu.asu.commons.event; + +import java.io.Serializable; + +import edu.asu.commons.net.Identifier; + +/** + * $Id$ + * + * Event marker interface, tags all semantic messages used locally within + * the event channel or transmit remotely via the Dispatcher. + * + * @author <a href='al...@cs...'>Allen Lee</a> + * @version $Revision$ + */ +public interface Event extends Serializable { + + public Identifier getId(); + // FIXME: use TimePoints instead. + public long getCreationTime(); + +} Added: csidex/trunk/src/main/java/edu/asu/commons/event/EventChannel.java ============================================================================== --- (empty file) +++ csidex/trunk/src/main/java/edu/asu/commons/event/EventChannel.java Wed Jul 23 15:15:18 2008 @@ -0,0 +1,17 @@ +package edu.asu.commons.event; + +/** + * $Id$ + * + * + * @author <a href='mailto:All...@as...'>Allen Lee</a> + * @version $Revision$ + */ + +public interface EventChannel extends EventHandler<Event> { + + public void add(Object owner, EventProcessor<? extends Event> processor); + public void remove(Object owner); + public void dispatch(Event event); + +} Added: csidex/trunk/src/main/java/edu/asu/commons/event/EventChannelFactory.java ============================================================================== --- (empty file) +++ csidex/trunk/src/main/java/edu/asu/commons/event/EventChannelFactory.java Wed Jul 23 15:15:18 2008 @@ -0,0 +1,15 @@ +package edu.asu.commons.event; + +/** + * $Id$ + * + * @author <a href='All...@as...'>Allen Lee</a> + * @version $Revision$ + */ +public class EventChannelFactory { + + public static EventChannel create() { + return new EventTypeChannel(); + } + +} Added: csidex/trunk/src/main/java/edu/asu/commons/event/EventConstraint.java ============================================================================== --- (empty file) +++ csidex/trunk/src/main/java/edu/asu/commons/event/EventConstraint.java Wed Jul 23 15:15:18 2008 @@ -0,0 +1,26 @@ +package edu.asu.commons.event; +/** + * $Id$ + * + * Constraints define a set of events. For any given event, a constraint's + * accepts() method should return true if that event is a member of its set, + * and false otherwise. + * + * @author alllee + * @version $Revision$ + */ +public interface EventConstraint { + /** + * Matches all events. + */ + public static final EventConstraint NONE = new EventConstraint() { + public boolean accepts(Event defendant) { + return true; + } + }; + /** + * Returns true if the given event fits the set of events defined by + * this constraint. + */ + public boolean accepts(Event event); +} Added: csidex/trunk/src/main/java/edu/asu/commons/event/EventConstraintChannel.java ============================================================================== --- (empty file) +++ csidex/trunk/src/main/java/edu/asu/commons/event/EventConstraintChannel.java Wed Jul 23 15:15:18 2008 @@ -0,0 +1,223 @@ +package edu.asu.commons.event; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Provides a generic event channel dispatching events to interested + * subscribers. Subscribers specify interest in a particular subset of Events + * by passing in an additional EventConstraint to the subscribe() method. + * + * @author Allen Lee + * @version $Revision$ + */ +public final class EventConstraintChannel implements EventGenerator, EventChannel { + + private final static EventConstraintChannel INSTANCE = new EventConstraintChannel(); + + private final Map<EventHandler<Event>, EventConstraint> eventListeners = + new HashMap<EventHandler<Event>, EventConstraint>(); + + // Maps a 'module' owner to a list of event processors (which encapsulate both EventHandling + // and an EventConstraint). + private final Map<Object, List<EventProcessor>> owners = + new HashMap<Object, List<EventProcessor>>(); + + private final Map<Class<? extends Event>, EventHandler<? extends Event>> typedEventMap = + new HashMap<Class<? extends Event>, EventHandler<? extends Event>>(); + + /** + * Provides access to a singleton version of the EventChannel. + * @return the EventChannel singleton + */ + public static EventConstraintChannel getInstance() { + return INSTANCE; + } + + /** + * Adds an event to the EventChannel which then propagates the event to + * all interested subscribers. EventHandler.handle(Event) is invoked in a separate + * thread of execution. + * + * @param event The event to distribute via this EventChannel. + */ + public void handle(final Event event) { + synchronized (eventListeners) { + new Thread() { + public void run() { + for (final Map.Entry<EventHandler<Event>, EventConstraint> entry : eventListeners.entrySet()) { + if (entry.getValue().accepts(event)) { + entry.getKey().handle(event); + } + } + } + }.start(); + } + } + + public void dispatch(final Event event) { + handle(event); + } + + // handles without the thread for better performance and/or sequential processing. + public void handleAndWait(final Event event) { + synchronized (eventListeners) { + for (final Map.Entry<EventHandler<Event>, EventConstraint> entry : eventListeners.entrySet()) { + if (entry.getValue().accepts(event)) { + entry.getKey().handle(event); + } + } + } + } + + public boolean acceptsSubtypes() { + return true; + } + + /** + * An EventTypeProcessor is a convenience type for subscribing to the pool and + * provides localized event handling for a given constraint. + * @param processor + */ + public void add(EventProcessor processor) { + subscribe(processor, processor); + } + + /** + * An EventTypeProcessor is a convenience type for subscribing to the pool and + * provides localized event handling for a given constraint. + * @param processor + */ + public void add(Object owner, EventProcessor processor) { + getEventProcessorsFor(owner).add(processor); + } + + private List<EventProcessor> getEventProcessorsFor(Object owner) { + synchronized (owners) { + List<EventProcessor> processors = owners.get(owner); + if (processors == null) { + processors = new EventProcessorList(); + owners.put(owner, processors); + } + return processors; + } + + } + + public List<EventProcessor> register(Object owner) { + return getEventProcessorsFor(owner); + } + + public void unregister(Object owner) { + List<EventProcessor> processors = null; + synchronized (owners) { + processors = owners.remove(owner); + } + if (processors != null) { + for (EventProcessor processor: processors) { + unsubscribe(processor); + } + } + } + + public void remove(Object owner) { + unregister(owner); + } + + /** + * The given handler will receive all Events received by this EventChannel + * accept()-ed by the given EventConstraint. + * + * @param handler The EventHandler to subscribe. + * @param constraint The constraint with which to filter events. + */ + public void subscribe(EventHandler<Event> handler, EventConstraint constraint) { + if (handler == this) { + throw new IllegalArgumentException( + "Cannot subscribe the event channel to itself."); + } + synchronized (eventListeners) { + eventListeners.put(handler, constraint); + } + } + + public void subscribe(EventHandler<Event> handler) { + subscribe(handler, EventConstraint.NONE); + } + + /** + * Unsubscribes an EventHandler from this EventChannel, stopping it from receiving any + * events from this EventChannel. + * + * @param handler The EventHandler to unsubscribe. + */ + public void unsubscribe(EventHandler<Event> handler) { + synchronized (eventListeners) { + eventListeners.remove(handler); + } + } + + /** + * $Id$ + * + * FIXME: this class should support automatic subscription/unsubscription with all methods that + * add/remove to this List. Right now only the basic add/remove methods are supported. + */ + private class EventProcessorList extends ArrayList<EventProcessor> { + private static final long serialVersionUID = -4756601346604320046L; + @Override + public boolean add(EventProcessor processor) { + subscribe(processor, processor); + return super.add(processor); + } + @Override + public void add(int index, EventProcessor processor) { + subscribe(processor, processor); + super.add(index, processor); + } + @Override + public boolean addAll(Collection<? extends EventProcessor> c) { + for (EventProcessor processor: c) { + subscribe(processor, processor); + } + return super.addAll(c); + } + @Override + public boolean addAll(int index, Collection<? extends EventProcessor> c) { + for (EventProcessor processor: c) { + subscribe(processor, processor); + } + return super.addAll(index, c); + } + @Override + public EventProcessor remove(int index) { + EventProcessor removed = super.remove(index); + unsubscribe(removed); + return removed; + } + @Override + public boolean remove(Object o) { + if (o instanceof EventProcessor) { + unsubscribe((EventProcessor) o); + } + return super.remove(o); + } + @Override + public boolean removeAll(Collection<?> c) { + for (Object o: c) { + if (o instanceof EventProcessor) { + unsubscribe((EventProcessor) o); + } + } + return super.removeAll(c); + } + + } + + public Class<Event> getEventClass() { + return Event.class; + } +} Added: csidex/trunk/src/main/java/edu/asu/commons/event/EventGenerator.java ============================================================================== --- (empty file) +++ csidex/trunk/src/main/java/edu/asu/commons/event/EventGenerator.java Wed Jul 23 15:15:18 2008 @@ -0,0 +1,31 @@ +package edu.asu.commons.event; + +/** + * $Id$ + * + * Marks all classes capable of generating Events and dispatching them to + * interested subscribers. + * + * @author alllee + * @version $Revision$ + */ +public interface EventGen... [truncated message content] |
From: <al...@as...> - 2008-07-03 21:02:48
|
Author: alllee Date: Thu Jul 3 14:04:01 2008 New Revision: 58 Added: trunk/lib/xpp3.jar (contents, props changed) trunk/lib/xstream.jar (contents, props changed) Log: adding xstream and xpp3 to csidnet Added: trunk/lib/xpp3.jar ============================================================================== Binary file. No diff available. Added: trunk/lib/xstream.jar ============================================================================== Binary file. No diff available. |
From: <al...@as...> - 2008-07-03 20:59:38
|
Author: alllee Date: Thu Jul 3 14:00:51 2008 New Revision: 57 Added: trunk/src/edu/asu/csid/conf/PersistenceType.java (contents, props changed) Log: new enum class to mark persistence type for top level Experiment Configurations. Added: trunk/src/edu/asu/csid/conf/PersistenceType.java ============================================================================== --- (empty file) +++ trunk/src/edu/asu/csid/conf/PersistenceType.java Thu Jul 3 14:00:51 2008 @@ -0,0 +1,9 @@ +package edu.asu.csid.conf; + +public enum PersistenceType { + ALL, XML, BINARY; + + public boolean isXmlEnabled() { + return this == ALL || this == XML; + } +} |
From: <al...@as...> - 2008-07-03 20:59:19
|
Author: alllee Date: Thu Jul 3 14:00:31 2008 New Revision: 56 Modified: trunk/.classpath trunk/src/edu/asu/csid/conf/ExperimentConfiguration.java trunk/src/edu/asu/csid/experiment/Persister.java trunk/src/edu/asu/csid/experiment/SavedRoundData.java Log: adding xstream and chatlog support to Persister, but need to tweak performance. Modified: trunk/.classpath ============================================================================== --- trunk/.classpath (original) +++ trunk/.classpath Thu Jul 3 14:00:31 2008 @@ -4,5 +4,6 @@ <classpathentry kind="src" path="test"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> + <classpathentry kind="lib" path="lib/xstream.jar"/> <classpathentry kind="output" path="build"/> </classpath> Modified: trunk/src/edu/asu/csid/conf/ExperimentConfiguration.java ============================================================================== --- trunk/src/edu/asu/csid/conf/ExperimentConfiguration.java (original) +++ trunk/src/edu/asu/csid/conf/ExperimentConfiguration.java Thu Jul 3 14:00:31 2008 @@ -33,6 +33,8 @@ public InetSocketAddress getServerAddress(); public String getPersistenceDirectory(); + + public PersistenceType getPersistenceType(); public boolean isFirstRound(); public boolean isLastRound(); @@ -183,6 +185,11 @@ public String getPersistenceDirectory() { return assistant.getStringProperty("save-dir", "experiment-data"); } + + public PersistenceType getPersistenceType() { + String persistenceType = assistant.getStringProperty("persistence-type", "BINARY"); + return PersistenceType.valueOf(persistenceType); + } } Modified: trunk/src/edu/asu/csid/experiment/Persister.java ============================================================================== --- trunk/src/edu/asu/csid/experiment/Persister.java (original) +++ trunk/src/edu/asu/csid/experiment/Persister.java Thu Jul 3 14:00:31 2008 @@ -14,50 +14,84 @@ import java.util.List; import java.util.SortedSet; import java.util.TreeSet; +import java.util.logging.FileHandler; import java.util.logging.Level; import java.util.logging.Logger; +import com.thoughtworks.xstream.persistence.FileStreamStrategy; +import com.thoughtworks.xstream.persistence.XmlSet; + import edu.asu.csid.conf.ExperimentConfiguration; import edu.asu.csid.conf.ExperimentRoundParameters; +import edu.asu.csid.event.ChatRequest; import edu.asu.csid.event.EventChannel; import edu.asu.csid.event.EventTypeProcessor; import edu.asu.csid.event.PersistableEvent; public abstract class Persister<T extends ExperimentConfiguration<R>, R extends ExperimentRoundParameters<T>> { - - private final static String ROUND_SAVE_DIRECTORY_FORMAT = "MM-dd-yyyy HH.mm.ss"; + + // FIXME: test on windows and mac to make sure that File.separator doesn't cause any bugs. + private final static String ROUND_SAVE_DIRECTORY_FORMAT = "MM-dd-yyyy" + File.separator + "HH.mm.ss"; private final static String DEFAULT_EXPERIMENT_CONFIGURATION_FILE = "experiment-configuration.save"; + private final static String DEFAULT_CHAT_LOG_FILE_NAME = "chat.log"; // FIXME: set up some kind of application logging for the server side classes. private final static Logger logger = Logger.getLogger(Persister.class.getName()); + private final Logger chatLogger = Logger.getLogger("chat-logger"); + private FileHandler chatLogFileHandler; + private R roundConfiguration; private final SortedSet<PersistableEvent> actions; + private final SortedSet<ChatRequest> chats; private String experimentSaveDirectory; private String persistenceDirectory; private EventChannel channel; -// private boolean usingEventChannel; +// private final XStream xstream = new XStream(); +// private PrintWriter xmlPrintWriter; - public static SavedRoundData restoreSavedRoundData(File directory, int roundNumber) { - if (roundNumber < 0) { - throw new IllegalArgumentException("Invalid round number: " + roundNumber); - } - if (! directory.exists()) { - throw new IllegalArgumentException("Directory " + directory.getAbsolutePath() + " does not exist."); - } - String roundSaveFilePath = getRoundSaveFilePath(directory.getAbsolutePath(), roundNumber); - return SavedRoundData.create(roundSaveFilePath); - } + private XmlSet xmlSet; + private boolean xmlEnabled; + +// private boolean usingEventChannel; + public Persister(T experimentConfiguration) { this.persistenceDirectory = experimentConfiguration.getPersistenceDirectory(); this.actions = new TreeSet<PersistableEvent>(); + this.chats = new TreeSet<ChatRequest>(); + // initialize persister with first round parameters SimpleDateFormat simpleDateFormat = new SimpleDateFormat(ROUND_SAVE_DIRECTORY_FORMAT); this.experimentSaveDirectory = simpleDateFormat.format(new Date()); - saveConfiguration(experimentConfiguration); + initialize(experimentConfiguration.getCurrentParameters()); + saveExperimentConfiguration(experimentConfiguration); + initializeChatLogFileHandler(); + } + + private void initializeXmlSave() { + xmlEnabled = roundConfiguration.getParentConfiguration().getPersistenceType().isXmlEnabled(); + if ( xmlEnabled ) { + String xmlSaveFilePath = getXmlSaveFilePath(); + System.err.println("saving xml files to: " + xmlSaveFilePath); + createDirectoryIfNeeded(xmlSaveFilePath); + xmlSet = new XmlSet(new FileStreamStrategy(new File(xmlSaveFilePath))); + /* + try { + xmlPrintWriter = new PrintWriter(getRoundSaveFilePath(persistenceDirectory + File.separator + "xml", roundConfiguration.getRoundNumber())); + } + catch (IOException e) { + e.printStackTrace(); + logger.severe("Could not initialize xml print writer."); + } + */ + } + } + + private String getXmlSaveFilePath() { + return getDefaultSavePath() + File.separator + roundConfiguration.getRoundNumber() + ".round.xml"; } public Persister(EventChannel channel, T experimentConfiguration) { @@ -75,8 +109,24 @@ }); } + private void initializeChatLogFileHandler() { + String chatLogPath = getDefaultSavePath() + File.separator + DEFAULT_CHAT_LOG_FILE_NAME; + try { + + chatLogFileHandler = new FileHandler(chatLogPath); + chatLogger.addHandler(chatLogFileHandler); + chatLogger.setLevel(Level.ALL); + } + catch (IOException e) { + e.printStackTrace(); + logger.severe("Unable to initialize chat log: " + chatLogPath); + } + } + public void stop() { channel.remove(this); + chatLogger.removeHandler(chatLogFileHandler); + chatLogFileHandler.close(); } public SortedSet<PersistableEvent> getActions() { @@ -90,11 +140,35 @@ synchronized (actions) { actions.add(event); } + if (isXmlEnabled()) { + synchronized (xmlSet) { + xmlSet.add(event); + } + } + } + + private boolean isXmlEnabled() { + return xmlEnabled; + } + + public void store(ChatRequest request) { + request.timestamp(); + // FIXME: this is inefficient, but chat data shouldn't be too huge.. should it? + synchronized (chats) { + chats.add(request); + } + chatLogger.log(Level.ALL, + String.format("%s, %s, %s, %s", + request.getCreationTime(), + request.getSource(), + request.getTarget(), + request.toString())); } public final void initialize(R roundConfiguration) { clear(); this.roundConfiguration = roundConfiguration; + initializeXmlSave(); } /** @@ -196,7 +270,7 @@ // now really give up unrecoverable.printStackTrace(); throw new RuntimeException( - "Couldn't save to the failsafe directory", unrecoverable); + "Unable to save to the failsafe directory: " + getFailSafeSaveDirectory(), unrecoverable); } } @@ -218,28 +292,54 @@ return String.format("%s%sround-%d.save", directory, File.separator, roundNumber); } + public static SavedRoundData restoreSavedRoundData(File directory, int roundNumber) { + if (roundNumber < 0) { + throw new IllegalArgumentException("Invalid round number: " + roundNumber); + } + if (! directory.exists()) { + throw new IllegalArgumentException("Directory " + directory.getAbsolutePath() + " does not exist."); + } + String roundSaveFilePath = getRoundSaveFilePath(directory.getAbsolutePath(), roundNumber); + return SavedRoundData.create(roundSaveFilePath); + } + protected abstract String getFailSafeSaveDirectory(); protected String getExperimentConfigurationSaveFileName() { return DEFAULT_EXPERIMENT_CONFIGURATION_FILE; } - private void saveConfiguration(T serverConfiguration) { + private void saveExperimentConfiguration(T experimentConfiguration) { + + try { + doSaveExperimentConfiguration(experimentConfiguration, persistenceDirectory); + } + catch (FileNotFoundException recoverable) { + recoverable.printStackTrace(); + try { + doSaveExperimentConfiguration(experimentConfiguration, getFailSafeSaveDirectory()); + } + catch (IOException e) { + e.printStackTrace(); + throw new RuntimeException("Unable to save to failsafe directory: " + getFailSafeSaveDirectory(), e); + } + } + catch (IOException e) { + e.printStackTrace(); + throw new RuntimeException("Unable to save experiment configuration to persistenceDirectory:" + persistenceDirectory, e); + } + } + + private void doSaveExperimentConfiguration(T experimentConfiguration, String persistenceDirectory) throws IOException { ObjectOutputStream objectOutputStream = null; + String savePath = getSavePath(persistenceDirectory); try { - String savePath = getSavePath(persistenceDirectory); createDirectoryIfNeeded(savePath); String configurationSavePath = savePath + File.separator + getExperimentConfigurationSaveFileName(); objectOutputStream = new ObjectOutputStream(new FileOutputStream(configurationSavePath)); - objectOutputStream.writeObject(serverConfiguration); + objectOutputStream.writeObject(experimentConfiguration); objectOutputStream.flush(); } - catch (FileNotFoundException e) { - e.printStackTrace(); - } - catch (IOException e) { - e.printStackTrace(); - } finally { try { if (objectOutputStream != null) { @@ -254,6 +354,7 @@ private <E extends DataModel<R>> void saveRound(E serverDataModel, String persistenceDirectory) throws IOException { String saveDestination = getSavePath(persistenceDirectory); + int roundNumber = roundConfiguration.getRoundNumber(); ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(getRoundSaveFilePath(saveDestination, roundConfiguration.getRoundNumber()))); try { @@ -262,6 +363,9 @@ synchronized (actions) { oos.writeObject(actions); } + synchronized (chats) { + oos.writeObject(chats); + } oos.flush(); } finally { @@ -279,6 +383,15 @@ } } + private String getDefaultSavePath() { + return getSavePath(persistenceDirectory); + } + + /** + * Returns the experiment data directory concatenated with the current run's experiment directory. + * @param persistenceDirectory + * @return + */ private String getSavePath(String persistenceDirectory) { return persistenceDirectory + File.separator + experimentSaveDirectory; } Modified: trunk/src/edu/asu/csid/experiment/SavedRoundData.java ============================================================================== --- trunk/src/edu/asu/csid/experiment/SavedRoundData.java (original) +++ trunk/src/edu/asu/csid/experiment/SavedRoundData.java Thu Jul 3 14:00:31 2008 @@ -47,8 +47,7 @@ this.saveFilePath = roundSaveFilePath; this.roundParameters = roundParameters; this.dataModel = dataModel; - this.actions = actions; - this.roundStartTime = actions.iterator().next().getCreationTime(); + setActions(actions); } public static SavedRoundData create(String roundSaveFilePath) { @@ -143,6 +142,5 @@ roundStartTime = actions.iterator().next().getCreationTime(); this.actions = actions; } - } } |
From: <al...@as...> - 2008-06-30 23:48:10
|
Author: alllee Date: Mon Jun 30 16:49:18 2008 New Revision: 55 Modified: trunk/src/edu/asu/csid/experiment/SaveFileProcessor.java trunk/src/edu/asu/csid/experiment/SavedRoundData.java Log: improving error handling capabilities of SaveFileProcessor/SavedRoundData. Still need to fix CsanSaveFileConverter's aggregate stat generator. Modified: trunk/src/edu/asu/csid/experiment/SaveFileProcessor.java ============================================================================== --- trunk/src/edu/asu/csid/experiment/SaveFileProcessor.java (original) +++ trunk/src/edu/asu/csid/experiment/SaveFileProcessor.java Mon Jun 30 16:49:18 2008 @@ -25,14 +25,14 @@ /** * - * @param savedRoundData - * @param stream + * @param savedRoundData the restored round data in Java object form. + * @param stream an output stream for the processed round data file. */ public void process(SavedRoundData savedRoundData, OutputStream stream); /** * - * @param savedRoundData - * @param roundSaveFile + * @param savedRoundData the restored round data in Java object form. + * @param roundSaveFile the full path to the processed round data file (which will be created upon successful exit of this method). */ public void process(SavedRoundData savedRoundData, String roundSaveFile); public String getOutputFileExtension(); @@ -53,6 +53,9 @@ e.printStackTrace(); throw new RuntimeException(e); } + finally { + dispose(); + } } public abstract void process(SavedRoundData savedRoundData, PrintWriter writer); @@ -63,7 +66,10 @@ writer.flush(); writer.close(); } - + + /** + * + */ public String getOutputFileName() { return roundSaveFile.concat( getOutputFileExtension() ); } Modified: trunk/src/edu/asu/csid/experiment/SavedRoundData.java ============================================================================== --- trunk/src/edu/asu/csid/experiment/SavedRoundData.java (original) +++ trunk/src/edu/asu/csid/experiment/SavedRoundData.java Mon Jun 30 16:49:18 2008 @@ -3,6 +3,7 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.ObjectInputStream; +import java.io.Serializable; import java.util.SortedSet; import java.util.logging.Logger; @@ -12,21 +13,35 @@ /** * $Id$ * - * Struct class for saved round data. + * Struct-ish class for saved round data. Should see if we can somehow preserve type information here. + * + * FIXME: how best to encode specific/concrete experiment types, like ServerConfiguration, RoundConfiguration, and ServerDataModel concrete subtypes + * in such a way that the library (i.e., this class) can return objects of the appropriate type to a caller? Right now the getter methods for + * this class just return the base interface type so casts are necessary to extract any round-specific data from the ExperimentRoundParameters or DataModel. * * @author <a href='mailto:All...@as...'>Allen Lee</a> * @version $Revision$ */ -public class SavedRoundData { +public class SavedRoundData implements Serializable { + private static final long serialVersionUID = -2136359143854670064L; + private final static Logger logger = Logger.getLogger(Persister.class.getName()); - private final ExperimentRoundParameters roundParameters; - private final DataModel dataModel; - private final SortedSet<PersistableEvent> actions; + private ExperimentRoundParameters roundParameters; + private DataModel dataModel; + private SortedSet<PersistableEvent> actions; private final String saveFilePath; - private final long roundStartTime; + private long roundStartTime; + + public SavedRoundData() { + this(""); + } + + public SavedRoundData(String roundSaveFilePath) { + this(roundSaveFilePath, null, null, null); + } public SavedRoundData(String roundSaveFilePath, ExperimentRoundParameters roundParameters, DataModel dataModel, SortedSet<PersistableEvent> actions) { this.saveFilePath = roundSaveFilePath; @@ -38,12 +53,18 @@ public static SavedRoundData create(String roundSaveFilePath) { ObjectInputStream stream = null; + SavedRoundData savedRoundData = new SavedRoundData(roundSaveFilePath); try { stream = new ObjectInputStream(new FileInputStream(roundSaveFilePath)); + ExperimentRoundParameters roundParameters = (ExperimentRoundParameters) stream.readObject(); + savedRoundData.setRoundParameters(roundParameters); + DataModel dataModel = (DataModel) stream.readObject(); + savedRoundData.setDataModel(dataModel); SortedSet<PersistableEvent> actions = (SortedSet<PersistableEvent>) stream.readObject(); - SavedRoundData savedRoundData = new SavedRoundData(roundSaveFilePath, roundParameters, dataModel, actions); + savedRoundData.setActions(actions); +// SavedRoundData savedRoundData = new SavedRoundData(roundSaveFilePath, roundParameters, dataModel, actions); return savedRoundData; } catch (IOException e) { @@ -108,5 +129,20 @@ double seconds = (double) t / 1000.0; return (int) seconds; } - + + public void setRoundParameters(ExperimentRoundParameters roundParameters) { + this.roundParameters = roundParameters; + } + + public void setDataModel(DataModel dataModel) { + this.dataModel = dataModel; + } + + public void setActions(SortedSet<PersistableEvent> actions) { + if (actions != null && ! actions.isEmpty()) { + roundStartTime = actions.iterator().next().getCreationTime(); + this.actions = actions; + } + + } } |