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"));
}
}
}
Aggregations