
Topology
本文不是停留在字面上去總結(jié)Storm的流分組方式,而是列出Storm流分組實(shí)現(xiàn)的源碼位置,看了源碼,對各種流分組也就可以做到知其所以然了。
各種流分組一覽,源碼位置
org.apache.storm.topology.InputDeclarer<T extends InputDeclarer>
讀讀這個(gè)接口的源碼,Storm支持的所有流分組方式瞬間收入囊中。
1.shuffle grouping源碼位置
org.apache.storm.grouping.ShuffleGrouping
2.fields grouping源碼位置
org.apache.storm.trident.partition.IndexHashGrouping
3.global grouping源碼位置
org.apache.storm.trident.partition.GlobalGrouping
4.local or shuffle grouping源碼位置
org.apache.storm.grouping.LoadAwareShuffleGrouping
5.none grouping源碼位置
org.apache.storm.testing.NGrouping
6.all grouping
源碼位置我沒找到,不過看了其他流分組方式的源碼,這種分組方式的實(shí)現(xiàn)也就豁然開朗了。
7.direct grouping源碼位置
org.apache.storm.trident.partition.IdentityGrouping
8.partial key grouping源碼位置
org.apache.storm.grouping.PartialKeyGrouping
9.custom grouping
自定義分組,實(shí)現(xiàn)接口
org.apache.storm.grouping.CustomStreamGrouping
看了其他流分組方式的源碼,你會(huì)發(fā)現(xiàn)所有流分組的實(shí)現(xiàn)類都實(shí)現(xiàn)了CustomStreamGrouping接口,因此,實(shí)現(xiàn)自定義流分組的方法也就一目了然了。