Examples of Bin


Examples of com.sleepycat.je.tree.BIN

        boolean lockDenied = false;   // The LN lock was denied.
        boolean obsolete = false;     // The LN is no longer in use.
        boolean completed = false;    // This method completed.

        BasicLocker locker = null;
        BIN bin = null;
        try {
            nPendingLNsProcessed++;

            /* The whole database is gone, so this LN is obsolete. */
            if (db == null || db.getIsDeleted()) {
                nLNsDead++;
                obsolete = true;
                completed = true;
                return;
            }

            Tree tree = db.getTree();
            assert tree != null;

            /* Get a non-blocking lock on the original node ID. */
      locker = new BasicLocker(env);
      if (locker.nonBlockingReadLock(ln.getNodeId(), db) ==
                LockGrantType.DENIED) {
                /* Try again later. */
                nPendingLNsLocked++;
                lockDenied = true;
                completed = true;
                return;
            }

            /*
       * Search down to the bottom most level for the parent of this LN.
             *
             * We pass searchDupTree=true to search the dup tree by nodeID if
             * necessary.  This handles the case where dupKey is null because
             * the pending entry was a deleted single-duplicate in a BIN.
       */
            parentFound = tree.getParentBINForChildLN
                (location, key, dupKey, ln,
                 false,  // splitsAllowed
                 true,   // findDeletedEntries
                 true,   // searchDupTree
                 false); // updateGeneration
            bin = location.bin;
            int index = location.index;

            if (!parentFound) {
                nLNsDead++;
                obsolete = true;
                completed = true;
    return;
            }

            migrateLN
                (db, bin.getLsn(index), bin, index,
                 true,           // wasCleaned
                 true,           // isPending
                 ln.getNodeId(), // lockedPendingNodeId
                 CLEAN_PENDING_LN);
            processedHere = false;
            completed = true;
  } catch (DatabaseException DBE) {
      DBE.printStackTrace();
      Tracer.trace(env, "com.sleepycat.je.cleaner.Cleaner", "processLN",
       "Exception thrown: ", DBE);
      throw DBE;
        } finally {
            if (bin != null) {
                bin.releaseLatchIfOwner();
            }

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

Examples of com.sleepycat.je.tree.BIN

        }

        /*
         * Search down to the bottom most level for the parent of this LN.
         */
        BIN bin = null;
        try {
            Tree tree = db.getTree();
            TreeLocation location = new TreeLocation();
            boolean parentFound = tree.getParentBINForChildLN
                (location,
                 entry.getKey(),
                 entry.getDupKey(),
                 entry.getLN(),
                 false,  // splitsAllowed
                 true,   // findDeletedEntries
                 false,  // searchDupTree ???
                 false); // updateGeneration
            bin = location.bin;
            int index = location.index;

            /* Is bin latched ? */
            if (!parentFound) {
                return true;
            }

            /*
             * Now we're at the parent for this LN, whether BIN, DBIN or DIN.
             * If knownDeleted, LN is deleted and can be purged.
             */
            if (bin.isEntryKnownDeleted(index)) {
                return true;
            }

            if (bin.getLsn(index) != lsn) {
                return true;
            }

            /* Oh no -- this lsn is in the tree. */
            /* should print, or trace? */
            System.err.println("lsn " + DbLsn.getNoFormatString(lsn)+
                               " was found in tree.");
            return false;
        } finally {
            if (bin != null) {
                bin.releaseLatch();
            }
        }
    }
View Full Code Here

Examples of com.sleepycat.je.tree.BIN

            writeAndRead(buffer, in, inFromLog);

            /*
             * BINs
             */
            BIN bin = new BIN(database,
                              new byte[] {3,2,1},
                              8, 5);
            bin.latch();
            bin.insertEntry(new ChildReference(null,
                                               new byte[] {1,0,1,0},
                                               DbLsn.makeLsn(212, 200)));
            bin.insertEntry(new ChildReference(null,
                                               new byte[] {1,1,1,0},
                                               DbLsn.makeLsn(229, 300)));
            bin.insertEntry(new ChildReference(null,
                                               new byte[] {0,0,1,0},
                                               DbLsn.makeLsn(235, 400)));
            BIN binFromLog = new BIN();
            writeAndRead(buffer, bin, binFromLog);
            binFromLog.verify(null);
            bin.releaseLatch();

            /*
             * DINs
             */
 
