org.apache.storm.utils.Utils.getBoolean()方法的使用及代码示例

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

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

Utils.getBoolean介绍

暂无

代码示例

代码示例来源:origin: org.apache.storm/storm-core

/**
 * Given the blob information returns the value of the uncompress field, handling it either being a string or a boolean value, or if it's not specified then
 * returns false
 * 
 * @param blobInfo
 * @return
 */
public static Boolean shouldUncompressBlob(Map<String, Object> blobInfo) {
  return Utils.getBoolean(blobInfo.get("uncompress"), false);
}

代码示例来源:origin: org.apache.storm/storm-core

public AdvancedWindowsFSOps(Map<String, Object> conf) {
  super(conf);
  if (Utils.getBoolean(conf.get(Config.SUPERVISOR_RUN_WORKER_AS_USER), false)) {
    throw new RuntimeException("ERROR: Windows doesn't support running workers as different users yet");
  }
}

代码示例来源:origin: DigitalPebble/storm-crawler

public static boolean getBoolean(Map<String, Object> conf, String key,
    boolean defaultValue) {
  Object obj = Utils.get(conf, key, defaultValue);
  return Utils.getBoolean(obj, defaultValue);
}

代码示例来源:origin: org.apache.storm/storm-core

public static void setupStormCodeDir(Map<String, Object> conf, String user, String dir) throws IOException {
  if (Utils.getBoolean(conf.get(Config.SUPERVISOR_RUN_WORKER_AS_USER), false)) {
    String logPrefix = "Storm Code Dir Setup for " + dir;
    List<String> commands = new ArrayList<>();
    commands.add("code-dir");
    commands.add(dir);
    processLauncherAndWait(conf, user, commands, null, logPrefix);
  }
}

代码示例来源:origin: org.apache.storm/storm-core

private List<String> getWorkerProfilerChildOpts(int memOnheap) {
  List<String> workerProfilerChildopts = new ArrayList<>();
  if (Utils.getBoolean(_conf.get(Config.WORKER_PROFILER_ENABLED), false)) {
    workerProfilerChildopts = substituteChildopts(_conf.get(Config.WORKER_PROFILER_CHILDOPTS), memOnheap);
  }
  return workerProfilerChildopts;
}

代码示例来源:origin: org.apache.storm/storm-core

public static void setupWorkerArtifactsDir(Map<String, Object> conf, String user, String dir) throws IOException {
  if (Utils.getBoolean(conf.get(Config.SUPERVISOR_RUN_WORKER_AS_USER), false)) {
    String logPrefix = "Worker Artifacts Setup for " + dir;
    List<String> commands = new ArrayList<>();
    commands.add("artifacts-dir");
    commands.add(dir);
    processLauncherAndWait(conf, user, commands, null, logPrefix);
  }
}

代码示例来源:origin: org.apache.storm/storm-core

public FileBlobStoreImpl(File path, Map<String, Object> conf) throws IOException {
  LOG.info("Creating new blob store based in {}", path);
  fullPath = path;
  fullPath.mkdirs();
  Object shouldCleanup = conf.get(Config.BLOBSTORE_CLEANUP_ENABLE);
  if (Utils.getBoolean(shouldCleanup, false)) {
    LOG.debug("Starting File blobstore cleaner");
    cleanup = new TimerTask() {
      @Override
      public void run() {
        try {
          fullCleanup(FULL_CLEANUP_FREQ);
        } catch (IOException e) {
          LOG.error("Error trying to cleanup", e);
        }
      }
    };
    timer.scheduleAtFixedRate(cleanup, 0, FULL_CLEANUP_FREQ);
  }
}

代码示例来源:origin: org.apache.storm/storm-hdfs

public HdfsBlobStoreImpl(Path path, Map<String, Object> conf,
             Configuration hconf) throws IOException {
  LOG.info("Blob store based in {}", path);
  _fullPath = path;
  _hadoopConf = hconf;
  _fs = path.getFileSystem(_hadoopConf);
  if (!_fs.exists(_fullPath)) {
    FsPermission perms = new FsPermission(BLOBSTORE_DIR_PERMISSION);
    boolean success = _fs.mkdirs(_fullPath, perms);
    if (!success) {
      throw new IOException("Error creating blobstore directory: " + _fullPath);
    }
  }
  Object shouldCleanup = conf.get(Config.BLOBSTORE_CLEANUP_ENABLE);
  if (Utils.getBoolean(shouldCleanup, false)) {
    LOG.debug("Starting hdfs blobstore cleaner");
    TimerTask cleanup = new TimerTask() {
      @Override
      public void run() {
        try {
          fullCleanup(FULL_CLEANUP_FREQ);
        } catch (IOException e) {
          LOG.error("Error trying to cleanup", e);
        }
      }
    };
    timer = new Timer("HdfsBlobStore cleanup thread", true);
    timer.scheduleAtFixedRate(cleanup, 0, FULL_CLEANUP_FREQ);
  }
}

代码示例来源:origin: org.apache.storm/storm-kafka

