<s> from __future__ import unicode_literals <EOL> from . base import BaseYarnAPI <EOL> from . constants import JobStateInternal <EOL> from . errors import IllegalArgumentError <EOL> from . hadoop_conf import get_jobhistory_host_port <EOL> class HistoryServer ( BaseYarnAPI ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , address = None , port = <NUM_LIT> , timeout = <NUM_LIT:30> ) : <EOL> self . address , self . port , self . timeout = address , port , timeout <EOL> if address is None : <EOL> self . logger . debug ( '<STR_LIT>' ) <EOL> address , port = get_jobhistory_host_port ( ) <EOL> self . address , self . port = address , port <EOL> def application_information ( self ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' <EOL> return self . request ( path ) <EOL> def jobs ( self , state = None , user = None , queue = None , limit = None , <EOL> started_time_begin = None , started_time_end = None , <EOL> finished_time_begin = None , finished_time_end = None ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' <EOL> legal_states = set ( [ s for s , _ in JobStateInternal ] ) <EOL> if state is not None and state not in legal_states : <EOL> msg = '<STR_LIT>' % ( state , ) <EOL> raise IllegalArgumentError ( msg ) <EOL> loc_args = ( <EOL> ( '<STR_LIT:state>' , state ) , <EOL> ( '<STR_LIT:user>' , user ) , <EOL> ( '<STR_LIT>' , queue ) , <EOL> ( '<STR_LIT>' , limit ) , <EOL> ( '<STR_LIT>' , started_time_begin ) , <EOL> ( '<STR_LIT>' , started_time_end ) , <EOL> ( '<STR_LIT>' , finished_time_begin ) , <EOL> ( '<STR_LIT>' , finished_time_end ) ) <EOL> params = self . construct_parameters ( loc_args ) <EOL> return self . request ( path , ** params ) <EOL> def job ( self , job_id ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' . format ( jobid = job_id ) <EOL> return self . request ( path ) <EOL> def job_attempts ( self , job_id ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' . format ( <EOL> jobid = job_id ) <EOL> return self . request ( path ) <EOL> def job_counters ( self , job_id ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' . format ( <EOL> jobid = job_id ) <EOL> return self . request ( path ) <EOL> def job_conf ( self , job_id ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' . format ( jobid = job_id ) <EOL> return self . request ( path ) <EOL> def job_tasks ( self , job_id , type = None ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' . format ( <EOL> jobid = job_id ) <EOL> valid_types = [ '<STR_LIT:m>' , '<STR_LIT:r>' ] <EOL> if type is not None and type not in valid_types : <EOL> msg = '<STR_LIT>' % ( type , ) <EOL> raise IllegalArgumentError ( msg ) <EOL> params = { } <EOL> if type is not None : <EOL> params [ '<STR_LIT:type>' ] = type <EOL> return self . request ( path , ** params ) <EOL> def job_task ( self , job_id , task_id ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' . format ( <EOL> jobid = job_id , taskid = task_id ) <EOL> return self . request ( path ) <EOL> def task_counters ( self , job_id , task_id ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' . format ( <EOL> jobid = job_id , taskid = task_id ) <EOL> return self . request ( path ) <EOL> def task_attempts ( self , job_id , task_id ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' . format ( <EOL> jobid = job_id , taskid = task_id ) <EOL> return self . request ( path ) <EOL> def task_attempt ( self , job_id , task_id , attempt_id ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' . format ( <EOL> jobid = job_id , taskid = task_id , attemptid = attempt_id ) <EOL> return self . request ( path ) <EOL> def task_attempt_counters ( self , job_id , task_id , attempt_id ) : <EOL> """<STR_LIT>""" <EOL> path = '<STR_LIT>' . format ( <EOL> jobid = job_id , taskid = task_id , attemptid = attempt_id ) <EOL> return self . request ( path ) </s>
