Package com.btoddb.fastpersitentqueue.exceptions

Examples of com.btoddb.fastpersitentqueue.exceptions.FpqException


        }
    }

    public static void logAndThrow(Logger logger, String msg) throws FpqException {
        logger.error(msg);
        throw new FpqException(msg);
    }
View Full Code Here


        throw new FpqException(msg);
    }

    public static void logAndThrow(Logger logger, String msg, Exception e) throws FpqException {
        logger.error(msg, e);
        throw new FpqException(msg, e);
    }
View Full Code Here

    public Event fromBytes(byte[] theBytes) {
        Context context = createContext(theBytes, 0);
        int tmp;

        if (VERSION != (tmp=bytesToInt(context))) {
            throw new FpqException("version, " + tmp + ", not supported");
        }

        Event event = new SimpleEvent();

        tmp = bytesToInt(context);
View Full Code Here

        return context.theBytes;
    }

    int calculateBufferLength(Event event) {
        if (null == event) {
            throw new FpqException("cannot process a null event");
        }

        int sum = calculateVIntBufferSpace(VERSION) + // version
                    calculateVIntBufferSpace(event.getHeaders().size()) // number of headers
                    ;
View Full Code Here

        return entry;
    }

    public Collection<FpqEntry> append(Collection<FpqEntry> events) throws IOException {
        if (shutdownInProgress) {
            throw new FpqException("FPQ has been shutdown or is in progress, cannot append");
        }

        // TODO:BTB - optimize this by calling file.append() with collection of data
        List<FpqEntry> entryList = new ArrayList<FpqEntry>(events.size());
        for (FpqEntry entry : events) {
View Full Code Here

        reportTake(Collections.singleton(entry));
    }

    public void reportTake(Collection<FpqEntry> entries) throws IOException {
        if (shutdownInProgress) {
            throw new FpqException("FPQ has been shutdown or is in progress, cannot report TAKE");
        }

        if (null == entries || entries.isEmpty()) {
            logger.debug("provided null or empty collection - ignoring");
            return;
View Full Code Here

    }

    private FpqContext contextThrowException() {
        FpqContext context = threadLocalFpqContext.get();
        if (null == context) {
            throw new FpqException("transaction not started - call beginTransaction first");
        }
        return context;
    }
View Full Code Here

    public void beginTransaction() {
        checkInitializing();
        checkShutdown();

        if (null != threadLocalFpqContext.get()) {
            throw new FpqException("transaction already started on this thread - must commit/rollback before starting another");
        }
        FpqContext context = createContext();
        threadLocalFpqContext.set(context);
        activeContexts.put(context, MAP_OBJECT);
    }
View Full Code Here

        // - can call 'pop' with same context over and over until context.queue has size context.maxBatchSize

        FpqContext context = contextThrowException();

        if (size > maxTransactionSize) {
            throw new FpqException("size of " + size + " exceeds maximum transaction size of " + maxTransactionSize);
        }

        Collection<FpqEntry> entries= memoryMgr.pop(size);

        // at this point, if system crashes, the entries are in the journal files
View Full Code Here

        }
    }

    private void checkInitializing() {
        if (initializing) {
            throw new FpqException("FPQ still initializing - can't perform operation");
        }
    }
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.