use of org.apache.flink.runtime.taskmanager.TaskActions in project flink by apache.
the class ResultPartitionTest method testNumBytesProducedCounter.
private void testNumBytesProducedCounter(boolean isBroadcast) throws IOException {
TestResultPartitionConsumableNotifier notifier = new TestResultPartitionConsumableNotifier();
JobID jobId = new JobID();
TaskActions taskActions = new NoOpTaskActions();
BufferWritingResultPartition bufferWritingResultPartition = createResultPartition(ResultPartitionType.BLOCKING);
ResultPartitionWriter partitionWriter = ConsumableNotifyingResultPartitionWriterDecorator.decorate(Collections.singleton(PartitionTestUtils.createPartitionDeploymentDescriptor(ResultPartitionType.BLOCKING)), new ResultPartitionWriter[] { bufferWritingResultPartition }, taskActions, jobId, notifier)[0];
if (isBroadcast) {
partitionWriter.broadcastRecord(ByteBuffer.allocate(bufferSize));
assertEquals(bufferSize, bufferWritingResultPartition.numBytesProduced.getCount());
assertEquals(2 * bufferSize, bufferWritingResultPartition.numBytesOut.getCount());
} else {
partitionWriter.emitRecord(ByteBuffer.allocate(bufferSize), 0);
assertEquals(bufferSize, bufferWritingResultPartition.numBytesProduced.getCount());
assertEquals(bufferSize, bufferWritingResultPartition.numBytesOut.getCount());
}
}
use of org.apache.flink.runtime.taskmanager.TaskActions in project flink by apache.
the class ResultPartitionTest method testAddOnPartition.
/**
* Tests {@link ResultPartition#emitRecord} on a working partition.
*
* @param partitionType the result partition type to set up
*/
private void testAddOnPartition(final ResultPartitionType partitionType) throws Exception {
TestResultPartitionConsumableNotifier notifier = new TestResultPartitionConsumableNotifier();
JobID jobId = new JobID();
TaskActions taskActions = new NoOpTaskActions();
BufferWritingResultPartition bufferWritingResultPartition = createResultPartition(partitionType);
ResultPartitionWriter partitionWriter = ConsumableNotifyingResultPartitionWriterDecorator.decorate(Collections.singleton(PartitionTestUtils.createPartitionDeploymentDescriptor(partitionType)), new ResultPartitionWriter[] { bufferWritingResultPartition }, taskActions, jobId, notifier)[0];
try {
// partitionWriter.emitRecord() will allocate a new buffer and copies the record to it
partitionWriter.emitRecord(ByteBuffer.allocate(bufferSize), 0);
} finally {
assertEquals(1, bufferWritingResultPartition.numBuffersOut.getCount());
assertEquals(bufferSize, bufferWritingResultPartition.numBytesOut.getCount());
assertEquals(1, bufferWritingResultPartition.getBufferPool().bestEffortGetNumOfUsedBuffers());
// should have been notified for pipelined partitions
if (partitionType.isPipelined()) {
notifier.check(jobId, partitionWriter.getPartitionId(), taskActions, 1);
}
}
}
use of org.apache.flink.runtime.taskmanager.TaskActions in project flink by apache.
the class ResultPartitionTest method testNotifyPartitionDataAvailable.
private void testNotifyPartitionDataAvailable(FutureConsumerWithException<ResultPartitionWriter, Exception> notificationCall) throws Exception {
JobID jobId = new JobID();
TaskActions taskActions = new NoOpTaskActions();
{
// Pipelined, send message => notify
TestResultPartitionConsumableNotifier notifier = new TestResultPartitionConsumableNotifier();
ResultPartitionWriter consumableNotifyingPartitionWriter = createConsumableNotifyingResultPartitionWriter(ResultPartitionType.PIPELINED, taskActions, jobId, notifier);
notificationCall.accept(consumableNotifyingPartitionWriter);
notifier.check(jobId, consumableNotifyingPartitionWriter.getPartitionId(), taskActions, 1);
}
{
// Blocking, send message => don't notify
TestResultPartitionConsumableNotifier notifier = new TestResultPartitionConsumableNotifier();
ResultPartitionWriter partition = createConsumableNotifyingResultPartitionWriter(ResultPartitionType.BLOCKING, taskActions, jobId, notifier);
notificationCall.accept(partition);
notifier.check(null, null, null, 0);
}
}
Aggregations