在Storm中,启动类是用于初始化和配置Storm集群的类,它通常包含一些必要的设置,如定义拓扑、设置工作目录、配置Nimbus和Supervisor等,下面是一个典型的Storm启动类的示例:
“`java
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.topology.TopologyBuilder;
import backtype.storm.tuple.Fields;
import backtype.storm.utils.Utils;
public class StormStarter {
public static void main(String[] args) {
// 创建拓扑构建器
TopologyBuilder builder = new TopologyBuilder();
// 定义拓扑组件
builder.setSpout(“spout”, new MySpout(), 1);
builder.setBolt(“bolt”, new MyBolt(), 2).shuffleGrouping(“spout”);
// 设置拓扑的配置
Config conf = new Config();
conf.setDebug(true);
conf.setNumWorkers(2);
conf.setMaxSpoutPending(1);
conf.setMaxBoltPending(1);
conf.setMessageTimeoutSecs(30);
conf.setDebugActions(“*”);
conf.setDebugOutputToStdOut(true);
conf.setDebugSuppressLogging(false);
conf.setDebugSuppressTimeStamp(false);
conf.setDebugSuppressExceptionStackTrace(false);
conf.setDebugSuppressRecursiveErrorDetails(false);
conf.setDebugSuppressDirectObjectInspection(false);
conf.setDebugSuppressClassLoadingDetails(false);
conf.setDebugSuppressFieldAccessDetails(false);
conf.setDebugSuppressMethodExecutionDetails(false);
conf.setDebugSuppressExceptionDetails(false);
conf.setDebugSuppressStackTrace(false);
conf.setDebugSuppressExceptionCause(false);
conf.setDebugSuppressExceptionClass(false);
conf.setDebugSuppressExceptionMessage(false);
conf.setDebugSuppressExceptionMessage
本文来自投稿,不代表重蔚自留地立场,如若转载,请注明出处https://www.cwhello.com/416560.html
如有侵犯您的合法权益请发邮件951076433@qq.com联系删除