[teiid-commits] teiid SVN: r2434 - in trunk: build/kits/jboss-container/deploy/teiid and 5 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Tue Aug 10 10:51:16 EDT 2010


Author: rareddy
Date: 2010-08-10 10:51:15 -0400 (Tue, 10 Aug 2010)
New Revision: 2434

Added:
   trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java
Removed:
   trunk/cache-jbosscache/src/main/java/com/metamatrix/cache/
Modified:
   trunk/build/kits/jboss-container/conf/jboss-teiid-log4j.xml
   trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml
   trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java
   trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java
   trunk/engine/src/main/java/org/teiid/cache/CacheConfiguration.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java
   trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
Log:
TEIID-1104: Configuring resultset cache as expirable cache.

Modified: trunk/build/kits/jboss-container/conf/jboss-teiid-log4j.xml
===================================================================
--- trunk/build/kits/jboss-container/conf/jboss-teiid-log4j.xml	2010-08-10 11:01:40 UTC (rev 2433)
+++ trunk/build/kits/jboss-container/conf/jboss-teiid-log4j.xml	2010-08-10 14:51:15 UTC (rev 2434)
@@ -7,8 +7,13 @@
    <!-- Teiid root category snippet.  Use this to control all of Teiid logging from a single category -->
    <logger name="org.teiid">
      <level value="INFO" />
-   </logger>   
+   </logger>
    
+   <!--  this is to avoid the "Unable to remove nodes to reduce region size below 1024.  Set expiration for nodes in this region" error -->
+   <logger name="org.jboss.cache">
+     <level value="ERROR" />
+   </logger>  
+   
  <!-- Other categories:
 	org.teiid.PROCESSOR - Query processing logs. See also org.teiid.PLANNER for query planning logs.
 	

Modified: trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml
===================================================================
--- trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml	2010-08-10 11:01:40 UTC (rev 2433)
+++ trunk/build/kits/jboss-container/deploy/teiid/teiid-jboss-beans.xml	2010-08-10 14:51:15 UTC (rev 2434)
@@ -49,6 +49,16 @@
         <property name="clusteredCacheName">mvcc-shared</property>
     </bean>
     
+    <bean name="ResultsetCacheConfig" class="org.teiid.cache.CacheConfiguration">
+        <property name="enabled">true</property>
+        <!-- Max Entries allowed for ResultSet Cache -->
+        <property name="maxEntries">1024</property>
+        <!-- 2 hrs -->
+        <property name="maxAgeInSeconds">7200</property>
+        <!-- Allowed values are LRU, FIFO, LFU, EXPIRATION -->
+        <property name="type">EXPIRATION</property>               
+    </bean>    
+    
     <bean name="RuntimeEngineDeployer" class="org.teiid.jboss.deployers.RuntimeEngineDeployer">
         <property name="jndiName">teiid/engine-deployer</property>
         <property name="profileService"><inject bean="ProfileService"/></property>
@@ -63,8 +73,8 @@
         <property name="securityHelper"><inject bean="SecurityHelper"/></property>
         <property name="VDBRepository"><inject bean="VDBRepository"/></property>
         <property name="cacheFactory"><inject bean="CacheFactory"/></property>
+        <property name="resultsetCacheConfig"><inject bean="ResultsetCacheConfig"/></property>
         
-        
         <!-- Process pool maximum thread count. (default 64) -->
         <property name="maxThreads">64</property>
         <!-- Max active plans (default 20).  Increase this value on highly concurrent systems - but ensure that the underlying pools can handle the increased load without timeouts. -->
@@ -77,10 +87,6 @@
         <property name="lobChunkSizeInKB">100</property>
         <!-- The maximum number of query plans that are cached. Note: this is a memory based cache. (default 250)  -->
         <property name="preparedPlanCacheMaxCount">250</property>
-        <!-- Max Entries allowed for ResultSet Cache -->
-        <property name="resultSetCacheMaxEntries">1024</property>
-        <!-- Enable Resultset Caching -->
-        <property name="resultSetCacheEnabled">true</property>
         <!-- Turn on checking the entitlements on resources based on the roles defined in VDB -->
         <property name="useEntitlements" class="java.lang.Boolean">false</property>
         <!-- Long running query threshold, after which a alert can be generated by tooling if configured-->

