org.apache.storm.Config.containsKey()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(4.4k)|赞(0)|评价(0)|浏览(107)

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

Config.containsKey介绍

暂无

代码示例

代码示例来源:origin: apache/storm

/**
   * A helper method to extract avro serialization configurations from the topology configuration and register
   * specific kryo serializers as necessary.  A default serializer will be provided if none is specified in the
   * configuration.  "avro.serializer" should specify the complete class name of the serializer, e.g.
   * "org.apache.stgorm.hdfs.avro.GenericAvroSerializer"
   *
   * @param conf The topology configuration
   * @throws ClassNotFoundException If the specified serializer cannot be located.
   */
  public static void addAvroKryoSerializations(Config conf) throws ClassNotFoundException {
    final Class serializerClass;
    if (conf.containsKey("avro.serializer")) {
      serializerClass = Class.forName((String) conf.get("avro.serializer"));
    } else {
      serializerClass = GenericAvroSerializer.class;
    }
    conf.registerSerialization(GenericData.Record.class, serializerClass);
    conf.setSkipMissingKryoRegistrations(false);
  }
}

代码示例来源:origin: apache/metron

return (int)c.get(Config.TOPOLOGY_WORKERS) == 100
  && (int)c.get(Config.TOPOLOGY_ACKER_EXECUTORS) == 200
  && !c.containsKey(Config.TOPOLOGY_DEBUG);

代码示例来源:origin: NationalSecurityAgency/lemongrenade

public void loadHandlers(String fileName, String field) throws Exception {
  Config conf = LGAdapter.readConfig(fileName);
  if(!conf.containsKey(field)) {
    throw new Exception("Config doesn't contain key:"+field);
  }
  JSONArray handlerDatas = new JSONArray(conf.get(field).toString());
  Iterator iterator = handlerDatas.iterator();
  while(iterator.hasNext()) {
    JSONObject handlerData = (JSONObject) iterator.next();
    String className = handlerData.getString("class");
    Class cls = Class.forName(className);
    Object handlerObject;
    if(handlerData.has("argument")) {
      Constructor<?> cons = cls.getConstructor(String.class);
      handlerObject = cons.newInstance(handlerData.getString("argument"));
    }
    else {
      Constructor<?> cons = cls.getConstructor();
      handlerObject = cons.newInstance();
    }
    Handler<T> tmp = (Handler) handlerObject;
    addHandler(tmp);
  }
}

代码示例来源:origin: NationalSecurityAgency/lemongrenade

public int getTaskCount() {
  try {
    if (getConfig().containsKey("adapter.tasks")) {
      Object hint = config.get("adapter.tasks");
      if (hint instanceof String) {
        return Integer.parseInt(hint.toString());
      }
      return (int) hint;
    }
  }
  catch(Exception e) {}
  return LGProperties.getInteger("adapter.tasks", getParallelismHint());//default to 1 to 1 with Executors if none are present
}//get the total number of tasks

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

/**
   * A helper method to extract avro serialization configurations from the topology configuration and register
   * specific kryo serializers as necessary.  A default serializer will be provided if none is specified in the
   * configuration.  "avro.serializer" should specify the complete class name of the serializer, e.g.
   * "org.apache.stgorm.hdfs.avro.GenericAvroSerializer"
   *
   * @param conf The topology configuration
   * @throws ClassNotFoundException If the specified serializer cannot be located.
   */
  public static void addAvroKryoSerializations(Config conf) throws ClassNotFoundException {
    final Class serializerClass;
    if (conf.containsKey("avro.serializer")) {
      serializerClass = Class.forName((String)conf.get("avro.serializer"));
    }
    else {
      serializerClass = GenericAvroSerializer.class;
    }
    conf.registerSerialization(GenericData.Record.class, serializerClass);
    conf.setSkipMissingKryoRegistrations(false);
  }
}

代码示例来源:origin: NationalSecurityAgency/lemongrenade

public int getParallelismHint() {
  try {
    if (getConfig().containsKey("adapter.threads")) {
      Object hint = config.get("adapter.threads");
      if (hint instanceof String) {
        return Integer.parseInt(hint.toString());
      }
      return (int) hint;
    }
  }
  catch(Exception e) {}
  try {
    Object hint = config.get("topology.parallelism");
    if(hint instanceof String) {
      return Integer.parseInt(hint.toString());
    }
    return (int)hint;
  }
  catch(Exception e) {}
  if(LGProperties.has("adapter.threads")) {
    return LGProperties.getInteger("adapter.threads", 6);
  }
  return LGProperties.getInteger("topology.parallelism", 6);//default to 6 if neither field is present
}

代码示例来源:origin: NationalSecurityAgency/lemongrenade

if (getConfig().containsKey("max_nodes_per_task")) {
  String str = getConfig().get("max_nodes_per_task").toString();
  try  {

相关文章