Search in sources :

Example 1 with ShuffleDescriptor

use of org.apache.flink.runtime.shuffle.ShuffleDescriptor in project flink by apache.

the class ShuffleDescriptorTest method testMixedLocalRemoteUnknownDeployment.

/**
 * Tests the deployment descriptors for local, remote, and unknown partition locations (with
 * lazy deployment allowed and all execution states for the producers).
 */
@Test
public void testMixedLocalRemoteUnknownDeployment() throws Exception {
    ResourceID consumerResourceID = ResourceID.generate();
    JobID jobID = new JobID();
    // states.
    for (ExecutionState state : ExecutionState.values()) {
        ResultPartitionID localPartitionId = new ResultPartitionID();
        ResultPartitionDeploymentDescriptor localPartition = createResultPartitionDeploymentDescriptor(jobID, localPartitionId, consumerResourceID);
        ResultPartitionID remotePartitionId = new ResultPartitionID();
        ResultPartitionDeploymentDescriptor remotePartition = createResultPartitionDeploymentDescriptor(jobID, remotePartitionId, ResourceID.generate());
        ResultPartitionID unknownPartitionId = new ResultPartitionID();
        ShuffleDescriptor localShuffleDescriptor = getConsumedPartitionShuffleDescriptor(localPartitionId, state, localPartition, TaskDeploymentDescriptorFactory.PartitionLocationConstraint.CAN_BE_UNKNOWN);
        ShuffleDescriptor remoteShuffleDescriptor = getConsumedPartitionShuffleDescriptor(remotePartitionId, state, remotePartition, TaskDeploymentDescriptorFactory.PartitionLocationConstraint.CAN_BE_UNKNOWN);
        ShuffleDescriptor unknownShuffleDescriptor = getConsumedPartitionShuffleDescriptor(unknownPartitionId, state, null, TaskDeploymentDescriptorFactory.PartitionLocationConstraint.CAN_BE_UNKNOWN);
        // These states are allowed
        if (state == ExecutionState.RUNNING || state == ExecutionState.INITIALIZING || state == ExecutionState.FINISHED || state == ExecutionState.SCHEDULED || state == ExecutionState.DEPLOYING) {
            NettyShuffleDescriptor nettyShuffleDescriptor;
            // Create local or remote channels
            verifyShuffleDescriptor(localShuffleDescriptor, NettyShuffleDescriptor.class, false, localPartitionId);
            nettyShuffleDescriptor = (NettyShuffleDescriptor) localShuffleDescriptor;
            assertThat(nettyShuffleDescriptor.isLocalTo(consumerResourceID), is(true));
            verifyShuffleDescriptor(remoteShuffleDescriptor, NettyShuffleDescriptor.class, false, remotePartitionId);
            nettyShuffleDescriptor = (NettyShuffleDescriptor) remoteShuffleDescriptor;
            assertThat(nettyShuffleDescriptor.isLocalTo(consumerResourceID), is(false));
            assertThat(nettyShuffleDescriptor.getConnectionId(), is(STUB_CONNECTION_ID));
        } else {
            // Unknown (lazy deployment allowed)
            verifyShuffleDescriptor(localShuffleDescriptor, UnknownShuffleDescriptor.class, true, localPartitionId);
            verifyShuffleDescriptor(remoteShuffleDescriptor, UnknownShuffleDescriptor.class, true, remotePartitionId);
        }
        verifyShuffleDescriptor(unknownShuffleDescriptor, UnknownShuffleDescriptor.class, true, unknownPartitionId);
    }
}
Also used : ExecutionState(org.apache.flink.runtime.execution.ExecutionState) NettyShuffleDescriptor(org.apache.flink.runtime.shuffle.NettyShuffleDescriptor) ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) ResultPartitionID(org.apache.flink.runtime.io.network.partition.ResultPartitionID) ShuffleDescriptor(org.apache.flink.runtime.shuffle.ShuffleDescriptor) UnknownShuffleDescriptor(org.apache.flink.runtime.shuffle.UnknownShuffleDescriptor) NettyShuffleDescriptor(org.apache.flink.runtime.shuffle.NettyShuffleDescriptor) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 2 with ShuffleDescriptor

