Example usage for org.apache.hadoop.mapred Counters.Group getCounter

List of usage examples for org.apache.hadoop.mapred Counters.Group getCounter

Introduction

In this page you can find the example usage for org.apache.hadoop.mapred Counters.Group getCounter.

Prototype

public synchronized long getCounter(Enum<?> key) 

Source Link

Document

Returns current value of the specified counter, or 0 if the counter does not exist.

Usage

From source file:cascading.flow.hadoop.HadoopStepStats.java

License:Open Source License

@Override
public long getCounterValue(String group, String counter) {
    try {//from  www .jav  a 2s .c  om
        RunningJob runningJob = getRunningJob();

        if (runningJob == null)
            return 0;

        Counters counters = runningJob.getCounters();

        if (counters == null)
            return 0;

        Counters.Group counterGroup = counters.getGroup(group);

        if (group == null)
            return 0;

        return counterGroup.getCounter(counter);
    } catch (IOException exception) {
        throw new FlowException("unable to get remote counter values");
    }
}

From source file:com.liveramp.cascading_ext.counters.Counters.java

License:Apache License

private static Long getHadoopCounterValue(HadoopStepStats hadoopStep, String group, String value) {
    try {//  w w w . ja v a2s.  com
        org.apache.hadoop.mapred.Counters.Group counterGroup = hadoopStep.getRunningJob().getCounters()
                .getGroup(group);
        if (counterGroup != null) {
            return counterGroup.getCounter(value);
        }
        return 0l;
    } catch (Exception e) {
        return 0l;
    }
}

From source file:org.apache.oozie.action.hadoop.LauncherHelper.java

License:Apache License

public static boolean isMainSuccessful(RunningJob runningJob) throws IOException {
    boolean succeeded = runningJob.isSuccessful();
    if (succeeded) {
        Counters counters = runningJob.getCounters();
        if (counters != null) {
            Counters.Group group = counters.getGroup(LauncherAMUtils.COUNTER_GROUP);
            if (group != null) {
                succeeded = group.getCounter(LauncherAMUtils.COUNTER_LAUNCHER_ERROR) == 0;
            }// w  w  w . j a  v  a  2 s.  c o m
        }
    }
    return succeeded;
}

From source file:org.apache.oozie.action.hadoop.LauncherMapperHelper.java

License:Apache License

public static boolean isMainSuccessful(RunningJob runningJob) throws IOException {
    boolean succeeded = runningJob.isSuccessful();
    if (succeeded) {
        Counters counters = runningJob.getCounters();
        if (counters != null) {
            Counters.Group group = counters.getGroup(LauncherMapper.COUNTER_GROUP);
            if (group != null) {
                succeeded = group.getCounter(LauncherMapper.COUNTER_LAUNCHER_ERROR) == 0;
            }/*  ww  w .j  a v a  2s  .c  o  m*/
        }
    }
    return succeeded;
}

From source file:org.apache.oozie.action.hadoop.MapperReducerCredentialsForTest.java

License:Apache License

public static boolean hasCredentials(RunningJob runningJob) throws IOException {
    boolean output = false;
    Counters counters = runningJob.getCounters();
    if (counters != null) {
        Counters.Group group = counters.getGroup(COUNTER_GROUP);
        if (group != null) {
            output = group.getCounter(COUNTER_OUTPUT_DATA) > 0;
        }/*from w w  w.j a v a  2  s  .  c  o m*/
    }
    return output;
}