Class: SimpleMapReduce::Server::Job
- Inherits:
-
Object
- Object
- SimpleMapReduce::Server::Job
- Extended by:
- Forwardable
- Includes:
- AASM
- Defined in:
- lib/simple_map_reduce/server/job.rb
Instance Attribute Summary collapse
-
#job_input_bucket_name ⇒ Object
readonly
Returns the value of attribute job_input_bucket_name.
-
#job_input_directory_path ⇒ Object
readonly
Returns the value of attribute job_input_directory_path.
-
#job_output_bucket_name ⇒ Object
readonly
Returns the value of attribute job_output_bucket_name.
-
#job_output_directory_path ⇒ Object
readonly
Returns the value of attribute job_output_directory_path.
-
#map_class_name ⇒ Object
readonly
Returns the value of attribute map_class_name.
-
#map_script ⇒ Object
readonly
Returns the value of attribute map_script.
-
#map_worker ⇒ Object
readonly
Returns the value of attribute map_worker.
-
#reduce_class_name ⇒ Object
readonly
Returns the value of attribute reduce_class_name.
-
#reduce_script ⇒ Object
readonly
Returns the value of attribute reduce_script.
Class Method Summary collapse
Instance Method Summary collapse
- #dump ⇒ Object
- #id ⇒ Object
-
#initialize(id: nil, 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:, map_worker_url: nil, map_worker: nil) ⇒ Job
constructor
A new instance of Job.
- #map_worker_url ⇒ Object
- #serialize ⇒ Object
- #to_h ⇒ Object
-
#update!(event: nil) ⇒ Object
update Job.
- #valid? ⇒ Boolean
Constructor Details
#initialize(id: nil, 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:, map_worker_url: nil, map_worker: nil) ⇒ Job
Returns a new instance of Job.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/simple_map_reduce/server/job.rb', line 40 def initialize(id: nil, 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:, map_worker_url: nil, map_worker: nil) @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 unless valid? raise ArgumentError, 'invalid Job parameters are detected' end end |
Instance Attribute Details
#job_input_bucket_name ⇒ Object (readonly)
Returns the value of attribute job_input_bucket_name.
13 14 15 |
# File 'lib/simple_map_reduce/server/job.rb', line 13 def job_input_bucket_name @job_input_bucket_name end |
#job_input_directory_path ⇒ Object (readonly)
Returns the value of attribute job_input_directory_path.
13 14 15 |
# File 'lib/simple_map_reduce/server/job.rb', line 13 def job_input_directory_path @job_input_directory_path end |
#job_output_bucket_name ⇒ Object (readonly)
Returns the value of attribute job_output_bucket_name.
13 14 15 |
# File 'lib/simple_map_reduce/server/job.rb', line 13 def job_output_bucket_name @job_output_bucket_name end |
#job_output_directory_path ⇒ Object (readonly)
Returns the value of attribute job_output_directory_path.
13 14 15 |
# File 'lib/simple_map_reduce/server/job.rb', line 13 def job_output_directory_path @job_output_directory_path end |
#map_class_name ⇒ Object (readonly)
Returns the value of attribute map_class_name.
13 14 15 |
# File 'lib/simple_map_reduce/server/job.rb', line 13 def map_class_name @map_class_name end |
#map_script ⇒ Object (readonly)
Returns the value of attribute map_script.
13 14 15 |
# File 'lib/simple_map_reduce/server/job.rb', line 13 def map_script @map_script end |
#map_worker ⇒ Object (readonly)
Returns the value of attribute map_worker.
13 14 15 |
# File 'lib/simple_map_reduce/server/job.rb', line 13 def map_worker @map_worker end |
#reduce_class_name ⇒ Object (readonly)
Returns the value of attribute reduce_class_name.
13 14 15 |
# File 'lib/simple_map_reduce/server/job.rb', line 13 def reduce_class_name @reduce_class_name end |
#reduce_script ⇒ Object (readonly)
Returns the value of attribute reduce_script.
13 14 15 |
# File 'lib/simple_map_reduce/server/job.rb', line 13 def reduce_script @reduce_script end |
Class Method Details
.deserialize(data) ⇒ Object
123 124 125 |
# File 'lib/simple_map_reduce/server/job.rb', line 123 def deserialize(data) new(Hash[MessagePack.unpack(data).map { |k, v| [k.to_sym, v] }]) end |
Instance Method Details
#dump ⇒ Object
94 95 96 |
# File 'lib/simple_map_reduce/server/job.rb', line 94 def dump to_h.merge(state: state) end |
#id ⇒ Object
71 72 73 |
# File 'lib/simple_map_reduce/server/job.rb', line 71 def id @id ||= SecureRandom.uuid end |
#map_worker_url ⇒ Object
98 99 100 |
# File 'lib/simple_map_reduce/server/job.rb', line 98 def map_worker_url @map_worker&.url end |
#serialize ⇒ Object
90 91 92 |
# File 'lib/simple_map_reduce/server/job.rb', line 90 def serialize to_h.to_msgpack end |
#to_h ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/simple_map_reduce/server/job.rb', line 75 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) ⇒ Object
update Job
116 117 118 119 120 |
# File 'lib/simple_map_reduce/server/job.rb', line 116 def update!(event: nil) if event public_send(event.to_sym) end end |
#valid? ⇒ Boolean
102 103 104 105 106 107 108 109 110 111 |
# File 'lib/simple_map_reduce/server/job.rb', line 102 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 |