org.apache.hadoop.mapreduce.OutputFormat.getOutputCommitter()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(82)

本文整理了Java中org.apache.hadoop.mapreduce.OutputFormat.getOutputCommitter()方法的一些代码示例,展示了OutputFormat.getOutputCommitter()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OutputFormat.getOutputCommitter()方法的具体详情如下:
包路径:org.apache.hadoop.mapreduce.OutputFormat
类名称:OutputFormat
方法名:getOutputCommitter

OutputFormat.getOutputCommitter介绍

[英]Get the output committer for this output format. This is responsible for ensuring the output is committed correctly.
[中]获取此输出格式的输出提交程序。这负责确保正确提交输出。

代码示例

代码示例来源:origin: apache/hive

/**
 * Get the output committer for this output format. This is responsible
 * for ensuring the output is committed correctly.
 * @param context the task context
 * @return an output committer
 * @throws IOException
 * @throws InterruptedException
 */
@Override
public OutputCommitter getOutputCommitter(TaskAttemptContext context
) throws IOException, InterruptedException {
 return getOutputFormat(context).getOutputCommitter(context);
}

代码示例来源:origin: apache/hive

public MultiOutputCommitter(TaskAttemptContext context) throws IOException,
  InterruptedException {
 outputCommitters = new LinkedHashMap<String, MultiOutputFormat.BaseOutputCommitterContainer>();
 String[] aliases = getOutputFormatAliases(context);
 for (String alias : aliases) {
  LOGGER.info("Creating output committer for alias: " + alias);
  TaskAttemptContext aliasContext = getTaskAttemptContext(alias, context);
  OutputCommitter baseCommitter = getOutputFormatInstance(aliasContext)
    .getOutputCommitter(aliasContext);
  outputCommitters.put(alias,
    new BaseOutputCommitterContainer(baseCommitter, aliasContext));
 }
}

代码示例来源:origin: apache/ignite

/**
 * Setup task.
 *
 * @param outputFormat Output format.
 * @throws IOException In case of IO exception.
 * @throws InterruptedException In case of interrupt.
 */
protected void setup(@Nullable OutputFormat outputFormat) throws IOException, InterruptedException {
  if (hadoopCtx.writer() != null) {
    assert outputFormat != null;
    outputFormat.getOutputCommitter(hadoopCtx).setupTask(hadoopCtx);
  }
}

代码示例来源:origin: apache/ignite

/**
 * Abort task.
 *
 * @param outputFormat Output format.
 */
protected void abort(@Nullable OutputFormat outputFormat) {
  if (hadoopCtx.writer() != null) {
    assert outputFormat != null;
    try {
      outputFormat.getOutputCommitter(hadoopCtx).abortTask(hadoopCtx);
    }
    catch (IOException ignore) {
      // Ignore.
    }
    catch (InterruptedException ignore) {
      Thread.currentThread().interrupt();
    }
  }
}

代码示例来源:origin: elastic/elasticsearch-hadoop

@Override
public OutputCommitter getOutputCommitter(TaskAttemptContext context) throws IOException, InterruptedException {
  List<OutputFormat> formats = getNewApiFormats(CompatHandler.taskAttemptContext(context).getConfiguration());
  List<OutputCommitter> committers = new ArrayList<OutputCommitter>();
  for (OutputFormat format : formats) {
    committers.add(format.getOutputCommitter(context));
  }
  return new MultiNewOutputCommitter(committers);
}

代码示例来源:origin: apache/ignite

/**
 * Commit task.
 *
 * @param outputFormat Output format.
 * @throws IgniteCheckedException In case of Grid exception.
 * @throws IOException In case of IO exception.
 * @throws InterruptedException In case of interrupt.
 */
