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

x33g5p2x  于2022-01-18 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(114)

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

Counter.getName介绍

暂无

代码示例

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

/** {@inheritDoc} */
@Override public void addCounter(Counter counter) {
  addCounter(counter.getName(), counter.getDisplayName(), 0);
}

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

/** {@inheritDoc} */
@Override public void incrAllCounters(CounterGroupBase<Counter> rightGroup) {
  for (final Counter counter : rightGroup)
    cntrs.findCounter(name, counter.getName()).increment(counter.getValue());
}

代码示例来源:origin: apache/incubator-gobblin

/**
 * Create a {@link org.apache.gobblin.metrics.GobblinMetrics} instance for this job run from the Hadoop counters.
 */
@VisibleForTesting
void countersToMetrics(GobblinMetrics metrics) throws IOException {
 Optional<Counters> counters = Optional.fromNullable(this.job.getCounters());
 if (counters.isPresent()) {
  // Write job-level counters
  CounterGroup jobCounterGroup = counters.get().getGroup(MetricGroup.JOB.name());
  for (Counter jobCounter : jobCounterGroup) {
   metrics.getCounter(jobCounter.getName()).inc(jobCounter.getValue());
  }
  // Write task-level counters
  CounterGroup taskCounterGroup = counters.get().getGroup(MetricGroup.TASK.name());
  for (Counter taskCounter : taskCounterGroup) {
   metrics.getCounter(taskCounter.getName()).inc(taskCounter.getValue());
  }
 }
}

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

/** {@inheritDoc} */
@Override public synchronized void incrAllCounters(AbstractCounters<Counter, CounterGroup> other) {
  for (CounterGroup group : other) {
    for (Counter counter : group) {
      findCounter(group.getName(), counter.getName()).increment(counter.getValue());
    }
  }
}

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

@Override
 protected void handleFailure(Counters counters) throws IOException {
  try (Connection conn = ConnectionFactory.createConnection(job.getConfiguration())) {
   TableName tableName = TableName.valueOf(COMMON_TABLE_NAME);
   CounterGroup g = counters.getGroup("undef");
   Iterator<Counter> it = g.iterator();
   while (it.hasNext()) {
    String keyString = it.next().getName();
    byte[] key = Bytes.toBytes(keyString);
    HRegionLocation loc = conn.getRegionLocator(tableName).getRegionLocation(key, true);
    LOG.error("undefined row " + keyString + ", " + loc);
   }
   g = counters.getGroup("unref");
   it = g.iterator();
   while (it.hasNext()) {
    String keyString = it.next().getName();
    byte[] key = Bytes.toBytes(keyString);
    HRegionLocation loc = conn.getRegionLocator(tableName).getRegionLocation(key, true);
    LOG.error("unreferred row " + keyString + ", " + loc);
   }
  }
 }
}

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

protected void handleFailure(Counters counters) throws IOException {
  Configuration conf = job.getConfiguration();
  TableName tableName = getTableName(conf);
  try (Connection conn = ConnectionFactory.createConnection(conf)) {
   try (RegionLocator rl = conn.getRegionLocator(tableName)) {
    CounterGroup g = counters.getGroup("undef");
    Iterator<Counter> it = g.iterator();
    while (it.hasNext()) {
     String keyString = it.next().getName();
     byte[] key = Bytes.toBytes(keyString);
     HRegionLocation loc = rl.getRegionLocation(key, true);
     LOG.error("undefined row " + keyString + ", " + loc);
    }
    g = counters.getGroup("unref");
    it = g.iterator();
    while (it.hasNext()) {
     String keyString = it.next().getName();
     byte[] key = Bytes.toBytes(keyString);
     HRegionLocation loc = rl.getRegionLocation(key, true);
     LOG.error("unreferred row " + keyString + ", " + loc);
    }
   }
  }
 }
}

代码示例来源:origin: cascading/cascading-hadoop2-mr1

@Override
protected Set<String> getCountersFor( Counters counters, String group )
 {
 Set<String> results = new HashSet<>();
 for( Counter counter : counters.getGroup( group ) )
  results.add( counter.getName() );
 return results;
 }

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

@Override
public synchronized void addCounter(T counter) {
 counters.put(counter.getName(), counter);
 limits.incrCounters();
}

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

@Override
public synchronized void addCounter(T counter) {
 counters.put(counter.getName(), counter);
 limits.incrCounters();
}

代码示例来源:origin: org.apache.hadoop/hadoop-mapreduce-client-app

