Search in sources :

Example 1 with HadoopV2Job

use of org.apache.ignite.internal.processors.hadoop.impl.v2.HadoopV2Job in project ignite by apache.

the class HadoopFileSystemCounterWriterDelegateImpl method write.

/**
 * {@inheritDoc}
 */
public void write(HadoopJobEx job, HadoopCounters cntrs) throws IgniteCheckedException {
    Configuration hadoopCfg = HadoopUtils.safeCreateConfiguration();
    final HadoopJobInfo jobInfo = job.info();
    final HadoopJobId jobId = job.id();
    for (Map.Entry<String, String> e : ((HadoopDefaultJobInfo) jobInfo).properties().entrySet()) hadoopCfg.set(e.getKey(), e.getValue());
    String user = jobInfo.user();
    user = IgfsUtils.fixUserName(user);
    String dir = jobInfo.property(IgniteHadoopFileSystemCounterWriter.COUNTER_WRITER_DIR_PROPERTY);
    if (dir == null)
        dir = DEFAULT_COUNTER_WRITER_DIR;
    Path jobStatPath = new Path(new Path(dir.replace(USER_MACRO, user)), jobId.toString());
    HadoopPerformanceCounter perfCntr = HadoopPerformanceCounter.getCounter(cntrs, null);
    try {
        hadoopCfg.set(MRJobConfig.USER_NAME, user);
        FileSystem fs = ((HadoopV2Job) job).fileSystem(jobStatPath.toUri(), hadoopCfg);
        fs.mkdirs(jobStatPath);
        try (PrintStream out = new PrintStream(fs.create(new Path(jobStatPath, IgniteHadoopFileSystemCounterWriter.PERFORMANCE_COUNTER_FILE_NAME)))) {
            for (T2<String, Long> evt : perfCntr.evts()) {
                out.print(evt.get1());
                out.print(':');
                out.println(evt.get2().toString());
            }
            out.flush();
        }
    } catch (IOException e) {
        throw new IgniteCheckedException(e);
    }
}
Also used : HadoopJobInfo(org.apache.ignite.internal.processors.hadoop.HadoopJobInfo) Path(org.apache.hadoop.fs.Path) PrintStream(java.io.PrintStream) Configuration(org.apache.hadoop.conf.Configuration) HadoopPerformanceCounter(org.apache.ignite.internal.processors.hadoop.counter.HadoopPerformanceCounter) IOException(java.io.IOException) HadoopJobId(org.apache.ignite.internal.processors.hadoop.HadoopJobId) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) HadoopV2Job(org.apache.ignite.internal.processors.hadoop.impl.v2.HadoopV2Job) FileSystem(org.apache.hadoop.fs.FileSystem) Map(java.util.Map)

Aggregations

IOException (java.io.IOException)1 PrintStream (java.io.PrintStream)1 Map (java.util.Map)1 Configuration (org.apache.hadoop.conf.Configuration)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 Path (org.apache.hadoop.fs.Path)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 HadoopJobId (org.apache.ignite.internal.processors.hadoop.HadoopJobId)1 HadoopJobInfo (org.apache.ignite.internal.processors.hadoop.HadoopJobInfo)1 HadoopPerformanceCounter (org.apache.ignite.internal.processors.hadoop.counter.HadoopPerformanceCounter)1 HadoopV2Job (org.apache.ignite.internal.processors.hadoop.impl.v2.HadoopV2Job)1