Search in sources :

Example 81 with InvalidProtocolBufferException

use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project grpc-java by grpc.

the class RouteLookupServiceClusterSpecifierPlugin method parsePlugin.

@Override
@SuppressWarnings("unchecked")
public ConfigOrError<RlsPluginConfig> parsePlugin(Message rawProtoMessage) {
    if (!(rawProtoMessage instanceof Any)) {
        return ConfigOrError.fromError("Invalid config type: " + rawProtoMessage.getClass());
    }
    try {
        Any anyMessage = (Any) rawProtoMessage;
        Class<? extends Message> protoClass;
        try {
            protoClass = (Class<? extends Message>) Class.forName("io.grpc.lookup.v1.RouteLookupClusterSpecifier");
        } catch (ClassNotFoundException e) {
            return ConfigOrError.fromError("Dependency for 'io.grpc:grpc-rls' is missing: " + e);
        }
        Message configProto;
        try {
            configProto = anyMessage.unpack(protoClass);
        } catch (InvalidProtocolBufferException e) {
            return ConfigOrError.fromError("Invalid proto: " + e);
        }
        String jsonString = MessagePrinter.print(configProto);
        try {
            Map<String, ?> jsonMap = (Map<String, ?>) JsonParser.parse(jsonString);
            Map<String, ?> config = JsonUtil.getObject(jsonMap, "routeLookupConfig");
            return ConfigOrError.fromConfig(RlsPluginConfig.create(config));
        } catch (IOException e) {
            return ConfigOrError.fromError("Unable to parse RouteLookupClusterSpecifier: " + jsonString);
        }
    } catch (RuntimeException e) {
        return ConfigOrError.fromError("Error parsing RouteLookupConfig: " + e);
    }
}
Also used : Message(com.google.protobuf.Message) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) IOException(java.io.IOException) Any(com.google.protobuf.Any) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map)

Example 82 with InvalidProtocolBufferException

use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project grpc-java by grpc.

the class RbacFilter method parseFilterConfig.

@Override
public ConfigOrError<RbacConfig> parseFilterConfig(Message rawProtoMessage) {
    RBAC rbacProto;
    if (!(rawProtoMessage instanceof Any)) {
        return ConfigOrError.fromError("Invalid config type: " + rawProtoMessage.getClass());
    }
    Any anyMessage = (Any) rawProtoMessage;
    try {
        rbacProto = anyMessage.unpack(RBAC.class);
    } catch (InvalidProtocolBufferException e) {
        return ConfigOrError.fromError("Invalid proto: " + e);
    }
    return parseRbacConfig(rbacProto);
}
Also used : RBAC(io.envoyproxy.envoy.extensions.filters.http.rbac.v3.RBAC) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) Any(com.google.protobuf.Any)

Example 83 with InvalidProtocolBufferException

use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project druid by druid-io.

the class ProtobufReader method parseInputRows.

@Override
protected List<InputRow> parseInputRows(DynamicMessage intermediateRow) throws ParseException, JsonProcessingException {
    Map<String, Object> record;
    if (flattenSpec == null || JSONPathSpec.DEFAULT.equals(flattenSpec)) {
        try {
            record = CollectionUtils.mapKeys(intermediateRow.getAllFields(), k -> k.getJsonName());
        } catch (Exception ex) {
            throw new ParseException(null, ex, "Protobuf message could not be parsed");
        }
    } else {
        try {
            String json = JsonFormat.printer().print(intermediateRow);
            record = recordFlattener.flatten(OBJECT_MAPPER.readValue(json, JsonNode.class));
        } catch (InvalidProtocolBufferException e) {
            throw new ParseException(null, e, "Protobuf message could not be parsed");
        }
    }
    return Collections.singletonList(MapInputRowParser.parse(inputRowSchema, record));
}
Also used : DynamicMessage(com.google.protobuf.DynamicMessage) ParseException(org.apache.druid.java.util.common.parsers.ParseException) ObjectFlattener(org.apache.druid.java.util.common.parsers.ObjectFlattener) CollectionUtils(org.apache.druid.utils.CollectionUtils) InputRowSchema(org.apache.druid.data.input.InputRowSchema) Iterators(com.google.common.collect.Iterators) ByteBuffer(java.nio.ByteBuffer) JSONPathSpec(org.apache.druid.java.util.common.parsers.JSONPathSpec) Map(java.util.Map) JsonNode(com.fasterxml.jackson.databind.JsonNode) CloseableIterator(org.apache.druid.java.util.common.parsers.CloseableIterator) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) MapInputRowParser(org.apache.druid.data.input.impl.MapInputRowParser) JSONFlattenerMaker(org.apache.druid.java.util.common.parsers.JSONFlattenerMaker) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IOException(java.io.IOException) IOUtils(org.apache.commons.io.IOUtils) InputRow(org.apache.druid.data.input.InputRow) List(java.util.List) IntermediateRowParsingReader(org.apache.druid.data.input.IntermediateRowParsingReader) CloseableIterators(org.apache.druid.java.util.common.CloseableIterators) JsonFormat(com.google.protobuf.util.JsonFormat) ObjectFlatteners(org.apache.druid.java.util.common.parsers.ObjectFlatteners) InputEntity(org.apache.druid.data.input.InputEntity) Collections(java.util.Collections) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ParseException(org.apache.druid.java.util.common.parsers.ParseException) ParseException(org.apache.druid.java.util.common.parsers.ParseException) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IOException(java.io.IOException)

