Java Code Examples for io.grpc.Status.Code#INTERNAL
The following examples show how to use
io.grpc.Status.Code#INTERNAL .
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: BlobFactory.java From modeldb with Apache License 2.0 | 6 votes |
public static BlobFactory create(InternalFolderElementEntity folderElementEntity) throws ModelDBException { switch (folderElementEntity.getElement_type()) { case S_3_DATASET_BLOB: case PATH_DATASET_BLOB: return new DatasetBlobFactory(folderElementEntity); case PYTHON_ENVIRONMENT_BLOB: case DOCKER_ENVIRONMENT_BLOB: return new EnvironmentBlobFactory(folderElementEntity); case GIT_CODE_BLOB: case NOTEBOOK_CODE_BLOB: return new CodeBlobFactory(folderElementEntity); case CONFIG_BLOB: return new ConfigBlobFactory(folderElementEntity); default: throw new ModelDBException("Unknown blob type found " + folderElementEntity, Code.INTERNAL); } }
Example 2
Source File: DatasetBlobFactory.java From modeldb with Apache License 2.0 | 6 votes |
@Override public Blob getBlob(Session session) throws ModelDBException { DatasetBlob.Builder datasetBlobBuilder = DatasetBlob.newBuilder(); switch (getElementType()) { case S_3_DATASET_BLOB: return Blob.newBuilder() .setDataset(datasetBlobBuilder.setS3(getS3Blob(session, getElementSha()))) .build(); case PATH_DATASET_BLOB: final PathDatasetBlob pathBlob = getPathBlob(session, getElementSha()); if (pathBlob == null) { throw new ModelDBException("Path blob not found", Code.INTERNAL); } return Blob.newBuilder().setDataset(datasetBlobBuilder.setPath(pathBlob)).build(); } return Blob.newBuilder().setDataset(datasetBlobBuilder).build(); }
Example 3
Source File: CodeBlobFactory.java From modeldb with Apache License 2.0 | 6 votes |
@Override public Blob getBlob(Session session) throws ModelDBException { Builder codeBlobBuilder = CodeBlob.newBuilder(); switch (getElementType()) { case GIT_CODE_BLOB: codeBlobBuilder.setGit(session.get(GitCodeBlobEntity.class, getElementSha()).toProto()); break; case NOTEBOOK_CODE_BLOB: NotebookCodeBlobEntity notebookCodeBlobEntity = session.get(NotebookCodeBlobEntity.class, getElementSha()); String datasetBlobHash = notebookCodeBlobEntity.getPath_dataset_blob_hash(); final NotebookCodeBlob.Builder builder = NotebookCodeBlob.newBuilder(); PathDatasetBlob pathBlob = DatasetBlobFactory.getPathBlob(session, datasetBlobHash); if (pathBlob != null) { if (pathBlob.getComponentsCount() == 1) { builder.setPath(pathBlob.getComponents(0)); } else { throw new ModelDBException("Path should have only one component", Code.INTERNAL); } } codeBlobBuilder.setNotebook( builder.setGitRepo(notebookCodeBlobEntity.getGitCodeBlobEntity().toProto()).build()); break; } return Blob.newBuilder().setCode(codeBlobBuilder).build(); }
Example 4
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 5
Source File: LineageServiceImpl.java From modeldb with Apache License 2.0 | 5 votes |
private boolean isResourceExists(Session session, String id, LineageEntryType type) throws ModelDBException { switch (type) { case EXPERIMENT_RUN: return experimentDAO.isExperimentRunExists(session, id); case DATASET_VERSION: return datasetVersionDAO.isDatasetVersionExists(session, id); default: throw new ModelDBException("Unexpected type", Code.INTERNAL); } }
Example 6
Source File: ConfigContainer.java From modeldb with Apache License 2.0 | 5 votes |
private String computeSHA(HyperparameterValuesConfigBlob hyperparameterValuesConfigBlob) throws NoSuchAlgorithmException, ModelDBException { switch (hyperparameterValuesConfigBlob.getValueCase()) { case INT_VALUE: return FileHasher.getSha(String.valueOf(hyperparameterValuesConfigBlob.getIntValue())); case FLOAT_VALUE: return FileHasher.getSha(String.valueOf(hyperparameterValuesConfigBlob.getFloatValue())); case STRING_VALUE: return FileHasher.getSha(hyperparameterValuesConfigBlob.getStringValue()); default: throw new ModelDBException("Unexpected wrong type", Code.INTERNAL); } }
Example 7
Source File: CodeContainer.java From modeldb with Apache License 2.0 | 5 votes |
@Override public void process( Session session, TreeElem rootTree, FileHasher fileHasher, Set<String> blobHashes) throws NoSuchAlgorithmException, ModelDBException { String blobType; final String blobHash; switch (code.getContentCase()) { case GIT: blobType = GIT_CODE_BLOB; GitCodeBlob gitCodeBlob = code.getGit(); blobHash = saveBlob(session, gitCodeBlob, blobHashes).getBlobHash(); break; case NOTEBOOK: blobType = NOTEBOOK_CODE_BLOB; NotebookCodeBlob notebook = code.getNotebook(); GitCodeBlobEntity gitCodeBlobEntity = saveBlob(session, notebook.getGitRepo(), blobHashes); PathDatasetBlob.Builder pathDatasetBlobBuilder = PathDatasetBlob.newBuilder(); if (notebook.getPath() != null) { pathDatasetBlobBuilder.addComponents(notebook.getPath()); } String pathBlobSha = DatasetContainer.saveBlob(session, pathDatasetBlobBuilder.build(), blobHashes); blobHash = FileHasher.getSha(gitCodeBlobEntity.getBlobHash() + ":" + pathBlobSha); if (!blobHashes.contains(blobHash)) { session.saveOrUpdate( new NotebookCodeBlobEntity(blobHash, gitCodeBlobEntity, pathBlobSha)); blobHashes.add(blobHash); } break; default: throw new ModelDBException("Blob unknown type", Code.INTERNAL); } rootTree.push(getLocationList(), blobHash, blobType); }
Example 8
Source File: ConflictGenerator.java From modeldb with Apache License 2.0 | 4 votes |
public static List<BlobDiff> setConflictBlobsInDiff( BlobDiff blobDiff, List<BlobDiff> locSpecificBlobDiffA, List<BlobDiff> locSpecificBlobDiffB, Blob parentBlob) throws ModelDBException { if (locSpecificBlobDiffA.size() != 1) { LOGGER.info("expecting diffs of same size"); throw new ModelDBException("different size of diff not expected", Code.INTERNAL); } if (locSpecificBlobDiffA.size() != locSpecificBlobDiffB.size()) { LOGGER.info("currently supporting diff of size 1"); throw new ModelDBException("different size of diff not expected", Code.INTERNAL); } AutogenBlobDiff a = AutogenBlobDiff.fromProto(locSpecificBlobDiffA.get(0)); AutogenBlobDiff b = AutogenBlobDiff.fromProto(locSpecificBlobDiffB.get(0)); AutogenBlob c = AutogenBlob.fromProto(parentBlob); if (locSpecificBlobDiffA.get(0).getContentCase() == locSpecificBlobDiffB.get(0).getContentCase()) { AutogenBlobDiff diff0 = AutogenBlobDiff.fromProto(blobDiff); AutogenBlobDiff diff1 = AutogenBlobDiff.fromProto(blobDiff); switch (locSpecificBlobDiffA.get(0).getContentCase()) { case CODE: List<AutogenCodeDiff> diffs = getCodeConflictBlob(a.getCode(), b.getCode(), c.getCode()); if (diffs.size() == 2) { return Arrays.asList( diff0.setCode(diffs.get(0)).toProto().build(), diff1.setCode(diffs.get(1)).toProto().build()); } else { return Collections.singletonList(diff0.setCode(diffs.get(0)).toProto().build()); } case CONFIG: return Collections.singletonList( diff0 .setConfig(getConfigConflictBlob(a.getConfig(), b.getConfig(), c.getConfig())) .toProto() .build()); case DATASET: List<AutogenDatasetDiff> datasetDiffs = getDatasetConflictBlob(a.getDataset(), b.getDataset(), c.getDataset()); if (datasetDiffs.size() == 2) { return Arrays.asList( diff0.setDataset(datasetDiffs.get(0)).toProto().build(), diff1.setDataset(datasetDiffs.get(1)).toProto().build()); } else { return Collections.singletonList( diff0.setDataset(datasetDiffs.get(0)).toProto().build()); } case ENVIRONMENT: List<AutogenEnvironmentDiff> envDiffs = getEnvironmentonflictBlob(a.getEnvironment(), b.getEnvironment(), c.getEnvironment()); if (envDiffs.size() == 2) { return Arrays.asList( diff0.setEnvironment(envDiffs.get(0)).toProto().build(), diff1.setEnvironment(envDiffs.get(1)).toProto().build()); } else { return Collections.singletonList( diff0.setEnvironment(envDiffs.get(0)).toProto().build()); } case CONTENT_NOT_SET: return Collections.emptyList(); } } else { return Arrays.asList( updateDiffBasedOnDiffType(locSpecificBlobDiffA, a, b, c, blobDiff), updateDiffBasedOnDiffType(locSpecificBlobDiffB, a, b, c, blobDiff)); } LOGGER.warn("During conflict generation code should not reach here."); throw new ModelDBException("Exception during conflict generation", Code.INTERNAL); }
Example 9
Source File: DatasetContainer.java From modeldb with Apache License 2.0 | 4 votes |
@Override public void process( Session session, TreeElem rootTree, FileHasher fileHasher, Set<String> blobHashes) throws NoSuchAlgorithmException, ModelDBException { final List<String> locationList = getLocationList(); String blobType = getBlobType(); String blobHash; switch (dataset.getContentCase()) { case S3: final S3DatasetBlob s3 = dataset.getS3(); // sorted Map<String, AutogenS3DatasetComponentBlob> componentHashes = new LinkedHashMap<>(); AutogenS3DatasetBlob autogenS3DatasetBlob = AutogenS3DatasetBlob.fromProto(s3); if (autogenS3DatasetBlob != null && autogenS3DatasetBlob.getComponents() != null) { for (AutogenS3DatasetComponentBlob componentBlob : autogenS3DatasetBlob.getComponents()) { final String componentHash = computeSHA(componentBlob); componentHashes.put(componentHash, componentBlob); } blobHash = computeSHAS3Dataset(componentHashes); if (!blobHashes.contains(blobHash)) { blobHashes.add(blobHash); for (Map.Entry<String, AutogenS3DatasetComponentBlob> component : componentHashes.entrySet()) { if (!blobHashes.contains(component.getKey())) { blobHashes.add(component.getKey()); S3DatasetComponentBlobEntity s3DatasetComponentBlobEntity = new S3DatasetComponentBlobEntity( component.getKey(), blobHash, component.getValue().toProto().build()); session.saveOrUpdate(s3DatasetComponentBlobEntity); } } } } else { blobHash = null; } break; case PATH: blobHash = saveBlob(session, dataset.getPath(), blobHashes); break; default: throw new ModelDBException("Unknown blob type", Code.INTERNAL); } if (blobHash != null) { rootTree.push(locationList, blobHash, blobType); } }