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);
}
}
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);
}
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);
}
}
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);
}
}
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);
}
}
Aggregations