use of org.apache.tez.runtime.api.OutputContext in project tez by apache.
the class TestOnFileSortedOutput method testPipelinedSettingsWithDefaultSorter.
@Test
public void testPipelinedSettingsWithDefaultSorter() throws Exception {
conf.setInt(TezRuntimeConfiguration.TEZ_RUNTIME_IO_SORT_MB, 3);
// negative. with default sorter
conf.set(TezRuntimeConfiguration.TEZ_RUNTIME_SORTER_CLASS, SorterImpl.LEGACY.name());
conf.setBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_ENABLE_FINAL_MERGE_IN_OUTPUT, false);
conf.setBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_PIPELINED_SHUFFLE_ENABLED, true);
OutputContext context = createTezOutputContext();
UserPayload payLoad = TezUtils.createUserPayloadFromConf(conf);
doReturn(payLoad).when(context).getUserPayload();
sortedOutput = new OrderedPartitionedKVOutput(context, partitions);
sortedOutput.initialize();
try {
sortedOutput.start();
fail("Should have thrown illegal argument exception as pipelining is enabled with " + "DefaultSorter");
} catch (IllegalArgumentException ie) {
assertTrue(ie.getMessage().contains("works with PipelinedSorter"));
}
}
use of org.apache.tez.runtime.api.OutputContext in project tez by apache.
the class TestOnFileSortedOutput method testPipelinedShuffleWithFinalMerge.
@Test(timeout = 5000)
public void testPipelinedShuffleWithFinalMerge() throws Exception {
conf.setInt(TezRuntimeConfiguration.TEZ_RUNTIME_IO_SORT_MB, 3);
conf.set(TezRuntimeConfiguration.TEZ_RUNTIME_SORTER_CLASS, SorterImpl.PIPELINED.name());
// wrong setting for final merge enable in output
conf.setBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_ENABLE_FINAL_MERGE_IN_OUTPUT, true);
conf.setBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_PIPELINED_SHUFFLE_ENABLED, true);
OutputContext context = createTezOutputContext();
UserPayload payLoad = TezUtils.createUserPayloadFromConf(conf);
doReturn(payLoad).when(context).getUserPayload();
sortedOutput = new OrderedPartitionedKVOutput(context, partitions);
sortedOutput.initialize();
sortedOutput.start();
// should be disabled as pipelining is on
assertFalse(sortedOutput.finalMergeEnabled);
assertTrue(sortedOutput.pipelinedShuffle);
}
use of org.apache.tez.runtime.api.OutputContext in project tez by apache.
the class TestOrderedPartitionedKVOutput2 method testNonStartedOutput.
@Test(timeout = 5000)
public void testNonStartedOutput() throws IOException {
OutputContext outputContext = OutputTestHelpers.createOutputContext(conf, workingDir);
int numPartitions = 10;
OrderedPartitionedKVOutput output = new OrderedPartitionedKVOutput(outputContext, numPartitions);
output.initialize();
List<Event> events = output.close();
assertEquals(2, events.size());
Event event1 = events.get(0);
assertTrue(event1 instanceof VertexManagerEvent);
Event event2 = events.get(1);
assertTrue(event2 instanceof CompositeDataMovementEvent);
CompositeDataMovementEvent cdme = (CompositeDataMovementEvent) event2;
ByteBuffer bb = cdme.getUserPayload();
ShuffleUserPayloads.DataMovementEventPayloadProto shufflePayload = ShuffleUserPayloads.DataMovementEventPayloadProto.parseFrom(ByteString.copyFrom(bb));
assertTrue(shufflePayload.hasEmptyPartitions());
byte[] emptyPartitions = TezCommonUtils.decompressByteStringToByteArray(shufflePayload.getEmptyPartitions());
BitSet emptyPartionsBitSet = TezUtilsInternal.fromByteArray(emptyPartitions);
assertEquals(numPartitions, emptyPartionsBitSet.cardinality());
for (int i = 0; i < numPartitions; i++) {
assertTrue(emptyPartionsBitSet.get(i));
}
}
use of org.apache.tez.runtime.api.OutputContext in project tez by apache.
the class TestUnorderedPartitionedKVOutput2 method testNonStartedOutput.
@Test(timeout = 5000)
public void testNonStartedOutput() throws Exception {
OutputContext outputContext = OutputTestHelpers.createOutputContext();
int numPartitions = 1;
UnorderedPartitionedKVOutput output = new UnorderedPartitionedKVOutput(outputContext, numPartitions);
output.initialize();
List<Event> events = output.close();
assertEquals(1, events.size());
Event event1 = events.get(0);
assertTrue(event1 instanceof CompositeDataMovementEvent);
CompositeDataMovementEvent dme = (CompositeDataMovementEvent) event1;
ByteBuffer bb = dme.getUserPayload();
ShuffleUserPayloads.DataMovementEventPayloadProto shufflePayload = ShuffleUserPayloads.DataMovementEventPayloadProto.parseFrom(ByteString.copyFrom(bb));
assertTrue(shufflePayload.hasEmptyPartitions());
byte[] emptyPartitions = TezCommonUtils.decompressByteStringToByteArray(shufflePayload.getEmptyPartitions());
BitSet emptyPartionsBitSet = TezUtilsInternal.fromByteArray(emptyPartitions);
assertEquals(numPartitions, emptyPartionsBitSet.cardinality());
for (int i = 0; i < numPartitions; i++) {
assertTrue(emptyPartionsBitSet.get(i));
}
}
use of org.apache.tez.runtime.api.OutputContext in project tez by apache.
the class TestWeightedScalingMemoryDistributor method testAdditionalReserveFractionWeightedScaling.
@Test(timeout = 5000)
public void testAdditionalReserveFractionWeightedScaling() throws TezException {
Configuration conf = new Configuration(this.conf);
conf.setStrings(TezConfiguration.TEZ_TASK_SCALE_MEMORY_WEIGHTED_RATIOS, WeightedScalingMemoryDistributor.generateWeightStrings(0, 0, 2, 3, 6, 1, 1));
conf.setDouble(TezConfiguration.TEZ_TASK_SCALE_MEMORY_ADDITIONAL_RESERVATION_FRACTION_PER_IO, 0.025d);
conf.setDouble(TezConfiguration.TEZ_TASK_SCALE_MEMORY_ADDITIONAL_RESERVATION_FRACTION_MAX, 0.2d);
MemoryDistributor dist = new MemoryDistributor(2, 2, conf);
dist.setJvmMemory(10000l);
// First request - ScatterGatherShuffleInput [weight 6]
MemoryUpdateCallbackForTest e1Callback = new MemoryUpdateCallbackForTest();
InputContext e1InputContext1 = createTestInputContext();
InputDescriptor e1InDesc1 = createTestInputDescriptor(OrderedGroupedKVInput.class);
dist.requestMemory(10000, e1Callback, e1InputContext1, e1InDesc1);
// Second request - BroadcastInput [weight 2]
MemoryUpdateCallbackForTest e2Callback = new MemoryUpdateCallbackForTest();
InputContext e2InputContext2 = createTestInputContext();
InputDescriptor e2InDesc2 = createTestInputDescriptor(UnorderedKVInput.class);
dist.requestMemory(10000, e2Callback, e2InputContext2, e2InDesc2);
// Third request - randomOutput (simulates MROutput) [weight 1]
MemoryUpdateCallbackForTest e3Callback = new MemoryUpdateCallbackForTest();
OutputContext e3OutputContext1 = createTestOutputContext();
OutputDescriptor e3OutDesc1 = createTestOutputDescriptor();
dist.requestMemory(10000, e3Callback, e3OutputContext1, e3OutDesc1);
// Fourth request - OnFileSortedOutput [weight 3]
MemoryUpdateCallbackForTest e4Callback = new MemoryUpdateCallbackForTest();
OutputContext e4OutputContext2 = createTestOutputContext();
OutputDescriptor e4OutDesc2 = createTestOutputDescriptor(OrderedPartitionedKVOutput.class);
dist.requestMemory(10000, e4Callback, e4OutputContext2, e4OutDesc2);
dist.makeInitialAllocations();
// Total available: 60% of 10K = 7000
// 4 requests (weight) - 10K (6), 10K(2), 10K(1), 10K(3)
// Scale down to - 3000, 1000, 500, 1500
assertEquals(3000, e1Callback.assigned);
assertEquals(1000, e2Callback.assigned);
assertEquals(500, e3Callback.assigned);
assertEquals(1500, e4Callback.assigned);
}
Aggregations