Refine search
@Override public void nextTuple() { Utils.sleep(100); String[] sentences = new String[] { "the cow jumped over the moon", "an apple a day keeps the doctor away", "four score and seven years ago", "snow white and the seven dwarfs", "i am at two with nature" }; String sentence = sentences[_rand.nextInt(sentences.length)]; _collector.emit(new Values(sentence)); }
public Emitter(Map conf) { Object c = conf.get(Config.TOPOLOGY_MAX_SPOUT_PENDING); if (c == null) _maxSpoutPending = 1; else _maxSpoutPending = Utils.getInt(c); }
public static Map read_storm_config() { return Utils.readStormConfig(); }
public static Map readStormConfig() { Map ret = readDefaultConfig(); Map storm = findAndReadConfigFile("storm.yaml", false); ret.putAll(storm); return ret; }
public static Map readStormConfig(String filename) { Map ret = readStormConfig(); Map storm = findAndReadConfigFile(filename, false); ret.putAll(storm); return ret; }
public static CuratorFramework newCurator(Map conf, List<String> servers, Object port, String root, ZookeeperAuthInfo auth) { List<String> serverPorts = new ArrayList<>(); for (String zkServer : servers) { serverPorts.add(zkServer + ":" + Utils.getInt(port)); } String zkStr = StringUtils.join(serverPorts, ",") + root; CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder(); setupBuilder(builder, zkStr, conf, auth); return builder.build(); }
@Override public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) { _rand = new Random(Utils.secureRandomLong()); _state = TransactionalState.newCoordinatorState(conf, (String) conf.get(Config.TOPOLOGY_TRANSACTIONAL_ID), _spout.getComponentConfiguration()); _coordinatorState = new RotatingTransactionalState(_state, META_DIR, true); _collector = collector; _coordinator = _spout.getCoordinator(conf, context); _currTransaction = getStoredCurrTransaction(_state); Object active = conf.get(Config.TOPOLOGY_MAX_SPOUT_PENDING); if (active == null) { _maxTransactionActive = 1; } else { _maxTransactionActive = Utils.getInt(active); } _initializer = new StateInitializer(); }
LocalCluster cluster = new LocalCluster(); cluster.submitTopology("wordCounter", conf, buildTopology(mapState, windowConfig)); Utils.sleep(60 * 1000); cluster.shutdown();
public static void main(String[] args) { StateFactory redis = RedisState.nonTransactional(new InetSocketAddress("localhost", 6379)); LocalDRPC drpc = new LocalDRPC(); StormTopology topology = buildTopology(drpc, redis); Config conf = new Config(); LocalCluster cluster = new LocalCluster(); cluster.submitTopology("tester", conf, topology); try { for (int i = 0; i < 100; i++) { System.out.println("DRPC: " + drpc.execute("words", "cat the man four")); Utils.sleep(1000); } } catch (JedisConnectionException e) { throw new RuntimeException("Unfortunately, this test requires redis-server runing on localhost:6379", e); } } }
returnInfo.put("port", client.getPort()); gotRequest = true; _collector.emit(new Values(req.get_func_args(), JSONValue.toJSONString(returnInfo)), new DRPCMessageId(req.get_request_id(), i)); break; returnInfo.put("port", 0); gotRequest = true; _collector.emit(new Values(req.get_func_args(), JSONValue.toJSONString(returnInfo)), new DRPCMessageId(req.get_request_id(), 0)); Utils.sleep(1);
@Override public void finish(StormToolOptions options) throws Exception { try { if (sleepTime < 0) { logger.debug("Waiting forever"); while (true) { Utils.sleep(DEFAULT_SLEEP_TIME); } } else { logger.debug("Waiting " + sleepTime + " milliseconds"); Utils.sleep(sleepTime); } } finally { logger.debug("Killing topology"); cluster.killTopology(options.topologyName()); logger.debug("Shutting down cluster"); cluster.shutdown(); options.topologyCleanup(); } }
log.info("submitting topology..."); String topId = System.getProperty("id", UUID.randomUUID().toString()); cluster.submitTopology(topId, conf, storm); log.info("########################################################################"); Utils.sleep(time); cluster.killTopology(topId);
public void nextTuple() { Utils.sleep(100); }
public List<Object> deserialize(byte[] ser) { return tuple(ser); }
@Deprecated public static Map getFullConf(Map conf) { Map realConf = new HashMap(); boolean isLocal = StormConfig.try_local_mode(conf); if (isLocal) { realConf.putAll(LocalCluster.getInstance().getLocalClusterMap().getConf()); } else { realConf.putAll(Utils.readStormConfig()); } realConf.putAll(conf); return realConf; }
@SuppressWarnings("unchecked") public Iterable<List<Object>> generateTuples(Message msg) { Iterable<List<Object>> tups = null; ByteBuffer payload = msg.payload(); if (payload == null) { return null; } tups = Arrays.asList(Utils.tuple(Utils.toByteArray(payload))); return tups; }
public static Map readDefaultConfig() { return findAndReadConfigFile("defaults.yaml", true); }
public static Map readStormConfig() { Map ret = readDefaultConfig(); String confFile = System.getProperty("storm.conf.file"); Map storm; if (confFile==null || confFile.equals("")) { storm = findAndReadConfigFile("storm.yaml", false); } else { storm = findAndReadConfigFile(confFile, true); } ret.putAll(storm); ret.putAll(readCommandLineOpts()); return ret; }
public int maxTopologyMessageTimeout() { Integer max = Utils.getInt(_stormConf.get(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS)); for (String spout : getRawTopology().get_spouts().keySet()) { ComponentCommon common = getComponentCommon(spout); String jsonConf = common.get_json_conf(); if (jsonConf != null) { Map conf = (Map) Utils.from_json(jsonConf); Object comp = conf.get(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS); if (comp != null) { max = Math.max(Utils.getInt(comp), max); } } } return max; }