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


Java StormTopology類代碼示例

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


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

示例1: buildTopology

import backtype.storm.generated.StormTopology; //導入依賴的package包/類
public static StormTopology buildTopology()

{
	TridentTopology topology = new TridentTopology();
	RandomWordSpout spout1 = new RandomWordSpout();
	
	Stream inputStream = topology.newStream("faltu", spout1);//faltu isnt used anywhere.
	
	/**
	 * partitionPersist : The partitionPersist operation updates a source of state.
	 * It returns a TridentState object. You could then use this state in stateQuery operations elsewhere in the topology.
	 * Args:
	 * StateFactory instance - This factory implement the makeState API, that should return a instance of State.
	 * Fields list, that needs to be persisted. These field list should be present in the input stream.
	 * StateUpdater instance - The StateUpdater instance will update the underlying State.
	 */
	 inputStream
	    .partitionPersist(new RedisStoreStateFactory(), new Fields("randomWord"), new RedisStoreStateUpdater());
	 
	 return topology.build();
}
 
開發者ID:BinitaBharati,項目名稱:storm-trident-example,代碼行數:22,代碼來源:ExampleTopology.java

示例2: buildTopology

import backtype.storm.generated.StormTopology; //導入依賴的package包/類
public static StormTopology buildTopology()

{
	TridentTopology topology = new TridentTopology();
	RandomPhraseSpout spout1 = new RandomPhraseSpout();
	
	Stream inputStream = topology.newStream("dumbo", spout1).parallelismHint(20);//where is dumbo used ? No where as per as I see.
	
	/**
	 * persistentAggregate : The persistentAggregate operation updates a source of state.
	 * persistentAggregate is an additional abstraction built on top of partitionPersist that knows how to take a 
	 * Trident aggregator and use it to apply updates to the source of state.
	 * Args:
	 * StateFactory instance - This factory implement the makeState API, that should return a instance of State.
	 * Fields list, that needs to be persisted. These field list should be present in the input stream.
	 * StateUpdater instance - The StateUpdater instance will update the underlying State.
	 */
	 inputStream
	    //input stream generated by spout1 has a field called randomPhrase.
	    //RandomPhraseSplitter takes a randomPhrase and additionally emits a field called randomWord into the stream.
	    .each(new Fields("randomPhrase"), new RandomPhraseSplitter(), new Fields("randomWord")).parallelismHint(6);
	    
	 return topology.build();
}
 
開發者ID:BinitaBharati,項目名稱:storm-trident-example,代碼行數:25,代碼來源:ExampleTopology.java

示例3: main

import backtype.storm.generated.StormTopology; //導入依賴的package包/類
public static void main(String[] args) {

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

    StormTopology topology = buildTopology();
    // Un-comment to run locally:
    LocalCluster localCluster = new LocalCluster();
    localCluster.submitTopology("local-moving-avg", config, topology);
    // Un-comment to run as part of a Storm cluster:
    // try {
    //   StormSubmitter.submitTopology("cluster-moving-average",
    //  				    config,
    // 				    topology);
    // } catch(AlreadyAliveException e) {
    //   e.printStackTrace();
    // } catch(InvalidTopologyException e) {
    //   e.printStackTrace();
    //}
  }
 
開發者ID:amitchmca,項目名稱:hadooparchitecturebook,代碼行數:21,代碼來源:MovingAvgLocalTopologyRunner.java

示例4: run

import backtype.storm.generated.StormTopology; //導入依賴的package包/類
public static void run(final String name, final StormTopology topo, final Counter hasCompleted) throws Exception {
    Thread th = new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                start(name, topo);
                hasCompleted.waitForZero(TimeValue.timeValueSeconds(15));
            } finally {
                stop(name);
            }

        }
    }, "test-storm-runner");
    th.setDaemon(true);

    copyPropertiesIntoCfg(cfg);
    th.start();
}
 
開發者ID:xushjie1987,項目名稱:es-hadoop-v2.2.0,代碼行數:19,代碼來源:AbstractStormSuite.java

示例5: TopologyContext