View Full Code Here

Examples of com.sleepycat.je.tree.BIN

                System.out.println("LSN " + i + " = " + lsn);
                System.out.println("IN " + i + " = " + in.getNodeId());
            }

            /* Add other types of INs. */
            BIN bin = new BIN(DbInternal.dbGetDatabaseImpl(db), key, 2, 1);
            lsn = bin.log(logManager);
            checkList.add(new CheckInfo(lsn, bin));

            /* Add provisional entries, which should get ignored. */
            lsn = bin.logProvisional(logManager, in);

            /* Add a LN, to stress the node tracking. */
            LN ln = new LN(data);
            lsn = ln.log(envImpl,
                         DbInternal.dbGetDatabaseImpl(db).getId(),
                         key, DbLsn.NULL_LSN, null);

            /*
       * Add an IN delete entry, it should get picked up by the reader.
       */
            INDeleteInfo info =
                new INDeleteInfo(i, key, DbInternal.
         dbGetDatabaseImpl(db).getId());
            lsn = logManager.log(info);
            checkList.add(new CheckInfo(lsn, info));

            /*
             * Add an BINDelta. Generate it by making the first, full version
             * provisional so the test doesn't pick it up, and then log a
             * delta.
             */
            BIN binDeltaBin =
    new BIN(DbInternal.dbGetDatabaseImpl(db), key, 10, 1);
            maxNodeId = binDeltaBin.getNodeId();
            binDeltaBin.latch();
            ChildReference newEntry =
                new ChildReference(null, key, DbLsn.makeLsn(0, 0));
            assertTrue(binDeltaBin.insertEntry(newEntry));

            lsn = binDeltaBin.logProvisional(logManager, in); // full

            /* Modify the bin with one entry so there can be a delta. */

            byte[] keyBuf2 = new byte[2];
            Arrays.fill(keyBuf2, (byte) (i + 2));
            ChildReference newEntry2 =
                new ChildReference(null, keyBuf2,
                                   DbLsn.makeLsn(100, 101));
            assertTrue(binDeltaBin.insertEntry(newEntry2));

            assertTrue(binDeltaBin.log(logManager, true, false) ==
           DbLsn.NULL_LSN);
            lsn = binDeltaBin.getLastDeltaVersion();
            if (DEBUG) {
                System.out.println("delta =" + binDeltaBin.getNodeId() +
                                   " at LSN " + lsn);
            }
            checkList.add(new CheckInfo(lsn, binDeltaBin));

            /*
             * Reset the generation to 0 so this version of the BIN, which gets
             * saved for unit test comparison, will compare to the version read
             * from the log, which is initialized to 0.
             */
            binDeltaBin.setGeneration(0);
            binDeltaBin.releaseLatch();
        }

        /* Flush the log, files. */
        logManager.flush();
        envImpl.getFileManager().clear();
View Full Code Here

