line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Parallel::Mpich::MPD::Job; |
2
|
|
|
|
|
|
|
|
3
|
12
|
|
|
12
|
|
79
|
use warnings; |
|
12
|
|
|
|
|
24
|
|
|
12
|
|
|
|
|
481
|
|
4
|
12
|
|
|
12
|
|
295
|
use strict; |
|
12
|
|
|
|
|
24
|
|
|
12
|
|
|
|
|
384
|
|
5
|
12
|
|
|
12
|
|
74
|
use Carp; |
|
12
|
|
|
|
|
23
|
|
|
12
|
|
|
|
|
699
|
|
6
|
12
|
|
|
12
|
|
67
|
use Data::Dumper; |
|
12
|
|
|
|
|
17
|
|
|
12
|
|
|
|
|
502
|
|
7
|
12
|
|
|
12
|
|
71
|
use Parallel::Mpich::MPD::Common; |
|
12
|
|
|
|
|
21
|
|
|
12
|
|
|
|
|
2411
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Parallel::Mpich::MPD::Job - Mpich MPD job wrapper |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 EXPORT |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 FUNCTIONS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 METHOD |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head2 infos |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Get information of this job. Information contains these values: |
24
|
|
|
|
|
|
|
my %info=$job->infos(); |
25
|
|
|
|
|
|
|
$info{jobid}; |
26
|
|
|
|
|
|
|
$info{jobalias}; |
27
|
|
|
|
|
|
|
$info{username}; |
28
|
|
|
|
|
|
|
$info{hosts}[0..N]{host}; |
29
|
|
|
|
|
|
|
$info{hosts}[0..N]{pid}; |
30
|
|
|
|
|
|
|
$info{hosts}[0..N]{sid}; |
31
|
|
|
|
|
|
|
$info{hosts}[0..N]{rank}; |
32
|
|
|
|
|
|
|
$info{hosts}[0..N]{cmd}; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 kill |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Kill this job. See examples: |
37
|
|
|
|
|
|
|
Parallel::Mpich::MPD::findJob(alias => 'olivier1')->kill(); |
38
|
|
|
|
|
|
|
Parallel::Mpich::MPD::findJob(jobid => '1@linux02_32996')->kill(); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 signal |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Send a sig to this job. |
43
|
|
|
|
|
|
|
It return false if not ok. |
44
|
|
|
|
|
|
|
examples: |
45
|
|
|
|
|
|
|
# SIGQUIT, SIGKILL, SIGSTOP, SIGCONT, SIGXCPU, SIGUSR1, SIGUSR2 |
46
|
|
|
|
|
|
|
Parallel::Mpich::MPD::findJob(alias => 'olivier1')->signal("SIGSTOP"); |
47
|
|
|
|
|
|
|
Parallel::Mpich::MPD::findJob(alias => 'olivier1')->signal("SIGCONT"); |
48
|
|
|
|
|
|
|
Parallel::Mpich::MPD::findJob(jobid => '1@linux02_32996')->kill(); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=over 4 |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
NOTE: |
53
|
|
|
|
|
|
|
You couLd check the state with the following ps command: |
54
|
|
|
|
|
|
|
ps -eo state,nice,user,comm |
55
|
|
|
|
|
|
|
ps state des: |
56
|
|
|
|
|
|
|
D Uninterruptible sleep (usually IO) |
57
|
|
|
|
|
|
|
R Running or runnable (on run queue) |
58
|
|
|
|
|
|
|
S Interruptible sleep (waiting for an event to complete) |
59
|
|
|
|
|
|
|
T Stopped, either by a job control signal or because it is being traced. |
60
|
|
|
|
|
|
|
W paging (not valid since the 2.6.xx kernel) |
61
|
|
|
|
|
|
|
X dead (should never be seen) |
62
|
|
|
|
|
|
|
Z Defunct ("zombie") process, terminated but not reaped by its parent. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=back |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 sig_stop |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Stop this job. |
69
|
|
|
|
|
|
|
return false if not ok |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 sig_cont |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Continue this job. |
74
|
|
|
|
|
|
|
return false if not ok |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 kill |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Send a kill signal |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 equals($job) |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
compare towo jobs and return true/false |
83
|
|
|
|
|
|
|
FIXME.: should be implemented |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 toSummaryString |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
return a string for the current job |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 AUTHOR |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Olivier Evalet, Alexandre Masselot, C<< >> |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 BUGS |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
96
|
|
|
|
|
|
|
C, or through the web interface at |
97
|
|
|
|
|
|
|
L. |
98
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
99
|
|
|
|
|
|
|
your bug as I make changes. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 SUPPORT |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
perldoc Parallel::Mpich::MPD |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
You can also look for information at: |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=over 4 |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
L |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item * CPAN Ratings |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
L |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
L |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item * Search CPAN |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
L |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=back |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Copyright 2006 Olivier Evalet, Alexandre Masselot, all rights reserved. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
136
|
|
|
|
|
|
|
under the same terms as Perl itself. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |
139
|
|
|
|
|
|
|
|
140
|
12
|
|
|
12
|
|
142029
|
use Object::InsideOut; |
|
12
|
|
|
|
|
751634
|
|
|
12
|
|
|
|
|
104
|
|
141
|
|
|
|
|
|
|
my @jobid :Field(Accessor => 'jobid'); |
142
|
|
|
|
|
|
|
#my @infos :Field(Accessor => 'infos'); |
143
|
|
|
|
|
|
|
my @jobalias :Field(Accessor => 'jobalias'); |
144
|
|
|
|
|
|
|
my @username :Field(Accessor => 'username'); |
145
|
|
|
|
|
|
|
my @hosts :Field(Accessor => '_hosts', Type=> 'List', Permission => 'private'); |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
# Query or Manage a Job instance defined by his jobid. |
149
|
|
|
|
|
|
|
my %init_args :InitArgs = ( |
150
|
|
|
|
|
|
|
JOBALIAS=>qr/^jobalias$/i, |
151
|
|
|
|
|
|
|
JOBID=>qr/^jobid$/i, |
152
|
|
|
|
|
|
|
); |
153
|
|
|
|
|
|
|
sub _init :Init{ |
154
|
9
|
|
|
0
|
|
17778
|
my ($self, $h) = @_; |
155
|
9
|
50
|
|
|
|
34
|
$self->jobalias($h->{JOBALIAS})if $h->{JOBALIAS}; |
156
|
9
|
50
|
|
|
|
520
|
$self->jobid($h->{JOBID}) if $h->{JOBID}; |
157
|
9
|
|
|
|
|
361
|
$self->_hosts([]); |
158
|
12
|
|
|
12
|
|
3217
|
} |
|
12
|
|
|
|
|
30
|
|
|
12
|
|
|
|
|
57
|
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub _automethod :Automethod{ |
161
|
0
|
|
|
0
|
|
0
|
my ($self, $val) = @_; |
162
|
0
|
|
|
|
|
0
|
my $set=exists $_[1]; |
163
|
0
|
|
|
|
|
0
|
my $name=$_; |
164
|
0
|
0
|
|
|
|
0
|
if ($name=~/sig(kill|cont|stop)/){ |
165
|
0
|
|
|
|
|
0
|
my $sig=uc $1; |
166
|
|
|
|
|
|
|
return sub{ |
167
|
0
|
|
|
0
|
|
0
|
return $self->signal("SIG$sig"); |
168
|
|
|
|
|
|
|
} |
169
|
0
|
|
|
|
|
0
|
} |
170
|
12
|
|
|
12
|
|
4322
|
} |
|
12
|
|
|
|
|
24
|
|
|
12
|
|
|
|
|
60
|
|
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
# n host index return hash of host |
173
|
|
|
|
|
|
|
# k key return value of the key |
174
|
|
|
|
|
|
|
# v value set value of the key |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
sub hosts{ |
177
|
23
|
|
|
23
|
0
|
53
|
my ($self, $n, $k, $val)=@_; |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
#return the array |
180
|
23
|
50
|
|
|
|
67
|
unless(defined $n){ |
181
|
23
|
50
|
|
|
|
59
|
return wantarray?@{$self->_hosts()}:$self->_hosts(); |
|
23
|
|
|
|
|
626
|
|
182
|
|
|
|
|
|
|
} |
183
|
0
|
0
|
|
|
|
0
|
unless(defined $k){ |
184
|
0
|
|
|
|
|
0
|
return $self->_hosts()->[$n]; |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
0
|
|
|
|
|
0
|
my $reHostField="(host|pid|sid|rank|cmd)"; |
188
|
0
|
0
|
|
|
|
0
|
croak "host parameter not in $reHostField" unless $k=~/^$reHostField$/o; |
189
|
0
|
0
|
|
|
|
0
|
if(defined $val){ |
190
|
0
|
|
|
|
|
0
|
$self->_hosts()->[$n]{$k}=$val; |
191
|
0
|
|
|
|
|
0
|
return $val; |
192
|
|
|
|
|
|
|
} |
193
|
0
|
|
|
|
|
0
|
return $self->_hosts()->[$n]{$k}; |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
sub hosts_push{ |
197
|
14
|
|
|
14
|
0
|
29
|
my ($self, $h)=@_; |
198
|
14
|
|
|
|
|
17
|
push @{$self->_hosts()}, $h; |
|
14
|
|
|
|
|
419
|
|
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
# \$out \$err |
203
|
|
|
|
|
|
|
sub kill{ |
204
|
0
|
|
|
0
|
1
|
0
|
my $this=shift; |
205
|
0
|
|
|
|
|
0
|
my ($out,$err)=@_; |
206
|
0
|
|
|
|
|
0
|
my $stdout=""; |
207
|
0
|
|
|
|
|
0
|
my $stderr=""; |
208
|
0
|
|
|
|
|
0
|
my $pid=""; |
209
|
0
|
0
|
|
|
|
0
|
env_Init() unless defined(%env); |
210
|
0
|
|
|
|
|
0
|
my $params; |
211
|
0
|
|
|
|
|
0
|
$params=$this->jobid(); |
212
|
|
|
|
|
|
|
|
213
|
0
|
|
|
|
|
0
|
my $ret=Parallel::Mpich::MPD::Common::__exec(cmd => commandPath('mpdkilljob')." $params"); |
214
|
0
|
|
|
|
|
0
|
return $ret==0; |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
# return true if the criteria match this job |
218
|
|
|
|
|
|
|
# $criteria{pid} [ && $criteria{rank}] |
219
|
|
|
|
|
|
|
# $criteria{jobid} |
220
|
|
|
|
|
|
|
# $criteria{jobalias} |
221
|
|
|
|
|
|
|
# $criteria{username} |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
sub equals{ |
224
|
0
|
|
|
0
|
1
|
0
|
my $this=shift; |
225
|
0
|
|
|
|
|
0
|
my %criteria=@_; |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
#print Dumper \%criteria; |
228
|
|
|
|
|
|
|
#print $this; |
229
|
|
|
|
|
|
|
|
230
|
0
|
0
|
0
|
|
|
0
|
if (defined($criteria{jobalias}) && $criteria{jobalias}{$this->jobalias}){ |
231
|
0
|
|
|
|
|
0
|
return 1; |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
|
234
|
0
|
0
|
0
|
|
|
0
|
if (defined($criteria{username}) && $criteria{username}{$this->username}){ |
235
|
0
|
|
|
|
|
0
|
return 1; |
236
|
|
|
|
|
|
|
} |
237
|
|
|
|
|
|
|
|
238
|
0
|
0
|
0
|
|
|
0
|
if (defined($criteria{jobid}) && $criteria{jobid}{$this->jobid}){ |
239
|
0
|
|
|
|
|
0
|
return 1; |
240
|
|
|
|
|
|
|
} |
241
|
|
|
|
|
|
|
|
242
|
0
|
|
|
|
|
0
|
foreach my $host (@{$this->_hosts()}){ |
|
0
|
|
|
|
|
0
|
|
243
|
0
|
0
|
|
|
|
0
|
if (defined($criteria{pid})) { |
244
|
0
|
0
|
|
|
|
0
|
if (defined($criteria{rank})) { |
245
|
0
|
0
|
0
|
|
|
0
|
return 1 if ($criteria{rank} eq $host->{rank} && $criteria{pid} eq $host->{rank}); |
246
|
|
|
|
|
|
|
}else{ |
247
|
0
|
0
|
|
|
|
0
|
return 1 if ($criteria{pid} eq $host->{pid}); |
248
|
|
|
|
|
|
|
} |
249
|
|
|
|
|
|
|
} |
250
|
|
|
|
|
|
|
} |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
} |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
# Send a signal to all process for the current job. |
255
|
|
|
|
|
|
|
# SIGQUIT, SIGKILL, SIGSTOP, SIGCONT, SIGXCPU, SIGUSR1, SIGUSR2 |
256
|
|
|
|
|
|
|
sub signal{ |
257
|
0
|
|
|
0
|
1
|
0
|
my $stdout=""; |
258
|
0
|
|
|
|
|
0
|
my $stderr=""; |
259
|
0
|
|
|
|
|
0
|
my $pid=""; |
260
|
0
|
|
|
|
|
0
|
my $this=shift; |
261
|
0
|
|
|
|
|
0
|
my ($sigtype)=@_; |
262
|
0
|
0
|
|
|
|
0
|
if (!defined($sigtype)){ |
263
|
0
|
|
|
|
|
0
|
printf STDERR "ERROR:".__PACKAGE__."::__sig() sigtype is not defined. \n"; |
264
|
0
|
|
|
|
|
0
|
return 0; |
265
|
|
|
|
|
|
|
} |
266
|
0
|
0
|
|
|
|
0
|
env_Init() unless defined(%env); |
267
|
0
|
|
|
|
|
0
|
my $params; |
268
|
0
|
|
|
|
|
0
|
$params="-j ".$this->jobid(); |
269
|
|
|
|
|
|
|
|
270
|
0
|
|
|
|
|
0
|
my $ret=Parallel::Mpich::MPD::Common::__exec(cmd => commandPath('mpdsigjob')." $sigtype $params"); |
271
|
|
|
|
|
|
|
|
272
|
0
|
|
|
|
|
0
|
return $ret==0; |
273
|
|
|
|
|
|
|
} |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
#sub stop{ |
276
|
|
|
|
|
|
|
# my $this=shift; |
277
|
|
|
|
|
|
|
# return $this->signal("SIGSTOP"); |
278
|
|
|
|
|
|
|
#} |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
#sub continue{ |
281
|
|
|
|
|
|
|
# my $this=shift; |
282
|
|
|
|
|
|
|
# return $this->signal("SIGCONT"); |
283
|
|
|
|
|
|
|
#} |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
#sub destroy{ |
286
|
|
|
|
|
|
|
# my $this=shift; |
287
|
|
|
|
|
|
|
# return $this->signal("SIGKILL"); |
288
|
|
|
|
|
|
|
#} |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
|
291
|
12
|
|
|
12
|
|
17221
|
use overload '""' => \&toSummaryString; |
|
12
|
|
|
|
|
29
|
|
|
12
|
|
|
|
|
181
|
|
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
sub toSummaryString{ |
294
|
20
|
|
|
20
|
1
|
520
|
my $self=shift; |
295
|
|
|
|
|
|
|
|
296
|
20
|
|
|
|
|
615
|
my $ret=$self->jobid."\t(alias='".$self->jobalias."', user='".$self->username."')\n"; |
297
|
20
|
|
|
|
|
2611
|
my @h=$self->hosts(); |
298
|
20
|
|
|
|
|
1526
|
foreach (sort {$a->{rank} <=> $b->{rank}} @h){ |
|
2
|
|
|
|
|
14
|
|
299
|
13
|
|
50
|
|
|
196
|
$ret.="$_->{rank}\t".($_->{host}||'')."\t".($_->{pid}||'')."\t".($_->{sid}||'')."\t".($_->{pgm}||'')."\n"; |
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
300
|
|
|
|
|
|
|
} |
301
|
20
|
|
|
|
|
147
|
return $ret."\n"; |
302
|
|
|
|
|
|
|
} |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
1; # End of Parallel::Mpich::MPD |