當前位置: 首頁>>代碼示例>>Java>>正文


Java BaseRichSpout類代碼示例

本文整理匯總了Java中backtype.storm.topology.base.BaseRichSpout的典型用法代碼示例。如果您正苦於以下問題:Java BaseRichSpout類的具體用法?Java BaseRichSpout怎麽用?Java BaseRichSpout使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BaseRichSpout類屬於backtype.storm.topology.base包,在下文中一共展示了BaseRichSpout類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: buildWithSpout

import backtype.storm.topology.base.BaseRichSpout; //導入依賴的package包/類
public static StormTopology buildWithSpout(String spoutId, BaseRichSpout spout) {
  TopologyBuilder builder = new TopologyBuilder();
  builder.setSpout(spoutId, spout);
  builder.setBolt(GEOCODE_LOOKUP_ID, new GeocodeLookup()).shuffleGrouping(spoutId);
  builder.setBolt(HEATMAP_BUILDER_ID, new HeatMapBuilder())
      .addConfiguration(Config.TOPOLOGY_TICK_TUPLE_FREQ_SECS, 3).globalGrouping(GEOCODE_LOOKUP_ID);
  builder.setBolt(PERSISTOR_ID, new Persistor()).shuffleGrouping(HEATMAP_BUILDER_ID);
  return builder.createTopology();
}
 
開發者ID:Storm-Applied,項目名稱:C3-Heatmap,代碼行數:10,代碼來源:StormTopologyBuilder.java

示例2: createTopology

import backtype.storm.topology.base.BaseRichSpout; //導入依賴的package包/類
public static StormTopology createTopology(XMLConfiguration config) {

	String redisHost = config.getString("redis.hostname", "localhost");
	String itemsChannel = config.getString("redis.itemsChannel", "items");
	
	String nerModel = config.getString("ner.model", "english.all.3class.distsim.crf.ser.gz");
	String POSModel = config.getString("pos.model", "english-left3words-distsim.tagger");
	
	BaseRichSpout itemsSpout;
	IRichBolt entityExtractor, posTagger;
	IRichBolt itemDeserializer, tokenizer, eventDetector;	
	try {
		itemsSpout = new RedisSpout(redisHost, itemsChannel);
		itemDeserializer = new ItemDeserializationBolt(itemsChannel);

		entityExtractor = new EntityExtractionBolt(nerModel);
		posTagger = new POSTaggingBolt(POSModel);
		
		tokenizer = new TokenizationBolt(TokenizationBolt.TokenType.NE);
		
		eventDetector = new EventDetectionBolt(5, 60);
		
	} catch (Exception e) {
		logger.error(e);
		return null;
	}
	
	// Create topology 
	TopologyBuilder builder = new TopologyBuilder();
	builder.setSpout("itemsSpout", itemsSpout, 1);
			
	builder.setBolt("itemDeserializer", itemDeserializer, 4).shuffleGrouping("itemsSpout");
	builder.setBolt("entityExtractor", entityExtractor, 4).shuffleGrouping("itemDeserializer");
	//builder.setBolt("posTagger", posTagger, 4).shuffleGrouping("entityExtractor");
	builder.setBolt("tokenizer", tokenizer, 8).shuffleGrouping("entityExtractor");
	
	builder.setBolt("eventDetector", eventDetector, 1).shuffleGrouping("tokenizer");
	
	StormTopology topology = builder.createTopology();
	return topology;
}
 
開發者ID:socialsensor,項目名稱:storm-focused-crawler,代碼行數:42,代碼來源:StreamMonitor.java

示例3: createTopology

