@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)
/** * 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); } } } /**
/** * 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)); } } } } /**
@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)
@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)
/** * 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; } } /**