Author: shawkins
Date: 2010-04-05 11:26:20 -0400 (Mon, 05 Apr 2010)
New Revision: 2022
Modified:
trunk/client/src/main/java/org/teiid/adminapi/Request.java
trunk/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java
trunk/client/src/main/java/org/teiid/adminapi/impl/RequestMetadataMapper.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
Log:
TEIID-1033 adding state to the request metadata
Modified: trunk/client/src/main/java/org/teiid/adminapi/Request.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/Request.java 2010-04-04 21:59:34 UTC
(rev 2021)
+++ trunk/client/src/main/java/org/teiid/adminapi/Request.java 2010-04-05 15:26:20 UTC
(rev 2022)
@@ -24,6 +24,7 @@
+
/**
* When a user submits a SQL command to the system for processing, usually that
represents
* a single request. A single request might have one or more source
@@ -34,6 +35,12 @@
* in the pattern [session]|[request] or [session]|[request]|[source request]
</p>
*/
public interface Request extends AdminObject {
+
+ public enum State {
+ PROCESSING,
+ DONE,
+ CANCELED
+ }
/**
* Get the ExecutionId for a Request
@@ -74,8 +81,13 @@
public boolean sourceRequest();
/**
+ * @return In the case that this is a source request this represents the node id.
Otherwise null
+ */
+ public Integer getNodeId();
+
+ /**
* @return In the case that this is a source request this represents the node id.
Otherwise blank
*/
- public int getNodeId();
+ State getState();
}
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java 2010-04-04
21:59:34 UTC (rev 2021)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java 2010-04-05
15:26:20 UTC (rev 2022)
@@ -41,8 +41,9 @@
private String command;
private long startTime;
private boolean sourceRequest;
- private int nodeID = Integer.MIN_VALUE;
+ private Integer nodeID;
private String transactionId;
+ private State state;
@Override
@ManagementProperty(description="Unique Identifier for Request",
readOnly=true)
@@ -52,9 +53,19 @@
public void setExecutionId(long id) {
this.executionId = id;
- }
+ }
@Override
+ @ManagementProperty(description="State of the Request", readOnly=true)
+ public State getState() {
+ return state;
+ }
+
+ public void setState(State state) {
+ this.state = state;
+ }
+
+ @Override
@ManagementProperty(description="Session ID", readOnly=true)
public long getSessionId() {
return this.sessionId;
@@ -96,7 +107,7 @@
@Override
@ManagementProperty(description="Node Id", readOnly=true)
- public int getNodeId() {
+ public Integer getNodeId() {
return this.nodeID;
}
@@ -130,7 +141,8 @@
return HashCodeUtil.hashCode((int)executionId, (int)sessionId);
}
- public String toString() {
+ @SuppressWarnings("nls")
+ public String toString() {
StringBuilder str = new StringBuilder();
str.append("Request: sessionid=").append(sessionId);
str.append("; executionId=").append(executionId);
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/RequestMetadataMapper.java
===================================================================
---
trunk/client/src/main/java/org/teiid/adminapi/impl/RequestMetadataMapper.java 2010-04-04
21:59:34 UTC (rev 2021)
+++
trunk/client/src/main/java/org/teiid/adminapi/impl/RequestMetadataMapper.java 2010-04-05
15:26:20 UTC (rev 2022)
@@ -33,6 +33,7 @@
import org.jboss.metatype.api.values.SimpleValueSupport;
import org.jboss.metatype.plugins.types.MutableCompositeMetaType;
import org.jboss.metatype.spi.values.MetaMapper;
+import org.teiid.adminapi.Request.State;
public class RequestMetadataMapper extends MetaMapper<RequestMetadata> {
private static final String TRANSACTION_ID = "transactionId"; //$NON-NLS-1$
@@ -43,6 +44,7 @@
private static final String CREATED_TIME = "createdTime"; //$NON-NLS-1$
private static final String SESSION_ID = "sessionId"; //$NON-NLS-1$
private static final String EXECUTION_ID = "executionId"; //$NON-NLS-1$
+ private static final String STATE = "state"; //$NON-NLS-1$
private static final MutableCompositeMetaType metaType;
private static final MetaValueFactory metaValueFactory =
MetaValueFactory.getInstance();
@@ -56,6 +58,7 @@
metaType.addItem(SOURCE_REQUEST, SOURCE_REQUEST, SimpleMetaType.BOOLEAN_PRIMITIVE);
metaType.addItem(NODE_ID, NODE_ID, SimpleMetaType.INTEGER_PRIMITIVE);
metaType.addItem(TRANSACTION_ID, TRANSACTION_ID, SimpleMetaType.STRING);
+ metaType.addItem(STATE, STATE, SimpleMetaType.STRING);
metaType.freeze();
}
@@ -84,7 +87,7 @@
request.set(SOURCE_REQUEST, SimpleValueSupport.wrap(object.sourceRequest()));
request.set(NODE_ID, SimpleValueSupport.wrap(object.getNodeId()));
request.set(TRANSACTION_ID,SimpleValueSupport.wrap(object.getTransactionId()));
-
+ request.set(STATE,SimpleValueSupport.wrap(object.getState()));
return request;
}
throw new IllegalArgumentException("Cannot convert RequestMetadata " +
object); //$NON-NLS-1$
@@ -106,6 +109,7 @@
request.setSourceRequest((Boolean)
metaValueFactory.unwrap(compositeValue.get(SOURCE_REQUEST)));
request.setNodeId((Integer) metaValueFactory.unwrap(compositeValue.get(NODE_ID)));
request.setTransactionId((String)
metaValueFactory.unwrap(compositeValue.get(TRANSACTION_ID)));
+ request.setState((State) metaValueFactory.unwrap(compositeValue.get(STATE)));
return request;
}
throw new IllegalStateException("Unable to unwrap RequestMetadata " +
metaValue); //$NON-NLS-1$
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 2010-04-04
21:59:34 UTC (rev 2021)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-04-05
15:26:20 UTC (rev 2022)
@@ -42,6 +42,7 @@
import org.teiid.adminapi.Admin;
import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.Request.State;
import org.teiid.adminapi.impl.RequestMetadata;
import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
import org.teiid.client.DQP;
@@ -246,7 +247,7 @@
req.setSessionId(Long.parseLong(holder.requestID.getConnectionID()));
req.setCommand(holder.requestMsg.getCommandString());
req.setStartTime(holder.getProcessingTimestamp());
-
+
req.setState(holder.isCanceled()?State.CANCELED:holder.isDoneProcessing()?State.DONE:State.PROCESSING);
if (holder.getTransactionContext() != null &&
holder.getTransactionContext().getTransactionType() != Scope.NONE) {
req.setTransactionId(holder.getTransactionContext().getTransactionId());
}
@@ -268,7 +269,7 @@
info.setStartTime(arm.getProcessingTimestamp());
info.setSourceRequest(true);
info.setNodeId(arm.getAtomicRequestID().getNodeID());
-
+
info.setState(conInfo.isCanceled()?State.CANCELED:conInfo.isDone()?State.DONE:State.PROCESSING);
results.add(info);
}
results.add(req);
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2010-04-04
21:59:34 UTC (rev 2021)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2010-04-05
15:26:20 UTC (rev 2022)
@@ -53,8 +53,9 @@
private ConnectorWork cwi;
private int index;
private int rowsProcessed;
- private AtomicResultsMessage arm;
+ private volatile AtomicResultsMessage arm;
private boolean closed;
+ private volatile boolean canceled;
/**
* Constructor for DataTierTupleSource.
@@ -82,7 +83,7 @@
if (index < arm.getResults().length) {
return this.arm.getResults()[index++];
}
- if (this.arm.getFinalRow() > 0) {
+ if (isDone()) {
return null;
}
try {
@@ -92,6 +93,10 @@
}
}
}
+
+ public boolean isDone() {
+ return this.arm != null && this.arm.getFinalRow() > 0;
+ }
void open() throws MetaMatrixComponentException, MetaMatrixProcessingException {
try {
@@ -116,7 +121,12 @@
}
}
+ public boolean isCanceled() {
+ return canceled;
+ }
+
public void cancelRequest() {
+ this.canceled = true;
if (this.cwi != null) {
this.cwi.cancel();
}
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 2010-04-04
21:59:34 UTC (rev 2021)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-04-05
15:26:20 UTC (rev 2022)
@@ -110,7 +110,7 @@
// This exception contains details of all the atomic requests that failed when query
is run in partial results mode.
private List<MetaMatrixException> warnings = new
LinkedList<MetaMatrixException>();
private boolean doneProducingBatches;
- private boolean isClosed;
+ private volatile boolean isClosed;
private volatile boolean isCanceled;
private volatile boolean closeRequested;
//results request