Added: trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java
===================================================================
--- trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java	                        (rev 0)
+++ trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java	2010-08-10 14:51:15 UTC (rev 2434)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.cache.jboss;
+
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+import org.jboss.cache.eviction.ExpirationAlgorithmConfig;
+
+public class ExpirationAwareCache<K, V> extends JBossCache<K, V> {
+
+	public ExpirationAwareCache(Cache cacheStore, Fqn fqn) {
+		super(cacheStore, fqn);
+	}
+
+	@Override
+	public V get(K key) {
+		Node<K, V> node = getRootNode();
+		Node child = node.getChild(Fqn.fromString(String.valueOf(key.getClass().getSimpleName()+key.hashCode())));
+		if (child != null) {
+			return (V)child.get(key);
+		}
+		return super.get(key);
+	}
+
+	@Override
+	public V put(K key, V value) {
+		Node<K, V> node = getRootNode();
+		Node child = node.addChild(Fqn.fromString(String.valueOf(key.getClass().getSimpleName()+key.hashCode())));
+		Long future = new Long(System.currentTimeMillis() + (config.getMaxAgeInSeconds()*1000));				
+		child.put(ExpirationAlgorithmConfig.EXPIRATION_KEY, future);
+		return (V)child.put(key, value);
+	}
+
+	@Override
+	public org.teiid.cache.Cache<K, V> addChild(String name) {
+		Node<K, V> node = getRootNode();
+		Node child = node.addChild(Fqn.fromString(name));
+		child.put(ExpirationAlgorithmConfig.EXPIRATION_KEY, Long.MAX_VALUE);		
+		return new JBossCache<K, V>(this.cacheStore, child.getFqn());
+	}
+
+}


Property changes on: trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/ExpirationAwareCache.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java
===================================================================
--- trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java	2010-08-10 11:01:40 UTC (rev 2433)
+++ trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCache.java	2010-08-10 14:51:15 UTC (rev 2434)
@@ -31,6 +31,7 @@
 import org.jboss.cache.Fqn;
 import org.jboss.cache.Node;
 import org.teiid.cache.Cache;
+import org.teiid.cache.CacheConfiguration;
 import org.teiid.cache.CacheListener;
 
 
@@ -39,9 +40,10 @@
  */
 public class JBossCache<K, V> implements Cache<K, V> {
 
-	private org.jboss.cache.Cache<K, V> cacheStore;
-	private Fqn rootFqn;
-	private JBossCacheListener cacheListener;
+	protected org.jboss.cache.Cache<K, V> cacheStore;
+	protected Fqn rootFqn;
+	protected JBossCacheListener cacheListener;
+	protected CacheConfiguration config;
 	
 	public JBossCache(org.jboss.cache.Cache<K, V> cacheStore, Fqn fqn) {
 		this.cacheStore = cacheStore;
@@ -149,7 +151,7 @@
 		return null;
 	}
 
-	private Node<K, V> getRootNode() {
+	protected Node<K, V> getRootNode() {
 		Node<K, V> node = this.cacheStore.getNode(this.rootFqn);
 		if (node == null) {
 			throw new IllegalStateException("Cache Node "+ this.rootFqn +" not found."); //$NON-NLS-1$ //$NON-NLS-2$
@@ -186,5 +188,9 @@
 	@Override
 	public String getName() {
 		return this.rootFqn.toString();
-	} 	
+	}
+
+	void setCacheConfiguration(CacheConfiguration config) {
+		this.config = config;
+	}
 }

Modified: trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java
===================================================================
--- trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java	2010-08-10 11:01:40 UTC (rev 2433)
+++ trunk/cache-jbosscache/src/main/java/org/teiid/cache/jboss/JBossCacheFactory.java	2010-08-10 14:51:15 UTC (rev 2434)
@@ -30,9 +30,11 @@
 import org.jboss.cache.Region;
 import org.jboss.cache.config.EvictionAlgorithmConfig;
 import org.jboss.cache.config.EvictionRegionConfig;
+import org.jboss.cache.eviction.ExpirationAlgorithmConfig;
 import org.jboss.cache.eviction.FIFOAlgorithmConfig;
 import org.jboss.cache.eviction.LFUAlgorithmConfig;
 import org.jboss.cache.eviction.LRUAlgorithmConfig;
+import org.jboss.cache.eviction.RemoveOnEvictActionPolicy;
 import org.teiid.cache.Cache;
 import org.teiid.cache.CacheConfiguration;
 import org.teiid.cache.CacheFactory;
@@ -64,39 +66,61 @@
 			
 			Node cacheRoot = this.cacheStore.getRoot().addChild(Fqn.fromString("Teiid")); //$NON-NLS-1$
 			Node node = cacheRoot.addChild(Fqn.fromString(type.location()));
+			node.put(ExpirationAlgorithmConfig.EXPIRATION_KEY, Long.MAX_VALUE);
+			node.setResident(true);
 			
 			Region cacheRegion = this.cacheStore.getRegion(node.getFqn(), true);
-			EvictionRegionConfig erc = new EvictionRegionConfig(node.getFqn(), buildEvictionAlgorithmConfig(config));
-			cacheRegion.setEvictionRegionConfig(erc);
+			cacheRegion.setEvictionRegionConfig(buildEvictionConfig(node.getFqn(), config));
+						
+			JBossCache jc = null;
+			if (config != null && config.getPolicy().equals(Policy.EXPIRATION)) {
+				jc = new ExpirationAwareCache(this.cacheStore, node.getFqn());
+			}
+			else {
+				jc = new JBossCache(this.cacheStore, node.getFqn());	
+			}
 			
-			return new JBossCache(this.cacheStore, node.getFqn());
+			jc.setCacheConfiguration(config);
+			return jc;
 		}
 		throw new TeiidRuntimeException("Cache system has been shutdown"); //$NON-NLS-1$
 	}
