public DataTierTupleSource(AtomicRequestMessage aqr, RequestWorkItem workItem, ConnectorWork cwi, DataTierManagerImpl dtm, int limit) { this.aqr = aqr; this.workItem = workItem; this.cwi = cwi; this.dtm = dtm; this.limit = limit; Assertion.isNull(workItem.getConnectorRequest(aqr.getAtomicRequestID())); workItem.addConnectorRequest(aqr.getAtomicRequestID(), this); }
public DataTierTupleSource(AtomicRequestMessage aqr, RequestWorkItem workItem, ConnectorWork cwi, DataTierManagerImpl dtm, int limit) { this.aqr = aqr; this.workItem = workItem; this.cwi = cwi; this.dtm = dtm; this.limit = limit; Assertion.isNull(workItem.getConnectorRequest(aqr.getAtomicRequestID())); workItem.addConnectorRequest(aqr.getAtomicRequestID(), this); }
public DataTierTupleSource(AtomicRequestMessage aqr, RequestWorkItem workItem, ConnectorWork cwi, DataTierManagerImpl dtm, int limit) { this.aqr = aqr; this.workItem = workItem; this.cwi = cwi; this.dtm = dtm; this.limit = limit; Assertion.isNull(workItem.getConnectorRequest(aqr.getAtomicRequestID())); workItem.addConnectorRequest(aqr.getAtomicRequestID(), this); }
public ConnectorWork registerRequest(AtomicRequestMessage message) throws TeiidComponentException { checkStatus(); AtomicRequestID atomicRequestId = message.getAtomicRequestID(); LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {atomicRequestId, "Create State"}); //$NON-NLS-1$ final ConnectorWorkItem item = new ConnectorWorkItem(message, this); ConnectorWork proxy = (ConnectorWork) Proxy.newProxyInstance(ConnectorWork.class.getClassLoader(), new Class[] { ConnectorWork.class }, new InvocationHandler() { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { ClassLoader originalCL = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(getExecutionFactory().getClass().getClassLoader()); return method.invoke(item, args); } catch (InvocationTargetException e) { throw e.getTargetException(); } finally { Thread.currentThread().setContextClassLoader(originalCL); } } }); Assertion.isNull(requestStates.put(atomicRequestId, proxy), "State already existed"); //$NON-NLS-1$ return proxy; }
public ConnectorWork registerRequest(AtomicRequestMessage message) throws TeiidComponentException { checkStatus(); AtomicRequestID atomicRequestId = message.getAtomicRequestID(); LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {atomicRequestId, "Create State"}); //$NON-NLS-1$ final ConnectorWorkItem item = new ConnectorWorkItem(message, this); ConnectorWork proxy = (ConnectorWork) Proxy.newProxyInstance(ConnectorWork.class.getClassLoader(), new Class[] { ConnectorWork.class }, new InvocationHandler() { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { ClassLoader originalCL = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(getExecutionFactory().getClass().getClassLoader()); return method.invoke(item, args); } catch (InvocationTargetException e) { throw e.getTargetException(); } finally { Thread.currentThread().setContextClassLoader(originalCL); } } }); Assertion.isNull(requestStates.put(atomicRequestId, proxy), "State already existed"); //$NON-NLS-1$ return proxy; }
public ConnectorWork registerRequest(AtomicRequestMessage message) throws TeiidComponentException { checkStatus(); AtomicRequestID atomicRequestId = message.getAtomicRequestID(); LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {atomicRequestId, "Create State"}); //$NON-NLS-1$ final ConnectorWorkItem item = new ConnectorWorkItem(message, this); ConnectorWork proxy = (ConnectorWork) Proxy.newProxyInstance(ConnectorWork.class.getClassLoader(), new Class[] { ConnectorWork.class }, new InvocationHandler() { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { ClassLoader originalCL = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(getExecutionFactory().getClass().getClassLoader()); return method.invoke(item, args); } catch (InvocationTargetException e) { throw e.getTargetException(); } finally { Thread.currentThread().setContextClassLoader(originalCL); } } }); Assertion.isNull(requestStates.put(atomicRequestId, proxy), "State already existed"); //$NON-NLS-1$ return proxy; }
throw BlockedException.block(aqr.getAtomicRequestID(), "Blocking on source query", aqr.getAtomicRequestID()); //$NON-NLS-1$
void helpAssureOneState() throws Exception { csm.registerRequest(request); ConnectorWork state = csm.getState(request.getAtomicRequestID()); assertEquals(state, csm.getState(request.getAtomicRequestID())); }
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$ }
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$ }
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$ }
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(); } } }); } } }
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(); } } }); } } }
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(); } } }); } } }
public void testRemoveConnectorInfo() { DQPCore rm = new DQPCore(); rm.setTransactionService(new FakeTransactionService()); RequestMessage r0 = new RequestMessage("foo"); //$NON-NLS-1$ RequestID requestID = new RequestID(SESSION_STRING, 1); RequestWorkItem workItem = addRequest(rm, r0, requestID, null, null); AtomicRequestMessage atomicReq = new AtomicRequestMessage(workItem.requestMsg, workItem.getDqpWorkContext(), 1); DataTierTupleSource info = Mockito.mock(DataTierTupleSource.class); workItem.addConnectorRequest(atomicReq.getAtomicRequestID(), info); workItem.closeAtomicRequest(atomicReq.getAtomicRequestID()); DataTierTupleSource arInfo = workItem.getConnectorRequest(atomicReq.getAtomicRequestID()); assertNull(arInfo); } }
public void testGetConnectorInfo() { DQPCore rm = new DQPCore(); rm.setTransactionService(new FakeTransactionService()); RequestMessage r0 = new RequestMessage("foo"); //$NON-NLS-1$ RequestID requestID = new RequestID(SESSION_STRING, 1); RequestWorkItem workItem = addRequest(rm, r0, requestID, null, null); AtomicRequestMessage atomicReq = new AtomicRequestMessage(workItem.requestMsg, workItem.getDqpWorkContext(), 1); DataTierTupleSource info = Mockito.mock(DataTierTupleSource.class); workItem.addConnectorRequest(atomicReq.getAtomicRequestID(), info); DataTierTupleSource arInfo = workItem.getConnectorRequest(atomicReq.getAtomicRequestID()); assertTrue(arInfo == info); }
@Test public void testRemoveRequestState() throws Exception { helpAssureOneState(); csm.removeState(request.getAtomicRequestID()); assertEquals("Expected size of 0", 0, csm.size()); //$NON-NLS-1$ }
@Test public void testDataTierTupleSource() throws Exception { DataTierTupleSource info = helpSetup(1); assertEquals(10, pullTuples(info, 10)); assertNotNull(workItem.getConnectorRequest(info.getAtomicRequestMessage().getAtomicRequestID())); assertNull(info.nextTuple()); info.closeSource(); assertNull(workItem.getConnectorRequest(info.getAtomicRequestMessage().getAtomicRequestID())); }
@Test public void testDataTierTupleSourceWarnings() throws Exception { DataTierTupleSource info = helpSetup(1); connectorManager.addWarning = true; assertEquals(10, pullTuples(info, 10)); assertNotNull(workItem.getConnectorRequest(info.getAtomicRequestMessage().getAtomicRequestID())); assertNull(info.nextTuple()); List<Exception> warnings = context.getAndClearWarnings(); assertEquals(1, warnings.size()); SourceWarning warning = (SourceWarning) warnings.get(0); assertFalse(warning.isPartialResultsError()); info.closeSource(); assertNull(workItem.getConnectorRequest(info.getAtomicRequestMessage().getAtomicRequestID())); }
@Test public void testDataTierTupleSourceLimit() throws Exception { limit = 1; DataTierTupleSource info = helpSetup(1); assertEquals(1, pullTuples(info, 1)); assertNotNull(workItem.getConnectorRequest(info.getAtomicRequestMessage().getAtomicRequestID())); assertNull(info.nextTuple()); info.closeSource(); assertNull(workItem.getConnectorRequest(info.getAtomicRequestMessage().getAtomicRequestID())); }