Changeset 92
- Timestamp:
- Jan 24, 2013, 2:53:43 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/oarutils/oar-dispatch
r33 r92 10 10 use Coro::Signal; 11 11 use Coro::Semaphore; 12 #use Coro::Timer qw(sleep); 12 13 13 14 my $task = 0; … … 18 19 19 20 Getopt::Long::GetOptions( 20 'task=i'=> \$task,21 'overload=f'=> \$overload,22 'file=s'=> \$file,23 'verbose'=> \$verbose,24 'help'=> \$help,25 21 'task=i' => \$task, 22 'overload=f' => \$overload, 23 'file=s' => \$file, 24 'verbose' => \$verbose, 25 'help' => \$help, 26 ) || pod2usage(-verbose => 0); 26 27 pod2usage(-verbose => 2) if $help; 27 28 28 29 if ($task == 0) { 29 30 31 32 }30 open(NODE_FILE, '<', "$ENV{OAR_NODE_FILE}") or die "can't open ENV{OAR_NODE_FILE}: $!"; 31 $task++ while <NODE_FILE>; 32 close NODE_FILE; 33 } 33 34 35 # job to run 34 36 my @job = (); 35 37 open (JOB_LIST, '<', "$file") or die "can't open $file: $!"; 36 38 while (<JOB_LIST>) { 37 38 39 40 }39 chomp; 40 next if m/^#/; 41 push @job, $_ if m/^\s*oarsub/; 42 } 41 43 close JOB_LIST; 42 44 … … 46 48 # interactive job 47 49 if (not $container_id > 1) { 48 49 50 }50 $insert_oar_option = ''; 51 $overload = 1; 52 } 51 53 52 54 … … 58 60 my %scheduled = (); 59 61 62 # asynchrone start job block 60 63 async { 61 for my $job (@job) { 62 while ($job_active->count >= $task*$overload) { 63 cede; 64 } 65 $job =~ s/^\s*oarsub//; 66 print "oarsub $insert_oar_option $job" if $verbose; 67 my $job_id = `oarsub $insert_oar_option $job|grep ^OAR_JOB_ID|cut -f 2 -d '='`; 68 chomp $job_id; 69 if ($job_id > 1) { 70 $scheduled{$job_id}++; 71 $job_active->up; 72 } 73 cede; 74 } 75 } 64 JOB: 65 for my $job (@job) { 66 while ($job_active->count >= $task*$overload) { 67 cede; 68 } 69 $job =~ s/^\s*oarsub//; 70 print "oarsub $insert_oar_option $job" if $verbose; 71 my $job_id = `oarsub $insert_oar_option $job|grep ^OAR_JOB_ID|cut -f 2 -d '='`; 72 chomp $job_id; 73 if ($job_id > 1) { 74 $scheduled{$job_id}++; 75 $job_active->up; 76 } 77 cede; 78 } 79 } 76 80 77 81 async { 78 79 80 81 82 83 84 85 86 87 88 82 while () { 83 for my $job_id (keys %scheduled) { 84 my $is_finish = `oarstat -s -j $job_id`; 85 chomp $is_finish; 86 if ($is_finish =~ m/Terminated/) { 87 delete $scheduled{$job_id}; 88 $job_active->down; 89 $job_todo->down; 90 } 91 cede; 92 } 89 93 90 91 92 93 }94 $finished->send if $job_todo->count == 0; 95 cede; 96 } 97 } 94 98 95 99 cede; 96 100 101 # all job have been done 97 102 $finished->wait; 98 103
Note: See TracChangeset
for help on using the changeset viewer.