-
-	private EvictionAlgorithmConfig  buildEvictionAlgorithmConfig(CacheConfiguration config) {
+	
+	private EvictionRegionConfig  buildEvictionConfig(Fqn rootFqn, CacheConfiguration config) {
 		EvictionAlgorithmConfig  evictionConfig = null;
 		
 		if (config.getPolicy() == Policy.LRU) {
 			LRUAlgorithmConfig lru = new LRUAlgorithmConfig();
-			lru.setMaxNodes(config.getMaxNodes());
+			lru.setMaxNodes(config.getMaxEntries());
 			lru.setMaxAge(config.getMaxAgeInSeconds()*1000);
 			lru.setTimeToLive(-1); // -1 no limit
 			evictionConfig = lru;
 		}
 		else if (config.getPolicy() == Policy.FIFO) {
 			FIFOAlgorithmConfig fifo = new FIFOAlgorithmConfig();
-			fifo.setMaxNodes(config.getMaxNodes());
+			fifo.setMaxNodes(config.getMaxEntries());
 			evictionConfig = fifo;
 		}
 		else if (config.getPolicy() == Policy.LFU) {
 			LFUAlgorithmConfig lfu  = new LFUAlgorithmConfig();
-			lfu.setMaxNodes(config.getMaxNodes());
+			lfu.setMaxNodes(config.getMaxEntries());
 			evictionConfig = lfu;
 		}
-		return evictionConfig;
-	}    
+		else if (config.getPolicy() == Policy.EXPIRATION) {
+			ExpirationAlgorithmConfig lfu  = new ExpirationAlgorithmConfig();
+			lfu.setMaxNodes(config.getMaxEntries());
+			evictionConfig = lfu;
+		}
+		
+		EvictionRegionConfig erc = new EvictionRegionConfig(rootFqn, evictionConfig);
+		
+		if (config.getPolicy() == Policy.EXPIRATION) {
+			erc.setEvictionActionPolicyClassName(RemoveOnEvictActionPolicy.class.getName());
+		}
+		return erc;
+	}	
 	
+	
 	public void destroy() {
 		this.destroyed = true;		
 	}	

Modified: trunk/engine/src/main/java/org/teiid/cache/CacheConfiguration.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/cache/CacheConfiguration.java	2010-08-10 11:01:40 UTC (rev 2433)
+++ trunk/engine/src/main/java/org/teiid/cache/CacheConfiguration.java	2010-08-10 14:51:15 UTC (rev 2434)
@@ -29,17 +29,22 @@
 	public enum Policy {
 		LRU,  // Least Recently Used
 		FIFO, // First in First Out
-		LFU;  // Least frequently Used
+		LFU,  // Least frequently Used
+		EXPIRATION; // expires after certain time.
 	}
 	
 	private Policy policy;
 	private int maxage;
-	private int maxnodes;
+	private int maxEntries;
+	private boolean enabled = true;
 	