import backtype.storm.generated.StormTopology; //導入依賴的package包/類
public TopologyContext(StormTopology topology, Map stormConf,
		Map<Integer, String> taskToComponent,
		Map<String, List<Integer>> componentToSortedTasks,
		Map<String, Map<String, Fields>> componentToStreamToFields,
		String topologyId, String codeDir, String pidDir, Integer taskId,
		Integer workerPort, List<Integer> workerTasks,
		Map<String, Object> defaultResources,
		Map<String, Object> userResources,
		Map<String, Object> executorData, Map registeredMetrics,
		clojure.lang.Atom openOrPrepareWasCalled) {
	super(topology, stormConf, taskToComponent, componentToSortedTasks,
			componentToStreamToFields, topologyId, codeDir, pidDir,
			workerPort, workerTasks, defaultResources, userResources);
	_taskId = taskId;
	_executorData = executorData;
	_registeredMetrics = registeredMetrics;
	_openOrPrepareWasCalled = openOrPrepareWasCalled;
}
 
開發者ID:greeenSY,項目名稱:Tstream,代碼行數:19,代碼來源:TopologyContext.java

示例6: add_metrics_component

import backtype.storm.generated.StormTopology; //導入依賴的package包/類
public static StormTopology add_metrics_component(StormTopology topology) {

		/**
		 */
		//		(defn metrics-consumer-bolt-specs [storm-conf topology]
		//				  (let [component-ids-that-emit-metrics (cons SYSTEM-COMPONENT-ID (keys (all-components topology)))
		//				        inputs (->> (for [comp-id component-ids-that-emit-metrics]
		//				                      {[comp-id METRICS-STREAM-ID] :shuffle})
		//				                    (into {}))
		//				        
		//				        mk-bolt-spec (fn [class arg p]
		//				                       (thrift/mk-bolt-spec*
		//				                        inputs
		//				                        (backtype.storm.metric.MetricsConsumerBolt. class arg)
		//				                        {} :p p :conf {TOPOLOGY-TASKS p}))]
		//				    
		//				    (map
		//				     (fn [component-id register]           
		//				       [component-id (mk-bolt-spec (get register "class")
		//				                                   (get register "argument")
		//				                                   (or (get register "parallelism.hint") 1))])
		//				     
		//				     (metrics-consumer-register-ids storm-conf)
		//				     (get storm-conf TOPOLOGY-METRICS-CONSUMER-REGISTER))))
		return topology;
	}
 
開發者ID:zhangjunfang,項目名稱:jstorm-0.9.6.3-,代碼行數:27,代碼來源:Common.java

示例7: submitTopologyWithOpts

import backtype.storm.generated.StormTopology; //導入依賴的package包/類
@Override
public void submitTopologyWithOpts(String topologyName, Map conf,
		StormTopology topology, SubmitOptions submitOpts){
	
	if (!Utils.isValidConf(conf))
		throw new RuntimeException("Topology conf is not json-serializable");
	JStormUtils.setLocalMode(true);
	
	try {
		if (submitOpts == null) {
			state.getNimbus().submitTopology(topologyName, null,
					Utils.to_json(conf), topology);
		}else {
			state.getNimbus().submitTopologyWithOpts(topologyName, null,
					Utils.to_json(conf), topology, submitOpts);
		}
		
	} catch (Exception e) {
		
		LOG.error("Failed to submit topology " + topologyName, e);
		throw new RuntimeException(e);
	} 
}
 
開發者ID:zhangjunfang,項目名稱:jstorm-0.9.6.3-,代碼行數:24,代碼來源:LocalCluster.java

示例8: WorkerTopologyContext

import backtype.storm.generated.StormTopology; //導入依賴的package包/類
public WorkerTopologyContext(StormTopology topology, Map stormConf,
		Map<Integer, String> taskToComponent,
		Map<String, List<Integer>> componentToSortedTasks,
		Map<String, Map<String, Fields>> componentToStreamToFields,
		String topologyId, String codeDir, String pidDir, Integer workerPort,
		List<Integer> workerTasks, Map<String, Object> defaultResources,
		Map<String, Object> userResources) {
	super(topology, stormConf, taskToComponent, componentToSortedTasks,
			componentToStreamToFields, topologyId);
	_codeDir = codeDir;
	_defaultResources = defaultResources;
	_userResources = userResources;
	try {
		if (pidDir != null) {
			_pidDir = new File(pidDir).getCanonicalPath();
		} else {
			_pidDir = null;
		}
	} catch (IOException e) {
		throw new RuntimeException("Could not get canonical path for "
				+ _pidDir, e);
	}
	_workerPort = workerPort;
	_workerTasks = workerTasks;
}
 
