Class: Houdah::Client
- Inherits:
-
Object
- Object
- Houdah::Client
- Defined in:
- lib/houdah/client.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Class Method Summary collapse
Instance Method Summary collapse
- #call(method, *args) ⇒ Object
- #close ⇒ Object
-
#initialize(server, port = 9290, user = "houdah", timeout = 60) ⇒ Client
constructor
A new instance of Client.
-
#jobs(type = :running) ⇒ Object
Get jobs.
- #name ⇒ Object
- #queues ⇒ Object
- #status ⇒ Object
- #trackers(type = :active) ⇒ Object
Constructor Details
#initialize(server, port = 9290, user = "houdah", timeout = 60) ⇒ Client
Returns a new instance of Client.
5 6 7 8 9 10 11 12 13 |
# File 'lib/houdah/client.rb', line 5 def initialize(server, port=9290, user="houdah", timeout=60) socket = Thrift::Socket.new(server, port) socket.timeout = timeout * 10000 @transport = Thrift::BufferedTransport.new(socket) @transport.open protocol = Thrift::BinaryProtocol.new(@transport) @client = Hadoop::API::Jobtracker::Jobtracker::Client.new(protocol) @context = Hadoop::API::RequestContext.new(:confOptions => { 'effective_user' => user }) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
4 5 6 |
# File 'lib/houdah/client.rb', line 4 def client @client end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
4 5 6 |
# File 'lib/houdah/client.rb', line 4 def context @context end |
Class Method Details
Instance Method Details
#call(method, *args) ⇒ Object
52 53 54 |
# File 'lib/houdah/client.rb', line 52 def call(method, *args) @client.send method, @context, *args end |
#close ⇒ Object
48 49 50 |
# File 'lib/houdah/client.rb', line 48 def close @transport.close end |
#jobs(type = :running) ⇒ Object
Get jobs. Type can be :running, :completed, :killed, :failed, or :all
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/houdah/client.rb', line 20 def jobs(type=:running) results = case type when :running then call(:getRunningJobs) when :completed then call(:getCompletedJobs) when :failed then call(:getFailedJobs) when :killed then call(:getKilledJobs) else call(:getAllJobs) end results.jobs.map { |j| Job.new(self, j) } end |
#name ⇒ Object
15 16 17 |
# File 'lib/houdah/client.rb', line 15 def name call :getJobTrackerName end |
#queues ⇒ Object
44 45 46 |
# File 'lib/houdah/client.rb', line 44 def queues call :getQueues end |
#status ⇒ Object
40 41 42 |
# File 'lib/houdah/client.rb', line 40 def status call :getClusterStatus end |
#trackers(type = :active) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/houdah/client.rb', line 31 def trackers(type=:active) results = case type when :active then call(:getActiveTrackers) when :blacklisted then call(:getBlacklistedTrackers) when :all then call(:getAllTrackers) end results.trackers.map { |t| Tracker.new(self, t) } end |