Class: MapRedus::Finalizer

Inherits:
QueueProcess show all
Defined in:
lib/mapredus/finalizer.rb

Overview

Run the stuff you want to run at the end of the process. Define subclass which defines self.finalize and self.serialize to do what is needed when you want to get the final output out of redis and into ruby.

This is basically the message back to the user program that a process is completed storing the necessary info.

Direct Known Subclasses

ToRedisHash

Class Method Summary collapse

Methods inherited from QueueProcess

queue

Class Method Details

.finalize(pid) ⇒ Object

The default finalizer is to notify of process completion

Example

Finalizer::finalize(pid)
# => "MapRedus Process : 111 : has completed"

Returns a message notification



19
20
21
# File 'lib/mapredus/finalizer.rb', line 19

def self.finalize(pid)
  "MapRedus Process : #{pid} : has completed"
end

.perform(pid) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/mapredus/finalizer.rb', line 23

def self.perform(pid)
  process = Process.open(pid)
  result = finalize(process)
  Master.finish_metrics(pid)
  result
ensure
  Master.free_slave(pid)
  process.next_state
end