Class: ElephantDriver::Client
- Inherits:
-
Object
- Object
- ElephantDriver::Client
- Defined in:
- lib/elephant-driver/client.rb
Instance Method Summary collapse
- #get_job(job_id) ⇒ Object
- #get_tracker(name) ⇒ Object
-
#initialize(host, port = 9290, user = 'mapred', timeout = 30) ⇒ Client
constructor
A new instance of Client.
-
#jobs(status = :running) ⇒ Object
Jobs.
-
#status ⇒ Object
Status.
-
#tasks ⇒ Object
Tasks.
-
#trackers(status = :active) ⇒ Object
Trackers.
Constructor Details
#initialize(host, port = 9290, user = 'mapred', timeout = 30) ⇒ Client
Returns a new instance of Client.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/elephant-driver/client.rb', line 4 def initialize(host, port=9290, user='mapred', timeout=30) sock = Thrift::Socket.new host, port sock.timeout = timeout * 1000 @transport = Thrift::BufferedTransport.new sock @transport.open # 2011/08/23 Kazuki Ohta <[email protected]> # explicitly specify TCP_NODELAY for low-latency communication. raw_sock = sock.to_io raw_sock.setsockopt Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1 protocol = Thrift::BinaryProtocol.new @transport @client = Hadoop::API::Jobtracker::Jobtracker::Client.new protocol = { 'effective_user' => user } @ctx = Hadoop::API::RequestContext.new(:confOptions => ) end |
Instance Method Details
#get_job(job_id) ⇒ Object
35 36 37 |
# File 'lib/elephant-driver/client.rb', line 35 def get_job(job_id) Job.new self, call(:getJob, job_id) end |
#get_tracker(name) ⇒ Object
50 51 52 |
# File 'lib/elephant-driver/client.rb', line 50 def get_tracker(name) Tracker.new(self, (call :getTracker, name)) end |
#jobs(status = :running) ⇒ Object
Jobs
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/elephant-driver/client.rb', line 23 def jobs(status=:running) ret = case status when :running then call :getRunningJobs when :completed then call :getCompletedJobs when :failed then call :getFailedJobs when :killed then call :getKilledJobs else call :getAllJobs end ret.jobs.collect{ |j| Job.new(self, j) } end |
#status ⇒ Object
Status
59 60 61 |
# File 'lib/elephant-driver/client.rb', line 59 def status call :getClusterStatus end |
#tasks ⇒ Object
Tasks
55 56 |
# File 'lib/elephant-driver/client.rb', line 55 def tasks end |
#trackers(status = :active) ⇒ Object
Trackers
40 41 42 43 44 45 46 47 48 |
# File 'lib/elephant-driver/client.rb', line 40 def trackers(status=:active) ret = case status when :active then call :getActiveTrackers when :blacklisted then call :getBlacklistedTrackers else call :getAllTrackers end ret.trackers.collect{ |t| Tracker.new(self, t) } end |