Search in sources :

Example 21 with NamedCache

use of com.tangosol.net.NamedCache in project radargun by radargun.

the class Coherence3Service method stop.

@Override
public synchronized void stop() {
    for (NamedCache nc : caches.values()) {
        releaseCache(nc);
    }
    caches.clear();
    CacheFactory.shutdown();
    try {
        Field ssField = MultiProviderSelectionService.class.getDeclaredField("m_mapServices");
        ssField.setAccessible(true);
        ConcurrentMap<SelectorProvider, SelectionService> selectionServices = (ConcurrentMap<SelectorProvider, SelectionService>) ssField.get(SelectionServices.getDefaultService());
        for (SelectionService ss : selectionServices.values()) {
            ss.shutdown();
        }
    } catch (Exception e) {
        log.error("Failed to shutdown selection services", e);
    }
    started = false;
    synchronized (this) {
        membershipHistory.add(Membership.empty());
    }
    log.info("Cache factory was shut down.");
}
Also used : Field(java.lang.reflect.Field) SelectorProvider(java.nio.channels.spi.SelectorProvider) MultiProviderSelectionService(com.oracle.common.internal.net.MultiProviderSelectionService) SelectionService(com.oracle.common.net.SelectionService) ConcurrentMap(java.util.concurrent.ConcurrentMap) NamedCache(com.tangosol.net.NamedCache)

Example 22 with NamedCache

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

the class CoherenceNamedCacheConfigurationTests method shouldInjectSuperTypeCacheMap.

@Test
void shouldInjectSuperTypeCacheMap() {
    SuperTypesBean bean = this.ctx.getBean(SuperTypesBean.class);
    CacheMap map = bean.getCacheMap();
    NamedCache cache = bean.getNamedCache();
    assertThat(map, is(notNullValue()));
    assertThat(cache, is(notNullValue()));
    assertThat(map, is(sameInstance(cache)));
}
Also used : CacheMap(com.tangosol.net.cache.CacheMap) NamedCache(com.tangosol.net.NamedCache) AsyncNamedCache(com.tangosol.net.AsyncNamedCache) Test(org.junit.jupiter.api.Test)

Example 23 with NamedCache

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

the class CoherenceGenericConverterTests method testContinuousQueryCacheConversion.

@Test
public void testContinuousQueryCacheConversion() {
    final Map map = this.conversionService.convert(this.mockedContinuousQueryCache, Map.class);
    assertThat(map).isSameAs(this.mockedContinuousQueryCache);
    final ContinuousQueryCache continuousQueryCache = this.conversionService.convert(this.mockedContinuousQueryCache, ContinuousQueryCache.class);
    assertThat(continuousQueryCache).isSameAs(this.mockedContinuousQueryCache);
    final AbstractKeySetBasedMap abstractKeySetBasedMap = this.conversionService.convert(this.mockedContinuousQueryCache, AbstractKeySetBasedMap.class);
    assertThat(abstractKeySetBasedMap).isSameAs(this.mockedContinuousQueryCache);
    final AbstractKeyBasedMap abstractKeyBasedMap = this.conversionService.convert(this.mockedContinuousQueryCache, AbstractKeyBasedMap.class);
    assertThat(abstractKeyBasedMap).isSameAs(this.mockedContinuousQueryCache);
    final NamedCache namedCache = this.conversionService.convert(this.mockedContinuousQueryCache, NamedCache.class);
    assertThat(namedCache).isSameAs(this.mockedContinuousQueryCache);
    final NamedMap namedMap = this.conversionService.convert(this.mockedContinuousQueryCache, NamedMap.class);
    assertThat(namedMap).isSameAs(this.mockedContinuousQueryCache);
    final CacheMap cacheMap = this.conversionService.convert(this.mockedContinuousQueryCache, CacheMap.class);
    assertThat(cacheMap).isSameAs(this.mockedContinuousQueryCache);
    final NamedCollection namedCollection = this.conversionService.convert(this.mockedContinuousQueryCache, NamedCollection.class);
    assertThat(namedCollection).isSameAs(this.mockedContinuousQueryCache);
    final ObservableMap observableMap = this.conversionService.convert(this.mockedContinuousQueryCache, ObservableMap.class);
    assertThat(observableMap).isSameAs(this.mockedContinuousQueryCache);
    final ConcurrentMap concurrentMap = this.conversionService.convert(this.mockedContinuousQueryCache, ConcurrentMap.class);
    assertThat(concurrentMap).isSameAs(this.mockedContinuousQueryCache);
    final QueryMap queryMap = this.conversionService.convert(this.mockedContinuousQueryCache, QueryMap.class);
    assertThat(queryMap).isSameAs(this.mockedContinuousQueryCache);
    final InvocableMap invocableMap = this.conversionService.convert(this.mockedContinuousQueryCache, InvocableMap.class);
    assertThat(invocableMap).isSameAs(this.mockedContinuousQueryCache);
    final Releasable releasable = this.conversionService.convert(this.mockedContinuousQueryCache, Releasable.class);
    assertThat(releasable).isSameAs(this.mockedContinuousQueryCache);
}
Also used : InvocableMap(com.tangosol.util.InvocableMap) QueryMap(com.tangosol.util.QueryMap) AbstractKeyBasedMap(com.tangosol.util.AbstractKeyBasedMap) ConcurrentMap(com.tangosol.util.ConcurrentMap) NamedCache(com.tangosol.net.NamedCache) AbstractKeySetBasedMap(com.tangosol.util.AbstractKeySetBasedMap) NamedMap(com.tangosol.net.NamedMap) NamedCollection(com.tangosol.net.NamedCollection) ContinuousQueryCache(com.tangosol.net.cache.ContinuousQueryCache) CacheMap(com.tangosol.net.cache.CacheMap) Releasable(com.tangosol.net.Releasable) ObservableMap(com.tangosol.util.ObservableMap) InvocableMap(com.tangosol.util.InvocableMap) CacheMap(com.tangosol.net.cache.CacheMap) AbstractKeySetBasedMap(com.tangosol.util.AbstractKeySetBasedMap) QueryMap(com.tangosol.util.QueryMap) Map(java.util.Map) ObservableMap(com.tangosol.util.ObservableMap) AbstractKeyBasedMap(com.tangosol.util.AbstractKeyBasedMap) ConcurrentMap(com.tangosol.util.ConcurrentMap) NamedMap(com.tangosol.net.NamedMap) Test(org.junit.jupiter.api.Test)

