[teiid-commits] teiid SVN: r1312 - in trunk: engine/src/main/java/org/teiid/dqp/internal/cache and 1 other directory.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Tue Sep 8 18:04:05 EDT 2009


Author: rareddy
Date: 2009-09-08 18:04:04 -0400 (Tue, 08 Sep 2009)
New Revision: 1312

Modified:
   trunk/cache-jbosscache/src/main/java/com/metamatrix/cache/jboss/JBossCache.java
   trunk/cache-jbosscache/src/main/java/com/metamatrix/cache/jboss/JBossCacheFactory.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/cache/DQPContextCache.java
Log:
TEIID-763: Node not valid exception is happening because of the setTimeLimit is set to zero (0), which should be unlimited. NPE, from the JBoss cache code there is no way to avoid it, as t happens during the thread interruptions or when a node is deleted. So if this is occurring in the "remove" situations handle them appropriately, otherwise it will still fail with a meaningful message.

Modified: trunk/cache-jbosscache/src/main/java/com/metamatrix/cache/jboss/JBossCache.java
===================================================================
--- trunk/cache-jbosscache/src/main/java/com/metamatrix/cache/jboss/JBossCache.java	2009-09-08 19:58:25 UTC (rev 1311)
+++ trunk/cache-jbosscache/src/main/java/com/metamatrix/cache/jboss/JBossCache.java	2009-09-08 22:04:04 UTC (rev 1312)
@@ -131,7 +131,7 @@
 	 */
 	@Override
 	public Cache<K, V> addChild(String name) {
-		Node<K, V> node = this.cacheStore.getNode(this.rootFqn);
+		Node<K, V> node = getRootNode();
 		Node<K, V> childNode = node.addChild(Fqn.fromString(name));
 		return new JBossCache<K, V>(this.cacheStore, childNode.getFqn());
 	}
@@ -141,20 +141,28 @@
 	 */
 	@Override
 	public Cache<K, V> getChild(String name) {
-		Node<K, V> node = this.cacheStore.getNode(this.rootFqn);
+		Node<K, V> node = getRootNode();
 		Node<K, V> child = node.getChild(Fqn.fromString(name));
 		if (child != null) {
 			return new JBossCache<K, V>(this.cacheStore, child.getFqn());
 		}
 		return null;
 	}
