Class: Rubydoop::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/rubydoop/dsl.rb

Defined Under Namespace

Classes: Jobs

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conf, arguments) ⇒ Context

Returns a new instance of Context.



376
377
378
379
380
# File 'lib/rubydoop/dsl.rb', line 376

def initialize(conf, arguments)
  @conf = conf
  @arguments = arguments.to_a
  @job_stack = [Jobs::Sequence.new]
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



374
375
376
# File 'lib/rubydoop/dsl.rb', line 374

def arguments
  @arguments
end

Instance Method Details

#create_job(name) ⇒ Object



382
383
384
385
386
# File 'lib/rubydoop/dsl.rb', line 382

def create_job(name)
  hadoop_job = Hadoop::Mapreduce::Job.new(@conf, name)
  @job_stack.last.add(hadoop_job)
  hadoop_job
end

#parallelObject



392
393
394
395
396
397
398
# File 'lib/rubydoop/dsl.rb', line 392

def parallel
  push(Jobs::Parallel.new)
  if block_given?
    yield
    pop
  end
end

#popObject



413
414
415
# File 'lib/rubydoop/dsl.rb', line 413

def pop
  @job_stack.pop
end

#push(job_list) ⇒ Object



408
409
410
411
# File 'lib/rubydoop/dsl.rb', line 408

def push(job_list)
  @job_stack.last.add(job_list)
  @job_stack.push(job_list)
end

#sequenceObject



400
401
402
403
404
405
406
# File 'lib/rubydoop/dsl.rb', line 400

def sequence
  push(Jobs::Sequence.new)
  if block_given?
    yield
    pop
  end
end

#wait_for_completion(verbose) ⇒ Object



388
389
390
# File 'lib/rubydoop/dsl.rb', line 388

def wait_for_completion(verbose)
  @job_stack.first.wait_for_completion(verbose)
end