Package kr.co.vcnc.haeinsa.exception

Examples of kr.co.vcnc.haeinsa.exception.ConflictException


            // If primary row is in prewritten state, transaction can be aborted only after expiry.
            if (ignoreExpiry || primaryRowTx.getCurrent().getExpiry() < System.currentTimeMillis()) {
                // if transaction is not expired, process recover
            } else {
                // if transaction haven't past expiry, recover should be failed.
                throw new ConflictException();
            }
        }

        extendExpiry();

        switch (primaryRowTx.getCurrent().getState()) {
        case ABORTED:
        case PREWRITTEN: {
            abort();
            break;
        }
        case COMMITTED: {
            // Transaction is already succeeded.
            makeStable();
            break;
        }
        default:
            throw new ConflictException();
        }
    }
View Full Code Here


            return rowState;
        }
        int recoverCount = 0;
        while (true) {
            if (recoverCount > RECOVER_MAX_RETRY_COUNT) {
                throw new ConflictException("recover retry count is exceeded.");
            }
            TRowLock currentRowLock = getRowLock(row);
            try {
                if (checkAndIsShouldRecover(currentRowLock)) {
                    recover(tx, row);
View Full Code Here

        TRowLock newRowLock = new TRowLock(ROW_LOCK_VERSION, TRowLockState.STABLE, tx.getCommitTimestamp());
        put.add(LOCK_FAMILY, LOCK_QUALIFIER, tx.getCommitTimestamp(), TRowLocks.serialize(newRowLock));

        byte[] currentRowLockBytes = TRowLocks.serialize(rowState.getCurrent());
        if (!table.checkAndPut(row, LOCK_FAMILY, LOCK_QUALIFIER, currentRowLockBytes, put)) {
            throw new ConflictException("can't acquire row's lock, commitSingleRowPutOnly failed");
        } else {
            rowState.setCurrent(newRowLock);
        }
    }
View Full Code Here

            HaeinsaTransaction tx = rowState.getTableTransaction().getTransaction();
            HaeinsaTransaction currentTx = tx.getManager().getTransaction(tx.getPrimary().getTableName(), tx.getPrimary().getRow());
            if (currentTx != null) {
                currentTx.recover(true);
            }
            throw new ConflictException("this row is modified, checkSingleRow failed");
        }
    }
View Full Code Here

            // Consider as conflict because another transaction might acquire lock of this row.
            HaeinsaTransaction currentTx = tx.getManager().getTransaction(tx.getPrimary().getTableName(), tx.getPrimary().getRow());
            if (currentTx != null) {
                currentTx.recover(true);
            }
            throw new ConflictException("can't acquire row's lock");
        } else {
            rowState.setCurrent(newRowLock);
        }
    }
View Full Code Here

                for (TKeyValue kv : mutation.getPut().getValues()) {
                    put.add(kv.getKey().getFamily(), kv.getKey().getQualifier(), newRowLock.getCurrentTimestamp(), kv.getValue());
                }
                if (!table.checkAndPut(row, LOCK_FAMILY, LOCK_QUALIFIER, currentRowLockBytes, put)) {
                    // Consider as conflict because another transaction might acquire lock of this row.
                    throw new ConflictException("can't acquire row's lock");
                } else {
                    rowTxState.setCurrent(newRowLock);
                }
                break;
            }
            case REMOVE: {
                Delete delete = new Delete(row);
                if (mutation.getRemove().getRemoveFamiliesSize() > 0) {
                    for (ByteBuffer removeFamily : mutation.getRemove().getRemoveFamilies()) {
                        delete.deleteFamily(removeFamily.array(), mutationTimestamp);
                    }
                }
                if (mutation.getRemove().getRemoveCellsSize() > 0) {
                    for (TCellKey removeCell : mutation.getRemove().getRemoveCells()) {
                        delete.deleteColumns(removeCell.getFamily(), removeCell.getQualifier(), mutationTimestamp);
                    }
                }
                if (!table.checkAndDelete(row, LOCK_FAMILY, LOCK_QUALIFIER, currentRowLockBytes, delete)) {
                    // Consider as conflict because another transaction might acquire lock of this row.
                    throw new ConflictException("can't acquire row's lock");
                }
                break;
            }
            default:
                break;
View Full Code Here

        put.add(LOCK_FAMILY, LOCK_QUALIFIER, newRowLock.getCurrentTimestamp(), newRowLockBytes);

        if (!table.checkAndPut(row, LOCK_FAMILY, LOCK_QUALIFIER, currentRowLockBytes, put)) {
            // We don't need abort current transaction. Because the transaction is already aborted.
            // Consider as conflict because another transaction might acquire lock of primary row.
            throw new ConflictException("can't acquire primary row's lock");
        } else {
            rowTxState.setCurrent(newRowLock);
        }
    }
View Full Code Here

        Put put = new Put(row);
        put.add(LOCK_FAMILY, LOCK_QUALIFIER, newRowLock.getCurrentTimestamp(), newRowLockBytes);

        if (!table.checkAndPut(row, LOCK_FAMILY, LOCK_QUALIFIER, currentRowLockBytes, put)) {
            // Consider as conflict because another transaction might acquire lock of primary row.
            throw new ConflictException("can't acquire primary row's lock");
        } else {
            rowTxState.setCurrent(newRowLock);
        }
    }
View Full Code Here

        for (TCellKey cellKey : rowTxState.getCurrent().getPrewritten()) {
            delete.deleteColumn(cellKey.getFamily(), cellKey.getQualifier(), prewriteTimestamp);
        }
        if (!table.checkAndDelete(row, LOCK_FAMILY, LOCK_QUALIFIER, currentRowLockBytes, delete)) {
            // Consider as conflict because another transaction might acquire lock of this row.
            throw new ConflictException("can't acquire primary row's lock");
        }
    }
View Full Code Here

TOP

Related Classes of kr.co.vcnc.haeinsa.exception.ConflictException

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.