backtype.storm.spout.MultiScheme Java Examples

The following examples show how to use backtype.storm.spout.MultiScheme. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CorrelationSpout.java    From eagle with Apache License 2.0 5 votes vote down vote up
private MultiScheme createMultiScheme(Map conf, String topic, String schemeClsName) throws Exception {
    Object scheme = SchemeBuilder.buildFromClsName(schemeClsName, topic, conf);
    if (scheme instanceof MultiScheme) {
        return (MultiScheme) scheme;
    } else if (scheme instanceof Scheme) {
        return new SchemeAsMultiScheme((Scheme) scheme);
    } else {
        LOG.error("create spout scheme failed.");
        throw new IllegalArgumentException("create spout scheme failed.");
    }
}
 
Example #2
Source File: KafkaUtils.java    From storm-benchmark with Apache License 2.0 5 votes vote down vote up
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 zkRoot = kafkaRoot + "/" + "storm-consumer-states";
  String appId = (String) Utils.get(options, CLIENT_ID, "storm-app");

  SpoutConfig config = new SpoutConfig(hosts, topic, zkRoot, appId);
  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;
}
 
Example #3
Source File: KafkaUtils.java    From storm-benchmark with Apache License 2.0 5 votes vote down vote up
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;
}