protected void commit(@Nullable OutputFormat outputFormat) throws IgniteCheckedException, IOException, InterruptedException {
  if (hadoopCtx.writer() != null) {
    assert outputFormat != null;
    OutputCommitter outputCommitter = outputFormat.getOutputCommitter(hadoopCtx);
    if (outputCommitter.needsTaskCommit(hadoopCtx))
      outputCommitter.commitTask(hadoopCtx);
  }
}

代码示例来源:origin: apache/flink

this.outputCommitter = this.mapreduceOutputFormat.getOutputCommitter(this.context);
  this.outputCommitter.setupJob(new JobContextImpl(this.configuration, new JobID()));
} catch (Exception e) {

代码示例来源:origin: apache/flink

@Override
public void finalizeGlobal(int parallelism) throws IOException {
  JobContext jobContext;
  TaskAttemptContext taskContext;
  try {
    TaskAttemptID taskAttemptID = TaskAttemptID.forName("attempt__0000_r_"
        + String.format("%" + (6 - Integer.toString(1).length()) + "s", " ").replace(" ", "0")
        + Integer.toString(1)
        + "_0");
    jobContext = new JobContextImpl(this.configuration, new JobID());
    taskContext = new TaskAttemptContextImpl(this.configuration, taskAttemptID);
    this.outputCommitter = this.mapreduceOutputFormat.getOutputCommitter(taskContext);
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
  jobContext.getCredentials().addAll(this.credentials);
  Credentials currentUserCreds = getCredentialsFromUGI(UserGroupInformation.getCurrentUser());
  if (currentUserCreds != null) {
    jobContext.getCredentials().addAll(currentUserCreds);
  }
  // finalize HDFS output format
  if (this.outputCommitter != null) {
    this.outputCommitter.commitJob(jobContext);
  }
}

代码示例来源:origin: apache/flink

@Test
public void testOpen() throws Exception {
  OutputFormat<String, Long> dummyOutputFormat = mock(DummyOutputFormat.class);
  OutputCommitter outputCommitter = setupOutputCommitter(true);
  when(dummyOutputFormat.getOutputCommitter(any(TaskAttemptContext.class))).thenReturn(outputCommitter);
  HadoopOutputFormat<String, Long> hadoopOutputFormat = setupHadoopOutputFormat(dummyOutputFormat,
    Job.getInstance(), new DummyRecordWriter(), setupOutputCommitter(true), new Configuration());
  hadoopOutputFormat.open(1, 4);
  verify(hadoopOutputFormat.outputCommitter, times(1)).setupJob(any(JobContext.class));
  verify(hadoopOutputFormat.mapreduceOutputFormat, times(1)).getRecordWriter(any(TaskAttemptContext.class));
}

代码示例来源:origin: apache/ignite

/** {@inheritDoc} */
  @Override protected void run0(HadoopV2TaskContext taskCtx) throws IgniteCheckedException {
    try {
      JobContextImpl jobCtx = taskCtx.jobContext();

      OutputFormat outputFormat = getOutputFormat(jobCtx);

      outputFormat.checkOutputSpecs(jobCtx);

      OutputCommitter committer = outputFormat.getOutputCommitter(hadoopContext());

      if (committer != null)
        committer.setupJob(jobCtx);
    }
    catch (ClassNotFoundException | IOException e) {
      throw new IgniteCheckedException(e);
    }
    catch (InterruptedException e) {
      Thread.currentThread().interrupt();

      throw new IgniteInterruptedCheckedException(e);
    }
  }
}

代码示例来源:origin: apache/ignite

/** {@inheritDoc} */
  @Override public void run0(HadoopV2TaskContext taskCtx) throws IgniteCheckedException {
    JobContextImpl jobCtx = taskCtx.jobContext();

    try {
      OutputFormat outputFormat = getOutputFormat(jobCtx);

      OutputCommitter committer = outputFormat.getOutputCommitter(hadoopContext());

      if (committer != null) {
        if (abort)
          committer.abortJob(jobCtx, JobStatus.State.FAILED);
        else
          committer.commitJob(jobCtx);
      }
    }
    catch (ClassNotFoundException | IOException e) {
      throw new IgniteCheckedException(e);
    }
    catch (InterruptedException e) {
      Thread.currentThread().interrupt();

      throw new IgniteInterruptedCheckedException(e);
    }
  }
}

