Java Code Examples for io.grpc.Status.Code#INVALID_ARGUMENT
The following examples show how to use
io.grpc.Status.Code#INVALID_ARGUMENT .
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: VersioningServiceImpl.java From modeldb with Apache License 2.0 | 6 votes |
@Override public void deleteBranch( DeleteBranchRequest request, StreamObserver<DeleteBranchRequest.Response> responseObserver) { QPSCountResource.inc(); try { try (RequestLatencyResource latencyResource = new RequestLatencyResource(modelDBAuthInterceptor.getMethodName())) { if (request.getBranch().isEmpty()) { throw new ModelDBException( "Branch not found in the DeleteBranchRequest", Code.INVALID_ARGUMENT); } DeleteBranchRequest.Response response = repositoryDAO.deleteBranch(request); responseObserver.onNext(response); responseObserver.onCompleted(); } } catch (Exception e) { ModelDBUtils.observeError( responseObserver, e, DeleteBranchRequest.Response.getDefaultInstance()); } }
Example 2
Source File: VersioningServiceImpl.java From modeldb with Apache License 2.0 | 6 votes |
@Override public void deleteTag( DeleteTagRequest request, StreamObserver<DeleteTagRequest.Response> responseObserver) { QPSCountResource.inc(); try { try (RequestLatencyResource latencyResource = new RequestLatencyResource(modelDBAuthInterceptor.getMethodName())) { if (request.getTag().isEmpty()) { throw new ModelDBException( "Tag not found in the DeleteTagRequest", Code.INVALID_ARGUMENT); } DeleteTagRequest.Response response = repositoryDAO.deleteTag(request); responseObserver.onNext(response); responseObserver.onCompleted(); } } catch (Exception e) { ModelDBUtils.observeError( responseObserver, e, DeleteTagRequest.Response.getDefaultInstance()); } }
Example 3
Source File: VersioningServiceImpl.java From modeldb with Apache License 2.0 | 6 votes |
@Override public void listCommitExperimentRuns( ListCommitExperimentRunsRequest request, StreamObserver<ListCommitExperimentRunsRequest.Response> responseObserver) { QPSCountResource.inc(); try (RequestLatencyResource latencyResource = new RequestLatencyResource(modelDBAuthInterceptor.getMethodName())) { if (request.getCommitSha().isEmpty()) { throw new ModelDBException("Commit SHA should not be empty", Code.INVALID_ARGUMENT); } ListCommitExperimentRunsRequest.Response response = experimentRunDAO.listCommitExperimentRuns( projectDAO, request, (session) -> repositoryDAO.getRepositoryById(session, request.getRepositoryId()), (session, repository) -> commitDAO.getCommitEntity(session, request.getCommitSha(), repository)); responseObserver.onNext(response); responseObserver.onCompleted(); } catch (Exception e) { ModelDBUtils.observeError( responseObserver, e, ListCommitExperimentRunsRequest.Response.getDefaultInstance()); } }
Example 4
Source File: LineageServiceImpl.java From modeldb with Apache License 2.0 | 6 votes |
@Override public void addLineage(AddLineage request, StreamObserver<AddLineage.Response> responseObserver) { QPSCountResource.inc(); try { if (request.getInputCount() == 0 && request.getOutputCount() == 0) { throw new ModelDBException("Input and output not specified", Code.INVALID_ARGUMENT); } else { if (request.getInputCount() == 0) { throw new ModelDBException("Input not specified", Code.INVALID_ARGUMENT); } else if (request.getOutputCount() == 0) { throw new ModelDBException("Output not specified", Code.INVALID_ARGUMENT); } } try (RequestLatencyResource latencyResource = new RequestLatencyResource(ModelDBAuthInterceptor.METHOD_NAME.get())) { AddLineage.Response response = lineageDAO.addLineage(request, this::isResourceExists); responseObserver.onNext(response); responseObserver.onCompleted(); } } catch (Exception e) { ModelDBUtils.observeError(responseObserver, e, AddLineage.Response.getDefaultInstance()); } }
Example 5
Source File: VersioningServiceImpl.java From modeldb with Apache License 2.0 | 6 votes |
private void validateGetUrlForVersionedBlobRequest(GetUrlForBlobVersioned request) throws ModelDBException { String errorMessage = null; if (request.getCommitSha().isEmpty() && request.getLocationList().isEmpty() && request.getMethod().isEmpty() && request.getPathDatasetComponentBlobPath().isEmpty()) { errorMessage = "Commit hash and Blob location and Method type AND Blob path not found in GetUrlForBlobVersioned request"; } else if (request.getCommitSha().isEmpty()) { errorMessage = "Commit hash not found in GetUrlForBlobVersioned request"; } else if (request.getLocationList().isEmpty()) { errorMessage = "Blob location not found in GetUrlForBlobVersioned request"; } else if (request.getPathDatasetComponentBlobPath().isEmpty()) { errorMessage = "Blob path not found in GetUrlForBlobVersioned request"; } else if (request.getMethod().isEmpty()) { errorMessage = "Method is not found in GetUrlForBlobVersioned request"; } if (errorMessage != null) { LOGGER.warn(errorMessage); throw new ModelDBException(errorMessage, Code.INVALID_ARGUMENT); } }
Example 6
Source File: VersioningServiceImpl.java From modeldb with Apache License 2.0 | 6 votes |
@Override public void listCommitBlobs( ListCommitBlobsRequest request, StreamObserver<ListCommitBlobsRequest.Response> responseObserver) { QPSCountResource.inc(); try (RequestLatencyResource latencyResource = new RequestLatencyResource(modelDBAuthInterceptor.getMethodName())) { if (request.getCommitSha().isEmpty()) { throw new ModelDBException("Commit SHA should not be empty", Code.INVALID_ARGUMENT); } ListCommitBlobsRequest.Response response = blobDAO.getCommitBlobsList( (session) -> repositoryDAO.getRepositoryById(session, request.getRepositoryId()), request.getCommitSha(), request.getLocationPrefixList()); responseObserver.onNext(response); responseObserver.onCompleted(); } catch (Exception e) { ModelDBUtils.observeError( responseObserver, e, ListCommitBlobsRequest.Response.getDefaultInstance()); } }
Example 7
Source File: VersioningServiceImpl.java From modeldb with Apache License 2.0 | 6 votes |
@Override public void listRepositories( ListRepositoriesRequest request, StreamObserver<Response> responseObserver) { QPSCountResource.inc(); try { try (RequestLatencyResource latencyResource = new RequestLatencyResource(modelDBAuthInterceptor.getMethodName())) { if (request.hasPagination()) { if (request.getPagination().getPageLimit() < 1 || request.getPagination().getPageLimit() > 100) { throw new ModelDBException("Page limit is invalid", Code.INVALID_ARGUMENT); } } UserInfo userInfo = authService.getCurrentLoginUserInfo(); Response response = repositoryDAO.listRepositories(request, userInfo); responseObserver.onNext(response); responseObserver.onCompleted(); } } catch (Exception e) { ModelDBUtils.observeError( responseObserver, e, ListRepositoriesRequest.Response.getDefaultInstance()); } }
Example 8
Source File: Validator.java From modeldb with Apache License 2.0 | 5 votes |
@Override public AutogenDockerEnvironmentBlob postVisitAutogenDockerEnvironmentBlob( AutogenDockerEnvironmentBlob blob) throws ModelDBException { if (blob.getRepository().isEmpty()) { throw new ModelDBException( "Environment repository path should not be empty", Code.INVALID_ARGUMENT); } return blob; }
Example 9
Source File: Validator.java From modeldb with Apache License 2.0 | 5 votes |
private void checkStringIsDouble( AutogenHyperparameterValuesConfigBlob beginSetConfigBlob, String description) throws ModelDBException { if (beginSetConfigBlob != null && !beginSetConfigBlob.getStringValue().isEmpty()) { try { Double.parseDouble(beginSetConfigBlob.getStringValue()); } catch (Exception ex) { throw new ModelDBException( description + HAS_A_STRING_VALUE_WHICH_IS_NOT_IN_A_VALID_NUMERIC_NOTATION, Code.INVALID_ARGUMENT); } } }
Example 10
Source File: VersioningServiceImpl.java From modeldb with Apache License 2.0 | 5 votes |
@Override public void commitMultipartVersionedBlobArtifact( CommitMultipartVersionedBlobArtifact request, StreamObserver<CommitMultipartVersionedBlobArtifact.Response> responseObserver) { QPSCountResource.inc(); try (RequestLatencyResource latencyResource = new RequestLatencyResource(ModelDBAuthInterceptor.METHOD_NAME.get())) { String errorMessage = null; if (request.getCommitSha().isEmpty() && request.getLocationList().isEmpty() && request.getPathDatasetComponentBlobPath().isEmpty()) { errorMessage = "Commit hash and Location and path not found in CommitMultipartVersionedBlobArtifact request"; } else if (request.getCommitSha().isEmpty()) { errorMessage = "Commit hash not found in CommitMultipartVersionedBlobArtifact request"; } else if (request.getLocationList().isEmpty()) { errorMessage = "Location not found in CommitMultipartVersionedBlobArtifact request"; } else if (request.getPathDatasetComponentBlobPath().isEmpty()) { errorMessage = "Path not found in CommitMultipartVersionedBlobArtifact request"; } if (errorMessage != null) { LOGGER.warn(errorMessage); throw new ModelDBException(errorMessage, Code.INVALID_ARGUMENT); } CommitMultipartVersionedBlobArtifact.Response response = blobDAO.commitMultipartVersionedBlobArtifact( (session) -> repositoryDAO.getRepositoryById(session, request.getRepositoryId()), (session, repository) -> commitDAO.getCommitEntity(session, request.getCommitSha(), repository), request, artifactStoreDAO::commitMultipart); responseObserver.onNext(response); responseObserver.onCompleted(); } catch (Exception e) { ModelDBUtils.observeError( responseObserver, e, CommitMultipartVersionedBlobArtifact.Response.getDefaultInstance()); } }
Example 11
Source File: Validator.java From modeldb with Apache License 2.0 | 5 votes |
@Override public AutogenGitCodeBlob postVisitAutogenGitCodeBlob(AutogenGitCodeBlob blob) throws ModelDBException { if (blob.getRepo().isEmpty()) { throw new ModelDBException("Code repository path should not be empty", Code.INVALID_ARGUMENT); } return blob; }
Example 12
Source File: Validator.java From modeldb with Apache License 2.0 | 5 votes |
@Override public AutogenHyperparameterSetConfigBlob postVisitAutogenHyperparameterSetConfigBlob( AutogenHyperparameterSetConfigBlob blob) throws ModelDBException { final String name = blob.getName(); if (name.isEmpty()) { throw new ModelDBException("Hyperparameter set name is empty", Code.INVALID_ARGUMENT); } return blob; }
Example 13
Source File: EnvironmentContainer.java From modeldb with Apache License 2.0 | 5 votes |
private void validateEnvironmentVariableName(String name) throws ModelDBException { if (!Pattern.compile(PATTERN).matcher(name).matches()) { throw new ModelDBException( "Environment variable name: " + name + " should be not empty, should contain only alphanumeric or underscore", Code.INVALID_ARGUMENT); } }
Example 14
Source File: Validator.java From modeldb with Apache License 2.0 | 5 votes |
@Override public AutogenPythonRequirementEnvironmentBlob postVisitAutogenPythonRequirementEnvironmentBlob( AutogenPythonRequirementEnvironmentBlob blob) throws ModelDBException { if (blob.getLibrary().isEmpty()) { throw new ModelDBException( "Requirement or constraint library name should not be empty", Code.INVALID_ARGUMENT); } return blob; }
Example 15
Source File: Validator.java From modeldb with Apache License 2.0 | 5 votes |
@Override public AutogenEnvironmentVariablesBlob postVisitAutogenEnvironmentVariablesBlob( AutogenEnvironmentVariablesBlob blob) throws ModelDBException { if (!Pattern.compile(PATTERN).matcher(blob.getName()).matches()) { throw new ModelDBException( "Environment variable name: " + blob.getName() + " should be not empty, should contain only alphanumeric or underscore", Code.INVALID_ARGUMENT); } return blob; }
Example 16
Source File: VersioningServiceImpl.java From modeldb with Apache License 2.0 | 5 votes |
@Override public void commitVersionedBlobArtifactPart( CommitVersionedBlobArtifactPart request, StreamObserver<CommitVersionedBlobArtifactPart.Response> responseObserver) { QPSCountResource.inc(); try (RequestLatencyResource latencyResource = new RequestLatencyResource(ModelDBAuthInterceptor.METHOD_NAME.get())) { String errorMessage = null; if (request.getCommitSha().isEmpty() && request.getLocationList().isEmpty() && !request.hasArtifactPart()) { errorMessage = "Commit hash and Location and Artifact Part not found in CommitVersionedBlobArtifactPart request"; } else if (request.getCommitSha().isEmpty()) { errorMessage = "Commit hash not found in CommitVersionedBlobArtifactPart request"; } else if (request.getLocationList().isEmpty()) { errorMessage = "Location not found in CommitVersionedBlobArtifactPart request"; } else if (!request.hasArtifactPart()) { errorMessage = "Artifact Part not found in CommitVersionedBlobArtifactPart request"; } if (errorMessage != null) { LOGGER.warn(errorMessage); throw new ModelDBException(errorMessage, Code.INVALID_ARGUMENT); } CommitVersionedBlobArtifactPart.Response response = blobDAO.commitVersionedBlobArtifactPart( (session) -> repositoryDAO.getRepositoryById(session, request.getRepositoryId()), (session, repository) -> commitDAO.getCommitEntity(session, request.getCommitSha(), repository), request); responseObserver.onNext(response); responseObserver.onCompleted(); } catch (Exception e) { ModelDBUtils.observeError( responseObserver, e, CommitVersionedBlobArtifactPart.Response.getDefaultInstance()); } }
Example 17
Source File: LineageDAORdbImpl.java From modeldb with Apache License 2.0 | 5 votes |
private void validate(LineageEntry lineageEntry) throws ModelDBException { String message; if (lineageEntry.getType() == LineageEntryType.UNKNOWN) { message = "Unknown lineage type"; } else if (lineageEntry.getExternalId().isEmpty()) { message = "External id is empty"; } else { message = null; } if (message != null) { LOGGER.info(message); throw new ModelDBException(message, Code.INVALID_ARGUMENT); } }
Example 18
Source File: JobsRpcUtils.java From dremio-oss with Apache License 2.0 | 5 votes |
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 19
Source File: GrpcClient.java From etcd-java with Apache License 2.0 | 4 votes |
protected boolean retryableStreamError(Throwable error) { return (Status.fromThrowable(error).getCode() != Code.INVALID_ARGUMENT && !causedBy(error, Error.class)); }
Example 20
Source File: VersioningServiceImpl.java From modeldb with Apache License 2.0 | 4 votes |
@Override public void createCommit( CreateCommitRequest request, StreamObserver<CreateCommitRequest.Response> responseObserver) { QPSCountResource.inc(); try (RequestLatencyResource latencyResource = new RequestLatencyResource(modelDBAuthInterceptor.getMethodName())) { if (request.getCommit().getParentShasList().isEmpty()) { throw new ModelDBException( "Parent commits not found in the CreateCommitRequest", Code.INVALID_ARGUMENT); } else if (request.getBlobsCount() > 0 && (!request.getCommitBase().isEmpty() || request.getDiffsCount() > 0)) { throw new ModelDBException( "Blob list and commit base with diffs should not be allowed together", Code.INVALID_ARGUMENT); } if (request.getCommit().getMessage().isEmpty()) { throw new ModelDBException("Commit message should not be empty", Code.INVALID_ARGUMENT); } List<BlobContainer> blobContainers; final RepositoryFunction repositoryFunction = (session) -> repositoryDAO.getRepositoryById(session, request.getRepositoryId(), true); if (request.getBlobsCount() != 0) { blobContainers = validateBlobs(request); } else if (request.getDiffsCount() != 0) { List<AutogenBlobDiff> diffs = validateBlobDiffs(request); blobContainers = blobDAO.convertBlobDiffsToBlobs( diffs, repositoryFunction, (session, repository) -> commitDAO.getCommitEntity(session, request.getCommitBase(), repository)); } else { blobContainers = Collections.emptyList(); } UserInfo currentLoginUserInfo = authService.getCurrentLoginUserInfo(); CreateCommitRequest.Response response = commitDAO.setCommit( authService.getVertaIdFromUserInfo(currentLoginUserInfo), request.getCommit(), (session) -> blobDAO.setBlobs(session, blobContainers, fileHasher), repositoryFunction); responseObserver.onNext(response); responseObserver.onCompleted(); } catch (Exception e) { ModelDBUtils.observeError( responseObserver, e, CreateCommitRequest.Response.getDefaultInstance()); } }