Module: Azkaban
- Defined in:
- lib/azkaban-rb.rb,
lib/azkaban-rb/tasks.rb,
lib/azkaban-rb/version.rb
Defined Under Namespace
Modules: Rb Classes: CommandJob, JavaJob, JavaProcessJob, JobFile, PigJob
Class Method Summary collapse
- .deploy(uri, path, zip_file) ⇒ Object
-
.mime_type_handler(path) ⇒ Object
custom MIME type handler so ZIP is uploaded as ‘application/zip’ as required by Azkaban UI.
Class Method Details
.deploy(uri, path, zip_file) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/azkaban-rb/tasks.rb', line 11 def self.deploy(uri, path, zip_file) client = HTTPClient.new client.send_timeout = 1200 File.open(zip_file) do |file| body = { 'path' => path, 'file' => file } puts "Uploading jobs ZIP file to #{uri}" result = client.post(uri,body) # We expect to be redirected after uploading raise "Error while uploading to Azkaban" if result.status != 302 location = result.header["Location"][0] success = /Installation Succeeded/ failure = /Installation Failed:\s*(.+)/ if location =~ success puts "Successfully uploaded to Azkaban" elsif (m = failure.match(location)) reason = m[1] raise "Failed to upload to Azkaban: #{reason}" else raise "Failed to upload to Azkaban for unknown reason" end end end |
.mime_type_handler(path) ⇒ Object
custom MIME type handler so ZIP is uploaded as ‘application/zip’ as required by Azkaban UI
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/azkaban-rb/tasks.rb', line 41 def self.mime_type_handler(path) case path when /\.txt$/i 'text/plain' when /\.zip$/i 'application/zip' when /\.(htm|html)$/i 'text/html' when /\.doc$/i 'application/msword' when /\.png$/i 'image/png' when /\.gif$/i 'image/gif' when /\.(jpg|jpeg)$/i 'image/jpeg' else 'application/octet-stream' end end |