+	public CacheConfiguration() {
+	}
+	
 	public CacheConfiguration(Policy policy, int maxAgeInSeconds, int maxNodes) {
 		this.policy = policy;
 		this.maxage = maxAgeInSeconds;
-		this.maxnodes = maxNodes;
+		this.maxEntries = maxNodes;
 	}
 	
 	public Policy getPolicy() {
@@ -49,8 +54,59 @@
 	public int getMaxAgeInSeconds(){
 		return maxage;
 	}
+
+	public void setMaxAgeInSeconds(int maxage){
+		this.maxage = maxage;
+	}
 	
-	public int getMaxNodes() {
-		return this.maxnodes;
+	public int getMaxEntries() {
+		return this.maxEntries;
 	}
+
+	public void setMaxEntries(int entries) {
+		this.maxEntries = entries;
+	}
+
+	public void setType (String type) {
+		this.policy = Policy.valueOf(type);
+	}
+	
+	@Override
+	public int hashCode() {
+		final int prime = 31;
+		int result = 1;
+		result = prime * result + maxage;
+		result = prime * result + maxEntries;
+		result = prime * result + ((policy == null) ? 0 : policy.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;
+		CacheConfiguration other = (CacheConfiguration) obj;
+		if (maxage != other.maxage)
+			return false;
+		if (maxEntries != other.maxEntries)
+			return false;
+		if (policy == null) {
+			if (other.policy != null)
+				return false;
+		} else if (!policy.equals(other.policy))
+			return false;
+		return true;
+	}
+
+	public boolean isEnabled() {
+		return enabled;
+	}
+
+	public void setEnabled(boolean enabled) {
+		this.enabled = enabled;
+	}
 }

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java	2010-08-10 11:01:40 UTC (rev 2433)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java	2010-08-10 14:51:15 UTC (rev 2434)
@@ -22,6 +22,7 @@
 package org.teiid.dqp.internal.process;
 
 import org.jboss.managed.api.annotation.ManagementProperty;
+import org.teiid.cache.CacheConfiguration;
 import org.teiid.client.RequestMessage;
 import org.teiid.core.util.ApplicationInfo;
 
@@ -43,13 +44,12 @@
 	private int maxRowsFetchSize = DEFAULT_FETCH_SIZE;
 	private int lobChunkSizeInKB = 100;
 	private int preparedPlanCacheMaxCount = SessionAwareCache.DEFAULT_MAX_SIZE_TOTAL;
-	private boolean resultSetCacheEnabled = true;
-	private int maxResultSetCacheEntries = DQPConfiguration.DEFAULT_MAX_RESULTSET_CACHE_ENTRIES;
 	private boolean useEntitlements = false;
 	private int queryThresholdInSecs = DEFAULT_QUERY_THRESHOLD;
 	private boolean exceptionOnMaxSourceRows = true;
 	private int maxSourceRows = -1;
 	private int maxActivePlans = DEFAULT_MAX_ACTIVE_PLANS;
+	private CacheConfiguration resultsetCacheConfig;
 
 	@ManagementProperty(description="Max active plans (default 20).  Increase this value, and max threads, on highly concurrent systems - but ensure that the underlying pools can handle the increased load without timeouts.")
 	public int getMaxActivePlans() {
@@ -107,22 +107,22 @@
 
 	@ManagementProperty(description="The maximum number of result set cache entries. 0 indicates no limit. (default 1024)")
 	public int getResultSetCacheMaxEntries() {
-		return this.maxResultSetCacheEntries;
+		return this.resultsetCacheConfig.getMaxEntries();
 	}
 	
-	public void setResultSetCacheMaxEntries(int value) {
-		this.maxResultSetCacheEntries = value;
+	public CacheConfiguration getResultsetCacheConfig() {
+		return this.resultsetCacheConfig;
+	}	
+	
+	public void setResultsetCacheConfig(CacheConfiguration config) {
+		this.resultsetCacheConfig = config;
 	}
-
+	
 	@ManagementProperty(description="Denotes whether or not result set caching is enabled. (default true)")
 	public boolean isResultSetCacheEnabled() {
-		return this.resultSetCacheEnabled;
+		return this.resultsetCacheConfig.isEnabled();
 	}
-	
-	public void setResultSetCacheEnabled(boolean value) {
-		this.resultSetCacheEnabled = value;
-	}		
-	
+		
     /**
      * Determine whether entitlements checking is enabled on the server.
      * @return <code>true</code> if server-side entitlements checking is enabled.

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java	2010-08-10 11:01:40 UTC (rev 2433)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java	2010-08-10 14:51:15 UTC (rev 2434)
@@ -44,7 +44,9 @@
 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;
 import org.teiid.client.DQP;
 import org.teiid.client.RequestMessage;
 import org.teiid.client.ResultsMessage;
@@ -630,13 +632,14 @@
         this.chunkSize = config.getLobChunkSizeInKB() * 1024;
         
         //result set cache
-        if (config.isResultSetCacheEnabled()) {
-			this.rsCache = new SessionAwareCache<CachedResults>(config.getResultSetCacheMaxEntries(), this.cacheFactory, Cache.Type.RESULTSET);
+        CacheConfiguration rsCacheConfig = config.getResultsetCacheConfig();
+        if (rsCacheConfig != null && rsCacheConfig.isEnabled()) {
+			this.rsCache = new SessionAwareCache<CachedResults>(this.cacheFactory, Cache.Type.RESULTSET, rsCacheConfig);
 			this.rsCache.setBufferManager(this.bufferManager);
         }
 
         //prepared plan cache
-        prepPlanCache = new SessionAwareCache<PreparedPlan>(config.getPreparedPlanCacheMaxCount(), this.cacheFactory, Cache.Type.PREPAREDPLAN);
+        prepPlanCache = new SessionAwareCache<PreparedPlan>(this.cacheFactory, Cache.Type.PREPAREDPLAN,  new CacheConfiguration(Policy.LRU, 60, config.getPreparedPlanCacheMaxCount()));
         prepPlanCache.setBufferManager(this.bufferManager);
 		
         //get buffer manager

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java	2010-08-10 11:01:40 UTC (rev 2433)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java	2010-08-10 14:51:15 UTC (rev 2434)
@@ -33,6 +33,7 @@
 import org.teiid.cache.CacheFactory;
 import org.teiid.cache.DefaultCache;
 import org.teiid.cache.DefaultCacheFactory;
+import org.teiid.cache.CacheConfiguration.Policy;
 import org.teiid.common.buffer.BufferManager;
 import org.teiid.core.util.EquivalenceUtil;
 import org.teiid.core.util.HashCodeUtil;
@@ -50,32 +51,32 @@
 	private Cache<CacheID, T> localCache;
 	private Cache<CacheID, T> distributedCache;
 	
-	private int maxSize;
+	private int maxSize = DEFAULT_MAX_SIZE_TOTAL;
 	
 	private AtomicInteger cacheHit = new AtomicInteger();
 	
 	private BufferManager bufferManager;
 	
 	SessionAwareCache(){
-		this(DEFAULT_MAX_SIZE_TOTAL, new DefaultCacheFactory(), Cache.Type.RESULTSET);
+		this(new DefaultCacheFactory(), Cache.Type.RESULTSET, new CacheConfiguration(Policy.LRU, 60, DEFAULT_MAX_SIZE_TOTAL));
 	}
 	
 	SessionAwareCache(int maxSize){
-		this(maxSize, new DefaultCacheFactory(), Cache.Type.RESULTSET);
+		this(new DefaultCacheFactory(), Cache.Type.RESULTSET, new CacheConfiguration(Policy.LRU, 60, maxSize));
 	}
 	
-	SessionAwareCache (int maxSize, final CacheFactory cacheFactory, final Cache.Type type){
-		if(maxSize < 0){
-			maxSize = DEFAULT_MAX_SIZE_TOTAL;
-		}
-		this.maxSize = maxSize;
+	SessionAwareCache (final CacheFactory cacheFactory, final Cache.Type type, final CacheConfiguration config){
+		this.maxSize = config.getMaxEntries();
+		if(this.maxSize < 0){
+			this.maxSize = DEFAULT_MAX_SIZE_TOTAL;
+		}		
 		this.localCache = new DefaultCache<CacheID, T>("local", maxSize); //$NON-NLS-1$
 		
 		if (type == Cache.Type.PREPAREDPLAN) {
 			this.distributedCache = localCache;
 		}
 		else {
-			this.distributedCache = cacheFactory.get(type, new CacheConfiguration(CacheConfiguration.Policy.LRU, -1, SessionAwareCache.this.maxSize));
+			this.distributedCache = cacheFactory.get(type, config);
 		}
 	}	
 	
@@ -238,5 +239,6 @@
     
     public void setBufferManager(BufferManager bufferManager) {
     	this.bufferManager = bufferManager;
-    }
+    }    
+    
 }

Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java	2010-08-10 11:01:40 UTC (rev 2433)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java	2010-08-10 14:51:15 UTC (rev 2434)
@@ -30,7 +30,9 @@
 import org.teiid.adminapi.VDB;
 import org.teiid.adminapi.impl.ModelMetaData;
 import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.cache.CacheConfiguration;
 import org.teiid.cache.DefaultCacheFactory;
+import org.teiid.cache.CacheConfiguration.Policy;
 import org.teiid.client.DQP;
 import org.teiid.client.security.ILogon;
 import org.teiid.deployers.MetadataStoreGroup;
@@ -82,8 +84,10 @@
         	}
         });
         
+        DQPConfiguration config = new DQPConfiguration();
+        config.setResultsetCacheConfig(new CacheConfiguration(Policy.LRU, 60, 250));
         this.dqp.setCacheFactory(new DefaultCacheFactory());
-        this.dqp.start(new DQPConfiguration());
+        this.dqp.start(config);
         this.sessionService.setDqp(this.dqp);
         
         registerClientService(ILogon.class, logon, null);



More information about the teiid-commits mailing list