Author: shawkins
Date: 2010-02-10 11:11:01 -0500 (Wed, 10 Feb 2010)
New Revision: 1812
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java
Log:
TEIID-948 changed pause to use a loop to check the state
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java 2010-02-10
15:17:58 UTC (rev 1811)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java 2010-02-10
16:11:01 UTC (rev 1812)
@@ -25,6 +25,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
import javax.transaction.InvalidTransactionException;
import javax.transaction.SystemException;
@@ -96,7 +97,7 @@
protected RequestState requestState = RequestState.NEW;
- private volatile boolean isCancelled;
+ private AtomicBoolean isCancelled = new AtomicBoolean();
private volatile boolean moreRequested;
private volatile boolean closeRequested;
private boolean isClosed;
@@ -190,7 +191,7 @@
}
private void checkForCloseEvent() throws NeedsClosedException {
- if (this.isCancelled || this.closeRequested) {
+ if (this.isCancelled.get() || this.closeRequested) {
throw new NeedsClosedException();
}
}
@@ -231,7 +232,7 @@
manager.logSRCCommand(this.requestMsg, this.securityContext,
CommandLogMessage.CMD_STATUS_ERROR, -1);
String msg = DQPPlugin.Util.getString("ConnectorWorker.process_failed",
this.id); //$NON-NLS-1$
- if (isCancelled) {
+ if (isCancelled.get()) {
LogManager.logDetail(LogConstants.CTX_CONNECTOR, msg);
} else if (t instanceof ConnectorException || t instanceof
MetaMatrixProcessingException) {
LogManager.logWarning(LogConstants.CTX_CONNECTOR, t, msg);
@@ -512,8 +513,7 @@
}
void asynchCancel() throws ConnectorException {
- if (!this.isCancelled) {
- this.isCancelled = true;
+ if (this.isCancelled.compareAndSet(false, true)) {
if(execution != null) {
execution.cancel();
}
@@ -522,7 +522,7 @@
}
boolean isCancelled() {
- return this.isCancelled;
+ return this.isCancelled.get();
}
@Override
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java 2010-02-10
15:17:58 UTC (rev 1811)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java 2010-02-10
16:11:01 UTC (rev 1812)
@@ -68,7 +68,9 @@
protected void pauseProcessing() {
releaseTxnLock();
try {
- this.wait();
+ while (isIdle()) {
+ this.wait();
+ }
acquireTransactionLock();
} catch (InterruptedException e) {
interrupted(e);
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java 2010-02-10
15:17:58 UTC (rev 1811)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java 2010-02-10
16:11:01 UTC (rev 1812)
@@ -47,7 +47,7 @@
}
}
- ThreadState getThreadState() {
+ synchronized ThreadState getThreadState() {
return this.threadState;
}
@@ -80,10 +80,14 @@
}
break;
default:
- throw new IllegalStateException("Should not END on IDLE or DONE");
//$NON-NLS-1$
+ throw new IllegalStateException("Should not END on " +
this.threadState); //$NON-NLS-1$
}
}
+ protected boolean isIdle() {
+ return this.threadState == ThreadState.IDLE;
+ }
+
protected void moreWork() {
moreWork(true);
}
Show replies by date