changeset 360:d10d35c0960a

add testtree script
author suruga
date Wed, 31 Jan 2018 19:16:11 +0900
parents f85a437e495b
children 33c04f3bec82
files scripts/LogupdateTree.sh scripts/tree.rb
diffstat 2 files changed, 64 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/LogupdateTree.sh	Wed Jan 31 19:16:11 2018 +0900
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+if [ ! -d output ]; then
+    mkdir output
+fi
+
+max=$1
+count=$2
+jar_path=../build/libs/logupdateTest-1.1.jar
+
+mkdir -p output
+ruby ./tree.rb $1 > ./tree.dot
+#dot -Tpng ./topology/ring.dot > ./topology/ring.png
+#open ./topology/ring.png
+java -cp $jar_path alice.topology.manager.TopologyManager -p 10000 -conf ./tree.dot -log ./output/manager.log -level debug &
+
+cnt=1
+while [ $cnt -lt $max ]
+do
+    java -jar $jar_path  -host `hostname` -port 10000 -p `expr 20000 + $cnt` -log ./output/ring${cnt}.log -level debug &
+    cnt=`expr $cnt + 1`
+done
+    java -jar $jar_path  -host `hostname` -port 10000 -p `expr 20000 + $cnt` -log ./output/ring${cnt}.log -level debug -write &
+wait
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/tree.rb	Wed Jan 31 19:16:11 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)
+