Search in sources :

Example 1 with ConfigurableCacheFactory

use of com.tangosol.net.ConfigurableCacheFactory in project coherence-spring by coherence-community.

the class ServiceEventHandler method isApplicable.

@Override
protected boolean isApplicable(EventDispatcher dispatcher, String scopeName) {
    if (dispatcher instanceof PartitionedServiceDispatcher) {
        PartitionedServiceDispatcher psd = (PartitionedServiceDispatcher) dispatcher;
        ConfigurableCacheFactory ccf = getConfigurableCacheFactory(psd.getService());
        if (ccf == null || scopeName == null || scopeName.equals(ccf.getScopeName())) {
            return this.serviceName == null || this.serviceName.equals(removeScope(psd.getServiceName()));
        }
    }
    return false;
}
Also used : PartitionedServiceDispatcher(com.tangosol.net.events.partition.PartitionedServiceDispatcher) ConfigurableCacheFactory(com.tangosol.net.ConfigurableCacheFactory)

Example 2 with ConfigurableCacheFactory

use of com.tangosol.net.ConfigurableCacheFactory in project oracle-bedrock by coherence-community.

the class GetAutoStartServiceNames method call.

@Override
public Set<String> call() throws Exception {
    ConfigurableCacheFactory configurableCacheFactory = CacheFactory.getConfigurableCacheFactory();
    if (configurableCacheFactory instanceof DefaultConfigurableCacheFactory) {
        DefaultConfigurableCacheFactory cacheFactory = (DefaultConfigurableCacheFactory) configurableCacheFactory;
        // obtain the XmlElements representing the service scheme configurations
        XmlElement xmlCacheConfig = cacheFactory.getConfig();
        Map<String, XmlElement> serviceSchemes = cacheFactory.collectServiceSchemes(xmlCacheConfig);
        HashSet<String> serviceNames = new HashSet<>();
        for (String serviceName : serviceSchemes.keySet()) {
            XmlElement xmlServiceScheme = serviceSchemes.get(serviceName);
            boolean isAutoStart = xmlServiceScheme.getSafeElement("autostart").getBoolean(false);
            if (isAutoStart) {
                serviceNames.add(serviceName);
            }
        }
        return serviceNames;
    } else {
        throw new RuntimeException("The ConfigurableCacheFactory is not an DefaultConfigurableCacheFactory");
    }
}
Also used : XmlElement(com.tangosol.run.xml.XmlElement) DefaultConfigurableCacheFactory(com.tangosol.net.DefaultConfigurableCacheFactory) DefaultConfigurableCacheFactory(com.tangosol.net.DefaultConfigurableCacheFactory) ConfigurableCacheFactory(com.tangosol.net.ConfigurableCacheFactory) HashSet(java.util.HashSet)

Example 3 with ConfigurableCacheFactory

use of com.tangosol.net.ConfigurableCacheFactory 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;
}
Also used : Table(com.oracle.bedrock.table.Table) Properties(java.util.Properties) ConfigurableCacheFactory(com.tangosol.net.ConfigurableCacheFactory) Profile(com.oracle.bedrock.runtime.Profile) ScopedCacheFactoryBuilder(com.tangosol.net.ScopedCacheFactoryBuilder) CoherenceClusterMember(com.oracle.bedrock.runtime.coherence.CoherenceClusterMember) MetaClass(com.oracle.bedrock.runtime.MetaClass)

Example 4 with ConfigurableCacheFactory

use of com.tangosol.net.ConfigurableCacheFactory 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 5 with ConfigurableCacheFactory

use of com.tangosol.net.ConfigurableCacheFactory in project oracle-bedrock by coherence-community.

the class CoherenceClusterResourceTest method shouldCreateStorageDisabledMemberSession.

/**
 * Ensure that a {@link StorageDisabledMember} session can be created against the {@link CoherenceClusterResource}.
 */
@Test
public void shouldCreateStorageDisabledMemberSession() {
    ConfigurableCacheFactory session = coherenceResource.createSession(SessionBuilders.storageDisabledMember());
    NamedCache cache = session.ensureCache("dist-example", null);
    Eventually.assertThat(coherenceResource.getCluster().getClusterSize(), is(4));
    cache.put("message", "hello world");
    Eventually.assertThat(invoking(coherenceResource.getCluster().getCache("dist-example")).get("message"), is((Object) "hello world"));
}
Also used : ConfigurableCacheFactory(com.tangosol.net.ConfigurableCacheFactory) NamedCache(com.tangosol.net.NamedCache) Test(org.junit.Test)

Aggregations

ConfigurableCacheFactory (com.tangosol.net.ConfigurableCacheFactory)19 NamedCache (com.tangosol.net.NamedCache)7 CoherenceClusterMember (com.oracle.bedrock.runtime.coherence.CoherenceClusterMember)4 Test (org.junit.jupiter.api.Test)4 OptionsByType (com.oracle.bedrock.OptionsByType)3 Test (org.junit.Test)3 DeferredHelper.invoking (com.oracle.bedrock.deferred.DeferredHelper.invoking)2 LocalPlatform (com.oracle.bedrock.runtime.LocalPlatform)2 MetaClass (com.oracle.bedrock.runtime.MetaClass)2 Profile (com.oracle.bedrock.runtime.Profile)2 CoherenceCluster (com.oracle.bedrock.runtime.coherence.CoherenceCluster)2 SystemProperty (com.oracle.bedrock.runtime.java.options.SystemProperty)2 DisplayName (com.oracle.bedrock.runtime.options.DisplayName)2 Table (com.oracle.bedrock.table.Table)2 Eventually (com.oracle.bedrock.testsupport.deferred.Eventually)2 Capture (com.oracle.bedrock.util.Capture)2 ScopedCacheFactoryBuilder (com.tangosol.net.ScopedCacheFactoryBuilder)2 Properties (java.util.Properties)2 Set (java.util.Set)2 TreeSet (java.util.TreeSet)2