Search in sources :

Example 1 with CoherenceCluster

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

the class SingleMemberCoherenceClusterResourceTest method shouldFormCorrectSizeCluster.

/**
 * Ensure that a single member cluster is formed by {@link CoherenceClusterResource}.
 */
@Test
public void shouldFormCorrectSizeCluster() {
    CoherenceCluster cluster = coherenceResource.getCluster();
    Set<String> setNames = new TreeSet<>();
    for (CoherenceClusterMember member : cluster) {
        setNames.add(member.getName());
    }
    assertThat(setNames, contains("storage-1"));
}
Also used : CoherenceClusterMember(com.oracle.bedrock.runtime.coherence.CoherenceClusterMember) TreeSet(java.util.TreeSet) CoherenceCluster(com.oracle.bedrock.runtime.coherence.CoherenceCluster) Test(org.junit.Test)

Example 2 with CoherenceCluster

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

the class CoherenceClusterResourceTest method shouldPerformRollingRestartWithStorageDisabledSession.

/**
 * Ensure that a {@link CoherenceClusterResource} can be used to perform a rolling restart
 * when there's a storage disabled session.
 */
@Test
public void shouldPerformRollingRestartWithStorageDisabledSession() throws Exception {
    CoherenceCluster cluster = coherenceResource.getCluster();
    ConfigurableCacheFactory cacheFactory = coherenceResource.createSession(new StorageDisabledMember());
    // only restart storage enabled members
    cluster.filter(member -> member.getName().startsWith("storage")).relaunch();
    CoherenceClusterMember member1 = cluster.get("storage-1");
    CoherenceClusterMember member2 = cluster.get("storage-2");
    assertThat(member1, is(notNullValue()));
    assertThat(member2, is(notNullValue()));
}
Also used : Multicast(com.oracle.bedrock.runtime.coherence.options.Multicast) RoleName(com.oracle.bedrock.runtime.coherence.options.RoleName) IsIterableContainingInOrder.contains(org.hamcrest.collection.IsIterableContainingInOrder.contains) CoherenceClusterMember(com.oracle.bedrock.runtime.coherence.CoherenceClusterMember) CoreMatchers.not(org.hamcrest.CoreMatchers.not) ClusterPort(com.oracle.bedrock.runtime.coherence.options.ClusterPort) CoherenceCluster(com.oracle.bedrock.runtime.coherence.CoherenceCluster) Capture(com.oracle.bedrock.util.Capture) TreeSet(java.util.TreeSet) Assert.assertThat(org.junit.Assert.assertThat) LocalHost(com.oracle.bedrock.runtime.coherence.options.LocalHost) Is.is(org.hamcrest.core.Is.is) ConfigurableCacheFactory(com.tangosol.net.ConfigurableCacheFactory) NamedCache(com.tangosol.net.NamedCache) LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) LocalStorage(com.oracle.bedrock.runtime.coherence.options.LocalStorage) Set(java.util.Set) Test(org.junit.Test) SystemProperty(com.oracle.bedrock.runtime.java.options.SystemProperty) DeferredHelper.invoking(com.oracle.bedrock.deferred.DeferredHelper.invoking) Rule(org.junit.Rule) IsNull.notNullValue(org.hamcrest.core.IsNull.notNullValue) DisplayName(com.oracle.bedrock.runtime.options.DisplayName) Assert(org.junit.Assert) Eventually(com.oracle.bedrock.testsupport.deferred.Eventually) CoherenceClusterMember(com.oracle.bedrock.runtime.coherence.CoherenceClusterMember) CoherenceCluster(com.oracle.bedrock.runtime.coherence.CoherenceCluster) ConfigurableCacheFactory(com.tangosol.net.ConfigurableCacheFactory) Test(org.junit.Test)

Example 3 with CoherenceCluster

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

the class CoherenceClusterExtensionTest method shouldPerformRollingRestart.

/**
 * Ensure that a {@link CoherenceClusterResource} can be used to perform a rolling restart.
 */
