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


Java Group类代码示例

本文整理汇总了Java中org.apache.hadoop.mapred.Counters.Group的典型用法代码示例。如果您正苦于以下问题:Java Group类的具体用法?Java Group怎么用?Java Group使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testFileSystemGroupIteratorConcurrency

import org.apache.hadoop.mapred.Counters.Group; //导入依赖的package包/类
@Test
public void testFileSystemGroupIteratorConcurrency() {
  Counters counters = new Counters();
  // create 2 filesystem counter groups
  counters.findCounter("fs1", FileSystemCounter.BYTES_READ).increment(1);
  counters.findCounter("fs2", FileSystemCounter.BYTES_READ).increment(1);
  
  // Iterate over the counters in this group while updating counters in
  // the group
  Group group = counters.getGroup(FileSystemCounter.class.getName());
  Iterator<Counter> iterator = group.iterator();
  counters.findCounter("fs3", FileSystemCounter.BYTES_READ).increment(1);
  assertTrue(iterator.hasNext());
  iterator.next();
  counters.findCounter("fs3", FileSystemCounter.BYTES_READ).increment(1);
  assertTrue(iterator.hasNext());
  iterator.next();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TestCounters.java

示例2: testFrameworkCounter

import org.apache.hadoop.mapred.Counters.Group; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Test
public void testFrameworkCounter() {
  GroupFactory groupFactory = new GroupFactoryForTest();
  FrameworkGroupFactory frameworkGroupFactory = 
      groupFactory.newFrameworkGroupFactory(JobCounter.class);
  Group group = (Group) frameworkGroupFactory.newGroup("JobCounter");
  
  FrameworkCounterGroup counterGroup = 
      (FrameworkCounterGroup) group.getUnderlyingGroup();

  org.apache.hadoop.mapreduce.Counter count1 = 
      counterGroup.findCounter(JobCounter.NUM_FAILED_MAPS.toString());
  Assert.assertNotNull(count1);
  
  // Verify no exception get thrown when finding an unknown counter
  org.apache.hadoop.mapreduce.Counter count2 = 
      counterGroup.findCounter("Unknown");
  Assert.assertNull(count2);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:TestCounters.java

示例3: toJson

import org.apache.hadoop.mapred.Counters.Group; //导入依赖的package包/类
/**
 * Converts Hadoop counters to a JSON representation.
 *
 * @param counters the Hadoop counters to convert
 * @return the JSON representation of the given counters
 *
 * @throws SerializationException if mapping the counters to JSON fails
 */
@VisibleForTesting
static String toJson(Counters counters) throws SerializationException {
  ArrayNode countersJsonNode = JsonNodeFactory.instance.arrayNode();

  ArrayNode groupsJsonNode = JsonNodeFactory.instance.arrayNode();
  for (Group group: counters) {
    for (Counters.Counter counter: group) {
      ObjectNode counterJsonNode = JsonNodeFactory.instance.objectNode();
      counterJsonNode.put("counterName", counter.getName())
                     .put("value", counter.getValue());
      countersJsonNode.add(counterJsonNode);
    }
    ObjectNode groupJsonNode = JsonNodeFactory.instance.objectNode();
    groupJsonNode.put("groupName", group.getDisplayName())
                 .put("counters", countersJsonNode);
    groupsJsonNode.add(groupJsonNode);
  }

  ObjectMapper mapper = new ObjectMapper();
  try {
    return mapper.writeValueAsString(groupsJsonNode);
  } catch (JsonProcessingException e) {
    throw new SerializationException(e);
  }
}
 
开发者ID:airbnb,项目名称:reair,代码行数:34,代码来源:MapRedStatsLogModule.java

示例4: countersToJson

import org.apache.hadoop.mapred.Counters.Group; //导入依赖的package包/类
public static Object countersToJson(Counters counters) {
  Map<String, Object> jsonObj = new HashMap<String, Object>();

  if (counters == null) {
    return jsonObj;
  }

  Collection<String> counterGroups = counters.getGroupNames();
  for (String groupName : counterGroups) {
    Map<String, String> counterStats = new HashMap<String, String>();
    Group group = counters.getGroup(groupName);
    Iterator<Counters.Counter> it = group.iterator();
    while (it.hasNext()) {
      Counter counter = it.next();
      counterStats.put(counter.getDisplayName(),
          String.valueOf(counter.getCounter()));
    }
    jsonObj.put(groupName, counterStats);
  }
  return jsonObj;
}
 
开发者ID:azkaban,项目名称:azkaban-plugins,代码行数:22,代码来源:StatsUtils.java

示例5: getCounter

import org.apache.hadoop.mapred.Counters.Group; //导入依赖的package包/类
public Counters.Counter getCounter(String group, String name) {
  Counters.Counter counter = null;
  if (counters != null) {
    counter = counters.findCounter(group, name);
    if (counter == null) {
      Group grp = counters.addGroup(group, group);
      counter = grp.addCounter(name, name, 10);
    }
  }
  return counter;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:TestPipeApplication.java

示例6: testCounterIteratorConcurrency

import org.apache.hadoop.mapred.Counters.Group; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Test
public void testCounterIteratorConcurrency() {
  Counters counters = new Counters();
  counters.incrCounter("group1", "counter1", 1);
  Iterator<Group> iterator = counters.iterator();
  counters.incrCounter("group2", "counter2", 1);
  iterator.next();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:10,代码来源:TestCounters.java

示例7: testGroupIteratorConcurrency

import org.apache.hadoop.mapred.Counters.Group; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Test
public void testGroupIteratorConcurrency() {
  Counters counters = new Counters();
  counters.incrCounter("group1", "counter1", 1);
  Group group = counters.getGroup("group1");
  Iterator<Counter> iterator = group.iterator();
  counters.incrCounter("group1", "counter2", 1);
  iterator.next();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:TestCounters.java

示例8: testFilesystemCounter

import org.apache.hadoop.mapred.Counters.Group; //导入依赖的package包/类
@Test
public void testFilesystemCounter() {
  GroupFactory groupFactory = new GroupFactoryForTest();
  Group fsGroup = groupFactory.newFileSystemGroup();

  org.apache.hadoop.mapreduce.Counter count1 = 
      fsGroup.findCounter("ANY_BYTES_READ");
  Assert.assertNotNull(count1);
  
  // Verify no exception get thrown when finding an unknown counter
  org.apache.hadoop.mapreduce.Counter count2 = 
      fsGroup.findCounter("Unknown");
  Assert.assertNull(count2);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:TestCounters.java

示例9: validateCounters

import org.apache.hadoop.mapred.Counters.Group; //导入依赖的package包/类
private void validateCounters() throws IOException {
  Counters counters = job.running_.getCounters();
  assertNotNull("Counters", counters);
  Group group = counters.getGroup("UserCounters");
  assertNotNull("Group", group);
  Counter counter = group.getCounterForName("InputLines");
  assertNotNull("Counter", counter);
  assertEquals(3, counter.getCounter());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:10,代码来源:TestStreamingCounters.java


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