changeset 140:77169cd8a5e8

マージ blockchain
author musou_aka
date Wed, 02 Jan 2019 21:48:37 +0900
parents 6b33e7dfb146 (diff) 694ea96a557a (current diff)
children a5cd12f6a942 0ef25958ac04
files scripts/.netrc scripts/Log/ring.dot scripts/ring.rb
diffstat 7 files changed, 140 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/Log/ring.dot	Wed Jan 02 21:48:37 2019 +0900
@@ -0,0 +1,8 @@
+digraph test {
+	node0 -> node1 [label="right"]
+	node0 -> node2 [label="left"]
+	node1 -> node2 [label="right"]
+	node1 -> node0 [label="left"]
+	node2 -> node0 [label="right"]
+	node2 -> node1 [label="left"]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ring.rb	Wed Jan 02 21:48:37 2019 +0900
@@ -0,0 +1,28 @@
+def create_nodes(node_num)
+  (0..node_num - 1).map { |i|
+    i = "node" + i.to_s
+  }
+end
+
+def print_dot(connections)
+  puts "digraph test {"
+  connections.each { |connection|
+    print "\t"
+    print connection[0]
+    print " -> "
+    print connection[1]
+    print ' [label="' + connection[2] + '"]'
+    puts
+  }
+  puts "}"
+end
+
+node_num = ARGV[0].to_i
+nodes = create_nodes(node_num)
+connections = Array.new
+nodes.each_with_index { |node, i|
+  connections << [nodes[i], nodes[(i + 1) % node_num], "right"]
+  connections << [nodes[i], nodes[i - 1], "left"]
+}
+print_dot(connections)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/christie/example/HelloWorld/HelloWorldCodeGear.java	Wed Jan 02 21:48:37 2019 +0900
@@ -0,0 +1,17 @@
+package christie.example.HelloWorld;
+
+import christie.annotation.Take;
+import christie.codegear.CodeGear;
+import christie.codegear.CodeGearManager;
+
+public class HelloWorldCodeGear extends CodeGear {
+
+    @Take
+    String helloWorld;
+
+    @Override
+    protected void run(CodeGearManager cgm) {
+        System.out.print(helloWorld + " ");
+        cgm.setup(new HelloWorldCodeGear());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/christie/example/HelloWorld/StartHelloWorld.java	Wed Jan 02 21:48:37 2019 +0900
@@ -0,0 +1,18 @@
+package christie.example.HelloWorld;
+
+import christie.codegear.CodeGearManager;
+import christie.codegear.StartCodeGear;
+
+public class StartHelloWorld extends StartCodeGear {
+
+    public StartHelloWorld(CodeGearManager cgm) {
+        super(cgm);
+    }
+
+    public static void main(String[] args){
+        CodeGearManager cgm = createCGM(10000);
+        cgm.setup(new HelloWorldCodeGear());
+        cgm.getLocalDGM().put("helloWorld","hello");
+        cgm.getLocalDGM().put("helloWorld","world");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/christie/example/OddEven/EvenCodeGear.java	Wed Jan 02 21:48:37 2019 +0900
@@ -0,0 +1,22 @@
+package christie.example.OddEven;
+
+import christie.annotation.Peek;
+import christie.annotation.Take;
+import christie.codegear.CodeGear;
+import christie.codegear.CodeGearManager;
+
+public class EvenCodeGear extends CodeGear {
+    @Take
+    int even;
+
+    @Peek
+    int finishCount;
+
+    @Override
+    protected void run(CodeGearManager cgm) {
+        if (finishCount == even) return;
+        System.out.println(even + " : even");
+        getDGM("odd").put("odd", even + 1);
+        cgm.setup(new EvenCodeGear());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/christie/example/OddEven/OddCodeGear.java	Wed Jan 02 21:48:37 2019 +0900
@@ -0,0 +1,22 @@
+package christie.example.OddEven;
+
+import christie.annotation.Peek;
+import christie.annotation.Take;
+import christie.codegear.CodeGear;
+import christie.codegear.CodeGearManager;
+
+public class OddCodeGear extends CodeGear {
+    @Take
+    int odd;
+
+    @Peek
+    int finishCount;
+
+    @Override
+    protected void run(CodeGearManager cgm) {
+        if (finishCount - 1 == odd) return;
+        System.out.println(odd + " : odd");
+        getDGM("even").put("even", odd + 1);
+        cgm.setup(new OddCodeGear());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/java/christie/example/OddEven/StartOddEven.java	Wed Jan 02 21:48:37 2019 +0900
@@ -0,0 +1,25 @@
+package christie.example.OddEven;
+
+import christie.codegear.CodeGearManager;
+import christie.codegear.StartCodeGear;
+
+public class StartOddEven extends StartCodeGear {
+
+    public StartOddEven(CodeGearManager cgm) {
+        super(cgm);
+    }
+
+    public static void main(String[] args){
+        int finishCount = 10;
+        CodeGearManager odd = createCGM(10001);
+        CodeGearManager even = createCGM(10002);
+        odd.setup(new OddCodeGear());
+        even.setup(new EvenCodeGear());
+        odd.createRemoteDGM("even","localhost",10002);
+        even.createRemoteDGM("odd","localhost", 10001);
+        odd.getLocalDGM().put("odd", 1);
+        odd.getLocalDGM().put("finishCount",finishCount);
+        even.getLocalDGM().put("finishCount", finishCount);
+
+    }
+}