Class: RedStorm::DSL::Topology::BoltDefinition

Inherits:
ComponentDefinition show all
Defined in:
lib/red_storm/dsl/topology.rb

Direct Known Subclasses

InputBoltDefinition

Instance Attribute Summary collapse

Attributes inherited from ComponentDefinition

#clazz, #constructor_args, #id, #parallelism

Attributes inherited from Configurator

#config

Instance Method Summary collapse

Methods inherited from ComponentDefinition

#is_java?, #output_fields

Methods inherited from Configurator

#method_missing, #set

Constructor Details

#initialize(*args) ⇒ BoltDefinition

Returns a new instance of BoltDefinition.



57
58
59
60
# File 'lib/red_storm/dsl/topology.rb', line 57

def initialize(*args)
  super
  @sources = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RedStorm::Configurator

Instance Attribute Details

#commandObject

Returns the value of attribute command.



55
56
57
# File 'lib/red_storm/dsl/topology.rb', line 55

def command
  @command
end

#sourcesObject

Returns the value of attribute sources.



55
56
57
# File 'lib/red_storm/dsl/topology.rb', line 55

def sources
  @sources
end

Instance Method Details

#define_grouping(declarer) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/red_storm/dsl/topology.rb', line 66

def define_grouping(declarer)
  @sources.each do |source_id, grouping|
    grouper, params = grouping.first
      # declarer.fieldsGrouping(source_id, Fields.new())
    case grouper
    when :fields
      declarer.fieldsGrouping(source_id, Fields.new(*([params].flatten.map(&:to_s))))
    when :global
      declarer.globalGrouping(source_id)
    when :shuffle
      declarer.shuffleGrouping(source_id)
    when :local_or_shuffle
      declarer.localOrShuffleGrouping(source_id)
    when :none
      declarer.noneGrouping(source_id)
    when :all
      declarer.allGrouping(source_id)
    when :direct
      declarer.directGrouping(source_id)
    else
      raise("unknown grouper=#{grouper.inspect}")
    end
  end
end

#new_instanceObject



91
92
93
94
95
96
97
98
99
100
# File 'lib/red_storm/dsl/topology.rb', line 91

def new_instance
  # WARNING non-dry see BoltDefinition#new_instance
  if @clazz.name == "Java::RedstormStormJruby::JRubyShellBolt"
    @clazz.new(constructor_args, @output_fields)
  elsif is_java?
    @clazz.new(*constructor_args)
  else
    JRubyBolt.new(@clazz.base_class_path, @clazz.name, @output_fields)
  end
end

#source(source_id, grouping) ⇒ Object



62
63
64
# File 'lib/red_storm/dsl/topology.rb', line 62

def source(source_id, grouping)
  @sources << [source_id.is_a?(Class) ? Topology.underscore(source_id) : source_id.to_s, grouping.is_a?(Hash) ? grouping : {grouping => nil}]
end