Search in sources :

Example 1 with ShuffleReadCounter

use of org.apache.beam.runners.dataflow.worker.util.common.worker.ShuffleReadCounter in project beam by apache.

the class GroupingShuffleReaderTest method expectShuffleReadCounterEquals.

private void expectShuffleReadCounterEquals(TestShuffleReadCounterFactory factory, Map<String, Long> expectedReadBytesForOriginal) {
    ShuffleReadCounter src = factory.getOnlyShuffleReadCounterOrNull();
    assertNotNull(src);
    // should not be set.
    if (src.legacyPerOperationPerDatasetBytesCounter != null) {
        assertEquals(0, (long) src.legacyPerOperationPerDatasetBytesCounter.getAggregate());
    }
    // Verify that each executing step used when reading from the GroupingShuffleReader
    // has a counter with a bytes read value.
    assertEquals(expectedReadBytesForOriginal.size(), (long) src.counterSet.size());
    Iterator it = expectedReadBytesForOriginal.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry<String, Long> pair = (Map.Entry) it.next();
        Counter counter = src.counterSet.getExistingCounter(ShuffleReadCounter.generateCounterName(ORIGINAL_SHUFFLE_STEP_NAME, pair.getKey()));
        assertEquals(pair.getValue(), counter.getAggregate());
    }
}
Also used : ShuffleEntry(org.apache.beam.runners.dataflow.worker.util.common.worker.ShuffleEntry) ShuffleReadCounter(org.apache.beam.runners.dataflow.worker.util.common.worker.ShuffleReadCounter) ShuffleReadCounter(org.apache.beam.runners.dataflow.worker.util.common.worker.ShuffleReadCounter) Counter(org.apache.beam.runners.dataflow.worker.counters.Counter) GroupingShuffleReaderIterator(org.apache.beam.runners.dataflow.worker.GroupingShuffleReader.GroupingShuffleReaderIterator) Iterator(java.util.Iterator) Base64.encodeBase64URLSafeString(com.google.api.client.util.Base64.encodeBase64URLSafeString) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with ShuffleReadCounter

use of org.apache.beam.runners.dataflow.worker.util.common.worker.ShuffleReadCounter in project beam by apache.

the class TestShuffleReadCounterFactory method create.

@Override
public ShuffleReadCounter create(String originalShuffleStepName, boolean experimentEnabled, Counter<Long, Long> legacyPerOperationPerDatasetBytesCounter) {
    ShuffleReadCounter src = new ShuffleReadCounter(originalShuffleStepName, experimentEnabled, legacyPerOperationPerDatasetBytesCounter);
    originalShuffleStepToCounter.put(originalShuffleStepName, src);
    return src;
}
Also used : ShuffleReadCounter(org.apache.beam.runners.dataflow.worker.util.common.worker.ShuffleReadCounter)

Aggregations

ShuffleReadCounter (org.apache.beam.runners.dataflow.worker.util.common.worker.ShuffleReadCounter)2 Base64.encodeBase64URLSafeString (com.google.api.client.util.Base64.encodeBase64URLSafeString)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 GroupingShuffleReaderIterator (org.apache.beam.runners.dataflow.worker.GroupingShuffleReader.GroupingShuffleReaderIterator)1 Counter (org.apache.beam.runners.dataflow.worker.counters.Counter)1 ShuffleEntry (org.apache.beam.runners.dataflow.worker.util.common.worker.ShuffleEntry)1