Java Code Examples for org.apache.flink.util.ExceptionUtils#stringifyException()
The following examples show how to use
org.apache.flink.util.ExceptionUtils#stringifyException() .
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: StringifiedAccumulatorResult.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
private static StringifiedAccumulatorResult stringifyAccumulatorResult( String name, @Nullable OptionalFailure<Accumulator<?, ?>> accumulator) { if (accumulator == null) { return new StringifiedAccumulatorResult(name, "null", "null"); } else if (accumulator.isFailure()) { return new StringifiedAccumulatorResult( name, "null", ExceptionUtils.stringifyException(accumulator.getFailureCause())); } else { Object localValue; String simpleName = "null"; try { simpleName = accumulator.getUnchecked().getClass().getSimpleName(); localValue = accumulator.getUnchecked().getLocalValue(); } catch (RuntimeException exception) { LOG.error("Failed to stringify accumulator [" + name + "]", exception); localValue = ExceptionUtils.stringifyException(exception); } return new StringifiedAccumulatorResult(name, simpleName, localValue != null ? localValue.toString() : "null"); } }
Example 2
Source File: KvStateServerHandler.java From flink with Apache License 2.0 | 6 votes |
@Override public CompletableFuture<KvStateResponse> handleRequest(final long requestId, final KvStateInternalRequest request) { final CompletableFuture<KvStateResponse> responseFuture = new CompletableFuture<>(); try { final KvStateEntry<?, ?, ?> kvState = registry.getKvState(request.getKvStateId()); if (kvState == null) { responseFuture.completeExceptionally(new UnknownKvStateIdException(getServerName(), request.getKvStateId())); } else { byte[] serializedKeyAndNamespace = request.getSerializedKeyAndNamespace(); byte[] serializedResult = getSerializedValue(kvState, serializedKeyAndNamespace); if (serializedResult != null) { responseFuture.complete(new KvStateResponse(serializedResult)); } else { responseFuture.completeExceptionally(new UnknownKeyOrNamespaceException(getServerName())); } } return responseFuture; } catch (Throwable t) { String errMsg = "Error while processing request with ID " + requestId + ". Caused by: " + ExceptionUtils.stringifyException(t); responseFuture.completeExceptionally(new RuntimeException(errMsg)); return responseFuture; } }
Example 3
Source File: StringifiedAccumulatorResult.java From flink with Apache License 2.0 | 6 votes |
private static StringifiedAccumulatorResult stringifyAccumulatorResult( String name, @Nullable OptionalFailure<Accumulator<?, ?>> accumulator) { if (accumulator == null) { return new StringifiedAccumulatorResult(name, "null", "null"); } else if (accumulator.isFailure()) { return new StringifiedAccumulatorResult( name, "null", ExceptionUtils.stringifyException(accumulator.getFailureCause())); } else { Object localValue; String simpleName = "null"; try { simpleName = accumulator.getUnchecked().getClass().getSimpleName(); localValue = accumulator.getUnchecked().getLocalValue(); } catch (RuntimeException exception) { LOG.error("Failed to stringify accumulator [" + name + "]", exception); localValue = ExceptionUtils.stringifyException(exception); } return new StringifiedAccumulatorResult(name, simpleName, localValue != null ? localValue.toString() : "null"); } }
Example 4
Source File: KvStateServerHandler.java From flink with Apache License 2.0 | 6 votes |
@Override public CompletableFuture<KvStateResponse> handleRequest(final long requestId, final KvStateInternalRequest request) { final CompletableFuture<KvStateResponse> responseFuture = new CompletableFuture<>(); try { final KvStateEntry<?, ?, ?> kvState = registry.getKvState(request.getKvStateId()); if (kvState == null) { responseFuture.completeExceptionally(new UnknownKvStateIdException(getServerName(), request.getKvStateId())); } else { byte[] serializedKeyAndNamespace = request.getSerializedKeyAndNamespace(); byte[] serializedResult = getSerializedValue(kvState, serializedKeyAndNamespace); if (serializedResult != null) { responseFuture.complete(new KvStateResponse(serializedResult)); } else { responseFuture.completeExceptionally(new UnknownKeyOrNamespaceException(getServerName())); } } return responseFuture; } catch (Throwable t) { String errMsg = "Error while processing request with ID " + requestId + ". Caused by: " + ExceptionUtils.stringifyException(t); responseFuture.completeExceptionally(new RuntimeException(errMsg)); return responseFuture; } }
Example 5
Source File: KvStateServerHandler.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override public CompletableFuture<KvStateResponse> handleRequest(final long requestId, final KvStateInternalRequest request) { final CompletableFuture<KvStateResponse> responseFuture = new CompletableFuture<>(); try { final KvStateEntry<?, ?, ?> kvState = registry.getKvState(request.getKvStateId()); if (kvState == null) { responseFuture.completeExceptionally(new UnknownKvStateIdException(getServerName(), request.getKvStateId())); } else { byte[] serializedKeyAndNamespace = request.getSerializedKeyAndNamespace(); byte[] serializedResult = getSerializedValue(kvState, serializedKeyAndNamespace); if (serializedResult != null) { responseFuture.complete(new KvStateResponse(serializedResult)); } else { responseFuture.completeExceptionally(new UnknownKeyOrNamespaceException(getServerName())); } } return responseFuture; } catch (Throwable t) { String errMsg = "Error while processing request with ID " + requestId + ". Caused by: " + ExceptionUtils.stringifyException(t); responseFuture.completeExceptionally(new RuntimeException(errMsg)); return responseFuture; } }
Example 6
Source File: AbstractServerHandler.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { final String msg = "Exception in server pipeline. Caused by: " + ExceptionUtils.stringifyException(cause); final ByteBuf err = MessageSerializer.serializeServerFailure(ctx.alloc(), new RuntimeException(msg)); LOG.debug(msg); ctx.writeAndFlush(err).addListener(ChannelFutureListener.CLOSE); }
Example 7
Source File: AbstractServerHandler.java From flink with Apache License 2.0 | 5 votes |
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { final String msg = "Exception in server pipeline. Caused by: " + ExceptionUtils.stringifyException(cause); final ByteBuf err = MessageSerializer.serializeServerFailure(ctx.alloc(), new RuntimeException(msg)); LOG.debug(msg); ctx.writeAndFlush(err).addListener(ChannelFutureListener.CLOSE); }
Example 8
Source File: ArchivedExecution.java From flink with Apache License 2.0 | 5 votes |
public ArchivedExecution(Execution execution) { this( execution.getUserAccumulatorsStringified(), execution.getIOMetrics(), execution.getAttemptId(), execution.getAttemptNumber(), execution.getState(), ExceptionUtils.stringifyException(execution.getFailureCause()), execution.getAssignedResourceLocation(), execution.getAssignedAllocationID(), execution.getVertex().getParallelSubtaskIndex(), execution.getStateTimestamps()); }
Example 9
Source File: AbstractServerHandler.java From flink with Apache License 2.0 | 5 votes |
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { final String msg = "Exception in server pipeline. Caused by: " + ExceptionUtils.stringifyException(cause); final ByteBuf err = MessageSerializer.serializeServerFailure(ctx.alloc(), new RuntimeException(msg)); LOG.debug(msg); ctx.writeAndFlush(err).addListener(ChannelFutureListener.CLOSE); }
Example 10
Source File: ArchivedExecution.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
public ArchivedExecution(Execution execution) { this( execution.getUserAccumulatorsStringified(), execution.getIOMetrics(), execution.getAttemptId(), execution.getAttemptNumber(), execution.getState(), ExceptionUtils.stringifyException(execution.getFailureCause()), execution.getAssignedResourceLocation(), execution.getAssignedAllocationID(), execution.getVertex().getParallelSubtaskIndex(), execution.getStateTimestamps()); }
Example 11
Source File: ArchivedExecution.java From flink with Apache License 2.0 | 5 votes |
public ArchivedExecution(Execution execution) { this( execution.getUserAccumulatorsStringified(), execution.getIOMetrics(), execution.getAttemptId(), execution.getAttemptNumber(), execution.getState(), ExceptionUtils.stringifyException(execution.getFailureCause()), execution.getAssignedResourceLocation(), execution.getAssignedAllocationID(), execution.getVertex().getParallelSubtaskIndex(), execution.getStateTimestamps()); }
Example 12
Source File: Execution.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override public String getFailureCauseAsString() { return ExceptionUtils.stringifyException(getFailureCause()); }
Example 13
Source File: AbstractOperatorRestoreTestBase.java From flink with Apache License 2.0 | 4 votes |
private String migrateJob(ClassLoader classLoader, ClusterClient<?> clusterClient, Deadline deadline) throws Throwable { URL savepointResource = AbstractOperatorRestoreTestBase.class.getClassLoader().getResource("operatorstate/" + getMigrationSavepointName()); if (savepointResource == null) { throw new IllegalArgumentException("Savepoint file does not exist."); } JobGraph jobToMigrate = createJobGraph(ExecutionMode.MIGRATE); jobToMigrate.setSavepointRestoreSettings(SavepointRestoreSettings.forPath(savepointResource.getFile())); assertNotNull(jobToMigrate.getJobID()); clusterClient.submitJob(jobToMigrate, classLoader); CompletableFuture<JobStatus> jobRunningFuture = FutureUtils.retrySuccessfulWithDelay( () -> clusterClient.getJobStatus(jobToMigrate.getJobID()), Time.milliseconds(50), deadline, (jobStatus) -> jobStatus == JobStatus.RUNNING, TestingUtils.defaultScheduledExecutor()); assertEquals( JobStatus.RUNNING, jobRunningFuture.get(deadline.timeLeft().toMillis(), TimeUnit.MILLISECONDS)); // Trigger savepoint File targetDirectory = tmpFolder.newFolder(); String savepointPath = null; // FLINK-6918: Retry cancel with savepoint message in case that StreamTasks were not running // TODO: The retry logic should be removed once the StreamTask lifecycle has been fixed (see FLINK-4714) while (deadline.hasTimeLeft() && savepointPath == null) { try { savepointPath = clusterClient.cancelWithSavepoint( jobToMigrate.getJobID(), targetDirectory.getAbsolutePath()); } catch (Exception e) { String exceptionString = ExceptionUtils.stringifyException(e); if (!PATTERN_CANCEL_WITH_SAVEPOINT_TOLERATED_EXCEPTIONS.matcher(exceptionString).find()) { throw e; } } } assertNotNull("Could not take savepoint.", savepointPath); CompletableFuture<JobStatus> jobCanceledFuture = FutureUtils.retrySuccessfulWithDelay( () -> clusterClient.getJobStatus(jobToMigrate.getJobID()), Time.milliseconds(50), deadline, (jobStatus) -> jobStatus == JobStatus.CANCELED, TestingUtils.defaultScheduledExecutor()); assertEquals( JobStatus.CANCELED, jobCanceledFuture.get(deadline.timeLeft().toMillis(), TimeUnit.MILLISECONDS)); return savepointPath; }
Example 14
Source File: ExecutionVertex.java From flink with Apache License 2.0 | 4 votes |
@Override public String getFailureCauseAsString() { return ExceptionUtils.stringifyException(getFailureCause()); }
Example 15
Source File: Execution.java From flink with Apache License 2.0 | 4 votes |
@Override public String getFailureCauseAsString() { return ExceptionUtils.stringifyException(getFailureCause()); }
Example 16
Source File: ExecutionVertex.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override public String getFailureCauseAsString() { return ExceptionUtils.stringifyException(getFailureCause()); }
Example 17
Source File: AbstractOperatorRestoreTestBase.java From flink with Apache License 2.0 | 4 votes |
private String migrateJob(ClusterClient<?> clusterClient, Deadline deadline) throws Throwable { URL savepointResource = AbstractOperatorRestoreTestBase.class.getClassLoader().getResource("operatorstate/" + getMigrationSavepointName()); if (savepointResource == null) { throw new IllegalArgumentException("Savepoint file does not exist."); } JobGraph jobToMigrate = createJobGraph(ExecutionMode.MIGRATE); jobToMigrate.setSavepointRestoreSettings(SavepointRestoreSettings.forPath(savepointResource.getFile())); assertNotNull(jobToMigrate.getJobID()); ClientUtils.submitJob(clusterClient, jobToMigrate); CompletableFuture<JobStatus> jobRunningFuture = FutureUtils.retrySuccessfulWithDelay( () -> clusterClient.getJobStatus(jobToMigrate.getJobID()), Time.milliseconds(50), deadline, (jobStatus) -> jobStatus == JobStatus.RUNNING, TestingUtils.defaultScheduledExecutor()); assertEquals( JobStatus.RUNNING, jobRunningFuture.get(deadline.timeLeft().toMillis(), TimeUnit.MILLISECONDS)); // Trigger savepoint File targetDirectory = tmpFolder.newFolder(); String savepointPath = null; // FLINK-6918: Retry cancel with savepoint message in case that StreamTasks were not running // TODO: The retry logic should be removed once the StreamTask lifecycle has been fixed (see FLINK-4714) while (deadline.hasTimeLeft() && savepointPath == null) { try { savepointPath = clusterClient.cancelWithSavepoint( jobToMigrate.getJobID(), targetDirectory.getAbsolutePath()).get(); } catch (Exception e) { String exceptionString = ExceptionUtils.stringifyException(e); if (!PATTERN_CANCEL_WITH_SAVEPOINT_TOLERATED_EXCEPTIONS.matcher(exceptionString).find()) { throw e; } } } assertNotNull("Could not take savepoint.", savepointPath); CompletableFuture<JobStatus> jobCanceledFuture = FutureUtils.retrySuccessfulWithDelay( () -> clusterClient.getJobStatus(jobToMigrate.getJobID()), Time.milliseconds(50), deadline, (jobStatus) -> jobStatus == JobStatus.CANCELED, TestingUtils.defaultScheduledExecutor()); assertEquals( JobStatus.CANCELED, jobCanceledFuture.get(deadline.timeLeft().toMillis(), TimeUnit.MILLISECONDS)); return savepointPath; }
Example 18
Source File: ExecutionVertex.java From flink with Apache License 2.0 | 4 votes |
@Override public String getFailureCauseAsString() { return ExceptionUtils.stringifyException(getFailureCause()); }
Example 19
Source File: Execution.java From flink with Apache License 2.0 | 4 votes |
@Override public String getFailureCauseAsString() { return ExceptionUtils.stringifyException(getFailureCause()); }
Example 20
Source File: AbstractOperatorRestoreTestBase.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
private String migrateJob(ClassLoader classLoader, ClusterClient<?> clusterClient, Deadline deadline) throws Throwable { URL savepointResource = AbstractOperatorRestoreTestBase.class.getClassLoader().getResource("operatorstate/" + getMigrationSavepointName()); if (savepointResource == null) { throw new IllegalArgumentException("Savepoint file does not exist."); } JobGraph jobToMigrate = createJobGraph(ExecutionMode.MIGRATE); jobToMigrate.setSavepointRestoreSettings(SavepointRestoreSettings.forPath(savepointResource.getFile())); assertNotNull(jobToMigrate.getJobID()); clusterClient.submitJob(jobToMigrate, classLoader); CompletableFuture<JobStatus> jobRunningFuture = FutureUtils.retrySuccessfulWithDelay( () -> clusterClient.getJobStatus(jobToMigrate.getJobID()), Time.milliseconds(50), deadline, (jobStatus) -> jobStatus == JobStatus.RUNNING, TestingUtils.defaultScheduledExecutor()); assertEquals( JobStatus.RUNNING, jobRunningFuture.get(deadline.timeLeft().toMillis(), TimeUnit.MILLISECONDS)); // Trigger savepoint File targetDirectory = tmpFolder.newFolder(); String savepointPath = null; // FLINK-6918: Retry cancel with savepoint message in case that StreamTasks were not running // TODO: The retry logic should be removed once the StreamTask lifecycle has been fixed (see FLINK-4714) while (deadline.hasTimeLeft() && savepointPath == null) { try { savepointPath = clusterClient.cancelWithSavepoint( jobToMigrate.getJobID(), targetDirectory.getAbsolutePath()); } catch (Exception e) { String exceptionString = ExceptionUtils.stringifyException(e); if (!(exceptionString.matches("(.*\n)*.*savepoint for the job .* failed(.*\n)*") // legacy || exceptionString.matches("(.*\n)*.*was not running(.*\n)*") || exceptionString.matches("(.*\n)*.*Not all required tasks are currently running(.*\n)*") // new || exceptionString.matches("(.*\n)*.*Checkpoint was declined \\(tasks not ready\\)(.*\n)*"))) { // new throw e; } } } assertNotNull("Could not take savepoint.", savepointPath); CompletableFuture<JobStatus> jobCanceledFuture = FutureUtils.retrySuccessfulWithDelay( () -> clusterClient.getJobStatus(jobToMigrate.getJobID()), Time.milliseconds(50), deadline, (jobStatus) -> jobStatus == JobStatus.CANCELED, TestingUtils.defaultScheduledExecutor()); assertEquals( JobStatus.CANCELED, jobCanceledFuture.get(deadline.timeLeft().toMillis(), TimeUnit.MILLISECONDS)); return savepointPath; }