com.devexperts.qd.qtp
Class DistributorAdapter

java.lang.Object
  extended by com.devexperts.qd.qtp.MessageConsumerAdapter
      extended by com.devexperts.qd.qtp.MessageAdapter
          extended by com.devexperts.qd.qtp.DistributorAdapter
All Implemented Interfaces:
MessageAdapterMBean, MessageConstants, MessageConsumer, MessageProvider, SubscriptionListener

public class DistributorAdapter
extends MessageAdapter
implements SubscriptionListener

The DistributorAdapter adapts distributor side of QD to message API. The distributor side of an QD is an aggregation of QDDistributor for all its APIs (the DistributorAdapter creates its own distributors, one distributor per API). Thus, the DistributorAdapter can be used to represent an outside data provider in the specific QD. if you are a QD client - use this Adapter


Nested Class Summary
static class DistributorAdapter.Factory
          The factory for distributor side of an QD.
 
Nested classes/interfaces inherited from class com.devexperts.qd.qtp.MessageAdapter
MessageAdapter.AbstractFactory, MessageAdapter.CloseListener
 
Field Summary
 
Fields inherited from class com.devexperts.qd.qtp.MessageAdapter
closeListener, messageListener
 
Fields inherited from interface com.devexperts.qd.SubscriptionListener
VOID
 
Fields inherited from interface com.devexperts.qd.qtp.MessageConstants
MESSAGE_DESCRIBE_PROTOCOL, MESSAGE_DESCRIBE_RECORDS, MESSAGE_DESCRIBE_RESERVED, MESSAGE_HEARTBEAT, MESSAGE_HISTORY_ADD_SUBSCRIPTION, MESSAGE_HISTORY_DATA, MESSAGE_HISTORY_REMOVE_SUBSCRIPTION, MESSAGE_PART, MESSAGE_RAW_DATA, MESSAGE_RMI_CANCEL, MESSAGE_RMI_DESCRIBE_OPERATION, MESSAGE_RMI_DESCRIBE_SUBJECT, MESSAGE_RMI_ERROR, MESSAGE_RMI_REQUEST, MESSAGE_RMI_RESULT, MESSAGE_STREAM_ADD_SUBSCRIPTION, MESSAGE_STREAM_DATA, MESSAGE_STREAM_REMOVE_SUBSCRIPTION, MESSAGE_TEXT_FORMAT_COMMENT, MESSAGE_TEXT_FORMAT_SPECIAL, MESSAGE_TICKER_ADD_SUBSCRIPTION, MESSAGE_TICKER_DATA, MESSAGE_TICKER_REMOVE_SUBSCRIPTION
 
Constructor Summary
DistributorAdapter(QDTicker ticker, QDStream stream, QDHistory history, SubscriptionFilter filter, QDStats stats)
           
 
Method Summary
protected  void closeImpl()
           
protected  QDDistributor createDistributor(QDCollector collector, SubscriptionFilter filter, java.lang.String keyProperties)
          This method is used internally by distributor adapter to create agent for the corresponding collector, filter, and keyProperties from this adapter's constructor.
 DataScheme getScheme()
           
 java.lang.String getSymbol(char[] chars, int offset, int length)
          Returns symbol used for specified characters or null if not found.
 boolean isProtocolDescriptorCompatible(ProtocolDescriptor desc)
           
 long nextRetrieveTime(long currentTime)
           
 void prepareProtocolDescriptor(ProtocolDescriptor desc)
          Prepares outgoing protocol descriptor.
protected  void processData(DataIterator iterator, MessageType message)
           
 void processDescribeProtocol(ProtocolDescriptor desc)
          Process incoming protocol descriptor.
 boolean retrieveMessages(MessageVisitor visitor)
          Retrieves accumulated message into specified message visitor.
protected  void startImpl()
           
 void subscriptionAvailable(SubscriptionProvider provider)
          Notifies this listener that subscription is available in the specified subscription provider.
protected  void subscriptionChanged(SubscriptionProvider provider, MessageType message)
           
 java.lang.String toString()
          Returns description of this MessageAdapter for management and logging purposes.
 void useDescribeProtocol()
          Invocation of this method causes this MessageAdapter to send DESCRIBE_PROTOCOL message if it is capable of doing so.