import backtype.storm.topology.base.BaseRichSpout; //導入依賴的package包/類
public static StormTopology createTopology(XMLConfiguration config) {

	String redisHost = config.getString("redis.hostname", "xxx.xxx.xxx.xxx");
	String webPagesChannel = config.getString("redis.webPagesChannel", "webpages");
	
	String mongodbHostname = config.getString("mongodb.hostname", "xxx.xxx.xxx.xxx");
	String mediaItemsDB = config.getString("mongodb.mediaItemsDB", "Prototype");
	String mediaItemsCollection = config.getString("mongodb.mediaItemsCollection", "MediaItems");
	String streamUsersDB = config.getString("mongodb.streamUsersDB", "Prototype");
	String streamUsersCollection = config.getString("mongodb.streamUsersCollection", "StreamUsers");
	String webPagesDB = config.getString("mongodb.webPagesDB", "Prototype");
	String webPagesCollection = config.getString("mongodb.webPagesCollection", "WebPages");
	
	String textIndexHostname = config.getString("textindex.hostname", "xxx.xxx.xxx.xxx:8080/solr");
	String textIndexCollection = config.getString("textindex.collections.webpages", "WebPages");
	String mediaIndexCollection = config.getString("textindex.collections.media", "MediaItems");
	String textIndexService = textIndexHostname + "/" + textIndexCollection;
	String mediaTextIndexService = textIndexHostname + "/" + mediaIndexCollection;
	
	BaseRichSpout wpSpout;
	IRichBolt wpDeserializer, mediaUpdater, urlExpander, mediaTextIndexer;
	IRichBolt articleExtraction, mediaExtraction, webPageUpdater, textIndexer;
	
	try {
		wpSpout = new RedisSpout(redisHost, webPagesChannel, "url");
		wpDeserializer = new WebPageDeserializationBolt(webPagesChannel);
		urlExpander = new URLExpansionBolt(webPagesChannel);
		
		articleExtraction = new ArticleExtractionBolt(24);
		mediaExtraction = new MediaExtractionBolt();
		webPageUpdater = new WebPagesUpdaterBolt(mongodbHostname, webPagesDB, webPagesCollection);
		textIndexer = new TextIndexerBolt(textIndexService);

		mediaUpdater = new MediaUpdaterBolt(mongodbHostname, mediaItemsDB, mediaItemsCollection, streamUsersDB, streamUsersCollection);
		mediaTextIndexer = new MediaTextIndexerBolt(mediaTextIndexService);
	} catch (Exception e) {
		logger.error(e);
		return null;
	}
	
	// Create topology 
	TopologyBuilder builder = new TopologyBuilder();
	builder.setSpout("wpSpout", wpSpout, 1);
			
	builder.setBolt("WpDeserializer", wpDeserializer, 4).shuffleGrouping("wpSpout");
	builder.setBolt("expander", urlExpander, 8).shuffleGrouping("WpDeserializer");
			
			
	builder.setBolt("articleExtraction", articleExtraction, 1)
		.shuffleGrouping("expander", "webpage");
	builder.setBolt("mediaExtraction", mediaExtraction, 1)
		.shuffleGrouping("expander", "media");
			
	builder.setBolt("webPageUpdater", webPageUpdater, 4)
		.shuffleGrouping("articleExtraction", "webpage")
		.shuffleGrouping("mediaExtraction", "webpage");
			
	builder.setBolt("textIndexer", textIndexer, 1)
		.shuffleGrouping("articleExtraction", "webpage");
			
	builder.setBolt("mediaupdater", mediaUpdater, 1)
		.shuffleGrouping("articleExtraction", "media")
		.shuffleGrouping("mediaExtraction", "media");
	
	builder.setBolt("mediatextindexer", mediaTextIndexer, 1)
		.shuffleGrouping("articleExtraction", "media")
		.shuffleGrouping("mediaExtraction", "media");
	
	StormTopology topology = builder.createTopology();
	return topology;
}
 
開發者ID:socialsensor,項目名稱:storm-focused-crawler,代碼行數:72,代碼來源:WikirateCrawler.java

示例4: createTopology

