Skip to content

Commit

Permalink
add signature documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ediskandarov committed Aug 3, 2014
1 parent 2dbd9a6 commit 9c13c50
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 0 deletions.
70 changes: 70 additions & 0 deletions yarn_api_client/application_master.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ class ApplicationMaster(BaseYarnAPI):
equivalent to a running MapReduce job. The information includes the jobs
the app master is running and all the job particulars like tasks,
counters, configuration, attempts, etc.
If `address` argument is `None` client will try to extract `address` and
`port` from Hadoop configuration files.
:param str address: Proxy HTTP address
:param int port: Proxy HTTP port
:param int timeout: API connection timeout in seconds
"""
def __init__(self, address=None, port=8088, timeout=30):
self.address, self.port, self.timeout = address, port, timeout
Expand All @@ -24,6 +31,9 @@ def application_information(self, application_id):
The MapReduce application master information resource provides overall
information about that mapreduce application master.
This includes application id, time it was started, user, name, etc.
:returns: API response object with JSON data
:rtype: :py:class:`yarn_api_client.base.Response`
"""
path = '/proxy/{appid}/ws/v1/mapreduce/info'.format(
appid=application_id)
Expand All @@ -34,6 +44,10 @@ def jobs(self, application_id):
"""
The jobs resource provides a list of the jobs running on this
application master.
:param str application_id: The application id
:returns: API response object with JSON data
:rtype: :py:class:`yarn_api_client.base.Response`
"""
path = '/proxy/{appid}/ws/v1/mapreduce/jobs'.format(
appid=application_id)
Expand All @@ -45,6 +59,11 @@ def job(self, application_id, job_id):
A job resource contains information about a particular job that was
started by this application master. Certain fields are only accessible
if user has permissions - depends on acl settings.
:param str application_id: The application id
:param str job_id: The job id
:returns: API response object with JSON data
:rtype: :py:class:`yarn_api_client.base.Response`
"""
path = '/proxy/{appid}/ws/v1/mapreduce/jobs/{jobid}'.format(
appid=application_id, jobid=job_id)
Expand All @@ -55,13 +74,22 @@ def job_attempts(self, job_id):
"""
With the job attempts API, you can obtain a collection of resources
that represent the job attempts.
:param str job_id: The job id
:returns: API response object with JSON data
:rtype: :py:class:`yarn_api_client.base.Response`
"""
pass

def job_counters(self, application_id, job_id):
"""
With the job counters API, you can object a collection of resources
that represent all the counters for that job.
:param str application_id: The application id
:param str job_id: The job id
:returns: API response object with JSON data
:rtype: :py:class:`yarn_api_client.base.Response`
"""
path = '/proxy/{appid}/ws/v1/mapreduce/jobs/{jobid}/counters'.format(
appid=application_id, jobid=job_id)
Expand All @@ -72,6 +100,11 @@ def job_conf(self, application_id, job_id):
"""
A job configuration resource contains information about the job
configuration for this job.
:param str application_id: The application id
:param str job_id: The job id
:returns: API response object with JSON data
:rtype: :py:class:`yarn_api_client.base.Response`
"""
path = '/proxy/{appid}/ws/v1/mapreduce/jobs/{jobid}/conf'.format(
appid=application_id, jobid=job_id)
Expand All @@ -82,6 +115,11 @@ def job_tasks(self, application_id, job_id):
"""
With the tasks API, you can obtain a collection of resources that
represent all the tasks for a job.
:param str application_id: The application id
:param str job_id: The job id
:returns: API response object with JSON data
:rtype: :py:class:`yarn_api_client.base.Response`
"""
path = '/proxy/{appid}/ws/v1/mapreduce/jobs/{jobid}/tasks'.format(
appid=application_id, jobid=job_id)
Expand All @@ -92,6 +130,12 @@ def job_task(self, application_id, job_id, task_id):
"""
A Task resource contains information about a particular
task within a job.
:param str application_id: The application id
:param str job_id: The job id
:param str task_id: The task id
:returns: API response object with JSON data
:rtype: :py:class:`yarn_api_client.base.Response`
"""
path = '/proxy/{appid}/ws/v1/mapreduce/jobs/{jobid}/tasks/{taskid}'.format(
appid=application_id, jobid=job_id, taskid=task_id)
Expand All @@ -102,6 +146,12 @@ def task_counters(self, application_id, job_id, task_id):
"""
With the task counters API, you can object a collection of resources
that represent all the counters for that task.
:param str application_id: The application id
:param str job_id: The job id
:param str task_id: The task id
:returns: API response object with JSON data
:rtype: :py:class:`yarn_api_client.base.Response`
"""
path = '/proxy/{appid}/ws/v1/mapreduce/jobs/{jobid}/tasks/{taskid}/counters'.format(
appid=application_id, jobid=job_id, taskid=task_id)
Expand All @@ -112,6 +162,12 @@ def task_attempts(self, application_id, job_id, task_id):
"""
With the task attempts API, you can obtain a collection of resources
that represent a task attempt within a job.
:param str application_id: The application id
:param str job_id: The job id
:param str task_id: The task id
:returns: API response object with JSON data
:rtype: :py:class:`yarn_api_client.base.Response`
"""
path = '/proxy/{appid}/ws/v1/mapreduce/jobs/{jobid}/tasks/{taskid}/attempts'.format(
appid=application_id, jobid=job_id, taskid=task_id)
Expand All @@ -122,6 +178,13 @@ def task_attempt(self, application_id, job_id, task_id, attempt_id):
"""
A Task Attempt resource contains information about a particular task
attempt within a job.
:param str application_id: The application id
:param str job_id: The job id
:param str task_id: The task id
:param str attempt_id: The attempt id
:returns: API response object with JSON data
:rtype: :py:class:`yarn_api_client.base.Response`
"""
path = '/proxy/{appid}/ws/v1/mapreduce/jobs/{jobid}/tasks/{taskid}/attempt/{attemptid}'.format(
appid=application_id, jobid=job_id, taskid=task_id,
Expand All @@ -133,6 +196,13 @@ def task_attempt_counters(self, application_id, job_id, task_id, attempt_id):
"""
With the task attempt counters API, you can object a collection
of resources that represent al the counters for that task attempt.
:param str application_id: The application id
:param str job_id: The job id
:param str task_id: The task id
:param str attempt_id: The attempt id
:returns: API response object with JSON data
:rtype: :py:class:`yarn_api_client.base.Response`
"""
path = '/proxy/{appid}/ws/v1/mapreduce/jobs/{jobid}/tasks/{taskid}/attempt/{attemptid}/counters'.format(
appid=application_id, jobid=job_id, taskid=task_id,
Expand Down
72 changes: 72 additions & 0 deletions yarn_api_client/history_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ class HistoryServer(BaseYarnAPI):
The history server REST API's allow the user to get status on finished
applications. Currently it only supports MapReduce and provides
information on finished jobs.
If `address` argument is `None` client will try to extract `address` and
`port` from Hadoop configuration files.
:param str address: HistoryServer HTTP address
:param int port: HistoryServer HTTP port
:param int timeout: API connection timeout in seconds
"""
def __init__(self, address=None, port=19888, timeout=30):
self.address, self.port, self.timeout = address, port, timeout
Expand All @@ -23,6 +30,9 @@ def application_information(self):
"""
The history server information resource provides overall information
about the history server.
:returns: API response object with JSON data
:rtype: :py:class:`yarn_api_client.base.Response`
"""
path = '/ws/v1/history/info'

