storm分布式实时计算四

Trident

Trident在storm之前提供了高层次抽象,抽象掉了事务处理和状态管理的细节,允许topology在数据上执行函数功能、过滤、聚合操作。

Trident topology

TridentTopology类替换原有的TopologyBuilder。

TridentTopology tridentTopology = new TridentTopology();
Stream stream = tridentTopology.newStream("event", new SentenceSpout());

tridentTopology.each

Trident spout

spout业务类实现ITridentSpout接口。

getCoordinator:返回定义的spout对象,SpoutOutputCollector collector,,返回的对象对应的类要实现BatchCoordinator接口。BatchCoordinator接口用于重放一个batch所需要的元数据。

getEmitter:返回指定的emitter对象,返回的对象对应的类要实现Emitter接口。Emitter接口用于将tuple发送出去。

getComponent:

getOutputFields:定义发送的fields,例如new Fields("event"),

Trident 操作

trident提供 filter与function两种运算。

filter:过滤指定的tuple。

function:与bolt类似,读取tuple并且发送新的tuple,不过function只能添加数据,function在发送数据时,将新字段添加到tuple中,并不会删除或者变更已有字段。

Trident 聚合

aggregator聚合器运行topology组合tuple。

combinerAggregator:用于将一个集合的tuple组合到一个单独的字段中。

reducerAggregator:将tuple合并到局部聚合结果中。

Aggregator:与function接口的excute方法类型,将值进行累加。

Trident状态

State接口,支持Trident对状态进行底层的操作源语。

 

posted @ 2024-05-21 13:16  使用D  阅读(3)  评论(0编辑  收藏  举报