use of com.tangosol.net.ConfigurableCacheFactory in project coherence-hibernate by coherence-community.
the class CoherenceRegionFactory method start.
// ---- interface org.hibernate.cache.spi.RegionFactory
/**
* {@inheritDoc}
*/
@Override
public void start(SessionFactoryOptions options, Properties properties) throws CacheException {
this.sessionFactoryOptions = options;
if (this.sessionFactoryOptions != null) {
StrategySelector selector = this.sessionFactoryOptions.getServiceRegistry().getService(StrategySelector.class);
this.cacheKeysFactory = selector.resolveDefaultableStrategy(CacheKeysFactory.class, properties.get(Environment.CACHE_KEYS_FACTORY), new DefaultCacheKeysFactory());
} else {
this.cacheKeysFactory = new DefaultCacheKeysFactory();
}
CacheFactory.ensureCluster();
String cacheConfigFilePath = (properties == null) ? null : properties.getProperty(CACHE_CONFIG_FILE_PATH_PROPERTY_NAME);
if (cacheConfigFilePath == null) {
cacheConfigFilePath = System.getProperty(CACHE_CONFIG_FILE_PATH_PROPERTY_NAME, DEFAULT_CACHE_CONFIG_FILE_PATH);
}
ConfigurableCacheFactory factory = CacheFactory.getCacheFactoryBuilder().getConfigurableCacheFactory(cacheConfigFilePath, getClass().getClassLoader());
setConfigurableCacheFactory(factory);
debugMessageSeverityLevel = Integer.getInteger(DEBUG_MESSAGE_SEVERITY_LEVEL_PROPERTY_NAME, DEFAULT_DEBUG_MESSAGE_SEVERITY_LEVEL);
dumpStackOnDebugMessage = Boolean.getBoolean(DUMP_STACK_ON_DEBUG_MESSAGE_PROPERTY_NAME);
debugf("%s.start(%s, %s)", this, options, properties);
}
use of com.tangosol.net.ConfigurableCacheFactory in project oracle-bedrock by coherence-community.
the class StorageDisabledMember 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 a new set of options based on those provided
optionsByType = OptionsByType.of(optionsByType);
// ----- establish the options for launching a local storage-disabled member -----
optionsByType.add(RoleName.of("client"));
optionsByType.add(LocalStorage.disabled());
optionsByType.addIfAbsent(CacheConfig.of("coherence-cache-config.xml"));
// ----- 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 Storage Disabled Member...\n" + "------------------------------------------------------------------------\n" + diagnosticsTable.toString() + "\n" + "------------------------------------------------------------------------\n");
}
// ----- establish the session -----
// create the session
ConfigurableCacheFactory session = new ScopedCacheFactoryBuilder().getConfigurableCacheFactory(optionsByType.get(CacheConfig.class).getUri(), getClass().getClassLoader());
// as this is a cluster member we have to join the cluster
CacheFactory.ensureCluster();
return session;
}
use of com.tangosol.net.ConfigurableCacheFactory in project oracle-bedrock by coherence-community.
the class CoherenceClusterResourceTest method shouldCreateExtendClientSession.
/**
* Ensure that a {@link ExtendClient} session can be created against the {@link CoherenceClusterResource}.
*/
@Test
public void shouldCreateExtendClientSession() {
ConfigurableCacheFactory session = coherenceResource.createSession(SessionBuilders.extendClient("proxy-cache-config.xml"));
NamedCache cache = session.ensureCache("dist-example", null);
Assert.assertThat(coherenceResource.getCluster().getClusterSize(), is(3));
cache.put("message", "hello world");
Eventually.assertThat(invoking(coherenceResource.getCluster().getCache("dist-example")).get("message"), is((Object) "hello world"));
}
use of com.tangosol.net.ConfigurableCacheFactory in project oracle-bedrock by coherence-community.
the class CoherenceClusterResource method createSession.
/**
* Obtains a session, represented as a {@link ConfigurableCacheFactory}, against the {@link CoherenceCluster}.
* <p>
* Only a single session may be created by a {@link CoherenceClusterResource} against the {@link CoherenceCluster}.
* <p>
* Attempts to request a session multiple times with the same {@link SessionBuilder} will return the same session.
*
* @param builder the builder for the specific type of session
*
* @return a {@link ConfigurableCacheFactory} representing the Coherence Session.
*
* @throws IllegalStateException when an attempt to request sessions for
* different {@link SessionBuilder}s is made
*/
public synchronized ConfigurableCacheFactory createSession(SessionBuilder builder) {
// restore the system properties (as the session needs to start cleanly)
com.oracle.bedrock.util.SystemProperties.replaceWith(systemProperties);
ConfigurableCacheFactory session = sessions.get(builder);
if (session == null) {
OptionsByType optionsByType = OptionsByType.of(commonOptionsByType);
optionsByType.add(RoleName.of("client"));
optionsByType.add(LocalStorage.disabled());
session = builder.build(LocalPlatform.get(), getCluster(), optionsByType);
sessions.put(builder, session);
}
return session;
}
use of com.tangosol.net.ConfigurableCacheFactory in project oracle-bedrock by coherence-community.
the class CoherenceClusterExtensionTest 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()));
}
Aggregations