class Backburner::Client
Attributes
raw_data[R]
Public Class Methods
new(host, port=3234)
click to toggle source
# File lib/backburner/client.rb, line 7 def initialize host, port=3234 @host = host @port = port @connection = Connection.new @host, @port send_client_info self end
Public Instance Methods
connect()
click to toggle source
# File lib/backburner/client.rb, line 15 def connect @connection = Connection.new @host, @port end
disconnect()
click to toggle source
# File lib/backburner/client.rb, line 19 def disconnect @connection.close end
jobs()
click to toggle source
# File lib/backburner/client.rb, line 23 def jobs response = @connection.jobhlist.get return [] if @connection.empty? job_handlers = response.jobh_list.job job_handlers = [job_handlers] unless job_handlers.kind_of?(Array) job_handlers.map do |job_data| Job.new job_data.handle, @connection end end
Private Instance Methods
computer_name()
click to toggle source
# File lib/backburner/client.rb, line 81 def computer_name `hostname`.gsub(/\n/, '') end
generate_client_info()
click to toggle source
# File lib/backburner/client.rb, line 35 def generate_client_info @raw_data = DataObject.new @raw_data.client_info = { version: 300, udp_port: 0, controler: 0, system_info: { total_memory: total_memory, total_memory_f: total_memory_f, num_cpus: num_cpus, platform: platform, user: user, computer_name: computer_name, mac: '00E052B9A2F20000', # TODO: change to dynamic work_disk_space: 0, i_p_address: '172.50.0.170' } } end
num_cpus()
click to toggle source
# File lib/backburner/client.rb, line 69 def num_cpus `cat /proc/cpuinfo`.split("\n\n" ).count end
platform()
click to toggle source
# File lib/backburner/client.rb, line 73 def platform `uname`.gsub(/\n/, '') end
send_client_info()
click to toggle source
# File lib/backburner/client.rb, line 55 def send_client_info generate_client_info xml = @raw_data.to_xml @connection.clientinfo.set xml end
total_memory()
click to toggle source
# File lib/backburner/client.rb, line 61 def total_memory `free -b`.match(/\d+/).to_s.to_i end
total_memory_f()
click to toggle source
# File lib/backburner/client.rb, line 65 def total_memory_f total_memory.to_f end
user()
click to toggle source
# File lib/backburner/client.rb, line 77 def user `whoami`.gsub(/\n/, '') end