Search in sources :

Example 1 with JMXServer

use of com.arjuna.ats.arjuna.tools.osb.util.JMXServer in project narayana by jbosstm.

the class ExposeAllLogsTest method test.

private void test(boolean exposeAllLogsViaJMX) throws Exception {
    RecoveryStore store = StoreManager.getRecoveryStore();
    Set<Uid> uids;
    Map<Uid, ObjectName> uids2 = new HashMap<Uid, ObjectName>();
    JMXServer agent = JMXServer.getAgent();
    // create a record that by default the tooling does not expose
    byte[] data = new byte[10240];
    OutputObjectState state = new OutputObjectState();
    Uid u = new Uid();
    state.packBytes(data);
    assertTrue(store.write_committed(u, FOO_TYPE, state));
    // check that the record is not exposed
    probeObjectStore(false, false);
    // get uids via the object store API
    uids = getUids(store, new HashSet<Uid>(), FOO_TYPE);
    // and validate that there is a uid corresponding to u
    assertTrue(uids.contains(u));
    // get uids via JMX
    getUids(uids2, agent.queryNames(osMBeanName + ",*", null));
    // and validate that there is no MBean corresponding to u
    assertFalse(uids2.containsKey(u));
    // now try the same but tell the browser to expose all log records
    probeObjectStore(true, exposeAllLogsViaJMX);
    // and get the uids for log record MBeans
    uids2.clear();
    getUids(uids2, agent.queryNames(osMBeanName + ",*", null));
    // and validate that there is now an MBean corresponding to u
    assertTrue(uids2.containsKey(u));
    // test that the MBean remove operation works
    agent.getServer().invoke(uids2.get(u), "remove", null, null);
    // check that both the log record and the MBean were removed
    uids.clear();
    getUids(store, uids, FOO_TYPE);
    assertFalse(uids.contains(u));
    uids2.clear();
    getUids(uids2, agent.queryNames(osMBeanName + ",*", null));
    assertFalse(uids2.containsKey(u));
}
Also used : Uid(com.arjuna.ats.arjuna.common.Uid) HashMap(java.util.HashMap) JMXServer(com.arjuna.ats.arjuna.tools.osb.util.JMXServer) OutputObjectState(com.arjuna.ats.arjuna.state.OutputObjectState) RecoveryStore(com.arjuna.ats.arjuna.objectstore.RecoveryStore) ObjectName(javax.management.ObjectName) HashSet(java.util.HashSet)

Aggregations

Uid (com.arjuna.ats.arjuna.common.Uid)1 RecoveryStore (com.arjuna.ats.arjuna.objectstore.RecoveryStore)1 OutputObjectState (com.arjuna.ats.arjuna.state.OutputObjectState)1 JMXServer (com.arjuna.ats.arjuna.tools.osb.util.JMXServer)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 ObjectName (javax.management.ObjectName)1