com.devexperts.qd.logger
Class LoggedAgent

java.lang.Object
  extended by com.devexperts.qd.logger.LoggedObject
      extended by com.devexperts.qd.logger.LoggedDataProvider
          extended by com.devexperts.qd.logger.LoggedAgent
All Implemented Interfaces:
DataProvider, QDAgent, QDStatsContainer, SubscriptionContainer

public class LoggedAgent
extends LoggedDataProvider
implements QDAgent


Field Summary
 
Fields inherited from class com.devexperts.qd.logger.LoggedObject
log, name
 
Constructor Summary
LoggedAgent(QDLog log, java.lang.String name, QDAgent delegate, DataScheme scheme)
           
 
Method Summary
 void addSubscription(SubscriptionIterator iterator)
          Adds specified subscription to this agent's data interest.
 void close()
          Closes this agent and releases allocated resources in its QDCollector.
 boolean examineSubscription(SubscriptionVisitor visitor)
          Examines subscription and passes it to the visitor.
 SubscriptionConsumer getAddingSubscriptionConsumer()
          Returns subscription consumer that can be used to add subscription.
 SubscriptionConsumer getRemovingSubscriptionConsumer()
          Returns subscription consumer that can be used to remove subscription.
 QDStats getStats()
           
 int getSubscriptionSize()
          Returns subscription size in terms of (record, symbol) pairs.
 boolean isSubscribed(DataRecord record, int cipher, java.lang.String symbol, long time)
          Returns true if subscribed to the corresponding record and symbol with the corresponding time.
 void removeSubscription(SubscriptionIterator iterator)
          Removes specified subscription from this agent's data interest.
 void setBufferOverflowStrategy(int max_buffer_size, boolean drop_oldest, boolean log_overflow)
          Sets new strategy for handling of stream and history buffer overflow events.
 void setStreamOverflowStrategy(int max_buffer_size, boolean drop_oldest, boolean log_overflow)
          Sets new strategy for handling of stream and history buffer overflow events.
 void setSubscription(SubscriptionIterator iterator)
          Sets specified subscription to be this agent's data interest.
 
Methods inherited from class com.devexperts.qd.logger.LoggedDataProvider
retrieveData, setDataListener
 
Methods inherited from class com.devexperts.qd.logger.LoggedObject
child, debug, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.devexperts.qd.DataProvider
retrieveData, setDataListener
 

Constructor Detail

LoggedAgent

public LoggedAgent(QDLog log,
                   java.lang.String name,
                   QDAgent delegate,
                   DataScheme scheme)
Method Detail

getAddingSubscriptionConsumer

public SubscriptionConsumer getAddingSubscriptionConsumer()
Description copied from interface: QDAgent
Returns subscription consumer that can be used to add subscription. Adding subscription via returned consumer has the same effect as adding it directly via QDAgent.addSubscription(com.devexperts.qd.SubscriptionIterator) method.

Specified by:
getAddingSubscriptionConsumer in interface QDAgent

getRemovingSubscriptionConsumer

public SubscriptionConsumer getRemovingSubscriptionConsumer()
Description copied from interface: QDAgent
Returns subscription consumer that can be used to remove subscription. Removing subscription via returned consumer has the same effect as removing it directly via QDAgent.removeSubscription(com.devexperts.qd.SubscriptionIterator) method.

Specified by:
getRemovingSubscriptionConsumer in interface QDAgent

addSubscription

public void addSubscription(SubscriptionIterator iterator)
Description copied from interface: QDAgent
Adds specified subscription to this agent's data interest. This is a shortcut to adding subscription via corresponding subscription consumer.

Specified by:
addSubscription in interface QDAgent

removeSubscription

public void removeSubscription(SubscriptionIterator iterator)
Description copied from interface: QDAgent
Removes specified subscription from this agent's data interest. This is a shortcut to removing subscription via corresponding subscription consumer.

Specified by:
removeSubscription in interface QDAgent

setSubscription

public void setSubscription(SubscriptionIterator iterator)
Description copied from interface: QDAgent
Sets specified subscription to be this agent's data interest. This method keeps state of survived subscription; in other words, it uses addAll+retainAll operations in contrast to removeAll+addAll operations.

Specified by:
setSubscription in interface QDAgent

close

public void close()
Description copied from interface: QDAgent
Closes this agent and releases allocated resources in its QDCollector. Closed agent can not be activated again and shall not be used anymore. Attempt to use closed agent will result in no action - subscription will be ignored and data retrieval will retrieve no data.

Specified by:
close in interface QDAgent

getStats

public QDStats getStats()
Specified by:
getStats in interface QDStatsContainer

isSubscribed

public boolean isSubscribed(DataRecord record,
                            int cipher,
                            java.lang.String symbol,
                            long time)
Description copied from interface: SubscriptionContainer
Returns true if subscribed to the corresponding record and symbol with the corresponding time. Non-historic (stream and ticker) QD ignores time parameter.

Note: Check by time in history is not guaranteed yet (may transiently give wrong result), because it performs unsynchronized read on two ints to get time from internal data structure. In history it is guaranteed to work properly only when time parameter is set to Long.MAX_VALUE.

Specified by:
isSubscribed in interface SubscriptionContainer

examineSubscription

public boolean examineSubscription(SubscriptionVisitor visitor)
Description copied from interface: SubscriptionContainer
Examines subscription and passes it to the visitor. Returns true if not all subscription was examined or false otherwise.

Note: Visited subscription time in history is not guaranteed yet (may transiently give wrong result), because it performs unsynchronized read on two ints to get time from internal data structure.

Specified by:
examineSubscription in interface SubscriptionContainer

getSubscriptionSize

public int getSubscriptionSize()
Description copied from interface: SubscriptionContainer
Returns subscription size in terms of (record, symbol) pairs.

Specified by:
getSubscriptionSize in interface SubscriptionContainer

setStreamOverflowStrategy

public void setStreamOverflowStrategy(int max_buffer_size,
                                      boolean drop_oldest,
                                      boolean log_overflow)
Description copied from interface: QDAgent
Sets new strategy for handling of stream and history buffer overflow events. New strategy settings apply only for newly distributed data. Their effect on already accumulated data is not defined. Has no effect on ticker agents.

Specified by:
setStreamOverflowStrategy in interface QDAgent
Parameters:
max_buffer_size - how many records to keep in buffer, default is 1000000
drop_oldest - which record shall be dropped - oldest (true) or newest (false), default is true
log_overflow - whether overflow event shall be logged or not, default is true

setBufferOverflowStrategy

public void setBufferOverflowStrategy(int max_buffer_size,
                                      boolean drop_oldest,
                                      boolean log_overflow)
Description copied from interface: QDAgent
Sets new strategy for handling of stream and history buffer overflow events. New strategy settings apply only for newly distributed data. Their effect on already accumulated data is not defined. Has no effect on ticker agents.

Specified by:
setBufferOverflowStrategy in interface QDAgent
Parameters:
max_buffer_size - how many records to keep in buffer, default is 1000000
drop_oldest - which record shall be dropped - oldest (true) or newest (false), default is true
log_overflow - whether overflow event shall be logged or not, default is true