类org.apache.hadoop.mapreduce.counters.CounterGroupBase源码实例Demo

下面列出了怎么用org.apache.hadoop.mapreduce.counters.CounterGroupBase的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: hadoop   文件: Counters.java
@Override
public synchronized boolean equals(Object genericRight) {
  if (genericRight instanceof CounterGroupBase<?>) {
    @SuppressWarnings("unchecked")
    CounterGroupBase<Counter> right = ((CounterGroupBase<Counter>) 
    genericRight).getUnderlyingGroup();
    return Iterators.elementsEqual(iterator(), right.iterator());
  }
  return false;
}
 
源代码2 项目: big-c   文件: Counters.java
@Override
public synchronized boolean equals(Object genericRight) {
  if (genericRight instanceof CounterGroupBase<?>) {
    @SuppressWarnings("unchecked")
    CounterGroupBase<Counter> right = ((CounterGroupBase<Counter>) 
    genericRight).getUnderlyingGroup();
    return Iterators.elementsEqual(iterator(), right.iterator());
  }
  return false;
}
 
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
    return null;
}
 
源代码4 项目: hadoop   文件: Counters.java
@Override
public void incrAllCounters(CounterGroupBase<Counter> rightGroup) {
  realGroup.incrAllCounters(rightGroup);
}
 
源代码5 项目: hadoop   文件: Counters.java
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
  return realGroup;
}
 
源代码6 项目: hadoop   文件: Counters.java
static long getCounterValue(CounterGroupBase<Counter> group, String counterName) {
  Counter counter = group.findCounter(counterName, false);
  if (counter != null) return counter.getValue();
  return 0L;
}
 
源代码7 项目: hadoop   文件: Counters.java
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
 return this;
}
 
源代码8 项目: hadoop   文件: Counters.java
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
  return this;
}
 
源代码9 项目: hadoop   文件: Counters.java
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
  return this;
}
 
源代码10 项目: hadoop   文件: Counters.java
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
  return this;
}
 
源代码11 项目: hadoop   文件: Counters.java
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
  return this;
}
 
源代码12 项目: hadoop   文件: Counters.java
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
  return this;
}
 
源代码13 项目: hadoop   文件: CountersStrings.java
/**
 * Make the 0.21 counter group string.
 * format: {(actual-name)(display-name)(value)[][][]}
 * where [] are compact strings for the counters within.
 * @param <G> type of the group
 * @param group to stringify
 * @return the stringified result
 */
public static <G extends CounterGroupBase<?>>
String toEscapedCompactString(G group) {
  List<String> escapedStrs = Lists.newArrayList();
  int length;
  String escapedName, escapedDispName;
  synchronized(group) {
    // First up, obtain the strings that need escaping. This will help us
    // determine the buffer length apriori.
    escapedName = escape(group.getName());
    escapedDispName = escape(group.getDisplayName());
    int i = 0;
    length = escapedName.length() + escapedDispName.length();
    for (Counter counter : group) {
      String escapedStr = toEscapedCompactString(counter);
      escapedStrs.add(escapedStr);
      length += escapedStr.length();
    }
  }
  length += 6; // for all the delimiting characters below
  StringBuilder builder = new StringBuilder(length);
  builder.append(GROUP_OPEN); // group start

  // Add the group 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);

  // write the value
  for(String escaped : escapedStrs) {
    builder.append(escaped);
  }

  builder.append(GROUP_CLOSE); // group end
  return builder.toString();
}
 
源代码14 项目: hadoop   文件: CountersStrings.java
/**
 * Parse a pre 0.21 counters string into a counter object.
 * @param <C> type of the counter
 * @param <G> type of the counter group
 * @param <T> type of the counters object
 * @param compactString to parse
 * @param counters an empty counters object to hold the result
 * @return the counters object holding the result
 * @throws ParseException
 */
@SuppressWarnings("deprecation")
public static <C extends Counter, G extends CounterGroupBase<C>,
               T extends AbstractCounters<C, G>>
