Class: TopologyLauncher

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

Overview

TopologyLauncher is the application entry point when launching a topology. Basically it will call require on the specified Ruby topology class file path and call its start method

Class Method Summary collapse

Class Method Details

.main(args) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/red_storm/topology_launcher.rb', line 39

def self.main(args)
  unless args.size > 1
    puts("Usage: redstorm local|cluster topology_class_file_name")
    exit(1)
  end

  env = args[0].to_sym
  class_path = args[1]

  launch_path = Dir.pwd
  $:.unshift File.expand_path(launch_path)
  $:.unshift File.expand_path(launch_path + '/lib')
  $:.unshift File.expand_path(launch_path + '/target/lib')

  require "#{class_path}"

  if RedStorm::Configuration.topology_class.nil? || !RedStorm::Configuration.topology_class.method_defined?(:start)
    puts("\nERROR: invalid topology class. make sure your topology class is a subclass of one of the DSL topology classes or that your class sets RedStorm::Configuration.topology_class and defines the start method\n\n")
    exit(1)
  end

  topology_name = RedStorm::Configuration.topology_class.respond_to?(:topology_name) ? "/#{RedStorm::Configuration.topology_class.topology_name}" : ''
  puts("RedStorm v#{RedStorm::VERSION} starting topology #{RedStorm::Configuration.topology_class.name}#{topology_name} in #{env.to_s} environment")
  RedStorm::Configuration.topology_class.new.start(env)
end