Java Code Examples for io.grpc.Status.Code#UNIMPLEMENTED

The following examples show how to use io.grpc.Status.Code#UNIMPLEMENTED . 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: StubWriteOutputStream.java    From bazel-buildfarm with Apache License 2.0 6 votes vote down vote up
@Override
public QueryWriteStatusResponse get() {
  if (wasReset) {
    return resetResponse;
  }
  try {
    QueryWriteStatusResponse response =
        bsBlockingStub
            .get()
            .queryWriteStatus(
                QueryWriteStatusRequest.newBuilder()
                    .setResourceName(resourceName)
                    .build());
    if (response.getComplete()) {
      writeFuture.set(response.getCommittedSize());
    }
    return response;
  } catch (StatusRuntimeException e) {
    Status status = Status.fromThrowable(e);
    if (status.getCode() == Code.UNIMPLEMENTED || status.getCode() == Code.NOT_FOUND) {
      return resetResponse;
    }
    throw e;
  }
}
 
Example 2
Source File: JobsRpcUtils.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
private static Code toCode(ErrorType errorType) {
  switch (errorType) {
  case DATA_READ:
  case DATA_WRITE:
    return Code.FAILED_PRECONDITION;

  case PERMISSION:
    return Code.PERMISSION_DENIED;

  case RESOURCE:
    return Code.RESOURCE_EXHAUSTED;

  case UNSUPPORTED_OPERATION:
    return Code.UNIMPLEMENTED;

  case PARSE:
  case PLAN:
  case VALIDATION:
    return Code.INVALID_ARGUMENT;

  case CONCURRENT_MODIFICATION:
    return Code.ABORTED;

  case FUNCTION:
  case IO_EXCEPTION:
  case CONNECTION:
  case SCHEMA_CHANGE:
  case INVALID_DATASET_METADATA:
  case REFLECTION_ERROR:
  case SOURCE_BAD_STATE:
  case JSON_FIELD_CHANGE:
  case SYSTEM:
  case OUT_OF_MEMORY:
    return Code.INTERNAL;

  default:
    return Code.UNKNOWN;
  }
}
 
Example 3
Source File: RemoteInputStreamFactory.java    From bazel-buildfarm with Apache License 2.0 5 votes vote down vote up
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 4
Source File: ConflictGenerator.java    From modeldb with Apache License 2.0 5 votes vote down vote up
private static BlobDiff updateDiffBasedOnDiffType(
    List<BlobDiff> locSpecificBlobDiffList,
    AutogenBlobDiff a,
    AutogenBlobDiff b,
    AutogenBlob c,
    BlobDiff blobDiff)
    throws ModelDBException {
  AutogenBlobDiff diff = AutogenBlobDiff.fromProto(blobDiff);
  switch (locSpecificBlobDiffList.get(0).getContentCase()) {
    case CODE:
      return diff.setCode(getCodeConflictBlob(a.getCode(), b.getCode(), c.getCode()).get(0))
          .toProto()
          .build();
    case CONFIG:
      return diff.setConfig(getConfigConflictBlob(a.getConfig(), b.getConfig(), c.getConfig()))
          .toProto()
          .build();
    case DATASET:
      return diff.setDataset(
              getDatasetConflictBlob(a.getDataset(), b.getDataset(), c.getDataset()).get(0))
          .toProto()
          .build();
    case ENVIRONMENT:
      return diff.setEnvironment(
              getEnvironmentonflictBlob(
                      a.getEnvironment(), b.getEnvironment(), c.getEnvironment())
                  .get(0))
          .toProto()
          .build();
    case CONTENT_NOT_SET:
      return diff.toProto().build();
    default:
      LOGGER.warn(
          "unsupported diff type found, {}", locSpecificBlobDiffList.get(0).getContentCase());
      throw new ModelDBException(
          "unsupported diff type found" + locSpecificBlobDiffList.get(0).getContentCase(),
          Code.UNIMPLEMENTED);
  }
}