[MOBY-guts] biomoby commit

Eddie Kawas kawas at dev.open-bio.org
Wed Jan 9 16:23:48 UTC 2008


kawas
Wed Jan  9 11:23:47 EST 2008
Update of /home/repository/moby/moby-live/Perl/scripts
In directory dev.open-bio.org:/tmp/cvs-serv15916/Perl/scripts

Modified Files:
	service_tester.pl 
Log Message:
formatted the code a little bit and also moved the call to retrieve service providers out of the foreach loop so that the call is made once and not numerous times.
moby-live/Perl/scripts service_tester.pl,1.6,1.7
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/scripts/service_tester.pl,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- /home/repository/moby/moby-live/Perl/scripts/service_tester.pl	2008/01/03 22:58:10	1.6
+++ /home/repository/moby/moby-live/Perl/scripts/service_tester.pl	2008/01/09 16:23:47	1.7
@@ -64,14 +64,14 @@
 
 # this is just to test if I'm going to have permissions
 # right now, rather than an hour from now...  Arghghg!
-open( OUT, ">>$DIRECTORY/$FILENAME" ) || die("Cannot Open File $DIRECTORY/$FILENAME $!");
+open( OUT, ">>$DIRECTORY/$FILENAME" ) || die("Cannot Open File '$DIRECTORY/$FILENAME' $!");
 close OUT;
 
 # create some shared variables
 my $alive_handle = tie %ALIVE, 'IPC::Shareable', undef, { destroy => 'yes' };
 
