为风暴中的个体工作者分配内存

时间:2016-12-02 06:26:06

标签: java configuration apache-storm topology

我需要为每个新工作者分配不同的内存值。所以我尝试为每个螺栓和喷口更换内存。我目前也在使用自定义调度程序。这是我解决问题的方法。

我的代码:

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());

MY 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"

当我提交拓扑时,我收到以下错误。

ERROR:

  

线程中的异常" main" java.lang.IllegalArgumentException:将无法成功调度拓扑:配置TOPOLOGY_WORKER_MAX_HEAP_SIZE_MB = 768.0< 2048.0(拓扑中组件的最大内存要求)。也许将TOPOLOGY_WORKER_MAX_HEAP_SIZE_MB设置为更大的数量

     

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

有什么建议吗?

2 个答案:

答案 0 :(得分:0)

您是否尝试按照错误消息提供建议?

  

或许将TOPOLOGY_WORKER_MAX_HEAP_SIZE_MB设置为更大的数量

尝试将此添加到storm.yaml:

topology.worker.max.heap.size.mb=2048.0 

答案 1 :(得分:0)

尝试使用它。

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);
   }

}