Mercurial > hg > Database > jungle-network
changeset 182:1cdde53a7ce8
merge
author | kono |
---|---|
date | Sun, 13 Jul 2014 18:16:52 +0900 |
parents | 13ececb7e35e (diff) 48f815fa7f74 (current diff) |
children | f54d4ab5df4b |
files | .project |
diffstat | 10 files changed, 258 insertions(+), 154 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.classpath Sun Jul 13 18:16:52 2014 +0900 @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry including="**/*.java" kind="src" output="target/test-classes" path="src/test/java"/> + <classpathentry including="**/*.java" kind="src" path="src/main/java"/> + <classpathentry kind="var" path="M2_REPO/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar"/> + <classpathentry kind="var" path="M2_REPO/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="var" path="M2_REPO/junit/junit/4.7/junit-4.7.jar"/> + <classpathentry kind="var" path="M2_REPO/org/eclipse/jetty/jetty-server/9.2.1.v20140609/jetty-server-9.2.1.v20140609.jar" sourcepath="/jetty/jetty-server/9.2.1.v20140609/jetty-server-9.2.1.v20140609-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/org/eclipse/jetty/jetty-http/9.2.1.v20140609/jetty-http-9.2.1.v20140609.jar" sourcepath="/M2_REPO/org/eclipse/jetty/jetty-http/9.2.1.v20140609/jetty-http-9.2.1.v20140609-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/org/eclipse/jetty/jetty-util/9.2.1.v20140609/jetty-util-9.2.1.v20140609.jar" sourcepath="/M2_REPO/org/eclipse/jetty/jetty-util/9.2.1.v20140609/jetty-util-9.2.1.v20140609-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/org/eclipse/jetty/jetty-io/9.2.1.v20140609/jetty-io-9.2.1.v20140609.jar" sourcepath="/M2_REPO/org/eclipse/jetty/jetty-io/9.2.1.v20140609/jetty-io-9.2.1.v20140609-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/org/eclipse/jetty/jetty-servlet/9.2.1.v20140609/jetty-servlet-9.2.1.v20140609.jar" sourcepath="/jetty/jetty-servlet/9.2.1.v20140609/jetty-servlet-9.2.1.v20140609-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/org/eclipse/jetty/jetty-security/9.2.1.v20140609/jetty-security-9.2.1.v20140609.jar"/> + <classpathentry kind="var" path="M2_REPO/org/hectorclient/hector-core/1.1-2/hector-core-1.1-2.jar"/> + <classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.4/commons-lang-2.4.jar"/> + <classpathentry kind="var" path="M2_REPO/commons-pool/commons-pool/1.5.3/commons-pool-1.5.3.jar"/> + <classpathentry kind="var" path="M2_REPO/org/apache/cassandra/cassandra-thrift/1.1.0/cassandra-thrift-1.1.0.jar"/> + <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar"/> + <classpathentry kind="var" path="M2_REPO/org/apache/thrift/libthrift/0.7.0/libthrift-0.7.0.jar"/> + <classpathentry kind="var" path="M2_REPO/org/apache/httpcomponents/httpclient/4.0.1/httpclient-4.0.1.jar"/> + <classpathentry kind="var" path="M2_REPO/org/apache/httpcomponents/httpcore/4.0.1/httpcore-4.0.1.jar"/> + <classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar"/> + <classpathentry kind="var" path="M2_REPO/commons-codec/commons-codec/1.3/commons-codec-1.3.jar"/> + <classpathentry kind="var" path="M2_REPO/com/google/guava/guava/r09/guava-r09.jar"/> + <classpathentry kind="var" path="M2_REPO/com/github/stephenc/eaio-uuid/uuid/3.3.0/uuid-3.3.0.jar"/> + <classpathentry kind="var" path="M2_REPO/com/ecyrd/speed4j/speed4j/0.9/speed4j-0.9.jar"/> + <classpathentry kind="var" path="M2_REPO/org/functionaljava/functionaljava/3.1/functionaljava-3.1.jar"/> + <classpathentry kind="var" path="M2_REPO/org/msgpack/msgpack/0.6.8/msgpack-0.6.8.jar" sourcepath="/M2_REPO/org/msgpack/msgpack/0.6.8/msgpack-0.6.8-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1.jar"/> + <classpathentry kind="var" path="M2_REPO/org/javassist/javassist/3.16.1-GA/javassist-3.16.1-GA.jar"/> + <classpathentry kind="src" path="/jungle-core"/> + <classpathentry kind="src" path="/bulletinboard"/> + <classpathentry combineaccessrules="false" kind="src" path="/Alice"/> + <classpathentry kind="output" path="target/classes"/> +</classpath>
--- a/.settings/org.eclipse.jdt.core.prefs Sun Jul 13 18:14:00 2014 +0900 +++ b/.settings/org.eclipse.jdt.core.prefs Sun Jul 13 18:16:52 2014 +0900 @@ -1,12 +1,13 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.source=1.8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/_classpath Sun Jul 13 18:16:52 2014 +0900 @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.java"/> + <classpathentry kind="src" path="src/main/java" including="**/*.java"/> + <classpathentry kind="output" path="target/classes"/> + <classpathentry kind="var" path="M2_REPO/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar" sourcepath="M2_REPO/javax/servlet/servlet-api/2.5/servlet-api-2.5-sources.jar"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="var" path="M2_REPO/junit/junit/4.7/junit-4.7.jar"/> + <classpathentry kind="var" path="M2_REPO/org/mortbay/jetty/jetty/6.1.26/jetty-6.1.26.jar" sourcepath="M2_REPO/org/mortbay/jetty/jetty/6.1.26/jetty-6.1.26-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/org/mortbay/jetty/jetty-util/6.1.26/jetty-util-6.1.26.jar" sourcepath="M2_REPO/org/mortbay/jetty/jetty-util/6.1.26/jetty-util-6.1.26-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/org/mortbay/jetty/servlet-api/2.5-20081211/servlet-api-2.5-20081211.jar" sourcepath="M2_REPO/org/mortbay/jetty/servlet-api/2.5-20081211/servlet-api-2.5-20081211-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/org/hectorclient/hector-core/1.1-2/hector-core-1.1-2.jar" sourcepath="M2_REPO/org/hectorclient/hector-core/1.1-2/hector-core-1.1-2-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.4/commons-lang-2.4.jar" sourcepath="M2_REPO/commons-lang/commons-lang/2.4/commons-lang-2.4-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/commons-pool/commons-pool/1.5.3/commons-pool-1.5.3.jar" sourcepath="M2_REPO/commons-pool/commons-pool/1.5.3/commons-pool-1.5.3-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/org/apache/cassandra/cassandra-thrift/1.1.0/cassandra-thrift-1.1.0.jar" sourcepath="M2_REPO/org/apache/cassandra/cassandra-thrift/1.1.0/cassandra-thrift-1.1.0-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar" sourcepath="M2_REPO/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/org/apache/thrift/libthrift/0.7.0/libthrift-0.7.0.jar"/> + <classpathentry kind="var" path="M2_REPO/org/apache/httpcomponents/httpclient/4.0.1/httpclient-4.0.1.jar" sourcepath="M2_REPO/org/apache/httpcomponents/httpclient/4.0.1/httpclient-4.0.1-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/org/apache/httpcomponents/httpcore/4.0.1/httpcore-4.0.1.jar" sourcepath="M2_REPO/org/apache/httpcomponents/httpcore/4.0.1/httpcore-4.0.1-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar" sourcepath="M2_REPO/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/commons-codec/commons-codec/1.2/commons-codec-1.2.jar"/> + <classpathentry kind="var" path="M2_REPO/com/google/guava/guava/r09/guava-r09.jar" sourcepath="M2_REPO/com/google/guava/guava/r09/guava-r09-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/com/github/stephenc/eaio-uuid/uuid/3.3.0/uuid-3.3.0.jar"/> + <classpathentry kind="var" path="M2_REPO/com/ecyrd/speed4j/speed4j/0.9/speed4j-0.9.jar" sourcepath="M2_REPO/com/ecyrd/speed4j/speed4j/0.9/speed4j-0.9-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/org/functionaljava/functionaljava/3.1/functionaljava-3.1.jar" sourcepath="M2_REPO/org/functionaljava/functionaljava/3.1/functionaljava-3.1-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/alice/alice/0.2/alice-0.2.jar"/> + <classpathentry kind="var" path="M2_REPO/org/msgpack/msgpack/0.6.8/msgpack-0.6.8.jar"/> + <classpathentry kind="var" path="M2_REPO/com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1.jar"/> + <classpathentry kind="var" path="M2_REPO/org/javassist/javassist/3.16.1-GA/javassist-3.16.1-GA.jar"/> + <classpathentry kind="src" path="/jungle-core"/> + <classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar" sourcepath="M2_REPO/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/org/apache/maven/surefire/surefire-junit4/2.13/surefire-junit4-2.13.jar" sourcepath="M2_REPO/org/apache/maven/surefire/surefire-junit4/2.13/surefire-junit4-2.13-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/org/apache/maven/surefire/surefire-api/2.13/surefire-api-2.13.jar" sourcepath="M2_REPO/org/apache/maven/surefire/surefire-api/2.13/surefire-api-2.13-sources.jar"/> + <classpathentry kind="src" path="/bulletinboard"/> + <classpathentry kind="var" path="M2_REPO/org/apache/cassandra/cassandra-all/1.2.1/cassandra-all-1.2.1.jar" sourcepath="M2_REPO/org/apache/cassandra/cassandra-all/1.2.1/cassandra-all-1.2.1-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/org/xerial/snappy/snappy-java/1.0.4.1/snappy-java-1.0.4.1.jar" sourcepath="M2_REPO/org/xerial/snappy/snappy-java/1.0.4.1/snappy-java-1.0.4.1-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/com/ning/compress-lzf/0.8.4/compress-lzf-0.8.4.jar" sourcepath="M2_REPO/com/ning/compress-lzf/0.8.4/compress-lzf-0.8.4-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/commons-cli/commons-cli/1.1/commons-cli-1.1.jar" sourcepath="M2_REPO/commons-cli/commons-cli/1.1/commons-cli-1.1-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/com/googlecode/concurrentlinkedhashmap/concurrentlinkedhashmap-lru/1.3/concurrentlinkedhashmap-lru-1.3.jar" sourcepath="M2_REPO/com/googlecode/concurrentlinkedhashmap/concurrentlinkedhashmap-lru/1.3/concurrentlinkedhashmap-lru-1.3-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/org/antlr/antlr/3.2/antlr-3.2.jar" sourcepath="M2_REPO/org/antlr/antlr/3.2/antlr-3.2-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.2/antlr-runtime-3.2.jar" sourcepath="M2_REPO/org/antlr/antlr-runtime/3.2/antlr-runtime-3.2-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/org/antlr/stringtemplate/3.2/stringtemplate-3.2.jar"/> + <classpathentry kind="var" path="M2_REPO/antlr/antlr/2.7.7/antlr-2.7.7.jar"/> + <classpathentry kind="var" path="M2_REPO/org/apache/cassandra/deps/avro/1.4.0-cassandra-1/avro-1.4.0-cassandra-1.jar" sourcepath="M2_REPO/org/apache/cassandra/deps/avro/1.4.0-cassandra-1/avro-1.4.0-cassandra-1-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/org/codehaus/jackson/jackson-mapper-asl/1.9.2/jackson-mapper-asl-1.9.2.jar" sourcepath="M2_REPO/org/codehaus/jackson/jackson-mapper-asl/1.9.2/jackson-mapper-asl-1.9.2-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/org/codehaus/jackson/jackson-core-asl/1.9.2/jackson-core-asl-1.9.2.jar" sourcepath="M2_REPO/org/codehaus/jackson/jackson-core-asl/1.9.2/jackson-core-asl-1.9.2-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/jline/jline/1.0/jline-1.0.jar" sourcepath="M2_REPO/jline/jline/1.0/jline-1.0-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/com/github/stephenc/high-scale-lib/high-scale-lib/1.1.2/high-scale-lib-1.1.2.jar" sourcepath="M2_REPO/com/github/stephenc/high-scale-lib/high-scale-lib/1.1.2/high-scale-lib-1.1.2-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/org/yaml/snakeyaml/1.6/snakeyaml-1.6.jar" sourcepath="M2_REPO/org/yaml/snakeyaml/1.6/snakeyaml-1.6-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/edu/stanford/ppl/snaptree/0.1/snaptree-0.1.jar" sourcepath="M2_REPO/edu/stanford/ppl/snaptree/0.1/snaptree-0.1-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/com/yammer/metrics/metrics-core/2.0.3/metrics-core-2.0.3.jar" sourcepath="M2_REPO/com/yammer/metrics/metrics-core/2.0.3/metrics-core-2.0.3-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/com/github/stephenc/jamm/0.2.5/jamm-0.2.5.jar" sourcepath="M2_REPO/com/github/stephenc/jamm/0.2.5/jamm-0.2.5-sources.jar"/> + <classpathentry kind="var" path="M2_REPO/com/eaio/uuid/uuid/3.3/uuid-3.3.jar"/> +</classpath> \ No newline at end of file
--- a/pom.xml Sun Jul 13 18:14:00 2014 +0900 +++ b/pom.xml Sun Jul 13 18:16:52 2014 +0900 @@ -27,11 +27,17 @@ <version>4.7</version> <scope>test</scope> </dependency> - <dependency> - <groupId>org.mortbay.jetty</groupId> - <artifactId>jetty</artifactId> - <version>6.1.26</version> - </dependency> +<dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-server</artifactId> + <version>9.2.1.v20140609</version> +</dependency> +<dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-servlet</artifactId> + <version>9.2.1.v20140609</version> +</dependency> + <dependency> <groupId>org.hectorclient</groupId> <artifactId>hector-core</artifactId> @@ -49,11 +55,6 @@ </dependency> <dependency> - <groupId>alice</groupId> - <artifactId>alice</artifactId> - <version>0.2</version> - </dependency> - <dependency> <groupId>org.msgpack</groupId> <artifactId>msgpack</artifactId> <version>0.6.8</version>
--- a/src/main/java/alice/jungle/persistent/PersistentJournal.java Sun Jul 13 18:14:00 2014 +0900 +++ b/src/main/java/alice/jungle/persistent/PersistentJournal.java Sun Jul 13 18:16:52 2014 +0900 @@ -14,7 +14,7 @@ public class PersistentJournal implements NetworkJournal { - private ChangeListWriter WRITER; + // private ChangeListWriter WRITER; private ChangeListReader READER; private OutputStream out; private InputStream in; @@ -25,7 +25,7 @@ public PersistentJournal(File file) throws FileNotFoundException { out = new FileOutputStream(file,true); in = new FileInputStream(file); - WRITER = new PersistentChangeListWriter(out); + // WRITER = new PersistentChangeListWriter(out); READER = new PersistentChangeListReader(in); } @@ -58,7 +58,7 @@ public void setOutputStream(OutputStream _out) { out = _out; - WRITER = new PersistentChangeListWriter(out); + // WRITER = new PersistentChangeListWriter(out); } public OutputStream getOutputStream() {
--- a/src/main/java/alice/jungle/remote/RemoteConfig.java Sun Jul 13 18:14:00 2014 +0900 +++ b/src/main/java/alice/jungle/remote/RemoteConfig.java Sun Jul 13 18:16:52 2014 +0900 @@ -17,4 +17,5 @@ } } } + }
--- a/src/main/java/app/bbs/DistributeApp.java Sun Jul 13 18:14:00 2014 +0900 +++ b/src/main/java/app/bbs/DistributeApp.java Sun Jul 13 18:16:52 2014 +0900 @@ -1,16 +1,19 @@ package app.bbs; - import alice.jungle.remote.RemoteConfig; import alice.topology.node.TopologyNode; import app.bbs.codesegment.StartBBSCodeSegment; - -public class DistributeApp -{ - public static void main( String[] args ) throws Exception - { - RemoteConfig conf = new RemoteConfig(args); - new TopologyNode(conf, new StartBBSCodeSegment(args, conf.bbsPort)); +public class DistributeApp { + public static void main(String[] args) throws Exception { + RemoteConfig conf = new RemoteConfig(args); + if (conf.getManagerHostName() == null) { + // String localHostName ="localhost"; + // HostMessage host = new HostMessage(localHostName, conf.localPort); + StartBBSCodeSegment cs1 = new StartBBSCodeSegment(args, conf.bbsPort); + cs1.ods.put("host", "node0"); + } else { + new TopologyNode(conf, new StartBBSCodeSegment(args, conf.bbsPort)); + } } }
--- a/src/main/java/app/bbs/ShowMessageWithTimeStampServlet.java Sun Jul 13 18:14:00 2014 +0900 +++ b/src/main/java/app/bbs/ShowMessageWithTimeStampServlet.java Sun Jul 13 18:16:52 2014 +0900 @@ -6,58 +6,62 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.eclipse.jetty.util.thread.ThreadPool; + import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.BoardMessage; -public class ShowMessageWithTimeStampServlet extends HttpServlet -{ - /** +public class ShowMessageWithTimeStampServlet extends HttpServlet { + /** * */ - private static final long serialVersionUID = 1L; - private final NetworkBulletinBoard bbs; - private final String createBoardMessagePath; - private final String editMessagePath; - - private static final String PARAM_BOARD_NAME = "bname"; + private static final long serialVersionUID = 1L; + private final NetworkBulletinBoard bbs; + private final String createBoardMessagePath; + private final String editMessagePath; + + private static final String PARAM_BOARD_NAME = "bname"; - public ShowMessageWithTimeStampServlet(NetworkBulletinBoard _bbs,String _createBoardMessagePath, String _editMessagePath) - { - bbs = _bbs; - createBoardMessagePath = _createBoardMessagePath; - editMessagePath = _editMessagePath; - } + public ShowMessageWithTimeStampServlet(NetworkBulletinBoard _bbs, + String _createBoardMessagePath, String _editMessagePath, + ThreadPool thp) { + bbs = _bbs; + createBoardMessagePath = _createBoardMessagePath; + editMessagePath = _editMessagePath; + } + + public void doGet(HttpServletRequest _req, HttpServletResponse _res) { + final String bname = _req.getParameter(PARAM_BOARD_NAME); + try { + printBoard(bname, _res.getWriter()); + } catch (Exception _e) { + _res.setStatus(500); + } + } - public void doGet(HttpServletRequest _req,HttpServletResponse _res) - { - String bname = _req.getParameter(PARAM_BOARD_NAME); - - try{ - printBoard(bname,_res.getWriter()); - }catch(Exception _e){ - _res.setStatus(500); - } - - } - - private void printBoard(String _bname,PrintWriter _pw) throws Exception - { - _pw.write("<html><body>\n"); - _pw.write("<h1>"+_bname+"</h1>\n"); - _pw.write("<p>Latest renew time : "+bbs.getRenewTime(_bname)+"</p>\n");; - - _pw.write("<form action='"+createBoardMessagePath+"' method='POST'\n"); - _pw.write("<p>Author : <input type='text' name='author'/> <input type='hidden' name='bname' value='"+_bname+"'/> EditKey : <input type='text' name='key'/></p>\n"); - _pw.write("<p>Message<br/> <input type='textarea' name='msg'/> </p>\n"); - _pw.write("<p><input type='submit' value='submit'/></p>\n"); - - for(BoardMessage msg : bbs.getMessages(_bname)){ - _pw.write("<hr/>"); - _pw.write("<p><b>"+msg.getAuthor()+"</b></p>"); - _pw.write("<p>"+msg.getMessage()+"</p>"); - _pw.write("<small><a href='"+editMessagePath+"?bname="+_bname+"&uuid="+msg.getUUID()+"'>edit</a></small>"); - } - - _pw.write("</body></html>"); - _pw.flush(); - } + private void printBoard(String _bname, PrintWriter _pw) throws Exception { + _pw.write("<html><body>\n"); + _pw.write("<h1>" + _bname + "</h1>\n"); + _pw.write("<p>Latest renew time : " + bbs.getRenewTime(_bname) + + "</p>\n"); + ; + + _pw.write("<form action='" + createBoardMessagePath + + "' method='POST'\n"); + _pw.write("<p>Author : <input type='text' name='author'/> <input type='hidden' name='bname' value='" + + _bname + + "'/> EditKey : <input type='text' name='key'/></p>\n"); + _pw.write("<p>Message<br/> <input type='textarea' name='msg'/> </p>\n"); + _pw.write("<p><input type='submit' value='submit'/></p>\n"); + + for (BoardMessage msg : bbs.getMessages(_bname)) { + _pw.write("<hr/>"); + _pw.write("<p><b>" + msg.getAuthor() + "</b></p>"); + _pw.write("<p>" + msg.getMessage() + "</p>"); + _pw.write("<small><a href='" + editMessagePath + "?bname=" + _bname + + "&uuid=" + msg.getUUID() + "'>edit</a></small>"); + } + + _pw.write("</body></html>"); + _pw.flush(); + } }
--- a/src/main/java/app/bbs/codesegment/StartBBSCodeSegment.java Sun Jul 13 18:14:00 2014 +0900 +++ b/src/main/java/app/bbs/codesegment/StartBBSCodeSegment.java Sun Jul 13 18:16:52 2014 +0900 @@ -5,15 +5,18 @@ import javax.servlet.Servlet; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.servlet.ServletHandler; +import org.eclipse.jetty.servlet.ServletHolder; +import org.eclipse.jetty.util.thread.ThreadPool; + import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.CreateBoardMessageServlet; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.CreateBoardServlet; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.EditMessageServlet; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.EditMessageUseGetServlet; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.bbs.ShowBoardsServlet; -import org.mortbay.jetty.Server; -import org.mortbay.jetty.servlet.ServletHandler; -import org.mortbay.jetty.servlet.ServletHolder; + import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; @@ -24,85 +27,86 @@ import app.bbs.ShowMessageWithTimeStampServlet; public class StartBBSCodeSegment extends CodeSegment { - - int bbsPort = 8080; - Receiver host = ids.create(CommandType.PEEK); - private Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$"); - private String[] args; - boolean persistentFlag = false; - - public StartBBSCodeSegment(String[] _args, int p) { - args = _args; - bbsPort = p; - host.setKey("host"); - } + + int bbsPort = 8080; + Receiver host = ids.create(CommandType.PEEK); + private Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$"); + private String[] args; + boolean persistentFlag = false; + + public StartBBSCodeSegment(String[] _args, int p) { + args = _args; + bbsPort = p; + host.setKey("host"); + } + + public StartBBSCodeSegment() { + args = null; + host.setKey("host"); + } + + @Override + public void run() { + String name = host.asString(); + Matcher matcher = pattern.matcher(name); + matcher.find(); + // String type = matcher.group(1); + for(String arg: args) { + if(arg.equals("-persistent")){ + persistentFlag = true; + } + } + NetworkBulletinBoard cassaBBS = null; + if(persistentFlag) { + System.out.println("log loading..."); + cassaBBS = NetworkJungleBulletinBoard.NewPersistentJungle(name); + cassaBBS.init(); + } else { + cassaBBS = new NetworkJungleBulletinBoard(name); + cassaBBS.init(); + } - public StartBBSCodeSegment() { - args = null; - host.setKey("host"); - } - - public void run() { - String name = host.asString(); - Matcher matcher = pattern.matcher(name); - matcher.find(); -// String type = matcher.group(1); - for(String arg: args) { - if(arg.equals("-persistent")){ - persistentFlag = true; - } - } - NetworkBulletinBoard cassaBBS = null; - if(persistentFlag) { - System.out.println("log loading..."); - cassaBBS = NetworkJungleBulletinBoard.NewPersistentJungle(name); - cassaBBS.init(); - } else { - cassaBBS = new NetworkJungleBulletinBoard(name); - cassaBBS.init(); - } - - System.out.println("StartBBSCodeSegment"); - System.out.println("name : "+ name); - /* Jetty registration */ - String createBoardMessagePath = "/createBoardMessage"; - String createBoardPath = "/createBoard"; - String editMessagePath = "/editMessage"; - String showBoardMessagePath = "/showBoardMessage"; + System.out.println("StartBBSCodeSegment"); + System.out.println("name : "+ name); + /* Jetty registration */ + String createBoardMessagePath = "/createBoardMessage"; + String createBoardPath = "/createBoard"; + String editMessagePath = "/editMessage"; + String showBoardMessagePath = "/showBoardMessage"; + + + Server serv = new Server(bbsPort); + ThreadPool thp = serv.getThreadPool(); + Servlet createBoardMessage = new CreateBoardMessageServlet(cassaBBS); + Servlet createBoard = new CreateBoardServlet(cassaBBS); + Servlet editBoardMessage = new EditMessageServlet(cassaBBS); + Servlet index = new ShowBoardsServlet(cassaBBS,createBoardPath,showBoardMessagePath); + // Servlet board = new ShowBoardMessageServlet(cassaBBS,createBoardMessagePath,editMessagePath); + Servlet board = new ShowMessageWithTimeStampServlet(cassaBBS,createBoardMessagePath,editMessagePath,thp); - - Servlet createBoardMessage = new CreateBoardMessageServlet(cassaBBS); - Servlet createBoard = new CreateBoardServlet(cassaBBS); - Servlet editBoardMessage = new EditMessageServlet(cassaBBS); - Servlet index = new ShowBoardsServlet(cassaBBS,createBoardPath,showBoardMessagePath); -// Servlet board = new ShowBoardMessageServlet(cassaBBS,createBoardMessagePath,editMessagePath); - Servlet board = new ShowMessageWithTimeStampServlet(cassaBBS,createBoardMessagePath,editMessagePath); - - Server serv = new Server(bbsPort); - ServletHandler context = new ServletHandler(); - context.addServletWithMapping(new ServletHolder(createBoardMessage),createBoardMessagePath); - context.addServletWithMapping(new ServletHolder(createBoard),createBoardPath); - context.addServletWithMapping(new ServletHolder(editBoardMessage),editMessagePath); - context.addServletWithMapping(new ServletHolder(index),"/"); - context.addServletWithMapping(new ServletHolder(board),showBoardMessagePath); - /* - * For write benchmark - */ - String editMessageUseGetPath = "/editMessageUseGet"; - Servlet editMessageUseGet = new EditMessageUseGetServlet(cassaBBS); - context.addServletWithMapping(new ServletHolder(editMessageUseGet), editMessageUseGetPath); - String requestNumCheckPath = "/requestNum"; - Servlet requestNumCheckServlet = new RequestNumCheckServlet(cassaBBS); - context.addServletWithMapping(new ServletHolder(requestNumCheckServlet), requestNumCheckPath); - - - serv.addHandler(context); - try { - serv.start(); - } catch (Exception e) { - e.printStackTrace(); - } - new LogUpdateCodeSegment(); - } + ServletHandler context = new ServletHandler(); + context.addServletWithMapping(new ServletHolder(createBoardMessage),createBoardMessagePath); + context.addServletWithMapping(new ServletHolder(createBoard),createBoardPath); + context.addServletWithMapping(new ServletHolder(editBoardMessage),editMessagePath); + context.addServletWithMapping(new ServletHolder(index),"/"); + context.addServletWithMapping(new ServletHolder(board),showBoardMessagePath); + /* + * For write benchmark + */ + String editMessageUseGetPath = "/editMessageUseGet"; + Servlet editMessageUseGet = new EditMessageUseGetServlet(cassaBBS); + context.addServletWithMapping(new ServletHolder(editMessageUseGet), editMessageUseGetPath); + String requestNumCheckPath = "/requestNum"; + Servlet requestNumCheckServlet = new RequestNumCheckServlet(cassaBBS); + context.addServletWithMapping(new ServletHolder(requestNumCheckServlet), requestNumCheckPath); + + serv.setHandler(context); + try { + serv.start(); + } catch (Exception e) { + e.printStackTrace(); + } + new LogUpdateCodeSegment(); + } }
--- a/src/test/java/alice/codesegment/local/HasFieldCodeSegment.java Sun Jul 13 18:14:00 2014 +0900 +++ b/src/test/java/alice/codesegment/local/HasFieldCodeSegment.java Sun Jul 13 18:16:52 2014 +0900 @@ -16,7 +16,7 @@ public void run() { int count = arg1.asInteger(); - System.out.println("-HasFieldCodeSegment- : "+str); + System.out.println("-HasFieldCodeSegment- : "+str+" "+count); System.exit(0); }