protected  boolean visitSubscription(MessageVisitor visitor, SubscriptionProvider provider, MessageType message)
           
 
Methods inherited from class com.devexperts.qd.qtp.MessageAdapter
addMask, clearMessageMask, close, getCommonScheme, getConnectionVariables, getMessageMask, getRemoteHostAddress, getStats, getStatus, getSubscriptionFilterFactory, handleCorruptedMessage, handleCorruptedStream, handleUnknownMessage, hasMessageMask, isAlive, isClosed, notifyListener, reportIgnoredMessage, retrieveDescribeProtocolMessage, retrieveMask, setCloseListener, setConnectionVariables, setMessageListener, start
 
Methods inherited from class com.devexperts.qd.qtp.MessageConsumerAdapter
processHistoryAddSubscription, processHistoryData, processHistoryRemoveSubscription, processOtherMessage, processStreamAddSubscription, processStreamData, processStreamRemoveSubscription, processSubscription, processTickerAddSubscription, processTickerData, processTickerRemoveSubscription
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DistributorAdapter

public DistributorAdapter(QDTicker ticker,
                          QDStream stream,
                          QDHistory history,
                          SubscriptionFilter filter,
                          QDStats stats)
Method Detail

createDistributor

protected QDDistributor createDistributor(QDCollector collector,
                                          SubscriptionFilter filter,
                                          java.lang.String keyProperties)
This method is used internally by distributor adapter to create agent for the corresponding collector, filter, and keyProperties from this adapter's constructor. This implementation returns collector.createDistributor(filter, keyProperties). This method may be overridden to create agent with other filter, otherwise customize the agent that is being created, or to keep track of created agents.


toString

public java.lang.String toString()
Description copied from class: MessageAdapter
Returns description of this MessageAdapter for management and logging purposes.

Overrides:
toString in class MessageAdapter

getScheme

public DataScheme getScheme()
Specified by:
getScheme in class MessageAdapter

getSymbol

public java.lang.String getSymbol(char[] chars,
                                  int offset,
                                  int length)
Description copied from class: MessageConsumerAdapter
Returns symbol used for specified characters or null if not found.

Overrides:
getSymbol in class MessageConsumerAdapter

useDescribeProtocol

public void useDescribeProtocol()
Description copied from class: MessageAdapter
Invocation of this method causes this MessageAdapter to send DESCRIBE_PROTOCOL message if it is capable of doing so. It should be invoked once before calling MessageAdapter.start(). The code that calls this method shall also consult MessageAdapter.nextRetrieveTime(long).

Overrides:
useDescribeProtocol in class MessageAdapter

startImpl

protected void startImpl()
Overrides:
startImpl in class MessageAdapter

closeImpl

protected void closeImpl()
Overrides:
closeImpl in class MessageAdapter

processData

protected void processData(DataIterator iterator,
                           MessageType message)
Overrides:
processData in class MessageConsumerAdapter

nextRetrieveTime

public long nextRetrieveTime(long currentTime)
Overrides:
nextRetrieveTime in class MessageAdapter

retrieveMessages

public boolean retrieveMessages(MessageVisitor visitor)
Description copied from interface: MessageProvider
Retrieves accumulated message into specified message visitor. Returns true if some messages still remains in the provider or false if all accumulated messages were retrieved.

Specified by:
retrieveMessages in interface MessageProvider
Overrides:
retrieveMessages in class MessageAdapter

prepareProtocolDescriptor

public void prepareProtocolDescriptor(ProtocolDescriptor desc)
Description copied from class: MessageAdapter
Prepares outgoing protocol descriptor. Implementers should call super.prepareProtocolDescriptor(desc).

Overrides:
prepareProtocolDescriptor in class MessageAdapter
Parameters:
desc - outgoing protocol descriptor

processDescribeProtocol

public void processDescribeProtocol(ProtocolDescriptor desc)
Description copied from class: MessageAdapter
Process incoming protocol descriptor. Implementers should call super.processDescribeProtocol(desc).

Specified by:
processDescribeProtocol in interface MessageConsumer
Overrides:
processDescribeProtocol in class MessageAdapter
Parameters:
desc - incoming protocol descriptor

isProtocolDescriptorCompatible

public boolean isProtocolDescriptorCompatible(ProtocolDescriptor desc)
Overrides:
isProtocolDescriptorCompatible in class MessageAdapter

visitSubscription

protected boolean visitSubscription(MessageVisitor visitor,
                                    SubscriptionProvider provider,
                                    MessageType message)

subscriptionAvailable

public void subscriptionAvailable(SubscriptionProvider provider)
Description copied from interface: SubscriptionListener
Notifies this listener that subscription is available in the specified subscription provider.

Specified by:
subscriptionAvailable in interface SubscriptionListener

subscriptionChanged

protected void subscriptionChanged(SubscriptionProvider provider,
                                   MessageType message)