org.apache.hadoop.mapred
Class JobID

java.lang.Object
  extended by org.apache.hadoop.mapred.ID
      extended by org.apache.hadoop.mapred.JobID
All Implemented Interfaces:
Comparable<ID>, Writable, WritableComparable<ID>

public class JobID
extends ID

JobID represents the immutable and unique identifier for the job. JobID consists of two parts. First part represents the jobtracker identifier, so that jobID to jobtracker map is defined. For cluster setup this string is the jobtracker start time, for local setting, it is "local". Second part of the JobID is the job number.
An example JobID is : job_200707121733_0003 , which represents the third job running at the jobtracker started at 200707121733.

Applications should never construct or parse JobID strings, but rather use appropriate constructors or forName(String) method.

See Also:
TaskID, TaskAttemptID, JobTracker.getNewJobId(), JobTracker.getStartTime()

Field Summary
 
Fields inherited from class org.apache.hadoop.mapred.ID
id
 
Constructor Summary
JobID(String jtIdentifier, int id)
          Constructs a JobID object
 
Method Summary
 int compareTo(ID o)
          Compare JobIds by first jtIdentifiers, then by job numbers
 boolean equals(Object o)
           
static JobID forName(String str)
          Construct a JobId object from given string
static String getJobIDsPattern(String jtIdentifier, Integer jobId)
          Returns a regex pattern which matches task IDs.
 String getJtIdentifier()
           
 int hashCode()
           
static JobID read(DataInput in)
           
 void readFields(DataInput in)
          Deserialize the fields of this object from in.
 String toString()
           
 void write(DataOutput out)
          Serialize the fields of this object to out.
 
Methods inherited from class org.apache.hadoop.mapred.ID
getId
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JobID

public JobID(String jtIdentifier,
             int id)
Constructs a JobID object

Parameters:
jtIdentifier - jobTracker identifier
id - job number
Method Detail

getJtIdentifier

public String getJtIdentifier()

equals

public boolean equals(Object o)
Overrides:
equals in class ID

compareTo

public int compareTo(ID o)
Compare JobIds by first jtIdentifiers, then by job numbers

Specified by:
compareTo in interface Comparable<ID>
Overrides:
compareTo in class ID

toString

public String toString()
Overrides:
toString in class ID

hashCode

public int hashCode()
Overrides:
hashCode in class ID

readFields

public void readFields(DataInput in)
                throws IOException
Description copied from interface: Writable
Deserialize the fields of this object from in.

For efficiency, implementations should attempt to re-use storage in the existing object where possible.

Specified by:
readFields in interface Writable
Overrides:
readFields in class ID
Parameters:
in - DataInput to deseriablize this object from.
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException
Description copied from interface: Writable
Serialize the fields of this object to out.

Specified by:
write in interface Writable
Overrides:
write in class ID
Parameters:
out - DataOuput to serialize this object into.
Throws:
IOException

read

public static JobID read(DataInput in)
                  throws IOException
Throws:
IOException

forName

public static JobID forName(String str)
                     throws IllegalArgumentException
Construct a JobId object from given string

Returns:
constructed JobId object or null if the given String is null
Throws:
IllegalArgumentException - if the given string is malformed

getJobIDsPattern

public static String getJobIDsPattern(String jtIdentifier,
                                      Integer jobId)
Returns a regex pattern which matches task IDs. Arguments can be given null, in which case that part of the regex will be generic. For example to obtain a regex matching any job run on the jobtracker started at 200707121733, we would use :
 
 JobID.getTaskIDsPattern("200707121733", null);
 
which will return :
 "job_200707121733_[0-9]*" 

Parameters:
jtIdentifier - jobTracker identifier, or null
jobId - job number, or null
Returns:
a regex pattern matching JobIDs


Copyright © 2008 The Apache Software Foundation