Author: shawkins
Date: 2009-11-09 11:41:36 -0500 (Mon, 09 Nov 2009)
New Revision: 1546
Added:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java
Removed:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/SharedCachedFinder.java
trunk/metadata/src/main/java/org/teiid/connector/
Modified:
trunk/engine/src/main/java/com/metamatrix/dqp/service/DataService.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
trunk/engine/src/test/java/com/metamatrix/dqp/service/AutoGenDataService.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedDataService.java
trunk/runtime/src/main/java/com/metamatrix/jdbc/LogListernerProvider.java
trunk/runtime/src/main/resources/com/metamatrix/dqp/embedded/i18n.properties
trunk/runtime/src/test/java/com/metamatrix/platform/security/membership/service/TestMembershipServiceImpl.java
Log:
TEIID-878 fixing capabilities caching
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/service/DataService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/DataService.java 2009-11-06
22:01:50 UTC (rev 1545)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/DataService.java 2009-11-09
16:41:36 UTC (rev 1546)
@@ -78,7 +78,7 @@
* @param connector Connector to retrieve capabilities from
* @return All capability information as key-value pairs
*/
- SourceCapabilities getCapabilities(RequestMessage request, DQPWorkContext
dqpWorkContext, ConnectorID connector)
+ SourceCapabilities getCapabilities(RequestMessage request, DQPWorkContext
dqpWorkContext, String modelName)
throws MetaMatrixComponentException;
/**
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2009-11-06
22:01:50 UTC (rev 1545)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2009-11-09
16:41:36 UTC (rev 1546)
@@ -127,6 +127,8 @@
private Properties props;
private ClassLoader classloader;
+
+ private SourceCapabilities cachedCapabilities;
public void initialize(Properties props) {
this.props = props;
@@ -160,6 +162,9 @@
}
public SourceCapabilities getCapabilities(RequestID requestID, Serializable
executionPayload, DQPWorkContext message) throws ConnectorException {
+ if (cachedCapabilities != null) {
+ return cachedCapabilities;
+ }
Connection conn = null;
// Defect 17536 - Set the thread-context classloader to the non-delegating
classloader when calling
// methods on the connector.
@@ -189,7 +194,12 @@
}
caps = (ConnectorCapabilities)
Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[]
{ConnectorCapabilities.class}, new CapabilitesOverloader(caps, this.props));
BasicSourceCapabilities resultCaps =
CapabilitiesConverter.convertCapabilities(caps, getName(), isXa);
- resultCaps.setScope(global?Scope.SCOPE_GLOBAL:Scope.SCOPE_PER_USER);
+ if (global) {
+ resultCaps.setScope(Scope.SCOPE_GLOBAL);
+ cachedCapabilities = resultCaps;
+ } else {
+ resultCaps.setScope(Scope.SCOPE_PER_USER);
+ }
return resultCaps;
} finally {
if ( conn != null ) {
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java (from
rev 1542,
trunk/engine/src/main/java/org/teiid/dqp/internal/process/SharedCachedFinder.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java
(rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java 2009-11-09
16:41:36 UTC (rev 1546)
@@ -0,0 +1,72 @@
+/*
+ * 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.dqp.internal.process;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.core.CoreConstants;
+import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.service.DataService;
+import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
+import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
+import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
+
+/**
+ */
+public class CachedFinder implements CapabilitiesFinder {
+
+ private static BasicSourceCapabilities SYSTEM_CAPS = new BasicSourceCapabilities();
+
+ private DataService dataService;
+ private RequestMessage requestMessage;
+ private DQPWorkContext workContext;
+
+ private Map<String, SourceCapabilities> userCache = new HashMap<String,
SourceCapabilities>();
+
+ /**
+ * Construct a CacheFinder that wraps another finder
+ * @param internalFinder Finder to wrap
+ */
+ public CachedFinder(DataService dataService, RequestMessage requestMessage,
DQPWorkContext workContext) {
+ this.dataService = dataService;
+ this.requestMessage = requestMessage;
+ this.workContext = workContext;
+ userCache.put(CoreConstants.SYSTEM_MODEL, SYSTEM_CAPS);
+ }
+
+ /**
+ * Find capabilities used the cache if possible, otherwise do the lookup.
+ */
+ public SourceCapabilities findCapabilities(String modelName) throws
MetaMatrixComponentException {
+ SourceCapabilities caps = userCache.get(modelName);
+ if(caps != null) {
+ return caps;
+ }
+ caps = dataService.getCapabilities(requestMessage, workContext, modelName);
+ userCache.put(modelName, caps);
+ return caps;
+ }
+
+}
Property changes on:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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 2009-11-06
22:01:50 UTC (rev 1545)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2009-11-09
16:41:36 UTC (rev 1546)
@@ -66,7 +66,6 @@
import com.metamatrix.common.xa.XATransactionException;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.log.MessageLevel;
-import com.metamatrix.core.util.LRUCache;
import com.metamatrix.dqp.DQPPlugin;
import com.metamatrix.dqp.client.ClientSideDQP;
import com.metamatrix.dqp.client.MetadataResult;
@@ -88,12 +87,10 @@
import com.metamatrix.dqp.service.VDBService;
import com.metamatrix.dqp.util.LogConstants;
import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
import com.metamatrix.query.processor.ProcessorDataManager;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.tempdata.TempTableStoreImpl;
import com.metamatrix.server.serverapi.RequestInfo;
-import com.metamatrix.vdb.runtime.VDBKey;
/**
* Implements the core DQP processing.
@@ -101,25 +98,6 @@
@Singleton
public class DQPCore implements ClientSideDQP {
- static class ConnectorCapabilitiesCache {
-
- private Map<VDBKey, Map<String, SourceCapabilities>> cache = new
LRUCache<VDBKey, Map<String, SourceCapabilities>>(1000);
-
- Map<String, SourceCapabilities> getVDBConnectorCapabilities(
- DQPWorkContext workContext) {
- VDBKey key = new VDBKey(workContext.getVdbName(), workContext.getVdbVersion());
- Map<String, SourceCapabilities> vdbCapabilties = null;
- synchronized (this.cache) {
- vdbCapabilties = cache.get(key);
- if (vdbCapabilties == null) {
- vdbCapabilties = new ConcurrentHashMap<String, SourceCapabilities>();
- this.cache.put(key, vdbCapabilties);
- }
- }
- return vdbCapabilties;
- }
- }
-
static class ClientState {
List<RequestID> requests;
TempTableStoreImpl tempTableStoreImpl;
@@ -169,7 +147,6 @@
private int maxFetchSize = DEFAULT_FETCH_SIZE;
// Resources
- private ConnectorCapabilitiesCache connectorCapabilitiesCache = new
ConnectorCapabilitiesCache();
private BufferManager bufferManager;
private ProcessorDataManager dataTierMgr;
private PreparedPlanCache prepPlanCache;
@@ -279,7 +256,6 @@
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
RequestID requestID = workContext.getRequestID(reqID);
requestMsg.markProcessingStart();
- Map<String, SourceCapabilities> vdbCapabilties =
this.connectorCapabilitiesCache.getVDBConnectorCapabilities(workContext);
requestMsg.setFetchSize(Math.min(requestMsg.getFetchSize(), maxFetchSize));
Request request = null;
if ( requestMsg.isPreparedStatement() || requestMsg.isCallableStatement()) {
@@ -289,9 +265,9 @@
}
ClientState state = this.getClientState(workContext.getConnectionID(), true);
request.initialize(requestMsg, environment, bufferManager,
- dataTierMgr, vdbCapabilties, transactionService,
- processorDebugAllowed, state.tempTableStoreImpl,
- workContext, chunkSize);
+ dataTierMgr, transactionService, processorDebugAllowed,
+ state.tempTableStoreImpl, workContext,
+ chunkSize);
RequestWorkItem workItem = null;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2009-11-06
22:01:50 UTC (rev 1545)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2009-11-09
16:41:36 UTC (rev 1546)
@@ -27,7 +27,6 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.Properties;
import java.util.Set;
@@ -121,7 +120,6 @@
private TempTableStore tempTableStore;
protected IDGenerator idGenerator = new IDGenerator();
private boolean procDebugAllowed = false;
- private Map connectorCapabilitiesCache;
DQPWorkContext workContext;
RequestID requestId;
@@ -150,7 +148,6 @@
ApplicationEnvironment env,
BufferManager bufferManager,
ProcessorDataManager processorDataManager,
- Map connectorCapabilitiesCache,
TransactionService transactionService,
boolean procDebugAllowed,
TempTableStore tempTableStore,
@@ -167,7 +164,6 @@
this.transactionService = transactionService;
this.procDebugAllowed = procDebugAllowed;
this.tempTableStore = tempTableStore;
- this.connectorCapabilitiesCache = connectorCapabilitiesCache;
idGenerator.setDefaultFactory(new IntegerIDFactory());
this.workContext = workContext;
this.requestId = workContext.getRequestID(this.requestMsg.getExecutionId());
@@ -191,10 +187,10 @@
}
// Prepare dependencies for running the optimizer
this.capabilitiesFinder =
- new SharedCachedFinder(
- this.vdbService,
+ new CachedFinder(
(DataService) this.env.findService(DQPServiceNames.DATA_SERVICE),
- requestMsg, workContext, connectorCapabilitiesCache);
+ requestMsg,
+ workContext);
MetadataService metadataService = (MetadataService)
this.env.findService(DQPServiceNames.METADATA_SERVICE);
if(metadataService == null){
Deleted:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/SharedCachedFinder.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/SharedCachedFinder.java 2009-11-06
22:01:50 UTC (rev 1545)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/SharedCachedFinder.java 2009-11-09
16:41:36 UTC (rev 1546)
@@ -1,109 +0,0 @@
-/*
- * 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.dqp.internal.process;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.core.CoreConstants;
-import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
-import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.dqp.service.DataService;
-import com.metamatrix.dqp.service.VDBService;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
-
-/**
- */
-public class SharedCachedFinder implements CapabilitiesFinder {
-
- private static BasicSourceCapabilities SYSTEM_CAPS = new BasicSourceCapabilities();
-
- private VDBService vdbService;
- private DataService dataService;
- private RequestMessage requestMessage;
- private DQPWorkContext workContext;
-
- // Cache of SourceCapabilities by modelName
- private Map<String, SourceCapabilities> capabilityCache; //synchronized
- private Map<String, SourceCapabilities> userCache = new HashMap<String,
SourceCapabilities>(); //unsynchronized
-
-
- /**
- * Construct a CacheFinder that wraps another finder
- * @param internalFinder Finder to wrap
- * @param sharedCache The shared cache - map of model name to SourceCapabilities
- */
- public SharedCachedFinder(VDBService vdbService, DataService dataService,
RequestMessage requestMessage, DQPWorkContext workContext, Map<String,
SourceCapabilities> sharedCache) {
- this.vdbService = vdbService;
- this.dataService = dataService;
- this.requestMessage = requestMessage;
- this.workContext = workContext;
- this.capabilityCache = sharedCache;
- userCache.put(CoreConstants.SYSTEM_MODEL, SYSTEM_CAPS);
- }
-
- /**
- * Find capabilities used the cache if possible, otherwise do the lookup.
- */
- public SourceCapabilities findCapabilities(String modelName) throws
MetaMatrixComponentException {
- if (CoreConstants.SYSTEM_MODEL.equals(modelName)) {
- return SYSTEM_CAPS;
- }
- SourceCapabilities caps = userCache.get(modelName);
- if(caps != null) {
- return caps;
- }
- caps = capabilityCache.get(modelName);
- if(caps == null) {
- // Find capabilities
- List bindings = vdbService.getConnectorBindingNames(workContext.getVdbName(),
workContext.getVdbVersion(), modelName);
- for(int i=0; i<bindings.size(); i++) {
- try {
- String connBinding = (String) bindings.get(i);
- ConnectorID connector = dataService.selectConnector(connBinding);
- caps = dataService.getCapabilities(requestMessage, workContext,
connector);
- break;
- }catch(MetaMatrixComponentException e) {
- if(i == bindings.size()-1) {
- throw e;
- }
- }
- }
- if(caps == null) {
- throw new
MetaMatrixComponentException(DQPPlugin.Util.getString("SharedCacheFinder.Didnt_find_caps",
modelName)); //$NON-NLS-1$
- }
- }
- if(caps.getScope() == SourceCapabilities.Scope.SCOPE_GLOBAL) {
- capabilityCache.put(modelName, caps);
- }
- userCache.put(modelName, caps);
- return caps;
- }
-
-}
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/service/AutoGenDataService.java
===================================================================
---
trunk/engine/src/test/java/com/metamatrix/dqp/service/AutoGenDataService.java 2009-11-06
22:01:50 UTC (rev 1545)
+++
trunk/engine/src/test/java/com/metamatrix/dqp/service/AutoGenDataService.java 2009-11-09
16:41:36 UTC (rev 1546)
@@ -164,10 +164,11 @@
}
}
- public SourceCapabilities getCapabilities(RequestMessage request,
- DQPWorkContext dqpWorkContext, ConnectorID connector)
- throws MetaMatrixComponentException {
- return caps;
+ @Override
+ public SourceCapabilities getCapabilities(RequestMessage request,
+ DQPWorkContext dqpWorkContext, String modelName)
+ throws MetaMatrixComponentException {
+ return caps;
}
/**
Modified:
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java 2009-11-06
22:01:50 UTC (rev 1545)
+++
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java 2009-11-09
16:41:36 UTC (rev 1546)
@@ -23,16 +23,11 @@
package org.teiid.dqp.internal.process;
import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
import junit.framework.TestCase;
import org.mockito.Mockito;
-import org.teiid.dqp.internal.process.DQPWorkContext;
-import org.teiid.dqp.internal.process.SharedCachedFinder;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.dqp.service.DataService;
import com.metamatrix.dqp.service.VDBService;
@@ -67,13 +62,11 @@
VDBService vdbService = Mockito.mock(VDBService.class);
Mockito.stub(vdbService.getConnectorBindingNames(vdbName, vdbVersion,
modelName)).toReturn(Arrays.asList(modelName));
DataService dataService = Mockito.mock(DataService.class);
- ConnectorID id = new ConnectorID("foo"); //$NON-NLS-1$
- Mockito.stub(dataService.selectConnector(modelName)).toReturn(id);
BasicSourceCapabilities basicSourceCapabilities = new BasicSourceCapabilities();
basicSourceCapabilities.setFunctionSupport(functionName, true);
- Mockito.stub(dataService.getCapabilities(request, workContext,
id)).toReturn(basicSourceCapabilities);
+ Mockito.stub(dataService.getCapabilities(request, workContext,
modelName)).toReturn(basicSourceCapabilities);
- SharedCachedFinder finder = new SharedCachedFinder(vdbService, dataService,
request, workContext, new HashMap<String, SourceCapabilities>());
+ CachedFinder finder = new CachedFinder(dataService, request, workContext);
// Test
SourceCapabilities actual = finder.findCapabilities(modelName);
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2009-11-06
22:01:50 UTC (rev 1545)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2009-11-09
16:41:36 UTC (rev 1546)
@@ -22,8 +22,9 @@
package org.teiid.dqp.internal.process;
+import static org.junit.Assert.*;
+
import java.sql.ResultSet;
-import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
@@ -33,12 +34,7 @@
import org.junit.Before;
import org.junit.Test;
import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
-import org.teiid.dqp.internal.process.DQPCore;
-import org.teiid.dqp.internal.process.DQPWorkContext;
-import org.teiid.dqp.internal.process.DQPCore.ConnectorCapabilitiesCache;
-import static org.junit.Assert.*;
-
import com.metamatrix.api.exception.query.QueryResolverException;
import com.metamatrix.common.application.ApplicationEnvironment;
import com.metamatrix.common.vdb.api.ModelInfo;
@@ -53,8 +49,6 @@
import com.metamatrix.jdbc.api.ExecutionProperties;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
import com.metamatrix.query.unittest.FakeMetadataFactory;
@@ -205,21 +199,6 @@
}
}
- @Test public void testCapabilitesCache() {
- ConnectorCapabilitiesCache cache = new ConnectorCapabilitiesCache();
- DQPWorkContext workContext = new DQPWorkContext();
- workContext.setVdbName("foo"); //$NON-NLS-1$
- workContext.setVdbVersion("1"); //$NON-NLS-1$
- Map<String, SourceCapabilities> vdbCapabilites =
cache.getVDBConnectorCapabilities(workContext);
- assertNull(vdbCapabilites.get("model1")); //$NON-NLS-1$
- vdbCapabilites.put("model1", new BasicSourceCapabilities());
//$NON-NLS-1$
- vdbCapabilites = cache.getVDBConnectorCapabilities(workContext);
- assertNotNull(vdbCapabilites.get("model1")); //$NON-NLS-1$
- workContext.setVdbName("bar"); //$NON-NLS-1$
- vdbCapabilites = cache.getVDBConnectorCapabilities(workContext);
- assertNull(vdbCapabilites.get("model1")); //$NON-NLS-1$
- }
-
@Test public void testLookupVisibility() throws Exception {
helpTestVisibilityFails("select lookup('bqt3.smalla', 'intkey',
'stringkey', '?')"); //$NON-NLS-1$
}
Modified:
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java 2009-11-06
22:01:50 UTC (rev 1545)
+++
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java 2009-11-09
16:41:36 UTC (rev 1546)
@@ -384,8 +384,9 @@
ConnectorID connectorId) throws MetaMatrixComponentException {
closed = true;
}
+ @Override
public SourceCapabilities getCapabilities(RequestMessage request,
- DQPWorkContext dqpWorkContext, ConnectorID connector)
+ DQPWorkContext dqpWorkContext, String modelName)
throws MetaMatrixComponentException {
return null;
}
Modified:
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2009-11-06
22:01:50 UTC (rev 1545)
+++
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2009-11-09
16:41:36 UTC (rev 1546)
@@ -26,7 +26,6 @@
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.List;
import org.junit.Test;
@@ -254,7 +253,7 @@
}
};
FakeApplicationEnvironment env = new FakeApplicationEnvironment(metadata,
"example1", "1", "pm1", "1", "BINDING");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- serverRequest.initialize(request, env,
BufferManagerFactory.getStandaloneBufferManager(), null, new HashMap(), null, DEBUG, null,
workContext, 101024);
+ serverRequest.initialize(request, env,
BufferManagerFactory.getStandaloneBufferManager(), null, null, DEBUG, null, workContext,
101024);
serverRequest.setMetadata(capFinder, metadata, null);
serverRequest.processRequest();
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2009-11-06
22:01:50 UTC (rev 1545)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2009-11-09
16:41:36 UTC (rev 1546)
@@ -25,7 +25,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
import junit.framework.TestCase;
@@ -122,7 +121,7 @@
FakeApplicationEnvironment environment =
new FakeApplicationEnvironment(metadata, VDB, VDB_VERSION, MODEL, BINDING_ID,
BINDING_NAME);
- request.initialize(message, environment, null, null, null, null, false, null,
workContext, 101024);
+ request.initialize(message, environment, null, null, null, false, null,
workContext, 101024);
request.initMetadata();
request.validateEntitlement(command);
}
@@ -189,8 +188,8 @@
request = new Request();
}
request.initialize(message, environment, Mockito.mock(BufferManager.class),
- new FakeDataManager(), new HashMap(), null, false, null,
- workContext, 101024);
+ new FakeDataManager(), null, false, null, workContext,
+ 101024);
request.processRequest();
return request;
Modified:
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedDataService.java
===================================================================
---
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedDataService.java 2009-11-06
22:01:50 UTC (rev 1545)
+++
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedDataService.java 2009-11-09
16:41:36 UTC (rev 1546)
@@ -24,14 +24,15 @@
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import org.teiid.adminapi.ConnectionPool;
+import org.teiid.connector.api.ConnectorCapabilities;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.ConnectorPropertyNames;
import org.teiid.connector.metadata.runtime.MetadataStore;
@@ -76,16 +77,16 @@
*/
public class EmbeddedDataService extends EmbeddedBaseDQPService implements DataService {
// Map of connector binding name to ConnectorID
- private Map connectorIDs = new HashMap();
+ private Map<String, ConnectorID> connectorIDs = new
ConcurrentHashMap<String, ConnectorID>();
// Map of ConnectorID to ConnectorData
- private Map connectorMgrs = new HashMap();
+ private Map<ConnectorID, ConnectorManager> connectorMgrs = new
ConcurrentHashMap<ConnectorID, ConnectorManager>();
// A counter to keep track of connector ids
private AtomicInteger counter = new AtomicInteger();
// Connector List
- private Map loadedConnectorBindingsMap = new HashMap();
+ private Map<String, ConnectorBinding> loadedConnectorBindingsMap = new
ConcurrentHashMap<String, ConnectorBinding>();
private ApplicationEnvironment env;
@@ -115,11 +116,11 @@
*/
public ConnectorID selectConnector(String deployedConnectorBindingName)
throws MetaMatrixComponentException {
- ConnectorID id = (ConnectorID) connectorIDs.get(deployedConnectorBindingName);
+ ConnectorID id = connectorIDs.get(deployedConnectorBindingName);
if (id == null) {
ConnectorBinding binding =
getConnectorBinding(deployedConnectorBindingName);
if (binding != null) {
- id = (ConnectorID) connectorIDs.get(binding.getDeployedName());
+ id = connectorIDs.get(binding.getDeployedName());
}
if (id == null) {
throw new
ComponentNotFoundException(DQPEmbeddedPlugin.Util.getString("DataService.Connector_State_invalid",
new Object[] { deployedConnectorBindingName })); //$NON-NLS-1$
@@ -139,10 +140,6 @@
String deployedConnectorBindingName = bindingNames.get(0);
ConnectorID connector = selectConnector(deployedConnectorBindingName);
ConnectorManager mgr = getConnectorManager(connector);
- if (mgr == null) {
- throw new
ComponentNotFoundException(DQPEmbeddedPlugin.Util.getString("DataService.Unable_to_find_connector_manager_for_{0}_1",
new Object[] { connector })); //$NON-NLS-1$
- }
-
try {
return mgr.getMetadata(modelName, importProperties);
} catch (ConnectorException e) {
@@ -161,53 +158,46 @@
ResultsReceiver<AtomicResultsMessage> resultListener)
throws MetaMatrixComponentException {
ConnectorManager mgr = getConnectorManager(connector);
- if(mgr != null) {
- mgr.executeRequest(resultListener, request);
- }
- else {
- throw new
ComponentNotFoundException(DQPEmbeddedPlugin.Util.getString("DataService.Unable_to_find_connector_manager_for_{0}_1",
new Object[] { connector })); //$NON-NLS-1$
- }
+ mgr.executeRequest(resultListener, request);
}
public void cancelRequest(AtomicRequestID request, ConnectorID connectorId)
throws MetaMatrixComponentException {
ConnectorManager mgr = getConnectorManager(connectorId);
- if (mgr == null ) {
- throw new
ComponentNotFoundException(DQPEmbeddedPlugin.Util.getString("DataService.Unable_to_find_connector_manager_for_{0}_1",
new Object[] { connectorId })); //$NON-NLS-1$
- }
mgr.cancelRequest(request);
}
public void closeRequest(AtomicRequestID request, ConnectorID connectorId)
throws MetaMatrixComponentException {
ConnectorManager mgr = getConnectorManager(connectorId);
- if (mgr == null ) {
- throw new
ComponentNotFoundException(DQPEmbeddedPlugin.Util.getString("DataService.Unable_to_find_connector_manager_for_{0}_1",
new Object[] { connectorId })); //$NON-NLS-1$
- }
mgr.closeRequest(request);
}
public void requestBatch(AtomicRequestID request, ConnectorID connectorId)
throws MetaMatrixComponentException {
ConnectorManager mgr = getConnectorManager(connectorId);
- if (mgr == null ) {
- throw new
ComponentNotFoundException(DQPEmbeddedPlugin.Util.getString("DataService.Unable_to_find_connector_manager_for_{0}_1",
new Object[] { connectorId })); //$NON-NLS-1$
- }
mgr.requstMore(request);
}
public SourceCapabilities getCapabilities(RequestMessage request,
- DQPWorkContext dqpWorkContext, ConnectorID connector)
+ DQPWorkContext dqpWorkContext, String modelName)
throws MetaMatrixComponentException {
- ConnectorManager mgr = getConnectorManager(connector);
- if (mgr != null ) {
+ // Find capabilities
+ VDBService vdbService = (VDBService)this.lookupService(DQPServiceNames.VDB_SERVICE);
+ List bindings = vdbService.getConnectorBindingNames(dqpWorkContext.getVdbName(),
dqpWorkContext.getVdbVersion(), modelName);
+ ConnectorCapabilities caps = null;
+ ConnectorException ex = null;
+ for(int i=0; i<bindings.size(); i++) {
+ String connBinding = (String) bindings.get(i);
+ ConnectorID connector = selectConnector(connBinding);
+ ConnectorManager mgr = getConnectorManager(connector);
try {
- return mgr.getCapabilities(dqpWorkContext.getRequestID(request.getExecutionId()),
request.getExecutionPayload(), dqpWorkContext);
- } catch (ConnectorException e) {
- throw new MetaMatrixComponentException(e);
- }
+ return mgr.getCapabilities(dqpWorkContext.getRequestID(request.getExecutionId()),
request.getExecutionPayload(), dqpWorkContext);
+ } catch (ConnectorException e) {
+ ex = e;
+ }
}
- throw new
ComponentNotFoundException(DQPEmbeddedPlugin.Util.getString("DataService.Unable_to_find_connector_manager_for_{0}_1",
new Object[] { connector })); //$NON-NLS-1$
+ throw new MetaMatrixComponentException(ex,
DQPEmbeddedPlugin.Util.getString("DataService.Didnt_find_caps", modelName));
//$NON-NLS-1$
}
/**
@@ -217,7 +207,7 @@
public Collection getConnectorBindingStatistics(String connectorBindingName) throws
MetaMatrixComponentException {
ConnectorBinding binding = getConnectorBinding(connectorBindingName);
if (binding != null) {
- ConnectorManager mgr = getConnectorManager(binding);
+ ConnectorManager mgr = getConnectorManager(binding, false);
if (mgr != null ) {
return mgr.getQueueStatistics();
}
@@ -232,7 +222,7 @@
public Collection<? extends ConnectionPool> getConnectionPoolStatistics(String
connectorBindingName) throws MetaMatrixComponentException {
ConnectorBinding binding = getConnectorBinding(connectorBindingName);
if (binding != null) {
- ConnectorManager mgr = getConnectorManager(binding);
+ ConnectorManager mgr = getConnectorManager(binding, false);
if (mgr != null ) {
Collection<MMConnectionPool> result = mgr.getConnectionPoolStats();
for (MMConnectionPool mmConnectionPool : result) {
@@ -251,7 +241,7 @@
public void clearConnectorBindingCache(String connectorBindingName) throws
MetaMatrixComponentException {
ConnectorBinding binding = getConnectorBinding(connectorBindingName);
if (binding != null) {
- ConnectorManager mgr = getConnectorManager(binding);
+ ConnectorManager mgr = getConnectorManager(binding, false);
if (mgr != null ) {
mgr.clearCache();
return;
@@ -268,24 +258,22 @@
throws ApplicationLifecycleException, MetaMatrixComponentException {
ConnectorBinding binding = getConnectorBinding(deployedConnectorBindingName);
- if (binding != null) {
- ConnectorManager mgr = getConnectorManager(binding);
- if (mgr != null && mgr.getStatus() ==
ConnectorStatus.NOT_INITIALIZED) {
- // Start the manager
- mgr.start(env);
-
- // Add the references to the mgr as loaded.
- ConnectorID connID = mgr.getConnectorID();
- this.connectorIDs.put(binding.getDeployedName(), connID);
- this.connectorMgrs.put(connID, mgr);
- this.loadedConnectorBindingsMap.put(binding.getDeployedName(), binding);
-
- DQPEmbeddedPlugin.logInfo("DataService.Connector_Started", new
Object[] {binding.getDeployedName()}); //$NON-NLS-1$
- }
+ if (binding == null) {
+ throw new
ApplicationLifecycleException(DQPEmbeddedPlugin.Util.getString("DataService.Unable_to_find_connector",
deployedConnectorBindingName)); //$NON-NLS-1$
}
- else {
- throw new
ApplicationLifecycleException(DQPEmbeddedPlugin.Util.getString("DataService.Unable_to_find_connector",
deployedConnectorBindingName)); //$NON-NLS-1$
- }
+ ConnectorManager mgr = getConnectorManager(binding, true);
+ if (mgr.getStatus() == ConnectorStatus.NOT_INITIALIZED) {
+ // Start the manager
+ mgr.start(env);
+
+ // Add the references to the mgr as loaded.
+ ConnectorID connID = mgr.getConnectorID();
+ this.connectorIDs.put(binding.getDeployedName(), connID);
+ this.connectorMgrs.put(connID, mgr);
+ this.loadedConnectorBindingsMap.put(binding.getDeployedName(), binding);
+
+ DQPEmbeddedPlugin.logInfo("DataService.Connector_Started", new
Object[] {binding.getDeployedName()}); //$NON-NLS-1$
+ }
}
/**
@@ -296,22 +284,20 @@
throws ApplicationLifecycleException, MetaMatrixComponentException {
ConnectorBinding binding = getConnectorBinding(deployedConnectorBindingName);
- if (binding != null) {
- ConnectorManager mgr = getConnectorManager(binding, false);
- if (mgr != null ) {
- // Run the stop command no matter what state they are in, since the Alive
status is not
- // always reliable, it is only based on the Connector implementation.
This is fool proof.
- mgr.stop();
-
- // remove from the local configuration. We want to create a new connector
binding each time
- // we start, so that we can initialize with correct properties, in case
they chnaged.
- removeConnectorBinding(binding.getDeployedName());
-
- DQPEmbeddedPlugin.logInfo("DataService.Connector_Stopped", new
Object[] {binding.getDeployedName()}); //$NON-NLS-1$
- }
+ if (binding == null) {
+ throw new
ApplicationLifecycleException(DQPEmbeddedPlugin.Util.getString("DataService.Unable_to_find_connector",
deployedConnectorBindingName)); //$NON-NLS-1$
}
- else {
- throw new
ApplicationLifecycleException(DQPEmbeddedPlugin.Util.getString("DataService.Unable_to_find_connector",
deployedConnectorBindingName)); //$NON-NLS-1$
+ ConnectorManager mgr = getConnectorManager(binding, false);
+ if (mgr != null ) {
+ // Run the stop command no matter what state they are in, since the Alive
status is not
+ // always reliable, it is only based on the Connector implementation. This is
fool proof.
+ mgr.stop();
+
+ // remove from the local configuration. We want to create a new connector
binding each time
+ // we start, so that we can initialize with correct properties, in case they
chnaged.
+ removeConnectorBinding(binding.getDeployedName());
+
+ DQPEmbeddedPlugin.logInfo("DataService.Connector_Stopped", new
Object[] {binding.getDeployedName()}); //$NON-NLS-1$
}
}
@@ -334,7 +320,7 @@
throws MetaMatrixComponentException {
ConnectorBinding binding = getConnectorBinding(deployedConnectorBindingName);
if (binding != null) {
- ConnectorManager mgr = getConnectorManager(binding);
+ ConnectorManager mgr = getConnectorManager(binding, false);
if (mgr != null) {
return mgr.getStatus();
}
@@ -405,7 +391,7 @@
getConfigurationService().unregister(this.listener);
// Avoid concurrent modification as stop binding also modifies the
// map.
- String[] connectorBindings =
(String[])loadedConnectorBindingsMap.keySet().toArray(new
String[loadedConnectorBindingsMap.keySet().size()]);
+ String[] connectorBindings = loadedConnectorBindingsMap.keySet().toArray(new
String[loadedConnectorBindingsMap.keySet().size()]);
for(int i = 0; i < connectorBindings.length; i++) {
try {
stopConnectorBinding(connectorBindings[i]);
@@ -430,34 +416,34 @@
ConnectorManager getConnectorManager(ConnectorBinding binding, boolean create)
throws MetaMatrixComponentException{
- ConnectorID connectionId =
(ConnectorID)connectorIDs.get(binding.getDeployedName());
- if (connectionId == null && create) {
- return createConnectorManger(binding);
+ ConnectorID connectionId = connectorIDs.get(binding.getDeployedName());
+ if (connectionId == null) {
+ if (create) {
+ return createConnectorManger(binding);
+ }
+ return null;
}
- return (ConnectorManager)connectorMgrs.get(connectionId);
+ return connectorMgrs.get(connectionId);
}
- ConnectorManager getConnectorManager(ConnectorBinding binding)
- throws MetaMatrixComponentException{
- return getConnectorManager(binding, true);
- }
-
/**
* When somebody asks for the connector manager by their ID, that means
* Manager has been already created, we do not need to load the connector
* binding.
+ * @throws ComponentNotFoundException
*/
- ConnectorManager getConnectorManager(ConnectorID connID) {
- if (connID != null) {
- return (ConnectorManager)connectorMgrs.get(connID);
+ ConnectorManager getConnectorManager(ConnectorID connID) throws
ComponentNotFoundException {
+ ConnectorManager mgr = connectorMgrs.get(connID);
+ if (mgr == null ) {
+ throw new
ComponentNotFoundException(DQPEmbeddedPlugin.Util.getString("DataService.Unable_to_find_connector_manager_for_{0}_1",
connID)); //$NON-NLS-1$
}
- return null;
+ return mgr;
}
public ConnectorBinding getConnectorBinding(String deployedConnectorBindingName)
throws MetaMatrixComponentException{
- ConnectorBinding binding =
(ConnectorBinding)loadedConnectorBindingsMap.get(deployedConnectorBindingName);
+ ConnectorBinding binding =
loadedConnectorBindingsMap.get(deployedConnectorBindingName);
if (binding == null) {
// if connector binding not found load from the configuration service.
binding =
getConfigurationService().getConnectorBinding(deployedConnectorBindingName);
Modified: trunk/runtime/src/main/java/com/metamatrix/jdbc/LogListernerProvider.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/jdbc/LogListernerProvider.java 2009-11-06
22:01:50 UTC (rev 1545)
+++ trunk/runtime/src/main/java/com/metamatrix/jdbc/LogListernerProvider.java 2009-11-09
16:41:36 UTC (rev 1546)
@@ -22,22 +22,15 @@
package com.metamatrix.jdbc;
-import java.util.Properties;
-
import org.apache.log4j.Logger;
-import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
-import com.google.inject.name.Named;
import com.metamatrix.core.log.LogListener;
@Singleton
class LogListernerProvider implements Provider<LogListener> {
- @Inject @Named("DQPProperties")
- Properties props;
-
@Override
public LogListener get() {
return new Log4jListener();
Modified: trunk/runtime/src/main/resources/com/metamatrix/dqp/embedded/i18n.properties
===================================================================
---
trunk/runtime/src/main/resources/com/metamatrix/dqp/embedded/i18n.properties 2009-11-06
22:01:50 UTC (rev 1545)
+++
trunk/runtime/src/main/resources/com/metamatrix/dqp/embedded/i18n.properties 2009-11-09
16:41:36 UTC (rev 1546)
@@ -70,6 +70,7 @@
VDBService.validityErrors=Failed to deploy VDB \"{0}\" because it has following
validity errors; {1}
VDBService.vdb_missing_models=VDB \"{0}\" with version \"{1}\" is
Invalid; This archive has no models defined.
+DataService.Didnt_find_caps=Unable to find capabilities for {0}
DataService.Unable_to_find_connector_manager_for_{0}_1=Unable to find connector manager
for \"{0}\"
DataService.Unable_to_find_connector=Invalid Connector name supplied or Connector not
found: \"{0}\"
DataService.System_model_initialze_error=Connector Binding for the System Model is not
initialized
Modified:
trunk/runtime/src/test/java/com/metamatrix/platform/security/membership/service/TestMembershipServiceImpl.java
===================================================================
---
trunk/runtime/src/test/java/com/metamatrix/platform/security/membership/service/TestMembershipServiceImpl.java 2009-11-06
22:01:50 UTC (rev 1545)
+++
trunk/runtime/src/test/java/com/metamatrix/platform/security/membership/service/TestMembershipServiceImpl.java 2009-11-09
16:41:36 UTC (rev 1546)
@@ -22,7 +22,6 @@
package com.metamatrix.platform.security.membership.service;
-import java.net.Inet4Address;
import java.net.InetAddress;
import java.util.Properties;
import java.util.regex.Pattern;
@@ -39,7 +38,6 @@
import com.metamatrix.platform.security.api.service.AuthenticationToken;
import com.metamatrix.platform.security.api.service.MembershipServiceInterface;
import com.metamatrix.platform.security.api.service.SuccessfulAuthenticationToken;
-import com.metamatrix.platform.security.membership.spi.MembershipSourceException;
import com.metamatrix.platform.security.membership.spi.file.TestFileMembershipDomain;
public class TestMembershipServiceImpl extends TestCase {