Skip to Content.
Sympa Menu

perfsonar-dev - [pS-dev] [GEANT/SA2/SA2T3-OPPD] r709 - in trunk: bin etc/oppd-mdm lib lib/perfSONAR/Client

Subject: perfsonar development work

List archive

[pS-dev] [GEANT/SA2/SA2T3-OPPD] r709 - in trunk: bin etc/oppd-mdm lib lib/perfSONAR/Client


Chronological Thread 
  • From:
  • To:
  • Subject: [pS-dev] [GEANT/SA2/SA2T3-OPPD] r709 - in trunk: bin etc/oppd-mdm lib lib/perfSONAR/Client
  • Date: Wed, 25 May 2011 09:03:50 +0100

Author: dfn.calim
Date: 2011-05-25 09:03:50 +0100 (Wed, 25 May 2011)
New Revision: 709

Modified:
trunk/bin/oppd.pl
trunk/etc/oppd-mdm/oppd.dev.conf
trunk/lib/perfSONAR.pm
trunk/lib/perfSONAR/Client/LS.pm
Log:
fixed lookup service registration

Modified: trunk/bin/oppd.pl
===================================================================
--- trunk/bin/oppd.pl 2011-05-11 08:06:08 UTC (rev 708)
+++ trunk/bin/oppd.pl 2011-05-25 08:03:50 UTC (rev 709)
@@ -537,7 +537,7 @@
# die on typical signals
$SIG{INT} = $SIG{TERM} = sub {
$logger->info("Caught SIG$_[0] - initiating shutdown");
- $shutdown_gracefully = 0;
+ $shutdown_gracefully = $gracetime;
exit 1;
# See END {} for shutdown sequence
};
@@ -838,19 +838,24 @@

