public void setFieldValue(_Fields field, Object value) { switch (field) { case WAIT_SECS: if (value == null) { unset_wait_secs(); } else { set_wait_secs((Integer) value); } break; } }
@Override public void stop( Application<StormEnvironment, StormTopology> executor, com.typesafe.config.Config config) { String appId = config.getString("appId"); LOG.info("Stopping topology {} ..." + appId); if (Objects.equals(config.getString("mode"), ApplicationEntity.Mode.CLUSTER.name())) { Nimbus.Client stormClient = NimbusClient.getConfiguredClient(getStormConfig(config)).getClient(); try { stormClient.killTopology(appId); } catch (NotAliveException | TException e) { LOG.error( "Failed to kill topology named {}, due to: {}", appId, e.getMessage(), e.getCause()); } } else { KillOptions killOptions = new KillOptions(); killOptions.set_wait_secs(0); getLocalCluster().killTopologyWithOpts(appId, killOptions); } LOG.info("Stopped topology {} ..." + appId); }
/** @param args */ public static void main(String[] args) { // TODO Auto-generated method stub if (args == null || args.length == 0) { throw new InvalidParameterException("Should input topology name"); } String topologyName = args[0]; NimbusClient client = null; try { Map conf = Utils.readStormConfig(); client = NimbusClient.getConfiguredClient(conf); if (args.length == 1) { client.getClient().killTopology(topologyName); } else { int delaySeconds = Integer.parseInt(args[1]); KillOptions options = new KillOptions(); options.set_wait_secs(delaySeconds); client.getClient().killTopologyWithOpts(topologyName, options); } System.out.println("Successfully submit command kill " + topologyName); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); throw new RuntimeException(e); } finally { if (client != null) { client.close(); } } }
public void realMain(String[] args) throws Exception { Map clusterConf = Utils.readStormConfig(); clusterConf.putAll(Utils.readCommandLineOpts()); Nimbus.Client client = NimbusClient.getConfiguredClient(clusterConf).getClient(); CmdLineParser parser = new CmdLineParser(this); parser.setUsageWidth(80); try { // parse the arguments. parser.parseArgument(args); } catch (CmdLineException e) { // if there's a problem in the command line, // you'll get this exception. this will report // an error message. System.err.println(e.getMessage()); _help = true; } if (_help) { parser.printUsage(System.err); System.err.println(); return; } if (_numWorkers <= 0) { throw new IllegalArgumentException("Need at least one worker"); } if (_name == null || _name.isEmpty()) { throw new IllegalArgumentException("name must be something"); } if (!_ackEnabled) { _ackers = 0; } try { for (int topoNum = 0; topoNum < _numTopologies; topoNum++) { int multiplier = 4; int totalSpout = _spoutParallel * _localGroup * multiplier; int totalLocalBolt = _boltLocalParallel * _localGroup * multiplier; int totalLocalResultBolt = _localGroup * multiplier; int totalGlobalBolt = _boltGlobalParallel * multiplier; int totalGlobalResultBolt = _boltGlobalParallel * multiplier; TopologyBuilder builder = new TopologyBuilder(); builder .setSpout("messageSpoutLocal1", new SOESpout(_messageSize, _ackEnabled), totalSpout) .addConfiguration("group-name", "Local1") .addConfiguration("TaskPerCloud", _spoutParallel); // builder.setBolt("messageBoltLocal1_1", new SOEBolt(), // totalLocalBolt).shuffleGrouping("messageSpoutLocal1").addConfiguration("group-name", // "Local1"); // builder.setBolt("messageBoltLocal1_LocalResult", new SOEFinalBolt(), // totalLocalResultBolt).shuffleGrouping("messageBoltLocal1_1").addConfiguration("group-name", "Local1"); builder .setBolt("messageBoltLocal1_1", new SOEBolt(), totalLocalBolt) .customGrouping("messageSpoutLocal1", new ZoneShuffleGrouping()) .addConfiguration("group-name", "Local1") .addConfiguration("TaskPerCloud", _boltLocalParallel); builder .setBolt("messageBoltLocal1_LocalResult", new SOEFinalBolt(), totalLocalResultBolt) .customGrouping("messageBoltLocal1_1", new ZoneShuffleGrouping()) .addConfiguration("group-name", "Local1"); builder .setSpout("messageSpoutLocal2", new SOESpout(_messageSize, _ackEnabled), totalSpout) .addConfiguration("group-name", "Local2") .addConfiguration("TaskPerCloud", _spoutParallel); // builder.setBolt("messageBoltLocal2_1", new SOEBolt(), // totalLocalBolt).shuffleGrouping("messageSpoutLocal2").addConfiguration("group-name", // "Local2"); // builder.setBolt("messageBoltLocal2_LocalResult", new SOEFinalBolt(), // totalLocalResultBolt).shuffleGrouping("messageBoltLocal2_1").addConfiguration("group-name", "Local2"); builder .setBolt("messageBoltLocal2_1", new SOEBolt(), totalLocalBolt) .customGrouping("messageSpoutLocal2", new ZoneShuffleGrouping()) .addConfiguration("group-name", "Local2") .addConfiguration("TaskPerCloud", _boltLocalParallel); builder .setBolt("messageBoltLocal2_LocalResult", new SOEFinalBolt(), totalLocalResultBolt) .customGrouping("messageBoltLocal2_1", new ZoneShuffleGrouping()) .addConfiguration("group-name", "Local2"); builder .setBolt("messageBoltGlobal1_1A", new SOEBolt(), totalGlobalBolt) .shuffleGrouping("messageBoltLocal1_1") .addConfiguration("group-name", "Global1") .addConfiguration("TaskPerCloud", _boltGlobalParallel); builder .setBolt("messageBoltGlobal1_1B", new SOEBolt(), totalGlobalBolt) .shuffleGrouping("messageBoltLocal2_1") .addConfiguration("group-name", "Global1") .addConfiguration("TaskPerCloud", _boltGlobalParallel); builder .setBolt("messageBoltGlobal1_FG", new SOEBolt(), 2) .fieldsGrouping("messageBoltGlobal1_1A", new Fields("fieldValue")) .fieldsGrouping("messageBoltGlobal1_1B", new Fields("fieldValue")) .addConfiguration("group-name", "Global1") .addConfiguration("TaskPerCloud", _boltGlobalParallel); builder .setBolt("messageBoltGlobal1_GlobalResult", new SOEFinalBolt(), totalGlobalResultBolt) .shuffleGrouping("messageBoltGlobal1_FG") .addConfiguration("group-name", "Global1"); Config conf = new Config(); conf.setDebug(_debug); conf.setNumWorkers(_numWorkers); conf.setNumAckers(_ackers); conf.setStatsSampleRate(_sampleRate); if (_maxSpoutPending > 0) { conf.setMaxSpoutPending(_maxSpoutPending); } StormSubmitter.submitTopology(_name + "_" + topoNum, conf, builder.createTopology()); } metrics(client, _messageSize, _pollFreqSec, _testRunTimeSec); } finally { // Kill it right now!!! KillOptions killOpts = new KillOptions(); killOpts.set_wait_secs(0); for (int topoNum = 0; topoNum < _numTopologies; topoNum++) { LOG.info("KILLING " + _name + "_" + topoNum); try { client.killTopologyWithOpts(_name + "_" + topoNum, killOpts); } catch (Exception e) { LOG.error("Error trying to kill " + _name + "_" + topoNum, e); } } } }
public void realMain(String[] args) throws Exception { Map clusterConf = Utils.readStormConfig(); clusterConf.putAll(Utils.readCommandLineOpts()); Client client = NimbusClient.getConfiguredClient(clusterConf).getClient(); CmdLineParser parser = new CmdLineParser(this); parser.setUsageWidth(80); try { // parse the arguments. parser.parseArgument(args); } catch (CmdLineException e) { // if there's a problem in the command line, // you'll get this exception. this will report // an error message. System.err.println(e.getMessage()); _help = true; } if (_help) { parser.printUsage(System.err); System.err.println(); return; } if (_numWorkers <= 0) { throw new IllegalArgumentException("Need at least one worker"); } if (_name == null || _name.isEmpty()) { throw new IllegalArgumentException("name must be something"); } if (!_ackEnabled) { _ackers = 0; } try { int totalSpout = _spoutParallel * _localGroup; int totalLocalBolt = _boltLocalParallel * _localGroup; int totalLocalResultBolt = _localGroup; int totalGlobalBolt = _boltGlobalParallel; int totalGlobalResultBolt = 1; int _clusteringGroupSize = 4; double _clusteringErrorRate = 0.2; long _expireTime = 5000; TopologyBuilder builder = new TopologyBuilder(); builder .setSpout("KmeansSpout", new ClusteringSpout(_ackEnabled), totalSpout) .addConfiguration("group-name", "local1"); builder .setBolt( "ClusteringBoltLocal", new ClusteringBoltLocal( _clusteringGroupSize, _clusteringErrorRate, _expireTime, _ackEnabled), totalLocalBolt) .customGrouping("KmeansSpout", new ZoneShuffleGrouping()) .addConfiguration("group-name", "local1"); builder .setBolt("resultBoltLocal", new ResultBolt(_ackEnabled), totalLocalResultBolt) .customGrouping("ClusteringBoltLocal", new ZoneShuffleGrouping()) .addConfiguration("group-name", "local1"); builder .setBolt( "ClusteringBoltGlobal", new ClusteringBoltGlobal(_clusteringGroupSize, _clusteringErrorRate, -1, _ackEnabled), totalGlobalBolt) .customGrouping("ClusteringBoltLocal", new ZoneShuffleGrouping()) .addConfiguration("group-name", "global1"); builder .setBolt("resultBoltGlobal", new ResultBolt(_ackEnabled), totalGlobalResultBolt) .shuffleGrouping("ClusteringBoltGlobal") .addConfiguration("group-name", "global1"); Config conf = new Config(); conf.setDebug(_debug); conf.setNumWorkers(_numWorkers); conf.setNumAckers(_ackers); conf.setStatsSampleRate(_sampleRate); StormSubmitter.submitTopology(_name, conf, builder.createTopology()); metrics(client, _pollFreqSec, _testRunTimeSec); } finally { // Kill it right now!!! KillOptions killOpts = new KillOptions(); killOpts.set_wait_secs(0); LOG.info("KILLING " + _name); try { client.killTopologyWithOpts(_name, killOpts); } catch (Exception e) { LOG.error("Error tying to kill " + _name, e); } } }