Commit 21c06220 authored by Leo Gordon's avatar Leo Gordon
Browse files

kill-worker-process-by-worker-id: simplified specific Meadow code by moving...

kill-worker-process-by-worker-id: simplified specific Meadow code by moving general checks out of them
parent 3fcd5f98
......@@ -91,18 +91,10 @@ sub check_worker_is_alive_and_mine {
sub kill_worker {
my ($self, $worker) = @_;
my $worker = pop @_;
if( $self->responsible_for_worker($worker) ) {
if($self->check_worker_is_alive_and_mine($worker)) {
my $cmd = 'kill -9 '.$worker->process_id();
system($cmd);
} else {
warn 'Cannot kill worker '.$worker->process_id().' because it is not running';
}
} else {
warn 'Cannot kill worker '.$worker->process_id().'@'.$worker->host.' it is probably running on a different host';
}
my $cmd = 'kill -9 '.$worker->process_id();
system($cmd);
}
......
......@@ -88,14 +88,10 @@ sub check_worker_is_alive_and_mine {
}
sub kill_worker {
my ($self, $worker) = @_;
my $worker = pop @_;
if($self->check_worker_is_alive_and_mine($worker)) {
my $cmd = 'bkill '.$worker->process_id();
system($cmd);
} else {
warn 'Cannot kill worker '.$worker->process_id().' because it is not running';
}
my $cmd = 'bkill '.$worker->process_id();
system($cmd);
}
sub find_out_causes {
......
......@@ -208,19 +208,23 @@ sub main {
unless( $worker->cause_of_death() ) {
if( my $meadow = $valley->find_available_meadow_responsible_for_worker( $worker ) ) {
printf("Killing worker: %10d %35s %15s %20s(%d) : ",
$worker->dbID, $worker->host, $worker->process_id,
$worker->analysis->logic_name, $worker->analysis->dbID);
$meadow->kill_worker($worker);
$worker->cause_of_death('KILLED_BY_USER');
$queen->register_worker_death($worker);
# what about clean-up? Should we do it here or not?
if( $meadow->check_worker_is_alive_and_mine ) {
printf("Killing worker: %10d %35s %15s %20s(%d) : ",
$worker->dbID, $worker->host, $worker->process_id,
$worker->analysis->logic_name, $worker->analysis->dbID);
$meadow->kill_worker($worker);
$worker->cause_of_death('KILLED_BY_USER');
$queen->register_worker_death($worker);
# what about clean-up? Should we do it here or not?
} else {
die "According to the Meadow, the Worker (dbID=$kill_worker_id) is not running, so cannot kill";
}
} else {
die "Could not access meadow responsible for worker (dbID=$kill_worker_id), so cannot kill";
die "Cannot access the Meadow responsible for the Worker (dbID=$kill_worker_id), so cannot kill";
}
} else {
die "Worker (dbID=$kill_worker_id) already dead, so cannot kill";
die "According to the Queen, the Worker (dbID=$kill_worker_id) is not running, so cannot kill";
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment