Class: Spout

Inherits:
Object
  • Object
show all
Defined in:
lib/red_storm/proxy/spout.rb

Overview

the Spout class is a proxy to the real spout to avoid having to deal with all the Java artifacts when creating a spout.

The real spout class implementation must define these methods:

  • open(conf, context, collector)

  • next_tuple

  • declare_output_fields

and optionnaly:

  • ack(msg_id)

  • fail(msg_id)

  • close

Instance Method Summary collapse

Constructor Details

#initialize(base_class_path, real_spout_class_name) ⇒ Spout

Returns a new instance of Spout.



36
37
38
39
40
41
# File 'lib/red_storm/proxy/spout.rb', line 36

def initialize(base_class_path, real_spout_class_name)
  @real_spout = Object.module_eval(real_spout_class_name).new
rescue NameError
  require base_class_path
  @real_spout = Object.module_eval(real_spout_class_name).new
end

Instance Method Details

#ack(msg_id) ⇒ Object



69
70
71
# File 'lib/red_storm/proxy/spout.rb', line 69

def ack(msg_id)
  @real_spout.ack(msg_id) if @real_spout.respond_to?(:ack)
end

#activateObject



54
55
56
# File 'lib/red_storm/proxy/spout.rb', line 54

def activate
  @real_spout.activate if @real_spout.respond_to?(:activate)
end

#closeObject



49
50
51
# File 'lib/red_storm/proxy/spout.rb', line 49

def close
  @real_spout.close if @real_spout.respond_to?(:close)
end

#deactivateObject



59
60
61
# File 'lib/red_storm/proxy/spout.rb', line 59

def deactivate
  @real_spout.deactivate if @real_spout.respond_to?(:deactivate)
end

#declareOutputFields(declarer) ⇒ Object



79
80
81
# File 'lib/red_storm/proxy/spout.rb', line 79

def declareOutputFields(declarer)
  @real_spout.declare_output_fields(declarer)
end

#fail(msg_id) ⇒ Object



74
75
76
# File 'lib/red_storm/proxy/spout.rb', line 74

def fail(msg_id)
  @real_spout.fail(msg_id) if @real_spout.respond_to?(:fail)
end

#getComponentConfigurationObject



84
85
86
# File 'lib/red_storm/proxy/spout.rb', line 84

def getComponentConfiguration
  @real_spout.get_component_configuration
end

#nextTupleObject



64
65
66
# File 'lib/red_storm/proxy/spout.rb', line 64

def nextTuple
  @real_spout.next_tuple
end

#open(conf, context, collector) ⇒ Object



44
45
46
# File 'lib/red_storm/proxy/spout.rb', line 44

def open(conf, context, collector)
  @real_spout.open(conf, context, collector)
end