当前位置: 首页>>代码示例>>Java>>正文


Java Utils.findAndReadConfigFile方法代码示例

本文整理汇总了Java中backtype.storm.utils.Utils.findAndReadConfigFile方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.findAndReadConfigFile方法的具体用法?Java Utils.findAndReadConfigFile怎么用?Java Utils.findAndReadConfigFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在backtype.storm.utils.Utils的用法示例。


在下文中一共展示了Utils.findAndReadConfigFile方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readAclFromConfig

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
protected Map<String, AclFunctionEntry> readAclFromConfig() {
    // Thread safety is mostly around _acl. If _acl needs to be updated it is changed atomically
    // More then one thread may be trying to update it at a time, but that is OK, because the
    // change is atomic
    long now = System.currentTimeMillis();
    if ((now - 5000) > _lastUpdate || _acl == null) {
        Map<String, AclFunctionEntry> acl = new HashMap<String, AclFunctionEntry>();
        Map conf = Utils.findAndReadConfigFile(_aclFileName);
        if (conf.containsKey(Config.DRPC_AUTHORIZER_ACL)) {
            Map<String, Map<String, ?>> confAcl = (Map<String, Map<String, ?>>) conf.get(Config.DRPC_AUTHORIZER_ACL);

            for (String function : confAcl.keySet()) {
                Map<String, ?> val = confAcl.get(function);
                Collection<String> clientUsers = val.containsKey(CLIENT_USERS_KEY) ? (Collection<String>) val.get(CLIENT_USERS_KEY) : null;
                String invocationUser = val.containsKey(INVOCATION_USER_KEY) ? (String) val.get(INVOCATION_USER_KEY) : null;
                acl.put(function, new AclFunctionEntry(clientUsers, invocationUser));
            }
        } else if (!_permitWhenMissingFunctionEntry) {
            LOG.warn("Requiring explicit ACL entries, but none given. " + "Therefore, all operiations will be denied.");
        }
        _acl = acl;
        _lastUpdate = System.currentTimeMillis();
    }
    return _acl;
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:26,代码来源:DRPCSimpleACLAuthorizer.java

示例2: getUserConf

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
private Map<String, Number> getUserConf() {
    Map<String, Number> ret = (Map<String, Number>) _conf.get(Config.MULTITENANT_SCHEDULER_USER_POOLS);
    if (ret == null) {
        ret = new HashMap<String, Number>();
    } else {
        ret = new HashMap<String, Number>(ret);
    }

    Map fromFile = Utils.findAndReadConfigFile("multitenant-scheduler.yaml", false);
    Map<String, Number> tmp = (Map<String, Number>) fromFile.get(Config.MULTITENANT_SCHEDULER_USER_POOLS);
    if (tmp != null) {
        ret.putAll(tmp);
    }
    return ret;
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:16,代码来源:MultitenantScheduler.java

示例3: read_yaml_config

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
public static Map read_yaml_config(String name) {
	return Utils.findAndReadConfigFile(name, true);
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:4,代码来源:StormConfig.java

示例4: readJStormConfig

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
    static Map readJStormConfig(String jstormYarnConfigPath) {
        //default configurations
        Map ret = Utils.readDefaultConfig();
        Map conf = Utils.findAndReadConfigFile(Config.MASTER_DEFAULTS_CONFIG);
        ret.putAll(conf);
        System.out.println("default ret:" + ret);
        
        //standard storm configuration
        String confFile = System.getProperty("jstorm.conf.file");
//        String confFile = Util.getJStormHome() + "/conf/storm.yaml";
        Map storm_conf;
        if (confFile==null || confFile.equals("")) {
            storm_conf = Utils.findAndReadConfigFile("storm.yaml", false);
        } else {
            storm_conf = Utils.findAndReadConfigFile(confFile, true);
        }
        System.out.println("storm_conf:" + storm_conf);
        ret.putAll(storm_conf);
        
        //configuration file per command parameter 
        if (jstormYarnConfigPath == null) {
            Map master_conf = Utils.findAndReadConfigFile(Config.MASTER_CONFIG, false);
            ret.putAll(master_conf);
        }
        else {
            try {
                Yaml yaml = new Yaml();
                FileInputStream is = new FileInputStream(jstormYarnConfigPath);
                Map storm_yarn_config = (Map) yaml.load(is);
                if(storm_yarn_config!=null)
                    ret.putAll(storm_yarn_config);
                is.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        //other configuration settings via CLS opts per system property: storm.options
        ret.putAll(Utils.readCommandLineOpts());

        return ret;
    }
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:44,代码来源:Config.java

示例5: main

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    TopologyBuilder builder = new TopologyBuilder();

    Options opts = new Options();
    opts.addOption("conf", true, "Path to the config file.");

    CommandLineParser parser = new DefaultParser();
    CommandLine cmd = parser.parse(opts, args);
    String configPath = cmd.getOptionValue("conf");
    Map commonConfig = Utils.findAndReadConfigFile(configPath, true);

    String zkServerHosts = joinHosts((List<String>)commonConfig.get("zookeeper.servers"),
                                     Integer.toString((Integer)commonConfig.get("zookeeper.port")));
    String redisServerHost = (String)commonConfig.get("redis.host");
    String kafkaTopic = (String)commonConfig.get("kafka.topic");
    int kafkaPartitions = ((Number)commonConfig.get("kafka.partitions")).intValue();
    int workers = ((Number)commonConfig.get("storm.workers")).intValue();
    int ackers = ((Number)commonConfig.get("storm.ackers")).intValue();
    int cores = ((Number)commonConfig.get("process.cores")).intValue();
    int parallel = Math.max(1, cores/7);

    ZkHosts hosts = new ZkHosts(zkServerHosts);



    SpoutConfig spoutConfig = new SpoutConfig(hosts, kafkaTopic, "/" + kafkaTopic, UUID.randomUUID().toString());
    spoutConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
    KafkaSpout kafkaSpout = new KafkaSpout(spoutConfig);

    builder.setSpout("ads", kafkaSpout, kafkaPartitions);
    builder.setBolt("event_deserializer", new DeserializeBolt(), parallel).shuffleGrouping("ads");
    builder.setBolt("event_filter", new EventFilterBolt(), parallel).shuffleGrouping("event_deserializer");
    builder.setBolt("event_projection", new EventProjectionBolt(), parallel).shuffleGrouping("event_filter");
    builder.setBolt("redis_join", new RedisJoinBolt(redisServerHost), parallel).shuffleGrouping("event_projection");
    builder.setBolt("campaign_processor", new CampaignProcessor(redisServerHost), parallel*2)
        .fieldsGrouping("redis_join", new Fields("campaign_id"));

    Config conf = new Config();

    if (args != null && args.length > 0) {
        conf.setNumWorkers(workers);
        conf.setNumAckers(ackers);
        StormSubmitter.submitTopologyWithProgressBar(args[0], conf, builder.createTopology());
    }
    else {

        LocalCluster cluster = new LocalCluster();
        cluster.submitTopology("test", conf, builder.createTopology());
        backtype.storm.utils.Utils.sleep(10000);
        cluster.killTopology("test");
        cluster.shutdown();
    }
}
 
开发者ID:yahoo,项目名称:streaming-benchmarks,代码行数:54,代码来源:AdvertisingTopology.java

示例6: read_yaml_config

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
public static Map read_yaml_config(String name) {
    return Utils.findAndReadConfigFile(name, true);
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:4,代码来源:StormConfig.java


注:本文中的backtype.storm.utils.Utils.findAndReadConfigFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。