public DynamicBrokersReader(Map conf, String zkStr, String zkPath, String topic) {
  // Check required parameters
  Preconditions.checkNotNull(conf, "conf cannot be null");
  validateConfig(conf);
  Preconditions.checkNotNull(zkStr,"zkString cannot be null");
  Preconditions.checkNotNull(zkPath, "zkPath cannot be null");
  Preconditions.checkNotNull(topic, "topic cannot be null");
  _zkPath = zkPath;
  _topic = topic;
  _isWildcardTopic = Utils.getBoolean(conf.get("kafka.topic.wildcard.match"), false);
  try {
    _curator = CuratorFrameworkFactory.newClient(
        zkStr,
        Utils.getInt(conf.get(Config.STORM_ZOOKEEPER_SESSION_TIMEOUT)),
        Utils.getInt(conf.get(Config.STORM_ZOOKEEPER_CONNECTION_TIMEOUT)),
        new RetryNTimes(Utils.getInt(conf.get(Config.STORM_ZOOKEEPER_RETRY_TIMES)),
            Utils.getInt(conf.get(Config.STORM_ZOOKEEPER_RETRY_INTERVAL))));
    _curator.start();
  } catch (Exception ex) {
    LOG.error("Couldn't connect to zookeeper", ex);
    throw new RuntimeException(ex);
  }
}

代码示例来源:origin: org.apache.storm/storm-core

public void setBlobPermissions(Map conf, String user, String path)
  throws IOException {
 if (!Utils.getBoolean(conf.get(Config.SUPERVISOR_RUN_WORKER_AS_USER), false)) {
  return;
 }
 String wlCommand = Utils.getString(conf.get(Config.SUPERVISOR_WORKER_LAUNCHER), "");
 if (wlCommand.isEmpty()) {
  String stormHome = System.getProperty("storm.home");
  wlCommand = stormHome + "/bin/worker-launcher";
 }
 List<String> command = new ArrayList<String>(Arrays.asList(wlCommand, user, "blob", path));
 String[] commandArray = command.toArray(new String[command.size()]);
 ShellCommandExecutor shExec = new ShellCommandExecutor(commandArray);
 LOG.info("Setting blob permissions, command: {}", Arrays.toString(commandArray));
 try {
  shExec.execute();
  LOG.debug("output: {}", shExec.getOutput());
 } catch (ExitCodeException e) {
  int exitCode = shExec.getExitCode();
  LOG.warn("Exit code from worker-launcher is : " + exitCode, e);
  LOG.debug("output: {}", shExec.getOutput());
  throw new IOException("Setting blob permissions failed" +
    " (exitCode=" + exitCode + ") with output: " + shExec.getOutput(), e);
 }
}

代码示例来源:origin: org.apache.storm/storm-core

/**
 * Factory to create a new AdvancedFSOps
 * @param conf the configuration of the process
 * @return the appropriate instance of the class for this config and environment.
 */
public static AdvancedFSOps make(Map<String, Object> conf) {
  if (Utils.isOnWindows()) {
    return new AdvancedWindowsFSOps(conf);
  }
  if (Utils.getBoolean(conf.get(Config.SUPERVISOR_RUN_WORKER_AS_USER), false)) {
    return new AdvancedRunAsUserFSOps(conf);
  }
  return new AdvancedFSOps(conf);
}

代码示例来源:origin: org.apache.storm/storm-core

/**
 * Factory to create the right container launcher 
 * for the config and the environment.
 * @param conf the config
 * @param supervisorId the ID of the supervisor
 * @param sharedContext Used in local mode to let workers talk together without netty
 * @return the proper container launcher
 * @throws IOException on any error
 */
public static ContainerLauncher make(Map<String, Object> conf, String supervisorId, IContext sharedContext) throws IOException {
  if (ConfigUtils.isLocalMode(conf)) {
    return new LocalContainerLauncher(conf, supervisorId, sharedContext);
  }
  
  if (Utils.getBoolean(conf.get(Config.SUPERVISOR_RUN_WORKER_AS_USER), false)) {
    return new RunAsUserContainerLauncher(conf, supervisorId);
  }
  return new BasicContainerLauncher(conf, supervisorId);
}

代码示例来源:origin: org.apache.storm/storm-core

@SuppressWarnings("rawtypes")
Client(Map stormConf, ChannelFactory factory, HashedWheelTimer scheduler, String host, int port, Context context) {
  this.stormConf = stormConf;
  closing = false;
  this.scheduler = scheduler;
  this.context = context;
  int bufferSize = Utils.getInt(stormConf.get(Config.STORM_MESSAGING_NETTY_BUFFER_SIZE));
  // if SASL authentication is disabled, saslChannelReady is initialized as true; otherwise false
  saslChannelReady.set(!Utils.getBoolean(stormConf.get(Config.STORM_MESSAGING_NETTY_AUTHENTICATION), false));
  LOG.info("creating Netty Client, connecting to {}:{}, bufferSize: {}", host, port, bufferSize);
  int messageBatchSize = Utils.getInt(stormConf.get(Config.STORM_NETTY_MESSAGE_BATCH_SIZE), 262144);
  int maxReconnectionAttempts = Utils.getInt(stormConf.get(Config.STORM_MESSAGING_NETTY_MAX_RETRIES));
  int minWaitMs = Utils.getInt(stormConf.get(Config.STORM_MESSAGING_NETTY_MIN_SLEEP_MS));
  int maxWaitMs = Utils.getInt(stormConf.get(Config.STORM_MESSAGING_NETTY_MAX_SLEEP_MS));
  retryPolicy = new StormBoundedExponentialBackoffRetry(minWaitMs, maxWaitMs, maxReconnectionAttempts);
  // Initiate connection to remote destination
  bootstrap = createClientBootstrap(factory, bufferSize, stormConf);
  dstHost = host;
  dstAddress = new InetSocketAddress(host, port);
  dstAddressPrefixedName = prefixedName(dstAddress);
  launchChannelAliveThread();
  scheduleConnect(NO_DELAY_MS);
  batcher = new MessageBuffer(messageBatchSize);
}

相关文章

Utils类方法