teiid SVN: r1488 - trunk/engine/src/main/java/com/metamatrix/query/processor/proc.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-09-28 17:11:23 -0400 (Mon, 28 Sep 2009)
New Revision: 1488
Modified:
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java
Log:
TEIID-849 fix for resolving subqueries in stored procedure parameters and for using the appropriate context information.
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java 2009-09-28 21:07:51 UTC (rev 1487)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java 2009-09-28 21:11:23 UTC (rev 1488)
@@ -83,6 +83,7 @@
// State initialized by processor
private ProcessorDataManager dataMgr;
+ private ProcessorDataManager parentDataMrg;
private BufferManager bufferMgr;
private int batchSize;
@@ -139,6 +140,7 @@
this.batchSize = bufferMgr.getProcessorBatchSize();
setContext(context);
this.dataMgr = dataMgr;
+ this.parentDataMrg = dataMgr;
if (evaluator == null) {
this.evaluator = new SubqueryAwareEvaluator(Collections.emptyMap(), getDataManager(), getContext(), this.bufferMgr);
}
@@ -318,6 +320,7 @@
this.evaluator.close();
}
this.tempTableStore = null;
+ this.dataMgr = parentDataMrg;
}
public String toString() {
15 years, 3 months
teiid SVN: r1487 - in trunk: connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal and 10 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-09-28 17:07:51 -0400 (Mon, 28 Sep 2009)
New Revision: 1487
Removed:
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/FakeProcessorDataManager.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/TempTableStoresHolder.java
Modified:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToCharacterTransform.java
trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java
trunk/engine/src/main/java/com/metamatrix/query/metadata/TempMetadataStore.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SubqueryAwareRelationalNode.java
trunk/engine/src/main/java/com/metamatrix/query/resolver/command/ExecResolver.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java
trunk/runtime/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java
trunk/test-integration/common/src/test/java/com/metamatrix/jdbc/TestResultsMetadataWithProvider.java
trunk/test-integration/common/src/test/java/com/metamatrix/jdbc/TestStaticMetadataProvider.java
Log:
TEIID-849 fix for resolving subqueries in stored procedure parameters and for using the appropriate context information.
Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToCharacterTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToCharacterTransform.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToCharacterTransform.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -42,7 +42,7 @@
return new Character(' ');
}
- return new Character( s.charAt(0) );
+ return Character.valueOf(s.charAt(0));
}
/**
Deleted: trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/FakeProcessorDataManager.java
===================================================================
--- trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/FakeProcessorDataManager.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/FakeProcessorDataManager.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -1,78 +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.connector.metadata.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.query.processor.FakeTupleSource;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.util.CommandContext;
-
-/**
- */
-public class FakeProcessorDataManager implements ProcessorDataManager {
- private Command command;
-
- public Command getCommand(){
- return command;
- }
- /**
- *
- */
- public FakeProcessorDataManager() {
- super();
- }
-
- /*
- * @see com.metamatrix.query.processor.ProcessorDataManager#registerRequest(java.lang.Object, com.metamatrix.query.sql.lang.Command, java.lang.String, int)
- */
- public TupleSource registerRequest(Object processorID, Command command, String modelName, String connectorBindingId, int nodeID)
- throws MetaMatrixComponentException {
- this.command = command;
- return new FakeTupleSource(new ArrayList(), new List[0]);
- }
-
- /*
- * @see com.metamatrix.query.processor.ProcessorDataManager#lookupCodeValue(com.metamatrix.query.util.CommandContext, java.lang.String, java.lang.String, java.lang.String, java.lang.Object)
- */
- public Object lookupCodeValue(
- CommandContext context,
- String codeTableName,
- String returnElementName,
- String keyElementName,
- Object keyValue)
- throws BlockedException, MetaMatrixComponentException {
- return null;
- }
-
- @Override
- public void clearCodeTables() {
-
- }
-
-}
Modified: trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -103,8 +103,9 @@
this.elements = elements;
}
- public void setContext(CommandContext context) {
+ public void initialize(CommandContext context, ProcessorDataManager dataMgr) {
this.context = context;
+ this.dataMgr = dataMgr;
}
public boolean evaluate(Criteria criteria, List tuple)
@@ -316,13 +317,7 @@
valueIter = new CollectionValueIterator(((SetCriteria)criteria).getValues());
} else if (criteria instanceof DependentSetCriteria){
ContextReference ref = (ContextReference)criteria;
- ValueIteratorSource vis = (ValueIteratorSource)getContext(criteria).getVariableContext().getGlobalValue(ref.getContextSymbol());
- HashSet<Object> values;
- try {
- values = vis.getCachedSet(ref.getValueExpression());
- } catch (MetaMatrixProcessingException e) {
- throw new CriteriaEvaluationException(e, e.getMessage());
- }
+ HashSet<Object> values = getValues(getContext(criteria), ref);
if (values != null) {
return values.contains(leftValue);
}
@@ -367,6 +362,19 @@
return Boolean.valueOf(criteria.isNegated());
}
+ public static HashSet<Object> getValues(CommandContext context,
+ ContextReference ref) throws MetaMatrixComponentException,
+ CriteriaEvaluationException {
+ ValueIteratorSource vis = (ValueIteratorSource)context.getVariableContext().getGlobalValue(ref.getContextSymbol());
+ HashSet<Object> values;
+ try {
+ values = vis.getCachedSet(ref.getValueExpression());
+ } catch (MetaMatrixProcessingException e) {
+ throw new CriteriaEvaluationException(e, e.getMessage());
+ }
+ return values;
+ }
+
public boolean evaluate(IsNullCriteria criteria, List tuple)
throws CriteriaEvaluationException, BlockedException, MetaMatrixComponentException {
Modified: trunk/engine/src/main/java/com/metamatrix/query/metadata/TempMetadataStore.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/metadata/TempMetadataStore.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/engine/src/main/java/com/metamatrix/query/metadata/TempMetadataStore.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -43,13 +43,13 @@
public class TempMetadataStore implements Serializable {
// UPPER CASE TEMP GROUP NAME --> TempMetadataID for group
- private Map tempGroups;
+ private Map<String, TempMetadataID> tempGroups;
/**
* Constructor for TempMetadataStore.
*/
public TempMetadataStore() {
- this(new HashMap());
+ this(new HashMap<String, TempMetadataID>());
}
/**
@@ -57,9 +57,9 @@
* the parameter is null, a new empty Map will beused instead.
* @param data Map of upper case group name to group TempMetadataID object
*/
- public TempMetadataStore(Map data) {
+ public TempMetadataStore(Map<String, TempMetadataID> data) {
if (data == null) {
- tempGroups = new HashMap();
+ tempGroups = new HashMap<String, TempMetadataID>();
} else {
tempGroups = data;
}
@@ -164,7 +164,7 @@
public TempMetadataID addElementSymbolToTempGroup(String tempGroup, SingleElementSymbol symbol) {
String tempName = tempGroup.toUpperCase();
- TempMetadataID groupID = (TempMetadataID)this.tempGroups.get(tempName);
+ TempMetadataID groupID = this.tempGroups.get(tempName);
if (groupID != null) {
TempMetadataID elementID = createElementSymbol(tempName, symbol, false);
@@ -198,7 +198,7 @@
* @return Metadata ID or null if not found
*/
public TempMetadataID getTempGroupID(String tempGroup) {
- return (TempMetadataID) tempGroups.get(tempGroup.toUpperCase());
+ return tempGroups.get(tempGroup.toUpperCase());
}
/**
@@ -213,7 +213,7 @@
}
String groupName = tempElement.substring(0, index);
- TempMetadataID groupID = (TempMetadataID) tempGroups.get(groupName.toUpperCase());
+ TempMetadataID groupID = tempGroups.get(groupName.toUpperCase());
if(groupID != null) {
Iterator elementIter = groupID.getElements().iterator();
while(elementIter.hasNext()) {
@@ -234,7 +234,7 @@
* @return Metadata ID or null if not found
*/
public List getTempElementElementIDs(String tempGroup) {
- TempMetadataID groupID = (TempMetadataID) tempGroups.get(tempGroup.toUpperCase());
+ TempMetadataID groupID = tempGroups.get(tempGroup.toUpperCase());
if(groupID != null) {
return groupID.getElements();
}
@@ -243,14 +243,14 @@
}
public void addElementToTempGroup(String tempGroup, ElementSymbol symbol) {
- TempMetadataID groupID = (TempMetadataID) tempGroups.get(tempGroup.toUpperCase());
+ TempMetadataID groupID = tempGroups.get(tempGroup.toUpperCase());
if(groupID != null) {
groupID.addElement((TempMetadataID)symbol.getMetadataID());
}
}
- public void removeTempGroup(String tempGroup) {
- tempGroups.remove(tempGroup.toUpperCase());
+ public TempMetadataID removeTempGroup(String tempGroup) {
+ return tempGroups.remove(tempGroup.toUpperCase());
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -137,9 +137,8 @@
public void initialize(CommandContext context, ProcessorDataManager dataMgr, BufferManager bufferMgr) {
this.bufferMgr = bufferMgr;
this.batchSize = bufferMgr.getProcessorBatchSize();
- tempTableStore = new TempTableStoreImpl(bufferMgr, context.getConnectionID(), (TempTableStore)context.getTempTableStore());
- this.dataMgr = new TempTableDataManager(dataMgr, tempTableStore);
setContext(context);
+ this.dataMgr = dataMgr;
if (evaluator == null) {
this.evaluator = new SubqueryAwareEvaluator(Collections.emptyMap(), getDataManager(), getContext(), this.bufferMgr);
}
@@ -199,6 +198,8 @@
context.setValue(entry.getKey(), value);
}
}
+ tempTableStore = new TempTableStoreImpl(bufferMgr, getContext().getConnectionID(), null);
+ this.dataMgr = new TempTableDataManager(dataMgr, tempTableStore);
}
this.evaluatedParams = true;
}
@@ -316,6 +317,7 @@
if (this.evaluator != null) {
this.evaluator.close();
}
+ this.tempTableStore = null;
}
public String toString() {
@@ -632,14 +634,14 @@
}
boolean evaluateCriteria(Criteria condition) throws BlockedException, MetaMatrixProcessingException, MetaMatrixComponentException {
- evaluator.setContext(getContext());
+ evaluator.initialize(getContext(), getDataManager());
boolean result = evaluator.evaluate(condition, Collections.emptyList());
this.evaluator.close();
return result;
}
Object evaluateExpression(Expression expression) throws BlockedException, MetaMatrixProcessingException, MetaMatrixComponentException {
- evaluator.setContext(getContext());
+ evaluator.initialize(getContext(), getDataManager());
Object result = evaluator.evaluate(expression, Collections.emptyList());
this.evaluator.close();
return result;
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SubqueryAwareRelationalNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SubqueryAwareRelationalNode.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SubqueryAwareRelationalNode.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -17,7 +17,7 @@
if (this.evaluator == null) {
this.evaluator = new SubqueryAwareEvaluator(elementMap, getDataManager(), getContext(), getBufferManager());
} else {
- this.evaluator.setContext(getContext());
+ this.evaluator.initialize(getContext(), getDataManager());
}
return this.evaluator;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/command/ExecResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/ExecResolver.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/command/ExecResolver.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -23,6 +23,7 @@
package com.metamatrix.query.resolver.command;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -44,6 +45,7 @@
import com.metamatrix.query.metadata.TempMetadataStore;
import com.metamatrix.query.parser.QueryParser;
import com.metamatrix.query.resolver.ProcedureContainerResolver;
+import com.metamatrix.query.resolver.QueryResolver;
import com.metamatrix.query.resolver.VariableResolver;
import com.metamatrix.query.resolver.util.ResolverUtil;
import com.metamatrix.query.resolver.util.ResolverVisitor;
@@ -52,10 +54,13 @@
import com.metamatrix.query.sql.lang.ProcedureContainer;
import com.metamatrix.query.sql.lang.SPParameter;
import com.metamatrix.query.sql.lang.StoredProcedure;
+import com.metamatrix.query.sql.lang.SubqueryContainer;
import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
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.visitor.CommandCollectorVisitor;
+import com.metamatrix.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
import com.metamatrix.query.util.ErrorMessageKeys;
/**
@@ -284,6 +289,11 @@
SPParameter param = (SPParameter) paramIter.next();
Expression expr = param.getExpression();
if(expr != null) {
+ for (SubqueryContainer container : ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(expr)) {
+ QueryResolver.setChildMetadata(container.getCommand(), command);
+
+ QueryResolver.resolveCommand(container.getCommand(), Collections.EMPTY_MAP, useMetadataCommands, metadata.getMetadata(), analysis);
+ }
ResolverVisitor.resolveLanguageObject(expr, null, externalGroups, metadata);
Class paramType = param.getClassType();
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -91,6 +91,7 @@
import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
import com.metamatrix.query.processor.ProcessorDataManager;
import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.tempdata.TempTableStoreImpl;
import com.metamatrix.server.serverapi.RequestInfo;
import com.metamatrix.vdb.runtime.VDBKey;
@@ -119,6 +120,36 @@
}
}
+ static class ClientState {
+ List<RequestID> requests;
+ TempTableStoreImpl tempTableStoreImpl;
+
+ public ClientState(TempTableStoreImpl tableStoreImpl) {
+ this.tempTableStoreImpl = tableStoreImpl;
+ }
+
+ public synchronized void addRequest(RequestID requestID) {
+ if (requests == null) {
+ requests = new LinkedList<RequestID>();
+ }
+ requests.add(requestID);
+ }
+
+ public synchronized List<RequestID> getRequests() {
+ if (requests == null) {
+ return Collections.emptyList();
+ }
+ return new ArrayList<RequestID>(requests);
+ }
+
+ public synchronized void removeRequest(RequestID requestID) {
+ if (requests != null) {
+ requests.remove(requestID);
+ }
+ }
+
+ }
+
//Constants
private static final int DEFAULT_MAX_CODE_TABLE_RECORDS = 10000;
private static final int DEFAULT_MAX_CODE_TABLES = 200;
@@ -151,11 +182,10 @@
private int processorTimeslice = DEFAULT_PROCESSOR_TIMESLICE;
private boolean processorDebugAllowed;
- 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>>());
+ private Map<RequestID, RequestWorkItem> requests = new ConcurrentHashMap<RequestID, RequestWorkItem>();
+ private Map<String, ClientState> clientState = Collections.synchronizedMap(new HashMap<String, ClientState>());
private DQPContextCache contextCache;
private ServiceLoader loader = new ServiceLoader();
@@ -179,27 +209,32 @@
* 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);
+ ClientState state = getClientState(clientConnection, false);
+ if (state == null) {
+ return Collections.emptyList();
+ }
+ return buildRequestInfos(state.getRequests());
}
+
+ public ClientState getClientState(String key, boolean create) {
+ synchronized (clientState) {
+ ClientState state = clientState.get(key);
+ if (state == null && create) {
+ state = new ClientState(new TempTableStoreImpl(bufferManager, key, null));
+ clientState.put(key, state);
+ }
+ return state;
+ }
+ }
/**
* 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);
+ return buildRequestInfos(requests.keySet());
}
- private List<RequestInfo> buildRequestInfos(List<RequestID> ids) {
- if(ids == null) {
- return Collections.emptyList();
- }
+ private List<RequestInfo> buildRequestInfos(Collection<RequestID> ids) {
List<RequestInfo> results = new ArrayList<RequestInfo>();
for (RequestID requestID : ids) {
RequestWorkItem holder = requests.get(requestID);
@@ -246,10 +281,10 @@
} else {
request = new Request();
}
+ ClientState state = this.getClientState(workContext.getConnectionID(), true);
request.initialize(requestMsg, getEnvironment(), bufferManager,
dataTierMgr, vdbCapabilties, transactionService,
- processorDebugAllowed, this.tempTableStoresHolder
- .getTempTableStore(workContext.getConnectionID()),
+ processorDebugAllowed, state.tempTableStoreImpl,
workContext, chunkSize);
RequestWorkItem workItem = null;
@@ -266,7 +301,7 @@
}
logMMCommand(workItem, true, false, 0); //TODO: there is no transaction at this point
- addRequest(requestID, workItem);
+ addRequest(requestID, workItem, state);
this.addWork(workItem);
return resultsFuture;
@@ -284,26 +319,17 @@
return resultsFuture;
}
- void addRequest(RequestID requestID, RequestWorkItem workItem) {
+ void addRequest(RequestID requestID, RequestWorkItem workItem, ClientState state) {
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);
- }
+ state.addRequest(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);
- }
- }
+ ClientState state = getClientState(workItem.getDqpWorkContext().getConnectionID(), false);
+ if (state != null) {
+ state.removeRequest(workItem.requestID);
+ }
contextCache.removeRequestScopedCache(workItem.requestID.toString());
}
@@ -414,12 +440,9 @@
// 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) {
+ ClientState state = getClientState(sessionId, false);
+ if (state != null) {
+ for (RequestID reqId : state.getRequests()) {
try {
cancelRequest(reqId);
} catch (MetaMatrixComponentException err) {
@@ -667,8 +690,6 @@
// Create the worker pools to tie the queues together
processWorkerPool = WorkerPoolFactory.newWorkerPool(PROCESS_PLAN_QUEUE_NAME, PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.PROCESS_POOL_MAX_THREADS, DEFAULT_MAX_PROCESS_WORKERS));
- tempTableStoresHolder = new TempTableStoresHolder(bufferManager);
-
dataTierMgr = new DataTierManagerImpl(this,
(DataService) env.findService(DQPServiceNames.DATA_SERVICE),
(VDBService) env.findService(DQPServiceNames.VDB_SERVICE),
@@ -761,7 +782,7 @@
public MetadataResult getMetadata(long requestID)
throws MetaMatrixComponentException, MetaMatrixProcessingException {
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
- MetaDataProcessor processor = new MetaDataProcessor(this.metadataService, this, this.prepPlanCache, getEnvironment(), this.tempTableStoresHolder);
+ MetaDataProcessor processor = new MetaDataProcessor(this.metadataService, this, this.prepPlanCache, getEnvironment());
return processor.processMessage(workContext.getRequestID(requestID), workContext, null, true);
}
@@ -769,7 +790,7 @@
boolean allowDoubleQuotedVariable)
throws MetaMatrixComponentException, MetaMatrixProcessingException {
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
- MetaDataProcessor processor = new MetaDataProcessor(this.metadataService, this, this.prepPlanCache, getEnvironment(), this.tempTableStoresHolder);
+ MetaDataProcessor processor = new MetaDataProcessor(this.metadataService, this, this.prepPlanCache, getEnvironment());
return processor.processMessage(workContext.getRequestID(requestID), workContext, preparedSql, allowDoubleQuotedVariable);
}
}
\ No newline at end of file
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -29,6 +29,7 @@
import java.util.List;
import java.util.Map;
+import org.teiid.dqp.internal.process.DQPCore.ClientState;
import org.teiid.dqp.internal.process.PreparedPlanCache.CacheID;
import org.teiid.dqp.internal.process.multisource.MultiSourceMetadataWrapper;
@@ -80,17 +81,15 @@
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) {
+ public MetaDataProcessor(MetadataService metadataService, DQPCore requestManager, PreparedPlanCache planCache, ApplicationEnvironment env) {
this.metadataService = metadataService;
this.requestManager = requestManager;
this.planCache = planCache;
this.env = env;
- this.tempTableStoresHolder = tempTableStoresHolder;
}
/**
@@ -128,9 +127,12 @@
}
TempTableStore tempTableStore = null;
- if(tempTableStoresHolder != null) {
+ if(requestManager != null) {
if (workItem != null) {
- tempTableStore = tempTableStoresHolder.getTempTableStore(workContext.getConnectionID());
+ ClientState state = requestManager.getClientState(workContext.getConnectionID(), false);
+ if (state != null) {
+ tempTableStore = state.tempTableStoreImpl;
+ }
}
}
if(tempTableStore != null) {
Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/process/TempTableStoresHolder.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/TempTableStoresHolder.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/TempTableStoresHolder.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -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 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;
- }
-}
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -2690,7 +2690,7 @@
helpTestProcess(plan, expected, dataMgr);
}
- @Test public void testTempSubqueryInput() throws Exception {
+ @Test public void testUpdateDeleteTemp() throws Exception {
String proc = "CREATE VIRTUAL PROCEDURE " + //$NON-NLS-1$
"BEGIN " + //$NON-NLS-1$
" select e1, e2, e3, e4 into #t1 from pm1.g1;\n" + //$NON-NLS-1$
@@ -2710,5 +2710,24 @@
helpTestProcess(plan, expected, dataMgr);
}
+ @Test public void testTempSubqueryInput() throws Exception {
+ String proc = "CREATE VIRTUAL PROCEDURE " + //$NON-NLS-1$
+ "BEGIN " + //$NON-NLS-1$
+ " create local temporary table t1 (e1 string);\n" + //$NON-NLS-1$
+ " select e1 into t1 from pm1.g1;\n" + //$NON-NLS-1$
+ " select e2 from (exec pm1.sq2((select max(e1) from t1))) x;\n" + //$NON-NLS-1$
+ "END"; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = createProcedureMetadata(proc);
+ String userQuery = "SELECT * FROM (EXEC pm1.sq1()) as proc"; //$NON-NLS-1$
+ FakeDataManager dataMgr = exampleDataManager2(metadata);
+ ProcessorPlan plan = getProcedurePlan(userQuery, metadata, TestOptimizer.getGenericFinder());
+
+ List[] expected = new List[] {
+ Arrays.asList( 51 ),
+ };
+ helpTestProcess(plan, expected, dataMgr);
+ }
+
private static final boolean DEBUG = false;
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -26,15 +26,10 @@
import java.util.HashSet;
import java.util.Set;
-import org.mockito.Mockito;
-import org.teiid.connector.xa.api.TransactionContext;
-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 org.teiid.dqp.internal.process.DQPCore.ClientState;
+
import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.dqp.exception.SourceWarning;
import com.metamatrix.dqp.internal.datamgr.ConnectorID;
@@ -91,7 +86,7 @@
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); //$NON-NLS-1$
+ addRequest(rm, r0, id, null, null);
return id;
}
@@ -118,7 +113,7 @@
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); //$NON-NLS-1$
+ RequestWorkItem workItem = addRequest(rm, r0, requestID, null, null);
assertTrue(workItem.resultsCursor.resultsRequested);
}
@@ -127,7 +122,7 @@
RequestMessage r0 = new RequestMessage("foo"); //$NON-NLS-1$
RequestID requestID = new RequestID(SESSION_STRING, 1);
- RequestWorkItem workItem = addRequest(rm, r0, requestID, null, null); //$NON-NLS-1$
+ RequestWorkItem workItem = addRequest(rm, r0, requestID, null, null);
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$
@@ -148,7 +143,8 @@
}
RequestWorkItem workItem = new RequestWorkItem(rm, requestMsg, null, null, id, workContext);
workItem.setOriginalCommand(originalCommand);
- rm.addRequest(id, workItem);
+ ClientState state = rm.getClientState(id.getConnectionID(), true);
+ rm.addRequest(id, workItem, state);
return workItem;
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -82,7 +82,7 @@
ApplicationEnvironment env = new ApplicationEnvironment();
FakeVDBService vdbService = new FakeVDBService();
env.bindService(DQPServiceNames.VDB_SERVICE, vdbService);
- MetaDataProcessor mdProc = new MetaDataProcessor(mdSvc, requestMgr, prepPlanCache, env, null);
+ MetaDataProcessor mdProc = new MetaDataProcessor(mdSvc, requestMgr, prepPlanCache, env);
return mdProc.processMessage(requestID, workContext, null, true).getColumnMetadata();
}
@@ -151,7 +151,7 @@
// Initialize components
ApplicationEnvironment env = new ApplicationEnvironment();
env.bindService(DQPServiceNames.VDB_SERVICE, vdbService);
- MetaDataProcessor mdProc = new MetaDataProcessor(mdSvc, new DQPCore(), prepPlanCache, env, null);
+ MetaDataProcessor mdProc = new MetaDataProcessor(mdSvc, new DQPCore(), prepPlanCache, env);
DQPWorkContext workContext = new DQPWorkContext();
workContext.setVdbName("MyVDB"); //$NON-NLS-1$
@@ -195,7 +195,7 @@
while(iter.hasNext()) {
String type = (String) iter.next();
Class typeClass = DataTypeManager.getDataTypeClass(type);
- MetaDataProcessor processor = new MetaDataProcessor(null, null, null, null, null);
+ MetaDataProcessor processor = new MetaDataProcessor(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);
}
Modified: trunk/runtime/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/runtime/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -39,7 +39,6 @@
import com.metamatrix.admin.api.exception.security.InvalidSessionException;
import com.metamatrix.admin.api.exception.security.MetaMatrixSecurityException;
import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.security.AuthorizationException;
import com.metamatrix.api.exception.security.MetaMatrixAuthenticationException;
import com.metamatrix.api.exception.security.SessionServiceException;
import com.metamatrix.common.api.MMURL;
Modified: trunk/test-integration/common/src/test/java/com/metamatrix/jdbc/TestResultsMetadataWithProvider.java
===================================================================
--- trunk/test-integration/common/src/test/java/com/metamatrix/jdbc/TestResultsMetadataWithProvider.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/test-integration/common/src/test/java/com/metamatrix/jdbc/TestResultsMetadataWithProvider.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -42,7 +42,7 @@
}
public StaticMetadataProvider exampleProvider() throws Exception {
- MetaDataProcessor processor = new MetaDataProcessor(null, null, null, null, null);
+ MetaDataProcessor processor = new MetaDataProcessor(null, null, null, null);
Map col1 = processor.getDefaultColumn("vdb", "1", "table", "col1", String.class); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
Map col2 = processor.getDefaultColumn("vdb", "1", "table", "col2", Integer.class); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
Modified: trunk/test-integration/common/src/test/java/com/metamatrix/jdbc/TestStaticMetadataProvider.java
===================================================================
--- trunk/test-integration/common/src/test/java/com/metamatrix/jdbc/TestStaticMetadataProvider.java 2009-09-28 17:09:14 UTC (rev 1486)
+++ trunk/test-integration/common/src/test/java/com/metamatrix/jdbc/TestStaticMetadataProvider.java 2009-09-28 21:07:51 UTC (rev 1487)
@@ -44,7 +44,7 @@
}
private StaticMetadataProvider example1() throws Exception {
- MetaDataProcessor processor = new MetaDataProcessor(null, null, null, null, null);
+ MetaDataProcessor processor = new MetaDataProcessor(null, null, null, null);
Map[] columnMetadata = new Map[] {
processor.getDefaultColumn("vdb", "1", "table", "c1", String.class), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
processor.getDefaultColumn("vdb", "1", "table", "c2", Integer.class) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
15 years, 3 months
teiid SVN: r1486 - trunk/test-integration/db/src/main/java/org/teiid/test/framework.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-28 13:09:14 -0400 (Mon, 28 Sep 2009)
New Revision: 1486
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
Log:
Teiid 773 - cleanup
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java 2009-09-28 17:06:00 UTC (rev 1485)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java 2009-09-28 17:09:14 UTC (rev 1486)
@@ -16,8 +16,8 @@
private boolean debug = false;
- protected Properties props;
- protected ConnectionStrategy connStrategy;
+ protected Properties props;
+ protected ConnectionStrategy connStrategy;
protected TransactionContainer(){
@@ -58,13 +58,13 @@
}
- private void runIt(TransactionQueryTest test) {
-
+ private void runIt(TransactionQueryTest test) {
detail("Start transaction test: " + test.getTestName());
-
+
try {
- setUp(test);
+ setUp(test);
+
debug(" setConnection");
test.setConnection(this.connStrategy.getConnection());
test.setExecutionProperties(this.props);
15 years, 3 months
teiid SVN: r1485 - in trunk/test-integration/db/src/main/java/org/teiid/test/framework: connection and 1 other directories.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-28 13:06:00 -0400 (Mon, 28 Sep 2009)
New Revision: 1485
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionUtil.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/JNDITransaction.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/XATransaction.java
Log:
Teiid 773 - cleanup
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java 2009-09-28 17:03:37 UTC (rev 1484)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java 2009-09-28 17:06:00 UTC (rev 1485)
@@ -1,14 +1,13 @@
package org.teiid.test.framework;
-import java.io.IOException;
-import java.io.InputStream;
import java.util.Properties;
-import org.teiid.test.framework.connection.ConnectionStrategyFactory;
import org.teiid.test.util.PropUtils;
-public class ConfigPropertyLoader {
-
+
+public class ConfigPropertyLoader {
+
+
/**
* The default config file to use when #CONFIG_FILE system property isn't set
*/
@@ -29,6 +28,9 @@
}
public synchronized static Properties getProperties() {
+ if (props == null) {
+ loadConfigurationProperties();
+ }
return props;
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java 2009-09-28 17:03:37 UTC (rev 1484)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java 2009-09-28 17:06:00 UTC (rev 1485)
@@ -4,9 +4,7 @@
*/
package org.teiid.test.framework;
-import java.sql.Connection;
import java.util.Properties;
-import java.util.Set;
import org.teiid.test.framework.connection.ConnectionStrategy;
import org.teiid.test.framework.connection.ConnectionStrategyFactory;
@@ -14,8 +12,6 @@
import org.teiid.test.framework.exception.TransactionRuntimeException;
-
-
public abstract class TransactionContainer {
private boolean debug = false;
@@ -23,18 +19,18 @@
protected Properties props;
protected ConnectionStrategy connStrategy;
- protected TransactionContainer(ConnectionStrategy strategy){
- this.connStrategy = strategy;
- this.props = new Properties();
- this.props.putAll(this.connStrategy.getEnvironment());
-
+ protected TransactionContainer(){
}
- protected void setupData(TransactionQueryTest test) {
- test.setDataSources(connStrategy.getDataSources());
+ protected void setUp(TransactionQueryTest test) throws QueryTestFailedException {
+ this.connStrategy = ConnectionStrategyFactory.getInstance().getConnectionStrategy();
+ this.props = new Properties();
+ this.props.putAll(this.connStrategy.getEnvironment());
+
+ test.setDataSources(connStrategy.getDataSources());
test.setupDataSources();
-
+
}
protected void before(TransactionQueryTest test){}
@@ -43,22 +39,23 @@
public void runTransaction(TransactionQueryTest test) {
- try {
- try {
-
- runIt(test);
-
- } finally {
- debug(" test.cleanup");
+ try {
+
+ runIt(test);
+
+ } finally {
+ debug(" test.cleanup");
+
+ try {
+ test.cleanup();
+ } finally {
+ // cleanup all connections created for this test.
+ ConnectionStrategyFactory.destroyInstance();
+
+ }
+ }
- test.cleanup();
- }
-
- } finally {
- // cleanup all connections created for this test.
- ConnectionStrategyFactory.destroyInstance();
- }
}
private void runIt(TransactionQueryTest test) {
@@ -66,7 +63,7 @@
detail("Start transaction test: " + test.getTestName());
try {
- setupData(test);
+ setUp(test);
debug(" setConnection");
test.setConnection(this.connStrategy.getConnection());
@@ -98,8 +95,6 @@
e.printStackTrace();
}
throw new TransactionRuntimeException(e.getMessage());
- }finally {
-
}
if (test.exceptionExpected() && !test.exceptionOccurred()) {
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java 2009-09-28 17:03:37 UTC (rev 1484)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java 2009-09-28 17:06:00 UTC (rev 1485)
@@ -192,9 +192,9 @@
}
- public static void main(String[] args) {
- ConnectionStrategyFactory cf = ConnectionStrategyFactory.getInstance();
-
- }
+// public static void main(String[] args) {
+// ConnectionStrategyFactory cf = ConnectionStrategyFactory.getInstance();
+//
+// }
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionUtil.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionUtil.java 2009-09-28 17:03:37 UTC (rev 1484)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionUtil.java 2009-09-28 17:06:00 UTC (rev 1485)
@@ -50,68 +50,5 @@
identifier, ds.getProperties()).getXAConnection();
}
-
-// public static final Connection getSource(String identifier)
-// throws QueryTestFailedException {
-// if (identifier != null) {
-// String mappedName = ConfigPropertyLoader.getProperty(identifier);
-//
-// if (mappedName == null) {
-// throw new TransactionRuntimeException("Identifier mapping "
-// + identifier
-// + " is not defined in the config properties file");
-// }
-//
-// Properties sourceProps;
-// try {
-// sourceProps = DataSourceMgr.getInstance()
-// .getDatasourceProperties(mappedName, identifier);
-// } catch (QueryTestFailedException e) {
-// throw new TransactionRuntimeException(e);
-// }
-//
-// if (sourceProps == null) {
-// throw new TransactionRuntimeException("Identifier "
-// + identifier + " mapped to " + mappedName
-// + " has no datasource properties");
-// }
-//
-// return ConnectionStrategyFactory.getInstance().createDriverStrategy(identifier,
-// sourceProps).getConnection();
-//
-// }
-// throw new RuntimeException("No Connection by name :" + identifier); //$NON-NLS-1$
-// }
-//
-// public static final XAConnection getXASource(String identifier)
-// throws QueryTestFailedException {
-// if (identifier != null) {
-// String mappedName = ConfigPropertyLoader.getProperty(identifier);
-//
-// if (mappedName == null) {
-// throw new TransactionRuntimeException("Identifier mapping "
-// + identifier
-// + " is not defined in the config properties file");
-// }
-//
-// Properties sourceProps;
-// try {
-// sourceProps = DataSourceMgr.getInstance()
-// .getDatasourceProperties(mappedName, identifier);
-// } catch (QueryTestFailedException e) {
-// throw new TransactionRuntimeException(e);
-// }
-//
-// if (sourceProps == null) {
-// throw new TransactionRuntimeException("Identifier "
-// + identifier + " mapped to " + mappedName
-// + " has no datasource properties");
-// }
-//
-// return ConnectionStrategyFactory.getInstance().createDataSourceStrategy(
-// identifier, sourceProps).getXAConnection();
-// }
-// throw new RuntimeException("No Connection by name :" + identifier); //$NON-NLS-1$
-// }
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/JNDITransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/JNDITransaction.java 2009-09-28 17:03:37 UTC (rev 1484)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/JNDITransaction.java 2009-09-28 17:06:00 UTC (rev 1485)
@@ -9,8 +9,8 @@
import org.teiid.test.framework.TransactionContainer;
import org.teiid.test.framework.TransactionQueryTest;
+import org.teiid.test.framework.connection.ConnectionStrategy;
import org.teiid.test.framework.exception.TransactionRuntimeException;
-import org.teiid.test.framework.connection.ConnectionStrategy;
@@ -18,8 +18,8 @@
public class JNDITransaction extends TransactionContainer {
UserTransaction userTxn = null;
- public JNDITransaction(ConnectionStrategy strategy) {
- super(strategy);
+ public JNDITransaction() {
+ super();
}
protected void before(TransactionQueryTest test) {
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java 2009-09-28 17:03:37 UTC (rev 1484)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java 2009-09-28 17:06:00 UTC (rev 1485)
@@ -4,14 +4,11 @@
*/
package org.teiid.test.framework.transaction;
-import java.sql.Connection;
import java.sql.SQLException;
import org.teiid.test.framework.TransactionContainer;
import org.teiid.test.framework.TransactionQueryTest;
-import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
-import org.teiid.test.framework.connection.ConnectionStrategy;
@@ -20,8 +17,8 @@
*/
public class LocalTransaction extends TransactionContainer {
- public LocalTransaction(ConnectionStrategy strategy) {
- super(strategy);
+ public LocalTransaction() {
+ super();
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java 2009-09-28 17:03:37 UTC (rev 1484)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/TransactionFactory.java 2009-09-28 17:06:00 UTC (rev 1485)
@@ -28,24 +28,28 @@
ConfigPropertyLoader.loadConfigurationProperties();
- ConnectionStrategy connstrategy = ConnectionStrategyFactory.getInstance().getConnectionStrategy();
+ // ConnectionStrategy connstrategy = ConnectionStrategyFactory.getInstance().getConnectionStrategy();
+
+// Properties props = ConfigPropertyLoader.getProperties();
- String type = connstrategy.getEnvironment().getProperty(ConfigPropertyNames.TRANSACTION_TYPE, ConfigPropertyNames.TRANSACTION_TYPES.LOCAL_TRANSACTION);
+ String type = ConfigPropertyLoader.getProperty(ConfigPropertyNames.TRANSACTION_TYPE);
+ //connstrategy.getEnvironment().getProperty(ConfigPropertyNames.TRANSACTION_TYPE, ConfigPropertyNames.TRANSACTION_TYPES.LOCAL_TRANSACTION);
if (type == null) {
- throw new RuntimeException("Property " + ConfigPropertyNames.TRANSACTION_TYPE + " was specified");
+ type = ConfigPropertyNames.TRANSACTION_TYPES.LOCAL_TRANSACTION;
+// throw new RuntimeException("Property " + ConfigPropertyNames.TRANSACTION_TYPE + " was specified");
}
System.out.println("Create TransactionContainer: " + type);
if (type.equalsIgnoreCase(ConfigPropertyNames.TRANSACTION_TYPES.LOCAL_TRANSACTION)) {
- transacton = new LocalTransaction(connstrategy);
+ transacton = new LocalTransaction();
}
else if (type.equalsIgnoreCase(ConfigPropertyNames.TRANSACTION_TYPES.XATRANSACTION)) {
- transacton = new XATransaction(connstrategy);
+ transacton = new XATransaction();
}
else if (type.equalsIgnoreCase(ConfigPropertyNames.TRANSACTION_TYPES.JNDI_TRANSACTION)) {
- transacton = new JNDITransaction(connstrategy);
+ transacton = new JNDITransaction();
} else {
throw new TransactionRuntimeException("Invalid property value of " + type + " for " + ConfigPropertyNames.TRANSACTION_TYPE );
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/XATransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/XATransaction.java 2009-09-28 17:03:37 UTC (rev 1484)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/XATransaction.java 2009-09-28 17:06:00 UTC (rev 1485)
@@ -11,7 +11,6 @@
import org.teiid.test.framework.TransactionContainer;
import org.teiid.test.framework.TransactionQueryTest;
-import org.teiid.test.framework.connection.ConnectionStrategy;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
@@ -21,8 +20,8 @@
private static Random RANDOM = new Random();
private MMXid xid;
- public XATransaction(ConnectionStrategy strategy) {
- super(strategy);
+ public XATransaction() {
+ super();
}
protected void before(TransactionQueryTest test) {
15 years, 3 months
teiid SVN: r1484 - trunk/test-integration/db/src/test/java/org/teiid/test/framework.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-28 13:03:37 -0400 (Mon, 28 Sep 2009)
New Revision: 1484
Modified:
trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java
Log:
Teiid 773 - cleanup
Modified: trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java 2009-09-28 17:01:51 UTC (rev 1483)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java 2009-09-28 17:03:37 UTC (rev 1484)
@@ -17,7 +17,6 @@
import javax.sql.XAConnection;
import org.teiid.test.framework.connection.ConnectionStrategy;
-import org.teiid.test.framework.connection.ConnectionStrategyFactory;
import org.teiid.test.framework.connection.ConnectionUtil;
import org.teiid.test.framework.datasource.DataSource;
import org.teiid.test.framework.datasource.DataSourceSetupFactory;
15 years, 3 months
teiid SVN: r1483 - trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-28 13:01:51 -0400 (Mon, 28 Sep 2009)
New Revision: 1483
Modified:
trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java
Log:
Teiid 773 - cleanup
Modified: trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java 2009-09-25 20:29:56 UTC (rev 1482)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java 2009-09-28 17:01:51 UTC (rev 1483)
@@ -32,16 +32,12 @@
// The connections will be closed at teardown
System.out.println("Run TwoSource Setup...");
-
- System.out.println("perform source pm1 set");
AbstractQueryTest test1 = new QueryExecution(ConnectionUtil.getConnection("pm1", ds));//$NON-NLS-1$
test1.execute("delete from g2"); //$NON-NLS-1$
test1.execute("delete from g1"); //$NON-NLS-1$
-
- System.out.println("removed old data");
-
+
test1.execute("select * from g1 ");
test1.assertRowCount(0);
test1.execute("select * from g2 ");
@@ -59,22 +55,18 @@
for (int i = 0; i < 100; i++) {
sql1[i] = "insert into g2 (e1, e2) values("+i+",'"+i+"')" ;
}
- System.out.println("add new data");
-
-
+
test1.executeBatch(sql1);
test1.execute("select * from g1 ");
test1.assertRowCount(100);
test1.execute("select * from g2 ");
test1.assertRowCount(100);
- System.out.println("perform source pm2 set...");
-
+
AbstractQueryTest test2 = new QueryExecution(ConnectionUtil.getConnection("pm2", ds));//$NON-NLS-1$
test2.execute("delete from g2"); //$NON-NLS-1$
test2.execute("delete from g1"); //$NON-NLS-1$
- System.out.println("removed old data");
test2.execute("select * from g1 ");
test2.assertRowCount(0);
@@ -93,10 +85,8 @@
for (int i = 0; i < 100; i++) {
sql2[i] = "insert into g2 (e1, e2) values("+i+",'"+i+"')" ;
}
+
- System.out.println("add new data");
-
-
test2.executeBatch(sql2);
test2.execute("select * from g1 ");
test2.assertRowCount(100);
15 years, 3 months
teiid SVN: r1482 - trunk/documentation/reference/src/main/docbook/en-US/content.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-09-25 16:29:56 -0400 (Fri, 25 Sep 2009)
New Revision: 1482
Modified:
trunk/documentation/reference/src/main/docbook/en-US/content/federated_planning.xml
Log:
updating programlisting of getting the query plan
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/federated_planning.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/federated_planning.xml 2009-09-24 19:06:34 UTC (rev 1481)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/federated_planning.xml 2009-09-25 20:29:56 UTC (rev 1482)
@@ -405,8 +405,17 @@
</para>
<example>
<title>Retrieving a Query Plan</title>
- <programlisting>ResultSet rs = statement.executeQuery("select ...");
-com.metamatrix.jdbc.api.Statement mmstatement = (com.metamatrix.jdbc.api.Statement)statement;
+ <programlisting>com.metamatrix.jdbc.api.Statement mmstatement = (com.metamatrix.jdbc.api.Statement)statement;
+String sql = "select ...";
+
+mmstatement.setExecutionProperty(ExecutionProperties.PROP_SQL_OPTIONS, ExecutionProperties.SQL_OPTION_SHOWPLAN);
+//or
+//sql += " OPTION SHOWPLAN";
+//or
+//sql += " OPTION PLANONLY";
+
+ResultSet rs = statement.executeQuery(sql);
+
PlanNode queryPlan = mmstatement.getPlanDescription();
System.out.println(XMLOutputVisitor.convertToXML(queryPlan);</programlisting>
</example>
15 years, 3 months
teiid SVN: r1481 - in trunk/engine/src: test/java/com/metamatrix/query/rewriter and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-09-24 15:06:34 -0400 (Thu, 24 Sep 2009)
New Revision: 1481
Removed:
trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/ExpressionSymbolCollector.java
Modified:
trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestOrderByRewrite.java
Log:
removing expressionsymbolcollectorvisitor
Deleted: trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/ExpressionSymbolCollector.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/ExpressionSymbolCollector.java 2009-09-24 15:21:27 UTC (rev 1480)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/ExpressionSymbolCollector.java 2009-09-24 19:06:34 UTC (rev 1481)
@@ -1,100 +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.query.sql.visitor;
-
-import java.util.Collection;
-
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.navigator.PreOrderNavigator;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.util.ErrorMessageKeys;
-
-/**
- * <p>This visitor class will traverse a language object tree and collect all expression
- * element symbol references it finds. It uses a collection to collect the symbols in so
- * different collections will give you different collection properties - for instance,
- * using a Set will remove duplicates.</p>
- *
- * <p>The easiest way to use this visitor is to call the static methods which create
- * the visitor (and possibly the collection), run the visitor, and return the collection.
- * The public visit() methods should NOT be called directly.</p>
- */
-public class ExpressionSymbolCollector extends LanguageVisitor {
- private Collection symbols;
-
- /**
- * Construct a new visitor with the specified collection, which should
- * be non-null.
- * @param elements Collection to use for elements
- * @throws IllegalArgumentException If elements is null
- */
- public ExpressionSymbolCollector(Collection elements) {
- if(elements == null) {
- throw new IllegalArgumentException(QueryPlugin.Util.getString(ErrorMessageKeys.SQL_0021));
- }
- this.symbols = elements;
- }
-
- /**
- * Get the elements collected by the visitor. This should best be called
- * after the visitor has been run on the language object tree.
- * @return Collection of {@link com.metamatrix.query.sql.symbol.ElementSymbol}
- */
- public Collection getSymbols() {
- return this.symbols;
- }
-
- /**
- * Visit a language object and collect symbols. This method should <b>NOT</b> be
- * called directly.
- * @param obj Language object
- */
- public void visit(ExpressionSymbol obj) {
- this.symbols.add(obj);
- }
-
- /**
- * Visit a language object and collect symbols. This method should <b>NOT</b> be
- * called directly.
- * @param obj Language object
- */
- public void visit(AggregateSymbol obj) {
- this.symbols.add(obj);
- }
-
- /**
- * Helper to quickly get the elements from obj in the elements collection
- * @param obj Language object
- * @param elements Collection to collect elements in
- */
- public static final void getSymbols(LanguageObject obj, Collection elements) {
- if(obj == null) {
- return;
- }
- ExpressionSymbolCollector visitor = new ExpressionSymbolCollector(elements);
- PreOrderNavigator.doVisit(obj, visitor);
- }
-}
Modified: trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestOrderByRewrite.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestOrderByRewrite.java 2009-09-24 15:21:27 UTC (rev 1480)
+++ trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestOrderByRewrite.java 2009-09-24 19:06:34 UTC (rev 1481)
@@ -38,10 +38,11 @@
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.OrderBy;
import com.metamatrix.query.sql.lang.Query;
+import com.metamatrix.query.sql.symbol.AliasSymbol;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.ExpressionSymbol;
+import com.metamatrix.query.sql.symbol.SingleElementSymbol;
import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.sql.visitor.ExpressionSymbolCollector;
import com.metamatrix.query.unittest.FakeMetadataFactory;
import com.metamatrix.query.unittest.FakeMetadataObject;
@@ -80,16 +81,17 @@
private void helpCheckExpressionsSymbols(OrderBy langObj,
String[] functionsNames) {
- List symbols = new ArrayList();
+ int expCount = 0;
for (Iterator i = langObj.getVariables().iterator(); i.hasNext();) {
- ExpressionSymbolCollector.getSymbols((LanguageObject)i.next(), symbols);
+ SingleElementSymbol ses = (SingleElementSymbol)i.next();
+ if (ses instanceof AliasSymbol) {
+ AliasSymbol aSymbol = (AliasSymbol)ses;
+ if (aSymbol.getSymbol() instanceof ExpressionSymbol) {
+ assertEquals("Expression Symbols does not match: ", functionsNames[expCount++], aSymbol.getSymbol().toString()); //$NON-NLS-1$
+ }
+ }
}
- assertEquals("Wrong number of Symbols: ", functionsNames.length, symbols.size()); //$NON-NLS-1$
-
- for (int i = 0; i < symbols.size(); i++) {
- ExpressionSymbol symbol = (ExpressionSymbol)symbols.get(i);
- assertEquals("Expression Symbols does not match: ", functionsNames[i], symbol.toString()); //$NON-NLS-1$
- }
+ assertEquals("Wrong number of Symbols: ", functionsNames.length, expCount); //$NON-NLS-1$
}
public void testNumberedOrderBy1() throws Exception {
15 years, 3 months
teiid SVN: r1480 - in trunk/test-integration/db/src/test/java/org/teiid/test: framework/datasource and 1 other directories.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-24 11:21:27 -0400 (Thu, 24 Sep 2009)
New Revision: 1480
Modified:
trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java
trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java
Log:
Teiid 773 - working on a hudson timeout issue, not seeing it locally
Modified: trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java 2009-09-24 14:45:26 UTC (rev 1479)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/AbstractQueryTransactionTest.java 2009-09-24 15:21:27 UTC (rev 1480)
@@ -174,13 +174,12 @@
/**
- * At end of each test, clean up the connection factory so that it can be
- * established at the start of the next test.
+ * At end of each test, perfrom any cleanup that your test requires.
+ * Note: Do not cleanup any connections. That is performed by
+ * the {@link TransactionContainer#runTransaction(TransactionQueryTest)} at the end of the test.
*/
public void cleanup() {
- ConnectionStrategyFactory.destroyInstance();
-
- // this.closeConnection();
+
}
@Override
Modified: trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java 2009-09-24 14:45:26 UTC (rev 1479)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/framework/datasource/TwoDataSourceSetup.java 2009-09-24 15:21:27 UTC (rev 1480)
@@ -33,12 +33,9 @@
System.out.println("Run TwoSource Setup...");
- System.out.println("perform source pm1 set...");
+ System.out.println("perform source pm1 set");
AbstractQueryTest test1 = new QueryExecution(ConnectionUtil.getConnection("pm1", ds));//$NON-NLS-1$
-
-
- System.out.println("perform source pm1 set...");
test1.execute("delete from g2"); //$NON-NLS-1$
test1.execute("delete from g1"); //$NON-NLS-1$
Modified: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java 2009-09-24 14:45:26 UTC (rev 1479)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/BaseAbstractTransactionTestCase.java 2009-09-24 15:21:27 UTC (rev 1480)
@@ -6,14 +6,9 @@
-import java.sql.Connection;
-
-import javax.sql.XAConnection;
-
import junit.framework.TestCase;
import org.teiid.test.framework.TransactionContainer;
-import org.teiid.test.framework.connection.ConnectionUtil;
import org.teiid.test.framework.datasource.DataSourceMgr;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.transaction.TransactionFactory;
15 years, 3 months
teiid SVN: r1479 - in trunk/test-integration/db/src/main/java/org/teiid/test/framework: connection and 1 other directory.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-09-24 10:45:26 -0400 (Thu, 24 Sep 2009)
New Revision: 1479
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTest.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java
Log:
Teiid 773 - working on a hudson timeout issue, not seeing it locally
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java 2009-09-24 14:40:50 UTC (rev 1478)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java 2009-09-24 14:45:26 UTC (rev 1479)
@@ -5,6 +5,7 @@
import java.util.Properties;
import org.teiid.test.framework.connection.ConnectionStrategyFactory;
+import org.teiid.test.util.PropUtils;
public class ConfigPropertyLoader {
@@ -32,21 +33,8 @@
}
private static void loadProperties(String filename) {
- props = System.getProperties();
- try {
- InputStream in = ConfigPropertyLoader.class.getResourceAsStream("/"+ filename);
- if (in != null) {
- Properties lprops = new Properties();
- lprops.load(in);
- props.putAll(lprops);
-
- }
- else {
- throw new RuntimeException("Failed to load properties from file '"+filename+ "' configuration file");
- }
- } catch (IOException e) {
- throw new RuntimeException("Error loading properties from file '"+filename+ "'" + e.getMessage());
- }
+ props =PropUtils.loadProperties("/"+ filename, System.getProperties());
+
}
public static void cleanup() {
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java 2009-09-24 14:40:50 UTC (rev 1478)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java 2009-09-24 14:45:26 UTC (rev 1479)
@@ -9,6 +9,7 @@
import java.util.Set;
import org.teiid.test.framework.connection.ConnectionStrategy;
+import org.teiid.test.framework.connection.ConnectionStrategyFactory;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
@@ -30,29 +31,45 @@
}
-
- protected Set getDataSources() {
- Set dss = null;
+ protected void setupData(TransactionQueryTest test) {
+ test.setDataSources(connStrategy.getDataSources());
+ test.setupDataSources();
-
- return dss;
}
-
protected void before(TransactionQueryTest test){}
protected void after(TransactionQueryTest test) {}
public void runTransaction(TransactionQueryTest test) {
+
+ try {
+
+ try {
+
+ runIt(test);
+
+ } finally {
+ debug(" test.cleanup");
+
+ test.cleanup();
+ }
+
+ } finally {
+ // cleanup all connections created for this test.
+ ConnectionStrategyFactory.destroyInstance();
+ }
+ }
+
+ private void runIt(TransactionQueryTest test) {
detail("Start transaction test: " + test.getTestName());
try {
- test.setDataSources(connStrategy.getDataSources());
- test.setupDataSources();
+ setupData(test);
debug(" setConnection");
- test.setConnection(getConnection());
+ test.setConnection(this.connStrategy.getConnection());
test.setExecutionProperties(this.props);
debug(" before(test)");
@@ -86,7 +103,7 @@
}
if (test.exceptionExpected() && !test.exceptionOccurred()) {
- throw new TransactionRuntimeException("Expected exception, but one did not occur");
+ throw new TransactionRuntimeException("Expected exception, but one did not occur for test: " + this.getClass().getName() + "." + test.getTestName());
}
try {
@@ -99,33 +116,25 @@
}catch(Exception e) {
throw new TransactionRuntimeException(e);
}
-
- debug(" test.cleanup");
-
- test.cleanup();
detail("Completed transaction test: " + test.getTestName());
- }
+ }
- protected Connection getConnection() throws QueryTestFailedException {
- return this.connStrategy.getConnection();
- }
-
public Properties getEnvironmentProperties() {
return props;
}
protected void debug(String message) {
if (debug) {
- System.out.println(message);
+ System.out.println("[" + this.getClass().getSimpleName() + "] " + message);
}
}
protected void detail(String message) {
- System.out.println(message);
+ System.out.println("[" + this.getClass().getSimpleName() + "] " + message);
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTest.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTest.java 2009-09-24 14:40:50 UTC (rev 1478)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTest.java 2009-09-24 14:45:26 UTC (rev 1479)
@@ -33,7 +33,8 @@
/**
- * Called by the @link TransactionContainer to set the datasoures used to create the connector bindings.
+ * Called by the @link TransactionContainer to set the datasoures used to create the connector bindings and
+ * used to create direct connection to the sources.
* @param datasources
*
* @since
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java 2009-09-24 14:40:50 UTC (rev 1478)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java 2009-09-24 14:45:26 UTC (rev 1479)
@@ -63,6 +63,14 @@
*/
public abstract Connection getConnection() throws QueryTestFailedException;
+ /**
+ * Implement shutdown of your type of connecton
+ *
+ *
+ * @since
+ */
+ public abstract void shutdown();
+
public Connection getAdminConnection() throws QueryTestFailedException{
return null;
}
@@ -72,7 +80,6 @@
return autoCommit;
}
- public abstract void shutdown();
public XAConnection getXAConnection() throws QueryTestFailedException {
return null;
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java 2009-09-24 14:40:50 UTC (rev 1478)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java 2009-09-24 14:45:26 UTC (rev 1479)
@@ -20,27 +20,27 @@
import com.metamatrix.jdbc.EmbeddedDataSource;
public class DataSourceConnection extends ConnectionStrategy {
-
- public static final String DS_USER = "user"; //$NON-NLS-1$
-
- // need both user variables because Teiid uses 'user' and connectors use 'username'
- public static final String DS_USERNAME = JDBCPropertyNames.USERNAME; //$NON-NLS-1$
- public static final String DS_PASSWORD = JDBCPropertyNames.PASSWORD; //$NON-NLS-1$
-
- // the driver is only used for making direct connections to the source, the
- // connector type will provide the JDBCPropertyNames.CONNECTION_SOURCE driver class
- public static final String DS_DRIVER = "driver"; //$NON-NLS-1$
-
- public static final String DS_SERVERNAME = "servername"; //$NON-NLS-1$
- public static final String DS_SERVERPORT = "portnumber"; //$NON-NLS-1$
- public static final String DS_JNDINAME = "ds-jndiname"; //$NON-NLS-1$
- public static final String DS_DATABASENAME = "databasename"; //$NON-NLS-1$
- public static final String DS_APPLICATION_NAME = "application-name"; //$NON-NLS-1$
-
-// public static final String JNDINAME_USERTXN = "usertxn-jndiname"; //$NON-NLS-1$
-
+ public static final String DS_USER = "user"; //$NON-NLS-1$
+ // need both user variables because Teiid uses 'user' and connectors use
+ // 'username'
+ public static final String DS_USERNAME = JDBCPropertyNames.USERNAME; //$NON-NLS-1$
+ public static final String DS_PASSWORD = JDBCPropertyNames.PASSWORD; //$NON-NLS-1$
+
+ // the driver is only used for making direct connections to the source, the
+ // connector type will provide the JDBCPropertyNames.CONNECTION_SOURCE
+ // driver class
+ public static final String DS_DRIVER = "driver"; //$NON-NLS-1$
+
+ public static final String DS_SERVERNAME = "servername"; //$NON-NLS-1$
+ public static final String DS_SERVERPORT = "portnumber"; //$NON-NLS-1$
+ public static final String DS_JNDINAME = "ds-jndiname"; //$NON-NLS-1$
+ public static final String DS_DATABASENAME = "databasename"; //$NON-NLS-1$
+ public static final String DS_APPLICATION_NAME = "application-name"; //$NON-NLS-1$
+
+ // public static final String JNDINAME_USERTXN = "usertxn-jndiname"; //$NON-NLS-1$
+
private String driver = null;
private String username = null;
private String pwd = null;
@@ -48,106 +48,109 @@
private String databaseName = null;
private String serverName = null;
private String portNumber = null;
-
-
- private XAConnection xaConnection;
-
- public DataSourceConnection(Properties props) throws QueryTestFailedException {
- super(props);
- }
-
+ private XAConnection xaConnection;
- public void validate() {
- databaseName = this.getEnvironment().getProperty(DS_DATABASENAME);
- if (databaseName == null || databaseName.length() == 0) {
- throw new TransactionRuntimeException("Property " + DS_DATABASENAME + " was not specified");
- }
-
- serverName = this.getEnvironment().getProperty(DS_SERVERNAME);
- if (serverName == null || serverName.length() == 0) {
- throw new TransactionRuntimeException("Property " + DS_SERVERNAME + " was not specified");
- }
+ public DataSourceConnection(Properties props)
+ throws QueryTestFailedException {
+ super(props);
+ }
-
- this.portNumber = this.getEnvironment().getProperty(DS_SERVERPORT);
-
- this.applName = this.getEnvironment().getProperty(DS_APPLICATION_NAME);
-
- driver = this.getEnvironment().getProperty(DS_DRIVER);
- if (driver == null || driver.length() == 0) {
- throw new TransactionRuntimeException("Property " + DS_DRIVER + " was not specified");
- }
-
- this.username = this.getEnvironment().getProperty(DS_USER);
- this.pwd = this.getEnvironment().getProperty(DS_PASSWORD);
-
+ public void validate() {
+ databaseName = this.getEnvironment().getProperty(DS_DATABASENAME);
+ if (databaseName == null || databaseName.length() == 0) {
+ throw new TransactionRuntimeException("Property " + DS_DATABASENAME
+ + " was not specified");
+ }
+
+ serverName = this.getEnvironment().getProperty(DS_SERVERNAME);
+ if (serverName == null || serverName.length() == 0) {
+ throw new TransactionRuntimeException("Property " + DS_SERVERNAME
+ + " was not specified");
+ }
+
+ this.portNumber = this.getEnvironment().getProperty(DS_SERVERPORT);
+
+ this.applName = this.getEnvironment().getProperty(DS_APPLICATION_NAME);
+
+ driver = this.getEnvironment().getProperty(DS_DRIVER);
+ if (driver == null || driver.length() == 0) {
+ throw new TransactionRuntimeException("Property " + DS_DRIVER
+ + " was not specified");
+ }
+
+ this.username = this.getEnvironment().getProperty(DS_USER);
+ if (username == null) {
+ this.username = this.getEnvironment().getProperty(DS_USERNAME);
+ }
+ this.pwd = this.getEnvironment().getProperty(DS_PASSWORD);
+
}
public Connection getConnection() throws QueryTestFailedException {
- try {
- return getXAConnection().getConnection();
- } catch (QueryTestFailedException qtf) {
- throw qtf;
- } catch (Exception e) {
- e.printStackTrace();
- throw new QueryTestFailedException(e);
- }
- }
-
- public synchronized XAConnection getXAConnection() throws QueryTestFailedException {
- if (xaConnection == null) {
- validate();
- try {
- xaConnection = createConnection();
- } catch (Exception e) {
- throw new QueryTestFailedException(e);
- }
- }
- return xaConnection;
- }
+ try {
+ return getXAConnection().getConnection();
+ } catch (QueryTestFailedException qtf) {
+ throw qtf;
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new QueryTestFailedException(e);
+ }
+ }
- private XAConnection createConnection() throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException {
- System.out.println("Creating Datasource Connection: \"" + this.serverName + " - " + this.databaseName + "\""); //$NON-NLS-1$ //$NON-NLS-2$
+ public synchronized XAConnection getXAConnection()
+ throws QueryTestFailedException {
+ if (xaConnection == null) {
+ validate();
+ try {
+ xaConnection = createConnection();
+ } catch (Exception e) {
+ throw new QueryTestFailedException(e);
+ }
+ }
+ return xaConnection;
+ }
-
- BaseDataSource dataSource = (BaseDataSource)Class.forName(this.driver).newInstance();
+ private XAConnection createConnection() throws SQLException,
+ InstantiationException, IllegalAccessException,
+ ClassNotFoundException {
+ System.out
+ .println("Creating Datasource Connection: \"" + this.serverName + " - " + this.databaseName + "\""); //$NON-NLS-1$ //$NON-NLS-2$
- dataSource.setDatabaseName(this.databaseName);
- if (this.applName != null) {
- dataSource.setApplicationName(this.applName);
- }
-
- if (dataSource instanceof EmbeddedDataSource) {
- ((EmbeddedDataSource)dataSource).setBootstrapFile(this.serverName);
- } else {
- ((TeiidDataSource)dataSource).setServerName(this.serverName);
- ((TeiidDataSource)dataSource).setPortNumber(Integer.parseInt(this.portNumber));
- }
-
- dataSource.setUser("admin");
- dataSource.setPassword("teiid");
-
-// if (this.username != null) {
-// dataSource.setUser(this.username);
-// dataSource.setPassword(this.pwd);
-// }
-
-
- return ((XADataSource)dataSource).getXAConnection();
- }
+ BaseDataSource dataSource = (BaseDataSource) Class.forName(this.driver)
+ .newInstance();
- public void shutdown() {
- try {
+ dataSource.setDatabaseName(this.databaseName);
+ if (this.applName != null) {
+ dataSource.setApplicationName(this.applName);
+ }
+ if (dataSource instanceof EmbeddedDataSource) {
+ ((EmbeddedDataSource) dataSource).setBootstrapFile(this.serverName);
+ } else {
+ ((TeiidDataSource) dataSource).setServerName(this.serverName);
+ ((TeiidDataSource) dataSource).setPortNumber(Integer
+ .parseInt(this.portNumber));
+ }
- if (this.xaConnection != null) {
- this.xaConnection.close();
- }
- } catch (SQLException e) {
- // ignore..
- }
-
- this.xaConnection = null;
- }
+ if (this.username != null) {
+ dataSource.setUser(this.username);
+ dataSource.setPassword(this.pwd);
+ }
+
+ return ((XADataSource) dataSource).getXAConnection();
+ }
+
+ public void shutdown() {
+ try {
+
+ if (this.xaConnection != null) {
+ this.xaConnection.close();
+ }
+ } catch (SQLException e) {
+ // ignore..
+ }
+
+ this.xaConnection = null;
+ }
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java 2009-09-24 14:40:50 UTC (rev 1478)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java 2009-09-24 14:45:26 UTC (rev 1479)
@@ -13,10 +13,8 @@
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
-import com.metamatrix.jdbc.api.ExecutionProperties;
-
/**
* The DriverConnection strategy that can get connections in standalone mode
* or embedded mode.
15 years, 3 months