Skip to Content.
Sympa Menu

perfsonar-dev - [pS-dev] [GEANT/SA2/SA2T3-OPPD] r658 - in branches/perfsonar-oppd-new-architect: etc/oppd-mdm/oppd.d lib/perfSONAR/DataStruct lib/perfSONAR/SOAP/HTTP

Subject: perfsonar development work

List archive

[pS-dev] [GEANT/SA2/SA2T3-OPPD] r658 - in branches/perfsonar-oppd-new-architect: etc/oppd-mdm/oppd.d lib/perfSONAR/DataStruct lib/perfSONAR/SOAP/HTTP


Chronological Thread 
  • From:
  • To:
  • Subject: [pS-dev] [GEANT/SA2/SA2T3-OPPD] r658 - in branches/perfsonar-oppd-new-architect: etc/oppd-mdm/oppd.d lib/perfSONAR/DataStruct lib/perfSONAR/SOAP/HTTP
  • Date: Wed, 20 Oct 2010 14:59:42 +0100

Author: dfn.calim
Date: 2010-10-20 14:59:42 +0100 (Wed, 20 Oct 2010)
New Revision: 658

Modified:
branches/perfsonar-oppd-new-architect/etc/oppd-mdm/oppd.d/bwctl.conf
branches/perfsonar-oppd-new-architect/lib/perfSONAR/DataStruct/NMWG.pm
branches/perfsonar-oppd-new-architect/lib/perfSONAR/SOAP/HTTP/UserAgent.pm
Log:
Include STORE support for MP/BWCTL and MP/OWAMP

Modified: branches/perfsonar-oppd-new-architect/etc/oppd-mdm/oppd.d/bwctl.conf
===================================================================
--- branches/perfsonar-oppd-new-architect/etc/oppd-mdm/oppd.d/bwctl.conf
2010-10-14 10:54:52 UTC (rev 657)
+++ branches/perfsonar-oppd-new-architect/etc/oppd-mdm/oppd.d/bwctl.conf
2010-10-20 13:59:42 UTC (rev 658)
@@ -36,9 +36,13 @@
#
# Store functionality
#
- store off # Enable/disable store functionality
- store_url "http://www.mySQL-MA:8090";
- # URL of a MA service to sent the results of measurements to
+ #To activate store to sent the results of measurements to
+ # Enable/disable store functionality
+ store on
+ # URL of a MA service
+ #Example
+ #store_url <HOSTNAME>:<PORT>//geant2-java-sql-ma/
+ store_url
"http://ippm-setup8.rrze.uni-erlangen.de:8080/geant2-java-sql-ma/";

</module_param>


Modified:
branches/perfsonar-oppd-new-architect/lib/perfSONAR/DataStruct/NMWG.pm
===================================================================
--- branches/perfsonar-oppd-new-architect/lib/perfSONAR/DataStruct/NMWG.pm
2010-10-14 10:54:52 UTC (rev 657)
+++ branches/perfsonar-oppd-new-architect/lib/perfSONAR/DataStruct/NMWG.pm
2010-10-20 13:59:42 UTC (rev 658)
@@ -46,6 +46,10 @@
use Log::Log4perl qw(get_logger);
use Carp;

+use perfSONAR::SOAP::Message;
+use perfSONAR::SOAP::HTTP::UserAgent;
+use perfSONAR::SOAP::HTTP::Request;
+
Readonly::Scalar our $CLASSPATH => "perfSONAR::DataStruct::NMWG";

=head2 new({})
@@ -389,16 +393,12 @@
}


-=head2 ds2nmwg()
-
-After a measurement the result data should be transformed
-from a data struct to a nmwg. The data in MRESULT will be used.
-The send message will be set in $ds->{RESULT}. Use this field to send
-the result.
+=head2 parseResult($datastruct_ref)
+The meaurement result is stored in $$ds->{SERVICE}->{DATA}. For this this
method is called with a reference to the data struct. Use the
+id field to get the specific result. Some checks are needed in this method
to decide if it is a EchoRequest or a error is occured
=cut
-
sub parseResult{
- my ($self, $ds) = @_;
+ my ($self, $ds) = @_;

my $ns_serivce = $$ds->{SERVICE}->{NAME};
$ns_serivce =~ s/\///;
@@ -409,27 +409,115 @@
my $messagetype = $$ds->{REQUESTMSG}->get_message_type();

foreach my $id (keys %{$data}){
- my $datalines_ref = $$ds->{SERVICE}->{DATA}->{$id}->{MRESULT};
- #$self->{LOGGER}->debug(Dumper($datalines_ref));
- if ($$ds->{DOECHO} == 1){
- my %data_hash =
%{@$datalines_ref[0]};
- $$ds->{REQUESTMSG}->return_result_code($data_hash{'echocode'},
$data_hash{'echomsg'}, "$id")
- }elsif ($$ds->{ERROROCCUR}){
- my $et = pop @$datalines_ref;
- $$ds->{REQUESTMSG}->return_result_code($et,
"@$datalines_ref", $$ds->{REQUESTMSG}->{"dataIDs"}{$id}{"metaref"});
- }else{
- $$ds->{REQUESTMSG}->set_data_ns ($id, $ns, @$datalines_ref);
-
- #Look if data should be store
- if (defined $$ds->{SERVICE}->{DATA}->{$id}->{STORE}->{DOIT}){
- $self->{LOGGER}->info("Storing data...")
- }
- }
- #$self->{LOGGER}->debug(Dumper(@$datalines_ref));
+ my $datalines_ref = $$ds->{SERVICE}->{DATA}->{$id}->{MRESULT};
+ #$self->{LOGGER}->debug(Dumper($datalines_ref));
+ if ($$ds->{DOECHO} == 1){
+ my %data_hash =
%{@$datalines_ref[0]};
+ #$ds->{REQUESTMSG}->return_result_code($data_hash{'echocode'},
$data_hash{'echomsg'}, "$id")
+ }elsif ($$ds->{ERROROCCUR}){
+ my $et = pop @$datalines_ref;
+ $$ds->{REQUESTMSG}->return_result_code($et, "@$datalines_ref",
$$ds->{REQUESTMSG}->{"dataIDs"}{$id}{"metaref"});
+ }else{
+ $$ds->{REQUESTMSG}->set_data_ns ($id, $ns, @$datalines_ref);
+ my $storesuccess = 1;
+ #Look if data should be stored by metadata
+ if (defined $$ds->{SERVICE}->{DATA}->{$id}->{STORE}->{DOIT}){
+ if (! $self->store($ds,$id,"META")){
+ #store was not possible
+ $storesuccess = 0
+ }
+ }#ENd if (defined $$ds
+ #Look if store is activated by configuration file
+ if (
$$ds->{SERVICES}->{$$ds->{SERVICE}->{NAME}}->{module_param}->{store}){
+ if (! $self->store($ds,$id,"CONF")){
+ #store was not possible
+ $storesuccess = 0
+ }
+ }#End f ( $$ds->{SERVICES
+
+ if (! $storesuccess){
+ my $et = "error.mp.store";
+ my $error = $$ds->{ERRORMSG};
+ $$ds->{REQUESTMSG}->return_result_code($et, $error,
$$ds->{REQUESTMSG}->{"dataIDs"}{$id}{"metaref"});
+ $self->{LOGGER}->error($error);
+ }
+ }#+End foreach my $id
+ #$self->{LOGGER}->info(Dumper($store));
}
}

