org.apache.hadoop.mapreduce.counters.CounterGroupBase Java Examples

The following examples show how to use org.apache.hadoop.mapreduce.counters.CounterGroupBase. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Counters.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #2
Source File: Counters.java    From big-c with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #3
Source File: Counters.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public void incrAllCounters(CounterGroupBase<Counter> rightGroup) {
  realGroup.incrAllCounters(rightGroup);
}
 
Example #4
Source File: HadoopMapReduceCounterGroup.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public CounterGroupBase<Counter> getUnderlyingGroup() {
    return this;
}
 
Example #5
Source File: HadoopMapReduceCounterGroup.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public void incrAllCounters(CounterGroupBase<Counter> rightGroup) {
    for (final Counter counter : rightGroup)
        cntrs.findCounter(name, counter.getName()).increment(counter.getValue());
}
 
Example #6
Source File: CountersStrings.java    From big-c with Apache License 2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example #7
Source File: CountersStrings.java    From big-c with Apache License 2.0 4 votes vote down vote up
/**
 * 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();
}
 
Example #8
Source File: Counters.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
  return this;
}
 
Example #9
Source File: Counters.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
  return this;
}
 
Example #10
Source File: Counters.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
  return this;
}
 
Example #11
Source File: Counters.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
  return this;
}
 
Example #12
Source File: Counters.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
  return this;
}
 
Example #13
Source File: Counters.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
 return this;
}
 
Example #14
Source File: Counters.java    From big-c with Apache License 2.0 4 votes vote down vote up
static long getCounterValue(CounterGroupBase<Counter> group, String counterName) {
  Counter counter = group.findCounter(counterName, false);
  if (counter != null) return counter.getValue();
  return 0L;
}
 
Example #15
Source File: Counters.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
  return realGroup;
}
 
Example #16
Source File: CountersStrings.java    From hadoop with Apache License 2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example #17
Source File: CountersStrings.java    From hadoop with Apache License 2.0 4 votes vote down vote up
/**
 * 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();
}
 
Example #18
Source File: Counters.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
  return this;
}
 
Example #19
Source File: Counters.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
  return this;
}
 
Example #20
Source File: Counters.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
  return this;
}
 
Example #21
Source File: Counters.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
  return this;
}
 
Example #22
Source File: Counters.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
  return this;
}
 
Example #23
Source File: Counters.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
 return this;
}
 
Example #24
Source File: Counters.java    From hadoop with Apache License 2.0 4 votes vote down vote up
static long getCounterValue(CounterGroupBase<Counter> group, String counterName) {
  Counter counter = group.findCounter(counterName, false);
  if (counter != null) return counter.getValue();
  return 0L;
}
 
Example #25
Source File: Counters.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
  return realGroup;
}
 
Example #26
Source File: Counters.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public void incrAllCounters(CounterGroupBase<Counter> rightGroup) {
  realGroup.incrAllCounters(rightGroup);
}
 
Example #27
Source File: CounterToStatsDConfigurationTest.java    From datawave with Apache License 2.0 4 votes vote down vote up
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
    return null;
}
 
Example #28
Source File: CounterToStatsDConfigurationTest.java    From datawave with Apache License 2.0 2 votes vote down vote up
@Override
public void incrAllCounters(CounterGroupBase<Counter> rightGroup) {
    
}
 
Example #29
Source File: Counters.java    From hadoop with Apache License 2.0 2 votes vote down vote up
/**
 * 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);
}
 
Example #30
Source File: Counters.java    From big-c with Apache License 2.0 2 votes vote down vote up
/**
 * 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);
}