@Test
public void shouldPerformRollingRestart() throws Exception {
    CoherenceCluster cluster = coherenceResource.getCluster();
    int memberOneBefore = cluster.get("storage-1").getLocalMemberId();
    int memberTwoBefore = cluster.get("storage-2").getLocalMemberId();
    // only restart storage enabled members
    cluster.filter(member -> member.getName().startsWith("storage")).relaunch();
    CoherenceClusterMember memberOneAfter = cluster.get("storage-1");
    CoherenceClusterMember memberTwoAfter = cluster.get("storage-2");
    assertThat(memberOneAfter, is(notNullValue()));
    assertThat(memberTwoAfter, is(notNullValue()));
    assertThat(memberOneAfter.getLocalMemberId(), is(not(memberOneBefore)));
    assertThat(memberTwoAfter.getLocalMemberId(), is(not(memberTwoBefore)));
}
Also used : LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) Matchers.greaterThanOrEqualTo(org.hamcrest.Matchers.greaterThanOrEqualTo) IsIterableContainingInOrder.contains(org.hamcrest.collection.IsIterableContainingInOrder.contains) CoherenceClusterMember(com.oracle.bedrock.runtime.coherence.CoherenceClusterMember) CoreMatchers.not(org.hamcrest.CoreMatchers.not) Set(java.util.Set) com.oracle.bedrock.runtime.coherence.options(com.oracle.bedrock.runtime.coherence.options) SystemProperty(com.oracle.bedrock.runtime.java.options.SystemProperty) CoherenceCluster(com.oracle.bedrock.runtime.coherence.CoherenceCluster) Capture(com.oracle.bedrock.util.Capture) TreeSet(java.util.TreeSet) DeferredHelper.invoking(com.oracle.bedrock.deferred.DeferredHelper.invoking) Test(org.junit.jupiter.api.Test) RegisterExtension(org.junit.jupiter.api.extension.RegisterExtension) IsNull.notNullValue(org.hamcrest.core.IsNull.notNullValue) Is.is(org.hamcrest.core.Is.is) DisplayName(com.oracle.bedrock.runtime.options.DisplayName) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) ConfigurableCacheFactory(com.tangosol.net.ConfigurableCacheFactory) Eventually(com.oracle.bedrock.testsupport.deferred.Eventually) NamedCache(com.tangosol.net.NamedCache) CoherenceClusterMember(com.oracle.bedrock.runtime.coherence.CoherenceClusterMember) CoherenceCluster(com.oracle.bedrock.runtime.coherence.CoherenceCluster) Test(org.junit.jupiter.api.Test)

Example 4 with CoherenceCluster

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

the class CoherenceClusterResourceTest method shouldPerformRollingRestart.

/**
 * Ensure that a {@link CoherenceClusterResource} can be used to perform a rolling restart.
 */
@Test
public void shouldPerformRollingRestart() throws Exception {
    CoherenceCluster cluster = coherenceResource.getCluster();
    // only restart storage enabled members
    cluster.filter(member -> member.getName().startsWith("storage")).relaunch();
    CoherenceClusterMember member1 = cluster.get("storage-1");
    CoherenceClusterMember member2 = cluster.get("storage-2");
    assertThat(member1, is(notNullValue()));
    assertThat(member2, is(notNullValue()));
    assertThat(member1.getLocalMemberId(), is(4));
    assertThat(member2.getLocalMemberId(), is(5));
}
Also used : Multicast(com.oracle.bedrock.runtime.coherence.options.Multicast) RoleName(com.oracle.bedrock.runtime.coherence.options.RoleName) IsIterableContainingInOrder.contains(org.hamcrest.collection.IsIterableContainingInOrder.contains) CoherenceClusterMember(com.oracle.bedrock.runtime.coherence.CoherenceClusterMember) CoreMatchers.not(org.hamcrest.CoreMatchers.not) ClusterPort(com.oracle.bedrock.runtime.coherence.options.ClusterPort) CoherenceCluster(com.oracle.bedrock.runtime.coherence.CoherenceCluster) Capture(com.oracle.bedrock.util.Capture) TreeSet(java.util.TreeSet) Assert.assertThat(org.junit.Assert.assertThat) LocalHost(com.oracle.bedrock.runtime.coherence.options.LocalHost) Is.is(org.hamcrest.core.Is.is) ConfigurableCacheFactory(com.tangosol.net.ConfigurableCacheFactory) NamedCache(com.tangosol.net.NamedCache) LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) LocalStorage(com.oracle.bedrock.runtime.coherence.options.LocalStorage) Set(java.util.Set) Test(org.junit.Test) SystemProperty(com.oracle.bedrock.runtime.java.options.SystemProperty) DeferredHelper.invoking(com.oracle.bedrock.deferred.DeferredHelper.invoking) Rule(org.junit.Rule) IsNull.notNullValue(org.hamcrest.core.IsNull.notNullValue) DisplayName(com.oracle.bedrock.runtime.options.DisplayName) Assert(org.junit.Assert) Eventually(com.oracle.bedrock.testsupport.deferred.Eventually) CoherenceClusterMember(com.oracle.bedrock.runtime.coherence.CoherenceClusterMember) CoherenceCluster(com.oracle.bedrock.runtime.coherence.CoherenceCluster) Test(org.junit.Test)

Example 5 with CoherenceCluster

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

the class CoherenceClusterResourceTest method shouldFormCluster.

/**
 * Ensure that the required cluster is formed by a {@link CoherenceClusterResource}.
 */
@Test
public void shouldFormCluster() {
    // ensure the size of the cluster is as expected
    Assert.assertThat(coherenceResource.getCluster().getClusterSize(), is(3));
    // collect the names of the members
    CoherenceCluster cluster = coherenceResource.getCluster();
    Set<String> setNames = new TreeSet<>();
    for (CoherenceClusterMember member : cluster) {
        setNames.add(member.getName());
    }
    // ensure the names of the cluster members are as expected
    assertThat(setNames, contains("proxy-1", "storage-1", "storage-2"));
}
Also used : CoherenceClusterMember(com.oracle.bedrock.runtime.coherence.CoherenceClusterMember) TreeSet(java.util.TreeSet) CoherenceCluster(com.oracle.bedrock.runtime.coherence.CoherenceCluster) Test(org.junit.Test)

Aggregations

CoherenceCluster (com.oracle.bedrock.runtime.coherence.CoherenceCluster)7 CoherenceClusterMember (com.oracle.bedrock.runtime.coherence.CoherenceClusterMember)7 TreeSet (java.util.TreeSet)7 DeferredHelper.invoking (com.oracle.bedrock.deferred.DeferredHelper.invoking)4 LocalPlatform (com.oracle.bedrock.runtime.LocalPlatform)4 SystemProperty (com.oracle.bedrock.runtime.java.options.SystemProperty)4 DisplayName (com.oracle.bedrock.runtime.options.DisplayName)4 Eventually (com.oracle.bedrock.testsupport.deferred.Eventually)4 Capture (com.oracle.bedrock.util.Capture)4 ConfigurableCacheFactory (com.tangosol.net.ConfigurableCacheFactory)4 NamedCache (com.tangosol.net.NamedCache)4 Set (java.util.Set)4 CoreMatchers.not (org.hamcrest.CoreMatchers.not)4 IsIterableContainingInOrder.contains (org.hamcrest.collection.IsIterableContainingInOrder.contains)4 Is.is (org.hamcrest.core.Is.is)4 IsNull.notNullValue (org.hamcrest.core.IsNull.notNullValue)4 Test (org.junit.Test)4 Test (org.junit.jupiter.api.Test)3 com.oracle.bedrock.runtime.coherence.options (com.oracle.bedrock.runtime.coherence.options)2 ClusterPort (com.oracle.bedrock.runtime.coherence.options.ClusterPort)2