my @pids = sort keys %connections;
push @pids, $ls_reg_pid if $ls_reg_pid;
+
if ($shutdown_gracefully && @pids) {
$logger->info("Trying to terminate all known children gracefully");
my $signal = $shutdown_gracefully > 0 ? "USR1" : "USR2";
my @pids_new = ();
+
foreach my $pid (@pids) {
next if waitpid($pid, WNOHANG) != 0; # Already dead ...
+ next if $pid == $ls_reg_pid; #Dont kill ls child because sending
dereg msg
kill $signal => $pid;
push @pids_new, $pid;
}
+
@pids = @pids_new; @pids_new = ();
+ push @pids, $ls_reg_pid if $ls_reg_pid; #LS not killed becaue doing
deregister
if (@pids) {
# Some processes were signaled
- $logger->debug("Sent SIG$signal to " . join(', ', @pids));
+ $logger->info("Sent SIG$signal to " . join(', ', @pids));
# Wait till processes have ended or timeout is reached.
# $shutdown_gracefully < 0 => Wait possibly forever!!
my $timeout = $shutdown_gracefully < 0 ? 0 : $shutdown_gracefully;
@@ -873,7 +878,7 @@
alarm 0;
};
die if $@ && $@ ne "alarm\n"; # propagate unexpected errors
- }
+ }#End if (@pids)
}
while (waitpid(-1,WNOHANG) > 0) {} # wait on all possibly exited children
if (waitpid(-1, WNOHANG) >= 0) {
@@ -902,9 +907,8 @@
# case correctly, though.
close_socket($conn, "Closing connection failed");
} elsif ($proc_type eq "lsreg") {
- $logger->info("Starting shutdown sequence");
+ $logger->info("Starting shutdown sequence for Lookup Service");
if ($shutdown_gracefully) {
- $logger->info("Deregistering services");
perfSONAR::Client::LS::deregister();
} else {
#TODO Change this? Perhaps a deregistration with a small timeout?
@@ -945,7 +949,7 @@
local ($!,$?);

while ((my $pid = waitpid(-1,WNOHANG)) > 0) {
- my $reason = $? ? " with exit code $?" : "";
+ my $reason = " with exit code $?";
if (exists $connections{$pid}) {
$logger->info(
"Connection process $pid for connection $connections{$pid} exited"
@@ -1051,12 +1055,14 @@
close_socket($http_daemon, "Closing listening socket failed");

# Start registration process
- perfSONAR::Client::LS::init(
- services => \%services, ls_url =>
\@ls_url,
- hostname => $hostname, port => $port,
- organization => $organization, contact => $contact,
- log => $logger
- );
+ perfSONAR::Client::LS::init(services => \%services,
+ ls_url =>
\@ls_url,
+ hostname =>
$hostname,
+ port => $port,
+ organization =>
$organization,
+ contact => $contact,
+ log => $logger
+ );
while (1) {
sleep $keepalive;
# Our parent may have died without being able to send us a signal. So
take

Modified: trunk/etc/oppd-mdm/oppd.dev.conf
===================================================================
--- trunk/etc/oppd-mdm/oppd.dev.conf 2011-05-11 08:06:08 UTC (rev 708)
+++ trunk/etc/oppd-mdm/oppd.dev.conf 2011-05-25 08:03:50 UTC (rev 709)
@@ -201,7 +201,7 @@
# Default: off
#
# Example:
-# ls_register on
+ls_register on
#
#ls_register off

@@ -243,9 +243,8 @@
# ls_url "http://dc211.internet2.edu:9995/perfSONAR_PS/services/hLS";
# ls_url
"http://loco4.man.poznan.pl:8180/geant2-java-xml-ls/services/LookupService";
#
-#ls_url [FILL ME]
+ls_url
"http://ls.perfsonar.pionier.net.pl:8180/geant2-java-xml-ls/services/LookupService";

-
#
# hostname - Host name sent to the Lookup Service.
#
@@ -258,7 +257,7 @@
# Example:
# hostname "myhost.mydomain.org"
#
-#hostname [FILL ME]
+hostname "calim.rrze.uni-erlangen.de"


#

Modified: trunk/lib/perfSONAR/Client/LS.pm
===================================================================
--- trunk/lib/perfSONAR/Client/LS.pm 2011-05-11 08:06:08 UTC (rev 708)
+++ trunk/lib/perfSONAR/Client/LS.pm 2011-05-25 08:03:50 UTC (rev 709)
@@ -57,7 +57,7 @@
$deregister_template = "$FindBin::RealBin/../etc/LS_deregister.xml";
$keepalive_template = "$FindBin::RealBin/../etc/LS_keepalive.xml";
} else {
- $register_template = "/etc/oppd/LS_register.xml";
+ $register_template = "/etc/oppd.d/LS_register.xml";
$deregister_template = "/etc/oppd/LS_deregister.xml";
$keepalive_template = "/etc/oppd/LS_keepalive.xml";
}
@@ -76,23 +76,24 @@
our @ls_url = ();
my %messages;

-my $debug_write = 0;
+my $debug_write = 1;

# Setup everything und sent initial registration ("first" heartbeat).
sub init {
- my %p = @_;
- %services = %{$p{services}}; @ls_url = @{$p{ls_url}};
- $hostname = $p{hostname}; $port = $p{port};
- $organization = $p{organization}; $contact = $p{contact};
- $log = $p{log};
+ my %p = @_;
+ %services = %{$p{services}}; @ls_url = @{$p{ls_url}};
+ $hostname = $p{hostname}; $port = $p{port};
+ $organization = $p{organization}; $contact = $p{contact};
+ $log = $p{log};

- #first registration:
- foreach my $service (keys %services){
- create_register_message($service);
- send_registration($messages{$service}{"register_msg"}, $service);
- }
+ #first registration:
+ foreach my $service (keys %services){
+ create_register_message($service);
+ send_registration($messages{$service}{"register_msg"}, $service);
+ }
}

+
# Send keepalive messages for each service
sub heartbeat {
foreach my $service (keys %messages){ #get services from global hash
@@ -100,10 +101,7 @@
if (exists $messages{$service}{"keepalive_msg"}){
foreach my $url (@ls_url){
$message = $messages{$service}{"keepalive_msg"}->clone();
- $log->log(
- level => "notice", service => $service,
- message => "Sending keepalive for $service to $url"
- );
+ $log->info("Sending keepalive for $service to $url");
my $response = perfSONAR::sendReceive(
message => $message,
uri => $url,
@@ -113,15 +111,9 @@
#TODO What to do if keepalive fails? At the moment: Nothing.
my $eventtype = ($response->{dom}->getElementsByTagNameNS("$nmwg",
"eventType"))[0]->textContent;
my $datumstring =
($response->{dom}->getElementsByTagNameNS("$nmwgr", "datum"))[0]->textContent;
- $log->log(
- level => "notice", service => $service,
- message => "Keepalive for $service returend $eventtype:
$datumstring"
- );
+ $log->info("Keepalive for $service returend $eventtype:
$datumstring");
} else { #no response...
- $log->log(
- level => "notice", service => $service,
- message => "error sending keepalive for $service: No response
from Lookup Server!"
- );
+ $log->info("error sending keepalive for $service: No response from
Lookup Server!");
}
}
} else { #something went wrong with first registration, otherwise there
would be a keepalive message!
@@ -140,7 +132,7 @@
my $message = NMWG::Message->new();
$message->parse_xml_from_file($register_template);
my $servicenode = ($message->{dom}->getElementsByTagNameNS("$psservice",
"service"))[0];
-
+
$message->add_element_NS($servicenode, "serviceName",
"$services{$service}->{name}", $psservice);
$message->add_element_NS($servicenode, "accessPoint",
"http://$hostname:$port/services/$service";, $psservice);
$message->add_element_NS($servicenode, "serviceType",
"$services{$service}->{servicetype}", $psservice);
@@ -164,6 +156,7 @@
parent => $subjectnode,
nodename => "node",
);
+
foreach my $addr (@addresses) {
my $name = lookup_hostname($addr);
next unless $name;
@@ -236,18 +229,12 @@
foreach my $meta (keys %{$response->{"metadataIDs"}}){
$eventtype = $response->{"metadataIDs"}{$meta}{"eventType"};
if (!$eventtype =~ /success/){
- $log->log(
- level => "notice", service => $service,
- message => "LS returned $eventtype for service $service"
- );
+ $log->info("LS returned $eventtype for service $service");
#return;
} else {
if ($eventtype =~ /register/){
$key = $response->{"metadataIDs"}{$meta}{"key"}{"lsKey"};
- $log->log(
- level => "notice", service => $service,
- message => "successfully registered service $service with key $key"
- );
+ $log->info("successfully registered service $service with key $key");
$messages{$service}{"ls_key"} = $key;
}
}
@@ -273,10 +260,7 @@

write_message($message, "register");
foreach my $url (@ls_url){
- $log->log(
- level => "notice", service => $service,
- message => "registering service $service to $url"
- );
+ $log->info("registering service $service to $url");
my $response = perfSONAR::sendReceive(
message => $message->clone,
uri => $url,
@@ -289,16 +273,10 @@
} else {
my $eventtype = ($response->{dom}->getElementsByTagNameNS("$nmwg",
"eventType"))[0]->textContent;
my $datumstring =
($response->{dom}->getElementsByTagNameNS("$nmwgr", "datum"))[0]->textContent;
- $log->log(
- level => "notice", service => $service,
- message => "error registering service $service with $eventtype:
$datumstring"
- );
+ $log->error("error registering service $service with $eventtype:
$datumstring");
}
} else {
- $log->log(
- level => "notice", service => $service,
- message => "error registering service $service: No response from
Lookup Server!"
- );
+ $log->eroor("error registering service $service: No response from
Lookup Server!");
}
}
}
@@ -306,20 +284,18 @@


sub deregister{
+
#read in deregistration template:
my $message = NMWG::Message->new();
$message->parse_xml_from_file($deregister_template);
-
#send deregistration
foreach my $service (keys %messages){
my $key = $messages{$service}{"ls_key"};
if (!$key){
- $log->log(
- level => "notice", service => $service,
- message => "no key for deregistering service $service found!"
- );
+ $log->error("no key for deregistering service $service found!");
next;
}
+
my $deregmsg = $message->clone;
my $parametersnode = (
$deregmsg->{dom}->getElementsByTagNameNS("$nmwg", "parameters")
@@ -331,29 +307,22 @@
);
$key_parameter->appendText($key);
write_message($deregmsg, "deregister");
+
foreach my $url (@ls_url){
- $log->log(
- level => "notice", service => $service,
- message => "deregistering service $service from $url"
- );
+ $log->info("deregistering service $service from $url");
my $response = perfSONAR::sendReceive(
message => $deregmsg->clone,
uri => $url,
);
+
if ($response){
write_message($response, "dereg-response");
- $log->log(
- level => "notice", service => $service,
- message => "successfully deregistered service $service with key
$key"
- );
+ $log->info("successfully deregistered service $service with key
$key");
#TODO do something interesting with result
#$response->parse_meta;
#$response->parse_data;
} else {
- $log->log(
- level => "notice", service => $service,
- message => "could not deregister $key: No response from Looukup
Server!"
- );
+ $log->info("could not deregister $key: No response from Looukup
Server!");
}
}
}

Modified: trunk/lib/perfSONAR.pm
===================================================================
--- trunk/lib/perfSONAR.pm 2011-05-11 08:06:08 UTC (rev 708)
+++ trunk/lib/perfSONAR.pm 2011-05-25 08:03:50 UTC (rev 709)
@@ -111,4 +111,52 @@

}

+#TODO this method should be implemented in a other modul
+#it should be independent from NMWG
+#Replace NMWG by DataStruct
+sub sendReceive {
+ my %p = (
+ message => undef,
+ host => "localhost",
+ port => "8090",
+ endpoint => "/",
+ uri => "",
+ soapheader => "", #TODO TODO noch nicht fertig und kein String!
+ @_
+ );
+
+ my $uri = $p{uri} || "http://$p{host}:$p{port}$p{endpoint}";;
+ my $body = $p{message}->as_dom;
+
+ # Message is NMWG::Message
+ my $message = perfSONAR::SOAP::Message->new(
+ body => $body,
+ uri => $uri
+ );
+ # Modify SOAP header using $message or set via "new" call directly
+
+ my $userAgent = perfSONAR::SOAP::HTTP::UserAgent->new;
+ my $request = perfSONAR::SOAP::HTTP::Request->new(message => $message);
+
+ my $response = $userAgent->request($request);
+ unless ($response->is_success) {
+ # HTTP error
+ #my $code = $response->code();
+ #my $message = $response->message();
+ carp $response->status_line if $^W; # "<code> <message>"
+ return;
+ }
+
+ my $soap_message = $response->soap_message;
+ if ($soap_message->is_fault) {
+ carp "TODO" if $^W;
+ return;
+ }
+
+ my $nmwg_message = NMWG::Message->new( ($soap_message->body)[0] );
+ #TODO This should perhaps be
NMWG::Message->from_soap_message($soap_message);
+
+ return $nmwg_message;
+}
+
1;
\ No newline at end of file



  • [pS-dev] [GEANT/SA2/SA2T3-OPPD] r709 - in trunk: bin etc/oppd-mdm lib lib/perfSONAR/Client, svn-noreply, 05/25/2011

Archive powered by MHonArc 2.6.16.

Top of Page