本文整理汇总了Java中org.apache.storm.utils.Utils.get方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.get方法的具体用法?Java Utils.get怎么用?Java Utils.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.storm.utils.Utils
的用法示例。
在下文中一共展示了Utils.get方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTopology
import org.apache.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public StormTopology getTopology(Config config) {
final int spoutNum = BenchmarkUtils.getInt(config, SPOUT_NUM, DEFAULT_SPOUT_NUM);
final int matBoltNum = BenchmarkUtils.getInt(config, FM_NUM, DEFAULT_MAT_BOLT_NUM);
final int cntBoltNum = BenchmarkUtils.getInt(config, CM_NUM, DEFAULT_CNT_BOLT_NUM);
final String ptnString = (String) Utils.get(config, PATTERN_STRING, DEFAULT_PATTERN_STR);
spout = new KafkaSpout(KafkaUtils.getSpoutConfig(config, new SchemeAsMultiScheme(new StringScheme())));
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout(SPOUT_ID, spout, spoutNum);
builder.setBolt(FM_ID, new FindMatchingSentence(ptnString), matBoltNum)
.localOrShuffleGrouping(SPOUT_ID);
builder.setBolt(CM_ID, new CountMatchingSentence(), cntBoltNum)
.fieldsGrouping(FM_ID, new Fields(FindMatchingSentence.FIELDS));
return builder.createTopology();
}
示例2: MetricsCollectorConfig
import org.apache.storm.utils.Utils; //导入方法依赖的package包/类
public MetricsCollectorConfig(Config stormConfig) {
this.stormConfig = stormConfig;
name = (String) Utils.get(
stormConfig, Config.TOPOLOGY_NAME, StormBenchmark.DEFAULT_TOPOLOGY_NAME);
pollInterval = BenchmarkUtils.getInt(
stormConfig, METRICS_POLL_INTERVAL, DEFAULT_POLL_INTERVAL);
totalTime = BenchmarkUtils.getInt(
stormConfig, METRICS_TOTAL_TIME, DEFAULT_TOTAL_TIME);
path = (String) Utils.get(stormConfig, METRICS_PATH, DEFAULT_PATH);
}
示例3: getKafkaConfig
import org.apache.storm.utils.Utils; //导入方法依赖的package包/类
private Map getKafkaConfig(Map options) {
Map kafkaConfig = new HashMap();
Map brokerConfig = new HashMap();
String brokers = (String) Utils.get(options, BROKER_LIST, "localhost:9092");
String topic = (String) Utils.get(options, TOPIC, KafkaUtils.DEFAULT_TOPIC);
brokerConfig.put("metadata.broker.list", brokers);
brokerConfig.put("serializer.class", "kafka.serializer.StringEncoder");
brokerConfig.put("key.serializer.class", "kafka.serializer.StringEncoder");
brokerConfig.put("request.required.acks", "1");
//kafkaConfig.put(KafkaBolt.KAFKA_BROKER_PROPERTIES, brokerConfig);
kafkaConfig.put(KafkaBolt.TOPIC, topic);
return kafkaConfig;
}
示例4: getSpoutConfig
import org.apache.storm.utils.Utils; //导入方法依赖的package包/类
public static SpoutConfig getSpoutConfig(Map options, MultiScheme scheme) throws IllegalArgumentException {
String zkServers = (String) Utils.get(options, ZOOKEEPER_SERVERS, "localhost:2181");
String kafkaRoot = (String) Utils.get(options, KAFKA_ROOT_PATH, "/kafka");
String connectString = zkServers + kafkaRoot;
BrokerHosts hosts = new ZkHosts(connectString);
String topic = (String) Utils.get(options, TOPIC, DEFAULT_TOPIC);
String appId = (String) Utils.get(options, CLIENT_ID, "storm-app");
SpoutConfig config = new SpoutConfig(hosts, topic, kafkaRoot, appId);
//config.forceFromStart = true;
config.zkServers = new ArrayList<String>();
String [] servers = zkServers.split(",");
for (int i = 0; i < servers.length; i++) {
String[] serverAndPort = servers[0].split(":");
config.zkServers.add(serverAndPort[0]);
int port = Integer.parseInt(serverAndPort[1]);
if (i == 0) {
config.zkPort = port;
}
if (config.zkPort != port) {
throw new IllegalArgumentException("The zookeeper port on all server must be same");
}
}
config.scheme = scheme;
return config;
}
示例5: getTridentKafkaConfig
import org.apache.storm.utils.Utils; //导入方法依赖的package包/类
public static TridentKafkaConfig getTridentKafkaConfig(Map options, MultiScheme scheme) {
String zkServers = (String) Utils.get(options, ZOOKEEPER_SERVERS, "localhost:2181") ;
String kafkaRoot = (String) Utils.get(options, KAFKA_ROOT_PATH, "/kafka");
String connectString = zkServers + kafkaRoot;
BrokerHosts hosts = new ZkHosts(connectString);
String topic = (String) Utils.get(options, TOPIC, DEFAULT_TOPIC);
String appId = (String) Utils.get(options, CLIENT_ID, "storm-app");
TridentKafkaConfig config = new TridentKafkaConfig(hosts, topic, appId);
config.scheme = scheme;
return config;
}
示例6: getFloat
import org.apache.storm.utils.Utils; //导入方法依赖的package包/类
public static float getFloat(Map<String, Object> conf, String key,
float defaultValue) {
Object obj = Utils.get(conf, key, defaultValue);
if (obj instanceof Double)
return ((Double) obj).floatValue();
return (Float) obj;
}
示例7: getInt
import org.apache.storm.utils.Utils; //导入方法依赖的package包/类
public static int getInt(Map<String, Object> conf, String key,
int defaultValue) {
Object obj = Utils.get(conf, key, defaultValue);
return Utils.getInt(obj);
}
示例8: getLong
import org.apache.storm.utils.Utils; //导入方法依赖的package包/类
public static long getLong(Map<String, Object> conf, String key,
long defaultValue) {
return (Long) Utils.get(conf, key, defaultValue);
}
示例9: getBoolean
import org.apache.storm.utils.Utils; //导入方法依赖的package包/类
public static boolean getBoolean(Map<String, Object> conf, String key,
boolean defaultValue) {
Object obj = Utils.get(conf, key, defaultValue);
return Utils.getBoolean(obj, defaultValue);
}
示例10: getString
import org.apache.storm.utils.Utils; //导入方法依赖的package包/类
public static String getString(Map<String, Object> conf, String key) {
return (String) Utils.get(conf, key, null);
}