class SimpleMapReduce::Server::Job
Attributes
job_input_bucket_name[R]
job_input_directory_path[R]
job_output_bucket_name[R]
job_output_directory_path[R]
map_class_name[R]
map_script[R]
map_worker[R]
reduce_class_name[R]
reduce_script[R]
Public Class Methods
deserialize(data)
click to toggle source
# File lib/simple_map_reduce/server/job.rb, line 124 def deserialize(data) params = MessagePack.unpack(data).transform_keys(&:to_sym) params[:data_store_type] = 'remote' new(params) end
new(map_script:, map_class_name:, reduce_script:, reduce_class_name:, job_input_bucket_name:, job_input_directory_path:, job_output_bucket_name:, job_output_directory_path:, id: nil, map_worker_url: nil, map_worker: nil, data_store_type: 'default')
click to toggle source
# File lib/simple_map_reduce/server/job.rb, line 42 def initialize(map_script:, map_class_name:, reduce_script:, reduce_class_name:, job_input_bucket_name:, job_input_directory_path:, job_output_bucket_name:, job_output_directory_path:, id: nil, map_worker_url: nil, map_worker: nil, data_store_type: 'default') @id = id @map_script = map_script&.strip @map_class_name = map_class_name&.strip @reduce_script = reduce_script&.strip @reduce_class_name = reduce_class_name&.strip @job_input_bucket_name = job_input_bucket_name&.strip @job_input_directory_path = job_input_directory_path&.strip @job_output_bucket_name = job_output_bucket_name&.strip @job_output_directory_path = job_output_directory_path&.strip @map_worker = map_worker if @map_worker.nil? && map_worker_url @map_worker = SimpleMapReduce::Server::Worker.new(url: map_worker_url) end @data_store = SimpleMapReduce::DataStoreFactory.create(data_store_type, server_url: SimpleMapReduce.job_tracker_url, resource_name: 'jobs', resource_id: @id) unless valid? raise ArgumentError, 'invalid Job parameters are detected' end end
Public Instance Methods
dump()
click to toggle source
# File lib/simple_map_reduce/server/job.rb, line 95 def dump to_h.merge(state: state) end
id()
click to toggle source
# File lib/simple_map_reduce/server/job.rb, line 72 def id @id ||= SecureRandom.uuid end
map_worker_url()
click to toggle source
# File lib/simple_map_reduce/server/job.rb, line 99 def map_worker_url @map_worker&.url end
serialize()
click to toggle source
# File lib/simple_map_reduce/server/job.rb, line 91 def serialize to_h.to_msgpack end
to_h()
click to toggle source
# File lib/simple_map_reduce/server/job.rb, line 76 def to_h { id: id, map_script: @map_script, map_class_name: @map_class_name, reduce_script: @reduce_script, reduce_class_name: @reduce_class_name, job_input_bucket_name: @job_input_bucket_name, job_input_directory_path: @job_input_directory_path, job_output_bucket_name: @job_output_bucket_name, job_output_directory_path: @job_output_directory_path, map_worker_url: @map_worker&.url } end
update!(event: nil)
click to toggle source
update Job
@params [Hash] attributes @options attributes [String] event
# File lib/simple_map_reduce/server/job.rb, line 117 def update!(event: nil) if event public_send(event.to_sym) end end
valid?()
click to toggle source
# File lib/simple_map_reduce/server/job.rb, line 103 def valid? !@map_script.to_s.empty? && !@map_class_name.to_s.empty? && !@reduce_script.to_s.empty? && !@reduce_class_name.to_s.empty? && !@job_input_bucket_name.to_s.empty? && !@job_input_directory_path.to_s.empty? && !@job_output_bucket_name.to_s.empty? && !@job_output_directory_path.to_s.empty? end
Private Instance Methods
save_state()
click to toggle source
# File lib/simple_map_reduce/server/job.rb, line 133 def save_state @data_store.save_state(aasm.current_event) end