example3.rb

Example 3 - Andreas Schröder, 07/12/2007 01:50 am

Download (883 Bytes)

 
1
#!/usr/bin/ruby
2

    
3

    
4
require 'libdrqueue'
5

    
6

    
7
puts "Master: #{ENV["DRQUEUE_MASTER"]}\n"
8

    
9
# First we receive the list of jobs
10
job_list = Libdrqueue::request_job_list(Libdrqueue::CLIENT)
11
#
12
# The result is a ruby array of job objects
13
#
14

    
15
# For every job in the array...
16
job_list.each do |j|
17
        # If the job is ACTIVE, that means that has processors assigned...
18
        if j.status == Libdrqueue::JOBSTATUS_ACTIVE
19
                print "Stopping job: #{j.name}"
20
                # We request the master to stop the job.
21
                if j.request_stop(Libdrqueue::CLIENT)
22
                        print "Stopped\n"
23
                else
24
                        print "Failed\n"
25
                end
26
        end
27
        # If the job is STOPPED, that means it's pending frames won't e dispatched...
28
        if j.status == Libdrqueue::JOBSTATUS_STOPPED
29
                print "Continuing job: #{j.name}"
30
                # We request the master to stop the job.
31
                if j.request_continue(Libdrqueue::CLIENT)
32
                        print "Continued\n"
33
                else
34
                        print "Failed\n"
35
                end
36
        end
37
end