Search in sources :

Example 86 with WaitCriterion

use of org.apache.geode.test.dunit.WaitCriterion in project geode by apache.

the class MyFunctionException method disconnect.

public static void disconnect() {
    long startTime = System.currentTimeMillis();
    WaitCriterion wc = new WaitCriterion() {

        String excuse;

        public boolean done() {
            return false;
        }

        public String description() {
            return excuse;
        }
    };
    Wait.waitForCriterion(wc, 2000, 200, false);
    long endTime = System.currentTimeMillis();
    region.getCache().getLogger().fine("Time wait for Disconnecting = " + (endTime - startTime));
    cache.getDistributedSystem().disconnect();
}
Also used : WaitCriterion(org.apache.geode.test.dunit.WaitCriterion)

Example 87 with WaitCriterion

use of org.apache.geode.test.dunit.WaitCriterion in project geode by apache.

the class RoutingObject method verifyColocation.

private static void verifyColocation() {
    // TODO does having this WaitCriterion help?
    WaitCriterion wc = new WaitCriterion() {

        public boolean done() {
            return tryVerifyColocation();
        }

        public String description() {
            return excuse;
        }
    };
    Wait.waitForCriterion(wc, 2 * 60 * 1000, 1000, true);
}
Also used : WaitCriterion(org.apache.geode.test.dunit.WaitCriterion)

Example 88 with WaitCriterion

use of org.apache.geode.test.dunit.WaitCriterion in project geode by apache.

the class PRClientServerRegionFunctionExecutionSelectorNoSingleHopDUnitTest method verifyDeadAndLiveServers.

public static void verifyDeadAndLiveServers(final Integer expectedDeadServers, final Integer expectedLiveServers) {
    WaitCriterion wc = new WaitCriterion() {

        String excuse;

        public boolean done() {
            int sz = pool.getConnectedServerCount();
            LogWriterUtils.getLogWriter().info("Checking for the Live Servers : Expected  : " + expectedLiveServers + " Available :" + sz);
            if (sz == expectedLiveServers.intValue()) {
                return true;
            }
            excuse = "Expected " + expectedLiveServers.intValue() + " but found " + sz;
            return false;
        }

        public String description() {
            return excuse;
        }
    };
    Wait.waitForCriterion(wc, 3 * 60 * 1000, 1000, true);
}
Also used : WaitCriterion(org.apache.geode.test.dunit.WaitCriterion)

Example 89 with WaitCriterion

use of org.apache.geode.test.dunit.WaitCriterion in project geode by apache.

the class HAClientCountEventListener method checkNoEvents.

private CacheSerializableRunnable checkNoEvents(final int expectedEvents) {
    CacheSerializableRunnable checkEvents = new CacheSerializableRunnable("checkEvents") {

        // millis
        final int interval = 200;

        public void run2() throws CacheException {
            WaitCriterion w = new WaitCriterion() {

                public boolean done() {
                    synchronized (HAConflationDUnitTest.LOCK) {
                        if (!lastKeyArrived) {
                            try {
                                LOCK.wait(interval);
                            } catch (InterruptedException e) {
                                fail("interrupted");
                            }
                        }
                    }
                    return lastKeyArrived;
                }

                public String description() {
                    return "expected " + expectedEvents + " events but received " + actualNoEvents;
                }
            };
            Wait.waitForCriterion(w, 3 * 60 * 1000, interval, true);
        }
    };
    return checkEvents;
}
Also used : WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable)

Example 90 with WaitCriterion

use of org.apache.geode.test.dunit.WaitCriterion in project geode by apache.

the class Bug48571DUnitTest method verifyProxyHasBeenPaused.

private static void verifyProxyHasBeenPaused() {
    WaitCriterion criterion = new WaitCriterion() {

        @Override
        public boolean done() {
            CacheClientNotifier ccn = CacheClientNotifier.getInstance();
            Collection<CacheClientProxy> ccProxies = ccn.getClientProxies();
            Iterator<CacheClientProxy> itr = ccProxies.iterator();
            while (itr.hasNext()) {
                CacheClientProxy ccp = itr.next();
                System.out.println("proxy status " + ccp.getState());
                if (ccp.isPaused())
                    return true;
            }
            return false;
        }

        @Override
        public String description() {
            return "Proxy has not paused yet";
        }
    };
    Wait.waitForCriterion(criterion, 15 * 1000, 200, true);
}
Also used : CacheClientProxy(org.apache.geode.internal.cache.tier.sockets.CacheClientProxy) WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) CacheClientNotifier(org.apache.geode.internal.cache.tier.sockets.CacheClientNotifier)

Aggregations

WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)368 Test (org.junit.Test)132 Region (org.apache.geode.cache.Region)105 VM (org.apache.geode.test.dunit.VM)96 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)93 Host (org.apache.geode.test.dunit.Host)73 LocalRegion (org.apache.geode.internal.cache.LocalRegion)58 CacheException (org.apache.geode.cache.CacheException)57 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)53 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)50 AttributesFactory (org.apache.geode.cache.AttributesFactory)41 IgnoredException (org.apache.geode.test.dunit.IgnoredException)40 IOException (java.io.IOException)36 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)36 Cache (org.apache.geode.cache.Cache)34 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)34 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)33 Properties (java.util.Properties)31 AsyncInvocation (org.apache.geode.test.dunit.AsyncInvocation)28 Iterator (java.util.Iterator)27