Example 84 with InvalidProtocolBufferException

use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project heron by twitter.

the class PhysicalPlanProvider method ParseResponseToPhysicalPlan.

protected PhysicalPlan ParseResponseToPhysicalPlan(byte[] responseData) {
    // byte to base64 string
    String encodedString = new String(responseData);
    LOG.fine("tmanager returns physical plan in base64 str: " + encodedString);
    // base64 string to proto bytes
    byte[] decodedBytes = Base64.getDecoder().decode(encodedString);
    // construct proto obj from bytes
    PhysicalPlan pp = null;
    try {
        pp = PhysicalPlan.parseFrom(decodedBytes);
    } catch (InvalidProtocolBufferException e) {
        throw new InvalidStateException(topologyName, "Failed to fetch the physical plan");
    }
    return pp;
}
Also used : PhysicalPlan(org.apache.heron.proto.system.PhysicalPlans.PhysicalPlan) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException)

Example 85 with InvalidProtocolBufferException

use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project heron by twitter.

the class LocalFileSystemStorage method restoreCheckpoint.

@Override
public Checkpoint restoreCheckpoint(CheckpointInfo info) throws StatefulStorageException {
    String path = getCheckpointPath(info.getCheckpointId(), info.getComponent(), info.getInstanceId());
    byte[] res = FileUtils.readFromFile(path);
    if (res.length != 0) {
        // Try to parse the protobuf
        CheckpointManager.InstanceStateCheckpoint state;
        try {
            state = CheckpointManager.InstanceStateCheckpoint.parseFrom(res);
        } catch (InvalidProtocolBufferException e) {
            throw new StatefulStorageException("Failed to parse the data", e);
        }
        return new Checkpoint(state);
    } else {
        throw new StatefulStorageException("Failed to parse the data");
    }
}
Also used : StatefulStorageException(org.apache.heron.spi.statefulstorage.StatefulStorageException) Checkpoint(org.apache.heron.spi.statefulstorage.Checkpoint) CheckpointManager(org.apache.heron.proto.ckptmgr.CheckpointManager) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException)

Aggregations

InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)334 IOException (java.io.IOException)69 ByteString (com.google.protobuf.ByteString)46 ServerRequest (com.pokegoapi.main.ServerRequest)46 RequestFailedException (com.pokegoapi.exceptions.request.RequestFailedException)39 GeneralSecurityException (java.security.GeneralSecurityException)32 CleartextKeysetHandle (com.google.crypto.tink.CleartextKeysetHandle)25 KeysetHandle (com.google.crypto.tink.KeysetHandle)25 HashMap (java.util.HashMap)25 ArrayList (java.util.ArrayList)22 InvalidProtocolBufferException (org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException)22 List (java.util.List)19 Any (com.google.protobuf.Any)18 Map (java.util.Map)18 Key (org.apache.accumulo.core.data.Key)17 Value (org.apache.accumulo.core.data.Value)17 Status (org.apache.accumulo.server.replication.proto.Replication.Status)17 Text (org.apache.hadoop.io.Text)17 HashSet (java.util.HashSet)12 RunnerApi (org.apache.beam.model.pipeline.v1.RunnerApi)11