開發者ID:songtk,項目名稱:learn_jstorm,代碼行數:26,代碼來源:WorkerTopologyContext.java

示例9: buildTopology

import backtype.storm.generated.StormTopology; //導入依賴的package包/類
public static StormTopology buildTopology(String redisIp, String redisPort) {
	// topology to build
	TopologyBuilder topology = new TopologyBuilder();

	// create a spout
	WikiCrawlerSpout wikiSpout = new WikiCrawlerSpout(redisIp, redisPort);

	// create a bolt
	WikiCrawlerExplorerBolt wikiBolt = new WikiCrawlerExplorerBolt(redisIp, redisPort);

	// set up the DAG
	// this spout always takes 1 task, it is light
	topology.setSpout("wikiSpout", wikiSpout, 1)
			.setNumTasks(2)
			.setMaxSpoutPending(5);
	// this bolt uses as many executors(threads) as the cores available
	topology.setBolt("wikiBolt", wikiBolt, numCores)
			.setNumTasks(numCores * 4) // 4 task per thread
			.shuffleGrouping("wikiSpout");

	return topology.createTopology();
}
 
開發者ID:sunil3590,項目名稱:spiderz,代碼行數:23,代碼來源:WikiCrawlerTopology.java

示例10: getComponentCommon

import backtype.storm.generated.StormTopology; //導入依賴的package包/類
public static ComponentCommon getComponentCommon(StormTopology topology,
		String componentId) {
	for (StormTopology._Fields f : StormTopology.metaDataMap.keySet()) {
		Map<String, Object> componentMap = (Map<String, Object>) topology
				.getFieldValue(f);
		if (componentMap.containsKey(componentId)) {
			Object component = componentMap.get(componentId);
			if (component instanceof Bolt) {
				return ((Bolt) component).get_common();
			}
			if (component instanceof SpoutSpec) {
				return ((SpoutSpec) component).get_common();
			}
			if (component instanceof StateSpoutSpec) {
				return ((StateSpoutSpec) component).get_common();
			}
			throw new RuntimeException(
					"Unreachable code! No get_common conversion for component "
							+ component);
		}
	}
	throw new IllegalArgumentException(
			"Could not find component common for " + componentId);
}
 
開發者ID:greeenSY,項目名稱:Tstream,代碼行數:25,代碼來源:ThriftTopologyUtils.java

示例11: buildTopology

import backtype.storm.generated.StormTopology; //導入依賴的package包/類
public static StormTopology buildTopology(LocalDRPC drpc) {
  FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence"), 3, new Values("the cow jumped over the moon"),
      new Values("the man went to the store and bought some candy"), new Values("four score and seven years ago"),
      new Values("how many apples can you eat"), new Values("to be or not to be the person"));
  spout.setCycle(true);

  TridentTopology topology = new TridentTopology();
  TridentState wordCounts = topology.newStream("spout1", spout).parallelismHint(16).each(new Fields("sentence"),
      new Split(), new Fields("word")).groupBy(new Fields("word")).persistentAggregate(new MemoryMapState.Factory(),
      new Count(), new Fields("count")).parallelismHint(16);

  topology.newDRPCStream("words", drpc).each(new Fields("args"), new Split(), new Fields("word")).groupBy(new Fields(
      "word")).stateQuery(wordCounts, new Fields("word"), new MapGet(), new Fields("count")).each(new Fields("count"),
      new FilterNull()).aggregate(new Fields("count"), new Sum(), new Fields("sum"));
  return topology.build();
}
 
開發者ID:luozhaoyu,項目名稱:big-data-system,代碼行數:17,代碼來源:TridentWordCount.java

示例12: submitTopology

import backtype.storm.generated.StormTopology; //導入依賴的package包/類
public static void submitTopology(String name, Map stormConf,
		StormTopology topology, SubmitOptions opts, List<File> jarFiles)
		throws AlreadyAliveException, InvalidTopologyException {
	if (jarFiles == null) {
		jarFiles = new ArrayList<File>();
	}
	Map<String, String> jars = new HashMap<String, String>(jarFiles.size());
	List<String> names = new ArrayList<String>(jarFiles.size());
	
	for (File f : jarFiles) {
		if (!f.exists()) {
			LOG.info(f.getName() + " is not existed: "
					+ f.getAbsolutePath());
			continue;
		}
		jars.put(f.getName(), f.getAbsolutePath());
		names.add(f.getName());
	}
	LOG.info("Files: " + names + " will be loaded");
	stormConf.put(GenericOptionsParser.TOPOLOGY_LIB_PATH, jars);
	stormConf.put(GenericOptionsParser.TOPOLOGY_LIB_NAME, names);
	submitTopology(name, stormConf, topology, opts);
}
 