T parseEscapedCompactString(String compactString, T counters)
    throws ParseException {
  IntWritable index = new IntWritable(0);

  // Get the group to work on
  String groupString =
    getBlock(compactString, GROUP_OPEN, GROUP_CLOSE, index);

  while (groupString != null) {
    IntWritable groupIndex = new IntWritable(0);

    // Get the actual name
    String groupName =
        StringInterner.weakIntern(getBlock(groupString, UNIT_OPEN, UNIT_CLOSE, groupIndex));
    groupName = StringInterner.weakIntern(unescape(groupName));

    // Get the display name
    String groupDisplayName =
        StringInterner.weakIntern(getBlock(groupString, UNIT_OPEN, UNIT_CLOSE, groupIndex));
    groupDisplayName = StringInterner.weakIntern(unescape(groupDisplayName));

    // Get the counters
    G group = counters.getGroup(groupName);
    group.setDisplayName(groupDisplayName);

    String counterString =
      getBlock(groupString, COUNTER_OPEN, COUNTER_CLOSE, groupIndex);

    while (counterString != null) {
      IntWritable counterIndex = new IntWritable(0);

      // Get the actual name
      String counterName =
          StringInterner.weakIntern(getBlock(counterString, UNIT_OPEN, UNIT_CLOSE, counterIndex));
      counterName = StringInterner.weakIntern(unescape(counterName));

      // Get the display name
      String counterDisplayName =
          StringInterner.weakIntern(getBlock(counterString, UNIT_OPEN, UNIT_CLOSE, counterIndex));
      counterDisplayName = StringInterner.weakIntern(unescape(counterDisplayName));

      // Get the value
      long value =
        Long.parseLong(getBlock(counterString, UNIT_OPEN, UNIT_CLOSE,
                                counterIndex));

      // Add the counter
      Counter counter = group.findCounter(counterName);
      counter.setDisplayName(counterDisplayName);
      counter.increment(value);

      // Get the next counter
      counterString =
        getBlock(groupString, COUNTER_OPEN, COUNTER_CLOSE, groupIndex);
    }

    groupString = getBlock(compactString, GROUP_OPEN, GROUP_CLOSE, index);
  }
  return counters;
}
 
源代码15 项目: big-c   文件: Counters.java
@Override
public void incrAllCounters(CounterGroupBase<Counter> rightGroup) {
  realGroup.incrAllCounters(rightGroup);
}
 
源代码16 项目: big-c   文件: Counters.java
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
  return realGroup;
}
 
源代码17 项目: big-c   文件: Counters.java
static long getCounterValue(CounterGroupBase<Counter> group, String counterName) {
  Counter counter = group.findCounter(counterName, false);
  if (counter != null) return counter.getValue();
  return 0L;
}
 
源代码18 项目: big-c   文件: Counters.java
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
 return this;
}
 
源代码19 项目: big-c   文件: Counters.java
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
  return this;
}
 
源代码20 项目: big-c   文件: Counters.java
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
  return this;
}
 
源代码21 项目: big-c   文件: Counters.java
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
  return this;
}
 
源代码22 项目: big-c   文件: Counters.java
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
  return this;
}
 
源代码23 项目: big-c   文件: Counters.java
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
  return this;
}
 
源代码24 项目: big-c   文件: CountersStrings.java
/**
 * Make the 0.21 counter group string.
 * format: {(actual-name)(display-name)(value)[][][]}
 * where [] are compact strings for the counters within.
 * @param <G> type of the group
 * @param group to stringify
 * @return the stringified result
 */
public static <G extends CounterGroupBase<?>>
String toEscapedCompactString(G group) {
  List<String> escapedStrs = Lists.newArrayList();
  int length;
  String escapedName, escapedDispName;
  synchronized(group) {
    // First up, obtain the strings that need escaping. This will help us
    // determine the buffer length apriori.
    escapedName = escape(group.getName());
    escapedDispName = escape(group.getDisplayName());
    int i = 0;
    length = escapedName.length() + escapedDispName.length();
    for (Counter counter : group) {
      String escapedStr = toEscapedCompactString(counter);
      escapedStrs.add(escapedStr);
      length += escapedStr.length();
    }
  }
  length += 6; // for all the delimiting characters below
  StringBuilder builder = new StringBuilder(length);
  builder.append(GROUP_OPEN); // group start

  // Add the group 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);

  // write the value
  for(String escaped : escapedStrs) {
    builder.append(escaped);
  }

  builder.append(GROUP_CLOSE); // group end
  return builder.toString();
}
 