public CounterGroupInfo(String name, CounterGroup group, CounterGroup mg,
  CounterGroup rg) {
 this.counterGroupName = name;
 this.counter = new ArrayList<CounterInfo>();
 for (Counter c : group) {
  Counter mc = mg == null ? null : mg.findCounter(c.getName());
  Counter rc = rg == null ? null : rg.findCounter(c.getName());
  CounterInfo cinfo = new CounterInfo(c, mc, rc);
  this.counter.add(cinfo);
 }
}

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

public CounterGroupInfo(String name, CounterGroup group, CounterGroup mg,
  CounterGroup rg) {
 this.counterGroupName = name;
 this.counter = new ArrayList<CounterInfo>();
 for (Counter c : group) {
  Counter mc = mg == null ? null : mg.findCounter(c.getName());
  Counter rc = rg == null ? null : rg.findCounter(c.getName());
  CounterInfo cinfo = new CounterInfo(c, mc, rc);
  this.counter.add(cinfo);
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-mapreduce-client-app

public TaskCounterGroupInfo(String name, CounterGroup group) {
  this.counterGroupName = name;
  this.counter = new ArrayList<TaskCounterInfo>();

  for (Counter c : group) {
   TaskCounterInfo cinfo = new TaskCounterInfo(c.getName(), c.getValue());
   this.counter.add(cinfo);
  }
 }
}

代码示例来源:origin: cwensel/cascading

private void setCounters( TaskReport taskReport )
 {
 this.counters = new HashMap<>();
 Counters hadoopCounters = taskReport.getTaskCounters();
 for( CounterGroup group : hadoopCounters )
  {
  Map<String, Long> values = new HashMap<String, Long>();
  this.counters.put( group.getName(), values );
  for( Counter counter : group )
   values.put( counter.getName(), counter.getValue() );
  }
 }

代码示例来源:origin: cascading/cascading-hadoop2-mr1

private void setCounters( TaskReport taskReport )
 {
 this.counters = new HashMap<>();
 Counters hadoopCounters = taskReport.getTaskCounters();
 for( CounterGroup group : hadoopCounters )
  {
  Map<String, Long> values = new HashMap<String, Long>();
  this.counters.put( group.getName(), values );
  for( Counter counter : group )
   values.put( counter.getName(), counter.getValue() );
  }
 }

代码示例来源:origin: openimaj/openimaj

@Override
  protected void reduce(Text key, Iterable<BytesWritable> values, Context context){
    Counter cheeseCounter = context.getCounter(CounterEnum.CHEESE);
    Counter fleesCounter = context.getCounter(CounterEnum.FLEES);
    System.out.println(cheeseCounter.getName() + ": " + cheeseCounter.getValue());
    System.out.println(fleesCounter.getName() + ": " + fleesCounter.getValue());
    
  }
}

代码示例来源:origin: com.facebook.hadoop/hadoop-core

public synchronized void readFields(DataInput in) throws IOException {
 displayName = Text.readString(in);
 counters.clear();
 int size = WritableUtils.readVInt(in);
 for(int i=0; i < size; i++) {
  Counter counter = new Counter();
  counter.readFields(in);
  counters.put(counter.getName(), counter);
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-mapreduce-client-app

public CounterInfo(Counter c, Counter mc, Counter rc) {
  this.name = c.getName();
  this.totalCounterValue = c.getValue();
  this.mapCounterValue = mc == null ? 0 : mc.getValue();
  this.reduceCounterValue = rc == null ? 0 : rc.getValue();
 }
}

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

public CounterInfo(Counter c, Counter mc, Counter rc) {
  this.name = c.getName();
  this.totalCounterValue = c.getValue();
  this.mapCounterValue = mc == null ? 0 : mc.getValue();
  this.reduceCounterValue = rc == null ? 0 : rc.getValue();
 }
}

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

@Override
public synchronized void readFields(DataInput in) throws IOException {
 displayName = StringInterner.weakIntern(Text.readString(in));
 counters.clear();
 int size = WritableUtils.readVInt(in);
 for (int i = 0; i < size; i++) {
  T counter = newCounter();
  counter.readFields(in);
  counters.put(counter.getName(), counter);
  limits.incrCounters();
 }
}

代码示例来源:origin: org.apache.crunch/crunch-core

public synchronized void incrAllCounters(Counters other) {
  for (CounterGroup cg : other) {
   for (Counter c : cg) {
    findCounter(cg.getName(), c.getName()).increment(c.getValue());
   }
  }
 }
}

相关文章