-foreach my $cat (@CATEGORIES) {
-	my $central =
+# create the central client and get all service providers once
+my $central =
 	  MOBY::Client::Central->new(
 		Registries => { 
 			mobycentral => { 
@@ -81,95 +81,92 @@
 		}
 	);
 my @providers = $central->retrieveServiceProviders();
-foreach my $authURI(@providers){
-	my ( $second, $minute, $hour, @whatever ) = localtime();
-	print "Finding services registered by '$authURI' as '$cat' @ $hour:$minute:$second\n";
-	my ( $services, $reg ) = $central->findService( Registry => "mobycentral",category => $cat, authURI => $authURI );
-	( $second, $minute, $hour, @whatever ) = localtime();
-	print "Services found "
-	  . scalar @$services
-	  . "... processing @ $hour:$minute:$second \n";
- 
-	my $count = 0;
-	print "\tservice count: " . scalar (@$services) . "\n";
-	foreach (@$services) {
-		# ignore test services
-		next if  $_->authority eq 'samples.jmoby.net';
-		wait, $count-- while $count >= $THREAD_COUNT;
-		$count++;
-		my $pid = fork();
-		$count-- unless defined $pid;
-		do { IPC::Shareable->clean_up_all; die "Couldn't fork: $!"; }
-		  unless defined $pid;
-		if ($pid) {
 
-			# parent - do nothing ...s
-		}
-		elsif ( $pid == 0 ) {
-			my $name = $_->name;
-			my $auth = $_->authority;
-			my $url  = $_->URL;
-
-			do {
-				# dont process localhost addresses ...
-				exit(0);
-			} if $url =~ /localhost/;
-
-			# child - stuff to do goes here
-			#print "Calling: " . $auth . "," . $name . "\n";
-			my $soap =
-			  SOAP::Lite->uri("http://biomoby.org/")
-			  ->proxy( $url, timeout => $TIMEOUT )->on_fault(
-				sub {
-					my $soap = shift;
-					my $res  = shift;
+foreach my $cat (@CATEGORIES) {
+	foreach my $authURI (@providers) {
+		my ( $second, $minute, $hour, @whatever ) = localtime();
+		print "Finding services registered by '$authURI' as '$cat' @ $hour:$minute:$second\n";
+		my ( $services, $reg ) = $central->findService( Registry => "mobycentral",category => $cat, authURI => $authURI );
+		( $second, $minute, $hour, @whatever ) = localtime();
+		print "Services found "
+	  	. scalar @$services
+	  	. "... processing @ $hour:$minute:$second \n";
+ 
+		my $count = 0;
+		print "\tservice count: " . scalar (@$services) . "\n";
+		foreach (@$services) {
+			# ignore test services
+			next if  $_->authority eq 'samples.jmoby.net';
+			wait, $count-- while $count >= $THREAD_COUNT;
+			$count++;
+			my $pid = fork();
+			$count-- unless defined $pid;
+			do { IPC::Shareable->clean_up_all; die "Couldn't fork: $!"; }
+		  	unless defined $pid;
+			if ($pid) {
+				# parent - do nothing ...s
+			} elsif ( $pid == 0 ) {
+				my $name = $_->name;
+				my $auth = $_->authority;
+				my $url  = $_->URL;
 
+				do {
+					# dont process localhost addresses ...
+					exit(0);
+				} if $url =~ /localhost/;
+	
+				# child - stuff to do goes here
+				#print "Calling: " . $auth . "," . $name . "\n";
+				my $soap =
+				  SOAP::Lite->uri("http://biomoby.org/")
+				  ->proxy( $url, timeout => $TIMEOUT )->on_fault(
+					sub {
+						my $soap = shift;
+						my $res  = shift;
+	
+						#TODO add to DEAD hash ...
+						$alive_handle->shlock();
+						$ALIVE{$auth} = () if not exists $ALIVE{$auth};
+						push @{ $ALIVE{$auth} }, {name=>$name, alive=>undef};
+						$alive_handle->shunlock();
+	
+						#print "\t" . $auth . "," . $name . " ~isAlive\n";
+						exit(0);
+					}
+				  );
+
+				my $input = _empty_input();
+				my $out   =
+				  $soap->$name( SOAP::Data->type( 'string' => "$input" ) )->result;
+				do {
+					#TODO add to ALIVE hash ...
+					#print "\t" . $auth . "," . $name . " isAlive\n";
+					$alive_handle->shlock();
+					$ALIVE{$auth} = () if not exists $ALIVE{$auth};
+					push @{ $ALIVE{$auth} }, {name=>$name, alive=>1};
+					$alive_handle->shunlock();
+					exit(0);
+				} if $out;
+				do {
 					#TODO add to DEAD hash ...
+					#print "\t" . $auth . "," . $name . " ~isAlive\n";
 					$alive_handle->shlock();
 					$ALIVE{$auth} = () if not exists $ALIVE{$auth};
 					push @{ $ALIVE{$auth} }, {name=>$name, alive=>undef};
 					$alive_handle->shunlock();
-
-					#print "\t" . $auth . "," . $name . " ~isAlive\n";
 					exit(0);
-				}
-			  );
-
-			my $input = _empty_input();
-			my $out   =
-			  $soap->$name( SOAP::Data->type( 'string' => "$input" ) )->result;
-			do {
-
-				#TODO add to ALIVE hash ...
-				#print "\t" . $auth . "," . $name . " isAlive\n";
-				$alive_handle->shlock();
-				$ALIVE{$auth} = () if not exists $ALIVE{$auth};
-				push @{ $ALIVE{$auth} }, {name=>$name, alive=>1};
-				$alive_handle->shunlock();
-				exit(0);
-			} if $out;
-			do {
-
-				#TODO add to DEAD hash ...
-				#print "\t" . $auth . "," . $name . " ~isAlive\n";
-				$alive_handle->shlock();
-				$ALIVE{$auth} = () if not exists $ALIVE{$auth};
-				push @{ $ALIVE{$auth} }, {name=>$name, alive=>undef};
-				$alive_handle->shunlock();
-				exit(0);
-			} unless $out;
-		}
-		else {
-			IPC::Shareable->clean_up_all;
-			die "couldn’t fork: $!\n";
+				} unless $out;
+			} else {
+				IPC::Shareable->clean_up_all;
+				die "couldn’t fork: $!\n";
+			}
 		}
-	}
 
-	# dont proceed until we are completed with the first batch of children!
-	wait, $count-- while $count > 0;
-	( $second, $minute, $hour, @whatever ) = localtime();
-	print "Testing of '$cat' services from '$authURI' completed @ $hour:$minute:$second \n";
-}
+		# dont proceed until we are completed with the first batch of children!
+		wait, $count-- while $count > 0;
+		( $second, $minute, $hour, @whatever ) = localtime();
+		print "Testing of '$cat' services from '$authURI' completed @ $hour:$minute:$second \n";
+	}
 }
 
 my $doc = XML::LibXML::Document->new( "1.0", "UTF-8" );




More information about the MOBY-guts mailing list