changeset 66:312de6b900bc

fix TopologyManager
author KaitoMaeshiro <aosskaito@cr.ie.u-ryukyu.ac.jp>
date Sun, 30 Jan 2022 01:48:43 +0900
parents 058d41dcec41
children 806965e04299
files Test/Topology/LocalTestTopology/LTRemoteIncrement.cs Test/Topology/LocalTestTopology/StartLocalTestTopology.cs scripts/.netrc scripts/ring.dot scripts/ring.rb topology/manager/TopologyManager.cs topology/node/StartTopologyNode.cs
diffstat 6 files changed, 101 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Test/Topology/LocalTestTopology/LTRemoteIncrement.cs	Sun Jan 30 01:48:43 2022 +0900
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using Christie_net.annotation;
+using Christie_net.codegear;
+using Christie_net.topology;
+using Christie_net.topology.node;
+
+
+namespace Christie_net.Test.Topology.LocalTestTopology
+{
+    public class LTRemoteIncrement : CodeGear
+    {
+        [Peek] public TopologyNodeConfig topologyNodeConfig;
+        [Take] public int num;
+
+        public override void Run(CodeGearManager cgm)
+        {
+            Console.WriteLine("node: " + " num = " + num);
+
+            if (num == 3) {
+                GetDgm(topologyNodeConfig.getManagerKey()).Put("FINISHMESSAGE", new Message());
+            } else {
+                num++;
+                GetDgm("right").Put("num", num);
+                cgm.Setup(new LTRemoteIncrement());
+            }
+        }
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Test/Topology/LocalTestTopology/StartLocalTestTopology.cs	Sun Jan 30 01:48:43 2022 +0900
@@ -0,0 +1,33 @@
+using System;
+using Christie_net.codegear;
+using Christie_net.topology.manager;
+using Christie_net.topology.node;
+
+
+namespace Christie_net.Test.Topology.LocalTestTopology
+{
+    public class StartLocalTestTopology : StartCodeGear
+    {
+        public StartLocalTestTopology(CodeGearManager cgm) : base(cgm) { }
+
+        public static void Main(String[] args)
+        {
+            int managerPort = 10000;
+            int nodeNum = 3;
+            String[] managerArg = {"--localPort", managerPort.ToString(), "--confFile", "scripts/ring.dot"};
+            TopologyManagerConfig topologyManagerConfig = new TopologyManagerConfig(managerArg);
+            new StartTopologyManager(topologyManagerConfig);
+            CodeGearManager nodeCGM = null;
+            for (int i = 1; i<=nodeNum; i++) {
+                nodeCGM = CreateCgm(managerPort + i);
+                String[] nodeArg = {"--managerPort", managerPort.ToString(),
+                    "--managerHost", "localhost"};
+                TopologyNodeConfig cs  = new TopologyNodeConfig(nodeArg);
+
+                new StartTopologyNode(nodeCGM, cs, new LTRemoteIncrement());
+
+            }
+            nodeCGM.GetLocalDGM().Put("num", 0);
+        }
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ring.dot	Sun Jan 30 01:48:43 2022 +0900
@@ -0,0 +1,5 @@
+digraph test {
+	node0 -> node1 [label="right"]
+	node1 -> node2 [label="right"]
+	node2 -> node0 [label="right"]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ring.rb	Sun Jan 30 01:48:43 2022 +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)
+
--- a/topology/manager/TopologyManager.cs	Sat Jan 29 20:28:13 2022 +0900
+++ b/topology/manager/TopologyManager.cs	Sun Jan 30 01:48:43 2022 +0900
@@ -30,11 +30,11 @@
                     GetLocalDgm().Put("running", false);
                     //cgm.Setup(new FileParser());
                     cgm.Setup(new IncomingHosts());
-                    cgm.Setup(new ConfigWaiter());
+                    //cgm.Setup(new ConfigWaiter());
 
                 }
 
-                cgm.Setup(new CreateHash());
+                //cgm.Setup(new CreateHash());
                 cgm.Setup(new TopologyFinish());
 
                 GetLocalDgm().Put("topology", new Dictionary<String, LinkedList<HostMessage>>());
--- a/topology/node/StartTopologyNode.cs	Sat Jan 29 20:28:13 2022 +0900
+++ b/topology/node/StartTopologyNode.cs	Sun Jan 30 01:48:43 2022 +0900
@@ -7,14 +7,14 @@
 {
     public class StartTopologyNode : StartCodeGear
     {
-        public StartTopologyNode(CodeGearManager cgm, TopologyNodeConfig conf, CodeGear startCG) : base(cgm)
+        public StartTopologyNode(CodeGearManager cgm, TopologyNodeConfig conf, CodeGear startCg) : base(cgm)
         {
-            cgm.GetLocalDGM().Put("startCG", startCG);
+            cgm.GetLocalDGM().Put("startCG", startCg);
             cgm.GetLocalDGM().Put("topologyNodeConfig", conf);
             cgm.Setup(new TopologyNode());
         }
 
-        public StartTopologyNode(TopologyNodeConfig conf, CodeGear startCG) : this(CreateCgm(conf.localPort), conf,
-            startCG) { }
+        public StartTopologyNode(TopologyNodeConfig conf, CodeGear startCg) : this(CreateCgm(conf.localPort), conf,
+            startCg) { }
     }
 }