Search in sources :

Example 1 with RecoveryStoreProxy

use of com.arjuna.ats.arjuna.tools.osb.api.proxy.RecoveryStoreProxy in project wildfly by wildfly.

the class TransactionObjectStoreTestCase method testExposeAllLogs.

@Test
public void testExposeAllLogs() throws Exception {
    String serviceUrl = managementClient.getRemoteJMXURL().toString();
    try {
        RecoveryStoreProxy prs = StoreManagerProxy.getRecoveryStore(serviceUrl, null);
        // this immediately checks whether we really got a store manager proxy or not
        assertNotNull(prs.getStoreName());
        // write a log record to the object store
        // create a record that by default the tooling does not expose
        byte[] data = new byte[10240];
        OutputObjectState state = new OutputObjectState();
        Uid uid = new Uid();
        state.packBytes(data);
        assertTrue(prs.write_committed(uid, FOO_TYPE, state));
        // probe the log store
        cli.sendLine("/subsystem=transactions/log-store=log-store:write-attribute(name=expose-all-logs,value=false)");
        cli.sendLine("/subsystem=transactions/log-store=log-store:probe()");
        // check the log record is not listed
        cli.sendLine("cd /subsystem=transactions/log-store=log-store/transactions");
        cli.sendLine("ls");
        String ls = cli.readOutput();
        assertFalse("Unexpected uid in the log.", ls != null && ls.contains(uid.toString()));
        // probe the log store again for all records
        cli.sendLine("/subsystem=transactions/log-store=log-store:write-attribute(name=expose-all-logs,value=true)");
        cli.sendLine("/subsystem=transactions/log-store=log-store:probe()");
        // check the log record is listed
        cli.sendLine("cd /subsystem=transactions/log-store=log-store/transactions");
        cli.sendLine("ls");
        ls = cli.readOutput();
        assertTrue("Could not find the expected uid in the log.", ls != null && ls.contains(uid.toString()));
        // remove the log record
        cli.sendLine("/subsystem=transactions/log-store=log-store/transactions=" + escapeColons(uid.toString()) + ":delete()");
        // probe the log store again
        cli.sendLine("/subsystem=transactions/log-store=log-store:probe()");
        // check the log record is not listed
        cli.sendLine("cd /subsystem=transactions/log-store=log-store/transactions");
        cli.sendLine("ls");
        ls = cli.readOutput();
        assertFalse("Unexpected uid in the log after its remove.", ls != null && ls.contains(uid.toString()));
        // set back the expose-all-logs attribute
        cli.sendLine("/subsystem=transactions/log-store=log-store:write-attribute(name=expose-all-logs,value=false)");
    } finally {
        StoreManagerProxy.releaseProxy(serviceUrl);
    }
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) RecoveryStoreProxy(com.arjuna.ats.arjuna.tools.osb.api.proxy.RecoveryStoreProxy) Test(org.junit.Test)

Aggregations

Uid (com.arjuna.ats.arjuna.common.Uid)1 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)1 RecoveryStoreProxy (com.arjuna.ats.arjuna.tools.osb.api.proxy.RecoveryStoreProxy)1 Test (org.junit.Test)1