Author: mdrillin
Date: 2011-06-27 17:48:28 -0400 (Mon, 27 Jun 2011)
New Revision: 3278
Modified:
branches/7.1.1.CP3/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
branches/7.1.1.CP3/engine/src/main/resources/org/teiid/query/i18n.properties
branches/7.1.1.CP3/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
branches/7.1.1.CP3/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
Log:
TEIID-1493 changing the listener logic to prevent unnecessary cache clearing
Modified:
branches/7.1.1.CP3/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
---
branches/7.1.1.CP3/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2011-06-27
21:46:26 UTC (rev 3277)
+++
branches/7.1.1.CP3/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2011-06-27
21:48:28 UTC (rev 3278)
@@ -557,7 +557,7 @@
}
private void clearPlanCache(String vdbName, int version){
- LogManager.logInfo(LogConstants.CTX_DQP,
QueryPlugin.Util.getString("DQPCore.Clearing_prepared_plan_cache"));
//$NON-NLS-1$
+ LogManager.logInfo(LogConstants.CTX_DQP,
QueryPlugin.Util.getString("DQPCore.Clearing_prepared_plan_cache_for_vdb",
vdbName, version)); //$NON-NLS-1$
this.prepPlanCache.clearForVDB(vdbName, version);
}
Modified: branches/7.1.1.CP3/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
---
branches/7.1.1.CP3/engine/src/main/resources/org/teiid/query/i18n.properties 2011-06-27
21:46:26 UTC (rev 3277)
+++
branches/7.1.1.CP3/engine/src/main/resources/org/teiid/query/i18n.properties 2011-06-27
21:48:28 UTC (rev 3278)
@@ -811,6 +811,8 @@
DQPCore.Unable_to_load_metadata_for_VDB_name__{0},_version__{1}=Unable to load metadata
for VDB name= {0}, version= {1}
DQPCore.Unknown_query_metadata_exception_while_registering_query__{0}.=Unknown query
metadata exception while registering query: {0}.
DQPCore.Clearing_prepared_plan_cache=Clearing prepared plan cache
+DQPCore.Clearing_prepared_plan_cache_for_vdb=Clearing prepared plan cache for vdb {0}.{1}
+DQPCore.clearing_resultset_cache=Clearing the resultset cache for vdb {0}.{1}
DQPCore.The_request_has_been_closed.=The request {0} has been closed.
DQPCore.The_atomic_request_has_been_cancelled=The atomic request {0} has been canceled.
DQPCore.failed_to_cancel=Failed to Cancel request, as request already finished
processing
Modified:
branches/7.1.1.CP3/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
---
branches/7.1.1.CP3/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2011-06-27
21:46:26 UTC (rev 3277)
+++
branches/7.1.1.CP3/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2011-06-27
21:48:28 UTC (rev 3278)
@@ -32,9 +32,11 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Properties;
+import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
@@ -78,6 +80,7 @@
import org.teiid.core.ComponentNotFoundException;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.util.LRUCache;
import org.teiid.deployers.VDBLifeCycleListener;
import org.teiid.deployers.VDBRepository;
import org.teiid.dqp.internal.process.DQPConfiguration;
@@ -101,6 +104,7 @@
import org.teiid.transport.ODBCSocketListener;
import org.teiid.transport.SocketConfiguration;
import org.teiid.transport.SocketListener;
+import org.teiid.vdb.runtime.VDBKey;
@ManagementObject(name="RuntimeEngineDeployer", isRuntime=true,
componentType=@ManagementComponent(type="teiid",subtype="dqp"),
properties=ManagementProperties.EXPLICIT)
@@ -212,14 +216,19 @@
// add vdb life cycle listeners
this.vdbRepository.addListener(new VDBLifeCycleListener() {
-
+
+ private Set<VDBKey> recentlyRemoved = Collections.newSetFromMap(new
LRUCache<VDBKey, Boolean>(10000));
+
@Override
public void removed(String name, int version) {
-
+ recentlyRemoved.add(new VDBKey(name, version));
}
@Override
public void added(String name, int version) {
+ if (!recentlyRemoved.remove(new VDBKey(name, version))) {
+ return;
+ }
// terminate all the previous sessions
try {
Collection<SessionMetadata> sessions = sessionService.getActiveSessions();
Modified: branches/7.1.1.CP3/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
===================================================================
---
branches/7.1.1.CP3/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2011-06-27
21:46:26 UTC (rev 3277)
+++
branches/7.1.1.CP3/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2011-06-27
21:48:28 UTC (rev 3278)
@@ -31,6 +31,7 @@
import java.util.NavigableMap;
import java.util.Properties;
import java.util.concurrent.ConcurrentSkipListMap;
+import java.util.concurrent.CopyOnWriteArrayList;
import org.jboss.deployers.spi.DeploymentException;
import org.teiid.adminapi.AdminException;
@@ -60,7 +61,7 @@
private MetadataStore systemStore;
private MetadataStore odbcStore;
private boolean odbcEnabled = false;
- private List<VDBLifeCycleListener> listeners = new
ArrayList<VDBLifeCycleListener>();
+ private List<VDBLifeCycleListener> listeners = new
CopyOnWriteArrayList<VDBLifeCycleListener>();
private SystemFunctionManager systemFunctionManager;
public void addVDB(VDBMetaData vdb, MetadataStoreGroup stores, LinkedHashMap<String,
Resource> visibilityMap, UDFMetaData udf, ConnectorManagerRepository cmr) throws
DeploymentException {
@@ -157,7 +158,7 @@
this.odbcEnabled = true;
}
- public synchronized boolean removeVDB(String vdbName, int vdbVersion) {
+ public boolean removeVDB(String vdbName, int vdbVersion) {
VDBKey key = new VDBKey(vdbName, vdbVersion);
CompositeVDB removed = this.vdbRepo.remove(key);
if (removed != null) {
@@ -214,11 +215,11 @@
}
}
- public synchronized void addListener(VDBLifeCycleListener listener) {
+ public void addListener(VDBLifeCycleListener listener) {
this.listeners.add(listener);
}
- public synchronized void removeListener(VDBLifeCycleListener listener) {
+ public void removeListener(VDBLifeCycleListener listener) {
this.listeners.remove(listener);
}