[teiid-commits] teiid SVN: r2556 - in branches/7.1.x: runtime/src/main/java/org/teiid/deployers and 1 other directory.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Fri Sep 10 15:34:56 EDT 2010


Author: rareddy
Date: 2010-09-10 15:34:56 -0400 (Fri, 10 Sep 2010)
New Revision: 2556

Added:
   branches/7.1.x/runtime/src/main/java/org/teiid/deployers/VDBLifeCycleListener.java
Modified:
   branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
   branches/7.1.x/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
Log:
TEIID-1256: when the vdb un-deployed the caches are flushed.

Modified: branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
--- branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java	2010-09-09 18:37:14 UTC (rev 2555)
+++ branches/7.1.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java	2010-09-10 19:34:56 UTC (rev 2556)
@@ -49,6 +49,7 @@
 import org.teiid.adminapi.Admin;
 import org.teiid.adminapi.AdminComponentException;
 import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.Admin.Cache;
 import org.teiid.adminapi.impl.CacheStatisticsMetadata;
 import org.teiid.adminapi.impl.DQPManagement;
 import org.teiid.adminapi.impl.RequestMetadata;
@@ -62,6 +63,7 @@
 import org.teiid.core.ComponentNotFoundException;
 import org.teiid.core.TeiidComponentException;
 import org.teiid.core.TeiidRuntimeException;
+import org.teiid.deployers.VDBLifeCycleListener;
 import org.teiid.deployers.VDBRepository;
 import org.teiid.dqp.internal.process.DQPConfiguration;
 import org.teiid.dqp.internal.process.DQPCore;
@@ -181,6 +183,35 @@
 	        	LogManager.logError(LogConstants.CTX_RUNTIME, ne, IntegrationPlugin.Util.getString("jndi_failed", new Date(System.currentTimeMillis()).toString())); //$NON-NLS-1$
 	    	}
     	}
+    	
+    	// add vdb life cycle listeners
+		this.vdbRepository.addListener(new VDBLifeCycleListener() {
+
+			@Override
+			public void added(String name, int version) {
+				
+			}
+			
+			@Override
+			public void removed(String name, int version) {
+				// terminate all the previous sessions
+				try {
+					Collection<SessionMetadata> sessions = sessionService.getActiveSessions();
+					for (SessionMetadata session:sessions) {
+						if (name.equalsIgnoreCase(session.getVDBName()) && version == session.getVDBVersion()){
+							sessionService.terminateSession(session.getSessionId(), null);
+						}
+					}
+				} catch (SessionServiceException e) {
+					//ignore
+				}
+
+				// dump the caches. TODO:It would have nice if only removed this VDB
+				// specific cache, but based on JBoss cache structure it is hard to just get keys
+				dqpCore.clearCache(Cache.PREPARED_PLAN_CACHE.toString());
+				dqpCore.clearCache(Cache.QUERY_SERVICE_RESULT_SET_CACHE.toString());
+			}			
+		});    	
 	}	
     
     public void stop() {

Added: branches/7.1.x/runtime/src/main/java/org/teiid/deployers/VDBLifeCycleListener.java
===================================================================
--- branches/7.1.x/runtime/src/main/java/org/teiid/deployers/VDBLifeCycleListener.java	                        (rev 0)
+++ branches/7.1.x/runtime/src/main/java/org/teiid/deployers/VDBLifeCycleListener.java	2010-09-10 19:34:56 UTC (rev 2556)
@@ -0,0 +1,27 @@
+/*
+ * 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.deployers;
+
+public interface VDBLifeCycleListener {
+	void added(String name, int version);
+	void removed(String name, int version);
+}


Property changes on: branches/7.1.x/runtime/src/main/java/org/teiid/deployers/VDBLifeCycleListener.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: branches/7.1.x/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
===================================================================
--- branches/7.1.x/runtime/src/main/java/org/teiid/deployers/VDBRepository.java	2010-09-09 18:37:14 UTC (rev 2555)
+++ branches/7.1.x/runtime/src/main/java/org/teiid/deployers/VDBRepository.java	2010-09-10 19:34:56 UTC (rev 2556)
@@ -61,6 +61,7 @@
 	private MetadataStore systemStore;
 	private MetadataStore odbcStore;
 	private boolean odbcEnabled = false;
+	private List<VDBLifeCycleListener> listeners = new ArrayList<VDBLifeCycleListener>();
 	
 	public void addVDB(VDBMetaData vdb, MetadataStoreGroup stores, LinkedHashMap<String, Resource> visibilityMap, UDFMetaData udf, ConnectorManagerRepository cmr) throws DeploymentException {
 		if (getVDB(vdb.getName(), vdb.getVersion()) != null) {
@@ -85,6 +86,7 @@
 			addODBCModel(vdb);
 			this.vdbRepo.put(vdbId(vdb), new CompositeVDB(vdb, stores, visibilityMap, udf, cmr, this.systemStore, odbcStore));
 		}
+		notifyAdd(vdb.getName(), vdb.getVersion());
 	}
 
 	private void addODBCModel(VDBMetaData vdb) {
@@ -186,6 +188,7 @@
 			for (CompositeVDB other:this.vdbRepo.values()) {
 				other.removeChild(key);
 			}
+			notifyRemove(key.getName(), key.getVersion());
 			return true;
 		}
 		return false;
@@ -227,10 +230,30 @@
 		}
 	}
 	
-	public void updateVDB(String name, int version) {
+	void updateVDB(String name, int version) {
 		CompositeVDB v = this.vdbRepo.get(new VDBKey(name, version));
 		if (v!= null) {
 			v.update(v.getVDB());
 		}
 	}
+	
+	public synchronized void addListener(VDBLifeCycleListener listener) {
+		this.listeners.add(listener);
+	}
+	
+	public synchronized void removeListener(VDBLifeCycleListener listener) {
+		this.listeners.remove(listener);
+	}
+	
+	private void notifyAdd(String name, int version) {
+		for(VDBLifeCycleListener l:this.listeners) {
+			l.added(name, version);
+		}
+	}
+	
+	private void notifyRemove(String name, int version) {
+		for(VDBLifeCycleListener l:this.listeners) {
+			l.removed(name, version);
+		}
+	}
 }



More information about the teiid-commits mailing list