/** * Perform necessary validation on the given URL. * * @param inURL a <code>String</code> value * @throws FeedException if the URL is not valid for the Market Data Feed */ protected void validateURL(String inURL) throws FeedException { if(inURL == null || inURL.trim().isEmpty()) { NULL_URL.error(AbstractMarketDataFeed.DATAFEED_STATUS_MESSAGES); throw new FeedException(NULL_URL); } } /* (non-Javadoc)
/** * Receives sink data from the Data Sink Module * * @param inFlowID the data flow ID of the data flow that * delivered the data. * @param inData the data */ void receiveSinkData(DataFlowID inFlowID, Object inData) { for(SinkDataListener listener: mSinkListeners) { try { listener.receivedData(inFlowID, inData); } catch (Throwable e) { Messages.LOG_SINK_LISTENER_RECEIVE_ERROR.error(this, e); } } }
@Override public int getActiveRequests() { Lock marketdataQueryLock = marketdataLock.readLock(); try { marketdataQueryLock.lockInterruptibly(); } catch (InterruptedException e) { org.marketcetera.marketdata.core.Messages.UNABLE_TO_ACQUIRE_LOCK.error(this); throw new MarketDataRequestFailed(e); } try { return requestsByAtom.size(); } finally { marketdataQueryLock.unlock(); } } /* (non-Javadoc)
/** * Indicates that an error occurred during a heartbeat request or response. * * <p>Attempts to make an orderly shutdown of the connection. * * @param inE an <code>Exception</code> value */ private void heartbeatError(Exception inE) { Messages.MARKETDATA_NEXUS_CONNECTION_LOST.error(this, inE); Messages.MARKETDATA_NEXUS_CONNECTION_LOST.error(org.marketcetera.core.Messages.USER_MSG_CATEGORY); reportServerStatus(false); try { stop(); } catch (Exception ignored) {} } /**
@Override public Event getSnapshot(Instrument inInstrument, Content inContent) { Lock snapshotLock = marketdataLock.readLock(); try { snapshotLock.lockInterruptibly(); MarketdataCacheElement cachedData = cachedMarketdata.get(inInstrument); if(cachedData != null) { return cachedData.getSnapshot(inContent); } return null; } catch (InterruptedException e) { org.marketcetera.marketdata.core.Messages.UNABLE_TO_ACQUIRE_LOCK.error(this); stop(); throw new MarketDataRequestFailed(e); } finally { snapshotLock.unlock(); } } /* (non-Javadoc)
org.marketcetera.marketdata.core.Messages.UNABLE_TO_ACQUIRE_LOCK.error(this); stop(); } finally {
/** * Fetches the next orderID base from the server and initializes, the * client portion of the ID back to zero. * * @throws NoMoreIDsException if the ID couldn't be fetched from the server. */ private void getNextServer() throws NoMoreIDsException { try { mServerID = mClientImpl.getNextServerID(); mClientID = 0; } catch (RemoteException e) { Messages.LOG_UNABLE_FETCH_ID_SERVER.error(this,e); throw new NoMoreIDsException(e, Messages.UNABLE_FETCH_ID_SERVER); } } private String mServerID;
/** * Fetches the next orderID value from the ID factory. * * @return the next orderID value. * * @throws IllegalArgumentException if the ID factory was not * configured correctly. */ private String getNextOrderID() throws IllegalArgumentException { try { return mIDFactory.getNext(); } catch (NoMoreIDsException e) { //Indicates that id factories are not correctly assembled //to prevent failure. The factory should not throw exceptions. //In case it's unable to generate IDs, it should rely on a //local, in-memory ID generator that cannot fail Messages.UNABLE_TO_GENERATE_IDS.error(this, e); throw new IllegalArgumentException( Messages.UNABLE_TO_GENERATE_IDS.getText(), e); } } private volatile IDFactory mIDFactory = new InMemoryIDFactory(
@Override public void receiveData(DataFlowID inFlowID, Object inData) throws UnsupportedDataTypeException, StopDataFlowException { synchronized(this) { String type = inData == null ? String.valueOf(inData) : inData.getClass().getName(); Counter c = mTypeStats.get(type); if(c == null) { c = new Counter(); mTypeStats.put(type,c); } c.increment(); c = mDataFlowStats.get(inFlowID); if(c == null) { c = new Counter(); mDataFlowStats.put(inFlowID, c); } c.increment(); } if(mManager == null) { Messages.LOG_SINK_MODULE_MISCONFIGURED.error(this); } else { mManager.receiveSinkData(inFlowID, inData); } }
org.marketcetera.marketdata.core.Messages.UNABLE_TO_ACQUIRE_LOCK.error(this); stop(); } finally {
Messages.ERROR_MARKET_DATA_FEED_UNKNOWN_MESSAGE_TYPE.error(this); return false; } catch (Exception e) { thrownException = e; Messages.ERROR_MARKET_DATA_FEED_EXECUTION_FAILED.error(this, e); Messages.ERROR_MARKET_DATA_FEED_EXECUTION_FAILED.error(org.marketcetera.core.Messages.USER_MSG_CATEGORY, e); return false;
msgType=outgoingMessage.getHeader().getString(MsgType.FIELD); } catch (FieldNotFound ex) { Messages.FIX_OUTGOING_NO_MSGTYPE.error(LOGGER_NAME, ex); return;
marketdataRequestLock.lockInterruptibly(); } catch (InterruptedException e) { org.marketcetera.marketdata.core.Messages.UNABLE_TO_ACQUIRE_LOCK.error(this); stop(); throw new MarketDataRequestFailed(e);
stop(); } catch(Exception e) { Messages.ERROR_CLEANING_UP_INIT_FAILURE.error(this, e);
Messages.UNEXPECTED_ERROR.error(this,e);
Messages.LOG_STOP_FAILURE.error(this,e); throw e; } catch (JMException e) {