Examples of LN


Examples of com.sleepycat.je.tree.LN

            logManager.log(rec);

            /* Make a transactional LN, we expect it to be there. */
            byte [] data = new byte[i+1];
            Arrays.fill(data, (byte)(i+1));
            LN ln = new LN(data);
            byte [] key = new byte[i+1];
            Arrays.fill(key, (byte)(i+10));
           
            /*
       * Log an LN. If we're tracking LNs add it to the verification
       * list.
       */
            userTxn.lock
                (ln.getNodeId(), LockType.WRITE,
                 DbInternal.dbGetDatabaseImpl(db));
            lsn = ln.log(envImpl,
                         DbInternal.dbGetDatabaseImpl(db).getId(),
                         key,
                         DbLsn.NULL_LSN,
                         userTxn);

            if (trackLNs) {
                checkList.add(new CheckInfo(lsn, ln, key,
                                            ln.getData(), txnId));
            }

            /* Log a deleted duplicate LN. */
            LN deleteLN = new LN(data);
            byte[] dupKey = new byte[i+1];
            Arrays.fill(dupKey, (byte)(i+2));

            userTxn.lock
                (deleteLN.getNodeId(), LockType.WRITE,
                 DbInternal.dbGetDatabaseImpl(db));
            lsn = deleteLN.delete(DbInternal.dbGetDatabaseImpl(db),
                                  key,
                                  dupKey,
                                  DbLsn.NULL_LSN,
                                  userTxn);
            if (trackLNs) {
                checkList.add(new CheckInfo(lsn, deleteLN,
                                            dupKey, key, txnId));
            }

            /*
       * Make a non-transactional ln. Shouldn't get picked up by reader.
       */
            LN nonTxnalLN = new LN(data);
            nonTxnalLN.log(envImpl,
         DbInternal.dbGetDatabaseImpl(db).getId(),
         key, DbLsn.NULL_LSN, null);

            /* Add a MapLN. */
            MapLN mapLN = new MapLN(DbInternal.dbGetDatabaseImpl(db));
View Full Code Here

