builder.setBolt("split", new SplitSentence(), 8).shuffleGrouping("spout");这句代码是什么意思?
时间: 2024-04-25 17:24:54 浏览: 10
这段代码是在Storm拓扑中设置一个Bolt组件的配置。让我解释一下每个部分的含义:
1. `builder.setBolt("split", new SplitSentence(), 8)`:这部分代码表示创建一个名为 "split" 的Bolt组件,并指定其实例为 `SplitSentence()`。数字8表示这个Bolt将被分配到8个任务(Task)中进行并行处理。
2. `.shuffleGrouping("spout")`:这部分代码表示将名为 "spout" 的Spout组件作为输入源,通过随机分组方式将元组发送给 "split" Bolt进行处理。这意味着 "split" Bolt的每个任务将随机接收来自 "spout" 的元组进行处理。
综合起来,这段代码的作用是将一个名为 "split" 的Bolt组件加入到拓扑中,并设置它的输入源为名为 "spout" 的Spout组件。该Bolt将以并行度为8的方式处理输入的元组,并使用随机分组策略从Spout接收元组。
相关问题
What+is+a+spout+in+Apache+Storm?  a. A+component+that+visualizes+data  b. A+component+that+stores
A spout in Apache Storm is a component that is responsible for ingesting data into the Storm topology. It acts as a source of data and emits streams of tuples, which are the basic units of data in Storm. Spouts can read data from various*** the data as tuples to be processed by the bolts in the topology.
Spouts are the starting point of a Storm topology and can be used to fetch real-time data from external systems. They can be configured to emit data continuously or in batches, and they can also handle failures and ensure data reliability.
In summary, a spout in Apache Storm is a component that fetches data from external sources and emits streams of tuples to be processed by the bolts in a Storm topology.
Storm中的Stream grouping有哪几种方式?
在Storm中,Stream grouping用于将Spout或Bolt发射的Tuple路由到下游Bolt的任务中。以下是Storm中的几种Stream grouping方式:
1. Shuffle grouping:随机分组,每个Tuple随机发送到下游Bolt的任务中。
2. Fields grouping:按字段分组,具有相同字段值的Tuple被发送到相同的任务中。
3. All grouping:广播分组,每个Tuple会被发送到所有下游Bolt的任务中。
4. Global grouping:全局分组,每个Tuple只会被发送到下游Bolt的一个任务中。
5. Direct grouping:直接分组,开发人员可以控制将Tuple发送到哪个具体的下游Bolt任务中。
6. Partial key grouping:部分键分组,按照指定的字段进行hash分组,具有相同hash值的Tuple被发送到相同的任务中。
这些Stream grouping方式可以根据具体业务需求进行选择和组合使用。