Example usage for org.apache.hadoop.mapreduce.counters GenericCounter GenericCounter

List of usage examples for org.apache.hadoop.mapreduce.counters GenericCounter GenericCounter

Introduction

In this page you can find the example usage for org.apache.hadoop.mapreduce.counters GenericCounter GenericCounter.

Prototype

public GenericCounter(String name, String displayName) 

Source Link

Usage

From source file:com.linkedin.cubert.plan.physical.TestContext.java

License:Open Source License

@Override
public Counter getCounter(String groupName, String counterName) {
    HashMap<String, Counter> group = counterCache.get(groupName);
    if (group == null) {
        group = new HashMap<String, Counter>();
        counterCache.put(groupName, group);
    }/*from   w w  w. j  a v a 2  s  .  co m*/

    Counter counter = group.get(counterName);
    if (counter == null) {
        counter = new GenericCounter(groupName, counterName);
        group.put(counterName, counter);
    }

    return counter;
}

From source file:org.apache.sqoop.job.mr.TestSqoopLoader.java

License:Apache License

@BeforeMethod(alwaysRun = true)
public void setUp() {
    conf = new Configuration();
    conf.setIfUnset(MRJobConstants.TO_INTERMEDIATE_DATA_FORMAT, CSVIntermediateDataFormat.class.getName());
    jobContextMock = mock(TaskAttemptContext.class);
    GenericCounter counter = new GenericCounter("test", "test-me");
    when(((TaskAttemptContext) jobContextMock).getCounter(SqoopCounters.ROWS_WRITTEN)).thenReturn(counter);
    org.apache.hadoop.mapred.JobConf testConf = new org.apache.hadoop.mapred.JobConf();
    when(jobContextMock.getConfiguration()).thenReturn(testConf);
}