Class: Azkaban::JobFile

Inherits:
Object
  • Object
show all
Defined in:
lib/azkaban-rb/tasks.rb

Direct Known Subclasses

CommandJob, JavaJob, JavaProcessJob, PigJob

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(task, ext) ⇒ JobFile

Returns a new instance of JobFile.



70
71
72
73
74
75
76
77
# File 'lib/azkaban-rb/tasks.rb', line 70

def initialize(task, ext)
  task.job = self
  @task = task
  @ext = ext
  @args = {}
  @read_locks = []
  @write_locks = []
end

Class Attribute Details

.output_dirObject

Returns the value of attribute output_dir.



80
81
82
# File 'lib/azkaban-rb/tasks.rb', line 80

def output_dir
  @output_dir
end

Instance Attribute Details

#read_locksObject (readonly)

Returns the value of attribute read_locks.



66
67
68
# File 'lib/azkaban-rb/tasks.rb', line 66

def read_locks
  @read_locks
end

#taskObject (readonly)

Returns the value of attribute task.



66
67
68
# File 'lib/azkaban-rb/tasks.rb', line 66

def task
  @task
end

#uses_argObject (readonly)

Returns the value of attribute uses_arg.



66
67
68
# File 'lib/azkaban-rb/tasks.rb', line 66

def uses_arg
  @uses_arg
end

#write_locksObject (readonly)

Returns the value of attribute write_locks.



66
67
68
# File 'lib/azkaban-rb/tasks.rb', line 66

def write_locks
  @write_locks
end

Instance Method Details

#[](k) ⇒ Object



83
84
85
# File 'lib/azkaban-rb/tasks.rb', line 83

def [](k)
  @args[k]
end

#[]=(k, v) ⇒ Object



87
88
89
# File 'lib/azkaban-rb/tasks.rb', line 87

def []=(k,v)
  @args[k] = v
end

#reads(name, *options) ⇒ Object



97
98
99
100
# File 'lib/azkaban-rb/tasks.rb', line 97

def reads(name, *options)    
  @read_locks << name
  handle_read_write_options(options, name)
end

#set(params) ⇒ Object



91
92
93
94
95
# File 'lib/azkaban-rb/tasks.rb', line 91

def set(params)
  params.each do |k,v|
    @args[k] = v
  end
end

#writeObject



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/azkaban-rb/tasks.rb', line 107

def write
  if @args.size > 0
    file_name = @task.name.gsub(":", "-") + @ext
    if @task.prerequisites.size > 0
      scope = @task.scope.map { |s| s.to_s }.join("-")
      @args["dependencies"] = @task.prerequisites.map{ |p| 
        # look up the prerequisite in the scope of its task
        prereq_task = Rake.application.lookup(p, @task.scope)
        prereq_task.name.gsub(":", "-")
      }.join(",")
    end
    create_properties_file(file_name, @args)
    puts "Created #{file_name}"
  end
end

#writes(name, *options) ⇒ Object



102
103
104
105
# File 'lib/azkaban-rb/tasks.rb', line 102

def writes(name, *options)
  @write_locks << name
  handle_read_write_options(options, name)
end