Package org.chaidb.db.exception

Examples of org.chaidb.db.exception.ChaiDBException


    public void checkLock(String treeName) throws ChaiDBException {
        if (!treeid2lock.containsKey(treeName)) {
            if (Debug.checkLock_DEBUG) {
                logger.error(new Throwable("please aquire lock on:" + treeName));
                logger.error(LockTable.getInstance().getDump());
                throw new ChaiDBException(ErrorCode.LOCK_NULL, "please aquire lock");
            }
        }
    }
View Full Code Here


     */
    public void removeLock(String treeName) throws ChaiDBException {
        if (treeid2lock.containsKey(treeName)) {
            treeid2lock.remove(treeName);
        } else {
            throw new ChaiDBException(ErrorCode.LOCK_NO_HOLD, "The lock which should be removed by treeid don't be hold.");
        }
    }
View Full Code Here

     * @throws ChaiDBException
     */
    public boolean delete(Key key, Object value, KernelContext kContext) throws ChaiDBException {
        kContext.checkLock(getBTreeName());
        if (value == null || !(value instanceof NodeId)) {
            throw new ChaiDBException(ErrorCode.BTREE_DEBUG, "the value is invalid , maybe null or not node id type.");
        }
        this.getBTreeSpec().setModified(true);
        NodeId nodeid = (NodeId) value;
        NodeId tmpId = null;
        DuplicatedKeyIterator dki = lookup(key, kContext);
View Full Code Here

            return newList;

        } catch (Exception ee) {
            logger.error(ee);
            String details = "Converter failed in Hyper BTree to decode : " + ee.toString() + ".";
            throw new ChaiDBException(ErrorCode.CONVERTER_DECODING_ERROR, details);
        }
    }
View Full Code Here

                    buffer.dump();
                    if (Debug.DEBUG_PAGEINFO_TRACE) Debug.pageHistory(this.pageNumber);
                    System.exit(-1);
                }

                throw new ChaiDBException(ErrorCode.BTREE_INVALID_BTREEPAGE, "[" + Thread.currentThread().getName() + "] time=" + System.currentTimeMillis() + " file=" + btreeSpec.getBtreeName() + " pg=" + pageNumber.toHexString());
            }

        }

    }
View Full Code Here

                if (Debug.DEBUG_PAGEINFO_TRACE) Debug.pageHistory(this.pageNumber);
                if (Debug.DEBUG_DUMP_MEMORY) buffer.dumpMemInfo(Debug.DUMP_ALL, "memoryinfo");
                System.exit(-1);
            }

            throw new ChaiDBException(ErrorCode.BTREE_INVALID_BTREEPAGE, "Unknown BTreePage Type:" + pageNumber.toHexString() + " of " + btreeSpec.btree.getBTreeName());
        }
    }
View Full Code Here

        try {
            // fix the current page
            page = buffer.getPage(pageNumber.getTreeId(), pageNumber);

            if (page == null)
                throw new ChaiDBException(ErrorCode.BTREE_INVALID_BTREEPAGE, "Page is null: " + pageNumber.toHexString() + " of " + btreeSpec.getBtreeName());
            if (Debug.DEBUG_CHECKPAGENUMBER) {
                if (!Debug.checkPageNumber(pageNumber, this.page)) {
                    logger.fatal(new Throwable("there is hole in GetPage!"));
                    this.buffer.dump();
                    Db.getLogManager().flush();
                    Debug.dumpPageToLog(page);
                    if (Debug.DEBUG_PAGEINFO_TRACE) Debug.pageHistory(this.pageNumber);

                    System.exit(-1);

                }
            }


            setKeyType((byte) key.getKeyType());

            //====>>> 1. calculate the place to insert the node
            // sort insert
            KeyIndex keyIndex = sortKey(key);
            boolean keyExist = keyIndex.keyExist;
            int nextIndex = keyIndex.keyIndex;
            int currNode = getCurrNodeNumbers();
            // check mode to replace existing key's value or just return
            if (keyExist && mode == IDBIndex.STORE_INSERT) {
                // untouch the node, may throw exception later &&&
                // unfix this page
                buffer.releasePage(pageNumber.getTreeId(), pageNumber, false);
                // details -ranjeet
                String details = "The key value is " + new String(key.toBytes()) + ".";
                /* Modified by ben at aug, 12, 2002. pending issue */
                throw new ChaiDBException(ErrorCode.ENTRY_ALREADY_EXIST, details);
            }
            /* Modified by ben zhang at aug, 12, 2002 */
            int newNodeSize = BTreeSpec.DATA_NODE_HEADER_SIZE + data.length;

            if (isLeaf()) {
                //=====>>> If is a leaf page
                //=====>>> 2. insert / replace key/data pair
//                BTreeNode leafNode;
                DataPage dataPage = null;
                if (keyExist) {
                    insertNodeWhenKeyExistedAndIsLeaf(nextIndex, kContext, key, data, mode);
                } else { //Key not exist
                    insertNodeWhenKeyNotExistedAndIsLeaf(key, needLog, txnId, kContext, dataPage, newNodeSize, data, keyExist, nextIndex, currNode, mode);
                }
            } else if (isBTree()) {
                //=====>>> If is an internal page
                if (data.length != 4) {
                    throw new ChaiDBException(ErrorCode.BTREE_INT_PAGE_NUMBER);
                }

                //=====>>> 3a. if node already exists, simply change the pageNumber and return
                if (keyExist) {
                    insertNodeWhenKeyExistedAndIsBTree(nextIndex, needLog, data, txnId);
View Full Code Here

        leafNode.setInternalNode(key.toBytes(), kContext);
        //reput it to LDPL if this datapage is allocated this time
        if (!pageFixed) {
            if (dataPage.isOverflow()) {
                String details = Debug.getDebugInfo() + " want to put overflowpage[" + dataPage.pageNumber + "] to LDPL.";
                throw new ChaiDBException(ErrorCode.BTREE_DEBUG, details);
            }
            buffer.putLatestDataPage(docid, dataPage.pageNumber, needLog ? new Integer(txnId) : null);
        } else {
            /* if the following statement is not within "else",
             * the below line must be uncommented
View Full Code Here

            // fix the current page
            page = buffer.getPage(pageNumber.getTreeId(), pageNumber);

            if (page == null)
                throw new ChaiDBException(ErrorCode.BTREE_INVALID_BTREEPAGE, "Page is null: " + pageNumber.toHexString() + " of " + btreeSpec.getBtreeName());
            if (Debug.DEBUG_CHECKPAGENUMBER) {
                if (!Debug.checkPageNumber(pageNumber, this.page)) {
                    logger.fatal(new Throwable("there is hole in GetPage!"));
                    this.buffer.dump();
                    Db.getLogManager().flush();
View Full Code Here

        logger.error("key=" + kk + ", KeyIndex=" + keyIndex
                .keyIndex + ",pg=" + pageNumber.toHexString());
        //Debug.pageHistory(Integer.toHexString(pageNumber.getPageNumber()));
        Debug.flushPages();
        if (Debug.DEBUG_THREAD) Debug.flushThreads();
        throw new ChaiDBException(ErrorCode.ENTRY_ALREADY_EXIST, details);
    }
View Full Code Here

TOP

Related Classes of org.chaidb.db.exception.ChaiDBException

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.