class RRRSpec::Slave
Attributes
key[R]
Public Class Methods
build_from_pid(pid)
click to toggle source
# File lib/rrrspec/redis_models.rb, line 946 def self.build_from_pid(pid) slave_key = RRRSpec.make_key('rrrspec', 'worker', RRRSpec.hostname, 'slave', pid) return new(slave_key) end
create()
click to toggle source
# File lib/rrrspec/redis_models.rb, line 940 def self.create slave_key = RRRSpec.make_key('rrrspec', 'worker', RRRSpec.hostname, 'slave', Process.getpgrp) slave = new(slave_key) return slave end
new(slave_key)
click to toggle source
# File lib/rrrspec/redis_models.rb, line 936 def initialize(slave_key) @key = slave_key end
Public Instance Methods
add_trial(trial)
click to toggle source
Public: Add trial to the list of the trials that the slave worked for.
# File lib/rrrspec/redis_models.rb, line 965 def add_trial(trial) RRRSpec.redis.rpush(RRRSpec.make_key(key, 'trial'), trial.key) end
append_log(string)
click to toggle source
Public: Append a line to the worker_log
# File lib/rrrspec/redis_models.rb, line 992 def append_log(string) RRRSpec.redis.append(RRRSpec.make_key(key, 'log'), string) end
exist?()
click to toggle source
Public: Check its existence with heartbeat key.
Returns bool
# File lib/rrrspec/redis_models.rb, line 1002 def exist? RRRSpec.redis.exists(RRRSpec.make_key(key, 'heartbeat')) end
expire(sec)
click to toggle source
heartbeat(time)
click to toggle source
Public: Maintain heartbeat
# File lib/rrrspec/redis_models.rb, line 1007 def heartbeat(time) RRRSpec.redis.setex(RRRSpec.make_key(key, 'heartbeat'), time, "alive") end
log()
click to toggle source
Public: Execution log of the slave
# File lib/rrrspec/redis_models.rb, line 987 def log RRRSpec.redis.get(RRRSpec.make_key(key, 'log')) || "" end
status()
click to toggle source
Public: Current status
Returns either nil, “normal_exit”, “timeout_exit” or “failure_exit”
# File lib/rrrspec/redis_models.rb, line 976 def status RRRSpec.redis.hget(key, 'status') end
to_h()
click to toggle source
to_json(options=nil)
click to toggle source
# File lib/rrrspec/redis_models.rb, line 1022 def to_json(options=nil) to_h.to_json(options) end
trials()
click to toggle source
Public: Returns the trials of the slave. The return value should be sorted in the order added.
Returns an array of the Trials
# File lib/rrrspec/redis_models.rb, line 958 def trials RRRSpec.redis.lrange(RRRSpec.make_key(key, 'trial'), 0, -1).map do |key| Trial.new(key) end end
update_status(status)
click to toggle source
Public: Update the status. It should be one of:
- “normal_exit”, “timeout_exit”, “failure_exit”
# File lib/rrrspec/redis_models.rb, line 982 def update_status(status) RRRSpec.redis.hset(key, 'status', status) end