backtype.storm.utils.Utils.getInt()方法的使用及代码示例

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

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

Utils.getInt介绍

暂无

代码示例

代码示例来源: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 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 Integer getInt(Object o) {
  Integer result = getInt(o, null);
  if (null == result) {
    throw new IllegalArgumentException("Don't know how to convert null to int");
  }
  return result;
}

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

public int getMaxBufferSize(Map conf) {
    return Utils.getInt(conf.get(_buffConf));
  }
}

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

public int getNumThreads(Map conf) {
  return Utils.getInt(conf.get(_threadsConf));
}

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

public int getPort(Map conf) {
  return Utils.getInt(conf.get(_portConf));
}

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

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

protected static void setupBuilder(CuratorFrameworkFactory.Builder builder, String zkStr, Map conf, ZookeeperAuthInfo auth) {
  builder.connectString(zkStr)
      .connectionTimeoutMs(Utils.getInt(conf.get(Config.STORM_ZOOKEEPER_CONNECTION_TIMEOUT)))
      .sessionTimeoutMs(Utils.getInt(conf.get(Config.STORM_ZOOKEEPER_SESSION_TIMEOUT)))
      .retryPolicy(
          new StormBoundedExponentialBackoffRetry(Utils.getInt(conf.get(Config.STORM_ZOOKEEPER_RETRY_INTERVAL)), Utils.getInt(conf
              .get(Config.STORM_ZOOKEEPER_RETRY_INTERVAL_CEILING)), Utils.getInt(conf.get(Config.STORM_ZOOKEEPER_RETRY_TIMES))));
  if (auth != null && auth.scheme != null && auth.payload != null) {
    builder = builder.authorization(auth.scheme, auth.payload);
  }
}

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

/**
 * Invoked once immediately after construction
 * 
 * @param storm_conf Storm configuration
 */
@Override
public void prepare(Map storm_conf) {
  int timeout = Utils.getInt(storm_conf.get(Config.STORM_GROUP_MAPPING_SERVICE_CACHE_DURATION_SECS));
  cachedGroups = new TimeCacheMap<String, Set<String>>(timeout);
}

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

private CuratorFramework newCurator(Map conf, KafkaSpoutConfig config) throws Exception {
  String serverPorts = "";
  List<Host> zkServers = config.zkServers;
  for (Host server : zkServers) {
    serverPorts = serverPorts + server.getHost() + ":" + server.getPort() + ",";
  }
  return CuratorFrameworkFactory.newClient(serverPorts, Utils.getInt(conf.get(Config.STORM_ZOOKEEPER_SESSION_TIMEOUT)), 15000, new RetryNTimes(
      Utils.getInt(conf.get(Config.STORM_ZOOKEEPER_RETRY_TIMES)), Utils.getInt(conf.get(Config.STORM_ZOOKEEPER_RETRY_INTERVAL))));
}

代码示例来源: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/mdrill

public static NimbusClient getConfiguredClient(Map conf) {
  String nimbusHost = (String) conf.get(Config.NIMBUS_HOST);
  int nimbusPort = Utils.getInt(conf.get(Config.NIMBUS_THRIFT_PORT));
  return new NimbusClient(nimbusHost, nimbusPort);
}

代码示例来源: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;
}

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

protected List<AsyncLoopThread> setDeserializeThreads() {
  WorkerTopologyContext workerTopologyContext = contextMaker.makeWorkerTopologyContext(sysTopology);
  int tasksNum = shutdownTasks.size();
  double workerRatio = ConfigExtension.getWorkerDeserializeThreadRatio(stormConf);
  int workerDeserThreadNum = Utils.getInt(Math.ceil(workerRatio * tasksNum));
  if (workerDeserThreadNum > 0 && tasksNum > 0) {
    double average = tasksNum / (double) workerDeserThreadNum;
    for (int i = 0; i < workerDeserThreadNum; i++) {
      int startRunTaskIndex = Utils.getInt(Math.rint(average * i));
      deserializeThreads.add(new AsyncLoopThread(new WorkerDeserializeRunnable(
          shutdownTasks, stormConf, workerTopologyContext, startRunTaskIndex, i)));
    }
  }
  return deserializeThreads;
}

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

protected List<AsyncLoopThread> setSerializeThreads() {
  WorkerTopologyContext workerTopologyContext = contextMaker.makeWorkerTopologyContext(sysTopology);
  int tasksNum = shutdownTasks.size();
  double workerRatio = ConfigExtension.getWorkerSerializeThreadRatio(stormConf);
  int workerSerialThreadNum = Utils.getInt(Math.ceil(workerRatio * tasksNum));
  if (workerSerialThreadNum > 0 && tasksNum > 0) {
    double average = tasksNum / (double) workerSerialThreadNum;
    for (int i = 0; i < workerSerialThreadNum; i++) {
      int startRunTaskIndex = Utils.getInt(Math.rint(average * i));
      serializeThreads.add(new AsyncLoopThread(new WorkerSerializeRunnable(
          shutdownTasks, stormConf, workerTopologyContext, startRunTaskIndex, i)));
    }
  }
  return serializeThreads;
}

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

public int maxTopologyMessageTimeout(Map<String, Object> topologyConfig) {
    Integer max = Utils.getInt(topologyConfig.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) JSONValue.parse(jsonConf);
        Object comp = conf.get(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS);
        if(comp!=null) {
          max = Math.max(Utils.getInt(comp), max);
        }
      }
    }
    return max;
  }
}

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

@SuppressWarnings("rawtypes")
NettyClientAsync(Map conf, ChannelFactory factory, String host, int port, ReconnectRunnable reconnector, final Set<Integer> sourceTasks, final Set<Integer> targetTasks) {
  super(conf, factory, host, port, reconnector);
  clientChannelFactory = factory;
  initFlowCtrl(conf, sourceTasks, targetTasks);
  
  flushCheckInterval = Utils.getInt(conf.get(Config.STORM_NETTY_FLUSH_CHECK_INTERVAL_MS), 5);
  flusher = new NettyClientFlush(flushCheckInterval);
  flusher.start();
  start();
}

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

/**
 * initialization per Storm configuration
 */
@SuppressWarnings("rawtypes")
public void prepare(Map stormConf) {
  this.stormConf = stormConf;
  int maxWorkers = Utils.getInt(stormConf.get(Config.STORM_MESSAGING_NETTY_CLIENT_WORKER_THREADS));
  ThreadFactory bossFactory = new NettyRenameThreadFactory(MetricDef.NETTY_CLI + "boss");
  ThreadFactory workerFactory = new NettyRenameThreadFactory(MetricDef.NETTY_CLI + "worker");
  if (maxWorkers > 0) {
    clientChannelFactory = new NioClientSocketChannelFactory(Executors.newCachedThreadPool(bossFactory),
        Executors.newCachedThreadPool(workerFactory), maxWorkers);
  } else {
    clientChannelFactory = new NioClientSocketChannelFactory(Executors.newCachedThreadPool(bossFactory),
        Executors.newCachedThreadPool(workerFactory));
  }
  reconnector = new ReconnectRunnable();
  new AsyncLoopThread(reconnector, true, Thread.MIN_PRIORITY, true);
}

代码示例来源: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/mdrill

@Override
public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) {
  _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();
}

相关文章