Package org.apache.derby.iapi.store.access

Examples of org.apache.derby.iapi.store.access.TransactionController


    _uuidString = (String) key;

        if ( _sequenceGenerator == null )
        {
            TransactionController executionTC = getLCC().getTransactionExecute();
           
            //
            // We lookup information in a read-only subtransaction in order to minimize
            // contention. Since this is a read-only subtransaction, there should be
            // no conflict with the parent transaction.
            //
            TransactionController subTransaction = executionTC.startNestedUserTransaction( true );
            try {
                _sequenceGenerator = createSequenceGenerator( subTransaction );
            }
            finally
            {
                subTransaction.commit();
                subTransaction.destroy();
            }
        }

    if ( _sequenceGenerator != null ) { return this; }
    else { return null; }
View Full Code Here


   * @return Returns true if the value was successfully updated, false if we lost a race with another session.
     *
     */
    public boolean updateCurrentValueOnDisk( Long oldValue, Long newValue ) throws StandardException
    {
        TransactionController executionTransaction = getLCC().getTransactionExecute();
        TransactionController nestedTransaction = null;

        try {
            nestedTransaction = executionTransaction.startNestedUserTransaction( false );
        } catch (StandardException se) {}
       
        // First try to do the work in the nested transaction. Fail if we can't
        // get a lock immediately.
        if ( nestedTransaction != null )
        {
            try {
                return updateCurrentValueOnDisk( nestedTransaction, oldValue, newValue, false );
            }
            catch (StandardException se)
            {
                if ( !se.getMessageId().equals( SQLState.LOCK_TIMEOUT ) ) { throw se; }
            }
            finally
            {
                nestedTransaction.commit();
                nestedTransaction.destroy();
            }
        }
       
        // If we get here, we failed to do the work in the nested transaction.
        // Fall back on the execution transaction
View Full Code Here

  }

  public LanguageConnectionContext setupConnection(ContextManager cm, String user, String drdaID, String dbname)
    throws StandardException {

    TransactionController tc = getConnectionTransaction(cm);

    cm.setLocaleFinder(this);
    pushDbContext(cm);

    // push a database shutdown context
View Full Code Here

  protected  UUID  makeDatabaseID(boolean create, Properties startParams)
    throws StandardException
  {
   
    TransactionController tc = af.getTransaction(
        ContextService.getFactory().getCurrentContextManager());

    String  upgradeID = null;
    UUID  databaseID;

    if ((databaseID = (UUID) tc.getProperty(DataDictionary.DATABASE_ID)) == null) {

      // no property defined in the Transaction set
      // this could be an upgrade, see if it's stored in the service set

      UUIDFactory  uuidFactory  = Monitor.getMonitor().getUUIDFactory();

     
      upgradeID = startParams.getProperty(DataDictionary.DATABASE_ID);
      if (upgradeID == null )
      {
        // just create one
        databaseID = uuidFactory.createUUID();
      } else {
        databaseID = uuidFactory.recreateUUID(upgradeID);
      }

      tc.setProperty(DataDictionary.DATABASE_ID, databaseID, true);
    }

    // Remove the database identifier from the service.properties
    // file only if we upgraded it to be stored in the transactional
    // property set.
    if (upgradeID != null)
      startParams.remove(DataDictionary.DATABASE_ID);

    tc.commit();
    tc.destroy();

    return databaseID;
  }
View Full Code Here

     * on disk outside of service.properties.
     */
  protected Properties getAllDatabaseProperties()
    throws StandardException {

    TransactionController tc = af.getTransaction(
                    ContextService.getFactory().getCurrentContextManager());
    Properties dbProps = tc.getProperties();
    tc.commit();
    tc.destroy();

    return dbProps;
  }
View Full Code Here

     *  setted up by the system properties.
     */
    private long getDefaultXATransactionTimeout() throws XAException {
        try {
            LanguageConnectionContext lcc = con.getLanguageConnection();
            TransactionController tc = lcc.getTransactionExecute();

            long timeoutMillis = 1000 * (long) PropertyUtil.getServiceInt(
                tc,
                Property.PROP_XA_TRANSACTION_TIMEOUT,
                0,
View Full Code Here

    }

    private void tempTablesXApostCommit()
        throws StandardException
    {
        TransactionController tc = getTransactionExecute();

        // at commit time for an XA transaction drop all temporary tables.
        // A transaction context may not be maintained from one
        // XAResource.xa_commit to the next in the case of XA with
        // network server and thus there is no way to get at the temp
        // tables again.  To provide consistent behavior in embedded vs
        // network server, consistently remove temp tables at XA commit
        // transaction boundary.
        for (int i=0; i < allDeclaredGlobalTempTables.size(); i++)
        {
            // remove all temp tables from this context.
            TableDescriptor td =
                ((TempTableInfo)
                 (allDeclaredGlobalTempTables.get(i))).getTableDescriptor();

            //remove the conglomerate created for this temp table
            tc.dropConglomerate(td.getHeapConglomerateId());

            //remove it from the list of temp tables
            allDeclaredGlobalTempTables.remove(i);
        }

        tc.commit();
    }
View Full Code Here

                SanityManager.THROWASSERT("Nested transaction active!");
            }
        }

        // now commit the Store transaction
        TransactionController tc = getTransactionExecute();
        if ( tc != null && commitStore )
        {
            if (sync)
            {
                if (commitflag == NON_XA)
                {
                    // regular commit
                    tc.commit();
                }
                else
                {
                    // This may be a xa_commit, check overloaded commitflag.

                    if (SanityManager.DEBUG)
                        SanityManager.ASSERT(commitflag == XA_ONE_PHASE ||
                                             commitflag == XA_TWO_PHASE,
                                               "invalid commit flag");

                    ((XATransactionController)tc).xa_commit(
                            commitflag == XA_ONE_PHASE);

                }
            }
            else
            {
                tc.commitNoSync(commitflag);
            }

            // reset the savepoints to the new
            // location, since any outer nesting
            // levels expect there to be a savepoint
View Full Code Here

    private TableDescriptor cleanupTempTableOnCommitOrRollback(
    TableDescriptor         td,
    boolean                 dropAndRedeclare)
         throws StandardException
    {
        TransactionController tc = getTransactionExecute();

        //create new conglomerate with same properties as the old conglomerate
        //and same row template as the old conglomerate
        long conglomId =
            tc.createConglomerate(
                "heap", // we're requesting a heap conglomerate
                td.getEmptyExecRow().getRowArray(), // row template
                null, //column sort order - not required for heap
                td.getColumnCollationIds()// same ids as old conglomerate
                null, // properties
                (TransactionController.IS_TEMPORARY |
                 TransactionController.IS_KEPT));

        long cid = td.getHeapConglomerateId();

        //remove the old conglomerate descriptor from the table descriptor
        ConglomerateDescriptor cgd = td.getConglomerateDescriptor(cid);
        td.getConglomerateDescriptorList().dropConglomerateDescriptorByUUID(
            cgd.getUUID());

        //add the new conglomerate descriptor to the table descriptor
        cgd = getDataDictionary().getDataDescriptorGenerator().newConglomerateDescriptor(conglomId, null, false, null, false, null, td.getUUID(),
        td.getSchemaDescriptor().getUUID());
        ConglomerateDescriptorList conglomList =
            td.getConglomerateDescriptorList();
        conglomList.add(cgd);

        //reset the heap conglomerate number in table descriptor to -1 so it
        //will be refetched next time with the new value
        td.resetHeapConglomNumber();

        if (dropAndRedeclare)
        {
            //remove the old conglomerate from the system
            tc.dropConglomerate(cid);

            replaceDeclaredGlobalTempTable(td.getName(), td);
        }

        return(td);
View Full Code Here

    try
    {
      if (af != null)
      {
        TransactionController tc = null;
        try
        {
          tc = af.getAndNameTransaction(
                            context, AccessFactoryGlobals.SYS_TRANS_NAME);

          getLogFactoryProperties(tc);
        }
        finally
        {
          if (tc != null)
            tc.commit();
        }
      }

      // checkpoint will start its own internal transaction on the current
      // context.
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.store.access.TransactionController

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.