Search in sources :

Example 1 with ExtensibleConfigurableCacheFactory

use of com.tangosol.net.ExtensibleConfigurableCacheFactory in project coherence-visualvm by oracle.

the class AbstractDataRetrieverTest method testElasticData.

/**
 * Test the retrieval of RamJournalData and FlashJournalData via the VisualVMModel.
 * Note: Called from testCacheData().
 */
public void testElasticData() throws Exception {
    final int RAM_INSERT_COUNT = 1000;
    final int FLASH_INSERT_COUNT = 2000;
    final int DATA_SIZE = 1000;
    List<Map.Entry<Object, Data>> ramJournalData;
    List<Map.Entry<Object, Data>> flashJournalData;
    // refresh the statistics
    VisualVMModel model = getModel();
    RequestSender requestSender = getRequestSender();
    model.refreshStatistics(requestSender);
    ramJournalData = model.getData(VisualVMModel.DataType.RAMJOURNAL);
    setCurrentDataType(VisualVMModel.DataType.RAMJOURNAL);
    // should have two entries from federation
    assertTrue("RamJournalData should be empty but size is " + (ramJournalData == null ? null : ramJournalData.size()), ramJournalData == null || ramJournalData.size() == 2);
    setClientProperties();
    ExtensibleConfigurableCacheFactory eccf = getECCF();
    NamedCache nc = eccf.ensureCache(RAM_CACHE, null);
    populateRandomData(nc, RAM_INSERT_COUNT, DATA_SIZE);
    assertTrue(nc.size() == RAM_INSERT_COUNT);
    waitForRefresh();
    model.refreshStatistics(requestSender);
    ramJournalData = model.getData(VisualVMModel.DataType.RAMJOURNAL);
    validateData(VisualVMModel.DataType.RAMJOURNAL, ramJournalData, 2);
    Map.Entry<Object, Data> entryRamJournal1 = ramJournalData.get(0);
    assertTrue(entryRamJournal1 != null && ((Integer) entryRamJournal1.getValue().getColumn(RamJournalData.NODE_ID)) != 0);
    NamedCache nc2 = eccf.ensureCache(FLASH_CACHE, null);
    populateRandomData(nc2, FLASH_INSERT_COUNT, DATA_SIZE);
    assertThat(nc2.size(), is(FLASH_INSERT_COUNT));
    waitForRefresh();
    model.refreshStatistics(getRequestSender());
    flashJournalData = model.getData(VisualVMModel.DataType.FLASHJOURNAL);
    setCurrentDataType(VisualVMModel.DataType.FLASHJOURNAL);
    validateData(VisualVMModel.DataType.FLASHJOURNAL, flashJournalData, 2);
    Map.Entry<Object, Data> entryFlashJournal1 = flashJournalData.get(0);
    assertTrue(entryFlashJournal1 != null && ((Integer) entryFlashJournal1.getValue().getColumn(RamJournalData.NODE_ID)) != 0);
}
Also used : RequestSender(com.oracle.coherence.plugin.visualvm.helper.RequestSender) MemberData(com.oracle.coherence.plugin.visualvm.tablemodel.model.MemberData) ServiceData(com.oracle.coherence.plugin.visualvm.tablemodel.model.ServiceData) PersistenceData(com.oracle.coherence.plugin.visualvm.tablemodel.model.PersistenceData) FederationDestinationDetailsData(com.oracle.coherence.plugin.visualvm.tablemodel.model.FederationDestinationDetailsData) Data(com.oracle.coherence.plugin.visualvm.tablemodel.model.Data) FederationOriginDetailsData(com.oracle.coherence.plugin.visualvm.tablemodel.model.FederationOriginDetailsData) CacheDetailData(com.oracle.coherence.plugin.visualvm.tablemodel.model.CacheDetailData) CacheData(com.oracle.coherence.plugin.visualvm.tablemodel.model.CacheData) RamJournalData(com.oracle.coherence.plugin.visualvm.tablemodel.model.RamJournalData) ServiceMemberData(com.oracle.coherence.plugin.visualvm.tablemodel.model.ServiceMemberData) FederationData(com.oracle.coherence.plugin.visualvm.tablemodel.model.FederationData) ClusterData(com.oracle.coherence.plugin.visualvm.tablemodel.model.ClusterData) ProxyData(com.oracle.coherence.plugin.visualvm.tablemodel.model.ProxyData) VisualVMModel(com.oracle.coherence.plugin.visualvm.VisualVMModel) ExtensibleConfigurableCacheFactory(com.tangosol.net.ExtensibleConfigurableCacheFactory) Map(java.util.Map) NamedCache(com.tangosol.net.NamedCache)