源代码25 项目: big-c   文件: CountersStrings.java
/**
 * Parse a pre 0.21 counters string into a counter object.
 * @param <C> type of the counter
 * @param <G> type of the counter group
 * @param <T> type of the counters object
 * @param compactString to parse
 * @param counters an empty counters object to hold the result
 * @return the counters object holding the result
 * @throws ParseException
 */
@SuppressWarnings("deprecation")
public static <C extends Counter, G extends CounterGroupBase<C>,
               T extends AbstractCounters<C, G>>
T parseEscapedCompactString(String compactString, T counters)
    throws ParseException {
  IntWritable index = new IntWritable(0);

  // Get the group to work on
  String groupString =
    getBlock(compactString, GROUP_OPEN, GROUP_CLOSE, index);

  while (groupString != null) {
    IntWritable groupIndex = new IntWritable(0);

    // Get the actual name
    String groupName =
        StringInterner.weakIntern(getBlock(groupString, UNIT_OPEN, UNIT_CLOSE, groupIndex));
    groupName = StringInterner.weakIntern(unescape(groupName));

    // Get the display name
    String groupDisplayName =
        StringInterner.weakIntern(getBlock(groupString, UNIT_OPEN, UNIT_CLOSE, groupIndex));
    groupDisplayName = StringInterner.weakIntern(unescape(groupDisplayName));

    // Get the counters
    G group = counters.getGroup(groupName);
    group.setDisplayName(groupDisplayName);

    String counterString =
      getBlock(groupString, COUNTER_OPEN, COUNTER_CLOSE, groupIndex);

    while (counterString != null) {
      IntWritable counterIndex = new IntWritable(0);

      // Get the actual name
      String counterName =
          StringInterner.weakIntern(getBlock(counterString, UNIT_OPEN, UNIT_CLOSE, counterIndex));
      counterName = StringInterner.weakIntern(unescape(counterName));

      // Get the display name
      String counterDisplayName =
          StringInterner.weakIntern(getBlock(counterString, UNIT_OPEN, UNIT_CLOSE, counterIndex));
      counterDisplayName = StringInterner.weakIntern(unescape(counterDisplayName));

      // Get the value
      long value =
        Long.parseLong(getBlock(counterString, UNIT_OPEN, UNIT_CLOSE,
                                counterIndex));

      // Add the counter
      Counter counter = group.findCounter(counterName);
      counter.setDisplayName(counterDisplayName);
      counter.increment(value);

      // Get the next counter
      counterString =
        getBlock(groupString, COUNTER_OPEN, COUNTER_CLOSE, groupIndex);
    }

    groupString = getBlock(compactString, GROUP_OPEN, GROUP_CLOSE, index);
  }
  return counters;
}
 
源代码26 项目: ignite   文件: HadoopMapReduceCounterGroup.java
/** {@inheritDoc} */
@Override public void incrAllCounters(CounterGroupBase<Counter> rightGroup) {
    for (final Counter counter : rightGroup)
        cntrs.findCounter(name, counter.getName()).increment(counter.getValue());
}
 
源代码27 项目: ignite   文件: HadoopMapReduceCounterGroup.java
/** {@inheritDoc} */
@Override public CounterGroupBase<Counter> getUnderlyingGroup() {
    return this;
}
 
@Override
public void incrAllCounters(CounterGroupBase<Counter> rightGroup) {
    
}
 
源代码29 项目: hadoop   文件: Counters.java
/**
 * Construct the Counters object from the another counters object
 * @param <C> the type of counter
 * @param <G> the type of counter group
 * @param counters the old counters object
 */
public <C extends Counter, G extends CounterGroupBase<C>>
Counters(AbstractCounters<C, G> counters) {
  super(counters, groupFactory);
}
 
源代码30 项目: big-c   文件: Counters.java
/**
 * Construct the Counters object from the another counters object
 * @param <C> the type of counter
 * @param <G> the type of counter group
 * @param counters the old counters object
 */
public <C extends Counter, G extends CounterGroupBase<C>>
Counters(AbstractCounters<C, G> counters) {
  super(counters, groupFactory);
}
 
 类方法
 同包方法