Search in sources :

Example 1 with TaskActions

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());
    }
}
Also used : ResultPartitionWriter(org.apache.flink.runtime.io.network.api.writer.ResultPartitionWriter) NoOpTaskActions(org.apache.flink.runtime.taskmanager.NoOpTaskActions) TaskActions(org.apache.flink.runtime.taskmanager.TaskActions) NoOpTaskActions(org.apache.flink.runtime.taskmanager.NoOpTaskActions) JobID(org.apache.flink.api.common.JobID)

Example 2 with TaskActions

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);
        }
    }
}
Also used : ResultPartitionWriter(org.apache.flink.runtime.io.network.api.writer.ResultPartitionWriter) NoOpTaskActions(org.apache.flink.runtime.taskmanager.NoOpTaskActions) TaskActions(org.apache.flink.runtime.taskmanager.TaskActions) NoOpTaskActions(org.apache.flink.runtime.taskmanager.NoOpTaskActions) JobID(org.apache.flink.api.common.JobID)

Example 3 with TaskActions

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);
    }
}
Also used : ResultPartitionWriter(org.apache.flink.runtime.io.network.api.writer.ResultPartitionWriter) NoOpTaskActions(org.apache.flink.runtime.taskmanager.NoOpTaskActions) TaskActions(org.apache.flink.runtime.taskmanager.TaskActions) NoOpTaskActions(org.apache.flink.runtime.taskmanager.NoOpTaskActions) JobID(org.apache.flink.api.common.JobID)

Aggregations

JobID (org.apache.flink.api.common.JobID)3 ResultPartitionWriter (org.apache.flink.runtime.io.network.api.writer.ResultPartitionWriter)3 NoOpTaskActions (org.apache.flink.runtime.taskmanager.NoOpTaskActions)3 TaskActions (org.apache.flink.runtime.taskmanager.TaskActions)3