Search in sources :

Example 1 with StabilityPredicate

use of com.oracle.bedrock.runtime.options.StabilityPredicate in project oracle-bedrock by coherence-community.

the class AbstractCoherenceClusterBuilderTest method shouldPerformRollingRestartOfCluster.

/**
 * Ensure we perform a rolling restart of a {@link CoherenceCluster}
 */
@Test
public void shouldPerformRollingRestartOfCluster() {
    final int CLUSTER_SIZE = 4;
    AvailablePortIterator availablePorts = LocalPlatform.get().getAvailablePorts();
    ClusterPort clusterPort = ClusterPort.of(new Capture<>(availablePorts));
    String clusterName = "Rolling" + getClass().getSimpleName();
    Platform platform = getPlatform();
    CoherenceClusterBuilder builder = new CoherenceClusterBuilder();
    builder.include(CLUSTER_SIZE, CoherenceClusterMember.class, DisplayName.of("DCS"), clusterPort, ClusterName.of(clusterName), LocalHost.only(), Console.system());
    try (CoherenceCluster cluster = builder.build(getPlatform())) {
        assertThat(invoking(cluster).getClusterSize(), is(CLUSTER_SIZE));
        StabilityPredicate<CoherenceCluster> predicate = StabilityPredicate.of(CoherenceCluster.Predicates.autoStartServicesSafe());
        cluster.filter(member -> member.isServiceRunning("ProxyService")).relaunch();
        cluster.unordered().limit(2).relaunch(predicate);
        assertThat(invoking(cluster).getClusterSize(), is(CLUSTER_SIZE));
        cluster.unordered().limit(2).relaunch(predicate);
        assertThat(invoking(cluster).getClusterSize(), is(CLUSTER_SIZE));
        cluster.unordered().limit(2).relaunch(predicate);
        assertThat(invoking(cluster).getClusterSize(), is(CLUSTER_SIZE));
        // introduce a new system property for the relaunched members
        cluster.relaunch(predicate, SystemProperty.of("cloned", "yes"));
        assertThat(invoking(cluster).getClusterSize(), is(CLUSTER_SIZE));
        // ensure all the members have the new system property
        for (CoherenceClusterMember member : cluster) {
            assertThat(member.getSystemProperty("cloned"), is("yes"));
        }
    }
}
Also used : WellKnownAddress(com.oracle.bedrock.runtime.coherence.options.WellKnownAddress) CoreMatchers.is(org.hamcrest.CoreMatchers.is) Decoration(com.oracle.bedrock.options.Decoration) ClusterName(com.oracle.bedrock.runtime.coherence.options.ClusterName) MachineName(com.oracle.bedrock.runtime.coherence.options.MachineName) StabilityPredicate(com.oracle.bedrock.runtime.options.StabilityPredicate) ClusterPort(com.oracle.bedrock.runtime.coherence.options.ClusterPort) CacheConfig(com.oracle.bedrock.runtime.coherence.options.CacheConfig) Capture(com.oracle.bedrock.util.Capture) HashSet(java.util.HashSet) LocalHost(com.oracle.bedrock.runtime.coherence.options.LocalHost) Console(com.oracle.bedrock.runtime.options.Console) AvailablePortIterator(com.oracle.bedrock.runtime.network.AvailablePortIterator) OptionsByType(com.oracle.bedrock.OptionsByType) NamedCache(com.tangosol.net.NamedCache) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) Trilean(com.oracle.bedrock.util.Trilean) LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) AbstractTest(com.oracle.bedrock.testsupport.junit.AbstractTest) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) LocalStorage(com.oracle.bedrock.runtime.coherence.options.LocalStorage) Test(org.junit.Test) SystemProperty(com.oracle.bedrock.runtime.java.options.SystemProperty) DeferredHelper.invoking(com.oracle.bedrock.deferred.DeferredHelper.invoking) Eventually.assertThat(com.oracle.bedrock.testsupport.deferred.Eventually.assertThat) Platform(com.oracle.bedrock.runtime.Platform) ApplicationListener(com.oracle.bedrock.runtime.ApplicationListener) DisplayName(com.oracle.bedrock.runtime.options.DisplayName) Matchers.greaterThan(org.hamcrest.Matchers.greaterThan) Assert(org.junit.Assert) LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) Platform(com.oracle.bedrock.runtime.Platform) AvailablePortIterator(com.oracle.bedrock.runtime.network.AvailablePortIterator) ClusterPort(com.oracle.bedrock.runtime.coherence.options.ClusterPort) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) AbstractTest(com.oracle.bedrock.testsupport.junit.AbstractTest) Test(org.junit.Test)

Aggregations

OptionsByType (com.oracle.bedrock.OptionsByType)1 DeferredHelper.invoking (com.oracle.bedrock.deferred.DeferredHelper.invoking)1 Decoration (com.oracle.bedrock.options.Decoration)1 ApplicationListener (com.oracle.bedrock.runtime.ApplicationListener)1 LocalPlatform (com.oracle.bedrock.runtime.LocalPlatform)1 Platform (com.oracle.bedrock.runtime.Platform)1 CacheConfig (com.oracle.bedrock.runtime.coherence.options.CacheConfig)1 ClusterName (com.oracle.bedrock.runtime.coherence.options.ClusterName)1 ClusterPort (com.oracle.bedrock.runtime.coherence.options.ClusterPort)1 LocalHost (com.oracle.bedrock.runtime.coherence.options.LocalHost)1 LocalStorage (com.oracle.bedrock.runtime.coherence.options.LocalStorage)1 MachineName (com.oracle.bedrock.runtime.coherence.options.MachineName)1 WellKnownAddress (com.oracle.bedrock.runtime.coherence.options.WellKnownAddress)1 SystemProperty (com.oracle.bedrock.runtime.java.options.SystemProperty)1 AvailablePortIterator (com.oracle.bedrock.runtime.network.AvailablePortIterator)1 Console (com.oracle.bedrock.runtime.options.Console)1 DisplayName (com.oracle.bedrock.runtime.options.DisplayName)1 StabilityPredicate (com.oracle.bedrock.runtime.options.StabilityPredicate)1 Eventually.assertThat (com.oracle.bedrock.testsupport.deferred.Eventually.assertThat)1 AbstractTest (com.oracle.bedrock.testsupport.junit.AbstractTest)1