import backtype.storm.topology.base.BaseRichSpout; //導入依賴的package包/類
public static StormTopology createTopology(XMLConfiguration config) {
	
	String redisHost = config.getString("redis.hostname", "xxx.xxx.xxx.xxx");
	String redisMediaChannel = config.getString("redis.mediaItemsChannel", "media");
	
	String mongodbHostname = config.getString("mongodb.hostname", "xxx.xxx.xxx.xxx");
	String mediaItemsDB = config.getString("mongodb.mediaItemsDB", "Prototype");
	String mediaItemsCollection = config.getString("mongodb.mediaItemsCollection", "MediaItems");
	String streamUsersDB = config.getString("mongodb.streamUsersDB", "Prototype");
	String streamUsersCollection = config.getString("mongodb.streamUsersCollection", "StreamUsers");
	String clustersDB = config.getString("mongodb.clustersDB", "Prototype");
	String clustersCollection = config.getString("mongodb.clustersCollection", "MediaClusters");
	
	String conceptDetectorMatlabfile = config.getString("conceptdetector.matlabfile");
	
	String mediaTextIndexHostname = config.getString("textindex.hostname", "http://xxx.xxx.xxx.xxx:8080/solr");
	String mediaTextIndexCollection = config.getString("textindex.collections.media", "MediaItems");
	String mediaTextIndexService = mediaTextIndexHostname + "/" + mediaTextIndexCollection;
	
	String visualIndexHostname = config.getString("visualindex.hostname");
	String visualIndexCollection = config.getString("visualindex.collection");
	
	String learningFiles = config.getString("visualindex.learningfiles");
	if(!learningFiles.endsWith("/"))
		learningFiles = learningFiles + "/";
	
	String[] codebookFiles = { 
			learningFiles + "surf_l2_128c_0.csv",
			learningFiles + "surf_l2_128c_1.csv", 
			learningFiles + "surf_l2_128c_2.csv",
			learningFiles + "surf_l2_128c_3.csv" };
	
	String pcaFile = learningFiles + "pca_surf_4x128_32768to1024.txt";
	
	BaseRichSpout miSpout;
	IRichBolt miRanker, mediaCounter, visualIndexer, mediaUpdater, conceptDetector;
	IRichBolt mediaTextIndexer, clusterer;
	
	try {
		miSpout = new RedisSpout(redisHost, redisMediaChannel, "id");	
		miRanker = new MediaRankerBolt(redisMediaChannel);
		
		mediaCounter = new MediaCounterBolt(mongodbHostname, "Prototype");
		visualIndexer = new VisualIndexerBolt(visualIndexHostname, visualIndexCollection, codebookFiles, pcaFile);
		clusterer = new ClustererBolt(mongodbHostname, mediaItemsDB, mediaItemsCollection, clustersDB, clustersCollection, visualIndexHostname, visualIndexCollection, mediaTextIndexService);
		conceptDetector = new ConceptDetectionBolt(conceptDetectorMatlabfile);
		
		mediaUpdater = new MediaUpdaterBolt(mongodbHostname, mediaItemsDB, mediaItemsCollection, streamUsersDB, streamUsersCollection);
		mediaTextIndexer = new MediaTextIndexerBolt(mediaTextIndexService);
	} catch (Exception e) {
		logger.error(e);
		return null;
	}
	
	// Create topology 
	TopologyBuilder builder = new TopologyBuilder();
	builder.setSpout("miInjector", miSpout, 1);
			
	builder.setBolt("miRanker", miRanker, 4).shuffleGrouping("miInjector");

	builder.setBolt("counter", mediaCounter, 1).shuffleGrouping("miRanker");
	builder.setBolt("indexer", visualIndexer, 16).shuffleGrouping("miRanker");
	builder.setBolt("clusterer", clusterer, 1).shuffleGrouping("indexer");   
	builder.setBolt("conceptDetector", conceptDetector, 1).shuffleGrouping("indexer");
	        
	builder.setBolt("mediaupdater", mediaUpdater, 1).shuffleGrouping("conceptDetector");
	builder.setBolt("mediaTextIndexer", mediaTextIndexer, 1).shuffleGrouping("conceptDetector");
	
	return builder.createTopology();
}
 
開發者ID:socialsensor,項目名稱:storm-focused-crawler,代碼行數:71,代碼來源:VisualIndexer.java


注:本文中的backtype.storm.topology.base.BaseRichSpout類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。