final String errMsg = "Failed to load JobCounter.conf"; LOG.error(errMsg); throw new JobCounterException(errMsg); final String errMsg = "Failed to load JobCounter.conf, reason: " + ex.getMessage(); LOG.error(errMsg, ex); throw new JobCounterException(errMsg, ex);
private CounterGroupKey getCounterGroup(String groupName) throws JobCounterException { if (dictionary == null) { dictionary = CounterGroupDictionary.getInstance(); } final CounterGroupKey groupKey = dictionary.getCounterGroupByName(groupName); if (groupKey == null) { throw new JobCounterException("Invalid counter group name: " + groupName); } return groupKey; }
private int serializeGroup(byte[] buffer, int currentPos, String groupName, Map<String, Long> counterMap) throws JobCounterException { int pos = currentPos; final CounterGroupKey groupKey = getCounterGroup(groupName); if (groupKey == null) { throw new JobCounterException("Group name " + groupName + " is not defined"); } Bytes.putInt(buffer, pos, groupKey.getIndex()); pos += 4; int totalCounterNumberPos = pos; pos += 4; int totalCounters = 0; for (Map.Entry<String, Long> entry : counterMap.entrySet()) { final String counterName = entry.getKey(); final CounterKey counterKey = groupKey.getCounterKeyByName(counterName); if (counterKey == null) { continue; } final Long counterValue = entry.getValue(); Bytes.putInt(buffer, pos, counterKey.getIndex()); pos += 4; Bytes.putLong(buffer, pos, counterValue); pos += 8; ++totalCounters; } Bytes.putInt(buffer, totalCounterNumberPos, totalCounters); return pos; }
final CounterGroupKey groupKey = getCounterGroup(groupIndex); if (groupKey == null) { throw new JobCounterException("Group index " + groupIndex + " is not defined");