Search in sources :

Example 21 with CertifiableTestCacheListener

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;
}
Also used : CertifiableTestCacheListener(org.apache.geode.cache30.CertifiableTestCacheListener) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) CacheListener(org.apache.geode.cache.CacheListener) CertifiableTestCacheListener(org.apache.geode.cache30.CertifiableTestCacheListener) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) Iterator(java.util.Iterator) DistributedMember(org.apache.geode.distributed.DistributedMember) Region(org.apache.geode.cache.Region)

Example 22 with CertifiableTestCacheListener

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);
    }
}
Also used : CertifiableTestCacheListener(org.apache.geode.cache30.CertifiableTestCacheListener) VM(org.apache.geode.test.dunit.VM) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) Region(org.apache.geode.cache.Region) CancelException(org.apache.geode.CancelException) CacheListener(org.apache.geode.cache.CacheListener) CertifiableTestCacheListener(org.apache.geode.cache30.CertifiableTestCacheListener)

Example 23 with CertifiableTestCacheListener

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);
    }
}
Also used : CertifiableTestCacheListener(org.apache.geode.cache30.CertifiableTestCacheListener) VM(org.apache.geode.test.dunit.VM) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) Region(org.apache.geode.cache.Region)

Aggregations

CertifiableTestCacheListener (org.apache.geode.cache30.CertifiableTestCacheListener)23 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)19 Region (org.apache.geode.cache.Region)14 VM (org.apache.geode.test.dunit.VM)14 Host (org.apache.geode.test.dunit.Host)12 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)12 Test (org.junit.Test)12 IOException (java.io.IOException)11 CacheException (org.apache.geode.cache.CacheException)11 ArrayList (java.util.ArrayList)9 List (java.util.List)9 LocalRegion (org.apache.geode.internal.cache.LocalRegion)9 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)9 CancelException (org.apache.geode.CancelException)6 Endpoint (org.apache.geode.cache.client.internal.Endpoint)6 ClientServerTest (org.apache.geode.test.junit.categories.ClientServerTest)6 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)6 NoAvailableServersException (org.apache.geode.cache.client.NoAvailableServersException)5 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)5 LinkedList (java.util.LinkedList)4