Package org.apache.derby.iapi.store.raw

Examples of org.apache.derby.iapi.store.raw.LockingPolicy


    {

    if (mode == LockingPolicy.MODE_NONE)
      isolation = TransactionController.ISOLATION_NOLOCK;

    LockingPolicy policy = lockingPolicies[mode][isolation];

    if ((policy != null) || (!stricterOk))
      return policy;

    for (mode++; mode <= LockingPolicy.MODE_CONTAINER; mode++)
View Full Code Here


        be freed when we the container handle is closed. This will happen in
        closeStream() or when the transaction commits.
        Hence, locks will be released before the end of transaction if
        blobs/clobs are explicitly released.
        */
        LockingPolicy lp =
            owner.getTransaction().newLockingPolicy(
                LockingPolicy.MODE_RECORD,
                TransactionController.ISOLATION_READ_COMMITTED, true);

        // reopen the container
View Full Code Here

    ContainerKey identity = new ContainerKey(segmentId, containerId);

    boolean tmpContainer = (segmentId == ContainerHandle.TEMPORARY_SEGMENT);

    ContainerHandle ch = null;
    LockingPolicy   cl = null;

    if (!tmpContainer)
        {
      // lock the container before we create it.

      if (isReadOnly())
            {
        throw StandardException.newException(
                        SQLState.DATA_CONTAINER_READ_ONLY);
            }

      cl = t.newLockingPolicy(LockingPolicy.MODE_CONTAINER,
          TransactionController.ISOLATION_SERIALIZABLE, true);
     
      if (SanityManager.DEBUG)
        SanityManager.ASSERT(cl != null);

      ch = t.openContainer(identity, cl,
                   (ContainerHandle.MODE_FORUPDATE |
                    ContainerHandle.MODE_OPEN_FOR_LOCK_ONLY));
    }

    FileContainer container =
      (FileContainer) containerCache.create(identity, tableProperties);

    // create the first alloc page and the first user page,
    // if this fails for any reason the transaction
    // will roll back and the container will be dropped (removed)
    ContainerHandle containerHdl = null;
    Page            firstPage    = null;

    try
        {
      // if opening a temporary container with IS_KEPT flag set,
      // make sure to open it with IS_KEPT too.
      if (tmpContainer &&
        ((temporaryFlag & TransactionController.IS_KEPT) ==
                     TransactionController.IS_KEPT))
            {

        mode |= ContainerHandle.MODE_TEMP_IS_KEPT;
      }

      // open no-locking as we already have the container locked
      containerHdl =
                t.openContainer(
                    identity, null, (ContainerHandle.MODE_FORUPDATE | mode));

      // we just added it, containerHdl should not be null
            if (SanityManager.DEBUG)
                SanityManager.ASSERT(containerHdl != null);

      if (!tmpContainer)
            {
        // make it persistent (in concept if not in reality)
        RawContainerHandle rch = (RawContainerHandle)containerHdl;

        ContainerOperation lop =
          new ContainerOperation(rch, ContainerOperation.CREATE);

        // mark the container as pre-dirtied so that if a checkpoint
        // happens after the log record is sent to the log stream, the
        // cache cleaning will wait for this change.
        rch.preDirty(true);
        try
        {
          t.logAndDo(lop);

          // flush the log to reduce the window between where
          // the container is created & synced and the log record
          // for it makes it to disk. If we fail in this
          // window we will leave a stranded container file.
          flush(t.getLastLogInstant());
        }
        finally
        {
          // in case logAndDo fail, make sure the container is not
          // stuck in preDirty state.
          rch.preDirty(false);
        }
      }

      firstPage = containerHdl.addPage();

    }
        finally
        {

      if (firstPage != null)
            {
        firstPage.unlatch();
        firstPage = null;
      }
     
      containerCache.release(container);

      if (containerHdl != null)
            {
        containerHdl.close();
        containerHdl = null;
      }

      if (!tmpContainer)
            {
                // this should do nothing, since we requested isolation 3
                // but we can't assume that, so call the policy correctly.

        cl.unlockContainer(t, ch)
      }
    }

    return containerId;
  }
