com.devexperts.qd.qtp
Class ChannelShaper

java.lang.Object
  extended by com.devexperts.qd.qtp.ChannelShaper

public class ChannelShaper
extends java.lang.Object

This class represents configuration of a single data channel within AgentAdapter. It includes collector, subscription filter, data filter, relative weight and aggregation period. Each channel may specify executor to be used for subscription processing (i.e. filtering) - it is required when subscription filtering is a heavy operation (e.g. requires database access).

Channel may change its parameters except for subscription executor to new values anytime. The changes of data filter, weight or aggregation period are immediately effective and do not require re-creation of agent (i.e. no interruption of data stream happens). The changes of collector or subscription filter require re-creation of agent which result with brief data stream interruption. The re-creation of agent will happen upon data or subscription message processing; it can be forced via invocation of AgentAdapter.updateChannel(com.devexperts.qd.qtp.ChannelShaper) method.


Constructor Summary
ChannelShaper(java.util.concurrent.Executor subscriptionExecutor, QDCollector collector, SubscriptionFilter subscriptionFilter, RecordFilter dataFilter)
          Creates new channel shaper with specified parameters.
ChannelShaper(QDCollector collector, SubscriptionFilter subscriptionFilter)
          Creates new channel shaper with specified collector and filter.
ChannelShaper(QDContract contract, java.util.concurrent.Executor subscriptionExecutor)
          Creates new channel shaper with specified contract and subscription executor.
 
Method Summary
 long getAggregationPeriod()
          Returns aggregation period in milliseconds for this channel data.
 QDCollector getCollector()
          Returns collector currently used by the channel.
 QDContract getContract()
          Returns contract of the channel.
 RecordFilter getDataFilter()
          Returns data filter currently used by the channel.
 java.util.concurrent.Executor getSubscriptionExecutor()
          Returns executor for subscription processing used by the channel or null if none specified.
 SubscriptionFilter getSubscriptionFilter()
          Returns subscription filter currently used by the channel.
 int getWeight()
          Returns relative weight of this channel data within the adapter for shaping.
 void setAggregationPeriod(long aggregationPeriod)
          Sets aggregation period for this channel data.
 void setCollector(QDCollector collector)
          Sets collector for the channel.
 void setDataFilter(RecordFilter dataFilter)
          Sets data filter for the channel.
 void setSubscriptionFilter(SubscriptionFilter subscriptionFilter)
          Sets subscription filter for the channel.
 void setWeight(int weight)
          Sets relative weight of this channel data within the adapter for shaping.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChannelShaper

public ChannelShaper(QDContract contract,
                     java.util.concurrent.Executor subscriptionExecutor)
Creates new channel shaper with specified contract and subscription executor.

Parameters:
contract - channel contract; may not be null
subscriptionExecutor - subscription executor; may be null
Throws:
java.lang.NullPointerException - if contract is null

ChannelShaper

public ChannelShaper(QDCollector collector,
                     SubscriptionFilter subscriptionFilter)
Creates new channel shaper with specified collector and filter.

Parameters:
collector - channel collector; may not be null
subscriptionFilter - subscription filter; may be null
Throws:
java.lang.NullPointerException - if collector is null

ChannelShaper

public ChannelShaper(java.util.concurrent.Executor subscriptionExecutor,
                     QDCollector collector,
                     SubscriptionFilter subscriptionFilter,
                     RecordFilter dataFilter)
Creates new channel shaper with specified parameters. All initialization parameters except for collector may be null.

Parameters:
subscriptionExecutor - subscription executor; may be null
collector - channel collector; may not be null
subscriptionFilter - subscription filter; may be null
dataFilter - data filter; may be null
Throws:
java.lang.NullPointerException - if collector is null
Method Detail

getContract

public QDContract getContract()
Returns contract of the channel.

Returns:
channel contract

getSubscriptionExecutor

public java.util.concurrent.Executor getSubscriptionExecutor()
Returns executor for subscription processing used by the channel or null if none specified.

Returns:
subscription executor or null

getCollector

public final QDCollector getCollector()
Returns collector currently used by the channel.

Returns:
channel collector or null

setCollector

public void setCollector(QDCollector collector)
Sets collector for the channel. The contract of collector must match the contract of this channel. The collector may be null in which case no agent will be created for the channel. Change of collector will trigger re-creation of agent.

Parameters:
collector - channel collector; may be null

getSubscriptionFilter

public final SubscriptionFilter getSubscriptionFilter()
Returns subscription filter currently used by the channel.

Returns:
subscription filter or null

setSubscriptionFilter

public void setSubscriptionFilter(SubscriptionFilter subscriptionFilter)
Sets subscription filter for the channel. The subscription filter may be null in which case all subscription will be accepted. Change of subscription filter will trigger re-creation of agent.

Parameters:
subscriptionFilter - subscription filter; may be null

getDataFilter

public RecordFilter getDataFilter()
Returns data filter currently used by the channel.

Returns:
data filter or null

setDataFilter

public void setDataFilter(RecordFilter dataFilter)
Sets data filter for the channel. The data filter may be null in which case all data will be accepted. Change of data filter is immediate and will not trigger re-creation of agent.

Parameters:
dataFilter - data filter; may be null

getWeight

public int getWeight()
Returns relative weight of this channel data within the adapter for shaping.

Returns:
relative weight of this channel data

setWeight

public void setWeight(int weight)
Sets relative weight of this channel data within the adapter for shaping. The weight must be between 1 and 100 inclusive. Change of weight is immediate and will not trigger re-creation of agent.

Parameters:
weight - relative weight
Throws:
java.lang.IllegalArgumentException - if weight is less than 1 or greater than 100.

getAggregationPeriod

public long getAggregationPeriod()
Returns aggregation period in milliseconds for this channel data.

Returns:
aggregation period in milliseconds

setAggregationPeriod

public void setAggregationPeriod(long aggregationPeriod)
Sets aggregation period for this channel data. The aggregation period must be non-negative and must not exceed 24 hours. Change of aggregation period is immediate and will not trigger re-creation of agent.

Parameters:
aggregationPeriod - in milliseconds
Throws:
java.lang.IllegalArgumentException - if aggregation period is negative or greater than 24 hours.