@Override protected LogRecordWrapper createParticipant(AbstractRecord rec, ParticipantStatus listType) { if (rec instanceof ExtendedResourceRecord) return new XAResourceRecordBean(this, rec, listType); return super.createParticipant(rec, listType); }
@Override public void register() { super.register(); // for each ExtendedResourceRecord see if there is a corresponding XARecoveryResource entry in the local store for (LogRecordWrapper participant : getParticipants()) { if (participant instanceof XAResourceRecordBean) { // this is an ExtendedResourceRecord XAResourceRecordBean xarrb = (XAResourceRecordBean) participant; // see if there is a corresponding JTSXAResourceRecordWrapper for this participant XARecoveryResourceMBean jtsxaResourceRecordWrapper = findJTSXAResourceRecordWrapper(xarrb); if (jtsxaResourceRecordWrapper != null && jtsxaResourceRecordWrapper instanceof JTSXAResourceRecordWrapper) xarrb.setJtsXAResourceRecord((JTSXAResourceRecordWrapper) jtsxaResourceRecordWrapper); } } } }
private HeuristicTestData getHeuristic() throws Exception { FailureXAResource failureXAResource = new FailureXAResource(FailureXAResource.FailLocation.commit); // generates a heuristic on commit TransactionImple tx = new TransactionImple(1000000000); XAResourceRecordBeanMBean resourceBean = getHeuristicMBean(osb, tx, failureXAResource); JTAActionBean txnMBean = getTransactionBean(osb, tx, true); Set<ObjectName> participants; String resourceBeanName; String txnBeanName; assertNotNull(txnMBean); assertNotNull(resourceBean); txnBeanName = String.format("jboss.jta:type=ObjectStore,itype=%s,uid=%s", txnMBean.type(), txnMBean.getId().replace(':', '_')); resourceBeanName = String.format("%s,puid=%s", txnBeanName, resourceBean.getId().replace(':', '_')); participants = JMXServer.getAgent().queryNames(resourceBeanName, null); assertEquals(1, participants.size()); return new HeuristicTestData(tx, failureXAResource, txnMBean, resourceBean, participants.iterator().next(), txnBeanName, resourceBeanName); }
/** * Test removing a transaction with heuristic participants fails if the ignores heuristics property is false */ @Test public void testTxnRemoveFails () throws Exception { // generate a heuristic HeuristicTestData hd = getHeuristic(); // ignore forget failures during MBean remove opertaions arjPropertyManager.getObjectStoreEnvironmentBean().setIgnoreMBeanHeuristics(false); // tell the heuristic resource to fail forget calls hd.setRefuseForget(true); // invoke the MBean remove operation on the transaction hd.txnMBean.remove(); osb.probe(); // verify that the txn is still instrumented assertEquals(1, hd.getTransactionObjectNames().size()); }
private XAResourceRecordBeanMBean getHeuristicMBean(ObjStoreBrowser osb, TransactionImple tx, FailureXAResource failureXAResource) throws Exception { generateHeuristic(tx, failureXAResource); osb.probe(); // there should be one MBean corresponding to the Transaction JTAActionBean actionBean = getTransactionBean(osb, tx, true); assertNotNull(actionBean); // and the transaction should contain only one participant (namely the FailureXAResource that generated the heuristic): Collection<LogRecordWrapper> participants = actionBean.getParticipants(); assertEquals(1, participants.size()); assertNotNull(failureXAResource.getXid()); LogRecordWrapper participant = participants.iterator().next(); assertTrue(participant.isHeuristic()); assertTrue(participant instanceof XAResourceRecordBeanMBean); return (XAResourceRecordBeanMBean) participant; } }
/** * Test removing a transaction with heuristic participants succeeds if the ignores heuristics property is true */ @Test public void testTxnRemovePasses () throws Exception { // generate a heuristic HeuristicTestData hd = getHeuristic(); // ignore forget failures during MBean remove opertaions arjPropertyManager.getObjectStoreEnvironmentBean().setIgnoreMBeanHeuristics(true); // tell the heuristic resource to fail forget calls hd.setRefuseForget(true); // invoke the MBean remove operation on the transaction hd.txnMBean.remove(); osb.probe(); // verify that the txn is no longer instrumented assertEquals(0, hd.getTransactionObjectNames().size()); }