Class: Albacore::Tools::FluentMigrator::BatchMigrateTask

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/albacore/tools/fluent_migrator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

#debug, #err, #error, #fatal, #info, #puts, #trace, #warn

Constructor Details

#initialize(*args) ⇒ BatchMigrateTask

Returns a new instance of BatchMigrateTask.

Raises:

  • (ArgumentError)


150
151
152
153
154
155
156
# File 'lib/albacore/tools/fluent_migrator.rb', line 150

def initialize *args
  @args = Map.options args 
  @args.apply :direction => 'migrate:up',
              :silent    => true
  raise ArgumentError, 'Passed nil file' if @args.get(:file).nil?
  raise ArgumentError, "Could not find file '#{@args.get(:file)}'" unless File.exists? @args.get(:file)
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



148
149
150
# File 'lib/albacore/tools/fluent_migrator.rb', line 148

def args
  @args
end

Instance Method Details

#executeObject



158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/albacore/tools/fluent_migrator.rb', line 158

def execute
  File.open(args[:file], "r") do |file_handle|
    file_handle.each_line do |server|
      server = server.chomp
      unless server.nil? or server.empty?
        info ''
        info " ********** Starting '#{server}' ************ " 
        info ''
        ::Albacore::Tools::FluentMigrator::Cmd.new(@args.set(:conn => server)).execute
        info ''
        info " ********** Finished '#{server}' ************ " 
        info ''
      end
    end
  end
end