Example usage for org.apache.cassandra.exceptions InvalidRequestException getMessage

List of usage examples for org.apache.cassandra.exceptions InvalidRequestException getMessage

Introduction

In this page you can find the example usage for org.apache.cassandra.exceptions InvalidRequestException getMessage.

Prototype

public String getMessage();

Source Link

Document

The exception message.

Usage

From source file:com.perpetumobile.bit.orm.cassandra.CliMain.java

License:Apache License

private void describeKeySpace(String keySpaceName, KsDef metadata) throws TException {
    NodeProbe probe = sessionState.getNodeProbe();

    // getting compaction manager MBean to displaying index building information
    CompactionManagerMBean compactionManagerMBean = (probe == null) ? null : probe.getCompactionManagerProxy();

    // Describe and display
    sessionState.out.println("Keyspace: " + keySpaceName + ":");
    try {/*from www . j  a  va2s  .  co m*/
        KsDef ks_def;
        ks_def = metadata == null ? thriftClient.describe_keyspace(keySpaceName) : metadata;
        sessionState.out.println("  Replication Strategy: " + ks_def.strategy_class);

        sessionState.out.println("  Durable Writes: " + ks_def.durable_writes);

        Map<String, String> options = ks_def.strategy_options;
        sessionState.out
                .println("    Options: [" + ((options == null) ? "" : FBUtilities.toString(options)) + "]");

        sessionState.out.println("  Column Families:");

        Collections.sort(ks_def.cf_defs, new CfDefNamesComparator());

        for (CfDef cf_def : ks_def.cf_defs)
            describeColumnFamily(ks_def, cf_def, probe);

        // compaction manager information
        if (compactionManagerMBean != null) {
            for (Map<String, String> info : compactionManagerMBean.getCompactions()) {
                // if ongoing compaction type is index build
                if (info.get("taskType").equals(OperationType.INDEX_BUILD.toString()))
                    continue;
                sessionState.out.printf("%nCurrently building index %s, completed %d of %d bytes.%n",
                        info.get("columnfamily"), info.get("bytesComplete"), info.get("totalBytes"));
            }
        }

        // closing JMX connection
        if (probe != null)
            probe.close();
    } catch (InvalidRequestException e) {
        sessionState.out.println("Invalid request: " + e);
    } catch (NotFoundException e) {
        sessionState.out.println("Keyspace " + keySpaceName + " could not be found.");
    } catch (IOException e) {
        sessionState.out.println("Error while closing JMX connection: " + e.getMessage());
    }
}

From source file:dk.dma.ais.store.importer.PacketsAreaCell10SSTableWriter.java

License:Open Source License

private void writePacket(AisPacket packet, Position position) {
    final long ts = packet.getBestTimestamp();
    if (ts > 0) {
        final int cellid = getGridCell(position);
        try {/*from  ww  w  .  ja v a  2 s .  c om*/
            writer().addRow(cellid, timeBlock(table(), Instant.ofEpochMilli(ts)), new Date(ts),
                    ByteBuffer.wrap(digest(packet)), packet.getStringMessage());
        } catch (InvalidRequestException e) {
            LOG.error("Failed to store message in " + table().toString() + " due to "
                    + e.getClass().getSimpleName() + ": " + e.getMessage());
        } catch (IOException e) {
            LOG.error("Failed to store message in " + table().toString() + " due to "
                    + e.getClass().getSimpleName() + ": " + e.getMessage());
        }
    } else {
        LOG.error("Cannot get timestamp from: " + packet.getStringMessage());
    }
}

From source file:dk.dma.ais.store.importer.PacketsAreaUnknownSSTableWriter.java

License:Open Source License

private void writePacket(AisPacket packet) {
    final long ts = packet.getBestTimestamp();
    if (ts > 0) {
        AisMessage message = packet.tryGetAisMessage();
        if (message != null) {
            final int mmsi = message.getUserId();
            if (mmsi >= 0) {
                try {
                    writer().addRow(mmsi, timeBlock(table(), Instant.ofEpochMilli(ts)), new Date(ts),
                            ByteBuffer.wrap(digest(packet)), packet.getStringMessage());
                } catch (InvalidRequestException e) {
                    LOG.error("Failed to store message in " + table().toString() + " due to "
                            + e.getClass().getSimpleName() + ": " + e.getMessage());
                } catch (IOException e) {
                    LOG.error("Failed to store message in " + table().toString() + " due to "
                            + e.getClass().getSimpleName() + ": " + e.getMessage());
                }/*from  www.  ja  v a  2 s.com*/
            } else {
                LOG.error("Cannot get MMSI from: " + packet.getStringMessage());
            }
        } else {
            LOG.error("Cannot decode: " + packet.getStringMessage());
        }
    } else {
        LOG.error("Cannot get timestamp from: " + packet.getStringMessage());
    }
}

From source file:dk.dma.ais.store.importer.PacketsMmsiSSTableWriter.java

License:Open Source License

@Override
public void accept(AisPacket packet) {
    incNumberOfPacketsProcessed();//from  w w  w .  j  a v a2s . c  om

    final long ts = packet.getBestTimestamp();
    if (ts > 0) {
        AisMessage message = packet.tryGetAisMessage();
        if (message != null) {
            final int mmsi = message.getUserId();
            if (mmsi >= 0) {
                try {
                    writer().addRow(mmsi, timeBlock(table(), Instant.ofEpochMilli(ts)), new Date(ts),
                            ByteBuffer.wrap(digest(packet)), packet.getStringMessage());
                } catch (InvalidRequestException e) {
                    LOG.error("Failed to store message in " + table().toString() + " due to "
                            + e.getClass().getSimpleName() + ": " + e.getMessage());
                } catch (IOException e) {
                    LOG.error("Failed to store message in " + table().toString() + " due to "
                            + e.getClass().getSimpleName() + ": " + e.getMessage());
                }
            } else {
                LOG.error("Cannot get MMSI from: " + packet.getStringMessage());
            }
        } else {
            LOG.error("Cannot decode: " + packet.getStringMessage());
        }
    } else {
        LOG.error("Cannot get timestamp from: " + packet.getStringMessage());
    }
}

From source file:dk.dma.ais.store.importer.PacketsTimeSSTableWriter.java

License:Open Source License

@Override
public void accept(AisPacket packet) {
    incNumberOfPacketsProcessed();/*from w w w  .  j  a  v a 2 s  . c o  m*/

    final long ts = packet.getBestTimestamp();
    if (ts > 0) {
        try {
            writer().addRow(timeBlock(table(), Instant.ofEpochMilli(ts)), new Date(ts),
                    ByteBuffer.wrap(digest(packet)), packet.getStringMessage());
        } catch (InvalidRequestException e) {
            LOG.error("Failed to store message in " + table().toString() + " due to "
                    + e.getClass().getSimpleName() + ": " + e.getMessage());
        } catch (IOException e) {
            LOG.error("Failed to store message in " + table().toString() + " due to "
                    + e.getClass().getSimpleName() + ": " + e.getMessage());
        }
    } else {
        LOG.error("Cannot get timestamp from: " + packet.getStringMessage());
    }
}