Search in sources :

Example 61 with TransactionController

use of org.apache.derby.iapi.store.access.TransactionController in project derby by apache.

the class StreamFileContainer method getContainerProperties.

/**
 * Request the system properties associated with a stream container.
 * <p>
 * Request the value of properties associated with a stream container.
 * The following properties can be requested:
 *     derby.storage.streamFileBufferSize
 *
 * <p>
 * To get the value of a particular property add it to the property list,
 * and on return the value of the property will be set to it's current
 * value.  For example:
 *
 * get_prop(ConglomerateController cc)
 * {
 *     Properties prop = new Properties();
 *     prop.put("derby.storage.streamFileBufferSize", "");
 *     cc.getContainerProperties(prop);
 *
 *     System.out.println(
 *         "stream table's buffer size = " +
 *         prop.getProperty("derby.storage.streamFileBufferSize");
 * }
 *
 * @param prop   Property list to fill in.
 *
 * @exception  StandardException  Standard exception policy.
 */
public void getContainerProperties(Properties prop) throws StandardException {
    AccessFactory af = (AccessFactory) getServiceModule(dataFactory, AccessFactory.MODULE);
    TransactionController tc = (af == null) ? null : af.getTransaction(getContextService().getCurrentContextManager());
    bufferSize = PropertyUtil.getServiceInt(tc, prop, RawStoreFactory.STREAM_FILE_BUFFER_SIZE_PARAMETER, RawStoreFactory.STREAM_FILE_BUFFER_SIZE_MINIMUM, RawStoreFactory.STREAM_FILE_BUFFER_SIZE_MAXIMUM, RawStoreFactory.STREAM_FILE_BUFFER_SIZE_DEFAULT);
}
Also used : TransactionController(org.apache.derby.iapi.store.access.TransactionController) AccessFactory(org.apache.derby.iapi.store.access.AccessFactory)

Example 62 with TransactionController

use of org.apache.derby.iapi.store.access.TransactionController in project derby by apache.

the class LogToFile method performWork.

public int performWork(ContextManager context) {
    synchronized (this) {
        if (corrupt != null)
            // don't do this again.
            return Serviceable.DONE;
    }
    // check to see if checkpointInterval and logSwitchInterval has changed
    AccessFactory af = (AccessFactory) getServiceModule(this, AccessFactory.MODULE);
    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.
        rawStoreFactory.checkpoint();
    } catch (StandardException se) {
        Monitor.logTextMessage(MessageId.LOG_CHECKPOINT_EXCEPTION);
        logErrMsg(se);
    } catch (ShutdownException shutdown) {
    // If we are shutting down, just ignore the error and let the
    // system go down without printing errors to the log.
    }
    checkpointDaemonCalled = false;
    return Serviceable.DONE;
}
Also used : StandardException(org.apache.derby.shared.common.error.StandardException) ShutdownException(org.apache.derby.shared.common.error.ShutdownException) TransactionController(org.apache.derby.iapi.store.access.TransactionController) AccessFactory(org.apache.derby.iapi.store.access.AccessFactory)

Example 63 with TransactionController

use of org.apache.derby.iapi.store.access.TransactionController in project derby by apache.

the class D_DiagnosticUtil method diag_conglomid.

/**
 * Given a Database name and conglomid, return diagnositic string.
 * <p>
 * Return a string with diagnostic information about a particular
 * conglomerate, can be called for any type of conglomerate (some types
 * may not return any info though).
 * <p>
 * Can be called from ij to find out info about conglomid 19 in database
 * 'msgdb' by using the following syntax:
 *
 *     values
 *     com.ibm.db2j.protocol.BasicServices.Diagnostic.T_Diagnosticable::
 *     diag_conglomid('msgdb', 19);
 *       maximumdisplaywidth 9000;
 *
 *       CREATE FUNCTION DIAG_CONGLOMID(DBNAME VARCHAR(128), CONGLOMID INT)
 *       RETURNS VARCHAR(32000) RETURNS NULL ON NULL INPUT
 *       EXTERNAL NAME
 *       'org.apache.derby.impl.store.raw.data.D_DiagnosticUtil.diag_conglomid'
 *       LANGUAGE JAVA PARAMETER STYLE JAVA;
 *
 *       values DIAG_CONGLOMID('msgdb', 19);
 *          com.ibm.db2j.protocol.BasicServices.Diagnostic.T_Diagnosticable::
 *          diag_conglomid_print('msgdb', 19);
 *
 * RESOLVE - An interface that takes a table name would be nice.
 *
 * @param db_name   name of the database
 * @param conglomid conglomerate id of the conglomerate to debug
 *
 * @exception  StandardException  Standard exception policy.
 */
