Skip to content

Commit 51f637f

Browse files
committed
Revert "JBTM-3859 MBean for JTA transaction heuristics is imprecise"
1 parent 12a15ad commit 51f637f

File tree

3 files changed

+27
-125
lines changed

3 files changed

+27
-125
lines changed

ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/logging/arjunaI18NLogger.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,10 +1634,6 @@ public void warn_objectstore_JDBCImple_over_max_image_size(int imageSize,
16341634
@LogMessage(level = WARN)
16351635
void warn_invalidObjStoreBrowser_type(String type, @Cause Exception e);
16361636

1637-
@Message(id = 12407, value = "Skipping handler for bean type: '{0}'", format = MESSAGE_FORMAT)
1638-
@LogMessage(level = INFO)
1639-
void info_osbSkipHandler(String type);
1640-
16411637
/*
16421638
Allocate new messages directly above this notice.
16431639
- id: use the next id number in numeric sequence. Don't reuse ids.

ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/tools/osb/mbean/ObjStoreBrowser.java

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,6 @@ public class ObjStoreBrowser implements ObjStoreBrowserMBean {
8585
"StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction",
8686
null
8787
),
88-
// JTAActionBean overrides ActionBean when the ArjunaJTA module is present, as opposed to just ArjunaCore
89-
// on its own.
90-
// These handlers are iterated over and added to the osbTypeMap map using typeName as the key so,
91-
// to ensure that JTAActionBean is added to the map in JTA mode, please ensure that it appears
92-
// last in this collection so that it overwrites the previous value. An alternative could be to make
93-
// the beanClass field a comma separated list and the first one that is found to be known to the
94-
// class loader would be used, or a completely different design for the instrumentation could be chosen
95-
new OSBTypeHandler(
96-
true,
97-
"com.arjuna.ats.arjuna.AtomicAction",
98-
"com.arjuna.ats.internal.jta.tools.osb.mbean.jta.JTAActionBean",
99-
"StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction",
100-
null
101-
),
10288
};
10389

10490
private static final OSBTypeHandler[] defaultJTSOsbTypes = {
@@ -319,17 +305,8 @@ private void init(String logDir) {
319305
setExposeAllRecordsAsMBeans(arjPropertyManager.
320306
getObjectStoreEnvironmentBean().getExposeAllLogRecordsAsMBeans());
321307

322-
for (OSBTypeHandler osbType : defaultOsbTypes) {
323-
try {
324-
Class.forName(osbType.getBeanClass(), true, this.getClass().getClassLoader());
325-
osbTypeMap.put(osbType.getTypeName(), osbType);
326-
} catch (ClassNotFoundException ignore) {
327-
// Some record types (currently only StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction)
328-
// use different handlers depending upon whether ArjunaJTA is present. Ignore classes which
329-
// aren't present and log an info message
330-
tsLogger.i18NLogger.info_osbSkipHandler(osbType.getBeanClass());
331-
}
332-
}
308+
for (OSBTypeHandler osbType : defaultOsbTypes)
309+
osbTypeMap.put(osbType.getTypeName(), osbType);
333310

334311
for (OSBTypeHandler osbType : defaultJTSOsbTypes)
335312
osbTypeMap.put(osbType.getTypeName(), osbType);

ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/tools/ObjStoreBrowserTest.java

Lines changed: 25 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
11
package com.hp.mwtests.ts.jta.tools;
22

33
import static org.junit.Assert.assertEquals;
4+
import static org.junit.Assert.assertFalse;
45
import static org.junit.Assert.assertNotNull;
56
import static org.junit.Assert.assertNull;
67
import static org.junit.Assert.assertTrue;
78
import static org.junit.Assert.fail;
89

9-
import java.io.IOException;
1010
import java.util.Collection;
1111
import java.util.HashSet;
1212
import java.util.Set;
1313

1414
import javax.management.MBeanException;
1515
import javax.management.MalformedObjectNameException;
1616
import javax.management.ObjectName;
17-
18-
import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
19-
import com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord;
20-
import org.jboss.tm.XAResourceWrapper;
21-
import com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecordWrappingPlugin;
22-
import com.arjuna.ats.jta.common.JTAEnvironmentBean;
23-
import com.arjuna.ats.jta.common.jtaPropertyManager;
2417
import jakarta.transaction.HeuristicMixedException;
2518
import javax.transaction.xa.XAException;
2619
import javax.transaction.xa.XAResource;
@@ -52,13 +45,8 @@
5245
* provide a better separation between public and internal classes.
5346
*/
5447
@Deprecated // in order to provide a better separation between public and internal classes.
55-
class ExtendedFailureXAResource extends FailureXAResource implements XAResourceWrapper {
48+
class ExtendedFailureXAResource extends FailureXAResource {
5649
private boolean forgotten;
57-
private String productName;
58-
59-
public ExtendedFailureXAResource(FailLocation loc) {
60-
super(loc);
61-
}
6250

6351
@Override
6452
public void commit(Xid id, boolean onePhase) throws XAException {
@@ -71,35 +59,19 @@ public void forget(Xid xid) throws XAException {
7159
super.forget(xid);
7260
forgotten = true;
7361
}
74-
75-
@Override
76-
public XAResource getResource() {
77-
return null;
78-
}
79-
80-
public void setProductName(String productName) {
81-
this.productName = productName;
82-
}
83-
84-
@Override
85-
public String getProductName() {
86-
return productName;
87-
}
88-
89-
@Override
90-
public String getProductVersion() {
91-
return null;
92-
}
93-
94-
@Override
95-
public String getJndiName() {
96-
return null;
97-
}
9862
}
9963

10064
public class ObjStoreBrowserTest {
10165
private ObjStoreBrowser osb;
10266

67+
private ObjStoreBrowser createObjStoreBrowser() {
68+
ObjStoreBrowser osb = new ObjStoreBrowser();
69+
70+
osb.setType("com.arjuna.ats.arjuna.AtomicAction", "com.arjuna.ats.internal.jta.tools.osb.mbean.jta.JTAActionBean");
71+
72+
return osb;
73+
}
74+
10375
@BeforeClass
10476
public static void setUp() {
10577
}
@@ -135,16 +107,9 @@ public void testCommitMarkableResourceRecordBean() throws Exception {
135107
@Test
136108
public void testMBeanHeuristic () throws Exception
137109
{
138-
// generates a heuristic on commit
139-
ExtendedFailureXAResource failureXAResource =
140-
new ExtendedFailureXAResource(FailureXAResource.FailLocation.commit);
141-
String productName = "P";
142-
143-
failureXAResource.setProductName(productName);
144-
145-
XAResourceRecordBeanMBean mbean = getHeuristicMBean(osb, new TransactionImple(1000000000), failureXAResource);
110+
FailureXAResource failureXAResource = new FailureXAResource(FailureXAResource.FailLocation.commit); // generates a heuristic on commit
146111

147-
assertEquals(productName, mbean.getEisProductName());
112+
getHeuristicMBean(osb, new TransactionImple(1000000000), failureXAResource);
148113
}
149114

150115
/**
@@ -373,61 +338,25 @@ private JTAActionBean getTransactionBean(ObjStoreBrowser osb, TransactionImple t
373338
}
374339

375340
private XAResourceRecordBeanMBean getHeuristicMBean(ObjStoreBrowser osb, TransactionImple tx, FailureXAResource failureXAResource) throws Exception {
376-
// use the wrapper plugin because we'd also like to test resource metadata
377-
XAResourceRecordWrappingPlugin xarWrapperPlugin = new XAResourceRecordWrappingPlugin() {
378-
String productName = "";
379-
@Override
380-
public void transcribeWrapperData(XAResourceRecord xaResourceRecord) {
381-
final XAResource xaResource = (XAResource) xaResourceRecord.value();
382-
383-
if (xaResource instanceof XAResourceWrapper) {
384-
XAResourceWrapper xaResourceWrapper = (XAResourceWrapper) xaResource;
385-
productName = xaResourceWrapper.getProductName();
386-
387-
xaResourceRecord.setProductName(xaResourceWrapper.getProductName());
388-
xaResourceRecord.setProductVersion(xaResourceWrapper.getProductVersion());
389-
xaResourceRecord.setJndiName(xaResourceWrapper.getJndiName());
390-
}
391-
}
392-
393-
@Override
394-
public Integer getEISName(XAResource xaResource) throws IOException, ObjectStoreException {
395-
return 0;
396-
}
397-
398-
@Override
399-
public String getEISName(Integer eisName) {
400-
return productName;
401-
}
402-
};
403-
404-
JTAEnvironmentBean env = jtaPropertyManager.getJTAEnvironmentBean();
405-
XAResourceRecordWrappingPlugin prevWrappingPlugin = env.getXAResourceRecordWrappingPlugin();
341+
generateHeuristic(tx, failureXAResource);
406342

407-
try {
408-
env.setXAResourceRecordWrappingPlugin(xarWrapperPlugin);
409-
generateHeuristic(tx, failureXAResource);
410-
osb.probe();
411-
// there should be one MBean corresponding to the Transaction
412-
JTAActionBean actionBean = getTransactionBean(osb, tx, true);
343+
osb.probe();
344+
// there should be one MBean corresponding to the Transaction
345+
JTAActionBean actionBean = getTransactionBean(osb, tx, true);
413346

414-
assertNotNull(actionBean);
347+
assertNotNull(actionBean);
415348

416-
// and the transaction should contain only one participant
417-
// (namely the FailureXAResource that generated the heuristic):
418-
Collection<LogRecordWrapper> participants = actionBean.getParticipants();
349+
// and the transaction should contain only one participant (namely the FailureXAResource that generated the heuristic):
350+
Collection<LogRecordWrapper> participants = actionBean.getParticipants();
419351

420-
assertEquals(1, participants.size());
421-
assertNotNull(failureXAResource.getXid());
352+
assertEquals(1, participants.size());
353+
assertNotNull(failureXAResource.getXid());
422354

423-
LogRecordWrapper participant = participants.iterator().next();
355+
LogRecordWrapper participant = participants.iterator().next();
424356

425-
assertTrue(participant.isHeuristic());
426-
assertTrue(participant instanceof XAResourceRecordBeanMBean);
357+
assertTrue(participant.isHeuristic());
358+
assertTrue(participant instanceof XAResourceRecordBeanMBean);
427359

428-
return (XAResourceRecordBeanMBean) participant;
429-
} finally {
430-
env.setXAResourceRecordWrappingPlugin(prevWrappingPlugin);
431-
}
360+
return (XAResourceRecordBeanMBean) participant;
432361
}
433362
}

0 commit comments

Comments
 (0)