+=head2 store()
+To store the measurement data in a measurement archive this method is used.
For this the {STORE}->{PARAMS} field
+in the data structure is used. To get the store parameters use the id of the
measurement. This is used if store
+request is included in metadata.

+Store by service configuration file is also supported. For this the
parameters in:
+$$ds->{SERVICES}->{$$ds->{SERVICE}->{NAME}}->{module_param} is used. This is
a hash with the information for store.
+On success this method returns 1 otherwise 0. On 0 (error) $$ds->{ERRORMSG}
field will be set.
+=cut
+sub store{
+
+ my ($self, $ds, $id, $store_by) = @_;
+ my $store_url = undef;
+
+ if ($store_by eq "CONF"){
+ $store_url =
$$ds->{SERVICES}->{$$ds->{SERVICE}->{NAME}}->{module_param}->{store_url};
+
+ }
+ elsif ($store_by eq "META"){
+ $store_url =
$$ds->{SERVICE}->{DATA}->{$id}->{STORE}->{PARAMS}->{uri};
+ #$$ds->{ERRORMSG} = "Store by METADATA is actually not
supported";
+ #return 0;
+ }else{
+ $$ds->{ERRORMSG} = "This kind of store request is not supported";
+ return 0;
+ }
+
+ if (! $store_url){
+ $$ds->{ERRORMSG} = "No store url defined in configuration file";
+ return 0;
+ }
+ $self->{LOGGER}->info("Storing data to SQL MA: $store_url");
+ my $store_msg = $$ds->{REQUESTMSG}->clone;
+
+ if (!$store_msg){
+ $$ds->{ERRORMSG} = "Store to MA failed: Could not clone storage
message.";
+ return 0;
+ }
+
+ $store_msg->set_message_type("MeasurementArchiveStoreRequest");
+ my $body = $store_msg->as_dom;
+ my $message = perfSONAR::SOAP::Message->new(
+ body => $body,
+ uri => $store_url
+ );
+
+ 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 $httperror = $response->status_line;
+ $$ds->{ERRORMSG} = "HTTP ERROR: Response from SQL MA:$httperror";
+ #$self->{LOGGER}->error($$ds->{ERRORMSG});
+ return 0;
+ }
+
+ #my $result = $response->as_string(2);
+ $self->{LOGGER}->info("Store was successful on SQL MA");
+
+ #Write success to METADATA if requestet
+ if ($store_by eq "META"){
+ my $et = "success.mp.store";
+ my $msg = "Store was successful on SQL MA: $store_url";
+ $$ds->{REQUESTMSG}->return_result_code($et, $msg,
$$ds->{REQUESTMSG}->{"dataIDs"}{$id}{"metaref"});
+ }
+ return 1;
+}


+
+
+
1;
\ No newline at end of file

Modified:
branches/perfsonar-oppd-new-architect/lib/perfSONAR/SOAP/HTTP/UserAgent.pm
===================================================================
---
branches/perfsonar-oppd-new-architect/lib/perfSONAR/SOAP/HTTP/UserAgent.pm
2010-10-14 10:54:52 UTC (rev 657)
+++
branches/perfsonar-oppd-new-architect/lib/perfSONAR/SOAP/HTTP/UserAgent.pm
2010-10-20 13:59:42 UTC (rev 658)
@@ -28,7 +28,7 @@
use Carp;

use LWP::UserAgent;
-
+use perfSONAR::SOAP::HTTP::Response;
use base 'LWP::UserAgent';





  • [pS-dev] [GEANT/SA2/SA2T3-OPPD] r658 - in branches/perfsonar-oppd-new-architect: etc/oppd-mdm/oppd.d lib/perfSONAR/DataStruct lib/perfSONAR/SOAP/HTTP, svn-noreply, 10/20/2010

Archive powered by MHonArc 2.6.16.

Top of Page