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


Java Config类代码示例

本文整理汇总了Java中org.apache.storm.Config的典型用法代码示例。如果您正苦于以下问题:Java Config类的具体用法?Java Config怎么用?Java Config使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: main

import org.apache.storm.Config; //导入依赖的package包/类
public static void main(String[] args) {
	FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence"), 3,
			new Values("this is simple example of trident topology"), new Values(
					"this example count same words"));
	spout.setCycle(true);

	//TransactionalTridentKafkaSpout spout = new TransactionalTridentKafkaSpout(new TridentKafkaConfig(new ZkHosts("localhost:9091"), "test"));
	TridentTopology topology = new TridentTopology();
	MemoryMapState.Factory stateFactory = new MemoryMapState.Factory();
	topology
			.newStream("spout1", spout)
			.each(new Fields("sentence"), new Split(), new Fields("word"))
			.groupBy(new Fields("word")).persistentAggregate(stateFactory, new Count(),
					new Fields("count")).newValuesStream()
			.filter(new DisplayOutputFilter()).parallelismHint(6);
	
	Config config = new Config();
	config.setNumWorkers(3);
	LocalCluster cluster = new LocalCluster();
	cluster.submitTopology("storm-trident-example", config, topology.build());
}
 
开发者ID:PacktPublishing,项目名称:Practical-Real-time-Processing-and-Analytics,代码行数:22,代码来源:BasicTridentTopology.java

示例2: main

import org.apache.storm.Config; //导入依赖的package包/类
public static void main(String args[]) {
	TridentKafkaConfig config = new TridentKafkaConfig(new ZkHosts(
			"localhost:2181"), "storm-trident-diy");
	config.scheme = new SchemeAsMultiScheme(new StringScheme());
	config.startOffsetTime = kafka.api.OffsetRequest.LatestTime();
	TransactionalTridentKafkaSpout spout = new TransactionalTridentKafkaSpout(
			config);
	TridentTopology topology = new TridentTopology();
	topology.newStream("spout", spout).filter(new ExcludePhoneNumber())
			.each(new Fields("str"), new DeviceInfoExtractor(), new Fields("phone", "bytes"))
			.groupBy(new Fields("phone"))
			.aggregate(new Fields("bytes", "phone"), new Sum(), new Fields("sum"))
			.applyAssembly(new FirstN(10, "sum"))
			.each(new Fields("phone", "sum"), new Debug());
	
	Config config1 = new Config();
	config1.setNumWorkers(3);
	LocalCluster cluster = new LocalCluster();
	cluster.submitTopology("storm-trident-diy", config1, topology.build());
}
 
开发者ID:PacktPublishing,项目名称:Practical-Real-time-Processing-and-Analytics,代码行数:21,代码来源:TridentDIY.java

示例3: main

import org.apache.storm.Config; //导入依赖的package包/类
public static void main(String args[]) throws InterruptedException {
	Config config = new Config();
	config.setNumWorkers(3);
	TopologyBuilder topologyBuilder = new TopologyBuilder();
	
	String zkConnString = "localhost:2181";
	String topicName = "sensor-data";
	
	BrokerHosts hosts = new ZkHosts(zkConnString);
	SpoutConfig spoutConfig = new SpoutConfig(hosts, topicName , "/" + topicName, UUID.randomUUID().toString());
	spoutConfig.scheme = new SchemeAsMultiScheme(new StringScheme());

	KafkaSpout kafkaSpout = new KafkaSpout(spoutConfig);
	topologyBuilder.setSpout("spout", kafkaSpout, 1);
       topologyBuilder.setBolt("es-bolt", new ElasticSearchBolt(), 1).shuffleGrouping("spout");
       
       LocalCluster cluster = new LocalCluster();
       cluster.submitTopology("storm-es-example", config, topologyBuilder.createTopology());
}
 
开发者ID:PacktPublishing,项目名称:Practical-Real-time-Processing-and-Analytics,代码行数:20,代码来源:SensorTopology.java

示例4: main

import org.apache.storm.Config; //导入依赖的package包/类
public static void main(String[] args) {
	Config config = new Config();
	config.setNumWorkers(3);
	TopologyBuilder topologyBuilder = new TopologyBuilder();
	
	String zkConnString = "localhost:2181";
	String topicName = "storm-diy";
	
	BrokerHosts hosts = new ZkHosts(zkConnString);
	SpoutConfig spoutConfig = new SpoutConfig(hosts, topicName , "/" + topicName, UUID.randomUUID().toString());
	spoutConfig.scheme = new SchemeAsMultiScheme(new StringScheme());

	KafkaSpout kafkaSpout = new KafkaSpout(spoutConfig);
	topologyBuilder.setSpout("spout", kafkaSpout, 1);
	topologyBuilder.setBolt("parser", new ParseAndUsageBolt(), 1).shuffleGrouping("spout");
	topologyBuilder.setBolt("usageCassandra", new UsageCassandraBolt("localhost", "usage"), 1).shuffleGrouping("parser", "usagestream");
	topologyBuilder.setBolt("tdrCassandra", new TDRCassandraBolt("localhost", "tdr"), 1).shuffleGrouping("parser", "tdrstream");
	
	LocalCluster cluster = new LocalCluster();
       cluster.submitTopology("storm-diy", config, topologyBuilder.createTopology());
}
 
