Example usage for org.apache.hadoop.mapreduce TaskInputOutputContext getCounter

List of usage examples for org.apache.hadoop.mapreduce TaskInputOutputContext getCounter

Introduction

In this page you can find the example usage for org.apache.hadoop.mapreduce TaskInputOutputContext getCounter.

Prototype

public Counter getCounter(String groupName, String counterName);

Source Link

Document

Get the Counter for the given groupName and counterName.

Usage

From source file:com.datasalt.pangool.utils.HadoopUtils.java

License:Apache License

/**
 * Utility for doing ctx.getCounter(groupName,
 * counter.toString()).increment(1);//from   w  w  w  .java 2 s. c o  m
 */
@SuppressWarnings("rawtypes")
public static void incCounter(TaskInputOutputContext ctx, String groupName, Enum counter) {
    ctx.getCounter(groupName, counter.toString()).increment(1);
}

From source file:gobblin.metrics.hadoop.NewAPIHadoopCounterReporterTest.java

License:Apache License

@BeforeClass
@SuppressWarnings("unchecked")
public void setUp() {
    TaskInputOutputContext<Object, Object, Object, Object> mockContext = Mockito
            .mock(TaskInputOutputContext.class);

    this.recordsProcessedCount = Mockito.mock(Counter.class);
    Mockito.when(mockContext.getCounter(this.name,
            MetricRegistry.name(RECORDS_PROCESSED, Measurements.COUNT.getName())))
            .thenReturn(this.recordsProcessedCount);

    this.recordProcessRateCount = Mockito.mock(Counter.class);
    Mockito.when(mockContext.getCounter(this.name,
            MetricRegistry.name(RECORD_PROCESS_RATE, Measurements.COUNT.getName())))
            .thenReturn(this.recordProcessRateCount);

    this.recordSizeDistributionCount = Mockito.mock(Counter.class);
    Mockito.when(mockContext.getCounter(this.name,
            MetricRegistry.name(RECORD_SIZE_DISTRIBUTION, Measurements.COUNT.getName())))
            .thenReturn(this.recordSizeDistributionCount);

    this.totalDurationCount = Mockito.mock(Counter.class);
    Mockito.when(mockContext.getCounter(this.name,
            MetricRegistry.name(TOTAL_DURATION, Measurements.COUNT.getName())))
            .thenReturn(this.totalDurationCount);

    this.queueSize = Mockito.mock(Counter.class);
    Mockito.when(mockContext.getCounter(this.name, QUEUE_SIZE)).thenReturn(this.queueSize);

    this.hadoopCounterReporter = NewAPIHadoopCounterReporter.builder(mockContext)
            .convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.SECONDS).filter(MetricFilter.ALL)
            .build(MetricContext.builder(this.name).build());
}

From source file:org.godhuli.rhipe.RHMRHelper.java

License:Apache License

void waitOutputThreads(
        TaskInputOutputContext<WritableComparable, RHBytesWritable, WritableComparable, RHBytesWritable> ctx) {
    try {/*w w  w .  j a  va 2s.  co  m*/
        // I commented this out, if uncommented, then uncomment the bit for DummyContext
        // if (outThread_ == null) {
        //    startOutputThreads(new DummyContext(ctx)); //will fail
        // }
        int exitVal = sim.waitFor();
        if (exitVal != 0) {
            if (nonZeroExitIsFailure_) {
                ctx.getCounter("R_ERRORS", "subprocess failed with code: " + exitVal).increment(1);
            } else {
                ctx.getCounter("R_SUBPROCESS", "subprocess failed with code: " + exitVal).increment(1);
            }
        }
        if (outThread_ != null)
            outThread_.join(joinDelay_);
        if (errThread_ != null)
            errThread_.join(joinDelay_);
    } catch (InterruptedException e) {
    }
}

From source file:org.janusgraph.hadoop.compat.h2.Hadoop2Compat.java

License:Apache License

@Override
public void incrementContextCounter(TaskInputOutputContext context, String group, String name, long increment) {
    context.getCounter(group, name).increment(increment);
}

From source file:org.janusgraph.hadoop.compat.h2.Hadoop2Compat.java

License:Apache License

@Override
public long getContextCounter(TaskInputOutputContext context, String group, String name) {
    return context.getCounter(group, name).getValue();
}