Example 2 with ExtensibleConfigurableCacheFactory

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

the class NamespaceHandlerTest method setup.

@BeforeEach
void setup() {
    String xml = "namespace-handler-test-config.xml";
    ExtensibleConfigurableCacheFactory.Dependencies deps = ExtensibleConfigurableCacheFactory.DependenciesHelper.newInstance(xml);
    this.eccf = new ExtensibleConfigurableCacheFactory(deps);
}
Also used : ExtensibleConfigurableCacheFactory(com.tangosol.net.ExtensibleConfigurableCacheFactory) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with ExtensibleConfigurableCacheFactory

use of com.tangosol.net.ExtensibleConfigurableCacheFactory in project coherence-visualvm by oracle.

the class AbstractDataRetrieverTest method testCacheData.

/**
 * Test the retrieval of CacheData via the VisualVMModel.
 */
private void testCacheData() throws Exception {
    final int INSERT1_COUNT = 10000;
    final int INSERT2_COUNT = 7500;
    final int INSERT3_COUNT = 100;
    final int DATA_SIZE = 250;
    List<Map.Entry<Object, Data>> cacheData;
    List<Map.Entry<Object, Data>> cacheDetailData;
    List<Map.Entry<Object, Data>> cacheStorageData;
    VisualVMModel model = getModel();
    RequestSender requestSender = getRequestSender();
    assertClusterReady();
    waitForRefresh();
    // refresh the statistics
    model.refreshStatistics(requestSender);
    cacheData = model.getData(VisualVMModel.DataType.CACHE);
    setCurrentDataType(VisualVMModel.DataType.CACHE);
    setClientProperties();
    ExtensibleConfigurableCacheFactory eccf = getECCF();
    // now add 2 caches on 2 different services - note we are connecting via Extend
    NamedCache nc1 = eccf.ensureCache(DIST1_CACHE, null);
    NamedCache nc2 = eccf.ensureCache(DIST2_CACHE, null);
    NamedCache nc3 = eccf.ensureCache(REPL_CACHE, null);
    populateRandomData(nc1, INSERT1_COUNT, DATA_SIZE);
    populateRandomData(nc2, INSERT2_COUNT, DATA_SIZE);
    populateRandomData(nc3, INSERT3_COUNT, DATA_SIZE);
    assertTrue(nc1.size() == INSERT1_COUNT);
    assertTrue(nc2.size() == INSERT2_COUNT);
    assertTrue(nc3.size() == INSERT3_COUNT);
    waitForRefresh();
    model.refreshStatistics(requestSender);
    cacheData = model.getData(VisualVMModel.DataType.CACHE);
    Map.Entry<Object, Data> distCache1 = getData(cacheData, new Pair<>(DIST1_SERVICE, DIST1_CACHE));
    Map.Entry<Object, Data> distCache2 = getData(cacheData, new Pair<>(DIST2_SERVICE, DIST2_CACHE));
    Map.Entry<Object, Data> replCache1 = getData(cacheData, new Pair<>(REPLICATED_SERVICE, REPL_CACHE));
    // validate the data returned where its deterministic
    validateColumnNotNull(CacheData.SIZE, distCache1);
    validateColumn(CacheData.CACHE_NAME, distCache1, getCacheName(DIST1_SERVICE, DIST1_CACHE));
    validateColumnNotNull(CacheData.SIZE, distCache2);
    validateColumn(CacheData.CACHE_NAME, distCache2, getCacheName(DIST2_SERVICE, DIST2_CACHE));
    validateColumnNotNull(CacheData.SIZE, replCache1);
    validateColumn(CacheData.CACHE_NAME, replCache1, getCacheName(REPLICATED_SERVICE, REPL_CACHE));
    validateColumn(CacheData.UNIT_CALCULATOR, distCache1, "BINARY");
    // select the first service, which should then generate both CacheDetailData and
    // CacheStorageManagerData on next refresh
    model.setSelectedCache(new Pair<>(DIST1_SERVICE, DIST1_CACHE));
    // do 2 gets
    nc1.get(0);
    nc1.get(INSERT1_COUNT - 1);
    waitForRefresh();
    model.refreshStatistics(getRequestSender());
    cacheDetailData = model.getData(VisualVMModel.DataType.CACHE_DETAIL);
    cacheStorageData = model.getData(VisualVMModel.DataType.CACHE_STORAGE_MANAGER);
    setCurrentDataType(VisualVMModel.DataType.CACHE_DETAIL);
    validateData(VisualVMModel.DataType.CACHE_DETAIL, cacheDetailData, 2);
    setCurrentDataType(VisualVMModel.DataType.CACHE_STORAGE_MANAGER);
    validateData(VisualVMModel.DataType.CACHE_STORAGE_MANAGER, cacheStorageData, 2);
    // validate the CacheDetail data
    Map.Entry<Object, Data> entryDetail1 = cacheDetailData.get(0);
    Map.Entry<Object, Data> entryDetail2 = cacheDetailData.get(1);
    validateColumn(CacheDetailData.NODE_ID, entryDetail1, 1);
    validateColumn(CacheDetailData.NODE_ID, entryDetail2, 2);
    // call the dependent tests as we can't guarantee execution order in JUnit
    testPersistenceData();
    testProxyData();
    if (isCommercial()) {
        testElasticData();
    }
}
Also used : RequestSender(com.oracle.coherence.plugin.visualvm.helper.RequestSender) MemberData(com.oracle.coherence.plugin.visualvm.tablemodel.model.MemberData) ServiceData(com.oracle.coherence.plugin.visualvm.tablemodel.model.ServiceData) PersistenceData(com.oracle.coherence.plugin.visualvm.tablemodel.model.PersistenceData) FederationDestinationDetailsData(com.oracle.coherence.plugin.visualvm.tablemodel.model.FederationDestinationDetailsData) Data(com.oracle.coherence.plugin.visualvm.tablemodel.model.Data) FederationOriginDetailsData(com.oracle.coherence.plugin.visualvm.tablemodel.model.FederationOriginDetailsData) CacheDetailData(com.oracle.coherence.plugin.visualvm.tablemodel.model.CacheDetailData) CacheData(com.oracle.coherence.plugin.visualvm.tablemodel.model.CacheData) RamJournalData(com.oracle.coherence.plugin.visualvm.tablemodel.model.RamJournalData) ServiceMemberData(com.oracle.coherence.plugin.visualvm.tablemodel.model.ServiceMemberData) FederationData(com.oracle.coherence.plugin.visualvm.tablemodel.model.FederationData) ClusterData(com.oracle.coherence.plugin.visualvm.tablemodel.model.ClusterData) ProxyData(com.oracle.coherence.plugin.visualvm.tablemodel.model.ProxyData) VisualVMModel(com.oracle.coherence.plugin.visualvm.VisualVMModel) ExtensibleConfigurableCacheFactory(com.tangosol.net.ExtensibleConfigurableCacheFactory) Map(java.util.Map) NamedCache(com.tangosol.net.NamedCache)

