com.google.protobuf.InvalidProtocolBufferException Java Examples
The following examples show how to use
com.google.protobuf.InvalidProtocolBufferException.
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: MoreMetadata.java From grpc-java-contrib with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * A metadata marshaller that encodes objects as protobuf according to their proto IDL specification. * * @param clazz the type to serialize * @param <T> */ public static <T extends GeneratedMessageV3> Metadata.BinaryMarshaller<T> PROTOBUF_MARSHALLER(Class<T> clazz) { try { Method defaultInstance = clazz.getMethod("getDefaultInstance"); GeneratedMessageV3 instance = (GeneratedMessageV3) defaultInstance.invoke(null); return new Metadata.BinaryMarshaller<T>() { @Override public byte[] toBytes(T value) { return value.toByteArray(); } @SuppressWarnings("unchecked") @Override public T parseBytes(byte[] serialized) { try { return (T) instance.getParserForType().parseFrom(serialized); } catch (InvalidProtocolBufferException ipbe) { throw new IllegalArgumentException(ipbe); } } }; } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { throw new IllegalStateException(ex); } }
Example #2
Source File: ReadsSearchIT.java From compliance with Apache License 2.0 | 6 votes |
/** * Call <tt>/reads/search</tt> with a range that contains zero reads, and verify that it returns none. * (Adapted from an old JavaScript test.) * * @throws GAWrapperException if the server finds the request invalid in some way * @throws UnirestException if there's a problem speaking HTTP to the server * @throws InvalidProtocolBufferException if there's a problem processing the JSON response from the server */ @Test public void searchRangeWithNoReadsReturnsZeroResults() throws InvalidProtocolBufferException, UnirestException, GAWrapperException { final String refId = Utils.getValidReferenceId(client); final long emptyRangeStart = 0; // is this range actually empty? final long emptyRangeEnd = 100; final SearchReadsRequest srReq = SearchReadsRequest.newBuilder() .setReferenceId(refId) .addAllReadGroupIds(aSingle(getReadGroupId(client))) .setStart(emptyRangeStart) .setEnd(emptyRangeEnd) .build(); final SearchReadsResponse srResp = client.reads.searchReads(srReq); final List<ReadAlignment> alignments = srResp.getAlignmentsList(); assertThat(alignments).isEmpty(); }
Example #3
Source File: EnvelopeDeserializer.java From fabric-sdk-java with Apache License 2.0 | 6 votes |
static EnvelopeDeserializer newInstance(ByteString byteString, byte b) throws InvalidProtocolBufferException { EnvelopeDeserializer ret; final int type = ChannelHeader.parseFrom(Payload.parseFrom(Envelope.parseFrom(byteString).getPayload()) .getHeader().getChannelHeader()).getType(); /* MESSAGE = 0; // Used for messages which are signed but opaque CONFIG = 1; // Used for messages which express the channel config CONFIG_UPDATE = 2; // Used for transactions which update the channel config ENDORSER_TRANSACTION = 3; // Used by the SDK to submit endorser based transactions ORDERER_TRANSACTION = 4; // Used internally by the orderer for management DELIVER_SEEK_INFO = 5; // Used as the type for Envelope messages submitted to instruct the Deliver API to seek CHAINCODE_PACKAGE = 6; // Used for packaging chaincode artifacts for install */ switch (type) { case 3: ret = new EndorserTransactionEnvDeserializer(byteString, b); break; default: //just assume base properties. ret = new EnvelopeDeserializer(byteString, b); break; } return ret; }
Example #4
Source File: RecordCursor.java From fdb-record-layer with Apache License 2.0 | 6 votes |
/** * Resume a nested cursor with the given continuation or start if <code>null</code>. * @param outerFunc a function that takes the outer continuation and returns the outer cursor. * @param innerFunc a function that takes an outer record and an inner continuation and returns the inner cursor. * @param checker a function that takes an outer record and returns a way of recognizing it again or <code>null</code>. * When computing the continuation, this is called on the current outer record and the result, if not <code>null</code>, * becomes part of the continuation. When this continuation is used, the function (presumably the same one) is called * on the outer record again. If the results match, the inner cursor picks up where it left off. If not, the entire * inner cursor is run. * This handles common cases of the data changing between transactions, such as the outer record being deleted (skip rest of inner record) * or a new record being inserted right before it (do full inner cursor, not partial based on previous). * @param continuation the continuation returned from a previous instance of this pipeline or <code>null</code> at start. * @param pipelineSize the number of outer items to work ahead; inner cursors for these will be started in parallel. * @param <T> the result type of the outer cursor * @param <V> the result type of the inner cursor produced by the mapping function * @return a {@link FlatMapPipelinedCursor} that maps the inner function across the results of the outer function */ @Nonnull static <T, V> RecordCursor<V> flatMapPipelined(@Nonnull Function<byte[], ? extends RecordCursor<T>> outerFunc, @Nonnull BiFunction<T, byte[], ? extends RecordCursor<V>> innerFunc, @Nullable Function<T, byte[]> checker, @Nullable byte[] continuation, int pipelineSize) { if (continuation == null) { return new FlatMapPipelinedCursor<>(outerFunc.apply(null), innerFunc, checker, null, null, null, pipelineSize); } RecordCursorProto.FlatMapContinuation parsed; try { parsed = RecordCursorProto.FlatMapContinuation.parseFrom(continuation); } catch (InvalidProtocolBufferException ex) { throw new RecordCoreException("error parsing continuation", ex) .addLogInfo("raw_bytes", ByteArrayUtil2.loggable(continuation)); } final byte[] outerContinuation = parsed.hasOuterContinuation() ? parsed.getOuterContinuation().toByteArray() : null; final byte[] innerContinuation = parsed.hasInnerContinuation() ? parsed.getInnerContinuation().toByteArray() : null; final byte[] checkValue = parsed.hasCheckValue() ? parsed.getCheckValue().toByteArray() : null; final RecordCursor<T> outerCursor = outerFunc.apply(outerContinuation); return new FlatMapPipelinedCursor<>(outerCursor, innerFunc, checker, outerContinuation, checkValue, innerContinuation, pipelineSize); }
Example #5
Source File: TransactionConverter.java From java-sdk with Apache License 2.0 | 6 votes |
private Transaction convertTimeLock(byte[] value) throws InvalidProtocolBufferException { byte[] array = new byte[value.length - 4]; System.arraycopy(value, 4, array, 0, array.length); TimeLock timeLock = TimeLock.parseFrom(array); com.binance.dex.api.client.domain.broadcast.TimeLock tl = new com.binance.dex.api.client.domain.broadcast.TimeLock(); tl.setFromAddr(Crypto.encodeAddress(hrp, timeLock.getFrom().toByteArray())); tl.setDescription(timeLock.getDescription()); tl.setLockTime(Date.from(Instant.ofEpochSecond(timeLock.getLockTime()))); List<Token> amount = timeLock.getAmountList().stream().map(token -> { Token msgToken = new Token(); msgToken.setAmount(token.getAmount()); msgToken.setDenom(token.getDenom()); return msgToken; }).collect(Collectors.toList()); tl.setAmount(amount); Transaction transaction = new Transaction(); transaction.setTxType(TxType.TimeLock); transaction.setRealTx(tl); return transaction; }
Example #6
Source File: TextFormatForTest.java From api-compiler with Apache License 2.0 | 6 votes |
/** * Attempt to unpack if its an any instance. Returns null if not unpacked. */ @Nullable private Message maybeUnpackAnyType(FieldDescriptor field, Object value) { if (field.getType() == FieldDescriptor.Type.MESSAGE && field.getMessageType().getFullName().equals(Any.getDescriptor().getFullName())) { Any any = (Any) value; Message defaultInstance = anyConverterRegistry.get(any.getTypeUrl()); if (defaultInstance != null) { try { return defaultInstance.toBuilder().mergeFrom(any.getValue()).build(); } catch (InvalidProtocolBufferException e) { throw new RuntimeException(e); } } } return null; }
Example #7
Source File: GroupsV2AuthorizationSignalStoreCache.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
@Override public @NonNull Map<Integer, AuthCredentialResponse> read() { byte[] credentialBlob = store.getBlob(KEY, null); if (credentialBlob == null) { Log.i(TAG, "No credentials responses are cached locally"); return Collections.emptyMap(); } try { TemporalAuthCredentialResponses temporalCredentials = TemporalAuthCredentialResponses.parseFrom(credentialBlob); HashMap<Integer, AuthCredentialResponse> result = new HashMap<>(temporalCredentials.getCredentialResponseCount()); for (TemporalAuthCredentialResponse credential : temporalCredentials.getCredentialResponseList()) { result.put(credential.getDate(), new AuthCredentialResponse(credential.getAuthCredentialResponse().toByteArray())); } Log.i(TAG, String.format(Locale.US, "Loaded %d credentials from local storage", result.size())); return result; } catch (InvalidProtocolBufferException | InvalidInputException e) { throw new AssertionError(e); } }
Example #8
Source File: TransactionConverter.java From java-sdk with Apache License 2.0 | 6 votes |
private Transaction convertListing(byte[] value) throws InvalidProtocolBufferException { byte[] array = new byte[value.length - 4]; System.arraycopy(value, 4, array, 0, array.length); com.binance.dex.api.proto.List listMessage = com.binance.dex.api.proto.List.parseFrom(array); Listing listing = new Listing(); listing.setProposalId(listMessage.getProposalId()); listing.setBaseAssetSymbol(listMessage.getBaseAssetSymbol()); listing.setQuoteAssetSymbol(listMessage.getQuoteAssetSymbol()); listing.setInitPrice(listMessage.getInitPrice()); listing.setFromAddr(Crypto.encodeAddress(hrp, listMessage.getFrom().toByteArray())); Transaction transaction = new Transaction(); transaction.setTxType(TxType.LISTING); transaction.setRealTx(listing); return transaction; }
Example #9
Source File: DatasetVersionDAORdbImpl.java From modeldb with Apache License 2.0 | 6 votes |
@Override public DatasetVersion addDatasetVersionAttributes( String datasetVersionId, List<KeyValue> attributesList) throws InvalidProtocolBufferException { try (Session session = ModelDBHibernateUtil.getSessionFactory().openSession()) { DatasetVersionEntity datasetVersionObj = session.get(DatasetVersionEntity.class, datasetVersionId); datasetVersionObj.setAttributeMapping( RdbmsUtils.convertAttributesFromAttributeEntityList( datasetVersionObj, ModelDBConstants.ATTRIBUTES, attributesList)); long currentTimestamp = Calendar.getInstance().getTimeInMillis(); datasetVersionObj.setTime_updated(currentTimestamp); Transaction transaction = session.beginTransaction(); session.saveOrUpdate(datasetVersionObj); transaction.commit(); LOGGER.debug("DatasetVersion attributes added successfully"); return datasetVersionObj.getProtoObject(); } catch (Exception ex) { if (ModelDBUtils.needToRetry(ex)) { return addDatasetVersionAttributes(datasetVersionId, attributesList); } else { throw ex; } } }
Example #10
Source File: SignedData.java From julongchain with Apache License 2.0 | 6 votes |
public static List<SignedData> asSignedData(ProposalPackage.SignedProposal signedProposal) throws ValidateException, InvalidProtocolBufferException { ValidateUtils.isNotNull(signedProposal, "signedProposal can not be null"); ValidateUtils.isNotNull(signedProposal.getProposalBytes(), "proposal can not be null"); List<SignedData> result = new ArrayList<>(); ProposalPackage.Proposal proposal = ProposalPackage.Proposal.parseFrom(signedProposal.getProposalBytes()); Common.Header header = Common.Header.parseFrom(proposal.getHeader()); Common.SignatureHeader signatureHeader = Common.SignatureHeader.parseFrom(header.getSignatureHeader()); SignedData signedData = new SignedData(signedProposal.getProposalBytes().toByteArray(), signatureHeader.getCreator().toByteArray(), signedProposal.getSignature().toByteArray()); result.add(signedData); return result; }
Example #11
Source File: VpcTest.java From alcor with Apache License 2.0 | 6 votes |
@Test public void serializationVerificationWithTransitRouterIps() { VpcState customerVpcState = new VpcState("dbf72700-5106-4a7a-918f-a016853911f8", "99d9d709-8478-4b46-9f3f-2206b1023fd3", "SuperVpc", "10.0.0.0/24"); HostInfo[] transitRouterHosts = { new HostInfo(OneBoxConfig.TRANSIT_ROUTER_1_HOST_ID, "transit router host1", OneBoxConfig.TRANSIT_ROUTER_1_IP, OneBoxConfig.TRANSIT_ROUTER_1_MAC), new HostInfo(OneBoxConfig.TRANSIT_ROUTER_2_HOST_ID, "transit router host2", OneBoxConfig.TRANSIT_ROUTER_2_IP, OneBoxConfig.TRANSIT_ROUTER_2_MAC) }; final Vpc.VpcState state = GoalStateUtil.CreateGSVpcState(Common.OperationType.CREATE, customerVpcState, transitRouterHosts); final byte[] binaryState = state.toByteArray(); try { final Vpc.VpcState deserializedObject = Vpc.VpcState.parseFrom(binaryState); TestUtil.AssertVpcStates(state, deserializedObject); } catch (InvalidProtocolBufferException bf_exp) { Assert.assertTrue(false); } }
Example #12
Source File: AbstractErrorUtilsTest.java From google-ads-java with Apache License 2.0 | 6 votes |
@Test public void getGoogleAdsErrors_duplicates_whenErrorsDiffer() throws InvalidProtocolBufferException { MockPath path0 = MockPath.newBuilder() .setIndex(Int64Value.newBuilder().setValue(0)) .setFieldName(operationsFieldName) .build(); MockPath path1 = MockPath.newBuilder() .setIndex(Int64Value.newBuilder().setValue(0)) .setFieldName(operationsFieldName) .build(); MockPath path2 = MockPath.newBuilder().setFieldName("somethingelse").build(); MockError error0 = MockError.newBuilder().addLocation(path0).build(); MockError error1 = MockError.newBuilder().addLocation(path1).addLocation(path2).build(); // Swap the order of the errors. MockFailure failure = MockFailure.newBuilder().addErrors(error0).addErrors(error1).build(); Status status = Status.newBuilder().addDetails(Any.pack(failure)).build(); List<MockError> result = impl.getGoogleAdsErrors(0, status); assertEquals(2, result.size()); assertEquals(error0, result.get(0)); assertEquals(error1, result.get(1)); }
Example #13
Source File: ParseSetCommandTest.java From distkv with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testSetPut() throws InvalidProtocolBufferException { final String command = "set.put k1 v1 v2 v3 v4"; DistkvParsedResult result = distkvParser.parse(command); final DistkvRequest request = result.getRequest(); Assert.assertEquals(DistkvRequest.class, request.getClass()); Assert.assertEquals("k1", request.getKey()); Assert.assertEquals(4, request.getRequest() .unpack(SetPutRequest.class).getValuesCount()); Assert.assertEquals("v1", request.getRequest() .unpack(SetPutRequest.class).getValues(0)); Assert.assertEquals("v2", request.getRequest() .unpack(SetPutRequest.class).getValues(1)); Assert.assertEquals("v3", request.getRequest() .unpack(SetPutRequest.class).getValues(2)); Assert.assertEquals("v4", request.getRequest() .unpack(SetPutRequest.class).getValues(3)); }
Example #14
Source File: ProjectDAORdbImpl.java From modeldb with Apache License 2.0 | 6 votes |
@Override public List<Project> getProjects(String key, String value, UserInfo userInfo) throws InvalidProtocolBufferException { FindProjects findProjects = FindProjects.newBuilder() .addPredicates( KeyValueQuery.newBuilder() .setKey(key) .setValue(Value.newBuilder().setStringValue(value).build()) .setOperator(OperatorEnum.Operator.EQ) .setValueType(ValueTypeEnum.ValueType.STRING) .build()) .build(); ProjectPaginationDTO projectPaginationDTO = findProjects(findProjects, null, userInfo, ProjectVisibility.PRIVATE); LOGGER.debug("Projects size is {}", projectPaginationDTO.getProjects().size()); return projectPaginationDTO.getProjects(); }
Example #15
Source File: ExperimentDAORdbImpl.java From modeldb with Apache License 2.0 | 6 votes |
@Override public Experiment updateExperimentDescription(String experimentId, String experimentDescription) throws InvalidProtocolBufferException { try (Session session = ModelDBHibernateUtil.getSessionFactory().openSession()) { ExperimentEntity experimentEntity = session.load(ExperimentEntity.class, experimentId); experimentEntity.setDescription(experimentDescription); long currentTimestamp = Calendar.getInstance().getTimeInMillis(); experimentEntity.setDate_updated(currentTimestamp); Transaction transaction = session.beginTransaction(); session.update(experimentEntity); transaction.commit(); LOGGER.debug("Experiment description updated successfully"); return experimentEntity.getProtoObject(); } catch (Exception ex) { if (ModelDBUtils.needToRetry(ex)) { return updateExperimentDescription(experimentId, experimentDescription); } else { throw ex; } } }
Example #16
Source File: ExperimentRunDAORdbImpl.java From modeldb with Apache License 2.0 | 6 votes |
@Override public List<String> getExperimentRunIdsByProjectIds(List<String> projectIds) throws InvalidProtocolBufferException { try (Session session = ModelDBHibernateUtil.getSessionFactory().openSession()) { Query experimentRunQuery = session.createQuery(GET_EXPERIMENT_RUN_BY_PROJECT_ID_HQL); experimentRunQuery.setParameterList("projectIds", projectIds); List<ExperimentRunEntity> experimentRunEntities = experimentRunQuery.list(); List<String> experimentRunIds = new ArrayList<>(); for (ExperimentRunEntity experimentRunEntity : experimentRunEntities) { experimentRunIds.add(experimentRunEntity.getId()); } return experimentRunIds; } catch (Exception ex) { if (ModelDBUtils.needToRetry(ex)) { return getExperimentRunIdsByProjectIds(projectIds); } else { throw ex; } } }
Example #17
Source File: JobEntity.java From modeldb with Apache License 2.0 | 5 votes |
public Job getProtoObject() throws InvalidProtocolBufferException { return Job.newBuilder() .setId(getId()) .setDescription(getDescription()) .setStartTime(getStart_time()) .setEndTime(getEnd_time()) .addAllMetadata(RdbmsUtils.convertAttributeEntityListFromAttributes(getAttributeMapping())) .setJobStatusValue(getJob_status()) .setJobTypeValue(getJob_type()) .setOwner(getOwner()) .build(); }
Example #18
Source File: TemplateEvaluatorTest.java From stateful-functions with Apache License 2.0 | 5 votes |
private static DynamicMessage dynamic(Message message) { try { return DynamicMessage.parseFrom(message.getDescriptorForType(), message.toByteString()); } catch (InvalidProtocolBufferException e) { throw new AssertionError(e); } }
Example #19
Source File: FabricExceptionsTest.java From fabric-sdk-java with Apache License 2.0 | 5 votes |
@Test public void testInvalidProtocolBufferRuntimeException1() throws InvalidProtocolBufferRuntimeException { thrown.expect(InvalidProtocolBufferRuntimeException.class); thrown.expectMessage(MESSAGE); throw new InvalidProtocolBufferRuntimeException(new InvalidProtocolBufferException(MESSAGE)); }
Example #20
Source File: MetricsLoggerClientTest.java From firebase-android-sdk with Apache License 2.0 | 5 votes |
@Test public void logDismiss_withClickDismissType_setsEquivalentDismissType() throws InvalidProtocolBufferException { metricsLoggerClient.logDismiss(BANNER_MESSAGE_MODEL, InAppMessagingDismissType.CLICK); verify(engagementMetricsLoggerInterface).logEvent(byteArrayCaptor.capture()); CampaignAnalytics campaignAnalytics = CampaignAnalytics.parser().parseFrom(byteArrayCaptor.getValue()); assertThat(campaignAnalytics.getDismissType()).isEqualTo(DismissType.CLICK); }
Example #21
Source File: TelemetryRpcMsgHandler.java From iotplatform with Apache License 2.0 | 5 votes |
private void processSessionClose(PluginContext ctx, RpcMsg msg) { SessionCloseProto proto; try { proto = SessionCloseProto.parseFrom(msg.getMsgData()); } catch (InvalidProtocolBufferException e) { throw new RuntimeException(e); } subscriptionManager.cleanupRemoteWsSessionSubscriptions(ctx, proto.getSessionId()); }
Example #22
Source File: ChaincodeActionPayloadDeserializer.java From fabric-sdk-java with Apache License 2.0 | 5 votes |
TransactionPackage.ChaincodeActionPayload getChaincodeActionPayload() { TransactionPackage.ChaincodeActionPayload ret = chaincodeActionPayload != null ? chaincodeActionPayload.get() : null; if (null == ret) { try { ret = TransactionPackage.ChaincodeActionPayload.parseFrom(byteString); } catch (InvalidProtocolBufferException e) { throw new InvalidProtocolBufferRuntimeException(e); } chaincodeActionPayload = new WeakReference<>(ret); } return ret; }
Example #23
Source File: ParseDictCommandTest.java From distkv with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testPutItem() throws InvalidProtocolBufferException { final String command = "dict.putItem dict1 k1 v1"; DistkvParsedResult result = distkvParser.parse(command); Assert.assertEquals(result.getRequestType(), RequestType.DICT_PUT_ITEM); DistkvRequest request = result.getRequest(); Assert.assertEquals(request.getRequest() .unpack(DictPutItemRequest.class).getItemValue(), "v1"); Assert.assertEquals(request.getRequest() .unpack(DictPutItemRequest.class).getItemKey(), "k1"); }
Example #24
Source File: WebPushEncrypterManager.java From capillary with Apache License 2.0 | 5 votes |
@Override HybridEncrypt rawLoadPublicKey(byte[] publicKey) throws GeneralSecurityException { WrappedWebPushPublicKey wrappedWebPushPublicKey; try { wrappedWebPushPublicKey = WrappedWebPushPublicKey.parseFrom(publicKey); } catch (InvalidProtocolBufferException e) { throw new GeneralSecurityException("unable to parse public key", e); } return new WebPushHybridEncrypt.Builder() .withAuthSecret(wrappedWebPushPublicKey.getAuthSecret().toByteArray()) .withRecipientPublicKey(wrappedWebPushPublicKey.getKeyBytes().toByteArray()) .build(); }
Example #25
Source File: DatasetVersionEntity.java From modeldb with Apache License 2.0 | 5 votes |
public DatasetVersion getProtoObject() throws InvalidProtocolBufferException { DatasetVersion.Builder datasetVersionBuilder = DatasetVersion.newBuilder() .setId(getId()) .setParentId(getParent_id()) .setDatasetId(getDataset_id()) .setTimeLogged(getTime_logged()) .setTimeUpdated(getTime_updated()) .setDescription(getDescription()) .addAllTags(RdbmsUtils.convertTagsMappingListFromTagList(getTags())) .setDatasetVersionVisibilityValue(getDataset_version_visibility()) .setDatasetTypeValue(getDataset_type()) .addAllAttributes( RdbmsUtils.convertAttributeEntityListFromAttributes(getAttributeMapping())) .setOwner(getOwner()) .setVersion(getVersion()); if (getRaw_dataset_version_info() != null) { datasetVersionBuilder.setRawDatasetVersionInfo( getRaw_dataset_version_info().getProtoObject()); } else if (getPath_dataset_version_info() != null) { datasetVersionBuilder.setPathDatasetVersionInfo( getPath_dataset_version_info().getProtoObject()); } else if (getQuery_dataset_version_info() != null) { datasetVersionBuilder.setQueryDatasetVersionInfo( getQuery_dataset_version_info().getProtoObject()); } return datasetVersionBuilder.build(); }
Example #26
Source File: ExperimentRunDAORdbImpl.java From modeldb with Apache License 2.0 | 5 votes |
@Override public ExperimentRun insertExperimentRun(ExperimentRun experimentRun, UserInfo userInfo) throws InvalidProtocolBufferException, ModelDBException { checkIfEntityAlreadyExists(experimentRun, true); createRoleBindingsForExperimentRun(experimentRun, userInfo); try (Session session = ModelDBHibernateUtil.getSessionFactory().openSession()) { ExperimentRunEntity experimentRunObj = RdbmsUtils.generateExperimentRunEntity(experimentRun); if (experimentRun.getVersionedInputs() != null && experimentRun.hasVersionedInputs()) { Map<String, Map.Entry<BlobExpanded, String>> locationBlobWithHashMap = validateVersioningEntity(session, experimentRun.getVersionedInputs()); List<VersioningModeldbEntityMapping> versioningModeldbEntityMappings = RdbmsUtils.getVersioningMappingFromVersioningInput( session, experimentRun.getVersionedInputs(), locationBlobWithHashMap, experimentRunObj); experimentRunObj.setVersioned_inputs(versioningModeldbEntityMappings); Set<HyperparameterElementMappingEntity> hyrParamMappings = prepareHyperparameterElemMappings(experimentRunObj, versioningModeldbEntityMappings); if (!hyrParamMappings.isEmpty()) { experimentRunObj.setHyperparameter_element_mappings(new ArrayList<>(hyrParamMappings)); } } Transaction transaction = session.beginTransaction(); session.saveOrUpdate(experimentRunObj); transaction.commit(); LOGGER.debug("ExperimentRun created successfully"); return experimentRun; } catch (Exception ex) { if (ModelDBUtils.needToRetry(ex)) { return insertExperimentRun(experimentRun, userInfo); } else { throw ex; } } }
Example #27
Source File: OmBucketInfoCodec.java From hadoop-ozone with Apache License 2.0 | 5 votes |
@Override public OmBucketInfo fromPersistedFormat(byte[] rawData) throws IOException { Preconditions .checkNotNull(rawData, "Null byte array can't converted to real object."); try { return OmBucketInfo.getFromProtobuf(BucketInfo.parseFrom(rawData)); } catch (InvalidProtocolBufferException e) { throw new IllegalArgumentException( "Can't encode the the raw data from the byte array", e); } }
Example #28
Source File: SpecServiceTest.java From feast with Apache License 2.0 | 5 votes |
@Test public void shouldThrowExceptionGivenReservedFeatureName() throws InvalidProtocolBufferException { List<String> reservedNames = Arrays.asList("created_timestamp", "event_timestamp", "ingestion_id", "job_id"); String reservedNamesString = StringUtils.join(reservedNames, ", "); expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage( String.format( "Reserved feature names have been used, which are not allowed. These names include %s." + "You've just used an invalid name, %s.", reservedNamesString, "created_timestamp")); FeatureSet invalidFeatureSet = invalidFeatureSets.get(0); specService.applyFeatureSet(invalidFeatureSet.toProto()); }
Example #29
Source File: OmVolumeArgsCodec.java From hadoop-ozone with Apache License 2.0 | 5 votes |
@Override public OmVolumeArgs fromPersistedFormat(byte[] rawData) throws IOException { Preconditions .checkNotNull(rawData, "Null byte array can't converted to real object."); try { return OmVolumeArgs.getFromProtobuf(VolumeInfo.parseFrom(rawData)); } catch (InvalidProtocolBufferException e) { throw new IllegalArgumentException( "Can't encode the the raw data from the byte array", e); } }
Example #30
Source File: ExperimentRunDAORdbImpl.java From modeldb with Apache License 2.0 | 5 votes |
@Override public List<KeyValue> getExperimentRunAttributes( String experimentRunId, List<String> attributeKeyList, Boolean getAll) throws InvalidProtocolBufferException { try (Session session = ModelDBHibernateUtil.getSessionFactory().openSession()) { ExperimentRunEntity experimentRunObj = session.get(ExperimentRunEntity.class, experimentRunId); if (experimentRunObj == null) { String errorMessage = "Invalid ExperimentRun ID found"; LOGGER.info(errorMessage); Status status = Status.newBuilder().setCode(Code.NOT_FOUND_VALUE).setMessage(errorMessage).build(); throw StatusProto.toStatusRuntimeException(status); } if (getAll) { return experimentRunObj.getProtoObject().getAttributesList(); } else { Query query = session.createQuery(GET_EXP_RUN_ATTRIBUTE_BY_KEYS_HQL); query.setParameterList("keys", attributeKeyList); query.setParameter(ModelDBConstants.EXPERIMENT_RUN_ID_STR, experimentRunId); query.setParameter(ModelDBConstants.FIELD_TYPE_STR, ModelDBConstants.ATTRIBUTES); List<AttributeEntity> attributeEntities = query.list(); return RdbmsUtils.convertAttributeEntityListFromAttributes(attributeEntities); } } catch (Exception ex) { if (ModelDBUtils.needToRetry(ex)) { return getExperimentRunAttributes(experimentRunId, attributeKeyList, getAll); } else { throw ex; } } }