Java Code Examples for io.grpc.Status.Code#CANCELLED
The following examples show how to use
io.grpc.Status.Code#CANCELLED .
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: OkHttpClientTransport.java From grpc-java with Apache License 2.0 | 6 votes |
@Override public void rstStream(int streamId, ErrorCode errorCode) { logger.logRstStream(OkHttpFrameLogger.Direction.INBOUND, streamId, errorCode); Status status = toGrpcStatus(errorCode).augmentDescription("Rst Stream"); boolean stopDelivery = (status.getCode() == Code.CANCELLED || status.getCode() == Code.DEADLINE_EXCEEDED); synchronized (lock) { OkHttpClientStream stream = streams.get(streamId); if (stream != null) { PerfMark.event("OkHttpClientTransport$ClientFrameHandler.rstStream", stream.transportState().tag()); finishStream( streamId, status, errorCode == ErrorCode.REFUSED_STREAM ? RpcProgress.REFUSED : RpcProgress.PROCESSED, stopDelivery, null, null); } } }
Example 2
Source File: CronetClientTransport.java From grpc-nebula-java with Apache License 2.0 | 5 votes |
void finishStream(CronetClientStream stream, Status status) { synchronized (lock) { if (streams.remove(stream)) { boolean isCancelled = (status.getCode() == Code.CANCELLED || status.getCode() == Code.DEADLINE_EXCEEDED); stream.transportState().transportReportStatus(status, isCancelled, new Metadata()); } else { return; } } stopIfNecessary(); }
Example 3
Source File: OkHttpClientTransport.java From grpc-nebula-java with Apache License 2.0 | 5 votes |
@Override public void rstStream(int streamId, ErrorCode errorCode) { Status status = toGrpcStatus(errorCode).augmentDescription("Rst Stream"); boolean stopDelivery = (status.getCode() == Code.CANCELLED || status.getCode() == Code.DEADLINE_EXCEEDED); finishStream( streamId, status, errorCode == ErrorCode.REFUSED_STREAM ? RpcProgress.REFUSED : RpcProgress.PROCESSED, stopDelivery, null, null); }
Example 4
Source File: EtcdClient.java From etcd-java with Apache License 2.0 | 5 votes |
protected static boolean reauthRequired(Throwable error) { Status status = Status.fromThrowable(error); Code code = status.getCode(); return code == Code.UNAUTHENTICATED || (OTHER_AUTH_FAILURE_CODES.contains(code) && (startsWith(status.getDescription(), "auth: ") || endsWith(status.getDescription(), AUTH_FAILURE_MESSAGES))) || (code == Code.CANCELLED && reauthRequired(error.getCause())); }
Example 5
Source File: RemoteInputStreamFactory.java From bazel-buildfarm with Apache License 2.0 | 5 votes |
private InputStream fetchBlobFromRemoteWorker( Digest blobDigest, Deque<String> workers, long offset, long deadlineAfter, TimeUnit deadlineAfterUnits, RequestMetadata requestMetadata) throws IOException, InterruptedException { String worker = workers.removeFirst(); try { Instance instance = workerStub(worker); InputStream input = instance.newBlobInput( blobDigest, offset, deadlineAfter, deadlineAfterUnits, requestMetadata); // ensure that if the blob cannot be fetched, that we throw here input.available(); if (Thread.interrupted()) { throw new InterruptedException(); } return input; } catch (StatusRuntimeException e) { Status st = Status.fromThrowable(e); if (st.getCode() == Code.UNAVAILABLE || st.getCode() == Code.UNIMPLEMENTED) { // for now, leave this up to schedulers onUnavailable.accept(worker, e, "getBlob(" + DigestUtil.toString(blobDigest) + ")"); } else if (st.getCode() == Code.NOT_FOUND) { // ignore this, the worker will update the backplane eventually } else if (st.getCode() != Code.DEADLINE_EXCEEDED && SHARD_IS_RETRIABLE.test(st)) { // why not, always workers.addLast(worker); } else if (st.getCode() == Code.CANCELLED) { throw new InterruptedException(); } else { throw e; } } throw new NoSuchFileException(DigestUtil.toString(blobDigest)); }
Example 6
Source File: ByteStreamService.java From bazel-buildfarm with Apache License 2.0 | 5 votes |
ServerCallStreamObserver<ReadResponse> onErrorLogReadObserver( String name, long offset, ServerCallStreamObserver<ReadResponse> delegate) { return new UniformDelegateServerCallStreamObserver<ReadResponse>(delegate) { long responseCount = 0; long responseBytes = 0; @Override public void onNext(ReadResponse response) { delegate.onNext(response); responseCount++; responseBytes += response.getData().size(); } @Override public void onError(Throwable t) { Status status = Status.fromThrowable(t); if (status.getCode() != Code.NOT_FOUND) { java.util.logging.Level level = Level.SEVERE; if (responseCount > 0 && status.getCode() == Code.DEADLINE_EXCEEDED || status.getCode() == Code.CANCELLED) { level = Level.WARNING; } String message = format("error reading %s at offset %d", name, offset); if (responseCount > 0) { message += format(" after %d responses and %d bytes of content", responseCount, responseBytes); } logger.log(level, message, t); } delegate.onError(t); } @Override public void onCompleted() { delegate.onCompleted(); } }; }
Example 7
Source File: CronetClientTransport.java From grpc-java with Apache License 2.0 | 5 votes |
void finishStream(CronetClientStream stream, Status status) { synchronized (lock) { if (streams.remove(stream)) { boolean isCancelled = (status.getCode() == Code.CANCELLED || status.getCode() == Code.DEADLINE_EXCEEDED); stream.transportState().transportReportStatus(status, isCancelled, new Metadata()); } else { return; } } stopIfNecessary(); }