line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package perfSONAR_PS::Client::Echo; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
22663
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
5
|
1
|
|
|
1
|
|
1351
|
use Log::Log4perl qw(get_logger :nowarn); |
|
1
|
|
|
|
|
63912
|
|
|
1
|
|
|
|
|
8
|
|
6
|
1
|
|
|
1
|
|
1808
|
use perfSONAR_PS::Common; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use perfSONAR_PS::Transport; |
8
|
|
|
|
|
|
|
use perfSONAR_PS::Messages; |
9
|
|
|
|
|
|
|
use perfSONAR_PS::XML::Document_string; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = 0.09; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use fields 'URI', 'EVENT_TYPE'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
|
|
|
|
|
|
my ($package, $uri_string, $eventType) = @_; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $self = fields::new($package); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
if (defined $uri_string and $uri_string ne "") { |
21
|
|
|
|
|
|
|
$self->{"URI"} = $uri_string; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
if (not defined $eventType or $eventType eq "") { |
26
|
|
|
|
|
|
|
$eventType = "http://schemas.perfsonar.net/tools/admin/echo/2.0"; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
$self->{"EVENT_TYPE"} = $eventType; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
return $self; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub setEventType { |
35
|
|
|
|
|
|
|
my ($self, $eventType) = @_; |
36
|
|
|
|
|
|
|
my $logger = get_logger("perfSONAR_PS::Client::Echo"); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
$self->{EVENT_TYPE} = $eventType; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
return; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub setURIString { |
44
|
|
|
|
|
|
|
my ($self, $uri_string) = @_; |
45
|
|
|
|
|
|
|
my $logger = get_logger("perfSONAR_PS::Client::Echo"); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
$self->{URI} = $uri_string; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
return; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub createEchoRequest { |
53
|
|
|
|
|
|
|
my ($self, $output) = @_; |
54
|
|
|
|
|
|
|
my $logger = get_logger("perfSONAR_PS::Client::Echo"); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
my $messageID = "message.".genuid(); |
57
|
|
|
|
|
|
|
my $mdID = "metadata.".genuid(); |
58
|
|
|
|
|
|
|
my $dID = "data.".genuid(); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
startMessage($output, $messageID, undef, "EchoRequest", "", undef); |
61
|
|
|
|
|
|
|
getResultCodeMetadata($output, $mdID, "", $self->{EVENT_TYPE}); |
62
|
|
|
|
|
|
|
createData($output, $dID, $mdID, "", undef); |
63
|
|
|
|
|
|
|
endMessage($output); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
$logger->debug("Finished creating echo request"); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
return 0; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub ping { |
71
|
|
|
|
|
|
|
my ($self) = @_; |
72
|
|
|
|
|
|
|
my $logger = get_logger("perfSONAR_PS::Client::Echo"); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
if (not defined $self->{URI}) { |
75
|
|
|
|
|
|
|
return (-1, "Invalid URI specified \"\""); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
my ($host, $port, $endpoint) = &perfSONAR_PS::Transport::splitURI($self->{URI}); |
79
|
|
|
|
|
|
|
if (not defined $host and not defined $port and not defined $endpoint) { |
80
|
|
|
|
|
|
|
return (-1, "Invalid URI specified \"".$self->{URI}."\""); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
my $doc = perfSONAR_PS::XML::Document_string->new(); |
84
|
|
|
|
|
|
|
$self->createEchoRequest($doc); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my ($status, $res) = consultArchive($host, $port, $endpoint, $doc->getValue()); |
87
|
|
|
|
|
|
|
if ($status != 0) { |
88
|
|
|
|
|
|
|
my $msg = "Error contacting service: $res"; |
89
|
|
|
|
|
|
|
$logger->error($msg); |
90
|
|
|
|
|
|
|
return(-1, $msg); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
$logger->debug("Response: ".$res->toString); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
foreach my $d ($res->getChildrenByTagName("nmwg:data")) { |
96
|
|
|
|
|
|
|
foreach my $m ($res->getChildrenByTagName("nmwg:metadata")) { |
97
|
|
|
|
|
|
|
my $md_id = $m->getAttribute("id"); |
98
|
|
|
|
|
|
|
my $md_idref = $m->getAttribute("metadataIdRef"); |
99
|
|
|
|
|
|
|
my $d_idref = $d->getAttribute("metadataIdRef"); |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
if($md_id eq $d_idref) { |
102
|
|
|
|
|
|
|
my $eventType = findvalue($m, "nmwg:eventType"); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
$eventType =~ s/\s*//g; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
if ($eventType =~ /^success\./) { |
107
|
|
|
|
|
|
|
return (0, ""); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
return (-1, "No successful return");; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
__END__ |