Search in sources :

Example 61 with FlinkException

use of org.apache.flink.util.FlinkException in project flink by apache.

the class JobMaster method notifyOfNewResourceManagerLeader.

private void notifyOfNewResourceManagerLeader(final String newResourceManagerAddress, final ResourceManagerId resourceManagerId) {
    resourceManagerAddress = createResourceManagerAddress(newResourceManagerAddress, resourceManagerId);
    reconnectToResourceManager(new FlinkException(String.format("ResourceManager leader changed to new address %s", resourceManagerAddress)));
}
Also used : FlinkException(org.apache.flink.util.FlinkException)

Example 62 with FlinkException

use of org.apache.flink.util.FlinkException in project flink by apache.

the class JobMasterServiceLeadershipRunner method stopJobMasterServiceProcess.

@GuardedBy("lock")
private CompletableFuture<Void> stopJobMasterServiceProcess() {
    LOG.debug("Stop current JobMasterServiceProcess because the leadership has been revoked.");
    jobMasterGatewayFuture.completeExceptionally(new FlinkException("Cannot obtain JobMasterGateway because the JobMaster lost leadership."));
    jobMasterGatewayFuture = new CompletableFuture<>();
    hasCurrentLeaderBeenCancelled = false;
    return jobMasterServiceProcess.closeAsync();
}
Also used : FlinkException(org.apache.flink.util.FlinkException) GuardedBy(javax.annotation.concurrent.GuardedBy)

Example 63 with FlinkException

use of org.apache.flink.util.FlinkException in project flink by apache.

the class JobMasterServiceLeadershipRunner method onJobCompletion.

@GuardedBy("lock")
private void onJobCompletion(JobManagerRunnerResult jobManagerRunnerResult, Throwable throwable) {
    state = State.JOB_COMPLETED;
    LOG.debug("Completing the result for job {}.", getJobID());
    if (throwable != null) {
        resultFuture.completeExceptionally(throwable);
        jobMasterGatewayFuture.completeExceptionally(new FlinkException("Could not retrieve JobMasterGateway because the JobMaster failed.", throwable));
    } else {
        if (!jobManagerRunnerResult.isSuccess()) {
            jobMasterGatewayFuture.completeExceptionally(new FlinkException("Could not retrieve JobMasterGateway because the JobMaster initialization failed.", jobManagerRunnerResult.getInitializationFailure()));
        }
        resultFuture.complete(jobManagerRunnerResult);
    }
}
Also used : FlinkException(org.apache.flink.util.FlinkException) GuardedBy(javax.annotation.concurrent.GuardedBy)

Example 64 with FlinkException

use of org.apache.flink.util.FlinkException in project flink by apache.

the class SourceCoordinator method handleEventFromOperator.

@Override
public void handleEventFromOperator(int subtask, OperatorEvent event) {
    runInEventLoop(() -> {
        if (event instanceof RequestSplitEvent) {
            LOG.info("Source {} received split request from parallel task {}", operatorName, subtask);
            enumerator.handleSplitRequest(subtask, ((RequestSplitEvent) event).hostName());
        } else if (event instanceof SourceEventWrapper) {
            final SourceEvent sourceEvent = ((SourceEventWrapper) event).getSourceEvent();
            LOG.debug("Source {} received custom event from parallel task {}: {}", operatorName, subtask, sourceEvent);
            enumerator.handleSourceEvent(subtask, sourceEvent);
        } else if (event instanceof ReaderRegistrationEvent) {
            final ReaderRegistrationEvent registrationEvent = (ReaderRegistrationEvent) event;
            LOG.info("Source {} registering reader for parallel task {} @ {}", operatorName, subtask, registrationEvent.location());
            handleReaderRegistrationEvent(registrationEvent);
        } else if (event instanceof ReportedWatermarkEvent) {
            handleReportedWatermark(subtask, new Watermark(((ReportedWatermarkEvent) event).getWatermark()));
        } else {
            throw new FlinkException("Unrecognized Operator Event: " + event);
        }
    }, "handling operator event %s from subtask %d", event, subtask);
}
Also used : RequestSplitEvent(org.apache.flink.runtime.source.event.RequestSplitEvent) SourceEventWrapper(org.apache.flink.runtime.source.event.SourceEventWrapper) ReaderRegistrationEvent(org.apache.flink.runtime.source.event.ReaderRegistrationEvent) Watermark(org.apache.flink.api.common.eventtime.Watermark) FlinkException(org.apache.flink.util.FlinkException) SourceEvent(org.apache.flink.api.connector.source.SourceEvent) ReportedWatermarkEvent(org.apache.flink.runtime.source.event.ReportedWatermarkEvent)

Example 65 with FlinkException

use of org.apache.flink.util.FlinkException in project flink by apache.

the class TaskSlotTableImpl method closeAsync.

@Override
public CompletableFuture<Void> closeAsync() {
    if (state == State.CREATED) {
        state = State.CLOSED;
        closingFuture.complete(null);
    } else if (state == State.RUNNING) {
        state = State.CLOSING;
        final FlinkException cause = new FlinkException("Closing task slot table");
        CompletableFuture<Void> cleanupFuture = FutureUtils.waitForAll(new ArrayList<>(allocatedSlots.values()).stream().map(slot -> freeSlotInternal(slot, cause)).collect(Collectors.toList())).thenRunAsync(() -> {
            state = State.CLOSED;
            timerService.stop();
        }, mainThreadExecutor);
        FutureUtils.forward(cleanupFuture, closingFuture);
    }
    return closingFuture;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) ArrayList(java.util.ArrayList) FlinkException(org.apache.flink.util.FlinkException)

Aggregations

FlinkException (org.apache.flink.util.FlinkException)197 Test (org.junit.Test)91 CompletableFuture (java.util.concurrent.CompletableFuture)59 IOException (java.io.IOException)38 ExecutionException (java.util.concurrent.ExecutionException)26 ArrayList (java.util.ArrayList)25 JobID (org.apache.flink.api.common.JobID)24 Collection (java.util.Collection)22 CompletionException (java.util.concurrent.CompletionException)22 Configuration (org.apache.flink.configuration.Configuration)21 TimeoutException (java.util.concurrent.TimeoutException)19 FutureUtils (org.apache.flink.util.concurrent.FutureUtils)19 Time (org.apache.flink.api.common.time.Time)16 OneShotLatch (org.apache.flink.core.testutils.OneShotLatch)16 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)16 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)15 AllocationID (org.apache.flink.runtime.clusterframework.types.AllocationID)14 Collections (java.util.Collections)13 List (java.util.List)13 ExecutorService (java.util.concurrent.ExecutorService)13