Skip to content

Commit 12a15ad

Browse files
committed
Revert "JBTM-3859 clear MBean cache before probing"
This reverts commit dc720aa.
1 parent 2773d02 commit 12a15ad

File tree

2 files changed

+45
-28
lines changed

2 files changed

+45
-28
lines changed

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

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,34 @@ public void setExposeAllRecordsAsMBeans(boolean exposeAllLogs) {
476476
this.exposeAllLogs = exposeAllLogs;
477477
}
478478

479+
/**
480+
* Update registered MBeans based on the current set of Uids.
481+
* @param allCurrUids any registered MBeans not in this collection will be deregistered
482+
*/
483+
private void unregisterRemovedUids(Map<String, Collection<Uid>> allCurrUids) {
484+
485+
for (Map.Entry<String, List<UidWrapper>> e : registeredMBeans.entrySet()) {
486+
String type = e.getKey();
487+
List<UidWrapper> registeredBeansOfType = e.getValue();
488+
Collection<Uid> currUidsOfType = allCurrUids.get(type);
489+
490+
if (currUidsOfType != null) {
491+
Iterator<UidWrapper> iterator = registeredBeansOfType.iterator();
492+
493+
while (iterator.hasNext()) {
494+
UidWrapper w = iterator.next();
495+
496+
if (!currUidsOfType.contains(w.getUid())) {
497+
w.unregister();
498+
iterator.remove();
499+
}
500+
}
501+
} else {
502+
unregisterMBeans(registeredBeansOfType);
503+
}
504+
}
505+
}
506+
479507
/**
480508
* See if any new MBeans need to be registered or if any existing MBeans no longer exist
481509
* as ObjectStore entries.
@@ -485,12 +513,12 @@ public void setExposeAllRecordsAsMBeans(boolean exposeAllLogs) {
485513
public synchronized void probe() throws MBeanException {
486514
Map<String, Collection<Uid>> currUidsForType = new HashMap<>();
487515

488-
// recreate every MBean so clear the cache first
489-
unregisterMBeans();
490-
491516
for (String type : getTypes())
492517
currUidsForType.put(type, getUids(type));
493518

519+
// if there are any beans in registeredMBeans that don't appear in new list and unregister them
520+
unregisterRemovedUids(currUidsForType); //unregisterMBeans();
521+
494522
for (Map.Entry<String, Collection<Uid>> e : currUidsForType.entrySet()) {
495523
String type = e.getKey();
496524

ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/tools/ObjStoreBrowserTest.java

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
import com.arjuna.ats.arjuna.coordinator.RecordType;
4040
import com.arjuna.ats.arjuna.coordinator.abstractrecord.RecordTypeManager;
4141
import com.arjuna.ats.arjuna.coordinator.abstractrecord.RecordTypeMap;
42+
import com.arjuna.ats.arjuna.recovery.RecoveryDriver;
43+
import com.arjuna.ats.arjuna.recovery.RecoveryManager;
4244
import com.arjuna.ats.arjuna.tools.osb.mbean.ActionBean;
4345
import com.arjuna.ats.arjuna.tools.osb.mbean.LogRecordWrapper;
4446
import com.arjuna.ats.arjuna.tools.osb.mbean.OSEntryBean;
@@ -50,8 +52,6 @@
5052
import com.arjuna.ats.internal.arjuna.recovery.RecoveryManagerImple;
5153
import com.hp.mwtests.ts.arjuna.resources.CrashRecord;
5254

53-
import java.util.Collection;
54-
5555
/**
5656
* @deprecated as of 5.0.5.Final In a subsequent release we will change packages names in order to
5757
* provide a better separation between public and internal classes.
@@ -184,8 +184,15 @@ public void aaTest(boolean replay) throws Exception {
184184
osb.start();
185185
osb.probe();
186186

187-
// there should be one MBean corresponding to the AtomicAction A and the MBean should wrap an ActionBean
188-
ActionBean actionBean = lookupActionBean(osb, A.get_uid());
187+
// there should be one MBean corresponding to the AtomicAction A
188+
UidWrapper w = osb.findUid(A.get_uid());
189+
assertNotNull(w);
190+
OSEntryBean ai = w.getMBean();
191+
assertNotNull(ai);
192+
193+
// the MBean should wrap an ActionBean
194+
assertTrue(ai instanceof ActionBean);
195+
ActionBean actionBean = (ActionBean) ai;
189196

190197
// and there should be one MBean corresponding to the CrashRecord that got the heuristic:
191198
int recCount = 0;
@@ -206,16 +213,6 @@ public void aaTest(boolean replay) throws Exception {
206213

207214
assertEquals(1, recCount);
208215

209-
// verify that the state on disk is no longer a heuristic
210-
actionBean = lookupActionBean(osb, A.get_uid());
211-
Collection<LogRecordWrapper> participants = actionBean.getParticipants();
212-
213-
// there should be only the heuristic participant remaining:
214-
assertEquals(1, participants.size());
215-
LogRecordWrapper wrapper = actionBean.getParticipants().iterator().next();
216-
// and it should no longer be a heuristic
217-
assertFalse(wrapper.isHeuristic());
218-
219216
if (!replay) {
220217
actionBean.remove();
221218
} else {
@@ -233,21 +230,13 @@ public void aaTest(boolean replay) throws Exception {
233230
osb.probe();
234231

235232
// look up the MBean and verify that it no longer exists
236-
assertNull(osb.findUid(A.get_uid()));
233+
w = osb.findUid(A.get_uid());
234+
assertNull(w);
237235

236+
osb.dump(new StringBuilder());
238237
osb.stop();
239238
}
240239

241-
private ActionBean lookupActionBean(ObjStoreBrowser osb, Uid uid) {
242-
UidWrapper w = osb.findUid(uid);
243-
assertNotNull(w);
244-
OSEntryBean ai = w.getMBean();
245-
assertNotNull(ai);
246-
assertTrue(ai instanceof ActionBean);
247-
248-
return (ActionBean) ai;
249-
}
250-
251240
// define an MBean interface for use in the next test
252241
public interface NotAnotherMBean extends ObjStoreItemMBean {}
253242

0 commit comments

Comments
 (0)