+
+	private 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$
+		}
+		return node;
+	}
 	
 	/**
 	 * {@inheritDoc}
 	 */
 	@Override
 	public List<Cache> getChildren() {
-		Node<K, V> node = this.cacheStore.getNode(this.rootFqn);
+		Node<K, V> node = getRootNode();
 		Set<Node<K,V>> nodes = node.getChildren();
 		if (nodes.isEmpty()) {
 			return Collections.emptyList();
@@ -171,7 +179,7 @@
 	 */
 	@Override
 	public boolean removeChild(String name) {
-		Node<K, V> node = this.cacheStore.getNode(this.rootFqn);
+		Node<K, V> node = getRootNode();
 		return node.removeChild(Fqn.fromString(name));
 	}
 

Modified: trunk/cache-jbosscache/src/main/java/com/metamatrix/cache/jboss/JBossCacheFactory.java
===================================================================
--- trunk/cache-jbosscache/src/main/java/com/metamatrix/cache/jboss/JBossCacheFactory.java	2009-09-08 19:58:25 UTC (rev 1311)
+++ trunk/cache-jbosscache/src/main/java/com/metamatrix/cache/jboss/JBossCacheFactory.java	2009-09-08 22:04:04 UTC (rev 1312)
@@ -88,7 +88,7 @@
 			LRUAlgorithmConfig lru = new LRUAlgorithmConfig();
 			lru.setMaxNodes(config.getMaxNodes());
 			lru.setMaxAge(config.getMaxAgeInSeconds()*1000);
-			lru.setTimeToLive(0);
+			lru.setTimeToLive(-1); // -1 no limit
 			evictionConfig = lru;
 		}
 		else if (config.getPolicy() == Policy.MRU) {

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/cache/DQPContextCache.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/cache/DQPContextCache.java	2009-09-08 19:58:25 UTC (rev 1311)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/cache/DQPContextCache.java	2009-09-08 22:04:04 UTC (rev 1312)
@@ -30,7 +30,9 @@
 import com.metamatrix.cache.CacheConfiguration;
 import com.metamatrix.cache.CacheFactory;
 import com.metamatrix.cache.CacheConfiguration.Policy;
+import com.metamatrix.common.log.LogManager;
 import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
+import com.metamatrix.dqp.util.LogConstants;
 
 @Singleton
 public class DQPContextCache {
@@ -50,7 +52,11 @@
 	}
 
 	public void shutdown() {
-		this.cache.removeChild(this.processIdentifier);
+		try {
+			this.cache.removeChild(this.processIdentifier);
+		} catch(IllegalStateException e) {
+			LogManager.logWarning(LogConstants.CTX_DQP, e, e.getMessage());
+		}
 	}
 	
 	public Cache getRequestScopedCache(String request) {
@@ -60,12 +66,16 @@
 	}
 
 	public void removeRequestScopedCache(String request) {
-		Cache processCache = this.cache.getChild(this.processIdentifier);
-		if (processCache != null) {
-			Cache scopeNode = processCache.getChild(Scope.REQUEST.name());
-			if (scopeNode != null) {
-				scopeNode.removeChild(request.toString());
+		try {
+			Cache processCache = this.cache.getChild(this.processIdentifier);
+			if (processCache != null) {
+				Cache scopeNode = processCache.getChild(Scope.REQUEST.name());
+				if (scopeNode != null) {
+					scopeNode.removeChild(request.toString());
+				}
 			}
+		} catch(IllegalStateException e) {
+			LogManager.logWarning(LogConstants.CTX_DQP, e, e.getMessage());
 		}
 	}
 	
@@ -76,12 +86,16 @@
 	}
 	
 	public void removeServiceScopedCache(String serviceId) {
-		Cache processCache = this.cache.getChild(this.processIdentifier);
-		if (processCache != null) {
-			Cache scopeNode = processCache.addChild(Scope.SERVICE.name());
-			if (scopeNode != null) {
-				scopeNode.removeChild(serviceId);
+		try {
+			Cache processCache = this.cache.getChild(this.processIdentifier);
+			if (processCache != null) {
+				Cache scopeNode = processCache.addChild(Scope.SERVICE.name());
+				if (scopeNode != null) {
+					scopeNode.removeChild(serviceId);
+				}
 			}
+		} catch(IllegalStateException e) {
+			LogManager.logWarning(LogConstants.CTX_DQP, e, e.getMessage());
 		}
 	}
 
@@ -91,9 +105,13 @@
 	}
 
 	public void removeSessionScopedCache(String session) {
-		Cache scopeNode = this.cache.addChild(Scope.SESSION.name());
-		if (scopeNode != null) {
-			scopeNode.removeChild(session);
+		try {
+			Cache scopeNode = this.cache.addChild(Scope.SESSION.name());
+			if (scopeNode != null) {
+				scopeNode.removeChild(session);
+			}
+		} catch(IllegalStateException e) {
+			LogManager.logWarning(LogConstants.CTX_DQP, e, e.getMessage());
 		}
 	}
 
@@ -104,10 +122,14 @@
 	}
 
 	public void removeVDBScopedCache(String vdbName, String vdbVersion) {
-		Cache scopeNode = this.cache.addChild(Scope.VDB.name());
-		if (scopeNode != null) {
-			String id = vdbName+"-"+vdbVersion; //$NON-NLS-1$
-			scopeNode.removeChild(id.toUpperCase());
+		try {
+			Cache scopeNode = this.cache.addChild(Scope.VDB.name());
+			if (scopeNode != null) {
+				String id = vdbName+"-"+vdbVersion; //$NON-NLS-1$
+				scopeNode.removeChild(id.toUpperCase());
+			}
+		} catch(IllegalStateException e) {
+			LogManager.logWarning(LogConstants.CTX_DQP, e, e.getMessage());
 		}
 	}
 }



More information about the teiid-commits mailing list