Package com.foundationdb.server.store.FDBTransactionService

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


    }

    @Override
    protected void clearOnlineState(Session session, OnlineSession onlineSession) {
        try {
            TransactionState txn = txnService.getTransaction(session);
            smDirectory.remove(txn.getTransaction(), onlineDirPath(onlineSession.id)).get();
        } catch (RuntimeException e) {
            throw FDBAdapter.wrapFDBException(session, e);
        }
    }
View Full Code Here


    @Override
    protected OnlineCache buildOnlineCache(Session session) {
        OnlineCache onlineCache = new OnlineCache();

        TransactionState txnState = txnService.getTransaction(session);
        Transaction txn = txnState.getTransaction();
       
        try {
           
            DirectorySubspace onlineDir = smDirectory.createOrOpen(txn, ONLINE_PATH).get();
   
            // For each online ID
            for(String idStr : onlineDir.list(txn).get()) {
                long onlineID = Long.parseLong(idStr);
                DirectorySubspace idDir = onlineDir.open(txn, Arrays.asList(idStr)).get();
                byte[] genBytes = txnState.getValue(idDir.pack(GENERATION_KEY));
                long generation = Tuple2.fromBytes(genBytes).getLong(0);
   
                // load protobuf
                if(idDir.exists(txn, PROTOBUF_PATH).get()) {
                    DirectorySubspace protobufDir = idDir.open(txn, PROTOBUF_PATH).get();
View Full Code Here

    public AkibanInformationSchema getSessionAIS(Session session) {
        AkibanInformationSchema localAIS = session.get(SESSION_AIS_KEY);
        if(localAIS != null) {
            return localAIS;
        }
        TransactionState txn = txnService.getTransaction(session);
        long generation = getTransactionalGeneration(txn);
        localAIS = curAIS;
        if(generation != localAIS.getGeneration()) {
            synchronized(AIS_LOCK) {
                // May have been waiting
View Full Code Here

        OnlineCache onlineCache = getOnlineCache(session, ais);
        Long onlineID = onlineCache.tableToOnline.get(tableID);
        if(onlineID == null) {
            throw new IllegalArgumentException("No online change for table: " + tableID);
        }
        TransactionState txn = txnService.getTransaction(session);
        DirectorySubspace tableDMLDir = getOnlineTableDMLDir(txn, onlineID, tableID);
        byte[] hKeyBytes = Arrays.copyOf(hKey.getEncodedBytes(), hKey.getEncodedSize());
        byte[] packedKey = tableDMLDir.pack(Tuple2.from(hKeyBytes));
        txn.setBytes(packedKey, new byte[0]);
    }
View Full Code Here

        OnlineCache onlineCache = getOnlineCache(session, ais);
        Long onlineID = onlineCache.tableToOnline.get(tableID);
        if(onlineID == null) {
            throw new IllegalArgumentException("No online change for table: " + tableID);
        }
        TransactionState txn = txnService.getTransaction(session);
        DirectorySubspace onlineDir = getOnlineDir(txn, onlineID);
        byte[] packedKey = onlineDir.pack(ERROR_KEY);
        byte[] packedValue = Tuple2.from(message).pack();
        txn.setBytes(packedKey, packedValue);
    }
View Full Code Here

    }

    @Override
    public String getOnlineDMLError(Session session) {
        OnlineSession onlineSession = getOnlineSession(session, true);
        TransactionState txn = txnService.getTransaction(session);
        DirectorySubspace dir = getOnlineDir(txn, onlineSession.id);
        byte[] value = txn.getValue(dir.pack(ERROR_KEY));
        return (value == null) ? null : Tuple2.fromBytes(value).getString(0);
    }
View Full Code Here

    public Iterator<byte[]> getOnlineHandledHKeyIterator(Session session, int tableID, Key hKey) {
        OnlineSession onlineSession = getOnlineSession(session, true);
        if(LOG.isDebugEnabled()) {
            LOG.debug("addOnlineHandledHKey: {}/{} -> {}", new Object[] { onlineSession.id, tableID, hKey });
        }
        TransactionState txn = txnService.getTransaction(session);
        DirectorySubspace tableDMLDir = getOnlineTableDMLDir(txn, onlineSession.id, tableID);
        byte[] startKey = tableDMLDir.pack();
        byte[] endKey = ByteArrayUtil.strinc(startKey);
        if(hKey != null) {
            startKey = ByteArrayUtil.join(tableDMLDir.pack(), Arrays.copyOf(hKey.getEncodedBytes(), hKey.getEncodedSize()));
        }
        final Iterator<KeyValue> iterator = txn.getRangeIterator(startKey, endKey);
        final int prefixLength = tableDMLDir.pack().length;
        return new Iterator<byte[]>() {
            @Override
            public boolean hasNext() {
                throw new UnsupportedOperationException();
View Full Code Here

        }
        assert isCompatible;
    }

    private AkibanInformationSchema loadFromStorage(Session session) {
        TransactionState txn = txnService.getTransaction(session);
        checkDataVersions(txn);
        ProtobufReader reader = newProtobufReader();
        loadPrimaryProtobuf(txn, reader, null);
        finishReader(reader);
        validateAndFreeze(session, reader.getAIS(), getTransactionalGeneration(txn));
View Full Code Here

        txnService().commitTransaction(session());
    }

    protected List<Object> treeTuples(HasStorage object) {
        byte[] prefix = ((FDBStorageDescription)object.getStorageDescription()).getPrefixBytes();
        TransactionState tr = ((FDBTransactionService)txnService()).getTransaction(session());
        List<Object> result = new ArrayList<>();
        for (KeyValue kv : tr.getRangeIterator(Range.startsWith(prefix),Transaction.ROW_LIMIT_UNLIMITED )) {
            byte[] key = kv.getKey();
            byte[] value = kv.getValue();
            key = Arrays.copyOfRange(key, prefix.length, key.length);
            result.add(Arrays.asList(Tuple2.fromBytes(key).getItems(),
                                     Tuple2.fromBytes(value).getItems()));
View Full Code Here

    @Override
    protected void checkReferencing(Session session, Index index, FDBStoreData storeData,
                                    RowData row, ForeignKey foreignKey, String operation) {
        assert index.isUnique() : index;
        TransactionState txn = txnService.getTransaction(session);
        FDBPendingIndexChecks.CheckPass finalPass =
            txn.isDeferred(foreignKey) ?
            FDBPendingIndexChecks.CheckPass.TRANSACTION :
            FDBPendingIndexChecks.CheckPass.ROW;
        FDBPendingIndexChecks.PendingCheck<?> check =
            FDBPendingIndexChecks.foreignKeyReferencingCheck(session, txn, index, storeData.persistitKey,
                                                             foreignKey, 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)) {
                notReferencing(session, index, storeData, row, foreignKey, operation);
            }
        }
        else {
            txn.getIndexChecks(true).add(session, txn, index, check);
        }
    }
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.