开发者ID:PacktPublishing,项目名称:Practical-Real-time-Processing-and-Analytics,代码行数:22,代码来源:TelecomProcessorTopology.java

示例5: FetchItemQueues

import org.apache.storm.Config; //导入依赖的package包/类
public FetchItemQueues(Config conf) {
    this.conf = conf;
    this.defaultMaxThread = ConfUtils.getInt(conf,
            "fetcher.threads.per.queue", 1);
    queueMode = ConfUtils.getString(conf, "fetcher.queue.mode",
            QUEUE_MODE_HOST);
    // check that the mode is known
    if (!queueMode.equals(QUEUE_MODE_IP)
            && !queueMode.equals(QUEUE_MODE_DOMAIN)
            && !queueMode.equals(QUEUE_MODE_HOST)) {
        LOG.error("Unknown partition mode : {} - forcing to byHost",
                queueMode);
        queueMode = QUEUE_MODE_HOST;
    }
    LOG.info("Using queue mode : {}", queueMode);

    this.crawlDelay = (long) (ConfUtils.getFloat(conf,
            "fetcher.server.delay", 1.0f) * 1000);
    this.minCrawlDelay = (long) (ConfUtils.getFloat(conf,
            "fetcher.server.min.delay", 0.0f) * 1000);
}
 
开发者ID:eorliac,项目名称:patent-crawler,代码行数:22,代码来源:FetcherBolt.java

示例6: setupOnce

import org.apache.storm.Config; //导入依赖的package包/类
@BeforeClass
public static void setupOnce() throws Exception {
    System.out.println("------> Creating Sheep \uD83D\uDC11\n");

    clusterParam = new MkClusterParam();
    clusterParam.setSupervisors(1);
    Config daemonConfig = new Config();
    daemonConfig.put(Config.STORM_LOCAL_MODE_ZMQ, false);
    clusterParam.setDaemonConf(daemonConfig);
    makeConfigFile();

    Config conf = new Config();
    conf.setNumWorkers(1);

    completeTopologyParam = new CompleteTopologyParam();
    completeTopologyParam.setStormConf(conf);
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:18,代码来源:StableAbstractStormTest.java

示例7: start

import org.apache.storm.Config; //导入依赖的package包/类
private void start(StormTopology topology, boolean runAsLocal) throws Exception {
    Config conf = new Config();
    conf.put(Constants.StormConfigKey.FULL_SPLITTER_TOPOLOGY_ID, fullSplitterTopologyId);
    conf.put(Constants.StormConfigKey.FULL_PULLER_TOPOLOGY_ID, fullPullerTopologyId);
    conf.put(Constants.StormConfigKey.ZKCONNECT, this.zkConnect);
    conf.setMessageTimeoutSecs(3600);
    conf.setMaxSpoutPending(30);
    conf.setDebug(true);
    conf.setNumWorkers(1);

    if (runAsLocal) {
        conf.setMaxTaskParallelism(3);
        LocalCluster cluster = new LocalCluster();
        cluster.submitTopology(topologyName, conf, topology);
    } else {
        StormSubmitter.submitTopology(topologyName, conf, topology);
    }
}
 
开发者ID:BriData,项目名称:DBus,代码行数:19,代码来源:FullPullerTopology.java

示例8: prepare

import org.apache.storm.Config; //导入依赖的package包/类
@Override
public void prepare(Map stormConf, Object registrationArgument, TopologyContext context, IErrorReporter errorReporter) {

    final Map<Object, Object> mergedConf = new HashMap<>();

    if (stormConf != null && stormConf.size() > 0) {

        LOG.debug("{}: Argument stormConf: {}", this.getClass().getSimpleName(), stormConf.toString());

        this.topologyName = (String) stormConf.get(Config.TOPOLOGY_NAME);
        mergedConf.putAll(stormConf);
    } else {
        LOG.warn("{}: Argument stormConf is Empty or null", this.getClass().getSimpleName());
    }

    if (registrationArgument != null && registrationArgument instanceof Map && ((Map) registrationArgument).size() > 0) {

        LOG.debug("{}: Argument registrationArgument: {}", this.getClass().getSimpleName(), registrationArgument.toString());

        mergedConf.putAll((Map) registrationArgument);
    } else {
        LOG.warn("{}: Argument registrationArgument is Empty or null", this.getClass().getSimpleName());
    }

    this.influxDBSender = makeInfluxDBSender(mergedConf);
}
 
开发者ID:christiangda,项目名称:storm-metrics-influxdb,代码行数:27,代码来源:InfluxDBMetricsConsumer.java

示例9: main

import org.apache.storm.Config; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout("integer", new RandomIntegerSpout(), 1);
    builder.setBolt("slidingsum", new SlidingWindowSumBolt().withWindow(new Count(30), new Count(10)), 1)
            .shuffleGrouping("integer");
    builder.setBolt("tumblingavg", new TumblingWindowAvgBolt().withTumblingWindow(new Count(3)), 1)
            .shuffleGrouping("slidingsum");
    builder.setBolt("printer", new PrinterBolt(), 1).shuffleGrouping("tumblingavg");
    Config conf = new Config();
    conf.setDebug(true);
    if (args != null && args.length > 0) {
        conf.setNumWorkers(1);
        StormSubmitter.submitTopologyWithProgressBar(args[0], conf, builder.createTopology());
    } else {
        LocalCluster cluster = new LocalCluster();
        cluster.submitTopology("test", conf, builder.createTopology());
        Utils.sleep(40000);
        cluster.killTopology("test");
        cluster.shutdown();
    }
}
 
