private String summary(String scheme, String vertexName, TezCounters vertexCounters) { final String counterGroup = FileSystemCounter.class.getName(); final long bytesRead = getCounterValueByGroupName(vertexCounters, counterGroup, scheme + "_" + FileSystemCounter.BYTES_READ.name()); final long bytesWritten = getCounterValueByGroupName(vertexCounters, counterGroup, scheme + "_" + FileSystemCounter.BYTES_WRITTEN.name()); final long readOps = getCounterValueByGroupName(vertexCounters, counterGroup, scheme + "_" + FileSystemCounter.READ_OPS.name()); final long largeReadOps = getCounterValueByGroupName(vertexCounters, counterGroup, scheme + "_" + FileSystemCounter.LARGE_READ_OPS.name()); final long writeOps = getCounterValueByGroupName(vertexCounters, counterGroup, scheme + "_" + FileSystemCounter.WRITE_OPS.name()); return String.format(FORMATTING_PATTERN, vertexName, Utilities.humanReadableByteCount(bytesRead), readOps, largeReadOps, Utilities.humanReadableByteCount(bytesWritten), writeOps); }
@SuppressWarnings("unchecked") public synchronized C findCounter(String scheme, FileSystemCounter key) { final String canonicalScheme = checkScheme(scheme); Object[] counters = map.get(canonicalScheme); int ord = key.ordinal(); if (counters == null) { counters = new Object[FileSystemCounter.values().length]; map.put(canonicalScheme, counters); counters[ord] = newCounter(canonicalScheme, key); } else if (counters[ord] == null) { counters[ord] = newCounter(canonicalScheme, key); } return (C) counters[ord]; }
@Override public C findCounter(String counterName, boolean create) { try { String[] pair = parseCounterName(counterName); return findCounter(pair[0], FileSystemCounter.valueOf(pair[1])); } catch (Exception e) { if (create) throw new IllegalArgumentException(e); return null; } }
/** * FileSystemGroup ::= #scheme (scheme #counter (key value)*)* */ @Override public void write(DataOutput out) throws IOException { WritableUtils.writeVInt(out, map.size()); // #scheme for (Map.Entry<String, Object[]> entry : map.entrySet()) { WritableUtils.writeString(out, entry.getKey()); // scheme // #counter for the above scheme WritableUtils.writeVInt(out, numSetCounters(entry.getValue())); for (Object counter : entry.getValue()) { if (counter == null) continue; FSCounter c = (FSCounter) ((TezCounter)counter).getUnderlyingCounter(); WritableUtils.writeVInt(out, c.key.ordinal()); // key WritableUtils.writeVLong(out, c.getValue()); // value } } }
@Override public void readFields(DataInput in) throws IOException { int numSchemes = WritableUtils.readVInt(in); // #scheme FileSystemCounter[] enums = FileSystemCounter.values(); for (int i = 0; i < numSchemes; ++i) { String scheme = WritableUtils.readString(in); // scheme int numCounters = WritableUtils.readVInt(in); // #counter for (int j = 0; j < numCounters; ++j) { findCounter(scheme, enums[WritableUtils.readVInt(in)]) // key .setValue(WritableUtils.readVLong(in)); // value } } }
private String summary(String scheme, String vertexName, TezCounters vertexCounters) { final String counterGroup = FileSystemCounter.class.getName(); final long bytesRead = getCounterValueByGroupName(vertexCounters, counterGroup, scheme + "_" + FileSystemCounter.BYTES_READ.name()); final long bytesWritten = getCounterValueByGroupName(vertexCounters, counterGroup, scheme + "_" + FileSystemCounter.BYTES_WRITTEN.name()); final long readOps = getCounterValueByGroupName(vertexCounters, counterGroup, scheme + "_" + FileSystemCounter.READ_OPS.name()); final long largeReadOps = getCounterValueByGroupName(vertexCounters, counterGroup, scheme + "_" + FileSystemCounter.LARGE_READ_OPS.name()); final long writeOps = getCounterValueByGroupName(vertexCounters, counterGroup, scheme + "_" + FileSystemCounter.WRITE_OPS.name()); return String.format(FORMATTING_PATTERN, vertexName, Utilities.humanReadableByteCount(bytesRead), readOps, largeReadOps, Utilities.humanReadableByteCount(bytesWritten), writeOps); }
@Override public String getName() { return NAME_JOINER.join(scheme, key.name()); }