[teiid-commits] teiid SVN: r2883 - in branches/7.1.x: cache-jbosscache/src/main/java/org/teiid/cache/jboss and 4 other directories.
teiid-commits at lists.jboss.org
teiid-commits at lists.jboss.org
Fri Jan 28 23:41:30 EST 2011
Author: rareddy
Date: 2011-01-28 23:41:29 -0500 (Fri, 28 Jan 2011)
New Revision: 2883
Modified:
branches/7.1.x/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusterableCacheFactory.java
branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java
branches/7.1.x/engine/src/main/java/org/teiid/cache/Cache.java
branches/7.1.x/engine/src/main/java/org/teiid/cache/CacheConfiguration.java
branches/7.1.x/engine/src/main/java/org/teiid/cache/CacheFactory.java
branches/7.1.x/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java
branches/7.1.x/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
branches/7.1.x/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
Log:
TEIID-1439: decoupled the cache type from the cache location. Materialization Cache and ResultSet cache were using the same JBoss cache node, thus the data was getting mixed up.
Modified: branches/7.1.x/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml
===================================================================
--- branches/7.1.x/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml 2011-01-28 16:30:26 UTC (rev 2882)
+++ branches/7.1.x/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml 2011-01-29 04:41:29 UTC (rev 2883)
@@ -66,7 +66,8 @@
<!-- Allowed values are LRU, EXPIRATION.
Setting this value to LRU will cause cache hint TTL values
to be ignored. (default EXPIRATION) -->
- <property name="type">EXPIRATION</property>
+ <property name="type">EXPIRATION</property>
+ <property name="location">resultset</property>
</bean>
<bean name="RuntimeEngineDeployer" class="org.teiid.jboss.deployers.RuntimeEngineDeployer">
Modified: branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusterableCacheFactory.java
===================================================================
--- branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusterableCacheFactory.java 2011-01-28 16:30:26 UTC (rev 2882)
+++ branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ClusterableCacheFactory.java 2011-01-29 04:41:29 UTC (rev 2883)
@@ -31,7 +31,6 @@
import org.teiid.cache.CacheConfiguration;
import org.teiid.cache.CacheFactory;
import org.teiid.cache.DefaultCacheFactory;
-import org.teiid.cache.Cache.Type;
import org.teiid.core.TeiidRuntimeException;
public class ClusterableCacheFactory implements CacheFactory, Serializable {
@@ -42,7 +41,7 @@
private String cacheManagerName;
@Override
- public <K, V> Cache<K, V> get(Type type, CacheConfiguration config) {
+ public <K, V> Cache<K, V> get(String location, CacheConfiguration config) {
if (this.delegate == null) {
Object cacheManager = getClusteredCache();
if (cacheManager == null) {
@@ -56,7 +55,7 @@
}
}
}
- return delegate.get(type, config);
+ return delegate.get(location, config);
}
public void setResultsetCacheName(String name) {
Modified: branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java
===================================================================
--- branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java 2011-01-28 16:30:26 UTC (rev 2882)
+++ branches/7.1.x/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java 2011-01-29 04:41:29 UTC (rev 2883)
@@ -36,7 +36,6 @@
import org.teiid.cache.Cache;
import org.teiid.cache.CacheConfiguration;
import org.teiid.cache.CacheFactory;
-import org.teiid.cache.Cache.Type;
import org.teiid.cache.CacheConfiguration.Policy;
import org.teiid.core.TeiidRuntimeException;
@@ -55,7 +54,7 @@
/**
* {@inheritDoc}
*/
- public Cache get(Type type, CacheConfiguration config) {
+ public Cache get(String location, CacheConfiguration config) {
if (!destroyed) {
if (!this.cacheStore.getCacheStatus().allowInvocations()) {
@@ -63,7 +62,7 @@
}
Node cacheRoot = this.cacheStore.getRoot().addChild(Fqn.fromString("Teiid")); //$NON-NLS-1$
- Node node = cacheRoot.addChild(Fqn.fromString(type.location()));
+ Node node = cacheRoot.addChild(Fqn.fromString(location));
node.setResident(true);
Region cacheRegion = this.cacheStore.getRegion(node.getFqn(), true);
Modified: branches/7.1.x/engine/src/main/java/org/teiid/cache/Cache.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/cache/Cache.java 2011-01-28 16:30:26 UTC (rev 2882)
+++ branches/7.1.x/engine/src/main/java/org/teiid/cache/Cache.java 2011-01-29 04:41:29 UTC (rev 2883)
@@ -28,29 +28,7 @@
* Abstraction over cache providers
*/
public interface Cache<K, V> {
-
- public enum Type {
- MATTABLES("MatTables"), //$NON-NLS-1$
- MATTABLEUPDATES("MatTableUpdates"), //$NON-NLS-1$
- RESULTSET("ResultSet"), //$NON-NLS-1$
- RESULTSET_BATCHES(RESULTSET, "batches"), //$NON-NLS-1$
- PREPAREDPLAN("PreparaedPlan"); //$NON-NLS-1$
- private String location;
-
- Type(String location){
- this.location = location;
- }
-
- Type(Type base, String location){
- this.location = base.location+"/"+location; //$NON-NLS-1$
- }
-
- public String location() {
- return this.location;
- }
- }
-
/**
* Retrieves the value for the given Key
*
Modified: branches/7.1.x/engine/src/main/java/org/teiid/cache/CacheConfiguration.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/cache/CacheConfiguration.java 2011-01-28 16:30:26 UTC (rev 2882)
+++ branches/7.1.x/engine/src/main/java/org/teiid/cache/CacheConfiguration.java 2011-01-29 04:41:29 UTC (rev 2883)
@@ -30,9 +30,7 @@
@ManagementObject(componentType=@ManagementComponent(type="teiid",subtype="dqp"), properties=ManagementProperties.EXPLICIT)
public class CacheConfiguration {
-
- public static CacheConfiguration DEFAULT = new CacheConfiguration(Policy.LRU, 60*60, 100); // 1 hours with 100 nodes.
-
+
public enum Policy {
LRU, // Least Recently Used
EXPIRATION
@@ -43,14 +41,16 @@
private int maxEntries;
private boolean enabled = true;
private String name;
-
+ private String location;
+
public CacheConfiguration() {
}
- public CacheConfiguration(Policy policy, int maxAgeInSeconds, int maxNodes) {
+ public CacheConfiguration(Policy policy, int maxAgeInSeconds, int maxNodes, String location) {
this.policy = policy;
this.maxage = maxAgeInSeconds;
this.maxEntries = maxNodes;
+ this.location = location;
}
public Policy getPolicy() {
@@ -89,6 +89,15 @@
this.name = name;
}
+ @ManagementProperty(description="location prefix in cache", readOnly=true)
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
@Override
public int hashCode() {
final int prime = 31;
Modified: branches/7.1.x/engine/src/main/java/org/teiid/cache/CacheFactory.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/cache/CacheFactory.java 2011-01-28 16:30:26 UTC (rev 2882)
+++ branches/7.1.x/engine/src/main/java/org/teiid/cache/CacheFactory.java 2011-01-29 04:41:29 UTC (rev 2883)
@@ -30,7 +30,7 @@
* @param config configuration setup for the cache
* @return
*/
- <K,V> Cache<K, V> get(Cache.Type type, CacheConfiguration config);
+ <K,V> Cache<K, V> get(String location, CacheConfiguration config);
/**
* Destroy the cache factory and any caches underneath.
Modified: branches/7.1.x/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java 2011-01-28 16:30:26 UTC (rev 2882)
+++ branches/7.1.x/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java 2011-01-29 04:41:29 UTC (rev 2883)
@@ -23,18 +23,19 @@
import java.io.Serializable;
-import org.teiid.cache.Cache.Type;
+import org.teiid.cache.CacheConfiguration.Policy;
import org.teiid.core.TeiidRuntimeException;
public class DefaultCacheFactory implements CacheFactory, Serializable {
private static final long serialVersionUID = -5541424157695857527L;
+ private static CacheConfiguration DEFAULT = new CacheConfiguration(Policy.LRU, 60*60, 100, "default"); // 1 hours with 100 nodes. //$NON-NLS-1$
DefaultCache cacheRoot;
private volatile boolean destroyed = false;
public DefaultCacheFactory() {
- this(CacheConfiguration.DEFAULT);
+ this(DEFAULT);
}
public DefaultCacheFactory(CacheConfiguration config) {
@@ -47,9 +48,9 @@
}
@Override
- public <K, V> Cache<K, V> get(Type type, CacheConfiguration config) {
+ public <K, V> Cache<K, V> get(String location, CacheConfiguration config) {
if (!destroyed) {
- return cacheRoot.addChild(type.location());
+ return cacheRoot.addChild(location);
}
throw new TeiidRuntimeException("Cache system has been shutdown"); //$NON-NLS-1$
}
Modified: branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2011-01-28 16:30:26 UTC (rev 2882)
+++ branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2011-01-29 04:41:29 UTC (rev 2883)
@@ -44,7 +44,6 @@
import org.teiid.adminapi.impl.CacheStatisticsMetadata;
import org.teiid.adminapi.impl.RequestMetadata;
import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
-import org.teiid.cache.Cache;
import org.teiid.cache.CacheConfiguration;
import org.teiid.cache.CacheFactory;
import org.teiid.cache.CacheConfiguration.Policy;
@@ -694,24 +693,23 @@
//result set cache
CacheConfiguration rsCacheConfig = config.getResultsetCacheConfig();
if (rsCacheConfig != null && rsCacheConfig.isEnabled()) {
- this.rsCache = new SessionAwareCache<CachedResults>(this.cacheFactory, Cache.Type.RESULTSET, rsCacheConfig);
+ this.rsCache = new SessionAwareCache<CachedResults>(this.cacheFactory, SessionAwareCache.Type.RESULTSET, rsCacheConfig);
this.rsCache.setBufferManager(this.bufferManager);
}
//prepared plan cache
- prepPlanCache = new SessionAwareCache<PreparedPlan>(this.cacheFactory, Cache.Type.PREPAREDPLAN, new CacheConfiguration(Policy.LRU, 60*60*8, config.getPreparedPlanCacheMaxCount()));
+ prepPlanCache = new SessionAwareCache<PreparedPlan>(this.cacheFactory, SessionAwareCache.Type.PREPAREDPLAN, new CacheConfiguration(Policy.LRU, 60*60*8, config.getPreparedPlanCacheMaxCount(), "PreparedCache")); //$NON-NLS-1$
prepPlanCache.setBufferManager(this.bufferManager);
this.processWorkerPool = new ThreadReuseExecutor(DQPConfiguration.PROCESS_PLAN_QUEUE_NAME, config.getMaxThreads());
if (cacheFactory.isReplicated()) {
- matTables = new SessionAwareCache<CachedResults>(this.cacheFactory, Cache.Type.RESULTSET, new CacheConfiguration(Policy.LRU, -1, -1));
+ matTables = new SessionAwareCache<CachedResults>(this.cacheFactory, SessionAwareCache.Type.RESULTSET, new CacheConfiguration(Policy.LRU, -1, -1, "MaterilizationTables")); //$NON-NLS-1$
matTables.setBufferManager(this.bufferManager);
}
- dataTierMgr = new TempTableDataManager(new DataTierManagerImpl(this,
- this.bufferService), this.bufferManager, this.processWorkerPool, this.rsCache, matTables, this.cacheFactory);
+ dataTierMgr = new TempTableDataManager(new DataTierManagerImpl(this,this.bufferService), this.bufferManager, this.processWorkerPool, this.rsCache, this.matTables, this.cacheFactory);
}
public void setBufferService(BufferService service) {
Modified: branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java 2011-01-28 16:30:26 UTC (rev 2882)
+++ branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java 2011-01-29 04:41:29 UTC (rev 2883)
@@ -51,6 +51,10 @@
*/
public class SessionAwareCache<T> {
public static final int DEFAULT_MAX_SIZE_TOTAL = 512;
+ public enum Type {
+ RESULTSET,
+ PREPAREDPLAN;
+ }
private Cache<CacheID, T> localCache;
private Cache<CacheID, T> distributedCache;
@@ -68,23 +72,24 @@
}
SessionAwareCache(int maxSize){
- this(new DefaultCacheFactory(), Cache.Type.RESULTSET, new CacheConfiguration(Policy.LRU, 60, maxSize));
+ this(new DefaultCacheFactory(), Type.RESULTSET, new CacheConfiguration(Policy.LRU, 60, maxSize, "default")); //$NON-NLS-1$
}
- SessionAwareCache (final CacheFactory cacheFactory, final Cache.Type type, final CacheConfiguration config){
+ SessionAwareCache (final CacheFactory cacheFactory, final Type type, final CacheConfiguration config){
this.maxSize = config.getMaxEntries();
if(this.maxSize < 0){
this.maxSize = Integer.MAX_VALUE;
}
this.localCache = new DefaultCache<CacheID, T>("local", maxSize, config.getMaxAgeInSeconds()*1000); //$NON-NLS-1$
- if (type == Cache.Type.PREPAREDPLAN) {
+ if (type == Type.PREPAREDPLAN) {
this.distributedCache = localCache;
}
else {
- this.distributedCache = cacheFactory.get(type, config);
- if (type == Cache.Type.RESULTSET) {
- this.tupleBatchCache = cacheFactory.get(Cache.Type.RESULTSET_BATCHES, config);
+ String location = config.getLocation()+"/"+type.name(); //$NON-NLS-1$
+ this.distributedCache = cacheFactory.get(location, config);
+ if (type == Type.RESULTSET) {
+ this.tupleBatchCache = cacheFactory.get(location+"/batches", config); //$NON-NLS-1$
}
else {
this.tupleBatchCache = this.distributedCache;
Modified: branches/7.1.x/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2011-01-28 16:30:26 UTC (rev 2882)
+++ branches/7.1.x/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2011-01-29 04:41:29 UTC (rev 2883)
@@ -153,8 +153,8 @@
this.cache = cache;
this.distributedCache = distibutedCache;
if (distibutedCache != null) {
- CacheConfiguration cc = new CacheConfiguration(Policy.LRU, -1, -1);
- tables = cacheFactory.get(Cache.Type.MATTABLES, cc);
+ CacheConfiguration cc = new CacheConfiguration(Policy.LRU, -1, -1, "MaterializationUpdates"); //$NON-NLS-1$
+ tables = cacheFactory.get(cc.getLocation(), cc);
}
}
Modified: branches/7.1.x/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
===================================================================
--- branches/7.1.x/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2011-01-28 16:30:26 UTC (rev 2882)
+++ branches/7.1.x/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2011-01-29 04:41:29 UTC (rev 2883)
@@ -87,7 +87,7 @@
});
DQPConfiguration config = new DQPConfiguration();
- config.setResultsetCacheConfig(new CacheConfiguration(Policy.LRU, 60, 250));
+ config.setResultsetCacheConfig(new CacheConfiguration(Policy.LRU, 60, 250, "resultsetcache")); //$NON-NLS-1$
this.dqp.setCacheFactory(new DefaultCacheFactory());
this.dqp.start(config);
this.sessionService.setDqp(this.dqp);
More information about the teiid-commits
mailing list