public static String diag_conglomid(String db_name, long conglomid) throws StandardException {
    String ret_string = null;
    AccessFactory store_module = null;
    store_module = (AccessFactory) getModuleFromDbName(db_name);
    if (store_module != null) {
        TransactionController tc = store_module.getTransaction(FileContainer.getContextService().getCurrentContextManager());
        ConglomerateController open_table = tc.openConglomerate(conglomid, false, 0, TransactionController.MODE_TABLE, TransactionController.ISOLATION_SERIALIZABLE);
        open_table.debugConglomerate();
        Diagnosticable diag_obj = DiagnosticUtil.findDiagnostic(open_table);
        ret_string = diag_obj.diag();
        open_table.close();
    } else {
        System.out.println("Could not find module for database: " + db_name);
    }
    return (ret_string);
}
Also used : ConglomerateController(org.apache.derby.iapi.store.access.ConglomerateController) TransactionController(org.apache.derby.iapi.store.access.TransactionController) Diagnosticable(org.apache.derby.iapi.services.diag.Diagnosticable) AccessFactory(org.apache.derby.iapi.store.access.AccessFactory)

Example 64 with TransactionController

use of org.apache.derby.iapi.store.access.TransactionController in project derby by apache.

the class RAMAccessManager method getAndNameTransaction.

public TransactionController getAndNameTransaction(ContextManager cm, String transName) throws StandardException {
    if (cm == null)
        // XXX (nat) should throw exception
        return null;
    // See if there's already a transaction context.
    RAMTransactionContext rtc = (RAMTransactionContext) cm.getContext(AccessFactoryGlobals.RAMXACT_CONTEXT_ID);
    if (rtc == null) {
        // No transaction context.  Create or find a raw store transaction,
        // make a context for it, and push the context.  Note this puts the
        // raw store transaction context above the access context, which is
        // required for error handling assumptions to be correct.
        Transaction rawtran = rawstore.findUserTransaction(cm, transName);
        RAMTransaction rt = new RAMTransaction(this, rawtran, null);
        rtc = new RAMTransactionContext(cm, AccessFactoryGlobals.RAMXACT_CONTEXT_ID, rt, false);
        TransactionController tc = rtc.getTransaction();
        if (xactProperties != null) {
            rawtran.setup(tc);
            tc.commit();
        }
        rawtran.setDefaultLockingPolicy(system_default_locking_policy);
        tc.commit();
        return tc;
    }
    return rtc.getTransaction();
}
Also used : Transaction(org.apache.derby.iapi.store.raw.Transaction) TransactionController(org.apache.derby.iapi.store.access.TransactionController)

Example 65 with TransactionController

use of org.apache.derby.iapi.store.access.TransactionController in project derby by apache.

the class TemporaryRowHolderImpl method getResultSet.

/**
 * Get a result set for scanning what has been inserted
 * so far.
 *
 * @return a result set to use
 */
public CursorResultSet getResultSet() {
    state = STATE_DRAIN;
    TransactionController tc = activation.getTransactionController();
    if (isUniqueStream) {
        return new TemporaryRowHolderResultSet(tc, rowArray, resultDescription, isVirtualMemHeap, true, positionIndexConglomId, this);
    } else {
        return new TemporaryRowHolderResultSet(tc, rowArray, resultDescription, isVirtualMemHeap, this);
    }
}
Also used : TransactionController(org.apache.derby.iapi.store.access.TransactionController)

Aggregations

TransactionController (org.apache.derby.iapi.store.access.TransactionController)124 LanguageConnectionContext (org.apache.derby.iapi.sql.conn.LanguageConnectionContext)47 DataDictionary (org.apache.derby.iapi.sql.dictionary.DataDictionary)40 StandardException (org.apache.derby.shared.common.error.StandardException)26 DependencyManager (org.apache.derby.iapi.sql.depend.DependencyManager)23 SchemaDescriptor (org.apache.derby.iapi.sql.dictionary.SchemaDescriptor)20 TableDescriptor (org.apache.derby.iapi.sql.dictionary.TableDescriptor)20 UUID (org.apache.derby.catalog.UUID)14 ConglomerateDescriptor (org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor)13 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)12 DataDescriptorGenerator (org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator)12 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)12 Properties (java.util.Properties)11 AccessFactory (org.apache.derby.iapi.store.access.AccessFactory)11 ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)11 ConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor)10 XATransactionController (org.apache.derby.iapi.store.access.XATransactionController)9 ColumnDescriptor (org.apache.derby.iapi.sql.dictionary.ColumnDescriptor)8 ReferencedKeyConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ReferencedKeyConstraintDescriptor)8 ScanController (org.apache.derby.iapi.store.access.ScanController)8