Package com.foundationdb.server.store.FDBTransactionService

Examples of com.foundationdb.server.store.FDBTransactionService.TransactionState


    @Override
    protected void checkNotReferenced(Session session, Index index, FDBStoreData storeData,
                                      RowData row, ForeignKey foreignKey,
                                      boolean selfReference, ForeignKey.Action action,
                                      String operation) {
        TransactionState txn = txnService.getTransaction(session);
        FDBPendingIndexChecks.CheckPass finalPass =
            (action == ForeignKey.Action.RESTRICT) ?
            FDBPendingIndexChecks.CheckPass.ROW :
            txn.isDeferred(foreignKey) ?
            FDBPendingIndexChecks.CheckPass.TRANSACTION :
            FDBPendingIndexChecks.CheckPass.STATEMENT;
        FDBPendingIndexChecks.PendingCheck<?> check =
            FDBPendingIndexChecks.foreignKeyNotReferencedCheck(session, txn, index, storeData.persistitKey, (row == null),
                                                               foreignKey, selfReference, finalPass, operation);
        if (txn.getForceImmediateForeignKeyCheck() ||
            ((finalPass == FDBPendingIndexChecks.CheckPass.ROW) &&
            ((txn.getIndexChecks(false) == null) || !txn.getIndexChecks(false).isDelayed()))) {
            check.blockUntilReady(txn);
            if (!check.check(session, txn, index)) {
                if (row == null) {
                    // Need actual key found for error message.
                    FDBStoreDataHelper.unpackTuple(index, storeData.persistitKey, check.getRawKey());
                }
                stillReferenced(session, index, storeData, row, foreignKey, operation);
            }
        }
        else {
            txn.getIndexChecks(true).add(session, txn, index, check);
        }
    }
View Full Code Here


        }
        if (cache != null) {
            rawValue = cache.currentValue();
        } else {
            // TODO: Allow FDBStorageDescription to intervene?
            TransactionState txn = txnService.getTransaction(session);
            byte[] byteValue = txn.getValue(prefixBytes(sequence));
            if(byteValue != null) {
                Tuple2 tuple = Tuple2.fromBytes(byteValue);
                rawValue = tuple.getLong(0);
            }
        }
View Full Code Here

        // Only called when child row does not contain full HKey.
        // Key contents are the logical parent of the actual index entry (if it exists).
        byte[] packed = packedTuple(parentPKIndex, parentPkKey);
        byte[] end = packedTuple(parentPKIndex, parentPkKey, Key.AFTER);
        TransactionState txn = txnService.getTransaction(session);
        List<KeyValue> pkValue = txn.getRangeAsValueList(packed, end);
        FDBIndexRow indexRow = null;
        if (!pkValue.isEmpty()) {
            assert pkValue.size() == 1 : parentPKIndex;
            KeyValue kv = pkValue.get(0);
            assert kv.getValue().length == 0 : parentPKIndex + ", " + kv;
View Full Code Here

                              Key hKey,
                              WriteIndexRow indexRow,
                              SpatialColumnHandler spatialColumnHandler,
                              long zValue,
                              boolean doLock) {
        TransactionState txn = txnService.getTransaction(session);
        Key indexKey = createKey();
        constructIndexRow(session, indexKey, rowData, index, hKey, indexRow, spatialColumnHandler, zValue, true);
        checkUniqueness(session, txn, index, rowData, indexKey);

        byte[] packedKey = packedTuple(index, indexKey);
        txn.setBytes(packedKey, EMPTY_BYTE_ARRAY);
    }
View Full Code Here

                               Key hKey,
                               WriteIndexRow indexRow,
                               SpatialColumnHandler spatialColumnHandler,
                               long zValue,
                               boolean doLock) {
        TransactionState txn = txnService.getTransaction(session);
        Key indexKey = createKey();
        constructIndexRow(session, indexKey, rowData, index, hKey, indexRow, spatialColumnHandler, zValue, false);
        byte[] packed = packedTuple(index, indexKey);
        txn.clearKey(packed);
    }
View Full Code Here

        // None
    }

    @Override
    public void truncateTree(Session session, HasStorage object) {
        TransactionState txn = txnService.getTransaction(session);
        txn.clearRange(Range.startsWith(prefixBytes(object)));
    }
View Full Code Here

        return new FDBAdapter(this, schema, session, txnService, configService);
    }

    @Override
    public boolean treeExists(Session session, StorageDescription storageDescription) {
        TransactionState txn = txnService.getTransaction(session);
        return txn.getRangeExists(Range.startsWith(prefixBytes((FDBStorageDescription)storageDescription)), 1);
    }
View Full Code Here

        }
    }

    @Override
    public void finishOnlineChange(Session session, Collection<ChangeSet> changeSets) {
        TransactionState txnState = txnService.getTransaction(session);
        Transaction txn = txnState.getTransaction();
        for(ChangeSet cs : changeSets) {
            TableName oldName = new TableName(cs.getOldSchema(), cs.getOldName());
            TableName newName = new TableName(cs.getNewSchema(), cs.getNewName());

            for(Change c : cs.getIdentityChangeList()) {
View Full Code Here

    @Override
    public <V extends IndexVisitor<Key, Value>> V traverse(Session session, Index index, V visitor, long scanTimeLimit, long sleepTime) {
        FDBStoreData storeData = createStoreData(session, index);
        storeData.persistitValue = new Value((Persistit)null);
        TransactionState txn = txnService.getTransaction(session);
        long nextCommitTime = 0;
        if (scanTimeLimit >= 0) {
            nextCommitTime = txn.getStartTime() + scanTimeLimit;
        }
        indexIterator(session, storeData, false);
        while(storeData.next()) {
            // Key
            unpackKey(storeData);

            // Value
            unpackValue(storeData);

            // Visit
            visitor.visit(storeData.persistitKey, storeData.persistitValue);

            if ((scanTimeLimit >= 0) &&
                (System.currentTimeMillis() >= nextCommitTime)) {
                storeData.closeIterator();
                txn.commitAndReset(session);
                if (sleepTime > 0) {
                    try {
                        Thread.sleep(sleepTime);
                    }
                    catch (InterruptedException ex) {
                        throw new QueryCanceledException(session);
                    }
                }
                nextCommitTime = txn.getStartTime() + scanTimeLimit;
                indexIterator(session, storeData, false, false);
            }           
        }
        return visitor;
    }
View Full Code Here

        // Ensure latest has been read
        ais();
        // And break it
        txnService().beginTransaction(session());
        try {
            TransactionState txn = fdbTxnService().getTransaction(session());
            if(changeGen) {
                txn.setBytes(fdbSchemaManager().getPackedGenKey(), BAD_PACKED_VALUE);
            }
            if(newValue == null) {
                txn.clearKey(key);
            } else {
                txn.setBytes(key, newValue);
            }
            try {
                fdbSchemaManager().getAis(session());
                fail("expected exception");
            } catch(FDBAdapterException e) {
View Full Code Here

TOP

Related Classes of com.foundationdb.server.store.FDBTransactionService.TransactionState

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.