Package com.sleepycat.je

Examples of com.sleepycat.je.Cursor


        }
        if (!range.check(key)) {
            status = OperationStatus.NOTFOUND;
        } else if (pkRange != null) {
            status = OperationStatus.NOTFOUND;
            Cursor oldCursor = beginOperation();
            try {
                shareData(key, privKey);
                status = doGetSearchKey(lockMode);
                if (status == OperationStatus.SUCCESS &&
                    !pkRange.check(privPKey)) {
View Full Code Here


            setParams(key, pKey, data);
            status = doGetSearchKeyRange(lockMode);
            endOperation(null, status, null, null, null);
            return status;
        }
        Cursor oldCursor = beginOperation();
        try {
            shareData(key, privKey);
            status = doGetSearchKeyRange(lockMode);
            if (status == OperationStatus.SUCCESS &&
                (!range.check(privKey) ||
View Full Code Here

            setParams(key, pKey, data);
            status = doGetSearchBothRange(lockMode);
            endOperation(null, status, null, null, null);
            return status;
        }
        Cursor oldCursor = beginOperation();
        try {
            shareData(key, privKey);
            if (secCursor != null) {
                shareData(pKey, privPKey);
            } else {
View Full Code Here

            setParams(key, pKey, data);
            status = doGetNextDup(lockMode);
            endOperation(null, status, null, null, null);
        } else if (pkRange != null && pkRange.endKey != null) {
            status = OperationStatus.NOTFOUND;
            Cursor oldCursor = beginOperation();
            try {
                status = doGetNextDup(lockMode);
                if (status == OperationStatus.SUCCESS &&
                    !pkRange.checkEnd(privPKey, true)) {
                    status = OperationStatus.NOTFOUND;
View Full Code Here

            setParams(key, pKey, data);
            status = doGetPrevDup(lockMode);
            endOperation(null, status, null, null, null);
        } else if (pkRange != null && pkRange.beginKey != null) {
            status = OperationStatus.NOTFOUND;
            Cursor oldCursor = beginOperation();
            try {
                status = doGetPrevDup(lockMode);
                if (status == OperationStatus.SUCCESS &&
                    !pkRange.checkBegin(privPKey, true)) {
                    status = OperationStatus.NOTFOUND;
View Full Code Here

                                  DiffTracker tracker,
                                  boolean doPrint)
        throws Exception {

        List<MismatchedRegion> regions = tracker.getDiffRegions();
        Cursor localCursor = null;
        try {
            localCursor = localDb.openCursor(null, null);

            for (MismatchedRegion region : regions) {
                if (region.isLocalAdditional()) {
                    printLocalAdditional(localCursor, region, doPrint);
                    continue;
                }

                if (region.isRemoteAdditional()) {
                     HashSet<Record> records =
                         getDiffArea(protocol, channel, region);
                     if (doPrint) {
                         printAdditional(records, true);
                     }
                     records.clear();
                     continue;
                }

                HashSet<Record> localRecords =
                    getDiffArea(localCursor, region.getLocalBeginKey(),
                                region.getLocalBeginData(),
                                region.getLocalDiffSize());
                HashSet<Record> remoteRecords =
                    getDiffArea(protocol, channel, region);
                if (doPrint) {
                printDiffs(localRecords, remoteRecords);
            }
                localRecords.clear();
                remoteRecords.clear();
            }
        } finally {
            if (localCursor != null) {
                localCursor.close();
            }
        }
    }
View Full Code Here

                                  DiffTracker tracker,
                                  boolean doPrint)
        throws Exception {

        List<MismatchedRegion> regions = tracker.getDiffRegions();
        Cursor localCursor = null;
        Cursor remoteCursor = null;
        try {
            localCursor = localDb.openCursor(null, null);
            remoteCursor = remoteDb.openCursor(null, null);

            for (MismatchedRegion region : regions) {
                if (region.isLocalAdditional()) {
                    printLocalAdditional(localCursor, region, doPrint);
                    continue;
                }
            
                if (region.isRemoteAdditional()) {
                    HashSet<Record> records =
                        getDiffArea(remoteCursor, region.getRemoteBeginKey(),
                                    region.getRemoteBeginData(),
                                    region.getRemoteDiffSize());
                    if (doPrint) {
                        printAdditional(records, true);
                    }
                    records.clear();
                    continue;
                }

                HashSet<Record> localRecords =
                    getDiffArea(localCursor, region.getLocalBeginKey(),
                                region.getLocalBeginData(),
                                region.getLocalDiffSize());
                HashSet<Record> remoteRecords =
                    getDiffArea(remoteCursor, region.getRemoteBeginKey(),
                                region.getRemoteBeginData(),
                                region.getRemoteDiffSize());
                if (doPrint) {
                printDiffs(localRecords, remoteRecords);
            }
                localRecords.clear();
                remoteRecords.clear();
            }
        } finally {
            if (localCursor != null) {
                localCursor.close();
            }
            if (remoteCursor != null) {
                remoteCursor.close();
            }
        }
    }
View Full Code Here

        public void runLDiff(DbBlocks request, Protocol protocol)
            throws IOException {

            Database db = null;
            Cursor cursor = null;
            try{
                db = env.openDatabase
                    (null, request.getDbName(), dbConfig);
                protocol.write(protocol.new BlockListStart(), channel);
                LDiffConfig cfg = new LDiffConfig();
                cfg.setBlockSize(request.getBlockSize());
                LDiff ldf = new LDiff(cfg);
                /* Use the Iterator to stream the blocks across the wire. */
                Iterator<Block> blocks = ldf.iterator(db);
                while (blocks.hasNext()) {
                    protocol.write(protocol.new BlockInfo(blocks.next()),
                            channel);
                }
                protocol.write(protocol.new BlockListEnd(), channel);

                /* Start to do the record difference analysis. */
                Message msg = protocol.read(channel);
                if (msg.getOp() == Protocol.REMOTE_DIFF_REQUEST) {
                    cursor = db.openCursor(null, null);
                    sendDiffArea(cursor, (RemoteDiffRequest) msg, protocol);
                    runDiffAnalysis(cursor, protocol);
                } else if (msg.getOp() != Protocol.DONE) {
                    protocol.write(protocol.new ProtocolError
                            ("Invalid message: " + msg), channel);
                }
            } catch (DatabaseNotFoundException e) {
                protocol.write(protocol.new DbMismatch(e.getMessage()),
                               channel);
            } finally {
                if (cursor != null) {
                    cursor.close();
                }
                if (db != null) {
                    db.close();
                }
            }
View Full Code Here

        /* Read the current range information. */
        DatabaseEntry key = new DatabaseEntry();
        DatabaseEntry data = new DatabaseEntry();
        LongBinding.longToEntry(VLSNRange.RANGE_KEY, key);

        Cursor cursor = null;
        Locker locker = null;
        try {
            locker = BasicLocker.createBasicLocker(envImpl);
            cursor = DbInternal.makeCursor(mappingDbImpl,
                                           locker,
                                           CursorConfig.DEFAULT);
            DbInternal.getCursorImpl(cursor).setAllowEviction(false);

            OperationStatus status = cursor.getSearchKey(key, data,
                                                         LockMode.DEFAULT);
            if (status == OperationStatus.SUCCESS) {
                /* initialize the range from the database. */
                VLSNRangeBinding rangeBinding = new VLSNRangeBinding();
                range = rangeBinding.entryToObject(data);
                lastOnDiskVLSN = range.getLast();
            } else if (status == OperationStatus.NOTFOUND) {
                /* No mappings exist before. */
                range = VLSNRange.EMPTY;
            } else {
                throw EnvironmentFailureException.unexpectedState
                    ("VLSNTracker init: status=" + status);
            }
        } finally {
            if (cursor != null) {
                cursor.close();
            }

            if (locker != null) {
                locker.operationEnd(true);
            }
View Full Code Here

                           OpType opType) {
        /* This method can only be invoked when env is not null. */
        assert env != null;

        Locker locker = null;
        Cursor cursor = null;
        boolean operationOK = false;

        try {
            locker = LockerFactory.getWritableLocker
                (env, txn, true /*isInternalDb*/, dbImpl.isTransactional(),
                 dbImpl.isReplicated());
            cursor = makeCursor(locker);

            DatabaseEntry key = new DatabaseEntry();
            StringBinding.stringToEntry
                (generateKey(processorName, dataSetName, dataType), key);

            DatabaseEntry oldData = new DatabaseEntry();
            cursor.getSearchKey(key, oldData, null);

            if (dataType == DataType.CHANGE_SET) {
                checkUsageErrors(oldData, opType, dataSetName);
            }

            OperationStatus status = null;
            if (opType == OpType.DELETE) {
                status = cursor.delete();
            } else {
                status = cursor.put(key, data);
            }

            assert status == OperationStatus.SUCCESS;
           
            operationOK = true;
        } finally {
            if (cursor != null) {
                cursor.close();
                cursor = null;
            }

            if (locker != null) {
                locker.operationEnd(operationOK);
View Full Code Here

TOP

Related Classes of com.sleepycat.je.Cursor

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.