[Sheepdog] [PATCH 6/6] add scripts to use collie

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Tue Dec 1 19:35:23 CET 2009


start-sheepdog is useful when you want to run some collies
in one machine. For example, the following command starts
eight collie processes in a local machine.

$ ./script/start-sheepdog -n=8

When you want to stop these processes, run the following command.

$ ./script/stop-sheepdog [0-7]

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 script/check-dog.pl   |   70 +++++++++++++-----------------------------------
 script/start-sheepdog |   27 +++++--------------
 script/stop-sheepdog  |    7 ++---
 3 files changed, 29 insertions(+), 75 deletions(-)

diff --git a/script/check-dog.pl b/script/check-dog.pl
index 9c35af8..4d8e4ba 100755
--- a/script/check-dog.pl
+++ b/script/check-dog.pl
@@ -16,10 +16,8 @@ sub command {
 
 sub start_sdog {
     my ($n) = @_;
-    my $dport = 7000 + $n;
-    my $sport = 9000 + $n;
-    &command("./sheep/sheep --dport $dport --sport $sport $store/$n/");
-    &command("./dog/dog --mport 9876 --dport $dport --sport $sport -d");
+    my $port = 7000 + $n;
+    &command("./collie/collie --port $port $store/$n/ -d");
 }
 
 sub stop_sdog {
@@ -41,7 +39,7 @@ sub shuffle {
 
 print("** setup **");
 &command("make clean");
-&command("make install");
+&command("make");
 
 print("kill all sheeps and dogs\n");
 foreach my $n (0..10) {
@@ -49,7 +47,7 @@ foreach my $n (0..10) {
 }
 
 print("clean up $store\n");
-&command("rm $store/*/*; rm /tmp/sheepdog-700*");
+&command("rm $store/[0-9]/*");
 
 print("start up sdogs\n");
 my $node = int(($min_node + $max_node) / 2);
@@ -60,39 +58,20 @@ foreach my $n (shuffle(0..$node - 1)) {
 my @join_node = (0..$node-1);
 my @leave_node = ($node..$max_node-1);
 
+sleep(8);
 print("make fs\n");
 &command("shepherd mkfs --copies=3");
-sleep(3);
 
 my $min_epoch = 1;
 my $max_epoch = 1;
 my $vdi = 0;
 for (;;) {
     my $op = int(rand(9));
-    if ($op == 0) {
-	next if (@join_node >= $max_node);
-
-	printf("** join test **\n");
-
-	@leave_node = shuffle(@leave_node);
-	$node = pop(@leave_node);
-	&start_sdog($node);
-	push(@join_node, $node);
-	$max_epoch++;
-	sleep(5);
-	&command("shepherd info -t dog -D ".(7000+$join_node[0]), 1);
+    print("op: $op\n");
+    if ($op == 0) { # join
+	next;
     } elsif ($op == 1) { # leave
-	next if (@join_node <= $min_node);
-
-	printf("** leave test **\n");
-
-	@join_node = shuffle(@join_node);
-	$node = pop(@join_node);
-	&stop_sdog($node);
-	push(@leave_node, $node);
-	$max_epoch++;
-	sleep(5);
-	&command("shepherd info -t dog -D 7000 -D ".(7000+$join_node[0]), 1);
+	next;
     } elsif ($op == 2) { # create
 	next if (!grep(/0/, @join_node));
 
@@ -100,7 +79,7 @@ for (;;) {
 
 	&command("qemu-img create -f sheepdog test$vdi ".int(rand(256))."G", 1);
 	$vdi++;
-	&command("shepherd info -t vdi -D ".(7000+$join_node[0]), 1);
+	&command("shepherd info -t vdi -p ".(7000+$join_node[0]), 1);
     } elsif ($op == 3) { # snapshot
 	next if ($vdi == 0);
 	next if (!grep(/0/, @join_node));
@@ -108,7 +87,7 @@ for (;;) {
 	printf("** snapshot test **\n");
 
 	&command("qemu-img snapshot -c name sheepdog:test".int(rand($vdi)), 1);
-	&command("shepherd info -t vdi -D ".(7000+$join_node[0]), 1);
+	&command("shepherd info -t vdi -p ".(7000+$join_node[0]), 1);
     } elsif ($op == 4) { # clone
 	next if (!grep(/0/, @join_node));
 	my $target_vdi;
@@ -125,43 +104,32 @@ for (;;) {
 
 	&command("qemu-img create -b sheepdog:test$target_vdi:$tag -f sheepdog test$vdi", 1);
 	$vdi++;
-	&command("shepherd info -t vdi -D ".(7000+$join_node[0]), 1);
+	&command("shepherd info -t vdi -p ".(7000+$join_node[0]), 1);
     } elsif ($op == 5) { # lock
 	next if ($vdi == 0);
 
 	printf("** lock test **\n");
 
-	&command("shepherd info -t vm -D ".(7000+$join_node[0]), 1);
+	&command("shepherd info -t vm -p ".(7000+$join_node[0]), 1);
 	&command("shepherd debug -o lock_vdi test".int(rand($vdi)));
-	&command("shepherd info -t vm -D ".(7000+$join_node[1]), 1);
+	&command("shepherd info -t vm -p ".(7000+$join_node[1]), 1);
     } elsif ($op == 6) { # release
 	next if ($vdi == 0);
 
 	printf("** release test **\n");
 
-	&command("shepherd info -t vm -D ".(7000+$join_node[0]), 1);
+	&command("shepherd info -t vm -p ".(7000+$join_node[0]), 1);
 	&command("shepherd debug -o release_vdi test".int(rand($vdi)));
-	&command("shepherd info -t vm -D ".(7000+$join_node[1]), 1);
+	&command("shepherd info -t vm -p ".(7000+$join_node[1]), 1);
     } elsif ($op == 7) { # update_epoch
-	next if ($vdi == 0);
-
-	printf("** epoch update test **\n");
-
-	my $target = int(rand($vdi));
-	&command("shepherd debug -o vdi_info test".$target." -D ".(7000+$join_node[0]), 1);
-	&command("shepherd debug -o update_epoch ".(262144 * ($target + 1))." -D ".(7000+$join_node[1]), 1);
-	&command("shepherd debug -o vdi_info test".$target." -D ".(7000+$join_node[2]), 1);
+	next;
     } elsif ($op == 8) { # get_node_list
 
 	printf("** get node list test **\n");
 
 	my $epoch = $min_epoch + int(rand($max_epoch - $min_epoch + 1));
-	&command("shepherd info -t dog -e $epoch -D 7000 -D ".(7000+$join_node[0]));
+	&command("shepherd info -t dog -e $epoch -p ".(7000+$join_node[0]));
     } elsif ($op == 9) { # make fs
-
-	printf("** make fs test **\n");
-
-	$min_epoch = $max_epoch;
-	&command("shepherd mkfs --copies=3 -D 7000 -D ".(7000+$join_node[0]));
+	next;
     }
 }
diff --git a/script/start-sheepdog b/script/start-sheepdog
index 6cd38e5..8f4b09a 100755
--- a/script/start-sheepdog
+++ b/script/start-sheepdog
@@ -4,9 +4,7 @@
 #
 # run-dogs.pl -n=5 -d=/tmp/1203
 
-$sport = 9000;
-$dport = 7000;
-$mport = 45566;
+$port = 7000;
 $nr = 1;
 @hosts = ();
 $home = ".";
@@ -20,8 +18,6 @@ while (@ARGV && $ARGV[0] =~ m/^-/) {
 	$nr = $1;
     } elsif (m/^-d=(.*)$/) {
 	$dir = $1;
-    } elsif (m/^-m=(.*)$/) {
-	$mport = $1;
     } elsif (m/^-h=(.*)$/) {
 	@hosts = &expand(split ':', $1);
     } elsif (m/^-H=(.*)$/) {
@@ -29,32 +25,23 @@ while (@ARGV && $ARGV[0] =~ m/^-/) {
     }
 }
 
-print("killing all dogs and sheeps...\n\n");
+print("killing all sheepdogs...\n\n");
 system("$home/script/stop-sheepdog [0-100]");
 
-foreach $pidfile (`ls /tmp/sheepdog*.pid`) {
-    chomp $pidfile;
-    system "jsvc -stop -pidfile $pidfile net.osrg.sheepdog.Sheepdog";
-}
-
 my %count;
 
 foreach $host (grep {!$count{$_}++} @hosts) {
     system("$home/script/stop-sheepdog [0-100]");
 }
 
-for ($i = 0; $i < $nr; $i++, $sport++, $dport++) {
+for ($i = 0; $i < $nr; $i++, $port++) {
     $_dir = $dir.$i;
     if ($hosts[$i]) {
-	print("ssh $hosts[$i] $home/sheep/sheep --dport $dport --sport $sport $_dir -d\n");
-	system("ssh $hosts[$i] $home/sheep/sheep --dport $dport --sport $sport $_dir -d");
-	print("ssh $hosts[$i] $home/dog/dog --mport $mport --dport $dport --sport $sport -d\n");
-	system("ssh $hosts[$i] $home/dog/dog --mport $mport --dport $dport --sport $sport -d");
+	print("ssh $hosts[$i] $home/collie/collie --port $port $_dir -d\n");
+	system("ssh $hosts[$i] $home/collie/collie --port $port $_dir -d");
     } else {
-	print("$home/sheep/sheep --dport $dport --sport $sport $_dir -d\n");
-	system("$home/sheep/sheep --dport $dport --sport $sport $_dir -d");
-	print("$home/dog/dog --mport $mport --dport $dport --sport $sport -d\n");
-	system("$home/dog/dog --mport $mport --dport $dport --sport $sport -d");
+	print("$home/collie/collie --port $port $_dir -d\n");
+	system("$home/collie/collie --port $port $_dir -d");
     }
 }
 
diff --git a/script/stop-sheepdog b/script/stop-sheepdog
index 7a88c0d..2ba286c 100755
--- a/script/stop-sheepdog
+++ b/script/stop-sheepdog
@@ -12,7 +12,7 @@ if (@index_list == 0) {
 
 $dport = 7000;
 
-foreach $proc (`ps -o pid,args -C sheep -C java -C jsvc`) {
+foreach $proc (`ps -o pid,args -C collie`) {
     foreach $i (@index_list) {
 	if ($i =~ /\[(\d+)-(\d+)\]/) {
 	    &stop_dog($dport + $_) foreach ($1..$2);
@@ -23,12 +23,11 @@ foreach $proc (`ps -o pid,args -C sheep -C java -C jsvc`) {
 }
 
 sub stop_dog {
-    my ($dport) = @_;
-    if ($proc =~ /dport $dport/) {
+    my ($port) = @_;
+    if ($proc =~ /port $port/) {
 	$proc =~ s/^\s+(.*)/$1/;
 	($pid, @cmd) = split /\s/, $proc;
 	print "kill -9 $pid (@cmd)\n";
 	system "kill -9 $pid";
-	system "jsvc -stop -pidfile /tmp/sheepdog-$dport.pid net.osrg.sheepdog.Sheepdog";
     }
 }
-- 
1.5.6.5




More information about the sheepdog mailing list