use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project yamcs-studio by yamcs.
the class ProcessingInfoDialogHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Shell shell = HandlerUtil.getActiveShellChecked(event);
ManagementCatalogue catalogue = ManagementCatalogue.getInstance();
ProcessorInfo processor = catalogue.getCurrentProcessorInfo();
if (processor != null) {
catalogue.fetchInstanceInformationRequest(processor.getInstance()).whenComplete((data, exc) -> {
if (exc == null) {
Display display = Display.getDefault();
if (!display.isDisposed()) {
display.asyncExec(() -> {
try {
YamcsInstance instance = YamcsInstance.parseFrom(data);
new ProcessingInfoDialog(shell, instance, processor).open();
} catch (InvalidProtocolBufferException e) {
log.log(Level.SEVERE, "Failed to decode server message", e);
}
});
}
}
});
}
return null;
}
use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project yamcs-studio by yamcs.
the class EventLog method fetchLatestEvents.
private void fetchLatestEvents() {
String instance = ManagementCatalogue.getCurrentYamcsInstance();
EventCatalogue.getInstance().fetchLatestEvents(instance).whenComplete((data, exc) -> {
try {
ListEventsResponse response = ListEventsResponse.parseFrom(data);
Display.getDefault().asyncExec(() -> {
addEvents(response.getEventList());
});
} catch (InvalidProtocolBufferException e) {
log.log(Level.SEVERE, "Failed to decode server message", e);
}
});
}
use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project yamcs-studio by yamcs.
the class ArchiveIndexReceiver method getIndex.
public void getIndex(TimeInterval interval) {
if (receiving) {
log.info("already receiving data");
return;
}
ArchiveCatalogue catalogue = ArchiveCatalogue.getInstance();
catalogue.downloadIndexes(interval, data -> {
try {
IndexResult response = IndexResult.parseFrom(data);
log.fine(String.format("Received %d archive records", response.getRecordsCount()));
archiveView.receiveArchiveRecords(response);
} catch (InvalidProtocolBufferException e) {
throw new YamcsApiException("Failed to decode server message", e);
}
}).whenComplete((data, exc) -> {
if (exc == null) {
log.info("Done receiving archive records.");
archiveView.receiveArchiveRecordsFinished();
receiving = false;
} else {
archiveView.receiveArchiveRecordsError(exc.toString());
}
});
}
use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project accumulo by apache.
the class CloseWriteAheadLogReferences method updateReplicationEntries.
/**
* Given the set of WALs which have references in the metadata table, close any status messages with reference that WAL.
*
* @param conn
* Connector
* @param closedWals
* {@link Set} of paths to WALs that marked as closed or unreferenced in zookeeper
*/
protected long updateReplicationEntries(Connector conn, Set<String> closedWals) {
BatchScanner bs = null;
BatchWriter bw = null;
long recordsClosed = 0;
try {
bw = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
bs = conn.createBatchScanner(MetadataTable.NAME, Authorizations.EMPTY, 4);
bs.setRanges(Collections.singleton(Range.prefix(ReplicationSection.getRowPrefix())));
bs.fetchColumnFamily(ReplicationSection.COLF);
Text replFileText = new Text();
for (Entry<Key, Value> entry : bs) {
Status status;
try {
status = Status.parseFrom(entry.getValue().get());
} catch (InvalidProtocolBufferException e) {
log.error("Could not parse Status protobuf for {}", entry.getKey(), e);
continue;
}
// Ignore things that aren't completely replicated as we can't delete those anyways
MetadataSchema.ReplicationSection.getFile(entry.getKey(), replFileText);
String replFile = replFileText.toString();
boolean isClosed = closedWals.contains(replFile);
// metadata doesn't have a reference to the given WAL
if (!status.getClosed() && !replFile.endsWith(RFILE_SUFFIX) && isClosed) {
try {
closeWal(bw, entry.getKey());
recordsClosed++;
} catch (MutationsRejectedException e) {
log.error("Failed to submit delete mutation for {}", entry.getKey());
continue;
}
}
}
} catch (TableNotFoundException e) {
log.error("Replication table was deleted", e);
} finally {
if (null != bs) {
bs.close();
}
if (null != bw) {
try {
bw.close();
} catch (MutationsRejectedException e) {
log.error("Failed to write delete mutations for replication table", e);
}
}
}
return recordsClosed;
}
use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project java-tron by tronprotocol.
the class TransferAssetActuator method validate.
@Override
public boolean validate() throws ContractValidateException {
try {
TransferAssetContract transferAssetContract = this.contract.unpack(TransferAssetContract.class);
Preconditions.checkNotNull(transferAssetContract.getOwnerAddress(), "OwnerAddress is null");
Preconditions.checkNotNull(transferAssetContract.getToAddress(), "ToAddress is null");
Preconditions.checkNotNull(transferAssetContract.getAssetName(), "AssetName is null");
Preconditions.checkNotNull(transferAssetContract.getAmount(), "Amount is null");
if (transferAssetContract.getOwnerAddress().equals(transferAssetContract.getToAddress())) {
throw new ContractValidateException("Cannot transfer asset to yourself.");
}
byte[] ownerKey = transferAssetContract.getOwnerAddress().toByteArray();
if (!this.dbManager.getAccountStore().has(ownerKey)) {
throw new ContractValidateException();
}
// if account with to_address is not existed, create it.
ByteString toAddress = transferAssetContract.getToAddress();
if (!dbManager.getAccountStore().has(toAddress.toByteArray())) {
AccountCapsule account = new AccountCapsule(toAddress, AccountType.Normal);
dbManager.getAccountStore().put(toAddress.toByteArray(), account);
}
byte[] nameKey = transferAssetContract.getAssetName().toByteArray();
if (!this.dbManager.getAssetIssueStore().has(nameKey)) {
throw new ContractValidateException();
}
long amount = transferAssetContract.getAmount();
AccountCapsule ownerAccount = this.dbManager.getAccountStore().get(ownerKey);
Map<String, Long> asset = ownerAccount.getAssetMap();
if (asset.isEmpty()) {
throw new ContractValidateException();
}
Long assetAmount = asset.get(ByteArray.toStr(nameKey));
if (amount <= 0 || null == assetAmount || amount > assetAmount || assetAmount <= 0) {
throw new ContractValidateException();
}
} catch (InvalidProtocolBufferException e) {
throw new ContractValidateException();
}
return true;
}
Aggregations