Package org.chaidb.db.exception

Examples of org.chaidb.db.exception.ChaiDBException


     */
    public static boolean removeElementChildElement(String path, String elementID, String childElementName, String childElementID, Hashtable filterCannotRemoved) throws ChaiDBException {

        ConfigTool element = ConfigTool.findElementByPath(path, elementID);
        if (element == null) {
            throw new ChaiDBException(ErrorCode.INVALID_INPUT_PARAM, "the config " + elementID + "has not exist!");
        }
        return element.removeChildElement(childElementName, childElementID, filterCannotRemoved);

    }
View Full Code Here


        if (!attributes.containsKey(attributeName)) {
            try {
                attributes.put(attributeName, attributeValue);
            } catch (Exception ex) {
                throw new ChaiDBException(ErrorCode.INVALID_INPUT_PARAM, "adding attribute name or adding attribute " + "value can't be null");
            }
        } else {
            throw new ChaiDBException(ErrorCode.INVALID_INPUT_PARAM, "the Attribute " + attributeName + "has existed!");
        }

    }
View Full Code Here

        recA = (byte[]) lsnList.get(lsn);

        if (recA == null) {
            String details = "Lsn: " + lsn.getFileId() + ":" + lsn.getOffset() + ".";
            throw new ChaiDBException(ErrorCode.LOG_RECORD_NOT_EXIST, details);
        } else {
            return recA;
        }
    }
View Full Code Here

    public synchronized LogRecord get(Lsn lsn, Lsn stopLsn) throws ChaiDBException {
        //modified by marriane 2001-11-21 add 'synchronized'
        byte[] recA = getBytes(lsn, stopLsn);

        if (recA == null) {
            throw new ChaiDBException(ErrorCode.LOG_RECORD_NOT_EXIST, "Lsn=" + lsn);
        }

        return RecordFactory.createRecord(recA, 0);
    }
View Full Code Here

        //Judge whether system are doing checkpoint.
        //ilockerId = lockManager.id();
        //lock = lockManager.get(ilockerId, lockManager.LOCK_WAITING, lockManager.OBJECT_OBJECT, checkpointOjb, lockManager.LOCK_READ);
        //lockManager.put(lock);

        if (DbEnvironment.READ_ONLY) throw new ChaiDBException(ErrorCode.DATABASE_IS_READONLY);

        //I don't know whether the logic is right ? Check it when release.
        if (flagCheck(flags, DB_TXN_NOWAIT | DB_TXN_NOSYNC | DB_TXN_SYNC))
            throw new ChaiDBException(ErrorCode.ILLEGAL_FLAG_BEGIN_TXN);
        if (flagCombinationCheck(flags, DB_TXN_NOSYNC, DB_TXN_SYNC) == false)
            throw new ChaiDBException(ErrorCode.ILLEGAL_COMBINATION_FLAG_BEGIN_TXN);
        //if ( txnChain.size() >= maxTxns)
        //    throw new ChaiDBException(ErrorCode.MAXIMUM_ACTIVE_TXNS, "The number of transaction is reach maximum.");
        if (freePool.isEmpty()) {   //Free transaction pool is empty.
            txn = new TransactionImpl(this)//Allocate memory from heap.
        } else {
            txn = (TransactionImpl) freePool.remove(); //Removes an element from the pool.
        }
        /* Sets the flags of transaction. */
        if ((flags & Transaction.TXN_DIRTY_READ) != 0) txn.setFlags(Transaction.TXN_DIRTY_READ);
        if ((flags & Transaction.TXN_NOSYNC) != 0) txn.setFlags(Transaction.TXN_NOSYNC);
        if ((flags & Transaction.TXN_SYNC) != 0) txn.setFlags(Transaction.TXN_SYNC);
        if ((flags & Transaction.TXN_NOWAIT) != 0) txn.setFlags(Transaction.TXN_NOWAIT);

        /*
         * We do not have to write begin records (and if we do not, then we
         * need never write records for read-only transactions).  However,
         * we do need to find the current LSN so that we can store it in the
         * transaction structure, so we can know where to take checkpoints.
* Note: Here Zhu Liang will put the value into the beginLsn field of the begun transaction instance.
         */

        /* Environment is being recovered by recover routine. Note: <this.flags> */
        if ((TransactionManagerImpl.flags & TXN_IN_RECOVERY) != 0) {
            throw new ChaiDBException(ErrorCode.IN_RECOVER_PROCESS);
        }

        /* Make sure that we aren't still recovering prepared transactions. Using only during XA recovery.*/
        //if (nRestoredTxns != 0){
        //  throw new ChaiDBException("txn_begin: recovery of prepared but not yet committed transactions is incomplete.");
View Full Code Here

    private synchronized void saveEnvironment() throws ChaiDBException {
        try {
            DBState.getInstance().setLatestTxnId(lastTxnId);
        } catch (Exception e) {
            logger.error(e);
            throw new ChaiDBException(ErrorCode.TXN_ENV_SAVE_FAILED, e.toString());
        }

    }
View Full Code Here

    /**
     * converts first 28 byte array into LogRecord instance
     */
    public boolean read(byte[] bArr, int start) throws ChaiDBException {
        if (bArr == null) {
            throw new ChaiDBException(ErrorCode.LOG_BYTE_ARRAY_IS_NULL);
        }

        /* get the values of Hdr object */
        if (!header.read(bArr, start)) {
            throw new ChaiDBException(ErrorCode.LOG_RECORD_HEADER_CANNOT_READ);
        }
        int logLen = header.getLength();

        if (logLen == 0 || logLen > LogManagerImpl.READ_LOG_CHUNK_SIZE) {
            throw new ChaiDBException(ErrorCode.INVALID_LOG_RECORD, "invalid log record length");
        }

        /* get the values of LogRecord object */
        int hdrLen = Hdr.getHdrLength();
        int step = start + hdrLen;
View Full Code Here

        Link lk = (Link) txnsLog.get(id);
        if (lk == null) {
            if (txnsLog.size() < maxCount) {
                lk = new Link();
                txnsLog.put(id, lk);
            } else throw new ChaiDBException(ErrorCode.TXN_TOO_MANY_IN_MEMORY);
        }
        // record the in-memory log only when the status is normal
        if (lk.status == NORMAL) lk.insertHead(record);
    }
View Full Code Here

     */
    public void commit(int txnId) throws ChaiDBException {
        Integer id = new Integer(txnId);
        Link lk = (Link) txnsLog.get(id);
        if (lk == null) return;
        if (lk.status != PRE_COMMIT) throw new ChaiDBException(ErrorCode.TRANSACTION_LACK_PRECOMMIT);
        cleanMemoryLog(txnId);
    }
View Full Code Here

        try {
            if (!bNotified) wait();
        } catch (InterruptedException e) {
            String errMessage = "The waiting lock is interrupted" + e.getMessage();
            logger.error(errMessage);
            throw new ChaiDBException(ErrorCode.LOCK_INTERRUPTED, errMessage);
        }
    }
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.