Search in sources :

Example 91 with TransactionController

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

the class T_Heap method runTests.

/**
 *		@exception T_Fail test failed.
 */
protected void runTests() throws T_Fail {
    AccessFactory store = null;
    TransactionController tc = null;
    boolean pass = false;
    out.println("executing heap test");
    // don't automatic boot this service if it gets left around
    if (startParams == null) {
        startParams = new Properties();
    }
    startParams.put(Property.NO_AUTO_BOOT, Boolean.TRUE.toString());
    // remove the service directory to ensure a clean run
    startParams.put(Property.DELETE_ON_CREATE, Boolean.TRUE.toString());
    // see if we are testing encryption
    startParams = T_Util.setEncryptionParam(startParams);
    try {
        store = (AccessFactory) createPersistentService(getModuleToTestProtocolName(), testService, startParams);
    } catch (StandardException mse) {
        throw T_Fail.exceptionFail(mse);
    }
    if (store == null) {
        throw T_Fail.testFailMsg(getModuleToTestProtocolName() + " service not started.");
    }
    REPORT("(unitTestMain) Testing " + testService);
    try {
        tc = store.getTransaction(getContextService().getCurrentContextManager());
        if (t_001(tc)) {
            pass = true;
        }
        tc.commit();
        tc.destroy();
    } catch (StandardException e) {
        System.out.println("got an exception.");
        String msg = e.getMessage();
        if (msg == null)
            msg = e.getClass().getName();
        REPORT(msg);
        throw T_Fail.exceptionFail(e);
    }
    if (!pass)
        throw T_Fail.testFailMsg("T_Heap test failed");
}
Also used : StandardException(org.apache.derby.shared.common.error.StandardException) TransactionController(org.apache.derby.iapi.store.access.TransactionController) Properties(java.util.Properties) AccessFactory(org.apache.derby.iapi.store.access.AccessFactory)

Example 92 with TransactionController

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

the class T_CreateConglomRet method runTestSet.

/**
 * Driver routine for the btree secondary index tests.
 * <p>
 *
 * @exception  T_Fail  Throws T_Fail on any test failure.
 */
protected void runTestSet() throws T_Fail {
    AccessFactory store = null;
    TransactionController tc = null;
    boolean pass = false;
    out.println("executing b2i test");
    store = (AccessFactory) store_module;
    if (store == null) {
        throw T_Fail.testFailMsg(getModuleToTestProtocolName() + " service not started.");
    }
    ContextManager cm1 = contextService.newContextManager();
    contextService.setCurrentContextManager(cm1);
    REPORT("(unitTestMain) Testing " + testService);
    try {
        tc = store.getTransaction(cm1);
        pass = true;
        if (t_005(tc) && t_001(tc) && t_003(tc) && t_004(tc) && t_005(tc) && t_006(tc) && t_009(tc) && t_010(tc) && t_011(tc) && t_012(tc) && t_013(tc) && t_014(tc) && t_017(tc) && t_018(tc) && t_019(tc) && t_020(tc) && t_021(tc)) {
            pass = true;
            if (SanityManager.DEBUG) {
                pass = false;
                if (t_002(tc) && t_007(tc) && t_008(tc) && t_015(tc) && t_016(tc))
                    pass = true;
            }
        }
        tc.commit();
        tc.destroy();
    } catch (StandardException e) {
        String msg = e.getMessage();
        if (msg == null)
            msg = e.getClass().getName();
        REPORT(msg);
        e.printStackTrace(out.getPrintWriter());
        cm1.cleanupOnError(e, isdbActive());
        pass = false;
    } catch (Throwable t) {
        String msg = t.getMessage();
        if (msg == null)
            msg = t.getClass().getName();
        REPORT(msg);
        t.printStackTrace(out.getPrintWriter());
        cm1.cleanupOnError(t, isdbActive());
        pass = false;
    } finally {
        contextService.resetCurrentContextManager(cm1);
    }
    if (!pass)
        throw T_Fail.testFailMsg("");
}
Also used : StandardException(org.apache.derby.shared.common.error.StandardException) ContextManager(org.apache.derby.iapi.services.context.ContextManager) TransactionController(org.apache.derby.iapi.store.access.TransactionController) AccessFactory(org.apache.derby.iapi.store.access.AccessFactory)

Example 93 with TransactionController

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

the class LogToFile method enableLogArchiveMode.

// enable the log archive mode
public void enableLogArchiveMode() throws StandardException {
    // if the log archive mode is already enabled; thre is nothing to do
    if (!logArchived) {
        logArchived = true;
        AccessFactory af = (AccessFactory) getServiceModule(this, AccessFactory.MODULE);
        if (af != null) {
            TransactionController tc = null;
            tc = af.getTransaction(getContextService().getCurrentContextManager());
            tc.setProperty(Property.LOG_ARCHIVE_MODE, "true", true);
        }
    }
}
Also used : TransactionController(org.apache.derby.iapi.store.access.TransactionController) AccessFactory(org.apache.derby.iapi.store.access.AccessFactory)

Example 94 with TransactionController

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

