backtype.storm.utils.Utils类的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(177)

本文整理了Java中backtype.storm.utils.Utils类的一些代码示例,展示了Utils类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils类的具体详情如下:
包路径:backtype.storm.utils.Utils
类名称:Utils

Utils介绍

暂无

代码示例

代码示例来源:origin: alibaba/jstorm

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

代码示例来源:origin: alibaba/jstorm

public Emitter(Map conf) {
  Object c = conf.get(Config.TOPOLOGY_MAX_SPOUT_PENDING);
  if (c == null)
    _maxSpoutPending = 1;
  else
    _maxSpoutPending = Utils.getInt(c);
}

代码示例来源:origin: alibaba/jstorm

public static Map read_storm_config() {
  return Utils.readStormConfig();
}

代码示例来源:origin: alibaba/mdrill

public static Map readStormConfig() {
  Map ret = readDefaultConfig();
  Map storm = findAndReadConfigFile("storm.yaml", false);
  ret.putAll(storm);
  return ret;
}

代码示例来源:origin: alibaba/mdrill

public static Map readStormConfig(String filename) {
  Map ret = readStormConfig();
  Map storm = findAndReadConfigFile(filename, false);
  ret.putAll(storm);
  return ret;
}

代码示例来源:origin: alibaba/jstorm

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

代码示例来源:origin: alibaba/jstorm

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

代码示例来源:origin: alibaba/jstorm

LocalCluster cluster = new LocalCluster();
cluster.submitTopology("wordCounter", conf, buildTopology(mapState, windowConfig));
Utils.sleep(60 * 1000);
cluster.shutdown();

代码示例来源:origin: kstyrc/trident-redis

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

  }
}

代码示例来源:origin: alibaba/mdrill

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

代码示例来源:origin: alibaba/jstorm

public void nextTuple() {
  if (_serveTuples.size() > 0) {
    FixedTuple ft = _serveTuples.remove(0);
    String id = UUID.randomUUID().toString();
    _pending.put(id, ft);
    _collector.emit(ft.stream, ft.values, id);
  } else {
    Utils.sleep(100);
  }
}

代码示例来源:origin: openimaj/openimaj

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

代码示例来源:origin: org.jwall/streams-storm

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

代码示例来源:origin: alibaba/jstorm

public void nextTuple() {
  Utils.sleep(100);
}

代码示例来源:origin: alibaba/jstorm

public List<Object> deserialize(byte[] ser) {
  return tuple(ser);
}

代码示例来源:origin: alibaba/jstorm

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

代码示例来源:origin: alibaba/jstorm

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

代码示例来源:origin: alibaba/mdrill

public static Map readDefaultConfig() {
  return findAndReadConfigFile("defaults.yaml", true);
}

代码示例来源:origin: com.n3twork.storm/storm-core

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

代码示例来源:origin: alibaba/jstorm

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

相关文章