简体   繁体   English

在风暴群集中的每台机器上严格分配一个特殊的螺栓

[英]Assign strictly one special bolt on each machine in storm cluster

I would like to start special bolt on every machine in my cluster. 我想在群集中的每台计算机上启动特殊螺栓。

Storm has pluggable scheduler, but documentation is very scanty. Storm具有可插入的调度程序,但是文档非常少。 There is only one understandable example from xumingming. 虚名只有一个可以理解的例子 How could be implemented this pattern using IScheduler ? 如何使用IScheduler实现此模式?

Example

We have TCPBolt , which listens port 8765. TCPBolt parallelism == cluster size. 我们有TCPBolt ,它侦听端口TCPBolt并行性==群集大小。 We need to start one instance of this bolt on each machine. 我们需要在每台机器上启动该螺栓的一个实例。

The example and source code gives enough demo code to do this. 该示例和源代码提供了足够的演示代码来执行此操作。

First you need to set the task number of TCPBolt to be the host number of your cluser. 首先,您需要将TCPBolt的任务号设置为cluser的主机号。

Then in your IScheduler impl, using data in private Map<String, SchedulerAssignmentImpl> assignments; 然后在您的IScheduler隐式中,使用private Map<String, SchedulerAssignmentImpl> assignments; to check if the TCPBolt is assign to a host ( in SchedulerAssignmentImpl, using data Map<ExecutorDetails, WorkerSlot> executorToSlot; ) 检查是否将TCPBolt分配给主机(在SchedulerAssignmentImpl中,使用数据Map<ExecutorDetails, WorkerSlot> executorToSlot;

Finally, if not assigned, using the following code to assign 最后,如果未分配,则使用以下代码进行分配

// re-get the aviableSlots
availableSlots = cluster.getAvailableSlots(specialSupervisor);
 
// since it is just a demo, to keep things simple, we assign all the
// executors into one slot.
cluster.assign(availableSlots.get(0), topology.getId(), executors);

This is just a rough idea. 这只是一个粗略的想法。 Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM