Author: shawkins
Date: 2011-10-25 12:43:31 -0400 (Tue, 25 Oct 2011)
New Revision: 3581
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
Log:
TEIID-1795 fix for long running query calculation
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java 2011-10-25
14:03:30 UTC (rev 3580)
+++
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java 2011-10-25
16:43:31 UTC (rev 3581)
@@ -33,7 +33,7 @@
static final int DEFAULT_FETCH_SIZE = RequestMessage.DEFAULT_FETCH_SIZE * 10;
static final int DEFAULT_PROCESSOR_TIMESLICE = 2000;
static final int DEFAULT_MAX_RESULTSET_CACHE_ENTRIES = 1024;
- static final int DEFAULT_QUERY_THRESHOLD = 600;
+ static final int DEFAULT_QUERY_THRESHOLD = 600000;
static final String PROCESS_PLAN_QUEUE_NAME = "QueryProcessorQueue";
//$NON-NLS-1$
public static final int DEFAULT_MAX_PROCESS_WORKERS = 64;
public static final int DEFAULT_MAX_SOURCE_ROWS = -1;
@@ -44,9 +44,7 @@
private int timeSliceInMilli = DEFAULT_PROCESSOR_TIMESLICE;
private int maxRowsFetchSize = DEFAULT_FETCH_SIZE;
private int lobChunkSizeInKB = 100;
- private boolean useDataRoles = true;
- private boolean allowCreateTemporaryTablesByDefault = true;
- private int queryThresholdInSecs = DEFAULT_QUERY_THRESHOLD;
+ private long queryThresholdInMilli = DEFAULT_QUERY_THRESHOLD;
private boolean exceptionOnMaxSourceRows = true;
private int maxSourceRows = -1;
private int maxActivePlans = DEFAULT_MAX_ACTIVE_PLANS;
@@ -57,7 +55,6 @@
private boolean detectingChangeEvents = true;
private transient AuthorizationValidator authorizationValidator;
- private boolean allowFunctionCallsByDefault;
@ManagementProperty(description="Max active plans (default 20). Increase this
value, and max threads, on highly concurrent systems - but ensure that the underlying
pools can handle the increased load without timeouts.")
public int getMaxActivePlans() {
@@ -146,11 +143,19 @@
@ManagementProperty(description="Long running query threshold, after which a alert
can be generated by tooling if configured")
public int getQueryThresholdInSecs() {
- return queryThresholdInSecs;
+ return (int)queryThresholdInMilli/1000;
}
+
+ public long getQueryThresholdInMilli() {
+ return queryThresholdInMilli;
+ }
+
+ public void setQueryThresholdInMilli(long queryThreshold) {
+ this.queryThresholdInMilli = queryThreshold;
+ }
public void setQueryThresholdInSecs(int queryThresholdInSecs) {
- this.queryThresholdInSecs = queryThresholdInSecs;
+ this.queryThresholdInMilli = queryThresholdInSecs * 1000;
}
@ManagementProperty(description="Teiid runtime version", readOnly=true)
Modified: branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2011-10-25
14:03:30 UTC (rev 3580)
+++
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2011-10-25
16:43:31 UTC (rev 3581)
@@ -262,16 +262,16 @@
}
public List<RequestMetadata> getLongRunningRequests(){
- return buildRequestInfos(requests.keySet(), this.config.getQueryThresholdInSecs());
+ return buildRequestInfos(requests.keySet(), System.currentTimeMillis() -
this.config.getQueryThresholdInMilli() );
}
- private List<RequestMetadata> buildRequestInfos(Collection<RequestID>
ids, int longRunningQueryThreshold) {
+ private List<RequestMetadata> buildRequestInfos(Collection<RequestID>
ids, long longRunningQueryThreshold) {
List<RequestMetadata> results = new ArrayList<RequestMetadata>();
for (RequestID requestID : ids) {
RequestWorkItem holder = requests.get(requestID);
- if(holder != null && !holder.isCanceled()) {
+ if(holder != null && !holder.isCanceled() &&
(longRunningQueryThreshold == -1 || holder.getProcessingTimestamp() <
longRunningQueryThreshold)) {
RequestMetadata req = new RequestMetadata();
req.setExecutionId(holder.requestID.getExecutionID());
@@ -322,11 +322,7 @@
results.add(info);
}
- // check if only need long running queries.
- long elapsedTime = System.currentTimeMillis() - req.getStartTime();
- if (longRunningQueryThreshold == -1 || elapsedTime >
longRunningQueryThreshold) {
- results.add(req);
- }
+ results.add(req);
}
}
return results;
Modified:
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
===================================================================
---
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2011-10-25
14:03:30 UTC (rev 3580)
+++
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2011-10-25
16:43:31 UTC (rev 3581)
@@ -543,6 +543,17 @@
assertNotNull(message.get().getException());
}
+ @Test public void testLongRunningQuery() throws Exception {
+ RequestMessage reqMsg = exampleRequestMessage("select * FROM
BQT1.SmallA");
+ execute("A", 1, reqMsg);
+ this.config.setQueryThresholdInMilli(5000);
+ assertEquals(1, this.core.getRequests().size());
+ assertEquals(0, this.core.getLongRunningRequests().size());
+ this.config.setQueryThresholdInMilli(10);
+ Thread.sleep(20);
+ assertEquals(1, this.core.getLongRunningRequests().size());
+ }
+
public void helpTestVisibilityFails(String sql) throws Exception {
RequestMessage reqMsg = exampleRequestMessage(sql);
reqMsg.setTxnAutoWrapMode(RequestMessage.TXN_WRAP_OFF);
Show replies by date