Example usage for org.apache.hadoop.mapreduce TaskAttemptID getJobID

List of usage examples for org.apache.hadoop.mapreduce TaskAttemptID getJobID

Introduction

In this page you can find the example usage for org.apache.hadoop.mapreduce TaskAttemptID getJobID.

Prototype

public JobID getJobID() 

Source Link

Document

Returns the JobID object that this task attempt belongs to

Usage

From source file:com.google.appengine.tools.mapreduce.ShardState.java

License:Apache License

/**
 * Creates a shard state that's active but hasn't made any progress as of yet.
 * //  w  w  w . ja  va2  s  .  co  m
 * The shard state isn't persisted when returned (so {@link #getKey()} will
 * return {@code null} until {@link #persist()} is called.
 * 
 * @param service the datastore to persist the ShardState to
 * @param taskAttemptId the TaskAttemptID corresponding to the returned 
 * ShardState
 * @return the initialized shard state
 */
public static ShardState generateInitializedShardState(DatastoreService service, TaskAttemptID taskAttemptId) {
    ShardState shardState = new ShardState(service);

    shardState.entity = new Entity("ShardState", taskAttemptId.toString());
    shardState.entity.setProperty(JOB_ID_PROPERTY, taskAttemptId.getJobID().toString());

    Counters counters = new Counters();
    shardState.setCounters(counters);

    shardState.setStatusString("");
    shardState.entity.setProperty(STATUS_PROPERTY, Status.ACTIVE.name());

    return shardState;
}

From source file:com.google.appengine.tools.mapreduce.v2.impl.ShardState.java

License:Apache License

/**
 * Creates a shard state that's active but hasn't made any progress as of yet.
 *
 * The shard state isn't persisted when returned (so {@link #getKey()} will
 * return {@code null} until {@link #persist()} is called.
 *
 * @param service the datastore to persist the ShardState to
 * @param taskAttemptId the TaskAttemptID corresponding to the returned
 * ShardState/*from w  w  w  . j  a  v a  2  s .com*/
 * @return the initialized shard state
 */
public static ShardState generateInitializedShardState(DatastoreService service, TaskAttemptID taskAttemptId) {
    ShardState shardState = new ShardState(service);

    shardState.entity = new Entity("ShardState", taskAttemptId.toString());
    shardState.entity.setProperty(JOB_ID_PROPERTY, taskAttemptId.getJobID().toString());

    Counters counters = new Counters();
    shardState.setCounters(counters);

    shardState.setStatusString("");
    shardState.entity.setProperty(STATUS_PROPERTY, "" + Status.ACTIVE);

    return shardState;
}

From source file:com.inmobi.conduit.local.CopyMapper.java

License:Apache License

private Path getTaskAttemptTmpDir(Context context) {
    TaskAttemptID attemptId = context.getTaskAttemptID();
    return new Path(getJobTmpDir(context, attemptId.getJobID()), attemptId.toString());
}

From source file:com.sourcecode.TaskAttemptContextImpl.java

License:Apache License

public TaskAttemptContextImpl(Configuration conf, TaskAttemptID taskId, StatusReporter reporter) {
    super(conf, taskId.getJobID());
    this.taskId = taskId;
    this.reporter = reporter;
}

From source file:it.crs4.pydoop.mapreduce.pipes.TaskLog.java

License:Apache License

/**
 * Obtain the owner of the log dir. This is
 * determined by checking the job's log directory.
 *//*  w ww.  java  2  s . co  m*/
static String obtainLogDirOwner(TaskAttemptID taskid) throws IOException {
    Configuration conf = new Configuration();
    FileSystem raw = FileSystem.getLocal(conf).getRaw();
    Path jobLogDir = new Path(getJobDir(taskid.getJobID()).getAbsolutePath());
    FileStatus jobStat = raw.getFileStatus(jobLogDir);
    return jobStat.getOwner();
}

From source file:it.crs4.pydoop.mapreduce.pipes.TaskLog.java

License:Apache License

static File getAttemptDir(TaskAttemptID taskid, boolean isCleanup) {
    String cleanupSuffix = isCleanup ? ".cleanup" : "";
    return new File(getJobDir(taskid.getJobID()), taskid + cleanupSuffix);
}

From source file:org.apache.blur.mapreduce.lib.BlurOutputCommitter.java

License:Apache License

private void commitOrAbortJob(JobContext jobContext, Path shardPath, boolean commit) throws IOException {
    LOG.info("CommitOrAbort [{0}] path [{1}]", commit, shardPath);
    FileSystem fileSystem = shardPath.getFileSystem(jobContext.getConfiguration());
    FileStatus[] listStatus = fileSystem.listStatus(shardPath, new PathFilter() {
        @Override//from  w w w . ja v  a 2s. co m
        public boolean accept(Path path) {
            LOG.info("Checking path [{0}]", path);
            if (path.getName().endsWith(".task_complete")) {
                return true;
            }
            return false;
        }
    });
    for (FileStatus fileStatus : listStatus) {
        Path path = fileStatus.getPath();
        LOG.info("Trying to commitOrAbort [{0}]", path);
        String name = path.getName();
        boolean taskComplete = name.endsWith(".task_complete");
        if (fileStatus.isDir()) {
            String taskAttemptName = getTaskAttemptName(name);
            if (taskAttemptName == null) {
                LOG.info("Dir name [{0}] not task attempt", name);
                continue;
            }
            TaskAttemptID taskAttemptID = TaskAttemptID.forName(taskAttemptName);
            if (taskAttemptID.getJobID().equals(jobContext.getJobID())) {
                if (commit) {
                    if (taskComplete) {
                        fileSystem.rename(path, new Path(shardPath, taskAttemptName + ".commit"));
                        LOG.info("Committing [{0}] in path [{1}]", taskAttemptID, path);
                    } else {
                        fileSystem.delete(path, true);
                        LOG.info("Deleting tmp dir [{0}] in path [{1}]", taskAttemptID, path);
                    }
                } else {
                    fileSystem.delete(path, true);
                    LOG.info("Deleting aborted job dir [{0}] in path [{1}]", taskAttemptID, path);
                }
            } else {
                LOG.warn("TaskAttempt JobID [{0}] does not match JobContext JobId [{1}]",
                        taskAttemptID.getJobID(), jobContext.getJobID());
            }
        }
    }
}

From source file:org.apache.tez.mapreduce.client.YARNRunner.java

License:Apache License

@Override
public String[] getTaskDiagnostics(TaskAttemptID arg0) throws IOException, InterruptedException {
    return clientCache.getClient(arg0.getJobID()).getTaskDiagnostics(arg0);
}

From source file:org.apache.tez.mapreduce.client.YARNRunner.java

License:Apache License

@Override
public boolean killTask(TaskAttemptID arg0, boolean arg1) throws IOException, InterruptedException {
    return clientCache.getClient(arg0.getJobID()).killTask(arg0, arg1);
}