use of org.apache.geode.cache30.CertifiableTestCacheListener in project geode by apache.
the class PartitionedRegionHAFailureAndRecoveryDUnitTest method validateNodeFailMetaDataCleanUp.
/**
* Returns CacheSerializableRunnable to validate the Failed node config metadata.
*
* @param dsMember Failed DistributedMember
*
* @return CacheSerializableRunnable
*/
private CacheSerializableRunnable validateNodeFailMetaDataCleanUp(final DistributedMember dsMember) {
SerializableRunnable validator = new CacheSerializableRunnable("validateNodeFailMetaDataCleanUp") {
public void run2() throws CacheException {
InternalCache cache = getCache();
Region rootReg = PartitionedRegionHelper.getPRRoot(cache);
CacheListener[] cls = rootReg.getAttributes().getCacheListeners();
assertEquals(2, cls.length);
CertifiableTestCacheListener ctcl = (CertifiableTestCacheListener) cls[1];
LogWriterUtils.getLogWriter().info("Listener update (" + ctcl.updates.size() + "): " + ctcl.updates);
LogWriterUtils.getLogWriter().info("Listener destroy: (" + ctcl.destroys.size() + "): " + ctcl.destroys);
Iterator itrator = rootReg.keySet().iterator();
for (Iterator itr = itrator; itr.hasNext(); ) {
String prName = (String) itr.next();
ctcl.waitForUpdated(prName);
Object obj = rootReg.get(prName);
if (obj != null) {
PartitionRegionConfig prConf = (PartitionRegionConfig) obj;
Set<Node> nodeList = prConf.getNodes();
Iterator itr2 = nodeList.iterator();
while (itr2.hasNext()) {
DistributedMember member = ((Node) itr2.next()).getMemberId();
if (member.equals(dsMember)) {
fail("Failed DistributedMember's = " + member + " global meta data not cleared. For PR Region = " + prName);
}
}
}
}
}
};
return (CacheSerializableRunnable) validator;
}
use of org.apache.geode.cache30.CertifiableTestCacheListener in project geode by apache.
the class PartitionedRegionHAFailureAndRecoveryDUnitTest method clearConfigListenerState.
private void clearConfigListenerState(VM[] vmsToClear) {
final SerializableRunnable clearListener = new SerializableRunnable("clear the listener state") {
private static final long serialVersionUID = 1L;
public void run() {
try {
InternalCache cache = getCache();
Region rootReg = PartitionedRegionHelper.getPRRoot(cache);
CacheListener[] cls = rootReg.getAttributes().getCacheListeners();
assertEquals(2, cls.length);
CertifiableTestCacheListener ctcl = (CertifiableTestCacheListener) cls[1];
ctcl.clearState();
} catch (CancelException possible) {
// If a member has been disconnected, we may get a CancelException
// in which case the config listener state has been cleared (in a big way)
}
}
};
for (int count = 0; count < vmsToClear.length; count++) {
VM vm = vmsToClear[count];
vm.invoke(clearListener);
}
}
use of org.apache.geode.cache30.CertifiableTestCacheListener in project geode by apache.
the class PartitionedRegionHAFailureAndRecoveryDUnitTest method addConfigListeners.
private void addConfigListeners() {
final SerializableRunnable addListener = new SerializableRunnable("add PRConfig listener") {
private static final long serialVersionUID = 1L;
public void run() {
InternalCache cache = (InternalCache) getCache();
Region rootReg = PartitionedRegionHelper.getPRRoot(cache);
rootReg.getAttributesMutator().addCacheListener(new CertifiableTestCacheListener(LogWriterUtils.getLogWriter()));
}
};
for (int count = 0; count < this.vmArr.length; count++) {
VM vm = this.vmArr[count];
vm.invoke(addListener);
}
}
Aggregations