Example 4 with ExtensibleConfigurableCacheFactory

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

the class SpringBasedCoherenceSession method afterPropertiesSet.

@Override
public void afterPropertiesSet() throws Exception {
    // establish the configuration dependencies for the
    // ConfigurableCacheFactory we're about to create
    ExtensibleConfigurableCacheFactory.Dependencies dependencies = this.cacheConfigURI.equals(DEFAULT_CACHE_CONFIG_URI) ? newInstance() : newInstance(this.cacheConfigURI);
    if (this.applicationContext != null) {
        // override the bean expression resolver with one that can also
        // resolve Coherence-based values eg: cache-name, manager-context etc.
        AutowireCapableBeanFactory beanFactory = this.applicationContext.getAutowireCapableBeanFactory();
        if (beanFactory instanceof ConfigurableBeanFactory) {
            ((ConfigurableBeanFactory) beanFactory).setBeanExpressionResolver(new CoherenceBeanExpressionResolver(ParameterMacroExpressionParser.INSTANCE));
        }
        // register this application context as a resource so that the
        // ConfigurableCacheFactory can later use it
        // (say for injecting into Coherence-based instances)
        dependencies.getResourceRegistry().registerResource(ApplicationContext.class, this.applicationContext);
        // also register this application context as the default BeanFactory
        dependencies.getResourceRegistry().registerResource(BeanFactory.class, this.applicationContext);
    }
    // create the ConfigurableCacheFactory
    this.configurableCacheFactory = new ExtensibleConfigurableCacheFactory(dependencies);
    // register the ConfigurableCacheFactory with the CacheFactoryBuilder
    // so that anyone attempting to use the static CacheFactory methods
    // like "CacheFactory.getCache()" has a chance of using the same
    // configuration and caches!
    CacheFactory.getCacheFactoryBuilder().setConfigurableCacheFactory(this.configurableCacheFactory, this.cacheConfigURI, null, false);
}
Also used : ConfigurableBeanFactory(org.springframework.beans.factory.config.ConfigurableBeanFactory) ExtensibleConfigurableCacheFactory(com.tangosol.net.ExtensibleConfigurableCacheFactory) AutowireCapableBeanFactory(org.springframework.beans.factory.config.AutowireCapableBeanFactory)

