Java Code Examples for org.apache.flink.runtime.execution.ExecutionState#FINISHED
The following examples show how to use
org.apache.flink.runtime.execution.ExecutionState#FINISHED .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PipelinedRegionSchedulingStrategy.java From flink with Apache License 2.0 | 6 votes |
@Override public void onExecutionStateChange(final ExecutionVertexID executionVertexId, final ExecutionState executionState) { if (executionState == ExecutionState.FINISHED) { final Set<SchedulingResultPartition> finishedPartitions = IterableUtils .toStream(schedulingTopology.getVertex(executionVertexId).getProducedResults()) .filter(partition -> partitionConsumerRegions.containsKey(partition.getId())) .filter(partition -> partition.getState() == ResultPartitionState.CONSUMABLE) .flatMap(partition -> correlatedResultPartitions.get(partition.getResultId()).stream()) .collect(Collectors.toSet()); final Set<SchedulingPipelinedRegion> consumerRegions = finishedPartitions.stream() .flatMap(partition -> partitionConsumerRegions.get(partition.getId()).stream()) .collect(Collectors.toSet()); maybeScheduleRegions(consumerRegions); } }
Example 2
Source File: ExecutionJobVertex.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * A utility function that computes an "aggregated" state for the vertex. * * <p>This state is not used anywhere in the coordination, but can be used for display * in dashboards to as a summary for how the particular parallel operation represented by * this ExecutionJobVertex is currently behaving. * * <p>For example, if at least one parallel task is failed, the aggregate state is failed. * If not, and at least one parallel task is cancelling (or cancelled), the aggregate state * is cancelling (or cancelled). If all tasks are finished, the aggregate state is finished, * and so on. * * @param verticesPerState The number of vertices in each state (indexed by the ordinal of * the ExecutionState values). * @param parallelism The parallelism of the ExecutionJobVertex * * @return The aggregate state of this ExecutionJobVertex. */ public static ExecutionState getAggregateJobVertexState(int[] verticesPerState, int parallelism) { if (verticesPerState == null || verticesPerState.length != ExecutionState.values().length) { throw new IllegalArgumentException("Must provide an array as large as there are execution states."); } if (verticesPerState[ExecutionState.FAILED.ordinal()] > 0) { return ExecutionState.FAILED; } if (verticesPerState[ExecutionState.CANCELING.ordinal()] > 0) { return ExecutionState.CANCELING; } else if (verticesPerState[ExecutionState.CANCELED.ordinal()] > 0) { return ExecutionState.CANCELED; } else if (verticesPerState[ExecutionState.RUNNING.ordinal()] > 0) { return ExecutionState.RUNNING; } else if (verticesPerState[ExecutionState.FINISHED.ordinal()] > 0) { return verticesPerState[ExecutionState.FINISHED.ordinal()] == parallelism ? ExecutionState.FINISHED : ExecutionState.RUNNING; } else { // all else collapses under created return ExecutionState.CREATED; } }
Example 3
Source File: ArchivedExecutionBuilder.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
public ArchivedExecution build() throws UnknownHostException { return new ArchivedExecution( userAccumulators != null ? userAccumulators : new StringifiedAccumulatorResult[0], ioMetrics != null ? ioMetrics : new TestIOMetrics(), attemptId != null ? attemptId : new ExecutionAttemptID(), attemptNumber, state != null ? state : ExecutionState.FINISHED, failureCause != null ? failureCause : "(null)", assignedResourceLocation != null ? assignedResourceLocation : new TaskManagerLocation(new ResourceID("tm"), InetAddress.getLocalHost(), 1234), assignedAllocationID != null ? assignedAllocationID : new AllocationID(0L, 0L), parallelSubtaskIndex, stateTimestamps != null ? stateTimestamps : new long[]{1, 2, 3, 4, 5, 5, 5, 5} ); }
Example 4
Source File: RemoteChannelStateChecker.java From flink with Apache License 2.0 | 5 votes |
private boolean isProducerConsumerReady(ResponseHandle responseHandle) { ExecutionState producerState = getProducerState(responseHandle); return producerState == ExecutionState.SCHEDULED || producerState == ExecutionState.DEPLOYING || producerState == ExecutionState.RUNNING || producerState == ExecutionState.FINISHED; }
Example 5
Source File: ExecutionGraph.java From flink with Apache License 2.0 | 5 votes |
private void maybeReleasePartitions(final Execution attempt) { final ExecutionVertexID finishedExecutionVertex = attempt.getVertex().getID(); if (attempt.getState() == ExecutionState.FINISHED) { final List<IntermediateResultPartitionID> releasablePartitions = partitionReleaseStrategy.vertexFinished(finishedExecutionVertex); releasePartitions(releasablePartitions); } else { partitionReleaseStrategy.vertexUnfinished(finishedExecutionVertex); } }
Example 6
Source File: ExecutionJobVertex.java From flink with Apache License 2.0 | 5 votes |
/** * A utility function that computes an "aggregated" state for the vertex. * * <p>This state is not used anywhere in the coordination, but can be used for display * in dashboards to as a summary for how the particular parallel operation represented by * this ExecutionJobVertex is currently behaving. * * <p>For example, if at least one parallel task is failed, the aggregate state is failed. * If not, and at least one parallel task is cancelling (or cancelled), the aggregate state * is cancelling (or cancelled). If all tasks are finished, the aggregate state is finished, * and so on. * * @param verticesPerState The number of vertices in each state (indexed by the ordinal of * the ExecutionState values). * @param parallelism The parallelism of the ExecutionJobVertex * * @return The aggregate state of this ExecutionJobVertex. */ public static ExecutionState getAggregateJobVertexState(int[] verticesPerState, int parallelism) { if (verticesPerState == null || verticesPerState.length != ExecutionState.values().length) { throw new IllegalArgumentException("Must provide an array as large as there are execution states."); } if (verticesPerState[ExecutionState.FAILED.ordinal()] > 0) { return ExecutionState.FAILED; } if (verticesPerState[ExecutionState.CANCELING.ordinal()] > 0) { return ExecutionState.CANCELING; } else if (verticesPerState[ExecutionState.CANCELED.ordinal()] > 0) { return ExecutionState.CANCELED; } else if (verticesPerState[ExecutionState.RUNNING.ordinal()] > 0) { return ExecutionState.RUNNING; } else if (verticesPerState[ExecutionState.FINISHED.ordinal()] > 0) { return verticesPerState[ExecutionState.FINISHED.ordinal()] == parallelism ? ExecutionState.FINISHED : ExecutionState.RUNNING; } else { // all else collapses under created return ExecutionState.CREATED; } }
Example 7
Source File: RemoteChannelStateChecker.java From flink with Apache License 2.0 | 5 votes |
private boolean isProducerConsumerReady(ResponseHandle responseHandle) { ExecutionState producerState = getProducerState(responseHandle); return producerState == ExecutionState.SCHEDULED || producerState == ExecutionState.DEPLOYING || producerState == ExecutionState.RUNNING || producerState == ExecutionState.FINISHED; }
Example 8
Source File: ExecutionJobVertex.java From flink with Apache License 2.0 | 5 votes |
/** * A utility function that computes an "aggregated" state for the vertex. * * <p>This state is not used anywhere in the coordination, but can be used for display * in dashboards to as a summary for how the particular parallel operation represented by * this ExecutionJobVertex is currently behaving. * * <p>For example, if at least one parallel task is failed, the aggregate state is failed. * If not, and at least one parallel task is cancelling (or cancelled), the aggregate state * is cancelling (or cancelled). If all tasks are finished, the aggregate state is finished, * and so on. * * @param verticesPerState The number of vertices in each state (indexed by the ordinal of * the ExecutionState values). * @param parallelism The parallelism of the ExecutionJobVertex * * @return The aggregate state of this ExecutionJobVertex. */ public static ExecutionState getAggregateJobVertexState(int[] verticesPerState, int parallelism) { if (verticesPerState == null || verticesPerState.length != ExecutionState.values().length) { throw new IllegalArgumentException("Must provide an array as large as there are execution states."); } if (verticesPerState[ExecutionState.FAILED.ordinal()] > 0) { return ExecutionState.FAILED; } if (verticesPerState[ExecutionState.CANCELING.ordinal()] > 0) { return ExecutionState.CANCELING; } else if (verticesPerState[ExecutionState.CANCELED.ordinal()] > 0) { return ExecutionState.CANCELED; } else if (verticesPerState[ExecutionState.RUNNING.ordinal()] > 0) { return ExecutionState.RUNNING; } else if (verticesPerState[ExecutionState.FINISHED.ordinal()] > 0) { return verticesPerState[ExecutionState.FINISHED.ordinal()] == parallelism ? ExecutionState.FINISHED : ExecutionState.RUNNING; } else { // all else collapses under created return ExecutionState.CREATED; } }
Example 9
Source File: ExecutionGraph.java From flink with Apache License 2.0 | 5 votes |
private void maybeReleasePartitions(final Execution attempt) { final ExecutionVertexID finishedExecutionVertex = attempt.getVertex().getID(); if (attempt.getState() == ExecutionState.FINISHED) { final List<IntermediateResultPartitionID> releasablePartitions = partitionReleaseStrategy.vertexFinished(finishedExecutionVertex); releasePartitions(releasablePartitions); } else { partitionReleaseStrategy.vertexUnfinished(finishedExecutionVertex); } }
Example 10
Source File: ArchivedExecutionBuilder.java From flink with Apache License 2.0 | 5 votes |
public ArchivedExecution build() throws UnknownHostException { return new ArchivedExecution( userAccumulators != null ? userAccumulators : new StringifiedAccumulatorResult[0], ioMetrics != null ? ioMetrics : new TestIOMetrics(), attemptId != null ? attemptId : new ExecutionAttemptID(), attemptNumber, state != null ? state : ExecutionState.FINISHED, failureCause != null ? failureCause : "(null)", assignedResourceLocation != null ? assignedResourceLocation : new TaskManagerLocation(new ResourceID("tm"), InetAddress.getLocalHost(), 1234), assignedAllocationID != null ? assignedAllocationID : new AllocationID(0L, 0L), parallelSubtaskIndex, stateTimestamps != null ? stateTimestamps : new long[]{1, 2, 3, 4, 5, 5, 5, 5} ); }
Example 11
Source File: SubtaskExecutionAttemptAccumulatorsHandlerTest.java From flink with Apache License 2.0 | 4 votes |
@Test public void testHandleRequest() throws Exception { // Instance the handler. final RestHandlerConfiguration restHandlerConfiguration = RestHandlerConfiguration.fromConfiguration(new Configuration()); final SubtaskExecutionAttemptAccumulatorsHandler handler = new SubtaskExecutionAttemptAccumulatorsHandler( () -> null, Time.milliseconds(100L), Collections.emptyMap(), SubtaskExecutionAttemptAccumulatorsHeaders.getInstance(), new DefaultExecutionGraphCache( restHandlerConfiguration.getTimeout(), Time.milliseconds(restHandlerConfiguration.getRefreshInterval())), TestingUtils.defaultExecutor()); // Instance a empty request. final HandlerRequest<EmptyRequestBody, SubtaskAttemptMessageParameters> request = new HandlerRequest<>( EmptyRequestBody.getInstance(), new SubtaskAttemptMessageParameters() ); final Map<String, OptionalFailure<Accumulator<?, ?>>> userAccumulators = new HashMap<>(3); userAccumulators.put("IntCounter", OptionalFailure.of(new IntCounter(10))); userAccumulators.put("LongCounter", OptionalFailure.of(new LongCounter(100L))); userAccumulators.put("Failure", OptionalFailure.ofFailure(new FlinkRuntimeException("Test"))); // Instance the expected result. final StringifiedAccumulatorResult[] accumulatorResults = StringifiedAccumulatorResult.stringifyAccumulatorResults(userAccumulators); final int attemptNum = 1; final int subtaskIndex = 2; // Instance the tested execution. final ArchivedExecution execution = new ArchivedExecution( accumulatorResults, null, new ExecutionAttemptID(), attemptNum, ExecutionState.FINISHED, null, null, null, subtaskIndex, new long[ExecutionState.values().length]); // Invoke tested method. final SubtaskExecutionAttemptAccumulatorsInfo accumulatorsInfo = handler.handleRequest(request, execution); final ArrayList<UserAccumulator> userAccumulatorList = new ArrayList<>(userAccumulators.size()); for (StringifiedAccumulatorResult accumulatorResult : accumulatorResults) { userAccumulatorList.add( new UserAccumulator( accumulatorResult.getName(), accumulatorResult.getType(), accumulatorResult.getValue())); } final SubtaskExecutionAttemptAccumulatorsInfo expected = new SubtaskExecutionAttemptAccumulatorsInfo( subtaskIndex, attemptNum, execution.getAttemptId().toString(), userAccumulatorList); // Verify. assertEquals(expected, accumulatorsInfo); }
Example 12
Source File: Task.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
/** * Answer to a partition state check issued after a failed partition request. */ @VisibleForTesting void onPartitionStateUpdate( IntermediateDataSetID intermediateDataSetId, ResultPartitionID resultPartitionId, ExecutionState producerState) throws IOException, InterruptedException { if (executionState == ExecutionState.RUNNING) { final SingleInputGate inputGate = inputGatesById.get(intermediateDataSetId); if (inputGate != null) { if (producerState == ExecutionState.SCHEDULED || producerState == ExecutionState.DEPLOYING || producerState == ExecutionState.RUNNING || producerState == ExecutionState.FINISHED) { // Retrigger the partition request inputGate.retriggerPartitionRequest(resultPartitionId.getPartitionId()); } else if (producerState == ExecutionState.CANCELING || producerState == ExecutionState.CANCELED || producerState == ExecutionState.FAILED) { // The producing execution has been canceled or failed. We // don't need to re-trigger the request since it cannot // succeed. if (LOG.isDebugEnabled()) { LOG.debug("Cancelling task {} after the producer of partition {} with attempt ID {} has entered state {}.", taskNameWithSubtask, resultPartitionId.getPartitionId(), resultPartitionId.getProducerId(), producerState); } cancelExecution(); } else { // Any other execution state is unexpected. Currently, only // state CREATED is left out of the checked states. If we // see a producer in this state, something went wrong with // scheduling in topological order. String msg = String.format("Producer with attempt ID %s of partition %s in unexpected state %s.", resultPartitionId.getProducerId(), resultPartitionId.getPartitionId(), producerState); failExternally(new IllegalStateException(msg)); } } else { failExternally(new IllegalStateException("Received partition producer state for " + "unknown input gate " + intermediateDataSetId + ".")); } } else { LOG.debug("Task {} ignored a partition producer state notification, because it's not running.", taskNameWithSubtask); } }
Example 13
Source File: ShuffleDescriptorTest.java From flink with Apache License 2.0 | 4 votes |
/** * 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(); // Local and remote channel are only allowed for certain execution // states. for (ExecutionState state : ExecutionState.values()) { ResultPartitionID localPartitionId = new ResultPartitionID(); ResultPartitionDeploymentDescriptor localPartition = createResultPartitionDeploymentDescriptor(localPartitionId, consumerResourceID); ResultPartitionID remotePartitionId = new ResultPartitionID(); ResultPartitionDeploymentDescriptor remotePartition = createResultPartitionDeploymentDescriptor(remotePartitionId, ResourceID.generate()); ResultPartitionID unknownPartitionId = new ResultPartitionID(); ShuffleDescriptor localShuffleDescriptor = getConsumedPartitionShuffleDescriptor(localPartitionId, state, localPartition, true); ShuffleDescriptor remoteShuffleDescriptor = getConsumedPartitionShuffleDescriptor(remotePartitionId, state, remotePartition, true); ShuffleDescriptor unknownShuffleDescriptor = getConsumedPartitionShuffleDescriptor(unknownPartitionId, state, null, true); // These states are allowed if (state == ExecutionState.RUNNING || 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); } }
Example 14
Source File: TaskDeploymentDescriptorFactory.java From flink with Apache License 2.0 | 4 votes |
private static boolean isProducerAvailable(ExecutionState producerState) { return producerState == ExecutionState.RUNNING || producerState == ExecutionState.FINISHED || producerState == ExecutionState.SCHEDULED || producerState == ExecutionState.DEPLOYING; }
Example 15
Source File: SubtaskExecutionAttemptAccumulatorsHandlerTest.java From flink with Apache License 2.0 | 4 votes |
@Test public void testHandleRequest() throws Exception { // Instance the handler. final RestHandlerConfiguration restHandlerConfiguration = RestHandlerConfiguration.fromConfiguration(new Configuration()); final SubtaskExecutionAttemptAccumulatorsHandler handler = new SubtaskExecutionAttemptAccumulatorsHandler( () -> null, Time.milliseconds(100L), Collections.emptyMap(), SubtaskExecutionAttemptAccumulatorsHeaders.getInstance(), new ExecutionGraphCache( restHandlerConfiguration.getTimeout(), Time.milliseconds(restHandlerConfiguration.getRefreshInterval())), TestingUtils.defaultExecutor()); // Instance a empty request. final HandlerRequest<EmptyRequestBody, SubtaskAttemptMessageParameters> request = new HandlerRequest<>( EmptyRequestBody.getInstance(), new SubtaskAttemptMessageParameters() ); final Map<String, OptionalFailure<Accumulator<?, ?>>> userAccumulators = new HashMap<>(3); userAccumulators.put("IntCounter", OptionalFailure.of(new IntCounter(10))); userAccumulators.put("LongCounter", OptionalFailure.of(new LongCounter(100L))); userAccumulators.put("Failure", OptionalFailure.ofFailure(new FlinkRuntimeException("Test"))); // Instance the expected result. final StringifiedAccumulatorResult[] accumulatorResults = StringifiedAccumulatorResult.stringifyAccumulatorResults(userAccumulators); final int attemptNum = 1; final int subtaskIndex = 2; // Instance the tested execution. final ArchivedExecution execution = new ArchivedExecution( accumulatorResults, null, new ExecutionAttemptID(), attemptNum, ExecutionState.FINISHED, null, null, null, subtaskIndex, new long[ExecutionState.values().length]); // Invoke tested method. final SubtaskExecutionAttemptAccumulatorsInfo accumulatorsInfo = handler.handleRequest(request, execution); final ArrayList<UserAccumulator> userAccumulatorList = new ArrayList<>(userAccumulators.size()); for (StringifiedAccumulatorResult accumulatorResult : accumulatorResults) { userAccumulatorList.add( new UserAccumulator( accumulatorResult.getName(), accumulatorResult.getType(), accumulatorResult.getValue())); } final SubtaskExecutionAttemptAccumulatorsInfo expected = new SubtaskExecutionAttemptAccumulatorsInfo( subtaskIndex, attemptNum, execution.getAttemptId().toString(), userAccumulatorList); // Verify. assertEquals(expected, accumulatorsInfo); }
Example 16
Source File: ShuffleDescriptorTest.java From flink with Apache License 2.0 | 4 votes |
/** * 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(); // Local and remote channel are only allowed for certain execution // states. for (ExecutionState state : ExecutionState.values()) { ResultPartitionID localPartitionId = new ResultPartitionID(); ResultPartitionDeploymentDescriptor localPartition = createResultPartitionDeploymentDescriptor(localPartitionId, consumerResourceID); ResultPartitionID remotePartitionId = new ResultPartitionID(); ResultPartitionDeploymentDescriptor remotePartition = createResultPartitionDeploymentDescriptor(remotePartitionId, ResourceID.generate()); ResultPartitionID unknownPartitionId = new ResultPartitionID(); ShuffleDescriptor localShuffleDescriptor = getConsumedPartitionShuffleDescriptor(localPartitionId, state, localPartition, true); ShuffleDescriptor remoteShuffleDescriptor = getConsumedPartitionShuffleDescriptor(remotePartitionId, state, remotePartition, true); ShuffleDescriptor unknownShuffleDescriptor = getConsumedPartitionShuffleDescriptor(unknownPartitionId, state, null, true); // These states are allowed if (state == ExecutionState.RUNNING || 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); } }
Example 17
Source File: TaskDeploymentDescriptorFactory.java From flink with Apache License 2.0 | 4 votes |
private static boolean isProducerAvailable(ExecutionState producerState) { return producerState == ExecutionState.RUNNING || producerState == ExecutionState.FINISHED || producerState == ExecutionState.SCHEDULED || producerState == ExecutionState.DEPLOYING; }
Example 18
Source File: SubtaskExecutionAttemptAccumulatorsHandlerTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Test public void testHandleRequest() throws Exception { // Instance the handler. final RestHandlerConfiguration restHandlerConfiguration = RestHandlerConfiguration.fromConfiguration(new Configuration()); final SubtaskExecutionAttemptAccumulatorsHandler handler = new SubtaskExecutionAttemptAccumulatorsHandler( () -> null, Time.milliseconds(100L), Collections.emptyMap(), SubtaskExecutionAttemptAccumulatorsHeaders.getInstance(), new ExecutionGraphCache( restHandlerConfiguration.getTimeout(), Time.milliseconds(restHandlerConfiguration.getRefreshInterval())), TestingUtils.defaultExecutor()); // Instance a empty request. final HandlerRequest<EmptyRequestBody, SubtaskAttemptMessageParameters> request = new HandlerRequest<>( EmptyRequestBody.getInstance(), new SubtaskAttemptMessageParameters() ); final Map<String, OptionalFailure<Accumulator<?, ?>>> userAccumulators = new HashMap<>(3); userAccumulators.put("IntCounter", OptionalFailure.of(new IntCounter(10))); userAccumulators.put("LongCounter", OptionalFailure.of(new LongCounter(100L))); userAccumulators.put("Failure", OptionalFailure.ofFailure(new FlinkRuntimeException("Test"))); // Instance the expected result. final StringifiedAccumulatorResult[] accumulatorResults = StringifiedAccumulatorResult.stringifyAccumulatorResults(userAccumulators); final int attemptNum = 1; final int subtaskIndex = 2; // Instance the tested execution. final ArchivedExecution execution = new ArchivedExecution( accumulatorResults, null, new ExecutionAttemptID(), attemptNum, ExecutionState.FINISHED, null, null, null, subtaskIndex, new long[ExecutionState.values().length]); // Invoke tested method. final SubtaskExecutionAttemptAccumulatorsInfo accumulatorsInfo = handler.handleRequest(request, execution); final ArrayList<UserAccumulator> userAccumulatorList = new ArrayList<>(userAccumulators.size()); for (StringifiedAccumulatorResult accumulatorResult : accumulatorResults) { userAccumulatorList.add( new UserAccumulator( accumulatorResult.getName(), accumulatorResult.getType(), accumulatorResult.getValue())); } final SubtaskExecutionAttemptAccumulatorsInfo expected = new SubtaskExecutionAttemptAccumulatorsInfo( subtaskIndex, attemptNum, execution.getAttemptId().toString(), userAccumulatorList); // Verify. assertEquals(expected, accumulatorsInfo); }
Example 19
Source File: InputChannelDeploymentDescriptorTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
/** * 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 { boolean allowLazyDeployment = true; ResourceID consumerResourceId = ResourceID.generate(); ExecutionVertex consumer = mock(ExecutionVertex.class); LogicalSlot consumerSlot = mockSlot(consumerResourceId); // Local and remote channel are only allowed for certain execution // states. for (ExecutionState state : ExecutionState.values()) { // Local partition ExecutionVertex localProducer = mockExecutionVertex(state, consumerResourceId); IntermediateResultPartition localPartition = mockPartition(localProducer); ResultPartitionID localPartitionId = new ResultPartitionID(localPartition.getPartitionId(), localProducer.getCurrentExecutionAttempt().getAttemptId()); ExecutionEdge localEdge = new ExecutionEdge(localPartition, consumer, 0); // Remote partition ExecutionVertex remoteProducer = mockExecutionVertex(state, ResourceID.generate()); // new resource ID IntermediateResultPartition remotePartition = mockPartition(remoteProducer); ResultPartitionID remotePartitionId = new ResultPartitionID(remotePartition.getPartitionId(), remoteProducer.getCurrentExecutionAttempt().getAttemptId()); ConnectionID remoteConnectionId = new ConnectionID(remoteProducer.getCurrentAssignedResource().getTaskManagerLocation(), 0); ExecutionEdge remoteEdge = new ExecutionEdge(remotePartition, consumer, 1); // Unknown partition ExecutionVertex unknownProducer = mockExecutionVertex(state, null); // no assigned resource IntermediateResultPartition unknownPartition = mockPartition(unknownProducer); ResultPartitionID unknownPartitionId = new ResultPartitionID(unknownPartition.getPartitionId(), unknownProducer.getCurrentExecutionAttempt().getAttemptId()); ExecutionEdge unknownEdge = new ExecutionEdge(unknownPartition, consumer, 2); InputChannelDeploymentDescriptor[] desc = InputChannelDeploymentDescriptor.fromEdges( new ExecutionEdge[]{localEdge, remoteEdge, unknownEdge}, consumerSlot.getTaskManagerLocation().getResourceID(), allowLazyDeployment); assertEquals(3, desc.length); // These states are allowed if (state == ExecutionState.RUNNING || state == ExecutionState.FINISHED || state == ExecutionState.SCHEDULED || state == ExecutionState.DEPLOYING) { // Create local or remote channels assertEquals(localPartitionId, desc[0].getConsumedPartitionId()); assertTrue(desc[0].getConsumedPartitionLocation().isLocal()); assertNull(desc[0].getConsumedPartitionLocation().getConnectionId()); assertEquals(remotePartitionId, desc[1].getConsumedPartitionId()); assertTrue(desc[1].getConsumedPartitionLocation().isRemote()); assertEquals(remoteConnectionId, desc[1].getConsumedPartitionLocation().getConnectionId()); } else { // Unknown (lazy deployment allowed) assertEquals(localPartitionId, desc[0].getConsumedPartitionId()); assertTrue(desc[0].getConsumedPartitionLocation().isUnknown()); assertNull(desc[0].getConsumedPartitionLocation().getConnectionId()); assertEquals(remotePartitionId, desc[1].getConsumedPartitionId()); assertTrue(desc[1].getConsumedPartitionLocation().isUnknown()); assertNull(desc[1].getConsumedPartitionLocation().getConnectionId()); } assertEquals(unknownPartitionId, desc[2].getConsumedPartitionId()); assertTrue(desc[2].getConsumedPartitionLocation().isUnknown()); assertNull(desc[2].getConsumedPartitionLocation().getConnectionId()); } }