the class FileContainer method createInfoFromProp.

/**
 *		Set container properties from the passed in createArgs.
 *		The following container properties are set:
 *
 *		pageSize
 *		spareSpace
 *		minimumRecordSize
 *		isReusableRecordId
 *		initialPages
 *
 *		RESOLVE - in the future setting parameters should be overridable
 *		by sub-class, e.g. one implementation of Container may require a
 *		minimum page size of 4k.
 */
private void createInfoFromProp(Properties createArgs) throws StandardException {
    // Need a TransactionController to get database/service wide properties.
    AccessFactory af = (AccessFactory) getServiceModule(dataFactory, AccessFactory.MODULE);
    // RESOLVE: sku defectid 2014
    TransactionController tc = (af == null) ? null : af.getTransaction(getContextService().getCurrentContextManager());
    pageSize = PropertyUtil.getServiceInt(tc, createArgs, Property.PAGE_SIZE_PARAMETER, Limits.DB2_MIN_PAGE_SIZE, Limits.DB2_MAX_PAGE_SIZE, RawStoreFactory.PAGE_SIZE_DEFAULT);
    // default if bad value given.
    if ((pageSize != 4096) && (pageSize != 8192) && (pageSize != 16384) && (pageSize != 32768)) {
        pageSize = RawStoreFactory.PAGE_SIZE_DEFAULT;
    }
    spareSpace = PropertyUtil.getServiceInt(tc, createArgs, RawStoreFactory.PAGE_RESERVED_SPACE_PARAMETER, 0, 100, 20);
    PreAllocSize = PropertyUtil.getServiceInt(tc, createArgs, RawStoreFactory.PRE_ALLOCATE_PAGE, MIN_PRE_ALLOC_SIZE, MAX_PRE_ALLOC_SIZE, DEFAULT_PRE_ALLOC_SIZE);
    // to be larger than pageSize, when long rows are supported.
    if (createArgs == null) {
        // if the createArgs is null, then the following method call
        // will get the system properties from the appropriete places.
        // we want to make sure minimumRecrodSize is set to at least
        // the default value MINIMUM_RECORD_SIZE_DEFAULT (12)
        // as set in rawStoreFactory.
        minimumRecordSize = PropertyUtil.getServiceInt(tc, RawStoreFactory.MINIMUM_RECORD_SIZE_PARAMETER, // this is different from the next call
        RawStoreFactory.MINIMUM_RECORD_SIZE_DEFAULT, // reserving 100 bytes for record/field headers
        (pageSize * (1 - spareSpace / 100) - 100), RawStoreFactory.MINIMUM_RECORD_SIZE_DEFAULT);
    } else {
        // if the createArgs is not null, then it has already been set
        // by upper layer or create statement, then, we allow the minimum
        // value of this to be MINIMUM_RECORD_SIZE_MINIMUM (1).
        minimumRecordSize = PropertyUtil.getServiceInt(tc, createArgs, RawStoreFactory.MINIMUM_RECORD_SIZE_PARAMETER, // this is different from the last call
        RawStoreFactory.MINIMUM_RECORD_SIZE_MINIMUM, // reserving 100 bytes for record/field headers
        (pageSize * (1 - spareSpace / 100) - 100), RawStoreFactory.MINIMUM_RECORD_SIZE_DEFAULT);
    }
    // if container is to be created with a large number of pages
    if (createArgs != null) {
        String reusableRecordIdParameter = createArgs.getProperty(RawStoreFactory.PAGE_REUSABLE_RECORD_ID);
        if (reusableRecordIdParameter != null) {
            Boolean reusableRecordId = Boolean.parseBoolean(reusableRecordIdParameter);
            setReusableRecordIdState(reusableRecordId.booleanValue());
        }
        String containerInitialPageParameter = createArgs.getProperty(RawStoreFactory.CONTAINER_INITIAL_PAGES);
        if (containerInitialPageParameter != null) {
            initialPages = Short.parseShort(containerInitialPageParameter);
            if (initialPages > 1) {
                if (initialPages > RawStoreFactory.MAX_CONTAINER_INITIAL_PAGES)
                    initialPages = RawStoreFactory.MAX_CONTAINER_INITIAL_PAGES;
            }
        }
    }
}
Also used : TransactionController(org.apache.derby.iapi.store.access.TransactionController) AccessFactory(org.apache.derby.iapi.store.access.AccessFactory)

Example 95 with TransactionController

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

the class LogToFile method disableLogArchiveMode.

// disable the log archive mode
public void disableLogArchiveMode() throws StandardException {
    AccessFactory af = (AccessFactory) getServiceModule(this, AccessFactory.MODULE);
    if (af != null) {
        TransactionController tc = null;
        tc = af.getTransaction(getContextService().getCurrentContextManager());
        tc.setProperty(Property.LOG_ARCHIVE_MODE, "false", true);
    }
    logArchived = false;
}
Also used : TransactionController(org.apache.derby.iapi.store.access.TransactionController) AccessFactory(org.apache.derby.iapi.store.access.AccessFactory)

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