use of org.apache.tez.runtime.api.events.CompositeDataMovementEvent in project tez by apache.
the class Edge method handleCompositeDataMovementEvent.
private void handleCompositeDataMovementEvent(TezEvent tezEvent) throws AMUserCodeException {
CompositeDataMovementEvent compEvent = (CompositeDataMovementEvent) tezEvent.getEvent();
EventMetaData srcInfo = tezEvent.getSourceInfo();
for (DataMovementEvent dmEvent : compEvent.getEvents()) {
TezEvent newEvent = new TezEvent(dmEvent, srcInfo, tezEvent.getEventReceivedTime());
sendTezEventToDestinationTasks(newEvent);
}
}
use of org.apache.tez.runtime.api.events.CompositeDataMovementEvent in project tez by apache.
the class TestShuffleUtils method testGenerateOnSpillEvent_With_All_EmptyPartitions.
@Test
public void testGenerateOnSpillEvent_With_All_EmptyPartitions() throws Exception {
List<Event> events = Lists.newLinkedList();
// Create an index file with all empty partitions
Path indexFile = createIndexFile(10, true);
boolean finalMergeDisabled = false;
boolean isLastEvent = true;
int spillId = 0;
int physicalOutputs = 10;
String pathComponent = "/attempt_x_y_0/file.out";
String auxiliaryService = conf.get(TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID, TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID_DEFAULT);
// normal code path where we do final merge all the time
ShuffleUtils.generateEventOnSpill(events, finalMergeDisabled, isLastEvent, outputContext, spillId, new TezSpillRecord(indexFile, conf), physicalOutputs, true, pathComponent, null, false, auxiliaryService, TezCommonUtils.newBestCompressionDeflater());
// one for VM
Assert.assertTrue(events.size() == 2);
Assert.assertTrue(events.get(0) instanceof VertexManagerEvent);
Assert.assertTrue(events.get(1) instanceof CompositeDataMovementEvent);
CompositeDataMovementEvent cdme = (CompositeDataMovementEvent) events.get(1);
Assert.assertTrue(cdme.getCount() == physicalOutputs);
Assert.assertTrue(cdme.getSourceIndexStart() == 0);
ShuffleUserPayloads.DataMovementEventPayloadProto dmeProto = ShuffleUserPayloads.DataMovementEventPayloadProto.parseFrom(ByteString.copyFrom(cdme.getUserPayload()));
// spill details should be present
Assert.assertTrue(dmeProto.getSpillId() == 0);
Assert.assertTrue(dmeProto.hasLastEvent() && dmeProto.getLastEvent());
Assert.assertTrue(dmeProto.getPathComponent().equals(""));
byte[] emptyPartitions = TezCommonUtils.decompressByteStringToByteArray(dmeProto.getEmptyPartitions());
BitSet emptyPartitionsBitSet = TezUtilsInternal.fromByteArray(emptyPartitions);
Assert.assertTrue("emptyPartitionBitSet cardinality (expecting 10) = " + emptyPartitionsBitSet.cardinality(), emptyPartitionsBitSet.cardinality() == 10);
}
use of org.apache.tez.runtime.api.events.CompositeDataMovementEvent in project tez by apache.
the class TestShuffleUtils method testGenerateOnSpillEvent.
@Test
public void testGenerateOnSpillEvent() throws Exception {
List<Event> events = Lists.newLinkedList();
Path indexFile = createIndexFile(10, false);
boolean finalMergeEnabled = false;
boolean isLastEvent = false;
int spillId = 0;
int physicalOutputs = 10;
String pathComponent = "/attempt_x_y_0/file.out";
String auxiliaryService = conf.get(TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID, TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID_DEFAULT);
ShuffleUtils.generateEventOnSpill(events, finalMergeEnabled, isLastEvent, outputContext, spillId, new TezSpillRecord(indexFile, conf), physicalOutputs, true, pathComponent, null, false, auxiliaryService, TezCommonUtils.newBestCompressionDeflater());
Assert.assertTrue(events.size() == 1);
Assert.assertTrue(events.get(0) instanceof CompositeDataMovementEvent);
CompositeDataMovementEvent cdme = (CompositeDataMovementEvent) events.get(0);
Assert.assertTrue(cdme.getCount() == physicalOutputs);
Assert.assertTrue(cdme.getSourceIndexStart() == 0);
ByteBuffer payload = cdme.getUserPayload();
ShuffleUserPayloads.DataMovementEventPayloadProto dmeProto = ShuffleUserPayloads.DataMovementEventPayloadProto.parseFrom(ByteString.copyFrom(payload));
Assert.assertTrue(dmeProto.getSpillId() == 0);
Assert.assertTrue(dmeProto.hasLastEvent() && !dmeProto.getLastEvent());
byte[] emptyPartitions = TezCommonUtils.decompressByteStringToByteArray(dmeProto.getEmptyPartitions());
BitSet emptyPartitionsBitSet = TezUtilsInternal.fromByteArray(emptyPartitions);
Assert.assertTrue("emptyPartitionBitSet cardinality (expecting 5) = " + emptyPartitionsBitSet.cardinality(), emptyPartitionsBitSet.cardinality() == 5);
events.clear();
}
use of org.apache.tez.runtime.api.events.CompositeDataMovementEvent in project tez by apache.
the class TestDefaultSorter method testEmptyCaseFileLengthsHelper.
public void testEmptyCaseFileLengthsHelper(int numPartitions, int numKeys, int keyLen, int expectedEmptyPartitions) throws IOException {
OutputContext context = createTezOutputContext();
MemoryUpdateCallbackHandler handler = new MemoryUpdateCallbackHandler();
conf.setInt(TezRuntimeConfiguration.TEZ_RUNTIME_IO_SORT_MB, 1);
context.requestInitialMemory(ExternalSorter.getInitialMemoryRequirement(conf, context.getTotalMemoryAvailableToTask()), handler);
String auxService = conf.get(TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID, TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID_DEFAULT);
DefaultSorter sorter = new DefaultSorter(context, conf, numPartitions, handler.getMemoryAssigned());
try {
writeData(sorter, numKeys, keyLen);
List<Event> events = new ArrayList<Event>();
String pathComponent = (context.getUniqueIdentifier() + "_" + 0);
ShuffleUtils.generateEventOnSpill(events, true, true, context, 0, sorter.indexCacheList.get(0), 0, true, pathComponent, sorter.getPartitionStats(), sorter.reportDetailedPartitionStats(), auxService, TezCommonUtils.newBestCompressionDeflater());
CompositeDataMovementEvent compositeDataMovementEvent = (CompositeDataMovementEvent) events.get(1);
ByteBuffer bb = compositeDataMovementEvent.getUserPayload();
ShuffleUserPayloads.DataMovementEventPayloadProto shufflePayload = ShuffleUserPayloads.DataMovementEventPayloadProto.parseFrom(ByteString.copyFrom(bb));
if (shufflePayload.hasEmptyPartitions()) {
byte[] emptyPartitionsBytesString = TezCommonUtils.decompressByteStringToByteArray(shufflePayload.getEmptyPartitions());
BitSet emptyPartitionBitSet = TezUtilsInternal.fromByteArray(emptyPartitionsBytesString);
Assert.assertTrue("Number of empty partitions did not match!", emptyPartitionBitSet.cardinality() == expectedEmptyPartitions);
} else {
Assert.assertTrue(expectedEmptyPartitions == 0);
}
// 4 bytes of header + numKeys* 2 *(keydata.length + keyLength.length) + 2 * 1 byte of EOF_MARKER + 4 bytes of checksum
assertEquals("Unexpected Output File Size!", localFs.getFileStatus(sorter.getFinalOutputFile()).getLen(), numKeys * (4 + (2 * (2 + keyLen)) + 2 + 4));
assertTrue(sorter.getNumSpills() == 1);
verifyCounters(sorter, context);
} catch (IOException ioe) {
fail(ioe.getMessage());
}
}
use of org.apache.tez.runtime.api.events.CompositeDataMovementEvent in project tez by apache.
the class TestDefaultSorter method testWithSingleSpillWithFinalMergeDisabled.
@Test(timeout = 60000)
@SuppressWarnings("unchecked")
public void testWithSingleSpillWithFinalMergeDisabled() throws IOException {
OutputContext context = createTezOutputContext();
conf.setBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_ENABLE_FINAL_MERGE_IN_OUTPUT, false);
conf.setLong(TezRuntimeConfiguration.TEZ_RUNTIME_IO_SORT_MB, 4);
MemoryUpdateCallbackHandler handler = new MemoryUpdateCallbackHandler();
context.requestInitialMemory(ExternalSorter.getInitialMemoryRequirement(conf, context.getTotalMemoryAvailableToTask()), handler);
DefaultSorter sorter = new DefaultSorter(context, conf, 1, handler.getMemoryAssigned());
writeData(sorter, 1000, 10);
assertTrue(sorter.getNumSpills() == 1);
ArgumentCaptor<List> eventCaptor = ArgumentCaptor.forClass(List.class);
verify(context, times(1)).sendEvents(eventCaptor.capture());
List<Event> events = eventCaptor.getValue();
for (Event event : events) {
if (event instanceof CompositeDataMovementEvent) {
CompositeDataMovementEvent cdme = (CompositeDataMovementEvent) event;
ShuffleUserPayloads.DataMovementEventPayloadProto shufflePayload = ShuffleUserPayloads.DataMovementEventPayloadProto.parseFrom(ByteString.copyFrom(cdme.getUserPayload()));
assertTrue(shufflePayload.getPathComponent().equalsIgnoreCase(UniqueID + "_0"));
verifyOutputPermissions(shufflePayload.getPathComponent());
}
}
verifyCounters(sorter, context);
}
Aggregations