teiid SVN: r597 - trunk/server/src/main/java/com/metamatrix/platform/security/api/service.
by teiid-commits@lists.jboss.org
Author: tejones
Date: 2009-03-19 17:11:35 -0400 (Thu, 19 Mar 2009)
New Revision: 597
Modified:
trunk/server/src/main/java/com/metamatrix/platform/security/api/service/MembershipServiceInterface.java
Log:
TEIID-422 - Updated anonymous username
Modified: trunk/server/src/main/java/com/metamatrix/platform/security/api/service/MembershipServiceInterface.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/security/api/service/MembershipServiceInterface.java 2009-03-19 21:11:00 UTC (rev 596)
+++ trunk/server/src/main/java/com/metamatrix/platform/security/api/service/MembershipServiceInterface.java 2009-03-19 21:11:35 UTC (rev 597)
@@ -31,6 +31,7 @@
import com.metamatrix.api.exception.security.MembershipServiceException;
import com.metamatrix.common.config.ResourceNames;
import com.metamatrix.common.config.util.ConfigurationPropertyNames;
+import com.metamatrix.core.CoreConstants;
import com.metamatrix.platform.security.api.Credentials;
import com.metamatrix.platform.security.api.MetaMatrixPrincipal;
import com.metamatrix.platform.security.api.MetaMatrixPrincipalName;
@@ -58,7 +59,7 @@
public static final String DOMAIN_NAME = "domainName"; //$NON-NLS-1$
public static final String DEFAULT_ADMIN_USERNAME = "metamatrixadmin"; //$NON-NLS-1$
- public static final String DEFAULT_WSDL_USERNAME = "teiidanonymous"; //$NON-NLS-1$
+ public static final String DEFAULT_WSDL_USERNAME = CoreConstants.DEFAULT_ANON_USERNAME;
public static final String ADMIN_PASSWORD = ConfigurationPropertyNames.MEMBERSHIP_ADMIN_PASSWORD;
public static final String ADMIN_USERNAME = ConfigurationPropertyNames.MEMBERSHIP_ADMIN_USERNAME;
15 years, 2 months
teiid SVN: r596 - trunk/common-core/src/main/java/com/metamatrix/core.
by teiid-commits@lists.jboss.org
Author: tejones
Date: 2009-03-19 17:11:00 -0400 (Thu, 19 Mar 2009)
New Revision: 596
Modified:
trunk/common-core/src/main/java/com/metamatrix/core/CoreConstants.java
Log:
TEIID-422 - Updated anonymous username
Modified: trunk/common-core/src/main/java/com/metamatrix/core/CoreConstants.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/core/CoreConstants.java 2009-03-19 19:39:21 UTC (rev 595)
+++ trunk/common-core/src/main/java/com/metamatrix/core/CoreConstants.java 2009-03-19 21:11:00 UTC (rev 596)
@@ -111,7 +111,12 @@
* @see #URL_SUFFIX_FOR_VDB
* @see #URL_ROOT_FOR_VDB
*/
- public static final String URL_FOR_DATA_WEBSERVICE = "http://vdb.dataservice.metamatrix.com"; //$NON-NLS-1$
+ public static final String URL_FOR_DATA_WEBSERVICE = "http://vdb.dataservice.metamatrix.com"; //$NON-NLS-1$\
+ /**
+ * Constant for the anonymous Teiid system username
+ */
+ public static final String DEFAULT_ANON_USERNAME = "teiidanonymous";
+
}
15 years, 2 months
teiid SVN: r595 - trunk/server/src/main/java/com/metamatrix/platform/security/api/service.
by teiid-commits@lists.jboss.org
Author: tejones
Date: 2009-03-19 15:39:21 -0400 (Thu, 19 Mar 2009)
New Revision: 595
Modified:
trunk/server/src/main/java/com/metamatrix/platform/security/api/service/MembershipServiceInterface.java
Log:
Updated anonymous username
Modified: trunk/server/src/main/java/com/metamatrix/platform/security/api/service/MembershipServiceInterface.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/security/api/service/MembershipServiceInterface.java 2009-03-19 19:11:17 UTC (rev 594)
+++ trunk/server/src/main/java/com/metamatrix/platform/security/api/service/MembershipServiceInterface.java 2009-03-19 19:39:21 UTC (rev 595)
@@ -58,7 +58,7 @@
public static final String DOMAIN_NAME = "domainName"; //$NON-NLS-1$
public static final String DEFAULT_ADMIN_USERNAME = "metamatrixadmin"; //$NON-NLS-1$
- public static final String DEFAULT_WSDL_USERNAME = "metamatrixwsdl"; //$NON-NLS-1$
+ public static final String DEFAULT_WSDL_USERNAME = "teiidanonymous"; //$NON-NLS-1$
public static final String ADMIN_PASSWORD = ConfigurationPropertyNames.MEMBERSHIP_ADMIN_PASSWORD;
public static final String ADMIN_USERNAME = ConfigurationPropertyNames.MEMBERSHIP_ADMIN_USERNAME;
15 years, 2 months
teiid SVN: r593 - in trunk: connector-api/src/main/java/org/teiid/connector/internal and 7 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-03-19 15:11:15 -0400 (Thu, 19 Mar 2009)
New Revision: 593
Added:
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItemFactory.java
Modified:
trunk/connector-api/src/main/java/org/teiid/connector/api/ExecutionContext.java
trunk/connector-api/src/main/java/org/teiid/connector/internal/ConnectorPropertyNames.java
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/TestIndexConnector.java
trunk/connector-sdk/src/main/java/com/metamatrix/cdk/api/ConnectorHost.java
trunk/connector-sdk/src/main/java/com/metamatrix/cdk/api/EnvironmentUtility.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/AsynchConnectorWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeConnector.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeExecutionContextImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorStateManager.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestExecutionContextImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionPool.java
trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPerUserPool.java
trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java
trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java
Log:
TEIID-164 adding back connector resultset caching.
Modified: trunk/connector-api/src/main/java/org/teiid/connector/api/ExecutionContext.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/api/ExecutionContext.java 2009-03-19 17:17:58 UTC (rev 592)
+++ trunk/connector-api/src/main/java/org/teiid/connector/api/ExecutionContext.java 2009-03-19 19:11:15 UTC (rev 593)
@@ -130,12 +130,6 @@
String getConnectionIdentifier();
/**
- * Whether to use ResultSet cache if it is enabled.
- * @return True if use ResultSet cache; false otherwise.
- */
- boolean useResultSetCache();
-
- /**
* When the execution is turned on with "alive=true", the execution object will not
* be implicitly closed at the end of the last batch. It will only be closed at end
* of the user query. This is useful in keeping the connection open for
Modified: trunk/connector-api/src/main/java/org/teiid/connector/internal/ConnectorPropertyNames.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/internal/ConnectorPropertyNames.java 2009-03-19 17:17:58 UTC (rev 592)
+++ trunk/connector-api/src/main/java/org/teiid/connector/internal/ConnectorPropertyNames.java 2009-03-19 19:11:15 UTC (rev 593)
@@ -104,6 +104,11 @@
public static final String ADMIN_CONNECTIONS_ALLOWED = "AdminConnectionsAllowed"; //$NON-NLS-1$
+ public static final String USE_RESULTSET_CACHE = "ResultSetCacheEnabled"; //$NON-NLS-1$
+ public static final String MAX_RESULTSET_CACHE_SIZE = "ResultSetCacheMaxSize"; //$NON-NLS-1$
+ public static final String MAX_RESULTSET_CACHE_AGE = "ResultSetCacheMaxAge"; //$NON-NLS-1$
+ public static final String RESULTSET_CACHE_SCOPE = "ResultSetCacheScope"; //$NON-NLS-1$
+
/**
* This property can be used to bypass the normal logic that throws an exception when a command
* is about to be executed by a non-XA compatible connector, but there is a global transaction.
Modified: trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/TestIndexConnector.java
===================================================================
--- trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/TestIndexConnector.java 2009-03-19 17:17:58 UTC (rev 592)
+++ trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/TestIndexConnector.java 2009-03-19 19:11:15 UTC (rev 593)
@@ -163,7 +163,7 @@
}
private ExecutionContext helpGetSecurityContext() {
- return new ExecutionContextImpl("testname", "1", null, null, null, null, null, null, null, null, false); //$NON-NLS-1$ //$NON-NLS-2$
+ return new ExecutionContextImpl("testname", "1", null, null, null, null, null, null, null, null); //$NON-NLS-1$ //$NON-NLS-2$
}
/*
* @see junit.framework.TestCase#tearDown()
Modified: trunk/connector-sdk/src/main/java/com/metamatrix/cdk/api/ConnectorHost.java
===================================================================
--- trunk/connector-sdk/src/main/java/com/metamatrix/cdk/api/ConnectorHost.java 2009-03-19 17:17:58 UTC (rev 592)
+++ trunk/connector-sdk/src/main/java/com/metamatrix/cdk/api/ConnectorHost.java 2009-03-19 19:11:15 UTC (rev 593)
@@ -128,7 +128,7 @@
}
public void setSecurityContext(String vdbName, String vdbVersion, String userName, Serializable trustedPayload, Serializable executionPayload) {
- this.executionContext = new ExecutionContextImpl(vdbName, vdbVersion, userName, trustedPayload, executionPayload, "Connection", "Connector<CDK>", "Request", "1", "0", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ this.executionContext = new ExecutionContextImpl(vdbName, vdbVersion, userName, trustedPayload, executionPayload, "Connection", "Connector<CDK>", "Request", "1", "0"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
public void setExecutionContext(ExecutionContext context) {
Modified: trunk/connector-sdk/src/main/java/com/metamatrix/cdk/api/EnvironmentUtility.java
===================================================================
--- trunk/connector-sdk/src/main/java/com/metamatrix/cdk/api/EnvironmentUtility.java 2009-03-19 17:17:58 UTC (rev 592)
+++ trunk/connector-sdk/src/main/java/com/metamatrix/cdk/api/EnvironmentUtility.java 2009-03-19 19:11:15 UTC (rev 593)
@@ -98,7 +98,7 @@
* @return A SecurityContext / ExecutionContext instance
*/
public static ExecutionContext createSecurityContext(String user) {
- return new ExecutionContextImpl("vdb", "1", user, null, null, "Connection", "ConnectorID<CDK>", "Request", "1", "0", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
+ return new ExecutionContextImpl("vdb", "1", user, null, null, "Connection", "ConnectorID<CDK>", "Request", "1", "0"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
}
/**
@@ -111,7 +111,7 @@
* @return A SecurityContext / ExecutionContext instance
*/
public static ExecutionContext createSecurityContext(String vdbName, String vdbVersion, String user, Serializable trustedToken) {
- return new ExecutionContextImpl(vdbName, vdbVersion, user, trustedToken, null, "Connection", "ConnectorID<CDK>", "Request", "1", "0", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ return new ExecutionContextImpl(vdbName, vdbVersion, user, trustedToken, null, "Connection", "ConnectorID<CDK>", "Request", "1", "0"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
/**
@@ -122,7 +122,7 @@
* @return A SecurityContext / ExecutionContext instance
*/
public static ExecutionContext createExecutionContext(String requestID, String partID) {
- return new ExecutionContextImpl("vdb", "1", "user", null, null, "Connection", "ConnectorID<CDK>", requestID, partID, "0", false); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ return new ExecutionContextImpl("vdb", "1", "user", null, null, "Connection", "ConnectorID<CDK>", requestID, partID, "0"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
}
/**
@@ -142,7 +142,7 @@
public static ExecutionContext createExecutionContext(String vdbName, String vdbVersion, String user,
Serializable trustedToken, Serializable executionPayload,
String connectionID, String connectorID, String requestID, String partID, boolean useResultSetCache) {
- return new ExecutionContextImpl(vdbName, vdbVersion, user, trustedToken, executionPayload, connectionID, connectorID, requestID, partID, "0", useResultSetCache); //$NON-NLS-1$
+ return new ExecutionContextImpl(vdbName, vdbVersion, user, trustedToken, executionPayload, connectionID, connectorID, requestID, partID, "0"); //$NON-NLS-1$
}
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/AsynchConnectorWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/AsynchConnectorWorkItem.java 2009-03-19 17:17:58 UTC (rev 592)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/AsynchConnectorWorkItem.java 2009-03-19 19:11:15 UTC (rev 593)
@@ -22,15 +22,27 @@
package org.teiid.dqp.internal.datamgr.impl;
+import org.teiid.connector.api.Connector;
+import org.teiid.connector.api.ConnectorException;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.comm.api.ResultsReceiver;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.message.AtomicResultsMessage;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
public class AsynchConnectorWorkItem extends ConnectorWorkItem {
AsynchConnectorWorkItem(AtomicRequestMessage message, ConnectorManager manager, ResultsReceiver<AtomicResultsMessage> resultsReceiver) {
super(message, manager, resultsReceiver);
+ }
+
+ @Override
+ protected void createConnection(Connector connector,
+ QueryMetadataInterface queryMetadata) throws ConnectorException,
+ MetaMatrixComponentException {
+ super.createConnection(connector, queryMetadata);
Assertion.assertTrue(!this.isTransactional, "Asynch work items are not suitable for transactions"); //$NON-NLS-1$
}
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-03-19 17:17:58 UTC (rev 592)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2009-03-19 19:11:15 UTC (rev 593)
@@ -58,6 +58,7 @@
import org.teiid.dqp.internal.process.DQPWorkContext;
import org.teiid.dqp.internal.transaction.TransactionProvider;
+import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.application.ApplicationEnvironment;
import com.metamatrix.common.application.ApplicationService;
import com.metamatrix.common.application.exception.ApplicationLifecycleException;
@@ -72,6 +73,7 @@
import com.metamatrix.core.util.ReflectionHelper;
import com.metamatrix.core.util.StringUtil;
import com.metamatrix.dqp.DQPPlugin;
+import com.metamatrix.dqp.ResourceFinder;
import com.metamatrix.dqp.internal.datamgr.ConnectorID;
import com.metamatrix.dqp.message.AtomicRequestID;
import com.metamatrix.dqp.message.AtomicRequestMessage;
@@ -103,11 +105,13 @@
private ConnectorID connectorID;
private WorkerPool connectorWorkerPool;
private ResultSetCache rsCache;
+ private ConnectorWorkItemFactory workItemFactory;
private String connectorName;
private int maxResultRows;
private boolean exceptionOnMaxRows = true;
private boolean synchWorkers;
private boolean isXa;
+ private boolean isImmutable;
//services acquired in start
private MetadataService metadataService;
@@ -127,13 +131,11 @@
public void initialize(Properties props) {
this.props = props;
+ this.isImmutable = PropertiesUtils.getBooleanProperty(props, ConnectorPropertyNames.IS_IMMUTABLE, false);
}
public boolean isImmutable() {
- if ( this.props == null ) {
- this.props = new Properties();
- }
- return PropertiesUtils.getBooleanProperty(props, ConnectorPropertyNames.IS_IMMUTABLE, false);
+ return isImmutable;
}
public ClassLoader getClassloader() {
@@ -160,7 +162,7 @@
"capabilities-request", //$NON-NLS-1$
connectorID.getID(),
requestID.toString(),
- "capabilities-request", "0", false); //$NON-NLS-1$ //$NON-NLS-2$
+ "capabilities-request", "0"); //$NON-NLS-1$ //$NON-NLS-2$
conn = connector.getConnection(context);
caps = conn.getCapabilities();
@@ -183,19 +185,14 @@
rsCache.clear();
}
}
-
+
public void executeRequest(ResultsReceiver<AtomicResultsMessage> receiver, AtomicRequestMessage message) {
// Set the connector ID to be used; if not already set.
AtomicRequestID atomicRequestId = message.getAtomicRequestID();
LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {atomicRequestId, "Create State"}); //$NON-NLS-1$
+
+ ConnectorWorkItem item = workItemFactory.createWorkItem(message, receiver);
- ConnectorWorkItem item = null;
- if (synchWorkers) {
- item = new SynchConnectorWorkItem(message, this, receiver);
- } else {
- item = new AsynchConnectorWorkItem(message, this, receiver);
- }
-
Assertion.isNull(requestStates.put(atomicRequestId, item), "State already existed"); //$NON-NLS-1$
message.markProcessingStart();
enqueueRequest(item);
@@ -337,7 +334,19 @@
// Initialize and start the connector
initStartConnector(connectorEnv);
-
+ try {
+ //check result set cache
+ if(PropertiesUtils.getBooleanProperty(props, ConnectorPropertyNames.USE_RESULTSET_CACHE, false)) {
+ Properties rsCacheProps = new Properties();
+ rsCacheProps.setProperty(ResultSetCache.RS_CACHE_MAX_SIZE, props.getProperty(ConnectorPropertyNames.MAX_RESULTSET_CACHE_SIZE, "0")); //$NON-NLS-1$
+ rsCacheProps.setProperty(ResultSetCache.RS_CACHE_MAX_AGE, props.getProperty(ConnectorPropertyNames.MAX_RESULTSET_CACHE_AGE, "0")); //$NON-NLS-1$
+ rsCacheProps.setProperty(ResultSetCache.RS_CACHE_SCOPE, props.getProperty(ConnectorPropertyNames.RESULTSET_CACHE_SCOPE, ResultSetCache.RS_CACHE_SCOPE_VDB));
+ this.rsCache = createResultSetCache(rsCacheProps);
+ }
+ } catch (MetaMatrixComponentException e) {
+ throw new ApplicationLifecycleException(e);
+ }
+ this.workItemFactory = new ConnectorWorkItemFactory(this, this.rsCache, synchWorkers);
this.started = true;
}
@@ -457,6 +466,11 @@
}
return c;
}
+
+ protected ResultSetCache createResultSetCache(Properties rsCacheProps)
+ throws MetaMatrixComponentException {
+ return new ResultSetCache(rsCacheProps, ResourceFinder.getCacheFactory());
+ }
/**
* Queries the Connector Manager, if it already has been started.
@@ -644,6 +658,10 @@
this.classloader = classloader;
}
+ public void setWorkItemFactory(ConnectorWorkItemFactory workItemFactory) {
+ this.workItemFactory = workItemFactory;
+ }
+
/**
* Overloads the connector capabilities with one defined in the connector binding properties
*/
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java 2009-03-19 17:17:58 UTC (rev 592)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java 2009-03-19 19:11:15 UTC (rev 593)
@@ -86,8 +86,8 @@
private List<Integer> convertToDesiredRuntimeType;
/* End state information */
- private boolean lastBatch;
- private int rowCount;
+ protected boolean lastBatch;
+ protected int rowCount;
protected enum RequestState {
NEW, MORE, CLOSE
@@ -100,33 +100,31 @@
private volatile boolean closeRequested;
private boolean isClosed;
- ResultsReceiver<AtomicResultsMessage> resultsReceiver;
+ protected ResultsReceiver<AtomicResultsMessage> resultsReceiver;
ConnectorWorkItem(AtomicRequestMessage message, ConnectorManager manager, ResultsReceiver<AtomicResultsMessage> resultsReceiver) {
this.id = message.getAtomicRequestID();
this.requestMsg = message;
this.manager = manager;
this.resultsReceiver = resultsReceiver;
+ AtomicRequestID requestID = this.requestMsg.getAtomicRequestID();
+ this.securityContext = new ExecutionContextImpl(requestMsg.getWorkContext().getVdbName(),
+ requestMsg.getWorkContext().getVdbVersion(),
+ requestMsg.getWorkContext().getUserName(),
+ requestMsg.getWorkContext().getTrustedPayload(),
+ requestMsg.getExecutionPayload(),
+ requestMsg.getWorkContext().getConnectionID(),
+ requestMsg.getConnectorID().getID(),
+ requestMsg.getRequestID().toString(),
+ Integer.toString(requestID.getNodeID()),
+ Integer.toString(requestID.getExecutionId())
+ );
+ this.securityContext.setBatchSize(this.requestMsg.getFetchSize());
}
protected void createConnection(Connector connector, QueryMetadataInterface queryMetadata) throws ConnectorException, MetaMatrixComponentException {
LogManager.logTrace(LogConstants.CTX_CONNECTOR, new Object[] {id, "creating connection for atomic-request"}); //$NON-NLS-1$
- AtomicRequestID requestID = this.requestMsg.getAtomicRequestID();
- this.securityContext = new ExecutionContextImpl(requestMsg.getWorkContext().getVdbName(),
- requestMsg.getWorkContext().getVdbVersion(),
- requestMsg.getWorkContext().getUserName(),
- requestMsg.getWorkContext().getTrustedPayload(),
- requestMsg.getExecutionPayload(),
- requestMsg.getWorkContext().getConnectionID(),
- requestMsg.getConnectorID().getID(),
- requestMsg.getRequestID().toString(),
- Integer.toString(requestID.getNodeID()),
- Integer.toString(requestID.getExecutionId()),
- requestMsg.useResultSetCache()
- && (requestMsg.getCommand()).areResultsCachable()
- );
- this.securityContext.setBatchSize(this.requestMsg.getFetchSize());
-
+
if (requestMsg.isTransactional()){
if (manager.isXa()) {
connection = ((XAConnector)connector).getXAConnection(this.securityContext, requestMsg.getTransactionContext());
@@ -273,7 +271,7 @@
this.resultsReceiver.receiveResults(response);
}
- protected void processNewRequest() throws ConnectorException, CommunicationException {
+ protected void processNewRequest() throws ConnectorException {
// Execute query
this.execution.execute();
LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Executed command"}); //$NON-NLS-1$
@@ -404,34 +402,39 @@
if (row != null) {
correctTypes(row);
rows.add(row);
+ this.rowCount++;
}
}
LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Obtained last batch, total row count:", rowCount}); //$NON-NLS-1$
}
if (sendResults) {
- int currentRowCount = rows.size();
- if ( !lastBatch && currentRowCount == 0 ) {
- // Defect 13366 - Should send all batches, even if they're zero size.
- // Log warning if received a zero-size non-last batch from the connector.
- LogManager.logWarning(LogConstants.CTX_CONNECTOR, DQPPlugin.Util.getString("ConnectorWorker.zero_size_non_last_batch", requestMsg.getConnectorID())); //$NON-NLS-1$
- }
-
- AtomicResultsMessage response = createResultsMessage(this.requestMsg, rows.toArray(new List[currentRowCount]), requestMsg.getCommand().getProjectedSymbols());
-
- // if we need to keep the execution alive, then we can not support
- // implicit close.
- response.setSupportsImplicitClose(!this.securityContext.keepExecutionAlive());
- response.setTransactional(this.securityContext.isTransactional());
- response.setWarnings(this.securityContext.getWarnings());
-
- if ( lastBatch ) {
- response.setFinalRow(rowCount);
- }
- this.resultsReceiver.receiveResults(response);
+ sendResults(rows);
}
}
+ protected void sendResults(List<List> rows) {
+ int currentRowCount = rows.size();
+ if ( !lastBatch && currentRowCount == 0 ) {
+ // Defect 13366 - Should send all batches, even if they're zero size.
+ // Log warning if received a zero-size non-last batch from the connector.
+ LogManager.logWarning(LogConstants.CTX_CONNECTOR, DQPPlugin.Util.getString("ConnectorWorker.zero_size_non_last_batch", requestMsg.getConnectorID())); //$NON-NLS-1$
+ }
+
+ AtomicResultsMessage response = createResultsMessage(this.requestMsg, rows.toArray(new List[currentRowCount]), requestMsg.getCommand().getProjectedSymbols());
+
+ // if we need to keep the execution alive, then we can not support
+ // implicit close.
+ response.setSupportsImplicitClose(!this.securityContext.keepExecutionAlive());
+ response.setTransactional(this.securityContext.isTransactional());
+ response.setWarnings(this.securityContext.getWarnings());
+
+ if ( lastBatch ) {
+ response.setFinalRow(rowCount);
+ }
+ this.resultsReceiver.receiveResults(response);
+ }
+
private void correctTypes(List row) throws ConnectorException {
//TODO: add a proper source schema
for (int i = convertToRuntimeType.size() - 1; i >= 0; i--) {
Added: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItemFactory.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItemFactory.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItemFactory.java 2009-03-19 19:11:15 UTC (rev 593)
@@ -0,0 +1,173 @@
+/*
+ * 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.datamgr.impl;
+
+import java.util.Arrays;
+
+import org.teiid.connector.api.ConnectorException;
+import org.teiid.dqp.internal.cache.CacheID;
+import org.teiid.dqp.internal.cache.CacheResults;
+import org.teiid.dqp.internal.cache.ResultSetCache;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.common.comm.api.ResultsReceiver;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.dqp.message.AtomicRequestID;
+import com.metamatrix.dqp.message.AtomicRequestMessage;
+import com.metamatrix.dqp.message.AtomicResultsMessage;
+import com.metamatrix.dqp.util.LogConstants;
+import com.metamatrix.query.sql.lang.Command;
+
+public class ConnectorWorkItemFactory {
+
+ private final static char DELIMITER = '.';
+
+ private ResultSetCache rsCache;
+ private ConnectorManager manager;
+ private boolean synchWorkers;
+
+ /**
+ * A work item that can get results from cache.
+ */
+ private final class CachedResultsConnectorWorkItem extends
+ AsynchConnectorWorkItem {
+ private final CacheID cacheID;
+
+ private CachedResultsConnectorWorkItem(AtomicRequestMessage message,
+ ConnectorManager manager,
+ ResultsReceiver<AtomicResultsMessage> resultsReceiver,
+ CacheID cacheID) {
+ super(message, manager, resultsReceiver);
+ this.cacheID = cacheID;
+ }
+
+ @Override
+ protected void createExecution()
+ throws MetaMatrixComponentException,
+ ConnectorException {
+ }
+
+ @Override
+ protected void processNewRequest() throws ConnectorException {
+ handleBatch();
+ }
+
+ @Override
+ protected void handleBatch() throws ConnectorException {
+ int firstRow = rowCount + 1;
+ //already in cache
+ CacheResults results = rsCache.getResults(cacheID, new int[]{firstRow, firstRow + requestMsg.getFetchSize() -1});
+ this.rowCount = rowCount + results.getResults().length;
+ if(results.isFinal()){
+ this.lastBatch = true;
+ }
+
+ LogManager.logTrace(LogConstants.CTX_DQP,
+ new Object[] { "CacheSynchQueryExecution - returnning batch from cache, startRow =", //$NON-NLS-1$
+ new Integer(firstRow),
+ ", endRow =", //$NON-NLS-1$
+ new Integer(rowCount)});
+ sendResults(Arrays.asList(results.getResults()));
+ }
+ }
+
+ /**
+ * Intercepts results for cachable commands
+ */
+ public class CachedResultsReceiver implements ResultsReceiver<AtomicResultsMessage> {
+
+ private ResultsReceiver<AtomicResultsMessage> actual;
+ private AtomicRequestID requestId;
+ private CacheID cacheID;
+ private int firstRow = 1;
+
+ public CachedResultsReceiver(ResultsReceiver<AtomicResultsMessage> actual,
+ CacheID cacheID, AtomicRequestID requestId) {
+ this.actual = actual;
+ this.cacheID = cacheID;
+ this.requestId = requestId;
+ }
+
+ @Override
+ public void receiveResults(AtomicResultsMessage results) {
+ boolean isFinal = results.getFinalRow() >= 0;
+ if (results.isRequestClosed()) {
+ rsCache.removeTempResults(cacheID);
+ } else {
+ CacheResults cr = new CacheResults(results.getResults(), firstRow, isFinal);
+ firstRow += results.getResults().length;
+ rsCache.setResults(cacheID, cr, requestId);
+ }
+ actual.receiveResults(results);
+ }
+
+ @Override
+ public void exceptionOccurred(Throwable e) {
+ rsCache.removeTempResults(cacheID);
+ actual.exceptionOccurred(e);
+ }
+
+ }
+
+ public ConnectorWorkItemFactory(ConnectorManager manager,
+ ResultSetCache rsCache, boolean synchWorkers) {
+ this.manager = manager;
+ this.rsCache = rsCache;
+ this.synchWorkers = synchWorkers;
+ }
+
+ public ConnectorWorkItem createWorkItem(AtomicRequestMessage message, ResultsReceiver<AtomicResultsMessage> receiver) {
+ if (this.rsCache != null && message.useResultSetCache()) {
+ final CacheID cacheID = createCacheID(message);
+
+ if (cacheID != null) {
+ if (rsCache.hasResults(cacheID)) {
+ return new CachedResultsConnectorWorkItem(message, manager,
+ receiver, cacheID);
+ }
+ receiver = new CachedResultsReceiver(receiver, cacheID, message.getAtomicRequestID());
+ }
+ }
+
+ if (synchWorkers) {
+ return new SynchConnectorWorkItem(message, manager, receiver);
+ }
+ return new AsynchConnectorWorkItem(message, manager, receiver);
+ }
+
+ private CacheID createCacheID(AtomicRequestMessage message) {
+ Command command = message.getCommand();
+ if (!command.areResultsCachable()) {
+ return null;
+ }
+ String scope = rsCache.getCacheScope();
+ String scopeId = null;
+ if(ResultSetCache.RS_CACHE_SCOPE_VDB.equalsIgnoreCase(scope)){
+ scopeId = message.getWorkContext().getVdbName() + DELIMITER + message.getWorkContext().getVdbVersion();
+ }else{
+ scopeId = message.getWorkContext().getConnectionID();
+ }
+ return new CacheID(scopeId, command.toString());
+ }
+
+}
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItemFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java 2009-03-19 17:17:58 UTC (rev 592)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java 2009-03-19 19:11:15 UTC (rev 593)
@@ -55,8 +55,6 @@
private Serializable executionPayload;
// ID of the parent JDBC Connection which is executing the statement
private String requestConnectionID;
- // uses the result set chache or not
- private boolean useResultSetCache;
// Execute count of the query
private String executeCount;
// keep the execution object alive during the processing. default:false
@@ -71,7 +69,7 @@
public ExecutionContextImpl(String vdbName, String vdbVersion, String userName,
Serializable trustedPayload, Serializable executionPayload,
- String originalConnectionID, String connectorId, String requestId, String partId, String execCount, boolean useResultSetCache) {
+ String originalConnectionID, String connectorId, String requestId, String partId, String execCount) {
this.vdbName = vdbName;
this.vdbVersion = vdbVersion;
@@ -83,7 +81,6 @@
this.partID = partId;
this.requestConnectionID = originalConnectionID;
this.executeCount = execCount;
- this.useResultSetCache = useResultSetCache;
}
public String getConnectorIdentifier() {
@@ -124,10 +121,6 @@
return requestConnectionID;
}
- public boolean useResultSetCache() {
- return useResultSetCache;
- }
-
public void keepExecutionAlive(boolean alive) {
this.keepAlive = alive;
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeConnector.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeConnector.java 2009-03-19 17:17:58 UTC (rev 592)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeConnector.java 2009-03-19 19:11:15 UTC (rev 593)
@@ -60,6 +60,17 @@
private long simulatedBatchRetrievalTime = 1000L;
private ClassLoader classloader;
+ private int connectionCount;
+ private int executionCount;
+
+ public int getConnectionCount() {
+ return connectionCount;
+ }
+
+ public int getExecutionCount() {
+ return executionCount;
+ }
+
@Override
public Connection getConnection(org.teiid.connector.api.ExecutionContext context) throws ConnectorException {
return new FakeConnection();
@@ -78,8 +89,14 @@
}
private class FakeConnection extends BasicConnection implements XAConnection {
+
+ public FakeConnection() {
+ connectionCount++;
+ }
+
public boolean released = false;
public Execution createExecution(ICommand command, ExecutionContext executionContext, RuntimeMetadata metadata) throws ConnectorException {
+ executionCount++;
return new FakeBlockingExecution(executionContext);
}
public ConnectorCapabilities getCapabilities() {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeExecutionContextImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeExecutionContextImpl.java 2009-03-19 17:17:58 UTC (rev 592)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeExecutionContextImpl.java 2009-03-19 19:11:15 UTC (rev 593)
@@ -46,8 +46,7 @@
"ConnectorID"+unique, //$NON-NLS-1$
"RequestID"+unique, //$NON-NLS-1$
"PartID"+unique, //$NON-NLS-1$
- "ExecCount"+unique, //$NON-NLS-1$
- false);
+ "ExecCount"+unique);
}
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java 2009-03-19 17:17:58 UTC (rev 592)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java 2009-03-19 19:11:15 UTC (rev 593)
@@ -26,23 +26,31 @@
*/
package org.teiid.dqp.internal.datamgr.impl;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
-import junit.framework.TestCase;
-
+import org.junit.Test;
import org.mockito.Mockito;
import org.teiid.connector.internal.ConnectorPropertyNames;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
+import org.teiid.dqp.internal.cache.ResultSetCache;
import org.teiid.dqp.internal.datamgr.impl.TestConnectorWorkItem.QueueResultsReceiver;
import org.teiid.dqp.internal.pooling.connector.FakeSourceConnectionFactory;
import org.teiid.dqp.internal.process.DQPWorkContext;
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.cache.FakeCache;
import com.metamatrix.common.application.ApplicationEnvironment;
import com.metamatrix.common.application.exception.ApplicationLifecycleException;
import com.metamatrix.dqp.message.AtomicRequestMessage;
+import com.metamatrix.dqp.message.AtomicResultsMessage;
import com.metamatrix.dqp.service.DQPServiceNames;
import com.metamatrix.dqp.service.FakeMetadataService;
import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
@@ -51,18 +59,7 @@
/**
* JUnit test for TestConnectorManagerImpl
*/
-public final class TestConnectorManagerImpl extends TestCase {
- // =========================================================================
- // F R A M E W O R K
- // =========================================================================
- /**
- * Constructor for TestConnectorManagerImpl.
- * @param name
- */
- public TestConnectorManagerImpl(final String name) {
- super(name);
- }
-
+public final class TestConnectorManagerImpl {
private Properties helpGetAppProps() {
Properties appProperties = new Properties();
@@ -77,7 +74,7 @@
// T E S T C A S E S
// =========================================================================
- public void testStartFailsWithNullRequiredProp() throws Exception {
+ @Test public void testStartFailsWithNullRequiredProp() throws Exception {
ConnectorManager cm = new ConnectorManager();
Properties appProperties = helpGetAppProps();
// Remove required property
@@ -92,7 +89,7 @@
}
}
- public void testReceive() throws Exception {
+ @Test public void testReceive() throws Exception {
ConnectorManager cm = new ConnectorManager();
startConnectorManager(cm, helpGetAppProps());
@@ -103,7 +100,7 @@
cm.stop();
}
- public void testConnectorCapabilitiesOverride() throws Exception {
+ @Test public void testConnectorCapabilitiesOverride() throws Exception {
ConnectorManager cm = new ConnectorManager();
startConnectorManager(cm, helpGetAppProps());
@@ -134,7 +131,7 @@
cm.start(env);
}
- public void testIsXA() throws Exception {
+ @Test public void testIsXA() throws Exception {
ConnectorManager cm = new ConnectorManager();
Properties props = new Properties();
props.setProperty(ConnectorPropertyNames.CONNECTOR_CLASS, FakeConnector.class.getName());
@@ -144,7 +141,7 @@
cm.stop();
}
- public void testIsXA_Failure() throws Exception {
+ @Test public void testIsXA_Failure() throws Exception {
ConnectorManager cm = new ConnectorManager();
Properties props = new Properties();
props.setProperty(ConnectorPropertyNames.CONNECTOR_CLASS, FakeSourceConnectionFactory.class.getName());
@@ -157,7 +154,51 @@
cm.stop();
}
- public void testDefect19049() throws Exception {
+ @Test public void testCaching() throws Exception {
+ ConnectorManager cm = new ConnectorManager() {
+ @Override
+ protected ResultSetCache createResultSetCache(
+ Properties rsCacheProps)
+ throws MetaMatrixComponentException {
+ assertEquals(rsCacheProps.get(ResultSetCache.RS_CACHE_MAX_AGE), String.valueOf(0));
+ return new ResultSetCache(rsCacheProps, new FakeCache.FakeCacheFactory());
+ }
+ };
+ Properties props = new Properties();
+ props.setProperty(ConnectorPropertyNames.CONNECTOR_CLASS, FakeConnector.class.getName());
+ props.setProperty(ConnectorPropertyNames.USE_RESULTSET_CACHE, Boolean.TRUE.toString());
+ startConnectorManager(cm, props);
+ ConnectorWrapper wrapper = cm.getConnector();
+ FakeConnector fc = (FakeConnector)wrapper.getActualConnector();
+ assertEquals(0, fc.getConnectionCount());
+ assertEquals(0, fc.getExecutionCount());
+ AtomicRequestMessage request = TestConnectorWorkItem.createNewAtomicRequestMessage(1, 1);
+ request.setUseResultSetCache(true);
+ QueueResultsReceiver receiver = new QueueResultsReceiver();
+ cm.executeRequest(receiver, request);
+ AtomicResultsMessage arm = receiver.getResults().poll(1000, TimeUnit.MILLISECONDS);
+ assertEquals(-1, arm.getFinalRow());
+ //get the last batch - it will be 0 sized
+ cm.requstMore(request.getAtomicRequestID());
+ assertNotNull(receiver.getResults().poll(1000, TimeUnit.MILLISECONDS));
+ cm.closeRequest(request.getAtomicRequestID());
+ assertEquals(1, fc.getConnectionCount());
+ assertEquals(1, fc.getExecutionCount());
+
+ //this request should hit the cache
+ AtomicRequestMessage request1 = TestConnectorWorkItem.createNewAtomicRequestMessage(2, 1);
+ request1.setUseResultSetCache(true);
+ QueueResultsReceiver receiver1 = new QueueResultsReceiver();
+ cm.executeRequest(receiver1, request1);
+ arm = receiver1.getResults().poll(1000, TimeUnit.MILLISECONDS);
+ assertEquals(5, arm.getFinalRow());
+ assertEquals(1, fc.getConnectionCount());
+ assertEquals(1, fc.getExecutionCount());
+
+ cm.stop();
+ }
+
+ @Test public void testDefect19049() throws Exception {
ConnectorManager cm = new ConnectorManager();
Properties props = new Properties();
final String connectorName = FakeConnector.class.getName();
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorStateManager.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorStateManager.java 2009-03-19 17:17:58 UTC (rev 592)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorStateManager.java 2009-03-19 19:11:15 UTC (rev 593)
@@ -66,6 +66,7 @@
csm = new ConnectorManager();
csm.setConnectorWorkerPool(Mockito.mock(WorkerPool.class));
csm.setConnector(new ConnectorWrapper(new FakeConnector()));
+ csm.setWorkItemFactory(new ConnectorWorkItemFactory(csm, null, true));
}
void helpAssureOneState() {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestExecutionContextImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestExecutionContextImpl.java 2009-03-19 17:17:58 UTC (rev 592)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestExecutionContextImpl.java 2009-03-19 19:11:15 UTC (rev 593)
@@ -38,7 +38,7 @@
public ExecutionContextImpl createContext(String requestID, String partID) {
return new ExecutionContextImpl("vdb", "1", "user", null, null, //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- "Connection", "Connector", requestID, partID, "0", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ "Connection", "Connector", requestID, partID, "0"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
public void testEqivalenceSemanticsSame() {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionPool.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionPool.java 2009-03-19 17:17:58 UTC (rev 592)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionPool.java 2009-03-19 19:11:15 UTC (rev 593)
@@ -71,7 +71,7 @@
}
public static ExecutionContext createContext(final String user, boolean userIdentity) {
- ExecutionContextImpl context = new ExecutionContextImpl(null, null, user, null, null, null, null, null, null, null, false);
+ ExecutionContextImpl context = new ExecutionContextImpl(null, null, user, null, null, null, null, null, null, null);
if (userIdentity) {
context.setConnectorIdentity(new MappedUserIdentity(context.getUser(), null, null));
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPerUserPool.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPerUserPool.java 2009-03-19 17:17:58 UTC (rev 592)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPerUserPool.java 2009-03-19 19:11:15 UTC (rev 593)
@@ -111,7 +111,7 @@
}
// session payload
- ExecutionContextImpl impl = new ExecutionContextImpl(null, null, null, credentials, null, null, null, null, null, null, false);
+ ExecutionContextImpl impl = new ExecutionContextImpl(null, null, null, credentials, null, null, null, null, null, null);
impl.setConnectorIdentity(factory.createIdentity(impl));
return impl;
}
Modified: trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java 2009-03-19 17:17:58 UTC (rev 592)
+++ trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java 2009-03-19 19:11:15 UTC (rev 593)
@@ -74,8 +74,7 @@
"ExecutionPayload", //$NON-NLS-1$
"ConnectionID", //$NON-NLS-1$
"Connector",
- "RequestID", "PartID", "ExecCount", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- false);
+ "RequestID", "PartID", "ExecCount");
/**
* Constructor for TestSQLConversionVisitor.
* @param name
Modified: trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java 2009-03-19 17:17:58 UTC (rev 592)
+++ trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java 2009-03-19 19:11:15 UTC (rev 593)
@@ -407,7 +407,7 @@
String output = "SELECT /*+ ALL_ROWS */ PARTS.PART_NAME, ROWNUM FROM PARTS"; //$NON-NLS-1$
String hint = "/*+ ALL_ROWS */"; //$NON-NLS-1$
- ExecutionContext context = new ExecutionContextImpl(null, null, null, null, hint, null, "", null, null, null, false); //$NON-NLS-1$
+ ExecutionContext context = new ExecutionContextImpl(null, null, null, null, hint, null, "", null, null, null); //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
15 years, 2 months
teiid SVN: r592 - in trunk: embedded/src/main/java/com/metamatrix/dqp/embedded/admin and 1 other directory.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-03-19 13:17:58 -0400 (Thu, 19 Mar 2009)
New Revision: 592
Modified:
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/Translator.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java
Log:
TEIID-66: problems found during the designer integration
Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/Translator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/Translator.java 2009-03-18 20:11:01 UTC (rev 591)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/Translator.java 2009-03-19 17:17:58 UTC (rev 592)
@@ -106,7 +106,12 @@
};
public final static TimeZone DEFAULT_TIME_ZONE = TimeZone.getDefault();
- private static final ThreadLocal<Calendar> CALENDAR = new ThreadLocal<Calendar>();
+ private static final ThreadLocal<Calendar> CALENDAR = new ThreadLocal<Calendar>() {
+ @Override
+ protected Calendar initialValue() {
+ return Calendar.getInstance();
+ }
+ };
private Map<String, FunctionModifier> functionModifiers = new HashMap<String, FunctionModifier>();
private ConnectorEnvironment environment;
@@ -135,8 +140,6 @@
TimeZone tz = TimeZone.getTimeZone(timeZone);
if(!DEFAULT_TIME_ZONE.hasSameRules(tz)) {
CALENDAR.set(Calendar.getInstance(tz));
- } else {
- CALENDAR.set(Calendar.getInstance());
}
}
Modified: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java 2009-03-18 20:11:01 UTC (rev 591)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java 2009-03-19 17:17:58 UTC (rev 592)
@@ -300,7 +300,7 @@
* @since 4.3
*/
private com.metamatrix.admin.api.objects.ConnectorBinding convertConnectorType(final com.metamatrix.common.config.api.ConnectorBinding src, final Object parent) {
- MMConnectorBinding binding = new MMConnectorBinding(new String[] {src.getDeployedName(), "Embedded"}); //$NON-NLS-1$
+ MMConnectorBinding binding = new MMConnectorBinding(new String[] {src.getDeployedName()});
binding.setConnectorTypeName(src.getComponentTypeID().getFullName());
binding.setCreated(src.getCreatedDate());
15 years, 2 months
teiid SVN: r591 - in trunk/engine/src: main/java/com/metamatrix/dqp/internal and 50 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-03-18 16:11:01 -0400 (Wed, 18 Mar 2009)
New Revision: 591
Added:
trunk/engine/src/main/java/org/
trunk/engine/src/main/java/org/teiid/
trunk/engine/src/main/java/org/teiid/dqp/
trunk/engine/src/main/java/org/teiid/dqp/internal/
trunk/engine/src/main/java/org/teiid/dqp/internal/cache/
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/
trunk/engine/src/main/java/org/teiid/dqp/internal/pooling/
trunk/engine/src/main/java/org/teiid/dqp/internal/pooling/connector/
trunk/engine/src/main/java/org/teiid/dqp/internal/process/
trunk/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedRequestWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/CodeTableCache.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManager.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobChunkStream.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedPlanCache.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/QueryMetadataWrapper.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/TempTableStoresHolder.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/capabilities/
trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/
trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/
trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/
trunk/engine/src/test/java/org/
trunk/engine/src/test/java/org/teiid/
trunk/engine/src/test/java/org/teiid/dqp/
trunk/engine/src/test/java/org/teiid/dqp/internal/
trunk/engine/src/test/java/org/teiid/dqp/internal/cache/
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/metadata/
trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/
trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/
trunk/engine/src/test/java/org/teiid/dqp/internal/process/
trunk/engine/src/test/java/org/teiid/dqp/internal/process/MockSingleMetadataService.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCallableStatement.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCodeTableCache.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.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/engine/src/test/java/org/teiid/dqp/internal/process/TestRequestWorkItem.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestWorkItemState.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/capabilities/
trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/
trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/
trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/
Removed:
trunk/engine/src/main/java/com/metamatrix/dqp/internal/cache/
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/CapabilitiesConverter.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/
trunk/engine/src/main/java/com/metamatrix/dqp/internal/pooling/connector/
trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/AbstractWorkItem.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/CachedRequestWorkItem.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/CodeTableCache.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/DQPCore.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/DQPWorkContext.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/DataTierManager.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/DataTierManagerImpl.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/DataTierTupleSource.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/LobChunkStream.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/LobWorkItem.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/MetaDataProcessor.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/PreparedPlanCache.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/PreparedStatementRequest.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/QueryMetadataWrapper.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/Request.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/RequestWorkItem.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/TempTableStoresHolder.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/capabilities/
trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/multisource/
trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/validator/
trunk/engine/src/main/java/com/metamatrix/dqp/internal/transaction/
trunk/engine/src/test/java/com/metamatrix/dqp/internal/cache/
trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl/
trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/
trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/metadata/
trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/
trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/MockSingleMetadataService.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestCallableStatement.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestCodeTableCache.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestDQPCore.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestDQPCoreRequestHandling.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestDQPWorkContext.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestDataTierManager.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestMetaDataProcessor.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestPreparedPlanCache.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestPreparedStatement.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestRequest.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestRequestWorkItem.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestWorkItemState.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/capabilities/
trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/multisource/
trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/validator/
trunk/engine/src/test/java/com/metamatrix/dqp/internal/transaction/
Modified:
trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestMessage.java
trunk/engine/src/main/java/com/metamatrix/dqp/service/DataService.java
trunk/engine/src/main/java/com/metamatrix/dqp/transaction/TransactionServer.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/batch/PreparedBatchUpdatePlanner.java
trunk/engine/src/main/java/com/metamatrix/query/processor/batch/PreparedBatchUpdatePlan.java
trunk/engine/src/main/java/org/teiid/dqp/internal/cache/CacheID.java
trunk/engine/src/main/java/org/teiid/dqp/internal/cache/CacheResults.java
trunk/engine/src/main/java/org/teiid/dqp/internal/cache/CursorReceiverWindowBuffer.java
trunk/engine/src/main/java/org/teiid/dqp/internal/cache/ResultSetCache.java
trunk/engine/src/main/java/org/teiid/dqp/internal/cache/ResultSetCacheUtil.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/AsynchConnectorWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorEnvironmentImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWrapper.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/DefaultConnectorLogger.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ProcedureBatchHandler.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/TypeFacilityImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/AggregateImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/BaseLanguageObject.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/BatchedUpdatesImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/BulkInsertImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/CompareCriteriaImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/CompoundCriteriaImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/DeleteImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ElementImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ExistsCriteriaImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/FromImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/FunctionImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/GroupByImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/GroupImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InCriteriaImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InlineViewImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InsertImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/IsNullCriteriaImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/JoinImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageFactoryImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LikeCriteriaImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LimitImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LiteralImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/NotCriteriaImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/OrderByImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/OrderByItemImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ParameterImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ProcedureImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/QueryCommandImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/QueryImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ScalarSubqueryImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SearchedCaseExpressionImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SelectImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SelectSymbolImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetClauseImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetClauseListImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetQueryImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SubqueryCompareCriteriaImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SubqueryInCriteriaImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/UpdateImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ElementImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/GroupImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/MetadataObjectImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ParameterImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ProcedureImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/TypeModelImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/pooling/connector/ConnectionPool.java
trunk/engine/src/main/java/org/teiid/dqp/internal/pooling/connector/ConnectionPoolException.java
trunk/engine/src/main/java/org/teiid/dqp/internal/pooling/connector/ConnectionWrapper.java
trunk/engine/src/main/java/org/teiid/dqp/internal/pooling/connector/PooledConnector.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/capabilities/ConnectorCapabilitiesFinder.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/capabilities/SharedCachedFinder.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceCapabilitiesFinder.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceElement.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceElementReplacementVisitor.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceMetadataWrapper.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/ModelVisibilityValidationVisitor.java
trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionContextImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionProvider.java
trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java
trunk/engine/src/test/java/com/metamatrix/dqp/config/TestDQPLauncher.java
trunk/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java
trunk/engine/src/test/java/com/metamatrix/dqp/service/AutoGenDataService.java
trunk/engine/src/test/java/com/metamatrix/dqp/service/TestCustomizableTrackingService.java
trunk/engine/src/test/java/com/metamatrix/query/processor/HardcodedDataManager.java
trunk/engine/src/test/java/com/metamatrix/query/unittest/QueryMetadataInterfaceBuilder.java
trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestCacheID.java
trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestCursorReceiverWindowBuffer.java
trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestResultSetCache.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeConnector.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeExecutionContextImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeProcedureExecution.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeTransactionService.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorStateManager.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestExecutionContextImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestTypeFacilityImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestAggregateImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestBatchedUpdatesImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestBulkInsertImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompareCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompoundCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestDeleteImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestElementImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestExistsCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFromImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFunctionImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupByImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInlineViewImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInsertImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestIsNullCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestJoinImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLikeCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLiteralImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestNotCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestOrderByImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestParameterImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestProcedureImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestQueryImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestScalarSubqueryImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSearchedCaseExpressionImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectSymbolImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSetQueryImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryCompareCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryInCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestUpdateImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TstLanguageBridgeFactory.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/metadata/TestMetadataFactory.java
trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/FakeSourceConnectionFactory.java
trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/FakeUserIdentityConnectionFactory.java
trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionPool.java
trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionWrapper.java
trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPerUserPool.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/capabilities/TestConnectorCapabilitiesFinder.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceCapabilitiesFinder.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceElementReplacementVisitor.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceMetadataWrapper.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestAuthorizationValidationVisitor.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestModelVisibilityValidationVisitor.java
trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionContextImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java
Log:
TEIID-346 adding in a compatibility layer with 5.5 connectors.
Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/CapabilitiesConverter.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/CapabilitiesConverter.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/CapabilitiesConverter.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,120 +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 com.metamatrix.dqp.internal.datamgr;
-
-import java.util.*;
-
-import org.teiid.connector.api.ConnectorCapabilities;
-
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-
-/**
- * Utility to convert a ConnectorCapabilities class into a Map of
- * capabilities information that can be passed through the system.
- */
-public class CapabilitiesConverter {
-
- private CapabilitiesConverter() {
- }
-
- public static SourceCapabilities convertCapabilities(ConnectorCapabilities srcCaps) {
- return convertCapabilities(srcCaps, null, false);
- }
-
- public static BasicSourceCapabilities convertCapabilities(ConnectorCapabilities srcCaps, String connectorID, boolean isXa) {
- BasicSourceCapabilities tgtCaps = new BasicSourceCapabilities();
-
- tgtCaps.setCapabilitySupport(Capability.QUERY_SELECT_DISTINCT, srcCaps.supportsSelectDistinct());
- tgtCaps.setCapabilitySupport(Capability.QUERY_SELECT_LITERALS, srcCaps.supportsSelectLiterals());
- tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, srcCaps.supportsAliasedGroup());
- tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN, srcCaps.supportsJoins());
- tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, srcCaps.supportsSelfJoins());
- tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, srcCaps.supportsOuterJoins());
- tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, srcCaps.supportsFullOuterJoins());
- tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, srcCaps.supportsInlineViews());
- tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE, srcCaps.supportsCriteria());
- tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_BETWEEN, srcCaps.supportsBetweenCriteria());
- tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE, srcCaps.supportsCompareCriteria());
- tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE_EQ, srcCaps.supportsCompareCriteriaEquals());
- tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE_NE, srcCaps.supportsCompareCriteriaNotEquals());
- tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE_LT, srcCaps.supportsCompareCriteriaLessThan());
- tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE_LE, srcCaps.supportsCompareCriteriaLessThanOrEqual());
- tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE_GT, srcCaps.supportsCompareCriteriaGreaterThan());
- tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE_GE, srcCaps.supportsCompareCriteriaGreaterThanOrEqual());
- tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_LIKE, srcCaps.supportsLikeCriteria());
- tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_LIKE_ESCAPE, srcCaps.supportsLikeCriteriaEscapeCharacter());
- tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_IN, srcCaps.supportsInCriteria());
- tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_IN_SUBQUERY, srcCaps.supportsInCriteriaSubquery());
- tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_ISNULL, srcCaps.supportsIsNullCriteria());
- tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_AND, srcCaps.supportsAndCriteria());
- tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_OR, srcCaps.supportsOrCriteria());
- tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_NOT, srcCaps.supportsNotCriteria());
- tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_EXISTS, srcCaps.supportsExistsCriteria());
- tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_QUANTIFIED_COMPARISON, srcCaps.supportsQuantifiedCompareCriteria());
- tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_QUANTIFIED_SOME, srcCaps.supportsQuantifiedCompareCriteriaSome());
- tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_QUANTIFIED_ALL, srcCaps.supportsQuantifiedCompareCriteriaAll());
- tgtCaps.setCapabilitySupport(Capability.QUERY_ORDERBY, srcCaps.supportsOrderBy());
- tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES, srcCaps.supportsAggregates());
- tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, srcCaps.supportsAggregatesSum());
- tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_AVG, srcCaps.supportsAggregatesAvg());
- tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MIN, srcCaps.supportsAggregatesMin());
- tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, srcCaps.supportsAggregatesMax());
- tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, srcCaps.supportsAggregatesCount());
- tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, srcCaps.supportsAggregatesCountStar());
- tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_DISTINCT, srcCaps.supportsAggregatesDistinct());
- tgtCaps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, srcCaps.supportsScalarSubqueries());
- tgtCaps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, srcCaps.supportsCorrelatedSubqueries());
- tgtCaps.setCapabilitySupport(Capability.QUERY_CASE, srcCaps.supportsCaseExpressions());
- tgtCaps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, srcCaps.supportsSearchedCaseExpressions());
- tgtCaps.setCapabilitySupport(Capability.QUERY_UNION, srcCaps.supportsUnions());
- tgtCaps.setCapabilitySupport(Capability.QUERY_INTERSECT, srcCaps.supportsIntersect());
- tgtCaps.setCapabilitySupport(Capability.QUERY_EXCEPT, srcCaps.supportsExcept());
- tgtCaps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, srcCaps.supportsSetQueryOrderBy());
- tgtCaps.setCapabilitySupport(Capability.BULK_INSERT , srcCaps.supportsBulkInsert());
- tgtCaps.setCapabilitySupport(Capability.BATCHED_UPDATES, srcCaps.supportsBatchedUpdates());
- tgtCaps.setCapabilitySupport(Capability.FUNCTION, srcCaps.supportsScalarFunctions());
- tgtCaps.setCapabilitySupport(Capability.QUERY_FUNCTIONS_IN_GROUP_BY, srcCaps.supportsFunctionsInGroupBy());
- tgtCaps.setCapabilitySupport(Capability.ROW_LIMIT, srcCaps.supportsRowLimit());
- tgtCaps.setCapabilitySupport(Capability.ROW_OFFSET, srcCaps.supportsRowOffset());
- tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_ANSI_JOIN, srcCaps.useAnsiJoin());
- tgtCaps.setCapabilitySupport(Capability.REQUIRES_CRITERIA, srcCaps.requiresCriteria());
-
- List functions = srcCaps.getSupportedFunctions();
- if(functions != null && functions.size() > 0) {
- Iterator iter = functions.iterator();
- while(iter.hasNext()) {
- String func = (String) iter.next();
- tgtCaps.setFunctionSupport(func.toLowerCase(), true);
- }
- }
-
- tgtCaps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(srcCaps.getMaxInCriteriaSize()));
- tgtCaps.setSourceProperty(Capability.CONNECTOR_ID, connectorID);
- tgtCaps.setSourceProperty(Capability.MAX_QUERY_FROM_GROUPS, new Integer(srcCaps.getMaxFromGroups()));
- tgtCaps.setSourceProperty(Capability.TRANSACTIONS_XA, isXa);
- return tgtCaps;
- }
-
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/AbstractWorkItem.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/AbstractWorkItem.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/AbstractWorkItem.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,125 +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 com.metamatrix.dqp.internal.process;
-
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.dqp.util.LogConstants;
-
-
-/**
- * Represents a task that performs work that may take more than one processing pass to complete.
- * During processing the WorkItem may receive events asynchronously through the moreWork method.
- */
-public abstract class AbstractWorkItem implements Runnable {
-
- enum ThreadState {
- MORE_WORK, WORKING, IDLE, DONE
- }
-
- private ThreadState threadState = ThreadState.MORE_WORK;
-
- public void run() {
- try {
- startProcessing();
- process();
- } finally {
- endProcessing();
- }
- }
-
- ThreadState getThreadState() {
- return this.threadState;
- }
-
- private synchronized void startProcessing() {
- logTrace("start processing"); //$NON-NLS-1$
- if (this.threadState != ThreadState.MORE_WORK) {
- throw new IllegalStateException("Must be in MORE_WORK"); //$NON-NLS-1$
- }
- this.threadState = ThreadState.WORKING;
- }
-
- private synchronized void endProcessing() {
- logTrace("end processing"); //$NON-NLS-1$
- switch (this.threadState) {
- case WORKING:
- if (isDoneProcessing()) {
- logTrace("done processing"); //$NON-NLS-1$
- this.threadState = ThreadState.DONE;
- } else {
- this.threadState = ThreadState.IDLE;
- pauseProcessing();
- }
- break;
- case MORE_WORK:
- if (isDoneProcessing()) {
- logTrace("done processing - ignoring more"); //$NON-NLS-1$
- this.threadState = ThreadState.DONE;
- } else {
- resumeProcessing();
- }
- break;
- default:
- throw new IllegalStateException("Should not END on IDLE or DONE"); //$NON-NLS-1$
- }
- }
-
- protected void moreWork() {
- moreWork(true);
- }
-
- protected synchronized void moreWork(boolean ignoreDone) {
- logTrace("more work"); //$NON-NLS-1$
- switch (this.threadState) {
- case WORKING:
- this.threadState = ThreadState.MORE_WORK;
- break;
- case MORE_WORK:
- break;
- case IDLE:
- this.threadState = ThreadState.MORE_WORK;
- resumeProcessing();
- break;
- default:
- if (!ignoreDone) {
- throw new IllegalStateException("More work is not valid once DONE"); //$NON-NLS-1$
- }
- LogManager.logDetail(LogConstants.CTX_DQP, new Object[] {this, "ignoring more work, since the work item is done"}); //$NON-NLS-1$
- }
- }
-
- private void logTrace(String msg) {
- LogManager.logTrace(LogConstants.CTX_DQP, new Object[] {this, msg, this.threadState});
- }
-
- protected abstract void process();
-
- protected void pauseProcessing() {
- }
-
- protected abstract void resumeProcessing();
-
- protected abstract boolean isDoneProcessing();
-
- public abstract String toString();
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/CachedRequestWorkItem.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/CachedRequestWorkItem.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/CachedRequestWorkItem.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,99 +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 com.metamatrix.dqp.internal.process;
-
-import java.util.List;
-
-import javax.transaction.SystemException;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BlockedOnMemoryException;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.buffer.TupleSourceNotFoundException;
-import com.metamatrix.common.comm.api.ResultsReceiver;
-import com.metamatrix.common.comm.exception.CommunicationException;
-import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.dqp.internal.cache.CacheResults;
-import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.dqp.message.ResultsMessage;
-import com.metamatrix.query.sql.lang.Command;
-
-public class CachedRequestWorkItem extends RequestWorkItem {
-
- public CachedRequestWorkItem(DQPCore dqpCore, RequestMessage requestMsg, Request request, ResultsReceiver<ResultsMessage> receiver, RequestID requestID, DQPWorkContext workContext, Command originalCommand) {
- super(dqpCore, requestMsg, request, receiver, requestID, workContext);
- this.originalCommand = originalCommand;
- }
-
- @Override
- protected void processNew() throws MetaMatrixComponentException, MetaMatrixProcessingException {
- request.initMetadata();
- request.validateEntitlement(originalCommand);
- this.request = null;
- }
-
- @Override
- protected void processMore() throws SystemException, BlockedException,
- MetaMatrixCoreException {
- //do nothing
- }
-
-
- @Override
- protected void sendResultsIfNeeded(TupleBatch batch)
- throws BlockedOnMemoryException, MetaMatrixComponentException,
- CommunicationException, TupleSourceNotFoundException {
- synchronized (this.resultsCursor) {
- if (!this.resultsCursor.resultsRequested) {
- return;
- }
- }
- CacheResults cResult = rsCache.getResults(cid, new int[] {this.resultsCursor.begin, this.resultsCursor.end});
- List results[] = cResult.getResults();
- int firstRow = cResult.getFirstRow();
-
- ResultsMessage response = createResultsMessage(requestMsg, results, cResult.getElements(), cResult.getAnalysisRecord());
- response.setFirstRow(firstRow);
- response.setLastRow(firstRow + results.length - 1);
-
- boolean isFinal = cResult.isFinal();
- if(isFinal){
- response.setFinalRow(cResult.getFinalRow());
- }
- response.setPartialResults(!isFinal);
-
- this.resultsCursor.resultsSent();
- this.resultsReceiver.receiveResults(response);
- }
-
- @Override
- protected void attemptClose() {
- this.isClosed = true;
- dqpCore.logMMCommand(requestMsg, false, false, -1);
- this.dqpCore.removeRequest(this);
- }
-
-}
\ No newline at end of file
Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/CodeTableCache.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/CodeTableCache.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/CodeTableCache.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,368 +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 com.metamatrix.dqp.internal.process;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.util.LogConstants;
-import com.metamatrix.query.util.CommandContext;
-
-/**
- * Code table cache.
- */
-class CodeTableCache {
-
- // Max number of code tables that can be loaded
- private int maxCodeTables;
-
- // Caches being loaded - key is CacheKey, value is WaitingRequests
- private Map loadingCaches = new HashMap();
-
- // Map of RequestID/nodeID -> CacheKey
- private Map requestToCacheKeyMap = Collections.synchronizedMap(new HashMap());
-
- // Cache itself - key is CacheKey, value is Map (which is the key value -> return value for the code table)
- private Map codeTableCache = new HashMap();
-
- // Cache keys for stuff already in the cache
- private Set cacheKeyDone = new HashSet();
-
- public enum CacheState {
- CACHE_EXISTS,
- CACHE_LOADING,
- CACHE_NOT_EXIST,
- CACHE_OVERLOAD
- }
-
- private AtomicInteger requestSequence = new AtomicInteger();
-
- /**
- * Construct a code table cache
- */
- public CodeTableCache(int maxCodeTables) {
- this.maxCodeTables = maxCodeTables;
- }
-
- /**
- * Return the state of cache.
- * @param codeTable code table name
- * @param returnElement return element name
- * @param keyElement key element name
- * @param context context in processing
- * @param keyValye key value cached in data map
- * @return int of cache states
- */
- public synchronized CacheState cacheExists(String codeTable, String returnElement, String keyElement, CommandContext context) {
- // Check whether CacheKey exist in cacheKeyDone:
- // If yes, return CACHE_EXISTS
- // If no, does it exist in loadingCaches?
- // If yes, add to additional contexts and return CACHE_LOADING
- // If no, can we add another cache?
- // If yes, add to loadingCaches as primary context, return CACHE_NOT_EXIST
- // If no, return CACHE_OVERLOAD
-
- // Create a CacheKey
- CacheKey cacheKey = new CacheKey(codeTable, returnElement, keyElement, context.getVdbName(), context.getVdbVersion());
-
- if (cacheKeyDone.contains(cacheKey)) { // CacheKey exists in codeTableCache
- return CacheState.CACHE_EXISTS;
-
- }
- if (loadingCaches.containsKey(cacheKey)) { // CacheKey exists in loadingCache
- // Add context to additional contexts
- WaitingRequests wqr = (WaitingRequests) loadingCaches.get(cacheKey);
- wqr.addRequestID(context.getProcessorID());
- loadingCaches.put(cacheKey, wqr);
- return CacheState.CACHE_LOADING;
-
- } else if(codeTableCache.size() + loadingCaches.size() >= maxCodeTables) {
- // In this case we already have some number of existing + loading caches
- // that are >= the max number we are allowed to have. Thus, we cannot load
- // another cache.
- return CacheState.CACHE_OVERLOAD;
-
- } else { // CacheKey not exists in loadingCache
- // Add to loadingCaches as primary context
- WaitingRequests wqr = new WaitingRequests(context.getProcessorID());
- loadingCaches.put(cacheKey, wqr);
- return CacheState.CACHE_NOT_EXIST;
- }
- }
-
- /**
- * Set request ID for request key to cache key mapping.
- * <Map: requestKey(requestID, nodeID) --> cacheKey(codeTable, returnElement, keyElement) >
- * @param codeTable Code table name
- * @param returnElement Return element name
- * @param keyElement Key element name
- * @param requestID Request ID
- * @param nodeID Plan Node ID
- */
- public Integer createCacheRequest(String codeTable, String returnElement, String keyElement, CommandContext context) {
- // Create a cache key
- CacheKey cacheKey = new CacheKey(codeTable, returnElement, keyElement, context.getVdbName(), context.getVdbVersion());
- Integer result = this.requestSequence.getAndIncrement();
-
- // Add requestID/nodeID pair to map for later lookup
- requestToCacheKeyMap.put(result, cacheKey);
- return result;
- }
-
- /**
- * Load all rows from the tuple source. Each row contains: keyElement and returnElement.
- * @param requestID Part of RequestKey
- * @param nodeID Part of RequestKey
- * @param results QueryResults of <List<List<keyValue, returnValue>>
- * @throws MetaMatrixProcessingException
- */
- public synchronized void loadTable(Integer requestKey, List[] records) throws MetaMatrixProcessingException {
- // Look up cache key by requestID/nodeID pair
- CacheKey cacheKey = (CacheKey) requestToCacheKeyMap.get(requestKey);
-
- // Lookup the existing data
- // Map of data: keyValue --> returnValue;
- Map existingMap = (Map) codeTableCache.get(cacheKey);
- if(existingMap == null) {
- existingMap = new HashMap();
- codeTableCache.put(cacheKey, existingMap);
- }
-
- // Add data: <List<List<keyValue, returnValue>> from results to the code table cache
- for ( int i = 0; i < records.length; i++ ) {
- // each record or row
- List record = records[i];
- Object keyValue = record.get(0);
- Object returnValue = record.get(1);
- Object existing = existingMap.put(keyValue, returnValue);
- if (existing != null) {
- throw new MetaMatrixProcessingException(DQPPlugin.Util.getString("CodeTableCache.duplicate_key", cacheKey.getCodeTable(), cacheKey.getKeyElement(), keyValue)); //$NON-NLS-1$
- }
- }
- }
-
- /**
- * Look up return value in code table cache given the key value.
- * @param codeTable Code Table name
- * @param returnElement Return element name
- * @param keyElement Key element name
- * @param keyValue Input key value
- * @return Object of return value in code table cache
- */
- public synchronized Object lookupValue(String codeTable, String returnElement, String keyElement, Object keyValue, CommandContext context) throws MetaMatrixComponentException {
- Object returnValue = null;
-
- // Create CacheKey
- CacheKey cacheKey = new CacheKey(codeTable, returnElement, keyElement, context.getVdbName(), context.getVdbVersion());
-
- // Find the corresponding data map in cache for the cache key
- Map dataMap = (Map) codeTableCache.get(cacheKey);
- if(dataMap == null) {
- Object[] params = new Object[] {codeTable,keyElement,returnElement};
- throw new MetaMatrixComponentException(DQPPlugin.Util.getString("CodeTableCache.No_code_table", params)); //$NON-NLS-1$
- }
- returnValue = dataMap.get(keyValue);
- return returnValue;
- }
-
- /**
- * Places the lookup results in the cache and marks the cache loaded
- * @param requestID
- * @param nodeID
- * @return the set of waiting requests
- * @since 4.2
- */
- public Set markCacheLoaded(Integer requestKey) {
- return markCacheDone(requestKey, false);
- }
-
- /**
- * Notifies the CodeTableCache that this code table had an error. Removes any existing cached results and clears any state
- * for this CacheKey.
- * @param requestID
- * @param nodeID
- * @return the set of waiting requests
- * @since 4.2
- */
- public Set errorLoadingCache(Integer requestKey) {
- return markCacheDone(requestKey, true);
- }
-
- private synchronized Set markCacheDone(Integer requestKey, boolean errorOccurred) {
- // Remove request from requestToCacheKeyMap
- CacheKey cacheKey = (CacheKey) requestToCacheKeyMap.remove(requestKey);
- if (errorOccurred) {
- // Remove any results already cached
- codeTableCache.remove(cacheKey);
- } else {
- cacheKeyDone.add(cacheKey);
- }
-
- // Remove cache key from loadingCaches
- WaitingRequests waitingRequests = (WaitingRequests)loadingCaches.remove(cacheKey);
- if (waitingRequests != null) {
- return waitingRequests.getWaitingRequestIDs();
- }
- return null;
- }
-
- public synchronized void clearAll() {
- // Look through the loaded caches and clear them - this is safe because
- // these are done. There is a window where cacheExists() can be called and
- // return CACHE_EXISTS but then clearAll() could be called before lookValue()
- // is called. We accept this as a possibility such that this is a risk when
- // clearing the cache - we need to throw an exception in this case to ensure the
- // query fails (rather than return the wrong result).
-
- // Walk through every key in the done cache and remove it
- int removedTables = 0;
- int removedRecords = 0;
- Iterator keyIter = cacheKeyDone.iterator();
- while(keyIter.hasNext()) {
- CacheKey cacheKey = (CacheKey) keyIter.next();
- Map codeTable = (Map) codeTableCache.remove(cacheKey);
- removedTables++;
- removedRecords += codeTable.size();
- }
-
- // Clear the cacheKeyDone
- cacheKeyDone.clear();
-
- // Log status
- LogManager.logInfo(LogConstants.CTX_DQP, DQPPlugin.Util.getString("CodeTableCache.Cleared_code_tables", new Object[]{new Integer(removedTables), new Integer(removedRecords)})); //$NON-NLS-1$
- }
-
- /**
- * Cache Key consists: codeTable, returnElement and keyElement.
- */
- private static class CacheKey {
- private String codeTable;
- private String returnElement;
- private String keyElement;
- private String vdbName;
- private String vdbVersion;
-
- private int hashCode;
-
- public CacheKey(String codeTable, String returnElement, String keyElement, String vdbName, String vdbVersion) {
- this.codeTable = codeTable;
- this.returnElement = returnElement;
- this.keyElement = keyElement;
- this.vdbName = vdbName;
- this.vdbVersion = vdbVersion;
-
- // Compute hash code and cache it
- hashCode = HashCodeUtil.hashCode(0, codeTable);
- hashCode = HashCodeUtil.hashCode(hashCode, returnElement);
- hashCode = HashCodeUtil.hashCode(hashCode, keyElement);
- hashCode = HashCodeUtil.hashCode(hashCode, vdbName);
- hashCode = HashCodeUtil.hashCode(hashCode, vdbVersion);
- }
-
- public String getCodeTable() {
- return this.codeTable;
- }
-
- public String getReturnElement() {
- return this.returnElement;
- }
-
- public String getKeyElement() {
- return this.keyElement;
- }
-
- public int hashCode() {
- return hashCode;
- }
-
- public boolean equals(Object obj) {
- if(this == obj) {
- return true;
- }
- if(obj instanceof CacheKey) {
- CacheKey other = (CacheKey) obj;
-
- return (other.hashCode() == hashCode() &&
- this.codeTable.equals(other.codeTable) &&
- this.returnElement.equals(other.returnElement) &&
- this.keyElement.equals(other.keyElement) &&
- this.vdbName.equals(other.vdbName) &&
- this.vdbVersion.equals(other.vdbVersion));
- }
- return false;
- }
- }
-
- /**
- * Waiting Requests consist: primary requestID and list of additional waiting requestIDs.
- */
- private static class WaitingRequests {
- Object primaryRequestID;
- Set additionalRequestIDs;
-
- public WaitingRequests(Object requestID) {
- this.primaryRequestID = requestID;
- }
-
- public void addRequestID(Object requestID) {
- if(additionalRequestIDs == null) {
- additionalRequestIDs = new HashSet(8, 0.9f);
- }
- additionalRequestIDs.add(requestID);
- }
-
- /**
- * Return the set of requestIDs for waiting requests.
- * @return Set of waiting requests' IDs
- */
- private Set getWaitingRequestIDs() {
- Set requestIDs = null;
-
- // Waiting Requests can contain both primary and additional context
- if (additionalRequestIDs != null) {
- requestIDs = new HashSet(additionalRequestIDs.size() + 1, 1.0f);
- requestIDs.addAll(additionalRequestIDs);
- } else {
- requestIDs = new HashSet(2, 1.0f);
- }
- if (primaryRequestID != null) {
- requestIDs.add(primaryRequestID);
- }
-
- return requestIDs;
- }
-
- }
-
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/DQPCore.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/DQPCore.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/DQPCore.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,722 +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 com.metamatrix.dqp.internal.process;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.transaction.InvalidTransactionException;
-import javax.transaction.SystemException;
-import javax.transaction.xa.Xid;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.common.application.Application;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.application.DQPConfigSource;
-import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.lob.LobChunk;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.queue.WorkerPool;
-import com.metamatrix.common.queue.WorkerPoolFactory;
-import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.common.xa.MMXid;
-import com.metamatrix.common.xa.XATransactionException;
-import com.metamatrix.core.log.MessageLevel;
-import com.metamatrix.core.util.LRUCache;
-import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.ResourceFinder;
-import com.metamatrix.dqp.client.ClientSideDQP;
-import com.metamatrix.dqp.client.MetadataResult;
-import com.metamatrix.dqp.client.ResultsFuture;
-import com.metamatrix.dqp.internal.cache.CacheID;
-import com.metamatrix.dqp.internal.cache.ResultSetCache;
-import com.metamatrix.dqp.internal.cache.ResultSetCacheUtil;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
-import com.metamatrix.dqp.message.AtomicRequestMessage;
-import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.dqp.message.ResultsMessage;
-import com.metamatrix.dqp.service.BufferService;
-import com.metamatrix.dqp.service.ConfigurationService;
-import com.metamatrix.dqp.service.DQPServiceNames;
-import com.metamatrix.dqp.service.DataService;
-import com.metamatrix.dqp.service.MetadataService;
-import com.metamatrix.dqp.service.TrackingService;
-import com.metamatrix.dqp.service.TransactionService;
-import com.metamatrix.dqp.service.VDBService;
-import com.metamatrix.dqp.spi.TrackerLogConstants;
-import com.metamatrix.dqp.util.LogConstants;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.server.serverapi.RequestInfo;
-import com.metamatrix.vdb.runtime.VDBKey;
-
-/**
- * Implements the core DQP processing.
- */
-public class DQPCore extends Application 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;
- }
- }
-
- //Constants
- private static final int DEFAULT_MAX_CODE_TABLE_RECORDS = 10000;
- private static final int DEFAULT_MAX_CODE_TABLES = 20;
- private static final int DEFAULT_PROCESSOR_TIMESLICE = 2000;
- private static final String PROCESS_PLAN_QUEUE_NAME = "QueryProcessorQueue"; //$NON-NLS-1$
- private static final String DEAFULT_PROCESS_WORKER_TIMEOUT = "120000"; //$NON-NLS-1$
- private static final int DEFAULT_MAX_PROCESS_WORKERS = 15;
-
- // System properties for Code Table
- private int maxCodeTableRecords = DEFAULT_MAX_CODE_TABLE_RECORDS;
- private int maxCodeTables = DEFAULT_MAX_CODE_TABLES;
-
- // Resources
- private ConnectorCapabilitiesCache connectorCapabilitiesCache = new ConnectorCapabilitiesCache();
- private BufferManager bufferManager;
- private DataTierManager dataTierMgr;
- private PreparedPlanCache prepPlanCache;
- private TrackingService tracker;
- private TransactionService transactionService;
- private MetadataService metadataService;
- private ResultSetCache rsCache;
-
- // Query worker pool for processing plans
- private WorkerPool processWorkerPool;
- private int processorTimeslice = DEFAULT_PROCESSOR_TIMESLICE;
- private boolean processDebugAllowed;
-
- private TempTableStoresHolder tempTableStoresHolder;
- private int chunkSize = 0;
-
- private Map<RequestID, RequestWorkItem> requests = Collections.synchronizedMap(new HashMap<RequestID, RequestWorkItem>());
- private Map<String, List<RequestID>> requestsByClients = Collections.synchronizedMap(new HashMap<String, List<RequestID>>());
-
- public DQPCore() {
-
- }
-
- public DQPCore(ApplicationEnvironment environment) {
- this.environment = environment;
- }
-
- /**
- * perform a graceful shutdown by allowing in process work to complete
- * TODO: this is not quite correct from a request perspective, since we need to re-queue in many instances,
- * which will now result in an exception
- * @throws ApplicationLifecycleException
- */
- @Override
- public void stop() throws ApplicationLifecycleException {
- processWorkerPool.shutdown();
- super.stop();
- }
-
- /**
- * Return a list of {@link RequestInfo} for the given session
- */
- public List<RequestInfo> getRequestsByClient(String clientConnection) {
- List<RequestID> ids = this.requestsByClients.get(clientConnection);
-
- return buildRequestInfos(ids);
- }
-
- /**
- * Return a list of all {@link RequestInfo}
- */
- public List<RequestInfo> getRequests() {
- List<RequestID> copies = null;
- synchronized(requests) {
- copies = new ArrayList<RequestID>(requests.keySet());
- }
-
- return buildRequestInfos(copies);
- }
-
- private List<RequestInfo> buildRequestInfos(List<RequestID> ids) {
- if(ids == null) {
- return Collections.emptyList();
- }
- List<RequestInfo> results = new ArrayList<RequestInfo>();
- for (RequestID requestID : ids) {
- RequestWorkItem holder = requests.get(requestID);
-
- if(holder != null && !holder.isCanceled()) {
- RequestInfo req = new RequestInfo(holder.requestID, holder.requestMsg.getCommandString(), holder.requestMsg.getSubmittedTimestamp(), holder.requestMsg.getProcessingTimestamp());
- if (holder.getTransactionContext() != null && holder.getTransactionContext().isInTransaction()) {
- req.setTransactionId(holder.getTransactionContext().getTxnID());
- }
-
- for (DataTierTupleSource conInfo : holder.getConnectorRequests()) {
- ConnectorID connectorID = conInfo.getConnectorId();
-
- if (connectorID == null) {
- continue;
- }
- // If the request has not yet completed processing, then
- // add all the subrequest messages
- AtomicRequestMessage arm = conInfo.getAtomicRequestMessage();
- RequestInfo info = new RequestInfo(arm.getRequestID(), arm.getCommand().toString(), arm.getSubmittedTimestamp(), arm.getProcessingTimestamp());
- info.setConnectorBindingUUID(arm.getConnectorBindingID());
- info.setNodeID(arm.getAtomicRequestID().getNodeID());
- results.add(info);
- }
- results.add(req);
- }
- }
- return results;
- }
-
- public ResultsFuture<ResultsMessage> executeRequest(long reqID,
- RequestMessage requestMsg) {
- logMMCommand(requestMsg, true, false, 0); //TODO: there is no transaction at this point
-
- DQPWorkContext workContext = DQPWorkContext.getWorkContext();
- RequestID requestID = workContext.getRequestID(reqID);
- requestMsg.markProcessingStart();
- Map<String, SourceCapabilities> vdbCapabilties = this.connectorCapabilitiesCache.getVDBConnectorCapabilities(workContext);
-
- Request request = null;
- if ( requestMsg.isPreparedStatement() || requestMsg.isCallableStatement()) {
- request = new PreparedStatementRequest(prepPlanCache);
- } else {
- request = new Request();
- }
- request.initialize(requestMsg, getEnvironment(), bufferManager,
- dataTierMgr, vdbCapabilties, transactionService,
- processDebugAllowed, this.tempTableStoresHolder
- .getTempTableStore(workContext.getConnectionID()),
- workContext, chunkSize);
-
- RequestWorkItem workItem = null;
-
- ResultsFuture<ResultsMessage> resultsFuture = new ResultsFuture<ResultsMessage>();
-
- if (areResultsInCache(requestMsg)) {
- CacheID cID = ResultSetCacheUtil.createCacheID(requestMsg, this.rsCache);
- Command command = this.rsCache.getResults(cID, new int[]{1, 1}).getCommand();
- workItem = new CachedRequestWorkItem(this, requestMsg, request, resultsFuture.getResultsReceiver(), requestID, workContext, command);
- }
- else {
- workItem = new RequestWorkItem(this, requestMsg, request, resultsFuture.getResultsReceiver(), requestID, workContext);
- }
-
- addRequest(requestID, workItem);
-
- this.addWork(workItem);
- return resultsFuture;
- }
-
- public ResultsFuture<ResultsMessage> processCursorRequest(long reqID,
- int batchFirst, int batchLast) throws MetaMatrixProcessingException {
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_DQP, "DQP process cursor request from " + batchFirst + " to " + batchLast); //$NON-NLS-1$//$NON-NLS-2$
- }
- DQPWorkContext workContext = DQPWorkContext.getWorkContext();
- ResultsFuture<ResultsMessage> resultsFuture = new ResultsFuture<ResultsMessage>();
- RequestWorkItem workItem = getRequestWorkItem(workContext.getRequestID(reqID));
- workItem.requestMore(batchFirst, batchLast, resultsFuture.getResultsReceiver());
- return resultsFuture;
- }
-
- void addRequest(RequestID requestID, RequestWorkItem workItem) {
- this.requests.put(requestID, workItem);
- synchronized (requestsByClients) {
- List<RequestID> clientRequests = this.requestsByClients.get(workItem.getDqpWorkContext().getConnectionID());
- if (clientRequests == null) {
- clientRequests = new LinkedList<RequestID>();
- this.requestsByClients.put(workItem.getDqpWorkContext().getConnectionID(), clientRequests);
- }
- clientRequests.add(requestID);
- }
- }
-
- void removeRequest(final RequestWorkItem workItem) {
- this.requests.remove(workItem.requestID);
- synchronized (requestsByClients) {
- List<RequestID> clientRequests = this.requestsByClients.get(workItem.getDqpWorkContext().getConnectionID());
- if (clientRequests != null) {
- clientRequests.remove(workItem.requestID);
- }
- }
- }
-
- boolean areResultsInCache(final RequestMessage requestMsg) {
- if(this.rsCache == null){
- return false;
- }
- if(!requestMsg.useResultSetCache()){
- return false;
- }
- CacheID cID = ResultSetCacheUtil.createCacheID(requestMsg, this.rsCache);
- return rsCache.hasResults(cID);
- }
-
- void addWork(Runnable r) {
- this.processWorkerPool.execute(r);
- }
-
- public ResultsFuture<?> closeLobChunkStream(int lobRequestId,
- long requestId, String streamId)
- throws MetaMatrixProcessingException {
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_DQP, "Request to close the Lob stream with Stream id="+streamId+" instance id="+lobRequestId); //$NON-NLS-1$//$NON-NLS-2$
- }
- DQPWorkContext workContext = DQPWorkContext.getWorkContext();
- RequestWorkItem workItem = getRequestWorkItem(workContext.getRequestID(requestId));
- workItem.removeLobStream(lobRequestId);
- ResultsFuture<Void> resultsFuture = new ResultsFuture<Void>();
- resultsFuture.getResultsReceiver().receiveResults(null);
- return resultsFuture;
- }
-
- public ResultsFuture<LobChunk> requestNextLobChunk(int lobRequestId,
- long requestId, String streamId)
- throws MetaMatrixProcessingException {
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_DQP, "Request for next Lob chunk with Stream id="+streamId+" instance id="+lobRequestId); //$NON-NLS-1$//$NON-NLS-2$
- }
- RequestWorkItem workItem = getRequestWorkItem(DQPWorkContext.getWorkContext().getRequestID(requestId));
- ResultsFuture<LobChunk> resultsFuture = new ResultsFuture<LobChunk>();
- workItem.processLobChunkRequest(streamId, lobRequestId, resultsFuture.getResultsReceiver());
- return resultsFuture;
- }
-
- /**
- * Cancels a node in the request. (This request is called by the
- * client directly using the admin API), so if this does not support
- * partial results then remove the original request.
- * @throws MetaMatrixComponentException
- */
- public void cancelAtomicRequest(RequestID requestID, int nodeID) throws MetaMatrixComponentException {
- RequestWorkItem workItem = safeGetWorkItem(requestID);
- if (workItem == null) {
- return;
- }
- workItem.requestAtomicRequestCancel(nodeID);
- }
-
- RequestWorkItem getRequestWorkItem(RequestID reqID) throws MetaMatrixProcessingException {
- RequestWorkItem result = this.requests.get(reqID);
- if (result == null) {
- throw new MetaMatrixProcessingException(DQPPlugin.Util.getString("DQPCore.The_request_has_been_cancelled.", reqID));//$NON-NLS-1$
- }
- return result;
- }
-
- RequestWorkItem safeGetWorkItem(Object processorID) {
- return this.requests.get((RequestID)processorID);
- }
-
- /**
- * Returns a list of QueueStats objects that represent the queues in
- * this service.
- * If there are no queues, an empty Collection is returned.
- */
- public Collection getQueueStatistics() {
- if ( this.processWorkerPool == null ) {
- return Collections.EMPTY_LIST;
- }
-
- return Arrays.asList(processWorkerPool.getStats());
- }
-
- /**
- * Returns a QueueStats object that represent the queue in
- * this service.
- * If there is no queue with the given name, an empty Collection is returned.
- */
- public Collection getQueueStatistics(String name) {
- if ( !name.equalsIgnoreCase(PROCESS_PLAN_QUEUE_NAME)) {
- return Collections.EMPTY_LIST;
- }
- return getQueueStatistics();
- }
-
- /**
- * Cancel and close all requests associated with the clientConnection/session. Also runs a final cleanup any caches within
- * the session's scope.
- * @param clientConnection
- * @param sendCancellationsToClient Notify the client that each request has been closed.
- * @throws MetaMatrixComponentException
- * @since 4.2
- */
- public void terminateConnection(String sessionId) throws MetaMatrixComponentException {
-
- // sometimes there will not be any atomic requests pending, in that
- // situation we still need to clear the master request from our map
- List<RequestID> requestIds = requestsByClients.get(sessionId);
- if (requestIds != null) {
- synchronized (requestsByClients) {
- requestIds = new ArrayList<RequestID>(requestIds);
- }
- for (RequestID reqId : requestIds) {
- try {
- cancelRequest(reqId);
- } catch (MetaMatrixComponentException err) {
- LogManager.logWarning(LogConstants.CTX_DQP, err, "Failed to cancel " + reqId); //$NON-NLS-1$
- }
- }
- }
-
- // cleanup the buffer manager
- try {
- bufferManager.removeTupleSources(sessionId);
- } catch (Exception e) {
- LogManager.logWarning(LogConstants.CTX_DQP, e, "Failed to remove buffered tuples for connection " + sessionId); //$NON-NLS-1$
- }
- // cleanup the prepared plan cache
- this.prepPlanCache.clear(sessionId);
-
- if (transactionService != null) {
- try {
- transactionService.getTransactionServer().cancelTransactions(sessionId, false);
- } catch (InvalidTransactionException err) {
- LogManager.logWarning(LogConstants.CTX_DQP, "rollback failed for requestID=" + sessionId); //$NON-NLS-1$
- } catch (SystemException err) {
- throw new MetaMatrixComponentException(err);
- }
- }
- }
-
- public boolean cancelRequest(RequestID requestID)
- throws MetaMatrixComponentException {
-
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_DQP, "cancelQuery for requestID=" + requestID); //$NON-NLS-1$
- }
-
- boolean markCancelled = false;
-
- RequestWorkItem workItem = safeGetWorkItem(requestID);
- if (workItem != null) {
- markCancelled = workItem.requestCancel();
- }
- if (markCancelled) {
- logMMCommand(workItem.requestMsg, false, true, 0);
- } else {
- LogManager.logDetail(LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPCore.failed_to_cancel")); //$NON-NLS-1$
- }
- return markCancelled;
- }
-
- public ResultsFuture<?> closeRequest(long requestId) throws MetaMatrixProcessingException {
- DQPWorkContext workContext = DQPWorkContext.getWorkContext();
- closeRequest(workContext.getRequestID(requestId));
- return null;
- }
-
- /**
- * Close the request with given ID
- * @param requestID
- */
- void closeRequest(RequestID requestID) {
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_DQP, "closeQuery for requestID=" + requestID); //$NON-NLS-1$
- }
-
- RequestWorkItem workItem = safeGetWorkItem(requestID);
- if (workItem != null) {
- workItem.requestClose();
- } else {
- LogManager.logDetail(LogConstants.CTX_DQP, requestID + " close call ignored as the request has already been removed."); //$NON-NLS-1$
- }
- }
-
- public void clearPlanCache(){
- LogManager.logInfo(LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPCore.Clearing_prepared_plan_cache")); //$NON-NLS-1$
- this.prepPlanCache.clearAll();
- }
-
- public void clearCodeTableCache(){
- LogManager.logInfo(LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPCore.Clearing_code_table_cache")); //$NON-NLS-1$
- this.dataTierMgr.clearCodeTables();
- }
-
- public void clearResultSetCache() {
- //clear cache in server
- if(rsCache != null){
- rsCache.clear();
- }
- }
-
- void logMMCommand(RequestMessage msg, boolean isBegin, boolean isCancel, int rowCount) {
- if(this.tracker == null || msg == null || !tracker.willRecordMMCmd()){
- return;
- }
- DQPWorkContext workContext = DQPWorkContext.getWorkContext();
- RequestID rID = new RequestID(workContext.getConnectionID(), msg.getExecutionId());
- String command = null;
- String txnID = null;
- if(isBegin && !isCancel){
- command = msg.getCommandString();
- }
- String appName = workContext.getAppName();
- // Log to request log
- short point = isBegin? TrackerLogConstants.CMD_POINT.BEGIN:TrackerLogConstants.CMD_POINT.END;
- short status = TrackerLogConstants.CMD_STATUS.NEW;
- if(!isBegin){
- if(isCancel){
- status = TrackerLogConstants.CMD_STATUS.CANCEL;
- }else{
- status = TrackerLogConstants.CMD_STATUS.END;
- }
- }
- tracker.log(rID.toString(),
- txnID,
- point,
- status,
- workContext.getConnectionID(),
- appName,
- workContext.getUserName(),
- workContext.getVdbName(),
- workContext.getVdbVersion(),
- command,
- rowCount);
- }
-
- DataTierManager getDataTierManager() {
- return this.dataTierMgr;
- }
-
- public void setDataTierManager(DataTierManager dataTierMgr) {
- this.dataTierMgr = dataTierMgr;
- }
-
- BufferManager getBufferManager() {
- return bufferManager;
- }
-
- TrackingService getTracker() {
- return tracker;
- }
-
- TransactionService getTransactionService() {
- return transactionService;
- }
-
- ResultSetCache getRsCache() {
- return rsCache;
- }
-
- int getProcessorTimeSlice() {
- return this.processorTimeslice;
- }
-
- int getChunkSize() {
- return chunkSize;
- }
-
- @Override
- public void start(DQPConfigSource configSource)
- throws ApplicationInitializationException {
- super.start(configSource);
- ConfigurationService cs = (ConfigurationService)this.getEnvironment().findService(DQPServiceNames.CONFIGURATION_SERVICE);
- Properties p = configSource.getProperties();
- if (cs != null) {
- p = cs.getSystemProperties();
- }
- start(p);
- }
-
- public void start(Properties props) {
- ApplicationEnvironment env = this.getEnvironment();
-
- this.chunkSize = PropertiesUtils.getIntProperty(props, DQPConfigSource.STREAMING_BATCH_SIZE, 10) * 1024;
-
- //result set cache
- if(PropertiesUtils.getBooleanProperty(props, DQPConfigSource.USE_RESULTSET_CACHE, false)){
- Properties rsCacheProps = new Properties();
- rsCacheProps.setProperty(ResultSetCache.RS_CACHE_MAX_SIZE, props.getProperty(DQPConfigSource.MAX_RESULTSET_CACHE_SIZE, "0")); //$NON-NLS-1$
- rsCacheProps.setProperty(ResultSetCache.RS_CACHE_MAX_AGE, props.getProperty(DQPConfigSource.MAX_RESULTSET_CACHE_AGE, "0")); //$NON-NLS-1$
- rsCacheProps.setProperty(ResultSetCache.RS_CACHE_SCOPE, props.getProperty(DQPConfigSource.RESULTSET_CACHE_SCOPE, ResultSetCache.RS_CACHE_SCOPE_VDB));
- try {
- this.rsCache = new ResultSetCache(rsCacheProps, ResourceFinder.getCacheFactory());
- } catch (MetaMatrixComponentException e) {
- // this does not really affect the
- //function of DQP, log warning for now
- LogManager.logWarning(LogConstants.CTX_DQP, e, DQPPlugin.Util.getString("DQPCORE.6")); //$NON-NLS-1$
- }
- }
-
- //prepared plan cache
- int maxSizeTotal = PropertiesUtils.getIntProperty(props, DQPConfigSource.MAX_PLAN_CACHE_SIZE, PreparedPlanCache.DEFAULT_MAX_SIZE_TOTAL);
- prepPlanCache = new PreparedPlanCache(maxSizeTotal);
-
- // Processor debug flag
- this.processDebugAllowed = PropertiesUtils.getBooleanProperty(props, DQPConfigSource.PROCESSOR_DEBUG_ALLOWED, false);
- LogManager.logInfo(LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPCore.Processor_debug_allowed_{0}", processDebugAllowed)); //$NON-NLS-1$
-
- this.maxCodeTables = PropertiesUtils.getIntProperty(props, DQPConfigSource.MAX_CODE_TABLES, DEFAULT_MAX_CODE_TABLES);
- this.maxCodeTableRecords = PropertiesUtils.getIntProperty(props, DQPConfigSource.MAX_CODE_TABLE_RECORDS, DEFAULT_MAX_CODE_TABLE_RECORDS);
- this.processorTimeslice = PropertiesUtils.getIntProperty(props, DQPConfigSource.PROCESSOR_TIMESLICE, DEFAULT_PROCESSOR_TIMESLICE);
-
- //get buffer manager
- BufferService bufferService = (BufferService) env.findService(DQPServiceNames.BUFFER_SERVICE);
- bufferManager = bufferService.getBufferManager();
-
- //Get tracking service
- tracker = (TrackingService) env.findService(DQPServiceNames.TRACKING_SERVICE);
- transactionService = (TransactionService )env.findService(DQPServiceNames.TRANSACTION_SERVICE);
- metadataService = (MetadataService) env.findService(DQPServiceNames.METADATA_SERVICE);
-
- // Create the worker pools to tie the queues together
- processWorkerPool = WorkerPoolFactory.newWorkerPool(PROCESS_PLAN_QUEUE_NAME, PropertiesUtils.getIntProperty(props, DQPConfigSource.PROCESS_POOL_MAX_THREADS, DEFAULT_MAX_PROCESS_WORKERS),
- Integer.parseInt(props.getProperty(DQPConfigSource.PROCESS_POOL_THREAD_TTL, DEAFULT_PROCESS_WORKER_TIMEOUT)));
-
- tempTableStoresHolder = new TempTableStoresHolder(bufferManager);
-
- dataTierMgr = new DataTierManagerImpl(this,
- (DataService) env.findService(DQPServiceNames.DATA_SERVICE),
- (MetadataService) env.findService(DQPServiceNames.METADATA_SERVICE),
- (VDBService) env.findService(DQPServiceNames.VDB_SERVICE),
- (BufferService) env.findService(DQPServiceNames.BUFFER_SERVICE),
- this.maxCodeTables,
- this.maxCodeTableRecords);
- }
-
- public List getXmlSchemas(String docName) throws MetaMatrixComponentException,
- QueryMetadataException {
- DQPWorkContext workContext = DQPWorkContext.getWorkContext();
- QueryMetadataInterface metadata = metadataService.lookupMetadata(workContext.getVdbName(), workContext.getVdbVersion());
-
- Object groupID = metadata.getGroupID(docName);
- return metadata.getXMLSchemas(groupID);
- }
-
- public void cancelRequest(long requestID)
- throws MetaMatrixProcessingException, MetaMatrixComponentException {
- DQPWorkContext workContext = DQPWorkContext.getWorkContext();
- this.cancelRequest(workContext.getRequestID(requestID));
- }
-
- public void begin() throws XATransactionException {
- String threadId = DQPWorkContext.getWorkContext().getConnectionID();
- try {
- this.transactionService.getTransactionServer().begin(threadId);
- } catch (SystemException e) {
- throw new XATransactionException(e);
- }
- }
-
- public void commit() throws XATransactionException {
- String threadId = DQPWorkContext.getWorkContext().getConnectionID();
- try {
- this.transactionService.getTransactionServer().commit(threadId);
- } catch (SystemException e) {
- throw new XATransactionException(e);
- }
- }
-
- public void rollback() throws XATransactionException {
- try {
- this.transactionService.getTransactionServer().rollback(
- DQPWorkContext.getWorkContext().getConnectionID());
- } catch (SystemException e) {
- throw new XATransactionException(e);
- }
- }
-
- public void commit(MMXid xid, boolean onePhase)
- throws XATransactionException {
- String threadId = DQPWorkContext.getWorkContext().getConnectionID();
- this.transactionService.getXAServer().commit(threadId, xid, onePhase);
- }
-
- public void end(MMXid xid, int flags) throws XATransactionException {
- String threadId = DQPWorkContext.getWorkContext().getConnectionID();
- this.transactionService.getXAServer().end(threadId, xid, flags);
- }
-
- public void forget(MMXid xid) throws XATransactionException {
- String threadId = DQPWorkContext.getWorkContext().getConnectionID();
- this.transactionService.getXAServer().forget(threadId, xid);
- }
-
- public int prepare(MMXid xid) throws XATransactionException {
- return this.transactionService.getXAServer().prepare(
- DQPWorkContext.getWorkContext().getConnectionID(),
- xid);
- }
-
- public Xid[] recover(int flag) throws XATransactionException {
- return this.transactionService.getXAServer().recover(flag);
- }
-
- public void rollback(MMXid xid) throws XATransactionException {
- this.transactionService.getXAServer().rollback(
- DQPWorkContext.getWorkContext().getConnectionID(),
- xid);
- }
-
- public void start(MMXid xid, int flags, int timeout)
- throws XATransactionException {
- String threadId = DQPWorkContext.getWorkContext().getConnectionID();
- this.transactionService.getXAServer().start(threadId, xid, flags, timeout);
- }
-
- public MetadataResult getMetadata(long requestID)
- throws MetaMatrixComponentException, MetaMatrixProcessingException {
- DQPWorkContext workContext = DQPWorkContext.getWorkContext();
- MetaDataProcessor processor = new MetaDataProcessor(this.metadataService, this, this.prepPlanCache, getEnvironment(), this.tempTableStoresHolder);
- return processor.processMessage(workContext.getRequestID(requestID), workContext, null, true);
- }
-
- public MetadataResult getMetadata(long requestID, String preparedSql,
- boolean allowDoubleQuotedVariable)
- throws MetaMatrixComponentException, MetaMatrixProcessingException {
- DQPWorkContext workContext = DQPWorkContext.getWorkContext();
- MetaDataProcessor processor = new MetaDataProcessor(this.metadataService, this, this.prepPlanCache, getEnvironment(), this.tempTableStoresHolder);
- return processor.processMessage(workContext.getRequestID(requestID), workContext, preparedSql, allowDoubleQuotedVariable);
- }
-
-}
\ No newline at end of file
Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/DQPWorkContext.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/DQPWorkContext.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/DQPWorkContext.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,166 +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 com.metamatrix.dqp.internal.process;
-
-import java.io.Serializable;
-
-import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.SessionToken;
-
-public class DQPWorkContext implements Serializable {
-
- private static final long serialVersionUID = -6389893410233192977L;
-
- private static ThreadLocal<DQPWorkContext> CONTEXTS = new ThreadLocal<DQPWorkContext>() {
- protected DQPWorkContext initialValue() {
- return new DQPWorkContext();
- }
- };
-
- public static DQPWorkContext getWorkContext() {
- return CONTEXTS.get();
- }
-
- public static void setWorkContext(DQPWorkContext context) {
- CONTEXTS.set(context);
- }
-
- private MetaMatrixSessionID sessionId;
- private String userName;
- private Serializable trustedPayload;
- private String vdbName;
- private String vdbVersion;
- private String appName;
- private SessionToken sessionToken;
- private String clientAddress;
- private String clientHostname;
-
- public DQPWorkContext() {
- }
-
- /**
- * @return
- */
- public Serializable getTrustedPayload() {
- return trustedPayload;
- }
-
- /**
- * @return
- */
- public String getUserName() {
- return userName;
- }
-
- /**
- * @return
- */
- public String getVdbName() {
- return vdbName;
- }
-
- /**
- * @return
- */
- public String getVdbVersion() {
- return vdbVersion;
- }
-
- /**
- * @param serializable
- */
- public void setTrustedPayload(Serializable trustedPayload) {
- this.trustedPayload = trustedPayload;
- }
-
- /**
- * @param string
- */
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- /**
- * @param string
- */
- public void setVdbName(String vdbName) {
- this.vdbName = vdbName;
- }
-
- /**
- * @param string
- */
- public void setVdbVersion(String vdbVersion) {
- this.vdbVersion = vdbVersion;
- }
-
- public String getConnectionID() {
- return this.sessionId!=null?this.sessionId.toString():null;
- }
-
- public MetaMatrixSessionID getSessionId() {
- return this.sessionId;
- }
-
- public void setSessionId(MetaMatrixSessionID sessionId) {
- this.sessionId = sessionId;
- }
-
- public void setAppName(String appName) {
- this.appName = appName;
- }
-
- public String getAppName() {
- return appName;
- }
-
- public RequestID getRequestID(long exeuctionId) {
- return new RequestID(this.getConnectionID(), exeuctionId);
- }
-
- public void setSessionToken(SessionToken sessionToken) {
- this.sessionToken = sessionToken;
- }
-
- public SessionToken getSessionToken() {
- return sessionToken;
- }
-
- public void setClientAddress(String clientAddress) {
- this.clientAddress = clientAddress;
- }
-
- public String getClientAddress() {
- return clientAddress;
- }
-
- public void setClientHostname(String clientHostname) {
- this.clientHostname = clientHostname;
- }
-
- public String getClientHostname() {
- return clientHostname;
- }
-
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/DataTierManager.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/DataTierManager.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/DataTierManager.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,31 +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 com.metamatrix.dqp.internal.process;
-
-import com.metamatrix.query.processor.ProcessorDataManager;
-
-public interface DataTierManager extends ProcessorDataManager {
-
- void clearCodeTables();
-
-}
\ No newline at end of file
Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/DataTierManagerImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/DataTierManagerImpl.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/DataTierManagerImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,256 +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 com.metamatrix.dqp.internal.process;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.common.comm.api.ResultsReceiver;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
-import com.metamatrix.dqp.message.AtomicRequestID;
-import com.metamatrix.dqp.message.AtomicRequestMessage;
-import com.metamatrix.dqp.message.AtomicResultsMessage;
-import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.dqp.service.BufferService;
-import com.metamatrix.dqp.service.DataService;
-import com.metamatrix.dqp.service.MetadataService;
-import com.metamatrix.dqp.service.VDBService;
-import com.metamatrix.dqp.util.LogConstants;
-import com.metamatrix.query.processor.QueryProcessor;
-import com.metamatrix.query.sql.ReservedWords;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.util.CommandContext;
-
-public class DataTierManagerImpl implements DataTierManager {
-
- // Resources
- private DQPCore requestMgr;
- private DataService dataService;
- private VDBService vdbService;
- private BufferService bufferService;
-
- // Code table limits
- private int maxCodeTableRecords;
-
- // Processor state
- private CodeTableCache codeTableCache;
-
- public DataTierManagerImpl(DQPCore requestMgr,
- DataService dataService, MetadataService metadataService, VDBService vdbService,
- BufferService bufferService, int maxCodeTables,
- int maxCodeTableRecords) {
-
- this.requestMgr = requestMgr;
- this.dataService = dataService;
- this.vdbService = vdbService;
- this.maxCodeTableRecords = maxCodeTableRecords;
- this.bufferService = bufferService;
-
- this.codeTableCache = new CodeTableCache(maxCodeTables);
- }
-
- public TupleSource registerRequest(Object processorId, Command command,
- String modelName, String connectorBindingId, int nodeID) throws MetaMatrixComponentException, MetaMatrixProcessingException {
- RequestWorkItem workItem = requestMgr.getRequestWorkItem((RequestID)processorId);
- AtomicRequestMessage aqr = createRequest(processorId, command, modelName, connectorBindingId, nodeID);
- DataTierTupleSource tupleSource = new DataTierTupleSource(aqr.getCommand().getProjectedSymbols(), aqr, this, aqr.getConnectorID(), workItem);
- tupleSource.open();
- return tupleSource;
- }
-
- private AtomicRequestMessage createRequest(Object processorId,
- Command command, String modelName, String connectorBindingId, int nodeID)
- throws MetaMatrixProcessingException, MetaMatrixComponentException {
- RequestWorkItem workItem = requestMgr.getRequestWorkItem((RequestID)processorId);
-
- RequestMessage request = workItem.requestMsg;
- // build the atomic request based on original request + context info
- AtomicRequestMessage aqr = new AtomicRequestMessage(request, workItem.getDqpWorkContext(), nodeID);
- aqr.markSubmissionStart();
- aqr.setCommand(command);
- aqr.setModelName(modelName);
- aqr.setUseResultSetCache(request.useResultSetCache());
- aqr.setPartialResults(request.supportsPartialResults());
- if (nodeID >= 0) {
- aqr.setTransactionContext(workItem.getTransactionContext());
- }
- aqr.setFetchSize(this.bufferService.getBufferManager().getConnectorBatchSize());
- if (connectorBindingId == null) {
- List bindings = vdbService.getConnectorBindingNames(workItem.getDqpWorkContext().getVdbName(), workItem.getDqpWorkContext().getVdbVersion(), modelName);
- if (bindings == null || bindings.size() != 1) {
- // this should not happen, but it did occur when setting up the SystemAdmin models
- throw new MetaMatrixComponentException(DQPPlugin.Util.getString("DataTierManager.could_not_obtain_connector_binding", new Object[]{modelName, workItem.getDqpWorkContext().getVdbName(), workItem.getDqpWorkContext().getVdbVersion() })); //$NON-NLS-1$
- }
- connectorBindingId = (String)bindings.get(0);
- Assertion.isNotNull(connectorBindingId, "could not obtain connector id"); //$NON-NLS-1$
- }
- aqr.setConnectorBindingID(connectorBindingId);
- // Select any connector instance for this connector binding
- ConnectorID connectorID = this.dataService.selectConnector(connectorBindingId);
- // if we had this as null before
- aqr.setConnectorID(connectorID);
- return aqr;
- }
-
- String getConnectorName(String connectorBindingID) {
- try {
- return vdbService.getConnectorName(connectorBindingID);
- } catch (MetaMatrixComponentException t) {
- // OK
- }
- return connectorBindingID;
- }
-
- void executeRequest(AtomicRequestMessage aqr, ConnectorID connectorId,
- ResultsReceiver<AtomicResultsMessage> receiver)
- throws MetaMatrixComponentException {
- this.dataService.executeRequest(aqr, connectorId, receiver);
- }
-
- public void closeRequest(AtomicRequestID request, ConnectorID connectorId)
- throws MetaMatrixComponentException {
- this.dataService.closeRequest(request, connectorId);
- }
-
- public void cancelRequest(AtomicRequestID request, ConnectorID connectorId)
- throws MetaMatrixComponentException {
- this.dataService.cancelRequest(request, connectorId);
- }
-
- void requestBatch(AtomicRequestID request, ConnectorID connectorId)
- throws MetaMatrixComponentException {
- this.dataService.requestBatch(request, connectorId);
- }
-
- /**
- * Notify each waiting request that the code table data is now available.
- * @param requests
- * @since 4.2
- */
- private void notifyWaitingCodeTableRequests(Collection requests) {
- if (requests != null) {
- for (Iterator reqIter = requests.iterator(); reqIter.hasNext();) {
- RequestWorkItem workItem = requestMgr.safeGetWorkItem(reqIter.next());
- if (workItem != null) {
- workItem.moreWork();
- }
- }
- }
- }
-
- public Object lookupCodeValue(
- CommandContext context,
- String codeTableName,
- String returnElementName,
- String keyElementName,
- Object keyValue)
- throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
-
- switch (this.codeTableCache.cacheExists(codeTableName, returnElementName, keyElementName, context)) {
- case CACHE_NOT_EXIST:
- registerCodeTableRequest(context, codeTableName, returnElementName, keyElementName);
- case CACHE_EXISTS:
- return this.codeTableCache.lookupValue(codeTableName, returnElementName, keyElementName, keyValue, context);
- case CACHE_OVERLOAD:
- throw new MetaMatrixProcessingException("ERR.018.005.0099", DQPPlugin.Util.getString("ERR.018.005.0099")); //$NON-NLS-1$ //$NON-NLS-2$
- default:
- throw BlockedException.INSTANCE;
- }
- }
-
- void registerCodeTableRequest(
- final CommandContext context,
- final String codeTableName,
- String returnElementName,
- String keyElementName)
- throws MetaMatrixComponentException, MetaMatrixProcessingException {
-
- String query = ReservedWords.SELECT + ' ' + keyElementName + " ," + returnElementName + ' ' + ReservedWords.FROM + ' ' + codeTableName; //$NON-NLS-1$
-
- final Integer codeRequestId = this.codeTableCache.createCacheRequest(codeTableName, returnElementName, keyElementName, context);
-
- boolean success = false;
- QueryProcessor processor = null;
- try {
- processor = context.getQueryProcessorFactory().createQueryProcessor(query, codeTableName.toUpperCase(), context);
-
- processor.setBatchHandler(new QueryProcessor.BatchHandler() {
- @Override
- public void batchProduced(TupleBatch batch)
- throws MetaMatrixCoreException {
- // Determine whether the results should be added to code table cache
- // Depends on size of results and available memory and system parameters
-
- if (batch.getEndRow() > maxCodeTableRecords) {
- throw new MetaMatrixProcessingException("ERR.018.005.0100", DQPPlugin.Util.getString("ERR.018.005.0100", context.getProcessorID(), codeRequestId)); //$NON-NLS-1$ //$NON-NLS-2$
- }
- codeTableCache.loadTable(codeRequestId, batch.getAllTuples());
- }
- });
-
- //process lookup as fully blocking
- processor.process();
- success = true;
- } catch (MetaMatrixProcessingException e) {
- throw e;
- } catch (MetaMatrixComponentException e) {
- throw e;
- } catch (MetaMatrixCoreException e) {
- throw new MetaMatrixComponentException(e);
- } finally {
- Collection requests = null;
- if (success) {
- requests = codeTableCache.markCacheLoaded(codeRequestId);
- } else {
- requests = codeTableCache.errorLoadingCache(codeRequestId);
- }
- notifyWaitingCodeTableRequests(requests);
- if (processor != null) {
- try {
- this.bufferService.getBufferManager().removeTupleSource(processor.getResultsID());
- } catch (MetaMatrixComponentException e1) {
- LogManager.logDetail(LogConstants.CTX_DQP, "Exception closing code table request"); //$NON-NLS-1$
- }
- }
- }
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.dqp.internal.process.DataTierManager#clearCodeTables()
- */
- public void clearCodeTables() {
- this.codeTableCache.clearAll();
- }
-
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/DataTierTupleSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/DataTierTupleSource.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/DataTierTupleSource.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,228 +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 com.metamatrix.dqp.internal.process;
-
-import java.util.List;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.common.comm.api.ResultsReceiver;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.dqp.exception.SourceWarning;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
-import com.metamatrix.dqp.message.AtomicRequestMessage;
-import com.metamatrix.dqp.message.AtomicResultsMessage;
-
-/**
- * This tuple source impl can only be used once; once it is closed, it
- * cannot be reopened and reused.
- */
-public class DataTierTupleSource implements TupleSource, ResultsReceiver<AtomicResultsMessage> {
-
- // Construction state
- private final List schema;
- private final AtomicRequestMessage aqr;
- private final DataTierManagerImpl dataMgr;
- private final ConnectorID connectorId;
- private final RequestWorkItem workItem;
-
- // Data state
- private List[] currentBatch;
- private List[] nextBatch;
- private int currentBatchCount = 0;
- private int index = 0;
- private boolean nextBatchIsLast = false;
- private volatile boolean isLast = false;
- private int rowsProcessed = 0;
- private boolean waitingForData = false;
- private Throwable exception;
- private volatile boolean supportsImplicitClose;
- private volatile boolean isTransactional;
-
- /**
- * Constructor for DataTierTupleSource.
- */
- public DataTierTupleSource(List schema, AtomicRequestMessage aqr, DataTierManagerImpl dataMgr, ConnectorID connectorID, RequestWorkItem workItem) {
- this.schema = schema;
- this.aqr = aqr;
- this.dataMgr = dataMgr;
- this.connectorId = connectorID;
- this.workItem = workItem;
- }
-
- /**
- * @see TupleSource#getSchema()
- */
- public List getSchema() {
- return this.schema;
- }
-
- public List nextTuple() throws MetaMatrixComponentException, MetaMatrixProcessingException {
- if (index < currentBatchCount) {
- return this.currentBatch[index++];
- } else if (isLast) {
- return null;
- } else {
- // We're past the end of the current batch, so switch to the next
- switchBatch();
- // If the new batch is empty
- if (currentBatchCount == 0) {
- if (isLast) {
- return null;
- }
- throw BlockedException.INSTANCE;
- }
- return currentBatch[index++];
- }
- }
-
- public void open() {
- Assertion.isNull(workItem.getConnectorRequest(aqr.getAtomicRequestID()));
- workItem.addConnectorRequest(aqr.getAtomicRequestID(), this);
- synchronized (this) {
- this.waitingForData = true;
- try {
- this.dataMgr.executeRequest(aqr, this.connectorId, this);
- } catch (MetaMatrixComponentException e) {
- exceptionOccurred(e);
- }
- }
- }
-
- /**
- * Switches to the next batch.
- * @throws BlockedException if we're still waiting for data from the connector
- * @throws MetaMatrixComponentException if the request for the next batch failed.
- * @since 4.3
- */
- private synchronized void switchBatch() throws MetaMatrixComponentException, MetaMatrixProcessingException {
- if (exception != null) {
- if (exception instanceof MetaMatrixComponentException) {
- throw (MetaMatrixComponentException)exception;
- }
- if (exception instanceof MetaMatrixProcessingException) {
- throw (MetaMatrixProcessingException)exception;
- }
- throw new MetaMatrixComponentException(exception);
- }
- boolean shouldBlock = true;
- if (nextBatch != null) {
- // Switch the current batch
- this.currentBatch = this.nextBatch;
- this.isLast = this.nextBatchIsLast;
- this.currentBatchCount = this.currentBatch.length;
- this.index = 0;
- this.nextBatch = null;
- shouldBlock = false;
- }
- // Request the next batch immediately
- if (!this.isLast && !waitingForData) {
- this.dataMgr.requestBatch(this.aqr.getAtomicRequestID(), connectorId);
-
- // update waitingForData
- this.waitingForData = true;
- }
- if (shouldBlock) {
- throw BlockedException.INSTANCE;
- }
- }
-
- public void fullyCloseSource() throws MetaMatrixComponentException {
- this.dataMgr.closeRequest(aqr.getAtomicRequestID(), connectorId);
- }
-
- public void cancelRequest() throws MetaMatrixComponentException {
- this.dataMgr.cancelRequest(aqr.getAtomicRequestID(), connectorId);
- }
-
- /**
- * @see TupleSource#closeSource()
- */
- public void closeSource() throws MetaMatrixComponentException {
- if (this.supportsImplicitClose) {
- this.dataMgr.closeRequest(aqr.getAtomicRequestID(), connectorId);
- }
- }
-
- public void exceptionOccurred(Throwable e) {
- synchronized (this) {
- if(workItem.requestMsg.supportsPartialResults()) {
- nextBatch = new List[0];
- nextBatchIsLast = true;
- String connectorBindingName = dataMgr.getConnectorName(aqr.getConnectorBindingID());
- SourceWarning sourceFailure = new SourceWarning(this.aqr.getModelName(), connectorBindingName, e, true);
- workItem.addSourceFailureDetails(sourceFailure);
- } else {
- this.exception = e;
- }
- waitingForData = false;
- }
- workItem.closeAtomicRequest(aqr.getAtomicRequestID());
- this.workItem.moreWork();
- }
-
- public void receiveResults(AtomicResultsMessage response) {
- boolean removeRequest = false;
- synchronized (this) {
- // check to see if this is close of the atomic request message.
- if (response.isRequestClosed()) {
- removeRequest = true;
- } else {
- supportsImplicitClose = response.supportsImplicitClose();
- isTransactional = response.isTransactional();
-
- nextBatch = response.getResults();
- nextBatchIsLast = response.getFinalRow() >= 0;
- rowsProcessed += nextBatch.length;
- }
- // reset waitingForData flag
- waitingForData = false;
- }
- if (response.getWarnings() != null) {
- String connectorBindingName = dataMgr.getConnectorName(aqr.getConnectorBindingID());
- for (Exception warning : response.getWarnings()) {
- SourceWarning sourceFailure = new SourceWarning(this.aqr.getModelName(), connectorBindingName, warning, true);
- workItem.addSourceFailureDetails(sourceFailure);
- }
- }
- if (removeRequest) {
- workItem.closeAtomicRequest(this.aqr.getAtomicRequestID());
- }
- this.workItem.moreWork();
- }
-
- public AtomicRequestMessage getAtomicRequestMessage() {
- return aqr;
- }
-
- public ConnectorID getConnectorId() {
- return connectorId;
- }
-
- public boolean isTransactional() {
- return this.isTransactional;
- }
-
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/LobChunkStream.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/LobChunkStream.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/LobChunkStream.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,95 +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 com.metamatrix.dqp.internal.process;
-
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.sql.SQLException;
-
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.lob.BufferManagerLobChunkStream;
-import com.metamatrix.common.lob.ByteLobChunkStream;
-import com.metamatrix.common.lob.LobChunk;
-import com.metamatrix.common.lob.LobChunkProducer;
-import com.metamatrix.common.lob.ReaderInputStream;
-import com.metamatrix.common.types.BlobType;
-import com.metamatrix.common.types.ClobType;
-import com.metamatrix.common.types.InvalidReferenceException;
-import com.metamatrix.common.types.Streamable;
-import com.metamatrix.common.types.XMLType;
-import com.metamatrix.dqp.DQPPlugin;
-
-/**
- * A Lob Stream builder class. Given the Lob object this object can build
- * an object which can produce a stream lob chunks, which can be sent to the
- * client one by one.
- */
-class LobChunkStream implements LobChunkProducer {
-
- LobChunkProducer internalStream = null;
-
- public LobChunkStream(Streamable streamable, int chunkSize, BufferManager bufferMgr)
- throws IOException {
-
- try {
- if (streamable instanceof XMLType) {
- XMLType xml = (XMLType)streamable;
- this.internalStream = new ByteLobChunkStream(new ReaderInputStream(xml.getCharacterStream(), Charset.forName("UTF-16")), chunkSize); //$NON-NLS-1$
- }
- else if (streamable instanceof ClobType) {
- ClobType clob = (ClobType)streamable;
- this.internalStream = new ByteLobChunkStream(new ReaderInputStream(clob.getCharacterStream(), Charset.forName("UTF-16")), chunkSize); //$NON-NLS-1$
- }
- else if (streamable instanceof BlobType) {
- BlobType blob = (BlobType)streamable;
- this.internalStream = new ByteLobChunkStream(blob.getBinaryStream(), chunkSize);
- }
- } catch (InvalidReferenceException e) {
- // if the lob did not have a persistent id, there is no way for us to re-create the
- // object. so throw an error.
- if (streamable.getPersistenceStreamId() == null) {
- throw new IOException(DQPPlugin.Util.getString("LobStream.noreference")); //$NON-NLS-1$
- }
- // otherwise read directly from the buffer manager.
- this.internalStream = new BufferManagerLobChunkStream(streamable.getPersistenceStreamId(), bufferMgr);
- } catch(SQLException e) {
- IOException ex = new IOException();
- ex.initCause(e);
- throw ex;
- }
- }
-
- /**
- * @see com.metamatrix.common.lob.LobChunkProducer#getNextChunk(int)
- */
- public LobChunk getNextChunk() throws IOException {
- return internalStream.getNextChunk();
- }
-
- /**
- * @see com.metamatrix.common.lob.LobChunkProducer#close()
- */
- public void close() throws IOException {
- internalStream.close();
- }
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/LobWorkItem.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/LobWorkItem.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/LobWorkItem.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,155 +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 com.metamatrix.dqp.internal.process;
-
-import java.io.IOException;
-import java.util.List;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.BlockedOnMemoryException;
-import com.metamatrix.common.buffer.MemoryNotAvailableException;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.buffer.TupleSourceID;
-import com.metamatrix.common.buffer.TupleSourceNotFoundException;
-import com.metamatrix.common.comm.api.ResultsReceiver;
-import com.metamatrix.common.lob.LobChunk;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.types.Streamable;
-import com.metamatrix.common.util.LogContextsUtil.DQPConstants;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.dqp.util.LogConstants;
-
-public class LobWorkItem implements Runnable {
-
- private RequestWorkItem parent;
- private RequestID requestID;
-
- private DQPCore dqpCore;
- private int chunkSize;
-
- /* private work item state */
- private String streamId;
- private LobChunkStream stream;
- private int streamRequestId;
- private ResultsReceiver<LobChunk> resultsReceiver;
-
- public LobWorkItem(RequestWorkItem parent, DQPCore dqpCore, String streamId, int streamRequestId) {
- this.chunkSize = dqpCore.getChunkSize();
- this.dqpCore = dqpCore;
- this.requestID = parent.requestID;
- this.streamId = streamId;
- this.parent = parent;
- this.streamRequestId = streamRequestId;
- }
-
- public void run() {
- LobChunk chunk = null;
- Exception ex = null;
- boolean shouldClose = false;
-
- try {
- // If no previous stream is not found for this request create one and
- // save for future
- if (stream == null) {
- stream = createLobStream(new TupleSourceID(streamId));
- }
-
- // now get the chunk from stream
- chunk = stream.getNextChunk();
- shouldClose = chunk.isLast();
- } catch (BlockedOnMemoryException e) {
- LogManager.logDetail(LogConstants.CTX_DQP, new Object[] {"Reenqueueing LOB chunk request due to lack of available memory ###########", requestID}); //$NON-NLS-1$ //$NON-NLS-2$
- this.dqpCore.addWork(this);
- return;
- } catch (TupleSourceNotFoundException e) {
- LogManager.logWarning(LogConstants.CTX_DQP, e, DQPPlugin.Util.getString("BufferManagerLobChunkStream.no_tuple_source", streamId)); //$NON-NLS-1$
- ex = e;
- } catch (MetaMatrixComponentException e) {
- LogManager.logWarning(LogConstants.CTX_DQP, e, DQPPlugin.Util.getString("ProcessWorker.LobError")); //$NON-NLS-1$
- ex = e;
- } catch (IOException e) {
- ex = e;
- }
-
- synchronized (this) {
- if (ex != null) {
- resultsReceiver.exceptionOccurred(ex);
- shouldClose = true;
- } else {
- resultsReceiver.receiveResults(chunk);
- }
- resultsReceiver = null;
- }
-
- if (shouldClose) {
- try {
- stream.close();
- } catch (IOException e) {
- LogManager.logWarning(LogConstants.CTX_DQP, e, DQPPlugin.Util.getString("ProcessWorker.LobError")); //$NON-NLS-1$
- }
- parent.removeLobStream(streamRequestId);
- }
- }
-
- /**
- * Create a object which can create a sequence of LobChunk objects on a given
- * LOB object
- */
- private LobChunkStream createLobStream(TupleSourceID referenceStreamId)
- throws BlockedOnMemoryException, MetaMatrixComponentException, IOException, TupleSourceNotFoundException {
-
- // get the reference object in the buffer manager, and try to stream off
- // the original sources.
- TupleBatch batch = null;
- try {
- batch = dqpCore.getBufferManager().pinTupleBatch(referenceStreamId, 1, 1);
- List[] tuples = batch.getAllTuples();
-
- if (tuples != null && tuples.length > 0) {
- Object anObj = tuples[0].get(0);
- if (anObj instanceof Streamable) {
- Streamable streamable = (Streamable)anObj;
- return new LobChunkStream(streamable, chunkSize, dqpCore.getBufferManager());
- }
- }
- throw new MetaMatrixComponentException(DQPPlugin.Util.getString("ProcessWorker.wrongdata")); //$NON-NLS-1$
- } catch (MemoryNotAvailableException e) {
- throw BlockedOnMemoryException.INSTANCE;
- } finally {
- try {
- if (batch != null) {
- dqpCore.getBufferManager().unpinTupleBatch(referenceStreamId, batch.getBeginRow(), batch.getEndRow());
- }
- } catch (MetaMatrixComponentException e) {
- LogManager.logDetail(DQPConstants.CTX_DQP, e, "Call to unpin failed during lob stream creation"); //$NON-NLS-1$
- }
- }
- }
-
- synchronized void setResultsReceiver(ResultsReceiver<LobChunk> resultsReceiver) {
- Assertion.isNull(this.resultsReceiver, "Cannot request results with a pending request"); //$NON-NLS-1$
- this.resultsReceiver = resultsReceiver;
- }
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/MetaDataProcessor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/MetaDataProcessor.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/MetaDataProcessor.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,451 +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 com.metamatrix.dqp.internal.process;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.types.XMLType;
-import com.metamatrix.dqp.client.MetadataResult;
-import com.metamatrix.dqp.internal.process.multisource.MultiSourceMetadataWrapper;
-import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.dqp.metadata.ResultsMetadataConstants;
-import com.metamatrix.dqp.metadata.ResultsMetadataDefaults;
-import com.metamatrix.dqp.service.DQPServiceNames;
-import com.metamatrix.dqp.service.MetadataService;
-import com.metamatrix.dqp.service.VDBService;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.SupportConstants;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataStore;
-import com.metamatrix.query.parser.ParseInfo;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.sql.ReservedWords;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.XQuery;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.visitor.ReferenceCollectorVisitor;
-import com.metamatrix.query.tempdata.TempTableStore;
-
-/**
- * Handles MetaDataMessages on behalf of DQPCore.
- */
-public class MetaDataProcessor {
-
-
- // Resources
- private MetadataService metadataService;
- private DQPCore requestManager;
- private QueryMetadataInterface metadata;
- private PreparedPlanCache planCache;
- private ApplicationEnvironment env;
-
- private TempTableStoresHolder tempTableStoresHolder;
- private String vdbName;
- private String vdbVersion;
- private RequestID requestID;
-
- public MetaDataProcessor(MetadataService metadataService, DQPCore requestManager, PreparedPlanCache planCache, ApplicationEnvironment env, TempTableStoresHolder tempTableStoresHolder) {
- this.metadataService = metadataService;
- this.requestManager = requestManager;
- this.planCache = planCache;
- this.env = env;
- this.tempTableStoresHolder = tempTableStoresHolder;
- }
-
- /**
- * Process a metadata request message - this is typically either a request
- * for metadata for a prepared statement or a request for full metadata from
- * an already processed command.
- * @param metadataMsg The message from the client
- * @return The message for the client
- * @throws MetaMatrixComponentException
- * @throws MetaMatrixProcessingException
- */
- MetadataResult processMessage(RequestID requestId, DQPWorkContext workContext, String preparedSql, boolean allowDoubleQuotedVariable) throws MetaMatrixComponentException, MetaMatrixProcessingException {
- final VDBService vdbService = (VDBService)env.findService(DQPServiceNames.VDB_SERVICE);
- this.requestID = requestId;
- this.vdbName = workContext.getVdbName();
- this.vdbVersion = workContext.getVdbVersion();
-
- QueryMetadataInterface md = metadataService.lookupMetadata(vdbName, vdbVersion);
- // Defect 15029 - Use the QueryMetadataWrapper to hide models with private visibility when resolving the command.
- this.metadata = new QueryMetadataWrapper(md, vdbName, vdbVersion, vdbService);
-
- // If multi-source, use the multi-source wrapper as well
- Collection multiModels = vdbService.getMultiSourceModels(vdbName, vdbVersion);
- if(multiModels != null && multiModels.size() > 0) {
- this.metadata = new MultiSourceMetadataWrapper(this.metadata, multiModels);
- }
-
- TempTableStore tempTableStore = null;
- if(tempTableStoresHolder != null) {
- RequestWorkItem workItem = requestManager.safeGetWorkItem(requestID);
- if (workItem != null) {
- tempTableStore = tempTableStoresHolder.getTempTableStore(workContext.getConnectionID());
- }
- }
- if(tempTableStore != null) {
- metadata = new TempMetadataAdapter(this.metadata, tempTableStore.getMetadataStore());
- }
-
- if(preparedSql == null) {
- RequestWorkItem workItem = requestManager.getRequestWorkItem(requestID);
- return getMetadataForCommand(workItem.getOriginalCommand());
- }
- return obtainMetadataForPreparedSql(preparedSql, workContext.getConnectionID(), allowDoubleQuotedVariable);
- }
-
- // For each projected symbol, construct a metadata map
- private MetadataResult getMetadataForCommand(Command originalCommand) throws MetaMatrixComponentException {
- Map[] columnMetadata = null;
-
- switch(originalCommand.getType()) {
- case Command.TYPE_QUERY:
- if(originalCommand instanceof Query) {
- if (((Query)originalCommand).getIsXML()) {
- columnMetadata = new Map[1];
- columnMetadata[0] = createXMLColumnMetadata((Query)originalCommand);
- } else if (((Query)originalCommand).getInto() != null) {
- columnMetadata = createUpdateMetadata();
- } else {
- columnMetadata = createProjectedSymbolMetadata(originalCommand);
- }
- } else {
- columnMetadata = createProjectedSymbolMetadata(originalCommand);
- }
- break;
- case Command.TYPE_STORED_PROCEDURE:
- columnMetadata = createProjectedSymbolMetadata(originalCommand);
- break;
- case Command.TYPE_INSERT:
- case Command.TYPE_UPDATE:
- case Command.TYPE_DELETE:
- case Command.TYPE_CREATE:
- case Command.TYPE_DROP:
- columnMetadata = createUpdateMetadata();
- break;
- case Command.TYPE_XQUERY:
- columnMetadata = new Map[1];
- columnMetadata[0] = createXQueryColumnMetadata((XQuery)originalCommand);
- break;
- default:
- columnMetadata = createProjectedSymbolMetadata(originalCommand);
- }
-
- return new MetadataResult(columnMetadata, ReferenceCollectorVisitor.getReferences(originalCommand).size());
- }
-
- private Map[] createProjectedSymbolMetadata(Command originalCommand) throws MetaMatrixComponentException {
- Map[] columnMetadata;
- // Allow command to use temporary metadata
- Map tempMetadata = originalCommand.getTemporaryMetadata();
- if(tempMetadata != null && tempMetadata.size() > 0) {
- TempMetadataAdapter tempFacade = new TempMetadataAdapter(this.metadata, new TempMetadataStore(tempMetadata));
- this.metadata = tempFacade;
- }
-
- List projectedSymbols = originalCommand.getProjectedSymbols();
- columnMetadata = new Map[projectedSymbols.size()];
-
- Iterator symbolIter = projectedSymbols.iterator();
- for(int i=0; symbolIter.hasNext(); i++) {
- SingleElementSymbol symbol = (SingleElementSymbol) symbolIter.next();
- String shortColumnName = SingleElementSymbol.getShortName(symbol.getOutputName());
- if(symbol instanceof AliasSymbol) {
- symbol = ((AliasSymbol)symbol).getSymbol();
- }
- try {
- columnMetadata[i] = createColumnMetadata(shortColumnName, symbol);
- } catch(QueryMetadataException e) {
- throw new MetaMatrixComponentException(e);
- }
- }
- return columnMetadata;
- }
-
- private MetadataResult obtainMetadataForPreparedSql(String sql, String sessionId, boolean isDoubleQuotedVariablesAllowed) throws QueryParserException, QueryResolverException, MetaMatrixComponentException {
- Command command = null;
-
- PreparedPlanCache.PreparedPlan plan = planCache.getPreparedPlan(sessionId, sql, false);
- if(plan != null) {
- command = plan.getCommand();
- } else {
- QueryParser parser = QueryParser.getQueryParser();
- ParseInfo info = new ParseInfo();
- // Defect 19747 - the parser needs the following connection property to decide whether to treat double-quoted strings as variable names
- info.allowDoubleQuotedVariable = isDoubleQuotedVariablesAllowed;
- command = parser.parseCommand(sql, info);
- QueryResolver.resolveCommand(command, Collections.EMPTY_MAP, false, this.metadata, AnalysisRecord.createNonRecordingRecord());
- }
- return getMetadataForCommand(command);
- }
-
- private Map createXMLColumnMetadata(Query xmlCommand) {
- GroupSymbol doc = (GroupSymbol) xmlCommand.getFrom().getGroups().get(0);
- Map xmlMetadata = getDefaultColumn(vdbName, vdbVersion, doc.getName(), ResultsMetadataDefaults.XML_COLUMN_NAME, XMLType.class);
-
- // Override size as XML may be big
- xmlMetadata.put(ResultsMetadataConstants.DISPLAY_SIZE, ResultsMetadataDefaults.XML_COLUMN_LENGTH);
-
- return xmlMetadata;
- }
-
- private Map createXQueryColumnMetadata(XQuery xqueryCommand) {
- Map xqueryMetadata = getDefaultColumn(vdbName, vdbVersion, null, ResultsMetadataDefaults.XML_COLUMN_NAME, XMLType.class);
-
- // Override size as XML may be big
- xqueryMetadata.put(ResultsMetadataConstants.DISPLAY_SIZE, ResultsMetadataDefaults.XML_COLUMN_LENGTH);
-
- return xqueryMetadata;
- }
-
- private Map createColumnMetadata(String shortColumnName, SingleElementSymbol symbol) throws QueryMetadataException, MetaMatrixComponentException {
- if(symbol instanceof ElementSymbol) {
- return createElementMetadata(shortColumnName, (ElementSymbol) symbol);
- } else if(symbol instanceof AggregateSymbol) {
- return createAggregateMetadata(shortColumnName, (AggregateSymbol) symbol);
- }
- return createTypedMetadata(shortColumnName, symbol);
- }
-
- private Map createElementMetadata(String shortColumnName, ElementSymbol symbol) throws QueryMetadataException, MetaMatrixComponentException {
- Object elementID = symbol.getMetadataID();
-
- Map column = new HashMap();
- column.put(ResultsMetadataConstants.AUTO_INCREMENTING, Boolean.valueOf(metadata.elementSupports(elementID, SupportConstants.Element.AUTO_INCREMENT)));
- column.put(ResultsMetadataConstants.CASE_SENSITIVE, Boolean.valueOf(metadata.elementSupports(elementID, SupportConstants.Element.CASE_SENSITIVE)));
- column.put(ResultsMetadataConstants.CURRENCY, Boolean.FALSE);
- Class type = symbol.getType();
- column.put(ResultsMetadataConstants.DATA_TYPE, DataTypeManager.getDataTypeName(type));
- column.put(ResultsMetadataConstants.ELEMENT_LABEL, shortColumnName);
- column.put(ResultsMetadataConstants.ELEMENT_NAME, shortColumnName);
-
- GroupSymbol group = symbol.getGroupSymbol();
- if(group == null) {
- column.put(ResultsMetadataConstants.GROUP_NAME, null);
- } else {
- column.put(ResultsMetadataConstants.GROUP_NAME, metadata.getFullName(group.getMetadataID()));
- }
-
- boolean allowsNull = metadata.elementSupports(elementID, SupportConstants.Element.NULL);
- boolean unknown = metadata.elementSupports(elementID, SupportConstants.Element.NULL_UNKNOWN);
- Integer nullable = null;
- if(unknown) {
- nullable = ResultsMetadataConstants.NULL_TYPES.UNKNOWN;
- } else {
- if(allowsNull) {
- nullable = ResultsMetadataConstants.NULL_TYPES.NULLABLE;
- } else {
- nullable = ResultsMetadataConstants.NULL_TYPES.NOT_NULL;
- }
- }
- column.put(ResultsMetadataConstants.NULLABLE, nullable);
-
- column.put(ResultsMetadataConstants.RADIX, new Integer(metadata.getRadix(elementID)));
- column.put(ResultsMetadataConstants.SCALE, new Integer(metadata.getScale(elementID)));
-
-
- int precision = getColumnPrecision(type, elementID);
- column.put(ResultsMetadataConstants.PRECISION, new Integer(precision));
- column.put(ResultsMetadataConstants.DISPLAY_SIZE, getColumnDisplaySize(precision, type, elementID));
-
- boolean comparable = metadata.elementSupports(elementID, SupportConstants.Element.SEARCHABLE_COMPARE);
- boolean likable = metadata.elementSupports(elementID, SupportConstants.Element.SEARCHABLE_LIKE);
- Integer searchable = null;
- if(comparable) {
- if(likable) {
- searchable = ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE;
- } else {
- searchable = ResultsMetadataConstants.SEARCH_TYPES.ALLEXCEPTLIKE;
- }
- } else {
- if(likable) {
- searchable = ResultsMetadataConstants.SEARCH_TYPES.LIKE_ONLY;
- } else {
- searchable = ResultsMetadataConstants.SEARCH_TYPES.UNSEARCHABLE;
- }
- }
- column.put(ResultsMetadataConstants.SEARCHABLE, searchable);
-
- column.put(ResultsMetadataConstants.SIGNED, Boolean.valueOf(metadata.elementSupports(elementID, SupportConstants.Element.SIGNED)));
- column.put(ResultsMetadataConstants.VIRTUAL_DATABASE_NAME, vdbName);
- column.put(ResultsMetadataConstants.VIRTUAL_DATABASE_VERSION, vdbVersion);
- column.put(ResultsMetadataConstants.WRITABLE, new Boolean(metadata.elementSupports(elementID, SupportConstants.Element.UPDATE)));
- return column;
- }
-
- private Map createAggregateMetadata(String shortColumnName,
- AggregateSymbol symbol) throws QueryMetadataException, MetaMatrixComponentException {
-
- Expression expression = symbol.getExpression();
- String function = symbol.getAggregateFunction();
- if(function.equals(ReservedWords.MIN) || function.equals(ReservedWords.MAX)){
- if(expression instanceof ElementSymbol) {
- return createColumnMetadata(shortColumnName, (ElementSymbol)expression);
- }
- }
- return createTypedMetadata(shortColumnName, symbol);
- }
-
- private Map createTypedMetadata(String shortColumnName, SingleElementSymbol symbol) {
- return getDefaultColumn(vdbName, vdbVersion, null, shortColumnName, symbol.getType());
- }
-
- private Map[] createUpdateMetadata() {
- Map[] metadata = new Map[1];
- metadata[0] = new HashMap();
- metadata[0].put(ResultsMetadataConstants.AUTO_INCREMENTING, Boolean.FALSE);
- metadata[0].put(ResultsMetadataConstants.CASE_SENSITIVE, Boolean.FALSE);
- metadata[0].put(ResultsMetadataConstants.CURRENCY, Boolean.FALSE);
- metadata[0].put(ResultsMetadataConstants.DATA_TYPE, DataTypeManager.DefaultDataTypes.INTEGER);
- metadata[0].put(ResultsMetadataConstants.DISPLAY_SIZE, ResultsMetadataDefaults.getMaxDisplaySize(DataTypeManager.DefaultDataTypes.INTEGER));
- metadata[0].put(ResultsMetadataConstants.ELEMENT_LABEL, null);
- metadata[0].put(ResultsMetadataConstants.ELEMENT_NAME, ResultsMetadataDefaults.UPDATE_COLUMN);
- metadata[0].put(ResultsMetadataConstants.GROUP_NAME, null);
- metadata[0].put(ResultsMetadataConstants.NULLABLE, ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
- metadata[0].put(ResultsMetadataConstants.PRECISION, ResultsMetadataDefaults.getDefaultPrecision(DataTypeManager.DefaultDataTypes.INTEGER));
- metadata[0].put(ResultsMetadataConstants.RADIX, new Integer(10));
- metadata[0].put(ResultsMetadataConstants.SCALE, new Integer(0));
- metadata[0].put(ResultsMetadataConstants.SEARCHABLE, ResultsMetadataConstants.SEARCH_TYPES.UNSEARCHABLE);
- metadata[0].put(ResultsMetadataConstants.SIGNED, Boolean.TRUE);
- metadata[0].put(ResultsMetadataConstants.WRITABLE, Boolean.FALSE);
- metadata[0].put(ResultsMetadataConstants.VIRTUAL_DATABASE_NAME, vdbName);
- metadata[0].put(ResultsMetadataConstants.VIRTUAL_DATABASE_VERSION, vdbVersion);
- return metadata;
- }
-
- private int getColumnPrecision(Class dataType, Object elementID) throws QueryMetadataException, MetaMatrixComponentException {
- if (!Number.class.isAssignableFrom(dataType)) {
- int length = metadata.getElementLength(elementID);
- if (length > 0) {
- return length;
- }
- } else {
- int precision = metadata.getPrecision(elementID);
- if (precision > 0) {
- return precision;
- }
- }
- return ResultsMetadataDefaults.getDefaultPrecision(dataType).intValue();
- }
-
- /**
- * This method would return the display size of the column to be returned by
- * getColumnDisplaySize() on ResultSetMetaData. This method would return the display
- * size based on the data type of the column.
- *
- * For numeric types, the display size for a numeric column will be equal to the precision of the column
- * plus 1 for the optional - sign plus "1" if the column is decimal to account for the ".".
- *
- * For string types, the display size is the length.
- *
- * @param dataType A string representing the MetaMatrix data type of the column
- * @return An int value giving the displaysize of the column
- */
- private Integer getColumnDisplaySize(int precision, Class dataType, Object elementID) throws QueryMetadataException, MetaMatrixComponentException {
-
- if(elementID != null && dataType.equals(DataTypeManager.DefaultDataClasses.STRING)) {
- int length = metadata.getElementLength(elementID);
- if(length > 0) {
- return new Integer(length);
- }
-
- } else if(Number.class.isAssignableFrom(dataType)) {
- if(precision > 0) {
- int displayLength = precision;
-
- // Add 1 for sign on all numbers
- displayLength = precision+1;
-
- // Add 1 for decimal point for FLOAT, DOUBLE, BIGDECIMAL
- if(dataType.equals(DataTypeManager.DefaultDataClasses.FLOAT) ||
- dataType.equals(DataTypeManager.DefaultDataClasses.DOUBLE) ||
- dataType.equals(DataTypeManager.DefaultDataClasses.BIG_DECIMAL)) {
- displayLength++;
- }
-
- return new Integer(displayLength);
- }
-
- } else if(elementID != null &&
- (dataType.equals(DataTypeManager.DefaultDataClasses.CLOB) ||
- dataType.equals(DataTypeManager.DefaultDataClasses.BLOB) ||
- dataType.equals(DataTypeManager.DefaultDataClasses.OBJECT))) {
-
- int length = metadata.getElementLength(elementID);
- if(length > 0) {
- return new Integer(length);
- }
- }
- // else BOOLEAN, DATE, TIME, TIMESTAMP, CHARACTER use max
- return ResultsMetadataDefaults.getMaxDisplaySize(dataType);
- }
-
- public Map getDefaultColumn(String vdbName, String vdbVersion,
- String tableName, String columnName, Class javaType) {
-
- Map column = new HashMap();
-
- // set defaults
- column.put(ResultsMetadataConstants.VIRTUAL_DATABASE_NAME, vdbName);
- column.put(ResultsMetadataConstants.VIRTUAL_DATABASE_VERSION, vdbVersion);
- column.put(ResultsMetadataConstants.GROUP_NAME, tableName);
- column.put(ResultsMetadataConstants.ELEMENT_NAME, columnName);
- column.put(ResultsMetadataConstants.ELEMENT_LABEL, columnName);
- column.put(ResultsMetadataConstants.AUTO_INCREMENTING, Boolean.FALSE);
- column.put(ResultsMetadataConstants.CASE_SENSITIVE, Boolean.FALSE);
- column.put(ResultsMetadataConstants.NULLABLE, ResultsMetadataConstants.NULL_TYPES.NULLABLE);
- column.put(ResultsMetadataConstants.SEARCHABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE);
- column.put(ResultsMetadataConstants.WRITABLE, Boolean.TRUE);
- column.put(ResultsMetadataConstants.CURRENCY, Boolean.FALSE);
- column.put(ResultsMetadataConstants.DATA_TYPE, DataTypeManager.getDataTypeName(javaType));
- column.put(ResultsMetadataConstants.RADIX, ResultsMetadataDefaults.DEFAULT_RADIX);
- column.put(ResultsMetadataConstants.SCALE, ResultsMetadataDefaults.DEFAULT_SCALE);
- column.put(ResultsMetadataConstants.SIGNED, Boolean.TRUE);
-
- column.put(ResultsMetadataConstants.PRECISION, ResultsMetadataDefaults.getDefaultPrecision(javaType));
- column.put(ResultsMetadataConstants.DISPLAY_SIZE, ResultsMetadataDefaults.getMaxDisplaySize(javaType));
- return column;
- }
-
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/PreparedPlanCache.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/PreparedPlanCache.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/PreparedPlanCache.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,204 +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 com.metamatrix.dqp.internal.process;
-
-import java.util.List;
-
-import com.metamatrix.core.util.ArgCheck;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.core.util.LRUCache;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.sql.lang.Command;
-
-/**
- * This class is used to cahce plan and related objects for prepared statement
- */
-public class PreparedPlanCache {
- public static final int DEFAULT_MAX_SIZE_TOTAL = 100;
-
- private LRUCache cache;
-
- PreparedPlanCache(){
- this(DEFAULT_MAX_SIZE_TOTAL);
- }
-
- PreparedPlanCache (int maxSize ){
- if(maxSize < 0){
- maxSize = DEFAULT_MAX_SIZE_TOTAL;
- }
- cache = new LRUCache(maxSize);
- }
-
- /**
- * Return the PreparedPlan for the given session and SQl query
- * @param session ClientConnection
- * @param sql SQL query string
- * @return PreparedPlan for the given clientConn and SQl query. Null if not exist.
- */
- public synchronized PreparedPlan getPreparedPlan(String sessionId, String sql, boolean isPreparedBatchUpdate){
- ArgCheck.isNotNull(sessionId);
- ArgCheck.isNotNull(sql);
-
- CacheID cID = new CacheID(sessionId, sql, isPreparedBatchUpdate);
-
- return (PreparedPlan)cache.get(cID);
- }
-
- /**
- * Create PreparedPlan for the given clientConn and SQl query
- */
- public synchronized PreparedPlan createPreparedPlan(String sessionId, String sql, boolean isPreparedBatchUpdate){
- ArgCheck.isNotNull(sessionId);
- ArgCheck.isNotNull(sql);
-
- CacheID cID = new CacheID(sessionId, sql, isPreparedBatchUpdate);
- PreparedPlan preparedPlan = (PreparedPlan)cache.get(cID);
- if(preparedPlan == null){
- preparedPlan = new PreparedPlan();
- cache.put(cID, preparedPlan);
- }
- return preparedPlan;
- }
-
- /**
- * Clear the cahced plans for the given clientConn
- * @param clientConn ClientConnection
- */
- public synchronized void clear(String sessionId){
- ArgCheck.isNotNull(sessionId);
- //do not do anything
- }
-
- /**
- * Clear all the cahced plans for all the clientConns
- * @param clientConn ClientConnection
- */
- public synchronized void clearAll(){
- cache.clear();
- }
-
- static class CacheID{
- private String sessionId;
- private String sql;
- int hashCode;
- private boolean isPreparedBatchUpdate;
-
- CacheID(String sessionId, String sql, boolean isPreparedBatchUpdate){
- this.sessionId = sessionId;
- this.sql = sql;
- this.isPreparedBatchUpdate = isPreparedBatchUpdate;
- hashCode = HashCodeUtil.hashCode(HashCodeUtil.hashCode(0, sessionId), sql);
- }
-
- public boolean equals(Object obj){
- if(obj == this) {
- return true;
- } else if(obj == null || ! (obj instanceof CacheID)) {
- return false;
- } else {
- CacheID that = (CacheID)obj;
- return this.sessionId.equals(that.sessionId)
- && this.isPreparedBatchUpdate == that.isPreparedBatchUpdate
- && this.sql.equals(that.sql);
- }
- }
-
- public int hashCode() {
- return hashCode;
- }
- }
-
- static class PreparedPlan{
- private ProcessorPlan plan;
- private Command command;
- private List refs;
- private AnalysisRecord analysisRecord;
-
- /**
- * Return the ProcessorPlan.
- */
- public ProcessorPlan getPlan(){
- return plan;
- }
-
- /**
- * Return the plan description.
- */
- public AnalysisRecord getAnalysisRecord(){
- return this.analysisRecord;
- }
-
- /**
- * Return the Command .
- */
- public Command getCommand(){
- return command;
- }
-
- /**
- * Return the list of Reference.
- */
- public List getReferences(){
- return refs;
- }
-
- /**
- * Set the ProcessorPlan.
- */
- public void setPlan(ProcessorPlan planValue){
- plan = planValue;
- }
-
- /**
- * Set the plan description.
- */
- public void setAnalysisRecord(AnalysisRecord analysisRecord){
- this.analysisRecord = analysisRecord;
- }
-
- /**
- * Set the Command.
- */
- public void setCommand(Command commandValue){
- command = commandValue;
- }
-
- /**
- * Set the list of Reference.
- */
- public void setReferences(List refsValue){
- refs = refsValue;
- }
-
- }
-
- //for testing purpose
- int getSpaceUsed() {
- return cache.size();
- }
- int getSpaceAllowed() {
- return cache.getSpaceLimit();
- }
-
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/PreparedStatementRequest.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/PreparedStatementRequest.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/PreparedStatementRequest.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,236 +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 com.metamatrix.dqp.internal.process;
-
-import java.util.Iterator;
-import java.util.List;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.api.exception.query.QueryValidatorException;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.util.LogConstants;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.eval.Evaluator;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.PreparedBatchUpdate;
-import com.metamatrix.query.sql.lang.SPParameter;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Reference;
-
-/**
- * Specific request for handling prepared statement calls.
- */
-public class PreparedStatementRequest extends Request {
- private PreparedPlanCache prepPlanCache;
- private PreparedPlanCache.PreparedPlan prepPlan;
-
- public PreparedStatementRequest(PreparedPlanCache prepPlanCache) {
- this.prepPlanCache = prepPlanCache;
- }
-
- @Override
- protected void checkReferences(List references)
- throws QueryValidatorException {
- //do nothing - references are allowed
- }
-
- /**
- * @see com.metamatrix.dqp.internal.process.Request#resolveCommand(com.metamatrix.query.sql.lang.Command)
- */
- protected void resolveCommand(Command command, List references) throws QueryResolverException,
- MetaMatrixComponentException {
-
- handleCallableStatement(command, references);
-
- super.resolveCommand(command, references);
-
- if(requestMsg.isPreparedBatchUpdate()){
- ((PreparedBatchUpdate)command).setParameterReferences(references);
- }
- //save the command in it's present form so that it can be validated later
- prepPlan.setCommand((Command) command.clone());
- prepPlan.setReferences(references);
- }
-
- /**
- * TODO: this is a hack that maintains pre 5.6 behavior, which ignores output parameters for resolving
- * @param command
- * @param references
- */
- private void handleCallableStatement(Command command, List references) {
- if (!this.requestMsg.isCallableStatement() || !(command instanceof StoredProcedure)) {
- return;
- }
- StoredProcedure proc = (StoredProcedure)command;
- if (!proc.isCallableStatement()) {
- return;
- }
- List values = requestMsg.getParameterValues();
- List spParams = proc.getParameters();
- proc.clearParameters();
- int inParameterCount = values.size();
- if (this.requestMsg.isPreparedBatchUpdate() && values.size() > 0) {
- inParameterCount = ((List)values.get(0)).size();
- }
- int index = 1;
- for (Iterator params = spParams.iterator(); params.hasNext();) {
- SPParameter param = (SPParameter) params.next();
- if (param.getParameterType() == SPParameter.RETURN_VALUE) {
- continue;
- }
- if (param.getExpression() instanceof Reference && index > inParameterCount) {
- //assume it's an output parameter
- references.remove(param.getExpression());
- continue;
- }
- param.setIndex(index++);
- proc.setParameter(param);
- }
- }
-
- protected void resolveParameterValues() throws QueryResolverException, MetaMatrixComponentException {
- List params = prepPlan.getReferences();
- List values = requestMsg.getParameterValues();
- if(requestMsg.isPreparedBatchUpdate()){
- if(values.size() > 1){
- ((PreparedBatchUpdate)command).setUpdatingModelCount(2);
- }
- for(int i=0; i<values.size(); i++){
- if (params.size() != ((List)values.get(i)).size()) {
- String msg = DQPPlugin.Util.getString("DQPCore.wrong_number_of_values", new Object[] {new Integer(values.size()), new Integer(params.size())}); //$NON-NLS-1$
- throw new QueryResolverException(msg);
- }
- }
- } else {
- PreparedStatementRequest.resolveParameterValues(params, values);
- }
- }
-
- @Override
- protected void validateQueryValues(Command command)
- throws QueryValidatorException, MetaMatrixComponentException {
- //do nothing initially - check after parameter values have been set
- }
-
- /**
- * @throws MetaMatrixComponentException
- * @throws QueryValidatorException
- * @throws QueryResolverException
- * @throws QueryParserException
- * @throws QueryPlannerException
- * @see com.metamatrix.dqp.internal.process.Request#generatePlan()
- */
- protected void generatePlan() throws QueryPlannerException, QueryParserException, QueryResolverException, QueryValidatorException, MetaMatrixComponentException {
-
- String sqlQuery = requestMsg.getCommands()[0];
- prepPlan = prepPlanCache.getPreparedPlan(this.workContext.getConnectionID(), sqlQuery, requestMsg.isPreparedBatchUpdate());
- if (prepPlan == null) {
- //if prepared plan does not exist, create one
- prepPlan = prepPlanCache.createPreparedPlan(this.workContext.getConnectionID(), sqlQuery, requestMsg.isPreparedBatchUpdate());
- LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Query does not exist in cache: ", sqlQuery}); //$NON-NLS-1$
- }
-
- ProcessorPlan cachedPlan = prepPlan.getPlan();
- Command command = prepPlan.getCommand();
-
- if (cachedPlan == null) {
- super.generatePlan();
-
- if (!this.addedLimit) { //TODO: this is a little problematic
- // Defect 13751: Clone the plan in its current state (i.e. before processing) so that it can be used for later queries
- prepPlan.setPlan((ProcessorPlan)processPlan.clone());
- prepPlan.setAnalysisRecord(analysisRecord);
- }
- command = prepPlan.getCommand();
- } else {
- LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Query exist in cache: ", sqlQuery }); //$NON-NLS-1$
- processPlan = (ProcessorPlan)cachedPlan.clone();
- //already in cache. obtain the values from cache
- analysisRecord = prepPlan.getAnalysisRecord();
-
- this.command = command;
- createCommandContext(command);
- }
-
- // validate parameters values - right number and right type
- resolveParameterValues();
- // call back to Request.validateQueryValues to ensure that bound references are valid
- super.validateQueryValues(command);
- }
-
- /**
- * @param params
- * @param values
- * @throws QueryResolverException
- */
- public static void resolveParameterValues(List params,
- List values) throws QueryResolverException, MetaMatrixComponentException {
- //the size of the values must be the same as that of the parameters
- if (params.size() != values.size()) {
- String msg = QueryPlugin.Util.getString("QueryUtil.wrong_number_of_values", new Object[] {new Integer(values.size()), new Integer(params.size())}); //$NON-NLS-1$
- throw new QueryResolverException(msg);
- }
-
- if (params.isEmpty()) {
- return;
- }
-
- //the type must be the same, or the type of the value can be implicitly converted
- //to that of the reference
- for (int i = 0; i < params.size(); i++) {
- Reference param = (Reference) params.get(i);
- Object value = values.get(i);
-
- //TODO: why is the list check in here
- if(value != null && !(value instanceof List)) {
- try {
- String targetTypeName = DataTypeManager.getDataTypeName(param.getType());
- Expression expr = ResolverUtil.convertExpression(new Constant(value), targetTypeName);
- value = Evaluator.evaluate(expr);
- } catch (ExpressionEvaluationException e) {
- String msg = QueryPlugin.Util.getString("QueryUtil.Error_executing_conversion_function_to_convert_value", new Integer(i + 1), value, DataTypeManager.getDataTypeName(param.getType())); //$NON-NLS-1$
- throw new QueryResolverException(msg);
- } catch (QueryResolverException e) {
- String msg = QueryPlugin.Util.getString("QueryUtil.Error_executing_conversion_function_to_convert_value", new Integer(i + 1), value, DataTypeManager.getDataTypeName(param.getType())); //$NON-NLS-1$
- throw new QueryResolverException(msg);
- }
- }
-
- // Create with expected type if null
- Constant constant = new Constant(value, param.getType());
-
- //bind variable
- param.setExpression(constant);
- }
- }
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/QueryMetadataWrapper.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/QueryMetadataWrapper.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/QueryMetadataWrapper.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,88 +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 com.metamatrix.dqp.internal.process;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.common.vdb.api.ModelInfo;
-import com.metamatrix.dqp.service.VDBService;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.BasicQueryMetadataWrapper;
-
-/**
- * This classs is a proxy to QueryMetadataInterface. It knows VDBService
- * and VNB name.
- */
-public class QueryMetadataWrapper extends BasicQueryMetadataWrapper{
- private String vdbName;
- private String vdbVersion;
- private VDBService vdbService;
-
- public QueryMetadataWrapper(QueryMetadataInterface actualMetadata, String vdbName, String vdbVersion, VDBService vdbService){
- super(actualMetadata);
- this.vdbName = vdbName;
- this.vdbService = vdbService;
- this.vdbVersion = vdbVersion;
- }
-
- protected QueryMetadataInterface getActualMetadata() {
- return this.actualMetadata;
- }
- protected String getVdbName() {
- return this.vdbName;
- }
- protected VDBService getVdbService() {
- return this.vdbService;
- }
- protected String getVdbVersion() {
- return this.vdbVersion;
- }
-
- /**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getGroupsForPartialName(java.lang.String)
- */
- public Collection getGroupsForPartialName(String partialGroupName) throws MetaMatrixComponentException, QueryMetadataException {
- Collection result = actualMetadata.getGroupsForPartialName(partialGroupName);
- if(result == null || result.isEmpty()){
- return result;
- }
- Collection filteredResult = new HashSet();
- Iterator iter = result.iterator();
- while(iter.hasNext()){
- String groupName = (String)iter.next();
- Object groupID = actualMetadata.getGroupID(groupName);
- Object modelID = actualMetadata.getModelID(groupID);
- String modelName = actualMetadata.getFullName(modelID);
- int visibility = vdbService.getModelVisibility(vdbName, vdbVersion, modelName);
- if(visibility == ModelInfo.PUBLIC){
- filteredResult.add(groupName);
- }
- }
- return filteredResult;
- }
-
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/Request.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/Request.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/Request.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,676 +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 com.metamatrix.dqp.internal.process;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import javax.transaction.SystemException;
-
-import org.teiid.connector.xa.api.TransactionContext;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.api.exception.query.QueryValidatorException;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.TupleSourceID;
-import com.metamatrix.common.buffer.BufferManager.TupleSourceType;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.xa.XATransactionException;
-import com.metamatrix.core.id.IDGenerator;
-import com.metamatrix.core.id.IntegerIDFactory;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.internal.process.capabilities.ConnectorCapabilitiesFinder;
-import com.metamatrix.dqp.internal.process.capabilities.SharedCachedFinder;
-import com.metamatrix.dqp.internal.process.multisource.MultiSourceCapabilitiesFinder;
-import com.metamatrix.dqp.internal.process.multisource.MultiSourceMetadataWrapper;
-import com.metamatrix.dqp.internal.process.multisource.MultiSourcePlanToProcessConverter;
-import com.metamatrix.dqp.internal.process.validator.AuthorizationValidationVisitor;
-import com.metamatrix.dqp.internal.process.validator.ModelVisibilityValidationVisitor;
-import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.dqp.service.AuthorizationService;
-import com.metamatrix.dqp.service.DQPServiceNames;
-import com.metamatrix.dqp.service.DataService;
-import com.metamatrix.dqp.service.MetadataService;
-import com.metamatrix.dqp.service.TransactionService;
-import com.metamatrix.dqp.service.VDBService;
-import com.metamatrix.dqp.util.LogConstants;
-import com.metamatrix.jdbc.api.ExecutionProperties;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.eval.SecurityFunctionEvaluator;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataStore;
-import com.metamatrix.query.optimizer.QueryOptimizer;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.parser.ParseInfo;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.QueryProcessor;
-import com.metamatrix.query.processor.TempTableDataManager;
-import com.metamatrix.query.processor.xml.XMLPlan;
-import com.metamatrix.query.processor.xquery.XQueryPlan;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.lang.BatchedUpdateCommand;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Limit;
-import com.metamatrix.query.sql.lang.Option;
-import com.metamatrix.query.sql.lang.QueryCommand;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.lang.XQuery;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.visitor.ReferenceCollectorVisitor;
-import com.metamatrix.query.tempdata.TempTableStore;
-import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.util.ContextProperties;
-import com.metamatrix.query.util.TypeRetrievalUtil;
-import com.metamatrix.query.validator.AbstractValidationVisitor;
-import com.metamatrix.query.validator.ValidationVisitor;
-import com.metamatrix.query.validator.Validator;
-import com.metamatrix.query.validator.ValidatorFailure;
-import com.metamatrix.query.validator.ValidatorReport;
-import com.metamatrix.query.validator.ValueValidationVisitor;
-
-/**
- * Server side representation of the RequestMessage. Knows how to process itself.
- */
-public class Request implements QueryProcessor.ProcessorFactory {
-
- // init state
- protected RequestMessage requestMsg;
- private String vdbName;
- private String vdbVersion;
- private ApplicationEnvironment env;
- private VDBService vdbService;
- private BufferManager bufferManager;
- private ProcessorDataManager processorDataManager;
- private TransactionService transactionService;
- private TempTableStore tempTableStore;
- private IDGenerator idGenerator = new IDGenerator();
- private boolean procDebugAllowed = false;
- private Map connectorCapabilitiesCache;
- DQPWorkContext workContext;
- RequestID requestId;
-
- // acquired state
- private CapabilitiesFinder capabilitiesFinder;
- private QueryMetadataInterface metadata;
- private Set multiSourceModels;
-
- // internal results
- protected boolean addedLimit;
- protected ProcessorPlan processPlan;
- // external results
- protected AnalysisRecord analysisRecord;
- protected CommandContext context;
- protected QueryProcessor processor;
- protected List schemas;
-
- protected TransactionContext transactionContext;
-
- private int chunkSize;
-
- protected Command command;
-
- void initialize(RequestMessage requestMsg,
- ApplicationEnvironment env,
- BufferManager bufferManager,
- ProcessorDataManager processorDataManager,
- Map connectorCapabilitiesCache,
- TransactionService transactionService,
- boolean procDebugAllowed,
- TempTableStore tempTableStore,
- DQPWorkContext workContext,
- int chunckSize) {
-
- this.requestMsg = requestMsg;
- this.vdbName = workContext.getVdbName();
- this.vdbVersion = workContext.getVdbVersion();
- this.env = env;
- this.vdbService = (VDBService) env.findService(DQPServiceNames.VDB_SERVICE);
- this.bufferManager = bufferManager;
- this.processorDataManager = processorDataManager;
- 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());
- this.chunkSize = chunckSize;
- }
-
- void setMetadata(CapabilitiesFinder capabilitiesFinder, QueryMetadataInterface metadata, Set multiSourceModels) {
- this.capabilitiesFinder = capabilitiesFinder;
- this.metadata = metadata;
- this.multiSourceModels = multiSourceModels;
- }
-
- /**
- * if the metadata has not been supplied via setMetadata, this method will create the appropriate state
- *
- * @throws MetaMatrixComponentException
- */
- protected void initMetadata() throws MetaMatrixComponentException {
- if (this.metadata != null) {
- return;
- }
- // Prepare dependencies for running the optimizer
- CapabilitiesFinder baseFinder =
- new ConnectorCapabilitiesFinder(
- this.vdbService,
- (DataService) this.env.findService(DQPServiceNames.DATA_SERVICE),
- requestMsg, workContext);
-
- // Wrap the finder with a cache
- this.capabilitiesFinder = new SharedCachedFinder(baseFinder, connectorCapabilitiesCache);
-
- MetadataService metadataService = (MetadataService) this.env.findService(DQPServiceNames.METADATA_SERVICE);
- if(metadataService == null){
- //should not come here. Per defect 15087,
- //in a rare situation it might be null
- //try to get it again
- metadataService = (MetadataService) this.env.findService(DQPServiceNames.METADATA_SERVICE);
- if(metadataService == null){
- String msg = DQPPlugin.Util.getString("Request.MetadataServiceIsNull"); //$NON-NLS-1$
- throw new MetaMatrixComponentException(msg);
- }
- }
- metadata = metadataService.lookupMetadata(vdbName, vdbVersion);
-
- if (metadata == null) {
- Object[] params = new Object[] { this.vdbName, this.vdbVersion };
- String msg = DQPPlugin.Util.getString("DQPCore.Unable_to_load_metadata_for_VDB_name__{0},_version__{1}", params); //$NON-NLS-1$
- MetaMatrixComponentException e = new MetaMatrixComponentException(msg);
- throw e;
- }
-
- this.metadata = new TempMetadataAdapter(metadata, new TempMetadataStore());
-
- //wrap metadata in the wrapper that knows VDBService
- this.metadata = new QueryMetadataWrapper(this.metadata, this.vdbName, this.vdbVersion, this.vdbService);
-
- // Check for multi-source models and further wrap the metadata interface
- List multiSourceModelList = vdbService.getMultiSourceModels(this.vdbName, this.vdbVersion);
- if(multiSourceModelList != null && multiSourceModelList.size() > 0) {
- this.multiSourceModels = new HashSet(multiSourceModelList);
- this.metadata = new MultiSourceMetadataWrapper(this.metadata, this.multiSourceModels);
- }
- }
-
- protected void createCommandContext(Command command) {
- // Create command context, used in rewriting, planning, and processing
- // Identifies a "group" of requests on a per-connection basis to allow later
- // cleanup of all resources in the group on connection shutdown
- String groupName = workContext.getConnectionID();
-
- RequestID reqID = workContext.getRequestID(this.requestMsg.getExecutionId());
-
- Properties props = new Properties();
- props.setProperty(ContextProperties.SESSION_ID, workContext.getConnectionID());
-
- this.context =
- new CommandContext(
- reqID,
- groupName,
- null,
- requestMsg.getFetchSize(),
- workContext.getUserName(),
- workContext.getTrustedPayload(),
- requestMsg.getExecutionPayload(),
- workContext.getVdbName(),
- workContext.getVdbVersion(),
- props,
- useProcDebug(command),
- collectNodeStatistics(command));
- this.context.setProcessorBatchSize(bufferManager.getProcessorBatchSize());
- this.context.setConnectorBatchSize(bufferManager.getConnectorBatchSize());
- this.context.setStreamingBatchSize(chunkSize);
-
- if (multiSourceModels != null) {
- MultiSourcePlanToProcessConverter modifier = new MultiSourcePlanToProcessConverter(
- metadata, idGenerator, analysisRecord, capabilitiesFinder,
- multiSourceModels, vdbName, vdbService, vdbVersion);
- context.setPlanToProcessConverter(modifier);
- }
-
- context.setSecurityFunctionEvaluator((SecurityFunctionEvaluator)this.env.findService(DQPServiceNames.AUTHORIZATION_SERVICE));
- if(requestMsg.isPreparedBatchUpdate()){
- context.setPreparedBatchUpdateValues(requestMsg.getParameterValues());
- }
- context.setTempTableStore(tempTableStore);
- context.setQueryProcessorFactory(this);
- }
-
- /**
- * Side effects:
- * creates the analysis record
- * creates the command context
- * sets the pre-rewrite command on the request
- * adds a limit clause if the row limit is specified
- *
- * @return the post rewrite query
- * @throws QueryParserException
- * @throws QueryResolverException
- * @throws QueryValidatorException
- * @throws MetaMatrixComponentException
- */
- protected Command prepareCommand() throws QueryParserException,
- QueryResolverException,
- QueryValidatorException,
- MetaMatrixComponentException {
-
- Command command = getCommand();
-
- List references = ReferenceCollectorVisitor.getReferences(command);
-
- //there should be no reference (?) for query/update executed as statement
- checkReferences(references);
-
- createAnalysisRecord(command);
-
- resolveCommand(command, references);
-
- createCommandContext(command);
-
- validateQuery(command, true);
-
- validateQueryValues(command);
-
- Command preRewrite = command;
-
- command = QueryRewriter.rewrite(command, null, metadata, context);
-
- /*
- * Adds a row limit to a query if Statement.setMaxRows has been called and the command
- * doesn't already have a limit clause.
- */
- if (requestMsg.getRowLimit() > 0 && command instanceof QueryCommand) {
- QueryCommand query = (QueryCommand)command;
- if (query.getLimit() == null) {
- query.setLimit(new Limit(null, new Constant(new Integer(requestMsg.getRowLimit()), DataTypeManager.DefaultDataClasses.INTEGER)));
- this.addedLimit = true;
- }
- }
-
- this.command = preRewrite;
- return command;
- }
-
- protected void checkReferences(List references) throws QueryValidatorException {
- referenceCheck(references);
- }
-
- static void referenceCheck(List references) throws QueryValidatorException {
- if (references != null && !references.isEmpty()) {
- throw new QueryValidatorException(DQPPlugin.Util.getString("Request.Invalid_character_in_query")); //$NON-NLS-1$
- }
- }
-
- protected void resolveCommand(Command command, List references) throws QueryResolverException, MetaMatrixComponentException {
- if (this.tempTableStore != null) {
- QueryResolver.setChildMetadata(command, tempTableStore.getMetadataStore().getData(), null);
- }
-
- QueryResolver.resolveCommand(command, metadata, analysisRecord);
- }
-
- private void validateQuery(Command command, boolean validateVisibility)
- throws QueryValidatorException, MetaMatrixComponentException {
-
- // Create generic sql validation visitor
- AbstractValidationVisitor visitor = new ValidationVisitor();
- validateWithVisitor(visitor, metadata, command, false);
-
- if (validateVisibility) {
- // Create model visibility validation visitor
- visitor = new ModelVisibilityValidationVisitor(this.vdbService, this.vdbName, this.vdbVersion);
- validateWithVisitor(visitor, metadata, command, true);
- }
- }
-
- protected void validateQueryValues(Command command)
- throws QueryValidatorException, MetaMatrixComponentException {
-
- AbstractValidationVisitor visitor = new ValueValidationVisitor();
- validateWithVisitor(visitor, metadata, command, false);
- }
-
- private Command getCommand() throws QueryParserException {
- String[] commands = requestMsg.getCommands();
- ParseInfo parseInfo = new ParseInfo();
- if (requestMsg.isDoubleQuotedVariableAllowed()) {
- parseInfo.allowDoubleQuotedVariable = true;
- }
- if (!requestMsg.isBatchedUpdate()) {
- String commandStr = commands[0];
- return QueryParser.getQueryParser().parseCommand(commandStr, parseInfo);
- }
- List parsedCommands = new ArrayList(commands.length);
- for (int i = 0; i < commands.length; i++) {
- String updateCommand = commands[i];
- parsedCommands.add(QueryParser.getQueryParser().parseCommand(updateCommand, parseInfo));
- }
- return new BatchedUpdateCommand(parsedCommands);
- }
-
- public static void validateWithVisitor(
- AbstractValidationVisitor visitor,
- QueryMetadataInterface metadata,
- Command command,
- boolean validateOnlyEmbedded)
- throws QueryValidatorException, MetaMatrixComponentException {
-
- // Validate with visitor
- ValidatorReport report = Validator.validate(command, metadata, visitor, validateOnlyEmbedded);
- if (report.hasItems()) {
- ValidatorFailure firstFailure = (ValidatorFailure) report.getItems().iterator().next();
- throw new QueryValidatorException(firstFailure.getMessage());
- }
- }
-
- protected void createProcessor() throws MetaMatrixComponentException {
-
- TransactionContext tc = null;
-
- if (transactionService != null) {
- tc = transactionService.getTransactionServer().getOrCreateTransactionContext(workContext.getConnectionID());
- }
-
- if (tc != null){
- Assertion.assertTrue(tc.getTransactionType() != TransactionContext.Scope.TRANSACTION_REQUEST, "Transaction already associated with request."); //$NON-NLS-1$
- }
-
- if (tc == null || !tc.isInTransaction()) {
- //if not under a transaction
-
- boolean startAutoWrapTxn = false;
-
- if(ExecutionProperties.AUTO_WRAP_ON.equals(requestMsg.getTxnAutoWrapMode())){
- startAutoWrapTxn = true;
- } else if ( command.updatingModelCount(metadata) > 1) {
- if (ExecutionProperties.AUTO_WRAP_OPTIMISTIC.equals(requestMsg.getTxnAutoWrapMode())){
- String msg = DQPPlugin.Util.getString("Request.txn_needed_wrong_mode", requestId); //$NON-NLS-1$
- throw new MetaMatrixComponentException(msg);
- } else if (ExecutionProperties.AUTO_WRAP_PESSIMISTIC.equals(requestMsg.getTxnAutoWrapMode())){
- startAutoWrapTxn = true;
- } else if (ExecutionProperties.AUTO_WRAP_OFF.equals(requestMsg.getTxnAutoWrapMode())) {
- LogManager.logDetail(LogConstants.CTX_DQP, DQPPlugin.Util.getString("Request.potentially_unsafe")); //$NON-NLS-1$
- }
- }
- if(ExecutionProperties.AUTO_WRAP_OPTIMISTIC.equals(requestMsg.getTxnAutoWrapMode())){
- this.context.setOptimisticTransaction(true);
- }
-
- if (startAutoWrapTxn) {
- if (transactionService == null) {
- throw new MetaMatrixComponentException(DQPPlugin.Util.getString("Request.transaction_not_supported")); //$NON-NLS-1$
- }
- try {
- tc = transactionService.getTransactionServer().start(tc);
- } catch (XATransactionException err) {
- throw new MetaMatrixComponentException(err);
- } catch (SystemException err) {
- throw new MetaMatrixComponentException(err);
- }
- }
- }
-
- this.transactionContext = tc;
- List outputElements = processPlan.getOutputElements();
- this.context.setTupleSourceID(this.bufferManager.createTupleSource(
- outputElements,
- TypeRetrievalUtil.getTypeNames(outputElements),
- this.workContext.getConnectionID(),
- TupleSourceType.FINAL));
- this.processor = new QueryProcessor(processPlan, context, bufferManager, new TempTableDataManager(processorDataManager, tempTableStore));
- }
-
- private boolean useProcDebug(Command command) {
- if(this.procDebugAllowed) {
- Option option = command.getOption();
- if(option != null) {
- return option.getDebug();
- }
- }
- return false;
- }
-
- private boolean collectNodeStatistics(Command command) {
- if(this.requestMsg.getShowPlan()) {
- return true;
- }
- Option option = command.getOption();
- if(option != null) {
- return (option.getDebug() || option.getShowPlan());
- }
- return false;
- }
-
- /**
- * side effects:
- * sets the processor plan
- *
- * @throws MetaMatrixComponentException
- * @throws QueryPlannerException
- * @throws QueryParserException
- * @throws QueryResolverException
- * @throws QueryValidatorException
- */
- protected void generatePlan() throws MetaMatrixComponentException, QueryPlannerException, QueryParserException, QueryResolverException, QueryValidatorException {
- Command command = prepareCommand();
-
- try {
- // If using multi-source models, insert a proxy to simplify the supported capabilities. This is
- // done OUTSIDE the cache (wrapped around the cache) intentionally to avoid caching the simplified
- // capabilities which may be different for the same model in a different VDB used by this same DQP.
- CapabilitiesFinder finder = this.capabilitiesFinder;
- if(this.multiSourceModels != null) {
- finder = new MultiSourceCapabilitiesFinder(finder, this.multiSourceModels);
- }
-
- // Run the optimizer
- try {
- processPlan = QueryOptimizer.optimizePlan(command, metadata, idGenerator, finder, analysisRecord, context);
- } finally {
- String debugLog = analysisRecord.getDebugLog();
- if(debugLog != null && debugLog.length() > 0) {
- LogManager.logInfo(LogConstants.CTX_DQP, debugLog);
- }
- }
-
- if (analysisRecord.recordQueryPlan()) {
- analysisRecord.setQueryPlan(processPlan.getDescriptionProperties());
- }
-
- LogManager.logDetail(LogConstants.CTX_DQP, new Object[] { DQPPlugin.Util.getString("BasicInterceptor.ProcessTree_for__4"), requestId, processPlan }); //$NON-NLS-1$
- } catch (QueryMetadataException e) {
- Object[] params = new Object[] { requestId};
- String msg = DQPPlugin.Util.getString("DQPCore.Unknown_query_metadata_exception_while_registering_query__{0}.", params); //$NON-NLS-1$
- throw new QueryPlannerException(e, msg);
- }
- }
-
- private void setSchemasForXMLPlan(Command command, QueryMetadataInterface metadata)
- throws MetaMatrixComponentException, QueryMetadataException {
-
- XMLPlan xmlPlan = null;
-
- if(processPlan instanceof XMLPlan) {
- xmlPlan = (XMLPlan)processPlan;
- }else if(processPlan instanceof XQueryPlan) {
- ((XQueryPlan)processPlan).setXMLFormat(requestMsg.getXMLFormat());
- }else if(command instanceof StoredProcedure) {
- Collection childPlans = processPlan.getChildPlans();
- if(!childPlans.isEmpty()) {
- ProcessorPlan plan = (ProcessorPlan)childPlans.iterator().next();
- //check the last child plan of this procedure plan
- Collection procChildPlans = plan.getChildPlans();
- if(procChildPlans.size() > 0) {
- Iterator iter = procChildPlans.iterator();
- ProcessorPlan lastPlan = null;
- while(iter.hasNext()) {
- lastPlan = (ProcessorPlan) iter.next();
- }
- if(lastPlan instanceof XMLPlan) {
- xmlPlan = (XMLPlan)lastPlan;
- }
- }
- }
- }
-
- if (xmlPlan == null) {
- return;
- }
-
- // Set the post-processing options on the plan
- boolean shouldValidate = requestMsg.getValidationMode();
-
- xmlPlan.setShouldValidate(shouldValidate);
- xmlPlan.setStylesheet(requestMsg.getStyleSheet());
- xmlPlan.setXMLFormat(requestMsg.getXMLFormat());
-
- // if the validation/schema mode is set to true look up the schema in runtime metadata
- if (shouldValidate) {
- this.schemas = metadata.getXMLSchemas(xmlPlan.getDocumentGroup().getMetadataID());
- // set the schema into the plan
- xmlPlan.setXMLSchemas(schemas);
- }
- }
-
- private void createAnalysisRecord(Command command) throws QueryValidatorException{
- Option option = command.getOption();
- boolean getPlan = requestMsg.getShowPlan();
- boolean debug = false;
- if (option != null) {
- getPlan = getPlan || option.getShowPlan() || option.getPlanOnly();
- debug = option.getDebug();
- }
-
- if (getPlan && !requestMsg.isQueryPlanAllowed()){
- final String message = DQPPlugin.Util.getString("Request.query_plan_not_allowed"); //$NON-NLS-1$
- throw new QueryValidatorException(message);
- }
-
- this.analysisRecord = new AnalysisRecord(getPlan, getPlan, debug);
- }
-
- public void processRequest()
- throws QueryValidatorException, QueryParserException, QueryResolverException, MetaMatrixComponentException, QueryPlannerException {
-
- initMetadata();
-
- generatePlan();
-
- validateEntitlement(command);
-
- setSchemasForXMLPlan(command, metadata);
-
- createProcessor();
- }
-
- public QueryProcessor createQueryProcessor(String query, String recursionGroup, CommandContext commandContext) throws MetaMatrixProcessingException, MetaMatrixComponentException {
- boolean isRootXQuery = recursionGroup == null && commandContext.getCallStackDepth() == 0 && command instanceof XQuery;
-
- ParseInfo parseInfo = new ParseInfo();
- if (isRootXQuery && requestMsg.isDoubleQuotedVariableAllowed()) {
- parseInfo.allowDoubleQuotedVariable = true;
- }
- Command newCommand = QueryParser.getQueryParser().parseCommand(query, parseInfo);
- QueryResolver.resolveCommand(newCommand, metadata);
-
- List references = ReferenceCollectorVisitor.getReferences(newCommand);
-
- referenceCheck(references);
-
- validateQuery(newCommand, isRootXQuery);
-
- validateQueryValues(newCommand);
-
- if (isRootXQuery) {
- validateEntitlement(newCommand);
- }
-
- CommandContext copy = (CommandContext) commandContext.clone();
- if (recursionGroup != null) {
- copy.pushCall(recursionGroup);
- }
-
- QueryRewriter.rewrite(newCommand, null, metadata, copy);
- ProcessorPlan plan = QueryOptimizer.optimizePlan(newCommand, metadata, idGenerator, capabilitiesFinder, analysisRecord, copy);
-
- TupleSourceID resultsId = bufferManager.createTupleSource(newCommand.getProjectedSymbols(), TypeRetrievalUtil.getTypeNames(newCommand.getProjectedSymbols()), copy.getConnectionID(), TupleSourceType.PROCESSOR);
- copy.setTupleSourceID(resultsId);
- return new QueryProcessor(plan, copy, bufferManager, processorDataManager);
- }
-
- protected void validateEntitlement(Command command)
- throws QueryValidatorException, MetaMatrixComponentException {
- // Validate the query (may only want to validate entitlement)
- AuthorizationService authSvc = (AuthorizationService) this.env
- .findService(DQPServiceNames.AUTHORIZATION_SERVICE);
- if (authSvc != null) {
- // See if entitlement checking is turned on
- if (authSvc.checkingEntitlements()) {
- AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(
- this.workContext.getConnectionID(), authSvc);
- if (command.getType() == Command.TYPE_XQUERY) {
- // validate its first level children
- Iterator iter = command.getSubCommands().iterator();
- while (iter.hasNext()) {
- validateWithVisitor(visitor, this.metadata,
- (Command) iter.next(), true);
- }
- } else {
- validateWithVisitor(visitor, this.metadata, command, true);
- }
- } else if (workContext.getUserName().equals(
- AuthorizationService.DEFAULT_WSDL_USERNAME)) {
- if (command.getType() == Command.TYPE_STORED_PROCEDURE &&
- AuthorizationValidationVisitor.GET_UPDATED_CHARACTER_VDB_RESOURCE.contains(((StoredProcedure) command).getProcedureName())) {
- // do nothing... this is valid
- } else {
- // Throw an exception since the WSDL user is trying to do something other than access the VDB resources
- final String message = DQPPlugin.Util.getString("Request.wsdl_user_not_authorized"); //$NON-NLS-1$
- throw new QueryValidatorException(message);
- }
- }
- }
- }
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/RequestWorkItem.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/RequestWorkItem.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/RequestWorkItem.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,740 +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 com.metamatrix.dqp.internal.process;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.transaction.InvalidTransactionException;
-import javax.transaction.SystemException;
-
-import org.teiid.connector.xa.api.TransactionContext;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BlockedOnMemoryException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.MemoryNotAvailableException;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.buffer.TupleSourceID;
-import com.metamatrix.common.buffer.TupleSourceNotFoundException;
-import com.metamatrix.common.buffer.BufferManager.TupleSourceStatus;
-import com.metamatrix.common.comm.api.ResultsReceiver;
-import com.metamatrix.common.comm.exception.CommunicationException;
-import com.metamatrix.common.lob.LobChunk;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.xa.XATransactionException;
-import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.core.log.MessageLevel;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.exception.SourceWarning;
-import com.metamatrix.dqp.internal.cache.CacheID;
-import com.metamatrix.dqp.internal.cache.CacheResults;
-import com.metamatrix.dqp.internal.cache.ResultSetCache;
-import com.metamatrix.dqp.internal.cache.ResultSetCacheUtil;
-import com.metamatrix.dqp.message.AtomicRequestID;
-import com.metamatrix.dqp.message.AtomicRequestMessage;
-import com.metamatrix.dqp.message.ParameterInfo;
-import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.dqp.message.ResultsMessage;
-import com.metamatrix.dqp.service.TransactionService;
-import com.metamatrix.dqp.spi.TrackerLogConstants;
-import com.metamatrix.dqp.util.LogConstants;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.analysis.QueryAnnotation;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.processor.QueryProcessor;
-import com.metamatrix.query.processor.QueryProcessor.BatchHandler;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Option;
-import com.metamatrix.query.sql.lang.SPParameter;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-
-public class RequestWorkItem extends AbstractWorkItem {
-
- protected static class ResultsCursor {
- int begin;
- int end;
- boolean resultsRequested;
-
- /**
- * Ask for results.
- * @param beginRow
- * @param endRow
- * @param isPoll
- */
- synchronized void requestResults(int beginRow, int endRow, boolean isPoll) {
- if (this.resultsRequested) {
- if (!isPoll) {
- throw new IllegalStateException("Results already requested"); //$NON-NLS-1$\
- } else if (begin != beginRow || end != endRow) {
- throw new IllegalStateException("Polling for different results than previously requested"); //$NON-NLS-1$
- }
- }
- this.begin = beginRow;
- this.end = endRow;
- Assertion.assertTrue(end - begin >= 0);
- this.resultsRequested = true;
- }
-
- synchronized void resultsSent() {
- this.resultsRequested = false;
- }
- }
-
- private enum ProcessingState {NEW, PROCESSING, CLOSE}
- private ProcessingState state = ProcessingState.NEW;
-
- private enum TransactionState {NONE, ACTIVE, END, DONE}
- private TransactionState transactionState = TransactionState.NONE;
-
- /*
- * Obtained at construction time
- */
- protected final DQPCore dqpCore;
- final RequestMessage requestMsg;
- final RequestID requestID;
- protected Request request; //provides the processing plan, held on a temporary basis
- final private BufferManager bufferMgr;
- final private int processorTimeslice;
- protected ResultSetCache rsCache;
- protected CacheID cid;
- final private TransactionService transactionService;
- final DQPWorkContext dqpWorkContext;
- ResultsReceiver<ResultsMessage> resultsReceiver;
-
- /*
- * obtained during new
- */
- private volatile QueryProcessor processor;
- protected Command originalCommand;
- private AnalysisRecord analysisRecord;
- private TransactionContext transactionContext;
- private TupleSourceID resultsID;
- private Collection schemas; // These are schemas associated with XML results
-
- /*
- * maintained during processing
- */
- private Throwable processingException;
- private Map<AtomicRequestID, DataTierTupleSource> connectorInfo = new ConcurrentHashMap<AtomicRequestID, DataTierTupleSource>(4);
- // This exception contains details of all the atomic requests that failed when query is run in partial results mode.
- private List<MetaMatrixException> warnings = new LinkedList<MetaMatrixException>();
-
- private boolean doneProducingBatches;
- protected boolean isClosed;
- private volatile boolean isCanceled;
- private volatile boolean closeRequested;
-
- /** Range of rows requested by the client */
- protected ResultsCursor resultsCursor = new ResultsCursor();
-
- private Map<Integer, LobWorkItem> lobStreams = Collections.synchronizedMap(new HashMap<Integer, LobWorkItem>(4));
-
- public RequestWorkItem(DQPCore dqpCore, RequestMessage requestMsg, Request request, ResultsReceiver<ResultsMessage> receiver, RequestID requestID, DQPWorkContext workContext) {
- this.requestMsg = requestMsg;
- this.requestID = requestID;
- this.resultsCursor.requestResults(1, requestMsg.getFetchSize(), false);
- this.bufferMgr = dqpCore.getBufferManager();
- this.processorTimeslice = dqpCore.getProcessorTimeSlice();
- this.rsCache = dqpCore.getRsCache();
- if (this.rsCache != null) {
- this.cid = ResultSetCacheUtil.createCacheID(requestMsg, rsCache);
- }
- this.transactionService = dqpCore.getTransactionService();
- this.dqpCore = dqpCore;
- this.request = request;
- this.resultsReceiver = receiver;
- this.dqpWorkContext = workContext;
- }
-
- @Override
- protected boolean isDoneProcessing() {
- return isClosed;
- }
-
- @Override
- protected void resumeProcessing() {
- dqpCore.addWork(this);
- }
-
- @Override
- protected void process() {
- DQPWorkContext.setWorkContext(this.dqpWorkContext);
-
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_DQP, "############# PW PROCESSING on " + requestID + " with state "+ state +" ###########"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- try {
- if (this.state == ProcessingState.NEW) {
- state = ProcessingState.PROCESSING;
- processNew();
- if (isCanceled) {
- this.processingException = new MetaMatrixProcessingException(QueryExecPlugin.Util.getString("QueryProcessor.request_cancelled", this.requestID)); //$NON-NLS-1$
- state = ProcessingState.CLOSE;
- }
- }
- if (this.state == ProcessingState.PROCESSING) {
- processMore();
- if (this.closeRequested) {
- this.state = ProcessingState.CLOSE;
- }
- }
- } catch (BlockedOnMemoryException e) {
- moreWork(false);
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_DQP, "############# PW EXITING on " + requestID + " - reenqueueing for more processing due to lack of available memory ###########"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- } catch (BlockedException e) {
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_DQP, "############# PW EXITING on " + requestID + " - processor blocked ###########"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- } catch (Throwable e) {
- //if there is a cache, remove temp results if there is any
- if(this.rsCache != null){
- rsCache.removeTempResults(cid);
- }
-
- if (isCanceled()) {
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_DQP, e, "############# PW EXITING on " + requestID + " - error occurred ###########"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- } else {
- logCommandError();
- //Case 5558: Differentiate between system level errors and
- //processing errors. Only log system level errors as errors,
- //log the processing errors as warnings only
- if(e instanceof MetaMatrixProcessingException) {
- LogManager.logWarning(LogConstants.CTX_DQP, e, "############# PW EXITING on " + requestID + " - error occurred ###########"); //$NON-NLS-1$ //$NON-NLS-2$
- }else {
- LogManager.logError(LogConstants.CTX_DQP, e, "############# PW EXITING on " + requestID + " - error occurred ###########"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- this.processingException = e;
- this.state = ProcessingState.CLOSE;
- } finally {
- if (this.state == ProcessingState.CLOSE && !isClosed) {
- attemptClose();
- } else if (isClosed) {
- /*
- * since there may be a client waiting notify them of a problem
- */
- if (this.processingException == null) {
- this.processingException = new IllegalStateException("Request is already closed"); //$NON-NLS-1$
- }
- sendError();
- }
- }
- }
-
- protected void processMore() throws SystemException, BlockedException, MetaMatrixCoreException {
- if (!doneProducingBatches) {
- sendResultsIfNeeded(null);
- doneProducingBatches = processor.process(this.processorTimeslice);
- }
- if (doneProducingBatches) {
- if (this.transactionState == TransactionState.ACTIVE) {
- boolean end = true;
- /*
- * TEIID-14 if we are done producing batches, then proactively close transactional
- * executions even ones that were intentionally kept alive. this may
- * break the read of a lob from a transactional source under a transaction
- * if the source does not support holding the clob open after commit
- */
- for (DataTierTupleSource connectorRequest : this.connectorInfo.values()) {
- if (connectorRequest.isTransactional()) {
- connectorRequest.fullyCloseSource();
- end = false;
- }
- }
- if (end) {
- this.transactionState = TransactionState.END;
- }
- }
- if (this.transactionState == TransactionState.END && transactionContext.getTransactionType() == TransactionContext.Scope.TRANSACTION_REQUEST) {
- this.transactionService.getTransactionServer().commit(transactionContext);
- this.transactionState = TransactionState.DONE;
- }
- sendResultsIfNeeded(null);
- } else {
- moreWork(false); // If the timeslice expired, then the processor can probably produce more batches.
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_DQP, "############# PW EXITING on " + requestID + " - reenqueueing for more processing ###########"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
-
- /**
- * Client close is currently implemented as asynch.
- * Any errors that occur will not make it to the client, instead we just log them here.
- */
- protected void attemptClose() {
- if (this.resultsID != null) {
- try {
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_DQP, "Removing tuplesource for the request " + requestID); //$NON-NLS-1$
- }
- this.dqpCore.getBufferManager().removeTupleSource(resultsID);
- } catch(TupleSourceNotFoundException e) {
- // ignore
- } catch (MetaMatrixComponentException e) {
- LogManager.logDetail(LogConstants.CTX_DQP, e, e.getMessage());
- }
-
- try {
- this.processor.closeProcessing();
- } catch (TupleSourceNotFoundException e) {
- // ignore
- } catch (MetaMatrixComponentException e) {
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_DQP, e, e.getMessage());
- }
- }
-
- for (DataTierTupleSource connectorRequest : this.connectorInfo.values()) {
- try {
- connectorRequest.fullyCloseSource();
- } catch (MetaMatrixComponentException e) {
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_DQP, e, e.getMessage());
- }
- }
- }
-
- this.resultsID = null;
- }
-
- if (this.transactionState == TransactionState.ACTIVE) {
- if (!this.connectorInfo.isEmpty()) {
- return; //wait for pending connector work
- }
- this.transactionState = TransactionState.END;
- }
-
- if (this.transactionState == TransactionState.END && transactionContext.getTransactionType() == TransactionContext.Scope.TRANSACTION_REQUEST) {
- this.transactionState = TransactionState.DONE;
- try {
- this.transactionService.getTransactionServer().rollback(transactionContext);
- } catch (XATransactionException e1) {
- LogManager.logWarning(LogConstants.CTX_DQP, e1, DQPPlugin.Util.getString("ProcessWorker.failed_rollback")); //$NON-NLS-1$
- } catch (SystemException err) {
- LogManager.logWarning(LogConstants.CTX_DQP, err, DQPPlugin.Util.getString("ProcessWorker.failed_rollback")); //$NON-NLS-1$
- }
- }
-
- isClosed = true;
-
- dqpCore.removeRequest(this);
-
- if (this.processingException != null) {
- sendError();
- } else {
- dqpCore.logMMCommand(requestMsg, false, false, this.processor.getHighestRow());
- }
- }
-
- protected void processNew() throws MetaMatrixProcessingException, MetaMatrixComponentException {
- request.processRequest();
- originalCommand = request.command;
- processor = request.processor;
- processor.setBatchHandler(new BatchHandler() {
- public void batchProduced(TupleBatch batch)
- throws MetaMatrixCoreException {
- //if there is a cache, and it is a query, save it
- if(rsCache != null && requestMsg.useResultSetCache() && originalCommand.areResultsCachable() && transactionState == TransactionState.NONE && !rsCache.hasResults(cid)){
- CacheResults cr = new CacheResults(batch.getAllTuples(), processor.getProcessorPlan().getOutputElements(), batch.getBeginRow(), !doneProducingBatches);
- cr.setCommand(originalCommand);
- cr.setSize(batch.getSize());
- if(batch.getSize() != TupleBatch.UNKNOWN_SIZE){
- cr.setSize(batch.getSize());
- }
- cr.setAnalysisRecord(analysisRecord);
- if (!rsCache.setResults(cid, cr, requestID)) {
- rsCache = null; //disable caching if we are over size
- }
- }
- sendResultsIfNeeded(batch);
- }
- });
- resultsID = request.context.getTupleSourceID();
- analysisRecord = request.analysisRecord;
- schemas = request.schemas;
- transactionContext = request.transactionContext;
- if (this.transactionContext != null && this.transactionContext.isInTransaction()) {
- this.transactionState = TransactionState.ACTIVE;
- }
- Option option = originalCommand.getOption();
- if (option != null && option.getPlanOnly()) {
- doneProducingBatches = true;
- this.bufferMgr.setStatus(resultsID, TupleSourceStatus.FULL);
- }
-
- if (analysisRecord.recordQueryPlan()) {
- analysisRecord.setQueryPlan(processor.getProcessorPlan().getDescriptionProperties());
- }
-
- request = null;
- }
-
- /**
- * Send results if they have been requested. This should only be called from the processing thread.
- */
- protected void sendResultsIfNeeded(TupleBatch batch) throws BlockedOnMemoryException,
- MetaMatrixComponentException, TupleSourceNotFoundException, CommunicationException {
-
- synchronized (resultsCursor) {
- if (!this.resultsCursor.resultsRequested
- || (this.resultsCursor.begin > this.processor.getHighestRow() && !doneProducingBatches)
- || (this.transactionState == TransactionState.ACTIVE)) {
- return;
- }
- }
-
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_DQP, "[RequestWorkItem.sendResultsIfNeeded] requestID: " + requestID + " resultsID: " + this.resultsID + " done: " + doneProducingBatches ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- boolean pinned = false;
-
- try {
- if (batch == null || batch.getBeginRow() > this.resultsCursor.begin) {
- batch = this.bufferMgr.pinTupleBatch(resultsID, resultsCursor.begin, resultsCursor.end);
- pinned = true;
- }
- int finalRowCount = doneProducingBatches?this.processor.getHighestRow():-1;
-
- ResultsMessage response = createResultsMessage(requestMsg, batch.getAllTuples(), this.processor.getProcessorPlan().getOutputElements(), analysisRecord);
- response.setFirstRow(batch.getBeginRow());
- response.setLastRow(batch.getEndRow());
-
- // set final row
- response.setFinalRow(finalRowCount);
- // Results are partial if the rowcount is not yet known,
- // or if the last row of this batch is less than the row count
- boolean isPartialResultSet = finalRowCount < 0
- || batch.getEndRow() < finalRowCount;
-
- // set parital result
- response.setPartialResults(isPartialResultSet);
-
- // send any schemas associated with the results
- response.setSchemas(this.schemas);
-
- // send any warnings with the response object
- List<Exception> responseWarnings = new ArrayList<Exception>();
- List<Exception> currentWarnings = processor.getAndClearWarnings();
- if (currentWarnings != null) {
- responseWarnings.addAll(currentWarnings);
- }
- synchronized (warnings) {
- responseWarnings.addAll(this.warnings);
- this.warnings.clear();
- }
- response.setWarnings(responseWarnings);
-
- // If it is stored procedure, set parameters
- if (originalCommand instanceof StoredProcedure) {
- StoredProcedure proc = (StoredProcedure)originalCommand;
- if (proc.returnParameters()) {
- response.setParameters(getParameterInfo(proc));
- }
- }
-
- /*
- * mark the results sent at this point.
- * communication exceptions will be treated as non-recoverable
- */
- this.resultsCursor.resultsSent();
- this.resultsReceiver.receiveResults(response);
- } catch (MemoryNotAvailableException e) {
- throw BlockedOnMemoryException.INSTANCE;
- } finally {
- try {
- if (pinned) {
- this.bufferMgr.unpinTupleBatch(this.resultsID, batch.getBeginRow(), batch.getEndRow());
- }
- } catch (Exception e) {
- // ignore - nothing more we can do
- }
- }
- }
-
- public static ResultsMessage createResultsMessage(RequestMessage message, List[] batch, List columnSymbols, AnalysisRecord analysisRecord) {
- String[] columnNames = new String[columnSymbols.size()];
- String[] dataTypes = new String[columnSymbols.size()];
-
- for(int i=0; i<columnSymbols.size(); i++) {
- SingleElementSymbol symbol = (SingleElementSymbol) columnSymbols.get(i);
- columnNames[i] = SingleElementSymbol.getShortName(symbol.getOutputName());
- dataTypes[i] = DataTypeManager.getDataTypeName(symbol.getType());
- }
-
- ResultsMessage result = new ResultsMessage(message, batch, columnNames, dataTypes);
- setAnalysisRecords(result, analysisRecord);
- return result;
- }
-
- private static void setAnalysisRecords(ResultsMessage response, AnalysisRecord analysisRecord) {
- if(analysisRecord != null) {
- response.setPlanDescription(analysisRecord.getQueryPlan());
- response.setDebugLog(analysisRecord.getDebugLog());
-
- // Convert annotations to JDBC expected format - String[4]
- Collection anns = analysisRecord.getAnnotations();
- Collection converted = null;
- if(anns != null) {
- converted = new ArrayList(anns.size());
- Iterator annIter = anns.iterator();
- while(annIter.hasNext()) {
- QueryAnnotation ann = (QueryAnnotation) annIter.next();
- String[] jdbcAnn = new String[4];
- jdbcAnn[0] = ann.getCategory();
- jdbcAnn[1] = ann.getAnnotation();
- jdbcAnn[2] = ann.getResolution();
- jdbcAnn[3] = "" + ann.getPriority(); //$NON-NLS-1$
- converted.add(jdbcAnn);
- }
- response.setAnnotations(converted);
- }
- }
- }
-
- private void sendError() {
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_DQP, processingException, DQPPlugin.Util.getString("ProcessWorker.send_error", requestID)); //$NON-NLS-1$
- }
-
- ResultsMessage response = new ResultsMessage(requestMsg);
- response.setException(processingException);
- setAnalysisRecords(response, analysisRecord);
- resultsReceiver.receiveResults(response);
- }
-
- private static List getParameterInfo(StoredProcedure procedure) {
- List params = procedure.getParameters();
- List paramInfos = new ArrayList(params.size());
-
- Iterator iter = params.iterator();
- while(iter.hasNext()) {
- SPParameter param = (SPParameter) iter.next();
- ParameterInfo info = new ParameterInfo(param.getParameterType(), param.getResultSetColumns().size());
- paramInfos.add(info);
- }
-
- return paramInfos;
- }
-
- public void processLobChunkRequest(String id, int streamRequestId, ResultsReceiver<LobChunk> chunckReceiver) {
- LobWorkItem workItem = null;
- synchronized (lobStreams) {
- workItem = this.lobStreams.get(new Integer(streamRequestId));
- if (workItem == null) {
- workItem = new LobWorkItem(this, dqpCore, id, streamRequestId);
- lobStreams.put(new Integer(streamRequestId), workItem);
- }
- }
- workItem.setResultsReceiver(chunckReceiver);
- dqpCore.addWork(workItem);
- }
-
- public void removeLobStream(int streamRequestId) {
- this.lobStreams.remove(new Integer(streamRequestId));
- }
-
- public boolean requestCancel() throws MetaMatrixComponentException {
- synchronized (this) {
- if (this.isCanceled) {
- return false;
- }
- this.isCanceled = true;
- }
- if (this.processor != null) {
- this.processor.requestCanceled();
- }
-
- // Cancel Connector atomic requests
- try {
- for (DataTierTupleSource connectorRequest : this.connectorInfo.values()) {
- connectorRequest.cancelRequest();
- }
- } finally {
- try {
- if (transactionService != null) {
- try {
- transactionService.getTransactionServer().cancelTransactions(requestID.getConnectionID(), true);
- } catch (InvalidTransactionException err) {
- LogManager.logWarning(LogConstants.CTX_DQP, "rollback failed for requestID=" + requestID.getConnectionID()); //$NON-NLS-1$
- } catch (SystemException err) {
- throw new MetaMatrixComponentException(err);
- }
- }
- } finally {
- this.moreWork();
- }
- }
- return true;
- }
-
- public boolean requestAtomicRequestCancel(int accessNodeID) throws MetaMatrixComponentException {
- // in the case that this does not support partial results; cancel
- // the original processor request.
- if(!requestMsg.supportsPartialResults()) {
- return requestCancel();
- }
- // Walk through all connector infos and attempt to cancel each one
- for (DataTierTupleSource connectorRequest : this.connectorInfo.values()) {
- AtomicRequestMessage aqr = connectorRequest.getAtomicRequestMessage();
- if (aqr.getAtomicRequestID().getNodeID() == accessNodeID) {
- connectorRequest.cancelRequest();
- return true;
- }
- }
-
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_DQP, "Connector request not queued yet. RequestID=" + requestID+ " Node id="+ accessNodeID); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return false;
- }
-
- public synchronized void requestClose() {
- if (this.state == ProcessingState.CLOSE || this.closeRequested) {
- if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_DQP, "Request already closing" + requestID); //$NON-NLS-1$
- }
- return;
- }
- this.closeRequested = true;
- if (this.processor != null) {
- this.processor.requestClosed();
- }
- this.moreWork();
- }
-
- public void requestMore(int batchFirst, int batchLast, ResultsReceiver<ResultsMessage> receiver) {
- this.resultsReceiver = receiver;
- this.resultsCursor.requestResults(batchFirst, batchLast, false);
- this.moreWork();
- }
-
- public void closeAtomicRequest(AtomicRequestID atomicRequestId) {
- connectorInfo.remove(atomicRequestId);
- LogManager.logTrace(LogConstants.CTX_DQP, new Object[] {"closed atomic-request:", atomicRequestId}); //$NON-NLS-1$
- }
-
- public void addConnectorRequest(AtomicRequestID atomicRequestId, DataTierTupleSource connInfo) {
- connectorInfo.put(atomicRequestId, connInfo);
- }
-
- /**
- * <p>This method add information to the warning on the work item for the given
- * <code>RequestID</code>. This method is called from <code>DataTierManager</code></p>
- */
- public void addSourceFailureDetails(SourceWarning details) {
- synchronized (warnings) {
- this.warnings.add(details);
- }
- }
-
- /**
- * Log the command to the MM cmd log.
- */
- private void logCommandError() {
- if ( dqpCore.getTracker() == null || !dqpCore.getTracker().willRecordMMCmd()) {
- return;
- }
- String transactionID = null;
- if (this.transactionContext != null && this.transactionContext.isInTransaction()) {
- transactionID = this.transactionContext.getTxnID();
- }
- dqpCore.getTracker().log(requestID.toString(),
- transactionID == null ? null : transactionID,
- TrackerLogConstants.CMD_POINT.END,
- TrackerLogConstants.CMD_STATUS.ERROR,
- requestID.getConnectionID(),
- dqpWorkContext.getAppName(),
- dqpWorkContext.getUserName(),
- dqpWorkContext.getVdbName(),
- dqpWorkContext.getVdbVersion(),
- (originalCommand != null ? originalCommand.toString() : null ),
- -1);
- }
-
- boolean isCanceled() {
- return isCanceled;
- }
-
- Command getOriginalCommand() throws MetaMatrixProcessingException {
- if (this.originalCommand == null) {
- if (this.processingException != null) {
- throw new MetaMatrixProcessingException(this.processingException);
- }
- throw new IllegalStateException("Original command is not available"); //$NON-NLS-1$
- }
- return this.originalCommand;
- }
-
- void setOriginalCommand(Command originalCommand) {
- this.originalCommand = originalCommand;
- }
-
- TransactionContext getTransactionContext() {
- return transactionContext;
- }
-
- Collection<DataTierTupleSource> getConnectorRequests() {
- return new LinkedList<DataTierTupleSource>(this.connectorInfo.values());
- }
-
- DataTierTupleSource getConnectorRequest(AtomicRequestID id) {
- return this.connectorInfo.get(id);
- }
-
- public List<MetaMatrixException> getWarnings() {
- return warnings;
- }
-
- @Override
- public String toString() {
- return this.requestID.toString();
- }
-
- public DQPWorkContext getDqpWorkContext() {
- return dqpWorkContext;
- }
-
-}
\ No newline at end of file
Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/TempTableStoresHolder.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/TempTableStoresHolder.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/TempTableStoresHolder.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,52 +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 com.metamatrix.dqp.internal.process;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.query.tempdata.TempTableStore;
-import com.metamatrix.query.tempdata.TempTableStoreImpl;
-
-
-/**
- * @since 5.5
- */
-public class TempTableStoresHolder {
- private BufferManager buffer;
- private Map tempTableStores = new HashMap();
-
- public TempTableStoresHolder(BufferManager buffer) {
- this.buffer = buffer;
- }
-
- public synchronized TempTableStore getTempTableStore(String sessionID) {
- TempTableStore tempTableStore = (TempTableStore)tempTableStores.get(sessionID);
- if(tempTableStore == null) {
- tempTableStore = new TempTableStoreImpl(buffer, sessionID, null);
- tempTableStores.put(sessionID, tempTableStore);
- }
- return tempTableStore;
- }
-}
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestMessage.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestMessage.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestMessage.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -29,10 +29,10 @@
import java.util.concurrent.atomic.AtomicInteger;
import org.teiid.connector.xa.api.TransactionContext;
+import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.common.buffer.impl.BufferConfig;
import com.metamatrix.dqp.internal.datamgr.ConnectorID;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.query.sql.lang.Command;
/**
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/service/DataService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/DataService.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/DataService.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -25,6 +25,8 @@
import java.util.Collection;
import java.util.List;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+
import com.metamatrix.api.exception.ComponentNotFoundException;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.application.ApplicationService;
@@ -32,7 +34,6 @@
import com.metamatrix.common.comm.api.ResultsReceiver;
import com.metamatrix.common.config.api.ConnectorBinding;
import com.metamatrix.dqp.internal.datamgr.ConnectorID;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.dqp.message.AtomicRequestID;
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.message.AtomicResultsMessage;
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/transaction/TransactionServer.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/transaction/TransactionServer.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/transaction/TransactionServer.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -27,9 +27,9 @@
import javax.transaction.xa.XAResource;
import org.teiid.connector.xa.api.TransactionContext;
+import org.teiid.dqp.internal.transaction.TransactionProvider.XAConnectionSource;
import com.metamatrix.common.xa.XATransactionException;
-import com.metamatrix.dqp.internal.transaction.TransactionProvider.XAConnectionSource;
public interface TransactionServer {
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/batch/PreparedBatchUpdatePlanner.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/batch/PreparedBatchUpdatePlanner.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/batch/PreparedBatchUpdatePlanner.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -26,6 +26,8 @@
import java.util.Iterator;
import java.util.List;
+import org.teiid.dqp.internal.process.PreparedStatementRequest;
+
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.ExpressionEvaluationException;
import com.metamatrix.api.exception.query.QueryMetadataException;
@@ -33,7 +35,6 @@
import com.metamatrix.api.exception.query.QueryResolverException;
import com.metamatrix.core.id.IDGenerator;
import com.metamatrix.core.id.IntegerID;
-import com.metamatrix.dqp.internal.process.PreparedStatementRequest;
import com.metamatrix.query.analysis.AnalysisRecord;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.CommandPlanner;
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/batch/PreparedBatchUpdatePlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/batch/PreparedBatchUpdatePlan.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/batch/PreparedBatchUpdatePlan.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -29,12 +29,13 @@
import java.util.List;
import java.util.Map;
+import org.teiid.dqp.internal.process.PreparedStatementRequest;
+
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.buffer.BlockedException;
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.dqp.internal.process.PreparedStatementRequest;
import com.metamatrix.query.processor.BaseProcessorPlan;
import com.metamatrix.query.processor.DescribableUtil;
import com.metamatrix.query.processor.ProcessorDataManager;
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/cache (from rev 569, trunk/engine/src/main/java/com/metamatrix/dqp/internal/cache)
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/cache
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/cache/CacheID.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/cache/CacheID.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/cache/CacheID.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.cache;
+package org.teiid.dqp.internal.cache;
import java.util.List;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/cache/CacheResults.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/cache/CacheResults.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/cache/CacheResults.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.cache;
+package org.teiid.dqp.internal.cache;
import java.util.List;
import java.util.Map;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/cache/CursorReceiverWindowBuffer.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/cache/CursorReceiverWindowBuffer.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/cache/CursorReceiverWindowBuffer.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.cache;
+package org.teiid.dqp.internal.cache;
import java.util.HashMap;
import java.util.Iterator;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/cache/ResultSetCache.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/cache/ResultSetCache.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/cache/ResultSetCache.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.cache;
+package org.teiid.dqp.internal.cache;
import java.util.HashMap;
import java.util.List;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/cache/ResultSetCacheUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/cache/ResultSetCacheUtil.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/cache/ResultSetCacheUtil.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,10 +20,11 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.cache;
+package org.teiid.dqp.internal.cache;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+
import com.metamatrix.common.buffer.impl.SizeUtility;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.dqp.message.RequestMessage;
public class ResultSetCacheUtil {
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java (from rev 569, trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/CapabilitiesConverter.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,120 @@
+/*
+ * 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.datamgr;
+
+import java.util.*;
+
+import org.teiid.connector.api.ConnectorCapabilities;
+
+import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
+import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
+import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
+
+/**
+ * Utility to convert a ConnectorCapabilities class into a Map of
+ * capabilities information that can be passed through the system.
+ */
+public class CapabilitiesConverter {
+
+ private CapabilitiesConverter() {
+ }
+
+ public static SourceCapabilities convertCapabilities(ConnectorCapabilities srcCaps) {
+ return convertCapabilities(srcCaps, null, false);
+ }
+
+ public static BasicSourceCapabilities convertCapabilities(ConnectorCapabilities srcCaps, String connectorID, boolean isXa) {
+ BasicSourceCapabilities tgtCaps = new BasicSourceCapabilities();
+
+ tgtCaps.setCapabilitySupport(Capability.QUERY_SELECT_DISTINCT, srcCaps.supportsSelectDistinct());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_SELECT_LITERALS, srcCaps.supportsSelectLiterals());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, srcCaps.supportsAliasedGroup());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN, srcCaps.supportsJoins());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, srcCaps.supportsSelfJoins());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, srcCaps.supportsOuterJoins());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, srcCaps.supportsFullOuterJoins());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, srcCaps.supportsInlineViews());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE, srcCaps.supportsCriteria());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_BETWEEN, srcCaps.supportsBetweenCriteria());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE, srcCaps.supportsCompareCriteria());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE_EQ, srcCaps.supportsCompareCriteriaEquals());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE_NE, srcCaps.supportsCompareCriteriaNotEquals());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE_LT, srcCaps.supportsCompareCriteriaLessThan());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE_LE, srcCaps.supportsCompareCriteriaLessThanOrEqual());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE_GT, srcCaps.supportsCompareCriteriaGreaterThan());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE_GE, srcCaps.supportsCompareCriteriaGreaterThanOrEqual());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_LIKE, srcCaps.supportsLikeCriteria());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_LIKE_ESCAPE, srcCaps.supportsLikeCriteriaEscapeCharacter());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_IN, srcCaps.supportsInCriteria());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_IN_SUBQUERY, srcCaps.supportsInCriteriaSubquery());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_ISNULL, srcCaps.supportsIsNullCriteria());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_AND, srcCaps.supportsAndCriteria());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_OR, srcCaps.supportsOrCriteria());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_NOT, srcCaps.supportsNotCriteria());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_EXISTS, srcCaps.supportsExistsCriteria());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_QUANTIFIED_COMPARISON, srcCaps.supportsQuantifiedCompareCriteria());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_QUANTIFIED_SOME, srcCaps.supportsQuantifiedCompareCriteriaSome());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_WHERE_QUANTIFIED_ALL, srcCaps.supportsQuantifiedCompareCriteriaAll());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_ORDERBY, srcCaps.supportsOrderBy());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES, srcCaps.supportsAggregates());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, srcCaps.supportsAggregatesSum());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_AVG, srcCaps.supportsAggregatesAvg());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MIN, srcCaps.supportsAggregatesMin());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, srcCaps.supportsAggregatesMax());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, srcCaps.supportsAggregatesCount());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, srcCaps.supportsAggregatesCountStar());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_DISTINCT, srcCaps.supportsAggregatesDistinct());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, srcCaps.supportsScalarSubqueries());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, srcCaps.supportsCorrelatedSubqueries());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_CASE, srcCaps.supportsCaseExpressions());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, srcCaps.supportsSearchedCaseExpressions());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_UNION, srcCaps.supportsUnions());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_INTERSECT, srcCaps.supportsIntersect());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_EXCEPT, srcCaps.supportsExcept());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, srcCaps.supportsSetQueryOrderBy());
+ tgtCaps.setCapabilitySupport(Capability.BULK_INSERT , srcCaps.supportsBulkInsert());
+ tgtCaps.setCapabilitySupport(Capability.BATCHED_UPDATES, srcCaps.supportsBatchedUpdates());
+ tgtCaps.setCapabilitySupport(Capability.FUNCTION, srcCaps.supportsScalarFunctions());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_FUNCTIONS_IN_GROUP_BY, srcCaps.supportsFunctionsInGroupBy());
+ tgtCaps.setCapabilitySupport(Capability.ROW_LIMIT, srcCaps.supportsRowLimit());
+ tgtCaps.setCapabilitySupport(Capability.ROW_OFFSET, srcCaps.supportsRowOffset());
+ tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_ANSI_JOIN, srcCaps.useAnsiJoin());
+ tgtCaps.setCapabilitySupport(Capability.REQUIRES_CRITERIA, srcCaps.requiresCriteria());
+
+ List functions = srcCaps.getSupportedFunctions();
+ if(functions != null && functions.size() > 0) {
+ Iterator iter = functions.iterator();
+ while(iter.hasNext()) {
+ String func = (String) iter.next();
+ tgtCaps.setFunctionSupport(func.toLowerCase(), true);
+ }
+ }
+
+ tgtCaps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(srcCaps.getMaxInCriteriaSize()));
+ tgtCaps.setSourceProperty(Capability.CONNECTOR_ID, connectorID);
+ tgtCaps.setSourceProperty(Capability.MAX_QUERY_FROM_GROUPS, new Integer(srcCaps.getMaxFromGroups()));
+ tgtCaps.setSourceProperty(Capability.TRANSACTIONS_XA, isXa);
+ return tgtCaps;
+ }
+
+}
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl (from rev 569, trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl)
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/AsynchConnectorWorkItem.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/AsynchConnectorWorkItem.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/AsynchConnectorWorkItem.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.impl;
+package org.teiid.dqp.internal.datamgr.impl;
import com.metamatrix.common.comm.api.ResultsReceiver;
import com.metamatrix.core.util.Assertion;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorEnvironmentImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ConnectorEnvironmentImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorEnvironmentImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -24,7 +24,7 @@
* Date: Sep 10, 2003
* Time: 3:58:41 PM
*/
-package com.metamatrix.dqp.internal.datamgr.impl;
+package org.teiid.dqp.internal.datamgr.impl;
import java.util.Properties;
@@ -33,10 +33,10 @@
import org.teiid.connector.api.TypeFacility;
import org.teiid.connector.internal.ConnectorPropertyNames;
import org.teiid.connector.language.ILanguageFactory;
+import org.teiid.dqp.internal.datamgr.language.LanguageFactoryImpl;
import com.metamatrix.common.application.ApplicationEnvironment;
import com.metamatrix.common.queue.WorkerPool;
-import com.metamatrix.dqp.internal.datamgr.language.LanguageFactoryImpl;
/**
* Default Connector Environment.
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ConnectorManager.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -24,7 +24,7 @@
* Date: Aug 25, 2003
* Time: 3:53:37 PM
*/
-package com.metamatrix.dqp.internal.datamgr.impl;
+package org.teiid.dqp.internal.datamgr.impl;
import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
@@ -52,6 +52,11 @@
import org.teiid.connector.internal.ConnectorPropertyNames;
import org.teiid.connector.xa.api.XAConnection;
import org.teiid.connector.xa.api.XAConnector;
+import org.teiid.dqp.internal.cache.ResultSetCache;
+import org.teiid.dqp.internal.datamgr.CapabilitiesConverter;
+import org.teiid.dqp.internal.pooling.connector.PooledConnector;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+import org.teiid.dqp.internal.transaction.TransactionProvider;
import com.metamatrix.common.application.ApplicationEnvironment;
import com.metamatrix.common.application.ApplicationService;
@@ -67,12 +72,7 @@
import com.metamatrix.core.util.ReflectionHelper;
import com.metamatrix.core.util.StringUtil;
import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.internal.cache.ResultSetCache;
-import com.metamatrix.dqp.internal.datamgr.CapabilitiesConverter;
import com.metamatrix.dqp.internal.datamgr.ConnectorID;
-import com.metamatrix.dqp.internal.pooling.connector.PooledConnector;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
-import com.metamatrix.dqp.internal.transaction.TransactionProvider;
import com.metamatrix.dqp.message.AtomicRequestID;
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.message.AtomicResultsMessage;
@@ -359,11 +359,22 @@
currentThread.setContextClassLoader(classloader);
Connector c;
try {
- c = (Connector)ReflectionHelper.create(connectorClassName, null, classloader);
+ Object o = ReflectionHelper.create(connectorClassName, null, classloader);
+ if (o instanceof Connector) {
+ c = (Connector)o;
+ this.isXa = PropertiesUtils.getBooleanProperty(env.getProperties(), ConnectorPropertyNames.IS_XA, false);
+ } else {
+ try {
+ Class legacyConnector = classloader.loadClass("com.metamatrix.data.api.Connector"); //$NON-NLS-1$
+ c = (Connector)ReflectionHelper.create("com.metamatrix.dqp.internal.datamgr.ConnectorWrapper", new Object[] {o}, new Class[] {legacyConnector}, classloader); //$NON-NLS-1$
+ this.isXa = classloader.loadClass("com.metamatrix.data.xa.api.XAConnector").isAssignableFrom(o.getClass()); //$NON-NLS-1$
+ } catch (ClassNotFoundException e) {
+ throw new ApplicationLifecycleException(e, DQPPlugin.Util.getString("failed_find_Connector_class", connectorClassName)); //$NON-NLS-1$
+ }
+ }
} catch (MetaMatrixCoreException e) {
throw new ApplicationLifecycleException(e, DQPPlugin.Util.getString("failed_find_Connector_class", connectorClassName)); //$NON-NLS-1$
}
- this.isXa = PropertiesUtils.getBooleanProperty(env.getProperties(), ConnectorPropertyNames.IS_XA, false);
if (this.isXa) {
if(!(c instanceof XAConnector)){
throw new ApplicationLifecycleException(DQPPlugin.Util.getString("non_xa_connector", connectorName)); //$NON-NLS-1$
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ConnectorWorkItem.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.impl;
+package org.teiid.dqp.internal.datamgr.impl;
import java.util.ArrayList;
import java.util.Arrays;
@@ -39,6 +39,10 @@
import org.teiid.connector.language.IQueryCommand;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import org.teiid.connector.xa.api.XAConnector;
+import org.teiid.dqp.internal.datamgr.language.LanguageBridgeFactory;
+import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
+import org.teiid.dqp.internal.process.AbstractWorkItem;
+import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
@@ -49,10 +53,6 @@
import com.metamatrix.common.types.TransformationException;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.internal.datamgr.language.LanguageBridgeFactory;
-import com.metamatrix.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
-import com.metamatrix.dqp.internal.process.AbstractWorkItem;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.dqp.message.AtomicRequestID;
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.message.AtomicResultsMessage;
@@ -311,17 +311,17 @@
// Create the execution based on mode
final Execution exec = connection.createExecution(this.translatedCommand, this.securityContext, rmd);
if (this.translatedCommand instanceof IProcedure) {
- Assertion.isInstanceOf(this.execution, ProcedureExecution.class, "IProcedure Executions are expected to be ProcedureExecutions");
+ Assertion.isInstanceOf(this.execution, ProcedureExecution.class, "IProcedure Executions are expected to be ProcedureExecutions"); //$NON-NLS-1$
this.execution = (ProcedureExecution)exec;
StoredProcedure proc = (StoredProcedure)command;
if (proc.returnParameters()) {
this.procedureBatchHandler = new ProcedureBatchHandler((IProcedure)this.translatedCommand, (ProcedureExecution)this.execution);
}
} else if (this.translatedCommand instanceof IQueryCommand){
- Assertion.isInstanceOf(this.execution, ResultSetExecution.class, "IQueryCommand Executions are expected to be ResultSetExecutions");
+ Assertion.isInstanceOf(this.execution, ResultSetExecution.class, "IQueryCommand Executions are expected to be ResultSetExecutions"); //$NON-NLS-1$
this.execution = (ResultSetExecution)exec;
} else {
- Assertion.isInstanceOf(this.execution, UpdateExecution.class, "Update Executions are expected to be UpdateExecutions");
+ Assertion.isInstanceOf(this.execution, UpdateExecution.class, "Update Executions are expected to be UpdateExecutions"); //$NON-NLS-1$
this.execution = new ResultSetExecution() {
private int[] results;
private int index;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWrapper.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ConnectorWrapper.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWrapper.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.impl;
+package org.teiid.dqp.internal.datamgr.impl;
import org.teiid.connector.api.Connection;
import org.teiid.connector.api.Connector;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/DefaultConnectorLogger.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/DefaultConnectorLogger.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/DefaultConnectorLogger.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -24,7 +24,7 @@
* Date: Sep 16, 2003
* Time: 11:23:00 AM
*/
-package com.metamatrix.dqp.internal.datamgr.impl;
+package org.teiid.dqp.internal.datamgr.impl;
import org.teiid.connector.api.ConnectorLogger;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ExecutionContextImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.impl;
+package org.teiid.dqp.internal.datamgr.impl;
import java.io.Serializable;
import java.util.ArrayList;
@@ -169,7 +169,7 @@
return "ExecutionContext<vdb=" + this.vdbName + ", version=" + this.vdbVersion + ", user=" + this.userName + ">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
- boolean isTransactional() {
+ public boolean isTransactional() {
return isTransactional;
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ProcedureBatchHandler.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ProcedureBatchHandler.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ProcedureBatchHandler.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -23,7 +23,7 @@
/**
*
*/
-package com.metamatrix.dqp.internal.datamgr.impl;
+package org.teiid.dqp.internal.datamgr.impl;
import java.util.ArrayList;
import java.util.Arrays;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.impl;
+package org.teiid.dqp.internal.datamgr.impl;
import java.util.HashMap;
import java.util.Map;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/TypeFacilityImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/TypeFacilityImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/TypeFacilityImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.impl;
+package org.teiid.dqp.internal.datamgr.impl;
import java.util.Calendar;
import java.util.Date;
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language (from rev 569, trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language)
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/AggregateImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/AggregateImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/AggregateImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import org.teiid.connector.language.IAggregate;
import org.teiid.connector.language.IExpression;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/BaseLanguageObject.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/BaseLanguageObject.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/BaseLanguageObject.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import org.teiid.connector.language.ILanguageObject;
import org.teiid.connector.visitor.util.SQLStringVisitor;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/BatchedUpdatesImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/BatchedUpdatesImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/BatchedUpdatesImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.List;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/BulkInsertImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/BulkInsertImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/BulkInsertImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.Collections;
import java.util.List;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/CompareCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/CompareCriteriaImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/CompareCriteriaImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import org.teiid.connector.language.ICompareCriteria;
import org.teiid.connector.language.IExpression;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/CompoundCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/CompoundCriteriaImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/CompoundCriteriaImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.List;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/DeleteImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/DeleteImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/DeleteImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import org.teiid.connector.language.ICriteria;
import org.teiid.connector.language.IDelete;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ElementImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/ElementImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ElementImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import org.teiid.connector.language.IElement;
import org.teiid.connector.language.IGroup;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ExistsCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/ExistsCriteriaImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ExistsCriteriaImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import org.teiid.connector.language.IExistsCriteria;
import org.teiid.connector.language.IQuery;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/FromImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/FromImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/FromImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.List;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/FunctionImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/FunctionImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/FunctionImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/GroupByImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/GroupByImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/GroupByImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.List;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/GroupImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/GroupImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/GroupImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import org.teiid.connector.language.IGroup;
import org.teiid.connector.metadata.runtime.Group;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/InCriteriaImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InCriteriaImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.List;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InlineViewImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/InlineViewImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InlineViewImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import org.teiid.connector.language.IInlineView;
import org.teiid.connector.language.IQueryCommand;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InsertImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/InsertImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/InsertImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.List;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/IsNullCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/IsNullCriteriaImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/IsNullCriteriaImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import org.teiid.connector.language.IExpression;
import org.teiid.connector.language.IIsNullCriteria;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/JoinImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/JoinImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/JoinImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.List;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/LanguageBridgeFactory.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.ArrayList;
import java.util.Iterator;
@@ -69,11 +69,11 @@
import org.teiid.connector.language.ISubqueryCompareCriteria.Quantifier;
import org.teiid.connector.metadata.runtime.Parameter;
import org.teiid.connector.metadata.runtime.Procedure;
+import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
import com.metamatrix.dqp.message.ParameterInfo;
import com.metamatrix.dqp.util.LogConstants;
import com.metamatrix.query.metadata.QueryMetadataInterface;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageFactoryImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/LanguageFactoryImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageFactoryImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.Arrays;
import java.util.List;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LikeCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/LikeCriteriaImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LikeCriteriaImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import org.teiid.connector.language.IExpression;
import org.teiid.connector.language.ILikeCriteria;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LimitImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/LimitImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LimitImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import org.teiid.connector.language.ILimit;
import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LiteralImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/LiteralImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LiteralImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import org.teiid.connector.language.ILiteral;
import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/NotCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/NotCriteriaImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/NotCriteriaImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import org.teiid.connector.language.ICriteria;
import org.teiid.connector.language.INotCriteria;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/OrderByImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/OrderByImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/OrderByImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.List;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/OrderByItemImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/OrderByItemImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/OrderByItemImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import org.teiid.connector.language.IElement;
import org.teiid.connector.language.IOrderByItem;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ParameterImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/ParameterImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ParameterImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import org.teiid.connector.language.IParameter;
import org.teiid.connector.metadata.runtime.Parameter;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ProcedureImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/ProcedureImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ProcedureImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.Iterator;
import java.util.List;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/QueryCommandImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/QueryCommandImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/QueryCommandImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.Iterator;
import java.util.List;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/QueryImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/QueryImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/QueryImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.Iterator;
import java.util.List;
@@ -150,7 +150,7 @@
}
/**
- * @see com.metamatrix.dqp.internal.datamgr.language.QueryCommandImpl#getProjectedQuery()
+ * @see org.teiid.dqp.internal.datamgr.language.QueryCommandImpl#getProjectedQuery()
*/
public IQuery getProjectedQuery() {
return this;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ScalarSubqueryImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/ScalarSubqueryImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/ScalarSubqueryImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import org.teiid.connector.language.IQueryCommand;
import org.teiid.connector.language.IScalarSubquery;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SearchedCaseExpressionImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/SearchedCaseExpressionImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SearchedCaseExpressionImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.List;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SelectImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/SelectImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SelectImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.List;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SelectSymbolImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/SelectSymbolImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SelectSymbolImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import org.teiid.connector.language.IExpression;
import org.teiid.connector.language.ISelectSymbol;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetClauseImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/SetClauseImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetClauseImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import org.teiid.connector.language.IElement;
import org.teiid.connector.language.IExpression;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetClauseListImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/SetClauseListImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetClauseListImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetQueryImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/SetQueryImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SetQueryImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import org.teiid.connector.language.IQuery;
import org.teiid.connector.language.IQueryCommand;
@@ -34,7 +34,7 @@
private Operation operation;
/**
- * @see com.metamatrix.dqp.internal.datamgr.language.QueryCommandImpl#getProjectedQuery()
+ * @see org.teiid.dqp.internal.datamgr.language.QueryCommandImpl#getProjectedQuery()
*/
public IQuery getProjectedQuery() {
if (leftQuery instanceof IQuery) {
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SubqueryCompareCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/SubqueryCompareCriteriaImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SubqueryCompareCriteriaImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import org.teiid.connector.language.*;
import org.teiid.connector.language.ICompareCriteria.Operator;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SubqueryInCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/SubqueryInCriteriaImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/SubqueryInCriteriaImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import org.teiid.connector.language.*;
import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/UpdateImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/UpdateImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/UpdateImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import org.teiid.connector.language.ICriteria;
import org.teiid.connector.language.IGroup;
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata (from rev 569, trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata)
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ElementImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ElementImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ElementImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -22,7 +22,7 @@
/*
*/
-package com.metamatrix.dqp.internal.datamgr.metadata;
+package org.teiid.dqp.internal.datamgr.metadata;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.metadata.runtime.Element;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/GroupImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/GroupImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/GroupImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -22,7 +22,7 @@
/*
*/
-package com.metamatrix.dqp.internal.datamgr.metadata;
+package org.teiid.dqp.internal.datamgr.metadata;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/MetadataObjectImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/MetadataObjectImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/MetadataObjectImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -22,7 +22,7 @@
/*
*/
-package com.metamatrix.dqp.internal.datamgr.metadata;
+package org.teiid.dqp.internal.datamgr.metadata;
import java.util.Properties;
@@ -53,7 +53,7 @@
}
}
- Object getActualID() {
+ public Object getActualID() {
return actualID;
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ParameterImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ParameterImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ParameterImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.metadata;
+package org.teiid.dqp.internal.datamgr.metadata;
import java.util.ArrayList;
import java.util.Collections;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ProcedureImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ProcedureImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/ProcedureImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -22,7 +22,7 @@
/*
*/
-package com.metamatrix.dqp.internal.datamgr.metadata;
+package org.teiid.dqp.internal.datamgr.metadata;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -22,7 +22,7 @@
/*
*/
-package com.metamatrix.dqp.internal.datamgr.metadata;
+package org.teiid.dqp.internal.datamgr.metadata;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.metadata.runtime.*;
@@ -129,7 +129,7 @@
}
}
- QueryMetadataInterface getMetadata() {
+ public QueryMetadataInterface getMetadata() {
return metadata;
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/TypeModelImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/TypeModelImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/TypeModelImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.metadata;
+package org.teiid.dqp.internal.datamgr.metadata;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.metadata.runtime.Element;
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/pooling/connector (from rev 569, trunk/engine/src/main/java/com/metamatrix/dqp/internal/pooling/connector)
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/pooling/connector
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/pooling/connector/ConnectionPool.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/pooling/connector/ConnectionPool.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/pooling/connector/ConnectionPool.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.pooling.connector;
+package org.teiid.dqp.internal.pooling.connector;
import java.util.ArrayList;
import java.util.Collection;
@@ -45,12 +45,12 @@
import org.teiid.connector.api.SingleIdentity;
import org.teiid.connector.xa.api.TransactionContext;
import org.teiid.connector.xa.api.XAConnector;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorWrapper;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.ArgCheck;
-import com.metamatrix.dqp.internal.datamgr.impl.ConnectorWrapper;
import com.metamatrix.dqp.util.LogConstants;
public class ConnectionPool {
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/pooling/connector/ConnectionPoolException.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/pooling/connector/ConnectionPoolException.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/pooling/connector/ConnectionPoolException.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -22,7 +22,7 @@
/*
*/
-package com.metamatrix.dqp.internal.pooling.connector;
+package org.teiid.dqp.internal.pooling.connector;
import org.teiid.connector.api.ConnectorException;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/pooling/connector/ConnectionWrapper.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/pooling/connector/ConnectionWrapper.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/pooling/connector/ConnectionWrapper.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.pooling.connector;
+package org.teiid.dqp.internal.pooling.connector;
import javax.transaction.xa.XAResource;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/pooling/connector/PooledConnector.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/pooling/connector/PooledConnector.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/pooling/connector/PooledConnector.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.pooling.connector;
+package org.teiid.dqp.internal.pooling.connector;
import java.util.Collections;
import java.util.HashMap;
@@ -39,8 +39,8 @@
import org.teiid.connector.xa.api.TransactionContext;
import org.teiid.connector.xa.api.XAConnection;
import org.teiid.connector.xa.api.XAConnector;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorWrapper;
-import com.metamatrix.dqp.internal.datamgr.impl.ConnectorWrapper;
/**
* Implements Pooling around a Connector or XAConnector.
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java (from rev 569, trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/AbstractWorkItem.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,125 @@
+/*
+ * 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 com.metamatrix.common.log.LogManager;
+import com.metamatrix.dqp.util.LogConstants;
+
+
+/**
+ * Represents a task that performs work that may take more than one processing pass to complete.
+ * During processing the WorkItem may receive events asynchronously through the moreWork method.
+ */
+public abstract class AbstractWorkItem implements Runnable {
+
+ enum ThreadState {
+ MORE_WORK, WORKING, IDLE, DONE
+ }
+
+ private ThreadState threadState = ThreadState.MORE_WORK;
+
+ public void run() {
+ try {
+ startProcessing();
+ process();
+ } finally {
+ endProcessing();
+ }
+ }
+
+ ThreadState getThreadState() {
+ return this.threadState;
+ }
+
+ private synchronized void startProcessing() {
+ logTrace("start processing"); //$NON-NLS-1$
+ if (this.threadState != ThreadState.MORE_WORK) {
+ throw new IllegalStateException("Must be in MORE_WORK"); //$NON-NLS-1$
+ }
+ this.threadState = ThreadState.WORKING;
+ }
+
+ private synchronized void endProcessing() {
+ logTrace("end processing"); //$NON-NLS-1$
+ switch (this.threadState) {
+ case WORKING:
+ if (isDoneProcessing()) {
+ logTrace("done processing"); //$NON-NLS-1$
+ this.threadState = ThreadState.DONE;
+ } else {
+ this.threadState = ThreadState.IDLE;
+ pauseProcessing();
+ }
+ break;
+ case MORE_WORK:
+ if (isDoneProcessing()) {
+ logTrace("done processing - ignoring more"); //$NON-NLS-1$
+ this.threadState = ThreadState.DONE;
+ } else {
+ resumeProcessing();
+ }
+ break;
+ default:
+ throw new IllegalStateException("Should not END on IDLE or DONE"); //$NON-NLS-1$
+ }
+ }
+
+ protected void moreWork() {
+ moreWork(true);
+ }
+
+ protected synchronized void moreWork(boolean ignoreDone) {
+ logTrace("more work"); //$NON-NLS-1$
+ switch (this.threadState) {
+ case WORKING:
+ this.threadState = ThreadState.MORE_WORK;
+ break;
+ case MORE_WORK:
+ break;
+ case IDLE:
+ this.threadState = ThreadState.MORE_WORK;
+ resumeProcessing();
+ break;
+ default:
+ if (!ignoreDone) {
+ throw new IllegalStateException("More work is not valid once DONE"); //$NON-NLS-1$
+ }
+ LogManager.logDetail(LogConstants.CTX_DQP, new Object[] {this, "ignoring more work, since the work item is done"}); //$NON-NLS-1$
+ }
+ }
+
+ private void logTrace(String msg) {
+ LogManager.logTrace(LogConstants.CTX_DQP, new Object[] {this, msg, this.threadState});
+ }
+
+ protected abstract void process();
+
+ protected void pauseProcessing() {
+ }
+
+ protected abstract void resumeProcessing();
+
+ protected abstract boolean isDoneProcessing();
+
+ public abstract String toString();
+}
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedRequestWorkItem.java (from rev 569, trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/CachedRequestWorkItem.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedRequestWorkItem.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedRequestWorkItem.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,100 @@
+/*
+ * 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.List;
+
+import javax.transaction.SystemException;
+
+import org.teiid.dqp.internal.cache.CacheResults;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.MetaMatrixProcessingException;
+import com.metamatrix.common.buffer.BlockedException;
+import com.metamatrix.common.buffer.BlockedOnMemoryException;
+import com.metamatrix.common.buffer.TupleBatch;
+import com.metamatrix.common.buffer.TupleSourceNotFoundException;
+import com.metamatrix.common.comm.api.ResultsReceiver;
+import com.metamatrix.common.comm.exception.CommunicationException;
+import com.metamatrix.core.MetaMatrixCoreException;
+import com.metamatrix.dqp.message.RequestID;
+import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.message.ResultsMessage;
+import com.metamatrix.query.sql.lang.Command;
+
+public class CachedRequestWorkItem extends RequestWorkItem {
+
+ public CachedRequestWorkItem(DQPCore dqpCore, RequestMessage requestMsg, Request request, ResultsReceiver<ResultsMessage> receiver, RequestID requestID, DQPWorkContext workContext, Command originalCommand) {
+ super(dqpCore, requestMsg, request, receiver, requestID, workContext);
+ this.originalCommand = originalCommand;
+ }
+
+ @Override
+ protected void processNew() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ request.initMetadata();
+ request.validateEntitlement(originalCommand);
+ this.request = null;
+ }
+
+ @Override
+ protected void processMore() throws SystemException, BlockedException,
+ MetaMatrixCoreException {
+ //do nothing
+ }
+
+
+ @Override
+ protected void sendResultsIfNeeded(TupleBatch batch)
+ throws BlockedOnMemoryException, MetaMatrixComponentException,
+ CommunicationException, TupleSourceNotFoundException {
+ synchronized (this.resultsCursor) {
+ if (!this.resultsCursor.resultsRequested) {
+ return;
+ }
+ }
+ CacheResults cResult = rsCache.getResults(cid, new int[] {this.resultsCursor.begin, this.resultsCursor.end});
+ List results[] = cResult.getResults();
+ int firstRow = cResult.getFirstRow();
+
+ ResultsMessage response = createResultsMessage(requestMsg, results, cResult.getElements(), cResult.getAnalysisRecord());
+ response.setFirstRow(firstRow);
+ response.setLastRow(firstRow + results.length - 1);
+
+ boolean isFinal = cResult.isFinal();
+ if(isFinal){
+ response.setFinalRow(cResult.getFinalRow());
+ }
+ response.setPartialResults(!isFinal);
+
+ this.resultsCursor.resultsSent();
+ this.resultsReceiver.receiveResults(response);
+ }
+
+ @Override
+ protected void attemptClose() {
+ this.isClosed = true;
+ dqpCore.logMMCommand(requestMsg, false, false, -1);
+ this.dqpCore.removeRequest(this);
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedRequestWorkItem.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/CodeTableCache.java (from rev 569, trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/CodeTableCache.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/CodeTableCache.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/CodeTableCache.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,368 @@
+/*
+ * 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.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.MetaMatrixProcessingException;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.core.util.HashCodeUtil;
+import com.metamatrix.dqp.DQPPlugin;
+import com.metamatrix.dqp.util.LogConstants;
+import com.metamatrix.query.util.CommandContext;
+
+/**
+ * Code table cache.
+ */
+class CodeTableCache {
+
+ // Max number of code tables that can be loaded
+ private int maxCodeTables;
+
+ // Caches being loaded - key is CacheKey, value is WaitingRequests
+ private Map loadingCaches = new HashMap();
+
+ // Map of RequestID/nodeID -> CacheKey
+ private Map requestToCacheKeyMap = Collections.synchronizedMap(new HashMap());
+
+ // Cache itself - key is CacheKey, value is Map (which is the key value -> return value for the code table)
+ private Map codeTableCache = new HashMap();
+
+ // Cache keys for stuff already in the cache
+ private Set cacheKeyDone = new HashSet();
+
+ public enum CacheState {
+ CACHE_EXISTS,
+ CACHE_LOADING,
+ CACHE_NOT_EXIST,
+ CACHE_OVERLOAD
+ }
+
+ private AtomicInteger requestSequence = new AtomicInteger();
+
+ /**
+ * Construct a code table cache
+ */
+ public CodeTableCache(int maxCodeTables) {
+ this.maxCodeTables = maxCodeTables;
+ }
+
+ /**
+ * Return the state of cache.
+ * @param codeTable code table name
+ * @param returnElement return element name
+ * @param keyElement key element name
+ * @param context context in processing
+ * @param keyValye key value cached in data map
+ * @return int of cache states
+ */
+ public synchronized CacheState cacheExists(String codeTable, String returnElement, String keyElement, CommandContext context) {
+ // Check whether CacheKey exist in cacheKeyDone:
+ // If yes, return CACHE_EXISTS
+ // If no, does it exist in loadingCaches?
+ // If yes, add to additional contexts and return CACHE_LOADING
+ // If no, can we add another cache?
+ // If yes, add to loadingCaches as primary context, return CACHE_NOT_EXIST
+ // If no, return CACHE_OVERLOAD
+
+ // Create a CacheKey
+ CacheKey cacheKey = new CacheKey(codeTable, returnElement, keyElement, context.getVdbName(), context.getVdbVersion());
+
+ if (cacheKeyDone.contains(cacheKey)) { // CacheKey exists in codeTableCache
+ return CacheState.CACHE_EXISTS;
+
+ }
+ if (loadingCaches.containsKey(cacheKey)) { // CacheKey exists in loadingCache
+ // Add context to additional contexts
+ WaitingRequests wqr = (WaitingRequests) loadingCaches.get(cacheKey);
+ wqr.addRequestID(context.getProcessorID());
+ loadingCaches.put(cacheKey, wqr);
+ return CacheState.CACHE_LOADING;
+
+ } else if(codeTableCache.size() + loadingCaches.size() >= maxCodeTables) {
+ // In this case we already have some number of existing + loading caches
+ // that are >= the max number we are allowed to have. Thus, we cannot load
+ // another cache.
+ return CacheState.CACHE_OVERLOAD;
+
+ } else { // CacheKey not exists in loadingCache
+ // Add to loadingCaches as primary context
+ WaitingRequests wqr = new WaitingRequests(context.getProcessorID());
+ loadingCaches.put(cacheKey, wqr);
+ return CacheState.CACHE_NOT_EXIST;
+ }
+ }
+
+ /**
+ * Set request ID for request key to cache key mapping.
+ * <Map: requestKey(requestID, nodeID) --> cacheKey(codeTable, returnElement, keyElement) >
+ * @param codeTable Code table name
+ * @param returnElement Return element name
+ * @param keyElement Key element name
+ * @param requestID Request ID
+ * @param nodeID Plan Node ID
+ */
+ public Integer createCacheRequest(String codeTable, String returnElement, String keyElement, CommandContext context) {
+ // Create a cache key
+ CacheKey cacheKey = new CacheKey(codeTable, returnElement, keyElement, context.getVdbName(), context.getVdbVersion());
+ Integer result = this.requestSequence.getAndIncrement();
+
+ // Add requestID/nodeID pair to map for later lookup
+ requestToCacheKeyMap.put(result, cacheKey);
+ return result;
+ }
+
+ /**
+ * Load all rows from the tuple source. Each row contains: keyElement and returnElement.
+ * @param requestID Part of RequestKey
+ * @param nodeID Part of RequestKey
+ * @param results QueryResults of <List<List<keyValue, returnValue>>
+ * @throws MetaMatrixProcessingException
+ */
+ public synchronized void loadTable(Integer requestKey, List[] records) throws MetaMatrixProcessingException {
+ // Look up cache key by requestID/nodeID pair
+ CacheKey cacheKey = (CacheKey) requestToCacheKeyMap.get(requestKey);
+
+ // Lookup the existing data
+ // Map of data: keyValue --> returnValue;
+ Map existingMap = (Map) codeTableCache.get(cacheKey);
+ if(existingMap == null) {
+ existingMap = new HashMap();
+ codeTableCache.put(cacheKey, existingMap);
+ }
+
+ // Add data: <List<List<keyValue, returnValue>> from results to the code table cache
+ for ( int i = 0; i < records.length; i++ ) {
+ // each record or row
+ List record = records[i];
+ Object keyValue = record.get(0);
+ Object returnValue = record.get(1);
+ Object existing = existingMap.put(keyValue, returnValue);
+ if (existing != null) {
+ throw new MetaMatrixProcessingException(DQPPlugin.Util.getString("CodeTableCache.duplicate_key", cacheKey.getCodeTable(), cacheKey.getKeyElement(), keyValue)); //$NON-NLS-1$
+ }
+ }
+ }
+
+ /**
+ * Look up return value in code table cache given the key value.
+ * @param codeTable Code Table name
+ * @param returnElement Return element name
+ * @param keyElement Key element name
+ * @param keyValue Input key value
+ * @return Object of return value in code table cache
+ */
+ public synchronized Object lookupValue(String codeTable, String returnElement, String keyElement, Object keyValue, CommandContext context) throws MetaMatrixComponentException {
+ Object returnValue = null;
+
+ // Create CacheKey
+ CacheKey cacheKey = new CacheKey(codeTable, returnElement, keyElement, context.getVdbName(), context.getVdbVersion());
+
+ // Find the corresponding data map in cache for the cache key
+ Map dataMap = (Map) codeTableCache.get(cacheKey);
+ if(dataMap == null) {
+ Object[] params = new Object[] {codeTable,keyElement,returnElement};
+ throw new MetaMatrixComponentException(DQPPlugin.Util.getString("CodeTableCache.No_code_table", params)); //$NON-NLS-1$
+ }
+ returnValue = dataMap.get(keyValue);
+ return returnValue;
+ }
+
+ /**
+ * Places the lookup results in the cache and marks the cache loaded
+ * @param requestID
+ * @param nodeID
+ * @return the set of waiting requests
+ * @since 4.2
+ */
+ public Set markCacheLoaded(Integer requestKey) {
+ return markCacheDone(requestKey, false);
+ }
+
+ /**
+ * Notifies the CodeTableCache that this code table had an error. Removes any existing cached results and clears any state
+ * for this CacheKey.
+ * @param requestID
+ * @param nodeID
+ * @return the set of waiting requests
+ * @since 4.2
+ */
+ public Set errorLoadingCache(Integer requestKey) {
+ return markCacheDone(requestKey, true);
+ }
+
+ private synchronized Set markCacheDone(Integer requestKey, boolean errorOccurred) {
+ // Remove request from requestToCacheKeyMap
+ CacheKey cacheKey = (CacheKey) requestToCacheKeyMap.remove(requestKey);
+ if (errorOccurred) {
+ // Remove any results already cached
+ codeTableCache.remove(cacheKey);
+ } else {
+ cacheKeyDone.add(cacheKey);
+ }
+
+ // Remove cache key from loadingCaches
+ WaitingRequests waitingRequests = (WaitingRequests)loadingCaches.remove(cacheKey);
+ if (waitingRequests != null) {
+ return waitingRequests.getWaitingRequestIDs();
+ }
+ return null;
+ }
+
+ public synchronized void clearAll() {
+ // Look through the loaded caches and clear them - this is safe because
+ // these are done. There is a window where cacheExists() can be called and
+ // return CACHE_EXISTS but then clearAll() could be called before lookValue()
+ // is called. We accept this as a possibility such that this is a risk when
+ // clearing the cache - we need to throw an exception in this case to ensure the
+ // query fails (rather than return the wrong result).
+
+ // Walk through every key in the done cache and remove it
+ int removedTables = 0;
+ int removedRecords = 0;
+ Iterator keyIter = cacheKeyDone.iterator();
+ while(keyIter.hasNext()) {
+ CacheKey cacheKey = (CacheKey) keyIter.next();
+ Map codeTable = (Map) codeTableCache.remove(cacheKey);
+ removedTables++;
+ removedRecords += codeTable.size();
+ }
+
+ // Clear the cacheKeyDone
+ cacheKeyDone.clear();
+
+ // Log status
+ LogManager.logInfo(LogConstants.CTX_DQP, DQPPlugin.Util.getString("CodeTableCache.Cleared_code_tables", new Object[]{new Integer(removedTables), new Integer(removedRecords)})); //$NON-NLS-1$
+ }
+
+ /**
+ * Cache Key consists: codeTable, returnElement and keyElement.
+ */
+ private static class CacheKey {
+ private String codeTable;
+ private String returnElement;
+ private String keyElement;
+ private String vdbName;
+ private String vdbVersion;
+
+ private int hashCode;
+
+ public CacheKey(String codeTable, String returnElement, String keyElement, String vdbName, String vdbVersion) {
+ this.codeTable = codeTable;
+ this.returnElement = returnElement;
+ this.keyElement = keyElement;
+ this.vdbName = vdbName;
+ this.vdbVersion = vdbVersion;
+
+ // Compute hash code and cache it
+ hashCode = HashCodeUtil.hashCode(0, codeTable);
+ hashCode = HashCodeUtil.hashCode(hashCode, returnElement);
+ hashCode = HashCodeUtil.hashCode(hashCode, keyElement);
+ hashCode = HashCodeUtil.hashCode(hashCode, vdbName);
+ hashCode = HashCodeUtil.hashCode(hashCode, vdbVersion);
+ }
+
+ public String getCodeTable() {
+ return this.codeTable;
+ }
+
+ public String getReturnElement() {
+ return this.returnElement;
+ }
+
+ public String getKeyElement() {
+ return this.keyElement;
+ }
+
+ public int hashCode() {
+ return hashCode;
+ }
+
+ public boolean equals(Object obj) {
+ if(this == obj) {
+ return true;
+ }
+ if(obj instanceof CacheKey) {
+ CacheKey other = (CacheKey) obj;
+
+ return (other.hashCode() == hashCode() &&
+ this.codeTable.equals(other.codeTable) &&
+ this.returnElement.equals(other.returnElement) &&
+ this.keyElement.equals(other.keyElement) &&
+ this.vdbName.equals(other.vdbName) &&
+ this.vdbVersion.equals(other.vdbVersion));
+ }
+ return false;
+ }
+ }
+
+ /**
+ * Waiting Requests consist: primary requestID and list of additional waiting requestIDs.
+ */
+ private static class WaitingRequests {
+ Object primaryRequestID;
+ Set additionalRequestIDs;
+
+ public WaitingRequests(Object requestID) {
+ this.primaryRequestID = requestID;
+ }
+
+ public void addRequestID(Object requestID) {
+ if(additionalRequestIDs == null) {
+ additionalRequestIDs = new HashSet(8, 0.9f);
+ }
+ additionalRequestIDs.add(requestID);
+ }
+
+ /**
+ * Return the set of requestIDs for waiting requests.
+ * @return Set of waiting requests' IDs
+ */
+ private Set getWaitingRequestIDs() {
+ Set requestIDs = null;
+
+ // Waiting Requests can contain both primary and additional context
+ if (additionalRequestIDs != null) {
+ requestIDs = new HashSet(additionalRequestIDs.size() + 1, 1.0f);
+ requestIDs.addAll(additionalRequestIDs);
+ } else {
+ requestIDs = new HashSet(2, 1.0f);
+ }
+ if (primaryRequestID != null) {
+ requestIDs.add(primaryRequestID);
+ }
+
+ return requestIDs;
+ }
+
+ }
+
+}
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/process/CodeTableCache.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java (from rev 569, trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/DQPCore.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,723 @@
+/*
+ * 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.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.SystemException;
+import javax.transaction.xa.Xid;
+
+import org.teiid.dqp.internal.cache.CacheID;
+import org.teiid.dqp.internal.cache.ResultSetCache;
+import org.teiid.dqp.internal.cache.ResultSetCacheUtil;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.MetaMatrixProcessingException;
+import com.metamatrix.api.exception.query.QueryMetadataException;
+import com.metamatrix.common.application.Application;
+import com.metamatrix.common.application.ApplicationEnvironment;
+import com.metamatrix.common.application.DQPConfigSource;
+import com.metamatrix.common.application.exception.ApplicationInitializationException;
+import com.metamatrix.common.application.exception.ApplicationLifecycleException;
+import com.metamatrix.common.buffer.BufferManager;
+import com.metamatrix.common.lob.LobChunk;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.queue.WorkerPool;
+import com.metamatrix.common.queue.WorkerPoolFactory;
+import com.metamatrix.common.util.PropertiesUtils;
+import com.metamatrix.common.xa.MMXid;
+import com.metamatrix.common.xa.XATransactionException;
+import com.metamatrix.core.log.MessageLevel;
+import com.metamatrix.core.util.LRUCache;
+import com.metamatrix.dqp.DQPPlugin;
+import com.metamatrix.dqp.ResourceFinder;
+import com.metamatrix.dqp.client.ClientSideDQP;
+import com.metamatrix.dqp.client.MetadataResult;
+import com.metamatrix.dqp.client.ResultsFuture;
+import com.metamatrix.dqp.internal.datamgr.ConnectorID;
+import com.metamatrix.dqp.message.AtomicRequestMessage;
+import com.metamatrix.dqp.message.RequestID;
+import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.message.ResultsMessage;
+import com.metamatrix.dqp.service.BufferService;
+import com.metamatrix.dqp.service.ConfigurationService;
+import com.metamatrix.dqp.service.DQPServiceNames;
+import com.metamatrix.dqp.service.DataService;
+import com.metamatrix.dqp.service.MetadataService;
+import com.metamatrix.dqp.service.TrackingService;
+import com.metamatrix.dqp.service.TransactionService;
+import com.metamatrix.dqp.service.VDBService;
+import com.metamatrix.dqp.spi.TrackerLogConstants;
+import com.metamatrix.dqp.util.LogConstants;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
+import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.server.serverapi.RequestInfo;
+import com.metamatrix.vdb.runtime.VDBKey;
+
+/**
+ * Implements the core DQP processing.
+ */
+public class DQPCore extends Application 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;
+ }
+ }
+
+ //Constants
+ private static final int DEFAULT_MAX_CODE_TABLE_RECORDS = 10000;
+ private static final int DEFAULT_MAX_CODE_TABLES = 20;
+ private static final int DEFAULT_PROCESSOR_TIMESLICE = 2000;
+ private static final String PROCESS_PLAN_QUEUE_NAME = "QueryProcessorQueue"; //$NON-NLS-1$
+ private static final String DEAFULT_PROCESS_WORKER_TIMEOUT = "120000"; //$NON-NLS-1$
+ private static final int DEFAULT_MAX_PROCESS_WORKERS = 15;
+
+ // System properties for Code Table
+ private int maxCodeTableRecords = DEFAULT_MAX_CODE_TABLE_RECORDS;
+ private int maxCodeTables = DEFAULT_MAX_CODE_TABLES;
+
+ // Resources
+ private ConnectorCapabilitiesCache connectorCapabilitiesCache = new ConnectorCapabilitiesCache();
+ private BufferManager bufferManager;
+ private DataTierManager dataTierMgr;
+ private PreparedPlanCache prepPlanCache;
+ private TrackingService tracker;
+ private TransactionService transactionService;
+ private MetadataService metadataService;
+ private ResultSetCache rsCache;
+
+ // Query worker pool for processing plans
+ private WorkerPool processWorkerPool;
+ private int processorTimeslice = DEFAULT_PROCESSOR_TIMESLICE;
+ private boolean processDebugAllowed;
+
+ private TempTableStoresHolder tempTableStoresHolder;
+ private int chunkSize = 0;
+
+ private Map<RequestID, RequestWorkItem> requests = Collections.synchronizedMap(new HashMap<RequestID, RequestWorkItem>());
+ private Map<String, List<RequestID>> requestsByClients = Collections.synchronizedMap(new HashMap<String, List<RequestID>>());
+
+ public DQPCore() {
+
+ }
+
+ public DQPCore(ApplicationEnvironment environment) {
+ this.environment = environment;
+ }
+
+ /**
+ * perform a graceful shutdown by allowing in process work to complete
+ * TODO: this is not quite correct from a request perspective, since we need to re-queue in many instances,
+ * which will now result in an exception
+ * @throws ApplicationLifecycleException
+ */
+ @Override
+ public void stop() throws ApplicationLifecycleException {
+ processWorkerPool.shutdown();
+ super.stop();
+ }
+
+ /**
+ * Return a list of {@link RequestInfo} for the given session
+ */
+ public List<RequestInfo> getRequestsByClient(String clientConnection) {
+ List<RequestID> ids = this.requestsByClients.get(clientConnection);
+
+ return buildRequestInfos(ids);
+ }
+
+ /**
+ * Return a list of all {@link RequestInfo}
+ */
+ public List<RequestInfo> getRequests() {
+ List<RequestID> copies = null;
+ synchronized(requests) {
+ copies = new ArrayList<RequestID>(requests.keySet());
+ }
+
+ return buildRequestInfos(copies);
+ }
+
+ private List<RequestInfo> buildRequestInfos(List<RequestID> ids) {
+ if(ids == null) {
+ return Collections.emptyList();
+ }
+ List<RequestInfo> results = new ArrayList<RequestInfo>();
+ for (RequestID requestID : ids) {
+ RequestWorkItem holder = requests.get(requestID);
+
+ if(holder != null && !holder.isCanceled()) {
+ RequestInfo req = new RequestInfo(holder.requestID, holder.requestMsg.getCommandString(), holder.requestMsg.getSubmittedTimestamp(), holder.requestMsg.getProcessingTimestamp());
+ if (holder.getTransactionContext() != null && holder.getTransactionContext().isInTransaction()) {
+ req.setTransactionId(holder.getTransactionContext().getTxnID());
+ }
+
+ for (DataTierTupleSource conInfo : holder.getConnectorRequests()) {
+ ConnectorID connectorID = conInfo.getConnectorId();
+
+ if (connectorID == null) {
+ continue;
+ }
+ // If the request has not yet completed processing, then
+ // add all the subrequest messages
+ AtomicRequestMessage arm = conInfo.getAtomicRequestMessage();
+ RequestInfo info = new RequestInfo(arm.getRequestID(), arm.getCommand().toString(), arm.getSubmittedTimestamp(), arm.getProcessingTimestamp());
+ info.setConnectorBindingUUID(arm.getConnectorBindingID());
+ info.setNodeID(arm.getAtomicRequestID().getNodeID());
+ results.add(info);
+ }
+ results.add(req);
+ }
+ }
+ return results;
+ }
+
+ public ResultsFuture<ResultsMessage> executeRequest(long reqID,
+ RequestMessage requestMsg) {
+ logMMCommand(requestMsg, true, false, 0); //TODO: there is no transaction at this point
+
+ DQPWorkContext workContext = DQPWorkContext.getWorkContext();
+ RequestID requestID = workContext.getRequestID(reqID);
+ requestMsg.markProcessingStart();
+ Map<String, SourceCapabilities> vdbCapabilties = this.connectorCapabilitiesCache.getVDBConnectorCapabilities(workContext);
+
+ Request request = null;
+ if ( requestMsg.isPreparedStatement() || requestMsg.isCallableStatement()) {
+ request = new PreparedStatementRequest(prepPlanCache);
+ } else {
+ request = new Request();
+ }
+ request.initialize(requestMsg, getEnvironment(), bufferManager,
+ dataTierMgr, vdbCapabilties, transactionService,
+ processDebugAllowed, this.tempTableStoresHolder
+ .getTempTableStore(workContext.getConnectionID()),
+ workContext, chunkSize);
+
+ RequestWorkItem workItem = null;
+
+ ResultsFuture<ResultsMessage> resultsFuture = new ResultsFuture<ResultsMessage>();
+
+ if (areResultsInCache(requestMsg)) {
+ CacheID cID = ResultSetCacheUtil.createCacheID(requestMsg, this.rsCache);
+ Command command = this.rsCache.getResults(cID, new int[]{1, 1}).getCommand();
+ workItem = new CachedRequestWorkItem(this, requestMsg, request, resultsFuture.getResultsReceiver(), requestID, workContext, command);
+ }
+ else {
+ workItem = new RequestWorkItem(this, requestMsg, request, resultsFuture.getResultsReceiver(), requestID, workContext);
+ }
+
+ addRequest(requestID, workItem);
+
+ this.addWork(workItem);
+ return resultsFuture;
+ }
+
+ public ResultsFuture<ResultsMessage> processCursorRequest(long reqID,
+ int batchFirst, int batchLast) throws MetaMatrixProcessingException {
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_DQP, "DQP process cursor request from " + batchFirst + " to " + batchLast); //$NON-NLS-1$//$NON-NLS-2$
+ }
+ DQPWorkContext workContext = DQPWorkContext.getWorkContext();
+ ResultsFuture<ResultsMessage> resultsFuture = new ResultsFuture<ResultsMessage>();
+ RequestWorkItem workItem = getRequestWorkItem(workContext.getRequestID(reqID));
+ workItem.requestMore(batchFirst, batchLast, resultsFuture.getResultsReceiver());
+ return resultsFuture;
+ }
+
+ void addRequest(RequestID requestID, RequestWorkItem workItem) {
+ this.requests.put(requestID, workItem);
+ synchronized (requestsByClients) {
+ List<RequestID> clientRequests = this.requestsByClients.get(workItem.getDqpWorkContext().getConnectionID());
+ if (clientRequests == null) {
+ clientRequests = new LinkedList<RequestID>();
+ this.requestsByClients.put(workItem.getDqpWorkContext().getConnectionID(), clientRequests);
+ }
+ clientRequests.add(requestID);
+ }
+ }
+
+ void removeRequest(final RequestWorkItem workItem) {
+ this.requests.remove(workItem.requestID);
+ synchronized (requestsByClients) {
+ List<RequestID> clientRequests = this.requestsByClients.get(workItem.getDqpWorkContext().getConnectionID());
+ if (clientRequests != null) {
+ clientRequests.remove(workItem.requestID);
+ }
+ }
+ }
+
+ boolean areResultsInCache(final RequestMessage requestMsg) {
+ if(this.rsCache == null){
+ return false;
+ }
+ if(!requestMsg.useResultSetCache()){
+ return false;
+ }
+ CacheID cID = ResultSetCacheUtil.createCacheID(requestMsg, this.rsCache);
+ return rsCache.hasResults(cID);
+ }
+
+ void addWork(Runnable r) {
+ this.processWorkerPool.execute(r);
+ }
+
+ public ResultsFuture<?> closeLobChunkStream(int lobRequestId,
+ long requestId, String streamId)
+ throws MetaMatrixProcessingException {
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_DQP, "Request to close the Lob stream with Stream id="+streamId+" instance id="+lobRequestId); //$NON-NLS-1$//$NON-NLS-2$
+ }
+ DQPWorkContext workContext = DQPWorkContext.getWorkContext();
+ RequestWorkItem workItem = getRequestWorkItem(workContext.getRequestID(requestId));
+ workItem.removeLobStream(lobRequestId);
+ ResultsFuture<Void> resultsFuture = new ResultsFuture<Void>();
+ resultsFuture.getResultsReceiver().receiveResults(null);
+ return resultsFuture;
+ }
+
+ public ResultsFuture<LobChunk> requestNextLobChunk(int lobRequestId,
+ long requestId, String streamId)
+ throws MetaMatrixProcessingException {
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_DQP, "Request for next Lob chunk with Stream id="+streamId+" instance id="+lobRequestId); //$NON-NLS-1$//$NON-NLS-2$
+ }
+ RequestWorkItem workItem = getRequestWorkItem(DQPWorkContext.getWorkContext().getRequestID(requestId));
+ ResultsFuture<LobChunk> resultsFuture = new ResultsFuture<LobChunk>();
+ workItem.processLobChunkRequest(streamId, lobRequestId, resultsFuture.getResultsReceiver());
+ return resultsFuture;
+ }
+
+ /**
+ * Cancels a node in the request. (This request is called by the
+ * client directly using the admin API), so if this does not support
+ * partial results then remove the original request.
+ * @throws MetaMatrixComponentException
+ */
+ public void cancelAtomicRequest(RequestID requestID, int nodeID) throws MetaMatrixComponentException {
+ RequestWorkItem workItem = safeGetWorkItem(requestID);
+ if (workItem == null) {
+ return;
+ }
+ workItem.requestAtomicRequestCancel(nodeID);
+ }
+
+ RequestWorkItem getRequestWorkItem(RequestID reqID) throws MetaMatrixProcessingException {
+ RequestWorkItem result = this.requests.get(reqID);
+ if (result == null) {
+ throw new MetaMatrixProcessingException(DQPPlugin.Util.getString("DQPCore.The_request_has_been_cancelled.", reqID));//$NON-NLS-1$
+ }
+ return result;
+ }
+
+ RequestWorkItem safeGetWorkItem(Object processorID) {
+ return this.requests.get((RequestID)processorID);
+ }
+
+ /**
+ * Returns a list of QueueStats objects that represent the queues in
+ * this service.
+ * If there are no queues, an empty Collection is returned.
+ */
+ public Collection getQueueStatistics() {
+ if ( this.processWorkerPool == null ) {
+ return Collections.EMPTY_LIST;
+ }
+
+ return Arrays.asList(processWorkerPool.getStats());
+ }
+
+ /**
+ * Returns a QueueStats object that represent the queue in
+ * this service.
+ * If there is no queue with the given name, an empty Collection is returned.
+ */
+ public Collection getQueueStatistics(String name) {
+ if ( !name.equalsIgnoreCase(PROCESS_PLAN_QUEUE_NAME)) {
+ return Collections.EMPTY_LIST;
+ }
+ return getQueueStatistics();
+ }
+
+ /**
+ * Cancel and close all requests associated with the clientConnection/session. Also runs a final cleanup any caches within
+ * the session's scope.
+ * @param clientConnection
+ * @param sendCancellationsToClient Notify the client that each request has been closed.
+ * @throws MetaMatrixComponentException
+ * @since 4.2
+ */
+ public void terminateConnection(String sessionId) throws MetaMatrixComponentException {
+
+ // sometimes there will not be any atomic requests pending, in that
+ // situation we still need to clear the master request from our map
+ List<RequestID> requestIds = requestsByClients.get(sessionId);
+ if (requestIds != null) {
+ synchronized (requestsByClients) {
+ requestIds = new ArrayList<RequestID>(requestIds);
+ }
+ for (RequestID reqId : requestIds) {
+ try {
+ cancelRequest(reqId);
+ } catch (MetaMatrixComponentException err) {
+ LogManager.logWarning(LogConstants.CTX_DQP, err, "Failed to cancel " + reqId); //$NON-NLS-1$
+ }
+ }
+ }
+
+ // cleanup the buffer manager
+ try {
+ bufferManager.removeTupleSources(sessionId);
+ } catch (Exception e) {
+ LogManager.logWarning(LogConstants.CTX_DQP, e, "Failed to remove buffered tuples for connection " + sessionId); //$NON-NLS-1$
+ }
+ // cleanup the prepared plan cache
+ this.prepPlanCache.clear(sessionId);
+
+ if (transactionService != null) {
+ try {
+ transactionService.getTransactionServer().cancelTransactions(sessionId, false);
+ } catch (InvalidTransactionException err) {
+ LogManager.logWarning(LogConstants.CTX_DQP, "rollback failed for requestID=" + sessionId); //$NON-NLS-1$
+ } catch (SystemException err) {
+ throw new MetaMatrixComponentException(err);
+ }
+ }
+ }
+
+ public boolean cancelRequest(RequestID requestID)
+ throws MetaMatrixComponentException {
+
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_DQP, "cancelQuery for requestID=" + requestID); //$NON-NLS-1$
+ }
+
+ boolean markCancelled = false;
+
+ RequestWorkItem workItem = safeGetWorkItem(requestID);
+ if (workItem != null) {
+ markCancelled = workItem.requestCancel();
+ }
+ if (markCancelled) {
+ logMMCommand(workItem.requestMsg, false, true, 0);
+ } else {
+ LogManager.logDetail(LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPCore.failed_to_cancel")); //$NON-NLS-1$
+ }
+ return markCancelled;
+ }
+
+ public ResultsFuture<?> closeRequest(long requestId) throws MetaMatrixProcessingException {
+ DQPWorkContext workContext = DQPWorkContext.getWorkContext();
+ closeRequest(workContext.getRequestID(requestId));
+ return null;
+ }
+
+ /**
+ * Close the request with given ID
+ * @param requestID
+ */
+ void closeRequest(RequestID requestID) {
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_DQP, "closeQuery for requestID=" + requestID); //$NON-NLS-1$
+ }
+
+ RequestWorkItem workItem = safeGetWorkItem(requestID);
+ if (workItem != null) {
+ workItem.requestClose();
+ } else {
+ LogManager.logDetail(LogConstants.CTX_DQP, requestID + " close call ignored as the request has already been removed."); //$NON-NLS-1$
+ }
+ }
+
+ public void clearPlanCache(){
+ LogManager.logInfo(LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPCore.Clearing_prepared_plan_cache")); //$NON-NLS-1$
+ this.prepPlanCache.clearAll();
+ }
+
+ public void clearCodeTableCache(){
+ LogManager.logInfo(LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPCore.Clearing_code_table_cache")); //$NON-NLS-1$
+ this.dataTierMgr.clearCodeTables();
+ }
+
+ public void clearResultSetCache() {
+ //clear cache in server
+ if(rsCache != null){
+ rsCache.clear();
+ }
+ }
+
+ void logMMCommand(RequestMessage msg, boolean isBegin, boolean isCancel, int rowCount) {
+ if(this.tracker == null || msg == null || !tracker.willRecordMMCmd()){
+ return;
+ }
+ DQPWorkContext workContext = DQPWorkContext.getWorkContext();
+ RequestID rID = new RequestID(workContext.getConnectionID(), msg.getExecutionId());
+ String command = null;
+ String txnID = null;
+ if(isBegin && !isCancel){
+ command = msg.getCommandString();
+ }
+ String appName = workContext.getAppName();
+ // Log to request log
+ short point = isBegin? TrackerLogConstants.CMD_POINT.BEGIN:TrackerLogConstants.CMD_POINT.END;
+ short status = TrackerLogConstants.CMD_STATUS.NEW;
+ if(!isBegin){
+ if(isCancel){
+ status = TrackerLogConstants.CMD_STATUS.CANCEL;
+ }else{
+ status = TrackerLogConstants.CMD_STATUS.END;
+ }
+ }
+ tracker.log(rID.toString(),
+ txnID,
+ point,
+ status,
+ workContext.getConnectionID(),
+ appName,
+ workContext.getUserName(),
+ workContext.getVdbName(),
+ workContext.getVdbVersion(),
+ command,
+ rowCount);
+ }
+
+ DataTierManager getDataTierManager() {
+ return this.dataTierMgr;
+ }
+
+ public void setDataTierManager(DataTierManager dataTierMgr) {
+ this.dataTierMgr = dataTierMgr;
+ }
+
+ BufferManager getBufferManager() {
+ return bufferManager;
+ }
+
+ TrackingService getTracker() {
+ return tracker;
+ }
+
+ TransactionService getTransactionService() {
+ return transactionService;
+ }
+
+ ResultSetCache getRsCache() {
+ return rsCache;
+ }
+
+ int getProcessorTimeSlice() {
+ return this.processorTimeslice;
+ }
+
+ int getChunkSize() {
+ return chunkSize;
+ }
+
+ @Override
+ public void start(DQPConfigSource configSource)
+ throws ApplicationInitializationException {
+ super.start(configSource);
+ ConfigurationService cs = (ConfigurationService)this.getEnvironment().findService(DQPServiceNames.CONFIGURATION_SERVICE);
+ Properties p = configSource.getProperties();
+ if (cs != null) {
+ p = cs.getSystemProperties();
+ }
+ start(p);
+ }
+
+ public void start(Properties props) {
+ ApplicationEnvironment env = this.getEnvironment();
+
+ this.chunkSize = PropertiesUtils.getIntProperty(props, DQPConfigSource.STREAMING_BATCH_SIZE, 10) * 1024;
+
+ //result set cache
+ if(PropertiesUtils.getBooleanProperty(props, DQPConfigSource.USE_RESULTSET_CACHE, false)){
+ Properties rsCacheProps = new Properties();
+ rsCacheProps.setProperty(ResultSetCache.RS_CACHE_MAX_SIZE, props.getProperty(DQPConfigSource.MAX_RESULTSET_CACHE_SIZE, "0")); //$NON-NLS-1$
+ rsCacheProps.setProperty(ResultSetCache.RS_CACHE_MAX_AGE, props.getProperty(DQPConfigSource.MAX_RESULTSET_CACHE_AGE, "0")); //$NON-NLS-1$
+ rsCacheProps.setProperty(ResultSetCache.RS_CACHE_SCOPE, props.getProperty(DQPConfigSource.RESULTSET_CACHE_SCOPE, ResultSetCache.RS_CACHE_SCOPE_VDB));
+ try {
+ this.rsCache = new ResultSetCache(rsCacheProps, ResourceFinder.getCacheFactory());
+ } catch (MetaMatrixComponentException e) {
+ // this does not really affect the
+ //function of DQP, log warning for now
+ LogManager.logWarning(LogConstants.CTX_DQP, e, DQPPlugin.Util.getString("DQPCORE.6")); //$NON-NLS-1$
+ }
+ }
+
+ //prepared plan cache
+ int maxSizeTotal = PropertiesUtils.getIntProperty(props, DQPConfigSource.MAX_PLAN_CACHE_SIZE, PreparedPlanCache.DEFAULT_MAX_SIZE_TOTAL);
+ prepPlanCache = new PreparedPlanCache(maxSizeTotal);
+
+ // Processor debug flag
+ this.processDebugAllowed = PropertiesUtils.getBooleanProperty(props, DQPConfigSource.PROCESSOR_DEBUG_ALLOWED, false);
+ LogManager.logInfo(LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPCore.Processor_debug_allowed_{0}", processDebugAllowed)); //$NON-NLS-1$
+
+ this.maxCodeTables = PropertiesUtils.getIntProperty(props, DQPConfigSource.MAX_CODE_TABLES, DEFAULT_MAX_CODE_TABLES);
+ this.maxCodeTableRecords = PropertiesUtils.getIntProperty(props, DQPConfigSource.MAX_CODE_TABLE_RECORDS, DEFAULT_MAX_CODE_TABLE_RECORDS);
+ this.processorTimeslice = PropertiesUtils.getIntProperty(props, DQPConfigSource.PROCESSOR_TIMESLICE, DEFAULT_PROCESSOR_TIMESLICE);
+
+ //get buffer manager
+ BufferService bufferService = (BufferService) env.findService(DQPServiceNames.BUFFER_SERVICE);
+ bufferManager = bufferService.getBufferManager();
+
+ //Get tracking service
+ tracker = (TrackingService) env.findService(DQPServiceNames.TRACKING_SERVICE);
+ transactionService = (TransactionService )env.findService(DQPServiceNames.TRANSACTION_SERVICE);
+ metadataService = (MetadataService) env.findService(DQPServiceNames.METADATA_SERVICE);
+
+ // Create the worker pools to tie the queues together
+ processWorkerPool = WorkerPoolFactory.newWorkerPool(PROCESS_PLAN_QUEUE_NAME, PropertiesUtils.getIntProperty(props, DQPConfigSource.PROCESS_POOL_MAX_THREADS, DEFAULT_MAX_PROCESS_WORKERS),
+ Integer.parseInt(props.getProperty(DQPConfigSource.PROCESS_POOL_THREAD_TTL, DEAFULT_PROCESS_WORKER_TIMEOUT)));
+
+ tempTableStoresHolder = new TempTableStoresHolder(bufferManager);
+
+ dataTierMgr = new DataTierManagerImpl(this,
+ (DataService) env.findService(DQPServiceNames.DATA_SERVICE),
+ (MetadataService) env.findService(DQPServiceNames.METADATA_SERVICE),
+ (VDBService) env.findService(DQPServiceNames.VDB_SERVICE),
+ (BufferService) env.findService(DQPServiceNames.BUFFER_SERVICE),
+ this.maxCodeTables,
+ this.maxCodeTableRecords);
+ }
+
+ public List getXmlSchemas(String docName) throws MetaMatrixComponentException,
+ QueryMetadataException {
+ DQPWorkContext workContext = DQPWorkContext.getWorkContext();
+ QueryMetadataInterface metadata = metadataService.lookupMetadata(workContext.getVdbName(), workContext.getVdbVersion());
+
+ Object groupID = metadata.getGroupID(docName);
+ return metadata.getXMLSchemas(groupID);
+ }
+
+ public void cancelRequest(long requestID)
+ throws MetaMatrixProcessingException, MetaMatrixComponentException {
+ DQPWorkContext workContext = DQPWorkContext.getWorkContext();
+ this.cancelRequest(workContext.getRequestID(requestID));
+ }
+
+ public void begin() throws XATransactionException {
+ String threadId = DQPWorkContext.getWorkContext().getConnectionID();
+ try {
+ this.transactionService.getTransactionServer().begin(threadId);
+ } catch (SystemException e) {
+ throw new XATransactionException(e);
+ }
+ }
+
+ public void commit() throws XATransactionException {
+ String threadId = DQPWorkContext.getWorkContext().getConnectionID();
+ try {
+ this.transactionService.getTransactionServer().commit(threadId);
+ } catch (SystemException e) {
+ throw new XATransactionException(e);
+ }
+ }
+
+ public void rollback() throws XATransactionException {
+ try {
+ this.transactionService.getTransactionServer().rollback(
+ DQPWorkContext.getWorkContext().getConnectionID());
+ } catch (SystemException e) {
+ throw new XATransactionException(e);
+ }
+ }
+
+ public void commit(MMXid xid, boolean onePhase)
+ throws XATransactionException {
+ String threadId = DQPWorkContext.getWorkContext().getConnectionID();
+ this.transactionService.getXAServer().commit(threadId, xid, onePhase);
+ }
+
+ public void end(MMXid xid, int flags) throws XATransactionException {
+ String threadId = DQPWorkContext.getWorkContext().getConnectionID();
+ this.transactionService.getXAServer().end(threadId, xid, flags);
+ }
+
+ public void forget(MMXid xid) throws XATransactionException {
+ String threadId = DQPWorkContext.getWorkContext().getConnectionID();
+ this.transactionService.getXAServer().forget(threadId, xid);
+ }
+
+ public int prepare(MMXid xid) throws XATransactionException {
+ return this.transactionService.getXAServer().prepare(
+ DQPWorkContext.getWorkContext().getConnectionID(),
+ xid);
+ }
+
+ public Xid[] recover(int flag) throws XATransactionException {
+ return this.transactionService.getXAServer().recover(flag);
+ }
+
+ public void rollback(MMXid xid) throws XATransactionException {
+ this.transactionService.getXAServer().rollback(
+ DQPWorkContext.getWorkContext().getConnectionID(),
+ xid);
+ }
+
+ public void start(MMXid xid, int flags, int timeout)
+ throws XATransactionException {
+ String threadId = DQPWorkContext.getWorkContext().getConnectionID();
+ this.transactionService.getXAServer().start(threadId, xid, flags, timeout);
+ }
+
+ public MetadataResult getMetadata(long requestID)
+ throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ DQPWorkContext workContext = DQPWorkContext.getWorkContext();
+ MetaDataProcessor processor = new MetaDataProcessor(this.metadataService, this, this.prepPlanCache, getEnvironment(), this.tempTableStoresHolder);
+ return processor.processMessage(workContext.getRequestID(requestID), workContext, null, true);
+ }
+
+ public MetadataResult getMetadata(long requestID, String preparedSql,
+ boolean allowDoubleQuotedVariable)
+ throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ DQPWorkContext workContext = DQPWorkContext.getWorkContext();
+ MetaDataProcessor processor = new MetaDataProcessor(this.metadataService, this, this.prepPlanCache, getEnvironment(), this.tempTableStoresHolder);
+ return processor.processMessage(workContext.getRequestID(requestID), workContext, preparedSql, allowDoubleQuotedVariable);
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java (from rev 569, trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/DQPWorkContext.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,166 @@
+/*
+ * 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.io.Serializable;
+
+import com.metamatrix.dqp.message.RequestID;
+import com.metamatrix.platform.security.api.MetaMatrixSessionID;
+import com.metamatrix.platform.security.api.SessionToken;
+
+public class DQPWorkContext implements Serializable {
+
+ private static final long serialVersionUID = -6389893410233192977L;
+
+ private static ThreadLocal<DQPWorkContext> CONTEXTS = new ThreadLocal<DQPWorkContext>() {
+ protected DQPWorkContext initialValue() {
+ return new DQPWorkContext();
+ }
+ };
+
+ public static DQPWorkContext getWorkContext() {
+ return CONTEXTS.get();
+ }
+
+ public static void setWorkContext(DQPWorkContext context) {
+ CONTEXTS.set(context);
+ }
+
+ private MetaMatrixSessionID sessionId;
+ private String userName;
+ private Serializable trustedPayload;
+ private String vdbName;
+ private String vdbVersion;
+ private String appName;
+ private SessionToken sessionToken;
+ private String clientAddress;
+ private String clientHostname;
+
+ public DQPWorkContext() {
+ }
+
+ /**
+ * @return
+ */
+ public Serializable getTrustedPayload() {
+ return trustedPayload;
+ }
+
+ /**
+ * @return
+ */
+ public String getUserName() {
+ return userName;
+ }
+
+ /**
+ * @return
+ */
+ public String getVdbName() {
+ return vdbName;
+ }
+
+ /**
+ * @return
+ */
+ public String getVdbVersion() {
+ return vdbVersion;
+ }
+
+ /**
+ * @param serializable
+ */
+ public void setTrustedPayload(Serializable trustedPayload) {
+ this.trustedPayload = trustedPayload;
+ }
+
+ /**
+ * @param string
+ */
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ /**
+ * @param string
+ */
+ public void setVdbName(String vdbName) {
+ this.vdbName = vdbName;
+ }
+
+ /**
+ * @param string
+ */
+ public void setVdbVersion(String vdbVersion) {
+ this.vdbVersion = vdbVersion;
+ }
+
+ public String getConnectionID() {
+ return this.sessionId!=null?this.sessionId.toString():null;
+ }
+
+ public MetaMatrixSessionID getSessionId() {
+ return this.sessionId;
+ }
+
+ public void setSessionId(MetaMatrixSessionID sessionId) {
+ this.sessionId = sessionId;
+ }
+
+ public void setAppName(String appName) {
+ this.appName = appName;
+ }
+
+ public String getAppName() {
+ return appName;
+ }
+
+ public RequestID getRequestID(long exeuctionId) {
+ return new RequestID(this.getConnectionID(), exeuctionId);
+ }
+
+ public void setSessionToken(SessionToken sessionToken) {
+ this.sessionToken = sessionToken;
+ }
+
+ public SessionToken getSessionToken() {
+ return sessionToken;
+ }
+
+ public void setClientAddress(String clientAddress) {
+ this.clientAddress = clientAddress;
+ }
+
+ public String getClientAddress() {
+ return clientAddress;
+ }
+
+ public void setClientHostname(String clientHostname) {
+ this.clientHostname = clientHostname;
+ }
+
+ public String getClientHostname() {
+ return clientHostname;
+ }
+
+}
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManager.java (from rev 569, trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/DataTierManager.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManager.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManager.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,31 @@
+/*
+ * 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 com.metamatrix.query.processor.ProcessorDataManager;
+
+public interface DataTierManager extends ProcessorDataManager {
+
+ void clearCodeTables();
+
+}
\ No newline at end of file
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManager.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java (from rev 569, trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/DataTierManagerImpl.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,256 @@
+/*
+ * 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.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.MetaMatrixProcessingException;
+import com.metamatrix.common.buffer.BlockedException;
+import com.metamatrix.common.buffer.TupleBatch;
+import com.metamatrix.common.buffer.TupleSource;
+import com.metamatrix.common.comm.api.ResultsReceiver;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.core.MetaMatrixCoreException;
+import com.metamatrix.core.util.Assertion;
+import com.metamatrix.dqp.DQPPlugin;
+import com.metamatrix.dqp.internal.datamgr.ConnectorID;
+import com.metamatrix.dqp.message.AtomicRequestID;
+import com.metamatrix.dqp.message.AtomicRequestMessage;
+import com.metamatrix.dqp.message.AtomicResultsMessage;
+import com.metamatrix.dqp.message.RequestID;
+import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.service.BufferService;
+import com.metamatrix.dqp.service.DataService;
+import com.metamatrix.dqp.service.MetadataService;
+import com.metamatrix.dqp.service.VDBService;
+import com.metamatrix.dqp.util.LogConstants;
+import com.metamatrix.query.processor.QueryProcessor;
+import com.metamatrix.query.sql.ReservedWords;
+import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.util.CommandContext;
+
+public class DataTierManagerImpl implements DataTierManager {
+
+ // Resources
+ private DQPCore requestMgr;
+ private DataService dataService;
+ private VDBService vdbService;
+ private BufferService bufferService;
+
+ // Code table limits
+ private int maxCodeTableRecords;
+
+ // Processor state
+ private CodeTableCache codeTableCache;
+
+ public DataTierManagerImpl(DQPCore requestMgr,
+ DataService dataService, MetadataService metadataService, VDBService vdbService,
+ BufferService bufferService, int maxCodeTables,
+ int maxCodeTableRecords) {
+
+ this.requestMgr = requestMgr;
+ this.dataService = dataService;
+ this.vdbService = vdbService;
+ this.maxCodeTableRecords = maxCodeTableRecords;
+ this.bufferService = bufferService;
+
+ this.codeTableCache = new CodeTableCache(maxCodeTables);
+ }
+
+ public TupleSource registerRequest(Object processorId, Command command,
+ String modelName, String connectorBindingId, int nodeID) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ RequestWorkItem workItem = requestMgr.getRequestWorkItem((RequestID)processorId);
+ AtomicRequestMessage aqr = createRequest(processorId, command, modelName, connectorBindingId, nodeID);
+ DataTierTupleSource tupleSource = new DataTierTupleSource(aqr.getCommand().getProjectedSymbols(), aqr, this, aqr.getConnectorID(), workItem);
+ tupleSource.open();
+ return tupleSource;
+ }
+
+ private AtomicRequestMessage createRequest(Object processorId,
+ Command command, String modelName, String connectorBindingId, int nodeID)
+ throws MetaMatrixProcessingException, MetaMatrixComponentException {
+ RequestWorkItem workItem = requestMgr.getRequestWorkItem((RequestID)processorId);
+
+ RequestMessage request = workItem.requestMsg;
+ // build the atomic request based on original request + context info
+ AtomicRequestMessage aqr = new AtomicRequestMessage(request, workItem.getDqpWorkContext(), nodeID);
+ aqr.markSubmissionStart();
+ aqr.setCommand(command);
+ aqr.setModelName(modelName);
+ aqr.setUseResultSetCache(request.useResultSetCache());
+ aqr.setPartialResults(request.supportsPartialResults());
+ if (nodeID >= 0) {
+ aqr.setTransactionContext(workItem.getTransactionContext());
+ }
+ aqr.setFetchSize(this.bufferService.getBufferManager().getConnectorBatchSize());
+ if (connectorBindingId == null) {
+ List bindings = vdbService.getConnectorBindingNames(workItem.getDqpWorkContext().getVdbName(), workItem.getDqpWorkContext().getVdbVersion(), modelName);
+ if (bindings == null || bindings.size() != 1) {
+ // this should not happen, but it did occur when setting up the SystemAdmin models
+ throw new MetaMatrixComponentException(DQPPlugin.Util.getString("DataTierManager.could_not_obtain_connector_binding", new Object[]{modelName, workItem.getDqpWorkContext().getVdbName(), workItem.getDqpWorkContext().getVdbVersion() })); //$NON-NLS-1$
+ }
+ connectorBindingId = (String)bindings.get(0);
+ Assertion.isNotNull(connectorBindingId, "could not obtain connector id"); //$NON-NLS-1$
+ }
+ aqr.setConnectorBindingID(connectorBindingId);
+ // Select any connector instance for this connector binding
+ ConnectorID connectorID = this.dataService.selectConnector(connectorBindingId);
+ // if we had this as null before
+ aqr.setConnectorID(connectorID);
+ return aqr;
+ }
+
+ String getConnectorName(String connectorBindingID) {
+ try {
+ return vdbService.getConnectorName(connectorBindingID);
+ } catch (MetaMatrixComponentException t) {
+ // OK
+ }
+ return connectorBindingID;
+ }
+
+ void executeRequest(AtomicRequestMessage aqr, ConnectorID connectorId,
+ ResultsReceiver<AtomicResultsMessage> receiver)
+ throws MetaMatrixComponentException {
+ this.dataService.executeRequest(aqr, connectorId, receiver);
+ }
+
+ public void closeRequest(AtomicRequestID request, ConnectorID connectorId)
+ throws MetaMatrixComponentException {
+ this.dataService.closeRequest(request, connectorId);
+ }
+
+ public void cancelRequest(AtomicRequestID request, ConnectorID connectorId)
+ throws MetaMatrixComponentException {
+ this.dataService.cancelRequest(request, connectorId);
+ }
+
+ void requestBatch(AtomicRequestID request, ConnectorID connectorId)
+ throws MetaMatrixComponentException {
+ this.dataService.requestBatch(request, connectorId);
+ }
+
+ /**
+ * Notify each waiting request that the code table data is now available.
+ * @param requests
+ * @since 4.2
+ */
+ private void notifyWaitingCodeTableRequests(Collection requests) {
+ if (requests != null) {
+ for (Iterator reqIter = requests.iterator(); reqIter.hasNext();) {
+ RequestWorkItem workItem = requestMgr.safeGetWorkItem(reqIter.next());
+ if (workItem != null) {
+ workItem.moreWork();
+ }
+ }
+ }
+ }
+
+ public Object lookupCodeValue(
+ CommandContext context,
+ String codeTableName,
+ String returnElementName,
+ String keyElementName,
+ Object keyValue)
+ throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
+
+ switch (this.codeTableCache.cacheExists(codeTableName, returnElementName, keyElementName, context)) {
+ case CACHE_NOT_EXIST:
+ registerCodeTableRequest(context, codeTableName, returnElementName, keyElementName);
+ case CACHE_EXISTS:
+ return this.codeTableCache.lookupValue(codeTableName, returnElementName, keyElementName, keyValue, context);
+ case CACHE_OVERLOAD:
+ throw new MetaMatrixProcessingException("ERR.018.005.0099", DQPPlugin.Util.getString("ERR.018.005.0099")); //$NON-NLS-1$ //$NON-NLS-2$
+ default:
+ throw BlockedException.INSTANCE;
+ }
+ }
+
+ void registerCodeTableRequest(
+ final CommandContext context,
+ final String codeTableName,
+ String returnElementName,
+ String keyElementName)
+ throws MetaMatrixComponentException, MetaMatrixProcessingException {
+
+ String query = ReservedWords.SELECT + ' ' + keyElementName + " ," + returnElementName + ' ' + ReservedWords.FROM + ' ' + codeTableName; //$NON-NLS-1$
+
+ final Integer codeRequestId = this.codeTableCache.createCacheRequest(codeTableName, returnElementName, keyElementName, context);
+
+ boolean success = false;
+ QueryProcessor processor = null;
+ try {
+ processor = context.getQueryProcessorFactory().createQueryProcessor(query, codeTableName.toUpperCase(), context);
+
+ processor.setBatchHandler(new QueryProcessor.BatchHandler() {
+ @Override
+ public void batchProduced(TupleBatch batch)
+ throws MetaMatrixCoreException {
+ // Determine whether the results should be added to code table cache
+ // Depends on size of results and available memory and system parameters
+
+ if (batch.getEndRow() > maxCodeTableRecords) {
+ throw new MetaMatrixProcessingException("ERR.018.005.0100", DQPPlugin.Util.getString("ERR.018.005.0100", context.getProcessorID(), codeRequestId)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ codeTableCache.loadTable(codeRequestId, batch.getAllTuples());
+ }
+ });
+
+ //process lookup as fully blocking
+ processor.process();
+ success = true;
+ } catch (MetaMatrixProcessingException e) {
+ throw e;
+ } catch (MetaMatrixComponentException e) {
+ throw e;
+ } catch (MetaMatrixCoreException e) {
+ throw new MetaMatrixComponentException(e);
+ } finally {
+ Collection requests = null;
+ if (success) {
+ requests = codeTableCache.markCacheLoaded(codeRequestId);
+ } else {
+ requests = codeTableCache.errorLoadingCache(codeRequestId);
+ }
+ notifyWaitingCodeTableRequests(requests);
+ if (processor != null) {
+ try {
+ this.bufferService.getBufferManager().removeTupleSource(processor.getResultsID());
+ } catch (MetaMatrixComponentException e1) {
+ LogManager.logDetail(LogConstants.CTX_DQP, "Exception closing code table request"); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see com.metamatrix.dqp.internal.process.DataTierManager#clearCodeTables()
+ */
+ public void clearCodeTables() {
+ this.codeTableCache.clearAll();
+ }
+
+}
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java (from rev 569, trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/DataTierTupleSource.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,228 @@
+/*
+ * 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.List;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.MetaMatrixProcessingException;
+import com.metamatrix.common.buffer.BlockedException;
+import com.metamatrix.common.buffer.TupleSource;
+import com.metamatrix.common.comm.api.ResultsReceiver;
+import com.metamatrix.core.util.Assertion;
+import com.metamatrix.dqp.exception.SourceWarning;
+import com.metamatrix.dqp.internal.datamgr.ConnectorID;
+import com.metamatrix.dqp.message.AtomicRequestMessage;
+import com.metamatrix.dqp.message.AtomicResultsMessage;
+
+/**
+ * This tuple source impl can only be used once; once it is closed, it
+ * cannot be reopened and reused.
+ */
+public class DataTierTupleSource implements TupleSource, ResultsReceiver<AtomicResultsMessage> {
+
+ // Construction state
+ private final List schema;
+ private final AtomicRequestMessage aqr;
+ private final DataTierManagerImpl dataMgr;
+ private final ConnectorID connectorId;
+ private final RequestWorkItem workItem;
+
+ // Data state
+ private List[] currentBatch;
+ private List[] nextBatch;
+ private int currentBatchCount = 0;
+ private int index = 0;
+ private boolean nextBatchIsLast = false;
+ private volatile boolean isLast = false;
+ private int rowsProcessed = 0;
+ private boolean waitingForData = false;
+ private Throwable exception;
+ private volatile boolean supportsImplicitClose;
+ private volatile boolean isTransactional;
+
+ /**
+ * Constructor for DataTierTupleSource.
+ */
+ public DataTierTupleSource(List schema, AtomicRequestMessage aqr, DataTierManagerImpl dataMgr, ConnectorID connectorID, RequestWorkItem workItem) {
+ this.schema = schema;
+ this.aqr = aqr;
+ this.dataMgr = dataMgr;
+ this.connectorId = connectorID;
+ this.workItem = workItem;
+ }
+
+ /**
+ * @see TupleSource#getSchema()
+ */
+ public List getSchema() {
+ return this.schema;
+ }
+
+ public List nextTuple() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ if (index < currentBatchCount) {
+ return this.currentBatch[index++];
+ } else if (isLast) {
+ return null;
+ } else {
+ // We're past the end of the current batch, so switch to the next
+ switchBatch();
+ // If the new batch is empty
+ if (currentBatchCount == 0) {
+ if (isLast) {
+ return null;
+ }
+ throw BlockedException.INSTANCE;
+ }
+ return currentBatch[index++];
+ }
+ }
+
+ public void open() {
+ Assertion.isNull(workItem.getConnectorRequest(aqr.getAtomicRequestID()));
+ workItem.addConnectorRequest(aqr.getAtomicRequestID(), this);
+ synchronized (this) {
+ this.waitingForData = true;
+ try {
+ this.dataMgr.executeRequest(aqr, this.connectorId, this);
+ } catch (MetaMatrixComponentException e) {
+ exceptionOccurred(e);
+ }
+ }
+ }
+
+ /**
+ * Switches to the next batch.
+ * @throws BlockedException if we're still waiting for data from the connector
+ * @throws MetaMatrixComponentException if the request for the next batch failed.
+ * @since 4.3
+ */
+ private synchronized void switchBatch() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ if (exception != null) {
+ if (exception instanceof MetaMatrixComponentException) {
+ throw (MetaMatrixComponentException)exception;
+ }
+ if (exception instanceof MetaMatrixProcessingException) {
+ throw (MetaMatrixProcessingException)exception;
+ }
+ throw new MetaMatrixComponentException(exception);
+ }
+ boolean shouldBlock = true;
+ if (nextBatch != null) {
+ // Switch the current batch
+ this.currentBatch = this.nextBatch;
+ this.isLast = this.nextBatchIsLast;
+ this.currentBatchCount = this.currentBatch.length;
+ this.index = 0;
+ this.nextBatch = null;
+ shouldBlock = false;
+ }
+ // Request the next batch immediately
+ if (!this.isLast && !waitingForData) {
+ this.dataMgr.requestBatch(this.aqr.getAtomicRequestID(), connectorId);
+
+ // update waitingForData
+ this.waitingForData = true;
+ }
+ if (shouldBlock) {
+ throw BlockedException.INSTANCE;
+ }
+ }
+
+ public void fullyCloseSource() throws MetaMatrixComponentException {
+ this.dataMgr.closeRequest(aqr.getAtomicRequestID(), connectorId);
+ }
+
+ public void cancelRequest() throws MetaMatrixComponentException {
+ this.dataMgr.cancelRequest(aqr.getAtomicRequestID(), connectorId);
+ }
+
+ /**
+ * @see TupleSource#closeSource()
+ */
+ public void closeSource() throws MetaMatrixComponentException {
+ if (this.supportsImplicitClose) {
+ this.dataMgr.closeRequest(aqr.getAtomicRequestID(), connectorId);
+ }
+ }
+
+ public void exceptionOccurred(Throwable e) {
+ synchronized (this) {
+ if(workItem.requestMsg.supportsPartialResults()) {
+ nextBatch = new List[0];
+ nextBatchIsLast = true;
+ String connectorBindingName = dataMgr.getConnectorName(aqr.getConnectorBindingID());
+ SourceWarning sourceFailure = new SourceWarning(this.aqr.getModelName(), connectorBindingName, e, true);
+ workItem.addSourceFailureDetails(sourceFailure);
+ } else {
+ this.exception = e;
+ }
+ waitingForData = false;
+ }
+ workItem.closeAtomicRequest(aqr.getAtomicRequestID());
+ this.workItem.moreWork();
+ }
+
+ public void receiveResults(AtomicResultsMessage response) {
+ boolean removeRequest = false;
+ synchronized (this) {
+ // check to see if this is close of the atomic request message.
+ if (response.isRequestClosed()) {
+ removeRequest = true;
+ } else {
+ supportsImplicitClose = response.supportsImplicitClose();
+ isTransactional = response.isTransactional();
+
+ nextBatch = response.getResults();
+ nextBatchIsLast = response.getFinalRow() >= 0;
+ rowsProcessed += nextBatch.length;
+ }
+ // reset waitingForData flag
+ waitingForData = false;
+ }
+ if (response.getWarnings() != null) {
+ String connectorBindingName = dataMgr.getConnectorName(aqr.getConnectorBindingID());
+ for (Exception warning : response.getWarnings()) {
+ SourceWarning sourceFailure = new SourceWarning(this.aqr.getModelName(), connectorBindingName, warning, true);
+ workItem.addSourceFailureDetails(sourceFailure);
+ }
+ }
+ if (removeRequest) {
+ workItem.closeAtomicRequest(this.aqr.getAtomicRequestID());
+ }
+ this.workItem.moreWork();
+ }
+
+ public AtomicRequestMessage getAtomicRequestMessage() {
+ return aqr;
+ }
+
+ public ConnectorID getConnectorId() {
+ return connectorId;
+ }
+
+ public boolean isTransactional() {
+ return this.isTransactional;
+ }
+
+}
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobChunkStream.java (from rev 569, trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/LobChunkStream.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobChunkStream.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobChunkStream.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,95 @@
+/*
+ * 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.io.IOException;
+import java.nio.charset.Charset;
+import java.sql.SQLException;
+
+import com.metamatrix.common.buffer.BufferManager;
+import com.metamatrix.common.lob.BufferManagerLobChunkStream;
+import com.metamatrix.common.lob.ByteLobChunkStream;
+import com.metamatrix.common.lob.LobChunk;
+import com.metamatrix.common.lob.LobChunkProducer;
+import com.metamatrix.common.lob.ReaderInputStream;
+import com.metamatrix.common.types.BlobType;
+import com.metamatrix.common.types.ClobType;
+import com.metamatrix.common.types.InvalidReferenceException;
+import com.metamatrix.common.types.Streamable;
+import com.metamatrix.common.types.XMLType;
+import com.metamatrix.dqp.DQPPlugin;
+
+/**
+ * A Lob Stream builder class. Given the Lob object this object can build
+ * an object which can produce a stream lob chunks, which can be sent to the
+ * client one by one.
+ */
+class LobChunkStream implements LobChunkProducer {
+
+ LobChunkProducer internalStream = null;
+
+ public LobChunkStream(Streamable streamable, int chunkSize, BufferManager bufferMgr)
+ throws IOException {
+
+ try {
+ if (streamable instanceof XMLType) {
+ XMLType xml = (XMLType)streamable;
+ this.internalStream = new ByteLobChunkStream(new ReaderInputStream(xml.getCharacterStream(), Charset.forName("UTF-16")), chunkSize); //$NON-NLS-1$
+ }
+ else if (streamable instanceof ClobType) {
+ ClobType clob = (ClobType)streamable;
+ this.internalStream = new ByteLobChunkStream(new ReaderInputStream(clob.getCharacterStream(), Charset.forName("UTF-16")), chunkSize); //$NON-NLS-1$
+ }
+ else if (streamable instanceof BlobType) {
+ BlobType blob = (BlobType)streamable;
+ this.internalStream = new ByteLobChunkStream(blob.getBinaryStream(), chunkSize);
+ }
+ } catch (InvalidReferenceException e) {
+ // if the lob did not have a persistent id, there is no way for us to re-create the
+ // object. so throw an error.
+ if (streamable.getPersistenceStreamId() == null) {
+ throw new IOException(DQPPlugin.Util.getString("LobStream.noreference")); //$NON-NLS-1$
+ }
+ // otherwise read directly from the buffer manager.
+ this.internalStream = new BufferManagerLobChunkStream(streamable.getPersistenceStreamId(), bufferMgr);
+ } catch(SQLException e) {
+ IOException ex = new IOException();
+ ex.initCause(e);
+ throw ex;
+ }
+ }
+
+ /**
+ * @see com.metamatrix.common.lob.LobChunkProducer#getNextChunk(int)
+ */
+ public LobChunk getNextChunk() throws IOException {
+ return internalStream.getNextChunk();
+ }
+
+ /**
+ * @see com.metamatrix.common.lob.LobChunkProducer#close()
+ */
+ public void close() throws IOException {
+ internalStream.close();
+ }
+}
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobChunkStream.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobWorkItem.java (from rev 569, trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/LobWorkItem.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobWorkItem.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobWorkItem.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,155 @@
+/*
+ * 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.io.IOException;
+import java.util.List;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.common.buffer.BlockedOnMemoryException;
+import com.metamatrix.common.buffer.MemoryNotAvailableException;
+import com.metamatrix.common.buffer.TupleBatch;
+import com.metamatrix.common.buffer.TupleSourceID;
+import com.metamatrix.common.buffer.TupleSourceNotFoundException;
+import com.metamatrix.common.comm.api.ResultsReceiver;
+import com.metamatrix.common.lob.LobChunk;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.types.Streamable;
+import com.metamatrix.common.util.LogContextsUtil.DQPConstants;
+import com.metamatrix.core.util.Assertion;
+import com.metamatrix.dqp.DQPPlugin;
+import com.metamatrix.dqp.message.RequestID;
+import com.metamatrix.dqp.util.LogConstants;
+
+public class LobWorkItem implements Runnable {
+
+ private RequestWorkItem parent;
+ private RequestID requestID;
+
+ private DQPCore dqpCore;
+ private int chunkSize;
+
+ /* private work item state */
+ private String streamId;
+ private LobChunkStream stream;
+ private int streamRequestId;
+ private ResultsReceiver<LobChunk> resultsReceiver;
+
+ public LobWorkItem(RequestWorkItem parent, DQPCore dqpCore, String streamId, int streamRequestId) {
+ this.chunkSize = dqpCore.getChunkSize();
+ this.dqpCore = dqpCore;
+ this.requestID = parent.requestID;
+ this.streamId = streamId;
+ this.parent = parent;
+ this.streamRequestId = streamRequestId;
+ }
+
+ public void run() {
+ LobChunk chunk = null;
+ Exception ex = null;
+ boolean shouldClose = false;
+
+ try {
+ // If no previous stream is not found for this request create one and
+ // save for future
+ if (stream == null) {
+ stream = createLobStream(new TupleSourceID(streamId));
+ }
+
+ // now get the chunk from stream
+ chunk = stream.getNextChunk();
+ shouldClose = chunk.isLast();
+ } catch (BlockedOnMemoryException e) {
+ LogManager.logDetail(LogConstants.CTX_DQP, new Object[] {"Reenqueueing LOB chunk request due to lack of available memory ###########", requestID}); //$NON-NLS-1$ //$NON-NLS-2$
+ this.dqpCore.addWork(this);
+ return;
+ } catch (TupleSourceNotFoundException e) {
+ LogManager.logWarning(LogConstants.CTX_DQP, e, DQPPlugin.Util.getString("BufferManagerLobChunkStream.no_tuple_source", streamId)); //$NON-NLS-1$
+ ex = e;
+ } catch (MetaMatrixComponentException e) {
+ LogManager.logWarning(LogConstants.CTX_DQP, e, DQPPlugin.Util.getString("ProcessWorker.LobError")); //$NON-NLS-1$
+ ex = e;
+ } catch (IOException e) {
+ ex = e;
+ }
+
+ synchronized (this) {
+ if (ex != null) {
+ resultsReceiver.exceptionOccurred(ex);
+ shouldClose = true;
+ } else {
+ resultsReceiver.receiveResults(chunk);
+ }
+ resultsReceiver = null;
+ }
+
+ if (shouldClose) {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ LogManager.logWarning(LogConstants.CTX_DQP, e, DQPPlugin.Util.getString("ProcessWorker.LobError")); //$NON-NLS-1$
+ }
+ parent.removeLobStream(streamRequestId);
+ }
+ }
+
+ /**
+ * Create a object which can create a sequence of LobChunk objects on a given
+ * LOB object
+ */
+ private LobChunkStream createLobStream(TupleSourceID referenceStreamId)
+ throws BlockedOnMemoryException, MetaMatrixComponentException, IOException, TupleSourceNotFoundException {
+
+ // get the reference object in the buffer manager, and try to stream off
+ // the original sources.
+ TupleBatch batch = null;
+ try {
+ batch = dqpCore.getBufferManager().pinTupleBatch(referenceStreamId, 1, 1);
+ List[] tuples = batch.getAllTuples();
+
+ if (tuples != null && tuples.length > 0) {
+ Object anObj = tuples[0].get(0);
+ if (anObj instanceof Streamable) {
+ Streamable streamable = (Streamable)anObj;
+ return new LobChunkStream(streamable, chunkSize, dqpCore.getBufferManager());
+ }
+ }
+ throw new MetaMatrixComponentException(DQPPlugin.Util.getString("ProcessWorker.wrongdata")); //$NON-NLS-1$
+ } catch (MemoryNotAvailableException e) {
+ throw BlockedOnMemoryException.INSTANCE;
+ } finally {
+ try {
+ if (batch != null) {
+ dqpCore.getBufferManager().unpinTupleBatch(referenceStreamId, batch.getBeginRow(), batch.getEndRow());
+ }
+ } catch (MetaMatrixComponentException e) {
+ LogManager.logDetail(DQPConstants.CTX_DQP, e, "Call to unpin failed during lob stream creation"); //$NON-NLS-1$
+ }
+ }
+ }
+
+ synchronized void setResultsReceiver(ResultsReceiver<LobChunk> resultsReceiver) {
+ Assertion.isNull(this.resultsReceiver, "Cannot request results with a pending request"); //$NON-NLS-1$
+ this.resultsReceiver = resultsReceiver;
+ }
+}
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobWorkItem.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java (from rev 569, trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/MetaDataProcessor.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,452 @@
+/*
+ * 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.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.teiid.dqp.internal.process.multisource.MultiSourceMetadataWrapper;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.MetaMatrixProcessingException;
+import com.metamatrix.api.exception.query.QueryMetadataException;
+import com.metamatrix.api.exception.query.QueryParserException;
+import com.metamatrix.api.exception.query.QueryResolverException;
+import com.metamatrix.common.application.ApplicationEnvironment;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.common.types.XMLType;
+import com.metamatrix.dqp.client.MetadataResult;
+import com.metamatrix.dqp.message.RequestID;
+import com.metamatrix.dqp.metadata.ResultsMetadataConstants;
+import com.metamatrix.dqp.metadata.ResultsMetadataDefaults;
+import com.metamatrix.dqp.service.DQPServiceNames;
+import com.metamatrix.dqp.service.MetadataService;
+import com.metamatrix.dqp.service.VDBService;
+import com.metamatrix.query.analysis.AnalysisRecord;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.metadata.SupportConstants;
+import com.metamatrix.query.metadata.TempMetadataAdapter;
+import com.metamatrix.query.metadata.TempMetadataStore;
+import com.metamatrix.query.parser.ParseInfo;
+import com.metamatrix.query.parser.QueryParser;
+import com.metamatrix.query.resolver.QueryResolver;
+import com.metamatrix.query.sql.ReservedWords;
+import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.sql.lang.Query;
+import com.metamatrix.query.sql.lang.XQuery;
+import com.metamatrix.query.sql.symbol.AggregateSymbol;
+import com.metamatrix.query.sql.symbol.AliasSymbol;
+import com.metamatrix.query.sql.symbol.ElementSymbol;
+import com.metamatrix.query.sql.symbol.Expression;
+import com.metamatrix.query.sql.symbol.GroupSymbol;
+import com.metamatrix.query.sql.symbol.SingleElementSymbol;
+import com.metamatrix.query.sql.visitor.ReferenceCollectorVisitor;
+import com.metamatrix.query.tempdata.TempTableStore;
+
+/**
+ * Handles MetaDataMessages on behalf of DQPCore.
+ */
+public class MetaDataProcessor {
+
+
+ // Resources
+ private MetadataService metadataService;
+ private DQPCore requestManager;
+ private QueryMetadataInterface metadata;
+ private PreparedPlanCache planCache;
+ private ApplicationEnvironment env;
+
+ private TempTableStoresHolder tempTableStoresHolder;
+ private String vdbName;
+ private String vdbVersion;
+ private RequestID requestID;
+
+ public MetaDataProcessor(MetadataService metadataService, DQPCore requestManager, PreparedPlanCache planCache, ApplicationEnvironment env, TempTableStoresHolder tempTableStoresHolder) {
+ this.metadataService = metadataService;
+ this.requestManager = requestManager;
+ this.planCache = planCache;
+ this.env = env;
+ this.tempTableStoresHolder = tempTableStoresHolder;
+ }
+
+ /**
+ * Process a metadata request message - this is typically either a request
+ * for metadata for a prepared statement or a request for full metadata from
+ * an already processed command.
+ * @param metadataMsg The message from the client
+ * @return The message for the client
+ * @throws MetaMatrixComponentException
+ * @throws MetaMatrixProcessingException
+ */
+ MetadataResult processMessage(RequestID requestId, DQPWorkContext workContext, String preparedSql, boolean allowDoubleQuotedVariable) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ final VDBService vdbService = (VDBService)env.findService(DQPServiceNames.VDB_SERVICE);
+ this.requestID = requestId;
+ this.vdbName = workContext.getVdbName();
+ this.vdbVersion = workContext.getVdbVersion();
+
+ QueryMetadataInterface md = metadataService.lookupMetadata(vdbName, vdbVersion);
+ // Defect 15029 - Use the QueryMetadataWrapper to hide models with private visibility when resolving the command.
+ this.metadata = new QueryMetadataWrapper(md, vdbName, vdbVersion, vdbService);
+
+ // If multi-source, use the multi-source wrapper as well
+ Collection multiModels = vdbService.getMultiSourceModels(vdbName, vdbVersion);
+ if(multiModels != null && multiModels.size() > 0) {
+ this.metadata = new MultiSourceMetadataWrapper(this.metadata, multiModels);
+ }
+
+ TempTableStore tempTableStore = null;
+ if(tempTableStoresHolder != null) {
+ RequestWorkItem workItem = requestManager.safeGetWorkItem(requestID);
+ if (workItem != null) {
+ tempTableStore = tempTableStoresHolder.getTempTableStore(workContext.getConnectionID());
+ }
+ }
+ if(tempTableStore != null) {
+ metadata = new TempMetadataAdapter(this.metadata, tempTableStore.getMetadataStore());
+ }
+
+ if(preparedSql == null) {
+ RequestWorkItem workItem = requestManager.getRequestWorkItem(requestID);
+ return getMetadataForCommand(workItem.getOriginalCommand());
+ }
+ return obtainMetadataForPreparedSql(preparedSql, workContext.getConnectionID(), allowDoubleQuotedVariable);
+ }
+
+ // For each projected symbol, construct a metadata map
+ private MetadataResult getMetadataForCommand(Command originalCommand) throws MetaMatrixComponentException {
+ Map[] columnMetadata = null;
+
+ switch(originalCommand.getType()) {
+ case Command.TYPE_QUERY:
+ if(originalCommand instanceof Query) {
+ if (((Query)originalCommand).getIsXML()) {
+ columnMetadata = new Map[1];
+ columnMetadata[0] = createXMLColumnMetadata((Query)originalCommand);
+ } else if (((Query)originalCommand).getInto() != null) {
+ columnMetadata = createUpdateMetadata();
+ } else {
+ columnMetadata = createProjectedSymbolMetadata(originalCommand);
+ }
+ } else {
+ columnMetadata = createProjectedSymbolMetadata(originalCommand);
+ }
+ break;
+ case Command.TYPE_STORED_PROCEDURE:
+ columnMetadata = createProjectedSymbolMetadata(originalCommand);
+ break;
+ case Command.TYPE_INSERT:
+ case Command.TYPE_UPDATE:
+ case Command.TYPE_DELETE:
+ case Command.TYPE_CREATE:
+ case Command.TYPE_DROP:
+ columnMetadata = createUpdateMetadata();
+ break;
+ case Command.TYPE_XQUERY:
+ columnMetadata = new Map[1];
+ columnMetadata[0] = createXQueryColumnMetadata((XQuery)originalCommand);
+ break;
+ default:
+ columnMetadata = createProjectedSymbolMetadata(originalCommand);
+ }
+
+ return new MetadataResult(columnMetadata, ReferenceCollectorVisitor.getReferences(originalCommand).size());
+ }
+
+ private Map[] createProjectedSymbolMetadata(Command originalCommand) throws MetaMatrixComponentException {
+ Map[] columnMetadata;
+ // Allow command to use temporary metadata
+ Map tempMetadata = originalCommand.getTemporaryMetadata();
+ if(tempMetadata != null && tempMetadata.size() > 0) {
+ TempMetadataAdapter tempFacade = new TempMetadataAdapter(this.metadata, new TempMetadataStore(tempMetadata));
+ this.metadata = tempFacade;
+ }
+
+ List projectedSymbols = originalCommand.getProjectedSymbols();
+ columnMetadata = new Map[projectedSymbols.size()];
+
+ Iterator symbolIter = projectedSymbols.iterator();
+ for(int i=0; symbolIter.hasNext(); i++) {
+ SingleElementSymbol symbol = (SingleElementSymbol) symbolIter.next();
+ String shortColumnName = SingleElementSymbol.getShortName(symbol.getOutputName());
+ if(symbol instanceof AliasSymbol) {
+ symbol = ((AliasSymbol)symbol).getSymbol();
+ }
+ try {
+ columnMetadata[i] = createColumnMetadata(shortColumnName, symbol);
+ } catch(QueryMetadataException e) {
+ throw new MetaMatrixComponentException(e);
+ }
+ }
+ return columnMetadata;
+ }
+
+ private MetadataResult obtainMetadataForPreparedSql(String sql, String sessionId, boolean isDoubleQuotedVariablesAllowed) throws QueryParserException, QueryResolverException, MetaMatrixComponentException {
+ Command command = null;
+
+ PreparedPlanCache.PreparedPlan plan = planCache.getPreparedPlan(sessionId, sql, false);
+ if(plan != null) {
+ command = plan.getCommand();
+ } else {
+ QueryParser parser = QueryParser.getQueryParser();
+ ParseInfo info = new ParseInfo();
+ // Defect 19747 - the parser needs the following connection property to decide whether to treat double-quoted strings as variable names
+ info.allowDoubleQuotedVariable = isDoubleQuotedVariablesAllowed;
+ command = parser.parseCommand(sql, info);
+ QueryResolver.resolveCommand(command, Collections.EMPTY_MAP, false, this.metadata, AnalysisRecord.createNonRecordingRecord());
+ }
+ return getMetadataForCommand(command);
+ }
+
+ private Map createXMLColumnMetadata(Query xmlCommand) {
+ GroupSymbol doc = (GroupSymbol) xmlCommand.getFrom().getGroups().get(0);
+ Map xmlMetadata = getDefaultColumn(vdbName, vdbVersion, doc.getName(), ResultsMetadataDefaults.XML_COLUMN_NAME, XMLType.class);
+
+ // Override size as XML may be big
+ xmlMetadata.put(ResultsMetadataConstants.DISPLAY_SIZE, ResultsMetadataDefaults.XML_COLUMN_LENGTH);
+
+ return xmlMetadata;
+ }
+
+ private Map createXQueryColumnMetadata(XQuery xqueryCommand) {
+ Map xqueryMetadata = getDefaultColumn(vdbName, vdbVersion, null, ResultsMetadataDefaults.XML_COLUMN_NAME, XMLType.class);
+
+ // Override size as XML may be big
+ xqueryMetadata.put(ResultsMetadataConstants.DISPLAY_SIZE, ResultsMetadataDefaults.XML_COLUMN_LENGTH);
+
+ return xqueryMetadata;
+ }
+
+ private Map createColumnMetadata(String shortColumnName, SingleElementSymbol symbol) throws QueryMetadataException, MetaMatrixComponentException {
+ if(symbol instanceof ElementSymbol) {
+ return createElementMetadata(shortColumnName, (ElementSymbol) symbol);
+ } else if(symbol instanceof AggregateSymbol) {
+ return createAggregateMetadata(shortColumnName, (AggregateSymbol) symbol);
+ }
+ return createTypedMetadata(shortColumnName, symbol);
+ }
+
+ private Map createElementMetadata(String shortColumnName, ElementSymbol symbol) throws QueryMetadataException, MetaMatrixComponentException {
+ Object elementID = symbol.getMetadataID();
+
+ Map column = new HashMap();
+ column.put(ResultsMetadataConstants.AUTO_INCREMENTING, Boolean.valueOf(metadata.elementSupports(elementID, SupportConstants.Element.AUTO_INCREMENT)));
+ column.put(ResultsMetadataConstants.CASE_SENSITIVE, Boolean.valueOf(metadata.elementSupports(elementID, SupportConstants.Element.CASE_SENSITIVE)));
+ column.put(ResultsMetadataConstants.CURRENCY, Boolean.FALSE);
+ Class type = symbol.getType();
+ column.put(ResultsMetadataConstants.DATA_TYPE, DataTypeManager.getDataTypeName(type));
+ column.put(ResultsMetadataConstants.ELEMENT_LABEL, shortColumnName);
+ column.put(ResultsMetadataConstants.ELEMENT_NAME, shortColumnName);
+
+ GroupSymbol group = symbol.getGroupSymbol();
+ if(group == null) {
+ column.put(ResultsMetadataConstants.GROUP_NAME, null);
+ } else {
+ column.put(ResultsMetadataConstants.GROUP_NAME, metadata.getFullName(group.getMetadataID()));
+ }
+
+ boolean allowsNull = metadata.elementSupports(elementID, SupportConstants.Element.NULL);
+ boolean unknown = metadata.elementSupports(elementID, SupportConstants.Element.NULL_UNKNOWN);
+ Integer nullable = null;
+ if(unknown) {
+ nullable = ResultsMetadataConstants.NULL_TYPES.UNKNOWN;
+ } else {
+ if(allowsNull) {
+ nullable = ResultsMetadataConstants.NULL_TYPES.NULLABLE;
+ } else {
+ nullable = ResultsMetadataConstants.NULL_TYPES.NOT_NULL;
+ }
+ }
+ column.put(ResultsMetadataConstants.NULLABLE, nullable);
+
+ column.put(ResultsMetadataConstants.RADIX, new Integer(metadata.getRadix(elementID)));
+ column.put(ResultsMetadataConstants.SCALE, new Integer(metadata.getScale(elementID)));
+
+
+ int precision = getColumnPrecision(type, elementID);
+ column.put(ResultsMetadataConstants.PRECISION, new Integer(precision));
+ column.put(ResultsMetadataConstants.DISPLAY_SIZE, getColumnDisplaySize(precision, type, elementID));
+
+ boolean comparable = metadata.elementSupports(elementID, SupportConstants.Element.SEARCHABLE_COMPARE);
+ boolean likable = metadata.elementSupports(elementID, SupportConstants.Element.SEARCHABLE_LIKE);
+ Integer searchable = null;
+ if(comparable) {
+ if(likable) {
+ searchable = ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE;
+ } else {
+ searchable = ResultsMetadataConstants.SEARCH_TYPES.ALLEXCEPTLIKE;
+ }
+ } else {
+ if(likable) {
+ searchable = ResultsMetadataConstants.SEARCH_TYPES.LIKE_ONLY;
+ } else {
+ searchable = ResultsMetadataConstants.SEARCH_TYPES.UNSEARCHABLE;
+ }
+ }
+ column.put(ResultsMetadataConstants.SEARCHABLE, searchable);
+
+ column.put(ResultsMetadataConstants.SIGNED, Boolean.valueOf(metadata.elementSupports(elementID, SupportConstants.Element.SIGNED)));
+ column.put(ResultsMetadataConstants.VIRTUAL_DATABASE_NAME, vdbName);
+ column.put(ResultsMetadataConstants.VIRTUAL_DATABASE_VERSION, vdbVersion);
+ column.put(ResultsMetadataConstants.WRITABLE, new Boolean(metadata.elementSupports(elementID, SupportConstants.Element.UPDATE)));
+ return column;
+ }
+
+ private Map createAggregateMetadata(String shortColumnName,
+ AggregateSymbol symbol) throws QueryMetadataException, MetaMatrixComponentException {
+
+ Expression expression = symbol.getExpression();
+ String function = symbol.getAggregateFunction();
+ if(function.equals(ReservedWords.MIN) || function.equals(ReservedWords.MAX)){
+ if(expression instanceof ElementSymbol) {
+ return createColumnMetadata(shortColumnName, (ElementSymbol)expression);
+ }
+ }
+ return createTypedMetadata(shortColumnName, symbol);
+ }
+
+ private Map createTypedMetadata(String shortColumnName, SingleElementSymbol symbol) {
+ return getDefaultColumn(vdbName, vdbVersion, null, shortColumnName, symbol.getType());
+ }
+
+ private Map[] createUpdateMetadata() {
+ Map[] metadata = new Map[1];
+ metadata[0] = new HashMap();
+ metadata[0].put(ResultsMetadataConstants.AUTO_INCREMENTING, Boolean.FALSE);
+ metadata[0].put(ResultsMetadataConstants.CASE_SENSITIVE, Boolean.FALSE);
+ metadata[0].put(ResultsMetadataConstants.CURRENCY, Boolean.FALSE);
+ metadata[0].put(ResultsMetadataConstants.DATA_TYPE, DataTypeManager.DefaultDataTypes.INTEGER);
+ metadata[0].put(ResultsMetadataConstants.DISPLAY_SIZE, ResultsMetadataDefaults.getMaxDisplaySize(DataTypeManager.DefaultDataTypes.INTEGER));
+ metadata[0].put(ResultsMetadataConstants.ELEMENT_LABEL, null);
+ metadata[0].put(ResultsMetadataConstants.ELEMENT_NAME, ResultsMetadataDefaults.UPDATE_COLUMN);
+ metadata[0].put(ResultsMetadataConstants.GROUP_NAME, null);
+ metadata[0].put(ResultsMetadataConstants.NULLABLE, ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
+ metadata[0].put(ResultsMetadataConstants.PRECISION, ResultsMetadataDefaults.getDefaultPrecision(DataTypeManager.DefaultDataTypes.INTEGER));
+ metadata[0].put(ResultsMetadataConstants.RADIX, new Integer(10));
+ metadata[0].put(ResultsMetadataConstants.SCALE, new Integer(0));
+ metadata[0].put(ResultsMetadataConstants.SEARCHABLE, ResultsMetadataConstants.SEARCH_TYPES.UNSEARCHABLE);
+ metadata[0].put(ResultsMetadataConstants.SIGNED, Boolean.TRUE);
+ metadata[0].put(ResultsMetadataConstants.WRITABLE, Boolean.FALSE);
+ metadata[0].put(ResultsMetadataConstants.VIRTUAL_DATABASE_NAME, vdbName);
+ metadata[0].put(ResultsMetadataConstants.VIRTUAL_DATABASE_VERSION, vdbVersion);
+ return metadata;
+ }
+
+ private int getColumnPrecision(Class dataType, Object elementID) throws QueryMetadataException, MetaMatrixComponentException {
+ if (!Number.class.isAssignableFrom(dataType)) {
+ int length = metadata.getElementLength(elementID);
+ if (length > 0) {
+ return length;
+ }
+ } else {
+ int precision = metadata.getPrecision(elementID);
+ if (precision > 0) {
+ return precision;
+ }
+ }
+ return ResultsMetadataDefaults.getDefaultPrecision(dataType).intValue();
+ }
+
+ /**
+ * This method would return the display size of the column to be returned by
+ * getColumnDisplaySize() on ResultSetMetaData. This method would return the display
+ * size based on the data type of the column.
+ *
+ * For numeric types, the display size for a numeric column will be equal to the precision of the column
+ * plus 1 for the optional - sign plus "1" if the column is decimal to account for the ".".
+ *
+ * For string types, the display size is the length.
+ *
+ * @param dataType A string representing the MetaMatrix data type of the column
+ * @return An int value giving the displaysize of the column
+ */
+ private Integer getColumnDisplaySize(int precision, Class dataType, Object elementID) throws QueryMetadataException, MetaMatrixComponentException {
+
+ if(elementID != null && dataType.equals(DataTypeManager.DefaultDataClasses.STRING)) {
+ int length = metadata.getElementLength(elementID);
+ if(length > 0) {
+ return new Integer(length);
+ }
+
+ } else if(Number.class.isAssignableFrom(dataType)) {
+ if(precision > 0) {
+ int displayLength = precision;
+
+ // Add 1 for sign on all numbers
+ displayLength = precision+1;
+
+ // Add 1 for decimal point for FLOAT, DOUBLE, BIGDECIMAL
+ if(dataType.equals(DataTypeManager.DefaultDataClasses.FLOAT) ||
+ dataType.equals(DataTypeManager.DefaultDataClasses.DOUBLE) ||
+ dataType.equals(DataTypeManager.DefaultDataClasses.BIG_DECIMAL)) {
+ displayLength++;
+ }
+
+ return new Integer(displayLength);
+ }
+
+ } else if(elementID != null &&
+ (dataType.equals(DataTypeManager.DefaultDataClasses.CLOB) ||
+ dataType.equals(DataTypeManager.DefaultDataClasses.BLOB) ||
+ dataType.equals(DataTypeManager.DefaultDataClasses.OBJECT))) {
+
+ int length = metadata.getElementLength(elementID);
+ if(length > 0) {
+ return new Integer(length);
+ }
+ }
+ // else BOOLEAN, DATE, TIME, TIMESTAMP, CHARACTER use max
+ return ResultsMetadataDefaults.getMaxDisplaySize(dataType);
+ }
+
+ public Map getDefaultColumn(String vdbName, String vdbVersion,
+ String tableName, String columnName, Class javaType) {
+
+ Map column = new HashMap();
+
+ // set defaults
+ column.put(ResultsMetadataConstants.VIRTUAL_DATABASE_NAME, vdbName);
+ column.put(ResultsMetadataConstants.VIRTUAL_DATABASE_VERSION, vdbVersion);
+ column.put(ResultsMetadataConstants.GROUP_NAME, tableName);
+ column.put(ResultsMetadataConstants.ELEMENT_NAME, columnName);
+ column.put(ResultsMetadataConstants.ELEMENT_LABEL, columnName);
+ column.put(ResultsMetadataConstants.AUTO_INCREMENTING, Boolean.FALSE);
+ column.put(ResultsMetadataConstants.CASE_SENSITIVE, Boolean.FALSE);
+ column.put(ResultsMetadataConstants.NULLABLE, ResultsMetadataConstants.NULL_TYPES.NULLABLE);
+ column.put(ResultsMetadataConstants.SEARCHABLE, ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE);
+ column.put(ResultsMetadataConstants.WRITABLE, Boolean.TRUE);
+ column.put(ResultsMetadataConstants.CURRENCY, Boolean.FALSE);
+ column.put(ResultsMetadataConstants.DATA_TYPE, DataTypeManager.getDataTypeName(javaType));
+ column.put(ResultsMetadataConstants.RADIX, ResultsMetadataDefaults.DEFAULT_RADIX);
+ column.put(ResultsMetadataConstants.SCALE, ResultsMetadataDefaults.DEFAULT_SCALE);
+ column.put(ResultsMetadataConstants.SIGNED, Boolean.TRUE);
+
+ column.put(ResultsMetadataConstants.PRECISION, ResultsMetadataDefaults.getDefaultPrecision(javaType));
+ column.put(ResultsMetadataConstants.DISPLAY_SIZE, ResultsMetadataDefaults.getMaxDisplaySize(javaType));
+ return column;
+ }
+
+}
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedPlanCache.java (from rev 569, trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/PreparedPlanCache.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedPlanCache.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedPlanCache.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,204 @@
+/*
+ * 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.List;
+
+import com.metamatrix.core.util.ArgCheck;
+import com.metamatrix.core.util.HashCodeUtil;
+import com.metamatrix.core.util.LRUCache;
+import com.metamatrix.query.analysis.AnalysisRecord;
+import com.metamatrix.query.processor.ProcessorPlan;
+import com.metamatrix.query.sql.lang.Command;
+
+/**
+ * This class is used to cahce plan and related objects for prepared statement
+ */
+public class PreparedPlanCache {
+ public static final int DEFAULT_MAX_SIZE_TOTAL = 100;
+
+ private LRUCache cache;
+
+ PreparedPlanCache(){
+ this(DEFAULT_MAX_SIZE_TOTAL);
+ }
+
+ PreparedPlanCache (int maxSize ){
+ if(maxSize < 0){
+ maxSize = DEFAULT_MAX_SIZE_TOTAL;
+ }
+ cache = new LRUCache(maxSize);
+ }
+
+ /**
+ * Return the PreparedPlan for the given session and SQl query
+ * @param session ClientConnection
+ * @param sql SQL query string
+ * @return PreparedPlan for the given clientConn and SQl query. Null if not exist.
+ */
+ public synchronized PreparedPlan getPreparedPlan(String sessionId, String sql, boolean isPreparedBatchUpdate){
+ ArgCheck.isNotNull(sessionId);
+ ArgCheck.isNotNull(sql);
+
+ CacheID cID = new CacheID(sessionId, sql, isPreparedBatchUpdate);
+
+ return (PreparedPlan)cache.get(cID);
+ }
+
+ /**
+ * Create PreparedPlan for the given clientConn and SQl query
+ */
+ public synchronized PreparedPlan createPreparedPlan(String sessionId, String sql, boolean isPreparedBatchUpdate){
+ ArgCheck.isNotNull(sessionId);
+ ArgCheck.isNotNull(sql);
+
+ CacheID cID = new CacheID(sessionId, sql, isPreparedBatchUpdate);
+ PreparedPlan preparedPlan = (PreparedPlan)cache.get(cID);
+ if(preparedPlan == null){
+ preparedPlan = new PreparedPlan();
+ cache.put(cID, preparedPlan);
+ }
+ return preparedPlan;
+ }
+
+ /**
+ * Clear the cahced plans for the given clientConn
+ * @param clientConn ClientConnection
+ */
+ public synchronized void clear(String sessionId){
+ ArgCheck.isNotNull(sessionId);
+ //do not do anything
+ }
+
+ /**
+ * Clear all the cahced plans for all the clientConns
+ * @param clientConn ClientConnection
+ */
+ public synchronized void clearAll(){
+ cache.clear();
+ }
+
+ static class CacheID{
+ private String sessionId;
+ private String sql;
+ int hashCode;
+ private boolean isPreparedBatchUpdate;
+
+ CacheID(String sessionId, String sql, boolean isPreparedBatchUpdate){
+ this.sessionId = sessionId;
+ this.sql = sql;
+ this.isPreparedBatchUpdate = isPreparedBatchUpdate;
+ hashCode = HashCodeUtil.hashCode(HashCodeUtil.hashCode(0, sessionId), sql);
+ }
+
+ public boolean equals(Object obj){
+ if(obj == this) {
+ return true;
+ } else if(obj == null || ! (obj instanceof CacheID)) {
+ return false;
+ } else {
+ CacheID that = (CacheID)obj;
+ return this.sessionId.equals(that.sessionId)
+ && this.isPreparedBatchUpdate == that.isPreparedBatchUpdate
+ && this.sql.equals(that.sql);
+ }
+ }
+
+ public int hashCode() {
+ return hashCode;
+ }
+ }
+
+ static class PreparedPlan{
+ private ProcessorPlan plan;
+ private Command command;
+ private List refs;
+ private AnalysisRecord analysisRecord;
+
+ /**
+ * Return the ProcessorPlan.
+ */
+ public ProcessorPlan getPlan(){
+ return plan;
+ }
+
+ /**
+ * Return the plan description.
+ */
+ public AnalysisRecord getAnalysisRecord(){
+ return this.analysisRecord;
+ }
+
+ /**
+ * Return the Command .
+ */
+ public Command getCommand(){
+ return command;
+ }
+
+ /**
+ * Return the list of Reference.
+ */
+ public List getReferences(){
+ return refs;
+ }
+
+ /**
+ * Set the ProcessorPlan.
+ */
+ public void setPlan(ProcessorPlan planValue){
+ plan = planValue;
+ }
+
+ /**
+ * Set the plan description.
+ */
+ public void setAnalysisRecord(AnalysisRecord analysisRecord){
+ this.analysisRecord = analysisRecord;
+ }
+
+ /**
+ * Set the Command.
+ */
+ public void setCommand(Command commandValue){
+ command = commandValue;
+ }
+
+ /**
+ * Set the list of Reference.
+ */
+ public void setReferences(List refsValue){
+ refs = refsValue;
+ }
+
+ }
+
+ //for testing purpose
+ int getSpaceUsed() {
+ return cache.size();
+ }
+ int getSpaceAllowed() {
+ return cache.getSpaceLimit();
+ }
+
+}
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedPlanCache.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java (from rev 569, trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/PreparedStatementRequest.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,236 @@
+/*
+ * 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.Iterator;
+import java.util.List;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.query.ExpressionEvaluationException;
+import com.metamatrix.api.exception.query.QueryParserException;
+import com.metamatrix.api.exception.query.QueryPlannerException;
+import com.metamatrix.api.exception.query.QueryResolverException;
+import com.metamatrix.api.exception.query.QueryValidatorException;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.dqp.DQPPlugin;
+import com.metamatrix.dqp.util.LogConstants;
+import com.metamatrix.query.QueryPlugin;
+import com.metamatrix.query.eval.Evaluator;
+import com.metamatrix.query.processor.ProcessorPlan;
+import com.metamatrix.query.resolver.util.ResolverUtil;
+import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.sql.lang.PreparedBatchUpdate;
+import com.metamatrix.query.sql.lang.SPParameter;
+import com.metamatrix.query.sql.lang.StoredProcedure;
+import com.metamatrix.query.sql.symbol.Constant;
+import com.metamatrix.query.sql.symbol.Expression;
+import com.metamatrix.query.sql.symbol.Reference;
+
+/**
+ * Specific request for handling prepared statement calls.
+ */
+public class PreparedStatementRequest extends Request {
+ private PreparedPlanCache prepPlanCache;
+ private PreparedPlanCache.PreparedPlan prepPlan;
+
+ public PreparedStatementRequest(PreparedPlanCache prepPlanCache) {
+ this.prepPlanCache = prepPlanCache;
+ }
+
+ @Override
+ protected void checkReferences(List references)
+ throws QueryValidatorException {
+ //do nothing - references are allowed
+ }
+
+ /**
+ * @see org.teiid.dqp.internal.process.Request#resolveCommand(com.metamatrix.query.sql.lang.Command)
+ */
+ protected void resolveCommand(Command command, List references) throws QueryResolverException,
+ MetaMatrixComponentException {
+
+ handleCallableStatement(command, references);
+
+ super.resolveCommand(command, references);
+
+ if(requestMsg.isPreparedBatchUpdate()){
+ ((PreparedBatchUpdate)command).setParameterReferences(references);
+ }
+ //save the command in it's present form so that it can be validated later
+ prepPlan.setCommand((Command) command.clone());
+ prepPlan.setReferences(references);
+ }
+
+ /**
+ * TODO: this is a hack that maintains pre 5.6 behavior, which ignores output parameters for resolving
+ * @param command
+ * @param references
+ */
+ private void handleCallableStatement(Command command, List references) {
+ if (!this.requestMsg.isCallableStatement() || !(command instanceof StoredProcedure)) {
+ return;
+ }
+ StoredProcedure proc = (StoredProcedure)command;
+ if (!proc.isCallableStatement()) {
+ return;
+ }
+ List values = requestMsg.getParameterValues();
+ List spParams = proc.getParameters();
+ proc.clearParameters();
+ int inParameterCount = values.size();
+ if (this.requestMsg.isPreparedBatchUpdate() && values.size() > 0) {
+ inParameterCount = ((List)values.get(0)).size();
+ }
+ int index = 1;
+ for (Iterator params = spParams.iterator(); params.hasNext();) {
+ SPParameter param = (SPParameter) params.next();
+ if (param.getParameterType() == SPParameter.RETURN_VALUE) {
+ continue;
+ }
+ if (param.getExpression() instanceof Reference && index > inParameterCount) {
+ //assume it's an output parameter
+ references.remove(param.getExpression());
+ continue;
+ }
+ param.setIndex(index++);
+ proc.setParameter(param);
+ }
+ }
+
+ protected void resolveParameterValues() throws QueryResolverException, MetaMatrixComponentException {
+ List params = prepPlan.getReferences();
+ List values = requestMsg.getParameterValues();
+ if(requestMsg.isPreparedBatchUpdate()){
+ if(values.size() > 1){
+ ((PreparedBatchUpdate)command).setUpdatingModelCount(2);
+ }
+ for(int i=0; i<values.size(); i++){
+ if (params.size() != ((List)values.get(i)).size()) {
+ String msg = DQPPlugin.Util.getString("DQPCore.wrong_number_of_values", new Object[] {new Integer(values.size()), new Integer(params.size())}); //$NON-NLS-1$
+ throw new QueryResolverException(msg);
+ }
+ }
+ } else {
+ PreparedStatementRequest.resolveParameterValues(params, values);
+ }
+ }
+
+ @Override
+ protected void validateQueryValues(Command command)
+ throws QueryValidatorException, MetaMatrixComponentException {
+ //do nothing initially - check after parameter values have been set
+ }
+
+ /**
+ * @throws MetaMatrixComponentException
+ * @throws QueryValidatorException
+ * @throws QueryResolverException
+ * @throws QueryParserException
+ * @throws QueryPlannerException
+ * @see org.teiid.dqp.internal.process.Request#generatePlan()
+ */
+ protected void generatePlan() throws QueryPlannerException, QueryParserException, QueryResolverException, QueryValidatorException, MetaMatrixComponentException {
+
+ String sqlQuery = requestMsg.getCommands()[0];
+ prepPlan = prepPlanCache.getPreparedPlan(this.workContext.getConnectionID(), sqlQuery, requestMsg.isPreparedBatchUpdate());
+ if (prepPlan == null) {
+ //if prepared plan does not exist, create one
+ prepPlan = prepPlanCache.createPreparedPlan(this.workContext.getConnectionID(), sqlQuery, requestMsg.isPreparedBatchUpdate());
+ LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Query does not exist in cache: ", sqlQuery}); //$NON-NLS-1$
+ }
+
+ ProcessorPlan cachedPlan = prepPlan.getPlan();
+ Command command = prepPlan.getCommand();
+
+ if (cachedPlan == null) {
+ super.generatePlan();
+
+ if (!this.addedLimit) { //TODO: this is a little problematic
+ // Defect 13751: Clone the plan in its current state (i.e. before processing) so that it can be used for later queries
+ prepPlan.setPlan((ProcessorPlan)processPlan.clone());
+ prepPlan.setAnalysisRecord(analysisRecord);
+ }
+ command = prepPlan.getCommand();
+ } else {
+ LogManager.logTrace(LogConstants.CTX_DQP, new Object[] { "Query exist in cache: ", sqlQuery }); //$NON-NLS-1$
+ processPlan = (ProcessorPlan)cachedPlan.clone();
+ //already in cache. obtain the values from cache
+ analysisRecord = prepPlan.getAnalysisRecord();
+
+ this.command = command;
+ createCommandContext(command);
+ }
+
+ // validate parameters values - right number and right type
+ resolveParameterValues();
+ // call back to Request.validateQueryValues to ensure that bound references are valid
+ super.validateQueryValues(command);
+ }
+
+ /**
+ * @param params
+ * @param values
+ * @throws QueryResolverException
+ */
+ public static void resolveParameterValues(List params,
+ List values) throws QueryResolverException, MetaMatrixComponentException {
+ //the size of the values must be the same as that of the parameters
+ if (params.size() != values.size()) {
+ String msg = QueryPlugin.Util.getString("QueryUtil.wrong_number_of_values", new Object[] {new Integer(values.size()), new Integer(params.size())}); //$NON-NLS-1$
+ throw new QueryResolverException(msg);
+ }
+
+ if (params.isEmpty()) {
+ return;
+ }
+
+ //the type must be the same, or the type of the value can be implicitly converted
+ //to that of the reference
+ for (int i = 0; i < params.size(); i++) {
+ Reference param = (Reference) params.get(i);
+ Object value = values.get(i);
+
+ //TODO: why is the list check in here
+ if(value != null && !(value instanceof List)) {
+ try {
+ String targetTypeName = DataTypeManager.getDataTypeName(param.getType());
+ Expression expr = ResolverUtil.convertExpression(new Constant(value), targetTypeName);
+ value = Evaluator.evaluate(expr);
+ } catch (ExpressionEvaluationException e) {
+ String msg = QueryPlugin.Util.getString("QueryUtil.Error_executing_conversion_function_to_convert_value", new Integer(i + 1), value, DataTypeManager.getDataTypeName(param.getType())); //$NON-NLS-1$
+ throw new QueryResolverException(msg);
+ } catch (QueryResolverException e) {
+ String msg = QueryPlugin.Util.getString("QueryUtil.Error_executing_conversion_function_to_convert_value", new Integer(i + 1), value, DataTypeManager.getDataTypeName(param.getType())); //$NON-NLS-1$
+ throw new QueryResolverException(msg);
+ }
+ }
+
+ // Create with expected type if null
+ Constant constant = new Constant(value, param.getType());
+
+ //bind variable
+ param.setExpression(constant);
+ }
+ }
+}
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/QueryMetadataWrapper.java (from rev 569, trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/QueryMetadataWrapper.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/QueryMetadataWrapper.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/QueryMetadataWrapper.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,88 @@
+/*
+ * 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.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.query.QueryMetadataException;
+import com.metamatrix.common.vdb.api.ModelInfo;
+import com.metamatrix.dqp.service.VDBService;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.metadata.BasicQueryMetadataWrapper;
+
+/**
+ * This classs is a proxy to QueryMetadataInterface. It knows VDBService
+ * and VNB name.
+ */
+public class QueryMetadataWrapper extends BasicQueryMetadataWrapper{
+ private String vdbName;
+ private String vdbVersion;
+ private VDBService vdbService;
+
+ public QueryMetadataWrapper(QueryMetadataInterface actualMetadata, String vdbName, String vdbVersion, VDBService vdbService){
+ super(actualMetadata);
+ this.vdbName = vdbName;
+ this.vdbService = vdbService;
+ this.vdbVersion = vdbVersion;
+ }
+
+ protected QueryMetadataInterface getActualMetadata() {
+ return this.actualMetadata;
+ }
+ protected String getVdbName() {
+ return this.vdbName;
+ }
+ protected VDBService getVdbService() {
+ return this.vdbService;
+ }
+ protected String getVdbVersion() {
+ return this.vdbVersion;
+ }
+
+ /**
+ * @see com.metamatrix.query.metadata.QueryMetadataInterface#getGroupsForPartialName(java.lang.String)
+ */
+ public Collection getGroupsForPartialName(String partialGroupName) throws MetaMatrixComponentException, QueryMetadataException {
+ Collection result = actualMetadata.getGroupsForPartialName(partialGroupName);
+ if(result == null || result.isEmpty()){
+ return result;
+ }
+ Collection filteredResult = new HashSet();
+ Iterator iter = result.iterator();
+ while(iter.hasNext()){
+ String groupName = (String)iter.next();
+ Object groupID = actualMetadata.getGroupID(groupName);
+ Object modelID = actualMetadata.getModelID(groupID);
+ String modelName = actualMetadata.getFullName(modelID);
+ int visibility = vdbService.getModelVisibility(vdbName, vdbVersion, modelName);
+ if(visibility == ModelInfo.PUBLIC){
+ filteredResult.add(groupName);
+ }
+ }
+ return filteredResult;
+ }
+
+}
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/process/QueryMetadataWrapper.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java (from rev 569, trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/Request.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,676 @@
+/*
+ * 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.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.transaction.SystemException;
+
+import org.teiid.connector.xa.api.TransactionContext;
+import org.teiid.dqp.internal.process.capabilities.ConnectorCapabilitiesFinder;
+import org.teiid.dqp.internal.process.capabilities.SharedCachedFinder;
+import org.teiid.dqp.internal.process.multisource.MultiSourceCapabilitiesFinder;
+import org.teiid.dqp.internal.process.multisource.MultiSourceMetadataWrapper;
+import org.teiid.dqp.internal.process.multisource.MultiSourcePlanToProcessConverter;
+import org.teiid.dqp.internal.process.validator.AuthorizationValidationVisitor;
+import org.teiid.dqp.internal.process.validator.ModelVisibilityValidationVisitor;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.MetaMatrixProcessingException;
+import com.metamatrix.api.exception.query.QueryMetadataException;
+import com.metamatrix.api.exception.query.QueryParserException;
+import com.metamatrix.api.exception.query.QueryPlannerException;
+import com.metamatrix.api.exception.query.QueryResolverException;
+import com.metamatrix.api.exception.query.QueryValidatorException;
+import com.metamatrix.common.application.ApplicationEnvironment;
+import com.metamatrix.common.buffer.BufferManager;
+import com.metamatrix.common.buffer.TupleSourceID;
+import com.metamatrix.common.buffer.BufferManager.TupleSourceType;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.common.xa.XATransactionException;
+import com.metamatrix.core.id.IDGenerator;
+import com.metamatrix.core.id.IntegerIDFactory;
+import com.metamatrix.core.util.Assertion;
+import com.metamatrix.dqp.DQPPlugin;
+import com.metamatrix.dqp.message.RequestID;
+import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.service.AuthorizationService;
+import com.metamatrix.dqp.service.DQPServiceNames;
+import com.metamatrix.dqp.service.DataService;
+import com.metamatrix.dqp.service.MetadataService;
+import com.metamatrix.dqp.service.TransactionService;
+import com.metamatrix.dqp.service.VDBService;
+import com.metamatrix.dqp.util.LogConstants;
+import com.metamatrix.jdbc.api.ExecutionProperties;
+import com.metamatrix.query.analysis.AnalysisRecord;
+import com.metamatrix.query.eval.SecurityFunctionEvaluator;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.metadata.TempMetadataAdapter;
+import com.metamatrix.query.metadata.TempMetadataStore;
+import com.metamatrix.query.optimizer.QueryOptimizer;
+import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
+import com.metamatrix.query.parser.ParseInfo;
+import com.metamatrix.query.parser.QueryParser;
+import com.metamatrix.query.processor.ProcessorDataManager;
+import com.metamatrix.query.processor.ProcessorPlan;
+import com.metamatrix.query.processor.QueryProcessor;
+import com.metamatrix.query.processor.TempTableDataManager;
+import com.metamatrix.query.processor.xml.XMLPlan;
+import com.metamatrix.query.processor.xquery.XQueryPlan;
+import com.metamatrix.query.resolver.QueryResolver;
+import com.metamatrix.query.rewriter.QueryRewriter;
+import com.metamatrix.query.sql.lang.BatchedUpdateCommand;
+import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.sql.lang.Limit;
+import com.metamatrix.query.sql.lang.Option;
+import com.metamatrix.query.sql.lang.QueryCommand;
+import com.metamatrix.query.sql.lang.StoredProcedure;
+import com.metamatrix.query.sql.lang.XQuery;
+import com.metamatrix.query.sql.symbol.Constant;
+import com.metamatrix.query.sql.visitor.ReferenceCollectorVisitor;
+import com.metamatrix.query.tempdata.TempTableStore;
+import com.metamatrix.query.util.CommandContext;
+import com.metamatrix.query.util.ContextProperties;
+import com.metamatrix.query.util.TypeRetrievalUtil;
+import com.metamatrix.query.validator.AbstractValidationVisitor;
+import com.metamatrix.query.validator.ValidationVisitor;
+import com.metamatrix.query.validator.Validator;
+import com.metamatrix.query.validator.ValidatorFailure;
+import com.metamatrix.query.validator.ValidatorReport;
+import com.metamatrix.query.validator.ValueValidationVisitor;
+
+/**
+ * Server side representation of the RequestMessage. Knows how to process itself.
+ */
+public class Request implements QueryProcessor.ProcessorFactory {
+
+ // init state
+ protected RequestMessage requestMsg;
+ private String vdbName;
+ private String vdbVersion;
+ private ApplicationEnvironment env;
+ private VDBService vdbService;
+ private BufferManager bufferManager;
+ private ProcessorDataManager processorDataManager;
+ private TransactionService transactionService;
+ private TempTableStore tempTableStore;
+ private IDGenerator idGenerator = new IDGenerator();
+ private boolean procDebugAllowed = false;
+ private Map connectorCapabilitiesCache;
+ DQPWorkContext workContext;
+ RequestID requestId;
+
+ // acquired state
+ private CapabilitiesFinder capabilitiesFinder;
+ private QueryMetadataInterface metadata;
+ private Set multiSourceModels;
+
+ // internal results
+ protected boolean addedLimit;
+ protected ProcessorPlan processPlan;
+ // external results
+ protected AnalysisRecord analysisRecord;
+ protected CommandContext context;
+ protected QueryProcessor processor;
+ protected List schemas;
+
+ protected TransactionContext transactionContext;
+
+ private int chunkSize;
+
+ protected Command command;
+
+ void initialize(RequestMessage requestMsg,
+ ApplicationEnvironment env,
+ BufferManager bufferManager,
+ ProcessorDataManager processorDataManager,
+ Map connectorCapabilitiesCache,
+ TransactionService transactionService,
+ boolean procDebugAllowed,
+ TempTableStore tempTableStore,
+ DQPWorkContext workContext,
+ int chunckSize) {
+
+ this.requestMsg = requestMsg;
+ this.vdbName = workContext.getVdbName();
+ this.vdbVersion = workContext.getVdbVersion();
+ this.env = env;
+ this.vdbService = (VDBService) env.findService(DQPServiceNames.VDB_SERVICE);
+ this.bufferManager = bufferManager;
+ this.processorDataManager = processorDataManager;
+ 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());
+ this.chunkSize = chunckSize;
+ }
+
+ void setMetadata(CapabilitiesFinder capabilitiesFinder, QueryMetadataInterface metadata, Set multiSourceModels) {
+ this.capabilitiesFinder = capabilitiesFinder;
+ this.metadata = metadata;
+ this.multiSourceModels = multiSourceModels;
+ }
+
+ /**
+ * if the metadata has not been supplied via setMetadata, this method will create the appropriate state
+ *
+ * @throws MetaMatrixComponentException
+ */
+ protected void initMetadata() throws MetaMatrixComponentException {
+ if (this.metadata != null) {
+ return;
+ }
+ // Prepare dependencies for running the optimizer
+ CapabilitiesFinder baseFinder =
+ new ConnectorCapabilitiesFinder(
+ this.vdbService,
+ (DataService) this.env.findService(DQPServiceNames.DATA_SERVICE),
+ requestMsg, workContext);
+
+ // Wrap the finder with a cache
+ this.capabilitiesFinder = new SharedCachedFinder(baseFinder, connectorCapabilitiesCache);
+
+ MetadataService metadataService = (MetadataService) this.env.findService(DQPServiceNames.METADATA_SERVICE);
+ if(metadataService == null){
+ //should not come here. Per defect 15087,
+ //in a rare situation it might be null
+ //try to get it again
+ metadataService = (MetadataService) this.env.findService(DQPServiceNames.METADATA_SERVICE);
+ if(metadataService == null){
+ String msg = DQPPlugin.Util.getString("Request.MetadataServiceIsNull"); //$NON-NLS-1$
+ throw new MetaMatrixComponentException(msg);
+ }
+ }
+ metadata = metadataService.lookupMetadata(vdbName, vdbVersion);
+
+ if (metadata == null) {
+ Object[] params = new Object[] { this.vdbName, this.vdbVersion };
+ String msg = DQPPlugin.Util.getString("DQPCore.Unable_to_load_metadata_for_VDB_name__{0},_version__{1}", params); //$NON-NLS-1$
+ MetaMatrixComponentException e = new MetaMatrixComponentException(msg);
+ throw e;
+ }
+
+ this.metadata = new TempMetadataAdapter(metadata, new TempMetadataStore());
+
+ //wrap metadata in the wrapper that knows VDBService
+ this.metadata = new QueryMetadataWrapper(this.metadata, this.vdbName, this.vdbVersion, this.vdbService);
+
+ // Check for multi-source models and further wrap the metadata interface
+ List multiSourceModelList = vdbService.getMultiSourceModels(this.vdbName, this.vdbVersion);
+ if(multiSourceModelList != null && multiSourceModelList.size() > 0) {
+ this.multiSourceModels = new HashSet(multiSourceModelList);
+ this.metadata = new MultiSourceMetadataWrapper(this.metadata, this.multiSourceModels);
+ }
+ }
+
+ protected void createCommandContext(Command command) {
+ // Create command context, used in rewriting, planning, and processing
+ // Identifies a "group" of requests on a per-connection basis to allow later
+ // cleanup of all resources in the group on connection shutdown
+ String groupName = workContext.getConnectionID();
+
+ RequestID reqID = workContext.getRequestID(this.requestMsg.getExecutionId());
+
+ Properties props = new Properties();
+ props.setProperty(ContextProperties.SESSION_ID, workContext.getConnectionID());
+
+ this.context =
+ new CommandContext(
+ reqID,
+ groupName,
+ null,
+ requestMsg.getFetchSize(),
+ workContext.getUserName(),
+ workContext.getTrustedPayload(),
+ requestMsg.getExecutionPayload(),
+ workContext.getVdbName(),
+ workContext.getVdbVersion(),
+ props,
+ useProcDebug(command),
+ collectNodeStatistics(command));
+ this.context.setProcessorBatchSize(bufferManager.getProcessorBatchSize());
+ this.context.setConnectorBatchSize(bufferManager.getConnectorBatchSize());
+ this.context.setStreamingBatchSize(chunkSize);
+
+ if (multiSourceModels != null) {
+ MultiSourcePlanToProcessConverter modifier = new MultiSourcePlanToProcessConverter(
+ metadata, idGenerator, analysisRecord, capabilitiesFinder,
+ multiSourceModels, vdbName, vdbService, vdbVersion);
+ context.setPlanToProcessConverter(modifier);
+ }
+
+ context.setSecurityFunctionEvaluator((SecurityFunctionEvaluator)this.env.findService(DQPServiceNames.AUTHORIZATION_SERVICE));
+ if(requestMsg.isPreparedBatchUpdate()){
+ context.setPreparedBatchUpdateValues(requestMsg.getParameterValues());
+ }
+ context.setTempTableStore(tempTableStore);
+ context.setQueryProcessorFactory(this);
+ }
+
+ /**
+ * Side effects:
+ * creates the analysis record
+ * creates the command context
+ * sets the pre-rewrite command on the request
+ * adds a limit clause if the row limit is specified
+ *
+ * @return the post rewrite query
+ * @throws QueryParserException
+ * @throws QueryResolverException
+ * @throws QueryValidatorException
+ * @throws MetaMatrixComponentException
+ */
+ protected Command prepareCommand() throws QueryParserException,
+ QueryResolverException,
+ QueryValidatorException,
+ MetaMatrixComponentException {
+
+ Command command = getCommand();
+
+ List references = ReferenceCollectorVisitor.getReferences(command);
+
+ //there should be no reference (?) for query/update executed as statement
+ checkReferences(references);
+
+ createAnalysisRecord(command);
+
+ resolveCommand(command, references);
+
+ createCommandContext(command);
+
+ validateQuery(command, true);
+
+ validateQueryValues(command);
+
+ Command preRewrite = command;
+
+ command = QueryRewriter.rewrite(command, null, metadata, context);
+
+ /*
+ * Adds a row limit to a query if Statement.setMaxRows has been called and the command
+ * doesn't already have a limit clause.
+ */
+ if (requestMsg.getRowLimit() > 0 && command instanceof QueryCommand) {
+ QueryCommand query = (QueryCommand)command;
+ if (query.getLimit() == null) {
+ query.setLimit(new Limit(null, new Constant(new Integer(requestMsg.getRowLimit()), DataTypeManager.DefaultDataClasses.INTEGER)));
+ this.addedLimit = true;
+ }
+ }
+
+ this.command = preRewrite;
+ return command;
+ }
+
+ protected void checkReferences(List references) throws QueryValidatorException {
+ referenceCheck(references);
+ }
+
+ static void referenceCheck(List references) throws QueryValidatorException {
+ if (references != null && !references.isEmpty()) {
+ throw new QueryValidatorException(DQPPlugin.Util.getString("Request.Invalid_character_in_query")); //$NON-NLS-1$
+ }
+ }
+
+ protected void resolveCommand(Command command, List references) throws QueryResolverException, MetaMatrixComponentException {
+ if (this.tempTableStore != null) {
+ QueryResolver.setChildMetadata(command, tempTableStore.getMetadataStore().getData(), null);
+ }
+
+ QueryResolver.resolveCommand(command, metadata, analysisRecord);
+ }
+
+ private void validateQuery(Command command, boolean validateVisibility)
+ throws QueryValidatorException, MetaMatrixComponentException {
+
+ // Create generic sql validation visitor
+ AbstractValidationVisitor visitor = new ValidationVisitor();
+ validateWithVisitor(visitor, metadata, command, false);
+
+ if (validateVisibility) {
+ // Create model visibility validation visitor
+ visitor = new ModelVisibilityValidationVisitor(this.vdbService, this.vdbName, this.vdbVersion);
+ validateWithVisitor(visitor, metadata, command, true);
+ }
+ }
+
+ protected void validateQueryValues(Command command)
+ throws QueryValidatorException, MetaMatrixComponentException {
+
+ AbstractValidationVisitor visitor = new ValueValidationVisitor();
+ validateWithVisitor(visitor, metadata, command, false);
+ }
+
+ private Command getCommand() throws QueryParserException {
+ String[] commands = requestMsg.getCommands();
+ ParseInfo parseInfo = new ParseInfo();
+ if (requestMsg.isDoubleQuotedVariableAllowed()) {
+ parseInfo.allowDoubleQuotedVariable = true;
+ }
+ if (!requestMsg.isBatchedUpdate()) {
+ String commandStr = commands[0];
+ return QueryParser.getQueryParser().parseCommand(commandStr, parseInfo);
+ }
+ List parsedCommands = new ArrayList(commands.length);
+ for (int i = 0; i < commands.length; i++) {
+ String updateCommand = commands[i];
+ parsedCommands.add(QueryParser.getQueryParser().parseCommand(updateCommand, parseInfo));
+ }
+ return new BatchedUpdateCommand(parsedCommands);
+ }
+
+ public static void validateWithVisitor(
+ AbstractValidationVisitor visitor,
+ QueryMetadataInterface metadata,
+ Command command,
+ boolean validateOnlyEmbedded)
+ throws QueryValidatorException, MetaMatrixComponentException {
+
+ // Validate with visitor
+ ValidatorReport report = Validator.validate(command, metadata, visitor, validateOnlyEmbedded);
+ if (report.hasItems()) {
+ ValidatorFailure firstFailure = (ValidatorFailure) report.getItems().iterator().next();
+ throw new QueryValidatorException(firstFailure.getMessage());
+ }
+ }
+
+ protected void createProcessor() throws MetaMatrixComponentException {
+
+ TransactionContext tc = null;
+
+ if (transactionService != null) {
+ tc = transactionService.getTransactionServer().getOrCreateTransactionContext(workContext.getConnectionID());
+ }
+
+ if (tc != null){
+ Assertion.assertTrue(tc.getTransactionType() != TransactionContext.Scope.TRANSACTION_REQUEST, "Transaction already associated with request."); //$NON-NLS-1$
+ }
+
+ if (tc == null || !tc.isInTransaction()) {
+ //if not under a transaction
+
+ boolean startAutoWrapTxn = false;
+
+ if(ExecutionProperties.AUTO_WRAP_ON.equals(requestMsg.getTxnAutoWrapMode())){
+ startAutoWrapTxn = true;
+ } else if ( command.updatingModelCount(metadata) > 1) {
+ if (ExecutionProperties.AUTO_WRAP_OPTIMISTIC.equals(requestMsg.getTxnAutoWrapMode())){
+ String msg = DQPPlugin.Util.getString("Request.txn_needed_wrong_mode", requestId); //$NON-NLS-1$
+ throw new MetaMatrixComponentException(msg);
+ } else if (ExecutionProperties.AUTO_WRAP_PESSIMISTIC.equals(requestMsg.getTxnAutoWrapMode())){
+ startAutoWrapTxn = true;
+ } else if (ExecutionProperties.AUTO_WRAP_OFF.equals(requestMsg.getTxnAutoWrapMode())) {
+ LogManager.logDetail(LogConstants.CTX_DQP, DQPPlugin.Util.getString("Request.potentially_unsafe")); //$NON-NLS-1$
+ }
+ }
+ if(ExecutionProperties.AUTO_WRAP_OPTIMISTIC.equals(requestMsg.getTxnAutoWrapMode())){
+ this.context.setOptimisticTransaction(true);
+ }
+
+ if (startAutoWrapTxn) {
+ if (transactionService == null) {
+ throw new MetaMatrixComponentException(DQPPlugin.Util.getString("Request.transaction_not_supported")); //$NON-NLS-1$
+ }
+ try {
+ tc = transactionService.getTransactionServer().start(tc);
+ } catch (XATransactionException err) {
+ throw new MetaMatrixComponentException(err);
+ } catch (SystemException err) {
+ throw new MetaMatrixComponentException(err);
+ }
+ }
+ }
+
+ this.transactionContext = tc;
+ List outputElements = processPlan.getOutputElements();
+ this.context.setTupleSourceID(this.bufferManager.createTupleSource(
+ outputElements,
+ TypeRetrievalUtil.getTypeNames(outputElements),
+ this.workContext.getConnectionID(),
+ TupleSourceType.FINAL));
+ this.processor = new QueryProcessor(processPlan, context, bufferManager, new TempTableDataManager(processorDataManager, tempTableStore));
+ }
+
+ private boolean useProcDebug(Command command) {
+ if(this.procDebugAllowed) {
+ Option option = command.getOption();
+ if(option != null) {
+ return option.getDebug();
+ }
+ }
+ return false;
+ }
+
+ private boolean collectNodeStatistics(Command command) {
+ if(this.requestMsg.getShowPlan()) {
+ return true;
+ }
+ Option option = command.getOption();
+ if(option != null) {
+ return (option.getDebug() || option.getShowPlan());
+ }
+ return false;
+ }
+
+ /**
+ * side effects:
+ * sets the processor plan
+ *
+ * @throws MetaMatrixComponentException
+ * @throws QueryPlannerException
+ * @throws QueryParserException
+ * @throws QueryResolverException
+ * @throws QueryValidatorException
+ */
+ protected void generatePlan() throws MetaMatrixComponentException, QueryPlannerException, QueryParserException, QueryResolverException, QueryValidatorException {
+ Command command = prepareCommand();
+
+ try {
+ // If using multi-source models, insert a proxy to simplify the supported capabilities. This is
+ // done OUTSIDE the cache (wrapped around the cache) intentionally to avoid caching the simplified
+ // capabilities which may be different for the same model in a different VDB used by this same DQP.
+ CapabilitiesFinder finder = this.capabilitiesFinder;
+ if(this.multiSourceModels != null) {
+ finder = new MultiSourceCapabilitiesFinder(finder, this.multiSourceModels);
+ }
+
+ // Run the optimizer
+ try {
+ processPlan = QueryOptimizer.optimizePlan(command, metadata, idGenerator, finder, analysisRecord, context);
+ } finally {
+ String debugLog = analysisRecord.getDebugLog();
+ if(debugLog != null && debugLog.length() > 0) {
+ LogManager.logInfo(LogConstants.CTX_DQP, debugLog);
+ }
+ }
+
+ if (analysisRecord.recordQueryPlan()) {
+ analysisRecord.setQueryPlan(processPlan.getDescriptionProperties());
+ }
+
+ LogManager.logDetail(LogConstants.CTX_DQP, new Object[] { DQPPlugin.Util.getString("BasicInterceptor.ProcessTree_for__4"), requestId, processPlan }); //$NON-NLS-1$
+ } catch (QueryMetadataException e) {
+ Object[] params = new Object[] { requestId};
+ String msg = DQPPlugin.Util.getString("DQPCore.Unknown_query_metadata_exception_while_registering_query__{0}.", params); //$NON-NLS-1$
+ throw new QueryPlannerException(e, msg);
+ }
+ }
+
+ private void setSchemasForXMLPlan(Command command, QueryMetadataInterface metadata)
+ throws MetaMatrixComponentException, QueryMetadataException {
+
+ XMLPlan xmlPlan = null;
+
+ if(processPlan instanceof XMLPlan) {
+ xmlPlan = (XMLPlan)processPlan;
+ }else if(processPlan instanceof XQueryPlan) {
+ ((XQueryPlan)processPlan).setXMLFormat(requestMsg.getXMLFormat());
+ }else if(command instanceof StoredProcedure) {
+ Collection childPlans = processPlan.getChildPlans();
+ if(!childPlans.isEmpty()) {
+ ProcessorPlan plan = (ProcessorPlan)childPlans.iterator().next();
+ //check the last child plan of this procedure plan
+ Collection procChildPlans = plan.getChildPlans();
+ if(procChildPlans.size() > 0) {
+ Iterator iter = procChildPlans.iterator();
+ ProcessorPlan lastPlan = null;
+ while(iter.hasNext()) {
+ lastPlan = (ProcessorPlan) iter.next();
+ }
+ if(lastPlan instanceof XMLPlan) {
+ xmlPlan = (XMLPlan)lastPlan;
+ }
+ }
+ }
+ }
+
+ if (xmlPlan == null) {
+ return;
+ }
+
+ // Set the post-processing options on the plan
+ boolean shouldValidate = requestMsg.getValidationMode();
+
+ xmlPlan.setShouldValidate(shouldValidate);
+ xmlPlan.setStylesheet(requestMsg.getStyleSheet());
+ xmlPlan.setXMLFormat(requestMsg.getXMLFormat());
+
+ // if the validation/schema mode is set to true look up the schema in runtime metadata
+ if (shouldValidate) {
+ this.schemas = metadata.getXMLSchemas(xmlPlan.getDocumentGroup().getMetadataID());
+ // set the schema into the plan
+ xmlPlan.setXMLSchemas(schemas);
+ }
+ }
+
+ private void createAnalysisRecord(Command command) throws QueryValidatorException{
+ Option option = command.getOption();
+ boolean getPlan = requestMsg.getShowPlan();
+ boolean debug = false;
+ if (option != null) {
+ getPlan = getPlan || option.getShowPlan() || option.getPlanOnly();
+ debug = option.getDebug();
+ }
+
+ if (getPlan && !requestMsg.isQueryPlanAllowed()){
+ final String message = DQPPlugin.Util.getString("Request.query_plan_not_allowed"); //$NON-NLS-1$
+ throw new QueryValidatorException(message);
+ }
+
+ this.analysisRecord = new AnalysisRecord(getPlan, getPlan, debug);
+ }
+
+ public void processRequest()
+ throws QueryValidatorException, QueryParserException, QueryResolverException, MetaMatrixComponentException, QueryPlannerException {
+
+ initMetadata();
+
+ generatePlan();
+
+ validateEntitlement(command);
+
+ setSchemasForXMLPlan(command, metadata);
+
+ createProcessor();
+ }
+
+ public QueryProcessor createQueryProcessor(String query, String recursionGroup, CommandContext commandContext) throws MetaMatrixProcessingException, MetaMatrixComponentException {
+ boolean isRootXQuery = recursionGroup == null && commandContext.getCallStackDepth() == 0 && command instanceof XQuery;
+
+ ParseInfo parseInfo = new ParseInfo();
+ if (isRootXQuery && requestMsg.isDoubleQuotedVariableAllowed()) {
+ parseInfo.allowDoubleQuotedVariable = true;
+ }
+ Command newCommand = QueryParser.getQueryParser().parseCommand(query, parseInfo);
+ QueryResolver.resolveCommand(newCommand, metadata);
+
+ List references = ReferenceCollectorVisitor.getReferences(newCommand);
+
+ referenceCheck(references);
+
+ validateQuery(newCommand, isRootXQuery);
+
+ validateQueryValues(newCommand);
+
+ if (isRootXQuery) {
+ validateEntitlement(newCommand);
+ }
+
+ CommandContext copy = (CommandContext) commandContext.clone();
+ if (recursionGroup != null) {
+ copy.pushCall(recursionGroup);
+ }
+
+ QueryRewriter.rewrite(newCommand, null, metadata, copy);
+ ProcessorPlan plan = QueryOptimizer.optimizePlan(newCommand, metadata, idGenerator, capabilitiesFinder, analysisRecord, copy);
+
+ TupleSourceID resultsId = bufferManager.createTupleSource(newCommand.getProjectedSymbols(), TypeRetrievalUtil.getTypeNames(newCommand.getProjectedSymbols()), copy.getConnectionID(), TupleSourceType.PROCESSOR);
+ copy.setTupleSourceID(resultsId);
+ return new QueryProcessor(plan, copy, bufferManager, processorDataManager);
+ }
+
+ protected void validateEntitlement(Command command)
+ throws QueryValidatorException, MetaMatrixComponentException {
+ // Validate the query (may only want to validate entitlement)
+ AuthorizationService authSvc = (AuthorizationService) this.env
+ .findService(DQPServiceNames.AUTHORIZATION_SERVICE);
+ if (authSvc != null) {
+ // See if entitlement checking is turned on
+ if (authSvc.checkingEntitlements()) {
+ AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(
+ this.workContext.getConnectionID(), authSvc);
+ if (command.getType() == Command.TYPE_XQUERY) {
+ // validate its first level children
+ Iterator iter = command.getSubCommands().iterator();
+ while (iter.hasNext()) {
+ validateWithVisitor(visitor, this.metadata,
+ (Command) iter.next(), true);
+ }
+ } else {
+ validateWithVisitor(visitor, this.metadata, command, true);
+ }
+ } else if (workContext.getUserName().equals(
+ AuthorizationService.DEFAULT_WSDL_USERNAME)) {
+ if (command.getType() == Command.TYPE_STORED_PROCEDURE &&
+ AuthorizationValidationVisitor.GET_UPDATED_CHARACTER_VDB_RESOURCE.contains(((StoredProcedure) command).getProcedureName())) {
+ // do nothing... this is valid
+ } else {
+ // Throw an exception since the WSDL user is trying to do something other than access the VDB resources
+ final String message = DQPPlugin.Util.getString("Request.wsdl_user_not_authorized"); //$NON-NLS-1$
+ throw new QueryValidatorException(message);
+ }
+ }
+ }
+ }
+}
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java (from rev 569, trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/RequestWorkItem.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,740 @@
+/*
+ * 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.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.SystemException;
+
+import org.teiid.connector.xa.api.TransactionContext;
+import org.teiid.dqp.internal.cache.CacheID;
+import org.teiid.dqp.internal.cache.CacheResults;
+import org.teiid.dqp.internal.cache.ResultSetCache;
+import org.teiid.dqp.internal.cache.ResultSetCacheUtil;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.MetaMatrixException;
+import com.metamatrix.api.exception.MetaMatrixProcessingException;
+import com.metamatrix.common.buffer.BlockedException;
+import com.metamatrix.common.buffer.BlockedOnMemoryException;
+import com.metamatrix.common.buffer.BufferManager;
+import com.metamatrix.common.buffer.MemoryNotAvailableException;
+import com.metamatrix.common.buffer.TupleBatch;
+import com.metamatrix.common.buffer.TupleSourceID;
+import com.metamatrix.common.buffer.TupleSourceNotFoundException;
+import com.metamatrix.common.buffer.BufferManager.TupleSourceStatus;
+import com.metamatrix.common.comm.api.ResultsReceiver;
+import com.metamatrix.common.comm.exception.CommunicationException;
+import com.metamatrix.common.lob.LobChunk;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.common.xa.XATransactionException;
+import com.metamatrix.core.MetaMatrixCoreException;
+import com.metamatrix.core.log.MessageLevel;
+import com.metamatrix.core.util.Assertion;
+import com.metamatrix.dqp.DQPPlugin;
+import com.metamatrix.dqp.exception.SourceWarning;
+import com.metamatrix.dqp.message.AtomicRequestID;
+import com.metamatrix.dqp.message.AtomicRequestMessage;
+import com.metamatrix.dqp.message.ParameterInfo;
+import com.metamatrix.dqp.message.RequestID;
+import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.message.ResultsMessage;
+import com.metamatrix.dqp.service.TransactionService;
+import com.metamatrix.dqp.spi.TrackerLogConstants;
+import com.metamatrix.dqp.util.LogConstants;
+import com.metamatrix.query.analysis.AnalysisRecord;
+import com.metamatrix.query.analysis.QueryAnnotation;
+import com.metamatrix.query.execution.QueryExecPlugin;
+import com.metamatrix.query.processor.QueryProcessor;
+import com.metamatrix.query.processor.QueryProcessor.BatchHandler;
+import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.sql.lang.Option;
+import com.metamatrix.query.sql.lang.SPParameter;
+import com.metamatrix.query.sql.lang.StoredProcedure;
+import com.metamatrix.query.sql.symbol.SingleElementSymbol;
+
+public class RequestWorkItem extends AbstractWorkItem {
+
+ protected static class ResultsCursor {
+ int begin;
+ int end;
+ boolean resultsRequested;
+
+ /**
+ * Ask for results.
+ * @param beginRow
+ * @param endRow
+ * @param isPoll
+ */
+ synchronized void requestResults(int beginRow, int endRow, boolean isPoll) {
+ if (this.resultsRequested) {
+ if (!isPoll) {
+ throw new IllegalStateException("Results already requested"); //$NON-NLS-1$\
+ } else if (begin != beginRow || end != endRow) {
+ throw new IllegalStateException("Polling for different results than previously requested"); //$NON-NLS-1$
+ }
+ }
+ this.begin = beginRow;
+ this.end = endRow;
+ Assertion.assertTrue(end - begin >= 0);
+ this.resultsRequested = true;
+ }
+
+ synchronized void resultsSent() {
+ this.resultsRequested = false;
+ }
+ }
+
+ private enum ProcessingState {NEW, PROCESSING, CLOSE}
+ private ProcessingState state = ProcessingState.NEW;
+
+ private enum TransactionState {NONE, ACTIVE, END, DONE}
+ private TransactionState transactionState = TransactionState.NONE;
+
+ /*
+ * Obtained at construction time
+ */
+ protected final DQPCore dqpCore;
+ final RequestMessage requestMsg;
+ final RequestID requestID;
+ protected Request request; //provides the processing plan, held on a temporary basis
+ final private BufferManager bufferMgr;
+ final private int processorTimeslice;
+ protected ResultSetCache rsCache;
+ protected CacheID cid;
+ final private TransactionService transactionService;
+ final DQPWorkContext dqpWorkContext;
+ ResultsReceiver<ResultsMessage> resultsReceiver;
+
+ /*
+ * obtained during new
+ */
+ private volatile QueryProcessor processor;
+ protected Command originalCommand;
+ private AnalysisRecord analysisRecord;
+ private TransactionContext transactionContext;
+ private TupleSourceID resultsID;
+ private Collection schemas; // These are schemas associated with XML results
+
+ /*
+ * maintained during processing
+ */
+ private Throwable processingException;
+ private Map<AtomicRequestID, DataTierTupleSource> connectorInfo = new ConcurrentHashMap<AtomicRequestID, DataTierTupleSource>(4);
+ // This exception contains details of all the atomic requests that failed when query is run in partial results mode.
+ private List<MetaMatrixException> warnings = new LinkedList<MetaMatrixException>();
+
+ private boolean doneProducingBatches;
+ protected boolean isClosed;
+ private volatile boolean isCanceled;
+ private volatile boolean closeRequested;
+
+ /** Range of rows requested by the client */
+ protected ResultsCursor resultsCursor = new ResultsCursor();
+
+ private Map<Integer, LobWorkItem> lobStreams = Collections.synchronizedMap(new HashMap<Integer, LobWorkItem>(4));
+
+ public RequestWorkItem(DQPCore dqpCore, RequestMessage requestMsg, Request request, ResultsReceiver<ResultsMessage> receiver, RequestID requestID, DQPWorkContext workContext) {
+ this.requestMsg = requestMsg;
+ this.requestID = requestID;
+ this.resultsCursor.requestResults(1, requestMsg.getFetchSize(), false);
+ this.bufferMgr = dqpCore.getBufferManager();
+ this.processorTimeslice = dqpCore.getProcessorTimeSlice();
+ this.rsCache = dqpCore.getRsCache();
+ if (this.rsCache != null) {
+ this.cid = ResultSetCacheUtil.createCacheID(requestMsg, rsCache);
+ }
+ this.transactionService = dqpCore.getTransactionService();
+ this.dqpCore = dqpCore;
+ this.request = request;
+ this.resultsReceiver = receiver;
+ this.dqpWorkContext = workContext;
+ }
+
+ @Override
+ protected boolean isDoneProcessing() {
+ return isClosed;
+ }
+
+ @Override
+ protected void resumeProcessing() {
+ dqpCore.addWork(this);
+ }
+
+ @Override
+ protected void process() {
+ DQPWorkContext.setWorkContext(this.dqpWorkContext);
+
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_DQP, "############# PW PROCESSING on " + requestID + " with state "+ state +" ###########"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ try {
+ if (this.state == ProcessingState.NEW) {
+ state = ProcessingState.PROCESSING;
+ processNew();
+ if (isCanceled) {
+ this.processingException = new MetaMatrixProcessingException(QueryExecPlugin.Util.getString("QueryProcessor.request_cancelled", this.requestID)); //$NON-NLS-1$
+ state = ProcessingState.CLOSE;
+ }
+ }
+ if (this.state == ProcessingState.PROCESSING) {
+ processMore();
+ if (this.closeRequested) {
+ this.state = ProcessingState.CLOSE;
+ }
+ }
+ } catch (BlockedOnMemoryException e) {
+ moreWork(false);
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_DQP, "############# PW EXITING on " + requestID + " - reenqueueing for more processing due to lack of available memory ###########"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ } catch (BlockedException e) {
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_DQP, "############# PW EXITING on " + requestID + " - processor blocked ###########"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ } catch (Throwable e) {
+ //if there is a cache, remove temp results if there is any
+ if(this.rsCache != null){
+ rsCache.removeTempResults(cid);
+ }
+
+ if (isCanceled()) {
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_DQP, e, "############# PW EXITING on " + requestID + " - error occurred ###########"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ } else {
+ logCommandError();
+ //Case 5558: Differentiate between system level errors and
+ //processing errors. Only log system level errors as errors,
+ //log the processing errors as warnings only
+ if(e instanceof MetaMatrixProcessingException) {
+ LogManager.logWarning(LogConstants.CTX_DQP, e, "############# PW EXITING on " + requestID + " - error occurred ###########"); //$NON-NLS-1$ //$NON-NLS-2$
+ }else {
+ LogManager.logError(LogConstants.CTX_DQP, e, "############# PW EXITING on " + requestID + " - error occurred ###########"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ this.processingException = e;
+ this.state = ProcessingState.CLOSE;
+ } finally {
+ if (this.state == ProcessingState.CLOSE && !isClosed) {
+ attemptClose();
+ } else if (isClosed) {
+ /*
+ * since there may be a client waiting notify them of a problem
+ */
+ if (this.processingException == null) {
+ this.processingException = new IllegalStateException("Request is already closed"); //$NON-NLS-1$
+ }
+ sendError();
+ }
+ }
+ }
+
+ protected void processMore() throws SystemException, BlockedException, MetaMatrixCoreException {
+ if (!doneProducingBatches) {
+ sendResultsIfNeeded(null);
+ doneProducingBatches = processor.process(this.processorTimeslice);
+ }
+ if (doneProducingBatches) {
+ if (this.transactionState == TransactionState.ACTIVE) {
+ boolean end = true;
+ /*
+ * TEIID-14 if we are done producing batches, then proactively close transactional
+ * executions even ones that were intentionally kept alive. this may
+ * break the read of a lob from a transactional source under a transaction
+ * if the source does not support holding the clob open after commit
+ */
+ for (DataTierTupleSource connectorRequest : this.connectorInfo.values()) {
+ if (connectorRequest.isTransactional()) {
+ connectorRequest.fullyCloseSource();
+ end = false;
+ }
+ }
+ if (end) {
+ this.transactionState = TransactionState.END;
+ }
+ }
+ if (this.transactionState == TransactionState.END && transactionContext.getTransactionType() == TransactionContext.Scope.TRANSACTION_REQUEST) {
+ this.transactionService.getTransactionServer().commit(transactionContext);
+ this.transactionState = TransactionState.DONE;
+ }
+ sendResultsIfNeeded(null);
+ } else {
+ moreWork(false); // If the timeslice expired, then the processor can probably produce more batches.
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_DQP, "############# PW EXITING on " + requestID + " - reenqueueing for more processing ###########"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ }
+
+ /**
+ * Client close is currently implemented as asynch.
+ * Any errors that occur will not make it to the client, instead we just log them here.
+ */
+ protected void attemptClose() {
+ if (this.resultsID != null) {
+ try {
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_DQP, "Removing tuplesource for the request " + requestID); //$NON-NLS-1$
+ }
+ this.dqpCore.getBufferManager().removeTupleSource(resultsID);
+ } catch(TupleSourceNotFoundException e) {
+ // ignore
+ } catch (MetaMatrixComponentException e) {
+ LogManager.logDetail(LogConstants.CTX_DQP, e, e.getMessage());
+ }
+
+ try {
+ this.processor.closeProcessing();
+ } catch (TupleSourceNotFoundException e) {
+ // ignore
+ } catch (MetaMatrixComponentException e) {
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_DQP, e, e.getMessage());
+ }
+ }
+
+ for (DataTierTupleSource connectorRequest : this.connectorInfo.values()) {
+ try {
+ connectorRequest.fullyCloseSource();
+ } catch (MetaMatrixComponentException e) {
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_DQP, e, e.getMessage());
+ }
+ }
+ }
+
+ this.resultsID = null;
+ }
+
+ if (this.transactionState == TransactionState.ACTIVE) {
+ if (!this.connectorInfo.isEmpty()) {
+ return; //wait for pending connector work
+ }
+ this.transactionState = TransactionState.END;
+ }
+
+ if (this.transactionState == TransactionState.END && transactionContext.getTransactionType() == TransactionContext.Scope.TRANSACTION_REQUEST) {
+ this.transactionState = TransactionState.DONE;
+ try {
+ this.transactionService.getTransactionServer().rollback(transactionContext);
+ } catch (XATransactionException e1) {
+ LogManager.logWarning(LogConstants.CTX_DQP, e1, DQPPlugin.Util.getString("ProcessWorker.failed_rollback")); //$NON-NLS-1$
+ } catch (SystemException err) {
+ LogManager.logWarning(LogConstants.CTX_DQP, err, DQPPlugin.Util.getString("ProcessWorker.failed_rollback")); //$NON-NLS-1$
+ }
+ }
+
+ isClosed = true;
+
+ dqpCore.removeRequest(this);
+
+ if (this.processingException != null) {
+ sendError();
+ } else {
+ dqpCore.logMMCommand(requestMsg, false, false, this.processor.getHighestRow());
+ }
+ }
+
+ protected void processNew() throws MetaMatrixProcessingException, MetaMatrixComponentException {
+ request.processRequest();
+ originalCommand = request.command;
+ processor = request.processor;
+ processor.setBatchHandler(new BatchHandler() {
+ public void batchProduced(TupleBatch batch)
+ throws MetaMatrixCoreException {
+ //if there is a cache, and it is a query, save it
+ if(rsCache != null && requestMsg.useResultSetCache() && originalCommand.areResultsCachable() && transactionState == TransactionState.NONE && !rsCache.hasResults(cid)){
+ CacheResults cr = new CacheResults(batch.getAllTuples(), processor.getProcessorPlan().getOutputElements(), batch.getBeginRow(), !doneProducingBatches);
+ cr.setCommand(originalCommand);
+ cr.setSize(batch.getSize());
+ if(batch.getSize() != TupleBatch.UNKNOWN_SIZE){
+ cr.setSize(batch.getSize());
+ }
+ cr.setAnalysisRecord(analysisRecord);
+ if (!rsCache.setResults(cid, cr, requestID)) {
+ rsCache = null; //disable caching if we are over size
+ }
+ }
+ sendResultsIfNeeded(batch);
+ }
+ });
+ resultsID = request.context.getTupleSourceID();
+ analysisRecord = request.analysisRecord;
+ schemas = request.schemas;
+ transactionContext = request.transactionContext;
+ if (this.transactionContext != null && this.transactionContext.isInTransaction()) {
+ this.transactionState = TransactionState.ACTIVE;
+ }
+ Option option = originalCommand.getOption();
+ if (option != null && option.getPlanOnly()) {
+ doneProducingBatches = true;
+ this.bufferMgr.setStatus(resultsID, TupleSourceStatus.FULL);
+ }
+
+ if (analysisRecord.recordQueryPlan()) {
+ analysisRecord.setQueryPlan(processor.getProcessorPlan().getDescriptionProperties());
+ }
+
+ request = null;
+ }
+
+ /**
+ * Send results if they have been requested. This should only be called from the processing thread.
+ */
+ protected void sendResultsIfNeeded(TupleBatch batch) throws BlockedOnMemoryException,
+ MetaMatrixComponentException, TupleSourceNotFoundException, CommunicationException {
+
+ synchronized (resultsCursor) {
+ if (!this.resultsCursor.resultsRequested
+ || (this.resultsCursor.begin > this.processor.getHighestRow() && !doneProducingBatches)
+ || (this.transactionState == TransactionState.ACTIVE)) {
+ return;
+ }
+ }
+
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_DQP, "[RequestWorkItem.sendResultsIfNeeded] requestID: " + requestID + " resultsID: " + this.resultsID + " done: " + doneProducingBatches ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ boolean pinned = false;
+
+ try {
+ if (batch == null || batch.getBeginRow() > this.resultsCursor.begin) {
+ batch = this.bufferMgr.pinTupleBatch(resultsID, resultsCursor.begin, resultsCursor.end);
+ pinned = true;
+ }
+ int finalRowCount = doneProducingBatches?this.processor.getHighestRow():-1;
+
+ ResultsMessage response = createResultsMessage(requestMsg, batch.getAllTuples(), this.processor.getProcessorPlan().getOutputElements(), analysisRecord);
+ response.setFirstRow(batch.getBeginRow());
+ response.setLastRow(batch.getEndRow());
+
+ // set final row
+ response.setFinalRow(finalRowCount);
+ // Results are partial if the rowcount is not yet known,
+ // or if the last row of this batch is less than the row count
+ boolean isPartialResultSet = finalRowCount < 0
+ || batch.getEndRow() < finalRowCount;
+
+ // set parital result
+ response.setPartialResults(isPartialResultSet);
+
+ // send any schemas associated with the results
+ response.setSchemas(this.schemas);
+
+ // send any warnings with the response object
+ List<Exception> responseWarnings = new ArrayList<Exception>();
+ List<Exception> currentWarnings = processor.getAndClearWarnings();
+ if (currentWarnings != null) {
+ responseWarnings.addAll(currentWarnings);
+ }
+ synchronized (warnings) {
+ responseWarnings.addAll(this.warnings);
+ this.warnings.clear();
+ }
+ response.setWarnings(responseWarnings);
+
+ // If it is stored procedure, set parameters
+ if (originalCommand instanceof StoredProcedure) {
+ StoredProcedure proc = (StoredProcedure)originalCommand;
+ if (proc.returnParameters()) {
+ response.setParameters(getParameterInfo(proc));
+ }
+ }
+
+ /*
+ * mark the results sent at this point.
+ * communication exceptions will be treated as non-recoverable
+ */
+ this.resultsCursor.resultsSent();
+ this.resultsReceiver.receiveResults(response);
+ } catch (MemoryNotAvailableException e) {
+ throw BlockedOnMemoryException.INSTANCE;
+ } finally {
+ try {
+ if (pinned) {
+ this.bufferMgr.unpinTupleBatch(this.resultsID, batch.getBeginRow(), batch.getEndRow());
+ }
+ } catch (Exception e) {
+ // ignore - nothing more we can do
+ }
+ }
+ }
+
+ public static ResultsMessage createResultsMessage(RequestMessage message, List[] batch, List columnSymbols, AnalysisRecord analysisRecord) {
+ String[] columnNames = new String[columnSymbols.size()];
+ String[] dataTypes = new String[columnSymbols.size()];
+
+ for(int i=0; i<columnSymbols.size(); i++) {
+ SingleElementSymbol symbol = (SingleElementSymbol) columnSymbols.get(i);
+ columnNames[i] = SingleElementSymbol.getShortName(symbol.getOutputName());
+ dataTypes[i] = DataTypeManager.getDataTypeName(symbol.getType());
+ }
+
+ ResultsMessage result = new ResultsMessage(message, batch, columnNames, dataTypes);
+ setAnalysisRecords(result, analysisRecord);
+ return result;
+ }
+
+ private static void setAnalysisRecords(ResultsMessage response, AnalysisRecord analysisRecord) {
+ if(analysisRecord != null) {
+ response.setPlanDescription(analysisRecord.getQueryPlan());
+ response.setDebugLog(analysisRecord.getDebugLog());
+
+ // Convert annotations to JDBC expected format - String[4]
+ Collection anns = analysisRecord.getAnnotations();
+ Collection converted = null;
+ if(anns != null) {
+ converted = new ArrayList(anns.size());
+ Iterator annIter = anns.iterator();
+ while(annIter.hasNext()) {
+ QueryAnnotation ann = (QueryAnnotation) annIter.next();
+ String[] jdbcAnn = new String[4];
+ jdbcAnn[0] = ann.getCategory();
+ jdbcAnn[1] = ann.getAnnotation();
+ jdbcAnn[2] = ann.getResolution();
+ jdbcAnn[3] = "" + ann.getPriority(); //$NON-NLS-1$
+ converted.add(jdbcAnn);
+ }
+ response.setAnnotations(converted);
+ }
+ }
+ }
+
+ private void sendError() {
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_DQP, processingException, DQPPlugin.Util.getString("ProcessWorker.send_error", requestID)); //$NON-NLS-1$
+ }
+
+ ResultsMessage response = new ResultsMessage(requestMsg);
+ response.setException(processingException);
+ setAnalysisRecords(response, analysisRecord);
+ resultsReceiver.receiveResults(response);
+ }
+
+ private static List getParameterInfo(StoredProcedure procedure) {
+ List params = procedure.getParameters();
+ List paramInfos = new ArrayList(params.size());
+
+ Iterator iter = params.iterator();
+ while(iter.hasNext()) {
+ SPParameter param = (SPParameter) iter.next();
+ ParameterInfo info = new ParameterInfo(param.getParameterType(), param.getResultSetColumns().size());
+ paramInfos.add(info);
+ }
+
+ return paramInfos;
+ }
+
+ public void processLobChunkRequest(String id, int streamRequestId, ResultsReceiver<LobChunk> chunckReceiver) {
+ LobWorkItem workItem = null;
+ synchronized (lobStreams) {
+ workItem = this.lobStreams.get(new Integer(streamRequestId));
+ if (workItem == null) {
+ workItem = new LobWorkItem(this, dqpCore, id, streamRequestId);
+ lobStreams.put(new Integer(streamRequestId), workItem);
+ }
+ }
+ workItem.setResultsReceiver(chunckReceiver);
+ dqpCore.addWork(workItem);
+ }
+
+ public void removeLobStream(int streamRequestId) {
+ this.lobStreams.remove(new Integer(streamRequestId));
+ }
+
+ public boolean requestCancel() throws MetaMatrixComponentException {
+ synchronized (this) {
+ if (this.isCanceled) {
+ return false;
+ }
+ this.isCanceled = true;
+ }
+ if (this.processor != null) {
+ this.processor.requestCanceled();
+ }
+
+ // Cancel Connector atomic requests
+ try {
+ for (DataTierTupleSource connectorRequest : this.connectorInfo.values()) {
+ connectorRequest.cancelRequest();
+ }
+ } finally {
+ try {
+ if (transactionService != null) {
+ try {
+ transactionService.getTransactionServer().cancelTransactions(requestID.getConnectionID(), true);
+ } catch (InvalidTransactionException err) {
+ LogManager.logWarning(LogConstants.CTX_DQP, "rollback failed for requestID=" + requestID.getConnectionID()); //$NON-NLS-1$
+ } catch (SystemException err) {
+ throw new MetaMatrixComponentException(err);
+ }
+ }
+ } finally {
+ this.moreWork();
+ }
+ }
+ return true;
+ }
+
+ public boolean requestAtomicRequestCancel(int accessNodeID) throws MetaMatrixComponentException {
+ // in the case that this does not support partial results; cancel
+ // the original processor request.
+ if(!requestMsg.supportsPartialResults()) {
+ return requestCancel();
+ }
+ // Walk through all connector infos and attempt to cancel each one
+ for (DataTierTupleSource connectorRequest : this.connectorInfo.values()) {
+ AtomicRequestMessage aqr = connectorRequest.getAtomicRequestMessage();
+ if (aqr.getAtomicRequestID().getNodeID() == accessNodeID) {
+ connectorRequest.cancelRequest();
+ return true;
+ }
+ }
+
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_DQP, "Connector request not queued yet. RequestID=" + requestID+ " Node id="+ accessNodeID); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return false;
+ }
+
+ public synchronized void requestClose() {
+ if (this.state == ProcessingState.CLOSE || this.closeRequested) {
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_DQP, "Request already closing" + requestID); //$NON-NLS-1$
+ }
+ return;
+ }
+ this.closeRequested = true;
+ if (this.processor != null) {
+ this.processor.requestClosed();
+ }
+ this.moreWork();
+ }
+
+ public void requestMore(int batchFirst, int batchLast, ResultsReceiver<ResultsMessage> receiver) {
+ this.resultsReceiver = receiver;
+ this.resultsCursor.requestResults(batchFirst, batchLast, false);
+ this.moreWork();
+ }
+
+ public void closeAtomicRequest(AtomicRequestID atomicRequestId) {
+ connectorInfo.remove(atomicRequestId);
+ LogManager.logTrace(LogConstants.CTX_DQP, new Object[] {"closed atomic-request:", atomicRequestId}); //$NON-NLS-1$
+ }
+
+ public void addConnectorRequest(AtomicRequestID atomicRequestId, DataTierTupleSource connInfo) {
+ connectorInfo.put(atomicRequestId, connInfo);
+ }
+
+ /**
+ * <p>This method add information to the warning on the work item for the given
+ * <code>RequestID</code>. This method is called from <code>DataTierManager</code></p>
+ */
+ public void addSourceFailureDetails(SourceWarning details) {
+ synchronized (warnings) {
+ this.warnings.add(details);
+ }
+ }
+
+ /**
+ * Log the command to the MM cmd log.
+ */
+ private void logCommandError() {
+ if ( dqpCore.getTracker() == null || !dqpCore.getTracker().willRecordMMCmd()) {
+ return;
+ }
+ String transactionID = null;
+ if (this.transactionContext != null && this.transactionContext.isInTransaction()) {
+ transactionID = this.transactionContext.getTxnID();
+ }
+ dqpCore.getTracker().log(requestID.toString(),
+ transactionID == null ? null : transactionID,
+ TrackerLogConstants.CMD_POINT.END,
+ TrackerLogConstants.CMD_STATUS.ERROR,
+ requestID.getConnectionID(),
+ dqpWorkContext.getAppName(),
+ dqpWorkContext.getUserName(),
+ dqpWorkContext.getVdbName(),
+ dqpWorkContext.getVdbVersion(),
+ (originalCommand != null ? originalCommand.toString() : null ),
+ -1);
+ }
+
+ boolean isCanceled() {
+ return isCanceled;
+ }
+
+ Command getOriginalCommand() throws MetaMatrixProcessingException {
+ if (this.originalCommand == null) {
+ if (this.processingException != null) {
+ throw new MetaMatrixProcessingException(this.processingException);
+ }
+ throw new IllegalStateException("Original command is not available"); //$NON-NLS-1$
+ }
+ return this.originalCommand;
+ }
+
+ void setOriginalCommand(Command originalCommand) {
+ this.originalCommand = originalCommand;
+ }
+
+ TransactionContext getTransactionContext() {
+ return transactionContext;
+ }
+
+ Collection<DataTierTupleSource> getConnectorRequests() {
+ return new LinkedList<DataTierTupleSource>(this.connectorInfo.values());
+ }
+
+ DataTierTupleSource getConnectorRequest(AtomicRequestID id) {
+ return this.connectorInfo.get(id);
+ }
+
+ public List<MetaMatrixException> getWarnings() {
+ return warnings;
+ }
+
+ @Override
+ public String toString() {
+ return this.requestID.toString();
+ }
+
+ public DQPWorkContext getDqpWorkContext() {
+ return dqpWorkContext;
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/TempTableStoresHolder.java (from rev 569, trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/TempTableStoresHolder.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/TempTableStoresHolder.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/TempTableStoresHolder.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,52 @@
+/*
+ * 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.common.buffer.BufferManager;
+import com.metamatrix.query.tempdata.TempTableStore;
+import com.metamatrix.query.tempdata.TempTableStoreImpl;
+
+
+/**
+ * @since 5.5
+ */
+public class TempTableStoresHolder {
+ private BufferManager buffer;
+ private Map tempTableStores = new HashMap();
+
+ public TempTableStoresHolder(BufferManager buffer) {
+ this.buffer = buffer;
+ }
+
+ public synchronized TempTableStore getTempTableStore(String sessionID) {
+ TempTableStore tempTableStore = (TempTableStore)tempTableStores.get(sessionID);
+ if(tempTableStore == null) {
+ tempTableStore = new TempTableStoreImpl(buffer, sessionID, null);
+ tempTableStores.put(sessionID, tempTableStore);
+ }
+ return tempTableStore;
+ }
+}
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/process/TempTableStoresHolder.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/capabilities (from rev 569, trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/capabilities)
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/process/capabilities
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/capabilities/ConnectorCapabilitiesFinder.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/capabilities/ConnectorCapabilitiesFinder.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/capabilities/ConnectorCapabilitiesFinder.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,13 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.process.capabilities;
+package org.teiid.dqp.internal.process.capabilities;
import java.util.List;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.dqp.internal.datamgr.ConnectorID;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.dqp.service.DataService;
import com.metamatrix.dqp.service.VDBService;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/capabilities/SharedCachedFinder.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/capabilities/SharedCachedFinder.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/capabilities/SharedCachedFinder.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.process.capabilities;
+package org.teiid.dqp.internal.process.capabilities;
import java.util.HashMap;
import java.util.Map;
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource (from rev 569, trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/multisource)
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceCapabilitiesFinder.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/multisource/MultiSourceCapabilitiesFinder.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceCapabilitiesFinder.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.process.multisource;
+package org.teiid.dqp.internal.process.multisource;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceElement.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/multisource/MultiSourceElement.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceElement.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.process.multisource;
+package org.teiid.dqp.internal.process.multisource;
public class MultiSourceElement {
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceElementReplacementVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/multisource/MultiSourceElementReplacementVisitor.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceElementReplacementVisitor.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.process.multisource;
+package org.teiid.dqp.internal.process.multisource;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.query.sql.symbol.Constant;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceMetadataWrapper.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/multisource/MultiSourceMetadataWrapper.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceMetadataWrapper.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.process.multisource;
+package org.teiid.dqp.internal.process.multisource;
import java.util.ArrayList;
import java.util.Collection;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.process.multisource;
+package org.teiid.dqp.internal.process.multisource;
import java.util.ArrayList;
import java.util.Iterator;
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator (from rev 569, trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/validator)
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/validator/AuthorizationValidationVisitor.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.process.validator;
+package org.teiid.dqp.internal.process.validator;
import java.util.ArrayList;
import java.util.Collection;
@@ -32,11 +32,12 @@
import java.util.Map;
import java.util.Set;
+import org.teiid.dqp.internal.process.multisource.MultiSourceElement;
+
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.internal.process.multisource.MultiSourceElement;
import com.metamatrix.dqp.service.AuthorizationService;
import com.metamatrix.query.function.FunctionLibrary;
import com.metamatrix.query.metadata.TempMetadataID;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/ModelVisibilityValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/process/validator/ModelVisibilityValidationVisitor.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/ModelVisibilityValidationVisitor.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.process.validator;
+package org.teiid.dqp.internal.process.validator;
import java.util.Collection;
import java.util.Iterator;
Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/transaction (from rev 569, trunk/engine/src/main/java/com/metamatrix/dqp/internal/transaction)
Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/transaction
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionContextImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/transaction/TransactionContextImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionContextImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.transaction;
+package org.teiid.dqp.internal.transaction;
import java.io.Externalizable;
import java.io.IOException;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionProvider.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/transaction/TransactionProvider.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionProvider.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.transaction;
+package org.teiid.dqp.internal.transaction;
import java.sql.SQLException;
import java.util.Properties;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/transaction/TransactionServerImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.transaction;
+package org.teiid.dqp.internal.transaction;
import java.util.HashMap;
import java.util.Iterator;
@@ -40,12 +40,12 @@
import javax.transaction.xa.Xid;
import org.teiid.connector.xa.api.TransactionContext;
+import org.teiid.dqp.internal.transaction.TransactionProvider.XAConnectionSource;
import com.metamatrix.common.xa.MMXid;
import com.metamatrix.common.xa.XATransactionException;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.internal.transaction.TransactionProvider.XAConnectionSource;
import com.metamatrix.dqp.transaction.TransactionServer;
import com.metamatrix.dqp.transaction.XAServer;
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/config/TestDQPLauncher.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/config/TestDQPLauncher.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/config/TestDQPLauncher.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -29,11 +29,11 @@
import junit.framework.TestCase;
import org.mockito.Mockito;
+import org.teiid.dqp.internal.process.DQPCore;
import com.metamatrix.common.application.ApplicationService;
import com.metamatrix.common.application.DQPConfigSource;
import com.metamatrix.core.log.LogListener;
-import com.metamatrix.dqp.internal.process.DQPCore;
import com.metamatrix.dqp.service.AutoGenDataService;
import com.metamatrix.dqp.service.DQPServiceNames;
import com.metamatrix.dqp.service.FakeAbstractService;
Deleted: trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/MockSingleMetadataService.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/MockSingleMetadataService.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/MockSingleMetadataService.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,62 +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 com.metamatrix.dqp.internal.process;
-
-import java.util.Properties;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-import com.metamatrix.dqp.service.MetadataService;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-
-/**
- */
-public class MockSingleMetadataService implements MetadataService {
-
- private QueryMetadataInterface metadata;
-
- public MockSingleMetadataService(QueryMetadataInterface metadata) {
- this.metadata = metadata;
- }
-
- public QueryMetadataInterface lookupMetadata(String vdbName, String vdbVersion)
- throws MetaMatrixComponentException {
-
- return this.metadata;
- }
-
- public void initialize(Properties props) throws ApplicationInitializationException {
-
- }
-
- public void start(ApplicationEnvironment environment) throws ApplicationLifecycleException {
-
- }
-
- public void stop() throws ApplicationLifecycleException {
-
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestCallableStatement.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestCallableStatement.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestCallableStatement.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,110 +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 com.metamatrix.dqp.internal.process;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.query.processor.HardcodedDataManager;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-public class TestCallableStatement extends TestCase {
-
- public void testMissingInput() throws Exception {
- String sql = "{? = call pm4.spTest9()}"; //$NON-NLS-1$
-
- try {
- TestPreparedStatement.helpTestProcessing(sql, Collections.EMPTY_LIST, null, FakeMetadataFactory.exampleBQTCached(), true);
- fail();
- } catch (QueryResolverException e) {
- assertEquals("Required parameter 'PM4.SPTEST9.INKEY' has no value was set or is an invalid parameter.", e.getMessage()); //$NON-NLS-1$
- }
- }
-
- public void testReturnParameter() throws Exception {
- String sql = "{? = call pm4.spTest9(?)}"; //$NON-NLS-1$
-
- List values = new ArrayList();
- values.add(1);
-
- List[] expected = new List[1];
- expected[0] = Arrays.asList(1);
-
- HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.addData("EXEC pm4.spTest9(1)", expected);
-
- TestPreparedStatement.helpTestProcessing(sql, values, expected, dataManager, FakeMetadataFactory.exampleBQTCached(), true);
- }
-
- /**
- * same result as above, but the return parameter is not specified
- * TODO: it would be best if the return parameter were not actually returned here, since it wasn't specified in the initial sql
- */
- public void testNoReturnParameter() throws Exception {
- String sql = "{call pm4.spTest9(?)}"; //$NON-NLS-1$
-
- List values = new ArrayList();
- values.add(1);
-
- List[] expected = new List[1];
- expected[0] = Arrays.asList(1);
-
- HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.addData("EXEC pm4.spTest9(1)", expected);
-
- TestPreparedStatement.helpTestProcessing(sql, values, expected, dataManager, FakeMetadataFactory.exampleBQTCached(), true);
- }
-
- public void testOutParameter() throws Exception {
- String sql = "{call pm2.spTest8(?, ?)}"; //$NON-NLS-1$
-
- List values = new ArrayList();
- values.add(2);
-
- List[] expected = new List[1];
- expected[0] = Arrays.asList(null, null, 1);
-
- HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.addData("EXEC pm2.spTest8(2)", expected);
-
- TestPreparedStatement.helpTestProcessing(sql, values, expected, dataManager, FakeMetadataFactory.exampleBQTCached(), true);
- }
-
- public void testInputExpression() throws Exception {
- String sql = "{call pm2.spTest8(1, ?)}"; //$NON-NLS-1$
-
- List[] expected = new List[1];
- expected[0] = Arrays.asList(null, null, 0);
-
- HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.addData("EXEC pm2.spTest8(1)", expected);
-
- TestPreparedStatement.helpTestProcessing(sql, null, expected, dataManager, FakeMetadataFactory.exampleBQTCached(), true);
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestCodeTableCache.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestCodeTableCache.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestCodeTableCache.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,208 +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 com.metamatrix.dqp.internal.process;
-
-import java.util.Arrays;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.dqp.internal.process.CodeTableCache.CacheState;
-import com.metamatrix.query.util.CommandContext;
-
-/**
- */
-public class TestCodeTableCache extends TestCase {
-
- private static CommandContext TEST_CONTEXT = new CommandContext("pid", "1", null, 5, null, null, "test", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- private static CommandContext TEST_CONTEXT_1 = new CommandContext("pid", "1", null, 5, null, null, "test", "2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-
- public TestCodeTableCache(String name) {
- super(name);
- }
-
- private static List[] exampleResultObject() {
- List record1 = Arrays.asList("US", "USA"); //$NON-NLS-1$ //$NON-NLS-2$
- List record2 = Arrays.asList("Germany", "GM"); //$NON-NLS-1$ //$NON-NLS-2$
-
- List[] records = new List[] {
- record1, record2
- };
-
- return records;
- }
-
- private CodeTableCache setUpSampleCodeTable(boolean setDone) {
- CodeTableCache ctc = new CodeTableCache(10);
-
- // must set the requestToCacheKeyMap first
- int nodeId = ctc.createCacheRequest("countrycode", "code", "country", TEST_CONTEXT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- List[] results = exampleResultObject();
-
- // table/countrycode (keyElem/country, returnElem/code);
- // r1--> 'US', 'USA'
- // r2--> 'Germany', 'GM'
-
- try {
- ctc.loadTable(nodeId, results);
- } catch (MetaMatrixProcessingException e) {
- throw new RuntimeException(e);
- }
- if(setDone) {
- ctc.markCacheLoaded(nodeId);
- }
- return ctc;
- }
-
- // Max = 1 and 1 table is set up
- private CodeTableCache setUpSampleCodeTable2() {
- CodeTableCache ctc = new CodeTableCache(1);
-
- // must set the requestToCacheKeyMap first
- int nodeId = ctc.createCacheRequest("countrycode", "code", "country", TEST_CONTEXT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- List[] results = exampleResultObject();
-
- // table/countrycode (keyElem/country, returnElem/code);
- // r1--> 'US', 'USA'
- // r2--> 'Germany', 'GM'
-
- try {
- ctc.loadTable(nodeId, results);
- } catch (MetaMatrixProcessingException e) {
- throw new RuntimeException(e);
- }
- ctc.markCacheLoaded(nodeId);
- return ctc;
- }
-
- public void testLookupValue() throws Exception {
- CodeTableCache ctc = setUpSampleCodeTable(false);
- String code = (String) ctc.lookupValue("countrycode", "code", "country", "Germany", TEST_CONTEXT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertEquals("Actual lookup value doesn't match with expected: ", code, "GM"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /** state = 0; exists*/
- public void testCacheExists1() {
- // load code table
- CodeTableCache ctc = setUpSampleCodeTable(true);
-
- CacheState actualState = ctc.cacheExists("countrycode", "code", "country", TEST_CONTEXT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- assertEquals("Actual cache state doesn't match with expected: ", CacheState.CACHE_EXISTS, actualState); //$NON-NLS-1$
- }
-
- /** state = 1; loading state */
- public void testCacheExists2() {
- CodeTableCache ctc = new CodeTableCache(10);
-
- ctc.cacheExists("countrycode", "code", "country", TEST_CONTEXT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- CacheState actualState = ctc.cacheExists("countrycode", "code", "country", TEST_CONTEXT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- assertEquals("Actual cache state doesn't match with expected: ", CacheState.CACHE_LOADING, actualState); //$NON-NLS-1$
- }
-
- /** state = 2; not exist */
- public void testCacheExists3() {
- CodeTableCache ctc = setUpSampleCodeTable(true);
-
- CacheState actualState = ctc.cacheExists("countrycode1", "code1", "country1", TEST_CONTEXT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- assertEquals("Actual cache state doesn't match with expected: ", CacheState.CACHE_NOT_EXIST, actualState); //$NON-NLS-1$
- }
-
- /** state = 2; not exist */
- public void testCacheExists3a() {
- CodeTableCache ctc = setUpSampleCodeTable(false);
-
- CacheState actualState = ctc.cacheExists("countrycode", "code", "country", TEST_CONTEXT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- assertEquals("Actual cache state doesn't match with expected: ", CacheState.CACHE_NOT_EXIST, actualState); //$NON-NLS-1$
- }
-
- /** state = 4; overload */
- public void testCacheOverload1() {
- CodeTableCache ctc = setUpSampleCodeTable2();
-
- CacheState actualState = ctc.cacheExists("countrycode", "something", "country", TEST_CONTEXT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- assertEquals("Actual cache state doesn't match with expected: ", CacheState.CACHE_OVERLOAD, actualState); //$NON-NLS-1$
- }
-
- /** test load, then clearAll, then cacheExists */
- public void testClearAllLoaded() {
- // load code table
- CodeTableCache ctc = setUpSampleCodeTable(true);
-
- // clear all code tables
- ctc.clearAll();
-
- // check state
- CacheState actualState = ctc.cacheExists("countrycode", "code", "country", TEST_CONTEXT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- assertEquals("Actual cache state doesn't match with expected: ", CacheState.CACHE_NOT_EXIST, actualState); //$NON-NLS-1$
- }
-
- /** load table, cacheExists, clearAll, then lookupValue - this should throw an exception */
- public void testClearAllLoading() {
- // load code table
- CodeTableCache ctc = setUpSampleCodeTable(true);
-
- // check state
- CacheState actualState = ctc.cacheExists("countrycode", "code", "country", TEST_CONTEXT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- assertEquals("Actual cache state doesn't match with expected: ", CacheState.CACHE_EXISTS, actualState); //$NON-NLS-1$
-
- // clear all code tables before it can be read
- ctc.clearAll();
-
- // lookup a value - this should throw an exception
- try {
- ctc.lookupValue("countrycode", "code", "country", "US", TEST_CONTEXT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- fail("Expected exception during lookup"); //$NON-NLS-1$
- } catch(MetaMatrixComponentException e) {
- // expected this
- }
- }
-
- public void testVdbSpecificCaching() {
- // load code table
- CodeTableCache ctc = setUpSampleCodeTable(true);
-
- CacheState actualState = ctc.cacheExists("countrycode", "code", "country", TEST_CONTEXT_1); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- assertEquals("Actual cache state doesn't match with expected: ", CacheState.CACHE_NOT_EXIST, actualState); //$NON-NLS-1$
- }
-
- public void testDuplicateKeyException() {
- CodeTableCache ctc = new CodeTableCache(1);
-
- // must set the requestToCacheKeyMap first
- int nodeId = ctc.createCacheRequest("table", "key", "value", TEST_CONTEXT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- List[] results = new List[] {
- Arrays.asList(1, 2),
- Arrays.asList(1, 3),
- };
-
- try {
- ctc.loadTable(nodeId, results);
- fail("expected exception"); //$NON-NLS-1$
- } catch (MetaMatrixProcessingException e) {
- assertEquals("Duplicate code table 'table' key 'value' value '1'", e.getMessage()); //$NON-NLS-1$
- }
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestDQPCore.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestDQPCore.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestDQPCore.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,267 +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 com.metamatrix.dqp.internal.process;
-
-import java.sql.ResultSet;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.vdb.api.ModelInfo;
-import com.metamatrix.dqp.internal.datamgr.impl.FakeTransactionService;
-import com.metamatrix.dqp.internal.process.DQPCore.ConnectorCapabilitiesCache;
-import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.dqp.message.ResultsMessage;
-import com.metamatrix.dqp.service.AutoGenDataService;
-import com.metamatrix.dqp.service.DQPServiceNames;
-import com.metamatrix.dqp.service.FakeBufferService;
-import com.metamatrix.dqp.service.FakeMetadataService;
-import com.metamatrix.dqp.service.FakeVDBService;
-import com.metamatrix.jdbc.api.ExecutionProperties;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-
-public class TestDQPCore extends TestCase {
-
- public TestDQPCore(String name) {
- super(name);
- }
-
- private DQPCore core;
-
- @Override
- protected void setUp() throws Exception {
- DQPWorkContext workContext = new DQPWorkContext();
- workContext.setVdbName("bqt"); //$NON-NLS-1$
- workContext.setVdbVersion("1"); //$NON-NLS-1$
- workContext.setSessionId(new MetaMatrixSessionID(1));
- DQPWorkContext.setWorkContext(workContext);
-
- String vdbName = "bqt"; //$NON-NLS-1$
- String vdbVersion = "1"; //$NON-NLS-1$
-
- ApplicationEnvironment env = new ApplicationEnvironment();
- env.bindService(DQPServiceNames.BUFFER_SERVICE, new FakeBufferService());
- FakeMetadataService mdSvc = new FakeMetadataService();
- mdSvc.addVdb(vdbName, vdbVersion, FakeMetadataFactory.exampleBQTCached());
- env.bindService(DQPServiceNames.METADATA_SERVICE, mdSvc);
- env.bindService(DQPServiceNames.DATA_SERVICE, new AutoGenDataService());
- env.bindService(DQPServiceNames.TRANSACTION_SERVICE, new FakeTransactionService());
- FakeVDBService vdbService = new FakeVDBService();
- vdbService.addBinding(vdbName, vdbVersion, "BQT1", "mmuuid:blah", "BQT"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- vdbService.addBinding(vdbName, vdbVersion, "BQT2", "mmuuid:blah", "BQT"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- vdbService.addBinding(vdbName, vdbVersion, "BQT3", "mmuuid:blah", "BQT"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- vdbService.addModel(vdbName, vdbVersion, "BQT3", ModelInfo.PRIVATE, false); //$NON-NLS-1$
- env.bindService(DQPServiceNames.VDB_SERVICE, vdbService);
-
- core = new DQPCore(env);
- core.start(new Properties());
- }
-
- @Override
- protected void tearDown() throws Exception {
- DQPWorkContext.setWorkContext(new DQPWorkContext());
- core.stop();
- }
-
- public RequestMessage exampleRequestMessage(String sql) {
- RequestMessage msg = new RequestMessage(sql);
- msg.setCallableStatement(false);
- msg.setCursorType(ResultSet.TYPE_SCROLL_INSENSITIVE);
- msg.setFetchSize(10);
- msg.setPartialResults(false);
- msg.setExecutionId(100);
- return msg;
- }
-
- public void testRequest1() throws Exception {
- helpExecute("SELECT IntKey FROM BQT1.SmallA", "a"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testUser1() throws Exception {
- String sql = "SELECT IntKey FROM BQT1.SmallA WHERE user() = 'logon'"; //$NON-NLS-1$
- String userName = "logon"; //$NON-NLS-1$
- helpExecute(sql, userName);
- }
-
- public void testUser2() throws Exception {
- String sql = "SELECT IntKey FROM BQT1.SmallA WHERE user() LIKE 'logon'"; //$NON-NLS-1$
- String userName = "logon"; //$NON-NLS-1$
- helpExecute(sql, userName);
- }
-
- public void testUser3() throws Exception {
- String sql = "SELECT IntKey FROM BQT1.SmallA WHERE user() IN ('logon3') AND StringKey LIKE '1'"; //$NON-NLS-1$
- String userName = "logon3"; //$NON-NLS-1$
- helpExecute(sql, userName);
- }
-
- public void testUser4() throws Exception {
- String sql = "SELECT IntKey FROM BQT1.SmallA WHERE 'logon4' = user() AND StringKey = '1'"; //$NON-NLS-1$
- String userName = "logon4"; //$NON-NLS-1$
- helpExecute(sql, userName);
- }
-
- public void testUser5() throws Exception {
- String sql = "SELECT IntKey FROM BQT1.SmallA WHERE user() IS NULL "; //$NON-NLS-1$
- String userName = "logon"; //$NON-NLS-1$
- helpExecute(sql, userName);
- }
-
- public void testUser6() throws Exception {
- String sql = "SELECT IntKey FROM BQT1.SmallA WHERE user() = 'logon33' "; //$NON-NLS-1$
- String userName = "logon"; //$NON-NLS-1$
- helpExecute(sql, userName);
- }
-
- public void testUser7() throws Exception {
- String sql = "UPDATE BQT1.SmallA SET IntKey = 2 WHERE user() = 'logon' AND StringKey = '1' "; //$NON-NLS-1$
- String userName = "logon"; //$NON-NLS-1$
- helpExecute(sql, userName);
- }
-
- public void testUser8() throws Exception {
- String sql = "SELECT user(), StringKey FROM BQT1.SmallA WHERE IntKey = 1 "; //$NON-NLS-1$
- String userName = "logon"; //$NON-NLS-1$
- helpExecute(sql, userName);
- }
-
- public void testUser9() throws Exception {
- String sql = "SELECT IntKey FROM BQT1.SmallA WHERE user() = StringKey AND StringKey = '1' "; //$NON-NLS-1$
- String userName = "1"; //$NON-NLS-1$
- helpExecute(sql, userName);
- }
-
- public void testEnvSessionId() throws Exception {
- String sql = "SELECT env('sessionid') as SessionID"; //$NON-NLS-1$
- String userName = "1"; //$NON-NLS-1$
- ResultsMessage rm = helpExecute(sql, userName);
- assertEquals("00000000-0000-0001-0000-000000000001", rm.getResults()[0].get(0));
- }
-
- public void testEnvSessionIdMixedCase() throws Exception {
- String sql = "SELECT env('sEsSIonId') as SessionID"; //$NON-NLS-1$
- String userName = "1"; //$NON-NLS-1$
- ResultsMessage rm = helpExecute(sql, userName);
- assertEquals("00000000-0000-0001-0000-000000000001", rm.getResults()[0].get(0));
- }
-
- public void testTxnAutoWrap() throws Exception {
- String sql = "SELECT * FROM BQT1.SmallA"; //$NON-NLS-1$
- helpExecute(sql, "a", 1, true); //$NON-NLS-1$
- }
-
- public void testPlanOnly() throws Exception {
- String sql = "SELECT * FROM BQT1.SmallA option planonly"; //$NON-NLS-1$
- helpExecute(sql,"a"); //$NON-NLS-1$
- }
-
- /**
- * Tests whether an exception result is sent when an exception occurs
- * @since 4.3
- */
- public void testPlanningException() throws Exception {
- String sql = "SELECT IntKey FROM BQT1.BadIdea "; //$NON-NLS-1$
-
- RequestMessage reqMsg = exampleRequestMessage(sql);
-
- Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
- try {
- message.get(5000, TimeUnit.MILLISECONDS);
- } catch (ExecutionException e) {
- assertTrue(e.getCause() instanceof QueryResolverException);
- }
- }
-
- 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$
- }
-
- public void testLookupVisibility() throws Exception {
- helpTestVisibilityFails("select lookup('bqt3.smalla', 'intkey', 'stringkey', '?')"); //$NON-NLS-1$
- }
-
- public void testCancel() throws Exception {
- assertFalse(this.core.cancelRequest(new RequestID(1)));
- }
-
- public void helpTestVisibilityFails(String sql) throws Exception {
- RequestMessage reqMsg = exampleRequestMessage(sql);
- reqMsg.setTxnAutoWrapMode(ExecutionProperties.AUTO_WRAP_OFF);
- Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
- ResultsMessage results = message.get(50000, TimeUnit.MILLISECONDS);
- assertEquals("[QueryValidatorException]Group does not exist: BQT3.SmallA", results.getException().toString()); //$NON-NLS-1$
- }
-
- public void testXQueryVisibility() throws Exception {
- String xquery = "<Items>\r\n" + //$NON-NLS-1$
- "{\r\n" + //$NON-NLS-1$
- "for $x in doc(\"select * from bqt3.smalla\")//Item\r\n" + //$NON-NLS-1$
- "return <Item>{$x/intkey/text()}</Item>\r\n" + //$NON-NLS-1$
- "}\r\n" + //$NON-NLS-1$
- "</Items>\r\n"; //$NON-NLS-1$
-
- helpTestVisibilityFails(xquery);
- }
-
-
- ///////////////////////////Helper method///////////////////////////////////
- private ResultsMessage helpExecute(String sql, String userName) throws Exception {
- return helpExecute(sql, userName, 1, false);
- }
-
- private ResultsMessage helpExecute(String sql, String userName, int sessionid, boolean txnAutoWrap) throws Exception {
- RequestMessage reqMsg = exampleRequestMessage(sql);
- DQPWorkContext.getWorkContext().setUserName(userName);
- DQPWorkContext.getWorkContext().setSessionId(new MetaMatrixSessionID(sessionid));
- if (txnAutoWrap) {
- reqMsg.setTxnAutoWrapMode(ExecutionProperties.AUTO_WRAP_ON);
- }
-
- Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
- ResultsMessage results = message.get(50000, TimeUnit.MILLISECONDS);
- assertNull(results.getException());
- return results;
- }
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestDQPCoreRequestHandling.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestDQPCoreRequestHandling.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestDQPCoreRequestHandling.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,183 +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 com.metamatrix.dqp.internal.process;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.common.buffer.TupleSourceID;
-import com.metamatrix.dqp.exception.SourceWarning;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
-import com.metamatrix.dqp.message.AtomicRequestMessage;
-import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.processor.QueryProcessor;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.server.serverapi.RequestInfo;
-
-/**
- */
-public class TestDQPCoreRequestHandling extends TestCase {
-
- private static final String SESSION_STRING = new MetaMatrixSessionID(2).toString();
-
- public TestDQPCoreRequestHandling(String name) {
- super(name);
- }
-
- private void compareReqInfos(Collection<RequestID> reqs1, Collection<RequestInfo> reqs2) {
- Set reqIDs2 = new HashSet();
- for (RequestInfo requestInfo : reqs2) {
- reqIDs2.add(requestInfo.getRequestID());
- }
-
- assertEquals("Collections of request infos are not the same: ", new HashSet(reqs1), reqIDs2); //$NON-NLS-1$
- }
-
- /**
- * Test for Collection getRequests(SessionToken) - no requests
- */
- public void testGetRequestsSessionToken1() {
- DQPCore rm = new DQPCore();
- Set reqs = new HashSet();
- Collection actualReqs = rm.getRequestsByClient("foo");
- compareReqInfos(reqs, actualReqs);
- }
-
- /**
- * Test for Collection getRequests(SessionToken) - 1 request
- */
- public void testGetRequestsSessionToken2() {
- DQPCore rm = new DQPCore();
- Set reqs = new HashSet();
- RequestID id = addRequest(rm, SESSION_STRING, 1);
- reqs.add(id);
-
- Collection<RequestInfo> actualReqs = rm.getRequestsByClient(SESSION_STRING);
- compareReqInfos(reqs, actualReqs);
- }
-
- private RequestID addRequest(DQPCore rm, String sessionId, int executionId) {
- RequestMessage r0 = new RequestMessage("test command"); //$NON-NLS-1$
- RequestID id = new RequestID(sessionId, executionId);
- addRequest(rm, r0, id, null, null, new TupleSourceID("ts-1"), null, null, null); //$NON-NLS-1$
- return id;
- }
-
- /**
- * Test for Collection getRequests(SessionToken) - 3 requests
- */
- public void testGetRequestsSessionToken3() {
- DQPCore rm = new DQPCore();
- Set reqs = new HashSet();
-
- reqs.add(addRequest(rm, SESSION_STRING, 0));
- reqs.add(addRequest(rm, SESSION_STRING, 1));
- reqs.add(addRequest(rm, SESSION_STRING, 2));
-
- Collection actualReqs = rm.getRequestsByClient(SESSION_STRING);
- compareReqInfos(reqs, actualReqs);
- }
-
- private SourceWarning getSourceFailures(String model, String binding, String message) {
- return new SourceWarning(model, binding, new MetaMatrixException(message), true);
- }
-
- public void testAddRequest() {
- DQPCore rm = new DQPCore();
- RequestMessage r0 = new RequestMessage("foo"); //$NON-NLS-1$
- RequestID requestID = new RequestID(SESSION_STRING, 1);
- RequestWorkItem workItem = addRequest(rm, r0, requestID, null, null, new TupleSourceID("ts-1"), null, null, null); //$NON-NLS-1$
- assertTrue(workItem.resultsCursor.resultsRequested);
- }
-
- public void testWarnings1() {
- DQPCore rm = new DQPCore();
- RequestMessage r0 = new RequestMessage("foo"); //$NON-NLS-1$
- RequestID requestID = new RequestID(SESSION_STRING, 1);
-
- RequestWorkItem workItem = addRequest(rm, r0, requestID, null, null, new TupleSourceID("ts-1"), null, null, null); //$NON-NLS-1$
-
- workItem.addSourceFailureDetails(getSourceFailures("Model1", "Binding1", "Warning1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- workItem.addSourceFailureDetails(getSourceFailures("Model2", "Binding2", "Warning2")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- workItem.addSourceFailureDetails(getSourceFailures("Model3", "Binding3", "Warning3")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- assertEquals(3, workItem.getWarnings().size());
- }
-
- static RequestWorkItem addRequest(DQPCore rm,
- RequestMessage requestMsg,
- RequestID id,
- Command originalCommand,
- QueryProcessor processor,
- TupleSourceID resultsID,
- AnalysisRecord analysisRecord,
- Collection schemas, DQPWorkContext workContext) {
-
- if (workContext == null) {
- workContext = new DQPWorkContext();
- workContext.setSessionId(new MetaMatrixSessionID(id.getConnectionID()));
- }
- RequestWorkItem workItem = new RequestWorkItem(rm, requestMsg, null, null, id, workContext);
- workItem.setOriginalCommand(originalCommand);
- rm.addRequest(id, workItem);
- return workItem;
- }
-
- public void testGetConnectorInfo() {
- DQPCore rm = new DQPCore();
- RequestMessage r0 = new RequestMessage("foo"); //$NON-NLS-1$
- RequestID requestID = new RequestID(SESSION_STRING, 1);
- RequestWorkItem workItem = addRequest(rm, r0, requestID, null, null, null, null, null, null);
- AtomicRequestMessage atomicReq = new AtomicRequestMessage(workItem.requestMsg, workItem.dqpWorkContext, 1);
-
- DataTierTupleSource info = new DataTierTupleSource(null, atomicReq, null, new ConnectorID("connID"), workItem); //$NON-NLS-1$
- workItem.addConnectorRequest(atomicReq.getAtomicRequestID(), info);
-
- DataTierTupleSource arInfo = workItem.getConnectorRequest(atomicReq.getAtomicRequestID());
- assertTrue(arInfo == info);
- }
-
- public void testRemoveConnectorInfo() {
- DQPCore rm = new DQPCore();
- RequestMessage r0 = new RequestMessage("foo"); //$NON-NLS-1$
- RequestID requestID = new RequestID(SESSION_STRING, 1);
- RequestWorkItem workItem = addRequest(rm, r0, requestID, null, null, null, null, null, null);
- AtomicRequestMessage atomicReq = new AtomicRequestMessage(workItem.requestMsg, workItem.dqpWorkContext, 1);
-
- DataTierTupleSource info = new DataTierTupleSource(null, atomicReq, null, new ConnectorID("connID"), workItem); //$NON-NLS-1$
- workItem.addConnectorRequest(atomicReq.getAtomicRequestID(), info);
-
- workItem.closeAtomicRequest(atomicReq.getAtomicRequestID());
-
- DataTierTupleSource arInfo = workItem.getConnectorRequest(atomicReq.getAtomicRequestID());
- assertNull(arInfo);
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestDQPWorkContext.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestDQPWorkContext.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestDQPWorkContext.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,63 +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 com.metamatrix.dqp.internal.process;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-
-public class TestDQPWorkContext extends TestCase {
-
- /**
- * Constructor for TestRequestMessage.
- *
- * @param name
- */
- public TestDQPWorkContext(String name) {
- super(name);
- }
-
- public static DQPWorkContext example() {
- DQPWorkContext message = new DQPWorkContext();
- message.setTrustedPayload("myTrustedPayload"); //$NON-NLS-1$
- message.setUserName("userName"); //$NON-NLS-1$
- message.setVdbName("vdbName"); //$NON-NLS-1$
- message.setVdbVersion("vdbVersion"); //$NON-NLS-1$
- message.setAppName("querybuilder");
- message.setSessionId(new MetaMatrixSessionID(5));
- return message;
- }
-
- public void testSerialize() throws Exception {
- DQPWorkContext copy = UnitTestUtil.helpSerialize(example());
-
- assertEquals("5", "5"); //$NON-NLS-1$
- assertEquals("myTrustedPayload", copy.getTrustedPayload()); //$NON-NLS-1$
- assertEquals("userName", copy.getUserName()); //$NON-NLS-1$
- assertEquals("vdbName", copy.getVdbName()); //$NON-NLS-1$
- assertEquals("vdbVersion", copy.getVdbVersion()); //$NON-NLS-1$
- assertEquals("querybuilder", copy.getAppName()); //$NON-NLS-1$
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestDataTierManager.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestDataTierManager.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestDataTierManager.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,397 +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 com.metamatrix.dqp.internal.process;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.api.exception.ComponentNotFoundException;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.buffer.TupleSourceID;
-import com.metamatrix.common.comm.api.ResultsReceiver;
-import com.metamatrix.common.config.api.ConnectorBinding;
-import com.metamatrix.dqp.internal.datamgr.ConnectorID;
-import com.metamatrix.dqp.message.AtomicRequestID;
-import com.metamatrix.dqp.message.AtomicRequestMessage;
-import com.metamatrix.dqp.message.AtomicResultsMessage;
-import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.dqp.service.DataService;
-import com.metamatrix.dqp.service.FakeBufferService;
-import com.metamatrix.dqp.service.FakeVDBService;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.QueryProcessor;
-import com.metamatrix.query.processor.dynamic.SimpleQueryProcessorFactory;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.util.CommandContext;
-
-
-public class TestDataTierManager extends TestCase {
-
- private DQPCore rm;
- private DataTierManagerImpl dtm;
- private CommandContext context;
- private AtomicRequestMessage request;
- private Command command;
- private DataTierTupleSource info;
- private QueryProcessor processor;
- private int executeRequestFailOnCall = 10000;
- private FakeDataService dataService;
- private RequestWorkItem workItem;
-
- public TestDataTierManager(String name) {
- super(name);
- }
-
- private static Command helpGetCommand(String sql, QueryMetadataInterface metadata) throws Exception {
- Command command = QueryParser.getQueryParser().parseCommand(sql);
- QueryResolver.resolveCommand(command, metadata);
- return command;
- }
-
- private void helpSetup(int nodeId) throws Exception {
- helpSetup("SELECT * FROM BQT1.SmallA", nodeId); //$NON-NLS-1$
- }
-
- private void helpSetup(String sql, int nodeId) throws Exception {
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- dataService = new FakeDataService(executeRequestFailOnCall);
-// dataService.addResults("SELECT StringKey, IntKey FROM BQT1.SmallA", helpCreateFakeCodeTableResults(1, 50)); //$NON-NLS-1$
- rm = new DQPCore();
-
- FakeVDBService vdbService = new FakeVDBService();
- vdbService.addBinding("MyVDB", "1", "BQT1", "mmuuid:binding", "bindingName"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
-
- FakeBufferService bs = new FakeBufferService();
-
- dtm = new DataTierManagerImpl(rm,
- dataService,
- new MockSingleMetadataService(metadata),
- vdbService,
- bs,
- 1000,
- 1000);
- command = helpGetCommand(sql, metadata);
-
- RequestMessage original = new RequestMessage();
- original.setExecutionId(1);
-
- DQPWorkContext workContext = new DQPWorkContext();
- workContext.setVdbName("MyVDB"); //$NON-NLS-1$
- workContext.setVdbVersion("1"); //$NON-NLS-1$
- workContext.setSessionId(new MetaMatrixSessionID(1));
- RequestID requestID = workContext.getRequestID(original.getExecutionId());
-
- context = new CommandContext();
- context.setProcessorID(requestID);
- context.setTupleSourceID(new TupleSourceID("fakeid")); //$NON-NLS-1$
- context.setVdbName("test"); //$NON-NLS-1$
- context.setVdbVersion("1"); //$NON-NLS-1$
- context.setQueryProcessorFactory(new SimpleQueryProcessorFactory(bs.getBufferManager(), dtm, new DefaultCapabilitiesFinder(), null, metadata));
- processor = new QueryProcessor(new FakeProcessorPlan(), context, bs.getBufferManager(), dtm);
- workItem = TestDQPCoreRequestHandling.addRequest(rm, original, requestID, null, processor, null, null, null, workContext);
-
- request = new AtomicRequestMessage(original, workContext, nodeId);
- request.setCommand(command);
- request.setConnectorID(new ConnectorID("FakeConnectorID")); //$NON-NLS-1$
-
- info = new DataTierTupleSource(command.getProjectedSymbols(), request, dtm, request.getConnectorID(), workItem);
- workItem.addConnectorRequest(request.getAtomicRequestID(), info);
- }
-
- private AtomicResultsMessage helpSetup(boolean isFirst, boolean isLast) throws Exception {
- return helpSetup("SELECT * FROM BQT1.SmallA", isFirst, isLast); //$NON-NLS-1$
- }
-
- private AtomicResultsMessage helpSetup(String sql, boolean isFirst, boolean isLast) throws Exception {
- return helpSetup(sql, isFirst, isLast, 3);
- }
-
- private AtomicResultsMessage helpSetup(String sql, boolean isFirst, boolean isLast, int nodeId) throws Exception {
- helpSetup(sql, nodeId);
-
- request.setCommand(command);
-
- AtomicResultsMessage results = new AtomicResultsMessage(request, new List[0], new String[0]);
-
- if (isLast) {
- results.setFinalRow(10);
- }
- return results;
- }
-
- /**
- * Defect 15646 - Ensure that when the final batch is received, the ConnectorRequestInfo object is removed from the RequestManager
- * @throws Exception
- * @since 4.2
- */
- public void testDeliverMessageNEWResponseFinal_Defect15646() throws Exception {
- AtomicResultsMessage results = helpSetup(true, true);
- info.receiveResults(results);
-
- assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
-
- DataTierTupleSource connRequest = workItem.getConnectorRequest(request.getAtomicRequestID());
-
- connRequest.closeSource();
-
- assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
-
- AtomicResultsMessage closeResult = new AtomicResultsMessage(request);
- closeResult.setRequestClosed(true);
- info.receiveResults(closeResult);
-
- assertNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
- }
-
- public void testDeliverMessageNEWResponseNonFinal() throws Exception {
- AtomicResultsMessage results = helpSetup(true, false);
- info.receiveResults(results);
- assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
- }
-
- public void testDeliverMessageMOREResponseFinal_Defect15646() throws Exception {
- AtomicResultsMessage results = helpSetup(false, true);
- info.receiveResults(results);
-
- assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
-
- DataTierTupleSource connRequest = workItem.getConnectorRequest(request.getAtomicRequestID());
-
- connRequest.closeSource();
-
- assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
-
- AtomicResultsMessage closeResult = new AtomicResultsMessage(request);
- closeResult.setRequestClosed(true);
- info.receiveResults(closeResult);
-
- assertNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
- }
-
- public void testExplicitClose() throws Exception {
- String sql = "select ClobValue from LOB.LobTbl"; //$NON-NLS-1$
-
- AtomicResultsMessage results = helpSetup(sql, true, true);
- results.setSupportsImplicitClose(false);
-
- info.receiveResults(results);
- assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
-
- DataTierTupleSource connRequest = workItem.getConnectorRequest(request.getAtomicRequestID());
- connRequest.closeSource();
- assertFalse(this.dataService.closed);
-
- assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
-
- // now explicit close and see it gone
- connRequest.fullyCloseSource();
-
- assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
-
- AtomicResultsMessage closeResult = new AtomicResultsMessage(request);
- closeResult.setRequestClosed(true);
- info.receiveResults(closeResult);
-
- assertNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
- }
-
-
- public void testImplictClose() throws Exception {
- String sql = "select ClobValue from LOB.LobTbl"; //$NON-NLS-1$
-
- AtomicResultsMessage results = helpSetup(sql, true, true);
- results.setSupportsImplicitClose(true);
-
- info.receiveResults(results);
-
- assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
-
- DataTierTupleSource connRequest = workItem.getConnectorRequest(request.getAtomicRequestID());
- connRequest.closeSource();
- assertTrue(this.dataService.closed);
-
- assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
-
- AtomicResultsMessage closeResult = new AtomicResultsMessage(request);
- closeResult.setRequestClosed(true);
- info.receiveResults(closeResult);
-
- assertNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
- }
-
- public void testImplictCloseWithNotAllowedState() throws Exception {
- String sql = "select ClobValue from LOB.LobTbl"; //$NON-NLS-1$
-
- AtomicResultsMessage results = helpSetup(sql, true, true);
- results.setSupportsImplicitClose(false);
-
- info.receiveResults(results);
- assertFalse(this.dataService.closed);
- assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
-
- DataTierTupleSource connRequest = workItem.getConnectorRequest(request.getAtomicRequestID());
-
- // now implicitly close the request then check to make sure it is not gone
- connRequest.closeSource();
- assertFalse(this.dataService.closed);
- assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
- }
-
-
- public void testDeliverMessageMOREResponseNonFinal() throws Exception {
- AtomicResultsMessage results = helpSetup(false, false);
- info.receiveResults(results);
-
- assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
- }
-
- public void testCodeTableResponseException() throws Exception {
- helpSetup(3);
- this.dataService.throwExceptionOnExecute = true;
-
- try {
- dtm.lookupCodeValue(context, "BQT1.SmallA", "IntKey", "StringKey", "49"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- fail("processor should have failed"); //$NON-NLS-1$
- } catch (MetaMatrixException e) {
- assertEquals("Connector Exception", e.getMessage()); //$NON-NLS-1$
- }
- }
-
- public void testCodeTableResponse_MoreRequestFails() throws Exception {
- executeRequestFailOnCall = 1;
-
- AtomicResultsMessage results = helpSetup("SELECT * FROM BQT1.SmallA", true, false, -1); //$NON-NLS-1$
-
- this.dataService.results = results;
-
- try {
- dtm.lookupCodeValue(context, "BQT1.SmallA", "IntKey", "StringKey", "49"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- fail("processor should have failed"); //$NON-NLS-1$
- } catch (MetaMatrixException e) {
- assertEquals("Force fail on executeRequest for call # 1", e.getMessage()); //$NON-NLS-1$
- }
- }
-
- private static class FakeProcessorPlan implements ProcessorPlan {
- public Object clone() {return this;}
- public void close() throws MetaMatrixComponentException {}
- public List getAndClearWarnings() {return null;}
- public CommandContext getContext() {return null;}
- public List getOutputElements() {return null;}
- public void initialize(CommandContext context,ProcessorDataManager dataMgr,BufferManager bufferMgr) {}
- public TupleBatch nextBatch() throws BlockedException,MetaMatrixComponentException {
- ArrayList one = new ArrayList(); one.add("1");
- ArrayList two = new ArrayList(); two.add("2");
- List[] results = {one, two};
- return new TupleBatch(1, results);
- }
- public void open() throws MetaMatrixComponentException {}
- public void reset() {}
- public Map getDescriptionProperties() {return null;}
- public Collection getChildPlans() { return Collections.EMPTY_LIST; }
- }
-
- private static class FakeDataService implements DataService {
- private int failOnCall = 10000;
- private int calls = 0;
- private boolean closed = false;
- boolean throwExceptionOnExecute;
- AtomicResultsMessage results;
-
- private FakeDataService(int failOnCallNumber) {
- this.failOnCall = failOnCallNumber;
- }
- public void executeRequest(AtomicRequestMessage request,
- ConnectorID connector,
- ResultsReceiver<AtomicResultsMessage> resultListener)
- throws MetaMatrixComponentException {
- if (closed) {
- throw new MetaMatrixComponentException("Already closed"); //$NON-NLS-1$
- }
- if (throwExceptionOnExecute) {
- resultListener.exceptionOccurred(new RuntimeException("Connector Exception")); //$NON-NLS-1$
- } else {
- resultListener.receiveResults(results);
- }
- }
- public ConnectorID selectConnector(String connectorBindingID) {
- if (connectorBindingID.equals("mmuuid:binding")) { //$NON-NLS-1$
- return new ConnectorID("FakeConnectorID"); //$NON-NLS-1$
- }
- return null;
- }
- public void initialize(Properties props) throws ApplicationInitializationException {}
- public void start(ApplicationEnvironment environment) throws ApplicationLifecycleException {}
- public void stop() throws ApplicationLifecycleException {}
- public void startConnectorBinding(String connectorBindingName) throws ApplicationLifecycleException,ComponentNotFoundException {}
- public void stopConnectorBinding(String connectorBindingName) throws ApplicationLifecycleException,ComponentNotFoundException {}
- public List getConnectorBindings() throws ComponentNotFoundException {return null;}
- public Boolean getConnectorBindingState(String connectorBindingName) throws MetaMatrixComponentException {return null;}
- public ConnectorBinding getConnectorBinding(String connectorBindingName) throws MetaMatrixComponentException {return null;}
- public Collection getConnectorBindingStatistics(String connectorBindingName) throws MetaMatrixComponentException {return null;}
- public void clearConnectorBindingCache(String connectorBindingName) throws MetaMatrixComponentException {}
-
- public void cancelRequest(AtomicRequestID request,
- ConnectorID connectorId) throws MetaMatrixComponentException {
- }
- public void closeRequest(AtomicRequestID request,
- ConnectorID connectorId) throws MetaMatrixComponentException {
- closed = true;
- }
- public SourceCapabilities getCapabilities(RequestMessage request,
- DQPWorkContext dqpWorkContext, ConnectorID connector)
- throws MetaMatrixComponentException {
- return null;
- }
- public void requestBatch(AtomicRequestID request,
- ConnectorID connectorId) throws MetaMatrixComponentException {
- calls++;
- if (calls == failOnCall) {
- throw new MetaMatrixComponentException("Force fail on executeRequest for call # " + calls); //$NON-NLS-1$
- }
- }
- }
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestMetaDataProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestMetaDataProcessor.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestMetaDataProcessor.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,267 +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 com.metamatrix.dqp.internal.process;
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.vdb.api.ModelInfo;
-import com.metamatrix.dqp.client.MetadataResult;
-import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.dqp.metadata.ResultsMetadataConstants;
-import com.metamatrix.dqp.service.DQPServiceNames;
-import com.metamatrix.dqp.service.FakeVDBService;
-import com.metamatrix.dqp.service.MetadataService;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-/**
- */
-public class TestMetaDataProcessor extends TestCase {
-
- public TestMetaDataProcessor(String name) {
- super(name);
- }
-
- public Map[] helpGetMetadata(String sql, QueryMetadataInterface metadata) throws Exception {
- // Prepare sql
- Command command = QueryParser.getQueryParser().parseCommand(sql);
- QueryResolver.resolveCommand(command, Collections.EMPTY_MAP, false, metadata, AnalysisRecord.createNonRecordingRecord());
-
- // Create components
- MetadataService mdSvc = new MockSingleMetadataService(metadata);
- PreparedPlanCache prepPlanCache = new PreparedPlanCache();
- DQPCore requestMgr = new DQPCore();
-
- DQPWorkContext workContext = new DQPWorkContext();
- workContext.setVdbName("MyVDB"); //$NON-NLS-1$
- workContext.setVdbVersion("1"); //$NON-NLS-1$
- workContext.setSessionId(new MetaMatrixSessionID(1));
-
- // Initialize components
- RequestID requestID = workContext.getRequestID(1);
- RequestMessage requestMsg = new RequestMessage(sql);
- TestDQPCoreRequestHandling.addRequest(requestMgr, requestMsg, requestID, command, null, null, AnalysisRecord.createNonRecordingRecord(), null, null); //$NON-NLS-1$
-
- ApplicationEnvironment env = new ApplicationEnvironment();
- FakeVDBService vdbService = new FakeVDBService();
- env.bindService(DQPServiceNames.VDB_SERVICE, vdbService);
- MetaDataProcessor mdProc = new MetaDataProcessor(mdSvc, requestMgr, prepPlanCache, env, null);
-
- return mdProc.processMessage(requestID, workContext, null, true).getColumnMetadata();
- }
-
- public void testSimpleQuery() throws Exception {
- Map[] metadata = helpGetMetadata("SELECT e1 FROM pm1.g1", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
- assertNotNull(metadata);
- assertEquals(1, metadata.length);
- }
-
- public void testSimpleUpdate() throws Exception {
- Map[] metadata = helpGetMetadata("INSERT INTO pm1.g1 (e1) VALUES ('x')", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
- assertNotNull(metadata);
- assertEquals(1, metadata.length);
-
- metadata = helpGetMetadata("DELETE FROM pm1.g1 WHERE e1 = 'x'", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
- assertNotNull(metadata);
- assertEquals(1, metadata.length);
-
- metadata = helpGetMetadata("UPDATE pm1.g1 SET e1='y' WHERE e1 = 'x'", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
- assertNotNull(metadata);
- assertEquals(1, metadata.length);
-
- metadata = helpGetMetadata("SELECT e1, e2, e3, e4 INTO pm1.g2 FROM pm1.g1", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
- assertNotNull(metadata);
- assertEquals(1, metadata.length);
- }
-
- public void testElementLabel() throws Exception {
- Map[] metadata = helpGetMetadata("SELECT E2 FROM pm1.g1", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
- assertNotNull(metadata);
- assertEquals(1, metadata.length);
- assertEquals("E2", metadata[0].get(ResultsMetadataConstants.ELEMENT_NAME)); //$NON-NLS-1$
- }
-
- public void testSimpleExec() throws Exception {
- Map[] metadata = helpGetMetadata("EXEC pm1.sq1()", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
- assertNotNull(metadata);
- assertEquals(2, metadata.length);
- }
-
- public void testExecNoResultColumns() throws Exception {
- Map[] metadata = helpGetMetadata("EXEC pm1.sp5()", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
- assertNotNull(metadata);
- assertEquals(0, metadata.length);
- }
-
- public void testDefect15029() throws Exception {
- String sql = "SELECT * FROM g1"; //$NON-NLS-1$
- QueryMetadataInterface metadata = FakeMetadataFactory.examplePrivatePhysicalModel();
-
- MetadataResult response = helpTestQuery(metadata, sql);
-
- Map[] md = response.getColumnMetadata();
- assertNotNull(md);
- assertEquals(1, md.length);
- assertEquals("e1", md[0].get(ResultsMetadataConstants.ELEMENT_NAME)); //$NON-NLS-1$
- assertEquals("vm1.g1", md[0].get(ResultsMetadataConstants.GROUP_NAME)); //$NON-NLS-1$
- }
-
- private MetadataResult helpTestQuery(QueryMetadataInterface metadata, String sql) throws Exception {
- FakeVDBService vdbService = new FakeVDBService();
- vdbService.addModel("MyVDB", "1", "pm1", ModelInfo.PRIVATE, false); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
-
- // Create components
- MetadataService mdSvc = new MockSingleMetadataService(metadata);
- PreparedPlanCache prepPlanCache = new PreparedPlanCache();
-
- // Initialize components
- ApplicationEnvironment env = new ApplicationEnvironment();
- env.bindService(DQPServiceNames.VDB_SERVICE, vdbService);
- MetaDataProcessor mdProc = new MetaDataProcessor(mdSvc, null, prepPlanCache, env, null);
-
- DQPWorkContext workContext = new DQPWorkContext();
- workContext.setVdbName("MyVDB"); //$NON-NLS-1$
- workContext.setVdbVersion("1"); //$NON-NLS-1$
- workContext.setSessionId(new MetaMatrixSessionID(1));
- return mdProc.processMessage(workContext.getRequestID(1), workContext, sql, true);
- }
-
- private void helpCheckNumericAttributes(MetadataResult message, int column, int expectedSize, int expectedPrecision, int expectedScale) {
- Map[] md = message.getColumnMetadata();
- assertNotNull(md);
- assertEquals(new Integer(expectedSize), md[column].get(ResultsMetadataConstants.DISPLAY_SIZE));
- assertEquals(new Integer(expectedPrecision), md[column].get(ResultsMetadataConstants.PRECISION));
- assertEquals(new Integer(expectedScale), md[column].get(ResultsMetadataConstants.SCALE));
- }
-
- public void testDefect16629_moneyType() throws Exception {
- QueryMetadataInterface metadata = FakeMetadataFactory.examplePrivatePhysicalModel(); //$NON-NLS-1$
- String sql = "SELECT e1 FROM pm1.g2"; //$NON-NLS-1$
-
- MetadataResult response = helpTestQuery(metadata, sql);
-
- helpCheckNumericAttributes(response, 0, 21, 19, 4);
- }
-
- public void testDefect16629_aggregatesOnMoneyType() throws Exception {
- QueryMetadataInterface metadata = FakeMetadataFactory.examplePrivatePhysicalModel(); //$NON-NLS-1$
- String sql = "SELECT min(e1), max(e1), sum(e1), avg(e1) FROM pm1.g2"; //$NON-NLS-1$
-
- MetadataResult response = helpTestQuery(metadata, sql);
- helpCheckNumericAttributes(response, 0, 21, 19, 4);
- helpCheckNumericAttributes(response, 1, 21, 19, 4);
- helpCheckNumericAttributes(response, 2, 22, 20, 0);
- helpCheckNumericAttributes(response, 3, 22, 20, 0);
- }
-
- public void testMetadataGenerationForAllTypes() throws Exception {
- Set dataTypes = DataTypeManager.getAllDataTypeNames();
- Iterator iter = dataTypes.iterator();
-
- while(iter.hasNext()) {
- String type = (String) iter.next();
- Class typeClass = DataTypeManager.getDataTypeClass(type);
- MetaDataProcessor processor = new MetaDataProcessor(null, null, null, null, null);
- Map columnMetadata = processor.getDefaultColumn("vdb", "1", "t", "c", typeClass); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- verifyColumn(columnMetadata, type);
- }
- }
-
- private void verifyColumn(Map column, String dataType) {
- verifyAttribute(column, ResultsMetadataConstants.AUTO_INCREMENTING, false, Boolean.class, dataType);
- verifyAttribute(column, ResultsMetadataConstants.CASE_SENSITIVE, false, Boolean.class, dataType);
- verifyAttribute(column, ResultsMetadataConstants.CURRENCY, false, Boolean.class, dataType);
-
- Object dt = verifyAttribute(column, ResultsMetadataConstants.DATA_TYPE, false, String.class, dataType);
- assertEquals(dataType, dt);
-
- verifyAttribute(column, ResultsMetadataConstants.DISPLAY_SIZE, false, Integer.class, dataType);
- verifyAttribute(column, ResultsMetadataConstants.ELEMENT_LABEL, true, String.class, dataType);
- verifyAttribute(column, ResultsMetadataConstants.ELEMENT_NAME, false, String.class, dataType);
- verifyAttribute(column, ResultsMetadataConstants.GROUP_NAME, true, String.class, dataType);
-
- Object nullable = verifyAttribute(column, ResultsMetadataConstants.NULLABLE, false, Integer.class, dataType);
- verifyNullable((Integer)nullable);
-
- verifyAttribute(column, ResultsMetadataConstants.PRECISION, false, Integer.class, dataType);
- verifyAttribute(column, ResultsMetadataConstants.RADIX, false, Integer.class, dataType);
- verifyAttribute(column, ResultsMetadataConstants.SCALE, false, Integer.class, dataType);
-
- Object searchable = verifyAttribute(column, ResultsMetadataConstants.SEARCHABLE, false, Integer.class, dataType);
- verifySearchable((Integer)searchable);
-
- verifyAttribute(column, ResultsMetadataConstants.SIGNED, false, Boolean.class, dataType);
-
- verifyAttribute(column, ResultsMetadataConstants.VIRTUAL_DATABASE_NAME, false, String.class, dataType);
- verifyAttribute(column, ResultsMetadataConstants.VIRTUAL_DATABASE_VERSION, false, String.class, dataType);
- verifyAttribute(column, ResultsMetadataConstants.WRITABLE, false, Boolean.class, dataType);
- }
-
- private Object verifyAttribute(Map column, Integer attributeType, boolean nullsAllowed, Class expectedClass, String columnDataType) {
- //System.out.println("Checking " + columnDataType + ", attribute " + attributeType); //$NON-NLS-1$ //$NON-NLS-2$
- Object value = column.get(attributeType);
- if(! nullsAllowed) {
- assertNotNull("Got null when not allowed for column of type " + columnDataType, value); //$NON-NLS-1$
- }
-
- if(value != null) {
- assertEquals("Got attribute of incorrect class for column of type " + columnDataType, expectedClass, value.getClass()); //$NON-NLS-1$
- }
-
- return value;
- }
-
- private void verifyNullable(Integer nullable) {
- if(!
- (nullable.equals(ResultsMetadataConstants.NULL_TYPES.NOT_NULL) ||
- nullable.equals(ResultsMetadataConstants.NULL_TYPES.NULLABLE) ||
- nullable.equals(ResultsMetadataConstants.NULL_TYPES.UNKNOWN) ) ) {
-
- fail("Invalid nullable constant value: " + nullable); //$NON-NLS-1$
- }
- }
-
- private void verifySearchable(Integer searchable) {
- if(!
- (searchable.equals(ResultsMetadataConstants.SEARCH_TYPES.ALLEXCEPTLIKE) ||
- searchable.equals(ResultsMetadataConstants.SEARCH_TYPES.LIKE_ONLY) ||
- searchable.equals(ResultsMetadataConstants.SEARCH_TYPES.UNSEARCHABLE) ||
- searchable.equals(ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE) ) ) {
-
- fail("Invalid searchable constant value: " + searchable); //$NON-NLS-1$
- }
- }
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestPreparedPlanCache.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestPreparedPlanCache.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestPreparedPlanCache.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,153 +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 com.metamatrix.dqp.internal.process;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.processor.relational.ProjectNode;
-import com.metamatrix.query.processor.relational.RelationalPlan;
-import com.metamatrix.query.sql.lang.Command;
-
-
-public class TestPreparedPlanCache extends TestCase{
- private static final String EXAMPLE_QUERY = "SELECT * FROM table"; //$NON-NLS-1$
- private final static String token = "1"; //$NON-NLS-1$
- private final static String token2 = "2"; //$NON-NLS-1$
-
- public TestPreparedPlanCache(String name) {
- super(name);
- }
-
- //====Tests====//
- public void testCreatePreparedPlan(){
- PreparedPlanCache cache = new PreparedPlanCache();
-
- //No PreparedPlan at the begining
- assertNull(cache.getPreparedPlan(token, EXAMPLE_QUERY + 1, false));
- //create one
- cache.createPreparedPlan(token, EXAMPLE_QUERY + 1, false);
- //should have one now
- assertNotNull("Unable to get prepared plan from cache", cache.getPreparedPlan(token, EXAMPLE_QUERY + 1, false)); //$NON-NLS-1$
- }
-
- public void testGetPreparedPlan(){
- PreparedPlanCache cache = new PreparedPlanCache();
- helpCreatePreparedPlans(cache, token, 0, 10);
- helpCreatePreparedPlans(cache, token2, 0, 15);
-
- //read an entry for session2 (token2)
- PreparedPlanCache.PreparedPlan pPlan = cache.getPreparedPlan(token2, EXAMPLE_QUERY + 12, false);
- assertNotNull("Unable to get prepared plan from cache", pPlan); //$NON-NLS-1$
- assertEquals("Error getting plan from cache", new RelationalPlan(new ProjectNode(12)).toString(), pPlan.getPlan().toString()); //$NON-NLS-1$
- assertEquals("Error getting command from cache", EXAMPLE_QUERY + 12, pPlan.getCommand().toString()); //$NON-NLS-1$
- assertNotNull("Error getting plan description from cache", pPlan.getAnalysisRecord().getQueryPlan()); //$NON-NLS-1$
- assertEquals("Error gettting reference from cache", "ref12", pPlan.getReferences().get(0)); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testClearAll(){
- PreparedPlanCache cache = new PreparedPlanCache();
-
- //create one for each session token
- cache.createPreparedPlan(token, EXAMPLE_QUERY + 1, false);
- cache.createPreparedPlan(token2, EXAMPLE_QUERY + 1, false);
- //should have one
- assertNotNull("Unable to get prepared plan from cache for token", cache.getPreparedPlan(token, EXAMPLE_QUERY + 1, false)); //$NON-NLS-1$
- cache.clearAll();
- //should not exist for token
- assertNull("Failed remove from cache", cache.getPreparedPlan(token, EXAMPLE_QUERY + 1, false)); //$NON-NLS-1$
- //should not exist for token2
- assertNull("Unable to get prepared plan from cache for token2", cache.getPreparedPlan(token2, EXAMPLE_QUERY + 1, false)); //$NON-NLS-1$
- }
-
- public void testMaxSize(){
- PreparedPlanCache cache = new PreparedPlanCache(100);
- helpCreatePreparedPlans(cache, token, 0, 101);
- //the first one should be gone because the max size is 100
- assertNull(cache.getPreparedPlan(token, EXAMPLE_QUERY + 0, false));
-
- assertNotNull(cache.getPreparedPlan(token, EXAMPLE_QUERY + 12, false));
- helpCreatePreparedPlans(cache, token, 102, 50);
- //"sql12" should still be there based on lru policy
- assertNotNull(cache.getPreparedPlan(token, EXAMPLE_QUERY + 12, false));
-
- helpCreatePreparedPlans(cache, token2, 0, 121);
- helpCreatePreparedPlans(cache, token, 0, 50);
- assertTrue(cache.getSpaceUsed() <= 100);
- }
-
- public void testZeroSizeCache() {
- // Create with 0 size cache
- PreparedPlanCache cache = new PreparedPlanCache(0);
- assertEquals(0, cache.getSpaceAllowed());
-
- // Add 1 plan and verify it is not in the cache
- helpCreatePreparedPlans(cache, token, 0, 1);
- assertNull(cache.getPreparedPlan(token, EXAMPLE_QUERY + 0, false));
- assertEquals(0, cache.getSpaceUsed());
-
- // Add another plan and verify it is not in the cache
- helpCreatePreparedPlans(cache, token, 1, 1);
- assertNull(cache.getPreparedPlan(token, EXAMPLE_QUERY + 1, false));
- assertEquals(0, cache.getSpaceUsed());
- }
-
- // set init size to negative number, which should default to 100 (default)
- public void testNegativeSizeCacheUsesDefault() {
- PreparedPlanCache negativeSizedCache = new PreparedPlanCache(-1000);
- PreparedPlanCache defaultSizedCache = new PreparedPlanCache();
-
- assertEquals(defaultSizedCache.getSpaceAllowed(), negativeSizedCache.getSpaceAllowed());
- assertEquals(PreparedPlanCache.DEFAULT_MAX_SIZE_TOTAL, negativeSizedCache.getSpaceAllowed());
- }
-
- //====Help methods====//
- private void helpCreatePreparedPlans(PreparedPlanCache cache, String token, int start, int count){
- for(int i=start; i<count; i++){
- Command dummy;
- try {
- dummy = QueryParser.getQueryParser().parseCommand(EXAMPLE_QUERY + i);
- } catch (QueryParserException e) {
- throw new RuntimeException(e);
- }
- PreparedPlanCache.PreparedPlan pPlan = cache.createPreparedPlan(token, dummy.toString(), false);
- pPlan.setCommand(dummy);
- pPlan.setPlan(new RelationalPlan(new ProjectNode(i)));
- Map props = new HashMap();
- props.put("desc", "desc"+i); //$NON-NLS-1$ //$NON-NLS-2$
- AnalysisRecord analysisRecord = new AnalysisRecord(true, true, false);
- analysisRecord.setQueryPlan(props);
- pPlan.setAnalysisRecord(analysisRecord);
- ArrayList refs = new ArrayList();
- refs.add("ref"+i); //$NON-NLS-1$
- pPlan.setReferences(refs);
- }
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestPreparedStatement.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestPreparedStatement.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestPreparedStatement.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,339 +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 com.metamatrix.dqp.internal.process;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.api.exception.query.QueryValidatorException;
-import com.metamatrix.common.buffer.BufferManagerFactory;
-import com.metamatrix.dqp.internal.process.TestRequest.FakeApplicationEnvironment;
-import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.TestOptimizer;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.processor.FakeDataManager;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.TestProcessor;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-public class TestPreparedStatement extends TestCase{
-
- private static final long SESSION_ID = 6;
-
- private static boolean DEBUG = false;
-
- static class TestablePreparedPlanCache extends PreparedPlanCache {
-
- int hitCount;
-
- @Override
- public synchronized PreparedPlan getPreparedPlan(
- String clientConn, String sql,
- boolean isPreparedBatchUpdate) {
- PreparedPlan plan = super.getPreparedPlan(clientConn, sql, isPreparedBatchUpdate);
- if (plan != null && plan.getPlan() != null) {
- hitCount++;
- }
- return plan;
- }
- }
-
- public TestPreparedStatement(String name) {
- super(name);
- }
-
- static void helpTestProcessing(String preparedSql, List values, List[] expected, QueryMetadataInterface metadata, boolean callableStatement) throws Exception {
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- helpTestProcessing(preparedSql, values, expected, dataManager, metadata, callableStatement);
- }
-
- static void helpTestProcessing(String preparedSql, List values, List[] expected, ProcessorDataManager dataManager, QueryMetadataInterface metadata, boolean callableStatement) throws Exception {
- TestablePreparedPlanCache prepPlan = new TestablePreparedPlanCache();
- //Create plan
- ProcessorPlan plan = TestPreparedStatement.helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), metadata, prepPlan, SESSION_ID, callableStatement, false);
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
-
- //test cached plan
- plan = TestPreparedStatement.helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), metadata, prepPlan, SESSION_ID, callableStatement, false);
-
- //make sure the plan is only created once
- assertEquals("should reuse the plan", 1, prepPlan.hitCount); //$NON-NLS-1$
-
- // Run query again
- TestProcessor.helpProcess(plan, dataManager, expected);
-
- //get the plan again with a new connection
- assertNotNull(TestPreparedStatement.helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), metadata, prepPlan, 7, callableStatement, false));
-
- assertEquals("new connection should not have used the same plan", 1, prepPlan.hitCount); //$NON-NLS-1$
- }
-
- public void testWhere() throws Exception {
- // Create query
- String preparedSql = "SELECT pm1.g1.e1, e2, pm1.g1.e3 as a, e4 as b FROM pm1.g1 WHERE e2=?"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
- };
-
- List values = new ArrayList();
- values.add(new Short((short)0));
-
- helpTestProcessing(preparedSql, values, expected, FakeMetadataFactory.example1Cached(), false);
- }
-
- public void testFunctionWithReferencePushDown() throws Exception {
- // Create query
- String preparedSql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = pm1.g2.e1 and pm1.g1.e2+2=?"; //$NON-NLS-1$
-
- //Create plan
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_WHERE, true);
- caps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE, true);
- caps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE_GT, true);
- caps.setCapabilitySupport(Capability.QUERY_WHERE_NOT, true);
- caps.setCapabilitySupport(Capability.QUERY_WHERE_IN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setCapabilitySupport(Capability.FUNCTION, true);
- caps.setFunctionSupport("+", false); //$NON-NLS-1$
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- List values = new ArrayList();
- values.add(new Integer(0));
-
- ProcessorPlan plan = helpGetProcessorPlan(preparedSql, values, capFinder, metadata, new PreparedPlanCache(), SESSION_ID, false, false);
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- private ProcessorPlan helpGetProcessorPlan(String preparedSql, List values, PreparedPlanCache prepPlanCache)
- throws MetaMatrixComponentException, QueryParserException,
- QueryResolverException, QueryValidatorException,
- QueryPlannerException {
- return helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), prepPlanCache, SESSION_ID, false, false);
- }
-
- private ProcessorPlan helpGetProcessorPlan(String preparedSql, List values,
- PreparedPlanCache prepPlanCache, long conn)
- throws MetaMatrixComponentException, QueryParserException,
- QueryResolverException, QueryValidatorException,
- QueryPlannerException {
- return helpGetProcessorPlan(preparedSql, values,
- new DefaultCapabilitiesFinder(), FakeMetadataFactory
- .example1Cached(), prepPlanCache, conn, false, false);
- }
-
- static ProcessorPlan helpGetProcessorPlan(String preparedSql, List values,
- CapabilitiesFinder capFinder, QueryMetadataInterface metadata, PreparedPlanCache prepPlanCache, long conn, boolean callableStatement, boolean limitResults)
- throws MetaMatrixComponentException, QueryParserException,
- QueryResolverException, QueryValidatorException,
- QueryPlannerException {
-
- //Create Request
- RequestMessage request = new RequestMessage(preparedSql);
- request.setPreparedStatement(true);
- request.setCallableStatement(callableStatement);
- request.setParameterValues(values);
- if (limitResults) {
- request.setRowLimit(1);
- }
-
- DQPWorkContext workContext = new DQPWorkContext();
- workContext.setVdbName("example1");
- workContext.setVdbVersion("1");
- workContext.setSessionId(new MetaMatrixSessionID(conn));
-
- PreparedStatementRequest serverRequest = new PreparedStatementRequest(prepPlanCache) {
- @Override
- protected void createProcessor()
- throws MetaMatrixComponentException {
- //don't bother
- }
- };
- FakeApplicationEnvironment env = new FakeApplicationEnvironment(metadata, "example1", "1", "pm1", "1", "BINDING");
- serverRequest.initialize(request, env, BufferManagerFactory.getStandaloneBufferManager(), null, new HashMap(), null, DEBUG, null, workContext, 101024);
- serverRequest.setMetadata(capFinder, metadata, null);
- serverRequest.processRequest();
-
- ProcessorPlan plan = serverRequest.processPlan;
- assertNotNull(plan);
- return plan;
- }
-
- public void testValidateCorrectValues() throws Exception {
- // Create query
- String preparedSql = "SELECT pm1.g1.e1, e2, pm1.g1.e3 as a, e4 as b FROM pm1.g1 WHERE pm1.g1.e1=?"; //$NON-NLS-1$
-
- List values = new ArrayList();
- values.add("a"); //$NON-NLS-1$
-
- //Create plan
- helpGetProcessorPlan(preparedSql, values, new PreparedPlanCache());
- }
-
- /** SELECT pm1.g1.e1 FROM pm1.g1 WHERE pm1.g1.e2 IN (SELECT pm1.g2.e2 FROM pm1.g2 WHERE pm1.g2.e1 = ?)*/
- public void testWithSubquery() throws Exception {
- // Create query
- String preparedSql = "SELECT pm1.g1.e1 FROM pm1.g1 WHERE pm1.g1.e2 IN (SELECT pm1.g2.e2 FROM pm1.g2 WHERE pm1.g2.e1 = ?)"; //$NON-NLS-1$
-
- List values = new ArrayList();
- values.add("a"); //$NON-NLS-1$
-
- //Create plan
- helpGetProcessorPlan(preparedSql, values, new PreparedPlanCache());
- }
-
- /** SELECT pm1.g1.e1 FROM pm1.g1 WHERE pm1.g1.e1 = ? AND pm1.g1.e2 IN (SELECT pm1.g2.e2 FROM pm1.g2 WHERE pm1.g2.e1 = ?) */
- public void testWithSubquery2() throws Exception {
- // Create query
- String preparedSql = "SELECT pm1.g1.e1 FROM pm1.g1 WHERE pm1.g1.e1 = ? AND pm1.g1.e2 IN (SELECT pm1.g2.e2 FROM pm1.g2 WHERE pm1.g2.e1 = ?)"; //$NON-NLS-1$
-
- List values = new ArrayList();
- values.add("d"); //$NON-NLS-1$
- values.add("c"); //$NON-NLS-1$
-
- //Create plan
- helpGetProcessorPlan(preparedSql, values, new PreparedPlanCache());
- }
-
- /** SELECT X.e1 FROM (SELECT pm1.g2.e1 FROM pm1.g2 WHERE pm1.g2.e1 = ?) as X */
- public void testWithSubquery3() throws Exception {
- // Create query
- String preparedSql = "SELECT X.e1 FROM (SELECT pm1.g2.e1 FROM pm1.g2 WHERE pm1.g2.e1 = ?) as X"; //$NON-NLS-1$
-
- //Create Request
- List values = new ArrayList();
- values.add("d"); //$NON-NLS-1$
-
- //Create plan
- helpGetProcessorPlan(preparedSql, values, new PreparedPlanCache());
- }
-
- public void testValidateWrongValues() throws Exception {
- // Create query
- String preparedSql = "SELECT pm1.g1.e1, e2, pm1.g1.e3 as a, e4 as b FROM pm1.g1 WHERE pm1.g1.e2=?"; //$NON-NLS-1$
- TestablePreparedPlanCache prepCache = new TestablePreparedPlanCache();
-
- //wrong type
- try{
- List values = new ArrayList();
- values.add("x"); //$NON-NLS-1$
-
- //Create plan
- helpGetProcessorPlan(preparedSql, values, prepCache, SESSION_ID);
- fail();
- }catch(QueryResolverException qe){
- assertEquals("Error converting parameter number 1 with value \"x\" to expected type integer.", qe.getMessage()); //$NON-NLS-1$
- }
- assertEquals(0, prepCache.hitCount);
-
- //test cached plan
- try{
- List values = new ArrayList();
- values.add("a"); //$NON-NLS-1$
- values.add("b"); //$NON-NLS-1$
- helpGetProcessorPlan(preparedSql, values, prepCache, SESSION_ID);
- fail();
- }catch(QueryResolverException qe){
- assertEquals("The number of bound values '2' does not match the number of parameters '1' in the prepared statement.", qe.getMessage()); //$NON-NLS-1$
- }
-
- assertEquals(1, prepCache.hitCount);
-
- //wrong number of values
- try{
- List values = new ArrayList();
- values.add("a"); //$NON-NLS-1$
- values.add(new Integer(0));
- helpGetProcessorPlan(preparedSql, values, prepCache);
- fail();
- }catch(QueryResolverException qe){
- assertEquals("The number of bound values '2' does not match the number of parameters '1' in the prepared statement.", qe.getMessage()); //$NON-NLS-1$
- }
-
- }
-
- public void testResolveParameterValues() throws Exception {
- // Create query
- String preparedSql = "SELECT pm1.g1.e1, e2, pm1.g1.e3 as a, e4 as b FROM pm1.g1 WHERE pm1.g1.e2=?"; //$NON-NLS-1$
-
- List values = new ArrayList();
- //values.add("a");
- values.add("0"); //$NON-NLS-1$
-
- helpGetProcessorPlan(preparedSql, values, new PreparedPlanCache());
- }
-
- /**
- * TODO: there may be other ways of handling this situation in the future
- */
- public void testLimitNoCache() throws Exception {
- // Create query
- String preparedSql = "SELECT pm1.g1.e1, e2, pm1.g1.e3 as a, e4 as b FROM pm1.g1 WHERE pm1.g1.e2=?"; //$NON-NLS-1$
-
- List values = new ArrayList();
- values.add("0"); //$NON-NLS-1$
-
- TestablePreparedPlanCache planCache = new TestablePreparedPlanCache();
-
- helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), planCache, SESSION_ID, false, true);
-
- helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), planCache, SESSION_ID, false, true);
- //make sure the plan wasn't reused
- assertEquals(0, planCache.hitCount);
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestRequest.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestRequest.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestRequest.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,284 +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 com.metamatrix.dqp.internal.process;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.mockito.Mockito;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.api.exception.query.QueryValidatorException;
-import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.common.application.ApplicationService;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.vdb.api.ModelInfo;
-import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.dqp.service.AutoGenDataService;
-import com.metamatrix.dqp.service.DQPServiceNames;
-import com.metamatrix.dqp.service.FakeAbstractService;
-import com.metamatrix.dqp.service.FakeAuthorizationService;
-import com.metamatrix.dqp.service.FakeVDBService;
-import com.metamatrix.dqp.service.MetadataService;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.processor.FakeDataManager;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
-import com.metamatrix.query.util.ContextProperties;
-
-
-/**
- * @since 4.2
- */
-public class TestRequest extends TestCase {
-
- private final static String QUERY = "SELECT * FROM pm1.g1"; //$NON-NLS-1$
- private final static String VDB = "VDB"; //$NON-NLS-1$
- private final static String VDB_VERSION = "1"; //$NON-NLS-1$
- private final static String MODEL = "pm1"; //$NON-NLS-1$
- private final static String BINDING_ID = "1"; //$NON-NLS-1$
- private final static String BINDING_NAME = "BINDING"; //$NON-NLS-1$
-
- /**
- * Constructor for TestRequest.
- * @param name
- */
- public TestRequest(String name) {
- super(name);
- }
-
- public void testGetSchemasForValidation() throws Exception {
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
- FakeMetadataObject doc1 = metadata.getStore().findObject("xmltest.doc1", FakeMetadataObject.GROUP); //$NON-NLS-1$
- List<String> schemas = Arrays.asList("a.xsd", "b.xsd"); //$NON-NLS-1$ //$NON-NLS-2$
- doc1.putProperty(FakeMetadataObject.Props.XML_SCHEMAS, schemas);
- RequestMessage message = new RequestMessage("select * from xmltest.doc1"); //$NON-NLS-1$
- message.setValidationMode(true);
- DQPWorkContext workContext = new DQPWorkContext();
- workContext.setVdbName(VDB);
- workContext.setVdbVersion(VDB_VERSION);
- workContext.setSessionId(new MetaMatrixSessionID(5));
- FakeApplicationEnvironment environment =
- new FakeApplicationEnvironment(metadata, VDB, VDB_VERSION, MODEL, BINDING_ID, BINDING_NAME);
- Request request = helpProcessMessage(environment, message, null, workContext);
- assertEquals(schemas, request.schemas);
- }
-
-
- /**
- * Test Request.validateEntitlement().
- * Make sure that this can be called both before and after metadata is initialized.
- * See defect 17209.
- * @throws Exception
- * @since 4.2
- */
- public void testValidateEntitlement() throws Exception {
- QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
-
-
- Request request = new Request();
- Command command = QueryParser.getQueryParser().parseCommand(QUERY);
- QueryResolver.resolveCommand(command, Collections.EMPTY_MAP, true, metadata, AnalysisRecord.createNonRecordingRecord());
-
- RequestMessage message = new RequestMessage();
- DQPWorkContext workContext = new DQPWorkContext();
- workContext.setVdbName(VDB);
- workContext.setVdbVersion(VDB_VERSION);
- workContext.setSessionId(new MetaMatrixSessionID(5));
- 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.initMetadata();
- request.validateEntitlement(command);
- }
-
-
- /**
- * Test Request.processRequest().
- * Test processing the same query twice, and make sure that doesn't cause problems.
- * See defect 17209.
- * @throws Exception
- * @since 4.2
- */
- public void testProcessRequest() throws Exception {
- QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
-
- FakeApplicationEnvironment environment =
- new FakeApplicationEnvironment(metadata, VDB, VDB_VERSION, MODEL, BINDING_ID, BINDING_NAME);
-
-
- //Try before plan is cached.
- //If this doesn't throw an exception, assume it was successful.
- RequestMessage message = new RequestMessage(QUERY);
- DQPWorkContext workContext = new DQPWorkContext();
- workContext.setVdbName(VDB);
- workContext.setVdbVersion(VDB_VERSION);
- workContext.setSessionId(new MetaMatrixSessionID(5));
-
- helpProcessMessage(environment, message, null, workContext);
-
- //Try again, now that plan is already cached.
- //If this doesn't throw an exception, assume it was successful.
- message = new RequestMessage(QUERY);
- helpProcessMessage(environment, message, null, workContext);
- }
-
- public void testCommandContext() throws Exception {
- QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
-
- FakeApplicationEnvironment environment =
- new FakeApplicationEnvironment(metadata, VDB, VDB_VERSION, MODEL, BINDING_ID, BINDING_NAME);
-
-
- //Try before plan is cached.
- //If this doesn't throw an exception, assume it was successful.
- RequestMessage message = new RequestMessage(QUERY);
- DQPWorkContext workContext = new DQPWorkContext();
- workContext.setVdbName(VDB);
- workContext.setVdbVersion(VDB_VERSION);
- workContext.setSessionId(new MetaMatrixSessionID(5));
- Request request = helpProcessMessage(environment, message, null, workContext);
- assertEquals("00000000-0000-0005-0000-000000000005", request.context.getEnvironmentProperties().get(ContextProperties.SESSION_ID));
- }
-
- private Request helpProcessMessage(FakeApplicationEnvironment environment,
- RequestMessage message, PreparedPlanCache cache, DQPWorkContext workContext) throws QueryValidatorException,
- QueryParserException,
- QueryResolverException,
- MetaMatrixComponentException,
- QueryPlannerException {
- Request request = null;
- if (cache != null) {
- request = new PreparedStatementRequest(cache);
- } else {
- request = new Request();
- }
- request.initialize(message, environment, Mockito.mock(BufferManager.class),
- new FakeDataManager(), new HashMap(), null, false, null,
- workContext, 101024);
-
- request.processRequest();
- return request;
- }
-
-
-
-
- /**
- * Test PreparedStatementRequest.processRequest().
- * Test processing the same query twice, and make sure that doesn't cause problems.
- * @throws Exception
- * @since 4.2
- */
- public void testProcessRequestPreparedStatement() throws Exception {
- QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
- PreparedPlanCache cache = new PreparedPlanCache();
- FakeApplicationEnvironment environment =
- new FakeApplicationEnvironment(metadata, VDB, VDB_VERSION, MODEL, BINDING_ID, BINDING_NAME);
-
-
- //Try before plan is cached.
- //If this doesn't throw an exception, assume it was successful.
- RequestMessage message = new RequestMessage(QUERY);
- DQPWorkContext workContext = new DQPWorkContext();
- workContext.setVdbName(VDB);
- workContext.setVdbVersion(VDB_VERSION);
- workContext.setSessionId(new MetaMatrixSessionID(5));
- message.setPreparedStatement(true);
- message.setParameterValues(new ArrayList());
-
- helpProcessMessage(environment, message, cache, workContext);
-
- //Try again, now that plan is already cached.
- //If this doesn't throw an exception, assume it was successful.
- message = new RequestMessage(QUERY);
- message.setPreparedStatement(true);
- message.setParameterValues(new ArrayList());
-
- helpProcessMessage(environment, message, cache, workContext);
- }
-
-
- /**Fake ApplicationEnvironment that always returns the same metadata*/
- public static final class FakeApplicationEnvironment extends ApplicationEnvironment {
- private QueryMetadataInterface metadata;
-
- private FakeVDBService fakeVDBService;
-
- public FakeApplicationEnvironment(QueryMetadataInterface metadata, String vdbname, String version, String model,
- String bindingID, String bindingName) {
- this.metadata = metadata;
-
- fakeVDBService = new FakeVDBService();
- fakeVDBService.addModel(vdbname, version, model, ModelInfo.PUBLIC, false);
- fakeVDBService.addBinding(vdbname, version, model, bindingID, bindingName);
- }
-
- public ApplicationService findService(String type) {
- if (type == DQPServiceNames.METADATA_SERVICE) {
- return new FakeMetadataService(metadata);
- } else if (type == DQPServiceNames.VDB_SERVICE) {
- return fakeVDBService;
- } else if (type == DQPServiceNames.DATA_SERVICE) {
- return new AutoGenDataService();
- } else if (type == DQPServiceNames.AUTHORIZATION_SERVICE) {
- return new FakeAuthorizationService(true);
- }
-
- return null;
- }
- }
-
- /**Fake MetadataService that always returns the same metadata*/
- public static final class FakeMetadataService extends FakeAbstractService implements MetadataService {
- private QueryMetadataInterface metadata;
-
-
- public FakeMetadataService(QueryMetadataInterface metadata) {
- this.metadata = metadata;
- }
-
- public synchronized void addVdb() {
- }
-
- public synchronized QueryMetadataInterface lookupMetadata(String vdbName, String vdbVersion) {
- return metadata;
- }
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestRequestWorkItem.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestRequestWorkItem.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestRequestWorkItem.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,43 +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 com.metamatrix.dqp.internal.process;
-
-import java.util.Arrays;
-import java.util.List;
-
-import com.metamatrix.dqp.message.ResultsMessage;
-import com.metamatrix.dqp.message.TestRequestMessage;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-
-import junit.framework.TestCase;
-
-public class TestRequestWorkItem extends TestCase {
-
- public void testResultsMetadata() {
- ElementSymbol e1 = new ElementSymbol("g1.E1"); //name in metadata
- e1.setOutputName("G1.e1"); //name in query
- ResultsMessage message = RequestWorkItem.createResultsMessage(TestRequestMessage.example(), new List[] {}, Arrays.asList(e1), null);
- assertEquals(Arrays.asList("e1"), Arrays.asList(message.getColumnNames()));
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestWorkItemState.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestWorkItemState.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestWorkItemState.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -1,157 +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 com.metamatrix.dqp.internal.process;
-
-import junit.framework.TestCase;
-
-public class TestWorkItemState extends TestCase {
-
- private class TestWorkItem extends AbstractWorkItem {
-
- private boolean isDone;
- private boolean callMoreWork;
- private boolean resumed;
-
- private TestWorkItem() {
- this(false, false);
- }
-
- private TestWorkItem(boolean done, boolean callMoreWork) {
- this.isDone = done;
- this.callMoreWork = callMoreWork;
- }
-
- @Override
- protected boolean isDoneProcessing() {
- return isDone;
- }
-
- @Override
- protected void process() {
- assertWorkingState();
- if (callMoreWork) {
- this.moreWork();
- }
- }
-
- @Override
- protected void resumeProcessing() {
- this.resumed = true;
- }
-
- @Override
- public String toString() {
- return "TestItem"; //$NON-NLS-1$
- }
-
- private void checkState(ThreadState expectedState) {
- assertEquals(expectedState, getThreadState());
- }
-
- private void assertIdleState() {
- checkState(ThreadState.IDLE);
- }
-
- private void assertMoreWorkState() {
- checkState(ThreadState.MORE_WORK);
- }
-
- private void assertWorkingState() {
- checkState(ThreadState.WORKING);
- }
-
- private void assertDoneState() {
- checkState(ThreadState.DONE);
- }
-
- }
-
- public TestWorkItemState(String name) {
- super(name);
- }
-
- public void testInitialState() {
- TestWorkItem item = new TestWorkItem();
- item.assertMoreWorkState();
- }
-
- public void testGotoIdleState() {
- TestWorkItem item = new TestWorkItem();
- item.run();
- item.assertIdleState();
- }
-
- public void testGotoMoreWorkState() {
- TestWorkItem item = new TestWorkItem();
- item.run();
- item.moreWork();
- item.assertMoreWorkState();
- }
-
- public void testGotoWorkingState() {
- TestWorkItem item = new TestWorkItem();
- item.run();
- item.moreWork();
- item.run();
- }
-
- public void testResume() {
- TestWorkItem item = new TestWorkItem();
- item.run();
- assertFalse(item.resumed);
- item.moreWork();
- assertTrue(item.resumed);
- }
-
- public void testResumeDuringWorking() {
- TestWorkItem item = new TestWorkItem(false, true);
- assertFalse(item.resumed);
- item.run();
- assertTrue(item.resumed);
- }
-
- public void testRunAfterDone() {
- TestWorkItem item = new TestWorkItem(true, false);
- item.run();
- item.assertDoneState();
- try {
- item.run();
- fail("exception expected"); //$NON-NLS-1$
- } catch (IllegalStateException e) {
-
- }
- }
-
- public void testRunDuringIdle() {
- TestWorkItem item = new TestWorkItem();
- item.run();
- item.assertIdleState();
- try {
- item.run();
- fail("exception expected"); //$NON-NLS-1$
- } catch (IllegalStateException e) {
-
- }
- }
-
-}
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -24,12 +24,13 @@
import java.util.Date;
+import org.teiid.dqp.internal.datamgr.language.TestQueryImpl;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+
import junit.framework.TestCase;
import com.metamatrix.core.util.UnitTestUtil;
import com.metamatrix.dqp.internal.datamgr.ConnectorID;
-import com.metamatrix.dqp.internal.datamgr.language.TestQueryImpl;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
public class TestAtomicRequestMessage extends TestCase {
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/service/AutoGenDataService.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/service/AutoGenDataService.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/service/AutoGenDataService.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -29,14 +29,15 @@
import java.util.Iterator;
import java.util.List;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorWorkItem;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.application.exception.ApplicationLifecycleException;
import com.metamatrix.common.comm.api.ResultsReceiver;
import com.metamatrix.common.config.api.ConnectorBinding;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.dqp.internal.datamgr.ConnectorID;
-import com.metamatrix.dqp.internal.datamgr.impl.ConnectorWorkItem;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.dqp.message.AtomicRequestID;
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.message.AtomicResultsMessage;
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/service/TestCustomizableTrackingService.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/service/TestCustomizableTrackingService.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/service/TestCustomizableTrackingService.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -35,6 +35,9 @@
import junit.framework.TestCase;
import org.teiid.connector.api.ExecutionContext;
+import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
+import org.teiid.dqp.internal.process.DQPCore;
+import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.application.ApplicationEnvironment;
@@ -42,9 +45,6 @@
import com.metamatrix.common.application.exception.ApplicationInitializationException;
import com.metamatrix.common.application.exception.ApplicationLifecycleException;
import com.metamatrix.common.vdb.api.ModelInfo;
-import com.metamatrix.dqp.internal.datamgr.impl.FakeTransactionService;
-import com.metamatrix.dqp.internal.process.DQPCore;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.dqp.message.ResultsMessage;
import com.metamatrix.dqp.spi.CommandLoggerSPI;
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/HardcodedDataManager.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/HardcodedDataManager.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/HardcodedDataManager.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -29,10 +29,11 @@
import java.util.Map;
import java.util.Set;
+import org.teiid.dqp.internal.process.DataTierManager;
+
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.buffer.BlockedException;
import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.dqp.internal.process.DataTierManager;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.util.CommandContext;
Modified: trunk/engine/src/test/java/com/metamatrix/query/unittest/QueryMetadataInterfaceBuilder.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/unittest/QueryMetadataInterfaceBuilder.java 2009-03-18 20:09:39 UTC (rev 590)
+++ trunk/engine/src/test/java/com/metamatrix/query/unittest/QueryMetadataInterfaceBuilder.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -29,10 +29,10 @@
import java.util.List;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
+import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
import com.metamatrix.dqp.message.ParameterInfo;
import com.metamatrix.query.metadata.QueryMetadataInterface;
Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/cache (from rev 569, trunk/engine/src/test/java/com/metamatrix/dqp/internal/cache)
Property changes on: trunk/engine/src/test/java/org/teiid/dqp/internal/cache
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestCacheID.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/cache/TestCacheID.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestCacheID.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,11 +20,13 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.cache;
+package org.teiid.dqp.internal.cache;
import java.util.ArrayList;
import java.util.List;
+import org.teiid.dqp.internal.cache.CacheID;
+
import junit.framework.TestCase;
public class TestCacheID extends TestCase{
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestCursorReceiverWindowBuffer.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/cache/TestCursorReceiverWindowBuffer.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestCursorReceiverWindowBuffer.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,10 +20,13 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.cache;
+package org.teiid.dqp.internal.cache;
import java.util.ArrayList;
import java.util.List;
+
+import org.teiid.dqp.internal.cache.CursorReceiverWindowBuffer;
+
import junit.framework.TestCase;
import com.metamatrix.common.util.Intervals;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestResultSetCache.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/cache/TestResultSetCache.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestResultSetCache.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,12 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.cache;
+package org.teiid.dqp.internal.cache;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
+import org.teiid.dqp.internal.cache.CacheID;
+import org.teiid.dqp.internal.cache.CacheResults;
+import org.teiid.dqp.internal.cache.ResultSetCache;
+
import junit.framework.TestCase;
import com.metamatrix.cache.FakeCache.FakeCacheFactory;
Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl (from rev 569, trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl)
Property changes on: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeConnector.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl/FakeConnector.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeConnector.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.impl;
+package org.teiid.dqp.internal.datamgr.impl;
import java.util.Arrays;
import java.util.List;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeExecutionContextImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl/FakeExecutionContextImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeExecutionContextImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,10 +20,12 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.impl;
+package org.teiid.dqp.internal.datamgr.impl;
import java.util.concurrent.atomic.AtomicInteger;
+import org.teiid.dqp.internal.datamgr.impl.ExecutionContextImpl;
+
/**
*/
public class FakeExecutionContextImpl extends ExecutionContextImpl {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeProcedureExecution.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl/FakeProcedureExecution.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeProcedureExecution.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.impl;
+package org.teiid.dqp.internal.datamgr.impl;
import java.util.ArrayList;
import java.util.Arrays;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeTransactionService.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl/FakeTransactionService.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeTransactionService.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,17 +20,18 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.impl;
+package org.teiid.dqp.internal.datamgr.impl;
import java.util.Properties;
+import org.teiid.dqp.internal.transaction.TransactionProvider;
+import org.teiid.dqp.internal.transaction.TransactionServerImpl;
+
import com.metamatrix.common.application.ApplicationEnvironment;
import com.metamatrix.common.application.exception.ApplicationInitializationException;
import com.metamatrix.common.application.exception.ApplicationLifecycleException;
import com.metamatrix.common.xa.XATransactionException;
import com.metamatrix.core.util.SimpleMock;
-import com.metamatrix.dqp.internal.transaction.TransactionProvider;
-import com.metamatrix.dqp.internal.transaction.TransactionServerImpl;
import com.metamatrix.dqp.service.TransactionService;
import com.metamatrix.dqp.transaction.TransactionServer;
import com.metamatrix.dqp.transaction.XAServer;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -24,7 +24,7 @@
* Date: Sep 17, 2003
* Time: 5:36:02 PM
*/
-package com.metamatrix.dqp.internal.datamgr.impl;
+package org.teiid.dqp.internal.datamgr.impl;
import java.net.URL;
import java.net.URLClassLoader;
@@ -35,12 +35,13 @@
import org.mockito.Mockito;
import org.teiid.connector.internal.ConnectorPropertyNames;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.impl.TestConnectorWorkItem.QueueResultsReceiver;
+import org.teiid.dqp.internal.pooling.connector.FakeSourceConnectionFactory;
+import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.common.application.ApplicationEnvironment;
import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-import com.metamatrix.dqp.internal.datamgr.impl.TestConnectorWorkItem.QueueResultsReceiver;
-import com.metamatrix.dqp.internal.pooling.connector.FakeSourceConnectionFactory;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.service.DQPServiceNames;
import com.metamatrix.dqp.service.FakeMetadataService;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorStateManager.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl/TestConnectorStateManager.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorStateManager.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -24,7 +24,7 @@
* Date: Sep 17, 2003
* Time: 3:48:54 PM
*/
-package com.metamatrix.dqp.internal.datamgr.impl;
+package org.teiid.dqp.internal.datamgr.impl;
import java.util.ArrayList;
import java.util.List;
@@ -32,6 +32,9 @@
import java.util.concurrent.TimeUnit;
import org.mockito.Mockito;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorWorkItem;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorWrapper;
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl/TestConnectorWorkItem.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.impl;
+package org.teiid.dqp.internal.datamgr.impl;
import java.util.Arrays;
import java.util.List;
@@ -37,13 +37,19 @@
import org.teiid.connector.internal.ConnectorPropertyNames;
import org.teiid.connector.language.IProcedure;
import org.teiid.connector.xa.api.TransactionContext;
+import org.teiid.dqp.internal.datamgr.impl.AsynchConnectorWorkItem;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorWorkItem;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorWrapper;
+import org.teiid.dqp.internal.datamgr.impl.ProcedureBatchHandler;
+import org.teiid.dqp.internal.datamgr.impl.SynchConnectorWorkItem;
+import org.teiid.dqp.internal.datamgr.language.LanguageBridgeFactory;
+import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.common.comm.api.ResultsReceiver;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.dqp.client.ResultsFuture;
import com.metamatrix.dqp.internal.datamgr.ConnectorID;
-import com.metamatrix.dqp.internal.datamgr.language.LanguageBridgeFactory;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.message.AtomicResultsMessage;
import com.metamatrix.dqp.message.RequestID;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestExecutionContextImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl/TestExecutionContextImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestExecutionContextImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,8 +20,10 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.impl;
+package org.teiid.dqp.internal.datamgr.impl;
+import org.teiid.dqp.internal.datamgr.impl.ExecutionContextImpl;
+
import com.metamatrix.core.util.UnitTestUtil;
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestTypeFacilityImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl/TestTypeFacilityImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestTypeFacilityImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,10 +20,12 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.impl;
+package org.teiid.dqp.internal.datamgr.impl;
import java.sql.Clob;
+import org.teiid.dqp.internal.datamgr.impl.TypeFacilityImpl;
+
import junit.framework.TestCase;
public class TestTypeFacilityImpl extends TestCase {
Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language (from rev 569, trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language)
Property changes on: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestAggregateImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestAggregateImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestAggregateImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,9 +20,11 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import org.teiid.connector.language.IAggregate;
+import org.teiid.dqp.internal.datamgr.language.AggregateImpl;
+import org.teiid.dqp.internal.datamgr.language.LiteralImpl;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.query.sql.ReservedWords;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestBatchedUpdatesImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestBatchedUpdatesImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestBatchedUpdatesImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.ArrayList;
import java.util.List;
@@ -28,6 +28,7 @@
import org.teiid.connector.language.IDelete;
import org.teiid.connector.language.IInsert;
import org.teiid.connector.language.IUpdate;
+import org.teiid.dqp.internal.datamgr.language.BatchedUpdatesImpl;
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestBulkInsertImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestBulkInsertImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestBulkInsertImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,12 +20,13 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.ArrayList;
import java.util.Iterator;
import org.teiid.connector.language.IElement;
+import org.teiid.dqp.internal.datamgr.language.BulkInsertImpl;
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompareCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestCompareCriteriaImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompareCriteriaImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,9 +20,11 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import org.teiid.connector.language.ICompareCriteria.Operator;
+import org.teiid.dqp.internal.datamgr.language.CompareCriteriaImpl;
+import org.teiid.dqp.internal.datamgr.language.LiteralImpl;
import com.metamatrix.query.sql.lang.CompareCriteria;
import com.metamatrix.query.sql.symbol.Constant;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompoundCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestCompoundCriteriaImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompoundCriteriaImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,12 +20,13 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.Iterator;
import org.teiid.connector.language.ICriteria;
import org.teiid.connector.language.ICompoundCriteria.Operator;
+import org.teiid.dqp.internal.datamgr.language.CompoundCriteriaImpl;
import com.metamatrix.query.sql.lang.CompareCriteria;
import com.metamatrix.query.sql.lang.CompoundCriteria;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestDeleteImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestDeleteImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestDeleteImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,8 +20,10 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
+import org.teiid.dqp.internal.datamgr.language.DeleteImpl;
+
import com.metamatrix.query.sql.lang.CompoundCriteria;
import com.metamatrix.query.sql.lang.Delete;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestElementImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestElementImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestElementImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,16 +20,18 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import org.teiid.connector.language.IElement;
import org.teiid.connector.language.IGroup;
import org.teiid.connector.metadata.runtime.Element;
+import org.teiid.dqp.internal.datamgr.language.ElementImpl;
+import org.teiid.dqp.internal.datamgr.language.GroupImpl;
+import org.teiid.dqp.internal.datamgr.metadata.TestMetadataFactory;
import junit.framework.TestCase;
import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.dqp.internal.datamgr.metadata.TestMetadataFactory;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.unittest.FakeMetadataObject;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestExistsCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestExistsCriteriaImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestExistsCriteriaImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,8 +20,10 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
+import org.teiid.dqp.internal.datamgr.language.ExistsCriteriaImpl;
+
import com.metamatrix.query.sql.lang.ExistsCriteria;
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFromImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestFromImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFromImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,13 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.teiid.connector.language.IFromItem;
+import org.teiid.dqp.internal.datamgr.language.FromImpl;
import com.metamatrix.query.sql.lang.From;
import com.metamatrix.query.sql.lang.UnaryFromClause;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFunctionImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestFunctionImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFunctionImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,11 +20,12 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.List;
import org.teiid.connector.language.IExpression;
+import org.teiid.dqp.internal.datamgr.language.FunctionImpl;
import com.metamatrix.query.sql.symbol.Constant;
import com.metamatrix.query.sql.symbol.Expression;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupByImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestGroupByImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupByImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,13 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.teiid.connector.language.IElement;
+import org.teiid.dqp.internal.datamgr.language.GroupByImpl;
import com.metamatrix.query.sql.lang.GroupBy;
import com.metamatrix.query.sql.symbol.ElementSymbol;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestGroupImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,8 +20,10 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
+import org.teiid.dqp.internal.datamgr.language.GroupImpl;
+
import junit.framework.TestCase;
import com.metamatrix.query.sql.symbol.GroupSymbol;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestInCriteriaImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInCriteriaImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.ArrayList;
import java.util.Iterator;
@@ -28,6 +28,7 @@
import org.teiid.connector.language.IExpression;
import org.teiid.connector.language.ILiteral;
+import org.teiid.dqp.internal.datamgr.language.InCriteriaImpl;
import com.metamatrix.query.sql.lang.SetCriteria;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInlineViewImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestInlineViewImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInlineViewImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,8 +20,10 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
+import org.teiid.dqp.internal.datamgr.language.InlineViewImpl;
+
import com.metamatrix.query.sql.lang.SubqueryFromClause;
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInsertImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestInsertImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInsertImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,13 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.ArrayList;
import java.util.Iterator;
import org.teiid.connector.language.IElement;
import org.teiid.connector.language.IExpression;
+import org.teiid.dqp.internal.datamgr.language.InsertImpl;
import com.metamatrix.query.sql.lang.Insert;
import com.metamatrix.query.sql.symbol.GroupSymbol;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestIsNullCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestIsNullCriteriaImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestIsNullCriteriaImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,8 +20,10 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
+import org.teiid.dqp.internal.datamgr.language.IsNullCriteriaImpl;
+
import com.metamatrix.query.sql.lang.IsNullCriteria;
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestJoinImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestJoinImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestJoinImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,12 +20,13 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.ArrayList;
import java.util.Iterator;
import org.teiid.connector.language.ICriteria;
+import org.teiid.dqp.internal.datamgr.language.JoinImpl;
import com.metamatrix.query.sql.lang.CompareCriteria;
import com.metamatrix.query.sql.lang.JoinPredicate;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLikeCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestLikeCriteriaImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLikeCriteriaImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,9 +20,10 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import org.teiid.connector.language.ILiteral;
+import org.teiid.dqp.internal.datamgr.language.LikeCriteriaImpl;
import com.metamatrix.query.sql.lang.MatchCriteria;
import com.metamatrix.query.sql.symbol.Constant;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLiteralImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestLiteralImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLiteralImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,8 +20,10 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
+import org.teiid.dqp.internal.datamgr.language.LiteralImpl;
+
import com.metamatrix.query.sql.symbol.Constant;
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestNotCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestNotCriteriaImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestNotCriteriaImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,8 +20,10 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
+import org.teiid.dqp.internal.datamgr.language.NotCriteriaImpl;
+
import com.metamatrix.query.sql.lang.CompareCriteria;
import com.metamatrix.query.sql.lang.NotCriteria;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestOrderByImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestOrderByImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestOrderByImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,13 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.teiid.connector.language.IOrderByItem;
+import org.teiid.dqp.internal.datamgr.language.OrderByImpl;
import com.metamatrix.query.sql.lang.OrderBy;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestParameterImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestParameterImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestParameterImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,11 +20,13 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.sql.ResultSet;
import org.teiid.connector.language.IParameter.Direction;
+import org.teiid.dqp.internal.datamgr.language.ParameterImpl;
+import org.teiid.dqp.internal.datamgr.language.ProcedureImpl;
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestProcedureImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestProcedureImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestProcedureImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,12 +20,13 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.Collections;
import java.util.Iterator;
import org.teiid.connector.language.IParameter;
+import org.teiid.dqp.internal.datamgr.language.ProcedureImpl;
import com.metamatrix.query.parser.QueryParser;
import com.metamatrix.query.resolver.QueryResolver;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestQueryImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestQueryImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestQueryImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,8 +20,10 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
+import org.teiid.dqp.internal.datamgr.language.QueryImpl;
+
import com.metamatrix.core.util.EquivalenceUtil;
import com.metamatrix.query.sql.lang.CompoundCriteria;
import com.metamatrix.query.sql.lang.Query;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestScalarSubqueryImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestScalarSubqueryImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestScalarSubqueryImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,10 +20,11 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import org.teiid.connector.language.IQuery;
import org.teiid.connector.language.ISelectSymbol;
+import org.teiid.dqp.internal.datamgr.language.ScalarSubqueryImpl;
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSearchedCaseExpressionImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestSearchedCaseExpressionImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSearchedCaseExpressionImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,11 +20,13 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.ArrayList;
import java.util.List;
+import org.teiid.dqp.internal.datamgr.language.SearchedCaseExpressionImpl;
+
import com.metamatrix.query.sql.lang.CompareCriteria;
import com.metamatrix.query.sql.symbol.Constant;
import com.metamatrix.query.sql.symbol.ElementSymbol;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestSelectImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,13 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.teiid.connector.language.ISelectSymbol;
+import org.teiid.dqp.internal.datamgr.language.SelectImpl;
import com.metamatrix.query.sql.lang.Select;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectSymbolImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestSelectSymbolImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectSymbolImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,9 +20,10 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import org.teiid.connector.language.IExpression;
+import org.teiid.dqp.internal.datamgr.language.SelectSymbolImpl;
import com.metamatrix.query.sql.symbol.*;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSetQueryImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestSetQueryImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSetQueryImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.ArrayList;
import java.util.List;
@@ -31,6 +31,15 @@
import org.teiid.connector.language.IQuery;
import org.teiid.connector.language.ISelectSymbol;
import org.teiid.connector.language.ISetQuery;
+import org.teiid.dqp.internal.datamgr.language.ElementImpl;
+import org.teiid.dqp.internal.datamgr.language.FromImpl;
+import org.teiid.dqp.internal.datamgr.language.GroupImpl;
+import org.teiid.dqp.internal.datamgr.language.OrderByImpl;
+import org.teiid.dqp.internal.datamgr.language.OrderByItemImpl;
+import org.teiid.dqp.internal.datamgr.language.QueryImpl;
+import org.teiid.dqp.internal.datamgr.language.SelectImpl;
+import org.teiid.dqp.internal.datamgr.language.SelectSymbolImpl;
+import org.teiid.dqp.internal.datamgr.language.SetQueryImpl;
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryCompareCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestSubqueryCompareCriteriaImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryCompareCriteriaImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,10 +20,11 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import org.teiid.connector.language.ICompareCriteria;
import org.teiid.connector.language.ISubqueryCompareCriteria.Quantifier;
+import org.teiid.dqp.internal.datamgr.language.SubqueryCompareCriteriaImpl;
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryInCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestSubqueryInCriteriaImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryInCriteriaImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,8 +20,10 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
+import org.teiid.dqp.internal.datamgr.language.SubqueryInCriteriaImpl;
+
import junit.framework.TestCase;
import com.metamatrix.query.sql.lang.Query;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestUpdateImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestUpdateImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestUpdateImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,10 +20,12 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
import java.util.List;
+import org.teiid.dqp.internal.datamgr.language.UpdateImpl;
+
import junit.framework.TestCase;
import com.metamatrix.query.sql.lang.CompareCriteria;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TstLanguageBridgeFactory.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TstLanguageBridgeFactory.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TstLanguageBridgeFactory.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,9 +20,11 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.datamgr.language;
+package org.teiid.dqp.internal.datamgr.language;
-import com.metamatrix.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
+import org.teiid.dqp.internal.datamgr.language.LanguageBridgeFactory;
+import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
+
import com.metamatrix.query.unittest.FakeMetadataFacade;
import com.metamatrix.query.unittest.FakeMetadataFactory;
Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/metadata (from rev 569, trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/metadata)
Property changes on: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/metadata
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/metadata/TestMetadataFactory.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/metadata/TestMetadataFactory.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/metadata/TestMetadataFactory.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -22,11 +22,15 @@
/*
*/
-package com.metamatrix.dqp.internal.datamgr.metadata;
+package org.teiid.dqp.internal.datamgr.metadata;
import java.util.ArrayList;
import java.util.List;
+import org.teiid.dqp.internal.datamgr.metadata.ElementImpl;
+import org.teiid.dqp.internal.datamgr.metadata.GroupImpl;
+import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
+
import junit.framework.TestCase;
import com.metamatrix.common.types.DataTypeManager;
Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector (from rev 569, trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector)
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/FakeSourceConnectionFactory.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/FakeSourceConnectionFactory.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/FakeSourceConnectionFactory.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -22,7 +22,7 @@
/*
*/
-package com.metamatrix.dqp.internal.pooling.connector;
+package org.teiid.dqp.internal.pooling.connector;
import org.teiid.connector.api.Connection;
import org.teiid.connector.api.ConnectorCapabilities;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/FakeUserIdentityConnectionFactory.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/FakeUserIdentityConnectionFactory.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/FakeUserIdentityConnectionFactory.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -22,7 +22,7 @@
/*
*/
-package com.metamatrix.dqp.internal.pooling.connector;
+package org.teiid.dqp.internal.pooling.connector;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.ConnectorIdentity;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionPool.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/TestConnectionPool.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionPool.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.pooling.connector;
+package org.teiid.dqp.internal.pooling.connector;
import java.util.ArrayList;
import java.util.List;
@@ -28,11 +28,14 @@
import org.teiid.connector.api.ExecutionContext;
import org.teiid.connector.api.MappedUserIdentity;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorWrapper;
+import org.teiid.dqp.internal.datamgr.impl.ExecutionContextImpl;
+import org.teiid.dqp.internal.pooling.connector.ConnectionPool;
+import org.teiid.dqp.internal.pooling.connector.ConnectionPoolException;
+import org.teiid.dqp.internal.pooling.connector.ConnectionWrapper;
import junit.framework.TestCase;
-import com.metamatrix.dqp.internal.datamgr.impl.ConnectorWrapper;
-import com.metamatrix.dqp.internal.datamgr.impl.ExecutionContextImpl;
public class TestConnectionPool extends TestCase{
private ConnectionPool userIDPool;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionWrapper.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/TestConnectionWrapper.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestConnectionWrapper.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,12 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.pooling.connector;
+package org.teiid.dqp.internal.pooling.connector;
import junit.framework.TestCase;
import org.mockito.Mockito;
import org.teiid.connector.basic.BasicConnection;
+import org.teiid.dqp.internal.pooling.connector.ConnectionPool;
+import org.teiid.dqp.internal.pooling.connector.ConnectionWrapper;
public class TestConnectionWrapper extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPerUserPool.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/TestPerUserPool.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/pooling/connector/TestPerUserPool.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.pooling.connector;
+package org.teiid.dqp.internal.pooling.connector;
import java.io.Serializable;
import java.util.Properties;
@@ -39,10 +39,10 @@
import org.teiid.connector.api.MappedUserIdentity;
import org.teiid.connector.basic.BasicConnector;
import org.teiid.connector.internal.ConnectorPropertyNames;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorEnvironmentImpl;
+import org.teiid.dqp.internal.datamgr.impl.ExecutionContextImpl;
import com.metamatrix.common.application.ApplicationEnvironment;
-import com.metamatrix.dqp.internal.datamgr.impl.ConnectorEnvironmentImpl;
-import com.metamatrix.dqp.internal.datamgr.impl.ExecutionContextImpl;
/**
*/
Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/process/MockSingleMetadataService.java (from rev 569, trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/MockSingleMetadataService.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/MockSingleMetadataService.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/MockSingleMetadataService.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -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.dqp.internal.process;
+
+import java.util.Properties;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.common.application.ApplicationEnvironment;
+import com.metamatrix.common.application.exception.ApplicationInitializationException;
+import com.metamatrix.common.application.exception.ApplicationLifecycleException;
+import com.metamatrix.dqp.service.MetadataService;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+
+/**
+ */
+public class MockSingleMetadataService implements MetadataService {
+
+ private QueryMetadataInterface metadata;
+
+ public MockSingleMetadataService(QueryMetadataInterface metadata) {
+ this.metadata = metadata;
+ }
+
+ public QueryMetadataInterface lookupMetadata(String vdbName, String vdbVersion)
+ throws MetaMatrixComponentException {
+
+ return this.metadata;
+ }
+
+ public void initialize(Properties props) throws ApplicationInitializationException {
+
+ }
+
+ public void start(ApplicationEnvironment environment) throws ApplicationLifecycleException {
+
+ }
+
+ public void stop() throws ApplicationLifecycleException {
+
+ }
+
+}
Property changes on: trunk/engine/src/test/java/org/teiid/dqp/internal/process/MockSingleMetadataService.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCallableStatement.java (from rev 569, trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestCallableStatement.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCallableStatement.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCallableStatement.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,110 @@
+/*
+ * 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.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import com.metamatrix.api.exception.query.QueryResolverException;
+import com.metamatrix.query.processor.HardcodedDataManager;
+import com.metamatrix.query.unittest.FakeMetadataFactory;
+
+public class TestCallableStatement extends TestCase {
+
+ public void testMissingInput() throws Exception {
+ String sql = "{? = call pm4.spTest9()}"; //$NON-NLS-1$
+
+ try {
+ TestPreparedStatement.helpTestProcessing(sql, Collections.EMPTY_LIST, null, FakeMetadataFactory.exampleBQTCached(), true);
+ fail();
+ } catch (QueryResolverException e) {
+ assertEquals("Required parameter 'PM4.SPTEST9.INKEY' has no value was set or is an invalid parameter.", e.getMessage()); //$NON-NLS-1$
+ }
+ }
+
+ public void testReturnParameter() throws Exception {
+ String sql = "{? = call pm4.spTest9(?)}"; //$NON-NLS-1$
+
+ List values = new ArrayList();
+ values.add(1);
+
+ List[] expected = new List[1];
+ expected[0] = Arrays.asList(1);
+
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData("EXEC pm4.spTest9(1)", expected);
+
+ TestPreparedStatement.helpTestProcessing(sql, values, expected, dataManager, FakeMetadataFactory.exampleBQTCached(), true);
+ }
+
+ /**
+ * same result as above, but the return parameter is not specified
+ * TODO: it would be best if the return parameter were not actually returned here, since it wasn't specified in the initial sql
+ */
+ public void testNoReturnParameter() throws Exception {
+ String sql = "{call pm4.spTest9(?)}"; //$NON-NLS-1$
+
+ List values = new ArrayList();
+ values.add(1);
+
+ List[] expected = new List[1];
+ expected[0] = Arrays.asList(1);
+
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData("EXEC pm4.spTest9(1)", expected);
+
+ TestPreparedStatement.helpTestProcessing(sql, values, expected, dataManager, FakeMetadataFactory.exampleBQTCached(), true);
+ }
+
+ public void testOutParameter() throws Exception {
+ String sql = "{call pm2.spTest8(?, ?)}"; //$NON-NLS-1$
+
+ List values = new ArrayList();
+ values.add(2);
+
+ List[] expected = new List[1];
+ expected[0] = Arrays.asList(null, null, 1);
+
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData("EXEC pm2.spTest8(2)", expected);
+
+ TestPreparedStatement.helpTestProcessing(sql, values, expected, dataManager, FakeMetadataFactory.exampleBQTCached(), true);
+ }
+
+ public void testInputExpression() throws Exception {
+ String sql = "{call pm2.spTest8(1, ?)}"; //$NON-NLS-1$
+
+ List[] expected = new List[1];
+ expected[0] = Arrays.asList(null, null, 0);
+
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData("EXEC pm2.spTest8(1)", expected);
+
+ TestPreparedStatement.helpTestProcessing(sql, null, expected, dataManager, FakeMetadataFactory.exampleBQTCached(), true);
+ }
+
+}
Property changes on: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCallableStatement.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCodeTableCache.java (from rev 569, trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestCodeTableCache.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCodeTableCache.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCodeTableCache.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,210 @@
+/*
+ * 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.Arrays;
+import java.util.List;
+
+import org.teiid.dqp.internal.process.CodeTableCache;
+import org.teiid.dqp.internal.process.CodeTableCache.CacheState;
+
+import junit.framework.TestCase;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.MetaMatrixProcessingException;
+import com.metamatrix.query.util.CommandContext;
+
+/**
+ */
+public class TestCodeTableCache extends TestCase {
+
+ private static CommandContext TEST_CONTEXT = new CommandContext("pid", "1", null, 5, null, null, "test", "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ private static CommandContext TEST_CONTEXT_1 = new CommandContext("pid", "1", null, 5, null, null, "test", "2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+ public TestCodeTableCache(String name) {
+ super(name);
+ }
+
+ private static List[] exampleResultObject() {
+ List record1 = Arrays.asList("US", "USA"); //$NON-NLS-1$ //$NON-NLS-2$
+ List record2 = Arrays.asList("Germany", "GM"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ List[] records = new List[] {
+ record1, record2
+ };
+
+ return records;
+ }
+
+ private CodeTableCache setUpSampleCodeTable(boolean setDone) {
+ CodeTableCache ctc = new CodeTableCache(10);
+
+ // must set the requestToCacheKeyMap first
+ int nodeId = ctc.createCacheRequest("countrycode", "code", "country", TEST_CONTEXT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ List[] results = exampleResultObject();
+
+ // table/countrycode (keyElem/country, returnElem/code);
+ // r1--> 'US', 'USA'
+ // r2--> 'Germany', 'GM'
+
+ try {
+ ctc.loadTable(nodeId, results);
+ } catch (MetaMatrixProcessingException e) {
+ throw new RuntimeException(e);
+ }
+ if(setDone) {
+ ctc.markCacheLoaded(nodeId);
+ }
+ return ctc;
+ }
+
+ // Max = 1 and 1 table is set up
+ private CodeTableCache setUpSampleCodeTable2() {
+ CodeTableCache ctc = new CodeTableCache(1);
+
+ // must set the requestToCacheKeyMap first
+ int nodeId = ctc.createCacheRequest("countrycode", "code", "country", TEST_CONTEXT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ List[] results = exampleResultObject();
+
+ // table/countrycode (keyElem/country, returnElem/code);
+ // r1--> 'US', 'USA'
+ // r2--> 'Germany', 'GM'
+
+ try {
+ ctc.loadTable(nodeId, results);
+ } catch (MetaMatrixProcessingException e) {
+ throw new RuntimeException(e);
+ }
+ ctc.markCacheLoaded(nodeId);
+ return ctc;
+ }
+
+ public void testLookupValue() throws Exception {
+ CodeTableCache ctc = setUpSampleCodeTable(false);
+ String code = (String) ctc.lookupValue("countrycode", "code", "country", "Germany", TEST_CONTEXT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ assertEquals("Actual lookup value doesn't match with expected: ", code, "GM"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /** state = 0; exists*/
+ public void testCacheExists1() {
+ // load code table
+ CodeTableCache ctc = setUpSampleCodeTable(true);
+
+ CacheState actualState = ctc.cacheExists("countrycode", "code", "country", TEST_CONTEXT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ assertEquals("Actual cache state doesn't match with expected: ", CacheState.CACHE_EXISTS, actualState); //$NON-NLS-1$
+ }
+
+ /** state = 1; loading state */
+ public void testCacheExists2() {
+ CodeTableCache ctc = new CodeTableCache(10);
+
+ ctc.cacheExists("countrycode", "code", "country", TEST_CONTEXT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ CacheState actualState = ctc.cacheExists("countrycode", "code", "country", TEST_CONTEXT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ assertEquals("Actual cache state doesn't match with expected: ", CacheState.CACHE_LOADING, actualState); //$NON-NLS-1$
+ }
+
+ /** state = 2; not exist */
+ public void testCacheExists3() {
+ CodeTableCache ctc = setUpSampleCodeTable(true);
+
+ CacheState actualState = ctc.cacheExists("countrycode1", "code1", "country1", TEST_CONTEXT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ assertEquals("Actual cache state doesn't match with expected: ", CacheState.CACHE_NOT_EXIST, actualState); //$NON-NLS-1$
+ }
+
+ /** state = 2; not exist */
+ public void testCacheExists3a() {
+ CodeTableCache ctc = setUpSampleCodeTable(false);
+
+ CacheState actualState = ctc.cacheExists("countrycode", "code", "country", TEST_CONTEXT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ assertEquals("Actual cache state doesn't match with expected: ", CacheState.CACHE_NOT_EXIST, actualState); //$NON-NLS-1$
+ }
+
+ /** state = 4; overload */
+ public void testCacheOverload1() {
+ CodeTableCache ctc = setUpSampleCodeTable2();
+
+ CacheState actualState = ctc.cacheExists("countrycode", "something", "country", TEST_CONTEXT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ assertEquals("Actual cache state doesn't match with expected: ", CacheState.CACHE_OVERLOAD, actualState); //$NON-NLS-1$
+ }
+
+ /** test load, then clearAll, then cacheExists */
+ public void testClearAllLoaded() {
+ // load code table
+ CodeTableCache ctc = setUpSampleCodeTable(true);
+
+ // clear all code tables
+ ctc.clearAll();
+
+ // check state
+ CacheState actualState = ctc.cacheExists("countrycode", "code", "country", TEST_CONTEXT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ assertEquals("Actual cache state doesn't match with expected: ", CacheState.CACHE_NOT_EXIST, actualState); //$NON-NLS-1$
+ }
+
+ /** load table, cacheExists, clearAll, then lookupValue - this should throw an exception */
+ public void testClearAllLoading() {
+ // load code table
+ CodeTableCache ctc = setUpSampleCodeTable(true);
+
+ // check state
+ CacheState actualState = ctc.cacheExists("countrycode", "code", "country", TEST_CONTEXT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ assertEquals("Actual cache state doesn't match with expected: ", CacheState.CACHE_EXISTS, actualState); //$NON-NLS-1$
+
+ // clear all code tables before it can be read
+ ctc.clearAll();
+
+ // lookup a value - this should throw an exception
+ try {
+ ctc.lookupValue("countrycode", "code", "country", "US", TEST_CONTEXT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ fail("Expected exception during lookup"); //$NON-NLS-1$
+ } catch(MetaMatrixComponentException e) {
+ // expected this
+ }
+ }
+
+ public void testVdbSpecificCaching() {
+ // load code table
+ CodeTableCache ctc = setUpSampleCodeTable(true);
+
+ CacheState actualState = ctc.cacheExists("countrycode", "code", "country", TEST_CONTEXT_1); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ assertEquals("Actual cache state doesn't match with expected: ", CacheState.CACHE_NOT_EXIST, actualState); //$NON-NLS-1$
+ }
+
+ public void testDuplicateKeyException() {
+ CodeTableCache ctc = new CodeTableCache(1);
+
+ // must set the requestToCacheKeyMap first
+ int nodeId = ctc.createCacheRequest("table", "key", "value", TEST_CONTEXT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ List[] results = new List[] {
+ Arrays.asList(1, 2),
+ Arrays.asList(1, 3),
+ };
+
+ try {
+ ctc.loadTable(nodeId, results);
+ fail("expected exception"); //$NON-NLS-1$
+ } catch (MetaMatrixProcessingException e) {
+ assertEquals("Duplicate code table 'table' key 'value' value '1'", e.getMessage()); //$NON-NLS-1$
+ }
+ }
+
+}
Property changes on: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCodeTableCache.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java (from rev 569, trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestDQPCore.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,270 @@
+/*
+ * 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.sql.ResultSet;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
+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 junit.framework.TestCase;
+
+import com.metamatrix.api.exception.query.QueryResolverException;
+import com.metamatrix.common.application.ApplicationEnvironment;
+import com.metamatrix.common.vdb.api.ModelInfo;
+import com.metamatrix.dqp.message.RequestID;
+import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.message.ResultsMessage;
+import com.metamatrix.dqp.service.AutoGenDataService;
+import com.metamatrix.dqp.service.DQPServiceNames;
+import com.metamatrix.dqp.service.FakeBufferService;
+import com.metamatrix.dqp.service.FakeMetadataService;
+import com.metamatrix.dqp.service.FakeVDBService;
+import com.metamatrix.jdbc.api.ExecutionProperties;
+import com.metamatrix.platform.security.api.MetaMatrixSessionID;
+import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
+import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
+import com.metamatrix.query.unittest.FakeMetadataFactory;
+
+
+public class TestDQPCore extends TestCase {
+
+ public TestDQPCore(String name) {
+ super(name);
+ }
+
+ private DQPCore core;
+
+ @Override
+ protected void setUp() throws Exception {
+ DQPWorkContext workContext = new DQPWorkContext();
+ workContext.setVdbName("bqt"); //$NON-NLS-1$
+ workContext.setVdbVersion("1"); //$NON-NLS-1$
+ workContext.setSessionId(new MetaMatrixSessionID(1));
+ DQPWorkContext.setWorkContext(workContext);
+
+ String vdbName = "bqt"; //$NON-NLS-1$
+ String vdbVersion = "1"; //$NON-NLS-1$
+
+ ApplicationEnvironment env = new ApplicationEnvironment();
+ env.bindService(DQPServiceNames.BUFFER_SERVICE, new FakeBufferService());
+ FakeMetadataService mdSvc = new FakeMetadataService();
+ mdSvc.addVdb(vdbName, vdbVersion, FakeMetadataFactory.exampleBQTCached());
+ env.bindService(DQPServiceNames.METADATA_SERVICE, mdSvc);
+ env.bindService(DQPServiceNames.DATA_SERVICE, new AutoGenDataService());
+ env.bindService(DQPServiceNames.TRANSACTION_SERVICE, new FakeTransactionService());
+ FakeVDBService vdbService = new FakeVDBService();
+ vdbService.addBinding(vdbName, vdbVersion, "BQT1", "mmuuid:blah", "BQT"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ vdbService.addBinding(vdbName, vdbVersion, "BQT2", "mmuuid:blah", "BQT"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ vdbService.addBinding(vdbName, vdbVersion, "BQT3", "mmuuid:blah", "BQT"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ vdbService.addModel(vdbName, vdbVersion, "BQT3", ModelInfo.PRIVATE, false); //$NON-NLS-1$
+ env.bindService(DQPServiceNames.VDB_SERVICE, vdbService);
+
+ core = new DQPCore(env);
+ core.start(new Properties());
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ DQPWorkContext.setWorkContext(new DQPWorkContext());
+ core.stop();
+ }
+
+ public RequestMessage exampleRequestMessage(String sql) {
+ RequestMessage msg = new RequestMessage(sql);
+ msg.setCallableStatement(false);
+ msg.setCursorType(ResultSet.TYPE_SCROLL_INSENSITIVE);
+ msg.setFetchSize(10);
+ msg.setPartialResults(false);
+ msg.setExecutionId(100);
+ return msg;
+ }
+
+ public void testRequest1() throws Exception {
+ helpExecute("SELECT IntKey FROM BQT1.SmallA", "a"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testUser1() throws Exception {
+ String sql = "SELECT IntKey FROM BQT1.SmallA WHERE user() = 'logon'"; //$NON-NLS-1$
+ String userName = "logon"; //$NON-NLS-1$
+ helpExecute(sql, userName);
+ }
+
+ public void testUser2() throws Exception {
+ String sql = "SELECT IntKey FROM BQT1.SmallA WHERE user() LIKE 'logon'"; //$NON-NLS-1$
+ String userName = "logon"; //$NON-NLS-1$
+ helpExecute(sql, userName);
+ }
+
+ public void testUser3() throws Exception {
+ String sql = "SELECT IntKey FROM BQT1.SmallA WHERE user() IN ('logon3') AND StringKey LIKE '1'"; //$NON-NLS-1$
+ String userName = "logon3"; //$NON-NLS-1$
+ helpExecute(sql, userName);
+ }
+
+ public void testUser4() throws Exception {
+ String sql = "SELECT IntKey FROM BQT1.SmallA WHERE 'logon4' = user() AND StringKey = '1'"; //$NON-NLS-1$
+ String userName = "logon4"; //$NON-NLS-1$
+ helpExecute(sql, userName);
+ }
+
+ public void testUser5() throws Exception {
+ String sql = "SELECT IntKey FROM BQT1.SmallA WHERE user() IS NULL "; //$NON-NLS-1$
+ String userName = "logon"; //$NON-NLS-1$
+ helpExecute(sql, userName);
+ }
+
+ public void testUser6() throws Exception {
+ String sql = "SELECT IntKey FROM BQT1.SmallA WHERE user() = 'logon33' "; //$NON-NLS-1$
+ String userName = "logon"; //$NON-NLS-1$
+ helpExecute(sql, userName);
+ }
+
+ public void testUser7() throws Exception {
+ String sql = "UPDATE BQT1.SmallA SET IntKey = 2 WHERE user() = 'logon' AND StringKey = '1' "; //$NON-NLS-1$
+ String userName = "logon"; //$NON-NLS-1$
+ helpExecute(sql, userName);
+ }
+
+ public void testUser8() throws Exception {
+ String sql = "SELECT user(), StringKey FROM BQT1.SmallA WHERE IntKey = 1 "; //$NON-NLS-1$
+ String userName = "logon"; //$NON-NLS-1$
+ helpExecute(sql, userName);
+ }
+
+ public void testUser9() throws Exception {
+ String sql = "SELECT IntKey FROM BQT1.SmallA WHERE user() = StringKey AND StringKey = '1' "; //$NON-NLS-1$
+ String userName = "1"; //$NON-NLS-1$
+ helpExecute(sql, userName);
+ }
+
+ public void testEnvSessionId() throws Exception {
+ String sql = "SELECT env('sessionid') as SessionID"; //$NON-NLS-1$
+ String userName = "1"; //$NON-NLS-1$
+ ResultsMessage rm = helpExecute(sql, userName);
+ assertEquals("00000000-0000-0001-0000-000000000001", rm.getResults()[0].get(0));
+ }
+
+ public void testEnvSessionIdMixedCase() throws Exception {
+ String sql = "SELECT env('sEsSIonId') as SessionID"; //$NON-NLS-1$
+ String userName = "1"; //$NON-NLS-1$
+ ResultsMessage rm = helpExecute(sql, userName);
+ assertEquals("00000000-0000-0001-0000-000000000001", rm.getResults()[0].get(0));
+ }
+
+ public void testTxnAutoWrap() throws Exception {
+ String sql = "SELECT * FROM BQT1.SmallA"; //$NON-NLS-1$
+ helpExecute(sql, "a", 1, true); //$NON-NLS-1$
+ }
+
+ public void testPlanOnly() throws Exception {
+ String sql = "SELECT * FROM BQT1.SmallA option planonly"; //$NON-NLS-1$
+ helpExecute(sql,"a"); //$NON-NLS-1$
+ }
+
+ /**
+ * Tests whether an exception result is sent when an exception occurs
+ * @since 4.3
+ */
+ public void testPlanningException() throws Exception {
+ String sql = "SELECT IntKey FROM BQT1.BadIdea "; //$NON-NLS-1$
+
+ RequestMessage reqMsg = exampleRequestMessage(sql);
+
+ Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
+ try {
+ message.get(5000, TimeUnit.MILLISECONDS);
+ } catch (ExecutionException e) {
+ assertTrue(e.getCause() instanceof QueryResolverException);
+ }
+ }
+
+ 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$
+ }
+
+ public void testLookupVisibility() throws Exception {
+ helpTestVisibilityFails("select lookup('bqt3.smalla', 'intkey', 'stringkey', '?')"); //$NON-NLS-1$
+ }
+
+ public void testCancel() throws Exception {
+ assertFalse(this.core.cancelRequest(new RequestID(1)));
+ }
+
+ public void helpTestVisibilityFails(String sql) throws Exception {
+ RequestMessage reqMsg = exampleRequestMessage(sql);
+ reqMsg.setTxnAutoWrapMode(ExecutionProperties.AUTO_WRAP_OFF);
+ Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
+ ResultsMessage results = message.get(50000, TimeUnit.MILLISECONDS);
+ assertEquals("[QueryValidatorException]Group does not exist: BQT3.SmallA", results.getException().toString()); //$NON-NLS-1$
+ }
+
+ public void testXQueryVisibility() throws Exception {
+ String xquery = "<Items>\r\n" + //$NON-NLS-1$
+ "{\r\n" + //$NON-NLS-1$
+ "for $x in doc(\"select * from bqt3.smalla\")//Item\r\n" + //$NON-NLS-1$
+ "return <Item>{$x/intkey/text()}</Item>\r\n" + //$NON-NLS-1$
+ "}\r\n" + //$NON-NLS-1$
+ "</Items>\r\n"; //$NON-NLS-1$
+
+ helpTestVisibilityFails(xquery);
+ }
+
+
+ ///////////////////////////Helper method///////////////////////////////////
+ private ResultsMessage helpExecute(String sql, String userName) throws Exception {
+ return helpExecute(sql, userName, 1, false);
+ }
+
+ private ResultsMessage helpExecute(String sql, String userName, int sessionid, boolean txnAutoWrap) throws Exception {
+ RequestMessage reqMsg = exampleRequestMessage(sql);
+ DQPWorkContext.getWorkContext().setUserName(userName);
+ DQPWorkContext.getWorkContext().setSessionId(new MetaMatrixSessionID(sessionid));
+ if (txnAutoWrap) {
+ reqMsg.setTxnAutoWrapMode(ExecutionProperties.AUTO_WRAP_ON);
+ }
+
+ Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
+ ResultsMessage results = message.get(50000, TimeUnit.MILLISECONDS);
+ assertNull(results.getException());
+ return results;
+ }
+}
Property changes on: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java (from rev 569, trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestDQPCoreRequestHandling.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,188 @@
+/*
+ * 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.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.teiid.dqp.internal.process.DQPCore;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+import org.teiid.dqp.internal.process.DataTierTupleSource;
+import org.teiid.dqp.internal.process.RequestWorkItem;
+
+import junit.framework.TestCase;
+
+import com.metamatrix.api.exception.MetaMatrixException;
+import com.metamatrix.common.buffer.TupleSourceID;
+import com.metamatrix.dqp.exception.SourceWarning;
+import com.metamatrix.dqp.internal.datamgr.ConnectorID;
+import com.metamatrix.dqp.message.AtomicRequestMessage;
+import com.metamatrix.dqp.message.RequestID;
+import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.platform.security.api.MetaMatrixSessionID;
+import com.metamatrix.query.analysis.AnalysisRecord;
+import com.metamatrix.query.processor.QueryProcessor;
+import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.server.serverapi.RequestInfo;
+
+/**
+ */
+public class TestDQPCoreRequestHandling extends TestCase {
+
+ private static final String SESSION_STRING = new MetaMatrixSessionID(2).toString();
+
+ public TestDQPCoreRequestHandling(String name) {
+ super(name);
+ }
+
+ private void compareReqInfos(Collection<RequestID> reqs1, Collection<RequestInfo> reqs2) {
+ Set reqIDs2 = new HashSet();
+ for (RequestInfo requestInfo : reqs2) {
+ reqIDs2.add(requestInfo.getRequestID());
+ }
+
+ assertEquals("Collections of request infos are not the same: ", new HashSet(reqs1), reqIDs2); //$NON-NLS-1$
+ }
+
+ /**
+ * Test for Collection getRequests(SessionToken) - no requests
+ */
+ public void testGetRequestsSessionToken1() {
+ DQPCore rm = new DQPCore();
+ Set reqs = new HashSet();
+ Collection actualReqs = rm.getRequestsByClient("foo");
+ compareReqInfos(reqs, actualReqs);
+ }
+
+ /**
+ * Test for Collection getRequests(SessionToken) - 1 request
+ */
+ public void testGetRequestsSessionToken2() {
+ DQPCore rm = new DQPCore();
+ Set reqs = new HashSet();
+ RequestID id = addRequest(rm, SESSION_STRING, 1);
+ reqs.add(id);
+
+ Collection<RequestInfo> actualReqs = rm.getRequestsByClient(SESSION_STRING);
+ compareReqInfos(reqs, actualReqs);
+ }
+
+ private RequestID addRequest(DQPCore rm, String sessionId, int executionId) {
+ RequestMessage r0 = new RequestMessage("test command"); //$NON-NLS-1$
+ RequestID id = new RequestID(sessionId, executionId);
+ addRequest(rm, r0, id, null, null, new TupleSourceID("ts-1"), null, null, null); //$NON-NLS-1$
+ return id;
+ }
+
+ /**
+ * Test for Collection getRequests(SessionToken) - 3 requests
+ */
+ public void testGetRequestsSessionToken3() {
+ DQPCore rm = new DQPCore();
+ Set reqs = new HashSet();
+
+ reqs.add(addRequest(rm, SESSION_STRING, 0));
+ reqs.add(addRequest(rm, SESSION_STRING, 1));
+ reqs.add(addRequest(rm, SESSION_STRING, 2));
+
+ Collection actualReqs = rm.getRequestsByClient(SESSION_STRING);
+ compareReqInfos(reqs, actualReqs);
+ }
+
+ private SourceWarning getSourceFailures(String model, String binding, String message) {
+ return new SourceWarning(model, binding, new MetaMatrixException(message), true);
+ }
+
+ public void testAddRequest() {
+ DQPCore rm = new DQPCore();
+ RequestMessage r0 = new RequestMessage("foo"); //$NON-NLS-1$
+ RequestID requestID = new RequestID(SESSION_STRING, 1);
+ RequestWorkItem workItem = addRequest(rm, r0, requestID, null, null, new TupleSourceID("ts-1"), null, null, null); //$NON-NLS-1$
+ assertTrue(workItem.resultsCursor.resultsRequested);
+ }
+
+ public void testWarnings1() {
+ DQPCore rm = new DQPCore();
+ RequestMessage r0 = new RequestMessage("foo"); //$NON-NLS-1$
+ RequestID requestID = new RequestID(SESSION_STRING, 1);
+
+ RequestWorkItem workItem = addRequest(rm, r0, requestID, null, null, new TupleSourceID("ts-1"), null, null, null); //$NON-NLS-1$
+
+ workItem.addSourceFailureDetails(getSourceFailures("Model1", "Binding1", "Warning1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ workItem.addSourceFailureDetails(getSourceFailures("Model2", "Binding2", "Warning2")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ workItem.addSourceFailureDetails(getSourceFailures("Model3", "Binding3", "Warning3")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ assertEquals(3, workItem.getWarnings().size());
+ }
+
+ static RequestWorkItem addRequest(DQPCore rm,
+ RequestMessage requestMsg,
+ RequestID id,
+ Command originalCommand,
+ QueryProcessor processor,
+ TupleSourceID resultsID,
+ AnalysisRecord analysisRecord,
+ Collection schemas, DQPWorkContext workContext) {
+
+ if (workContext == null) {
+ workContext = new DQPWorkContext();
+ workContext.setSessionId(new MetaMatrixSessionID(id.getConnectionID()));
+ }
+ RequestWorkItem workItem = new RequestWorkItem(rm, requestMsg, null, null, id, workContext);
+ workItem.setOriginalCommand(originalCommand);
+ rm.addRequest(id, workItem);
+ return workItem;
+ }
+
+ public void testGetConnectorInfo() {
+ DQPCore rm = new DQPCore();
+ RequestMessage r0 = new RequestMessage("foo"); //$NON-NLS-1$
+ RequestID requestID = new RequestID(SESSION_STRING, 1);
+ RequestWorkItem workItem = addRequest(rm, r0, requestID, null, null, null, null, null, null);
+ AtomicRequestMessage atomicReq = new AtomicRequestMessage(workItem.requestMsg, workItem.dqpWorkContext, 1);
+
+ DataTierTupleSource info = new DataTierTupleSource(null, atomicReq, null, new ConnectorID("connID"), workItem); //$NON-NLS-1$
+ workItem.addConnectorRequest(atomicReq.getAtomicRequestID(), info);
+
+ DataTierTupleSource arInfo = workItem.getConnectorRequest(atomicReq.getAtomicRequestID());
+ assertTrue(arInfo == info);
+ }
+
+ public void testRemoveConnectorInfo() {
+ DQPCore rm = new DQPCore();
+ RequestMessage r0 = new RequestMessage("foo"); //$NON-NLS-1$
+ RequestID requestID = new RequestID(SESSION_STRING, 1);
+ RequestWorkItem workItem = addRequest(rm, r0, requestID, null, null, null, null, null, null);
+ AtomicRequestMessage atomicReq = new AtomicRequestMessage(workItem.requestMsg, workItem.dqpWorkContext, 1);
+
+ DataTierTupleSource info = new DataTierTupleSource(null, atomicReq, null, new ConnectorID("connID"), workItem); //$NON-NLS-1$
+ workItem.addConnectorRequest(atomicReq.getAtomicRequestID(), info);
+
+ workItem.closeAtomicRequest(atomicReq.getAtomicRequestID());
+
+ DataTierTupleSource arInfo = workItem.getConnectorRequest(atomicReq.getAtomicRequestID());
+ assertNull(arInfo);
+ }
+
+}
Property changes on: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java (from rev 569, trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestDQPWorkContext.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,65 @@
+/*
+ * 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 org.teiid.dqp.internal.process.DQPWorkContext;
+
+import junit.framework.TestCase;
+
+import com.metamatrix.core.util.UnitTestUtil;
+import com.metamatrix.platform.security.api.MetaMatrixSessionID;
+
+public class TestDQPWorkContext extends TestCase {
+
+ /**
+ * Constructor for TestRequestMessage.
+ *
+ * @param name
+ */
+ public TestDQPWorkContext(String name) {
+ super(name);
+ }
+
+ public static DQPWorkContext example() {
+ DQPWorkContext message = new DQPWorkContext();
+ message.setTrustedPayload("myTrustedPayload"); //$NON-NLS-1$
+ message.setUserName("userName"); //$NON-NLS-1$
+ message.setVdbName("vdbName"); //$NON-NLS-1$
+ message.setVdbVersion("vdbVersion"); //$NON-NLS-1$
+ message.setAppName("querybuilder");
+ message.setSessionId(new MetaMatrixSessionID(5));
+ return message;
+ }
+
+ public void testSerialize() throws Exception {
+ DQPWorkContext copy = UnitTestUtil.helpSerialize(example());
+
+ assertEquals("5", "5"); //$NON-NLS-1$
+ assertEquals("myTrustedPayload", copy.getTrustedPayload()); //$NON-NLS-1$
+ assertEquals("userName", copy.getUserName()); //$NON-NLS-1$
+ assertEquals("vdbName", copy.getVdbName()); //$NON-NLS-1$
+ assertEquals("vdbVersion", copy.getVdbVersion()); //$NON-NLS-1$
+ assertEquals("querybuilder", copy.getAppName()); //$NON-NLS-1$
+ }
+
+}
Property changes on: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java (from rev 569, trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestDataTierManager.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,403 @@
+/*
+ * 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.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.teiid.dqp.internal.process.DQPCore;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+import org.teiid.dqp.internal.process.DataTierManagerImpl;
+import org.teiid.dqp.internal.process.DataTierTupleSource;
+import org.teiid.dqp.internal.process.RequestWorkItem;
+
+import junit.framework.TestCase;
+
+import com.metamatrix.api.exception.ComponentNotFoundException;
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.MetaMatrixException;
+import com.metamatrix.common.application.ApplicationEnvironment;
+import com.metamatrix.common.application.exception.ApplicationInitializationException;
+import com.metamatrix.common.application.exception.ApplicationLifecycleException;
+import com.metamatrix.common.buffer.BlockedException;
+import com.metamatrix.common.buffer.BufferManager;
+import com.metamatrix.common.buffer.TupleBatch;
+import com.metamatrix.common.buffer.TupleSourceID;
+import com.metamatrix.common.comm.api.ResultsReceiver;
+import com.metamatrix.common.config.api.ConnectorBinding;
+import com.metamatrix.dqp.internal.datamgr.ConnectorID;
+import com.metamatrix.dqp.message.AtomicRequestID;
+import com.metamatrix.dqp.message.AtomicRequestMessage;
+import com.metamatrix.dqp.message.AtomicResultsMessage;
+import com.metamatrix.dqp.message.RequestID;
+import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.service.DataService;
+import com.metamatrix.dqp.service.FakeBufferService;
+import com.metamatrix.dqp.service.FakeVDBService;
+import com.metamatrix.platform.security.api.MetaMatrixSessionID;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
+import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
+import com.metamatrix.query.parser.QueryParser;
+import com.metamatrix.query.processor.ProcessorDataManager;
+import com.metamatrix.query.processor.ProcessorPlan;
+import com.metamatrix.query.processor.QueryProcessor;
+import com.metamatrix.query.processor.dynamic.SimpleQueryProcessorFactory;
+import com.metamatrix.query.resolver.QueryResolver;
+import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.unittest.FakeMetadataFactory;
+import com.metamatrix.query.util.CommandContext;
+
+
+public class TestDataTierManager extends TestCase {
+
+ private DQPCore rm;
+ private DataTierManagerImpl dtm;
+ private CommandContext context;
+ private AtomicRequestMessage request;
+ private Command command;
+ private DataTierTupleSource info;
+ private QueryProcessor processor;
+ private int executeRequestFailOnCall = 10000;
+ private FakeDataService dataService;
+ private RequestWorkItem workItem;
+
+ public TestDataTierManager(String name) {
+ super(name);
+ }
+
+ private static Command helpGetCommand(String sql, QueryMetadataInterface metadata) throws Exception {
+ Command command = QueryParser.getQueryParser().parseCommand(sql);
+ QueryResolver.resolveCommand(command, metadata);
+ return command;
+ }
+
+ private void helpSetup(int nodeId) throws Exception {
+ helpSetup("SELECT * FROM BQT1.SmallA", nodeId); //$NON-NLS-1$
+ }
+
+ private void helpSetup(String sql, int nodeId) throws Exception {
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ dataService = new FakeDataService(executeRequestFailOnCall);
+// dataService.addResults("SELECT StringKey, IntKey FROM BQT1.SmallA", helpCreateFakeCodeTableResults(1, 50)); //$NON-NLS-1$
+ rm = new DQPCore();
+
+ FakeVDBService vdbService = new FakeVDBService();
+ vdbService.addBinding("MyVDB", "1", "BQT1", "mmuuid:binding", "bindingName"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+
+ FakeBufferService bs = new FakeBufferService();
+
+ dtm = new DataTierManagerImpl(rm,
+ dataService,
+ new MockSingleMetadataService(metadata),
+ vdbService,
+ bs,
+ 1000,
+ 1000);
+ command = helpGetCommand(sql, metadata);
+
+ RequestMessage original = new RequestMessage();
+ original.setExecutionId(1);
+
+ DQPWorkContext workContext = new DQPWorkContext();
+ workContext.setVdbName("MyVDB"); //$NON-NLS-1$
+ workContext.setVdbVersion("1"); //$NON-NLS-1$
+ workContext.setSessionId(new MetaMatrixSessionID(1));
+ RequestID requestID = workContext.getRequestID(original.getExecutionId());
+
+ context = new CommandContext();
+ context.setProcessorID(requestID);
+ context.setTupleSourceID(new TupleSourceID("fakeid")); //$NON-NLS-1$
+ context.setVdbName("test"); //$NON-NLS-1$
+ context.setVdbVersion("1"); //$NON-NLS-1$
+ context.setQueryProcessorFactory(new SimpleQueryProcessorFactory(bs.getBufferManager(), dtm, new DefaultCapabilitiesFinder(), null, metadata));
+ processor = new QueryProcessor(new FakeProcessorPlan(), context, bs.getBufferManager(), dtm);
+ workItem = TestDQPCoreRequestHandling.addRequest(rm, original, requestID, null, processor, null, null, null, workContext);
+
+ request = new AtomicRequestMessage(original, workContext, nodeId);
+ request.setCommand(command);
+ request.setConnectorID(new ConnectorID("FakeConnectorID")); //$NON-NLS-1$
+
+ info = new DataTierTupleSource(command.getProjectedSymbols(), request, dtm, request.getConnectorID(), workItem);
+ workItem.addConnectorRequest(request.getAtomicRequestID(), info);
+ }
+
+ private AtomicResultsMessage helpSetup(boolean isFirst, boolean isLast) throws Exception {
+ return helpSetup("SELECT * FROM BQT1.SmallA", isFirst, isLast); //$NON-NLS-1$
+ }
+
+ private AtomicResultsMessage helpSetup(String sql, boolean isFirst, boolean isLast) throws Exception {
+ return helpSetup(sql, isFirst, isLast, 3);
+ }
+
+ private AtomicResultsMessage helpSetup(String sql, boolean isFirst, boolean isLast, int nodeId) throws Exception {
+ helpSetup(sql, nodeId);
+
+ request.setCommand(command);
+
+ AtomicResultsMessage results = new AtomicResultsMessage(request, new List[0], new String[0]);
+
+ if (isLast) {
+ results.setFinalRow(10);
+ }
+ return results;
+ }
+
+ /**
+ * Defect 15646 - Ensure that when the final batch is received, the ConnectorRequestInfo object is removed from the RequestManager
+ * @throws Exception
+ * @since 4.2
+ */
+ public void testDeliverMessageNEWResponseFinal_Defect15646() throws Exception {
+ AtomicResultsMessage results = helpSetup(true, true);
+ info.receiveResults(results);
+
+ assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
+
+ DataTierTupleSource connRequest = workItem.getConnectorRequest(request.getAtomicRequestID());
+
+ connRequest.closeSource();
+
+ assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
+
+ AtomicResultsMessage closeResult = new AtomicResultsMessage(request);
+ closeResult.setRequestClosed(true);
+ info.receiveResults(closeResult);
+
+ assertNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
+ }
+
+ public void testDeliverMessageNEWResponseNonFinal() throws Exception {
+ AtomicResultsMessage results = helpSetup(true, false);
+ info.receiveResults(results);
+ assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
+ }
+
+ public void testDeliverMessageMOREResponseFinal_Defect15646() throws Exception {
+ AtomicResultsMessage results = helpSetup(false, true);
+ info.receiveResults(results);
+
+ assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
+
+ DataTierTupleSource connRequest = workItem.getConnectorRequest(request.getAtomicRequestID());
+
+ connRequest.closeSource();
+
+ assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
+
+ AtomicResultsMessage closeResult = new AtomicResultsMessage(request);
+ closeResult.setRequestClosed(true);
+ info.receiveResults(closeResult);
+
+ assertNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
+ }
+
+ public void testExplicitClose() throws Exception {
+ String sql = "select ClobValue from LOB.LobTbl"; //$NON-NLS-1$
+
+ AtomicResultsMessage results = helpSetup(sql, true, true);
+ results.setSupportsImplicitClose(false);
+
+ info.receiveResults(results);
+ assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
+
+ DataTierTupleSource connRequest = workItem.getConnectorRequest(request.getAtomicRequestID());
+ connRequest.closeSource();
+ assertFalse(this.dataService.closed);
+
+ assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
+
+ // now explicit close and see it gone
+ connRequest.fullyCloseSource();
+
+ assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
+
+ AtomicResultsMessage closeResult = new AtomicResultsMessage(request);
+ closeResult.setRequestClosed(true);
+ info.receiveResults(closeResult);
+
+ assertNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
+ }
+
+
+ public void testImplictClose() throws Exception {
+ String sql = "select ClobValue from LOB.LobTbl"; //$NON-NLS-1$
+
+ AtomicResultsMessage results = helpSetup(sql, true, true);
+ results.setSupportsImplicitClose(true);
+
+ info.receiveResults(results);
+
+ assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
+
+ DataTierTupleSource connRequest = workItem.getConnectorRequest(request.getAtomicRequestID());
+ connRequest.closeSource();
+ assertTrue(this.dataService.closed);
+
+ assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
+
+ AtomicResultsMessage closeResult = new AtomicResultsMessage(request);
+ closeResult.setRequestClosed(true);
+ info.receiveResults(closeResult);
+
+ assertNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
+ }
+
+ public void testImplictCloseWithNotAllowedState() throws Exception {
+ String sql = "select ClobValue from LOB.LobTbl"; //$NON-NLS-1$
+
+ AtomicResultsMessage results = helpSetup(sql, true, true);
+ results.setSupportsImplicitClose(false);
+
+ info.receiveResults(results);
+ assertFalse(this.dataService.closed);
+ assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
+
+ DataTierTupleSource connRequest = workItem.getConnectorRequest(request.getAtomicRequestID());
+
+ // now implicitly close the request then check to make sure it is not gone
+ connRequest.closeSource();
+ assertFalse(this.dataService.closed);
+ assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
+ }
+
+
+ public void testDeliverMessageMOREResponseNonFinal() throws Exception {
+ AtomicResultsMessage results = helpSetup(false, false);
+ info.receiveResults(results);
+
+ assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
+ }
+
+ public void testCodeTableResponseException() throws Exception {
+ helpSetup(3);
+ this.dataService.throwExceptionOnExecute = true;
+
+ try {
+ dtm.lookupCodeValue(context, "BQT1.SmallA", "IntKey", "StringKey", "49"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ fail("processor should have failed"); //$NON-NLS-1$
+ } catch (MetaMatrixException e) {
+ assertEquals("Connector Exception", e.getMessage()); //$NON-NLS-1$
+ }
+ }
+
+ public void testCodeTableResponse_MoreRequestFails() throws Exception {
+ executeRequestFailOnCall = 1;
+
+ AtomicResultsMessage results = helpSetup("SELECT * FROM BQT1.SmallA", true, false, -1); //$NON-NLS-1$
+
+ this.dataService.results = results;
+
+ try {
+ dtm.lookupCodeValue(context, "BQT1.SmallA", "IntKey", "StringKey", "49"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ fail("processor should have failed"); //$NON-NLS-1$
+ } catch (MetaMatrixException e) {
+ assertEquals("Force fail on executeRequest for call # 1", e.getMessage()); //$NON-NLS-1$
+ }
+ }
+
+ private static class FakeProcessorPlan implements ProcessorPlan {
+ public Object clone() {return this;}
+ public void close() throws MetaMatrixComponentException {}
+ public List getAndClearWarnings() {return null;}
+ public CommandContext getContext() {return null;}
+ public List getOutputElements() {return null;}
+ public void initialize(CommandContext context,ProcessorDataManager dataMgr,BufferManager bufferMgr) {}
+ public TupleBatch nextBatch() throws BlockedException,MetaMatrixComponentException {
+ ArrayList one = new ArrayList(); one.add("1");
+ ArrayList two = new ArrayList(); two.add("2");
+ List[] results = {one, two};
+ return new TupleBatch(1, results);
+ }
+ public void open() throws MetaMatrixComponentException {}
+ public void reset() {}
+ public Map getDescriptionProperties() {return null;}
+ public Collection getChildPlans() { return Collections.EMPTY_LIST; }
+ }
+
+ private static class FakeDataService implements DataService {
+ private int failOnCall = 10000;
+ private int calls = 0;
+ private boolean closed = false;
+ boolean throwExceptionOnExecute;
+ AtomicResultsMessage results;
+
+ private FakeDataService(int failOnCallNumber) {
+ this.failOnCall = failOnCallNumber;
+ }
+ public void executeRequest(AtomicRequestMessage request,
+ ConnectorID connector,
+ ResultsReceiver<AtomicResultsMessage> resultListener)
+ throws MetaMatrixComponentException {
+ if (closed) {
+ throw new MetaMatrixComponentException("Already closed"); //$NON-NLS-1$
+ }
+ if (throwExceptionOnExecute) {
+ resultListener.exceptionOccurred(new RuntimeException("Connector Exception")); //$NON-NLS-1$
+ } else {
+ resultListener.receiveResults(results);
+ }
+ }
+ public ConnectorID selectConnector(String connectorBindingID) {
+ if (connectorBindingID.equals("mmuuid:binding")) { //$NON-NLS-1$
+ return new ConnectorID("FakeConnectorID"); //$NON-NLS-1$
+ }
+ return null;
+ }
+ public void initialize(Properties props) throws ApplicationInitializationException {}
+ public void start(ApplicationEnvironment environment) throws ApplicationLifecycleException {}
+ public void stop() throws ApplicationLifecycleException {}
+ public void startConnectorBinding(String connectorBindingName) throws ApplicationLifecycleException,ComponentNotFoundException {}
+ public void stopConnectorBinding(String connectorBindingName) throws ApplicationLifecycleException,ComponentNotFoundException {}
+ public List getConnectorBindings() throws ComponentNotFoundException {return null;}
+ public Boolean getConnectorBindingState(String connectorBindingName) throws MetaMatrixComponentException {return null;}
+ public ConnectorBinding getConnectorBinding(String connectorBindingName) throws MetaMatrixComponentException {return null;}
+ public Collection getConnectorBindingStatistics(String connectorBindingName) throws MetaMatrixComponentException {return null;}
+ public void clearConnectorBindingCache(String connectorBindingName) throws MetaMatrixComponentException {}
+
+ public void cancelRequest(AtomicRequestID request,
+ ConnectorID connectorId) throws MetaMatrixComponentException {
+ }
+ public void closeRequest(AtomicRequestID request,
+ ConnectorID connectorId) throws MetaMatrixComponentException {
+ closed = true;
+ }
+ public SourceCapabilities getCapabilities(RequestMessage request,
+ DQPWorkContext dqpWorkContext, ConnectorID connector)
+ throws MetaMatrixComponentException {
+ return null;
+ }
+ public void requestBatch(AtomicRequestID request,
+ ConnectorID connectorId) throws MetaMatrixComponentException {
+ calls++;
+ if (calls == failOnCall) {
+ throw new MetaMatrixComponentException("Force fail on executeRequest for call # " + calls); //$NON-NLS-1$
+ }
+ }
+ }
+}
Property changes on: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java (from rev 569, trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestMetaDataProcessor.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,272 @@
+/*
+ * 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.Collections;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.teiid.dqp.internal.process.DQPCore;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+import org.teiid.dqp.internal.process.MetaDataProcessor;
+import org.teiid.dqp.internal.process.PreparedPlanCache;
+
+import junit.framework.TestCase;
+
+import com.metamatrix.common.application.ApplicationEnvironment;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.common.vdb.api.ModelInfo;
+import com.metamatrix.dqp.client.MetadataResult;
+import com.metamatrix.dqp.message.RequestID;
+import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.metadata.ResultsMetadataConstants;
+import com.metamatrix.dqp.service.DQPServiceNames;
+import com.metamatrix.dqp.service.FakeVDBService;
+import com.metamatrix.dqp.service.MetadataService;
+import com.metamatrix.platform.security.api.MetaMatrixSessionID;
+import com.metamatrix.query.analysis.AnalysisRecord;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.parser.QueryParser;
+import com.metamatrix.query.resolver.QueryResolver;
+import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.unittest.FakeMetadataFactory;
+
+/**
+ */
+public class TestMetaDataProcessor extends TestCase {
+
+ public TestMetaDataProcessor(String name) {
+ super(name);
+ }
+
+ public Map[] helpGetMetadata(String sql, QueryMetadataInterface metadata) throws Exception {
+ // Prepare sql
+ Command command = QueryParser.getQueryParser().parseCommand(sql);
+ QueryResolver.resolveCommand(command, Collections.EMPTY_MAP, false, metadata, AnalysisRecord.createNonRecordingRecord());
+
+ // Create components
+ MetadataService mdSvc = new MockSingleMetadataService(metadata);
+ PreparedPlanCache prepPlanCache = new PreparedPlanCache();
+ DQPCore requestMgr = new DQPCore();
+
+ DQPWorkContext workContext = new DQPWorkContext();
+ workContext.setVdbName("MyVDB"); //$NON-NLS-1$
+ workContext.setVdbVersion("1"); //$NON-NLS-1$
+ workContext.setSessionId(new MetaMatrixSessionID(1));
+
+ // Initialize components
+ RequestID requestID = workContext.getRequestID(1);
+ RequestMessage requestMsg = new RequestMessage(sql);
+ TestDQPCoreRequestHandling.addRequest(requestMgr, requestMsg, requestID, command, null, null, AnalysisRecord.createNonRecordingRecord(), null, null); //$NON-NLS-1$
+
+ ApplicationEnvironment env = new ApplicationEnvironment();
+ FakeVDBService vdbService = new FakeVDBService();
+ env.bindService(DQPServiceNames.VDB_SERVICE, vdbService);
+ MetaDataProcessor mdProc = new MetaDataProcessor(mdSvc, requestMgr, prepPlanCache, env, null);
+
+ return mdProc.processMessage(requestID, workContext, null, true).getColumnMetadata();
+ }
+
+ public void testSimpleQuery() throws Exception {
+ Map[] metadata = helpGetMetadata("SELECT e1 FROM pm1.g1", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ assertNotNull(metadata);
+ assertEquals(1, metadata.length);
+ }
+
+ public void testSimpleUpdate() throws Exception {
+ Map[] metadata = helpGetMetadata("INSERT INTO pm1.g1 (e1) VALUES ('x')", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ assertNotNull(metadata);
+ assertEquals(1, metadata.length);
+
+ metadata = helpGetMetadata("DELETE FROM pm1.g1 WHERE e1 = 'x'", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ assertNotNull(metadata);
+ assertEquals(1, metadata.length);
+
+ metadata = helpGetMetadata("UPDATE pm1.g1 SET e1='y' WHERE e1 = 'x'", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ assertNotNull(metadata);
+ assertEquals(1, metadata.length);
+
+ metadata = helpGetMetadata("SELECT e1, e2, e3, e4 INTO pm1.g2 FROM pm1.g1", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ assertNotNull(metadata);
+ assertEquals(1, metadata.length);
+ }
+
+ public void testElementLabel() throws Exception {
+ Map[] metadata = helpGetMetadata("SELECT E2 FROM pm1.g1", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ assertNotNull(metadata);
+ assertEquals(1, metadata.length);
+ assertEquals("E2", metadata[0].get(ResultsMetadataConstants.ELEMENT_NAME)); //$NON-NLS-1$
+ }
+
+ public void testSimpleExec() throws Exception {
+ Map[] metadata = helpGetMetadata("EXEC pm1.sq1()", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ assertNotNull(metadata);
+ assertEquals(2, metadata.length);
+ }
+
+ public void testExecNoResultColumns() throws Exception {
+ Map[] metadata = helpGetMetadata("EXEC pm1.sp5()", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ assertNotNull(metadata);
+ assertEquals(0, metadata.length);
+ }
+
+ public void testDefect15029() throws Exception {
+ String sql = "SELECT * FROM g1"; //$NON-NLS-1$
+ QueryMetadataInterface metadata = FakeMetadataFactory.examplePrivatePhysicalModel();
+
+ MetadataResult response = helpTestQuery(metadata, sql);
+
+ Map[] md = response.getColumnMetadata();
+ assertNotNull(md);
+ assertEquals(1, md.length);
+ assertEquals("e1", md[0].get(ResultsMetadataConstants.ELEMENT_NAME)); //$NON-NLS-1$
+ assertEquals("vm1.g1", md[0].get(ResultsMetadataConstants.GROUP_NAME)); //$NON-NLS-1$
+ }
+
+ private MetadataResult helpTestQuery(QueryMetadataInterface metadata, String sql) throws Exception {
+ FakeVDBService vdbService = new FakeVDBService();
+ vdbService.addModel("MyVDB", "1", "pm1", ModelInfo.PRIVATE, false); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+
+ // Create components
+ MetadataService mdSvc = new MockSingleMetadataService(metadata);
+ PreparedPlanCache prepPlanCache = new PreparedPlanCache();
+
+ // Initialize components
+ ApplicationEnvironment env = new ApplicationEnvironment();
+ env.bindService(DQPServiceNames.VDB_SERVICE, vdbService);
+ MetaDataProcessor mdProc = new MetaDataProcessor(mdSvc, null, prepPlanCache, env, null);
+
+ DQPWorkContext workContext = new DQPWorkContext();
+ workContext.setVdbName("MyVDB"); //$NON-NLS-1$
+ workContext.setVdbVersion("1"); //$NON-NLS-1$
+ workContext.setSessionId(new MetaMatrixSessionID(1));
+ return mdProc.processMessage(workContext.getRequestID(1), workContext, sql, true);
+ }
+
+ private void helpCheckNumericAttributes(MetadataResult message, int column, int expectedSize, int expectedPrecision, int expectedScale) {
+ Map[] md = message.getColumnMetadata();
+ assertNotNull(md);
+ assertEquals(new Integer(expectedSize), md[column].get(ResultsMetadataConstants.DISPLAY_SIZE));
+ assertEquals(new Integer(expectedPrecision), md[column].get(ResultsMetadataConstants.PRECISION));
+ assertEquals(new Integer(expectedScale), md[column].get(ResultsMetadataConstants.SCALE));
+ }
+
+ public void testDefect16629_moneyType() throws Exception {
+ QueryMetadataInterface metadata = FakeMetadataFactory.examplePrivatePhysicalModel(); //$NON-NLS-1$
+ String sql = "SELECT e1 FROM pm1.g2"; //$NON-NLS-1$
+
+ MetadataResult response = helpTestQuery(metadata, sql);
+
+ helpCheckNumericAttributes(response, 0, 21, 19, 4);
+ }
+
+ public void testDefect16629_aggregatesOnMoneyType() throws Exception {
+ QueryMetadataInterface metadata = FakeMetadataFactory.examplePrivatePhysicalModel(); //$NON-NLS-1$
+ String sql = "SELECT min(e1), max(e1), sum(e1), avg(e1) FROM pm1.g2"; //$NON-NLS-1$
+
+ MetadataResult response = helpTestQuery(metadata, sql);
+ helpCheckNumericAttributes(response, 0, 21, 19, 4);
+ helpCheckNumericAttributes(response, 1, 21, 19, 4);
+ helpCheckNumericAttributes(response, 2, 22, 20, 0);
+ helpCheckNumericAttributes(response, 3, 22, 20, 0);
+ }
+
+ public void testMetadataGenerationForAllTypes() throws Exception {
+ Set dataTypes = DataTypeManager.getAllDataTypeNames();
+ Iterator iter = dataTypes.iterator();
+
+ while(iter.hasNext()) {
+ String type = (String) iter.next();
+ Class typeClass = DataTypeManager.getDataTypeClass(type);
+ MetaDataProcessor processor = new MetaDataProcessor(null, null, null, null, null);
+ Map columnMetadata = processor.getDefaultColumn("vdb", "1", "t", "c", typeClass); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ verifyColumn(columnMetadata, type);
+ }
+ }
+
+ private void verifyColumn(Map column, String dataType) {
+ verifyAttribute(column, ResultsMetadataConstants.AUTO_INCREMENTING, false, Boolean.class, dataType);
+ verifyAttribute(column, ResultsMetadataConstants.CASE_SENSITIVE, false, Boolean.class, dataType);
+ verifyAttribute(column, ResultsMetadataConstants.CURRENCY, false, Boolean.class, dataType);
+
+ Object dt = verifyAttribute(column, ResultsMetadataConstants.DATA_TYPE, false, String.class, dataType);
+ assertEquals(dataType, dt);
+
+ verifyAttribute(column, ResultsMetadataConstants.DISPLAY_SIZE, false, Integer.class, dataType);
+ verifyAttribute(column, ResultsMetadataConstants.ELEMENT_LABEL, true, String.class, dataType);
+ verifyAttribute(column, ResultsMetadataConstants.ELEMENT_NAME, false, String.class, dataType);
+ verifyAttribute(column, ResultsMetadataConstants.GROUP_NAME, true, String.class, dataType);
+
+ Object nullable = verifyAttribute(column, ResultsMetadataConstants.NULLABLE, false, Integer.class, dataType);
+ verifyNullable((Integer)nullable);
+
+ verifyAttribute(column, ResultsMetadataConstants.PRECISION, false, Integer.class, dataType);
+ verifyAttribute(column, ResultsMetadataConstants.RADIX, false, Integer.class, dataType);
+ verifyAttribute(column, ResultsMetadataConstants.SCALE, false, Integer.class, dataType);
+
+ Object searchable = verifyAttribute(column, ResultsMetadataConstants.SEARCHABLE, false, Integer.class, dataType);
+ verifySearchable((Integer)searchable);
+
+ verifyAttribute(column, ResultsMetadataConstants.SIGNED, false, Boolean.class, dataType);
+
+ verifyAttribute(column, ResultsMetadataConstants.VIRTUAL_DATABASE_NAME, false, String.class, dataType);
+ verifyAttribute(column, ResultsMetadataConstants.VIRTUAL_DATABASE_VERSION, false, String.class, dataType);
+ verifyAttribute(column, ResultsMetadataConstants.WRITABLE, false, Boolean.class, dataType);
+ }
+
+ private Object verifyAttribute(Map column, Integer attributeType, boolean nullsAllowed, Class expectedClass, String columnDataType) {
+ //System.out.println("Checking " + columnDataType + ", attribute " + attributeType); //$NON-NLS-1$ //$NON-NLS-2$
+ Object value = column.get(attributeType);
+ if(! nullsAllowed) {
+ assertNotNull("Got null when not allowed for column of type " + columnDataType, value); //$NON-NLS-1$
+ }
+
+ if(value != null) {
+ assertEquals("Got attribute of incorrect class for column of type " + columnDataType, expectedClass, value.getClass()); //$NON-NLS-1$
+ }
+
+ return value;
+ }
+
+ private void verifyNullable(Integer nullable) {
+ if(!
+ (nullable.equals(ResultsMetadataConstants.NULL_TYPES.NOT_NULL) ||
+ nullable.equals(ResultsMetadataConstants.NULL_TYPES.NULLABLE) ||
+ nullable.equals(ResultsMetadataConstants.NULL_TYPES.UNKNOWN) ) ) {
+
+ fail("Invalid nullable constant value: " + nullable); //$NON-NLS-1$
+ }
+ }
+
+ private void verifySearchable(Integer searchable) {
+ if(!
+ (searchable.equals(ResultsMetadataConstants.SEARCH_TYPES.ALLEXCEPTLIKE) ||
+ searchable.equals(ResultsMetadataConstants.SEARCH_TYPES.LIKE_ONLY) ||
+ searchable.equals(ResultsMetadataConstants.SEARCH_TYPES.UNSEARCHABLE) ||
+ searchable.equals(ResultsMetadataConstants.SEARCH_TYPES.SEARCHABLE) ) ) {
+
+ fail("Invalid searchable constant value: " + searchable); //$NON-NLS-1$
+ }
+ }
+}
Property changes on: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java (from rev 569, trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestPreparedPlanCache.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,155 @@
+/*
+ * 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.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.teiid.dqp.internal.process.PreparedPlanCache;
+
+import junit.framework.TestCase;
+
+import com.metamatrix.api.exception.query.QueryParserException;
+import com.metamatrix.query.analysis.AnalysisRecord;
+import com.metamatrix.query.parser.QueryParser;
+import com.metamatrix.query.processor.relational.ProjectNode;
+import com.metamatrix.query.processor.relational.RelationalPlan;
+import com.metamatrix.query.sql.lang.Command;
+
+
+public class TestPreparedPlanCache extends TestCase{
+ private static final String EXAMPLE_QUERY = "SELECT * FROM table"; //$NON-NLS-1$
+ private final static String token = "1"; //$NON-NLS-1$
+ private final static String token2 = "2"; //$NON-NLS-1$
+
+ public TestPreparedPlanCache(String name) {
+ super(name);
+ }
+
+ //====Tests====//
+ public void testCreatePreparedPlan(){
+ PreparedPlanCache cache = new PreparedPlanCache();
+
+ //No PreparedPlan at the begining
+ assertNull(cache.getPreparedPlan(token, EXAMPLE_QUERY + 1, false));
+ //create one
+ cache.createPreparedPlan(token, EXAMPLE_QUERY + 1, false);
+ //should have one now
+ assertNotNull("Unable to get prepared plan from cache", cache.getPreparedPlan(token, EXAMPLE_QUERY + 1, false)); //$NON-NLS-1$
+ }
+
+ public void testGetPreparedPlan(){
+ PreparedPlanCache cache = new PreparedPlanCache();
+ helpCreatePreparedPlans(cache, token, 0, 10);
+ helpCreatePreparedPlans(cache, token2, 0, 15);
+
+ //read an entry for session2 (token2)
+ PreparedPlanCache.PreparedPlan pPlan = cache.getPreparedPlan(token2, EXAMPLE_QUERY + 12, false);
+ assertNotNull("Unable to get prepared plan from cache", pPlan); //$NON-NLS-1$
+ assertEquals("Error getting plan from cache", new RelationalPlan(new ProjectNode(12)).toString(), pPlan.getPlan().toString()); //$NON-NLS-1$
+ assertEquals("Error getting command from cache", EXAMPLE_QUERY + 12, pPlan.getCommand().toString()); //$NON-NLS-1$
+ assertNotNull("Error getting plan description from cache", pPlan.getAnalysisRecord().getQueryPlan()); //$NON-NLS-1$
+ assertEquals("Error gettting reference from cache", "ref12", pPlan.getReferences().get(0)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testClearAll(){
+ PreparedPlanCache cache = new PreparedPlanCache();
+
+ //create one for each session token
+ cache.createPreparedPlan(token, EXAMPLE_QUERY + 1, false);
+ cache.createPreparedPlan(token2, EXAMPLE_QUERY + 1, false);
+ //should have one
+ assertNotNull("Unable to get prepared plan from cache for token", cache.getPreparedPlan(token, EXAMPLE_QUERY + 1, false)); //$NON-NLS-1$
+ cache.clearAll();
+ //should not exist for token
+ assertNull("Failed remove from cache", cache.getPreparedPlan(token, EXAMPLE_QUERY + 1, false)); //$NON-NLS-1$
+ //should not exist for token2
+ assertNull("Unable to get prepared plan from cache for token2", cache.getPreparedPlan(token2, EXAMPLE_QUERY + 1, false)); //$NON-NLS-1$
+ }
+
+ public void testMaxSize(){
+ PreparedPlanCache cache = new PreparedPlanCache(100);
+ helpCreatePreparedPlans(cache, token, 0, 101);
+ //the first one should be gone because the max size is 100
+ assertNull(cache.getPreparedPlan(token, EXAMPLE_QUERY + 0, false));
+
+ assertNotNull(cache.getPreparedPlan(token, EXAMPLE_QUERY + 12, false));
+ helpCreatePreparedPlans(cache, token, 102, 50);
+ //"sql12" should still be there based on lru policy
+ assertNotNull(cache.getPreparedPlan(token, EXAMPLE_QUERY + 12, false));
+
+ helpCreatePreparedPlans(cache, token2, 0, 121);
+ helpCreatePreparedPlans(cache, token, 0, 50);
+ assertTrue(cache.getSpaceUsed() <= 100);
+ }
+
+ public void testZeroSizeCache() {
+ // Create with 0 size cache
+ PreparedPlanCache cache = new PreparedPlanCache(0);
+ assertEquals(0, cache.getSpaceAllowed());
+
+ // Add 1 plan and verify it is not in the cache
+ helpCreatePreparedPlans(cache, token, 0, 1);
+ assertNull(cache.getPreparedPlan(token, EXAMPLE_QUERY + 0, false));
+ assertEquals(0, cache.getSpaceUsed());
+
+ // Add another plan and verify it is not in the cache
+ helpCreatePreparedPlans(cache, token, 1, 1);
+ assertNull(cache.getPreparedPlan(token, EXAMPLE_QUERY + 1, false));
+ assertEquals(0, cache.getSpaceUsed());
+ }
+
+ // set init size to negative number, which should default to 100 (default)
+ public void testNegativeSizeCacheUsesDefault() {
+ PreparedPlanCache negativeSizedCache = new PreparedPlanCache(-1000);
+ PreparedPlanCache defaultSizedCache = new PreparedPlanCache();
+
+ assertEquals(defaultSizedCache.getSpaceAllowed(), negativeSizedCache.getSpaceAllowed());
+ assertEquals(PreparedPlanCache.DEFAULT_MAX_SIZE_TOTAL, negativeSizedCache.getSpaceAllowed());
+ }
+
+ //====Help methods====//
+ private void helpCreatePreparedPlans(PreparedPlanCache cache, String token, int start, int count){
+ for(int i=start; i<count; i++){
+ Command dummy;
+ try {
+ dummy = QueryParser.getQueryParser().parseCommand(EXAMPLE_QUERY + i);
+ } catch (QueryParserException e) {
+ throw new RuntimeException(e);
+ }
+ PreparedPlanCache.PreparedPlan pPlan = cache.createPreparedPlan(token, dummy.toString(), false);
+ pPlan.setCommand(dummy);
+ pPlan.setPlan(new RelationalPlan(new ProjectNode(i)));
+ Map props = new HashMap();
+ props.put("desc", "desc"+i); //$NON-NLS-1$ //$NON-NLS-2$
+ AnalysisRecord analysisRecord = new AnalysisRecord(true, true, false);
+ analysisRecord.setQueryPlan(props);
+ pPlan.setAnalysisRecord(analysisRecord);
+ ArrayList refs = new ArrayList();
+ refs.add("ref"+i); //$NON-NLS-1$
+ pPlan.setReferences(refs);
+ }
+ }
+
+}
Property changes on: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java (from rev 569, trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestPreparedStatement.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,343 @@
+/*
+ * 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.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+
+import org.teiid.dqp.internal.process.DQPWorkContext;
+import org.teiid.dqp.internal.process.PreparedPlanCache;
+import org.teiid.dqp.internal.process.PreparedStatementRequest;
+import org.teiid.dqp.internal.process.TestRequest.FakeApplicationEnvironment;
+
+import junit.framework.TestCase;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.query.QueryParserException;
+import com.metamatrix.api.exception.query.QueryPlannerException;
+import com.metamatrix.api.exception.query.QueryResolverException;
+import com.metamatrix.api.exception.query.QueryValidatorException;
+import com.metamatrix.common.buffer.BufferManagerFactory;
+import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.platform.security.api.MetaMatrixSessionID;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.optimizer.TestOptimizer;
+import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
+import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
+import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
+import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
+import com.metamatrix.query.processor.FakeDataManager;
+import com.metamatrix.query.processor.ProcessorDataManager;
+import com.metamatrix.query.processor.ProcessorPlan;
+import com.metamatrix.query.processor.TestProcessor;
+import com.metamatrix.query.unittest.FakeMetadataFacade;
+import com.metamatrix.query.unittest.FakeMetadataFactory;
+
+public class TestPreparedStatement extends TestCase{
+
+ private static final long SESSION_ID = 6;
+
+ private static boolean DEBUG = false;
+
+ static class TestablePreparedPlanCache extends PreparedPlanCache {
+
+ int hitCount;
+
+ @Override
+ public synchronized PreparedPlan getPreparedPlan(
+ String clientConn, String sql,
+ boolean isPreparedBatchUpdate) {
+ PreparedPlan plan = super.getPreparedPlan(clientConn, sql, isPreparedBatchUpdate);
+ if (plan != null && plan.getPlan() != null) {
+ hitCount++;
+ }
+ return plan;
+ }
+ }
+
+ public TestPreparedStatement(String name) {
+ super(name);
+ }
+
+ static void helpTestProcessing(String preparedSql, List values, List[] expected, QueryMetadataInterface metadata, boolean callableStatement) throws Exception {
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ helpTestProcessing(preparedSql, values, expected, dataManager, metadata, callableStatement);
+ }
+
+ static void helpTestProcessing(String preparedSql, List values, List[] expected, ProcessorDataManager dataManager, QueryMetadataInterface metadata, boolean callableStatement) throws Exception {
+ TestablePreparedPlanCache prepPlan = new TestablePreparedPlanCache();
+ //Create plan
+ ProcessorPlan plan = TestPreparedStatement.helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), metadata, prepPlan, SESSION_ID, callableStatement, false);
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+
+ //test cached plan
+ plan = TestPreparedStatement.helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), metadata, prepPlan, SESSION_ID, callableStatement, false);
+
+ //make sure the plan is only created once
+ assertEquals("should reuse the plan", 1, prepPlan.hitCount); //$NON-NLS-1$
+
+ // Run query again
+ TestProcessor.helpProcess(plan, dataManager, expected);
+
+ //get the plan again with a new connection
+ assertNotNull(TestPreparedStatement.helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), metadata, prepPlan, 7, callableStatement, false));
+
+ assertEquals("new connection should not have used the same plan", 1, prepPlan.hitCount); //$NON-NLS-1$
+ }
+
+ public void testWhere() throws Exception {
+ // Create query
+ String preparedSql = "SELECT pm1.g1.e1, e2, pm1.g1.e3 as a, e4 as b FROM pm1.g1 WHERE e2=?"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
+ };
+
+ List values = new ArrayList();
+ values.add(new Short((short)0));
+
+ helpTestProcessing(preparedSql, values, expected, FakeMetadataFactory.example1Cached(), false);
+ }
+
+ public void testFunctionWithReferencePushDown() throws Exception {
+ // Create query
+ String preparedSql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = pm1.g2.e1 and pm1.g1.e2+2=?"; //$NON-NLS-1$
+
+ //Create plan
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_WHERE, true);
+ caps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE, true);
+ caps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE_GT, true);
+ caps.setCapabilitySupport(Capability.QUERY_WHERE_NOT, true);
+ caps.setCapabilitySupport(Capability.QUERY_WHERE_IN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setCapabilitySupport(Capability.FUNCTION, true);
+ caps.setFunctionSupport("+", false); //$NON-NLS-1$
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ List values = new ArrayList();
+ values.add(new Integer(0));
+
+ ProcessorPlan plan = helpGetProcessorPlan(preparedSql, values, capFinder, metadata, new PreparedPlanCache(), SESSION_ID, false, false);
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ private ProcessorPlan helpGetProcessorPlan(String preparedSql, List values, PreparedPlanCache prepPlanCache)
+ throws MetaMatrixComponentException, QueryParserException,
+ QueryResolverException, QueryValidatorException,
+ QueryPlannerException {
+ return helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), prepPlanCache, SESSION_ID, false, false);
+ }
+
+ private ProcessorPlan helpGetProcessorPlan(String preparedSql, List values,
+ PreparedPlanCache prepPlanCache, long conn)
+ throws MetaMatrixComponentException, QueryParserException,
+ QueryResolverException, QueryValidatorException,
+ QueryPlannerException {
+ return helpGetProcessorPlan(preparedSql, values,
+ new DefaultCapabilitiesFinder(), FakeMetadataFactory
+ .example1Cached(), prepPlanCache, conn, false, false);
+ }
+
+ static ProcessorPlan helpGetProcessorPlan(String preparedSql, List values,
+ CapabilitiesFinder capFinder, QueryMetadataInterface metadata, PreparedPlanCache prepPlanCache, long conn, boolean callableStatement, boolean limitResults)
+ throws MetaMatrixComponentException, QueryParserException,
+ QueryResolverException, QueryValidatorException,
+ QueryPlannerException {
+
+ //Create Request
+ RequestMessage request = new RequestMessage(preparedSql);
+ request.setPreparedStatement(true);
+ request.setCallableStatement(callableStatement);
+ request.setParameterValues(values);
+ if (limitResults) {
+ request.setRowLimit(1);
+ }
+
+ DQPWorkContext workContext = new DQPWorkContext();
+ workContext.setVdbName("example1");
+ workContext.setVdbVersion("1");
+ workContext.setSessionId(new MetaMatrixSessionID(conn));
+
+ PreparedStatementRequest serverRequest = new PreparedStatementRequest(prepPlanCache) {
+ @Override
+ protected void createProcessor()
+ throws MetaMatrixComponentException {
+ //don't bother
+ }
+ };
+ FakeApplicationEnvironment env = new FakeApplicationEnvironment(metadata, "example1", "1", "pm1", "1", "BINDING");
+ serverRequest.initialize(request, env, BufferManagerFactory.getStandaloneBufferManager(), null, new HashMap(), null, DEBUG, null, workContext, 101024);
+ serverRequest.setMetadata(capFinder, metadata, null);
+ serverRequest.processRequest();
+
+ ProcessorPlan plan = serverRequest.processPlan;
+ assertNotNull(plan);
+ return plan;
+ }
+
+ public void testValidateCorrectValues() throws Exception {
+ // Create query
+ String preparedSql = "SELECT pm1.g1.e1, e2, pm1.g1.e3 as a, e4 as b FROM pm1.g1 WHERE pm1.g1.e1=?"; //$NON-NLS-1$
+
+ List values = new ArrayList();
+ values.add("a"); //$NON-NLS-1$
+
+ //Create plan
+ helpGetProcessorPlan(preparedSql, values, new PreparedPlanCache());
+ }
+
+ /** SELECT pm1.g1.e1 FROM pm1.g1 WHERE pm1.g1.e2 IN (SELECT pm1.g2.e2 FROM pm1.g2 WHERE pm1.g2.e1 = ?)*/
+ public void testWithSubquery() throws Exception {
+ // Create query
+ String preparedSql = "SELECT pm1.g1.e1 FROM pm1.g1 WHERE pm1.g1.e2 IN (SELECT pm1.g2.e2 FROM pm1.g2 WHERE pm1.g2.e1 = ?)"; //$NON-NLS-1$
+
+ List values = new ArrayList();
+ values.add("a"); //$NON-NLS-1$
+
+ //Create plan
+ helpGetProcessorPlan(preparedSql, values, new PreparedPlanCache());
+ }
+
+ /** SELECT pm1.g1.e1 FROM pm1.g1 WHERE pm1.g1.e1 = ? AND pm1.g1.e2 IN (SELECT pm1.g2.e2 FROM pm1.g2 WHERE pm1.g2.e1 = ?) */
+ public void testWithSubquery2() throws Exception {
+ // Create query
+ String preparedSql = "SELECT pm1.g1.e1 FROM pm1.g1 WHERE pm1.g1.e1 = ? AND pm1.g1.e2 IN (SELECT pm1.g2.e2 FROM pm1.g2 WHERE pm1.g2.e1 = ?)"; //$NON-NLS-1$
+
+ List values = new ArrayList();
+ values.add("d"); //$NON-NLS-1$
+ values.add("c"); //$NON-NLS-1$
+
+ //Create plan
+ helpGetProcessorPlan(preparedSql, values, new PreparedPlanCache());
+ }
+
+ /** SELECT X.e1 FROM (SELECT pm1.g2.e1 FROM pm1.g2 WHERE pm1.g2.e1 = ?) as X */
+ public void testWithSubquery3() throws Exception {
+ // Create query
+ String preparedSql = "SELECT X.e1 FROM (SELECT pm1.g2.e1 FROM pm1.g2 WHERE pm1.g2.e1 = ?) as X"; //$NON-NLS-1$
+
+ //Create Request
+ List values = new ArrayList();
+ values.add("d"); //$NON-NLS-1$
+
+ //Create plan
+ helpGetProcessorPlan(preparedSql, values, new PreparedPlanCache());
+ }
+
+ public void testValidateWrongValues() throws Exception {
+ // Create query
+ String preparedSql = "SELECT pm1.g1.e1, e2, pm1.g1.e3 as a, e4 as b FROM pm1.g1 WHERE pm1.g1.e2=?"; //$NON-NLS-1$
+ TestablePreparedPlanCache prepCache = new TestablePreparedPlanCache();
+
+ //wrong type
+ try{
+ List values = new ArrayList();
+ values.add("x"); //$NON-NLS-1$
+
+ //Create plan
+ helpGetProcessorPlan(preparedSql, values, prepCache, SESSION_ID);
+ fail();
+ }catch(QueryResolverException qe){
+ assertEquals("Error converting parameter number 1 with value \"x\" to expected type integer.", qe.getMessage()); //$NON-NLS-1$
+ }
+ assertEquals(0, prepCache.hitCount);
+
+ //test cached plan
+ try{
+ List values = new ArrayList();
+ values.add("a"); //$NON-NLS-1$
+ values.add("b"); //$NON-NLS-1$
+ helpGetProcessorPlan(preparedSql, values, prepCache, SESSION_ID);
+ fail();
+ }catch(QueryResolverException qe){
+ assertEquals("The number of bound values '2' does not match the number of parameters '1' in the prepared statement.", qe.getMessage()); //$NON-NLS-1$
+ }
+
+ assertEquals(1, prepCache.hitCount);
+
+ //wrong number of values
+ try{
+ List values = new ArrayList();
+ values.add("a"); //$NON-NLS-1$
+ values.add(new Integer(0));
+ helpGetProcessorPlan(preparedSql, values, prepCache);
+ fail();
+ }catch(QueryResolverException qe){
+ assertEquals("The number of bound values '2' does not match the number of parameters '1' in the prepared statement.", qe.getMessage()); //$NON-NLS-1$
+ }
+
+ }
+
+ public void testResolveParameterValues() throws Exception {
+ // Create query
+ String preparedSql = "SELECT pm1.g1.e1, e2, pm1.g1.e3 as a, e4 as b FROM pm1.g1 WHERE pm1.g1.e2=?"; //$NON-NLS-1$
+
+ List values = new ArrayList();
+ //values.add("a");
+ values.add("0"); //$NON-NLS-1$
+
+ helpGetProcessorPlan(preparedSql, values, new PreparedPlanCache());
+ }
+
+ /**
+ * TODO: there may be other ways of handling this situation in the future
+ */
+ public void testLimitNoCache() throws Exception {
+ // Create query
+ String preparedSql = "SELECT pm1.g1.e1, e2, pm1.g1.e3 as a, e4 as b FROM pm1.g1 WHERE pm1.g1.e2=?"; //$NON-NLS-1$
+
+ List values = new ArrayList();
+ values.add("0"); //$NON-NLS-1$
+
+ TestablePreparedPlanCache planCache = new TestablePreparedPlanCache();
+
+ helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), planCache, SESSION_ID, false, true);
+
+ helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), planCache, SESSION_ID, false, true);
+ //make sure the plan wasn't reused
+ assertEquals(0, planCache.hitCount);
+ }
+
+}
Property changes on: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java (from rev 569, trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestRequest.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,288 @@
+/*
+ * 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.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.mockito.Mockito;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+import org.teiid.dqp.internal.process.PreparedPlanCache;
+import org.teiid.dqp.internal.process.PreparedStatementRequest;
+import org.teiid.dqp.internal.process.Request;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.query.QueryParserException;
+import com.metamatrix.api.exception.query.QueryPlannerException;
+import com.metamatrix.api.exception.query.QueryResolverException;
+import com.metamatrix.api.exception.query.QueryValidatorException;
+import com.metamatrix.common.application.ApplicationEnvironment;
+import com.metamatrix.common.application.ApplicationService;
+import com.metamatrix.common.buffer.BufferManager;
+import com.metamatrix.common.vdb.api.ModelInfo;
+import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.service.AutoGenDataService;
+import com.metamatrix.dqp.service.DQPServiceNames;
+import com.metamatrix.dqp.service.FakeAbstractService;
+import com.metamatrix.dqp.service.FakeAuthorizationService;
+import com.metamatrix.dqp.service.FakeVDBService;
+import com.metamatrix.dqp.service.MetadataService;
+import com.metamatrix.platform.security.api.MetaMatrixSessionID;
+import com.metamatrix.query.analysis.AnalysisRecord;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.parser.QueryParser;
+import com.metamatrix.query.processor.FakeDataManager;
+import com.metamatrix.query.resolver.QueryResolver;
+import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.unittest.FakeMetadataFacade;
+import com.metamatrix.query.unittest.FakeMetadataFactory;
+import com.metamatrix.query.unittest.FakeMetadataObject;
+import com.metamatrix.query.util.ContextProperties;
+
+
+/**
+ * @since 4.2
+ */
+public class TestRequest extends TestCase {
+
+ private final static String QUERY = "SELECT * FROM pm1.g1"; //$NON-NLS-1$
+ private final static String VDB = "VDB"; //$NON-NLS-1$
+ private final static String VDB_VERSION = "1"; //$NON-NLS-1$
+ private final static String MODEL = "pm1"; //$NON-NLS-1$
+ private final static String BINDING_ID = "1"; //$NON-NLS-1$
+ private final static String BINDING_NAME = "BINDING"; //$NON-NLS-1$
+
+ /**
+ * Constructor for TestRequest.
+ * @param name
+ */
+ public TestRequest(String name) {
+ super(name);
+ }
+
+ public void testGetSchemasForValidation() throws Exception {
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataObject doc1 = metadata.getStore().findObject("xmltest.doc1", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ List<String> schemas = Arrays.asList("a.xsd", "b.xsd"); //$NON-NLS-1$ //$NON-NLS-2$
+ doc1.putProperty(FakeMetadataObject.Props.XML_SCHEMAS, schemas);
+ RequestMessage message = new RequestMessage("select * from xmltest.doc1"); //$NON-NLS-1$
+ message.setValidationMode(true);
+ DQPWorkContext workContext = new DQPWorkContext();
+ workContext.setVdbName(VDB);
+ workContext.setVdbVersion(VDB_VERSION);
+ workContext.setSessionId(new MetaMatrixSessionID(5));
+ FakeApplicationEnvironment environment =
+ new FakeApplicationEnvironment(metadata, VDB, VDB_VERSION, MODEL, BINDING_ID, BINDING_NAME);
+ Request request = helpProcessMessage(environment, message, null, workContext);
+ assertEquals(schemas, request.schemas);
+ }
+
+
+ /**
+ * Test Request.validateEntitlement().
+ * Make sure that this can be called both before and after metadata is initialized.
+ * See defect 17209.
+ * @throws Exception
+ * @since 4.2
+ */
+ public void testValidateEntitlement() throws Exception {
+ QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
+
+
+ Request request = new Request();
+ Command command = QueryParser.getQueryParser().parseCommand(QUERY);
+ QueryResolver.resolveCommand(command, Collections.EMPTY_MAP, true, metadata, AnalysisRecord.createNonRecordingRecord());
+
+ RequestMessage message = new RequestMessage();
+ DQPWorkContext workContext = new DQPWorkContext();
+ workContext.setVdbName(VDB);
+ workContext.setVdbVersion(VDB_VERSION);
+ workContext.setSessionId(new MetaMatrixSessionID(5));
+ 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.initMetadata();
+ request.validateEntitlement(command);
+ }
+
+
+ /**
+ * Test Request.processRequest().
+ * Test processing the same query twice, and make sure that doesn't cause problems.
+ * See defect 17209.
+ * @throws Exception
+ * @since 4.2
+ */
+ public void testProcessRequest() throws Exception {
+ QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
+
+ FakeApplicationEnvironment environment =
+ new FakeApplicationEnvironment(metadata, VDB, VDB_VERSION, MODEL, BINDING_ID, BINDING_NAME);
+
+
+ //Try before plan is cached.
+ //If this doesn't throw an exception, assume it was successful.
+ RequestMessage message = new RequestMessage(QUERY);
+ DQPWorkContext workContext = new DQPWorkContext();
+ workContext.setVdbName(VDB);
+ workContext.setVdbVersion(VDB_VERSION);
+ workContext.setSessionId(new MetaMatrixSessionID(5));
+
+ helpProcessMessage(environment, message, null, workContext);
+
+ //Try again, now that plan is already cached.
+ //If this doesn't throw an exception, assume it was successful.
+ message = new RequestMessage(QUERY);
+ helpProcessMessage(environment, message, null, workContext);
+ }
+
+ public void testCommandContext() throws Exception {
+ QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
+
+ FakeApplicationEnvironment environment =
+ new FakeApplicationEnvironment(metadata, VDB, VDB_VERSION, MODEL, BINDING_ID, BINDING_NAME);
+
+
+ //Try before plan is cached.
+ //If this doesn't throw an exception, assume it was successful.
+ RequestMessage message = new RequestMessage(QUERY);
+ DQPWorkContext workContext = new DQPWorkContext();
+ workContext.setVdbName(VDB);
+ workContext.setVdbVersion(VDB_VERSION);
+ workContext.setSessionId(new MetaMatrixSessionID(5));
+ Request request = helpProcessMessage(environment, message, null, workContext);
+ assertEquals("00000000-0000-0005-0000-000000000005", request.context.getEnvironmentProperties().get(ContextProperties.SESSION_ID));
+ }
+
+ private Request helpProcessMessage(FakeApplicationEnvironment environment,
+ RequestMessage message, PreparedPlanCache cache, DQPWorkContext workContext) throws QueryValidatorException,
+ QueryParserException,
+ QueryResolverException,
+ MetaMatrixComponentException,
+ QueryPlannerException {
+ Request request = null;
+ if (cache != null) {
+ request = new PreparedStatementRequest(cache);
+ } else {
+ request = new Request();
+ }
+ request.initialize(message, environment, Mockito.mock(BufferManager.class),
+ new FakeDataManager(), new HashMap(), null, false, null,
+ workContext, 101024);
+
+ request.processRequest();
+ return request;
+ }
+
+
+
+
+ /**
+ * Test PreparedStatementRequest.processRequest().
+ * Test processing the same query twice, and make sure that doesn't cause problems.
+ * @throws Exception
+ * @since 4.2
+ */
+ public void testProcessRequestPreparedStatement() throws Exception {
+ QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
+ PreparedPlanCache cache = new PreparedPlanCache();
+ FakeApplicationEnvironment environment =
+ new FakeApplicationEnvironment(metadata, VDB, VDB_VERSION, MODEL, BINDING_ID, BINDING_NAME);
+
+
+ //Try before plan is cached.
+ //If this doesn't throw an exception, assume it was successful.
+ RequestMessage message = new RequestMessage(QUERY);
+ DQPWorkContext workContext = new DQPWorkContext();
+ workContext.setVdbName(VDB);
+ workContext.setVdbVersion(VDB_VERSION);
+ workContext.setSessionId(new MetaMatrixSessionID(5));
+ message.setPreparedStatement(true);
+ message.setParameterValues(new ArrayList());
+
+ helpProcessMessage(environment, message, cache, workContext);
+
+ //Try again, now that plan is already cached.
+ //If this doesn't throw an exception, assume it was successful.
+ message = new RequestMessage(QUERY);
+ message.setPreparedStatement(true);
+ message.setParameterValues(new ArrayList());
+
+ helpProcessMessage(environment, message, cache, workContext);
+ }
+
+
+ /**Fake ApplicationEnvironment that always returns the same metadata*/
+ public static final class FakeApplicationEnvironment extends ApplicationEnvironment {
+ private QueryMetadataInterface metadata;
+
+ private FakeVDBService fakeVDBService;
+
+ public FakeApplicationEnvironment(QueryMetadataInterface metadata, String vdbname, String version, String model,
+ String bindingID, String bindingName) {
+ this.metadata = metadata;
+
+ fakeVDBService = new FakeVDBService();
+ fakeVDBService.addModel(vdbname, version, model, ModelInfo.PUBLIC, false);
+ fakeVDBService.addBinding(vdbname, version, model, bindingID, bindingName);
+ }
+
+ public ApplicationService findService(String type) {
+ if (type == DQPServiceNames.METADATA_SERVICE) {
+ return new FakeMetadataService(metadata);
+ } else if (type == DQPServiceNames.VDB_SERVICE) {
+ return fakeVDBService;
+ } else if (type == DQPServiceNames.DATA_SERVICE) {
+ return new AutoGenDataService();
+ } else if (type == DQPServiceNames.AUTHORIZATION_SERVICE) {
+ return new FakeAuthorizationService(true);
+ }
+
+ return null;
+ }
+ }
+
+ /**Fake MetadataService that always returns the same metadata*/
+ public static final class FakeMetadataService extends FakeAbstractService implements MetadataService {
+ private QueryMetadataInterface metadata;
+
+
+ public FakeMetadataService(QueryMetadataInterface metadata) {
+ this.metadata = metadata;
+ }
+
+ public synchronized void addVdb() {
+ }
+
+ public synchronized QueryMetadataInterface lookupMetadata(String vdbName, String vdbVersion) {
+ return metadata;
+ }
+ }
+
+}
Property changes on: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequestWorkItem.java (from rev 569, trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestRequestWorkItem.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequestWorkItem.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequestWorkItem.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,45 @@
+/*
+ * 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.Arrays;
+import java.util.List;
+
+import org.teiid.dqp.internal.process.RequestWorkItem;
+
+import com.metamatrix.dqp.message.ResultsMessage;
+import com.metamatrix.dqp.message.TestRequestMessage;
+import com.metamatrix.query.sql.symbol.ElementSymbol;
+
+import junit.framework.TestCase;
+
+public class TestRequestWorkItem extends TestCase {
+
+ public void testResultsMetadata() {
+ ElementSymbol e1 = new ElementSymbol("g1.E1"); //name in metadata
+ e1.setOutputName("G1.e1"); //name in query
+ ResultsMessage message = RequestWorkItem.createResultsMessage(TestRequestMessage.example(), new List[] {}, Arrays.asList(e1), null);
+ assertEquals(Arrays.asList("e1"), Arrays.asList(message.getColumnNames()));
+ }
+
+}
Property changes on: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequestWorkItem.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestWorkItemState.java (from rev 569, trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestWorkItemState.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestWorkItemState.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestWorkItemState.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -0,0 +1,159 @@
+/*
+ * 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 org.teiid.dqp.internal.process.AbstractWorkItem;
+
+import junit.framework.TestCase;
+
+public class TestWorkItemState extends TestCase {
+
+ private class TestWorkItem extends AbstractWorkItem {
+
+ private boolean isDone;
+ private boolean callMoreWork;
+ private boolean resumed;
+
+ private TestWorkItem() {
+ this(false, false);
+ }
+
+ private TestWorkItem(boolean done, boolean callMoreWork) {
+ this.isDone = done;
+ this.callMoreWork = callMoreWork;
+ }
+
+ @Override
+ protected boolean isDoneProcessing() {
+ return isDone;
+ }
+
+ @Override
+ protected void process() {
+ assertWorkingState();
+ if (callMoreWork) {
+ this.moreWork();
+ }
+ }
+
+ @Override
+ protected void resumeProcessing() {
+ this.resumed = true;
+ }
+
+ @Override
+ public String toString() {
+ return "TestItem"; //$NON-NLS-1$
+ }
+
+ private void checkState(ThreadState expectedState) {
+ assertEquals(expectedState, getThreadState());
+ }
+
+ private void assertIdleState() {
+ checkState(ThreadState.IDLE);
+ }
+
+ private void assertMoreWorkState() {
+ checkState(ThreadState.MORE_WORK);
+ }
+
+ private void assertWorkingState() {
+ checkState(ThreadState.WORKING);
+ }
+
+ private void assertDoneState() {
+ checkState(ThreadState.DONE);
+ }
+
+ }
+
+ public TestWorkItemState(String name) {
+ super(name);
+ }
+
+ public void testInitialState() {
+ TestWorkItem item = new TestWorkItem();
+ item.assertMoreWorkState();
+ }
+
+ public void testGotoIdleState() {
+ TestWorkItem item = new TestWorkItem();
+ item.run();
+ item.assertIdleState();
+ }
+
+ public void testGotoMoreWorkState() {
+ TestWorkItem item = new TestWorkItem();
+ item.run();
+ item.moreWork();
+ item.assertMoreWorkState();
+ }
+
+ public void testGotoWorkingState() {
+ TestWorkItem item = new TestWorkItem();
+ item.run();
+ item.moreWork();
+ item.run();
+ }
+
+ public void testResume() {
+ TestWorkItem item = new TestWorkItem();
+ item.run();
+ assertFalse(item.resumed);
+ item.moreWork();
+ assertTrue(item.resumed);
+ }
+
+ public void testResumeDuringWorking() {
+ TestWorkItem item = new TestWorkItem(false, true);
+ assertFalse(item.resumed);
+ item.run();
+ assertTrue(item.resumed);
+ }
+
+ public void testRunAfterDone() {
+ TestWorkItem item = new TestWorkItem(true, false);
+ item.run();
+ item.assertDoneState();
+ try {
+ item.run();
+ fail("exception expected"); //$NON-NLS-1$
+ } catch (IllegalStateException e) {
+
+ }
+ }
+
+ public void testRunDuringIdle() {
+ TestWorkItem item = new TestWorkItem();
+ item.run();
+ item.assertIdleState();
+ try {
+ item.run();
+ fail("exception expected"); //$NON-NLS-1$
+ } catch (IllegalStateException e) {
+
+ }
+ }
+
+}
Property changes on: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestWorkItemState.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/process/capabilities (from rev 569, trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/capabilities)
Property changes on: trunk/engine/src/test/java/org/teiid/dqp/internal/process/capabilities
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/capabilities/TestConnectorCapabilitiesFinder.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/capabilities/TestConnectorCapabilitiesFinder.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/capabilities/TestConnectorCapabilitiesFinder.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,15 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.process.capabilities;
+package org.teiid.dqp.internal.process.capabilities;
import java.util.Arrays;
import junit.framework.TestCase;
import org.mockito.Mockito;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+import org.teiid.dqp.internal.process.capabilities.ConnectorCapabilitiesFinder;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.dqp.service.AutoGenDataService;
import com.metamatrix.dqp.service.DataService;
Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource (from rev 569, trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/multisource)
Property changes on: trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceCapabilitiesFinder.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/multisource/TestMultiSourceCapabilitiesFinder.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceCapabilitiesFinder.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,11 +20,13 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.process.multisource;
+package org.teiid.dqp.internal.process.multisource;
import java.util.ArrayList;
import java.util.List;
+import org.teiid.dqp.internal.process.multisource.MultiSourceCapabilitiesFinder;
+
import junit.framework.TestCase;
import com.metamatrix.query.optimizer.capabilities.AllCapabilities;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceElementReplacementVisitor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/multisource/TestMultiSourceElementReplacementVisitor.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceElementReplacementVisitor.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,10 +20,13 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.process.multisource;
+package org.teiid.dqp.internal.process.multisource;
import java.util.Collection;
+import org.teiid.dqp.internal.process.multisource.MultiSourceElementReplacementVisitor;
+import org.teiid.dqp.internal.process.multisource.MultiSourceMetadataWrapper;
+
import junit.framework.TestCase;
import com.metamatrix.common.vdb.api.ModelInfo;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceMetadataWrapper.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/multisource/TestMultiSourceMetadataWrapper.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceMetadataWrapper.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,12 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.process.multisource;
+package org.teiid.dqp.internal.process.multisource;
import java.util.Collection;
import java.util.List;
import java.util.Properties;
+import org.teiid.dqp.internal.process.multisource.MultiSourceElement;
+import org.teiid.dqp.internal.process.multisource.MultiSourceMetadataWrapper;
+
import junit.framework.TestCase;
import com.metamatrix.common.types.DataTypeManager;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.process.multisource;
+package org.teiid.dqp.internal.process.multisource;
import java.util.Arrays;
import java.util.Collection;
@@ -30,6 +30,11 @@
import java.util.Properties;
import java.util.Set;
+import org.teiid.dqp.internal.process.multisource.MultiSourceCapabilitiesFinder;
+import org.teiid.dqp.internal.process.multisource.MultiSourceElement;
+import org.teiid.dqp.internal.process.multisource.MultiSourceMetadataWrapper;
+import org.teiid.dqp.internal.process.multisource.MultiSourcePlanToProcessConverter;
+
import junit.framework.TestCase;
import com.metamatrix.common.buffer.TupleSource;
Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator (from rev 569, trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/validator)
Property changes on: trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestAuthorizationValidationVisitor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/validator/TestAuthorizationValidationVisitor.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestAuthorizationValidationVisitor.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,13 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.process.validator;
+package org.teiid.dqp.internal.process.validator;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
+import org.teiid.dqp.internal.process.validator.AuthorizationValidationVisitor;
+
import junit.framework.TestCase;
import com.metamatrix.api.exception.MetaMatrixComponentException;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestModelVisibilityValidationVisitor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/validator/TestModelVisibilityValidationVisitor.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestModelVisibilityValidationVisitor.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,15 +20,17 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.process.validator;
+package org.teiid.dqp.internal.process.validator;
+import org.teiid.dqp.internal.process.Request;
+import org.teiid.dqp.internal.process.validator.ModelVisibilityValidationVisitor;
+
import junit.framework.TestCase;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryParserException;
import com.metamatrix.api.exception.query.QueryValidatorException;
import com.metamatrix.common.vdb.api.ModelInfo;
-import com.metamatrix.dqp.internal.process.Request;
import com.metamatrix.dqp.service.FakeVDBService;
import com.metamatrix.query.parser.QueryParser;
import com.metamatrix.query.sql.lang.Command;
Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/transaction (from rev 569, trunk/engine/src/test/java/com/metamatrix/dqp/internal/transaction)
Property changes on: trunk/engine/src/test/java/org/teiid/dqp/internal/transaction
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionContextImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/transaction/TestTransactionContextImpl.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionContextImpl.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.transaction;
+package org.teiid.dqp.internal.transaction;
import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
@@ -30,6 +30,8 @@
import javax.transaction.Transaction;
import javax.transaction.xa.XAResource;
+import org.teiid.dqp.internal.transaction.TransactionContextImpl;
+
import junit.framework.TestCase;
import com.metamatrix.core.MetaMatrixRuntimeException;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/transaction/TestTransactionServer.java 2009-03-17 20:02:26 UTC (rev 569)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java 2009-03-18 20:11:01 UTC (rev 591)
@@ -20,10 +20,13 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.internal.transaction;
+package org.teiid.dqp.internal.transaction;
import javax.transaction.xa.XAResource;
+import org.teiid.dqp.internal.transaction.TransactionProvider;
+import org.teiid.dqp.internal.transaction.TransactionServerImpl;
+
import junit.framework.TestCase;
import com.metamatrix.common.xa.MMXid;
15 years, 2 months
teiid SVN: r590 - in trunk/embedded/src/main/java/com/metamatrix: jdbc and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-03-18 16:09:39 -0400 (Wed, 18 Mar 2009)
New Revision: 590
Modified:
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedDataService.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedTransactionService.java
trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
trunk/embedded/src/main/java/com/metamatrix/jdbc/transport/LocalServerConnection.java
Log:
TEIID-346 adding in a compatibility layer with 5.5 connectors.
Modified: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedDataService.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedDataService.java 2009-03-18 20:09:36 UTC (rev 589)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedDataService.java 2009-03-18 20:09:39 UTC (rev 590)
@@ -35,6 +35,8 @@
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.internal.ConnectorPropertyNames;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
+import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.api.exception.ComponentNotFoundException;
import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -56,8 +58,6 @@
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
import com.metamatrix.dqp.embedded.configuration.ExtensionModuleReader;
import com.metamatrix.dqp.internal.datamgr.ConnectorID;
-import com.metamatrix.dqp.internal.datamgr.impl.ConnectorManager;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.dqp.message.AtomicRequestID;
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.message.AtomicResultsMessage;
Modified: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedTransactionService.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedTransactionService.java 2009-03-18 20:09:36 UTC (rev 589)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedTransactionService.java 2009-03-18 20:09:39 UTC (rev 590)
@@ -24,6 +24,8 @@
import java.util.Properties;
+import org.teiid.dqp.internal.transaction.TransactionServerImpl;
+
import com.metamatrix.common.application.ApplicationEnvironment;
import com.metamatrix.common.application.exception.ApplicationInitializationException;
import com.metamatrix.common.application.exception.ApplicationLifecycleException;
@@ -32,7 +34,6 @@
import com.metamatrix.common.xa.XATransactionException;
import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
-import com.metamatrix.dqp.internal.transaction.TransactionServerImpl;
import com.metamatrix.dqp.service.TransactionService;
import com.metamatrix.dqp.transaction.TransactionServer;
import com.metamatrix.dqp.transaction.XAServer;
Modified: trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java 2009-03-18 20:09:36 UTC (rev 589)
+++ trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java 2009-03-18 20:09:39 UTC (rev 590)
@@ -30,6 +30,8 @@
import java.util.List;
import java.util.Properties;
+import org.teiid.dqp.internal.process.DQPCore;
+
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -44,7 +46,6 @@
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.dqp.ResourceFinder;
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
-import com.metamatrix.dqp.internal.process.DQPCore;
import com.metamatrix.dqp.service.ConfigurationService;
import com.metamatrix.dqp.service.DQPServiceNames;
import com.metamatrix.dqp.service.VDBService;
Modified: trunk/embedded/src/main/java/com/metamatrix/jdbc/transport/LocalServerConnection.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/jdbc/transport/LocalServerConnection.java 2009-03-18 20:09:36 UTC (rev 589)
+++ trunk/embedded/src/main/java/com/metamatrix/jdbc/transport/LocalServerConnection.java 2009-03-18 20:09:39 UTC (rev 590)
@@ -28,13 +28,14 @@
import java.lang.reflect.Proxy;
import java.util.Properties;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.client.ExceptionUtil;
import com.metamatrix.common.api.MMURL;
import com.metamatrix.common.comm.api.ServerConnection;
import com.metamatrix.common.comm.api.ServerConnectionListener;
import com.metamatrix.dqp.client.ClientSideDQP;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.jdbc.JDBCPlugin;
import com.metamatrix.platform.security.api.LogonResult;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
15 years, 2 months
teiid SVN: r589 - in trunk/server/src: main/java/com/metamatrix/common/comm/platform/socket/server and 7 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-03-18 16:09:36 -0400 (Wed, 18 Mar 2009)
New Revision: 589
Modified:
trunk/server/src/main/java/com/metamatrix/admin/server/AbstractAdminImpl.java
trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/AdminAuthorizationInterceptor.java
trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/ClientInstance.java
trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/LogonImpl.java
trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/ServerWorkItem.java
trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/SocketClientInstance.java
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/AdminHelper.java
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/SessionAdminAPIImpl.java
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/SubSystemAdminAPIImpl.java
trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorService.java
trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorServiceInterface.java
trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformAuthorizationService.java
trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformDataService.java
trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformTransactionService.java
trunk/server/src/main/java/com/metamatrix/server/query/service/QueryService.java
trunk/server/src/test/java/com/metamatrix/admin/server/FakeServerAdminImpl.java
trunk/server/src/test/java/com/metamatrix/common/comm/platform/server/TestAdminAuthInterceptor.java
trunk/server/src/test/java/com/metamatrix/common/comm/platform/socket/server/TestSocketRemoting.java
Log:
TEIID-346 adding in a compatibility layer with 5.5 connectors.
Modified: trunk/server/src/main/java/com/metamatrix/admin/server/AbstractAdminImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/admin/server/AbstractAdminImpl.java 2009-03-18 20:09:30 UTC (rev 588)
+++ trunk/server/src/main/java/com/metamatrix/admin/server/AbstractAdminImpl.java 2009-03-18 20:09:36 UTC (rev 589)
@@ -36,6 +36,7 @@
import javax.xml.parsers.ParserConfigurationException;
+import org.teiid.dqp.internal.process.DQPWorkContext;
import org.xml.sax.SAXException;
import com.metamatrix.admin.api.exception.AdminComponentException;
@@ -64,7 +65,6 @@
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.object.PropertyDefinition;
import com.metamatrix.common.util.LogContextsUtil.PlatformAdminConstants;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.metadata.runtime.RuntimeMetadataCatalog;
import com.metamatrix.metadata.runtime.api.Model;
import com.metamatrix.metadata.runtime.api.VirtualDatabase;
Modified: trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/AdminAuthorizationInterceptor.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/AdminAuthorizationInterceptor.java 2009-03-18 20:09:30 UTC (rev 588)
+++ trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/AdminAuthorizationInterceptor.java 2009-03-18 20:09:36 UTC (rev 589)
@@ -26,6 +26,8 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+
import com.metamatrix.admin.api.exception.AdminProcessingException;
import com.metamatrix.admin.api.server.ServerAdmin;
import com.metamatrix.admin.util.AdminMethodRoleResolver;
@@ -37,7 +39,6 @@
import com.metamatrix.common.util.LogContextsUtil.PlatformAdminConstants;
import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.ArgCheck;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.platform.admin.apiimpl.IAdminHelper;
import com.metamatrix.platform.security.api.SessionToken;
Modified: trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/ClientInstance.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/ClientInstance.java 2009-03-18 20:09:30 UTC (rev 588)
+++ trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/ClientInstance.java 2009-03-18 20:09:36 UTC (rev 589)
@@ -24,10 +24,11 @@
import java.io.Serializable;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+
import com.metamatrix.common.comm.api.Message;
import com.metamatrix.common.comm.exception.CommunicationException;
import com.metamatrix.common.util.crypto.Cryptor;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
/**
* Represents a ClientConnection from the server's point of view. This interface
Modified: trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/LogonImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/LogonImpl.java 2009-03-18 20:09:30 UTC (rev 588)
+++ trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/LogonImpl.java 2009-03-18 20:09:36 UTC (rev 589)
@@ -29,6 +29,7 @@
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.CredentialMap;
+import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.admin.api.exception.security.InvalidSessionException;
import com.metamatrix.api.exception.ComponentNotFoundException;
@@ -39,7 +40,6 @@
import com.metamatrix.common.api.MMURL;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.dqp.client.ResultsFuture;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.jdbc.api.ConnectionProperties;
import com.metamatrix.platform.security.api.Credentials;
import com.metamatrix.platform.security.api.ILogon;
Modified: trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/ServerWorkItem.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/ServerWorkItem.java 2009-03-18 20:09:30 UTC (rev 588)
+++ trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/ServerWorkItem.java 2009-03-18 20:09:36 UTC (rev 589)
@@ -32,6 +32,8 @@
import javax.crypto.SealedObject;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+
import com.metamatrix.admin.api.exception.AdminException;
import com.metamatrix.admin.api.exception.AdminProcessingException;
import com.metamatrix.api.exception.ComponentNotFoundException;
@@ -47,7 +49,6 @@
import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.ReflectionHelper;
import com.metamatrix.dqp.client.ResultsFuture;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.platform.PlatformPlugin;
import com.metamatrix.platform.security.api.ILogon;
import com.metamatrix.platform.security.api.service.SessionServiceInterface;
Modified: trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/SocketClientInstance.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/SocketClientInstance.java 2009-03-18 20:09:30 UTC (rev 588)
+++ trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/SocketClientInstance.java 2009-03-18 20:09:36 UTC (rev 589)
@@ -26,6 +26,8 @@
import java.net.InetSocketAddress;
import java.net.SocketAddress;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+
import com.metamatrix.common.comm.ClientServiceRegistry;
import com.metamatrix.common.comm.api.Message;
import com.metamatrix.common.comm.exception.CommunicationException;
@@ -41,7 +43,6 @@
import com.metamatrix.common.util.crypto.DhKeyGenerator;
import com.metamatrix.common.util.crypto.NullCryptor;
import com.metamatrix.core.log.MessageLevel;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.platform.security.api.service.SessionServiceInterface;
/**
Modified: trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/AdminHelper.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/AdminHelper.java 2009-03-18 20:09:30 UTC (rev 588)
+++ trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/AdminHelper.java 2009-03-18 20:09:36 UTC (rev 589)
@@ -22,6 +22,8 @@
package com.metamatrix.platform.admin.apiimpl;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+
import com.metamatrix.admin.AdminMessages;
import com.metamatrix.admin.AdminPlugin;
import com.metamatrix.admin.api.exception.security.InvalidSessionException;
@@ -31,7 +33,6 @@
import com.metamatrix.api.exception.security.SessionServiceException;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.core.log.MessageLevel;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.platform.admin.api.PlatformAdminLogConstants;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
Modified: trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/SessionAdminAPIImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/SessionAdminAPIImpl.java 2009-03-18 20:09:30 UTC (rev 588)
+++ trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/SessionAdminAPIImpl.java 2009-03-18 20:09:36 UTC (rev 589)
@@ -24,12 +24,13 @@
import java.util.Collection;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+
import com.metamatrix.admin.api.exception.security.InvalidSessionException;
import com.metamatrix.admin.api.server.AdminRoles;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.security.AuthorizationException;
import com.metamatrix.api.exception.security.SessionServiceException;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.platform.admin.api.SessionAdminAPI;
import com.metamatrix.platform.security.api.MetaMatrixPrincipal;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
Modified: trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/SubSystemAdminAPIImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/SubSystemAdminAPIImpl.java 2009-03-18 20:09:30 UTC (rev 588)
+++ trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/SubSystemAdminAPIImpl.java 2009-03-18 20:09:36 UTC (rev 589)
@@ -22,7 +22,8 @@
package com.metamatrix.platform.admin.apiimpl;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+
import com.metamatrix.platform.admin.api.SubSystemAdminAPI;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
Modified: trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorService.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorService.java 2009-03-18 20:09:30 UTC (rev 588)
+++ trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorService.java 2009-03-18 20:09:36 UTC (rev 589)
@@ -43,6 +43,9 @@
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.internal.ConnectorPropertyNames;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
+import org.teiid.dqp.internal.process.DQPCore;
+import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.application.ApplicationEnvironment;
@@ -78,9 +81,6 @@
import com.metamatrix.core.util.ReflectionHelper;
import com.metamatrix.dqp.client.ClientSideDQP;
import com.metamatrix.dqp.internal.datamgr.ConnectorID;
-import com.metamatrix.dqp.internal.datamgr.impl.ConnectorManager;
-import com.metamatrix.dqp.internal.process.DQPCore;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.dqp.message.AtomicRequestID;
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.message.AtomicResultsMessage;
Modified: trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorServiceInterface.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorServiceInterface.java 2009-03-18 20:09:30 UTC (rev 588)
+++ trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorServiceInterface.java 2009-03-18 20:09:36 UTC (rev 589)
@@ -29,11 +29,11 @@
import java.io.Serializable;
import org.teiid.connector.api.ConnectorException;
+import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.comm.api.ResultsReceiver;
import com.metamatrix.dqp.internal.datamgr.ConnectorID;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.dqp.message.AtomicRequestID;
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.message.AtomicResultsMessage;
Modified: trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformAuthorizationService.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformAuthorizationService.java 2009-03-18 20:09:30 UTC (rev 588)
+++ trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformAuthorizationService.java 2009-03-18 20:09:36 UTC (rev 589)
@@ -29,6 +29,8 @@
import java.util.List;
import java.util.Properties;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+
import com.google.inject.Inject;
import com.metamatrix.admin.api.exception.security.InvalidSessionException;
import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -39,7 +41,6 @@
import com.metamatrix.common.application.exception.ApplicationInitializationException;
import com.metamatrix.common.application.exception.ApplicationLifecycleException;
import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.dqp.service.AuthorizationService;
import com.metamatrix.platform.security.api.AuthorizationActions;
import com.metamatrix.platform.security.api.AuthorizationPermission;
Modified: trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformDataService.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformDataService.java 2009-03-18 20:09:30 UTC (rev 588)
+++ trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformDataService.java 2009-03-18 20:09:36 UTC (rev 589)
@@ -32,6 +32,7 @@
import java.util.concurrent.ConcurrentHashMap;
import org.teiid.connector.api.ConnectorException;
+import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.api.exception.ComponentNotFoundException;
import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -42,7 +43,6 @@
import com.metamatrix.common.config.api.ConnectorBinding;
import com.metamatrix.core.util.ArgCheck;
import com.metamatrix.dqp.internal.datamgr.ConnectorID;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.dqp.message.AtomicRequestID;
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.message.AtomicResultsMessage;
Modified: trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformTransactionService.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformTransactionService.java 2009-03-18 20:09:30 UTC (rev 588)
+++ trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformTransactionService.java 2009-03-18 20:09:36 UTC (rev 589)
@@ -26,6 +26,8 @@
import java.util.Properties;
+import org.teiid.dqp.internal.transaction.TransactionServerImpl;
+
import com.google.inject.Inject;
import com.google.inject.name.Named;
import com.metamatrix.common.application.ApplicationEnvironment;
@@ -41,7 +43,6 @@
import com.metamatrix.common.xa.XATransactionException;
import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.FileUtils;
-import com.metamatrix.dqp.internal.transaction.TransactionServerImpl;
import com.metamatrix.dqp.service.TransactionService;
import com.metamatrix.dqp.transaction.TransactionServer;
import com.metamatrix.dqp.transaction.XAServer;
Modified: trunk/server/src/main/java/com/metamatrix/server/query/service/QueryService.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/query/service/QueryService.java 2009-03-18 20:09:30 UTC (rev 588)
+++ trunk/server/src/main/java/com/metamatrix/server/query/service/QueryService.java 2009-03-18 20:09:36 UTC (rev 589)
@@ -33,6 +33,8 @@
import java.util.Map;
import java.util.Properties;
+import org.teiid.dqp.internal.process.DQPCore;
+
import com.metamatrix.api.exception.ComponentNotFoundException;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.server.InvalidRequestIDException;
@@ -50,7 +52,6 @@
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.dqp.DQPPlugin;
import com.metamatrix.dqp.client.ClientSideDQP;
-import com.metamatrix.dqp.internal.process.DQPCore;
import com.metamatrix.dqp.message.RequestID;
import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.platform.service.api.CacheAdmin;
Modified: trunk/server/src/test/java/com/metamatrix/admin/server/FakeServerAdminImpl.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/admin/server/FakeServerAdminImpl.java 2009-03-18 20:09:30 UTC (rev 588)
+++ trunk/server/src/test/java/com/metamatrix/admin/server/FakeServerAdminImpl.java 2009-03-18 20:09:36 UTC (rev 589)
@@ -24,10 +24,11 @@
import java.util.Collection;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.extensionmodule.ExtensionModuleManager;
import com.metamatrix.core.util.SimpleMock;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.platform.admin.apiimpl.RuntimeStateAdminAPIHelper;
import com.metamatrix.platform.config.api.service.ConfigurationServiceInterface;
import com.metamatrix.platform.registry.ClusteredRegistryState;
Modified: trunk/server/src/test/java/com/metamatrix/common/comm/platform/server/TestAdminAuthInterceptor.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/common/comm/platform/server/TestAdminAuthInterceptor.java 2009-03-18 20:09:30 UTC (rev 588)
+++ trunk/server/src/test/java/com/metamatrix/common/comm/platform/server/TestAdminAuthInterceptor.java 2009-03-18 20:09:36 UTC (rev 589)
@@ -26,6 +26,8 @@
import java.util.HashSet;
import java.util.Set;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+
import junit.framework.TestCase;
import com.metamatrix.admin.api.exception.AdminException;
@@ -35,7 +37,6 @@
import com.metamatrix.common.comm.platform.FakeAdminHelper;
import com.metamatrix.common.comm.platform.socket.server.AdminAuthorizationInterceptor;
import com.metamatrix.core.util.SimpleMock;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.platform.admin.apiimpl.IAdminHelper;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
Modified: trunk/server/src/test/java/com/metamatrix/common/comm/platform/socket/server/TestSocketRemoting.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/common/comm/platform/socket/server/TestSocketRemoting.java 2009-03-18 20:09:30 UTC (rev 588)
+++ trunk/server/src/test/java/com/metamatrix/common/comm/platform/socket/server/TestSocketRemoting.java 2009-03-18 20:09:36 UTC (rev 589)
@@ -29,6 +29,8 @@
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+
import junit.framework.TestCase;
@@ -54,7 +56,6 @@
import com.metamatrix.core.util.SimpleMock;
import com.metamatrix.dqp.client.ClientSideDQP;
import com.metamatrix.dqp.client.ResultsFuture;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.platform.security.api.ILogon;
import com.metamatrix.platform.security.api.LogonResult;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
15 years, 2 months
teiid SVN: r588 - in trunk/txn-jbossts/src: test/java/com/metamatrix/xa/arjuna and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-03-18 16:09:30 -0400 (Wed, 18 Mar 2009)
New Revision: 588
Modified:
trunk/txn-jbossts/src/main/java/com/metamatrix/xa/arjuna/ArjunaTransactionProvider.java
trunk/txn-jbossts/src/main/java/com/metamatrix/xa/arjuna/XAConnectorRecovery.java
trunk/txn-jbossts/src/test/java/com/metamatrix/xa/arjuna/TestArjunaRecovery.java
Log:
TEIID-346 adding in a compatibility layer with 5.5 connectors.
Modified: trunk/txn-jbossts/src/main/java/com/metamatrix/xa/arjuna/ArjunaTransactionProvider.java
===================================================================
--- trunk/txn-jbossts/src/main/java/com/metamatrix/xa/arjuna/ArjunaTransactionProvider.java 2009-03-18 20:09:28 UTC (rev 587)
+++ trunk/txn-jbossts/src/main/java/com/metamatrix/xa/arjuna/ArjunaTransactionProvider.java 2009-03-18 20:09:30 UTC (rev 588)
@@ -37,6 +37,7 @@
import org.apache.log4j.PatternLayout;
import org.apache.log4j.RollingFileAppender;
import org.apache.log4j.spi.LoggingEvent;
+import org.teiid.dqp.internal.transaction.TransactionProvider;
import com.arjuna.ats.arjuna.common.Configuration;
import com.arjuna.ats.arjuna.common.arjPropertyManager;
@@ -56,7 +57,6 @@
import com.metamatrix.common.xa.MMXid;
import com.metamatrix.common.xa.XATransactionException;
import com.metamatrix.core.log.MessageLevel;
-import com.metamatrix.dqp.internal.transaction.TransactionProvider;
import com.metamatrix.dqp.service.TransactionService;
public class ArjunaTransactionProvider implements TransactionProvider {
@@ -83,7 +83,7 @@
}
/**
- * @see com.metamatrix.dqp.internal.transaction.TransactionProvider#init(java.lang.String)
+ * @see org.teiid.dqp.internal.transaction.TransactionProvider#init(java.lang.String)
*/
public void init(Properties props) throws XATransactionException {
// unique name for this txn manager
@@ -151,28 +151,28 @@
}
/**
- * @see com.metamatrix.dqp.internal.transaction.TransactionProvider#getXATerminator()
+ * @see org.teiid.dqp.internal.transaction.TransactionProvider#getXATerminator()
*/
public XATerminator getXATerminator() {
return terminator;
}
/**
- * @see com.metamatrix.dqp.internal.transaction.TransactionProvider#getTransactionManager()
+ * @see org.teiid.dqp.internal.transaction.TransactionProvider#getTransactionManager()
*/
public TransactionManager getTransactionManager() {
return com.arjuna.ats.jta.TransactionManager.transactionManager();
}
/**
- * @see com.metamatrix.dqp.internal.transaction.TransactionProvider#importTransaction(com.metamatrix.common.xa.MMXid, int)
+ * @see org.teiid.dqp.internal.transaction.TransactionProvider#importTransaction(com.metamatrix.common.xa.MMXid, int)
*/
public Transaction importTransaction(MMXid xid, int timeout) throws XAException {
return TxImporter.importTransaction(xid, timeout);
}
/**
- * @see com.metamatrix.dqp.internal.transaction.TransactionProvider#getTransactionID(javax.transaction.Transaction)
+ * @see org.teiid.dqp.internal.transaction.TransactionProvider#getTransactionID(javax.transaction.Transaction)
*/
public String getTransactionID(Transaction tx) {
TransactionImple arjunaTx = (TransactionImple)tx;
@@ -180,7 +180,7 @@
}
/**
- * @see com.metamatrix.dqp.internal.transaction.TransactionProvider#shutdown()
+ * @see org.teiid.dqp.internal.transaction.TransactionProvider#shutdown()
*/
public void shutdown() {
if (this.recoveryManager != null) {
Modified: trunk/txn-jbossts/src/main/java/com/metamatrix/xa/arjuna/XAConnectorRecovery.java
===================================================================
--- trunk/txn-jbossts/src/main/java/com/metamatrix/xa/arjuna/XAConnectorRecovery.java 2009-03-18 20:09:28 UTC (rev 587)
+++ trunk/txn-jbossts/src/main/java/com/metamatrix/xa/arjuna/XAConnectorRecovery.java 2009-03-18 20:09:30 UTC (rev 588)
@@ -30,8 +30,9 @@
import javax.transaction.xa.XAResource;
+import org.teiid.dqp.internal.transaction.TransactionProvider.XAConnectionSource;
+
import com.arjuna.ats.jta.recovery.XAResourceRecovery;
-import com.metamatrix.dqp.internal.transaction.TransactionProvider.XAConnectionSource;
/**
Modified: trunk/txn-jbossts/src/test/java/com/metamatrix/xa/arjuna/TestArjunaRecovery.java
===================================================================
--- trunk/txn-jbossts/src/test/java/com/metamatrix/xa/arjuna/TestArjunaRecovery.java 2009-03-18 20:09:28 UTC (rev 587)
+++ trunk/txn-jbossts/src/test/java/com/metamatrix/xa/arjuna/TestArjunaRecovery.java 2009-03-18 20:09:30 UTC (rev 588)
@@ -31,13 +31,13 @@
import javax.transaction.xa.Xid;
import org.teiid.connector.api.ConnectorException;
+import org.teiid.dqp.internal.transaction.TransactionProvider;
import junit.framework.TestCase;
import com.arjuna.ats.arjuna.common.Configuration;
import com.arjuna.ats.arjuna.recovery.RecoveryConfiguration;
import com.metamatrix.common.xa.MMXid;
-import com.metamatrix.dqp.internal.transaction.TransactionProvider;
import com.metamatrix.dqp.service.TransactionService;
15 years, 2 months