Search in sources :

Example 11 with InvalidProtocolBufferException

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

the class MetaStoreImplZookeeper method asyncGetCursorInfo.

@Override
public void asyncGetCursorInfo(String ledgerName, String consumerName, final MetaStoreCallback<ManagedCursorInfo> callback) {
    String path = prefix + ledgerName + "/" + consumerName;
    if (log.isDebugEnabled()) {
        log.debug("Reading from {}", path);
    }
    zk.getData(path, false, (rc, path1, ctx, data, stat) -> executor.submit(safeRun(() -> {
        if (rc != Code.OK.intValue()) {
            callback.operationFailed(new MetaStoreException(KeeperException.create(Code.get(rc))));
        } else {
            try {
                ManagedCursorInfo info = parseManagedCursorInfo(data);
                callback.operationComplete(info, new ZKStat(stat));
            } catch (ParseException | InvalidProtocolBufferException e) {
                callback.operationFailed(new MetaStoreException(e));
            }
        }
    })), null);
    if (log.isDebugEnabled()) {
        log.debug("Reading from {} ok", path);
    }
}
Also used : MetaStoreException(org.apache.bookkeeper.mledger.ManagedLedgerException.MetaStoreException) ManagedCursorInfo(org.apache.bookkeeper.mledger.proto.MLDataFormats.ManagedCursorInfo) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ParseException(com.google.protobuf.TextFormat.ParseException)

Example 12 with InvalidProtocolBufferException

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

the class MetaStoreImplZookeeper method getManagedLedgerInfo.

@Override
public void getManagedLedgerInfo(final String ledgerName, final MetaStoreCallback<ManagedLedgerInfo> callback) {
    // Try to get the content or create an empty node
    zk.getData(prefix + ledgerName, false, (rc, path, ctx, readData, stat) -> executor.submit(safeRun(() -> {
        if (rc == Code.OK.intValue()) {
            try {
                ManagedLedgerInfo info = parseManagedLedgerInfo(readData);
                info = updateMLInfoTimestamp(info);
                callback.operationComplete(info, new ZKStat(stat));
            } catch (ParseException | InvalidProtocolBufferException e) {
                callback.operationFailed(new MetaStoreException(e));
            }
        } else if (rc == Code.NONODE.intValue()) {
            log.info("Creating '{}{}'", prefix, ledgerName);
            StringCallback createcb = (rc1, path1, ctx1, name) -> {
                if (rc1 == Code.OK.intValue()) {
                    ManagedLedgerInfo info = ManagedLedgerInfo.getDefaultInstance();
                    callback.operationComplete(info, new ZKStat());
                } else {
                    callback.operationFailed(new MetaStoreException(KeeperException.create(Code.get(rc1))));
                }
            };
            ZkUtils.asyncCreateFullPathOptimistic(zk, prefix + ledgerName, new byte[0], Acl, CreateMode.PERSISTENT, createcb, null);
        } else {
            callback.operationFailed(new MetaStoreException(KeeperException.create(Code.get(rc))));
        }
    })), null);
}
Also used : MetaStoreException(org.apache.bookkeeper.mledger.ManagedLedgerException.MetaStoreException) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) StringCallback(org.apache.zookeeper.AsyncCallback.StringCallback) ParseException(com.google.protobuf.TextFormat.ParseException) ManagedLedgerInfo(org.apache.bookkeeper.mledger.proto.MLDataFormats.ManagedLedgerInfo)

Example 13 with InvalidProtocolBufferException

use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project PokeGOAPI-Java by Grover-c13.

the class Map method requestIncensePokemon.

/**
	 * Requests and returns incense pokemon from the server.
	 *
	 * @return the returned incense pokemon response
	 * @throws RequestFailedException if an exception occurred while sending requests
	 */
protected GetIncensePokemonResponse requestIncensePokemon() throws RequestFailedException {
    GetIncensePokemonMessage message = GetIncensePokemonMessage.newBuilder().setPlayerLatitude(api.getLatitude()).setPlayerLongitude(api.getLongitude()).build();
    ServerRequest request = new ServerRequest(RequestType.GET_INCENSE_POKEMON, message);
    api.getRequestHandler().sendServerRequests(request);
    try {
        return GetIncensePokemonResponse.parseFrom(request.getData());
    } catch (InvalidProtocolBufferException e) {
        throw new RequestFailedException(e);
    }
}
Also used : GetIncensePokemonMessage(POGOProtos.Networking.Requests.Messages.GetIncensePokemonMessageOuterClass.GetIncensePokemonMessage) RequestFailedException(com.pokegoapi.exceptions.request.RequestFailedException) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ServerRequest(com.pokegoapi.main.ServerRequest)

Example 14 with InvalidProtocolBufferException

use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project PokeGOAPI-Java by Grover-c13.

the class RequestHandler method sendServerRequests.

/**
	 * Sends a single ServerRequest
	 *
	 * @param request the request to send
	 * @param commons whether this request should include commons
	 * @param commonExclusions the common requests to exclude from this request
	 * @return the result from this request
	 * @throws RequestFailedException if an exception occurred while sending requests
	 */
public ByteString sendServerRequests(ServerRequest request, boolean commons, RequestType... commonExclusions) throws RequestFailedException {
    ServerRequestEnvelope envelope = ServerRequestEnvelope.create();
    envelope.add(request);
    envelope.setCommons(commons);
    envelope.excludeCommons(commonExclusions);
    AsyncHelper.toBlocking(sendAsyncServerRequests(envelope));
    try {
        return request.getData();
    } catch (InvalidProtocolBufferException e) {
        throw new RequestFailedException(e);
    }
}
Also used : RequestFailedException(com.pokegoapi.exceptions.request.RequestFailedException) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException)

Example 15 with InvalidProtocolBufferException

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

the class BoundedSourceRunner method start.

/**
   * The runner harness is meant to send the source over the Beam Fn Data API which would be
   * consumed by the {@link #runReadLoop}. Drop this method once the runner harness sends the
   * source instead of unpacking it from the data block of the function specification.
   */
@Deprecated
public void start() throws Exception {
    try {
        // The representation here is defined as the java serialized representation of the
        // bounded source object packed into a protobuf Any using a protobuf BytesValue wrapper.
        byte[] bytes = definition.getData().unpack(BytesValue.class).getValue().toByteArray();
        @SuppressWarnings("unchecked") InputT boundedSource = (InputT) SerializableUtils.deserializeFromByteArray(bytes, definition.toString());
        runReadLoop(WindowedValue.valueInGlobalWindow(boundedSource));
    } catch (InvalidProtocolBufferException e) {
        throw new IOException(String.format("Failed to decode %s, expected %s", definition.getData().getTypeUrl(), BytesValue.getDescriptor().getFullName()), e);
    }
}
Also used : InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) IOException(java.io.IOException)

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