Storm Local Mode

本文介绍Apache Storm中的LocalMode,一种用于开发和测试拓扑结构的工具。LocalMode可以在单个进程中模拟Storm集群,并允许开发者使用LocalCluster类创建进程内集群。文章还详细介绍了如何提交拓扑结构以及关闭本地集群的方法,并提供了常用配置选项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Local Mode

Local mode simulates a Storm cluster in process and is useful for developing and testing topologies. Running topologies in local mode is similar to running topologies on a cluster.

To create an in-process cluster, simply use the LocalCluster class. For example:

import org.apache.storm.LocalCluster;

LocalCluster cluster = new LocalCluster();

You can then submit topologies using the submitTopology method on the LocalCluster object.Just like the corresponding(对应的) method on StormSubmittersubmitTopology takes a name, a topology configuration, and the topology object. You can then kill a topology using the killTopology method which takes the topology name as an argument.

To shutdown a local cluster, simple call:

cluster.shutdown();

Common configurations for local mode

You can see a full list of configurations here.

  1. Config.TOPOLOGY_MAX_TASK_PARALLELISM(并行的|平行的): This config puts a ceiling(隔板) on the number of threads spawned(量产的) for a single component. Oftentimes production topologies have a lot of parallelism (hundreds of threads) which places unreasonable(不合理的) load when trying to test the topology in local mode. This config lets you easy control that parallelism.
  2. Config.TOPOLOGY_DEBUG: When this is set to true, Storm will log a message every time a tuple is emitted(发出|放出) from any spout or bolt. This is extremely useful for debugging.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值