Examples of com.sleepycat.je.tree.LN

    private void checkLogFile(LNFileReader reader,
                              int checkIndex,
                              boolean redo)
        throws IOException, DatabaseException {

        LN lnFromLog;
        byte[] keyFromLog;
               
        /* Read all the LNs. */
        int i;
        if (redo) {
            /* start where indicated. */
            i = checkIndex;
        } else {
            /* start at the end. */
            i = checkList.size() - 1;
        }
        while (reader.readNextEntry()) {
            CheckInfo expected = (CheckInfo) checkList.get(i);

            /* Check LSN. */
            assertEquals("LSN " + i + " should match",
                         expected.lsn,
                         reader.getLastLsn());

            if (reader.isLN()) {

                /* Check the LN. */
                lnFromLog = reader.getLN();
                LN expectedLN = expected.ln;
                assertEquals("Should be the same type of object",
                             expectedLN.getClass(),
                             lnFromLog.getClass());

                if (DEBUG) {
                    if (!expectedLN.toString().equals(lnFromLog.toString())) {
                        System.out.println("expected = " +
                                           expectedLN.toString()+
                                           "lnFromLog = " +
                                           lnFromLog.toString());
                    }
                }
                assertEquals("LN " + i + " should match",
                             expectedLN.toString(),
                             lnFromLog.toString());

                /* Check the key. */
                keyFromLog = reader.getKey();
                byte[] expectedKey = expected.key;
View Full Code Here

Examples of com.sleepycat.je.tree.LN

      /*
       * Invoke the evictor to reduce memory consumption.
       */
      env.invokeEvictor();

      LN ln = reader.getLN();
      long logLsn = reader.getLastLsn();
      long abortLsn = reader.getAbortLsn();
      boolean abortKnownDeleted =
          reader.getAbortKnownDeleted();
      DatabaseId dbId = reader.getDatabaseId();
      DatabaseImpl db = dbMapTree.getDb(dbId);
                       
      /* Database may be null if it's been deleted. */
      if (db != null) {
          ln.postFetchInit(db, logLsn);
          try {
                                undo(detailedTraceLevel,
                                     db,
                                     location,
                                     ln,
View Full Code Here

Examples of com.sleepycat.je.tree.LN

        if (processThisLN) {

                        /* Invoke the evictor to reduce memory consumption. */
                        env.invokeEvictor();

                        LN ln = reader.getLN();
                        DatabaseId dbId = reader.getDatabaseId();
                        DatabaseImpl db = dbMapTree.getDb(dbId);
                        long logLsn = reader.getLastLsn();
                        long treeLsn = DbLsn.NULL_LSN;

                        /* Database may be null if it's been deleted. */
                        if (db != null) {
                            ln.postFetchInit(db, logLsn);

          if (preparedTxn != null) {
        preparedTxn.addLogInfo(logLsn);

        /*
         * We're reconstructing a prepared, but not
         * finished, transaction.  We know that there
         * was a write lock on this LN since it exists
         * in the log under this txnId.
         */
        preparedTxn.lock(ln.getNodeId(),
             LockType.WRITE,
             db);
        preparedTxn.setPrepared(true);
          }

View Full Code Here

Examples of com.sleepycat.je.tree.LN

                /*
                 * Read the LN that's in this slot to check for deleted
                 * status.  No need to lock, since this is recovery.  If
                 * fetchTarget returns null, a deleted LN was cleaned.
                 */
                LN currentLN = (LN) parentBIN.fetchTarget(entryIndex);

                if (currentLN == null || currentLN.isDeleted()) {
                    canOverwrite = true;
                }

                /*
     * Evict the target again manually, to reduce memory
View Full Code Here

Examples of com.sleepycat.je.tree.LN

             * which actually reduce the amount of memory held, because it
             * causes LNS to get evicted.
             */
            if (endMode.equals(ABORT) &&
                writesDone) {
                LN sampleLN = new LN(dataEntry);
                expectedFreedNodeMemory +=
                    ((numRecordsPerTxn * numTxns) *
                     sampleLN.getMemorySizeIncludedByParent());
            }

            assertTrue((afterAction - afterTxnsCreated) >= expectedLockUsage);

            for (int t = 0; t < numTxns; t++) {
View Full Code Here

Examples of com.sleepycat.je.tree.LN

                             i < origBIN.getNEntries();
                             i++) {
                            if (!origBIN.isEntryKnownDeleted(i)) {
                                Node n = origBIN.fetchTarget(i);
                                if (n != null && !n.containsDuplicates()) {
                                    LN ln = (LN) n;
                                    /* See comment above about locking. */
                                    if (!ln.isDeleted()) {
                                        ret = true;
                                        break;
                                    }
                                }
                            } else {
                                /* Need to check the DupCountLN. */
                            }
                        }
                    }
                } else {
                    if (origCursor.getIndex() > 0) {

                        /*
                         * We were adjusted to something other than the first
                         * entry so some insertion happened.
                         */
                        DatabaseImpl database = origBIN.getDatabase();
                        for (int i = 0; i < origCursor.getIndex(); i++) {
                            if (!origBIN.isEntryKnownDeleted(i)) {
                                Node n = origBIN.fetchTarget(i);
                                if (n != null && !n.containsDuplicates()) {
                                    LN ln = (LN) n;
                                    /* See comment above about locking. */
                                    if (!ln.isDeleted()) {
                                        ret = true;
                                        break;
                                    }
                                } else {
                                    /* Need to check the DupCountLN. */
                                }
                            }
                        }
                    }
                }
            }
            origCursor.releaseBINs();
            return ret;
        }

        if (origDBIN != dupCursor.getDupBIN() &&
            origCursor.getIndex() == dupCursor.getIndex() &&
            getMode != GetMode.NEXT_NODUP &&
            getMode != GetMode.PREV_NODUP) {
            /* Same as above, only for the dupBIN. */
            origCursor.latchBINs();
            if (forward) {
                if (origDBIN.getNEntries() - 1 >
                    origCursor.getDupIndex()) {

                    /*
                     * We were adjusted to something other than the last entry
                     * so some insertion happened.
                     */
                    DatabaseImpl database = origDBIN.getDatabase();
                    for (int i = origCursor.getDupIndex() + 1;
                         i < origDBIN.getNEntries();
                         i++) {
                        if (!origDBIN.isEntryKnownDeleted(i)) {
                            Node n = origDBIN.fetchTarget(i);
                            LN ln = (LN) n;
                            /* See comment above about locking. */
                            if (n != null && !ln.isDeleted()) {
                                ret = true;
                                break;
                            }
                        }
                    }
                }
            } else {
                if (origCursor.getDupIndex() > 0) {

                    /*
                     * We were adjusted to something other than the first entry
                     * so some insertion happened.
                     */
                    DatabaseImpl database = origDBIN.getDatabase();
                    for (int i = 0; i < origCursor.getDupIndex(); i++) {
                        if (!origDBIN.isEntryKnownDeleted(i)) {
                            Node n = origDBIN.fetchTarget(i);
                            LN ln = (LN) n;
                            /* See comment above about locking. */
                            if (n != null && !ln.isDeleted()) {
                                ret = true;
                                break;
                            }
                        }
                    }
View Full Code Here

Examples of com.sleepycat.je.tree.LN

        /*
         * Release latches, lock LN. Don't access BIN until latched again.
         * If fetchTarget returns null, a deleted LN was cleaned.
         */
        LN ln = (LN) targetBin.fetchTarget(targetIndex);
        if (ln == null) {
      releaseBINs();
            return OperationStatus.KEYEMPTY;
        }

  LockResult lockResult = lockLN(ln, LockType.WRITE);
  ln = lockResult.getLN();
           
        /* Check LN deleted status under the protection of a write lock. */
        if (ln == null) {
            return OperationStatus.KEYEMPTY;
        }

  DIN dupRoot = null;

  /*
         * Between the release of the BIN latch and acquiring the write lock
         * any number of operations may have executed which would result in a
         * new abort LSN for this record. Therefore, wait until now to get the
         * abort LSN.
         */
  latchBIN();
  isDup = (dupBin != null);
  if (isDup) {

      /*
       * We can't call latchBINs here because that would latch both BIN
       * and DBIN.  Subsequently we'd have to latch the dupRoot which is
       * higher in the tree than the DBIN which would be latching up the
       * tree.  So we have to latch in BIN, dupRoot, DBIN order.
       */
            /* Latch couple with the DupRoot. */
            dupRoot = (DIN) bin.fetchTarget(index);
            dupRoot.latch();

            latchDBIN();
  }
  setTargetBin();
        long oldLsn = targetBin.getLsn(targetIndex);
        byte[] lnKey = targetBin.getKey(targetIndex);
        long nodeId = targetBin.getNodeId();
        lockResult.setAbortLsn(oldLsn,
             targetBin.isEntryKnownDeleted(targetIndex));

        long oldLNSize = ln.getMemorySizeIncludedByParent();
        long newLsn = ln.delete(database, lnKey, dupKey, oldLsn, locker);
        long newLNSize = ln.getMemorySizeIncludedByParent();

        targetBin.updateEntry(targetIndex, newLsn, oldLNSize, newLNSize);
        targetBin.setPendingDeleted(targetIndex);
  releaseBINs();

View Full Code Here

Examples of com.sleepycat.je.tree.LN

        throws DatabaseException {

        assert assertCursorState(false) : dumpToString(true);

        OperationStatus result = putLN
            (Key.makeKey(key), new LN(data), database.getSortedDuplicates());
        if (result == OperationStatus.KEYEXIST) {
            status = CURSOR_INITIALIZED;

            /*
             * If dups are allowed and putLN() returns KEYEXIST, the duplicate
View Full Code Here

Examples of com.sleepycat.je.tree.LN

            DatabaseEntry data)
        throws DatabaseException {

        assert assertCursorState(false) : dumpToString(true);

        return putLN(Key.makeKey(key), new LN(data), false);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.