Package com.sleepycat.je.txn

Examples of com.sleepycat.je.txn.BasicLocker


        throws DatabaseException {

        Locker locker = null;
        CursorImpl cursor = null;
        try {
            locker = new BasicLocker(env);
            cursor = new CursorImpl(fileSummaryDb, locker);

            /* Prevent recursion when synchronized on this object. */
            cursor.setAllowEviction(false);

View Full Code Here


            /*
             * Preventing eviction/recursion is not necessary here because we
             * are not synchronized on this object.  Eviction may be beneficial
             * since we are reading several largish records.
             */
            locker = new BasicLocker(env);
            cursor = new CursorImpl(fileSummaryDb, locker);

            DatabaseEntry keyEntry = new DatabaseEntry();
            DatabaseEntry dataEntry = new DatabaseEntry();

View Full Code Here

         */
        Long[] existingFiles = env.getFileManager().getAllFileNumbers();
        Locker locker = null;
        CursorImpl cursor = null;
        try {
            locker = new BasicLocker(env);
            cursor = new CursorImpl(fileSummaryDb, locker);

            /* Prevent recursion when synchronized on this object. */
            cursor.setAllowEviction(false);

View Full Code Here

        byte[] keyBytes = FileSummaryLN.makeFullKey(fileNum, sequence);

        Locker locker = null;
        CursorImpl cursor = null;
        try {
            locker = new BasicLocker(env);
            cursor = new CursorImpl(fileSummaryDb, locker);

            /* Prevent recursion when synchronized on this object. */
            cursor.setAllowEviction(false);

View Full Code Here

        Locker locker = null;
        CursorImpl cursor = null;
        boolean ok = true;
       
        try {
            locker = new BasicLocker(env);
            cursor = new CursorImpl(fileSummaryDb, locker);

            if (cursor.positionFirstOrLast(true, null)) {

                OperationStatus status = cursor.getCurrentAlreadyLatched
View Full Code Here

        assert in.getNEntries() > 0;

  DIN duplicateRoot = null;
  boolean dupCountLNLocked = false;
  DupCountLN dcl = null;
  BasicLocker locker = new BasicLocker(env);
        LogManager logManager =
            database.getDbEnvironment().getLogManager();

  try {
            int index = in.findEntry(dupKey, false, true);
      if (index >= 0) {
    duplicateRoot = (DIN) in.fetchTarget(index);
    duplicateRoot.latch();

    ChildReference dclRef = duplicateRoot.getDupCountLNRef();
    dcl = (DupCountLN)
        dclRef.fetchTarget(database, duplicateRoot);

    /* Read lock the dup count LN. */
    if (locker.nonBlockingReadLock(dcl.getNodeId(), database) ==
                    LockGrantType.DENIED) {
        return false;
    } else {
        dupCountLNLocked = true;
    }

    /*
     * We don't release the latch on 'in' before we search the
     * duplicate tree below because we might be deleting the whole
     * subtree from the IN and we want to keep it latched until we
     * know.
     */
    IN subtreeRoot;
    try {
        subtreeRoot = searchSubTree(duplicateRoot,
            idKey,
            SearchType.DELETE,
            -1,
                                                null,
                                                true /*updateGeneration*/);
    } catch (NodeNotEmptyException NNEE) {

        /*
         * We can't delete the subtree because there are still
         * cursors pointing to the lowest node on it.
         */
        in.releaseLatch();
        throw NNEE;
    }

    if (subtreeRoot == null) {
        /* We're deleting the duplicate root. */
        BIN bin = (BIN) in;
        if (bin.nCursors() == 0) {
      try {

          /*
           * duplicateRoot is not currently latched.  Relatch
           * it and recheck if it still is deletable.
           */
          duplicateRoot.latch();
          if (duplicateRoot.isValidForDelete()) {
        boolean deleteOk =
            bin.deleteEntry(index, true);
        assert deleteOk;

        logManager.log(new INDupDeleteInfo
                 (duplicateRoot.getNodeId(),
            duplicateRoot.getMainTreeKey(),
            duplicateRoot.getDupTreeKey(),
            database.getId()));

                                /*
                                 * Count obsolete nodes after logging the
                                 * delete info.
                                 */
                                accountForSubtreeRemoval
            (inMemoryINs, duplicateRoot, tracker);

        if (bin.getNEntries() == 0) {
            database.getDbEnvironment().
          addToCompressorQueue(bin, null, false);
        }
          }
      } finally {
          duplicateRoot.releaseLatch();
      }
        } else {

      /*
       * Don't delete anything off this IN if there are
       * cursors referring to it.
       */
      ret = false;
        }
        in.releaseLatch();
    } else {
        try {
      /* We're deleting a portion of the duplicate tree. */
      in.releaseLatch();
      int dupIndex =
          subtreeRoot.findEntry(idKey, false, false);
      IN rootIN = (IN) subtreeRoot.fetchTarget(dupIndex);
      boolean deleteOk =
          subtreeRoot.deleteEntry(dupIndex, true);
      assert deleteOk;

      /*
       * Record in the log the nodeid of the highest node in
       * the subtree that we're deleting. We'll use this
       * later to navigate to the right place if we need to
       * replay this delete.
       */
      logManager.log(new INDupDeleteInfo
               (rootIN.getNodeId(),
          rootIN.getMainTreeKey(),
          rootIN.getDupTreeKey(),
          database.getId()));

                        /*
                         * Count obsolete nodes after logging the delete info.
                         */
                        accountForSubtreeRemoval(inMemoryINs, rootIN, tracker);
        } finally {
      subtreeRoot.releaseLatch();
        }
    }
      }
  } finally {

      /*
       * Release this IN, either because it didn't prove to be the target
       * IN, or because we threw out of the attempt to delete the
       * subtree.
       */
            in.releaseLatchIfOwner();
      if (duplicateRoot != null) {
    duplicateRoot.releaseLatchIfOwner();
      }

      if (dupCountLNLocked) {
    locker.releaseLock(dcl.getNodeId());
      }
  }

        return ret;
    }
View Full Code Here

                              long lockTimeout,
                              boolean allowEviction,
                              String dbNameIfAvailable)
        throws DatabaseException {

  Locker locker = new BasicLocker(envImpl);
  if (lockTimeout != -1) {
      locker.setLockTimeout(lockTimeout);
  }

        if (dbId.equals(idDatabase.getId())) {
            /* We're looking for the id database itself. */
            return idDatabase;
        } else if (dbId.equals(nameDatabase.getId())) {
            /* We're looking for the name database itself. */
            return nameDatabase;
        } else {
            /* Scan the tree for this db. */
            CursorImpl idCursor = null;
            DatabaseImpl foundDbImpl = null;

      /*
       * Retry in the face of lock timeouts.  Deadlocks may be due to
       * conflicts with modifyDbRoot.
       */
      while (true) {
                idCursor = new CursorImpl(idDatabase, locker);
                idCursor.setAllowEviction(allowEviction);
    try {
        DatabaseEntry keyDbt = new DatabaseEntry(dbId.getBytes());
        boolean found =
      (idCursor.searchAndPosition
       (keyDbt, new DatabaseEntry(), SearchMode.SET,
        LockType.READ) &
       CursorImpl.FOUND) != 0;
        if (found) {
      MapLN mapLN = (MapLN)
          idCursor.getCurrentLNAlreadyLatched(LockType.READ);
                        assert mapLN != null; /* Should be locked. */
                        foundDbImpl =  mapLN.getDatabase();
                    }
                    break;
    } catch (DeadlockException DE) {
        idCursor.close();
        locker.operationEnd(false);
        locker = new BasicLocker(envImpl);
        if (lockTimeout != -1) {
      locker.setLockTimeout(lockTimeout);
        }
        idCursor = new CursorImpl(idDatabase, locker);
                    idCursor.setAllowEviction(allowEviction);
        continue;
    } finally {
        idCursor.releaseBIN();
        idCursor.close();
        locker.operationEnd(true);
    }
      }

            /*
             * Set the debugging name in the databaseImpl, but only after
View Full Code Here

       */
      Locker locker = null;
      CursorImpl cursor = null;
            LockType lockType = LockType.NONE;
      try {
    locker = new BasicLocker(envImpl);
    cursor = new CursorImpl(idDatabase, locker);
    if (cursor.positionFirstOrLast(true, null)) {
                    MapLN mapLN = (MapLN) cursor.
                        getCurrentLNAlreadyLatched(lockType);

View Full Code Here

        }

        Locker locker = null;
        CursorImpl cursor = null;
        try {
            locker = new BasicLocker(envImpl);
            cursor = new CursorImpl(nameDatabase, locker);
            /* Use dirty reads (LockType.NONE). */
            DatabaseEntry keyDbt = new DatabaseEntry();
            DatabaseEntry dataDbt = new DatabaseEntry();
            String name = null;
View Full Code Here

       
        List nameList = new ArrayList();
        Locker locker = null;
        CursorImpl cursor = null;
        try {
            locker = new BasicLocker(envImpl);
            cursor = new CursorImpl(nameDatabase, locker);
            DatabaseEntry keyDbt = new DatabaseEntry();
            DatabaseEntry dataDbt = new DatabaseEntry();
            if (cursor.positionFirstOrLast(true, null)) {
                OperationStatus status;
View Full Code Here

TOP

Related Classes of com.sleepycat.je.txn.BasicLocker

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.