開發者ID:songtk,項目名稱:learn_jstorm,代碼行數:24,代碼來源:StormSubmitter.java

示例13: buildTopology

import backtype.storm.generated.StormTopology; //導入依賴的package包/類
public static StormTopology buildTopology(LocalDRPC drpc) {
	FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence"), 3,
			new Values("the$$cow$$jumped$$over$$the$$moon"),
			new Values("the$$man$$went$$to$$the$$store$$and$$bought$$some$$candy"),
			new Values("four$$score$$and$$seven$$years$$ago"),
			new Values("how$$many$$apples$$can$$you$$eat"),
			new Values("to$$be$$or$$not$$to$$be$$the$$person"));
	spout.setCycle(true);

	TridentTopology topology = new TridentTopology();

	TridentState wordCounts = topology.newStream("spout1", spout)
			.each(new Fields("sentence"), new Split(), new Fields("word"))
			.groupBy(new Fields("word"))
			.persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("count"))
			.parallelismHint(6);

	topology.newDRPCStream("words", drpc).each(new Fields("args"), new Split(), new Fields("word"))
			.groupBy(new Fields("word"))
			.stateQuery(wordCounts, new Fields("word"), new MapGet(), new Fields("count"))
			.each(new Fields("count"), new FilterNull())
			.aggregate(new Fields("count"), new Sum(), new Fields("sum"));

	return topology.build();
}
 
開發者ID:desp0916,項目名稱:LearnStorm,代碼行數:26,代碼來源:TridentWordCount.java

示例14: WorkerTopologyContext

import backtype.storm.generated.StormTopology; //導入依賴的package包/類
public WorkerTopologyContext(StormTopology topology, Map stormConf, Map<Integer, String> taskToComponent,
        Map<String, List<Integer>> componentToSortedTasks, Map<String, Map<String, Fields>> componentToStreamToFields, String stormId, String codeDir,
        String pidDir, Integer workerPort, List<Integer> workerTasks, Map<String, Object> defaultResources, Map<String, Object> userResources) {
    super(topology, stormConf, taskToComponent, componentToSortedTasks, componentToStreamToFields, stormId);
    _codeDir = codeDir;
    _defaultResources = defaultResources;
    _userResources = userResources;
    try {
        if (pidDir != null) {
            _pidDir = new File(pidDir).getCanonicalPath();
        } else {
            _pidDir = null;
        }
    } catch (IOException e) {
        throw new RuntimeException("Could not get canonical path for " + _pidDir, e);
    }
    _workerPort = workerPort;
    _workerTasks = workerTasks;
}
 
開發者ID:kkllwww007,項目名稱:jstrom,代碼行數:20,代碼來源:WorkerTopologyContext.java

示例15: submitTopology

import backtype.storm.generated.StormTopology; //導入依賴的package包/類
public static void submitTopology(String name, Map stormConf,
		StormTopology topology, SubmitOptions opts, List<File> jarFiles)
		throws AlreadyAliveException, InvalidTopologyException {
	Map<String, String> jars = new HashMap<String, String>(jarFiles.size());
	List<String> names = new ArrayList<String>(jarFiles.size());
	if (jarFiles == null)
		jarFiles = new ArrayList<File>();
	for (File f : jarFiles) {
		if (!f.exists()) {
			LOG.info(f.getName() + " is not existed: "
					+ f.getAbsolutePath());
			continue;
		}
		jars.put(f.getName(), f.getAbsolutePath());
		names.add(f.getName());
	}
	LOG.info("Files: " + names + " will be loaded");
	stormConf.put(GenericOptionsParser.TOPOLOGY_LIB_PATH, jars);
	stormConf.put(GenericOptionsParser.TOPOLOGY_LIB_NAME, names);
	submitTopology(name, stormConf, topology, opts);
}
 
開發者ID:greeenSY,項目名稱:Tstream,代碼行數:22,代碼來源:StormSubmitter.java


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