java - 在 Storm 中为单个 worker 分配内存

标签 java configuration apache-storm topology

我需要为每个新 worker 分配不同的内存值。所以我尝试改变每个 bolt 和喷口的内存。我目前也在使用自定义调度程序。这是我解决问题的方法。
我的代码:

TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("spout", new EmailSpout(), 1).addConfiguration("node", "zoo1").setMemoryLoad(512.0);
builder.setBolt("increment1", new IncrementBolt(), PARALLELISM).shuffleGrouping("spout").addConfiguration("node", "zoo2").setMemoryLoad(2048.0);
builder.setBolt("increment2", new IncrementBolt(), PARALLELISM).shuffleGrouping("increment1").addConfiguration("node", "zoo3").setMemoryLoad(2048.0);
builder.setBolt("increment3", new IncrementBolt(), PARALLELISM).shuffleGrouping("increment2").addConfiguration("node", "zoo4").setMemoryLoad(2048.0);
builder.setBolt("output", new OutputBolt(), 1).globalGrouping("increment2").addConfiguration("node", "zoo1").setMemoryLoad(512.0);
Config conf = new Config();
conf.setDebug(false);
conf.setNumWorkers(4);
StormSubmitter.submitTopologyWithProgressBar("Microbenchmark", conf, builder.createTopology());
我的 STORM.YAML:
 storm.zookeeper.servers:
     - "zoo1"
 storm.zookeeper.port: 2181
 nimbus.seeds: ["zoo1"]
 storm.local.dir: "/home/ubuntu/eranga/storm-data"
 supervisor.slots.ports:
     - 6700
     - 6701
     - 6702
     - 6703
     - 6704
 storm.scheduler: "org.apache.storm.scheduler.NodeBasedCustomScheduler"
 supervisor.scheduler.meta:
     node: "zoo4"
 worker.profiler.enabled: true
 worker.profiler.childopts: "-XX:+UnlockCommercialFeatures -XX:+FlightRecorder"
 worker.profiler.command: "flight.bash"
 worker.heartbeat.frequency.secs: 1
 worker.childopts: "-Xmx2048m -Xms2048m -Djava.net.preferIPv4Stack=true -Dorg.xml.sax.driver=com.sun.org.apache.xerces.internal.parsers.SAXParser -Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl -Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl"
当我提交拓扑时,出现以下错误。
错误:

Exception in thread "main" java.lang.IllegalArgumentException: Topology will not be able to be successfully scheduled: Config TOPOLOGY_WORKER_MAX_HEAP_SIZE_MB=768.0 < 2048.0 (Largest memory requirement of a component in the topology). Perhaps set TOPOLOGY_WORKER_MAX_HEAP_SIZE_MB to a larger amount

at org.apache.storm.StormSubmitter.validateTopologyWorkerMaxHeapSizeMBConfigs(StormSubmitter.java:496)


有什么建议?

最佳答案

尝试使用这个。

import org.apache.storm.Config;

public class TopologyExecuter{
   for(List<StormTopology> StormTopologyObject : StormTopologyObjects ){
       Config topologyConf = new Config();
       topologyConf.put(Config.TOPOLOGY_WORKER_CHILDOPTS,"-Xmx512m -Xms256m");
       StormSubmitter.submitTopology("topology name", topologyConf, StormTopologyObject);
   }

}

关于java - 在 Storm 中为单个 worker 分配内存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40926092/

相关文章:

java - 从java中的类添加值

java - 无需重新部署应用程序即可反射(reflect)更改

linux - IRCD配置: authentication using a database table

redis - 用于流应用程序的时间序列窗口

netty - Spark 是如何使用 Netty 的?

Java Past Paper - 是我一个人还是这个 switch 语句 q 的措辞使它无法解决?

java - 生成随机数,第一个为零

configuration - Doctrine2 实体命名空间

ios - Apple 帐户中缺少 NSFileProtectionNone

redis - Redisson内部是如何实现Redis命令的?