public class ChannelShaper extends Object implements Cloneable
AgentAdapter
.
It includes contract, collector, keep rejected flag, 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 contract, subscription executor, and keep reject flag,
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 and Description |
---|
ChannelShaper(Executor subscriptionExecutor,
QDCollector collector,
SubscriptionFilter subscriptionFilter,
RecordFilter dataFilter)
|
ChannelShaper(QDContract contract,
Executor subscriptionExecutor)
Creates new channel shaper with specified contract and subscription executor.
|
ChannelShaper(QDContract contract,
Executor subscriptionExecutor,
boolean keepRejected)
Creates new channel shaper with specified contract, subscription executor,
and keep rejected flag.
|
Modifier and Type | Method and Description |
---|---|
ChannelShaper |
clone() |
void |
close()
Closes this channel shaper and releases its resources (stops tracking dynamic filters).
|
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.
|
Executor |
getSubscriptionExecutor()
Returns executor for subscription processing used by the channel
or
null if none specified. |
QDFilter |
getSubscriptionFilter()
Returns subscription filter currently used by the channel.
|
int |
getWeight()
Returns relative weight of this channel data within the adapter for shaping.
|
boolean |
hasSubscriptionExecutor()
Returns
true if there is an executor for subscription processing. |
boolean |
isKeepRejected()
Returns
true when subscription rejected by this channel's filter is kept for
the case of future changes of subscription filter. |
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(QDFilter subscriptionFilter)
Sets subscription filter for the channel.
|
void |
setSubscriptionFilter(SubscriptionFilter subscriptionFilter)
Deprecated.
Use
setSubscriptionFilter(QDFilter)
that accepts non-null QDFilter instance which replaces legacy SubscriptionFilter . |
void |
setWeight(int weight)
Sets relative weight of this channel data within the adapter for shaping.
|
public ChannelShaper(QDContract contract, Executor subscriptionExecutor)
contract
- channel contract; may not be null
subscriptionExecutor
- subscription executor; may be null
NullPointerException
- if contract
is null
public ChannelShaper(QDContract contract, Executor subscriptionExecutor, boolean keepRejected)
contract
- channel contract; may not be null
subscriptionExecutor
- subscription executor; may be null
keepRejected
- true
when rejected subscription elements shall be kept for future changes of filter.NullPointerException
- if contract
is null
public ChannelShaper(Executor subscriptionExecutor, QDCollector collector, SubscriptionFilter subscriptionFilter, RecordFilter dataFilter)
ChannelShaper(QDContract, Executor)
and setCollector(QDCollector)
,
setSubscriptionFilter(QDFilter)
, setDataFilter(RecordFilter)
null
.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
NullPointerException
- if collector
is null
public void close()
public ChannelShaper clone()
public QDContract getContract()
public boolean hasSubscriptionExecutor()
true
if there is an executor for subscription processing.
This property is fixed for a given channel.true
if there is an executor for subscription processing.public Executor getSubscriptionExecutor()
null
if none specified.
This property is fixed for a given channel.null
public boolean isKeepRejected()
true
when subscription rejected by this channel's filter is kept for
the case of future changes of subscription filter.
This property is fixed for a given channel.public final QDCollector getCollector()
null
public void setCollector(QDCollector collector)
null
in which case no agent will be created for the channel.
Change of collector will trigger re-creation of agent.collector
- channel collector; may be null
public final QDFilter getSubscriptionFilter()
public void setSubscriptionFilter(SubscriptionFilter subscriptionFilter)
setSubscriptionFilter(QDFilter)
that accepts non-null QDFilter
instance which replaces legacy SubscriptionFilter
.null
in which case all subscription will be accepted.
Change of subscription filter will trigger re-creation of agent.subscriptionFilter
- subscription filter; may be null
public void setSubscriptionFilter(QDFilter subscriptionFilter)
QDFilter.ANYTHING
to accept any subscription.
Change of subscription filter will trigger re-creation of agent.subscriptionFilter
- subscription filter;
may be null
for backwards-compatibility (it is replaced with QDFilter.ANYTHING
)public RecordFilter getDataFilter()
null
public void setDataFilter(RecordFilter dataFilter)
null
in which case all data will be accepted.
Change of data filter is immediate and will not trigger re-creation of agent.dataFilter
- data filter; may be null
public int getWeight()
public void setWeight(int weight)
weight
- relative weightIllegalArgumentException
- if weight is less than 1 or greater than 100.public long getAggregationPeriod()
public void setAggregationPeriod(long aggregationPeriod)
aggregationPeriod
- in millisecondsIllegalArgumentException
- if aggregation period is negative or greater than 24 hours.Copyright © 2002–2025 Devexperts LLC. All rights reserved.