Aggregations

ExtensibleConfigurableCacheFactory (com.tangosol.net.ExtensibleConfigurableCacheFactory)4 VisualVMModel (com.oracle.coherence.plugin.visualvm.VisualVMModel)2 RequestSender (com.oracle.coherence.plugin.visualvm.helper.RequestSender)2 CacheData (com.oracle.coherence.plugin.visualvm.tablemodel.model.CacheData)2 CacheDetailData (com.oracle.coherence.plugin.visualvm.tablemodel.model.CacheDetailData)2 ClusterData (com.oracle.coherence.plugin.visualvm.tablemodel.model.ClusterData)2 Data (com.oracle.coherence.plugin.visualvm.tablemodel.model.Data)2 FederationData (com.oracle.coherence.plugin.visualvm.tablemodel.model.FederationData)2 FederationDestinationDetailsData (com.oracle.coherence.plugin.visualvm.tablemodel.model.FederationDestinationDetailsData)2 FederationOriginDetailsData (com.oracle.coherence.plugin.visualvm.tablemodel.model.FederationOriginDetailsData)2 MemberData (com.oracle.coherence.plugin.visualvm.tablemodel.model.MemberData)2 PersistenceData (com.oracle.coherence.plugin.visualvm.tablemodel.model.PersistenceData)2 ProxyData (com.oracle.coherence.plugin.visualvm.tablemodel.model.ProxyData)2 RamJournalData (com.oracle.coherence.plugin.visualvm.tablemodel.model.RamJournalData)2 ServiceData (com.oracle.coherence.plugin.visualvm.tablemodel.model.ServiceData)2 ServiceMemberData (com.oracle.coherence.plugin.visualvm.tablemodel.model.ServiceMemberData)2 NamedCache (com.tangosol.net.NamedCache)2 Map (java.util.Map)2 BeforeEach (org.junit.jupiter.api.BeforeEach)1 AutowireCapableBeanFactory (org.springframework.beans.factory.config.AutowireCapableBeanFactory)1