Search in sources :

Example 6 with AccessFactory

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

the class D_DiagnosticUtil method diag_containerid_to_conglomid.

public static long diag_containerid_to_conglomid(Object module, long containerid) {
    String ret_string = null;
    AccessFactory store_module = null;
    long conglom_id = Long.MIN_VALUE;
    // Find the AccessFactory
    store_module = (AccessFactory) getServiceModule(module, AccessFactory.MODULE);
    if (store_module != null) {
        try {
            TransactionController tc = store_module.getTransaction(FileContainer.getContextService().getCurrentContextManager());
            conglom_id = tc.findConglomid(containerid);
        } catch (Throwable t) {
            t.printStackTrace();
        // on error just return the initialized bad value conglom_id
        }
    } else {
    // during access boot this does not exist, assume for now that
    // is why we got here.  RESOLVE - it would be nice if we could
    // actuallly figure that is why we failed.
    /*
            System.out.println(
                "Could not find module for module: " + module);
            */
    }
    return (conglom_id);
}
Also used : TransactionController(org.apache.derby.iapi.store.access.TransactionController) AccessFactory(org.apache.derby.iapi.store.access.AccessFactory)

Example 7 with AccessFactory

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

the class D_DiagnosticUtil method diag_conglomid_to_containerid.

public static long diag_conglomid_to_containerid(Object module, long conglomid) {
    String ret_string = null;
    AccessFactory store_module = null;
    long container_id = Long.MIN_VALUE;
    // Find the AccessFactory
    store_module = (AccessFactory) getServiceModule(module, AccessFactory.MODULE);
    if (store_module != null) {
        try {
            TransactionController tc = store_module.getTransaction(FileContainer.getContextService().getCurrentContextManager());
            container_id = tc.findContainerid(conglomid);
        } catch (Throwable t) {
            t.printStackTrace();
        // on error just return the initialized bad value conglom_id
        }
    } else {
    // during access boot this does not exist, assume for now that
    // is why we got here.  RESOLVE - it would be nice if we could
    // actuallly figure that is why we failed.
    /*
            System.out.println(
                "Could not find module for module: " + module);
            */
    }
    return (container_id);
}
Also used : TransactionController(org.apache.derby.iapi.store.access.TransactionController) AccessFactory(org.apache.derby.iapi.store.access.AccessFactory)

Example 8 with AccessFactory

use of org.apache.derby.iapi.store.access.AccessFactory 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 9 with AccessFactory

use of org.apache.derby.iapi.store.access.AccessFactory 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 10 with AccessFactory

use of org.apache.derby.iapi.store.access.AccessFactory 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)

Aggregations

AccessFactory (org.apache.derby.iapi.store.access.AccessFactory)14 TransactionController (org.apache.derby.iapi.store.access.TransactionController)11 StandardException (org.apache.derby.shared.common.error.StandardException)4 ContextManager (org.apache.derby.iapi.services.context.ContextManager)2 Properties (java.util.Properties)1 ContextService (org.apache.derby.iapi.services.context.ContextService)1 Diagnosticable (org.apache.derby.iapi.services.diag.Diagnosticable)1 LanguageConnectionContext (org.apache.derby.iapi.sql.conn.LanguageConnectionContext)1 ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)1 TransactionManager (org.apache.derby.iapi.store.access.conglomerate.TransactionManager)1 XAXactId (org.apache.derby.iapi.store.access.xa.XAXactId)1 RawStoreFactory (org.apache.derby.iapi.store.raw.RawStoreFactory)1 ShutdownException (org.apache.derby.shared.common.error.ShutdownException)1