Search in sources :

Example 86 with InvalidProtocolBufferException

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

the class MetricsCacheMetricsProvider method getMetricsFromMetricsCache.

@VisibleForTesting
TopologyManager.MetricResponse getMetricsFromMetricsCache(String metric, String component, Instant start, Duration duration) {
    LOG.log(Level.FINE, "MetricsCache Query request metric name : {0}", metric);
    TopologyManager.MetricRequest request = TopologyManager.MetricRequest.newBuilder().setComponentName(component).setExplicitInterval(MetricInterval.newBuilder().setStart(start.minus(duration).getEpochSecond()).setEnd(start.getEpochSecond()).build()).addMetric(metric).build();
    LOG.log(Level.FINE, "MetricsCache Query request: \n{0}", request);
    HttpURLConnection connection = NetworkUtils.getHttpConnection(getCacheLocation());
    try {
        boolean result = NetworkUtils.sendHttpPostRequest(connection, "X", request.toByteArray());
        if (!result) {
            LOG.warning("Failed to get response from metrics cache. Resetting connection...");
            resetCacheLocation();
            return null;
        }
        byte[] responseData = NetworkUtils.readHttpResponse(connection);
        try {
            TopologyManager.MetricResponse response = TopologyManager.MetricResponse.parseFrom(responseData);
            LOG.log(Level.FINE, "MetricsCache Query response: \n{0}", response);
            return response;
        } catch (InvalidProtocolBufferException e) {
            LOG.log(Level.SEVERE, "protobuf cannot parse the reply from MetricsCache ", e);
            return null;
        }
    } finally {
        if (connection != null) {
            connection.disconnect();
        }
    }
}
Also used : TopologyManager(org.apache.heron.proto.tmanager.TopologyManager) HttpURLConnection(java.net.HttpURLConnection) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 87 with InvalidProtocolBufferException

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

the class CompatibilityTest method testParseFromInvalidProtocolBufferException.

public void testParseFromInvalidProtocolBufferException() throws Exception {
    try {
        @SuppressWarnings("unused") TypicalData output = TypicalData.parseFrom(new byte[] { 0x08 });
        fail("Expected InvalidProtocolBufferException to be thrown.");
    } catch (InvalidProtocolBufferException e) {
    // Expected
    }
}
Also used : TypicalData(protos.TypicalData) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException)

Example 88 with InvalidProtocolBufferException

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

the class CompatibilityTest method testParseDelimitedFromInvalidProtocolBufferException.

public void testParseDelimitedFromInvalidProtocolBufferException() throws Exception {
    try {
        ByteArrayInputStream in = new ByteArrayInputStream(new byte[] { 0x03, 0x01, 0x02 });
        @SuppressWarnings("unused") TypicalData output = TypicalData.parseDelimitedFrom(in);
        fail("Expected InvalidProtocolBufferException to be thrown.");
    } catch (InvalidProtocolBufferException e) {
    // Expected
    }
}
Also used : TypicalData(protos.TypicalData) ByteArrayInputStream(java.io.ByteArrayInputStream) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException)

Example 89 with InvalidProtocolBufferException

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

the class TrailingZerosTest method testFailsToReadMessageWithTooManyTrailingZeros.

public void testFailsToReadMessageWithTooManyTrailingZeros() throws Exception {
    TypicalData data = TypicalData.newBuilder().build();
    byte[] serializedData = data.toByteArray();
    byte[] paddedSerializedData = Arrays.copyOf(serializedData, serializedData.length + 8);
    try {
        TypicalData.parseFrom(paddedSerializedData);
        fail("should not have parsed a buffer with too many trailing zeros");
    } catch (InvalidProtocolBufferException e) {
    // expected
    }
}
Also used : TypicalData(protos.TypicalData) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException)

Example 90 with InvalidProtocolBufferException

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

the class CompatibilityTest method testMergeDelimitedFromInvalidProtocolBufferException.

public void testMergeDelimitedFromInvalidProtocolBufferException() throws Exception {
    try {
        ByteArrayInputStream in = new ByteArrayInputStream(new byte[] { 0x03, 0x01, 0x02 });
        TypicalData.Builder builder = TypicalData.newBuilder();
        builder.mergeDelimitedFrom(in, ExtensionRegistry.getEmptyRegistry());
        builder.build();
        fail("Expected InvalidProtocolBufferException to be thrown.");
    } catch (InvalidProtocolBufferException e) {
    // Expected
    }
}
Also used : TypicalData(protos.TypicalData) ByteArrayInputStream(java.io.ByteArrayInputStream) 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