Package net.sf.ehcache.store

Examples of net.sf.ehcache.store.Store


        CacheConfiguration config = cache.getCacheConfiguration();
        MemoryStore memoryStore = createMemoryStore( cache, onHeapPool );
        DirectMemoryStore offHeapStore = createOffHeapStore( cache, true );
        DiskStore diskStore = null; //need to implement disk backing to store.
        Store store = null;
        if ( diskStore == null )
        {
            store = new FrontEndCacheTier<MemoryStore, DirectMemoryStore>( memoryStore, offHeapStore,
                                                                           config.getCopyStrategy(),
                                                                           config.isCopyOnWrite(),
View Full Code Here


        CacheConfiguration config = cache.getCacheConfiguration();
        MemoryStore memoryStore = createMemoryStore( cache, onHeapPool );
        DirectMemoryStore offHeapStore = createOffHeapStore( cache );
        DiskStore diskStore = null; //need to implement disk backing to store.
        Store store = null;
        if ( diskStore == null )
        {
            store = new FrontEndCacheTier<MemoryStore, DirectMemoryStore>( memoryStore, offHeapStore,
                                                                           config.getCopyStrategy(),
                                                                           new MockSearchManager(),
View Full Code Here

                && configuration.isTerracottaClustered()
                && configuration.getTerracottaConfiguration().getValueMode() != TerracottaConfiguration.ValueMode.SERIALIZATION) {
                throw new CacheException("To be transactional, a Terracotta clustered cache needs to be in Serialization value mode");
            }

            final Store store;
            if (isTerracottaClustered()) {
                final Consistency consistency = getCacheConfiguration().getTerracottaConfiguration().getConsistency();
                final boolean coherent = getCacheConfiguration().getTerracottaConfiguration().isCoherent();
                if (getCacheConfiguration().isOverflowToOffHeap()) {
                    throw new InvalidConfigurationException(
                            "Terracotta clustered caches with local overflow to offheap are not supported yet."
                                    + " You can fix this by disabling overflow to offheap for clustered caches.");
                }
                if (getCacheConfiguration().getTerracottaConfiguration().isSynchronousWrites() && consistency == Consistency.EVENTUAL) {
                    throw new InvalidConfigurationException(
                            "Terracotta clustered caches with eventual consistency and synchronous writes are not supported yet."
                                    + " You can fix this by either making the cache in 'strong' consistency mode "
                                    + "(<terracotta consistency=\"strong\"/>) or turning off synchronous writes.");
                }
                if (getCacheConfiguration().getTransactionalMode().isTransactional() && consistency == Consistency.EVENTUAL) {
                    throw new InvalidConfigurationException("Consistency should be " + Consistency.STRONG
                            + " when cache is configured with transactions enabled. "
                            + "You can fix this by either making the cache in 'strong' consistency mode "
                            + "(<terracotta consistency=\"strong\"/>) or turning off transactions.");
                }
                if (getCacheConfiguration().getTransactionalMode().isTransactional()
                        && !getCacheConfiguration().getTransactionalMode().equals(CacheConfiguration.TransactionalMode.XA_STRICT)
                        && getCacheConfiguration().getTerracottaConfiguration().isNonstopEnabled()) {
                    LOG.warn("Cache: " + configuration.getName() + " configured both NonStop and transactional non xa_strict."
                            + " NonStop features won't work for this cache!");
                }
                if ((coherent && consistency == Consistency.EVENTUAL) || (!coherent && consistency == Consistency.STRONG)) {
                    throw new InvalidConfigurationException("Coherent and consistency attribute values are conflicting. "
                            + "Please remove the coherent attribute as its deprecated.");
                }
                int maxConcurrency = Integer.getInteger(EHCACHE_CLUSTERREDSTORE_MAX_CONCURRENCY_PROP,
                        DEFAULT_EHCACHE_CLUSTERREDSTORE_MAX_CONCURRENCY);
                if (getCacheConfiguration().getTerracottaConfiguration().getConcurrency() > maxConcurrency) {
                    throw new InvalidConfigurationException("Maximum supported concurrency for Terracotta clustered caches is "
                            + maxConcurrency + ". Please reconfigure cache '" + getName() + "' with concurrency value <= " + maxConcurrency
                            + " or use system property '" + EHCACHE_CLUSTERREDSTORE_MAX_CONCURRENCY_PROP + "' to override the default");
                }
                if (getCacheConfiguration().getMaxElementsOnDisk() == 0) {
                    LOG.warn("Performance may degrade and server disks could run out of space!\nThe distributed cache {} does not have " +
                             "maxElementsOnDisk set. Failing to set maxElementsOnDisk could mean no eviction of its elements from the " +
                             "Terracotta Server Array disk store. To avoid this, set maxElementsOnDisk to a non-zero value.", getName());
                }
                if (!getCacheConfiguration().getTerracottaConfiguration().isStorageStrategySet()) {
                    getCacheConfiguration().getTerracottaConfiguration().storageStrategy(
                            TerracottaClient.getTerracottaDefaultStrategyForCurrentRuntime(getCacheConfiguration()));
                }
                Store tempStore = cacheManager.createTerracottaStore(this);
                if (!(tempStore instanceof TerracottaStore)) {
                    throw new CacheException(
                            "CacheManager should create instances of TerracottaStore for Terracotta Clustered caches instead of - "
                                    + (tempStore == null ? "null" : tempStore.getClass().getName()));
                }
                TerracottaStore terracottaStore = (TerracottaStore) makeXaStrictTransactionalIfNeeded(tempStore, copyStrategy);

                NonstopConfiguration nonstopConfig = getCacheConfiguration().getTerracottaConfiguration().getNonstopConfiguration();
                // freeze the config whether nonstop is enabled or not
                if (nonstopConfig != null) {
                    nonstopConfig.freezeConfig();
                }
                if (getCacheConfiguration().getTerracottaConfiguration().isNonstopEnabled()) {
                    nonstopActiveDelegateHolder.terracottaStoreInitialized(terracottaStore);
                    store = nonstopActiveDelegateHolder.getNonstopStore();
                } else {
                    store = terracottaStore;
                }
            } else if (getCacheConfiguration().isOverflowToOffHeap()) {
                try {
                    Class<Store> storeClass = ClassLoaderUtil.loadClass(OFF_HEAP_STORE_CLASSNAME);
                    try {
                        store = makeXaStrictTransactionalIfNeeded((Store) storeClass.getMethod("create", Ehcache.class, String.class)
                                .invoke(null, this, diskStorePath), copyStrategy);
                    } catch (NoSuchMethodException e) {
                        throw new CacheException("Cache: " + configuration.getName() + " cannot find static factory"
                                + " method create(Ehcache, String)" + " in store class " + OFF_HEAP_STORE_CLASSNAME, e);
                    } catch (InvocationTargetException e) {
                        Throwable cause = e.getCause();
                        if (cause instanceof CacheException) {
                            throw (CacheException) cause;
                        } else {
                            throw new CacheException("Cache: " + configuration.getName() + " cannot instantiate store "
                                    + OFF_HEAP_STORE_CLASSNAME, cause);
                        }
                    } catch (IllegalAccessException e) {
                        throw new CacheException("Cache: " + configuration.getName() + " cannot instantiate store "
                                + OFF_HEAP_STORE_CLASSNAME, e);
                    }
                } catch (ClassNotFoundException e) {
                    throw new CacheException("Cache " + configuration.getName()
                            + " cannot be configured because the off-heap store class could not be found. "
                            + "You must use an enterprise version of Ehcache to successfully enable overflowToOffHeap.");
                }
            } else {
                if (useClassicLru && configuration.getMemoryStoreEvictionPolicy().equals(MemoryStoreEvictionPolicy.LRU)) {
                    Store disk = createDiskStore();
                    store = makeXaStrictTransactionalIfNeeded(new LegacyStoreWrapper(
                            new LruMemoryStore(this, disk), disk, registeredEventListeners, configuration), copyStrategy);
                } else {
                    if (configuration.isDiskPersistent()) {
                        store = makeXaStrictTransactionalIfNeeded(DiskPersistentStore.create(this, diskStorePath), copyStrategy);
View Full Code Here

    /*
     * Note: this method could be used for xa and local tx modes as well if they supported NonStop
     */
    private Store makeXaStrictTransactionalIfNeeded(Store clusteredStore, ReadWriteCopyStrategy<Element> copyStrategy) {
        Store wrappedStore;

        if (configuration.isXaStrictTransactional()) {
            if (transactionManagerLookup.getTransactionManager() == null) {
                throw new CacheException("You've configured cache " + cacheManager.getName() + "."
                                         + configuration.getName() + " to be transactional, but no TransactionManager could be found!");
View Full Code Here

TOP

Related Classes of net.sf.ehcache.store.Store

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.