backtype.storm.generated.StormTopology Java Examples
The following examples show how to use
backtype.storm.generated.StormTopology.
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: TridentWordCount.java From flink-perf with Apache License 2.0 | 7 votes |
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(); }
Example #2
Source File: ExampleRunner.java From flowmix with Apache License 2.0 | 6 votes |
public void run() { StormTopology topology = new FlowmixBuilder() .setFlowLoader(new SimpleFlowLoaderSpout(provider.getFlows(), 60000)) .setEventsLoader(new MockEventGeneratorSpout(getMockEvents(), 10)) .setOutputBolt(new PrinterBolt()) .setParallelismHint(6) .create() .createTopology(); Config conf = new Config(); conf.setNumWorkers(20); conf.setMaxSpoutPending(5000); conf.setDebug(false); conf.registerSerialization(BaseEvent.class, EventSerializer.class); conf.setSkipMissingKryoRegistrations(false); LocalCluster cluster = new LocalCluster(); cluster.submitTopology("example-topology", conf, topology); }
Example #3
Source File: EventsimTopology.java From storm-solr with Apache License 2.0 | 6 votes |
public StormTopology build(StreamingApp app) throws Exception { SpringSpout eventsimSpout = new SpringSpout("eventsimSpout", spoutFields); SpringBolt collectionPerTimeFrameSolrBolt = new SpringBolt("collectionPerTimeFrameSolrBoltAction", app.tickRate("collectionPerTimeFrameSolrBoltAction")); // Send all docs for the same hash range to the same bolt instance, // which allows us to use a streaming approach to send docs to the leader int numShards = Integer.parseInt(String.valueOf(app.getStormConfig().get("spring.eventsimNumShards"))); HashRangeGrouping hashRangeGrouping = new HashRangeGrouping(app.getStormConfig(), numShards); int tasksPerShard = hashRangeGrouping.getNumShards()*2; TopologyBuilder builder = new TopologyBuilder(); builder.setSpout("eventsimSpout", eventsimSpout, app.parallelism("eventsimSpout")); builder.setBolt("collectionPerTimeFrameSolrBolt", collectionPerTimeFrameSolrBolt, tasksPerShard) .customGrouping("eventsimSpout", hashRangeGrouping); return builder.createTopology(); }
Example #4
Source File: AuditActiveLoginsTopology.java From Kafka-Storm-ElasticSearch with Apache License 2.0 | 6 votes |
public StormTopology buildTopology(Properties properties) { // Load properties for the storm topology String kafkaTopic = properties.getProperty("kafka.topic"); SpoutConfig kafkaConfig = new SpoutConfig(kafkaBrokerHosts, kafkaTopic, "", "storm"); kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme()); TopologyBuilder builder = new TopologyBuilder(); // Specific audit logs analysis bolts AuditLoginsCounterBolt loginCounterbolt = new AuditLoginsCounterBolt(); AuditParserBolt auditParserBolt = new AuditParserBolt(); // Elastic search bolt TupleMapper tupleMapper = new DefaultTupleMapper(); ElasticSearchBolt elasticSearchBolt = new ElasticSearchBolt(tupleMapper); // Topology scheme: KafkaSpout -> auditParserBolt -> loginCounterBolt -> elasticSearchBolt builder.setSpout("KafkaSpout", new KafkaSpout(kafkaConfig), 1); builder.setBolt("ParseBolt", auditParserBolt, 1).shuffleGrouping("KafkaSpout"); builder.setBolt("CountBolt", loginCounterbolt, 1).shuffleGrouping("ParseBolt"); builder.setBolt("ElasticSearchBolt", elasticSearchBolt, 1) .fieldsGrouping("CountBolt", new Fields("id", "index", "type", "document")); return builder.createTopology(); }
Example #5
Source File: TridentWordCount.java From storm-benchmark with Apache License 2.0 | 6 votes |
@Override public StormTopology getTopology(Config config) { final int spoutNum = BenchmarkUtils.getInt(config, SPOUT_NUM, DEFAULT_SPOUT_NUM); final int splitNum = BenchmarkUtils.getInt(config, SPLIT_NUM, DEFAULT_SPLIT_BOLT_NUM); final int countNum = BenchmarkUtils.getInt(config, COUNT_NUM, DEFAULT_COUNT_BOLT_NUM); spout = new TransactionalTridentKafkaSpout( KafkaUtils.getTridentKafkaConfig(config, new SchemeAsMultiScheme(new StringScheme()))); TridentTopology trident = new TridentTopology(); trident.newStream("wordcount", spout).name("sentence").parallelismHint(spoutNum).shuffle() .each(new Fields(StringScheme.STRING_SCHEME_KEY), new WordSplit(), new Fields("word")) .parallelismHint(splitNum) .groupBy(new Fields("word")) .persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("count")) .parallelismHint(countNum); /* trident.newStream("wordcount", spout) .each(new Fields(StringScheme.STRING_SCHEME_KEY), new WordSplit(), new Fields("word")) .groupBy(new Fields("word")) .persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("count"));*/ return trident.build(); }
Example #6
Source File: TCKTest.java From jstorm with Apache License 2.0 | 6 votes |
@Test public void testTopologySourceWithConfigMethods() throws Exception { TopologyDef topologyDef = FluxParser.parseResource("/configs/config-methods-test.yaml", false, true, null, false); assertTrue(topologyDef.validate()); Config conf = FluxBuilder.buildConfig(topologyDef); ExecutionContext context = new ExecutionContext(topologyDef, conf); StormTopology topology = FluxBuilder.buildTopology(context); assertNotNull(topology); topology.validate(); // make sure the property was actually set TestBolt bolt = (TestBolt)context.getBolt("bolt-1"); assertTrue(bolt.getFoo().equals("foo")); assertTrue(bolt.getBar().equals("bar")); assertTrue(bolt.getFooBar().equals("foobar")); }
Example #7
Source File: TopHashtagByCountry.java From trident-tutorial with Apache License 2.0 | 6 votes |
public static StormTopology buildTopology(TransactionalTridentKafkaSpout spout) throws IOException { TridentTopology topology = new TridentTopology(); TridentState count = topology .newStream("tweets", spout) .each(new Fields("str"), new ParseTweet(), new Fields("status", "content", "user")) .project(new Fields("content", "user", "status")) .each(new Fields("content"), new OnlyHashtags()) .each(new Fields("status"), new OnlyGeo()) .each(new Fields("status", "content"), new ExtractLocation(), new Fields("country", "contentName")) .groupBy(new Fields("country", "contentName")) .persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("count")) ; topology .newDRPCStream("location_hashtag_count") .stateQuery(count, new TupleCollectionGet(), new Fields("country", "contentName")) .stateQuery(count, new Fields("country", "contentName"), new MapGet(), new Fields("count")) .groupBy(new Fields("country")) .aggregate(new Fields("contentName", "count"), new FirstN.FirstNSortedAgg(3,"count", true), new Fields("contentName", "count")) ; return topology.build(); }
Example #8
Source File: LocalRunner.java From storm-benchmark with Apache License 2.0 | 6 votes |
private static void run(String name) throws ClassNotFoundException, IllegalAccessException, InstantiationException, AlreadyAliveException, InvalidTopologyException { LOG.info("running benchmark " + name); IBenchmark benchmark = (IBenchmark) Runner.getApplicationFromName(PACKAGE + "." + name); Config config = new Config(); config.putAll(Utils.readStormConfig()); config.setDebug(true); StormTopology topology = benchmark.getTopology(config); LocalCluster localCluster = new LocalCluster(); localCluster.submitTopology(name, config, topology); final int runtime = BenchmarkUtils.getInt(config, MetricsCollectorConfig.METRICS_TOTAL_TIME, MetricsCollectorConfig.DEFAULT_TOTAL_TIME); IMetricsCollector collector = benchmark.getMetricsCollector(config, topology); collector.run(); try { Thread.sleep(runtime); } catch (InterruptedException e) { LOG.error("benchmark interrupted", e); } localCluster.shutdown(); }
Example #9
Source File: ContextMaker.java From jstorm with Apache License 2.0 | 6 votes |
public TopologyContext makeTopologyContext(StormTopology topology, Integer taskId, clojure.lang.Atom openOrPrepareWasCalled) { Map stormConf = new HashMap(); stormConf.putAll(workerData.getStormConf()); String topologyId = workerData.getTopologyId(); HashMap<String, Map<String, Fields>> componentToStreamToFields = workerData.generateComponentToStreamToFields(topology); return new TopologyContext(topology, stormConf, workerData.getTasksToComponent(), workerData.getComponentToSortedTasks(), componentToStreamToFields, topologyId, resourcePath, workerId, taskId, workerData.getPort(), workerTasks, workerData.getDefaultResources(), workerData.getUserResources(), workerData.getExecutorData(), workerData.getRegisteredMetrics(), openOrPrepareWasCalled, workerData.getZkCluster()); }
Example #10
Source File: MovingAvgLocalTopologyRunner.java From hadoop-arch-book with Apache License 2.0 | 6 votes |
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(); //} }
Example #11
Source File: SimpleTopologySource.java From flux with Apache License 2.0 | 6 votes |
@Override public StormTopology getTopology(Map<String, Object> config) { TopologyBuilder builder = new TopologyBuilder(); // spouts FluxShellSpout spout = new FluxShellSpout( new String[]{"node", "randomsentence.js"}, new String[]{"word"}); builder.setSpout("sentence-spout", spout, 1); // bolts builder.setBolt("log-bolt", new LogInfoBolt(), 1) .shuffleGrouping("sentence-spout"); return builder.createTopology(); }
Example #12
Source File: TridentTopologySource.java From flux with Apache License 2.0 | 6 votes |
public StormTopology getTopology(Config config) { this.spout = new FixedBatchSpout(new Fields("sentence"), 20, new Values("one two"), new Values("two three"), new Values("three four"), new Values("four five"), new Values("five six") ); TridentTopology trident = new TridentTopology(); trident.newStream("wordcount", spout).name("sentence").parallelismHint(1).shuffle() .each(new Fields("sentence"), new Split(), new Fields("word")) .parallelismHint(1) .groupBy(new Fields("word")) .persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("count")) .parallelismHint(1); return trident.build(); }
Example #13
Source File: SimpleEMQTopology.java From galaxy-sdk-java with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { if (args == null || args.length != 1) { System.err.println("Usage: ./bin/storm jar " + "${your_topology-jar-with-dependencies.jar}" + "${package.path.main.class} ${config_file_for_the_topology}"); System.exit(-1); } // setup StormTopology String topologyConfigFile = args[0]; Map topologyConfig = ConfigHelper.getTopologyConfig(topologyConfigFile); SimpleEMQTopology topology = new SimpleEMQTopology(topologyConfig); StormTopology stormTopology = topology.buildTopology(); SubmitTopologyHelper.submitTopology(stormTopology, topologyConfig); }
Example #14
Source File: RollingSort.java From storm-benchmark with Apache License 2.0 | 6 votes |
@Override public StormTopology getTopology(Config config) { final int spoutNum = BenchmarkUtils.getInt(config, SPOUT_NUM, DEFAULT_SPOUT_NUM); final int boltNum = BenchmarkUtils.getInt(config, SORT_BOLT_NUM, DEFAULT_SORT_BOLT_NUM); final int msgSize = BenchmarkUtils.getInt(config, RandomMessageSpout.MESSAGE_SIZE, RandomMessageSpout.DEFAULT_MESSAGE_SIZE); final int chunkSize = BenchmarkUtils.getInt(config, SortBolt.CHUNK_SIZE, SortBolt.DEFAULT_CHUNK_SIZE); final int emitFreq = BenchmarkUtils.getInt(config, SortBolt.EMIT_FREQ, SortBolt.DEFAULT_EMIT_FREQ); spout = new RandomMessageSpout(msgSize, BenchmarkUtils.ifAckEnabled(config)); TopologyBuilder builder = new TopologyBuilder(); builder.setSpout(SPOUT_ID, spout, spoutNum); builder.setBolt(SORT_BOLT_ID, new SortBolt(emitFreq, chunkSize), boltNum) .localOrShuffleGrouping(SPOUT_ID); return builder.createTopology(); }
Example #15
Source File: GlobalTop20Hashtags.java From trident-tutorial with Apache License 2.0 | 6 votes |
public static StormTopology buildTopology(TransactionalTridentKafkaSpout spout) throws IOException { TridentTopology topology = new TridentTopology(); TridentState count = topology .newStream("tweets", spout) .each(new Fields("str"), new ParseTweet(), new Fields("text", "content", "user")) .project(new Fields("content", "user")) .each(new Fields("content"), new OnlyHashtags()) .each(new Fields("user"), new OnlyEnglish()) .each(new Fields("content", "user"), new ExtractFollowerClassAndContentName(), new Fields("followerClass", "contentName")) .groupBy(new Fields("followerClass", "contentName")) .persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("count")) ; topology .newDRPCStream("top_hashtags") .stateQuery(count, new TupleCollectionGet(), new Fields("followerClass", "contentName")) .stateQuery(count, new Fields("followerClass", "contentName"), new MapGet(), new Fields("count")) .aggregate(new Fields("contentName", "count"), new FirstN.FirstNSortedAgg(5,"count", true), new Fields("contentName", "count")) ; return topology.build(); }
Example #16
Source File: ServiceHandler.java From jstorm with Apache License 2.0 | 6 votes |
/** * get StormTopology throw deserialize local files * * @param id String: topology id * @return StormTopology */ @Override public StormTopology getTopology(String id) throws TException { StormTopology topology; try { StormTopology stormtopology = StormConfig.read_nimbus_topology_code(id, data.getBlobStore()); if (stormtopology == null) { throw new NotAliveException("No topology of " + id); } Map<Object, Object> topologyConf = (Map<Object, Object>) StormConfig.read_nimbus_topology_conf(id, data.getBlobStore()); topology = Common.system_topology(topologyConf, stormtopology); } catch (Exception e) { LOG.error("Failed to get topology " + id + ",", e); throw new TException("Failed to get system_topology"); } return topology; }
Example #17
Source File: TopologyContext.java From jstorm with Apache License 2.0 | 6 votes |
public TopologyContext(StormTopology topology, Map stormConf, Map<Integer, String> taskToComponent, Map<String, List<Integer>> componentToSortedTasks, Map<String, Map<String, Fields>> componentToStreamToFields, String stormId, String codeDir, String workerId, 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, StormClusterState zkCluster) { super(topology, stormConf, taskToComponent, componentToSortedTasks, componentToStreamToFields, stormId, codeDir, workerId, workerPort, workerTasks, defaultResources, userResources); _taskId = taskId; _executorData = executorData; _registeredMetrics = registeredMetrics; _openOrPrepareWasCalled = openOrPrepareWasCalled; _zkCluster = zkCluster; }
Example #18
Source File: FluxBuilder.java From jstorm with Apache License 2.0 | 6 votes |
private static StormTopology buildExternalTopology(ObjectDef def, ExecutionContext context) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException { Object topologySource = buildObject(def, context); String methodName = context.getTopologyDef().getTopologySource().getMethodName(); Method getTopology = findGetTopologyMethod(topologySource, methodName); if(getTopology.getParameterTypes()[0].equals(Config.class)){ Config config = new Config(); config.putAll(context.getTopologyDef().getConfig()); return (StormTopology) getTopology.invoke(topologySource, config); } else { return (StormTopology) getTopology.invoke(topologySource, context.getTopologyDef().getConfig()); } }
Example #19
Source File: TCKTest.java From flux with Apache License 2.0 | 5 votes |
@Test public void testHdfs() throws Exception { TopologyDef topologyDef = FluxParser.parseResource("/configs/hdfs_test.yaml", false, true, null, false); Config conf = FluxBuilder.buildConfig(topologyDef); ExecutionContext context = new ExecutionContext(topologyDef, conf); StormTopology topology = FluxBuilder.buildTopology(context); assertNotNull(topology); topology.validate(); }
Example #20
Source File: TCKTest.java From flux with Apache License 2.0 | 5 votes |
@Test public void testIncludes() throws Exception { TopologyDef topologyDef = FluxParser.parseResource("/configs/include_test.yaml", false, true, null, false); Config conf = FluxBuilder.buildConfig(topologyDef); ExecutionContext context = new ExecutionContext(topologyDef, conf); StormTopology topology = FluxBuilder.buildTopology(context); assertNotNull(topology); assertTrue(topologyDef.getName().equals("include-topology")); assertTrue(topologyDef.getBolts().size() > 0); assertTrue(topologyDef.getSpouts().size() > 0); topology.validate(); }
Example #21
Source File: TCKTest.java From flux with Apache License 2.0 | 5 votes |
@Test public void testTopologySourceWithGetMethodName() throws Exception { TopologyDef topologyDef = FluxParser.parseResource("/configs/existing-topology-reflection.yaml", false, true, null, false); assertTrue(topologyDef.validate()); Config conf = FluxBuilder.buildConfig(topologyDef); ExecutionContext context = new ExecutionContext(topologyDef, conf); StormTopology topology = FluxBuilder.buildTopology(context); assertNotNull(topology); topology.validate(); }
Example #22
Source File: ContextMaker.java From jstorm with Apache License 2.0 | 5 votes |
public WorkerTopologyContext makeWorkerTopologyContext(StormTopology topology) { Map stormConf = workerData.getStormConf(); String topologyId = workerData.getTopologyId(); HashMap<String, Map<String, Fields>> componentToStreamToFields = workerData.generateComponentToStreamToFields(topology); return new WorkerTopologyContext(topology, stormConf, workerData.getTasksToComponent(), workerData.getComponentToSortedTasks(), componentToStreamToFields, topologyId, resourcePath, workerId, workerData.getPort(), workerTasks, workerData.getDefaultResources(), workerData.getUserResources()); }
Example #23
Source File: StormBenchmark.java From storm-benchmark with Apache License 2.0 | 5 votes |
@Override public IMetricsCollector getMetricsCollector(Config config, StormTopology topology) { Set<MetricsItem> items = Sets.newHashSet( MetricsItem.SUPERVISOR_STATS, MetricsItem.TOPOLOGY_STATS, MetricsItem.THROUGHPUT, MetricsItem.SPOUT_THROUGHPUT, MetricsItem.SPOUT_LATENCY ); return new BasicMetricsCollector(config, topology, items); }
Example #24
Source File: ServiceHandler.java From jstorm with Apache License 2.0 | 5 votes |
/** * @return Map[task id, component id] */ public Map<Integer, TaskInfo> mkTaskComponentAssignments(Map<Object, Object> conf, String topologyId) throws IOException, InvalidTopologyException, KeyNotFoundException { // we can directly pass stormConf from submit method ? Map<Object, Object> stormConf = StormConfig.read_nimbus_topology_conf(topologyId, data.getBlobStore()); StormTopology rawTopology = StormConfig.read_nimbus_topology_code(topologyId, data.getBlobStore()); StormTopology topology = Common.system_topology(stormConf, rawTopology); return Common.mkTaskInfo(stormConf, topology, topologyId); }
Example #25
Source File: RecursiveTopology.java From storm-example with Apache License 2.0 | 5 votes |
public static StormTopology buildTopology() { LOG.info("Building topology."); TridentTopology topology = new TridentTopology(); // Work Queue / Spout LocalQueueEmitter<GameState> workSpoutEmitter = new LocalQueueEmitter<GameState>("WorkQueue"); LocalQueueSpout<GameState> workSpout = new LocalQueueSpout<GameState>(workSpoutEmitter); GameState initialState = new GameState(new Board(), new ArrayList<Board>(), "X"); workSpoutEmitter.enqueue(initialState); // Scoring Queue / Spout LocalQueueEmitter<GameState> scoringSpoutEmitter = new LocalQueueEmitter<GameState>("ScoringQueue"); Stream inputStream = topology.newStream("gamestate", workSpout); inputStream.each(new Fields("gamestate"), new isEndGame()) .each(new Fields("gamestate"), new LocalQueuerFunction<GameState>(scoringSpoutEmitter), new Fields("")); inputStream.each(new Fields("gamestate"), new GenerateBoards(), new Fields("children")) .each(new Fields("children"), new LocalQueuerFunction<GameState>(workSpoutEmitter), new Fields()); return topology.build(); }
Example #26
Source File: SimpleEMQTopology.java From galaxy-sdk-java with Apache License 2.0 | 5 votes |
private StormTopology buildTopology() { TopologyBuilder topologyBuilder = new TopologyBuilder(); EMQSpout spout = new EMQSpout(getEMQConfig()); LogBolt bolt = new LogBolt(); topologyBuilder.setSpout("spout", spout, 4); topologyBuilder.setBolt("bolt", bolt).shuffleGrouping("spout"); return topologyBuilder.createTopology(); }
Example #27
Source File: StormAbstractCloudLiveTest.java From brooklyn-library with Apache License 2.0 | 5 votes |
public boolean submitTopology(StormTopology stormTopology, String topologyName, int numOfWorkers, boolean debug, long timeoutMs) { if (log.isDebugEnabled()) log.debug("Connecting to NimbusClient: {}", nimbus.getConfig(Storm.NIMBUS_HOSTNAME)); Config conf = new Config(); conf.setDebug(debug); conf.setNumWorkers(numOfWorkers); // TODO - confirm this creats the JAR correctly String jar = createJar( new File(Os.mergePaths(ResourceUtils.create(this).getClassLoaderDir(), "org/apache/brooklyn/entity/messaging/storm/topologies")), "org/apache/brooklyn/entity/messaging/storm/"); System.setProperty("storm.jar", jar); long startMs = System.currentTimeMillis(); long endMs = (timeoutMs == -1) ? Long.MAX_VALUE : (startMs + timeoutMs); long currentTime = startMs; Throwable lastError = null; int attempt = 0; while (currentTime <= endMs) { currentTime = System.currentTimeMillis(); if (attempt != 0) Time.sleep(Duration.ONE_SECOND); if (log.isTraceEnabled()) log.trace("trying connection to {} at time {}", nimbus.getConfig(Storm.NIMBUS_HOSTNAME), currentTime); try { StormSubmitter.submitTopology(topologyName, conf, stormTopology); return true; } catch (Exception e) { if (shouldRetryOn(e)) { if (log.isDebugEnabled()) log.debug("Attempt {} failed connecting to {} ({})", new Object[] {attempt + 1, nimbus.getConfig(Storm.NIMBUS_HOSTNAME), e.getMessage()}); lastError = e; } else { throw Throwables.propagate(e); } } attempt++; } log.warn("unable to connect to Nimbus client: ", lastError); Assert.fail(); return false; }
Example #28
Source File: GeneralTopologyContext.java From jstorm with Apache License 2.0 | 5 votes |
public GeneralTopologyContext(StormTopology topology, Map stormConf, Map<Integer, String> taskToComponent, Map<String, List<Integer>> componentToSortedTasks, Map<String, Map<String, Fields>> componentToStreamToFields, String topologyId) { _topology = topology; _stormConf = stormConf; _taskToComponent = taskToComponent; _topologyId = topologyId; _componentToTasks = componentToSortedTasks; _componentToStreamToFields = componentToStreamToFields; _topologyMasterId = _componentToTasks.get("__topology_master").get(0); }
Example #29
Source File: TridentReach.java From flink-perf with Apache License 2.0 | 5 votes |
public static StormTopology buildTopology(LocalDRPC drpc) { TridentTopology topology = new TridentTopology(); TridentState urlToTweeters = topology.newStaticState(new StaticSingleKeyMapState.Factory(TWEETERS_DB)); TridentState tweetersToFollowers = topology.newStaticState(new StaticSingleKeyMapState.Factory(FOLLOWERS_DB)); topology.newDRPCStream("reach", drpc).stateQuery(urlToTweeters, new Fields("args"), new MapGet(), new Fields( "tweeters")).each(new Fields("tweeters"), new ExpandList(), new Fields("tweeter")).shuffle().stateQuery( tweetersToFollowers, new Fields("tweeter"), new MapGet(), new Fields("followers")).each(new Fields("followers"), new ExpandList(), new Fields("follower")).groupBy(new Fields("follower")).aggregate(new One(), new Fields( "one")).aggregate(new Fields("one"), new Sum(), new Fields("reach")); return topology.build(); }
Example #30
Source File: KafkaProducer.java From storm-benchmark with Apache License 2.0 | 5 votes |
@Override public StormTopology getTopology(Config config) { config.putAll(getKafkaConfig(config)); final int spoutNum = BenchmarkUtils.getInt(config , SPOUT_NUM, DEFAULT_SPOUT_NUM); final int boltNum = BenchmarkUtils.getInt(config, BOLT_NUM, DEFAULT_BOLT_NUM); TopologyBuilder builder = new TopologyBuilder(); builder.setSpout(SPOUT_ID, spout, spoutNum); builder.setBolt(BOLT_ID, bolt, boltNum).localOrShuffleGrouping(SPOUT_ID); return builder.createTopology(); }