Search in sources :

Example 21 with InvalidProtocolBufferException

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;
}
Also used : ManagementCatalogue(org.yamcs.studio.core.model.ManagementCatalogue) Shell(org.eclipse.swt.widgets.Shell) ProcessorInfo(org.yamcs.protobuf.YamcsManagement.ProcessorInfo) YamcsInstance(org.yamcs.protobuf.YamcsManagement.YamcsInstance) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) Display(org.eclipse.swt.widgets.Display)

Example 22 with InvalidProtocolBufferException

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);
        }
    });
}
Also used : ListEventsResponse(org.yamcs.protobuf.Rest.ListEventsResponse) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException)

Example 23 with InvalidProtocolBufferException

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());
        }
    });
}
Also used : EditTagRequest(org.yamcs.protobuf.Rest.EditTagRequest) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) YamcsApiException(org.yamcs.api.YamcsApiException) ArchiveTag(org.yamcs.protobuf.Yamcs.ArchiveTag) TimeInterval(org.yamcs.studio.core.TimeInterval) TimeEncoding(org.yamcs.utils.TimeEncoding) ListTagsResponse(org.yamcs.protobuf.Rest.ListTagsResponse) Logger(java.util.logging.Logger) CreateTagRequest(org.yamcs.protobuf.Rest.CreateTagRequest) IndexResult(org.yamcs.protobuf.Yamcs.IndexResult) ArchiveCatalogue(org.yamcs.studio.core.model.ArchiveCatalogue) Level(java.util.logging.Level) YamcsApiException(org.yamcs.api.YamcsApiException) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) IndexResult(org.yamcs.protobuf.Yamcs.IndexResult) ArchiveCatalogue(org.yamcs.studio.core.model.ArchiveCatalogue)

Example 24 with InvalidProtocolBufferException

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;
}
Also used : Status(org.apache.accumulo.server.replication.proto.Replication.Status) BatchScanner(org.apache.accumulo.core.client.BatchScanner) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) Text(org.apache.hadoop.io.Text) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) Value(org.apache.accumulo.core.data.Value) BatchWriterConfig(org.apache.accumulo.core.client.BatchWriterConfig) BatchWriter(org.apache.accumulo.core.client.BatchWriter) Key(org.apache.accumulo.core.data.Key) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException)

Example 25 with InvalidProtocolBufferException

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;
}
Also used : AccountCapsule(org.tron.core.capsule.AccountCapsule) ByteString(com.google.protobuf.ByteString) ContractValidateException(org.tron.core.exception.ContractValidateException) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ByteString(com.google.protobuf.ByteString) TransferAssetContract(org.tron.protos.Contract.TransferAssetContract)

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