Expand All @@ -34,6 +44,23 @@ def jobs(self, state=None, user=None, queue=None, limit=None,
"""
The jobs resource provides a list of the MapReduce jobs that have
finished. It does not currently return a full list of parameters.
:param str user: user name
:param str state: the job state
:param str queue: queue name
:param str limit: total number of app objects to be returned
:param str started_time_begin: jobs with start time beginning with
this time, specified in ms since epoch
:param str started_time_end: jobs with start time ending with this
time, specified in ms since epoch
:param str finished_time_begin: jobs with finish time beginning with
this time, specified in ms since epoch
:param str finished_time_end: jobs with finish time ending with this
time, specified in ms since epoch
:returns: API response object with JSON data
:rtype: :py:class:`yarn_api_client.base.Response`
:raises yarn_api_client.errors.IllegalArgumentError: if `state`
incorrect
"""
path = '/ws/v1/history/mapreduce/jobs'

Expand All @@ -60,6 +87,10 @@ def job(self, job_id):
"""
A Job resource contains information about a particular job identified
by jobid.
:param str job_id: The job id
:returns: API response object with JSON data
:rtype: :py:class:`yarn_api_client.base.Response`
"""
path = '/ws/v1/history/mapreduce/jobs/{jobid}'.format(jobid=job_id)

Expand All @@ -79,6 +110,10 @@ def job_counters(self, job_id):
"""
With the job counters API, you can object a collection of resources
that represent al the counters for that job.
:param str job_id: The job id
:returns: API response object with JSON data
:rtype: :py:class:`yarn_api_client.base.Response`
"""
path = '/ws/v1/history/mapreduce/jobs/{jobid}/counters'.format(
jobid=job_id)
Expand All @@ -89,6 +124,10 @@ def job_conf(self, job_id):
"""
A job configuration resource contains information about the job
configuration for this job.
:param str job_id: The job id
:returns: API response object with JSON data
:rtype: :py:class:`yarn_api_client.base.Response`
"""
path = '/ws/v1/history/mapreduce/jobs/{jobid}/conf'.format(jobid=job_id)

Expand All @@ -98,6 +137,12 @@ def job_tasks(self, job_id, type=None):
"""
With the tasks API, you can obtain a collection of resources that
represent a task within a job.
:param str job_id: The job id
:param str type: type of task, valid values are m or r. m for map
task or r for reduce task
:returns: API response object with JSON data
:rtype: :py:class:`yarn_api_client.base.Response`
"""
path = '/ws/v1/history/mapreduce/jobs/{jobid}/tasks'.format(
jobid=job_id)
Expand All @@ -119,6 +164,11 @@ def job_task(self, job_id, task_id):
"""
A Task resource contains information about a particular task
within a job.
:param str job_id: The job id
:param str task_id: The task id
:returns: API response object with JSON data
:rtype: :py:class:`yarn_api_client.base.Response`
"""
path = '/ws/v1/history/mapreduce/jobs/{jobid}/tasks/{taskid}'.format(
jobid=job_id, taskid=task_id)
Expand All @@ -129,6 +179,11 @@ def task_counters(self, job_id, task_id):
"""
With the task counters API, you can object a collection of resources
that represent all the counters for that task.
:param str job_id: The job id
:param str task_id: The task id
:returns: API response object with JSON data
:rtype: :py:class:`yarn_api_client.base.Response`
"""
path = '/ws/v1/history/mapreduce/jobs/{jobid}/tasks/{taskid}/counters'.format(
jobid=job_id, taskid=task_id)
Expand All @@ -139,6 +194,11 @@ def task_attempts(self, job_id, task_id):
"""
With the task attempts API, you can obtain a collection of resources
that represent a task attempt within a job.
:param str job_id: The job id
:param str task_id: The task id
:returns: API response object with JSON data
:rtype: :py:class:`yarn_api_client.base.Response`
"""
path = '/ws/v1/history/mapreduce/jobs/{jobid}/tasks/{taskid}/attempts'.format(
jobid=job_id, taskid=task_id)
Expand All @@ -149,6 +209,12 @@ def task_attempt(self, job_id, task_id, attempt_id):
"""
A Task Attempt resource contains information about a particular task
attempt within a job.
:param str job_id: The job id
:param str task_id: The task id
:param str attempt_id: The attempt id
:returns: API response object with JSON data
:rtype: :py:class:`yarn_api_client.base.Response`
"""
path = '/ws/v1/history/mapreduce/jobs/{jobid}/tasks/{taskid}/attempt/{attemptid}'.format(
jobid=job_id, taskid=task_id, attemptid=attempt_id)
Expand All @@ -159,6 +225,12 @@ def task_attempt_counters(self, job_id, task_id, attempt_id):
"""
With the task attempt counters API, you can object a collection of
resources that represent al the counters for that task attempt.
:param str job_id: The job id
:param str task_id: The task id
:param str attempt_id: The attempt id
:returns: API response object with JSON data
:rtype: :py:class:`yarn_api_client.base.Response`
"""
path = '/ws/v1/history/mapreduce/jobs/{jobid}/tasks/{taskid}/attempt/{attemptid}/counters'.format(
jobid=job_id, taskid=task_id, attemptid=attempt_id)
Expand Down
25 changes: 25 additions & 0 deletions yarn_api_client/node_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ class NodeManager(BaseYarnAPI):
"""
The NodeManager REST API's allow the user to get status on the node and
information about applications and containers running on that node.
:param str address: NodeManager HTTP address
:param int port: NodeManager HTTP port
:param int timeout: API connection timeout in seconds
"""
def __init__(self, address=None, port=8042, timeout=30):
self.address, self.port, self.timeout = address, port, timeout
Expand All @@ -16,6 +20,9 @@ def node_information(self):
"""
The node information resource provides overall information about that
particular node.
:returns: API response object with JSON data
:rtype: :py:class:`yarn_api_client.base.Response`
"""
path = '/ws/v1/node/info'
return self.request(path)
Expand All @@ -24,6 +31,13 @@ def node_applications(self, state=None, user=None):
"""
With the Applications API, you can obtain a collection of resources,
each of which represents an application.
:param str state: application state
:param str user: user name
:returns: API response object with JSON data
:rtype: :py:class:`yarn_api_client.base.Response`
:raises yarn_api_client.errors.IllegalArgumentError: if `state`
incorrect
"""
path = '/ws/v1/node/apps'

Expand All @@ -44,6 +58,10 @@ def node_application(self, application_id):
"""
An application resource contains information about a particular
application that was run or is running on this NodeManager.
:param str application_id: The application id
:returns: API response object with JSON data
:rtype: :py:class:`yarn_api_client.base.Response`
"""
path = '/ws/v1/node/apps/{appid}'.format(appid=application_id)

Expand All @@ -53,6 +71,9 @@ def node_containers(self):
"""
With the containers API, you can obtain a collection of resources,
each of which represents a container.
:returns: API response object with JSON data
:rtype: :py:class:`yarn_api_client.base.Response`
"""
path = '/ws/v1/node/containers'

Expand All @@ -62,6 +83,10 @@ def node_container(self, container_id):
"""
A container resource contains information about a particular container
that is running on this NodeManager.
:param str container_id: The container id
:returns: API response object with JSON data
:rtype: :py:class:`yarn_api_client.base.Response`
"""
path = '/ws/v1/node/containers/{containerid}'.format(
containerid=container_id)
Expand Down

0 comments on commit 9c13c50

Please sign in to comment.