/usr/share/arc/DGBridge.pm is in nordugrid-arc-arex 4.0.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | package DGBridge;
use strict;
use POSIX qw(ceil floor);
use Sys::Hostname;
our @ISA = ('Exporter');
our @EXPORT_OK = ('cluster_info',
'queue_info',
'jobs_info',
'users_info');
use LogUtils ( 'start_logging', 'error', 'warning', 'debug' );
##########################################
# Saved private variables
##########################################
our (%lrms_queue);
our $running = undef; # total running jobs in a queue
# the queue passed in the latest call to queue_info, jobs_info or users_info
my $currentqueue = undef;
# Resets queue-specific global variables if
# the queue has changed since the last call
sub init_globals($) {
my $qname = shift;
if (not defined $currentqueue or $currentqueue ne $qname) {
$currentqueue = $qname;
%lrms_queue = ();
$running = undef;
}
}
##########################################
# Private subs
##########################################
############################################
# Public subs
#############################################
sub cluster_info ($) {
my ($config) = shift;
my (%lrms_cluster);
$lrms_cluster{lrms_type} = "DGBridge";
$lrms_cluster{lrms_version} = "1.8.1";
# only enforcing per-process cputime limit
$lrms_cluster{has_total_cputime_limit} = 0;
$lrms_cluster{totalcpus} = 1000;
# Since fork is a single machine backend all there will only be one machine available
$lrms_cluster{cpudistribution} = $lrms_cluster{totalcpus}."cpu:1";
# usedcpus on a fork machine is determined from the 1min cpu
# loadaverage and cannot be larger than the totalcpus
$lrms_cluster{usedcpus} = 0;
$lrms_cluster{runningjobs} = 0;
# no LRMS queuing jobs on a fork machine, fork has no queueing ability
$lrms_cluster{queuedcpus} = 0;
$lrms_cluster{queuedjobs} = 0;
$lrms_cluster{queue} = [ ];
return %lrms_cluster;
}
sub queue_info ($$) {
my ($config) = shift;
my ($qname) = shift;
init_globals($qname);
if (defined $running) {
# job_info was already called, we know exactly how many grid jobs
# are running
$lrms_queue{running} = $running;
} else {
$lrms_queue{running}= 0;
}
$lrms_queue{totalcpus} =1000;
$lrms_queue{status} = $lrms_queue{totalcpus}-$lrms_queue{running};
# reserve negative numbers for error states
$lrms_queue{status} = 0;
$lrms_queue{maxrunning} = "10000";
$lrms_queue{maxuserrun} = "10000";
$lrms_queue{maxqueuable} = ""; #unlimited
$lrms_queue{maxcputime} = "";
$lrms_queue{queued} = 0;
$lrms_queue{mincputime} = "";
$lrms_queue{defaultcput} = "";
$lrms_queue{minwalltime} = "";
$lrms_queue{defaultwallt} = "";
$lrms_queue{maxwalltime} = $lrms_queue{maxcputime};
$lrms_queue{MaxSlotsPerJob} = 1;
return %lrms_queue;
}
sub getDGstate($$) {
my ($jid) = shift;
my ($ep) = shift;
my ($state);
my ($cmdl) = "wsclient -e $ep -m status -j $jid |";
unless (open DGSTATUSOUT, $cmdl) {
error("Error in executing wsclient");
}
$state="WSError";
while (<DGSTATUSOUT>) {
unless (/^$jid/) {
next;
}
chomp;
my ($vid,$val) = split' ',$_,2;
$state = $val;
}
close DGSTATUSOUT;
return $state;
}
sub jobs_info ($$@) {
my ($config) = shift;
my ($qname) = shift;
my ($jids) = shift;
init_globals($qname);
my (%lrms_jobs);
foreach my $id (@$jids){
$lrms_jobs{$id}{nodes} = [ ];
# get real endpoint
my ($endp, $bid) = split'\|',$id,2;
$endp =~ s/^\"//;
$bid =~ s/\"$//;
my $dgstate = getDGstate($bid, $endp);
#states possible
#Init
#Running
#Unknown
#Finished
#Error
#TempFailed
$lrms_jobs{$id}{status} = 'O'; # job is ?
if ($dgstate eq "Init") {
$lrms_jobs{$id}{status} = 'Q'; # job is preparing
}
if ($dgstate eq "Running") {
$lrms_jobs{$id}{status} = 'R'; # job is running
++$running;
}
if (
($dgstate eq "Finished") ||
($dgstate eq "Error")
) {
$lrms_jobs{$id}{status} = 'E'; # job is EXECUTED
}
if ( ($dgstate eq "TempFailed") ||
($dgstate eq "WSError")
) {
$lrms_jobs{$id}{status} = 'S'; # job is temporarily failed
}
if ($dgstate eq "Unknown") {
$lrms_jobs{$id}{status} = 'O'; # job is temporarily failed
}
$lrms_jobs{$id}{comment} = [ "LRMS: $dgstate" ];
$lrms_jobs{$id}{mem} = '';
$lrms_jobs{$id}{walltime} = '';
$lrms_jobs{$id}{cputime} = '';
$lrms_jobs{$id}{reqwalltime} = "";
$lrms_jobs{$id}{reqcputime} = "";
$lrms_jobs{$id}{rank} = -1;
#DGBridge backend does not support parallel jobs
$lrms_jobs{$id}{cpus} = 1;
}
return %lrms_jobs;
}
sub users_info($$@) {
my ($config) = shift;
my ($qname) = shift;
my ($accts) = shift;
init_globals($qname);
my (%lrms_users);
# freecpus
# queue length
if ( ! exists $lrms_queue{status} ) {
%lrms_queue = queue_info( $config, $qname );
}
foreach my $u ( @{$accts} ) {
$lrms_users{$u}{freecpus} = $lrms_queue{maxuserrun} - $lrms_queue{running};
$lrms_users{$u}{queuelength} = "$lrms_queue{queued}";
}
return %lrms_users;
}
1;
|