352
|
1 package jp.ac.u_ryukyu.ie.cr.jungleNetwork.logupdate;
|
340
|
2
|
|
3 import alice.codesegment.CodeSegment;
|
342
|
4 import alice.datasegment.CommandType;
|
|
5 import alice.datasegment.Receiver;
|
345
|
6 import jp.ac.u_ryukyu.ie.cr.jungle.bbs.BBSTest;
|
342
|
7 import jp.ac.u_ryukyu.ie.cr.jungleNetwork.codesegment.LogUpdateCodeSegment;
|
345
|
8 import jp.ac.u_ryukyu.ie.cr.jungleNetwork.core.NetworkDefaultJungle;
|
346
|
9 import jp.ac.u_ryukyu.ie.cr.jungleNetwork.persistent.AliceJournal;
|
363
|
10 import org.msgpack.type.ValueFactory;
|
342
|
11
|
|
12 import java.util.regex.Matcher;
|
|
13 import java.util.regex.Pattern;
|
340
|
14
|
|
15 /**
|
|
16 * Created by kono on 2017/08/28.
|
|
17 */
|
|
18 public class LogupdateTestStartCodeSegment extends CodeSegment {
|
342
|
19
|
|
20 int bbsPort = 8080;
|
|
21 Receiver host = ids.create(CommandType.PEEK);
|
359
|
22 Receiver clist = ids.create(CommandType.PEEK);
|
345
|
23 Receiver conf = ids.create(CommandType.PEEK);
|
342
|
24 private Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$");
|
|
25 private String[] args;
|
|
26 boolean persistentFlag = false;
|
|
27
|
345
|
28 public LogupdateTestStartCodeSegment(){
|
|
29 conf.setKey("config");
|
|
30 host.setKey("host");
|
359
|
31 clist.setKey("_CLIST");
|
345
|
32 }
|
|
33
|
340
|
34 @Override
|
|
35 public void run() {
|
342
|
36 String name = host.asString();
|
345
|
37 LogupdateTestConfig config = conf.asClass(LogupdateTestConfig.class);
|
346
|
38 args = config.getArgs();
|
345
|
39
|
342
|
40 Matcher matcher = pattern.matcher(name);
|
|
41 matcher.find();
|
|
42 // String type = matcher.group(1);
|
|
43 for(String arg: args)
|
|
44 if (arg.equals("-persistent")) {
|
|
45 persistentFlag = true;
|
|
46 }
|
357
|
47 BBSTest bbsTest = new BBSTest(new NetworkDefaultJungle(new AliceJournal(), "hoge"), host.asString());
|
345
|
48 Logupdator cassaBBS = new Logupdator(name, bbsTest);
|
342
|
49 cassaBBS.init();
|
|
50 ods.put("updator", cassaBBS);
|
|
51
|
|
52 new LogUpdateCodeSegment();
|
364
|
53 new LogupdateFinish(host.asString(
|
|
54
|
|
55
|
|
56 ));
|
359
|
57 if (config.isWriteMode()) {
|
|
58 for (int i = config.writeCount;i>0;i--) {
|
|
59 bbsTest.createMessage();
|
|
60 }
|
357
|
61 try {
|
|
62 bbsTest.checkTime();
|
362
|
63 Thread.sleep(5000);
|
363
|
64 ods.put("log", ValueFactory.createNilValue());
|
362
|
65 } catch (Exception e) {
|
357
|
66 e.printStackTrace();
|
|
67 }
|
345
|
68 }
|
340
|
69 }
|
|
70 }
|