Package com.btoddb.fastpersitentqueue.exceptions

Examples of com.btoddb.fastpersitentqueue.exceptions.FpqException


        }
    }

    private void checkShutdown() {
        if (shuttingDown) {
            throw new FpqException("FPQ shutting down - can't perform operation");
        }
    }
View Full Code Here


    public void push(Collection<byte[]> entries) {
        if (!popping) {
            pushing = true;
        }
        else {
            throw new FpqException("This context has already been used for 'popping'.  can't switch to pushing - create a new context");
        }

        if (queue.size()+entries.size() <= maxTransactionSize) {
            for (byte[] entry : entries) {
                queue.add(new FpqEntry(idGen.incrementAndGet(), entry));
            }
        }
        else {
            throw new FpqException("pushing " + entries.size() + " will exceed maximum transaction size of " + maxTransactionSize + " events");
        }
        jmxMetrics.pushes.mark(entries.size());
    }
View Full Code Here

    public void createPoppedEntries(Collection<FpqEntry> entries) {
        if (!pushing) {
            popping = true;
        }
        else {
            throw new FpqException("This context has already been used for 'pushing'.  can't switch to popping - create a new context");
        }

        if (null == entries || entries.isEmpty()) {
            return;
        }
View Full Code Here

                                                          }
                                                      });

    public void init() throws IOException {
        if (0 == maxSegmentSizeInBytes) {
            throw new FpqException("property, maxSegmentSizeInBytes, must be greater than zero");
        }
        if (4 > maxNumberOfActiveSegments) {
            throw new FpqException("property, maxNumberOfActiveSegments, must be 4 or greater");
        }

        segmentSerializer.setDirectory(pagingDirectory);
        segmentSerializer.init();
View Full Code Here

     *
     * @param events
     */
    public void push(Collection<FpqEntry> events) {
        if (shutdownInProgress) {
            throw new FpqException("FPQ has been shutdown or is in progress, cannot push events");
        }

        // calculate memory used by the list of entries
        long spaceRequired = 0;
        for (FpqEntry entry : events) {
            spaceRequired += entry.getMemorySize();
        }

        if (spaceRequired > maxSegmentSizeInBytes) {
            throw new FpqException(String.format("the space required to push entries (%d) is greater than maximum segment size (%d) - increase segment size or reduce entry size", spaceRequired, maxSegmentSizeInBytes));
        }

        logger.debug("pushing {} event(s) totalling {} bytes", events.size(), spaceRequired);
        MemorySegment segment;
        while (true) {
View Full Code Here

     * @param batchSize
     * @return
     */
    public Collection<FpqEntry> pop(int batchSize) {
        if (shutdownInProgress) {
            throw new FpqException("FPQ has been shutdown or is in progress, cannot pop events");
        }

        logger.debug("popping up to {} events", batchSize);

        // find the memory segment we need and reserve our entries
View Full Code Here

TOP

Related Classes of com.btoddb.fastpersitentqueue.exceptions.FpqException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.