Search in sources :

Example 26 with StopWatch

use of org.apache.geode.internal.util.StopWatch in project geode by apache.

the class ProcessStreamReaderTestCase method assertEventuallyFalse.

protected static void assertEventuallyFalse(final String message, final Callable<Boolean> callable, final int timeout, final int interval) throws Exception {
    boolean done = false;
    for (StopWatch time = new StopWatch(true); !done && time.elapsedTimeMillis() < timeout; done = (!callable.call())) {
        Thread.sleep(interval);
    }
    assertTrue(message + " within timeout of " + timeout + " milliseconds", done);
}
Also used : StopWatch(org.apache.geode.internal.util.StopWatch)

Example 27 with StopWatch

use of org.apache.geode.internal.util.StopWatch in project geode by apache.

the class ProcessStreamReaderTestCase method assertEventuallyTrue.

protected static void assertEventuallyTrue(final String message, final Callable<Boolean> callable, final int timeout, final int interval) throws Exception {
    boolean done = false;
    for (StopWatch time = new StopWatch(true); !done && time.elapsedTimeMillis() < timeout; done = (callable.call())) {
        Thread.sleep(interval);
    }
    assertTrue(message + " within timeout of " + timeout + " milliseconds", done);
}
Also used : StopWatch(org.apache.geode.internal.util.StopWatch)

Example 28 with StopWatch

use of org.apache.geode.internal.util.StopWatch in project geode by apache.

the class StatMonitorHandlerWithEnabledMonitorThreadTest method waitUntilWaiting.

private static void waitUntilWaiting(StatMonitorNotifier notifier) throws InterruptedException {
    boolean done = false;
    for (StopWatch time = new StopWatch(true); !done && time.elapsedTimeMillis() < 2000; done = (notifier.isWaiting())) {
        Thread.sleep(10);
    }
    assertTrue("waiting for notifier to be waiting", done);
}
Also used : StopWatch(org.apache.geode.internal.util.StopWatch)

Example 29 with StopWatch

use of org.apache.geode.internal.util.StopWatch in project geode by apache.

the class StatSamplerTestCase method assertStatValueDoesNotChange.

protected static void assertStatValueDoesNotChange(final Statistics statSamplerStats, final String statName, final int expectedStatValue, final long millis, final long sleep) {
    boolean done = false;
    try {
        for (StopWatch time = new StopWatch(true); !done && time.elapsedTimeMillis() < millis; done = (statSamplerStats.getInt(statName) != expectedStatValue)) {
            Thread.sleep(sleep);
        }
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
    }
    assertFalse("Waiting to assert that " + statName + " does not change from " + expectedStatValue, done);
}
Also used : StopWatch(org.apache.geode.internal.util.StopWatch)

Example 30 with StopWatch

use of org.apache.geode.internal.util.StopWatch in project geode by apache.

the class StatSamplerTestCase method waitForFileToExist.

protected static void waitForFileToExist(final File file, final long millis, final long sleep) {
    boolean done = false;
    try {
        for (StopWatch time = new StopWatch(true); !done && time.elapsedTimeMillis() < millis; done = (file.exists())) {
            Thread.sleep(sleep);
        }
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
    }
    assertTrue("Waiting for file to exist: " + file, done);
}
Also used : StopWatch(org.apache.geode.internal.util.StopWatch)

Aggregations

StopWatch (org.apache.geode.internal.util.StopWatch)37 Test (org.junit.Test)13 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)9 ClientServerTest (org.apache.geode.test.junit.categories.ClientServerTest)4 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)4 File (java.io.File)3 IOException (java.io.IOException)3 Properties (java.util.Properties)2 TimeoutException (java.util.concurrent.TimeoutException)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Statistics (org.apache.geode.Statistics)2 Region (org.apache.geode.cache.Region)2 FailureTracker (org.apache.geode.cache.client.internal.ServerBlackList.FailureTracker)2 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)2 ServerLocation (org.apache.geode.distributed.internal.ServerLocation)2 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)2 MemberMXBean (org.apache.geode.management.MemberMXBean)2 CliMetaData (org.apache.geode.management.cli.CliMetaData)2 MXBeanProvider.getMemberMXBean (org.apache.geode.management.internal.cli.shell.MXBeanProvider.getMemberMXBean)2 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)2