@Override public void cancelDataFlow(DataFlowID inDataFlowID) throws ModuleException { try(CloseableLock closeableLock = CloseableLock.create(dataFlowLock.writeLock())) { closeableLock.lock(); RequestContainer container = getDataRequestBy(inDataFlowID); if(container != null) { container.cancel(); } else { dataFlowSupport.cancel(inDataFlowID); } } } /* (non-Javadoc)
@Override public DataFlowID createDataFlow(DataRequest[] inRequests, boolean inAppendDataSink) throws ModuleException { try(CloseableLock closeableLock = CloseableLock.create(dataFlowLock.writeLock())) { closeableLock.lock(); DataFlowID dataFlowId = dataFlowSupport.createDataFlow(inRequests, inAppendDataSink); new RequestContainer(dataFlowId, counter.incrementAndGet()); return dataFlowId; } } /* (non-Javadoc)
inMarketDataRequest); DataRequest targetRequest = new DataRequest(getURN()); DataFlowID dataFlowId = dataFlowSupport.createDataFlow(new DataRequest[] { sourceRequest, targetRequest }, false); SLF4JLoggerProxy.debug(this,
/** * Cancels the market data request and removes it from the request collections. * * <p>This method requires an external lock. */ private void cancel() { if(dataFlowId != null) { try { dataFlowSupport.cancel(dataFlowId); } finally { requestsByDataFlowId.remove(dataFlowId); } } else { try { if(marketDataManager != null) { marketDataManager.cancelMarketDataRequest(marketDataRequestId); } } finally { requestsByInternalId.remove(internalRequestId); } } } /**
/** * Connects the strategy to the ORS, if necessary. * * If the strategy is already connected to the ORS, this method does nothing * * @throws ModuleException if the data flow cannot be established */ private void establishORSRouting() throws ModuleException { SLF4JLoggerProxy.debug(this, "Establishing connection to ORS"); //$NON-NLS-1$ try(CloseableLock closeableLock = CloseableLock.create(dataFlowLock.writeLock())) { closeableLock.lock(); if(orsFlow == null) { // no current routing, establish one orsFlow = dataFlowSupport.createDataFlow(new DataRequest[] { new DataRequest(getURN(), OutputType.ORDERS), new DataRequest(ClientModuleFactory.INSTANCE_URN) }, false); new RequestContainer(orsFlow, counter.incrementAndGet()); } } } /**
/** * Cancel the market data request with the given request id. * * @param inRequestId a <code>long</code> value */ public void cancelMarketDataRequest(long inRequestId) { Collection<DataFlowID> dataFlows = dataFlowsByRequestId.removeAll(inRequestId); if(dataFlows != null) { for(DataFlowID dataFlowId : dataFlows) { try { contentByDataFlowId.removeAll(dataFlowId); subscribersByDataFlowId.remove(dataFlowId); SLF4JLoggerProxy.debug(this, "Canceling data flow {} owned by {}", dataFlowId, inRequestId); dataFlowSupport.cancel(dataFlowId); } catch (Exception e) { SLF4JLoggerProxy.warn(this, "Unable to cancel data flow {}: {}", inRequestId, ExceptionUtils.getRootCauseMessage(e)); } } } } /**
closeableLock.lock(); DataFlowID cepFlow = dataFlowSupport.createDataFlow(new DataRequest[] { new DataRequest(getURN(),new InternalRequest(inCEPModule)),new DataRequest(inCEPModule) }, false); new RequestContainer(cepFlow,
@Override public void cancelAllDataRequests() { try(CloseableLock closeableLock = CloseableLock.create(dataFlowLock.writeLock())) { closeableLock.lock(); Set<RequestContainer> requests = Sets.newHashSet(); requests.addAll(requestsByDataFlowId.values()); requests.addAll(requestsByInternalId.values()); for(RequestContainer container : requests) { try { container.cancel(); } catch (Exception e) { SLF4JLoggerProxy.warn(this, e, Messages.UNABLE_TO_CANCEL_DATA_REQUEST.getText(strategy, container)); StrategyModule.log(LogEventBuilder.warn().withMessage(UNABLE_TO_CANCEL_DATA_REQUEST, String.valueOf(strategy), String.valueOf(container)) .withException(e).create(), strategy); } } } } /* (non-Javadoc)
closeableLock.lock(); try { DataFlowID flowID = dataFlowSupport.createDataFlow(new DataRequest[] { new DataRequest(providerURN, determineCepStatements(inSource, inStatements)),
@Override public void cancelDataRequest(int inDataRequestID) { try(CloseableLock closeableLock = CloseableLock.create(dataFlowLock.writeLock())) { closeableLock.lock(); RequestContainer container = getDataRequestBy(inDataRequestID); if(container == null) { StrategyModule.log(LogEventBuilder.warn().withMessage(NO_DATA_HANDLE, String.valueOf(strategy), inDataRequestID).create(), strategy); return; } container.cancel(); } } /* (non-Javadoc)
try(CloseableLock closeableLock = CloseableLock.create(dataFlowLock.writeLock())) { closeableLock.lock(); DataFlowID dataFlowID = dataFlowSupport.createDataFlow(new DataRequest[] { new DataRequest(marketDataURN, inRequest), new DataRequest(cepDataURN,
/** * Disconnects the strategy from the ORS, if necessary. * * If the strategy is not currently connected to the ORS, this method does nothing * * @throws ModuleException if the data flow cannot be disconnected */ private void disconnectORSRouting() throws ModuleException { SLF4JLoggerProxy.debug(this, "Breaking connection to ORS"); //$NON-NLS-1$ try(CloseableLock closeableLock = CloseableLock.create(dataFlowLock.writeLock())) { closeableLock.lock(); if(orsFlow != null) { RequestContainer container = getDataRequestBy(orsFlow); if(container != null) { container.cancel(); } } } catch (Exception e) { SLF4JLoggerProxy.debug(StrategyModule.class, e, "Unable to cancel dataflow {} - continuing", //$NON-NLS-1$ orsFlow); } finally { orsFlow = null; } } /**
inRequest, marketDataURN); DataFlowID dataFlowID = dataFlowSupport.createDataFlow(new DataRequest[] { new DataRequest(marketDataURN, inRequest), new DataRequest(getURN()) },
closeableLock.lock(); try { DataFlowID reportsDataFlow = dataFlowSupport.createDataFlow(new DataRequest[] { new DataRequest(ClientModuleFactory.INSTANCE_URN), new DataRequest(getURN()) }, false);