@Override public void onCompletion(FutureWork<AtomicResultsMessage> future) { if (running) { return; //-- let the other thread close } if (closed.compareAndSet(false, true)) { cwi.close(); } } });
AtomicResultsMessage getResults() throws BlockedException, TeiidComponentException, TranslatorException { AtomicResultsMessage results = null; if (cancelAsynch) { return null; } running = true; try { if (!executed) { cwi.execute(); executed = true; } results = cwi.more(); } finally { running = false; } return results; }
/** * Stop this connector. */ public void stop() { stopped = true; //ensure that all requests receive a response for (ConnectorWork workItem : this.requestStates.values()) { workItem.cancel(true); } }
if (!work.isForkable()) { aqr.setSerial(true); if (cv.cacheable) { try { cd = work.getCacheDirective(); } catch (TranslatorException e) { throw new TeiidProcessingException(QueryPlugin.Event.TEIID30504, e, aqr.getConnectorName() + ": " + e.getMessage()); //$NON-NLS-1$ parameterObject.doNotCache = true; LogManager.logDetail(LogConstants.CTX_DQP, "Using cache entry for", cid); //$NON-NLS-1$ work.close(); return cr.getResults().createIndexedTupleSource(); result = new CachingTupleSource(this, tb, (DataTierTupleSource)result, cid, parameterObject, cd, accessedGroups, workItem); if (work.isThreadBound()) { result = handleThreadBound(workItem, aqr, work, cid, result, dtts, tb); } else if (!aqr.isSerial()) {
public void fullyCloseSource() { cancelFutures(); cancelAsynch = true; if (closing.compareAndSet(false, true)) { if (!done && !errored) { this.cwi.cancel(false); } workItem.closeAtomicRequest(this.aqr.getAtomicRequestID()); if (aqr.isSerial() || futureResult == null) { this.cwi.close(); } else { futureResult.addCompletionListener(new CompletionListener<AtomicResultsMessage>() { @Override public void onCompletion(FutureWork<AtomicResultsMessage> future) { if (running) { return; //-- let the other thread close } if (closed.compareAndSet(false, true)) { cwi.close(); } } }); } } }
@Test public void testConvertIn() throws Exception { Command command = helpGetCommand("select intkey from bqt1.smalla where stringkey in ('1', '2')", EXAMPLE_BQT); //$NON-NLS-1$ AtomicRequestMessage arm = createNewAtomicRequestMessage(1, 1); arm.setCommand(command); ConnectorManager cm = TestConnectorManager.getConnectorManager(); cm.getExecutionFactory().setSourceRequired(false); ConnectorWork synchConnectorWorkItem = cm.registerRequest(arm); synchConnectorWorkItem.execute(); synchConnectorWorkItem.close(); FakeConnector fc = (FakeConnector)cm.getExecutionFactory(); assertEquals("SELECT SmallA.IntKey FROM SmallA WHERE SmallA.StringKey = '2' OR SmallA.StringKey = '1'", fc.getCommands().get(0).toString()); assertEquals(1, fc.getConnectionCount()); assertEquals(1, fc.getCloseCount()); }
private void handleDataNotAvailable(DataNotAvailableException e) throws BlockedException { if (e.getWaitUntil() != null) { long timeDiff = e.getWaitUntil().getTime() - System.currentTimeMillis(); if (timeDiff <= 0) { //already met the time return; } if (e.isStrict()) { this.waitUntil = e.getWaitUntil().getTime(); } scheduleMoreWork(timeDiff); } else if (e.getRetryDelay() >= 0) { if (e.isStrict()) { this.waitUntil = System.currentTimeMillis() + e.getRetryDelay(); } scheduleMoreWork(e.getRetryDelay()); } else if (this.cwi.isDataAvailable()) { return; //no polling, but data is already available } else if (e.isStrict()) { //no polling, wait indefinitely this.waitUntil = Long.MAX_VALUE; } throw BlockedException.block(aqr.getAtomicRequestID(), "Blocking on DataNotAvailableException", aqr.getAtomicRequestID()); //$NON-NLS-1$ }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof ConnectorWork)) return false; ConnectorWork other = (ConnectorWork) obj; if (id == null) { if (other.getId() != null) return false; } else if (!id.equals(other.getId())) return false; return true; }
if (!work.isForkable()) { aqr.setSerial(true); if (cv.cacheable) { try { cd = work.getCacheDirective(); } catch (TranslatorException e) { throw new TeiidProcessingException(QueryPlugin.Event.TEIID30504, e, aqr.getConnectorName() + ": " + e.getMessage()); //$NON-NLS-1$ parameterObject.doNotCache = true; LogManager.logDetail(LogConstants.CTX_DQP, "Using cache entry for", cid); //$NON-NLS-1$ work.close(); return cr.getResults().createIndexedTupleSource(); result = new CachingTupleSource(this, tb, (DataTierTupleSource)result, cid, parameterObject, cd, accessedGroups, workItem); if (work.isThreadBound()) { result = handleThreadBound(workItem, aqr, work, cid, result, dtts, tb); } else if (!aqr.isSerial()) {
public void fullyCloseSource() { cancelFutures(); cancelAsynch = true; if (closing.compareAndSet(false, true)) { if (!done && !errored) { this.cwi.cancel(false); } workItem.closeAtomicRequest(this.aqr.getAtomicRequestID()); if (aqr.isSerial() || futureResult == null) { this.cwi.close(); } else { futureResult.addCompletionListener(new CompletionListener<AtomicResultsMessage>() { @Override public void onCompletion(FutureWork<AtomicResultsMessage> future) { if (running) { return; //-- let the other thread close } if (closed.compareAndSet(false, true)) { cwi.close(); } } }); } } }
@Test public void testSourceNotRequired() throws Exception { Command command = helpGetCommand("update bqt1.smalla set stringkey = 1 where stringkey = 2", EXAMPLE_BQT); //$NON-NLS-1$ AtomicRequestMessage arm = createNewAtomicRequestMessage(1, 1); arm.setCommand(command); ConnectorManager cm = TestConnectorManager.getConnectorManager(); cm.getExecutionFactory().setSourceRequired(false); ConnectorWork synchConnectorWorkItem = cm.registerRequest(arm); synchConnectorWorkItem.execute(); synchConnectorWorkItem.close(); FakeConnector fc = (FakeConnector)cm.getExecutionFactory(); assertEquals(1, fc.getConnectionCount()); assertEquals(1, fc.getCloseCount()); }
private void handleDataNotAvailable(DataNotAvailableException e) throws BlockedException { if (e.getWaitUntil() != null) { long timeDiff = e.getWaitUntil().getTime() - System.currentTimeMillis(); if (timeDiff <= 0) { //already met the time return; } if (e.isStrict()) { this.waitUntil = e.getWaitUntil().getTime(); } scheduleMoreWork(timeDiff); } else if (e.getRetryDelay() >= 0) { if (e.isStrict()) { this.waitUntil = System.currentTimeMillis() + e.getRetryDelay(); } scheduleMoreWork(e.getRetryDelay()); } else if (this.cwi.isDataAvailable()) { return; //no polling, but data is already available } else if (e.isStrict()) { //no polling, wait indefinitely this.waitUntil = Long.MAX_VALUE; } throw BlockedException.block(aqr.getAtomicRequestID(), "Blocking on DataNotAvailableException", aqr.getAtomicRequestID()); //$NON-NLS-1$ }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof ConnectorWork)) return false; ConnectorWork other = (ConnectorWork) obj; if (id == null) { if (other.getId() != null) return false; } else if (!id.equals(other.getId())) return false; return true; }
if (!work.isForkable()) { aqr.setSerial(true); if (cv.cacheable) { try { cd = work.getCacheDirective(); } catch (TranslatorException e) { throw new TeiidProcessingException(QueryPlugin.Event.TEIID30504, e, aqr.getConnectorName() + ": " + e.getMessage()); //$NON-NLS-1$ parameterObject.doNotCache = true; LogManager.logDetail(LogConstants.CTX_DQP, "Using cache entry for", cid); //$NON-NLS-1$ work.close(); return cr.getResults().createIndexedTupleSource(); result = new CachingTupleSource(this, tb, (DataTierTupleSource)result, cid, parameterObject, cd, accessedGroups, workItem); if (work.isThreadBound()) { result = handleThreadBound(workItem, aqr, work, cid, result, dtts, tb); } else if (!aqr.isSerial()) {
AtomicResultsMessage getResults() throws BlockedException, TeiidComponentException, TranslatorException { AtomicResultsMessage results = null; if (cancelAsynch) { return null; } running = true; try { if (!executed) { cwi.execute(); executed = true; } results = cwi.more(); } finally { running = false; } return results; }
public void fullyCloseSource() { cancelFutures(); cancelAsynch = true; if (closing.compareAndSet(false, true)) { if (!done && !errored) { this.cwi.cancel(false); } workItem.closeAtomicRequest(this.aqr.getAtomicRequestID()); if (aqr.isSerial() || futureResult == null) { this.cwi.close(); } else { futureResult.addCompletionListener(new CompletionListener<AtomicResultsMessage>() { @Override public void onCompletion(FutureWork<AtomicResultsMessage> future) { if (running) { return; //-- let the other thread close } if (closed.compareAndSet(false, true)) { cwi.close(); } } }); } } }
@Override public void onCompletion(FutureWork<AtomicResultsMessage> future) { if (running) { return; //-- let the other thread close } if (closed.compareAndSet(false, true)) { cwi.close(); } } });
/** * Stop this connector. */ public void stop() { stopped = true; //ensure that all requests receive a response for (ConnectorWork workItem : this.requestStates.values()) { workItem.cancel(true); } }
private void handleDataNotAvailable(DataNotAvailableException e) throws BlockedException { if (e.getWaitUntil() != null) { long timeDiff = e.getWaitUntil().getTime() - System.currentTimeMillis(); if (timeDiff <= 0) { //already met the time return; } if (e.isStrict()) { this.waitUntil = e.getWaitUntil().getTime(); } scheduleMoreWork(timeDiff); } else if (e.getRetryDelay() >= 0) { if (e.isStrict()) { this.waitUntil = System.currentTimeMillis() + e.getRetryDelay(); } scheduleMoreWork(e.getRetryDelay()); } else if (this.cwi.isDataAvailable()) { return; //no polling, but data is already available } else if (e.isStrict()) { //no polling, wait indefinitely this.waitUntil = Long.MAX_VALUE; } throw BlockedException.block(aqr.getAtomicRequestID(), "Blocking on DataNotAvailableException", aqr.getAtomicRequestID()); //$NON-NLS-1$ }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof ConnectorWork)) return false; ConnectorWork other = (ConnectorWork) obj; if (id == null) { if (other.getId() != null) return false; } else if (!id.equals(other.getId())) return false; return true; }