代码示例来源:origin: apache/ignite

/**
 * Put write into Hadoop context and return associated output format instance.
 *
 * @param jobCtx Job context.
 * @return Output format.
 * @throws IgniteCheckedException In case of Grid exception.
 * @throws InterruptedException In case of interrupt.
 */
protected OutputFormat prepareWriter(JobContext jobCtx)
  throws IgniteCheckedException, InterruptedException {
  try {
    OutputFormat outputFormat = getOutputFormat(jobCtx);
    assert outputFormat != null;
    OutputCommitter outCommitter = outputFormat.getOutputCommitter(hadoopCtx);
    if (outCommitter != null)
      outCommitter.setupTask(hadoopCtx);
    RecordWriter writer = outputFormat.getRecordWriter(hadoopCtx);
    hadoopCtx.writer(writer);
    return outputFormat;
  }
  catch (IOException | ClassNotFoundException e) {
    throw new IgniteCheckedException(e);
  }
}

代码示例来源:origin: com.datasalt.pangool/pangool-core

@Override
public OutputCommitter getOutputCommitter(TaskAttemptContext context)
  throws IOException, InterruptedException {
  instantiateWhenNeeded();
  return instance.getOutputCommitter(context);
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-mapreduce-client-core

@Override
public OutputCommitter getOutputCommitter(TaskAttemptContext context) 
throws IOException, InterruptedException {
 return getBaseOut().getOutputCommitter(context);
}

代码示例来源:origin: ch.cern.hadoop/hadoop-mapreduce-client-core

@Override
public OutputCommitter getOutputCommitter(TaskAttemptContext context) 
throws IOException, InterruptedException {
 return getBaseOut().getOutputCommitter(context);
}

代码示例来源:origin: io.hops/hadoop-mapreduce-client-core

@Override
public OutputCommitter getOutputCommitter(TaskAttemptContext context) 
throws IOException, InterruptedException {
 return getBaseOut().getOutputCommitter(context);
}

代码示例来源:origin: io.prestosql.hadoop/hadoop-apache

@Override
public OutputCommitter getOutputCommitter(TaskAttemptContext context) 
throws IOException, InterruptedException {
 return getBaseOut().getOutputCommitter(context);
}

代码示例来源:origin: datasalt/pangool

@Override
public OutputCommitter getOutputCommitter(TaskAttemptContext context)
  throws IOException, InterruptedException {
  instantiateWhenNeeded();
  return instance.getOutputCommitter(context);
}

代码示例来源:origin: org.elasticsearch/elasticsearch-hadoop

@Override
public OutputCommitter getOutputCommitter(TaskAttemptContext context) throws IOException, InterruptedException {
  List<OutputFormat> formats = getNewApiFormats(CompatHandler.taskAttemptContext(context).getConfiguration());
  List<OutputCommitter> committers = new ArrayList<OutputCommitter>();
  for (OutputFormat format : formats) {
    committers.add(format.getOutputCommitter(context));
  }
  return new MultiNewOutputCommitter(committers);
}

代码示例来源:origin: org.elasticsearch/elasticsearch-spark-13

@Override
public OutputCommitter getOutputCommitter(TaskAttemptContext context) throws IOException, InterruptedException {
  List<OutputFormat> formats = getNewApiFormats(CompatHandler.taskAttemptContext(context).getConfiguration());
  List<OutputCommitter> committers = new ArrayList<OutputCommitter>();
  for (OutputFormat format : formats) {
    committers.add(format.getOutputCommitter(context));
  }
  return new MultiNewOutputCommitter(committers);
}

相关文章