use of org.apache.flink.runtime.shuffle.ShuffleDescriptor in project flink by apache.

the class ShuffleDescriptorTest method testUnknownDescriptorWithOrWithoutLazyDeployment.

@Test
public void testUnknownDescriptorWithOrWithoutLazyDeployment() {
    ResultPartitionID unknownPartitionId = new ResultPartitionID();
    // This should work if lazy deployment is allowed
    ShuffleDescriptor unknownSdd = getConsumedPartitionShuffleDescriptor(unknownPartitionId, ExecutionState.CREATED, null, TaskDeploymentDescriptorFactory.PartitionLocationConstraint.CAN_BE_UNKNOWN);
    assertThat(unknownSdd, instanceOf(UnknownShuffleDescriptor.class));
    assertThat(unknownSdd.isUnknown(), is(true));
    assertThat(unknownSdd.getResultPartitionID(), is(unknownPartitionId));
    try {
        // Fail if lazy deployment is *not* allowed
        getConsumedPartitionShuffleDescriptor(unknownPartitionId, ExecutionState.CREATED, null, TaskDeploymentDescriptorFactory.PartitionLocationConstraint.MUST_BE_KNOWN);
        fail("Did not throw expected ExecutionGraphException");
    } catch (IllegalStateException ignored) {
    }
}
Also used : ResultPartitionID(org.apache.flink.runtime.io.network.partition.ResultPartitionID) ShuffleDescriptor(org.apache.flink.runtime.shuffle.ShuffleDescriptor) UnknownShuffleDescriptor(org.apache.flink.runtime.shuffle.UnknownShuffleDescriptor) NettyShuffleDescriptor(org.apache.flink.runtime.shuffle.NettyShuffleDescriptor) UnknownShuffleDescriptor(org.apache.flink.runtime.shuffle.UnknownShuffleDescriptor) Test(org.junit.Test)

Example 3 with ShuffleDescriptor

use of org.apache.flink.runtime.shuffle.ShuffleDescriptor in project flink by apache.

the class ResultPartitionDeploymentDescriptorTest method testSerializationOfUnknownShuffleDescriptor.

/**
 * Tests simple de/serialization with {@link UnknownShuffleDescriptor}.
 */
@Test
public void testSerializationOfUnknownShuffleDescriptor() throws IOException {
    ShuffleDescriptor shuffleDescriptor = new UnknownShuffleDescriptor(resultPartitionID);
    ShuffleDescriptor shuffleDescriptorCopy = CommonTestUtils.createCopySerializable(shuffleDescriptor);
    assertThat(shuffleDescriptorCopy, instanceOf(UnknownShuffleDescriptor.class));
    assertThat(shuffleDescriptorCopy.getResultPartitionID(), is(resultPartitionID));
    assertThat(shuffleDescriptorCopy.isUnknown(), is(true));
}
Also used : ShuffleDescriptor(org.apache.flink.runtime.shuffle.ShuffleDescriptor) UnknownShuffleDescriptor(org.apache.flink.runtime.shuffle.UnknownShuffleDescriptor) NettyShuffleDescriptor(org.apache.flink.runtime.shuffle.NettyShuffleDescriptor) UnknownShuffleDescriptor(org.apache.flink.runtime.shuffle.UnknownShuffleDescriptor) Test(org.junit.Test)

Example 4 with ShuffleDescriptor

use of org.apache.flink.runtime.shuffle.ShuffleDescriptor in project flink by apache.

the class Execution method createPartitionInfo.

