- * This implementation returns Ehcache specific access strategy instances for all the non-transactional access types. Transactional access
- * is not supported.
- *
- * @author Chris Dennis
- * @author Abhishek Sanoujam
- */
-public class EhcacheEntityRegion extends EhcacheTransactionalDataRegion implements EntityRegion {
-
- private static final Logger LOG = LoggerFactory.getLogger(EhcacheEntityRegion.class);
-
- /**
- * Constructs an EhcacheEntityRegion around the given underlying cache.
- *
- * @param accessStrategyFactory
- */
- public EhcacheEntityRegion(EhcacheAccessStrategyFactory accessStrategyFactory, Ehcache underlyingCache, Settings settings,
- CacheDataDescription metadata, Properties properties) {
- super(accessStrategyFactory, underlyingCache, settings, metadata, properties);
- }
-
- /**
- * {@inheritDoc}
- */
- public EntityRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
- return accessStrategyFactory.createEntityRegionAccessStrategy(this, accessType);
- }
-}
Index: rctags/ehcache-2.10.7.0.43/ehcache-search-parser/src/main/java/net/sf/ehcache/search/parser/MAggregate.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/ehcache-search-parser/src/main/java/net/sf/ehcache/search/parser/MAggregate.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/ehcache-search-parser/src/main/java/net/sf/ehcache/search/parser/MAggregate.java (revision 0)
@@ -1,130 +0,0 @@
-/**
- * Copyright Terracotta, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.sf.ehcache.search.parser;
-
-import net.sf.ehcache.search.aggregator.Aggregator;
-
-public class MAggregate implements ModelElement {
-
- /**
- * The aggregation type enum.
- */
- public static enum AggOp {
- /**
- * The Sum.
- */
- Sum,
- /**
- * The Min.
- */
- Min,
- /**
- * The Max.
- */
- Max,
- /**
- * The Average.
- */
- Average,
- /**
- * The Count.
- */
- Count
- }
-
- ;
-
- /**
- * The op.
- */
- private final AggOp op;
-
- /**
- * The attribute.
- */
- private final MAttribute ma;
-
- /**
- * Instantiates a new m aggregate.
- *
- * @param op the operation
- * @param ma the attribute
- */
- public MAggregate(AggOp op, MAttribute ma) {
- this.op = op;
- this.ma = ma;
- }
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return op.toString().toLowerCase() + "(" + ma + ")";
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((ma == null) ? 0 : ma.hashCode());
- result = prime * result + ((op == null) ? 0 : op.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null) return false;
- if (getClass() != obj.getClass()) return false;
- MAggregate other = (MAggregate)obj;
- if (ma == null) {
- if (other.ma != null) return false;
- } else if (!ma.equals(other.ma)) return false;
- if (op != other.op) return false;
- return true;
- }
-
- public AggOp getOp() {
- return op;
- }
-
- public MAttribute getAttribute() {
- return ma;
- }
-
- /**
- * Return this model aggregator as an ehacache aggregator.
- *
- * @return the aggregator
- */
- public Aggregator asEhcacheObject(ClassLoader loader) {
- switch (op) {
- case Sum:
- return ma.asEhcacheObject(loader).sum();
- case Min:
- return ma.asEhcacheObject(loader).min();
- case Max:
- return ma.asEhcacheObject(loader).max();
- case Count:
- return ma.asEhcacheObject(loader).count();
- case Average:
- return ma.asEhcacheObject(loader).average();
- }
- throw new IllegalStateException("Unknown agg operator: " + op);
- }
-
-}
Index: rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/transaction/ExpiredTransactionIDImpl.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/transaction/ExpiredTransactionIDImpl.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/transaction/ExpiredTransactionIDImpl.java (revision 0)
@@ -1,32 +0,0 @@
-/**
- * Copyright Terracotta, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.sf.ehcache.transaction;
-
-
-/**
- * @author Ludovic Orban
- */
-public class ExpiredTransactionIDImpl extends TransactionIDImpl {
-
- /**
- * Create an expired transaction ID
- * @param transactionId the non-expired transaction ID to copy
- */
- public ExpiredTransactionIDImpl(TransactionIDImpl transactionId) {
- super(transactionId);
- }
-
-}
Index: rctags/ehcache-2.10.7.0.43/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/async/DefaultAsyncConfig.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/async/DefaultAsyncConfig.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/async/DefaultAsyncConfig.java (revision 0)
@@ -1,78 +0,0 @@
-/*
- * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved.
- */
-package org.terracotta.modules.ehcache.async;
-
-import java.util.concurrent.TimeUnit;
-
-public class DefaultAsyncConfig implements AsyncConfig {
- private final static AsyncConfig INSTANCE = new DefaultAsyncConfig();
-
- public final static long WORK_DELAY = TimeUnit.SECONDS.toMillis(1L); // 1 second
- public final static long MAX_ALLOWED_FALLBEHIND = TimeUnit.SECONDS.toMillis(2L); // 2 seconds
- public final static int BATCH_SIZE = 1;
- public final static boolean BATCHING_ENABLED = false;
- public final static boolean SYNCHRONOUS_WRITE = false;
- public final static int RETRY_ATTEMPTS = 0;
- public final static long RETRY_ATTEMPT_DELAY = TimeUnit.SECONDS.toMillis(1L); // 1 second
- public final static int RATE_LIMIT = 0;
- public final static int MAX_QUEUE_SIZE = 0;
-
- /**
- * Return an {@code AsyncConfig} instance representing the default configuration.
- *
- * @return the default configuration
- */
- public static AsyncConfig getInstance() {
- return INSTANCE;
- }
-
- protected DefaultAsyncConfig() {
- // private constructor for singleton
- }
-
- @Override
- public long getWorkDelay() {
- return WORK_DELAY;
- }
-
- @Override
- public long getMaxAllowedFallBehind() {
- return MAX_ALLOWED_FALLBEHIND;
- }
-
- @Override
- public int getBatchSize() {
- return BATCH_SIZE;
- }
-
- @Override
- public boolean isBatchingEnabled() {
- return BATCHING_ENABLED;
- }
-
- @Override
- public boolean isSynchronousWrite() {
- return SYNCHRONOUS_WRITE;
- }
-
- @Override
- public int getRetryAttempts() {
- return RETRY_ATTEMPTS;
- }
-
- @Override
- public long getRetryAttemptDelay() {
- return RETRY_ATTEMPT_DELAY;
- }
-
- @Override
- public int getRateLimit() {
- return RATE_LIMIT;
- }
-
- @Override
- public int getMaxQueueSize() {
- return MAX_QUEUE_SIZE;
- }
-}
Index: rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/config/generator/model/elements/SizeOfPolicyConfigurationElement.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/config/generator/model/elements/SizeOfPolicyConfigurationElement.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/config/generator/model/elements/SizeOfPolicyConfigurationElement.java (revision 0)
@@ -1,67 +0,0 @@
-/**
- * Copyright Terracotta, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.sf.ehcache.config.generator.model.elements;
-
-import net.sf.ehcache.config.SizeOfPolicyConfiguration;
-import net.sf.ehcache.config.generator.model.NodeElement;
-import net.sf.ehcache.config.generator.model.SimpleNodeAttribute;
-import net.sf.ehcache.config.generator.model.SimpleNodeElement;
-
-/**
- * Element representing the {@link net.sf.ehcache.config.SizeOfPolicyConfiguration}
- *
- * @author Ludovic Orban
- *
- */
-public class SizeOfPolicyConfigurationElement extends SimpleNodeElement {
- private final SizeOfPolicyConfiguration sizeOfPolicyConfiguration;
-
- /**
- * Construtor accepting the parent and the {@link net.sf.ehcache.config.SizeOfPolicyConfiguration}
- *
- * @param parent
- * @param sizeOfPolicyConfiguration
- */
- public SizeOfPolicyConfigurationElement(ConfigurationElement parent, SizeOfPolicyConfiguration sizeOfPolicyConfiguration) {
- super(parent, "sizeOfPolicy");
- this.sizeOfPolicyConfiguration = sizeOfPolicyConfiguration;
- init();
- }
-
- /**
- * Construtor accepting the element and the {@link net.sf.ehcache.config.SizeOfPolicyConfiguration}
- *
- * @param element
- * @param sizeOfPolicyConfiguration
- */
- public SizeOfPolicyConfigurationElement(NodeElement element, SizeOfPolicyConfiguration sizeOfPolicyConfiguration) {
- super(element, "sizeOfPolicy");
- this.sizeOfPolicyConfiguration = sizeOfPolicyConfiguration;
- init();
- }
-
- private void init() {
- if (sizeOfPolicyConfiguration == null) {
- return;
- }
- addAttribute(new SimpleNodeAttribute("maxDepth", sizeOfPolicyConfiguration.getMaxDepth())
- .optional(true).defaultValue(SizeOfPolicyConfiguration.DEFAULT_MAX_SIZEOF_DEPTH));
- addAttribute(new SimpleNodeAttribute("maxDepthExceededBehavior", sizeOfPolicyConfiguration.getMaxDepthExceededBehavior())
- .optional(true).defaultValue(SizeOfPolicyConfiguration.DEFAULT_MAX_DEPTH_EXCEEDED_BEHAVIOR));
- }
-
-}
Index: rctags/ehcache-2.10.7.0.43/system-tests/src/test/java/org/terracotta/ehcache/tests/txns/TwoResourceBTMXATest.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/system-tests/src/test/java/org/terracotta/ehcache/tests/txns/TwoResourceBTMXATest.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/system-tests/src/test/java/org/terracotta/ehcache/tests/txns/TwoResourceBTMXATest.java (revision 0)
@@ -1,33 +0,0 @@
-/*
- * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved.
- */
-package org.terracotta.ehcache.tests.txns;
-
-import org.terracotta.ehcache.tests.AbstractCacheTestBase;
-import org.terracotta.test.util.TestBaseUtil;
-
-import bitronix.tm.TransactionManagerServices;
-
-import com.tc.test.config.model.TestConfig;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class TwoResourceBTMXATest extends AbstractCacheTestBase {
-
- public TwoResourceBTMXATest(TestConfig testConfig) {
- super("two-resource-xa-test.xml", testConfig, BTMTwoResourceTx1.class, BTMTwoResourceTx2.class);
- testConfig.getClientConfig().setParallelClients(true);
-
- // DEV-3930
- // disableAllUntil("2010-03-31");
- }
-
- @Override
- protected List getExtraJars() {
- List extraJars = new ArrayList();
- extraJars.add(TestBaseUtil.jarFor(TransactionManagerServices.class));
- return extraJars;
- }
-
-}
Index: rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/search/impl/OrderComparator.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/search/impl/OrderComparator.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/search/impl/OrderComparator.java (revision 0)
@@ -1,137 +0,0 @@
-/**
- * Copyright Terracotta, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.sf.ehcache.search.impl;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-
-import net.sf.ehcache.store.StoreQuery.Ordering;
-
-/**
- * Compound sort ordering comparactor
- *
- * @author teck
- * @param
- */
-public class OrderComparator implements Comparator {
-
- private final List> comparators;
-
- /**
- * Constructor
- *
- * @param orderings
- */
- public OrderComparator(List orderings) {
- comparators = new ArrayList>();
- int pos = 0;
- for (Ordering ordering : orderings) {
- switch (ordering.getDirection()) {
- case ASCENDING: {
- comparators.add(new AscendingComparator(pos));
- break;
- }
- case DESCENDING: {
- comparators.add(new DescendingComparator(pos));
- break;
- }
- default: {
- throw new AssertionError(ordering.getDirection());
- }
- }
-
- pos++;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public int compare(T o1, T o2) {
- for (Comparator c : comparators) {
- int cmp = c.compare(o1, o2);
- if (cmp != 0) {
- return cmp;
- }
- }
- return 0;
- }
-
- /**
- * Simple ascending comparator
- */
- private class AscendingComparator implements Comparator, Serializable {
-
- private final int pos;
-
- AscendingComparator(int pos) {
- this.pos = pos;
- }
-
- public int compare(T o1, T o2) {
- Object attr1 = o1.getSortAttribute(pos);
- Object attr2 = o2.getSortAttribute(pos);
-
- if ((attr1 == null) && (attr2 == null)) {
- return 0;
- }
-
- if (attr1 == null) {
- return -1;
- }
-
- if (attr2 == null) {
- return 1;
- }
-
- return ((Comparable) attr1).compareTo(attr2);
- }
- }
-
- /**
- * Simple descending comparator
- */
- private class DescendingComparator implements Comparator, Serializable {
-
- private final int pos;
-
- DescendingComparator(int pos) {
- this.pos = pos;
- }
-
- public int compare(T o1, T o2) {
- Object attr1 = o1.getSortAttribute(pos);
- Object attr2 = o2.getSortAttribute(pos);
-
- if ((attr1 == null) && (attr2 == null)) {
- return 0;
- }
-
- if (attr1 == null) {
- return 1;
- }
-
- if (attr2 == null) {
- return -1;
- }
-
- return ((Comparable) attr2).compareTo(attr1);
- }
- }
-}
Index: rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/pool/Size.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/pool/Size.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/pool/Size.java (revision 0)
@@ -1,58 +0,0 @@
-/**
- * Copyright Terracotta, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.sf.ehcache.pool;
-
-/**
- * Holder for the size calculated by the SizeOf engine
- *
- * @author Ludovic Orban
- */
-public final class Size {
-
- private final long calculated;
- private final boolean exact;
-
- /**
- * Constructor
- *
- * @param calculated the calculated size
- * @param exact true if the calculated size is exact, false if it's an estimate or known to be inaccurate in some way
- */
- public Size(long calculated, boolean exact) {
- this.calculated = calculated;
- this.exact = exact;
- }
-
- /**
- * Get the calculated size
- *
- * @return the calculated size
- */
- public long getCalculated() {
- return calculated;
- }
-
- /**
- * Check if the calculated size is exact
- *
- * @return true if the calculated size is exact, false if it's an estimate or known to be inaccurate in some way
- */
- public boolean isExact() {
- return exact;
- }
-
-}
Index: rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/transaction/SoftLockFactory.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/transaction/SoftLockFactory.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/transaction/SoftLockFactory.java (revision 0)
@@ -1,35 +0,0 @@
-/**
- * Copyright Terracotta, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.sf.ehcache.transaction;
-
-/**
- * A factory of soft-locks supporting a specific isolation level.
- *
- * @author Chris Dennis
- */
-public interface SoftLockFactory {
-
- /**
- * Construct a new softlock to be managed by the given manager for a specific key.
- *
- * @param manager soft lock manager
- * @param key key to generate against
- * @return a new soft lock
- */
- SoftLock newSoftLock(SoftLockManager manager, Object key);
-
-}
Index: rctags/ehcache-2.10.7.0.43/ehcache-scheduled-refresh/src/main/java/net/sf/ehcache/constructs/scheduledrefresh/RefreshBatchJob.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/ehcache-scheduled-refresh/src/main/java/net/sf/ehcache/constructs/scheduledrefresh/RefreshBatchJob.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/ehcache-scheduled-refresh/src/main/java/net/sf/ehcache/constructs/scheduledrefresh/RefreshBatchJob.java (revision 0)
@@ -1,157 +0,0 @@
-/**
- * Copyright Terracotta, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.sf.ehcache.constructs.scheduledrefresh;
-
-import net.sf.ehcache.CacheManager;
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.Element;
-import net.sf.ehcache.loader.CacheLoader;
-import org.quartz.Job;
-import org.quartz.JobDataMap;
-import org.quartz.JobExecutionContext;
-import org.quartz.JobExecutionException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.locks.ReentrantLock;
-
-/**
- * This class is used to actually process a batch of keys for refreshing.
- * Instances of this job are scheduled by the {@link OverseerJob} class.
- *
- * @author cschanck
- */
-public class RefreshBatchJob implements Job {
-
- private static final Logger LOG = LoggerFactory.getLogger(OverseerJob.class);
- private static HashMap bulkLoadTrackingMap = new HashMap(1);
- private static ReentrantLock bulkloadLock = new ReentrantLock();
-
- private static void requestBulkLoadEnabled(Ehcache cache) {
- bulkloadLock.lock();
- try {
- boolean prior = cache.isNodeBulkLoadEnabled();
- // yes, this is racy. we can do no better until we have per-thread bulk loading
- if (prior) {
- String key = cache.getCacheManager().getName() + "/" + cache.getName();
- AtomicInteger permits = bulkLoadTrackingMap.get(key);
- if (permits == null) {
- // first time in. actually switch it
- permits = new AtomicInteger(1);
- bulkLoadTrackingMap.put(key, permits);
- cache.setNodeBulkLoadEnabled(true);
- } else {
- permits.incrementAndGet();
- }
- }
- } finally {
- bulkloadLock.unlock();
- }
- }
-
- private static void requestBulkLoadRestored(Ehcache cache) {
- bulkloadLock.lock();
- try {
- String key = cache.getCacheManager().getName() + "/" + cache.getName();
- AtomicInteger permits = bulkLoadTrackingMap.get(key);
- if (permits != null) {
- if (permits.decrementAndGet() == 0) {
- // last one out. reset it to true
- bulkLoadTrackingMap.remove(key);
- cache.setNodeBulkLoadEnabled(true);
- }
- }
- } finally {
- bulkloadLock.unlock();
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Override
- public void execute(JobExecutionContext context) throws JobExecutionException {
- try {
- JobDataMap jdm = context.getMergedJobDataMap();
- ScheduledRefreshConfiguration config = (ScheduledRefreshConfiguration) jdm.get(ScheduledRefreshCacheExtension
- .PROP_CONFIG_OBJECT);
- String cacheManagerName = jdm.getString(ScheduledRefreshCacheExtension.PROP_CACHE_MGR_NAME);
- String cacheName = jdm.getString(ScheduledRefreshCacheExtension.PROP_CACHE_NAME);
-
- CacheManager cacheManager = CacheManager.getCacheManager(cacheManagerName);
- Ehcache underlyingCache = cacheManager.getEhcache(cacheName);
-
- HashSet extends Object> keysToProcess = new HashSet((Collection extends Object>) jdm.get(
- ScheduledRefreshCacheExtension.PROP_KEYS_TO_PROCESS));
-
- ScheduledRefreshCacheExtension extension = ScheduledRefreshCacheExtension.findExtensionFromCache(underlyingCache,
- context.getJobDetail().getKey().getGroup());
- boolean keepingStats=false;
- if (extension != null) {
- extension.incrementJobCount();
- extension.incrementProcessedCount(keysToProcess.size());
- keepingStats=true;
- }
-
- LOG.info("Scheduled refresh batch job: " + context.getJobDetail().getKey() + " size: " + keysToProcess.size()+" "+OverseerJob.statsNote(keepingStats));
- try {
- if (config.isUseBulkload()) {
- requestBulkLoadEnabled(underlyingCache);
- }
- } catch (UnsupportedOperationException e) {
- LOG.warn("Bulk Load requested for cache that does not support bulk load.");
- }
-
- // iterate through the loaders
- for (CacheLoader loader : underlyingCache.getRegisteredCacheLoaders()) {
- // if we are out of keys, punt
- if (keysToProcess.isEmpty()) {
- break;
- }
-
- // try and load them all
- Map extends Object, ? extends Object> values = loader.loadAll(keysToProcess);
- // subtract the ones that were loaded
- keysToProcess.removeAll(values.keySet());
- for (Map.Entry extends Object, ? extends Object> entry : values.entrySet()) {
- Element newElement = new Element(entry.getKey(), entry.getValue());
- underlyingCache.put(newElement);
- }
- }
- // assume we got here ok, now evict any that don't evict
- if (config.isEvictOnLoadMiss() && !keysToProcess.isEmpty()) {
- underlyingCache.removeAll(keysToProcess);
- }
-
- try {
- if (config.isUseBulkload()) {
- requestBulkLoadRestored(underlyingCache);
- }
- } catch (UnsupportedOperationException e) {
- // warned above.
- }
- }
- catch(Throwable t) {
- LOG.warn("Scheduled refresh batch job failure: " + context.getJobDetail().getKey(), t);
- }
-
- }
-
-}
Index: rctags/ehcache-2.10.7.0.43/distribution/events/src/assemble/bin/stop-jetty.bat
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/distribution/events/src/assemble/bin/stop-jetty.bat (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/distribution/events/src/assemble/bin/stop-jetty.bat (revision 0)
@@ -1,38 +0,0 @@
-@echo off
-
-if not defined JAVA_HOME (
- echo JAVA_HOME is not defined
- exit /b 1
-)
-
-setlocal
-
-set jetty_instance=%1
-
-if "%jetty_instance%" == "" (
- echo Need to specify which instance of Jetty: 9081 or 9082
- exit /b 1
-)
-
-pushd "%~d0%~p0"
-for /f "tokens=*" %%a in ('call relative-paths.bat tc_install_dir') do set tc_install_dir=%%a
-pushd
-cd %tc_install_dir%
-set tc_install_dir=%CD%
-set tc_install_dir="%tc_install_dir:"=%"
-popd
-popd
-
-set JAVA_HOME="%JAVA_HOME:"=%"
-set root=%~d0%~p0..
-set root="%root:"=%"
-set jetty_work_dir=%root%\jetty6.1\%jetty_instance%
-set jetty_home=%tc_install_dir%\third-party\jetty-6.1.15
-set start_jar=%jetty_home%\start.jar
-set /a stop_port=jetty_instance + 2
-
-cd %jetty_work_dir%
-echo Stopping Jetty %jetty_instance%...
-%JAVA_HOME%\bin\java -Djetty.home=%jetty_home% -DSTOP.PORT=%stop_port% -DSTOP.KEY=secret -jar %start_jar% --stop
-
-endlocal
Index: rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/search/impl/ResultImpl.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/search/impl/ResultImpl.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/search/impl/ResultImpl.java (revision 0)
@@ -1,77 +0,0 @@
-/**
- * Copyright Terracotta, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.sf.ehcache.search.impl;
-
-import java.util.Map;
-
-import net.sf.ehcache.store.StoreQuery;
-
-/**
- * Result implementation
- *
- * @author teck
- */
-public class ResultImpl extends BaseResult {
-
- private final Object key;
- private final Object value;
- private final Map attributes;
- private final Object[] sortAttributes;
-
- /**
- * Constructor
- *
- * @param key
- * @param value
- * @param query
- * @param attributes
- * @param sortAttributes
- */
- public ResultImpl(Object key, Object value, StoreQuery query, Map attributes, Object[] sortAttributes) {
- super(query);
- this.key = key;
- this.value = value;
- this.attributes = attributes;
- this.sortAttributes = sortAttributes;
- }
-
- /**
- * Get attribute value for use in sorting
- *
- * @param pos
- * @return
- */
- Object getSortAttribute(int pos) {
- return sortAttributes[pos];
- }
-
- @Override
- protected Object basicGetKey() {
- return key;
- }
-
- @Override
- protected Object basicGetValue() {
- return value;
- }
-
- @Override
- protected Object basicGetAttribute(String name) {
- return attributes.get(name);
- }
-
-}
Index: rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/transaction/DelegatingTransactionIDFactory.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/transaction/DelegatingTransactionIDFactory.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/transaction/DelegatingTransactionIDFactory.java (revision 0)
@@ -1,151 +0,0 @@
-/**
- * Copyright Terracotta, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.sf.ehcache.transaction;
-
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.FeaturesManager;
-import net.sf.ehcache.terracotta.ClusteredInstanceFactory;
-import net.sf.ehcache.terracotta.TerracottaClient;
-import net.sf.ehcache.transaction.xa.XidTransactionID;
-
-import java.util.Set;
-import java.util.UUID;
-import java.util.concurrent.atomic.AtomicReference;
-
-import javax.transaction.xa.Xid;
-
-/**
- * A TransactionIDFactory implementation with delegates calls to either a clustered
- * or non-clustered factory
- *
- * @author Ludovic Orban
- */
-public class DelegatingTransactionIDFactory implements TransactionIDFactory {
-
- private final FeaturesManager featuresManager;
- private final TerracottaClient terracottaClient;
- private final String cacheManagerName;
- private volatile ClusteredInstanceFactory clusteredInstanceFactory;
- private volatile AtomicReference transactionIDFactory = new AtomicReference();
-
- /**
- * Create a new DelegatingTransactionIDFactory
- *
- * @param terracottaClient a terracotta client
- * @param cacheManagerName the name of the cache manager which creates this.
- */
- public DelegatingTransactionIDFactory(FeaturesManager featuresManager, TerracottaClient terracottaClient, String cacheManagerName) {
- this.featuresManager = featuresManager;
- this.terracottaClient = terracottaClient;
- this.cacheManagerName = cacheManagerName;
- }
-
- private TransactionIDFactory get() {
- ClusteredInstanceFactory cif = terracottaClient.getClusteredInstanceFactory();
- if (cif != null && cif != this.clusteredInstanceFactory) {
- this.transactionIDFactory.set(cif.createTransactionIDFactory(UUID.randomUUID().toString(), cacheManagerName));
- this.clusteredInstanceFactory = cif;
- }
-
- if (transactionIDFactory.get() == null) {
- TransactionIDFactory constructed;
- if (featuresManager == null) {
- constructed = new TransactionIDFactoryImpl();
- } else {
- constructed = featuresManager.createTransactionIDFactory();
- }
- if (transactionIDFactory.compareAndSet(null, constructed)) {
- return constructed;
- } else {
- return transactionIDFactory.get();
- }
- } else {
- return transactionIDFactory.get();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public TransactionID createTransactionID() {
- return get().createTransactionID();
- }
-
- /**
- * {@inheritDoc}
- */
- public TransactionID restoreTransactionID(TransactionIDSerializedForm serializedForm) {
- return get().restoreTransactionID(serializedForm);
- }
-
- /**
- * {@inheritDoc}
- */
- public XidTransactionID createXidTransactionID(Xid xid, Ehcache cache) {
- return get().createXidTransactionID(xid, cache);
- }
-
- /**
- * {@inheritDoc}
- */
- public XidTransactionID restoreXidTransactionID(XidTransactionIDSerializedForm serializedForm) {
- return get().restoreXidTransactionID(serializedForm);
- }
-
- @Override
- public void markForCommit(TransactionID transactionID) {
- get().markForCommit(transactionID);
- }
-
- @Override
- public void markForRollback(XidTransactionID transactionID) {
- get().markForRollback(transactionID);
- }
-
- @Override
- public boolean isDecisionCommit(TransactionID transactionID) {
- return get().isDecisionCommit(transactionID);
- }
-
- @Override
- public void clear(TransactionID transactionID) {
- get().clear(transactionID);
- }
-
- @Override
- public Set getAllXidTransactionIDsFor(Ehcache cache) {
- return get().getAllXidTransactionIDsFor(cache);
- }
-
- @Override
- public Set getAllTransactionIDs() {
- return get().getAllTransactionIDs();
- }
-
- @Override
- public boolean isExpired(TransactionID transactionID) {
- return get().isExpired(transactionID);
- }
-
- @Override
- public Boolean isPersistent() {
- if (transactionIDFactory.get() == null) {
- return null;
- } else {
- return get().isPersistent();
- }
- }
-}
Index: rctags/ehcache-2.10.7.0.43/system-tests/src/test/java/org/terracotta/ehcache/tests/servermap/ServerMapElementTTLExpressTest.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/system-tests/src/test/java/org/terracotta/ehcache/tests/servermap/ServerMapElementTTLExpressTest.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/system-tests/src/test/java/org/terracotta/ehcache/tests/servermap/ServerMapElementTTLExpressTest.java (revision 0)
@@ -1,37 +0,0 @@
-/*
- * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved.
- */
-package org.terracotta.ehcache.tests.servermap;
-
-import org.terracotta.ehcache.tests.AbstractCacheTestBase;
-
-import com.tc.properties.TCPropertiesConsts;
-import com.tc.test.config.model.TestConfig;
-
-import java.util.Iterator;
-
-public class ServerMapElementTTLExpressTest extends AbstractCacheTestBase {
-
- public ServerMapElementTTLExpressTest(TestConfig testConfig) {
- super("/servermap/basic-servermap-cache-test.xml", testConfig, ServerMapElementTTLExpressTestClient.class);
- testConfig.setDgcEnabled(true);
- testConfig.setDgcIntervalInSec(60);
- testConfig.addTcProperty("ehcache.evictor.logging.enabled", "true");
- testConfig.addTcProperty(TCPropertiesConsts.EHCACHE_EVICTOR_LOGGING_ENABLED, "true");
- testConfig.addTcProperty(TCPropertiesConsts.EHCACHE_STORAGESTRATEGY_DCV2_EVICT_UNEXPIRED_ENTRIES_ENABLED, "false");
- testConfig.addTcProperty(TCPropertiesConsts.EHCACHE_STORAGESTRATEGY_DCV2_PERELEMENT_TTI_TTL_ENABLED, "true");
-
- final Iterator iter = testConfig.getClientConfig().getExtraClientJvmArgs().iterator();
- while (iter.hasNext()) {
- final String prop = iter.next();
- if (prop.contains("ehcache.storageStrategy.dcv2.localcache.enabled")) {
- // remove it and always disable localcache for this test
- iter.remove();
- }
- }
- // always disable local cache
- testConfig.getClientConfig().addExtraClientJvmArg("-Dcom.tc.ehcache.storageStrategy.dcv2.localcache.enabled=false");
- testConfig.getClientConfig().addExtraClientJvmArg("-Dcom.tc.ehcache.evictor.logging.enabled=true");
- }
-
-}
Index: rctags/ehcache-2.10.7.0.43/system-tests/src/test/resources/one-cache-test.xml
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/system-tests/src/test/resources/one-cache-test.xml (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/system-tests/src/test/resources/one-cache-test.xml (revision 0)
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
Index: rctags/ehcache-2.10.7.0.43/ehcache-core/src/test/java/net/sf/ehcache/search/DynamicAttributeExtractorTest.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/ehcache-core/src/test/java/net/sf/ehcache/search/DynamicAttributeExtractorTest.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/ehcache-core/src/test/java/net/sf/ehcache/search/DynamicAttributeExtractorTest.java (revision 0)
@@ -1,180 +0,0 @@
-/**
- * Copyright Terracotta, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.sf.ehcache.search;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import static junit.framework.Assert.*;
-
-import net.sf.ehcache.CacheManager;
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.Element;
-import net.sf.ehcache.config.CacheConfiguration;
-import net.sf.ehcache.config.Configuration;
-import net.sf.ehcache.config.SearchAttribute;
-import net.sf.ehcache.config.Searchable;
-import net.sf.ehcache.search.Person.Gender;
-import net.sf.ehcache.search.aggregator.Aggregators;
-import net.sf.ehcache.search.attribute.DynamicAttributesExtractor;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class DynamicAttributeExtractorTest {
-
- private CacheManager cm;
- private Ehcache cache;
-
- private Attribute age;
- private Attribute name;
- private Attribute dept;
-
- private final Attribute gender = new Attribute("gender"); // dynamically extracted
-
- private final DynamicAttributesExtractor indexer = new DynamicAttributesExtractor() {
-
- @Override
- public Map attributesFor(Element element) {
- Person p = (Person) element.getObjectValue();
- return Collections.singletonMap("gender", p.getGender());
- }
- };
-
- @Before
- public void setUp() throws Exception {
- Configuration cfg = new Configuration();
- CacheConfiguration cacheCfg = new CacheConfiguration("searchCache", 1000);
- Searchable s = new Searchable();
- s.keys(true);
- s.allowDynamicIndexing(true);
- s.addSearchAttribute(new SearchAttribute().name("age"));
- s.addSearchAttribute(new SearchAttribute().name("name"));
- s.addSearchAttribute(new SearchAttribute().name("department"));
- cacheCfg.searchable(s);
- cfg.addCache(cacheCfg);
-
- cm = new CacheManager(cfg);
- cache = cm.getCache("searchCache");
- cache.registerDynamicAttributesExtractor(indexer);
- SearchTestUtil.populateData(cache);
-
- age = cache.getSearchAttribute("age");
- dept = cache.getSearchAttribute("department");
- name = cache.getSearchAttribute("name");
- }
-
- @After
- public void tearDown() throws Exception {
- cm.shutdown();
- }
-
- private void verifyOrdered(Query q, int... expectedKeys) {
- Results results = q.execute();
- assertEquals(expectedKeys.length, results.size());
- if (expectedKeys.length == 0) {
- assertFalse(results.hasKeys());
- } else {
- assertTrue(results.hasKeys());
- }
- assertFalse(results.hasAttributes());
-
- int i = 0;
- for (Result result : results.all()) {
-
- int key = (Integer) result.getKey();
- assertEquals(expectedKeys[i++], key);
- }
- }
-
- private void verify(Query q, Integer... expectedKeys) {
- Results results = q.execute();
- assertEquals(expectedKeys.length, results.size());
- if (expectedKeys.length == 0) {
- assertFalse(results.hasKeys());
- } else {
- assertTrue(results.hasKeys());
- }
- assertFalse(results.hasAttributes());
-
- Set keys = new HashSet(Arrays.asList(expectedKeys));
- for (Result result : results.all()) {
-
- int key = (Integer) result.getKey();
- if (!keys.remove(key)) {
- throw new AssertionError("unexpected key: " + key);
- }
- }
- }
-
- @Test
- public void testBasicCriteria() {
- Query q = cache.createQuery();
- q.addCriteria(gender.eq(Gender.MALE));
- q.includeKeys();
- verify(q, 1, 3, 4);
-
- q.addCriteria(age.lt(31));
- verify(q, 4);
-
- q = cache.createQuery();
- q.includeKeys();
- q.addCriteria(gender.ne(Gender.MALE).and(dept.ilike("eng?")));
- verify(q, 2);
-
- }
-
- @Test
- public void testSorting() {
- Query q = cache.createQuery().includeKeys();
- q.addOrderBy(gender, Direction.DESCENDING);
- q.addOrderBy(name, Direction.ASCENDING);
- verifyOrdered(q, 2, 3, 4, 1);
- }
-
- @Test
- public void testGroupBy() {
- Query q = cache.createQuery().addGroupBy(gender);
- q.includeAggregator(age.max());
- Results res = q.execute();
- assertEquals(2, res.size());
- }
-
- @Test
- public void testAggregators() {
- Query q = cache.createQuery().addCriteria(gender.eq(Gender.MALE));
- q.includeAggregator(Aggregators.count());
- q.addCriteria(dept.ilike("sales*").not());
- Results res = q.execute();
- assertEquals(1, res.size());
- assertEquals(3, res.all().get(0).getAggregatorResults().get(0));
- }
-
- @Test
- public void testAttributeSelect() {
- Query q = cache.createQuery().includeAttribute(gender, age).addCriteria(gender.ne(Gender.MALE));
- Results res = q.execute();
- assertEquals(1, res.size());
- Result r = res.all().get(0);
- assertEquals(Gender.FEMALE, r.getAttribute(gender));
- assertEquals(23, r.getAttribute(age).intValue());
- }
-}
Index: rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/constructs/blocking/package.html
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/constructs/blocking/package.html (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/constructs/blocking/package.html (revision 0)
@@ -1,11 +0,0 @@
-
-
-
-
- Doug Lea in his book Concurrent Programming in Java talks about concurrency support constructs.
- One meaning of a construct is "an abstract or general idea inferred or derived from specific instances".
- Just like patterns emerge from noting the similarities of problems and gradually finding a solution to
- classes of them, so to constructs are general solutions to commond problems. With the constructs package,
- concrete, extensible implementations are offered to solve these common problems.
-
-
Index: rctags/ehcache-2.10.7.0.43/system-tests/src/test/resources/cache-locks-test.xml
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/system-tests/src/test/resources/cache-locks-test.xml (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/system-tests/src/test/resources/cache-locks-test.xml (revision 0)
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Index: rctags/ehcache-2.10.7.0.43/system-tests/src/test/java/org/terracotta/modules/ehcache/store/DynamicCacheConfigurationTest.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/system-tests/src/test/java/org/terracotta/modules/ehcache/store/DynamicCacheConfigurationTest.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/system-tests/src/test/java/org/terracotta/modules/ehcache/store/DynamicCacheConfigurationTest.java (revision 0)
@@ -1,368 +0,0 @@
-/*
- * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved.
- */
-package org.terracotta.modules.ehcache.store;
-
-import net.sf.ehcache.Cache;
-import net.sf.ehcache.CacheManager;
-import net.sf.ehcache.Element;
-import net.sf.ehcache.config.CacheConfiguration;
-import net.sf.ehcache.config.TerracottaConfiguration;
-import net.sf.ehcache.config.TerracottaConfiguration.Consistency;
-import org.junit.Assert;
-import org.terracotta.ehcache.tests.AbstractCacheTestBase;
-import org.terracotta.ehcache.tests.ClientBase;
-import org.terracotta.test.util.WaitUtil;
-import org.terracotta.toolkit.Toolkit;
-
-import com.tc.properties.TCPropertiesConsts;
-import com.tc.test.config.model.TestConfig;
-
-import java.util.concurrent.Callable;
-
-import static java.util.concurrent.TimeUnit.SECONDS;
-
-/**
- * @author cdennis
- */
-public class DynamicCacheConfigurationTest extends AbstractCacheTestBase {
- public DynamicCacheConfigurationTest(TestConfig testConfig) {
- super(testConfig, App.class);
- testConfig.addTcProperty(TCPropertiesConsts.L2_SERVERMAP_EVICTION_CLIENTOBJECT_REFERENCES_REFRESH_INTERVAL, "5000");
- testConfig.addTcProperty(TCPropertiesConsts.EHCACHE_EVICTOR_LOGGING_ENABLED, "true");
- }
-
- public static class App extends ClientBase {
- private static final double TOLERANCE = 0.1;
-
- public App(String[] args) {
- super(args);
- }
-
- public static void main(String[] args) {
- new App(args).run();
- }
-
- @Override
- protected void runTest(Cache cache, Toolkit clusteringToolkit) throws Throwable {
- testTTIChange(cacheManager);
- testTTLChange(cacheManager);
- testDiskCapacityChange(cacheManager);
- testMemoryCapacityChange(cacheManager);
- testTTIChangeWithCustomElements(cacheManager);
- testTTLChangeWithCustomElements(cacheManager);
- }
-
- private Cache createCache(String cacheName, int maxMemory, boolean eternal, long ttl, long tti) {
- return new Cache(new CacheConfiguration(cacheName, maxMemory)
- .eternal(eternal)
- .timeToLiveSeconds(ttl)
- .timeToIdleSeconds(tti)
- .clearOnFlush(true)
- .terracotta(new TerracottaConfiguration().clustered(true).consistency(Consistency.STRONG)
- .coherentReads(true).orphanEviction(true).orphanEvictionPeriod(4).localKeyCache(false)
- .localKeyCacheSize(0).copyOnRead(false)).logging(true));
- }
-
- private void testTTIChange(CacheManager manager) throws InterruptedException {
- Cache cache = createCache("testTTIChange", 10, false, 0, 10);
- manager.addCache(cache);
-
- cache.put(new Element("key1", new byte[0]));
- cache.put(new Element("key2", new byte[0]));
-
- SECONDS.sleep(6);
-
- cache.get("key2");
-
- SECONDS.sleep(6);
-
- Assert.assertNull(cache.get("key1"));
- Assert.assertNotNull(cache.get("key2"));
-
- cache.getCacheConfiguration().setTimeToIdleSeconds(20);
- long currentTime = System.currentTimeMillis();
-
- cache.put(new Element("key1", new byte[0]));
-
- SECONDS.sleep(15);
-
- Assert.assertNotNull(cache.get("key1"));
- if (System.currentTimeMillis() - currentTime < 20000 ) {
- Assert.assertNotNull(cache.get("key2"));
- } else {
- Assert.assertNull(cache.get("key2"));
- }
-
- SECONDS.sleep(25);
-
- Assert.assertNull(cache.get("key1"));
- Assert.assertNull(cache.get("key2"));
-
- cache.getCacheConfiguration().setTimeToIdleSeconds(4);
-
- cache.put(new Element("key1", new byte[0]));
- cache.put(new Element("key2", new byte[0]));
-
- SECONDS.sleep(8);
-
- Assert.assertNull(cache.get("key1"));
- Assert.assertNull(cache.get("key2"));
-
- cache.removeAll();
- }
-
- private void testTTLChange(CacheManager cm) throws InterruptedException {
- Cache cache = createCache("testTTLChange", 10, false, 10, 0);
- cm.addCache(cache);
-
- cache.put(new Element("key1", new byte[0]));
-
- SECONDS.sleep(6);
-
- Assert.assertNotNull(cache.get("key1"));
- cache.put(new Element("key2", new byte[0]));
-
- SECONDS.sleep(6);
-
- Assert.assertNull(cache.get("key1"));
- Assert.assertNotNull(cache.get("key2"));
-
- cache.getCacheConfiguration().setTimeToLiveSeconds(20);
-
- cache.put(new Element("key1", new byte[0]));
-
- SECONDS.sleep(8);
-
- Assert.assertNotNull(cache.get("key1"));
- Assert.assertNotNull(cache.get("key2"));
-
- SECONDS.sleep(8);
-
- Assert.assertNotNull(cache.get("key1"));
- Assert.assertNull(cache.get("key2"));
-
- SECONDS.sleep(10);
-
- Assert.assertNull(cache.get("key1"));
-
- cache.getCacheConfiguration().setTimeToLiveSeconds(4);
-
- cache.put(new Element("key1", new byte[0]));
- cache.put(new Element("key2", new byte[0]));
-
- SECONDS.sleep(8);
-
- Assert.assertNull(cache.get("key1"));
- Assert.assertNull(cache.get("key2"));
-
- cache.removeAll();
- }
-
- public void testTTIChangeWithCustomElements(CacheManager cm) throws InterruptedException {
- Cache cache = createCache("testTTIChangeWithCustomElements", 10, false, 0, 10);
- cm.addCache(cache);
-
- cache.put(new Element("default", new byte[0]));
- cache.put(new Element("eternal", new byte[0], true, 0, 0));
- cache.put(new Element("short", new byte[0], false, 1, 1));
- cache.put(new Element("long", new byte[0], true, 100, 100));
-
- SECONDS.sleep(6);
-
- Assert.assertNull(cache.get("short"));
-
- SECONDS.sleep(6);
-
- Assert.assertNull(cache.get("default"));
- Assert.assertNotNull(cache.get("eternal"));
- Assert.assertNull(cache.get("short"));
- Assert.assertNotNull(cache.get("long"));
-
- cache.getCacheConfiguration().setTimeToIdleSeconds(20);
-
- cache.put(new Element("default", new byte[0]));
- cache.put(new Element("short", new byte[0], false, 1, 1));
-
- SECONDS.sleep(15);
-
- Assert.assertNotNull(cache.get("default"));
- Assert.assertNotNull(cache.get("eternal"));
- Assert.assertNull(cache.get("short"));
- Assert.assertNotNull(cache.get("long"));
-
- SECONDS.sleep(25);
-
- Assert.assertNull(cache.get("default"));
- Assert.assertNotNull(cache.get("eternal"));
- Assert.assertNull(cache.get("short"));
- Assert.assertNotNull(cache.get("long"));
-
- cache.getCacheConfiguration().setTimeToIdleSeconds(4);
-
- cache.put(new Element("default", new byte[0]));
- cache.put(new Element("short", new byte[0], false, 1, 1));
-
- SECONDS.sleep(8);
-
- Assert.assertNull(cache.get("default"));
- Assert.assertNotNull(cache.get("eternal"));
- Assert.assertNull(cache.get("short"));
- Assert.assertNotNull(cache.get("long"));
-
- cache.removeAll();
- }
-
- public void testTTLChangeWithCustomElements(CacheManager cm) throws InterruptedException {
- Cache cache = createCache("testTTLChangeWithCustomElements", 10, false, 10, 0);
- cm.addCache(cache);
-
- cache.put(new Element("default", new byte[0]));
- cache.put(new Element("eternal", new byte[0], true, 0, 0));
- cache.put(new Element("short", new byte[0], false, 1, 1));
- cache.put(new Element("long", new byte[0], true, 100, 100));
-
- SECONDS.sleep(6);
-
- Assert.assertNotNull(cache.get("default"));
- Assert.assertNotNull(cache.get("eternal"));
- Assert.assertNull(cache.get("short"));
- Assert.assertNotNull(cache.get("long"));
-
- SECONDS.sleep(6);
-
- Assert.assertNull(cache.get("default"));
- Assert.assertNotNull(cache.get("eternal"));
- Assert.assertNull(cache.get("short"));
- Assert.assertNotNull(cache.get("long"));
-
- cache.getCacheConfiguration().setTimeToLiveSeconds(20);
-
- cache.put(new Element("default", new byte[0]));
- cache.put(new Element("short", new byte[0], false, 1, 1));
-
- SECONDS.sleep(6);
-
- Assert.assertNotNull(cache.get("default"));
- Assert.assertNotNull(cache.get("eternal"));
- Assert.assertNull(cache.get("short"));
- Assert.assertNotNull(cache.get("long"));
-
- SECONDS.sleep(6);
-
- Assert.assertNotNull(cache.get("default"));
- Assert.assertNotNull(cache.get("eternal"));
- Assert.assertNull(cache.get("short"));
- Assert.assertNotNull(cache.get("long"));
-
- SECONDS.sleep(10);
-
- Assert.assertNull(cache.get("default"));
- Assert.assertNotNull(cache.get("eternal"));
- Assert.assertNull(cache.get("short"));
- Assert.assertNotNull(cache.get("long"));
-
- cache.getCacheConfiguration().setTimeToLiveSeconds(4);
-
- cache.put(new Element("default", new byte[0]));
- cache.put(new Element("short", new byte[0], false, 1, 1));
-
- SECONDS.sleep(8);
-
- Assert.assertNull(cache.get("default"));
- Assert.assertNotNull(cache.get("eternal"));
- Assert.assertNull(cache.get("short"));
- Assert.assertNotNull(cache.get("long"));
-
- cache.removeAll();
- }
-
- private void testMemoryCapacityChange(CacheManager cm) throws Exception {
- final Cache cache = createCache("testMemoryCapacityChange", 100, true, 0, 0);
- cache.getCacheConfiguration().getTerracottaConfiguration()
- .consistency(TerracottaConfiguration.Consistency.STRONG);
- cm.addCache(cache);
-
- int i = 0;
- for (; i < 150; i++) {
- cache.put(new Element("key" + i, new byte[0]));
- }
-
- waitForCacheMemoryStoreSize(cache, 100);
-
- cache.getCacheConfiguration().setMaxEntriesLocalHeap(200);
-
- for (; i < 250; i++) {
- cache.put(new Element("key" + i, new byte[0]));
- }
-
- waitForCacheMemoryStoreSize(cache, 100, 200);
-
- cache.getCacheConfiguration().setMaxEntriesLocalHeap(50);
-
- for (; i < 350; i++) {
- cache.put(new Element("key" + i, new byte[0]));
- }
-
- waitForCacheMemoryStoreSize(cache, 50);
-
- cache.removeAll();
- }
-
- private void waitForCacheMemoryStoreSize(final Cache cache, final int lowerBound, final int upperBound)
- throws Exception {
- final int min = (int) ((1 - TOLERANCE) * lowerBound);
- final int max = (int) ((1 + TOLERANCE) * upperBound);
- WaitUtil.waitUntilCallableReturnsTrue(new Callable() {
- @Override
- public Boolean call() throws Exception {
- if (cache.getStatistics().getLocalHeapSize() <= max && cache.getStatistics().getLocalHeapSize() >= min) {
- return true;
- }
- System.out.println("Still waiting for memory store size to fall in bounds [" + lowerBound + ", " + upperBound
- + "] current=" + cache.getStatistics().getLocalHeapSize());
- return false;
- }
- });
- }
-
- private void waitForCacheMemoryStoreSize(final Cache cache, final int upperBound) throws Exception {
- waitForCacheMemoryStoreSize(cache, 0, upperBound);
- }
-
- public void testDiskCapacityChange(CacheManager cm) throws Exception {
- final Cache cache = createCache("testDiskCapacityChange", 10, true, 0, 0);
- cache.getCacheConfiguration().maxEntriesLocalHeap(1).maxEntriesInCache(100).getTerracottaConfiguration()
- .consistency(TerracottaConfiguration.Consistency.STRONG).concurrency(16);
- cm.addCache(cache);
-
- testCacheDiskCapacity(cache, 100);
-
- cache.getCacheConfiguration().setMaxEntriesInCache(200);
-
- testCacheDiskCapacity(cache, 200);
-
- cache.getCacheConfiguration().setMaxEntriesInCache(50);
-
- testCacheDiskCapacity(cache, 50);
-
- cache.removeAll();
- }
-
- private void testCacheDiskCapacity(final Cache cache, final int capacity) throws Exception {
- for (int i = 0; i < 1000; i++) {
- cache.put(new Element("key" + i, new byte[0]));
- }
- System.out.println("Waiting on capacoty of " + capacity);
- WaitUtil.waitUntilCallableReturnsTrue(new Callable() {
- @Override
- public Boolean call() throws Exception {
- System.out.println("Current cache size " + cache.getSize());
- Assert.assertTrue(cache.getSize() > capacity * .85);
- return cache.getSize() >= capacity * 0.9 && cache.getSize() <= capacity * 1.1;
- }
- });
- }
-
- }
-}
Index: rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/hibernate/ccs/EhcacheReadOnlyCache.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/hibernate/ccs/EhcacheReadOnlyCache.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/hibernate/ccs/EhcacheReadOnlyCache.java (revision 0)
@@ -1,125 +0,0 @@
-/**
- * Copyright Terracotta, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.sf.ehcache.hibernate.ccs;
-
-import java.util.Comparator;
-
-import org.hibernate.cache.CacheException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.hibernate.cache.access.SoftLock;
-
-/**
- * Ehcache specific read-only cache concurrency strategy.
- *
- * This is the Ehcache specific equivalent to Hibernate's ReadOnlyCache.
- *
- * @author Chris Dennis
- */
-@Deprecated
-public class EhcacheReadOnlyCache extends AbstractEhcacheConcurrencyStrategy {
-
- private static final Logger LOG = LoggerFactory.getLogger(EhcacheReadOnlyCache.class);
-
- /**
- * {@inheritDoc}
- */
- public Object get(Object key, long timestamp) throws CacheException {
- return cache.get(key);
- }
-
- /**
- * Throws UnsupportedOperationException since items in a read-only cache should not be mutated.
- *
- * @throws UnsupportedOperationException always
- */
- public SoftLock lock(Object key, Object version) throws UnsupportedOperationException {
- LOG.error("Application attempted to edit read only item: " + key);
- throw new UnsupportedOperationException("Can't write to a readonly object");
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean put(Object key, Object value, long timestamp, Object version,
- Comparator versionComparator, boolean minimalPut) throws CacheException {
- if (minimalPut && cache.get(key) != null) {
- return false;
- } else {
- cache.put(key, value);
- return true;
- }
- }
-
- /**
- * Logs an error since items in a read-only cache should not be mutated.
- */
- public void release(Object key, SoftLock lock) {
- LOG.error("Application attempted to edit read only item: " + key);
- //throw new UnsupportedOperationException("Can't write to a readonly object");
- }
-
- /**
- * Throws UnsupportedOperationException since items in a read-only cache should not be mutated.
- *
- * @throws UnsupportedOperationException always
- */
- public boolean afterUpdate(Object key, Object value, Object version, SoftLock lock) throws UnsupportedOperationException {
- LOG.error("Application attempted to edit read only item: " + key);
- throw new UnsupportedOperationException("Can't write to a readonly object");
- }
-
- /**
- * Inserts the specified item into the cache.
- */
- public boolean afterInsert(Object key, Object value, Object version) throws CacheException {
- cache.update(key, value);
- return true;
- }
-
- /**
- * A No-Op, since we are an asynchronous cache concurrency strategy.
- */
- public void evict(Object key) throws CacheException {
- }
-
- /**
- * A No-Op, since we are an asynchronous cache concurrency strategy.
- */
- public boolean insert(Object key, Object value, Object currentVersion) {
- return false;
- }
-
- /**
- * Throws UnsupportedOperationException since items in a read-only cache should not be mutated.
- *
- * @throws UnsupportedOperationException always
- */
- public boolean update(Object key, Object value, Object currentVersion, Object previousVersion) throws UnsupportedOperationException {
- LOG.error("Application attempted to edit read only item: " + key);
- throw new UnsupportedOperationException("Can't write to a readonly object");
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return cache + "(read-only)";
- }
-}
Index: rctags/ehcache-2.10.7.0.43/system-tests/src/test/java/org/terracotta/ehcache/tests/OverflowToDiskStandaloneCacheTest.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/system-tests/src/test/java/org/terracotta/ehcache/tests/OverflowToDiskStandaloneCacheTest.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/system-tests/src/test/java/org/terracotta/ehcache/tests/OverflowToDiskStandaloneCacheTest.java (revision 0)
@@ -1,45 +0,0 @@
-/*
- * All content copyright (c) 2003-2008 Terracotta, Inc., except as may otherwise be noted in a separate copyright
- * notice. All rights reserved.
- */
-package org.terracotta.ehcache.tests;
-
-import com.tc.test.config.model.TestConfig;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-
-/**
- * @author cdennis
- */
-public class OverflowToDiskStandaloneCacheTest extends AbstractCacheTestBase {
-
- public OverflowToDiskStandaloneCacheTest(TestConfig testConfig) {
- super("overflow-to-disk-cache-test.xml", testConfig);
- }
-
- @Override
- protected void evaluateClientOutput(String clientName, int exitCode, File output) throws Throwable {
- if ((exitCode == 0)) { throw new AssertionError("Client " + clientName + " exited with exit code: " + exitCode); }
-
- FileReader fr = null;
- try {
- fr = new FileReader(output);
- BufferedReader reader = new BufferedReader(fr);
- String st = "";
- while ((st = reader.readLine()) != null) {
- if (st.contains("InvalidConfigurationException")) return;
- }
- throw new AssertionError("Client " + clientName + " did not pass");
- } catch (Exception e) {
- throw new AssertionError(e);
- } finally {
- try {
- fr.close();
- } catch (Exception e) {
- //
- }
- }
- }
-}
Index: rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/store/compound/ReadWriteSerializationCopyStrategy.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/store/compound/ReadWriteSerializationCopyStrategy.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/store/compound/ReadWriteSerializationCopyStrategy.java (revision 0)
@@ -1,132 +0,0 @@
-/**
- * Copyright Terracotta, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.sf.ehcache.store.compound;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-
-import net.sf.ehcache.CacheException;
-import net.sf.ehcache.Element;
-import net.sf.ehcache.ElementIdHelper;
-import net.sf.ehcache.util.PreferredLoaderObjectInputStream;
-
-/**
- * A copy strategy that can use partial (if both copy on read and copy on write are set) or full Serialization to copy the object graph
- *
- * @author Alex Snaps
- * @author Ludovic Orban
- */
-public class ReadWriteSerializationCopyStrategy implements ReadWriteCopyStrategy {
-
- private static final long serialVersionUID = 2659269742281205622L;
-
- /**
- * Deep copies some object and returns an internal storage-ready copy
- *
- * @param value the value to copy
- * @return the storage-ready copy
- */
- public Element copyForWrite(Element value, ClassLoader loader) {
- if (value == null) {
- return null;
- } else {
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- ObjectOutputStream oos = null;
-
- if (value.getObjectValue() == null) {
- return duplicateElementWithNewValue(value, null);
- }
-
- try {
- oos = new ObjectOutputStream(bout);
- oos.writeObject(value.getObjectValue());
- } catch (Exception e) {
- throw new CacheException("When configured copyOnRead or copyOnWrite, a Store will only accept Serializable values", e);
- } finally {
- try {
- if (oos != null) {
- oos.close();
- }
- } catch (Exception e) {
- //
- }
- }
-
- return duplicateElementWithNewValue(value, bout.toByteArray());
- }
- }
-
- /**
- * Reconstruct an object from its storage-ready copy.
- *
- * @param storedValue the storage-ready copy
- * @return the original object
- */
- public Element copyForRead(Element storedValue, ClassLoader loader) {
- if (storedValue == null) {
- return null;
- } else {
- if (storedValue.getObjectValue() == null) {
- return duplicateElementWithNewValue(storedValue, null);
- }
-
- ByteArrayInputStream bin = new ByteArrayInputStream((byte[]) storedValue.getObjectValue());
- ObjectInputStream ois = null;
- try {
- ois = new PreferredLoaderObjectInputStream(bin, loader);
- return duplicateElementWithNewValue(storedValue, ois.readObject());
- } catch (Exception e) {
- throw new CacheException("When configured copyOnRead or copyOnWrite, a Store will only accept Serializable values", e);
- } finally {
- try {
- if (ois != null) {
- ois.close();
- }
- } catch (Exception e) {
- //
- }
- }
- }
- }
-
- /**
- * Make a duplicate of an element but using the specified value
- *
- * @param element the element to duplicate
- * @param newValue the new element's value
- * @return the duplicated element
- */
- public Element duplicateElementWithNewValue(final Element element, final Object newValue) {
- Element newElement;
- if (element.usesCacheDefaultLifespan()) {
- newElement = new Element(element.getObjectKey(), newValue, element.getVersion(),
- element.getCreationTime(), element.getLastAccessTime(), element.getHitCount(), element.usesCacheDefaultLifespan(),
- Integer.MIN_VALUE, Integer.MIN_VALUE, element.getLastUpdateTime());
- } else {
- newElement = new Element(element.getObjectKey(), newValue, element.getVersion(),
- element.getCreationTime(), element.getLastAccessTime(), element.getHitCount(), element.usesCacheDefaultLifespan(),
- element.getTimeToLive(), element.getTimeToIdle(), element.getLastUpdateTime());
- }
- if (ElementIdHelper.hasId(element)) {
- ElementIdHelper.setId(newElement, ElementIdHelper.getId(element));
- }
- return newElement;
- }
-
-}
Index: rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/statistics/extended/OperationImpl.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/statistics/extended/OperationImpl.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/statistics/extended/OperationImpl.java (revision 0)
@@ -1,130 +0,0 @@
-/**
- * Copyright Terracotta, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.sf.ehcache.statistics.extended;
-
-import java.util.Set;
-import java.util.concurrent.ScheduledExecutorService;
-
-import net.sf.ehcache.statistics.extended.ExtendedStatistics.Latency;
-import net.sf.ehcache.statistics.extended.ExtendedStatistics.Result;
-import net.sf.ehcache.statistics.extended.ExtendedStatistics.Statistic;
-
-import org.terracotta.statistics.OperationStatistic;
-
-/**
- * The Class OperationImpl.
- *
- * @param the generic type
- * @author cdennis
- */
-class OperationImpl> implements Result {
-
- /** The source. */
- private final OperationStatistic source;
-
- /** The count. */
- private final SemiExpiringStatistic count;
-
- /** The rate. */
- private final RateImpl rate;
-
- /** The latency. */
- private final LatencyImpl latency;
-
- /**
- * Instantiates a new operation impl.
- *
- * @param source the source
- * @param targets the targets
- * @param averageNanos the average nanos
- * @param executor the executor
- * @param historySize the history size
- * @param historyNanos the history nanos
- */
- public OperationImpl(OperationStatistic source, Set targets, long averageNanos,
- ScheduledExecutorService executor, int historySize, long historyNanos) {
- this.source = source;
- this.count = new SemiExpiringStatistic(source.statistic(targets), executor, historySize, historyNanos);
- this.latency = new LatencyImpl(source, targets, averageNanos, executor, historySize, historyNanos);
- this.rate = new RateImpl(source, targets, averageNanos, executor, historySize, historyNanos);
- }
-
- /* (non-Javadoc)
- * @see net.sf.ehcache.statisticsV2.extended.ExtendedStatistics.Result#rate()
- */
- @Override
- public Statistic rate() {
- return rate;
- }
-
- /* (non-Javadoc)
- * @see net.sf.ehcache.statisticsV2.extended.ExtendedStatistics.Result#latency()
- */
- @Override
- public Latency latency() throws UnsupportedOperationException {
- return latency;
- }
-
- /* (non-Javadoc)
- * @see net.sf.ehcache.statisticsV2.extended.ExtendedStatistics.Result#count()
- */
- @Override
- public Statistic count() {
- return count;
- }
-
- /**
- * Start.
- */
- void start() {
- count.start();
- rate.start();
- latency.start();
- }
-
- /**
- * Expire.
- *
- * @param expiryTime the expiry time
- * @return true, if successful
- */
- boolean expire(long expiryTime) {
- return (count.expire(expiryTime) & rate.expire(expiryTime) & latency.expire(expiryTime));
- }
-
- /**
- * Sets the window.
- *
- * @param averageNanos the new window
- */
- void setWindow(long averageNanos) {
- rate.setWindow(averageNanos);
- latency.setWindow(averageNanos);
- }
-
- /**
- * Sets the history.
- *
- * @param historySize the history size
- * @param historyNanos the history nanos
- */
- void setHistory(int historySize, long historyNanos) {
- count.setHistory(historySize, historyNanos);
- rate.setHistory(historySize, historyNanos);
- latency.setHistory(historySize, historyNanos);
- }
-}
Index: rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/terracotta/KeySnapshotter.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/terracotta/KeySnapshotter.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/terracotta/KeySnapshotter.java (revision 0)
@@ -1,228 +0,0 @@
-/**
- * Copyright Terracotta, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.sf.ehcache.terracotta;
-
-import net.sf.ehcache.Cache;
-import net.sf.ehcache.CacheManager;
-import net.sf.ehcache.CacheStoreHelper;
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.store.Store;
-import net.sf.ehcache.store.TerracottaStore;
-import net.sf.ehcache.util.WeakIdentityConcurrentMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
-/**
- * A class that will snapshot the local keySet of a Terracotta clustered cache to disk
- *
- * @author Alex Snaps
- */
-class KeySnapshotter implements Runnable {
-
- private static final Logger LOG = LoggerFactory.getLogger(KeySnapshotter.class.getName());
- private static final int POOL_SIZE = Integer.getInteger("net.sf.ehcache.terracotta.KeySnapshotter.threadPoolSize", 10);
-
- private static final WeakIdentityConcurrentMap INSTANCES =
- new WeakIdentityConcurrentMap(
- new WeakIdentityConcurrentMap.CleanUpTask() {
- public void cleanUp(final ScheduledExecutorService executor) {
- executor.shutdownNow();
- }
- });
-
- private final String cacheName;
- private volatile TerracottaStore tcStore;
- private final RotatingSnapshotFile rotatingWriter;
- private final Thread thread;
-
- private volatile Runnable onSnapshot;
- private final ScheduledFuture> scheduledFuture;
-
- /**
- * Default Constructor
- *
- * @param cache the Terracotta clustered Cache to snapshot
- * @param interval the interval to do the snapshots on
- * @param doKeySnapshotOnDedicatedThread whether the snapshots have to be done on a dedicated thread
- * @param rotatingWriter the RotatingSnapshotFile to write to
- * @throws IllegalArgumentException if interval is less than or equal to zero
- */
- KeySnapshotter(final Ehcache cache, final long interval,
- final boolean doKeySnapshotOnDedicatedThread,
- final RotatingSnapshotFile rotatingWriter)
- throws IllegalArgumentException {
- final Store store = new CacheStoreHelper((Cache)cache).getStore();
- if (!(store instanceof TerracottaStore)) {
- throw new IllegalArgumentException("Cache '" + cache.getName() + "' isn't backed by a " + TerracottaStore.class.getSimpleName()
- + " but uses a " + store.getClass().getName() + " instead");
- }
-
- if (interval <= 0) {
- throw new IllegalArgumentException("Interval needs to be a positive & non-zero value");
- }
-
- if (rotatingWriter == null) {
- throw new NullPointerException();
- }
-
- this.cacheName = cache.getName();
- this.rotatingWriter = rotatingWriter;
- this.tcStore = (TerracottaStore)store;
-
- if (doKeySnapshotOnDedicatedThread) {
- scheduledFuture = null;
- thread = new SnapShottingThread(this, interval, "KeySnapshotter for cache " + cacheName);
- thread.start();
- } else {
- scheduledFuture = getScheduledExecutorService(cache.getCacheManager())
- .scheduleWithFixedDelay(this, interval, interval, TimeUnit.SECONDS);
- thread = null;
- }
- }
-
- private ScheduledExecutorService getScheduledExecutorService(final CacheManager cacheManager) {
- ScheduledExecutorService scheduledExecutorService = INSTANCES.get(cacheManager);
- if (scheduledExecutorService == null) {
- scheduledExecutorService = new ScheduledThreadPoolExecutor(POOL_SIZE);
- final ScheduledExecutorService previous = INSTANCES.putIfAbsent(cacheManager, scheduledExecutorService);
- if (previous != null) {
- scheduledExecutorService.shutdownNow();
- scheduledExecutorService = previous;
- }
- }
- return scheduledExecutorService;
- }
-
- /**
- * Shuts down the writer thread and cleans up resources
- *
- * @param immediately whether to leave the writer finish or shut down immediately
- */
- void dispose(boolean immediately) {
- if (thread != null) {
- rotatingWriter.setShutdownOnThreadInterrupted(immediately);
- thread.interrupt();
- try {
- thread.join();
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- }
- } else {
- scheduledFuture.cancel(immediately);
- }
- tcStore = null;
- }
-
- /**
- * {@inheritDoc}
- */
- public void run() {
- try {
- INSTANCES.cleanUp();
- rotatingWriter.writeAll(tcStore.getLocalKeys());
- onSnapshot();
- } catch (Throwable e) {
- LOG.error("Couldn't snapshot local keySet for Cache {}", cacheName, e);
- }
- }
-
- private void onSnapshot() {
- if (onSnapshot != null) {
- try {
- onSnapshot.run();
- } catch (Exception e) {
- LOG.warn("Error occurred in onSnapshot callback", e);
- }
- }
- }
-
- /**
- * Accessor to all known cacheManagers (which are also bound to a ScheduledExecutorService)
- *
- * @return the collection of known CacheManagers
- */
- static Collection getKnownCacheManagers() {
- return INSTANCES.keySet();
- }
-
- /**
- * Calling this method will result in a snapshot being taken or wait for the one in progress to finish
- *
- * @throws IOException On exception being thrown while doing the snapshot
- */
- void doSnapshot() throws IOException {
- rotatingWriter.snapshotNowOrWaitForCurrentToFinish(tcStore.getLocalKeys());
- onSnapshot();
- }
-
- /**
- * Let register a Runnable that will be called on every snapshot happening
- * @param onSnapshot the runnable
- */
- void setOnSnapshot(final Runnable onSnapshot) {
- this.onSnapshot = onSnapshot;
- }
-
- /**
- * Returns the name of the underlying cache for which this snapshots
- * @return The name of the cache
- */
- public String getCacheName() {
- return cacheName;
- }
-
- /**
- * Thread doing background snapshots of the local key set
- */
- private static class SnapShottingThread extends Thread {
-
- private long lastRun;
- private final long interval;
-
- public SnapShottingThread(final Runnable runnable, final long interval, final String threadName) {
- super(runnable, threadName);
- this.interval = interval;
- lastRun = System.currentTimeMillis();
- this.setDaemon(true);
- }
-
- @Override
- public void run() {
- while (!isInterrupted()) {
- final long nextTime = lastRun + TimeUnit.SECONDS.toMillis(interval);
- final long now = System.currentTimeMillis();
- if (nextTime <= now) {
- super.run();
- lastRun = System.currentTimeMillis();
- } else {
- try {
- sleep(nextTime - now);
- } catch (InterruptedException e) {
- interrupt();
- }
- }
- }
- }
- }
-}
Index: rctags/ehcache-2.10.7.0.43/ehcache-core/src/test/java/net/sf/ehcache/loader/NullCountingCacheLoaderFactory.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/ehcache-core/src/test/java/net/sf/ehcache/loader/NullCountingCacheLoaderFactory.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/ehcache-core/src/test/java/net/sf/ehcache/loader/NullCountingCacheLoaderFactory.java (revision 0)
@@ -1,52 +0,0 @@
-/**
- * Copyright Terracotta, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.sf.ehcache.loader;
-
-
-import net.sf.ehcache.Ehcache;
-
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * A factory for creating counting cache loaders. This can be hooked up to the JCacheFactory by
- * specifying "cacheLoaderFactoryClassName" in the environment
- *
- * @author Greg Luck
- * @version $Id: NullCountingCacheLoaderFactory.java 5594 2012-05-07 16:04:31Z cdennis $
- */
-public class NullCountingCacheLoaderFactory extends CacheLoaderFactory {
-
-
- /**
- */
- public CacheLoader createCacheLoader(Map environment) {
- return new NullCountingCacheLoader();
- }
-
- /**
- * Creates a CacheLoader using the Ehcache configuration mechanism at the time the associated cache is created.
- *
- * @param properties implementation specific properties. These are configured as comma
- * separated name value pairs in ehcache.xml
- * @return a constructed CacheLoader
- */
- public CacheLoader createCacheLoader(Ehcache cache, Properties properties) {
- return new NullCountingCacheLoader();
- }
-
-}
\ No newline at end of file
Index: rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/statistics/package.html
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/statistics/package.html (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/statistics/package.html (revision 0)
@@ -1,8 +0,0 @@
-
-
-
-
-This package contains classes related to LiveCacheStatistics and its implementation.
-
-
-
Index: rctags/ehcache-2.10.7.0.43/ehcache-core/src/test/java/net/sf/ehcache/hibernate/domain/VersionedItem.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/ehcache-core/src/test/java/net/sf/ehcache/hibernate/domain/VersionedItem.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/ehcache-core/src/test/java/net/sf/ehcache/hibernate/domain/VersionedItem.java (revision 0)
@@ -1,28 +0,0 @@
-/**
- * Copyright Terracotta, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.sf.ehcache.hibernate.domain;
-
-public class VersionedItem extends Item {
- private Long version;
-
- public Long getVersion() {
- return version;
- }
-
- public void setVersion(Long version) {
- this.version = version;
- }
-}
Index: rctags/ehcache-2.10.7.0.43/system-tests/src/test/java/org/terracotta/modules/ehcache/store/CachePinningFaultInvalidatedEntriesTest.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/system-tests/src/test/java/org/terracotta/modules/ehcache/store/CachePinningFaultInvalidatedEntriesTest.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/system-tests/src/test/java/org/terracotta/modules/ehcache/store/CachePinningFaultInvalidatedEntriesTest.java (revision 0)
@@ -1,107 +0,0 @@
-/*
- * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved.
- */
-package org.terracotta.modules.ehcache.store;
-
-import net.sf.ehcache.Cache;
-import net.sf.ehcache.Element;
-
-import org.terracotta.ehcache.tests.AbstractCacheTestBase;
-import org.terracotta.ehcache.tests.ClientBase;
-import org.terracotta.test.util.WaitUtil;
-import org.terracotta.toolkit.Toolkit;
-
-import com.tc.properties.TCPropertiesConsts;
-import com.tc.test.config.model.TestConfig;
-
-import java.util.concurrent.Callable;
-
-import junit.framework.Assert;
-
-public class CachePinningFaultInvalidatedEntriesTest extends AbstractCacheTestBase {
-
- private static final int ELEMENT_COUNT = 1000;
-
- public CachePinningFaultInvalidatedEntriesTest(TestConfig testConfig) {
- super("cache-pinning-test.xml", testConfig, App.class, App.class);
- testConfig.getClientConfig()
- .addExtraClientJvmArg("-Dcom.tc." + TCPropertiesConsts.L1_SERVERMAPMANAGER_FAULT_INVALIDATED_PINNED_ENTRIES
- + "=true");
- }
-
- public static class App extends ClientBase {
- public App(String[] args) {
- super("pinned", args);
- }
-
- @Override
- protected void runTest(Cache cache, Toolkit clusteringToolkit) throws Throwable {
-
- System.out.println("Testing with Eventual tier pinned cache");
- basicTestInvalidatedEntriesFaulted(cacheManager.getCache("pinnedEventual"), true);
- System.out.println("Testing with Strong tier pinned cache");
- basicTestInvalidatedEntriesFaulted(cacheManager.getCache("pinned"), true);
-
- }
-
- private void basicTestInvalidatedEntriesFaulted(final Cache cache, boolean tierPinned) throws Exception {
- int index = getBarrierForAllClients().await();
- if (index == 0) {
- for (int i = 0; i < ELEMENT_COUNT; i++) {
- cache.put(new Element(getKey(i), getValue(i)));
- }
- Assert.assertEquals(ELEMENT_COUNT, cache.getSize());
- for (int i = 0; i < ELEMENT_COUNT; i++) {
- assertNotNull(cache.get(getKey(i)));
- assertEquals(cache.get(getKey(i)).getValue(), getValue(i));
- }
- // All the gets on both the clients should be local as the pinned entries would have been faulted.
- Assert.assertEquals(ELEMENT_COUNT, cache.getMemoryStoreSize());
- Assert.assertEquals(ELEMENT_COUNT * 2, cache.getStatistics().localHeapHitCount());
- Assert.assertEquals(0, cache.getStatistics().cacheEvictedCount());
- }
- getBarrierForAllClients().await();
- if (index == 1) {
- // Update elements, invalidate entries on other client
- for (int i = 0; i < ELEMENT_COUNT; i++) {
- cache.put(new Element(getKey(i), getValue(i + 1)));
- }
- Assert.assertEquals(ELEMENT_COUNT, cache.getSize());
- }
-
- getBarrierForAllClients().await();
- WaitUtil.waitUntilCallableReturnsTrue(new Callable() {
-
- @Override
- public Boolean call() throws Exception {
- // wait until the client repopulates the local cache after receiving invalidations.
- long localsize = cache.getMemoryStoreSize();
- System.out.println("Local cache Size = " + localsize);
- return localsize == ELEMENT_COUNT;
- }
- });
-
- getBarrierForAllClients().await();
- for (int i = 0; i < ELEMENT_COUNT; i++) {
- assertNotNull(cache.get(getKey(i)));
- assertEquals(cache.get(getKey(i)).getValue(), getValue(i + 1));
- }
- // All the gets on both the clients should be local as the pinned entries would have been faulted.
- if (index == 0) {
- Assert.assertEquals(ELEMENT_COUNT, cache.getMemoryStoreSize());
- // Assert.assertEquals(ELEMENT_COUNT * 4, cache.getStatistics().localHeapHitCount());
- Assert.assertEquals(0, cache.getStatistics().cacheEvictedCount());
- }
- getBarrierForAllClients().await();
- }
-
- private Object getKey(int i) {
- return String.valueOf(i);
- }
-
- private Object getValue(int i) {
- return i;
- }
-
- }
-}
Index: rctags/ehcache-2.10.7.0.43/system-tests/src/test/java/org/terracotta/ehcache/tests/NonHibernateCacheDecorator.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/system-tests/src/test/java/org/terracotta/ehcache/tests/NonHibernateCacheDecorator.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/system-tests/src/test/java/org/terracotta/ehcache/tests/NonHibernateCacheDecorator.java (revision 0)
@@ -1,43 +0,0 @@
-package org.terracotta.ehcache.tests;
-
-import net.sf.ehcache.CacheException;
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.Element;
-import net.sf.ehcache.constructs.EhcacheDecoratorAdapter;
-
-import java.io.Serializable;
-
-/**
- * This decorator class intercepts cache gets and acts as a cache read through during or before a cache load and acts as a system of record
- * after the cache has been loaded. Cache read through: get the object from the cache, if not in cache, get object from database, load in to
- * cache and return object. System of Record (SOR): only get the object from the cache.
- *
- * @author sdalto2
- *
- */
-public class NonHibernateCacheDecorator extends EhcacheDecoratorAdapter {
-
- private Ehcache cache;
- public NonHibernateCacheDecorator(Ehcache cache) {
- super(cache);
- this.cache=cache;
- }
-
- /**
- * This get method will always call Element get(Serializable key) So a serializable key is mandatory.
- */
- @Override
- public Element get(Object key) throws IllegalStateException, CacheException {
- return get((Serializable) key);
- }
-
- @Override
- public Element get(Serializable key) throws IllegalStateException, CacheException {
- return new Element(1,"dummy");
- }
- @Override
- public void removeAll(boolean doNotNotifyListeners) throws IllegalStateException, CacheException {
- cache.removeAll(doNotNotifyListeners);
- }
-
-}
\ No newline at end of file
Index: rctags/ehcache-2.10.7.0.43/system-tests/src/test/resources/hibernate-config/shutdowntest/domain/Item.hbm.xml
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/system-tests/src/test/resources/hibernate-config/shutdowntest/domain/Item.hbm.xml (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/system-tests/src/test/resources/hibernate-config/shutdowntest/domain/Item.hbm.xml (revision 0)
@@ -1,28 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Index: rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/transaction/Decision.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/transaction/Decision.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/transaction/Decision.java (revision 0)
@@ -1,40 +0,0 @@
-/**
- * Copyright Terracotta, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.sf.ehcache.transaction;
-
-/**
- * The decision types a Transaction ID can be in
- *
- * @author Ludovic Orban
- */
-public enum Decision {
-
- /**
- * Transaction decision not yet made.
- */
- IN_DOUBT,
-
- /**
- * Transaction has been marked for commit.
- */
- COMMIT,
-
- /**
- * Transaction has been marked for rollback.
- */
- ROLLBACK
-}
\ No newline at end of file
Index: rctags/ehcache-2.10.7.0.43/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/async/scatterpolicies/SingleBucketScatterPolicy.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/async/scatterpolicies/SingleBucketScatterPolicy.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/terracotta/bootstrap/src/main/java/org/terracotta/modules/ehcache/async/scatterpolicies/SingleBucketScatterPolicy.java (revision 0)
@@ -1,15 +0,0 @@
-/*
- * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved.
- */
-package org.terracotta.modules.ehcache.async.scatterpolicies;
-
-
-import java.io.Serializable;
-
-public class SingleBucketScatterPolicy implements ItemScatterPolicy {
-
- public int selectBucket(final int count, final E item) {
- return 0;
- }
-
-}
Index: rctags/ehcache-2.10.7.0.43/ehcache-core/checkstyle/suppressions.xml
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/ehcache-core/checkstyle/suppressions.xml (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/ehcache-core/checkstyle/suppressions.xml (revision 0)
@@ -1,451 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Index: rctags/ehcache-2.10.7.0.43/terracotta/bootstrap/src/test/java/org/terracotta/modules/ehcache/ToolkitInstanceFactoryImplTest.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/terracotta/bootstrap/src/test/java/org/terracotta/modules/ehcache/ToolkitInstanceFactoryImplTest.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/terracotta/bootstrap/src/test/java/org/terracotta/modules/ehcache/ToolkitInstanceFactoryImplTest.java (revision 0)
@@ -1,433 +0,0 @@
-/**
- * Copyright Terracotta, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the specific language governing permissions and limitations under the
- * License.
- */
-
-package org.terracotta.modules.ehcache;
-
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.inOrder;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.mockito.Mockito.when;
-import net.sf.ehcache.CacheException;
-import net.sf.ehcache.CacheManager;
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.config.CacheConfiguration;
-import net.sf.ehcache.config.TerracottaConfiguration;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.mockito.ArgumentCaptor;
-import org.mockito.InOrder;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-import org.terracotta.modules.ehcache.wan.WANUtil;
-import org.terracotta.modules.ehcache.wan.Watchdog;
-import org.terracotta.test.categories.CheckShorts;
-import org.terracotta.toolkit.Toolkit;
-import org.terracotta.toolkit.ToolkitFeatureType;
-import org.terracotta.toolkit.collections.ToolkitMap;
-import org.terracotta.toolkit.concurrent.locks.ToolkitLock;
-import org.terracotta.toolkit.concurrent.locks.ToolkitReadWriteLock;
-import org.terracotta.toolkit.config.Configuration;
-import org.terracotta.toolkit.feature.NonStopFeature;
-import org.terracotta.toolkit.internal.ToolkitInternal;
-import org.terracotta.toolkit.internal.ToolkitLogger;
-import org.terracotta.toolkit.internal.cache.BufferingToolkitCache;
-import org.terracotta.toolkit.internal.cache.ToolkitCacheInternal;
-import org.terracotta.toolkit.nonstop.NonStopConfigurationRegistry;
-import org.terracotta.toolkit.store.ToolkitConfigFields;
-
-import com.terracotta.entity.ClusteredEntityManager;
-import com.terracotta.entity.EntityLockHandler;
-import com.terracotta.entity.ehcache.ClusteredCache;
-import com.terracotta.entity.ehcache.ClusteredCacheManager;
-import com.terracotta.entity.ehcache.ClusteredCacheManagerConfiguration;
-import com.terracotta.entity.ehcache.EhcacheEntitiesNaming;
-import com.terracotta.entity.ehcache.ToolkitBackedClusteredCacheManager;
-
-import java.io.Serializable;
-
-import junit.framework.Assert;
-
-/**
- * ToolkitInstanceFactoryImplTest
- */
-@Category(CheckShorts.class)
-public class ToolkitInstanceFactoryImplTest {
-
- private static final String CACHE_MANAGER_NAME = "CACHE_MANAGER_NAME";
- private static final String CACHE_NAME = "CACHE_NAME";
-
- @Mock private Toolkit toolkit;
- @Mock private WANUtil wanUtil;
- @Mock private Ehcache ehcache;
- @Mock private CacheManager cacheManager;
-
- private ToolkitInstanceFactoryImpl factory;
- private ToolkitCacheInternal resultantCache;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- toolkit = getMockToolkit();
- final ToolkitMap toolkitMap = mockMap();
- when(toolkit.getMap(anyString(), any(Class.class), any(Class.class))).thenReturn(toolkitMap);
- when(toolkit.getCache(anyString(), any(Configuration.class), any(Class.class)))
- .thenReturn(mock(BufferingToolkitCache.class));
- ToolkitReadWriteLock rwLock = mockReadWriteLock();
- when(toolkit.getReadWriteLock(any(String.class))).thenReturn(rwLock);
- makeToolkitReturnNonStopConfigurationRegistry();
-
- wanUtil = mock(WANUtil.class);
- final Watchdog wanWatchdog = mock(Watchdog.class);
- ehcache = mock(Ehcache.class);
- when(cacheManager.isNamed()).thenReturn(true);
- when(cacheManager.getName()).thenReturn(CACHE_MANAGER_NAME);
- when(ehcache.getCacheManager()).thenReturn(cacheManager);
- when(ehcache.getName()).thenReturn(CACHE_NAME);
- CacheConfiguration configuration = new CacheConfiguration().terracotta(new TerracottaConfiguration());
- when(ehcache.getCacheConfiguration()).thenReturn(configuration);
-
- ClusteredEntityManager clusteredEntityManager = mock(ClusteredEntityManager.class);
- ToolkitBackedClusteredCacheManager clusteredCacheManager = new ToolkitBackedClusteredCacheManager("aName", new ClusteredCacheManagerConfiguration(defaultCMConfig));
- clusteredCacheManager.setToolkit(toolkit);
- clusteredCacheManager.setEntityLockHandler(mock(EntityLockHandler.class));
- when(clusteredEntityManager.getRootEntity(any(String.class), any(Class.class))).thenReturn(clusteredCacheManager);
- when(clusteredEntityManager.getEntityLock(anyString())).thenReturn(mock(ToolkitReadWriteLock.class));
- factory = new ToolkitInstanceFactoryImpl(toolkit, clusteredEntityManager, wanUtil, wanWatchdog);
- factory.linkClusteredCacheManager(CACHE_MANAGER_NAME, null);
- }
-
- private ToolkitMap mockMap() {
- ToolkitMap map = mock(ToolkitMap.class);
- ToolkitReadWriteLock readWriteLock = mockReadWriteLock();
- when(map.getReadWriteLock()).thenReturn(readWriteLock);
- return map;
- }
-
- private ToolkitReadWriteLock mockReadWriteLock() {
- ToolkitReadWriteLock readWriteLock = mock(ToolkitReadWriteLock.class);
- ToolkitLock lock = mockLock();
- when(readWriteLock.readLock()).thenReturn(lock);
- when(readWriteLock.writeLock()).thenReturn(lock);
- return readWriteLock;
- }
-
- private ToolkitLock mockLock() {
- return when(mock(ToolkitLock.class).tryLock()).thenReturn(true).getMock();
- }
-
- @Test
- public void testGetOrCreateToolkitCacheForWanEnabled() throws Exception {
- whenCacheIsWanEnabled().callGetOrCreateToolkitCache().assertInstanceOfWanAwareToolkitCache(true);
- }
-
- @Test
- public void testGetOrCreateToolkitCacheForWanDisabled() throws Exception {
- whenCacheIsWanDisabled().callGetOrCreateToolkitCache().assertInstanceOfWanAwareToolkitCache(false);
- }
-
- @Test(expected = CacheException.class)
- public void testWanAwareToolkitCacheDoesNotSupportDynamicConfigChange() throws Exception {
- whenCacheIsWanEnabled().callGetOrCreateToolkitCache().assertInstanceOfWanAwareToolkitCache(true).updateTimeToLive();
- }
-
- @Test
- public void testMaxEntriesInCacheToMaxTotalCountTransformation() {
- CacheConfiguration configuration = new CacheConfiguration().terracotta(new TerracottaConfiguration()).maxEntriesInCache(10);
- forEhcacheConfig(configuration).callGetOrCreateToolkitCache().validateMaxTotalCountForToolkitCacheIs(10);
- }
-
- private void updateTimeToLive() {
- ehcache.getCacheConfiguration().setTimeToLiveSeconds(10);
- }
-
- private void validateMaxTotalCountForToolkitCacheIs(int maxTotalCount) {
- ArgumentCaptor captor = ArgumentCaptor.forClass(Configuration.class);
- verify(toolkit).getCache(anyString(), captor.capture(), eq(Serializable.class));
- assertThat(captor.getValue().getInt(ToolkitConfigFields.MAX_TOTAL_COUNT_FIELD_NAME), is(10));
- }
-
- private ToolkitInstanceFactoryImplTest forEhcacheConfig(CacheConfiguration configuration) {
- when(ehcache.getCacheConfiguration()).thenReturn(configuration);
- return this;
- }
-
-
- private void makeToolkitReturnNonStopConfigurationRegistry() {
- NonStopFeature feature = mock(NonStopFeature.class);
- when(toolkit.getFeature(any(ToolkitFeatureType.class))).thenReturn(feature);
- when(feature.getNonStopConfigurationRegistry()).thenReturn(mock(NonStopConfigurationRegistry.class));
- }
-
- /**
- * This test case was added while fixing DEV-9223. From now on, we assume that the default value for maxTotalCount in
- * Toolkit (-1), and the default value for maxEntriesInCache in EhCache (0) will be aligned. That is, they both will
- * mean the same thing. Currently they mean no-limit cache. If someone changes the default value of one of those, then
- * this test case will fail and we would need to handle it.
- */
- @Test
- public void testToolkitAndEhCacheDefaultsAreAligned() {
- Assert.assertEquals(0, CacheConfiguration.DEFAULT_MAX_ENTRIES_IN_CACHE);
- Assert.assertEquals(-1, ToolkitConfigFields.DEFAULT_MAX_TOTAL_COUNT);
- }
-
-
- private ToolkitInstanceFactoryImplTest assertInstanceOfWanAwareToolkitCache(boolean expectedResult) {
- Assert.assertEquals(expectedResult, (resultantCache instanceof WanAwareToolkitCache));
- return this;
- }
-
- private ToolkitInstanceFactoryImplTest callGetOrCreateToolkitCache() {
- resultantCache = factory.getOrCreateToolkitCache(ehcache);
- return this;
- }
-
- private ToolkitInstanceFactoryImplTest whenCacheIsWanEnabled() {
- when(wanUtil.isWanEnabledCache(CACHE_MANAGER_NAME, CACHE_NAME)).thenReturn(true);
- return this;
- }
-
- private ToolkitInstanceFactoryImplTest whenCacheIsWanDisabled() {
- when(wanUtil.isWanEnabledCache(CACHE_MANAGER_NAME, CACHE_NAME)).thenReturn(false);
- return this;
- }
-
- @Test
- public void testAddCacheEntityInfo() {
- factory.addCacheEntityInfo(CACHE_NAME, new CacheConfiguration(), "testTKCacheName");
- }
-
- @Test
- public void testRetrievingExistingClusteredCacheManagerEntity() {
- String name = "existing";
- net.sf.ehcache.config.Configuration configuration = new net.sf.ehcache.config.Configuration();
-
- Toolkit toolkit = getMockToolkit();
- when(toolkit.getMap(anyString(), eq(String.class), eq(ClusteredCache.class))).thenReturn(mock(ToolkitMap.class));
-
- ClusteredEntityManager clusteredEntityManager = mock(ClusteredEntityManager.class);
- ToolkitBackedClusteredCacheManager cacheManagerEntity = new ToolkitBackedClusteredCacheManager(name, new ClusteredCacheManagerConfiguration("test"));
- cacheManagerEntity.setEntityLockHandler(mock(EntityLockHandler.class));
- when(clusteredEntityManager.getRootEntity(name, ClusteredCacheManager.class))
- .thenReturn(cacheManagerEntity);
- when(clusteredEntityManager.getEntityLock(anyString())).thenReturn(mock(ToolkitReadWriteLock.class));
- ToolkitInstanceFactoryImpl toolkitInstanceFactory = new ToolkitInstanceFactoryImpl(getMockToolkit(),
- clusteredEntityManager);
-
- toolkitInstanceFactory.linkClusteredCacheManager(name, configuration);
- verify(clusteredEntityManager).getRootEntity(name, ClusteredCacheManager.class);
- verify(clusteredEntityManager).getEntityLock(anyString());
- verifyNoMoreInteractions(clusteredEntityManager);
- }
-
- @Test
- public void testCreatingNewClusteredCacheManagerEntity() {
- String name = "newCM";
-
- net.sf.ehcache.config.Configuration configuration = new net.sf.ehcache.config.Configuration();
-
- ClusteredEntityManager clusteredEntityManager = mock(ClusteredEntityManager.class);
- doAnswer(new Answer() {
- @Override
- public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
- Object[] arguments = invocationOnMock.getArguments();
- ((ToolkitBackedClusteredCacheManager)arguments[2]).setEntityLockHandler(mock(EntityLockHandler.class));
- return null;
- }
- }).when(clusteredEntityManager).addRootEntityIfAbsent(eq(name), eq(ClusteredCacheManager.class), any(ClusteredCacheManager.class));
- ToolkitReadWriteLock rwLock = mock(ToolkitReadWriteLock.class);
- ToolkitLock writeLock = mock(ToolkitLock.class);
- when(writeLock.tryLock()).thenReturn(true);
- when(rwLock.writeLock()).thenReturn(writeLock);
- when(clusteredEntityManager.getEntityLock(any(String.class))).thenReturn(rwLock);
-
- ToolkitInstanceFactoryImpl toolkitInstanceFactory = new ToolkitInstanceFactoryImpl(getMockToolkit(),
- clusteredEntityManager);
-
- toolkitInstanceFactory.linkClusteredCacheManager(name, configuration);
- verify(clusteredEntityManager).getRootEntity(name, ClusteredCacheManager.class);
- verify(clusteredEntityManager).getEntityLock(EhcacheEntitiesNaming.getCacheManagerLockNameFor(name));
- verify(clusteredEntityManager).addRootEntityIfAbsent(eq(name), any(Class.class), any(ClusteredCacheManager.class));
- verifyNoMoreInteractions(clusteredEntityManager);
- }
-
- @Test
- public void testTryingToCreateNewClusteredCacheManagerEntityButLooseRace() {
- String name = "newCM";
-
- net.sf.ehcache.config.Configuration configuration = new net.sf.ehcache.config.Configuration();
-
- ClusteredEntityManager clusteredEntityManager = mock(ClusteredEntityManager.class);
- when(clusteredEntityManager.addRootEntityIfAbsent(eq(name), any(Class.class), any(ClusteredCacheManager.class))).thenReturn(mock(ClusteredCacheManager.class));
- when(clusteredEntityManager.getRootEntity(name, ClusteredCacheManager.class)).thenReturn(null, mock(ClusteredCacheManager.class));
- ToolkitReadWriteLock rwLock = mock(ToolkitReadWriteLock.class);
- ToolkitLock writeLock = mock(ToolkitLock.class);
- when(writeLock.tryLock()).thenReturn(true);
- when(rwLock.writeLock()).thenReturn(writeLock);
- when(clusteredEntityManager.getEntityLock(any(String.class))).thenReturn(rwLock);
-
- ToolkitInstanceFactoryImpl toolkitInstanceFactory = new ToolkitInstanceFactoryImpl(getMockToolkit(),
- clusteredEntityManager);
-
- toolkitInstanceFactory.linkClusteredCacheManager(name, configuration);
- InOrder inOrder = inOrder(clusteredEntityManager);
- inOrder.verify(clusteredEntityManager).getRootEntity(name, ClusteredCacheManager.class);
- inOrder.verify(clusteredEntityManager).getEntityLock(EhcacheEntitiesNaming.getCacheManagerLockNameFor(name));
- inOrder.verify(clusteredEntityManager).addRootEntityIfAbsent(eq(name), any(Class.class), any(ClusteredCacheManager.class));
- verifyNoMoreInteractions(clusteredEntityManager);
- }
-
- @Test
- public void testConfigurationSavedContainsNoCachesAnymore() {
- String name = "newCM";
-
- net.sf.ehcache.config.Configuration configuration = new net.sf.ehcache.config.Configuration();
- configuration.addCache(new CacheConfiguration("test", 1));
-
- ClusteredEntityManager clusteredEntityManager = mock(ClusteredEntityManager.class);
- doAnswer(new Answer() {
- @Override
- public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
- Object[] arguments = invocationOnMock.getArguments();
- ((ToolkitBackedClusteredCacheManager)arguments[2]).setEntityLockHandler(mock(EntityLockHandler.class));
- return null;
- }
- }).when(clusteredEntityManager).addRootEntityIfAbsent(eq(name), eq(ClusteredCacheManager.class), any(ClusteredCacheManager.class));
- ToolkitReadWriteLock rwLock = mock(ToolkitReadWriteLock.class);
- ToolkitLock writeLock = mock(ToolkitLock.class);
- when(writeLock.tryLock()).thenReturn(true);
- when(rwLock.writeLock()).thenReturn(writeLock);
- when(clusteredEntityManager.getEntityLock(any(String.class))).thenReturn(rwLock);
-
- ToolkitInstanceFactoryImpl toolkitInstanceFactory = new ToolkitInstanceFactoryImpl(getMockToolkit(),
- clusteredEntityManager);
-
- toolkitInstanceFactory.linkClusteredCacheManager(name, configuration);
- ArgumentCaptor captor = ArgumentCaptor.forClass(ClusteredCacheManager.class);
- verify(clusteredEntityManager).addRootEntityIfAbsent(eq(name), any(Class.class), captor.capture());
-
- assertThat(captor.getValue().getConfiguration().getConfigurationAsText(), not(containsString(" captor = ArgumentCaptor.forClass(ClusteredCacheManager.class);
- verify(clusteredEntityManager).addRootEntityIfAbsent(eq(name), any(Class.class), captor.capture());
-
- assertThat(captor.getValue().getConfiguration().getConfigurationAsText(), containsString("name=\"" + name));
- }
-
- @Test
- public void testClusterRejoinedCacheManagerDestroyed() {
- Toolkit toolkit = getMockToolkit();
- ClusteredEntityManager entityManager = mock(ClusteredEntityManager.class);
- ToolkitInstanceFactoryImpl toolkitInstanceFactory = new ToolkitInstanceFactoryImpl(toolkit, entityManager);
-
- toolkitInstanceFactory.clusterRejoined();
-
- verify(entityManager).dispose();
- verify(toolkit).shutdown();
- }
-
- @Test
- public void testClusterRejoinedCMDestroyedBetweenGetAndLock() {
- Toolkit toolkit = getMockToolkit();
- ClusteredEntityManager entityManager = mock(ClusteredEntityManager.class);
- ClusteredCacheManager cmEntity = mock(ClusteredCacheManager.class);
- ClusteredCache cEntity = mock(ClusteredCache.class);
- when(cmEntity.getCache(CACHE_NAME)).thenReturn(cEntity);
-
- when(entityManager.getRootEntity(CACHE_MANAGER_NAME, ClusteredCacheManager.class)).thenReturn(cmEntity, cmEntity, null);
- when(entityManager.getEntityLock(any(String.class))).thenReturn(mock(ToolkitReadWriteLock.class));
-
- ToolkitInstanceFactoryImpl toolkitInstanceFactory = new ToolkitInstanceFactoryImpl(toolkit, entityManager);
- toolkitInstanceFactory.linkClusteredCacheManager(CACHE_MANAGER_NAME, null);
- toolkitInstanceFactory.addCacheEntityInfo(CACHE_NAME, null, EhcacheEntitiesNaming.getToolkitCacheNameFor(CACHE_MANAGER_NAME, CACHE_NAME));
-
- toolkitInstanceFactory.clusterRejoined();
-
- verify(cmEntity, times(2)).markInUse();
- verify(entityManager).dispose();
- verify(toolkit).shutdown();
- }
-
- private Toolkit getMockToolkit() {
- ToolkitInternal toolkitInternal = mock(ToolkitInternal.class);
- when(toolkitInternal.getLogger(anyString())).thenReturn(mock(ToolkitLogger.class));
-
- return toolkitInternal;
- }
-
- @Test
- public void testClusterRejoined() {
- Toolkit toolkit = getMockToolkit();
- ClusteredEntityManager entityManager = mock(ClusteredEntityManager.class);
- ClusteredCacheManager cmEntity = mock(ClusteredCacheManager.class);
- ClusteredCache cEntity = mock(ClusteredCache.class);
- when(cmEntity.getCache(CACHE_NAME)).thenReturn(cEntity);
-
- when(entityManager.getRootEntity(CACHE_MANAGER_NAME, ClusteredCacheManager.class)).thenReturn(cmEntity);
- when(entityManager.getEntityLock(any(String.class))).thenReturn(mock(ToolkitReadWriteLock.class));
-
- ToolkitInstanceFactoryImpl toolkitInstanceFactory = new ToolkitInstanceFactoryImpl(toolkit, entityManager);
- toolkitInstanceFactory.linkClusteredCacheManager(CACHE_MANAGER_NAME, null);
- toolkitInstanceFactory.addCacheEntityInfo(CACHE_NAME, null, EhcacheEntitiesNaming.getToolkitCacheNameFor(CACHE_MANAGER_NAME, CACHE_NAME));
-
- toolkitInstanceFactory.clusterRejoined();
-
- verify(cmEntity, times(2)).markInUse();
- verify(cmEntity, times(2)).markCacheInUse(cEntity);
- }
-
- private final String defaultCMConfig = "" +
- " " +
- " " +
- "";
-
-}
Index: rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/management/sampled/CacheManagerSampler.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/management/sampled/CacheManagerSampler.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/management/sampled/CacheManagerSampler.java (revision 0)
@@ -1,334 +0,0 @@
-/**
- * Copyright Terracotta, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.sf.ehcache.management.sampled;
-
-import java.util.Map;
-
-import net.sf.ehcache.util.ManagementAttribute;
-
-/**
- * An abstraction for sampled cache manager usage statistics.
- *
- * @author Abhishek Sanoujam
- * @author byoukste
- */
-public interface CacheManagerSampler {
- /**
- * Gets the actual name of the cache manager.
- */
- @ManagementAttribute
- String getName();
-
- /**
- * Gets the cluster uuid if applicable.
- *
- * @return the cluster uuid
- */
- @ManagementAttribute
- String getClusterUUID();
-
- /**
- * Gets the status attribute of the Ehcache
- *
- * @return The status value, as a String from the Status enum class
- */
- @ManagementAttribute
- String getStatus();
-
- /**
- * Enables/disables each cache contained by this CacheManager
- *
- * @param enabled
- */
- void setEnabled(boolean enabled);
-
- /**
- * Returns if each cache is enabled.
- *
- * @return boolean indicating that each cache is enabled
- */
- @ManagementAttribute
- boolean isEnabled();
-
- /**
- * Shuts down the CacheManager.
- *
- * If the shutdown occurs on the singleton, then the singleton is removed, so that if a singleton access method is called, a new
- * singleton will be created.
- */
- void shutdown();
-
- /**
- * Clears the contents of all caches in the CacheManager, but without
- * removing any caches.
- *
- * This method is not synchronized. It only guarantees to clear those elements in a cache at the time that the
- * {@link net.sf.ehcache.Ehcache#removeAll()} mehod on each cache is called.
- */
- void clearAll();
-
- /**
- * Gets the cache names managed by the CacheManager
- */
- @ManagementAttribute
- String[] getCacheNames() throws IllegalStateException;
-
- /**
- * Get a map of cache name to performance metrics (hits, misses).
- *
- * @return a map of cache metrics
- */
- Map getCacheMetrics();
-
- /**
- * @return aggregate hit rate
- */
- long getCacheHitRate();
-
- /**
- * @return aggregate in-memory hit rate
- */
- long getCacheInMemoryHitRate();
-
- /**
- * @return aggregate off-heap hit rate
- */
- long getCacheOffHeapHitRate();
-
- /**
- * @return aggregate on-disk hit rate
- */
- long getCacheOnDiskHitRate();
-
- /**
- * @return aggregate miss rate
- */
- long getCacheMissRate();
-
- /**
- * @return aggregate in-memory miss rate
- */
- long getCacheInMemoryMissRate();
-
- /**
- * @return aggregate off-heap miss rate
- */
- long getCacheOffHeapMissRate();
-
- /**
- * @return aggregate on-disk miss rate
- */
- long getCacheOnDiskMissRate();
-
- /**
- * @return aggregate put rate
- */
- long getCachePutRate();
-
- /**
- * @return aggregate update rate
- */
- long getCacheUpdateRate();
-
- /**
- * @return aggregate remove rate
- */
- long getCacheRemoveRate();
-
- /**
- * @return aggregate eviction rate
- */
- long getCacheEvictionRate();
-
- /**
- * @return aggregate expiration rate
- */
- long getCacheExpirationRate();
-
- /**
- * @return aggregate average get time (ms.)
- */
- float getCacheAverageGetTime();
-
- /**
- * @return if any contained caches are configured for search
- */
- @ManagementAttribute
- boolean getSearchable();
-
- /**
- * @return aggregate search rate
- */
- long getCacheSearchRate();
-
- /**
- * @return aggregate search time
- */
- long getCacheAverageSearchTime();
-
- /**
- * generateActiveConfigDeclaration
- *
- * @return CacheManager configuration as String
- */
- String generateActiveConfigDeclaration();
-
- /**
- * generateActiveConfigDeclaration
- *
- * @param cacheName
- * @return Cache configuration as String
- */
- String generateActiveConfigDeclaration(String cacheName);
-
- /**
- * Are any of the caches transactional
- *
- * @see net.sf.ehcache.config.CacheConfiguration.TransactionalMode
- */
- @ManagementAttribute
- boolean getTransactional();
-
- /**
- * Get the committed transactions count
- *
- * @return the committed transactions count
- */
- long getTransactionCommittedCount();
-
- /**
- * @return aggregate Xa commit rate
- */
- long getTransactionCommitRate();
-
- /**
- * Get the rolled back transactions count
- *
- * @return the rolled back transactions count
- */
- long getTransactionRolledBackCount();
-
- /**
- * @return aggregate Xa rollback rate
- */
- long getTransactionRollbackRate();
-
- /**
- * Get the timed out transactions count. Note that only transactions which failed to
- * commit due to a timeout are taken into account
- *
- * @return the timed out transactions count
- */
- long getTransactionTimedOutCount();
-
- /**
- * Returns whether any caches are configured for write-behind
- */
- @ManagementAttribute
- boolean getHasWriteBehindWriter();
-
- /**
- * Returns the total length of all write-behind queues across all caches
- *
- * @return aggregate writer-behind queue length
- */
- long getWriterQueueLength();
-
- /**
- * Maximum elements that can be queued for processing by the write-behind writer
- *
- * @return aggregate of the maximum elements that can be waiting to be processed
- * by the write-behind writer across all caches
- */
- @ManagementAttribute
- int getWriterMaxQueueSize();
-
- /**
- * Maximum number of bytes of entries in the disk stores of all caches that
- * did not declare their own max size.
- *
- * @return maximum number of bytes in the disk stores of all caches that
- * did not declare their own max size.
- */
- @ManagementAttribute
- long getMaxBytesLocalDisk();
-
- /**
- * @param maxBytes
- */
- void setMaxBytesLocalDisk(long maxBytes);
-
- /**
- * @param maxBytes
- */
- void setMaxBytesLocalDiskAsString(String maxBytes);
-
- /**
- * @return Original input for maxBytesLocalDisk
- */
- @ManagementAttribute
- String getMaxBytesLocalDiskAsString();
-
- /**
- * Maximum number of bytes of entries in the heap memory stores of all caches that
- * did not declare their own max size.
- *
- * @return maximum number of bytes in the heap memory stores of all caches that
- * did not declare their own max size.
- */
- @ManagementAttribute
- long getMaxBytesLocalHeap();
-
- /**
- * @return Original input for maxBytesLocalHeap
- */
- @ManagementAttribute
- String getMaxBytesLocalHeapAsString();
-
- /**
- * @param maxBytes
- */
- void setMaxBytesLocalHeap(long maxBytes);
-
- /**
- * @param maxBytes
- */
- void setMaxBytesLocalHeapAsString(String maxBytes);
-
- /**
- * Maximum number of bytes of entries in the off-heap stores of all caches that
- * did not declare their own max size.
- *
- * @return maximum number of bytes in the off-heap stores of all caches that
- * did not declare their own max size.
- */
- @ManagementAttribute
- long getMaxBytesLocalOffHeap();
-
- /**
- * @return Original input for maxBytesLocalOffHeap
- */
- @ManagementAttribute
- String getMaxBytesLocalOffHeapAsString();
-
- /**
- * Execute a BMSQL query against the CacheManager and return result grid.
- *
- * @param queryString
- * @return query result grid
- */
- Object[][] executeQuery(String queryString);
-}
Index: rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/constructs/refreshahead/RefreshAheadCacheFactory.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/constructs/refreshahead/RefreshAheadCacheFactory.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/constructs/refreshahead/RefreshAheadCacheFactory.java (revision 0)
@@ -1,45 +0,0 @@
-/**
- * Copyright Terracotta, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.sf.ehcache.constructs.refreshahead;
-
-import java.util.Properties;
-
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.constructs.CacheDecoratorFactory;
-
-/**
- * Cache decorator factory for {@link RefreshAheadCache} instances
- *
- * @author cschanck
- *
- */
-public class RefreshAheadCacheFactory extends CacheDecoratorFactory {
-
- @Override
- public Ehcache createDecoratedEhcache(Ehcache cache, Properties properties) {
- RefreshAheadCacheConfiguration config = new RefreshAheadCacheConfiguration().fromProperties(properties).build();
- RefreshAheadCache decorator = new RefreshAheadCache(cache, config);
- return decorator;
- }
-
- @Override
- public Ehcache createDefaultDecoratedEhcache(Ehcache cache, Properties properties) {
- RefreshAheadCacheConfiguration config = new RefreshAheadCacheConfiguration().fromProperties(properties).build();
- RefreshAheadCache decorator = new RefreshAheadCache(cache, config);
- return decorator;
- }
-
-}
Index: rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/transaction/local/LocalRecoveryManager.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/transaction/local/LocalRecoveryManager.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/transaction/local/LocalRecoveryManager.java (revision 0)
@@ -1,90 +0,0 @@
-/**
- * Copyright Terracotta, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.sf.ehcache.transaction.local;
-
-import net.sf.ehcache.transaction.TransactionID;
-import net.sf.ehcache.transaction.TransactionIDFactory;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-/**
- * The local transactions mode recovery manager which is used to trigger full recovery of all
- * caches configured with local transaction mode.
- *
- * @author Ludovic Orban
- */
-public class LocalRecoveryManager {
-
- private final TransactionIDFactory transactionIdFactory;
- private final List localTransactionStores = new CopyOnWriteArrayList();
- private volatile Set previouslyRecoveredTransactionIDs = Collections.emptySet();
-
- /**
- * Create a LocalRecoveryManager instance
- * @param transactionIdFactory the TransactionIDFactory
- */
- public LocalRecoveryManager(TransactionIDFactory transactionIdFactory) {
- this.transactionIdFactory = transactionIdFactory;
- }
-
- /**
- * Register a LocalTransactionStore from the recovery manager
- * @param localTransactionStore the LocalTransactionStore
- */
- void register(LocalTransactionStore localTransactionStore) {
- localTransactionStores.add(localTransactionStore);
- }
-
- /**
- * Unregister a LocalTransactionStore from the recovery manager
- * @param localTransactionStore the LocalTransactionStore
- */
- void unregister(LocalTransactionStore localTransactionStore) {
- localTransactionStores.remove(localTransactionStore);
- }
-
- /**
- * Run recovery on all registered local transaction stores. The latter
- * are used internally by caches when they're configured with local transaction mode.
- * @return the set of recovered TransactionIDs
- */
- public Set recover() {
- Set recovered = new HashSet();
- // first ask all stores to cleanup their soft locks
- for (LocalTransactionStore localTransactionStore : localTransactionStores) {
- recovered.addAll(localTransactionStore.recover());
- }
- // then clear the transaction ID
- for (TransactionID transactionId : recovered) {
- transactionIdFactory.clear(transactionId);
- }
-
- previouslyRecoveredTransactionIDs = recovered;
- return recovered;
- }
-
- /**
- * Get the set of transaction IDs collected by the previous recover() call
- * @return the set of previously recovered TransactionIDs
- */
- public Set getPreviouslyRecoveredTransactionIDs() {
- return previouslyRecoveredTransactionIDs;
- }
-}
Index: rctags/ehcache-2.10.7.0.43/ehcache-core/src/test/java/net/sf/ehcache/config/generator/DecoratedCacheConfigTest.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/ehcache-core/src/test/java/net/sf/ehcache/config/generator/DecoratedCacheConfigTest.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/ehcache-core/src/test/java/net/sf/ehcache/config/generator/DecoratedCacheConfigTest.java (revision 0)
@@ -1,60 +0,0 @@
-/**
- * Copyright Terracotta, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.sf.ehcache.config.generator;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import junit.framework.Assert;
-import net.sf.ehcache.CacheManager;
-
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.terracotta.test.categories.CheckShorts;
-
-@Category(CheckShorts.class)
-public class DecoratedCacheConfigTest {
-
- private static final List ALL_CACHE_NAMES = Arrays.asList(new String[] {"noDecoratorCache", "oneDecoratorCache",
- "oneDecoratorCacheFirst", "twoDecoratorCache", "twoDecoratorCacheSecond", "twoDecoratorCacheFirst"});
-
- @Test
- public void testDecoratedCacheConfig() {
- CacheManager cm = CacheManager.newInstance(DecoratedCacheConfigTest.class.getClassLoader().getResource(
- "ehcache-decorator-noname-test.xml"));
- try {
- List names = new ArrayList(Arrays.asList(cm.getCacheNames()));
- names.removeAll(ALL_CACHE_NAMES);
- Assert.assertEquals("This list should be empty - " + names, 0, names.size());
- // System.out.println("Original config: " + cm.getOriginalConfigurationText());
- String text = cm.getActiveConfigurationText();
- // System.out.println("Cache manager config: " + text);
- for (String name : ALL_CACHE_NAMES) {
- Assert.assertTrue("Config not generated for cache name: " + name, text.contains("name=\"" + name + "\""));
- String cacheConfigTest = cm.getActiveConfigurationText(name);
- // System.out.println("Config for cache: '"+name+"': " + cacheConfigTest);
- Assert.assertTrue("Config not generated for cache name: " + name + ", with explicit call: ",
- cacheConfigTest.contains("name=\"" + name + "\""));
- }
-
- } finally {
- cm.shutdown();
- }
-
- }
-}
Index: rctags/ehcache-2.10.7.0.43/system-tests/src/test/java/org/terracotta/modules/ehcache/hibernate/domain/Person.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/system-tests/src/test/java/org/terracotta/modules/ehcache/hibernate/domain/Person.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/system-tests/src/test/java/org/terracotta/modules/ehcache/hibernate/domain/Person.java (revision 0)
@@ -1,108 +0,0 @@
-/*
- * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved.
- */
-
-package org.terracotta.modules.ehcache.hibernate.domain;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-public class Person {
-
- private Long id;
- private int age;
- private String firstname;
- private String lastname;
- private List events = new ArrayList(); // list semantics, e.g., indexed
- private Set emailAddresses = new HashSet();
- private Set phoneNumbers = new HashSet();
- private List talismans = new ArrayList(); // a Bag of good-luck charms.
-
- public Person() {
- //
- }
-
- public List getEvents() {
- return events;
- }
-
- protected void setEvents(List events) {
- this.events = events;
- }
-
- public void addToEvent(Event event) {
- this.getEvents().add(event);
- event.getParticipants().add(this);
- }
-
- public void removeFromEvent(Event event) {
- this.getEvents().remove(event);
- event.getParticipants().remove(this);
- }
-
- public int getAge() {
- return age;
- }
-
- public void setAge(int age) {
- this.age = age;
- }
-
- public String getFirstname() {
- return firstname;
- }
-
- public void setFirstname(String firstname) {
- this.firstname = firstname;
- }
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getLastname() {
- return lastname;
- }
-
- public void setLastname(String lastname) {
- this.lastname = lastname;
- }
-
- public Set getEmailAddresses() {
- return emailAddresses;
- }
-
- public void setEmailAddresses(Set emailAddresses) {
- this.emailAddresses = emailAddresses;
- }
-
- public Set getPhoneNumbers() {
- return phoneNumbers;
- }
-
- public void setPhoneNumbers(Set phoneNumbers) {
- this.phoneNumbers = phoneNumbers;
- }
-
- public void addTalisman(String name) {
- talismans.add(name);
- }
-
- public List getTalismans() {
- return talismans;
- }
-
- public void setTalismans(List talismans) {
- this.talismans = talismans;
- }
-
- public String toString() {
- return getFirstname() + " " + getLastname();
- }
-}
Index: rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/pool/sizeof/filter/package.html
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/pool/sizeof/filter/package.html (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/pool/sizeof/filter/package.html (revision 0)
@@ -1,7 +0,0 @@
-
-
-
-
-This package contains the SizeOf filtering interface and implementations for the pooling in Ehcache.
-
-
Index: rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/store/cachingtier/OnHeapCachingTier.java
===================================================================
diff -u -N
--- rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/store/cachingtier/OnHeapCachingTier.java (revision 11002)
+++ rctags/ehcache-2.10.7.0.43/ehcache-core/src/main/java/net/sf/ehcache/store/cachingtier/OnHeapCachingTier.java (revision 0)
@@ -1,364 +0,0 @@
-/**
- * Copyright Terracotta, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.sf.ehcache.store.cachingtier;
-
-import net.sf.ehcache.CacheException;
-import net.sf.ehcache.Ehcache;
-import net.sf.ehcache.Element;
-import net.sf.ehcache.config.AbstractCacheConfigurationListener;
-import net.sf.ehcache.config.PinningConfiguration;
-import net.sf.ehcache.config.SizeOfPolicyConfiguration;
-import net.sf.ehcache.pool.Pool;
-import net.sf.ehcache.pool.Size;
-import net.sf.ehcache.pool.SizeOfEngine;
-import net.sf.ehcache.pool.SizeOfEngineLoader;
-import net.sf.ehcache.pool.sizeof.annotations.IgnoreSizeOf;
-import net.sf.ehcache.store.CachingTier;
-import net.sf.ehcache.store.FifoPolicy;
-import net.sf.ehcache.store.LfuPolicy;
-import net.sf.ehcache.store.LruPolicy;
-import net.sf.ehcache.store.MemoryStoreEvictionPolicy;
-import net.sf.ehcache.store.Policy;
-
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CopyOnWriteArrayList;
-import net.sf.ehcache.store.StoreOperationOutcomes.GetOutcome;
-import net.sf.ehcache.store.StoreOperationOutcomes.PutOutcome;
-import net.sf.ehcache.store.StoreOperationOutcomes.RemoveOutcome;
-import org.terracotta.context.annotations.ContextChild;
-import org.terracotta.statistics.Statistic;
-import org.terracotta.statistics.observer.OperationObserver;
-
-import static net.sf.ehcache.statistics.StatisticBuilder.operation;
-
-/**
- * An instance of this class will delegate the storage to the backing HeapCacheBackEnd.
- * Adding :
- *
- *
making sure only a single thread populates the cache for a given key at a time
- *
translate calls to the eviction listeners
- *
Add all the crap about sizing and stuff
- *
- *
- * @param The key type
- * @param the value type
- * @author Alex Snaps
- */
-public class OnHeapCachingTier implements CachingTier {
-
- @ContextChild
- private final HeapCacheBackEnd backEnd;
-
- private final OperationObserver getObserver = operation(GetOutcome.class).named("get").of(this).tag("local-heap").build();
- private final OperationObserver putObserver = operation(PutOutcome.class).named("put").of(this).tag("local-heap").build();
- private final OperationObserver removeObserver = operation(RemoveOutcome.class).named("remove").of(this).tag("local-heap").build();
-
-
- private volatile List> listeners = new CopyOnWriteArrayList>();
-
- /**
- * A Constructor
- *
- * @param backEnd the HeapCacheBackEnd that will back this CachingTier
- */
- public OnHeapCachingTier(final HeapCacheBackEnd backEnd) {
- this.backEnd = backEnd;
- this.backEnd.registerEvictionCallback(new HeapCacheBackEnd.EvictionCallback() {
- @Override
- public void evicted(final K key, final Object value) {
- final V v = getValue(value);
- if (v != null) {
- for (Listener listener : listeners) {
- listener.evicted(key, v);
- }
- }
- }
- });
- }
-
- /**
- * Factory method
- * @param cache the cache we're planning to back
- * @param onHeapPool the pool, if any, to use
- * @return the OnHeapCachingTier properly configured for this cache
- */
- public static OnHeapCachingTier