Author: shawkins
Date: 2011-12-08 13:54:42 -0500 (Thu, 08 Dec 2011)
New Revision: 3727
Added:
trunk/api/src/main/java/org/teiid/CommandListener.java
Modified:
trunk/api/src/main/java/org/teiid/CommandContext.java
trunk/api/src/main/java/org/teiid/translator/ExecutionContext.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCBaseExecution.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/QueryExecutionImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ExecutionContextImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java
trunk/engine/src/main/java/org/teiid/query/processor/BatchCollector.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLPlan.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/FakeExecutionContextImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
Log:
TEIID-1604 cleaning up methods/javadoc and adding a commandlistener for close events.
Modified: trunk/api/src/main/java/org/teiid/CommandContext.java
===================================================================
--- trunk/api/src/main/java/org/teiid/CommandContext.java 2011-12-08 17:13:56 UTC (rev
3726)
+++ trunk/api/src/main/java/org/teiid/CommandContext.java 2011-12-08 18:54:42 UTC (rev
3727)
@@ -60,6 +60,13 @@
* Get the connection id
* @return
*/
+ String getConnectionId();
+
+ /**
+ * Get the connection id
+ * @return
+ * @deprecated see {@link #getConnectionId()}
+ */
String getConnectionID();
/**
@@ -124,5 +131,17 @@
* @return
*/
VDB getVdb();
+
+ /**
+ * Add a listener for command events
+ * @param listener
+ */
+ void addListener(CommandListener listener);
+
+ /**
+ * Add a listener for command events
+ * @param listener
+ */
+ void removeListener(CommandListener listener);
}
Added: trunk/api/src/main/java/org/teiid/CommandListener.java
===================================================================
--- trunk/api/src/main/java/org/teiid/CommandListener.java (rev
0)
+++ trunk/api/src/main/java/org/teiid/CommandListener.java 2011-12-08 18:54:42 UTC (rev
3727)
@@ -0,0 +1,29 @@
+/*
+ * 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;
+
+public interface CommandListener {
+
+ void commandClosed(CommandContext context);
+
+}
Property changes on: trunk/api/src/main/java/org/teiid/CommandListener.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/api/src/main/java/org/teiid/translator/ExecutionContext.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/ExecutionContext.java 2011-12-08 17:13:56
UTC (rev 3726)
+++ trunk/api/src/main/java/org/teiid/translator/ExecutionContext.java 2011-12-08 18:54:42
UTC (rev 3727)
@@ -53,13 +53,19 @@
/**
* Get the identifier for the command being executed. This can be
* correlated back to identifiers exposed in other parts of the system.
+ * shortcut for {@link #getCommandContext()}.getRequestId()
* @return command identifier
*/
- String getRequestIdentifier();
+ String getRequestId();
/**
+ * @deprecated see {@link #getRequestId()}
+ * @return
+ */
+ String getRequestID();
+
+ /**
* This specifies the node id for the atomic request in the relational plan of query.
- * when combined with the request identifier, uniquely identifies a command sent to a
connector.
*/
String getPartIdentifier();
@@ -73,14 +79,28 @@
/**
* Get the name of the VDB this query is being run against.
+ * shortcut for {@link #getCommandContext()}.getVdbName()
* @return VDB name, never null
*/
+ String getVdbName();
+
+ /**
+ * @deprecated see {@link #getVdbName()}
+ * @return
+ */
String getVirtualDatabaseName();
/**
* Get the version of the VDB this query is being run against.
- * @return VDB version, never null
+ * shortcut for {@link #getCommandContext()}.getVdbVersion()
+ * @return VDB version
*/
+ int getVdbVersion();
+
+ /**
+ * @deprecated see {@link #getVdbVersion()}
+ * @return
+ */
int getVirtualDatabaseVersion();
/**
@@ -88,18 +108,17 @@
* @return User, never null
*/
Subject getSubject();
+
+ /**
+ * Get the command payload
+ * shortcut for {@link #getCommandContext()}.getCommandPayload()
+ * @return the payload or null if one was not set by the client
+ */
+ Serializable getCommandPayload();
/**
- * Get the trusted payload passed when the user statement was executed.
- * Teiid has no knowledge about what the payload contains - it is merely
- * passed through the system. It is most often used to pass security
- * information such as credentials.
- *
- * <p>Given that the Execution Payload is not authenticated by the Teiid
- * system, connector writers are responsible for ensuring its validity. </p>
- *
- * @return Trusted execution payload if one exists, otherwise null
- * @since 4.2
+ * @deprecated see {@link #getCommandPayload()
+ * @return
*/
Serializable getExecutionPayload();
@@ -117,13 +136,20 @@
/**
* Get the identifier for the connection through which
- * the command is being executed. This represents the original JDBC user
+ * the command is being executed. This represents the original user
* connection to the Teiid system
+ * shortcut for {@link #getCommandContext()}.getConnectionId()
* @return Connection identifier
*/
- String getConnectionIdentifier();
+ String getConnectionId();
/**
+ * @deprecated see {@link #getConnectionId()}
+ * @return
+ */
+ String getConnectionID();
+
+ /**
* 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.
@@ -159,6 +185,7 @@
/**
* Get the current session.
+ * shortcut for {@link #getCommandContext()}.getSession()
* @return
*/
Session getSession();
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCBaseExecution.java
===================================================================
---
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCBaseExecution.java 2011-12-08
17:13:56 UTC (rev 3726)
+++
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCBaseExecution.java 2011-12-08
18:54:42 UTC (rev 3727)
@@ -139,7 +139,7 @@
statement.setFetchSize(fetchSize);
} catch (SQLException e) {
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_CONNECTOR, MessageLevel.DETAIL))
{
- LogManager.logDetail(LogConstants.CTX_CONNECTOR, context.getRequestIdentifier(),
" could not set fetch size: ", fetchSize); //$NON-NLS-1$
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, context.getRequestId(), "
could not set fetch size: ", fetchSize); //$NON-NLS-1$
}
}
}
@@ -191,7 +191,7 @@
warning = toAdd.getNextWarning();
toAdd.setNextException(null);
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_CONNECTOR,
MessageLevel.DETAIL)) {
- LogManager.logDetail(LogConstants.CTX_CONNECTOR, context.getRequestIdentifier() +
" Warning: ", warning); //$NON-NLS-1$
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, context.getRequestId() + "
Warning: ", warning); //$NON-NLS-1$
}
context.addWarning(toAdd);
}
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
===================================================================
---
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2011-12-08
17:13:56 UTC (rev 3726)
+++
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2011-12-08
18:54:42 UTC (rev 3727)
@@ -722,7 +722,7 @@
*/
public String getSourceComment(ExecutionContext context, Command command) {
if (addSourceComment() && context != null) {
- return COMMENT.get().format(new Object[] {context.getConnectionIdentifier(),
context.getRequestIdentifier(), context.getPartIdentifier()});
+ return COMMENT.get().format(new Object[] {context.getConnectionId(),
context.getRequestId(), context.getPartIdentifier()});
}
return ""; //$NON-NLS-1$
}
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
===================================================================
---
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java 2011-12-08
17:13:56 UTC (rev 3726)
+++
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java 2011-12-08
18:54:42 UTC (rev 3727)
@@ -353,7 +353,7 @@
boolean usingPayloadComment = false;
if (context != null) {
// Check for db hints
- Object payload = context.getExecutionPayload();
+ Object payload = context.getCommandPayload();
if (payload instanceof String) {
String payloadString = (String)payload;
if (payloadString.startsWith(HINT_PREFIX)) {
Modified:
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/QueryExecutionImpl.java
===================================================================
---
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/QueryExecutionImpl.java 2011-12-08
17:13:56 UTC (rev 3726)
+++
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/QueryExecutionImpl.java 2011-12-08
18:54:42 UTC (rev 3727)
@@ -116,9 +116,9 @@
this.context = context;
this.query = command;
- connectionIdentifier = context.getConnectionIdentifier();
+ connectionIdentifier = context.getConnectionId();
connectorIdentifier = context.getConnectorIdentifier();
- requestIdentifier = context.getRequestIdentifier();
+ requestIdentifier = context.getRequestId();
partIdentifier = context.getPartIdentifier();
}
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ExecutionContextImpl.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ExecutionContextImpl.java 2011-12-08
17:13:56 UTC (rev 3726)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ExecutionContextImpl.java 2011-12-08
18:54:42 UTC (rev 3727)
@@ -93,7 +93,7 @@
}
@Override
- public String getRequestIdentifier() {
+ public String getRequestId() {
return this.commandContext.getRequestId();
}
@@ -107,11 +107,11 @@
return this.executeCount;
}
@Override
- public String getVirtualDatabaseName() {
+ public String getVdbName() {
return this.commandContext.getVdbName();
}
@Override
- public int getVirtualDatabaseVersion() {
+ public int getVdbVersion() {
return this.commandContext.getVdbVersion();
}
@Override
@@ -120,13 +120,13 @@
}
@Override
- public Serializable getExecutionPayload() {
+ public Serializable getCommandPayload() {
return this.commandContext.getCommandPayload();
}
@Override
- public String getConnectionIdentifier() {
- return this.commandContext.getConnectionID();
+ public String getConnectionId() {
+ return this.commandContext.getConnectionId();
}
@Override
public void keepExecutionAlive(boolean alive) {
@@ -145,7 +145,7 @@
return false;
}
ExecutionContext other = (ExecutionContext) obj;
- return compareWithNull(this.getRequestIdentifier(), other.getRequestIdentifier())
&&
+ return compareWithNull(this.getRequestId(), other.getRequestId()) &&
compareWithNull(this.getPartIdentifier(), other.getPartIdentifier());
}
@@ -163,7 +163,7 @@
}
public int hashCode() {
- return HashCodeUtil.hashCode(HashCodeUtil.hashCode(0, getRequestIdentifier()),
partID);
+ return HashCodeUtil.hashCode(HashCodeUtil.hashCode(0, getRequestId()), partID);
}
public String toString() {
@@ -173,7 +173,7 @@
userName = p.getName();
}
}
- return "ExecutionContext<vdb=" + this.getVirtualDatabaseName() +
", version=" + this.getVirtualDatabaseVersion() + ", user=" + userName
+ ">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ return "ExecutionContext<vdb=" + this.getVdbName() + ",
version=" + this.getVdbVersion() + ", user=" + userName + ">";
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
@Override
@@ -256,4 +256,30 @@
public void setHint(String hint) {
this.hint = hint;
}
+
+ @Override
+ public String getConnectionID() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Serializable getExecutionPayload() {
+ return getCommandPayload();
+ }
+
+ @Override
+ public String getRequestID() {
+ return getRequestId();
+ }
+
+ @Override
+ public String getVirtualDatabaseName() {
+ return getVdbName();
+ }
+
+ @Override
+ public int getVirtualDatabaseVersion() {
+ return getVdbVersion();
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2011-12-08
17:13:56 UTC (rev 3726)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2011-12-08
18:54:42 UTC (rev 3727)
@@ -564,7 +564,7 @@
this.resultsBuffer = collector.getTupleBuffer();
if (this.resultsBuffer == null) {
//This is just a dummy result it will get replaced by collector source
- resultsBuffer =
this.processor.getBufferManager().createTupleBuffer(this.originalCommand.getProjectedSymbols(),
this.request.context.getConnectionID(), TupleSourceType.FINAL);
+ resultsBuffer =
this.processor.getBufferManager().createTupleBuffer(this.originalCommand.getProjectedSymbols(),
this.request.context.getConnectionId(), TupleSourceType.FINAL);
}
analysisRecord = request.analysisRecord;
transactionContext = request.transactionContext;
Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java 2011-12-08
17:13:56 UTC (rev 3726)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java 2011-12-08
18:54:42 UTC (rev 3727)
@@ -1277,7 +1277,7 @@
}
public static Object session_id(CommandContext context) {
- return context.getConnectionID();
+ return context.getConnectionId();
}
// ================= Function - MODIFYTIMEZONE ========================
Modified: trunk/engine/src/main/java/org/teiid/query/processor/BatchCollector.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/BatchCollector.java 2011-12-08
17:13:56 UTC (rev 3726)
+++ trunk/engine/src/main/java/org/teiid/query/processor/BatchCollector.java 2011-12-08
18:54:42 UTC (rev 3727)
@@ -124,7 +124,7 @@
this.sourceNode = sourceNode;
this.forwardOnly = forwardOnly;
if (!this.sourceNode.hasFinalBuffer()) {
- this.buffer = bm.createTupleBuffer(sourceNode.getOutputElements(),
context.getConnectionID(), TupleSourceType.PROCESSOR);
+ this.buffer = bm.createTupleBuffer(sourceNode.getOutputElements(),
context.getConnectionId(), TupleSourceType.PROCESSOR);
this.buffer.setForwardOnly(forwardOnly);
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java 2011-12-08
17:13:56 UTC (rev 3726)
+++
trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java 2011-12-08
18:54:42 UTC (rev 3727)
@@ -505,9 +505,9 @@
state.processor = new QueryProcessor(command, subContext, this.bufferMgr,
this.dataMgr);
state.ts = new BatchIterator(state.processor);
if (procAssignments != null &&
state.processor.getOutputElements().size() - procAssignments.size() > 0) {
- state.resultsBuffer =
bufferMgr.createTupleBuffer(state.processor.getOutputElements().subList(0,
state.processor.getOutputElements().size() - procAssignments.size()),
getContext().getConnectionID(), TupleSourceType.PROCESSOR);
+ state.resultsBuffer =
bufferMgr.createTupleBuffer(state.processor.getOutputElements().subList(0,
state.processor.getOutputElements().size() - procAssignments.size()),
getContext().getConnectionId(), TupleSourceType.PROCESSOR);
} else if (this.blockContext != null) {
- state.resultsBuffer =
bufferMgr.createTupleBuffer(state.processor.getOutputElements(),
getContext().getConnectionID(), TupleSourceType.PROCESSOR);
+ state.resultsBuffer =
bufferMgr.createTupleBuffer(state.processor.getOutputElements(),
getContext().getConnectionId(), TupleSourceType.PROCESSOR);
}
this.currentState = state;
}
@@ -595,7 +595,7 @@
}
public void push(Program program) throws XATransactionException {
- program.reset(this.getContext().getConnectionID());
+ program.reset(this.getContext().getConnectionId());
TempTableStore tts = getTempTableStore();
getContext().setTempTableStore(program.getTempTableStore());
program.getTempTableStore().setParentTempTableStore(tts);
Modified:
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNode.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNode.java 2011-12-08
17:13:56 UTC (rev 3726)
+++
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNode.java 2011-12-08
18:54:42 UTC (rev 3727)
@@ -146,7 +146,7 @@
}
protected String getConnectionID() {
- return this.getProcessingState().context.getConnectionID();
+ return this.getProcessingState().context.getConnectionId();
}
protected int getBatchSize() {
Modified:
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java 2011-12-08
17:13:56 UTC (rev 3726)
+++
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java 2011-12-08
18:54:42 UTC (rev 3727)
@@ -101,7 +101,7 @@
}
if (this.with != null) {
context = context.clone();
- tempTableStore = new TempTableStore(context.getConnectionID(),
TransactionMode.NONE);
+ tempTableStore = new TempTableStore(context.getConnectionId(),
TransactionMode.NONE);
tempTableStore.setParentTempTableStore(context.getTempTableStore());
context.setTempTableStore(tempTableStore);
for (WithQueryCommand withCommand : this.with) {
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLPlan.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLPlan.java 2011-12-08
17:13:56 UTC (rev 3726)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLPlan.java 2011-12-08
18:54:42 UTC (rev 3727)
@@ -111,7 +111,7 @@
public void initialize(CommandContext context, ProcessorDataManager dataMgr,
BufferManager bufferMgr) {
context = context.clone();
setContext(context);
- TempTableStore tempTableStore = new TempTableStore(context.getConnectionID(),
TransactionMode.NONE);
+ TempTableStore tempTableStore = new TempTableStore(context.getConnectionId(),
TransactionMode.NONE);
tempTableStore.setParentTempTableStore(context.getTempTableStore());
context.setTempTableStore(tempTableStore);
this.dataMgr = dataMgr;
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2011-12-08
17:13:56 UTC (rev 3726)
+++
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2011-12-08
18:54:42 UTC (rev 3727)
@@ -223,7 +223,7 @@
hash |= (hash >>> 8);
hash &= 0x000000ff;
CacheID cid = new CacheID(new ParseInfo(), fullName + hash, context.getVdbName(),
- context.getVdbVersion(), context.getConnectionID(), context.getUserName());
+ context.getVdbVersion(), context.getConnectionId(), context.getUserName());
cid.setParameters(vals);
CachedResults results = cache.get(cid);
if (results != null) {
Modified: trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java 2011-12-08
17:13:56 UTC (rev 3726)
+++ trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java 2011-12-08
18:54:42 UTC (rev 3727)
@@ -25,6 +25,7 @@
import java.io.Serializable;
import java.util.Collections;
import java.util.HashSet;
+import java.util.IdentityHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -36,6 +37,7 @@
import javax.security.auth.Subject;
+import org.teiid.CommandListener;
import org.teiid.adminapi.DataPolicy;
import org.teiid.adminapi.Session;
import org.teiid.adminapi.VDB;
@@ -140,6 +142,7 @@
private SourceHint sourceHint;
private Executor executor = ExecutorUtils.getDirectExecutor();
Map<String, ReusableExecution<?>> reusableExecutions;
+ Set<CommandListener> commandListeners = null;
}
private GlobalState globalState = new GlobalState();
@@ -229,31 +232,23 @@
public String toString() {
return "CommandContext: " + globalState.processorID; //$NON-NLS-1$
}
-
- /**
- * @return String
- */
+
+ public String getConnectionId() {
+ return globalState.connectionID;
+ }
+
public String getConnectionID() {
return globalState.connectionID;
}
- /**
- * @return String
- */
public String getUserName() {
return globalState.userName;
}
- /**
- * @return String
- */
public String getVdbName() {
return globalState.vdbName;
}
- /**
- * @return String
- */
public int getVdbVersion() {
return globalState.vdbVersion;
}
@@ -501,7 +496,7 @@
if (this.globalState.planCache == null) {
return null;
}
- CacheID id = new CacheID(new ParseInfo(), key, getVdbName(), getVdbVersion(),
getConnectionID(), getUserName());
+ CacheID id = new CacheID(new ParseInfo(), key, getVdbName(), getVdbVersion(),
getConnectionId(), getUserName());
PreparedPlan pp = this.globalState.planCache.get(id);
if (pp != null) {
if (id.getSessionId() != null) {
@@ -518,7 +513,7 @@
if (this.globalState.planCache == null) {
return;
}
- CacheID id = new CacheID(new ParseInfo(), key, getVdbName(), getVdbVersion(),
getConnectionID(), getUserName());
+ CacheID id = new CacheID(new ParseInfo(), key, getVdbName(), getVdbVersion(),
getConnectionId(), getUserName());
this.globalState.planCache.put(id, determinismLevel, plan, null);
}
@@ -644,29 +639,69 @@
}
public ReusableExecution<?> getReusableExecution(String nodeId) {
- if (this.globalState.reusableExecutions == null) {
- return null;
+ synchronized (this.globalState) {
+ if (this.globalState.reusableExecutions == null) {
+ return null;
+ }
+ return this.globalState.reusableExecutions.get(nodeId);
}
- return this.globalState.reusableExecutions.get(nodeId);
}
public void putReusableExecution(String nodeId, ReusableExecution<?> execution) {
- if (this.globalState.reusableExecutions == null) {
- this.globalState.reusableExecutions = new ConcurrentHashMap<String,
ReusableExecution<?>>();
+ synchronized (this.globalState) {
+ if (this.globalState.reusableExecutions == null) {
+ this.globalState.reusableExecutions = new ConcurrentHashMap<String,
ReusableExecution<?>>();
+ }
+ this.globalState.reusableExecutions.put(nodeId, execution);
}
- this.globalState.reusableExecutions.put(nodeId, execution);
}
public void close() {
- if (this.globalState.reusableExecutions != null) {
- for (ReusableExecution<?> reusableExecution :
this.globalState.reusableExecutions.values()) {
- try {
- reusableExecution.dispose();
- } catch (Exception e) {
- LogManager.logWarning(LogConstants.CTX_DQP, e, "Unhandled exception disposing
reusable execution"); //$NON-NLS-1$
+ synchronized (this.globalState) {
+ if (this.globalState.reusableExecutions != null) {
+ for (ReusableExecution<?> reusableExecution :
this.globalState.reusableExecutions.values()) {
+ try {
+ reusableExecution.dispose();
+ } catch (Exception e) {
+ LogManager.logWarning(LogConstants.CTX_DQP, e, "Unhandled exception disposing
reusable execution"); //$NON-NLS-1$
+ }
}
+ this.globalState.reusableExecutions.clear();
}
+ if (this.globalState.commandListeners != null) {
+ for (CommandListener listener : this.globalState.commandListeners) {
+ try {
+ listener.commandClosed(this);
+ } catch (Exception e) {
+ LogManager.logWarning(LogConstants.CTX_DQP, e, "Unhandled exception calling
CommandListener"); //$NON-NLS-1$
+ }
+ }
+ this.globalState.commandListeners.clear();
+ }
}
}
+
+ @Override
+ public void addListener(CommandListener listener) {
+ if (listener != null) {
+ synchronized (this.globalState) {
+ if (this.globalState.commandListeners == null) {
+ this.globalState.commandListeners = Collections.newSetFromMap(new
IdentityHashMap<CommandListener, Boolean>());
+ }
+ this.globalState.commandListeners.add(listener);
+ }
+ }
+ }
+
+ @Override
+ public void removeListener(CommandListener listener) {
+ if (listener != null) {
+ synchronized (this.globalState) {
+ if (this.globalState.commandListeners != null) {
+ this.globalState.commandListeners.remove(listener);
+ }
+ }
+ }
+ }
}
Modified:
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/FakeExecutionContextImpl.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/FakeExecutionContextImpl.java 2011-12-08
17:13:56 UTC (rev 3726)
+++
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/FakeExecutionContextImpl.java 2011-12-08
18:54:42 UTC (rev 3727)
@@ -48,9 +48,9 @@
}
public FakeExecutionContextImpl(ExecutionContext c) {
- super(c.getVirtualDatabaseName(), c.getVirtualDatabaseVersion(),
c.getExecutionPayload(), c
- .getConnectionIdentifier(), c.getConnectorIdentifier(), Long.valueOf(c
- .getRequestIdentifier()), c.getPartIdentifier(), c
+ super(c.getVdbName(), c.getVdbVersion(), c.getCommandPayload(), c
+ .getConnectionId(), c.getConnectorIdentifier(), Long.valueOf(c
+ .getRequestId()), c.getPartIdentifier(), c
.getExecutionCountIdentifier());
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2011-12-08
17:13:56 UTC (rev 3726)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2011-12-08
18:54:42 UTC (rev 3727)
@@ -124,7 +124,7 @@
DQPWorkContext workContext = RealMetadataFactory.buildWorkContext(metadata,
RealMetadataFactory.example1VDB());
Request request = helpProcessMessage(message, null, workContext);
- assertEquals("1", request.context.getConnectionID()); //$NON-NLS-1$
+ assertEquals("1", request.context.getConnectionId()); //$NON-NLS-1$
}
private Request helpProcessMessage(RequestMessage message,
SessionAwareCache<PreparedPlan> cache, DQPWorkContext workContext) throws
TeiidComponentException,
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2011-12-08
17:13:56 UTC (rev 3726)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2011-12-08
18:54:42 UTC (rev 3727)
@@ -237,7 +237,7 @@
}
context.getNextRand(0);
if (context.getTempTableStore() == null) {
- context.setTempTableStore(new TempTableStore(context.getConnectionID(),
TransactionMode.ISOLATE_WRITES));
+ context.setTempTableStore(new TempTableStore(context.getConnectionId(),
TransactionMode.ISOLATE_WRITES));
}
if (context.getGlobalTableStore() == null) {
GlobalTableStoreImpl gts = new GlobalTableStoreImpl(bufferMgr,
context.getMetadata());