use of com.oracle.bedrock.runtime.coherence.CoherenceClusterMember 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"));
}
use of com.oracle.bedrock.runtime.coherence.CoherenceClusterMember in project oracle-bedrock by coherence-community.
the class ExtendClient method build.
@Override
public ConfigurableCacheFactory build(LocalPlatform platform, CoherenceCluster cluster, OptionsByType optionsByType) {
// ----- establish the diagnostics output table -----
Table diagnosticsTable = new Table();
diagnosticsTable.getOptions().add(Table.orderByColumn(0));
// ----- establish the options for launching a local extend-based member -----
optionsByType.add(RoleName.of("extend-client"));
optionsByType.add(Clustering.disabled());
optionsByType.add(LocalStorage.disabled());
optionsByType.add(LocalHost.only());
optionsByType.add(SystemProperty.of("tangosol.coherence.extend.enabled", true));
optionsByType.add(CacheConfig.of(cacheConfigURI));
// ----- notify the Profiles that we're about to launch an application -----
MetaClass<CoherenceClusterMember> metaClass = new CoherenceClusterMember.MetaClass();
for (Profile profile : optionsByType.getInstancesOf(Profile.class)) {
profile.onLaunching(platform, metaClass, optionsByType);
}
// ----- create local system properties based on those defined by the launch options -----
// modify the current system properties to include/override those in the schema
com.oracle.bedrock.runtime.java.options.SystemProperties systemProperties = optionsByType.get(com.oracle.bedrock.runtime.java.options.SystemProperties.class);
Properties properties = systemProperties.resolve(platform, optionsByType);
Table systemPropertiesTable = new Table();
systemPropertiesTable.getOptions().add(Table.orderByColumn(0));
systemPropertiesTable.getOptions().add(Cell.Separator.of(""));
systemPropertiesTable.getOptions().add(Cell.DisplayNull.asEmptyString());
for (String propertyName : properties.stringPropertyNames()) {
String propertyValue = properties.getProperty(propertyName);
systemPropertiesTable.addRow(propertyName + (System.getProperties().containsKey(propertyName) ? "*" : ""), propertyValue);
System.setProperty(propertyName, propertyValue.isEmpty() ? "" : propertyValue);
}
diagnosticsTable.addRow("System Properties", systemPropertiesTable.toString());
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.log(Level.INFO, "Oracle Bedrock " + Bedrock.getVersion() + ": Starting *Extend Client...\n" + "------------------------------------------------------------------------\n" + diagnosticsTable.toString() + "\n" + "------------------------------------------------------------------------\n");
}
// ----- establish the session -----
// create the session
ConfigurableCacheFactory session = new ScopedCacheFactoryBuilder().getConfigurableCacheFactory(cacheConfigURI, getClass().getClassLoader());
return session;
}
use of com.oracle.bedrock.runtime.coherence.CoherenceClusterMember 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()));
}
use of com.oracle.bedrock.runtime.coherence.CoherenceClusterMember 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)));
}
use of com.oracle.bedrock.runtime.coherence.CoherenceClusterMember in project oracle-bedrock by coherence-community.
the class CoherenceClusterOrchestration method before.
@Override
protected void before() throws Throwable {
// take a snapshot of the system properties
systemProperties = com.oracle.bedrock.util.SystemProperties.createSnapshot();
// establish a CoherenceClusterBuilder with the required configuration
CoherenceClusterBuilder clusterBuilder = new CoherenceClusterBuilder();
// define the options for the storage enabled members of the cluster
OptionsByType storageServerOptions = createStorageEnabledMemberOptions();
storageServerOptions.addAll(clusterCreationOptions);
clusterBuilder.include(storageMemberCount, CoherenceClusterMember.class, storageServerOptions.asArray());
// define the schema for the proxy enabled members of the cluster
OptionsByType proxyServerOptions = createProxyServerOptions();
proxyServerOptions.addAll(clusterCreationOptions);
int proxyMemberCount = 1;
clusterBuilder.include(proxyMemberCount, CoherenceClusterMember.class, proxyServerOptions.asArray());
int preferredClusterSize = storageMemberCount + proxyMemberCount;
// establish the cluster
cluster = clusterBuilder.build();
// ensure that the cluster has been orchestrated correctly
Eventually.assertThat(invoking(cluster).getClusterSize(), is(preferredClusterSize));
// ensure that all services marked as autostart on the proxy have started
CoherenceClusterMember proxyServer = cluster.get("proxy-1");
Set<String> setServiceNames = proxyServer.invoke(new GetAutoStartServiceNames());
for (String sServiceName : setServiceNames) {
Eventually.assertThat(invoking(proxyServer).isServiceRunning(sServiceName), is(true));
}
// let's ensure that we don't have a local cluster member
CacheFactory.setCacheFactoryBuilder(null);
CacheFactory.shutdown();
// let the super-class perform it's initialization
super.before();
}
Aggregations