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.



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

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



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

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

#activateObject



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

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

#closeObject



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

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

#deactivateObject



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

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

#declareOutputFields(declarer) ⇒ Object



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

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

#fail(msg_id) ⇒ Object



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

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

#getComponentConfigurationObject



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

def getComponentConfiguration
  @real_spout.get_component_configuration
end

#nextTupleObject



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

def nextTuple
  @real_spout.next_tuple
end

#open(conf, context, collector) ⇒ Object



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

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