Example usage for org.apache.hadoop.mapred TaskID forName

List of usage examples for org.apache.hadoop.mapred TaskID forName

Introduction

In this page you can find the example usage for org.apache.hadoop.mapred TaskID forName.

Prototype

public static TaskID forName(String str) throws IllegalArgumentException 

Source Link

Usage

From source file:de.l3s.streamcorpus.mapreduce.TerrierIndexing.java

License:Mozilla Public License

/** Performs cleanup of an index path removing temporary files */
public static void deleteTaskFiles(String path, JobID job) {
    String[] fileNames = Files.list(path);
    if (fileNames == null)
        return;/*from w  ww. java  2 s. c  om*/
    for (String filename : fileNames) {
        String periodParts[] = filename.split("\\.");
        try {
            TaskID tid = TaskID.forName(periodParts[0]);
            if (tid.getJobID().equals(job)) {
                if (!Files.delete(path + "/" + filename))
                    logger.warn("Could not delete temporary map side-effect file " + path + "/" + filename);
            }
        } catch (Exception e) {
        }
    }
}

From source file:hivemall.utils.hadoop.HadoopUtils.java

License:Open Source License

@Nonnull
public static String getJobIdFromTaskId(@Nonnull String taskidStr) {
    if (!taskidStr.startsWith("task_")) {// workaround for Tez
        taskidStr = taskidStr.replace("task", "task_");
        taskidStr = taskidStr.substring(0, taskidStr.lastIndexOf('_'));
    }/*from www.  j  a v a2  s  .  c o  m*/
    TaskID taskId = TaskID.forName(taskidStr);
    JobID jobId = taskId.getJobID();
    return jobId.toString();
}

From source file:org.elasticsearch.hadoop.mr.HadoopCfgUtils.java

License:Apache License

public static TaskID getTaskID(Configuration cfg) {
    // first try with the attempt since some Hadoop versions mix the two
    String taskAttemptId = HadoopCfgUtils.getTaskAttemptId(cfg);
    if (StringUtils.hasText(taskAttemptId)) {
        try {/*from ww w .j  a  va 2s . com*/
            return TaskAttemptID.forName(taskAttemptId).getTaskID();
        } catch (IllegalArgumentException ex) {
            // the task attempt is invalid (Tez in particular uses the wrong string - see #346)
            // try to fallback to task id
            return parseTaskIdFromTaskAttemptId(taskAttemptId);
        }
    }
    String taskIdProp = HadoopCfgUtils.getTaskId(cfg);
    // double-check task id bug in Hadoop 2.5.x
    if (StringUtils.hasText(taskIdProp) && !taskIdProp.contains("attempt")) {
        return TaskID.forName(taskIdProp);
    }
    return null;
}

From source file:org.terrier.structures.indexing.singlepass.hadoop.MapData.java

License:Mozilla Public License

/**
 * Constructor - Loads the Map Information from the DataInputStream Provided
 * @param in - Stream of the Map data file
 *//* w ww.  ja  va 2  s  . c  om*/
public MapData(DataInputStream in) throws IOException {
    super();
    mapTaskID = in.readUTF();
    int_mapTaskId = TaskID.forName(mapTaskID).getId();
    int flushSize;
    while ((flushSize = in.readInt()) != -1) {
        flushDocSizes.add(flushSize);
    }
    numMapDocs = in.readInt();
    splitnum = in.readInt();
    logger.info("map " + mapTaskID + " processed split " + splitnum + " which had " + numMapDocs
            + " docs, with " + flushDocSizes.size() + " flushes\n");
}