Search in sources :

Example 1 with RawStoreFactory

use of org.apache.derby.iapi.store.raw.RawStoreFactory in project derby by apache.

the class D_DiagnosticUtil method diag_dump_page.

/**
 * Dump raw contents of a page.
 * <p>
 * A utility routine that can be called from an ij session that will
 * dump the raw contents of a page, in the raw store dump format.
 *
 * @param db_name       name of the database
 * @param segmentid     segmentid of the table (usually 0)
 * @param containerid   containerid of the table (not conglomid)
 * @param pagenumber    pagenumber of page to dump.
 */
public static void diag_dump_page(String db_name, long segmentid, long containerid, long pagenumber) {
    Transaction xact = null;
    try {
        Object module = getModuleFromDbName(db_name);
        RawStoreFactory store_module = (RawStoreFactory) findServiceModule(module, RawStoreFactory.MODULE);
        xact = store_module.startInternalTransaction(FileContainer.getContextService().getCurrentContextManager());
        ContainerKey id = new ContainerKey(segmentid, containerid);
        ContainerHandle container = xact.openContainer(id, ContainerHandle.MODE_READONLY);
        Page page = container.getPage(pagenumber);
        if (page != null) {
            System.out.println(page.toString());
            page.unlatch();
        } else {
            System.out.println("page " + pagenumber + " not found");
        }
        xact.abort();
        xact.close();
        xact = null;
    } catch (StandardException se) {
        se.printStackTrace();
    } finally {
        if (xact != null) {
            try {
                xact.abort();
                xact.close();
            } catch (StandardException se) {
            }
        }
    }
}
Also used : StandardException(org.apache.derby.shared.common.error.StandardException) Transaction(org.apache.derby.iapi.store.raw.Transaction) Page(org.apache.derby.iapi.store.raw.Page) ContainerKey(org.apache.derby.iapi.store.raw.ContainerKey) RawStoreFactory(org.apache.derby.iapi.store.raw.RawStoreFactory) ContainerHandle(org.apache.derby.iapi.store.raw.ContainerHandle)

Example 2 with RawStoreFactory

use of org.apache.derby.iapi.store.raw.RawStoreFactory in project derby by apache.

the class T_AccessFactory method flush_cache.

/*
	** Methods of T_AccessFactory.
	*/
private void flush_cache() throws StandardException {
    // flush and empty cache to make sure rereading stuff works.
    RawStoreFactory rawstore = (RawStoreFactory) findServiceModule(this.store, RawStoreFactory.MODULE);
    rawstore.checkpoint();
}
Also used : RawStoreFactory(org.apache.derby.iapi.store.raw.RawStoreFactory)

Example 3 with RawStoreFactory

use of org.apache.derby.iapi.store.raw.RawStoreFactory in project derby by apache.

the class T_CreateConglomRet method t_005.

/**
 * Test Branch splits - number of rows necessary to cause splits is raw
 * store implementation dependant (currently 5 rows per page in in-memory
 * implementation).
 *
 * @exception  StandardException  Standard exception policy.
 * @exception  T_Fail  Throws T_Fail on any test failure.
 */
