oozie-client 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +20 -0
- data/LICENSE +22 -0
- data/README.md +36 -0
- data/Rakefile +2 -0
- data/lib/oozie-client.rb +28 -0
- data/lib/oozie-client/admin.rb +35 -0
- data/lib/oozie-client/base.rb +39 -0
- data/lib/oozie-client/config.rb +13 -0
- data/lib/oozie-client/job_collection.rb +52 -0
- data/lib/oozie-client/oozie_job.rb +44 -0
- data/lib/oozie-client/version.rb +3 -0
- data/oozie-client.gemspec +20 -0
- metadata +92 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
oozie-client (0.0.1)
|
5
|
+
builder
|
6
|
+
rest-client
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
builder (3.0.0)
|
12
|
+
mime-types (1.19)
|
13
|
+
rest-client (1.6.7)
|
14
|
+
mime-types (>= 1.16)
|
15
|
+
|
16
|
+
PLATFORMS
|
17
|
+
ruby
|
18
|
+
|
19
|
+
DEPENDENCIES
|
20
|
+
oozie-client!
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Neville Kadwa
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# OozieClient for Ruby
|
2
|
+
|
3
|
+
Standalone client for the Apache Oozie workflow engine.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'oozie-client'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install oozie-client
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
oozie = OozieClient.new "http://OOZIE_URL"
|
22
|
+
job = oozie.jobs.create workflow_properties
|
23
|
+
job.start
|
24
|
+
job.info
|
25
|
+
...
|
26
|
+
oozie.jobs[oozie_id].info
|
27
|
+
oozie.jobs.first
|
28
|
+
...
|
29
|
+
|
30
|
+
## Contributing
|
31
|
+
|
32
|
+
1. Fork it
|
33
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
34
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
35
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
36
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/lib/oozie-client.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'oozie-client/version'
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'builder'
|
5
|
+
|
6
|
+
require 'oozie-client/base'
|
7
|
+
require 'oozie-client/config'
|
8
|
+
require 'oozie-client/job_collection'
|
9
|
+
require 'oozie-client/admin'
|
10
|
+
require 'oozie-client/oozie_job'
|
11
|
+
require 'rest-client'
|
12
|
+
|
13
|
+
class OozieClient
|
14
|
+
attr_reader :config
|
15
|
+
|
16
|
+
def initialize(oozie_url)
|
17
|
+
@config = Config.new(oozie_url)
|
18
|
+
end
|
19
|
+
|
20
|
+
def admin
|
21
|
+
Admin.new(config: config)
|
22
|
+
end
|
23
|
+
|
24
|
+
def jobs
|
25
|
+
JobCollection.new(config: config)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class OozieClient
|
2
|
+
class Admin
|
3
|
+
include Base
|
4
|
+
|
5
|
+
def build_version
|
6
|
+
JSON.parse(admin_url('build-version').get)
|
7
|
+
end
|
8
|
+
|
9
|
+
def status
|
10
|
+
JSON.parse(admin_url('status').get)
|
11
|
+
end
|
12
|
+
|
13
|
+
def safemode= safemode
|
14
|
+
admin_url('status').put('', {'params' => {'safemode' => !!safemode}})
|
15
|
+
end
|
16
|
+
|
17
|
+
def os_env
|
18
|
+
JSON.parse(admin_url('os-env').get)
|
19
|
+
end
|
20
|
+
|
21
|
+
def java_sys_properties
|
22
|
+
JSON.parse(admin_url('java-sys-properties').get)
|
23
|
+
end
|
24
|
+
|
25
|
+
def configuration
|
26
|
+
JSON.parse(admin_url('configuration').get)
|
27
|
+
end
|
28
|
+
|
29
|
+
def instrumentation
|
30
|
+
JSON.parse(admin_url('instrumentation').get)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class OozieClient
|
2
|
+
module Base
|
3
|
+
def initialize options
|
4
|
+
@config = options[:config]
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.included(base)
|
8
|
+
base.class_eval do
|
9
|
+
attr_reader :config
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
def admin_url path
|
15
|
+
@config.client["admin/#{path}"]
|
16
|
+
end
|
17
|
+
|
18
|
+
def jobs_url *path
|
19
|
+
@config.client["jobs"]
|
20
|
+
end
|
21
|
+
|
22
|
+
def job_url *path
|
23
|
+
@config.client["job/#{oozie_id}"]
|
24
|
+
end
|
25
|
+
|
26
|
+
def properties_to_conf_xml params
|
27
|
+
builder = Builder::XmlMarkup.new(:indent => 2)
|
28
|
+
xml = builder.configuration do |xb|
|
29
|
+
params.each do |name, value|
|
30
|
+
xb.property do |xb|
|
31
|
+
xb.name(name.to_s)
|
32
|
+
xb.value(value.to_s)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
class OozieClient
|
2
|
+
|
3
|
+
class JobCollection
|
4
|
+
include Base
|
5
|
+
include Enumerable
|
6
|
+
|
7
|
+
def initialize options
|
8
|
+
@filters = options[:filters] || {}
|
9
|
+
super
|
10
|
+
end
|
11
|
+
|
12
|
+
def [] oozie_id
|
13
|
+
OozieJob.new(oozie_id, :config => config)
|
14
|
+
end
|
15
|
+
|
16
|
+
def create(properties, params={})
|
17
|
+
job = JSON.parse jobs_url.post(properties_to_conf_xml(properties), {params: params, content_type: :xml})
|
18
|
+
self[job['id']]
|
19
|
+
end
|
20
|
+
alias_method :submit, :create
|
21
|
+
|
22
|
+
def with_user *users
|
23
|
+
filter(:user, users.flatten)
|
24
|
+
end
|
25
|
+
|
26
|
+
def with_name *names
|
27
|
+
filter(:name, names.flatten)
|
28
|
+
end
|
29
|
+
|
30
|
+
def with_group *groups
|
31
|
+
filter(:group, groups.flatten)
|
32
|
+
end
|
33
|
+
|
34
|
+
def with_status *statuses
|
35
|
+
filter(:status, statuses.flatten)
|
36
|
+
end
|
37
|
+
|
38
|
+
def filter name, value
|
39
|
+
options = {}
|
40
|
+
options[:filters] = @filters.merge(name.to_s.to_sym => value)
|
41
|
+
options[:config] = config
|
42
|
+
JobCollection.new(options)
|
43
|
+
end
|
44
|
+
|
45
|
+
def each &block
|
46
|
+
result = JSON.parse jobs_url.get
|
47
|
+
result['workflows'].each &block
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
class OozieClient
|
2
|
+
class OozieJob
|
3
|
+
include Base
|
4
|
+
|
5
|
+
attr_reader :oozie_id
|
6
|
+
|
7
|
+
def initialize oozie_id, options
|
8
|
+
@oozie_id = oozie_id
|
9
|
+
super(options)
|
10
|
+
end
|
11
|
+
|
12
|
+
def start
|
13
|
+
job_url.put('', {'params' => {'action' => 'start'}})
|
14
|
+
end
|
15
|
+
|
16
|
+
def suspend
|
17
|
+
job_url.put('', {'params' => {'action' => 'suspend'}})
|
18
|
+
end
|
19
|
+
def resume
|
20
|
+
job_url.put('', {'params' => {'action' => 'resume'}})
|
21
|
+
end
|
22
|
+
def kill
|
23
|
+
job_url.put('', {'params' => {'action' => 'kill'}})
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
def rerun(properties, params={})
|
28
|
+
job_url.put(properties_to_conf_xml(properties), {'params' => {'action' => 'rerun'}.merge(params)})
|
29
|
+
end
|
30
|
+
|
31
|
+
def info
|
32
|
+
JSON.parse job_url.put({'params' => {'show' => 'info'}})
|
33
|
+
end
|
34
|
+
|
35
|
+
def definition
|
36
|
+
job_url.put({'params' => {'show' => 'definition'}})
|
37
|
+
end
|
38
|
+
|
39
|
+
def log
|
40
|
+
job_url.put({'params' => {'show' => 'log'}})
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/oozie-client/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Neville Kadwa"]
|
6
|
+
gem.email = ["neville@kadwa.com"]
|
7
|
+
gem.description = %q{Standalone Oozie Client for the Oozie Workflow engine on Hadoop.}
|
8
|
+
gem.summary = %q{Oozie Client for Ruby}
|
9
|
+
gem.homepage = "https://github.com/kadwanev/oozie-client"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "oozie-client"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = OozieClient::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency('rest-client')
|
19
|
+
gem.add_dependency('builder')
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: oozie-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Neville Kadwa
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rest-client
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: builder
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: Standalone Oozie Client for the Oozie Workflow engine on Hadoop.
|
47
|
+
email:
|
48
|
+
- neville@kadwa.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- Gemfile
|
55
|
+
- Gemfile.lock
|
56
|
+
- LICENSE
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- lib/oozie-client.rb
|
60
|
+
- lib/oozie-client/admin.rb
|
61
|
+
- lib/oozie-client/base.rb
|
62
|
+
- lib/oozie-client/config.rb
|
63
|
+
- lib/oozie-client/job_collection.rb
|
64
|
+
- lib/oozie-client/oozie_job.rb
|
65
|
+
- lib/oozie-client/version.rb
|
66
|
+
- oozie-client.gemspec
|
67
|
+
homepage: https://github.com/kadwanev/oozie-client
|
68
|
+
licenses: []
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ! '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 1.8.24
|
88
|
+
signing_key:
|
89
|
+
specification_version: 3
|
90
|
+
summary: Oozie Client for Ruby
|
91
|
+
test_files: []
|
92
|
+
has_rdoc:
|