Class: SimpleMapReduce::Server::Task
- Inherits:
-
Object
- Object
- SimpleMapReduce::Server::Task
- Extended by:
- Forwardable
- Includes:
- AASM
- Defined in:
- lib/simple_map_reduce/server/task.rb
Instance Attribute Summary collapse
-
#job_id ⇒ Object
readonly
Returns the value of attribute job_id.
-
#task_class_name ⇒ Object
readonly
Returns the value of attribute task_class_name.
-
#task_input_bucket_name ⇒ Object
readonly
Returns the value of attribute task_input_bucket_name.
-
#task_input_file_path ⇒ Object
readonly
Returns the value of attribute task_input_file_path.
-
#task_output_bucket_name ⇒ Object
readonly
Returns the value of attribute task_output_bucket_name.
-
#task_output_directory_path ⇒ Object
readonly
Returns the value of attribute task_output_directory_path.
-
#task_script ⇒ Object
readonly
Returns the value of attribute task_script.
-
#worker ⇒ Object
readonly
Returns the value of attribute worker.
Class Method Summary collapse
Instance Method Summary collapse
- #dump ⇒ Object
- #id ⇒ Object
-
#initialize(id: nil, job_id:, task_class_name:, task_script:, task_input_bucket_name:, task_input_file_path:, task_output_bucket_name:, task_output_directory_path:, worker: nil) ⇒ Task
constructor
A new instance of Task.
- #serialize ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(id: nil, job_id:, task_class_name:, task_script:, task_input_bucket_name:, task_input_file_path:, task_output_bucket_name:, task_output_directory_path:, worker: nil) ⇒ Task
Returns a new instance of Task.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/simple_map_reduce/server/task.rb', line 40 def initialize(id: nil, job_id:, task_class_name:, task_script:, task_input_bucket_name:, task_input_file_path:, task_output_bucket_name:, task_output_directory_path:, worker: nil) @id = id @job_id = job_id @task_class_name = task_class_name @task_script = task_script @task_input_bucket_name = task_input_bucket_name @task_input_file_path = task_input_file_path @task_output_bucket_name = task_output_bucket_name @task_output_directory_path = task_output_directory_path @worker = worker end |
Instance Attribute Details
#job_id ⇒ Object (readonly)
Returns the value of attribute job_id.
12 13 14 |
# File 'lib/simple_map_reduce/server/task.rb', line 12 def job_id @job_id end |
#task_class_name ⇒ Object (readonly)
Returns the value of attribute task_class_name.
12 13 14 |
# File 'lib/simple_map_reduce/server/task.rb', line 12 def task_class_name @task_class_name end |
#task_input_bucket_name ⇒ Object (readonly)
Returns the value of attribute task_input_bucket_name.
12 13 14 |
# File 'lib/simple_map_reduce/server/task.rb', line 12 def task_input_bucket_name @task_input_bucket_name end |
#task_input_file_path ⇒ Object (readonly)
Returns the value of attribute task_input_file_path.
12 13 14 |
# File 'lib/simple_map_reduce/server/task.rb', line 12 def task_input_file_path @task_input_file_path end |
#task_output_bucket_name ⇒ Object (readonly)
Returns the value of attribute task_output_bucket_name.
12 13 14 |
# File 'lib/simple_map_reduce/server/task.rb', line 12 def task_output_bucket_name @task_output_bucket_name end |
#task_output_directory_path ⇒ Object (readonly)
Returns the value of attribute task_output_directory_path.
12 13 14 |
# File 'lib/simple_map_reduce/server/task.rb', line 12 def task_output_directory_path @task_output_directory_path end |
#task_script ⇒ Object (readonly)
Returns the value of attribute task_script.
12 13 14 |
# File 'lib/simple_map_reduce/server/task.rb', line 12 def task_script @task_script end |
#worker ⇒ Object (readonly)
Returns the value of attribute worker.
12 13 14 |
# File 'lib/simple_map_reduce/server/task.rb', line 12 def worker @worker end |
Class Method Details
.deserialize(data) ⇒ Object
86 87 88 |
# File 'lib/simple_map_reduce/server/task.rb', line 86 def deserialize(data) new(Hash[MessagePack.unpack(data).map { |k, v| [k.to_sym, v] }]) end |
Instance Method Details
#dump ⇒ Object
81 82 83 |
# File 'lib/simple_map_reduce/server/task.rb', line 81 def dump to_h.merge(state: state) end |
#id ⇒ Object
60 61 62 |
# File 'lib/simple_map_reduce/server/task.rb', line 60 def id @id ||= SecureRandom.uuid end |
#serialize ⇒ Object
77 78 79 |
# File 'lib/simple_map_reduce/server/task.rb', line 77 def serialize to_h.to_msgpack end |
#to_h ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/simple_map_reduce/server/task.rb', line 64 def to_h { id: id, job_id: @job_id, task_class_name: @task_class_name, task_script: @task_script, task_input_bucket_name: @task_input_bucket_name, task_input_file_path: @task_input_file_path, task_output_bucket_name: @task_output_bucket_name, task_output_directory_path: @task_output_directory_path } end |