Class: SimpleMapReduce::Server::Task

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
AASM
Defined in:
lib/simple_map_reduce/server/task.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(job_id:, task_class_name:, task_script:, task_input_bucket_name:, task_input_file_path:, task_output_bucket_name:, task_output_directory_path:, id: nil, worker: nil) ⇒ Task

Returns a new instance of Task.



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/simple_map_reduce/server/task.rb', line 40

def initialize(job_id:, task_class_name:, task_script:, task_input_bucket_name:, task_input_file_path:,
  task_output_bucket_name:, task_output_directory_path:, id: nil, 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_idObject (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_nameObject (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_nameObject (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_pathObject (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_nameObject (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_pathObject (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_scriptObject (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

#workerObject (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



79
80
81
# File 'lib/simple_map_reduce/server/task.rb', line 79

def deserialize(data)
  new(MessagePack.unpack(data).transform_keys(&:to_sym))
end

Instance Method Details

#dumpObject



74
75
76
# File 'lib/simple_map_reduce/server/task.rb', line 74

def dump
  to_h.merge(state: state)
end

#idObject



53
54
55
# File 'lib/simple_map_reduce/server/task.rb', line 53

def id
  @id ||= SecureRandom.uuid
end

#serializeObject



70
71
72
# File 'lib/simple_map_reduce/server/task.rb', line 70

def serialize
  to_h.to_msgpack
end

#to_hObject



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/simple_map_reduce/server/task.rb', line 57

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