changeset 8:8a33595a0d8c

add tree.rb
author suruga
date Wed, 07 Feb 2018 19:31:33 +0900
parents 3fda0de2d139
children afbd290bb017
files scripts/LogupdateTest.sh scripts/tree.rb
diffstat 2 files changed, 40 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/LogupdateTest.sh	Thu Jan 25 13:04:09 2018 +0900
+++ b/scripts/LogupdateTest.sh	Wed Feb 07 19:31:33 2018 +0900
@@ -1,5 +1,6 @@
 export JAR=build/libs/logupdateTest-1.1.jar
-java -cp $JAR  alice.topology.manager.TopologyManager -host localhost -p 10000 -port 10001 --noKeepAlive &
+ruby scripts/tree.rb 3 > scripts/tree.dot
+java -cp $JAR  alice.topology.manager.TopologyManager -conf scripts/tree.dot -host localhost -p 10000 -port 10001 --noKeepAlive &
 sleep 3 
 java -jar $JAR  -host localhost -p 10003 -port 10000  --noKeepAlive &
 java -jar $JAR  -host localhost -p 10001 -port 10000  --noKeepAlive &
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/tree.rb	Wed Feb 07 19:31:33 2018 +0900
@@ -0,0 +1,38 @@
+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|
+  parent = (i - 1) / 2;
+  child1 = 2 * i + 1;
+  child2 = 2 * i + 2;
+  if parent >= 0 then
+    connections << [nodes[i], nodes[parent], "parent"]
+  end
+  if child1 < node_num then
+    connections << [nodes[i], nodes[child1], "child1"]
+  end
+  if child2 < node_num then
+    connections << [nodes[i], nodes[child2], "child2"]
+  end
+}
+print_dot(connections)
+