| 1 | package Helios::Panoptes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.008000; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use base qw(CGI::Application); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use CGI::Application::Plugin::DBH qw(dbh_config dbh); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Error qw(:try); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Helios::Service; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | our $VERSION = '1.44'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | our $CONF_PARAMS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | Helios::Panoptes - CGI::Application providing web admin interface to Helios distributed job | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | processing system | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | Helios::Panoptes is the web interface to the Helios distributed job processing system. It | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | provides a central point of control for all of the services and jobs in a Helios collective. This | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | web interface can be used to track jobs through the system and manage workloads on a per service | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | and per host basis. Available workers may be increased or decreased as necessary, tuned to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | match available resources. Job processing can be held, or Helios daemons can be HALTed, from this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | interface. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | (Why I<Panoptes>? Check your Wikipedia. Or better yet, Greek dictionary.) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | =head1 CGI::Application SETUP METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | =head2 setup() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | The setup() method defines the available run modes, which include: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | =item ctrl_panel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | The Ctrl Panel is the web interface to the central Helios configuration parameter repository (the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | helios_params_tb table in the Helios database). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | =item ctrl_panel_mod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | Used by the Ctrl Panel and Worker Admin run modes to change configuration parameters in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | helios_params_tb. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | =item job_queue_view | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | The Job Queue view provides views of waiting, running, and completed jobs in the Helios collective. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | =item collective | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | The Collective Admin provides a simple, dashboard-style view of the current services running in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | the Helios collective, broken down by host. The service class version is displayed, as well | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | as the daemons' uptime. Job processing can be held and unheld here, and the daemons' run modes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | can be shifted between Normal and Overdrive mode. The maximum workers for each service can be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | managed, and services can be shut down here via the HALT button. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | =item job_submit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | The Submit Job view provides a simple interface to submit a test job to the Helios collective for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | debugging purposes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | sub setup { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setup: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | $self->start_mode('job_queue_view'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | $self->mode_param('rm'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | $self->run_modes( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | ctrl_panel => 'ctrl_panel', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | ctrl_panel_mod => 'ctrl_panel_mod', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | job_queue_view => 'job_queue_view', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | job_detail => 'job_detail', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | job_submit => 'job_submit', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | collective => 'collective', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my $inifile; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | if (defined($ENV{HELIOS_INI}) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | $inifile = $ENV{HELIOS_INI}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $inifile = './helios.ini'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | $self->{service} = Helios::Service->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | $self->{service}->prep(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | my $config = $self->{service}->getConfig(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | $CONF_PARAMS = $config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | # connect to db | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | $self->dbh_config($config->{dsn},$config->{user},$config->{password}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | =head2 teardown() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | The only thing that currently happens in teardown() is the database is disconnected. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | sub teardown { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
teardown: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | $self->dbh->disconnect(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | =head1 RUN MODE METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | These methods define code that back the particular application pages. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | =head2 ctrl_panel() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | This method controls the rendering of the Ctrl Panel view, used to display Helios configuration | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | parameters. The view also allows the user to change config parameters, although the actual config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | modifications are handled by the ctrl_panel_mod() run mode. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | sub ctrl_panel { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ctrl_panel: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | my $dbh = $self->dbh(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my $q = $self->query(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | my $sql = <<PNLSQL; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | SELECT worker_class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | host, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | param, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | FROM helios_params_tb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | ORDER BY worker_class, host, param | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | PNLSQL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my $sth = $dbh->prepare($sql); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | unless($sth) { throw Error::Simple($dbh->errstr); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | $sth->execute() or throw Error::Simple($dbh->errstr()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my $classes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | my $hosts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | my $params = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | my $last_host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | my $last_class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | my $current_host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | my $current_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | my $first_result = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | while (my $result = $sth->fetchrow_hashref() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | if ($first_result) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | $last_class = $result->{worker_class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | $last_host = $result->{host}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | $first_result = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | if ($result->{worker_class} ne $last_class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | $current_host->{PARAMS} = $params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | $current_host->{HOST} = $last_host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | $current_host->{WORKER_CLASS} = $last_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | push(@$hosts, $current_host); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | undef $params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | undef $current_host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $last_host = $result->{host}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | $current_class->{HOSTS} = $hosts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | $current_class->{WORKER_CLASS} = $last_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | push(@$classes, $current_class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | undef $hosts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | undef $current_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | $last_class = $result->{worker_class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | if ($result->{host} ne $last_host) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | $current_host->{PARAMS} = $params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | $current_host->{HOST} = $last_host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | $current_host->{WORKER_CLASS} = $last_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | push(@$hosts, $current_host); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | undef $params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | undef $current_host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $last_host = $result->{host}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | push(@$params, $result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | $current_host->{PARAMS} = $params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | $current_host->{HOST} = $last_host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | $current_host->{WORKER_CLASS} = $last_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | push(@$hosts, $current_host); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | $current_class->{HOSTS} = $hosts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | $current_class->{WORKER_CLASS} = $last_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | push(@$classes, $current_class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my $tmpl = $self->load_tmpl(undef, die_on_bad_params => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | $tmpl->param(TITLE => "Helios - Control Panel"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | # only fill in parameters if we actually have some | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | if ( $classes->[0]->{HOSTS}->[0]->{HOST} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | $tmpl->param(CLASSES => $classes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | return $tmpl->output(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | =head2 ctrl_panel_mod() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | Run mode used to modify Helios config parameters. Used by ctrl_panel() and collective(). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | The ctrl_panel_mod run mode uses the following parameters: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | =item worker_class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | The worker (service) class of the changed parameter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | =item host | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | The host of the changed parameter (* for all hosts) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | =item param | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | THe name of the parameter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | =item value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | The value the parameter should be changed to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | =item action | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | The action (add, modify, delete) to perform. A delete action will delete the param for the worker | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | class and host in question (obviously), add will add it, and modify will replace any existing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | values of the parameter with the new value. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | sub ctrl_panel_mod { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ctrl_panel_mod: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | my $dbh = $self->dbh(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | my $q = $self->query(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | my $return_to = $q->param('return_to'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | my $sql; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | my $worker_class = $q->param('worker_class'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | my $host = $q->param('host'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | my $param = $q->param('param'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | my $value = $q->param('value'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | my $action = $q->param('action'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | unless ($worker_class && $host && $param && $action) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$worker_class and $host and $param and $action
$worker_class and $host and $param
$worker_class and $host
MC/DC0%0/4
$worker_class and $host and $param and $action
$worker_class
$host
$param
$action
Truth table0%0/5
A and B and C and D
A= $worker_classB= $hostC= $paramD= $action
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | throw Error::Simple("Worker class ($worker_class), host ($host), param ($param), and action ($action) required"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | $self->modParam($action, $worker_class, $host, $param, $value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | if (defined($return_to)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | if ( defined($q->param('groupby')) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | print $q->redirect("./panoptes.pl?rm=$return_to&groupby=".$q->param('groupby')); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | print $q->redirect("./panoptes.pl?rm=$return_to"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | print $q->redirect('./panoptes.pl?rm=ctrl_panel'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | =head2 job_queue_view() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | The job_queue_view() run mode handles the display of the lists of running, waiting, and completed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | jobs. Note that although all Job Queue lists are dispatched to here, lists of completed jobs are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | actually redirected to _job_queue_view_completed(). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | sub job_queue_view { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
job_queue_view: not called CC=21 SCAR=61.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | my $q = $self->query(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | my $job_status = $q->param('status'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | my $job_detail = $q->param('job_detail'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | # "job_queue_view" is actually a basket of views, all sharing the same template | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | if ( defined($job_status) && $job_status eq 'done' && $job_detail) { return $self->_job_queue_view_done($q); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $job_status and $job_status eq "done" and $job_detail
defined $job_status and $job_status eq "done"
MC/DC0%0/3
defined $job_status and $job_status eq "done" and $job_detail
defined $job_status
$job_status eq "done"
$job_detail
Truth table0%0/4
A and B and C
A= defined $job_statusB= $job_status eq "done"C= $job_detail
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | if ( defined($job_status) && $job_status eq 'done' && !$job_detail) { return $self->_job_queue_count_done($q); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $job_status and $job_status eq "done" and not $job_detail
defined $job_status and $job_status eq "done"
MC/DC0%0/3
defined $job_status and $job_status eq "done" and not $job_detail
defined $job_status
$job_status eq "done"
not $job_detail
Truth table0%0/4
A and B and not(C)
A= defined $job_statusB= $job_status eq "done"C= not $job_detail
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | if ( !$job_detail ) { return $self->_job_queue_count($q); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | my $dbh = $self->dbh(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | my $now = time(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | my $funcmap = $self->loadFuncMap(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | my $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | my $sql; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | my @where_clauses; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | # defaults | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | my $time_horizon = 3600; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | $job_status = 'run'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | $sql = <<ACTIVEJOBSQL; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | SELECT funcid, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | jobid, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | arg, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | uniqkey, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | insert_time, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | run_after, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | grabbed_until, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | priority, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | coalesce | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | FROM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | job j | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | ACTIVEJOBSQL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | # form values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | if ( defined($q->param('time')) ) { $time_horizon = $q->param('time'); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | if ( defined($q->param('status')) ) { $job_status = $q->param('status'); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | SWITCH: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | if ($job_status eq 'run') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | push(@where_clauses,"grabbed_until != 0"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | $time_horizon = 'all'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | last SWITCH; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | if ($job_status eq 'wait') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | push(@where_clauses,"run_after < $now"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | push(@where_clauses,"grabbed_until < $now"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | last SWITCH; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | #[] default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | $time_horizon = 'all'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | # time horizon filter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | if ( defined($time_horizon) && ($time_horizon ne '') && ($time_horizon ne 'all') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $time_horizon and $time_horizon ne "" and $time_horizon ne "all"
defined $time_horizon and $time_horizon ne ""
MC/DC0%0/3
defined $time_horizon and $time_horizon ne "" and $time_horizon ne "all"
defined $time_horizon
$time_horizon ne ""
$time_horizon ne "all"
Truth table0%0/4
A and B and C
A= defined $time_horizonB= $time_horizon ne ""C= $time_horizon ne "all"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | push(@where_clauses, "run_after > ".($now - $time_horizon) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | # complete WHERE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | if (scalar(@where_clauses)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | $sql .= " WHERE ". join(' AND ',@where_clauses); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | # ORDER BY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | $sql .= " ORDER BY funcid asc, run_after desc"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | #t print $q->header(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | #t print $sql; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | my $sth = $dbh->prepare($sql); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | unless($sth) { throw Error::Simple($dbh->errstr); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | $sth->execute() or throw Error::Simple($dbh->errstr()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | my @job_types; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | my $job_count = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | my @dbresult; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | my $current_job_class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | my $first_result = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | my $last_class = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | while ( my $result = $sth->fetchrow_arrayref() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | if ($first_result) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | $last_class = $result->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | $first_result = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | if ($result->[0] ne $last_class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | push(@job_types, $current_job_class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | undef $current_job_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | $last_class = $result->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | $job_count = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | my $date_parts = $self->splitEpochDate($result->[5]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | my $grabbed_until = $self->splitEpochDate($result->[6]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | $current_job_class->{JOB_CLASS} = $funcmap->{$result->[0]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | $current_job_class->{JOB_COUNT} = ++$job_count; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | push(@{ $current_job_class->{JOBS} }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | { JOBID => $result->[1], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | # ARG => $result->[2], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | UNIQKEY => $result->[3], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | INSERT_TIME => $result->[4], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | RUN_AFTER => $date_parts->{YYYY}.'-'.$date_parts->{MM}.'-'.$date_parts->{DD}.' '.$date_parts->{HH24}.':'.$date_parts->{MI}.':'.$date_parts->{SS}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | GRABBED_UNTIL => $grabbed_until->{YYYY}.'-'.$grabbed_until->{MM}.'-'.$grabbed_until->{DD}.' '.$grabbed_until->{HH24}.':'.$grabbed_until->{MI}.':'.$grabbed_until->{SS}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | PRIORITY => $result->[7], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | COALESCE => $result->[8] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | push(@job_types, $current_job_class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | my $tmpl = $self->load_tmpl(undef, die_on_bad_params => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | $tmpl->param(TITLE => "Helios - Job Queue"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | $tmpl->param("STATUS_".$job_status, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | $tmpl->param("TIME_".$time_horizon, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | $tmpl->param("JOB_DETAIL_CHECKED" => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | $tmpl->param(JOB_CLASSES => \@job_types); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | return $tmpl->output(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | =head2 _job_queue_view_done() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | This method is called from job_queue_view() to deal with displaying completed jobs, which pulls | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | completed job data from helios_job_history_tb instead of the job table. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | ▶ | sub _job_queue_view_done { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_job_queue_view_done: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | my $q = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | my $dbh = $self->dbh(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | my $now = time(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | my $funcmap = $self->loadFuncMap(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | my $job_status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | my $output; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | my $sql; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | my @where_clauses; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | # defaults | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | my $time_horizon = 3600; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | $sql = ' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | select * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | from (select | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | if (@jid = jobid, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | if (@time = complete_time, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | @rnk := @rnk + least(0, @inc := @inc + 1), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | @rnk := @rnk + greatest(@inc, @inc := 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | + least(0, @time := complete_time) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | @rnk := 1 + least(0, @jid := jobid) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | + least(0, @time := complete_time) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | + least(0, @inc := 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | ) rank, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | jobid, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | funcid, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | run_after, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | grabbed_until, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | exitstatus, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | complete_time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | from helios_job_history_tb, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | (select (@jid := 0)) as x | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | where complete_time >= ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | order by jobid, complete_time desc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | ) as y | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | where rank < 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | order by funcid asc, complete_time desc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | '; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | # form values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | ▶ | if ( defined($q->param('time')) ) { $time_horizon = $q->param('time'); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | ▶ | if ( defined($q->param('time')) && ($q->param('time') eq '') ) { $time_horizon = 3600; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $q->param("time") and $q->param("time") eq ""
MC/DC0%0/2
defined $q->param("time") and $q->param("time") eq ""
defined $q->param("time")
$q->param("time") eq ""
Truth table0%0/3
A and B
A= defined $q->param("time")B= $q->param("time") eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | if ( defined($q->param('status')) ) { $job_status = $q->param('status'); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | #t print $q->header(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | #t print $sql,"<br>\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | #t print $now - $time_horizon,"<br>\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | my $sth = $dbh->prepare($sql); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | ▶ | unless($sth) { throw Error::Simple($dbh->errstr); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | ▶ | $sth->execute($now - $time_horizon) or throw Error::Simple($dbh->errstr()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | my @job_types; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | my $job_count = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | my $job_count_failed = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | my @dbresult; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | my $current_job_class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | my $first_result = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | my $last_class = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | my $last_jobid = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | ▶ | while ( my $result = $sth->fetchrow_hashref() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | # print join("|",($result->{rank},$result->{funcid},$result->{jobid},$result->{complete_time},$result->{run_after},$result->{exitstatus},$result->{run_after},$result->{grabbed_until})),"<br>\n"; #p | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | ▶ | if ($first_result) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | $last_class = $result->{funcid}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | $first_result = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | if ($result->{funcid} ne $last_class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | push(@job_types, $current_job_class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | undef $current_job_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | $last_class = $result->{funcid}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | $job_count = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | $job_count_failed = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | my $date_parts = $self->splitEpochDate($result->{run_after}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | my $complete_time = $self->splitEpochDate($result->{complete_time}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | $current_job_class->{JOB_CLASS} = $funcmap->{$result->{funcid}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | $current_job_class->{JOB_COUNT} = ++$job_count; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | if ( $result->{exitstatus} != 0 ) { $current_job_class->{JOB_COUNT_FAILED} = ++$job_count_failed; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | # if this jobid is the same as the last, that means it was a failure that was retried | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | # dump it, because we've already added the final completion of the job (whether success or fail) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | # because we sorted "jobid, complete_time desc" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | push(@{ $current_job_class->{JOBS} }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | { JOBID => $result->{jobid}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | # ARG => $result->[2], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | RUN_AFTER => $date_parts->{YYYY}.'-'.$date_parts->{MM}.'-'.$date_parts->{DD}.' '.$date_parts->{HH24}.':'.$date_parts->{MI}.':'.$date_parts->{SS}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | GRABBED_UNTIL => $result->{grabbed_until}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | COMPLETE_TIME => $complete_time->{YYYY}.'-'.$complete_time->{MM}.'-'.$complete_time->{DD}.' '.$complete_time->{HH24}.':'.$complete_time->{MI}.':'.$complete_time->{SS}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | EXITSTATUS => $result->{exitstatus} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | $last_jobid = $result->{jobid}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | push(@job_types, $current_job_class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | @job_types = sort { $a->{JOB_CLASS} cmp $b->{JOB_CLASS} } @job_types; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | my $tmpl = $self->load_tmpl('job_queue_view.html', die_on_bad_params => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | $tmpl->param(TITLE => 'Helios - Job Queue'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | $tmpl->param("STATUS_".$job_status, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | $tmpl->param("TIME_".$time_horizon, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | $tmpl->param("JOB_DETAIL_CHECKED" => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | $tmpl->param(JOB_CLASSES => \@job_types); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | return $tmpl->output(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | =head2 job_queue_count() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | This method will handle a job queue view that displays only counts. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | ▶ | sub _job_queue_count { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_job_queue_count: not called CC=14 SCAR=53.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | my $q = $self->query(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | my $job_status = $q->param('status'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | my $dbh = $self->dbh(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | my $now = time(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | my $funcmap = $self->loadFuncMap(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | my $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | my $sql; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | my @where_clauses; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | # defaults | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | my $time_horizon = 3600; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | $job_status = 'run'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | # form values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | if ( defined($q->param('time')) ) { $time_horizon = $q->param('time'); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | ▶ | if ( defined($q->param('status')) ) { $job_status = $q->param('status'); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | $sql = "SELECT funcid, count(*) FROM job "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | SWITCH: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | ▶ | if ($job_status eq 'run') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | push(@where_clauses,"grabbed_until != 0"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | $time_horizon = 'all'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | last SWITCH; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | ▶ | if ($job_status eq 'wait') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | push(@where_clauses,"run_after < $now"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | push(@where_clauses,"grabbed_until < $now"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | last SWITCH; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | # default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | $time_horizon = 'all'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | # time horizon filter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | ▶ | if ( defined($time_horizon) && ($time_horizon ne '') && ($time_horizon ne 'all') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $time_horizon and $time_horizon ne "" and $time_horizon ne "all"
defined $time_horizon and $time_horizon ne ""
MC/DC0%0/3
defined $time_horizon and $time_horizon ne "" and $time_horizon ne "all"
defined $time_horizon
$time_horizon ne ""
$time_horizon ne "all"
Truth table0%0/4
A and B and C
A= defined $time_horizonB= $time_horizon ne ""C= $time_horizon ne "all"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | push(@where_clauses, "run_after > ".($now - $time_horizon) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | # complete WHERE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | ▶ | if (scalar(@where_clauses)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | $sql .= " WHERE ". join(' AND ',@where_clauses); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | # GROUP BY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | $sql .= " GROUP BY funcid"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | # ORDER BY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | $sql .= " ORDER BY funcid asc"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | my $sth = $dbh->prepare($sql); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | ▶ | unless($sth) { throw Error::Simple($dbh->errstr); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | ▶ | $sth->execute() or throw Error::Simple($dbh->errstr()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | my @job_types; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | my $job_count = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | my @dbresult; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | my $current_job_class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | my $first_result = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | my $last_class = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | ▶ | while ( my $result = $sth->fetchrow_arrayref() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | ▶ | if ($first_result) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | $last_class = $result->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | $first_result = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | ▶ | if ($result->[0] ne $last_class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | push(@job_types, $current_job_class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | undef $current_job_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | $last_class = $result->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | $job_count = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | $current_job_class->{JOB_CLASS} = $funcmap->{$result->[0]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | $current_job_class->{JOB_COUNT} = $result->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | push(@job_types, $current_job_class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | my $tmpl = $self->load_tmpl('job_queue_view.html', die_on_bad_params => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | $tmpl->param(TITLE => "Helios - Job Queue"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | $tmpl->param("STATUS_".$job_status, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | $tmpl->param("TIME_".$time_horizon, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | $tmpl->param("JOB_DETAIL_CHECKED" => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | $tmpl->param(JOB_CLASSES => \@job_types); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | return $tmpl->output(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | ▶ | sub _job_queue_count_done { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_job_queue_count_done: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | my $q = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | my $dbh = $self->dbh(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | my $now = time(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | my $funcmap = $self->loadFuncMap(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | my $job_status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | my $output; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | my $sql; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | my @where_clauses; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | # defaults | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | my $time_horizon = 3600; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | $sql = ' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | select funcid, if(exitstatus,1,0) as exitstatus, count(*) as count | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | from (select | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | if (@jid = jobid, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | if (@time = complete_time, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | @rnk := @rnk + least(0, @inc := @inc + 1), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | @rnk := @rnk + greatest(@inc, @inc := 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | + least(0, @time := complete_time) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | @rnk := 1 + least(0, @jid := jobid) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | + least(0, @time := complete_time) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | + least(0, @inc := 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | ) rank, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | jobid, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | funcid, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | run_after, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | exitstatus, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | complete_time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | from helios_job_history_tb, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | (select (@jid := 0)) as x | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | where complete_time >= ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | order by jobid, complete_time desc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | ) as y | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | where rank < 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | GROUP BY funcid, if(exitstatus,1,0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | '; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | # form values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | ▶ | if ( defined($q->param('time')) ) { $time_horizon = $q->param('time'); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | ▶ | if ( defined($q->param('time')) && ($q->param('time') eq '') ) { $time_horizon = 3600; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $q->param("time") and $q->param("time") eq ""
MC/DC0%0/2
defined $q->param("time") and $q->param("time") eq ""
defined $q->param("time")
$q->param("time") eq ""
Truth table0%0/3
A and B
A= defined $q->param("time")B= $q->param("time") eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | ▶ | if ( defined($q->param('status')) ) { $job_status = $q->param('status'); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | #t print $q->header(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | #t print $sql,"<br>\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | #t print $now - $time_horizon,"<br>\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | my $sth = $dbh->prepare($sql); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | ▶ | unless($sth) { throw Error::Simple($dbh->errstr); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | ▶ | $sth->execute($now - $time_horizon) or throw Error::Simple($dbh->errstr()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | my @job_types; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | my $current_funcid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | my $current_success_jobs = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | my $current_failed_jobs = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | my $last_funcid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | my $first_result = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | ▶ | while ( my $result = $sth->fetchrow_arrayref() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | # print join("|",@$result),"<br>\n"; #p | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | ▶ | if ($first_result) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | $last_funcid = $result->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | $current_funcid = $result->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | $first_result = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | ▶ | if ($current_funcid ne $result->[0] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | # flush | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | push(@job_types, { JOB_CLASS => $funcmap->{$current_funcid}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | JOB_COUNT => $current_success_jobs + $current_failed_jobs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | JOB_COUNT_FAILED => $current_failed_jobs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | $last_funcid = $result->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | $current_success_jobs = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | $current_failed_jobs = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | $current_funcid = $result->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | ▶ | if ($result->[1] == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | $current_success_jobs = $result->[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | $current_failed_jobs = $result->[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | push(@job_types, { JOB_CLASS => $funcmap->{$current_funcid}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | JOB_COUNT => $current_success_jobs + $current_failed_jobs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | JOB_COUNT_FAILED => $current_failed_jobs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | @job_types = sort { $a->{JOB_CLASS} cmp $b->{JOB_CLASS} } @job_types; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | my $tmpl = $self->load_tmpl('job_queue_view.html', die_on_bad_params => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | $tmpl->param(TITLE => 'Helios - Job Queue'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | $tmpl->param("STATUS_".$job_status, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | $tmpl->param("TIME_".$time_horizon, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | $tmpl->param("JOB_DETAIL_CHECKED" => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | $tmpl->param(JOB_CLASSES => \@job_types); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | return $tmpl->output(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | =head2 job_submit() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | The job_submit() run mode allows for manual submission of a job to the Helios collective via | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | Panoptes. This run mode is useful mainly for debugging purposes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | This run mode uses the Helios web job submission interface (submitJob.pl) and requires the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | job_submit_url option being set in the [global] section of helios.ini so it can submit the job to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | the appropriate URL. eg: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | [global] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | job_submit_url=http://localhost/cgi-bin/submitJob.pl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | This run mode is really just displaying a form with some of the details filled in. Once you | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | submit the form, the response you receive is actually the response returned from submitJob.pl. If | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | job submission was successful, this is normally a file of type text/xml with a <status> section | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | (normally containing 0) and a <jobid> section (containing the id of the job just submitted). If | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | there was an error during submission, the response will be an HTTP error, and submitJob.pl will | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | log a message in the Helios log. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | ▶ | sub job_submit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
job_submit: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | my $q = $self->query(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | my $classmap = $self->loadClassMap(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | my @classes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | foreach (sort keys %$classmap) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | push(@classes, { job_type => $_, job_class => $classmap->{$_} }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | my $tmpl = $self->load_tmpl('job_submit.html', die_on_bad_params => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | $tmpl->param(TITLE => 'Helios - Job Submit'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | $tmpl->param(CLASSES => \@classes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | $tmpl->param(JOB_SUBMIT_URL => $CONF_PARAMS->{job_submit_url}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | return $tmpl->output(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | =head2 collective() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | The collective() run mode provides the Collective display, a list of what Helios service daemons | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | are running in the collective, with some limited convenience controls for admins that don't want | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | to deal with the Ctrl Panel. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | The collective() method actually reads the groupby CGI parameter and dispatches to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | _collective_host() or _collective_service(), depending on which the user specified (the default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | is service). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | ▶ | sub collective { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
collective: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 0 | my $q = $self->query(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | ▶ | if ($q->param('groupby') eq 'service') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 0 | return $self->_collective_service(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | return $self->_collective_host(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | =head2 _collective_host() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | The _collective_host() method provides the Collective display grouped by host. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 0 | ▶ | sub _collective_host { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_collective_host: not called CC=20 SCAR=59.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | my $dbh = $self->dbh(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | my $q = $self->query(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 0 | my $config = $self->loadParams('host'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | my $register_threshold = time() - 360; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | my $sql = <<STATUSSQL; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | SELECT host, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | worker_class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | worker_version, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | process_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | register_time, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | start_time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | FROM helios_worker_registry_tb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | WHERE register_time > ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | ORDER BY host, worker_class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | STATUSSQL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 0 | my $sth = $dbh->prepare($sql); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | ▶ | unless ($sth) { throw Error::Simple($dbh->errstr); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | ▶ | $sth->execute($register_threshold) or throw Error::Simple($dbh->errstr()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 0 | my @collective; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | my @dbresult; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 0 | my $current_host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 0 | my $first_result = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | my $last_host = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 0 | ▶ | while ( my $result = $sth->fetchrow_arrayref() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 0 | ▶ | if ($first_result) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 0 | $last_host = $result->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | $first_result = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | ▶ | if ($result->[0] ne $last_host) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | push(@collective, $current_host); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 0 | undef $current_host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | $last_host = $result->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | my $date_parts = $self->splitEpochDate($result->[4]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | $current_host->{HOST} = $result->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | # calc uptime | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | my $uptime_string = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | ▶ | use integer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | my $uptime = time() - $result->[5]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | my $uptime_days = $uptime/86400; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | my $uptime_hours = ($uptime % 86400)/3600; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 0 | my $uptime_mins = (($uptime % 86400) % 3600)/60; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | ▶ | if ($uptime_days != 0) { $uptime_string .= $uptime_days.'d '; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | ▶ | if ($uptime_hours != 0) { $uptime_string .= $uptime_hours.'h '; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 0 | ▶ | if ($uptime_mins != 0) { $uptime_string .= $uptime_mins.'m '; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | # max_workers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | my $max_workers = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 0 | ▶ | if ( defined($config->{ $result->[0] }->{ $result->[1] }->{MAX_WORKERS}) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | $max_workers = $config->{ $result->[0] }->{ $result->[1] }->{MAX_WORKERS}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | # figure out status (normal/overdrive/holding/halting) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 0 | my $status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | my $halt_status = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 0 | my $hold_status = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 0 | my $overdrive_status = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | ▶ | if ( (defined( $config->{$result->[0] }->{ $result->[1] }->{OVERDRIVE}) && ($config->{$result->[0] }->{ $result->[1] }->{OVERDRIVE} == 1) ) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
defined $$config{$result->[0]}{$result->[1]}{"OVERDRIVE"} and $$config{$result->[0]}{$result->[1]}{"OVERDRIVE"} == 1 or defined $config->{"*"}{$result->[1]}{"OVERDRIVE"} and $config->{"*"}{$result->[1]}{"OVERDRIVE"} == 1
defined $$config{$result->[0]}{$result->[1]}{"OVERDRIVE"} and $$config{$result->[0]}{$result->[1]}{"OVERDRIVE"} == 1
defined $config->{"*"}{$result->[1]}{"OVERDRIVE"} and $config->{"*"}{$result->[1]}{"OVERDRIVE"} == 1
MC/DC0%0/4
defined $$config{$result->[0]}{$result->[1]}{"OVERDRIVE"} and $$config{$result->[0]}{$result->[1]}{"OVERDRIVE"} == 1 or defined $config->{"*"}{$result->[1]}{"OVERDRIVE"} and $config->{"*"}{$result->[1]}{"OVERDRIVE"} == 1
defined $$config{$result->[0]}{$result->[1]}{"OVERDRIVE"}
$$config{$result->[0]}{$result->[1]}{"OVERDRIVE"} == 1
defined $config->{"*"}{$result->[1]}{"OVERDRIVE"}
$config->{"*"}{$result->[1]}{"OVERDRIVE"} == 1
Truth table0%0/7
A and B or C and D
A= defined $$config{$result->[0]}{$result->[1]}{"OVERDRIVE"}B= $$config{$result->[0]}{$result->[1]}{"OVERDRIVE"} == 1C= defined $config->{"*"}{$result->[1]}{"OVERDRIVE"}D= $config->{"*"}{$result->[1]}{"OVERDRIVE"} == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | (defined( $config->{'*'}->{ $result->[1] }->{OVERDRIVE}) && ($config->{'*'}->{ $result->[1] }->{OVERDRIVE} == 1) ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 0 | $overdrive_status = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | $status = "Overdrive"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | ▶ | if ( (defined( $config->{$result->[0] }->{ $result->[1] }->{HOLD}) && ($config->{$result->[0] }->{ $result->[1] }->{HOLD} == 1) ) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
defined $$config{$result->[0]}{$result->[1]}{"HOLD"} and $$config{$result->[0]}{$result->[1]}{"HOLD"} == 1 or defined $config->{"*"}{$result->[1]}{"HOLD"} and $config->{"*"}{$result->[1]}{"HOLD"} == 1
defined $$config{$result->[0]}{$result->[1]}{"HOLD"} and $$config{$result->[0]}{$result->[1]}{"HOLD"} == 1
defined $config->{"*"}{$result->[1]}{"HOLD"} and $config->{"*"}{$result->[1]}{"HOLD"} == 1
MC/DC0%0/4
defined $$config{$result->[0]}{$result->[1]}{"HOLD"} and $$config{$result->[0]}{$result->[1]}{"HOLD"} == 1 or defined $config->{"*"}{$result->[1]}{"HOLD"} and $config->{"*"}{$result->[1]}{"HOLD"} == 1
defined $$config{$result->[0]}{$result->[1]}{"HOLD"}
$$config{$result->[0]}{$result->[1]}{"HOLD"} == 1
defined $config->{"*"}{$result->[1]}{"HOLD"}
$config->{"*"}{$result->[1]}{"HOLD"} == 1
Truth table0%0/7
A and B or C and D
A= defined $$config{$result->[0]}{$result->[1]}{"HOLD"}B= $$config{$result->[0]}{$result->[1]}{"HOLD"} == 1C= defined $config->{"*"}{$result->[1]}{"HOLD"}D= $config->{"*"}{$result->[1]}{"HOLD"} == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | (defined( $config->{'*'}->{ $result->[1] }->{HOLD}) && ($config->{'*'}->{ $result->[1] }->{HOLD} == 1) ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | $hold_status = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 0 | $status = "HOLDING"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 0 | ▶ | if ( defined( $config->{$result->[0] }->{ $result->[1] }->{HALT}) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $$config{$result->[0]}{$result->[1]}{"HALT"} or defined $config->{"*"}{$result->[1]}{"HALT"}
MC/DC0%0/2
defined $$config{$result->[0]}{$result->[1]}{"HALT"} or defined $config->{"*"}{$result->[1]}{"HALT"}
defined $$config{$result->[0]}{$result->[1]}{"HALT"}
defined $config->{"*"}{$result->[1]}{"HALT"}
Truth table0%0/3
A or B
A= defined $$config{$result->[0]}{$result->[1]}{"HALT"}B= defined $config->{"*"}{$result->[1]}{"HALT"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | defined( $config->{'*'}->{ $result->[1] }->{HALT}) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 0 | $halt_status = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 0 | $status = "HALTING"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 0 | push(@{ $current_host->{SERVICES} }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | { HOST => $result->[0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | SERVICE_CLASS => $result->[1], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | SERVICE_VERSION => $result->[2], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | PROCESS_ID => $result->[3], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | REGISTER_TIME => $date_parts->{YYYY}.'-'.$date_parts->{MM}.'-'.$date_parts->{DD}.' '.$date_parts->{HH24}.':'.$date_parts->{MI}.':'.$date_parts->{SS}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 0 | UPTIME => $uptime_string, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | STATUS => $status, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | MAX_WORKERS => $max_workers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | OVERDRIVE => $overdrive_status, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | HOLDING => $hold_status, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | HALTING => $halt_status, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | push(@collective, $current_host); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | my $tmpl = $self->load_tmpl('collective_host.html', die_on_bad_params => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 0 | $tmpl->param(TITLE => 'Helios - Collective View'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 0 | $tmpl->param(COLLECTIVE => \@collective); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 0 | return $tmpl->output(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | =head2 _collective_service() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | The _collective_service() method provides the Collective display grouped by service. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | ▶ | sub _collective_service { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_collective_service: not called CC=19 SCAR=58.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 0 | my $dbh = $self->dbh(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 0 | my $q = $self->query(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 0 | my $config = $self->loadParams('worker_class'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | my $register_threshold = time() - 360; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | my $sql = <<STATUSSQL; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | SELECT worker_class AS service, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | host, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | worker_version AS version, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | process_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | register_time, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | start_time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | FROM helios_worker_registry_tb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | WHERE register_time > ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | ORDER BY service, host | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | STATUSSQL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 0 | my $sth = $dbh->prepare($sql); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 0 | ▶ | unless ($sth) { throw Error::Simple($dbh->errstr); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 0 | ▶ | $sth->execute($register_threshold) or throw Error::Simple($dbh->errstr()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 0 | my @collective; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | my @dbresult; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 0 | my $current_service; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 0 | my $first_result = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 0 | my $last_service = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | #t print $q->header(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 0 | ▶ | while ( my $result = $sth->fetchrow_arrayref() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | #t print join("|", @$result),"<br>\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 0 | ▶ | if ($first_result) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 0 | $last_service = $result->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | $first_result = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 0 | ▶ | if ($result->[0] ne $last_service) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 0 | push(@collective, $current_service); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 0 | undef $current_service; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 0 | $last_service = $result->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 0 | my $date_parts = $self->splitEpochDate($result->[4]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 0 | $current_service->{SERVICE_CLASS} = $result->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | # calc uptime | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | my $uptime_string = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 0 | ▶ | use integer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 0 | my $uptime = time() - $result->[5]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 0 | my $uptime_days = $uptime/86400; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 0 | my $uptime_hours = ($uptime % 86400)/3600; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 0 | my $uptime_mins = (($uptime % 86400) % 3600)/60; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | ▶ | if ($uptime_days != 0) { $uptime_string .= $uptime_days.'d '; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | ▶ | if ($uptime_hours != 0) { $uptime_string .= $uptime_hours.'h '; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 0 | ▶ | if ($uptime_mins != 0) { $uptime_string .= $uptime_mins.'m '; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | # max_workers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | my $max_workers = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 0 | ▶ | if ( defined($config->{ $result->[0] }->{ '*' }->{MAX_WORKERS}) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 0 | $max_workers = $config->{ $result->[0] }->{ '*' }->{MAX_WORKERS}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 0 | ▶ | if ( defined($config->{ $result->[0] }->{ $result->[1] }->{MAX_WORKERS}) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 0 | $max_workers = $config->{ $result->[0] }->{ $result->[1] }->{MAX_WORKERS}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | # figure out status (normal/overdrive/holding/halting) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 0 | my $status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | 0 | my $halt_status = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 0 | my $hold_status = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 0 | my $overdrive_status = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | # determine overdrive status | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 0 | ▶ | if ( defined($config->{$result->[0]}->{'*'}->{OVERDRIVE}) && ($config->{$result->[0]}->{'*'}->{OVERDRIVE} == 1) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $$config{$result->[0]}{"*"}{"OVERDRIVE"} and $$config{$result->[0]}{"*"}{"OVERDRIVE"} == 1
MC/DC0%0/2
defined $$config{$result->[0]}{"*"}{"OVERDRIVE"} and $$config{$result->[0]}{"*"}{"OVERDRIVE"} == 1
defined $$config{$result->[0]}{"*"}{"OVERDRIVE"}
$$config{$result->[0]}{"*"}{"OVERDRIVE"} == 1
Truth table0%0/3
A and B
A= defined $$config{$result->[0]}{"*"}{"OVERDRIVE"}B= $$config{$result->[0]}{"*"}{"OVERDRIVE"} == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 0 | $overdrive_status = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 0 | ▶ | if ( defined($config->{$result->[0]}->{$result->[1]}->{OVERDRIVE}) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 0 | $overdrive_status = $config->{$result->[0]}->{$result->[1]}->{OVERDRIVE}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | # determine holding status | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | ▶ | if ( defined($config->{$result->[0]}->{'*'}->{HOLD}) && ($config->{$result->[0]}->{'*'}->{HOLD} == 1) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $$config{$result->[0]}{"*"}{"HOLD"} and $$config{$result->[0]}{"*"}{"HOLD"} == 1
MC/DC0%0/2
defined $$config{$result->[0]}{"*"}{"HOLD"} and $$config{$result->[0]}{"*"}{"HOLD"} == 1
defined $$config{$result->[0]}{"*"}{"HOLD"}
$$config{$result->[0]}{"*"}{"HOLD"} == 1
Truth table0%0/3
A and B
A= defined $$config{$result->[0]}{"*"}{"HOLD"}B= $$config{$result->[0]}{"*"}{"HOLD"} == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 0 | $hold_status = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 0 | ▶ | if ( defined($config->{$result->[0]}->{$result->[1]}->{HOLD}) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 0 | $hold_status = $config->{$result->[0]}->{$result->[1]}->{HOLD}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | # determine halt status; if it's even defined, that means the service instance is HALTing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 0 | ▶ | if ( defined( $config->{$result->[0] }->{ '*' }->{HALT}) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $$config{$result->[0]}{"*"}{"HALT"} or defined $$config{$result->[0]}{$result->[1]}{"HALT"}
MC/DC0%0/2
defined $$config{$result->[0]}{"*"}{"HALT"} or defined $$config{$result->[0]}{$result->[1]}{"HALT"}
defined $$config{$result->[0]}{"*"}{"HALT"}
defined $$config{$result->[0]}{$result->[1]}{"HALT"}
Truth table0%0/3
A or B
A= defined $$config{$result->[0]}{"*"}{"HALT"}B= defined $$config{$result->[0]}{$result->[1]}{"HALT"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | defined( $config->{$result->[0]}->{ $result->[1] }->{HALT}) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 0 | $halt_status = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 0 | $status = "HALTING"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | 0 | push(@{ $current_service->{HOSTS} }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | { HOST => $result->[1], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | SERVICE_CLASS => $result->[0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | SERVICE_VERSION => $result->[2], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | PROCESS_ID => $result->[3], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | REGISTER_TIME => $date_parts->{YYYY}.'-'.$date_parts->{MM}.'-'.$date_parts->{DD}.' '.$date_parts->{HH24}.':'.$date_parts->{MI}.':'.$date_parts->{SS}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 0 | UPTIME => $uptime_string, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | STATUS => $status, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | MAX_WORKERS => $max_workers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | OVERDRIVE => $overdrive_status, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | HOLDING => $hold_status, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | HALTING => $halt_status, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 0 | push(@collective, $current_service); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | 0 | my $tmpl = $self->load_tmpl('collective_service.html', die_on_bad_params => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 0 | $tmpl->param(TITLE => 'Helios - Collective View'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 0 | $tmpl->param(COLLECTIVE => \@collective); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 0 | return $tmpl->output(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | =head1 OTHER METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | These are auxiliary/utility methods used by the run mode methods. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | =head2 splitEpochDate($epoch_seconds) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | Given a datetime in epoch seconds, this method returns a hashref containing the component date | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | parts. The keys of the hash follow Oracle naming conventions because that is what the author was | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | most familiar with: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | YYYY four-digit year | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | MM two-digit month | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | DD two-digit day | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | HH twenty-four hour | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | HH12 twelve hour | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | HH24 twenty-four hour | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | MI two-digit minutes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | SS two-digit seconds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | AMPM ante/post meridium | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 0 | ▶ | sub splitEpochDate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
splitEpochDate: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 0 | my $epoch_secs = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | 0 | my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($epoch_secs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | 0 | my $return_date; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 0 | $return_date->{YYYY} = sprintf("%04d", $year + 1900); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 0 | $return_date->{MM} = sprintf("%02d", $mon+1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | 0 | $return_date->{DD} = sprintf("%02d", $mday); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | 0 | $return_date->{MI} = sprintf("%02d", $min); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | 0 | $return_date->{SS} = sprintf("%02d", $sec); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | # hours | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | 0 | ▶ | if ($hour == 12) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | 0 | $return_date->{AMPM} = 'PM'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | 0 | $return_date->{HH12} = '12'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | 0 | $return_date->{HH24} = '12'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | 0 | $return_date->{HH} = '12'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | } elsif ($hour == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | 0 | $return_date->{AMPM} = 'AM'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 0 | $return_date->{HH12} = '12'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 0 | $return_date->{HH24} = '00'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | 0 | $return_date->{HH} = '12'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | } elsif ($hour > 12) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 0 | $return_date->{AMPM} = 'PM'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | 0 | $return_date->{HH12} = sprintf("%02d", $hour - 12); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | 0 | $return_date->{HH24} = sprintf("%02d", $hour); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | 0 | $return_date->{HH} = sprintf("%02d", $hour); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | # hour is AM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | 0 | $return_date->{AMPM} = 'AM'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | 0 | $return_date->{HH12} = sprintf("%02d", $hour); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | 0 | $return_date->{HH24} = sprintf("%02d", $hour); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | 0 | $return_date->{HH} = sprintf("%02d", $hour); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | 0 | return $return_date; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | =head2 loadClassMap([$keyfield]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | Load the contents of the helios_class_map table into memory, returning it as a hashref. If | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | $keyfield is specified (job_type, job_class), it will be the key field in the hash. If | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | $keyfield is not specified, job_type is the default. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | 0 | ▶ | sub loadClassMap { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
loadClassMap: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | 0 | ▶ | my $keyfield = @_ ? shift : 'job_type'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | 0 | my $dbh = $self->dbh(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 0 | my $classmap; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 0 | my $sql = "SELECT job_type, job_class FROM helios_class_map "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | 0 | my $sth = $dbh->prepare($sql); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | 0 | ▶ | unless($sth) { throw Error::Simple($dbh->errstr); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | 0 | ▶ | $sth->execute() or throw Error::Simple($dbh->errstr()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | 0 | ▶ | while (my $result = $sth->fetchrow_arrayref() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | 0 | ▶ | if ($keyfield eq 'job_class') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | 0 | $classmap->{$result->[1]} = $result->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 0 | $classmap->{$result->[0]} = $result->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | 0 | return $classmap; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | =head2 loadFuncMap | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | Load the contents of the funcmap table into memory, because it's small and lots of methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | need it. THe funcmap table associates a funcid with a service class name for internal purposes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | 0 | ▶ | sub loadFuncMap { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
loadFuncMap: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | 0 | my $dbh = $self->dbh(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | 0 | my $funcmap; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | 0 | my $sql = "SELECT funcid, funcname FROM funcmap"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | 0 | my $sth = $dbh->prepare($sql); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | 0 | ▶ | unless($sth) { throw Error::Simple($dbh->errstr); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | 0 | ▶ | $sth->execute() or throw Error::Simple($dbh->errstr()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | 0 | ▶ | while (my $result = $sth->fetchrow_arrayref() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | 0 | $funcmap->{$result->[0]} = $result->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | 0 | $funcmap->{$result->[1]} = $result->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | 0 | return $funcmap; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | =head2 loadParams([$keyfield]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | Returns a hashref data structure containing all of the Helios config params. The keyfield can be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | either 'worker_class' or 'host' ('worker_class' is the default). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | 0 | ▶ | sub loadParams { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
loadParams: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 0 | ▶ | my $keyfield = @_ ? shift : 'worker_class'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 0 | my $dbh = $self->dbh(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | 0 | $dbh->{FetchHashKeyName} = 'NAME_lc'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | 0 | my $keyfield2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | my $config; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 0 | ▶ | if ($keyfield eq 'worker_class') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | 0 | $keyfield2 = 'host'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | 0 | $keyfield2 = 'worker_class'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | 0 | my $sql = "SELECT $keyfield, $keyfield2, param, value FROM helios_params_tb ORDER BY $keyfield, $keyfield2"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | 0 | my $sth = $dbh->prepare($sql); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | 0 | ▶ | unless ($sth) { throw Error::Simple($dbh->errstr()); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | 0 | ▶ | $sth->execute() or throw Error::Simple($dbh->errstr()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | 0 | ▶ | while(my $result = $sth->fetchrow_arrayref()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | 0 | $config->{ $result->[0] }->{ $result->[1] }->{ $result->[2] } = $result->[3]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | 0 | return $config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | =head2 modParam($action, $worker_class, $host, $param, [$value]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | Modify Helios config parameters. Used by ctrl_panel() and collective() displays. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | Valid values for $action: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | =item add | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | Add the given parameter for the given class and host | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | =item delete | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | Delete the given parameter for the given class and host | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | =item modify | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | Modify the given parameter for the given class and host with a new value. Effectively the same | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | as a delete followed by an add. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | Worker class is the name of the class. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | Host is the name of the host. Use '*' to make the parameter global to all instances of the worker | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | class. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | Returns a true value if successful and throws an Error::Simple exception otherwise. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | 0 | ▶ | sub modParam { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
modParam: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | 0 | my $dbh = $self->dbh(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | 0 | my $action = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | 0 | my $worker_class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | 0 | my $host = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | 0 | my $param = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | 0 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | 0 | my $sql; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | 0 | ▶ | unless ($worker_class && $host && $param && $action) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$worker_class and $host and $param and $action
$worker_class and $host and $param
$worker_class and $host
MC/DC0%0/4
$worker_class and $host and $param and $action
$worker_class
$host
$param
$action
Truth table0%0/5
A and B and C and D
A= $worker_classB= $hostC= $paramD= $action
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | 0 | throw Error::Simple("Worker class ($worker_class), host ($host), param ($param), and action ($action) required"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | SWITCH: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | 0 | ▶ | if ($action eq 'add') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | 0 | $sql = 'INSERT INTO helios_params_tb (host, worker_class, param, value) VALUES (?,?,?,?)'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | 0 | ▶ | $dbh->do($sql, undef, $host, $worker_class, $param, $value) or throw Error::Simple('modParam add FAILURE: '.$dbh->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | 0 | last SWITCH; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | 0 | ▶ | if ($action eq 'delete') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | 0 | $sql = 'DELETE FROM helios_params_tb WHERE host = ? AND worker_class = ? AND param = ?'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | 0 | ▶ | $dbh->do($sql, undef, $host, $worker_class, $param) or throw Error::Simple('modParam delete FAILURE: '.$dbh->errstr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | 0 | last SWITCH; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | 0 | ▶ | if ($action eq 'modify') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | 0 | $self->modParam('delete', $worker_class, $host, $param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | 0 | $self->modParam('add', $worker_class, $host, $param, $value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | 0 | last SWITCH; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | 0 | throw Error::Simple("modParam invalid action: $action"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||