简体   繁体   English

在Apache Storm中运行时编辑螺栓过程

[英]Edit bolt process at run time in Apache Storm

My project streams object data through storm to a graphics application. 我的项目通过风暴将对象数据流传输到图形应用程序。 The appearance of these objects depends upon variables assigned by a bolt in the storm topology. 这些对象的外观取决于风暴拓扑中螺栓分配的变量。

My question is whether it is possible to update the bolt process by sending a message to it that changes the variables it attaches to object data. 我的问题是,是否有可能通过向其发送一条消息来更改其附加到对象数据的变量来更新螺栓过程。 For example, after sending a message to the bolt declaring that I want any object with parameter x above a certain number to appear as red rather than blue. 例如,在向螺栓发送一条消息后,声明我希望参数x超过一定数字的任何对象显示为红色而不是蓝色。 The bolt process would then append a red rgb variable to the object data rather than blue. 然后,bolt进程会将红色rgb变量附加到对象数据,而不是蓝色。

I was thinking this would be possible by having a displayConfig class that the bolt uses to apply appearance and who's contents can be edited by messages with a certain header. 我当时想通过有一个DisplayConfig类来实现这一点,螺栓可以使用该类来应用外观,并且可以使用具有特定标题的消息来编辑谁的内容。

Is this possible? 这可能吗?

It is possible, but you need to do it manually and prepare you topology before you start it. 可以,但是您需要手动进行并在启动之前准备拓扑。

There are two ways to do this: 有两种方法可以做到这一点:

  1. use a local config file for bolt that you put into the worker machine (maybe via NFS). 将本地配置文件用于您放入工作机中的螺栓(也许通过NFS)。 The bolts regularly check the file for updates an read an updated configuration if you do change the file. 螺栓会定期检查文件是否更新,如果确实要更改文件,则读取更新的配置。

  2. You use one more spout that produces a configuration stream. 您将使用一个额外的喷口来产生配置流。 All bolts you want to send a configuration during runtime, need to consumer from this configuration-spout via "allGrouping". 要在运行期间发送配置的所有螺栓,都需要通过“ allGrouping”从此配置喷嘴中使用。 When processing input tuple, you check if its a regular data tuple or and configuration tuple (and update you config accordingly). 处理输入元组时,请检查其是常规数据元组还是配置元组(并相应地更新配置)。

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

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