use of com.oracle.bedrock.runtime.coherence.options.ClusterPort in project oracle-bedrock by coherence-community.
the class AbstractCoherenceClusterBuilderTest method shouldBuildStorageEnabledCluster.
/**
* Ensure we can build and destroy a {@link CoherenceCluster} containing storage-enabled
* {@link CoherenceCacheServer}s.
*/
@Test
public void shouldBuildStorageEnabledCluster() {
final int CLUSTER_SIZE = 3;
AvailablePortIterator availablePorts = LocalPlatform.get().getAvailablePorts();
ClusterPort clusterPort = ClusterPort.of(new Capture<>(availablePorts));
CoherenceClusterBuilder builder = new CoherenceClusterBuilder();
builder.include(CLUSTER_SIZE, CoherenceClusterMember.class, clusterPort, LocalHost.only(), ClusterName.of("Storage-Only"));
try (CoherenceCluster cluster = builder.build(getPlatform(), Console.system())) {
assertThat(invoking(cluster).getClusterSize(), is(CLUSTER_SIZE));
}
}
use of com.oracle.bedrock.runtime.coherence.options.ClusterPort in project oracle-bedrock by coherence-community.
the class AbstractCoherenceClusterBuilderTest method shouldFailOverNamedCache.
/**
* Ensure that a {@link NamedCache} produced by a {@link CoherenceCluster} {@link CoherenceClusterMember}
* is failed over to another {@link CoherenceClusterMember} when the original {@link CoherenceClusterMember}
* is closed.
*/
@Test
public void shouldFailOverNamedCache() {
Capture<Integer> wkaPort = new Capture<>(LocalPlatform.get().getAvailablePorts());
final int CLUSTER_SIZE = 3;
String localHost = System.getProperty("tangosol.coherence.localhost", "127.0.0.1");
AvailablePortIterator availablePorts = LocalPlatform.get().getAvailablePorts();
ClusterPort clusterPort = ClusterPort.of(new Capture<>(availablePorts));
CoherenceClusterBuilder builder = new CoherenceClusterBuilder();
builder.include(CLUSTER_SIZE, CoherenceClusterMember.class, WellKnownAddress.of(localHost, wkaPort), clusterPort, LocalHost.of(localHost, wkaPort), ClusterName.of("FailOver"), DisplayName.of("DCS"));
try (CoherenceCluster cluster = builder.build(getPlatform(), Console.system())) {
assertThat(invoking(cluster).getClusterSize(), is(CLUSTER_SIZE));
// acquire a NamedCache from a specific cluster member
CoherenceClusterMember member = cluster.get("DCS-1");
NamedCache cache = member.getCache("dist-example");
// use the cache to put some data
cache.put("message", "hello");
assertThat(cluster.get("DCS-2").getCache("dist-example").get("message"), is("hello"));
// close the cluster member
member.close();
// ensure that it's not in the cluster
assertThat(invoking(cluster).getClusterSize(), is(CLUSTER_SIZE - 1));
// attempt to use the cache
assertThat(invoking(cache).get("message"), is("hello"));
}
}
use of com.oracle.bedrock.runtime.coherence.options.ClusterPort in project oracle-bedrock by coherence-community.
the class AbstractCoherenceClusterBuilderTest method shouldBuilderWKABasedStorageCluster.
/**
* Ensure that we can build a cluster using WKA.
*/
@Test
public void shouldBuilderWKABasedStorageCluster() {
Capture<Integer> wkaPort = new Capture<>(LocalPlatform.get().getAvailablePorts());
ClusterPort clusterPort = ClusterPort.of(new Capture<>(LocalPlatform.get().getAvailablePorts()));
String localHost = System.getProperty("tangosol.coherence.localhost", "127.0.0.1");
String clusterName = "WKA" + getClass().getSimpleName();
int desiredClusterSize = 4;
CoherenceClusterBuilder clusterBuilder = new CoherenceClusterBuilder();
clusterBuilder.include(desiredClusterSize, CoherenceClusterMember.class, DisplayName.of("storage"), LocalStorage.enabled(), WellKnownAddress.of(localHost, wkaPort), ClusterName.of(clusterName), LocalHost.of(localHost, wkaPort), clusterPort);
try (CoherenceCluster cluster = clusterBuilder.build(Console.system())) {
assertThat(invoking(cluster).getClusterSize(), is(desiredClusterSize));
}
}
use of com.oracle.bedrock.runtime.coherence.options.ClusterPort in project oracle-bedrock by coherence-community.
the class AbstractCoherenceClusterBuilderTest method shouldRemoveCoherenceClusterMemberFromCoherenceCluster.
/**
* Ensure that the explicitly closing a CoherenceCacheServer removes it from
* the CoherenceCluster in which is it defined.
*/
@Test
public void shouldRemoveCoherenceClusterMemberFromCoherenceCluster() {
final int CLUSTER_SIZE = 3;
Capture<Integer> wkaPort = new Capture<>(LocalPlatform.get().getAvailablePorts());
String localHost = System.getProperty("tangosol.coherence.localhost", "127.0.0.1");
ClusterPort clusterPort = ClusterPort.of(new Capture<>(LocalPlatform.get().getAvailablePorts()));
CoherenceClusterBuilder builder = new CoherenceClusterBuilder();
builder.include(CLUSTER_SIZE, CoherenceClusterMember.class, WellKnownAddress.of(localHost, wkaPort), clusterPort, LocalHost.of(localHost, wkaPort), ClusterName.of("Access"), DisplayName.of("DCS"));
try (CoherenceCluster cluster = builder.build(getPlatform(), Console.system())) {
assertThat(invoking(cluster).getClusterSize(), is(CLUSTER_SIZE));
// acquire a cluster member
CoherenceClusterMember member = cluster.get("DCS-1");
// close it
member.close();
// ensure that it's not in the cluster
assertThat(invoking(cluster).getClusterSize(), is(CLUSTER_SIZE - 1));
}
}
use of com.oracle.bedrock.runtime.coherence.options.ClusterPort 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"));
}
}
}
Aggregations