protected boolean t_005(TransactionController tc) throws StandardException, T_Fail {
    boolean ret_val = true;
    REPORT("Starting t_005");
    T_CreateConglomRet create_ret = new T_CreateConglomRet();
    createCongloms(tc, 2, false, false, 0, create_ret);
    // Open the base conglomerate.
    ConglomerateController base_cc = tc.openConglomerate(create_ret.base_conglomid, false, TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE);
    // Open the index conglomerate.
    ConglomerateController index_cc = tc.openConglomerate(create_ret.index_conglomid, false, TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE);
    // Create a row.
    T_SecondaryIndexRow index_row = new T_SecondaryIndexRow();
    RowLocation rowloc = base_cc.newRowLocationTemplate();
    DataValueDescriptor[] base_row = TemplateRow.newU8Row(2);
    index_row.init(base_row, rowloc, 3);
    // insert them in reverse order just to make sure btree is sorting them
    for (int i = 200; i >= 0; i -= 4) {
        ((SQLLongint) base_row[0]).setValue(1);
        ((SQLLongint) base_row[1]).setValue(i);
        base_cc.insertAndFetchLocation(base_row, rowloc);
        if (index_cc.insert(index_row.getRow()) != 0)
            throw T_Fail.testFailMsg("insert failed");
    }
    for (int i = 199; i >= 0; i -= 4) {
        ((SQLLongint) base_row[0]).setValue(1);
        ((SQLLongint) base_row[1]).setValue(i);
        base_cc.insertAndFetchLocation(base_row, rowloc);
        if (index_cc.insert(index_row.getRow()) != 0)
            throw T_Fail.testFailMsg("insert failed");
    }
    index_cc.checkConsistency();
    // Close the conglomerate.
    index_cc.close();
    tc.commit();
    // Search for each of the keys and delete them one at a time.
    DataValueDescriptor[] delete_key = TemplateRow.newU8Row(2);
    for (int i = 200; i >= 0; i -= 4) {
        ((SQLLongint) delete_key[0]).setValue(1);
        ((SQLLongint) delete_key[1]).setValue(i);
        if (!t_delete(tc, create_ret.index_conglomid, delete_key, false)) {
            ret_val = false;
        }
    }
    for (int i = 199; i >= 0; i -= 4) {
        ((SQLLongint) delete_key[0]).setValue(1);
        ((SQLLongint) delete_key[1]).setValue(i);
        if (!t_delete(tc, create_ret.index_conglomid, delete_key, false)) {
            ret_val = false;
        }
    }
    tc.commit();
    // Open the base conglomerate.
    base_cc = tc.openConglomerate(create_ret.base_conglomid, false, TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE);
    // Open the conglomerate.
    index_cc = tc.openConglomerate(create_ret.index_conglomid, false, TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE);
    // flush and empty cache to make sure rereading stuff works.
    RawStoreFactory rawstore = (RawStoreFactory) findServiceModule(this.store_module, RawStoreFactory.MODULE);
    rawstore.idle();
    for (int i = 200; i >= 0; i -= 3) {
        ((SQLLongint) base_row[0]).setValue(1);
        ((SQLLongint) base_row[1]).setValue(i);
        base_cc.insertAndFetchLocation(base_row, rowloc);
        if (index_cc.insert(index_row.getRow()) != 0)
            throw T_Fail.testFailMsg("insert failed");
    }
    for (int i = 200; i >= 0; i -= 3) {
        ((SQLLongint) delete_key[0]).setValue(1);
        ((SQLLongint) delete_key[1]).setValue(i);
        if (!t_delete(tc, create_ret.index_conglomid, delete_key, false)) {
            ret_val = false;
        }
    }
    // index check - there should be no records left.
    ScanController empty_scan = tc.openScan(create_ret.index_conglomid, false, 0, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE, (FormatableBitSet) null, null, ScanController.NA, null, null, ScanController.NA);
    if (empty_scan.next())
        throw T_Fail.testFailMsg("t_005: there are still rows in table.");
    index_cc.checkConsistency();
    for (int i = 600; i >= 400; i -= 3) {
        ((SQLLongint) base_row[0]).setValue(1);
        ((SQLLongint) base_row[1]).setValue(i);
        base_cc.insertAndFetchLocation(base_row, rowloc);
        if (index_cc.insert(index_row.getRow()) != 0)
            throw T_Fail.testFailMsg("insert failed");
    }
    index_cc.checkConsistency();
    tc.abort();
    // index check - there should be no records left.
    empty_scan = tc.openScan(create_ret.index_conglomid, false, 0, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE, (FormatableBitSet) null, null, ScanController.NA, null, null, ScanController.NA);
    if (empty_scan.next())
        throw T_Fail.testFailMsg("t_005: there are still rows in table.");
    REPORT("Ending t_005");
    return (ret_val);
}
Also used : ScanController(org.apache.derby.iapi.store.access.ScanController) ConglomerateController(org.apache.derby.iapi.store.access.ConglomerateController) SQLLongint(org.apache.derby.iapi.types.SQLLongint) FormatableBitSet(org.apache.derby.iapi.services.io.FormatableBitSet) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) RowLocation(org.apache.derby.iapi.types.RowLocation) SQLLongint(org.apache.derby.iapi.types.SQLLongint) RawStoreFactory(org.apache.derby.iapi.store.raw.RawStoreFactory)

Example 4 with RawStoreFactory

use of org.apache.derby.iapi.store.raw.RawStoreFactory in project derby by apache.

the class CacheLock method bootPasswordChange.

private boolean bootPasswordChange(TransactionController tc, String key, Serializable value) throws StandardException {
    // boot password in clear text
    if (key.equals(Attribute.BOOT_PASSWORD)) {
        // The user is trying to change the secret key.
        // The secret key is never stored in clear text, but we
        // store the encrypted form in the services.properties
        // file.  Swap the secret key with the encrypted form and
        // put that in the services.properties file.
        AccessFactory af = ((TransactionManager) tc).getAccessManager();
        RawStoreFactory rsf = (RawStoreFactory) findServiceModule(af, RawStoreFactory.MODULE);
        // remove secret key from properties list if possible
        serviceProperties.remove(Attribute.BOOT_PASSWORD);
        value = rsf.changeBootPassword(serviceProperties, value);
        serviceProperties.put(RawStoreFactory.ENCRYPTED_KEY, value);
        return true;
    } else {
        return false;
    }
}
Also used : TransactionManager(org.apache.derby.iapi.store.access.conglomerate.TransactionManager) AccessFactory(org.apache.derby.iapi.store.access.AccessFactory) RawStoreFactory(org.apache.derby.iapi.store.raw.RawStoreFactory)

Aggregations

RawStoreFactory (org.apache.derby.iapi.store.raw.RawStoreFactory)4 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)1 AccessFactory (org.apache.derby.iapi.store.access.AccessFactory)1 ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)1 ScanController (org.apache.derby.iapi.store.access.ScanController)1 TransactionManager (org.apache.derby.iapi.store.access.conglomerate.TransactionManager)1 ContainerHandle (org.apache.derby.iapi.store.raw.ContainerHandle)1 ContainerKey (org.apache.derby.iapi.store.raw.ContainerKey)1 Page (org.apache.derby.iapi.store.raw.Page)1 Transaction (org.apache.derby.iapi.store.raw.Transaction)1 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)1 RowLocation (org.apache.derby.iapi.types.RowLocation)1 SQLLongint (org.apache.derby.iapi.types.SQLLongint)1 StandardException (org.apache.derby.shared.common.error.StandardException)1