Examples of com.sleepycat.je.tree.BIN

       
        /* Make a child reference as a candidate for insertion. */
        ChildReference newLNRef =
      new ChildReference(null, location.lnKey, logLsn);

        BIN parentBIN = location.bin;
        int entryIndex = parentBIN.insertEntry1(newLNRef);

        if ((entryIndex & IN.INSERT_SUCCESS) == 0) {

            /*
       * Entry may have been a duplicate. Insertion was not successful.
       */
            entryIndex &= ~IN.EXACT_MATCH;

            boolean canOverwrite = false;
            if (parentBIN.isEntryKnownDeleted(entryIndex)) {
                canOverwrite = true;
            } else {

                /*
                 * 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
     * consumption while the evictor is not running.
                 */
    parentBIN.updateEntry(entryIndex, null);
            }

            if (canOverwrite) {
                parentBIN.updateEntry(entryIndex, null, logLsn,
                                      location.lnKey);
                parentBIN.clearKnownDeleted(entryIndex);
                location.index = entryIndex;
                return true;
            } else {
                return false;
            }
View Full Code Here

Examples of com.sleepycat.je.tree.BIN

        initEnv(true);
  synchronized (DbInternal.envGetEnvironmentImpl(exampleEnv).
          getINCompressor()) {
      writeEmptyNodeData();

      BIN bin = null;
      try {
    bin = (BIN) DbInternal.dbGetDatabaseImpl(exampleDb)
        .getTree()
        .getFirstNode();
    DIN dupRoot = (DIN) bin.fetchTarget(0);
    bin.releaseLatch();
    bin = null;
    dupRoot.latch();
    bin = (BIN) DbInternal.dbGetDatabaseImpl(exampleDb)
        .getTree()
        .getFirstNode(dupRoot);
    bin.compress(null, true);
    bin.releaseLatch();
    bin = null;

    Cursor cursor = exampleDb.openCursor(null, null);
    DatabaseEntry foundKey = new DatabaseEntry();
    DatabaseEntry foundData = new DatabaseEntry();
    OperationStatus status = cursor.getFirst(foundKey, foundData,
               LockMode.DEFAULT);
    cursor.close();
    assertEquals(OperationStatus.SUCCESS, status);
      } finally {
    if (bin != null) {
        bin.releaseLatch();
    }
      }
  }
    }
View Full Code Here

Examples of com.sleepycat.je.tree.BIN

        env.sync();
        env.sync();

  /* Write out the DelDupLN and DupCountLN. */
  delete(db, "cfhaa", "yrhwlvlgvq");
  BIN bin = (BIN) dbImpl.getTree().search("cfhaa".getBytes(),
            SearchType.NORMAL,
            -1,
                                                null,
                                                true);
  assertNotNull(bin);
  int idx = bin.findEntry("cfhaa".getBytes(), false, true);
  DIN din = (DIN) bin.getTarget(idx);
  assertNotNull(din);
  idx = din.findEntry("yrhwlvlgvq".getBytes(), false, true);
  DBIN dbin = (DBIN) din.getTarget(idx);
  Key.DUMP_BINARY = false;
  dbin.log(envImpl.getLogManager());
  din.log(envImpl.getLogManager());
  bin.releaseLatch();
  env.compress();
  bin.log(envImpl.getLogManager());
    }
View Full Code Here

Examples of com.sleepycat.je.tree.BIN

  Iterator it = queueSnapshot.iterator();
  while (it.hasNext()) {
      BINReference binRef = (BINReference) it.next();
            DatabaseImpl db =
    env.getDbMapTree().getDb(binRef.getDatabaseId(), lockTimeout);
      BIN bin = searchForBIN(db, binRef);
      if (bin != null) {
    bin.verifyCursors();
    bin.releaseLatch();
      }
  }
    }
View Full Code Here

Examples of com.sleepycat.je.tree.BIN

                        /*
                         * An empty BINReference on the queue was put there by
                         * a lazy compressor to indicate that we should try to
                         * prune an empty BIN.
                         */
                        BIN foundBin = binSearch.bin;

                        byte[] idKey = foundBin.getIdentifierKey();
                        boolean isDBIN = foundBin.containsDuplicates();
                        byte[] dupKey = null;
                        if (isDBIN) {
                            dupKey = ((DBIN) foundBin).getDupKey();
                        }

                        /*
                         * Release the bin latch taken by the initial
                         * search. Pruning starts from the top of the tree
                         * and requires that no latches are held.
                         */
                        foundBin.releaseLatch();
                       
                        pruneBIN(binSearch.db,  binRef, idKey, isDBIN,
                                 dupKey, tracker);
                    }
                }
View Full Code Here

Examples of com.sleepycat.je.tree.BIN

                /*
                 * Lookup the BIN for each deleted key, and compress that BIN
                 * separately.
                 */
                BIN splitBin = isDup ?
                    searchForBIN(db, mainKey, key.getKey()) :
                    searchForBIN(db, key.getKey(), null);
                if (splitBin != null) {
                    BINReference splitBinRef = splitBin.createReference();
                    splitBinRef.addDeletedKey(key);
        compressBin(db, splitBin, splitBinRef, tracker);
                }
            }
        }
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.