开发者ID:bigdataFlySQL,项目名称:SQLonStorm,代码行数:22,代码来源:SlidingWindowTopology.java

示例10: main

import org.apache.storm.Config; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	Config conf = new Config();
	conf.setMaxSpoutPending(20);
	LocalDRPC drpc = new LocalDRPC();
	if (args.length == 0) {
		
		LocalCluster cluster = new LocalCluster();
		cluster.submitTopology("CountryCount", conf, buildTopology(drpc));
		Thread.sleep(2000);
		for(int i=0; i<100 ; i++) {
			System.out.println("Result - "+drpc.execute("Count", "Japan India Europe"));
			Thread.sleep(1000);
			}
	} else {
		conf.setNumWorkers(3);
		StormSubmitter.submitTopology(args[0], conf, buildTopology(null));
		Thread.sleep(2000);
  		  	DRPCClient client = new DRPCClient(conf, "RRPC-Server", 1234);
  		  	System.out.println(client.execute("Count", "Japan India Europe"));
	}
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Apache-Storm,代码行数:22,代码来源:DistributedRPC.java

示例11: main

import org.apache.storm.Config; //导入依赖的package包/类
public static void main(String[] args) throws AlreadyAliveException,
		InvalidTopologyException {
	// create an instance of TopologyBuilder class
	TopologyBuilder builder = new TopologyBuilder();
	// set the spout class
	builder.setSpout("SampleSpout", new SampleSpout(), 2);
	// set the bolt class
	builder.setBolt("SampleBolt", new SampleBolt(), 4).shuffleGrouping(
			"SampleSpout");
	Config conf = new Config();
	conf.setNumWorkers(3);
	// This statement submit the topology on remote
	// args[0] = name of topology
	try {
		StormSubmitter.submitTopology(args[0], conf,
				builder.createTopology());
	} catch (AlreadyAliveException alreadyAliveException) {
		System.out.println(alreadyAliveException);
	} catch (InvalidTopologyException invalidTopologyException) {
		System.out.println(invalidTopologyException);
	} catch (AuthorizationException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Apache-Storm,代码行数:26,代码来源:SampleStormClusterTopology.java

示例12: main

import org.apache.storm.Config; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    TopologyBuilder builder = new TopologyBuilder();

    builder.setSpout("word", new WordSpout(), 1);
    builder.setBolt("exclaim", new ExclamationBolt(), 1).shuffleGrouping("word");   // Tuple流向:word 》 exclaim
    builder.setBolt("print", new PrintBolt(), 1).shuffleGrouping("exclaim");        // exclaim 》 print

    Config conf = new Config();
    conf.setDebug(true);

    if (args != null && args.length > 0) {
        conf.setNumWorkers(3);

        StormSubmitter.submitTopologyWithProgressBar(args[0], conf, builder.createTopology());
    } else {

        LocalCluster cluster = new LocalCluster();      // storm依赖,<scope>provided</scope>--> 本地开发是注释掉 -->
        cluster.submitTopology("test3", conf, builder.createTopology());
        Utils.sleep(60 * 1000);
        cluster.killTopology("test3");
        cluster.shutdown();
    }
}
 
开发者ID:xuxueli,项目名称:xxl-incubator,代码行数:24,代码来源:ExclamationTopology.java

示例13: submitTopology

import org.apache.storm.Config; //导入依赖的package包/类
private LocalCluster submitTopology() throws AlreadyAliveException,
        InvalidTopologyException {
    Config stormConfig = new Config();
    stormConfig.setDebug(false);
    stormConfig.setFallBackOnJavaSerialization(true);
    stormConfig.setNumWorkers(1);

    // enable backpressure since the spouts can move at a much faster speed than the bolts
    stormConfig.put(Config.TOPOLOGY_BACKPRESSURE_ENABLE, true);
    stormConfig.put(Config.TOPOLOGY_EXECUTOR_RECEIVE_BUFFER_SIZE, 2048);
    stormConfig.put(Config.TOPOLOGY_EXECUTOR_SEND_BUFFER_SIZE, 2048);
    stormConfig.put(Config.TOPOLOGY_SLEEP_SPOUT_WAIT_STRATEGY_TIME_MS, 1000);
    stormConfig.put(Config.TOPOLOGY_MAX_SPOUT_PENDING, 10);

    stormConfig.setSkipMissingKryoRegistrations(true);
    stormConfig.put(ConfigurationConstants.CHATALYTICS_CONFIG.txt,
                    YamlUtils.writeYaml(chatalyticsConfig));

    LocalCluster cluster = new LocalCluster();
    cluster.submitTopology(TOPOLOGY_NAME, stormConfig, chatTopology);
    return cluster;
}
 
开发者ID:OpenChatAlytics,项目名称:OpenChatAlytics,代码行数:23,代码来源:ChatAlyticsService.java

示例14: main

import org.apache.storm.Config; //导入依赖的package包/类
public static void main(String[] args){
    TopologyBuilder topologyBuilder = new TopologyBuilder();
    topologyBuilder.setSpout(SPOUT_ID,new SentenceSpout());
    topologyBuilder.setBolt(BOLT_ID_SENTENCE_SPLIT,new SentenceSplitBolt()).shuffleGrouping(SPOUT_ID);
    topologyBuilder.setBolt(BOLT_ID_WORD_COUNT,new WordCountBlot()).fieldsGrouping(BOLT_ID_SENTENCE_SPLIT,new Fields("word"));
    topologyBuilder.setBolt(BOLT_ID_COUNT_REPORT,new WordsReportBolt()).globalGrouping(BOLT_ID_WORD_COUNT);

    Config config  = new Config();
    LocalCluster localCluster = new LocalCluster();

    localCluster.submitTopology(TOPOLOGY_ID,config,topologyBuilder.createTopology());
    //
    Utils.sleep(10000);
    localCluster.killTopology(TOPOLOGY_ID);
    localCluster.shutdown();
}
 
开发者ID:yangboz,项目名称:SpringBootKafkaStorm,代码行数:17,代码来源:WordCountTopology.java

示例15: main

import org.apache.storm.Config; //导入依赖的package包/类
public static void  main(String[] args){
    args = new String[] {"localhost:2181", "storm-test-topic", "/brokers", "storm-consumer"};
    // Log program usages and exit if there are less than 4 command line arguments
    if(args.length < 4) {
        LOG.fatal("Incorrect number of arguments. Required arguments: <zk-hosts> <kafka-topic> <zk-path> <clientid>");
        System.exit(1);
    }
    // Build Spout configuration using input command line parameters
    final BrokerHosts zkrHosts = new ZkHosts(args[0]);
    final String kafkaTopic = args[1];
    final String zkRoot = args[2];
    final String clientId = args[3];
    final SpoutConfig spoutConfig = new SpoutConfig(zkrHosts,kafkaTopic,zkRoot,clientId);
    spoutConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
    // Build topology to consume message from kafka and print them on console
    final TopologyBuilder topologyBuilder = new TopologyBuilder();
    // Build topology to consume message from kafka and print them on console
    topologyBuilder.setSpout("kafka-spout",new KafkaSpout(spoutConfig));
    //Route the output of Kafka Spout to Logger bolt to log messages consumed from Kafka
    topologyBuilder.setBolt("kafka-message",new LoggerBolt()).globalGrouping("kafka-spout");
    //Route the output of Kafka Spout to Logger bolt to log messages consumed from Kafka
    final LocalCluster localCluster = new LocalCluster();
    localCluster.submitTopology("kafka-toology",new Config(),topologyBuilder.createTopology());
}
 
开发者ID:yangboz,项目名称:SpringBootKafkaStorm,代码行数:25,代码来源:LoggerTopology.java


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