Skip to main content
Common Reference

shardbyseqno.js Filter

Shards within the replicator enable data to be parallelized when they are applied on the Target.

Pre-configured filter nameshardbyseqno
JavaScript Filter Filetungsten-replicator/support/filters-javascript/shardbyseqno.js
Property prefixreplicator.filter.shardbyseqno
Stage compatibilityq-to-dbms
tpm Option compatibilitysvc-applier-filters
Data compatibilityAny event

Parameters

ParameterTypeDefaultDescription
shardsnumeric(none)Number of shards to be used by the applier

The shardbyseqno filter updates the shard ID, which is embedded into the event metadata, by a configurable number of shards, set by the shards parameter in the configuration:

replicator.filter.shardbyseqno=com.continuent.tungsten.replicator.filter.JavaScriptFilter
replicator.filter.shardbyseqno.script=${replicator.home}/samples/extensions/javascript/shardbyseqno.js
replicator.filter.shardbyseqno.shards=10

The filter works by setting the shard ID in the event using the setShardId() method on the event object:

event.setShardId(event.getSeqno() % shards);
note

Care should be taken with this filter, as it assumes that the events can be applied in a completely random order by blindly updating the shard ID to a computed value. Sharding in this way is best used when provisioning new Targets.