Package org.chaidb.db.exception

Examples of org.chaidb.db.exception.ChaiDBException


                        Debug.pageHistory(op);
                    }


                    String details = e.toString() + ". nodeoffset=0x" + Integer.toHexString(nodeOffset) + " keysize=0x" + Integer.toHexString(keySize) + " pg=0x" + Integer.toHexString(overflowPage.pageNumber.getPageNumber()) + " of file " + PageBufferManager.getInstance().getBTreeName(overflowPage.pageNumber.getTreeId()) + ".";
                    throw new ChaiDBException(ErrorCode.BTREE_BUFFER_OVERFLOW, details);
                }
                // unfix / release the overflow page
                page.buffer.releasePage(pageNumber.getTreeId(), overflowPage.pageNumber, false);
                keyStartPos += keyLength;
                keyLeft -= keyLength;
                if (keyLeft > 0 && overflowPage.nextPage.getPageNumber() > 0) {
                    overflowPage = new BTreePage(pageNumber.getTreeId(), overflowPage.nextPage, page.btreeSpec, page.buffer);
                    dataLength = page.btreeSpec.getPageSize() - overflowPage.upperBound;
                    keyLength = (keyLeft < dataLength) ? keyLeft : dataLength;
                } else if (keyLeft > 0 && overflowPage.nextPage.getPageNumber() <= 0) {
                    logger.error("[" + Thread.currentThread().getName() + "] time=" + System.currentTimeMillis() + " node offset=0x" + Integer.toHexString(getNodeOffset()) + "  keyLeft=0x" + Integer.toHexString(keyLeft) + " keySize=0x" + Integer.toHexString(keySize) + " node pageNumber=0x" + Integer.toHexString(page.pageNumber.getPageNumber()) + " overflowpage=0x" + Integer.toHexString(overflowPage.pageNumber.getPageNumber()) + " of " + page.buffer.getBTreeName(overflowPage.pageNumber.getTreeId()));
                    for (int i = 0; i < v.size(); i++) {
                        PageNumber op = (PageNumber) v.get(i);
                        Debug.dumpPage(op, page.buffer.getPage(page.pageNumber.getTreeId(), page.pageNumber));
                    }
                    //page in mem!
                    Debug.dumpPage(page.pageNumber, page.buffer.getPage(page.pageNumber.getTreeId(), page.pageNumber));
                    //page we have got!
                    Debug.dumpPage(page.pageNumber, ByteTool.append(new String("Error??\r\n").getBytes(), page.getPage()));
                    Debug.flushPages();

                    // details -ranjeet
                    String details = "Non-match key length in overflow page. The node page number is " + pageNumber.toString() + ".";
                    throw new ChaiDBException(ErrorCode.DATA_LENGTH_NOT_MATCH, details);
                }
            }
        }
        return KeyFactory.createInstance((int) page.getKeyType(), key);
    }
View Full Code Here


        try {
            // fix the current page
            page.page = page.buffer.getPage(pageNumber.getTreeId(), page.pageNumber);
            if (page.page == null)
                throw new ChaiDBException(ErrorCode.BTREE_INVALID_DATAPAGE, "Page is null: " + page.pageNumber.toHexString() + " of " + page.getPageNumber().getTreeId());

            // 1. remove old key and free the overflow pages if true
            if (isOverflowKey()) {
                PageNumber overflowPageNumber = new PageNumber(ByteTool.bytesToInt(page.page, nodeOffset + BTreeSpec.NODE_HEADER_SIZE, page.btreeSpec.isMsbFirst()));
                overflowPageNumber.setTreeId(pageNumber.getTreeId());
View Full Code Here

            } else return values;

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

                if (!undo()) return false;
            } catch (Exception e) {
                this.status = INVALID_STAGE;
                logger.error(e);
                releaseBtrees();//close all btrees, release all btree resource of all abort txn
                throw new ChaiDBException(ErrorCode.RECOVER_ERROR_BASE, e.toString());
            } finally {
                bpm.releaseAllTxnResources();
            }

            ///////////////////////// REDO OPERATION //////////////////////////////////////////
            try {
                redo();
            } catch (Exception e) {
                this.status = INVALID_STAGE;
                logger.error(e);
                throw new ChaiDBException(ErrorCode.RECOVER_ERROR_BASE, e.toString());
            } finally {
                releaseBtrees();//close all btrees
            }

            this.status = INVALID_STAGE;
            txnManager.doCheckpoint(true);

            logger.info("Total time is " + (System.currentTimeMillis() - start) + "ms");

            //Clear up routine.
            redoTable.clear();
            redoStack.clear();
        } catch (ChaiDBException ie) {
            throw ie;
        } catch (Exception e) {
            logger.error(e);
            throw new ChaiDBException(ErrorCode.RECOVER_ERROR_BASE, e.toString());
        } finally {
            // Remove TXN_IN_RECOVERY flag from txn manager.
            txnManager.clearFlags(TransactionManager.TXN_IN_RECOVERY);
        }
        return true;
View Full Code Here

            }

            return true;
        } catch (Exception e) {
            logger.debug(e);
            throw new ChaiDBException(ErrorCode.LOG_REDO_FAILED, e.toString());
        }
    }
View Full Code Here

            }

            return true;
        } catch (Exception e) {
            logger.debug(e);
            throw new ChaiDBException(ErrorCode.LOG_UNDO_FAILED, e.toString());
        }
    }
View Full Code Here

     * @param btree
     * @throws ChaiDBException
     */
    void removeBTreeFromMap(BTree btree) throws ChaiDBException {
        if (!btree2Path.containsKey(btree)) {
            throw new ChaiDBException(ErrorCode.BTREE_NOT_FOUND);
        }
        String filename = (String) btree2Path.remove(btree);
        openedBTree.remove(filename);      
    }
View Full Code Here

     * @return true if the BTree was dropped successfully.
     * @throws ChaiDBException
     */
    public boolean dropBTree(String filename) throws ChaiDBException {
        if (openedBTree.containsKey(filename)) {
            throw new ChaiDBException(ErrorCode.BTREE_ALREADY_OPENED);
        }
        String path = DbEnvironment.getDataHome().concat(File.separator).concat(filename);
        return new File(path).delete();
    }
View Full Code Here

                bp.removeLatestDataPage(docid, treeId, super.getPageNum(), new Integer(super.getTxnId()));
            }
            return true;
        } catch (Exception e) {
            logger.debug(e);
            throw new ChaiDBException(ErrorCode.LOG_REDO_FAILED, e.toString());
        }
    }
View Full Code Here

            System.arraycopy(this.dataArr, 0, page, upperBound, BTreeSpec.PAGE_SIZE - upperBound);

            return true;
        } catch (Exception e) {
            logger.debug(e);
            throw new ChaiDBException(ErrorCode.LOG_UNDO_FAILED, e.toString());
        }

    }
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.