当前位置: 首页>>代码示例>>Java>>正文


Java Counter.getValue方法代码示例

本文整理汇总了Java中org.apache.hadoop.mapreduce.Counter.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java Counter.getValue方法的具体用法?Java Counter.getValue怎么用?Java Counter.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.mapreduce.Counter的用法示例。


在下文中一共展示了Counter.getValue方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toAvro

import org.apache.hadoop.mapreduce.Counter; //导入方法依赖的package包/类
static JhCounters toAvro(Counters counters, String name) {
  JhCounters result = new JhCounters();
  result.name = new Utf8(name);
  result.groups = new ArrayList<JhCounterGroup>(0);
  if (counters == null) return result;
  for (CounterGroup group : counters) {
    JhCounterGroup g = new JhCounterGroup();
    g.name = new Utf8(group.getName());
    g.displayName = new Utf8(group.getDisplayName());
    g.counts = new ArrayList<JhCounter>(group.size());
    for (Counter counter : group) {
      JhCounter c = new JhCounter();
      c.name = new Utf8(counter.getName());
      c.displayName = new Utf8(counter.getDisplayName());
      c.value = counter.getValue();
      g.counts.add(c);
    }
    result.groups.add(g);
  }
  return result;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:EventWriter.java

示例2: verifyExpectedValues

import org.apache.hadoop.mapreduce.Counter; //导入方法依赖的package包/类
/**
 * Verify the values in the Counters against the expected number of entries written.
 *
 * @param expectedReferenced
 *          Expected number of referenced entrires
 * @param counters
 *          The Job's Counters object
 * @return True if the values match what's expected, false otherwise
 */
protected boolean verifyExpectedValues(long expectedReferenced, Counters counters) {
  final Counter referenced = counters.findCounter(Counts.REFERENCED);
  final Counter unreferenced = counters.findCounter(Counts.UNREFERENCED);
  boolean success = true;

  if (expectedReferenced != referenced.getValue()) {
    LOG.error("Expected referenced count does not match with actual referenced count. " +
        "expected referenced=" + expectedReferenced + " ,actual=" + referenced.getValue());
    success = false;
  }

  if (unreferenced.getValue() > 0) {
    final Counter multiref = counters.findCounter(Counts.EXTRAREFERENCES);
    boolean couldBeMultiRef = (multiref.getValue() == unreferenced.getValue());
    LOG.error("Unreferenced nodes were not expected. Unreferenced count=" + unreferenced.getValue()
        + (couldBeMultiRef ? "; could be due to duplicate random numbers" : ""));
    success = false;
  }

  return success;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:31,代码来源:IntegrationTestBigLinkedList.java

示例3: verifyUnexpectedValues

import org.apache.hadoop.mapreduce.Counter; //导入方法依赖的package包/类
/**
 * Verify that the Counters don't contain values which indicate an outright failure from the Reducers.
 *
 * @param counters
 *          The Job's counters
 * @return True if the "bad" counter objects are 0, false otherwise
 */
protected boolean verifyUnexpectedValues(Counters counters) {
  final Counter undefined = counters.findCounter(Counts.UNDEFINED);
  final Counter lostfamilies = counters.findCounter(Counts.LOST_FAMILIES);
  boolean success = true;

  if (undefined.getValue() > 0) {
    LOG.error("Found an undefined node. Undefined count=" + undefined.getValue());
    success = false;
  }

  if (lostfamilies.getValue() > 0) {
    LOG.error("Found nodes which lost big or tiny families, count=" + lostfamilies.getValue());
    success = false;
  }

  return success;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:25,代码来源:IntegrationTestBigLinkedList.java

示例4: TaskCounterGroupInfo

import org.apache.hadoop.mapreduce.Counter; //导入方法依赖的package包/类
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);
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:10,代码来源:TaskCounterGroupInfo.java

示例5: updateProgressSplits

import org.apache.hadoop.mapreduce.Counter; //导入方法依赖的package包/类
private void updateProgressSplits() {
  double newProgress = reportedStatus.progress;
  newProgress = Math.max(Math.min(newProgress, 1.0D), 0.0D);
  Counters counters = reportedStatus.counters;
  if (counters == null)
    return;

  WrappedProgressSplitsBlock splitsBlock = getProgressSplitBlock();
  if (splitsBlock != null) {
    long now = clock.getTime();
    long start = getLaunchTime(); // TODO Ensure not 0

    if (start != 0 && now - start <= Integer.MAX_VALUE) {
      splitsBlock.getProgressWallclockTime().extend(newProgress,
          (int) (now - start));
    }

    Counter cpuCounter = counters.findCounter(TaskCounter.CPU_MILLISECONDS);
    if (cpuCounter != null && cpuCounter.getValue() <= Integer.MAX_VALUE) {
      splitsBlock.getProgressCPUTime().extend(newProgress,
          (int) cpuCounter.getValue()); // long to int? TODO: FIX. Same below
    }

    Counter virtualBytes = counters
      .findCounter(TaskCounter.VIRTUAL_MEMORY_BYTES);
    if (virtualBytes != null) {
      splitsBlock.getProgressVirtualMemoryKbytes().extend(newProgress,
          (int) (virtualBytes.getValue() / (MEMORY_SPLITS_RESOLUTION)));
    }

    Counter physicalBytes = counters
      .findCounter(TaskCounter.PHYSICAL_MEMORY_BYTES);
    if (physicalBytes != null) {
      splitsBlock.getProgressPhysicalMemoryKbytes().extend(newProgress,
          (int) (physicalBytes.getValue() / (MEMORY_SPLITS_RESOLUTION)));
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:39,代码来源:TaskAttemptImpl.java

示例6: equals

import org.apache.hadoop.mapreduce.Counter; //导入方法依赖的package包/类
@Override
public synchronized boolean equals(Object genericRight) {
  if (genericRight instanceof Counter) {
    synchronized (genericRight) {
      Counter right = (Counter) genericRight;
      return getName().equals(right.getName()) &&
             getDisplayName().equals(right.getDisplayName()) &&
             getValue() == right.getValue();
    }
  }
  return false;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:13,代码来源:AbstractCounter.java

示例7: toEscapedCompactString

import org.apache.hadoop.mapreduce.Counter; //导入方法依赖的package包/类
/**
 * Make the pre 0.21 counter string (for e.g. old job history files)
 * [(actual-name)(display-name)(value)]
 * @param counter to stringify
 * @return the stringified result
 */
public static String toEscapedCompactString(Counter counter) {

  // First up, obtain the strings that need escaping. This will help us
  // determine the buffer length apriori.
  String escapedName, escapedDispName;
  long currentValue;
  synchronized(counter) {
    escapedName = escape(counter.getName());
    escapedDispName = escape(counter.getDisplayName());
    currentValue = counter.getValue();
  }
  int length = escapedName.length() + escapedDispName.length() + 4;


  length += 8; // For the following delimiting characters
  StringBuilder builder = new StringBuilder(length);
  builder.append(COUNTER_OPEN);

  // Add the counter name
  builder.append(UNIT_OPEN);
  builder.append(escapedName);
  builder.append(UNIT_CLOSE);

  // Add the display name
  builder.append(UNIT_OPEN);
  builder.append(escapedDispName);
  builder.append(UNIT_CLOSE);

  // Add the value
  builder.append(UNIT_OPEN);
  builder.append(currentValue);
  builder.append(UNIT_CLOSE);

  builder.append(COUNTER_CLOSE);

  return builder.toString();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:44,代码来源:CountersStrings.java

示例8: verify

import org.apache.hadoop.mapreduce.Counter; //导入方法依赖的package包/类
public boolean verify(long expectedReferenced) throws Exception {
  if (job == null) {
    throw new IllegalStateException("You should call run() first");
  }
  
  Counters counters = job.getCounters();
  
  Counter referenced = counters.findCounter(Counts.REFERENCED);
  Counter unreferenced = counters.findCounter(Counts.UNREFERENCED);
  Counter undefined = counters.findCounter(Counts.UNDEFINED);
  
  boolean success = true;
  //assert
  if (expectedReferenced != referenced.getValue()) {
    LOG.error("Expected referenced count does not match with actual referenced count. " +
    		"expected referenced=" + expectedReferenced + " ,actual=" + referenced.getValue());
    success = false;
  }

  if (unreferenced.getValue() > 0) { 
    LOG.error("Unreferenced nodes were not expected. Unreferenced count=" + unreferenced.getValue());
    success = false;
  }
  
  if (undefined.getValue() > 0) { 
    LOG.error("Found an undefined node. Undefined count=" + undefined.getValue());
    success = false;
  }
  
  return success;
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:32,代码来源:Verify.java

示例9: CounterInfo

import org.apache.hadoop.mapreduce.Counter; //导入方法依赖的package包/类
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();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:7,代码来源:CounterInfo.java


注:本文中的org.apache.hadoop.mapreduce.Counter.getValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。