Mercurial > hg > Database > jungle-network
changeset 40:7e94de2d6bc0
add PutAnotherLogCodeSegment, PutHostLogCodeSegment
author | one |
---|---|
date | Tue, 09 Jul 2013 17:32:06 +0900 |
parents | 10359a815068 |
children | b8b9668da13c |
files | src/alice/jungle/codesegment/LogUpdateCodeSegment.java src/jungle/test/bbs/DistributeApp.java src/jungle/test/bbs/codesegment/PutAnotherLogCodeSegment.java src/jungle/test/bbs/codesegment/PutHostLogCodeSegment.java src/jungle/test/codesegment/remote/ClientCodeSegment.java src/jungle/test/codesegment/remote/HostCodeSegment.java |
diffstat | 6 files changed, 83 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/jungle/codesegment/LogUpdateCodeSegment.java Tue Jul 09 15:10:06 2013 +0900 +++ b/src/alice/jungle/codesegment/LogUpdateCodeSegment.java Tue Jul 09 17:32:06 2013 +0900 @@ -1,8 +1,17 @@ package alice.jungle.codesegment; +import java.io.IOException; + +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.DefaultTreeOperationLog; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; +import jungle.test.bbs.JungleManager; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; +import alice.jungle.datasegment.store.operations.DefaultTreeOperationLogContainer; public class LogUpdateCodeSegment extends CodeSegment { @@ -13,9 +22,22 @@ } public void run() { + DefaultTreeOperationLogContainer container = arg1.asClass(DefaultTreeOperationLogContainer.class); + DefaultTreeOperationLog log = null; + try { + log = container.convert(); + } catch (IOException e) { + e.printStackTrace(); + } - + JungleManager jm = new JungleManager(); + JungleTree tree = jm.getJungle().getTreeByName("boards"); + JungleTreeEditor editor = tree.getTreeEditor(); + Either<Error, JungleTreeEditor> either = jm.edit(editor, log); + if(either.isA()) { + throw new IllegalStateException(); + } + editor = either.b(); + editor.success(); } - - }
--- a/src/jungle/test/bbs/DistributeApp.java Tue Jul 09 15:10:06 2013 +0900 +++ b/src/jungle/test/bbs/DistributeApp.java Tue Jul 09 17:32:06 2013 +0900 @@ -2,6 +2,9 @@ import javax.servlet.Servlet; +import jungle.test.bbs.codesegment.PutAnotherLogCodeSegment; +import jungle.test.bbs.codesegment.PutHostLogCodeSegment; + import org.mortbay.jetty.Server; import org.mortbay.jetty.servlet.ServletHandler; import org.mortbay.jetty.servlet.ServletHolder; @@ -22,12 +25,18 @@ BulletinBoard cassaBBS = null; cassaBBS = new NetworkJungleBulletinBoard(); RemoteConfig conf = new RemoteConfig(args); - new AliceDaemon(conf).listen(); - if(conf.hostname != null) { + if(conf.hostname == null) { + /* Host Side */ + new AliceDaemon(conf).listen(); + PutHostLogCodeSegment cs = new PutHostLogCodeSegment(); + cs.arg1.setKey("local","log"); + } else { + /* Client Side */ DataSegment.connect(conf.key, "", conf.hostname, conf.connectPort); LogUpdateCodeSegment cs = new LogUpdateCodeSegment(); - cs.arg1.setKey("remote", "log"); - + cs.arg1.setKey("remote", "hostLog"); + PutAnotherLogCodeSegment cs2 = new PutAnotherLogCodeSegment(); + cs2.arg1.setKey("local", "log"); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/jungle/test/bbs/codesegment/PutAnotherLogCodeSegment.java Tue Jul 09 17:32:06 2013 +0900 @@ -0,0 +1,21 @@ +package jungle.test.bbs.codesegment; + +import org.msgpack.type.Value; + +import alice.codesegment.CodeSegment; +import alice.datasegment.CommandType; +import alice.datasegment.Receiver; + +public class PutAnotherLogCodeSegment extends CodeSegment { + + public Receiver arg1 = ids.create(CommandType.TAKE); + + public void run() { + Value v = (Value)arg1.getVal(); + ods.put("remote", "anotherLog", v); + PutAnotherLogCodeSegment cs = new PutAnotherLogCodeSegment(); + cs.arg1.setKey("local", "log"); + + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/jungle/test/bbs/codesegment/PutHostLogCodeSegment.java Tue Jul 09 17:32:06 2013 +0900 @@ -0,0 +1,19 @@ +package jungle.test.bbs.codesegment; + +import org.msgpack.type.Value; + +import alice.codesegment.CodeSegment; +import alice.datasegment.CommandType; +import alice.datasegment.Receiver; + +public class PutHostLogCodeSegment extends CodeSegment { + + public Receiver arg1 = ids.create(CommandType.TAKE); + + public void run() { + Value v = (Value) arg1.getVal(); + ods.put("remote", "hostLog", v); + PutHostLogCodeSegment cs = new PutHostLogCodeSegment(); + cs.arg1.setKey("local", "log"); + } +}
--- a/src/jungle/test/codesegment/remote/ClientCodeSegment.java Tue Jul 09 15:10:06 2013 +0900 +++ b/src/jungle/test/codesegment/remote/ClientCodeSegment.java Tue Jul 09 17:32:06 2013 +0900 @@ -10,12 +10,14 @@ public void run() { System.out.println("--ClientCodeSegment--"); + System.out.println("from : " + arg1.from); + System.out.println("index : "+ arg1.index); int num = arg1.asInteger(); System.out.println("num : "+num); num++; ods.put("remote", "num", num); System.exit(0); -// ods.put("remote", "num", num); + } }
--- a/src/jungle/test/codesegment/remote/HostCodeSegment.java Tue Jul 09 15:10:06 2013 +0900 +++ b/src/jungle/test/codesegment/remote/HostCodeSegment.java Tue Jul 09 17:32:06 2013 +0900 @@ -10,6 +10,8 @@ public void run() { System.out.println("--HostCodeSegment--"); + System.out.println("index : "+ arg1.index); + System.out.println("from : "+ arg1.from); int num = arg1.asInteger(); System.out.println("num : "+ num); num++;