Example 24 with NamedCache

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

the class SpringApplicationTests method testBackingMapManagerContextInjection.

/**
 * Test the injection of a backing map manager context via
 * the {manager-context} macro.
 */
@Test
public void testBackingMapManagerContextInjection() {
    String[] asCacheNames = new String[] { "CacheBML", "CacheBMLPull" };
    String[] asBeanNames = new String[] { "bml", "bmlPull" };
    for (int i = 0; i < asCacheNames.length; ++i) {
        NamedCache cache = this.session.getCache(asCacheNames[i]);
        BeanFactory beanFactory = this.session.getResourceRegistry().getResource(BeanFactory.class);
        StubBackingMapListener bml = beanFactory.getBean(asBeanNames[i], StubBackingMapListener.class);
        assertThat(bml.isContextConfigured()).isFalse();
        cache.put("key", "value");
        assertThat(bml.isContextConfigured()).isTrue();
    }
}
Also used : BeanFactory(org.springframework.beans.factory.BeanFactory) NamedCache(com.tangosol.net.NamedCache) Test(org.junit.jupiter.api.Test)

Example 25 with NamedCache

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

the class SpringNamespaceHandlerTests method testCacheStore.

/**
 * Test the use of Spring to inject a CacheStore.
 */
@Test
public void testCacheStore() {
    String[] asCacheNames = new String[] { "CacheStore", "CacheStorePull" };
    for (String sCacheName : asCacheNames) {
        NamedCache cache = getFactory().ensureCache(sCacheName, null);
        // the CacheStore provided by Spring is an instance of MapCacheStore
        // which has an internal map that contains the entry <"key", "value">
        assertThat("value").isEqualTo(cache.get("key"));
        // this asserts that the {cache-name} macro succeeded in injecting
        // the cache name to the cache store (see StubNamedCacheStore)
        assertThat(sCacheName).isEqualTo(cache.get(StubNamedCacheStore.CACHE_NAME_KEY));
    }
    BeanFactory beanFactory = getFactory().getResourceRegistry().getResource(BeanFactory.class);
    StubNamedCacheStore cs = beanFactory.getBean("mapCacheStorePull", StubNamedCacheStore.class);
    assertThat(cs.getSpelValue()).isEqualTo("Prosper");
}
Also used : BeanFactory(org.springframework.beans.factory.BeanFactory) NamedCache(com.tangosol.net.NamedCache) Test(org.junit.jupiter.api.Test)

Aggregations

NamedCache (com.tangosol.net.NamedCache)28 Test (org.junit.jupiter.api.Test)14 Map (java.util.Map)10 BeanFactory (org.springframework.beans.factory.BeanFactory)6 VisualVMModel (com.oracle.coherence.plugin.visualvm.VisualVMModel)3 RequestSender (com.oracle.coherence.plugin.visualvm.helper.RequestSender)3 CacheData (com.oracle.coherence.plugin.visualvm.tablemodel.model.CacheData)3 CacheDetailData (com.oracle.coherence.plugin.visualvm.tablemodel.model.CacheDetailData)3 ClusterData (com.oracle.coherence.plugin.visualvm.tablemodel.model.ClusterData)3 Data (com.oracle.coherence.plugin.visualvm.tablemodel.model.Data)3 FederationData (com.oracle.coherence.plugin.visualvm.tablemodel.model.FederationData)3 FederationDestinationDetailsData (com.oracle.coherence.plugin.visualvm.tablemodel.model.FederationDestinationDetailsData)3 FederationOriginDetailsData (com.oracle.coherence.plugin.visualvm.tablemodel.model.FederationOriginDetailsData)3 MemberData (com.oracle.coherence.plugin.visualvm.tablemodel.model.MemberData)3 PersistenceData (com.oracle.coherence.plugin.visualvm.tablemodel.model.PersistenceData)3 ProxyData (com.oracle.coherence.plugin.visualvm.tablemodel.model.ProxyData)3 RamJournalData (com.oracle.coherence.plugin.visualvm.tablemodel.model.RamJournalData)3 ServiceData (com.oracle.coherence.plugin.visualvm.tablemodel.model.ServiceData)3 ServiceMemberData (com.oracle.coherence.plugin.visualvm.tablemodel.model.ServiceMemberData)3 ExtensibleConfigurableCacheFactory (com.tangosol.net.ExtensibleConfigurableCacheFactory)3