View Full Code Here

     throws StandardException
  {
    boolean tmpContainer =
            (ckey.getSegmentId() == ContainerHandle.TEMPORARY_SEGMENT);

    LockingPolicy cl = null;

    if (!tmpContainer)
        {
      if (isReadOnly())
            {
View Full Code Here

   
    if (files != null) {
      // No user visible locks are acquired to backup the database. A stable backup
      // is made by latching the pages and internal synchronization
      // mechanisms.
      LockingPolicy lockPolicy =   rt.newLockingPolicy(LockingPolicy.MODE_NONE,
                              TransactionController.ISOLATION_NOLOCK,
                              false);
      long segmentId = 0;

      // loop through all the files in seg0 and backup all valid containers.
View Full Code Here

    {

    if (mode == LockingPolicy.MODE_NONE)
      isolation = TransactionController.ISOLATION_NOLOCK;

    LockingPolicy policy = lockingPolicies[mode][isolation];

    if ((policy != null) || (!stricterOk))
      return policy;

    for (mode++; mode <= LockingPolicy.MODE_CONTAINER; mode++)
View Full Code Here

     **/
    private LockingPolicy determine_locking_policy(
    int requested_lock_level,
    int isolation_level)
    {
        LockingPolicy ret_locking_policy;

        if ((accessmanager.getSystemLockLevel() ==
                TransactionController.MODE_TABLE) ||
            (requested_lock_level == TransactionController.MODE_TABLE))
        {
View Full Code Here

    ContainerKey identity = new ContainerKey(segmentId, containerId);

    boolean tmpContainer = (segmentId == ContainerHandle.TEMPORARY_SEGMENT);

    ContainerHandle ch = null;
    LockingPolicy   cl = null;

    if (!tmpContainer)
        {
      // lock the container before we create it.

      if (isReadOnly())
            {
        throw StandardException.newException(
                        SQLState.DATA_CONTAINER_READ_ONLY);
            }

      cl = t.newLockingPolicy(LockingPolicy.MODE_CONTAINER,
          TransactionController.ISOLATION_SERIALIZABLE, true);
     
      if (SanityManager.DEBUG)
        SanityManager.ASSERT(cl != null);

      ch = t.openContainer(identity, cl,
                   (ContainerHandle.MODE_FORUPDATE |
                    ContainerHandle.MODE_OPEN_FOR_LOCK_ONLY));
    }

    FileContainer container =
      (FileContainer) containerCache.create(identity, tableProperties);

    // create the first alloc page and the first user page,
    // if this fails for any reason the transaction
    // will roll back and the container will be dropped (removed)
    ContainerHandle containerHdl = null;
    Page            firstPage    = null;

    try
        {
      // if opening a temporary container with IS_KEPT flag set,
      // make sure to open it with IS_KEPT too.
      if (tmpContainer &&
        ((temporaryFlag & TransactionController.IS_KEPT) ==
                     TransactionController.IS_KEPT))
            {

        mode |= ContainerHandle.MODE_TEMP_IS_KEPT;
      }

      // open no-locking as we already have the container locked
      containerHdl =
                t.openContainer(
                    identity, null, (ContainerHandle.MODE_FORUPDATE | mode));

      // we just added it, containerHdl should not be null
            if (SanityManager.DEBUG)
                SanityManager.ASSERT(containerHdl != null);

      if (!tmpContainer)
            {
        // make it persistent (in concept if not in reality)
        RawContainerHandle rch = (RawContainerHandle)containerHdl;

        ContainerOperation lop =
          new ContainerOperation(rch, ContainerOperation.CREATE);

        // mark the container as pre-dirtied so that if a checkpoint
        // happens after the log record is sent to the log stream, the
        // cache cleaning will wait for this change.
        rch.preDirty(true);
        try
        {
          t.logAndDo(lop);

          // flush the log to reduce the window between where
          // the container is created & synced and the log record
          // for it makes it to disk. If we fail in this
          // window we will leave a stranded container file.
          flush(t.getLastLogInstant());
        }
        finally
        {
          // in case logAndDo fail, make sure the container is not
          // stuck in preDirty state.
          rch.preDirty(false);
        }
      }

      firstPage = containerHdl.addPage();

    }
        finally
        {

      if (firstPage != null)
            {
        firstPage.unlatch();
        firstPage = null;
      }
     
      containerCache.release(container);

      if (containerHdl != null)
            {
        containerHdl.close();
        containerHdl = null;
      }

      if (!tmpContainer)
            {
                // this should do nothing, since we requested isolation 3
                // but we can't assume that, so call the policy correctly.

        cl.unlockContainer(t, ch)
      }
    }

    return containerId;
  }
View Full Code Here

     throws StandardException
  {
    boolean tmpContainer =
            (ckey.getSegmentId() == ContainerHandle.TEMPORARY_SEGMENT);

    LockingPolicy cl = null;

    if (!tmpContainer)
        {
      if (isReadOnly())
            {
View Full Code Here

   
    if (files != null) {
      // No user visible locks are acquired to backup the database. A stable backup
      // is made by latching the pages and internal synchronization
      // mechanisms.
      LockingPolicy lockPolicy =   rt.newLockingPolicy(LockingPolicy.MODE_NONE,
                              TransactionController.ISOLATION_NOLOCK,
                              false);
      long segmentId = 0;

      // loop through all the files in seg0 and backup all valid containers.
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.store.raw.LockingPolicy

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.