private static PartitionInfo createPartitionInfo(IntermediateResultPartition consumedPartition) {
    IntermediateDataSetID intermediateDataSetID = consumedPartition.getIntermediateResult().getId();
    ShuffleDescriptor shuffleDescriptor = getConsumedPartitionShuffleDescriptor(consumedPartition, TaskDeploymentDescriptorFactory.PartitionLocationConstraint.MUST_BE_KNOWN);
    return new PartitionInfo(intermediateDataSetID, shuffleDescriptor);
}
Also used : IntermediateDataSetID(org.apache.flink.runtime.jobgraph.IntermediateDataSetID) TaskDeploymentDescriptorFactory.getConsumedPartitionShuffleDescriptor(org.apache.flink.runtime.deployment.TaskDeploymentDescriptorFactory.getConsumedPartitionShuffleDescriptor) ShuffleDescriptor(org.apache.flink.runtime.shuffle.ShuffleDescriptor)

Example 5 with ShuffleDescriptor

use of org.apache.flink.runtime.shuffle.ShuffleDescriptor in project flink by apache.

the class InputGateDeploymentDescriptor method loadBigData.

public void loadBigData(@Nullable PermanentBlobService blobService, JobID jobId) throws IOException, ClassNotFoundException {
    if (serializedInputChannels instanceof Offloaded) {
        PermanentBlobKey blobKey = ((Offloaded<ShuffleDescriptor[]>) serializedInputChannels).serializedValueKey;
        Preconditions.checkNotNull(blobService);
        // NOTE: Do not delete the ShuffleDescriptor BLOBs since it may be needed again during
        // recovery. (it is deleted automatically on the BLOB server and cache when its
        // partition is no longer available or the job enters a terminal state)
        CompressedSerializedValue<ShuffleDescriptor[]> serializedValue = CompressedSerializedValue.fromBytes(blobService.readFile(jobId, blobKey));
        serializedInputChannels = new NonOffloaded<>(serializedValue);
        Preconditions.checkNotNull(serializedInputChannels);
    }
}
Also used : Offloaded(org.apache.flink.runtime.deployment.TaskDeploymentDescriptor.Offloaded) NonOffloaded(org.apache.flink.runtime.deployment.TaskDeploymentDescriptor.NonOffloaded) MaybeOffloaded(org.apache.flink.runtime.deployment.TaskDeploymentDescriptor.MaybeOffloaded) PermanentBlobKey(org.apache.flink.runtime.blob.PermanentBlobKey) ShuffleDescriptor(org.apache.flink.runtime.shuffle.ShuffleDescriptor)

Aggregations

ShuffleDescriptor (org.apache.flink.runtime.shuffle.ShuffleDescriptor)21 NettyShuffleDescriptor (org.apache.flink.runtime.shuffle.NettyShuffleDescriptor)9 UnknownShuffleDescriptor (org.apache.flink.runtime.shuffle.UnknownShuffleDescriptor)9 JobID (org.apache.flink.api.common.JobID)7 Test (org.junit.Test)7 IntermediateDataSetID (org.apache.flink.runtime.jobgraph.IntermediateDataSetID)5 IntermediateResultPartitionID (org.apache.flink.runtime.jobgraph.IntermediateResultPartitionID)5 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)5 InputGateDeploymentDescriptor (org.apache.flink.runtime.deployment.InputGateDeploymentDescriptor)4 ResultPartitionID (org.apache.flink.runtime.io.network.partition.ResultPartitionID)3 DefaultScheduler (org.apache.flink.runtime.scheduler.DefaultScheduler)3 HashMap (java.util.HashMap)2 PermanentBlobKey (org.apache.flink.runtime.blob.PermanentBlobKey)2 ResultPartitionDeploymentDescriptor (org.apache.flink.runtime.deployment.ResultPartitionDeploymentDescriptor)2 TaskDeploymentDescriptor (org.apache.flink.runtime.deployment.TaskDeploymentDescriptor)2 MaybeOffloaded (org.apache.flink.runtime.deployment.TaskDeploymentDescriptor.MaybeOffloaded)2 Offloaded (org.apache.flink.runtime.deployment.TaskDeploymentDescriptor.Offloaded)2 ExecutionState (org.apache.flink.runtime.execution.ExecutionState)2 ExecutionAttemptID (org.apache.flink.runtime.executiongraph.ExecutionAttemptID)2 ArrayList (java.util.ArrayList)1