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

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


     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

    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

  {

    boolean tmpContainer =
            (ckey.getSegmentId() == ContainerHandle.TEMPORARY_SEGMENT);

    LockingPolicy cl = null;

    if (!tmpContainer) {

      if (isReadOnly())
            {
View Full Code Here

  {
    // get deallocate lock on page so that the GC won't attempt to
    // free and re-allocate it until the transaction commits
    RawTransaction tran = handle.getTransaction();

    LockingPolicy lp =
            tran.newLockingPolicy(
                LockingPolicy.MODE_RECORD,
                TransactionController.ISOLATION_REPEATABLE_READ,
                true); // striterOK
   
    PageKey pkey = new PageKey(identity, deallocLock.getPageNumber());
    if (lp != null)
        {
      if (zeroDuration)
        return lp.zeroDurationLockRecordForWrite(
                        tran, deallocLock, false, wait);
      else
        return lp.lockRecordForWrite(tran, deallocLock, false, wait);
        }
    else
    {
      throw StandardException.newException(
                    SQLState.DATA_CANNOT_GET_DEALLOC_LOCK, pkey);
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.