/// <summary> /// Use Topology Specification API to describe the topology /// </summary> /// <returns></returns> public ITopologyBuilder GetTopologyBuilder() { // Use TopologyBuilder to define a Non-Tx topology // And define each spouts/bolts one by one TopologyBuilder topologyBuilder = new TopologyBuilder("HelloWorldHostModeMultiSpout"); // Set a User customized config (SentenceGenerator.config) for the SentenceGenerator topologyBuilder.SetSpout( "SentenceGenerator", SentenceGenerator.Get, new Dictionary <string, List <string> >() { { SentenceGenerator.STREAM_ID, new List <string>() { "sentence" } } }, 1, "SentenceGenerator.config"); topologyBuilder.SetSpout( "PersonGenerator", PersonGenerator.Get, new Dictionary <string, List <string> >() { { PersonGenerator.STREAM_ID, new List <string>() { "person" } } }, 1); topologyBuilder.SetBolt( "displayer", Displayer.Get, new Dictionary <string, List <string> >(), 1) .shuffleGrouping("SentenceGenerator", SentenceGenerator.STREAM_ID) .shuffleGrouping("PersonGenerator", PersonGenerator.STREAM_ID); // Demo how to set topology config topologyBuilder.SetTopologyConfig(new Dictionary <string, string>() { { "topology.kryo.register", "[\"[B\"]" } }); return(topologyBuilder); }
public ITopologyBuilder GetTopologyBuilder() { TopologyBuilder topologyBuilder = new TopologyBuilder(typeof(TwitterTopology).Name + DateTime.Now.ToString("-yyyyMMddHHmmss")); topologyBuilder.SetSpout( typeof(TwitterSpout).Name, TwitterSpout.Get, new Dictionary<string, List<string>>() { {Constants.DEFAULT_STREAM_ID, new List<string>(){"tweet"}} }, 1); topologyBuilder.SetBolt( typeof(TwitterBolt).Name, TwitterBolt.Get, new Dictionary<string, List<string>>() { {Constants.DEFAULT_STREAM_ID, new List<string>(){"count", "tweet"}} }, 1).shuffleGrouping(typeof(TwitterSpout).Name); topologyBuilder.SetBolt( typeof(SqlAzureBolt).Name, SqlAzureBolt.Get, new Dictionary<string, List<string>>(), 1).shuffleGrouping(typeof(TwitterBolt).Name); topologyBuilder.SetBolt( typeof(SignalRBroadcastBolt).Name, SignalRBroadcastBolt.Get, new Dictionary<string, List<string>>(), 1).shuffleGrouping(typeof(TwitterBolt).Name); return topologyBuilder; }
public ITopologyBuilder GetTopologyBuilder() { appConfig = new AppConfig(); TopologyBuilder topologyBuilder = new TopologyBuilder(this.GetType().Name); topologyBuilder.SetSpout( typeof(EventGenerator).Name, EventGenerator.Get, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, new List <string>() { "Event" } } }, appConfig.EventHubPartitions ); topologyBuilder.SetBolt( typeof(EventHubWriter).Name, EventHubWriter.Get, new Dictionary <string, List <string> >(), appConfig.EventHubPartitions ). shuffleGrouping(typeof(EventGenerator).Name); var topologyConfig = new StormConfig(); topologyConfig.setNumWorkers(8); topologyConfig.setMaxSpoutPending(1600); topologyBuilder.SetTopologyConfig(topologyConfig); return(topologyBuilder); }
public ITopologyBuilder GetTopologyBuilder() { var topologyBuilder = new TopologyBuilder(typeof(SqlAzureWriterTopology).Name + DateTime.Now.ToString("yyyyMMddHHmmss")); //Component tasks expect output field names in TopologyBuilder topologyBuilder.SetSpout( typeof(IISLogGeneratorSpout).Name, //Set task name IISLogGeneratorSpout.Get, //Set task constructor delegate new Dictionary<string, List<string>>() { {Constants.DEFAULT_STREAM_ID, IISLogGeneratorSpout.OutputFields} }, 1, //Set number of tasks true //Set enableAck ); topologyBuilder.SetBolt( typeof(SqlAzureBolt).Name, //Set task name SqlAzureBolt.Get, //Set task constructor delegate new Dictionary<string, List<string>>(), //Leave empty if the task has no outputSchema defined i.e. no outgoing tuples 1, //Set number of tasks true //Set enableAck ). globalGrouping(typeof(IISLogGeneratorSpout).Name); //Set the topology config var topologyConfig = new StormConfig(); topologyConfig.setNumWorkers(1); //Set number of worker processes topologyConfig.setMaxSpoutPending(512); //Set maximum pending tuples from spout topologyConfig.setWorkerChildOps("-Xmx768m"); //Set Java Heap Size topologyBuilder.SetTopologyConfig(topologyConfig); return topologyBuilder; }
public ITopologyBuilder GetTopologyBuilder() { TopologyBuilder topologyBuilder = new TopologyBuilder("TwitterStreaming" + DateTime.Now.ToString("yyyyMMddHHmmss")); topologyBuilder.SetSpout( "TwitterSpout", TwitterSpout.Get, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, TwitterSpout.OutputSchemaName } }, 1, true); var boltConfig = new StormConfig(); boltConfig.Set("topology.tick.tuple.freq.secs", "20"); topologyBuilder.SetBolt( "TopNTweetBolt", TopNTweetBolt.Get, new Dictionary <string, List <string> >() { { "TOPNTWEETS_STREAM", TopNTweetBolt.OutputSchemaName } }, 1, true) .shuffleGrouping("TwitterSpout") .addConfigurations(boltConfig); topologyBuilder.SetBolt( "AzureSqlBolt", AzureSqlBolt.Get, new Dictionary <string, List <string> >(), 1).shuffleGrouping("TopNTweetBolt", "TOPNTWEETS_STREAM"); return(topologyBuilder); }
/// <summary> /// Defines and configures the topology /// </summary> /// <returns></returns> public ITopologyBuilder GetTopologyBuilder() { //Define a new topology named "EventTopology" TopologyBuilder topologyBuilder = new TopologyBuilder("EventTopology"); //The spout, which emits events topologyBuilder.SetSpout( "Spout", Spout.Get, new Dictionary<string, List<string>>() { {Constants.DEFAULT_STREAM_ID, new List<string>(){"id", "event", "eventtime"}} }, 1); //A bolt that is used to look up previous events for the same session from HBase //If this is an end event, the time span between the start and end events is //emitted as 'duration' topologyBuilder.SetBolt( "Lookup", HBaseLookupBolt.Get, new Dictionary<string, List<string>>() { {Constants.DEFAULT_STREAM_ID, new List<string>(){"id", "event", "eventtime", "duration"}} }, 1).shuffleGrouping("Spout"); //A bolt that writes events to HBase topologyBuilder.SetBolt( "Store", HBaseBolt.Get, new Dictionary<string, List<string>>(), 1).shuffleGrouping("Lookup"); return topologyBuilder; }
public ITopologyBuilder GetTopologyBuilder() { var topologyBuilder = new TopologyBuilder(typeof(DocumentDBWriterTopology).Name + DateTime.Now.ToString("yyyyMMddHHmmss")); topologyBuilder.SetSpout( typeof(VehicleRecordGeneratorSpoutForDocumentDB).Name, //Set task name VehicleRecordGeneratorSpoutForDocumentDB.Get, //Set task constructor delegate new Dictionary<string, List<string>>() { { Constants.DEFAULT_STREAM_ID, VehicleRecordGeneratorSpoutForDocumentDB.OutputFields } }, 1, //Set number of tasks true //Set enableAck ); //Store the incoming Vehicle records in DocumentDb topologyBuilder.SetBolt( typeof(DocumentDbBolt).Name, //Set task name DocumentDbBolt.Get, //Set task constructor delegate new Dictionary<string, List<string>>(), //Leave empty if the task has no outputSchema defined i.e. no outgoing tuples 1, //Set number of tasks true //Set enableAck ). globalGrouping(typeof(VehicleRecordGeneratorSpoutForDocumentDB).Name); //Choose grouping //Set the topology config var topologyConfig = new StormConfig(); topologyConfig.setNumWorkers(1); //Set number of worker processes topologyConfig.setMaxSpoutPending(512); //Set maximum pending tuples from spout topologyConfig.setWorkerChildOps("-Xmx768m"); //Set Java Heap Size topologyBuilder.SetTopologyConfig(topologyConfig); return topologyBuilder; }
public ITopologyBuilder GetTopologyBuilder() { var topologyBuilder = new TopologyBuilder(typeof(HBaseLookupTopology).Name + DateTime.Now.ToString("yyyyMMddHHmmss")); topologyBuilder.SetSpout( typeof(VehicleRecordGeneratorSpoutForHBase).Name, //Set task name VehicleRecordGeneratorSpoutForHBase.Get, //Set task constructor delegate new Dictionary<string, List<string>>() { { Constants.DEFAULT_STREAM_ID, VehicleRecordGeneratorSpoutForHBase.OutputFields } }, 1, //Set number of tasks true //Set enableAck ); topologyBuilder.SetBolt( typeof(HBaseLookupBolt).Name, //Set task name HBaseLookupBolt.Get, //Set task constructor delegate new Dictionary<string, List<string>>() { { Constants.DEFAULT_STREAM_ID, VehicleRecordGeneratorSpoutForHBase.OutputFields } }, 1, //Set number of tasks true //Set enableAck ). globalGrouping(typeof(VehicleRecordGeneratorSpoutForHBase).Name); //Set the topology config var topologyConfig = new StormConfig(); topologyConfig.setNumWorkers(1); //Set number of worker processes topologyConfig.setMaxSpoutPending(512); //Set maximum pending tuples from spout topologyConfig.setWorkerChildOps("-Xmx768m"); //Set Java Heap Size topologyBuilder.SetTopologyConfig(topologyConfig); return topologyBuilder; }
public ITopologyBuilder GetTopologyBuilder() { TopologyBuilder topoBuilder = new TopologyBuilder("TwitterSentimentAnalysis" + DateTime.Now.ToString("yyyyMMddHHmmss")); topoBuilder.SetSpout("TwitterReaderSpout", TwitterReaderSpout.Get, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, TwitterReaderSpout.OutputSchemaName } }, 1, true); // create a bolt with tick frequence of 10 secs to emit tuple var boltConfig = new StormConfig(); boltConfig.Set("topology.tick.tuple.freq.secs", "10"); topoBuilder.SetBolt("TweetRankBolt", TweetRankBolt.Get, new Dictionary <string, List <string> >() { { "TWEETRANK_STREAM", TweetRankBolt.OutputSchemaName } }, 1, true) .shuffleGrouping("TwitterReaderSpout") .addConfigurations(boltConfig); topoBuilder.SetBolt( "AzureSqlBolt", AzureSqlBolt.Get, new Dictionary <string, List <string> >(), 1).shuffleGrouping("TweetRankBolt", "TWEETRANK_STREAM"); return(topoBuilder); }
public ITopologyBuilder GetTopologyBuilder() { var topologyBuilder = new TopologyBuilder(typeof(DocumentDBLookupTopology).Name + DateTime.Now.ToString("yyyyMMddHHmmss")); topologyBuilder.SetSpout( typeof(VehicleRecordGeneratorSpoutForDocumentDB).Name, //Set task name VehicleRecordGeneratorSpoutForDocumentDB.Get, //Set task constructor delegate new Dictionary<string, List<string>>() { { Constants.DEFAULT_STREAM_ID, VehicleRecordGeneratorSpoutForDocumentDB.OutputFields } }, 1, true); topologyBuilder.SetBolt( typeof(DocumentDbLookupBolt).Name, //Set task name DocumentDbLookupBolt.Get, //Set task constructor delegate //Set the output field names - As DocumentDb return a JSON object, we will be expecting only 1 field new Dictionary<string, List<string>>() { { Constants.DEFAULT_STREAM_ID, VehicleRecordGeneratorSpoutForDocumentDB.OutputFields } }, 1, true). globalGrouping(typeof(VehicleRecordGeneratorSpoutForDocumentDB).Name); //Set the topology config var topologyConfig = new StormConfig(); topologyConfig.setNumWorkers(1); //Set number of worker processes topologyConfig.setMaxSpoutPending(512); //Set maximum pending tuples from spout topologyConfig.setWorkerChildOps("-Xmx768m"); //Set Java Heap Size topologyBuilder.SetTopologyConfig(topologyConfig); return topologyBuilder; }
public ITopologyBuilder GetTopologyBuilder() { appConfig = new AppConfig(); TopologyBuilder topologyBuilder = new TopologyBuilder(this.GetType().Name); topologyBuilder.SetSpout( typeof(EventGenerator).Name, EventGenerator.Get, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, new List <string>() { "Event" } } }, appConfig.EventHubPartitions ); topologyBuilder.SetBolt( typeof(EventHubWriter).Name, EventHubWriter.Get, new Dictionary <string, List <string> >(), appConfig.EventHubPartitions ). shuffleGrouping(typeof(EventGenerator).Name); topologyBuilder.SetTopologyConfig(new Dictionary <string, string>() { { "topology.workers", "8" }, { "topology.max.spout.pending", "16000" } }); return(topologyBuilder); }
/// <summary> /// Use Topology Specification API to describe the topology /// </summary> /// <returns></returns> public ITopologyBuilder GetTopologyBuilder() { // Use TopologyBuilder to define a Non-Tx topology // And define each spouts/bolts one by one TopologyBuilder topologyBuilder = new TopologyBuilder(typeof(HelloWorld).Name + DateTime.Now.ToString("yyyyMMddHHmmss")); // Set a User customized config (Generator.config) for the Generator topologyBuilder.SetSpout( "generator", Generator.Get, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, new List <string>() { "sentence" } } }, 1, "Generator.config"); topologyBuilder.SetBolt( "splitter", Splitter.Get, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, new List <string>() { "word", "firstLetterOfWord" } } }, 1).shuffleGrouping("generator"); // Use scp-field-group from Splitter to Counter, // and specify the second field in the Output schema of Splitter (Input schema of Counter) as the field grouping target // by passing the index array [1] (index start from 0) topologyBuilder.SetBolt( "counter", Counter.Get, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, new List <string>() { "word", "count" } } }, 1).fieldsGrouping("splitter", new List <int>() { 1 }); // Add topology config topologyBuilder.SetTopologyConfig(new Dictionary <string, string>() { { "topology.kryo.register", "[\"[B\"]" } }); return(topologyBuilder); }
public ITopologyBuilder GetTopologyBuilder() { TopologyBuilder topologyBuilder = new TopologyBuilder("HybridTopology_csharpSpout_javaCsharpBolt"); // Demo how to set a customized JSON Deserializer to deserialize a JSON string into Java object (to send to a Java Bolt) // Here, fullname of the Java JSON Deserializer class and target deserialized class are required List<string> javaDeserializerInfo = new List<string>() { "microsoft.scp.storm.multilang.CustomizedInteropJSONDeserializer", "microsoft.scp.example.HybridTopology.Person" }; topologyBuilder.SetSpout( "generator", Generator.Get, new Dictionary<string, List<string>>() { {Constants.DEFAULT_STREAM_ID, new List<string>(){"person"}} }, 1, null).DeclareCustomizedJavaDeserializer(javaDeserializerInfo); // Demo how to set parameters to initialize the constructor of Java Spout/Bolt JavaComponentConstructor constructor = new JavaComponentConstructor( "microsoft.scp.example.HybridTopology.Displayer", new List<Tuple<string, object>>() { Tuple.Create<string, object>(JavaComponentConstructor.JAVA_PRIMITIVE_TYPE_INT, 100), Tuple.Create<string, object>(JavaComponentConstructor.JAVA_LANG_STRING, "test"), Tuple.Create<string, object>(JavaComponentConstructor.JAVA_LANG_STRING, string.Empty) }); // The java bolt "java_displayer" receives from the C# spout "generator" topologyBuilder.SetJavaBolt( "java_displayer", constructor, 1).shuffleGrouping("generator"); // Demo how to set a customized JSON Serializer to serialize a Java object (emitted by Java Spout) into JSON string // Here, fullname of the Java JSON Serializer class is required List<string> javaSerializerInfo = new List<string>() { "microsoft.scp.storm.multilang.CustomizedInteropJSONSerializer" }; // The C# bolt "csharp-displayer" receive from the C# spout "generator" topologyBuilder.SetBolt( "csharp-displayer", Displayer.Get, new Dictionary<string, List<string>>(), 1). DeclareCustomizedJavaSerializer(javaSerializerInfo). shuffleGrouping("generator"); // Demo how to set topology config StormConfig conf = new StormConfig(); conf.setDebug(false); conf.setNumWorkers(1); conf.setStatsSampleRate(0.05); conf.setWorkerChildOps("-Xmx1024m"); conf.Set("topology.kryo.register", "[\"[B\"]"); topologyBuilder.SetTopologyConfig(conf); return topologyBuilder; }
public ITopologyBuilder GetTopologyBuilder() { appConfig = new AppConfig(); TopologyBuilder topologyBuilder = new TopologyBuilder(this.GetType().Name); // Set a customized JSON Deserializer to deserialize a C# object (emitted by C# Spout) into JSON string for Java to Deserialize // Here, fullname of the Java JSON Deserializer class is required followed by the Java types for each of the fields List <string> javaDeserializerInfo = new List <string>() { "microsoft.scp.storm.multilang.CustomizedInteropJSONDeserializer", "java.lang.String" }; topologyBuilder.SetSpout( typeof(EventGenerator).Name, EventGenerator.Get, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, new List <string>() { "Event" } } }, appConfig.EventHubPartitions, true ). DeclareCustomizedJavaDeserializer(javaDeserializerInfo); //We will use CreateFromClojureExpr method as we wish to pass in a complex Java object //The EventHubBolt takes a EventHubBoltConfig that we will create using clojure //NOTE: We need to escape the quotes for strings that need to be passes to clojure JavaComponentConstructor constructor = JavaComponentConstructor.CreateFromClojureExpr( String.Format(@"(com.microsoft.eventhubs.bolt.EventHubBolt. (com.microsoft.eventhubs.bolt.EventHubBoltConfig. " + @"""{0}"" ""{1}"" ""{2}"" ""{3}"" ""{4}"" {5}))", appConfig.EventHubSharedAccessKeyName, appConfig.EventHubSharedAccessKey, appConfig.EventHubNamespace, appConfig.EventHubFqnAddress, appConfig.EventHubEntityPath, "true")); topologyBuilder.SetJavaBolt( "EventHubBolt", constructor, appConfig.EventHubPartitions ). shuffleGrouping(typeof(EventGenerator).Name); //Assuming a 4 'L' node cluster, we will have 16 worker slots available //We will half of those slots for this topology topologyBuilder.SetTopologyConfig(new Dictionary <string, string>() { { "topology.workers", "8" }, { "topology.max.spout.pending", "1600" } }); return(topologyBuilder); }
/// <summary> /// Use Topology Specification API to describe the topology /// </summary> /// <returns></returns> public ITopologyBuilder GetTopologyBuilder() { // Use TopologyBuilder to define a Non-Tx topology // And define each spouts/bolts one by one TopologyBuilder topologyBuilder = new TopologyBuilder("HelloWorldHostModeMultiSpout"); // Set a User customized config (SentenceGenerator.config) for the SentenceGenerator topologyBuilder.SetSpout( "SentenceGenerator", SentenceGenerator.Get, new Dictionary<string, List<string>>() { {SentenceGenerator.STREAM_ID, new List<string>(){"sentence"}} }, 1, "SentenceGenerator.config"); topologyBuilder.SetSpout( "PersonGenerator", PersonGenerator.Get, new Dictionary<string, List<string>>() { {PersonGenerator.STREAM_ID, new List<string>(){"person"}} }, 1); topologyBuilder.SetBolt( "displayer", Displayer.Get, new Dictionary<string, List<string>>(), 1) .shuffleGrouping("SentenceGenerator", SentenceGenerator.STREAM_ID) .shuffleGrouping("PersonGenerator", PersonGenerator.STREAM_ID); // Demo how to set topology config topologyBuilder.SetTopologyConfig(new Dictionary<string, string>() { {"topology.kryo.register","[\"[B\"]"} }); return topologyBuilder; }
/// <summary> /// Builds a topology that can be submitted to Storm on HDInsight /// </summary> /// <returns>A topology builder</returns> public ITopologyBuilder GetTopologyBuilder() { //The friendly name is 'EventHubWriter' TopologyBuilder topologyBuilder = new TopologyBuilder("EventHubWriter" + DateTime.Now.ToString("yyyyMMddHHmmss")); //Get the partition count int partitionCount = int.Parse(ConfigurationManager.AppSettings["EventHubPartitionCount"]); //Create a deserializer for JSON to java.lang.String //so that Java components can consume data emitted by //C# components List <string> javaDeserializerInfo = new List <string>() { "microsoft.scp.storm.multilang.CustomizedInteropJSONDeserializer", "java.lang.String" }; //Set the spout topologyBuilder.SetSpout( "Spout", Spout.Get, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, new List <string>() { "Event" } } }, partitionCount). //Parallelism hint uses partition count DeclareCustomizedJavaDeserializer(javaDeserializerInfo); //Deserializer for the output stream //Create constructor for the Java bolt JavaComponentConstructor constructor = JavaComponentConstructor.CreateFromClojureExpr( String.Format(@"(org.apache.storm.eventhubs.bolt.EventHubBolt. (org.apache.storm.eventhubs.bolt.EventHubBoltConfig. " + @"""{0}"" ""{1}"" ""{2}"" ""{3}"" ""{4}"" {5}))", ConfigurationManager.AppSettings["EventHubPolicyName"], ConfigurationManager.AppSettings["EventHubPolicyKey"], ConfigurationManager.AppSettings["EventHubNamespace"], "servicebus.windows.net", //suffix for servicebus fqdn ConfigurationManager.AppSettings["EventHubName"], "true")); topologyBuilder.SetJavaBolt( "EventHubBolt", constructor, partitionCount). //Parallelism hint uses partition count shuffleGrouping("Spout"); //Consume data from spout StormConfig config = new StormConfig(); config.setNumWorkers(1); //Set the number of workers topologyBuilder.SetTopologyConfig(config); return(topologyBuilder); }
public ITopologyBuilder GetTopologyBuilder() { var topologyBuilder = new TopologyBuilder(typeof(EventHubWriterTopology).Name + DateTime.Now.ToString("yyyyMMddHHmmss")); topologyBuilder.SetSpout( typeof(IISLogGeneratorSpout).Name, //Set task name IISLogGeneratorSpout.Get, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, IISLogGeneratorSpout.OutputFields } }, 1, //Set number of tasks true //Set enableAck ); topologyBuilder.SetBolt( typeof(LoggerBolt).Name, //Set task name LoggerBolt.Get, //Set task constructor delegate new Dictionary <string, List <string> >(), //Leave empty if the task has no outputSchema defined i.e. no outgoing tuples 1, //Set number of tasks true //Set enableAck ). globalGrouping(typeof(IISLogGeneratorSpout).Name); var EventHubPartitions = ConfigurationManager.AppSettings["EventHubPartitions"]; if (String.IsNullOrWhiteSpace(EventHubPartitions)) { throw new ArgumentException("A required AppSetting cannot be null or empty", "EventHubPartitions"); } var partitionCount = int.Parse(EventHubPartitions); topologyBuilder.SetBolt( typeof(EventHubBolt).Name, //Set task name EventHubBolt.Get, //Set task constructor delegate new Dictionary <string, List <string> >(), //Leave empty if the task has no outputSchema defined i.e. no outgoing tuples partitionCount, //Set number of tasks true //Set enableAck ). globalGrouping(typeof(IISLogGeneratorSpout).Name); //Set the topology config var topologyConfig = new StormConfig(); topologyConfig.setNumWorkers(1); //Set number of worker processes topologyConfig.setMaxSpoutPending(512); //Set maximum pending tuples from spout topologyConfig.setWorkerChildOps("-Xmx768m"); //Set Java Heap Size topologyBuilder.SetTopologyConfig(topologyConfig); return(topologyBuilder); }
public ITopologyBuilder GetTopologyBuilder() { // use TopologyBuilder to define topology and define each spout/bolt one by one TopologyBuilder topologyBuilder = new TopologyBuilder("SimplestWordCount" + DateTime.Now.ToString("yyyyMMddHHmmss")); topologyBuilder.SetSpout( "sentenceSpout", SentenceSpout.Get, new Dictionary <string, List <string> >() { // name the 1-tuple's single field as 'sentence' { Constants.DEFAULT_STREAM_ID, new List <string>() { "sentence" } } }, 1); // initial nbr of instances of this spout (same for bolts below) topologyBuilder.SetBolt( "splitterBolt", SplitterBolt.Get, new Dictionary <string, List <string> >() { // name the 1-tuple's single field as 'word' { Constants.DEFAULT_STREAM_ID, new List <string>() { "word" } } }, // wire it up to the stream from the sentence generator 2).shuffleGrouping("sentenceSpout"); topologyBuilder.SetBolt( "counterBolt", CounterBolt.Get, new Dictionary <string, List <string> >() { // name the 2-tuple's fields as 'word' and 'count' { Constants.DEFAULT_STREAM_ID, new List <string>() { "word", "count" } } }, // wire it up to the stream from the sentence splitting bolt 3).fieldsGrouping("splitterBolt", new List <int>() { 0 }); // ^^^^^ make sure every instance of specific word goes to same bolt instance return(topologyBuilder); }
public ITopologyBuilder GetTopologyBuilder() { appConfig = new AppConfig(); TopologyBuilder topologyBuilder = new TopologyBuilder(this.GetType().Name); // Set a customized JSON Deserializer to deserialize a C# object (emitted by C# Spout) into JSON string for Java to Deserialize // Here, fullname of the Java JSON Deserializer class is required followed by the Java types for each of the fields List<string> javaDeserializerInfo = new List<string>() { "microsoft.scp.storm.multilang.CustomizedInteropJSONDeserializer", "java.lang.String" }; topologyBuilder.SetSpout( typeof(EventGenerator).Name, EventGenerator.Get, new Dictionary<string, List<string>>() { {Constants.DEFAULT_STREAM_ID, new List<string>(){"Event"}} }, appConfig.EventHubPartitions, true ). DeclareCustomizedJavaDeserializer(javaDeserializerInfo); //We will use CreateFromClojureExpr method as we wish to pass in a complex Java object //The EventHubBolt takes a EventHubBoltConfig that we will create using clojure //NOTE: We need to escape the quotes for strings that need to be passes to clojure JavaComponentConstructor constructor = JavaComponentConstructor.CreateFromClojureExpr( String.Format(@"(com.microsoft.eventhubs.bolt.EventHubBolt. (com.microsoft.eventhubs.bolt.EventHubBoltConfig. " + @"""{0}"" ""{1}"" ""{2}"" ""{3}"" ""{4}"" {5}))", appConfig.EventHubSharedAccessKeyName, appConfig.EventHubSharedAccessKey, appConfig.EventHubNamespace, appConfig.EventHubFqnAddress, appConfig.EventHubEntityPath, "true")); topologyBuilder.SetJavaBolt( "EventHubBolt", constructor, appConfig.EventHubPartitions ). shuffleGrouping(typeof(EventGenerator).Name); //Assuming a 4 'L' node cluster, we will have 16 worker slots available //We will half of those slots for this topology topologyBuilder.SetTopologyConfig(new Dictionary<string, string>() { {"topology.workers", appConfig.EventHubPartitions.ToString()}, {"topology.max.spout.pending","4096"} }); return topologyBuilder; }
public ITopologyBuilder GetTopologyBuilder() { TopologyBuilder topologyBuilder = new TopologyBuilder("HybridTopology_csharpSpout_javaBolt"); // Demo how to set a customized JSON Deserializer to deserialize a JSON string into Java object (to send to a Java Bolt) // Here, fullname of the Java JSON Deserializer class and target deserialized class are required List <string> javaDeserializerInfo = new List <string>() { "microsoft.scp.storm.multilang.CustomizedInteropJSONDeserializer", "microsoft.scp.example.HybridTopology.Person" }; topologyBuilder.SetSpout( "generator", Generator.Get, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, new List <string>() { "person" } } }, 1, null).DeclareCustomizedJavaDeserializer(javaDeserializerInfo); // Demo how to set parameters to initialize the constructor of Java Spout/Bolt JavaComponentConstructor constructor = new JavaComponentConstructor( "microsoft.scp.example.HybridTopology.Displayer", new List <Tuple <string, object> >() { Tuple.Create <string, object>(JavaComponentConstructor.JAVA_PRIMITIVE_TYPE_INT, 100), Tuple.Create <string, object>(JavaComponentConstructor.JAVA_LANG_STRING, "test"), Tuple.Create <string, object>(JavaComponentConstructor.JAVA_LANG_STRING, string.Empty) }); topologyBuilder.SetJavaBolt( "displayer", constructor, 1).shuffleGrouping("generator"); // Demo how to set topology config StormConfig conf = new StormConfig(); conf.setDebug(false); conf.setNumWorkers(1); conf.setStatsSampleRate(0.05); conf.setWorkerChildOps("-Xmx1024m"); conf.Set("topology.kryo.register", "[\"[B\"]"); topologyBuilder.SetTopologyConfig(conf); return(topologyBuilder); }
public ITopologyBuilder GetTopologyBuilder() { TopologyBuilder topologyBuilder = new TopologyBuilder("HybridTopology_csharpSpout_javaBolt"); // Demo how to set a customized JSON Deserializer to deserialize a JSON string into Java object (to send to a Java Bolt) // Here, fullname of the Java JSON Deserializer class and target deserialized class are required List <string> javaDeserializerInfo = new List <string>() { "microsoft.scp.storm.multilang.CustomizedInteropJSONDeserializer", "microsoft.scp.example.HybridTopology.Person" }; topologyBuilder.SetSpout( "generator", Generator.Get, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, new List <string>() { "person" } } }, 1, null).DeclareCustomizedJavaDeserializer(javaDeserializerInfo); // Demo how to set parameters to initialize the constructor of Java Spout/Bolt List <object> constructorParams = new List <object>() { 100, "test", string.Empty }; List <string> paramTypes = new List <string>() { "int", "java.lang.String", "java.lang.String" }; JavaComponentConstructor constructor = new JavaComponentConstructor("microsoft.scp.example.HybridTopology.Displayer", constructorParams, paramTypes); topologyBuilder.SetJavaBolt( "displayer", constructor, 1).shuffleGrouping("generator"); // Demo how to set topology config topologyBuilder.SetTopologyConfig(new Dictionary <string, string>() { { "topology.kryo.register", "[\"[B\"]" } }); return(topologyBuilder); }
/// <summary> /// Builds a topology that can be submitted to Storm on HDInsight /// </summary> /// <returns>A topology builder</returns> public ITopologyBuilder GetTopologyBuilder() { // Friendly name of the topology TopologyBuilder topologyBuilder = new TopologyBuilder("EventHubWriter" + DateTime.Now.ToString("yyyyMMddHHmmss")); // Number of partitions in Event Hub. Used for parallelization. int partitionCount = int.Parse(ConfigurationManager.AppSettings["EventHubPartitionCount"]); // Deserializer used to deserialize JSON data from C# components to java.lang.string List <string> javaDeserializerInfo = new List <string>() { "microsoft.scp.storm.multilang.CustomizedInteropJSONDeserializer", "java.lang.String" }; // Spout that emits randomly generated JSON data topologyBuilder.SetSpout( "Spout", Spout.Get, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, new List <string>() { "event" } } }, partitionCount) .DeclareCustomizedJavaDeserializer(javaDeserializerInfo); // Java construcvtor for the Event Hub Bolt JavaComponentConstructor constructor = JavaComponentConstructor.CreateFromClojureExpr( String.Format(@"(org.apache.storm.eventhubs.bolt.EventHubBolt. (org.apache.storm.eventhubs.bolt.EventHubBoltConfig. " + @"""{0}"" ""{1}"" ""{2}"" ""{3}"" ""{4}"" {5}))", ConfigurationManager.AppSettings["EventHubPolicyName"], ConfigurationManager.AppSettings["EventHubPolicyKey"], ConfigurationManager.AppSettings["EventHubNamespace"], "servicebus.windows.net", ConfigurationManager.AppSettings["EventHubName"], "true")); // Set the bolt to subscribe to data from the spout topologyBuilder.SetJavaBolt( "eventhubbolt", constructor, partitionCount) .shuffleGrouping("Spout"); // Return the topology builder return(topologyBuilder); }
public ITopologyBuilder GetTopologyBuilder() { var topologyBuilder = new TopologyBuilder(typeof(HBaseWriterTopology).Name + DateTime.Now.ToString("yyyyMMddHHmmss")); topologyBuilder.SetSpout( typeof(VehicleRecordGeneratorSpout).Name, //Set task name VehicleRecordGeneratorSpout.Get, //Set task constructor delegate new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, VehicleRecordGeneratorSpout.OutputFields } }, 1, //Set number of tasks true //Set enableAck ); topologyBuilder.SetBolt( typeof(VehicleRecordGeneratorSpout).Name + typeof(LoggerBolt).Name, //Set task name LoggerBolt.Get, //Set task constructor delegate new Dictionary <string, List <string> >(), //Leave empty if the task has no outputSchema defined i.e. no outgoing tuples 1, //Set number of tasks true //Set enableAck ). globalGrouping(typeof(VehicleRecordGeneratorSpout).Name); var boltConfig = new StormConfig(); boltConfig.Set("topology.tick.tuple.freq.secs", "5"); topologyBuilder.SetBolt( typeof(HBaseBolt).Name, //Set task name HBaseBolt.Get, //Set task constructor delegate new Dictionary <string, List <string> >(), //Leave empty if the task has no outputSchema defined i.e. no outgoing tuples 1, //Set number of tasks true //Set enableAck ). globalGrouping(typeof(VehicleRecordGeneratorSpout).Name). addConfigurations(boltConfig); //Set the topology config var topologyConfig = new StormConfig(); topologyConfig.setNumWorkers(1); //Set number of worker processes topologyConfig.setMaxSpoutPending(512); //Set maximum pending tuples from spout topologyConfig.setWorkerChildOps("-Xmx768m"); //Set Java Heap Size topologyBuilder.SetTopologyConfig(topologyConfig); return(topologyBuilder); }
/// <summary> /// Builds a topology that can be submitted to Storm on HDInsight /// </summary> /// <returns>A topology builder</returns> public ITopologyBuilder GetTopologyBuilder() { //The friendly name is 'EventHubWriter' TopologyBuilder topologyBuilder = new TopologyBuilder("EventHubWriter" + DateTime.Now.ToString("yyyyMMddHHmmss")); //Get the partition count int partitionCount = int.Parse(ConfigurationManager.AppSettings["EventHubPartitionCount"]); //Create a deserializer for JSON to java.lang.String //so that Java components can consume data emitted by //C# components List<string> javaDeserializerInfo = new List<string>() { "microsoft.scp.storm.multilang.CustomizedInteropJSONDeserializer", "java.lang.String" }; //Set the spout topologyBuilder.SetSpout( "Spout", Spout.Get, new Dictionary<string, List<string>>() { {Constants.DEFAULT_STREAM_ID, new List<string>(){"Event"}} }, partitionCount). //Parallelism hint uses partition count DeclareCustomizedJavaDeserializer(javaDeserializerInfo); //Deserializer for the output stream //Create constructor for the Java bolt JavaComponentConstructor constructor = JavaComponentConstructor.CreateFromClojureExpr( String.Format(@"(com.microsoft.eventhubs.bolt.EventHubBolt. (com.microsoft.eventhubs.bolt.EventHubBoltConfig. " + @"""{0}"" ""{1}"" ""{2}"" ""{3}"" ""{4}"" {5}))", ConfigurationManager.AppSettings["EventHubPolicyName"], ConfigurationManager.AppSettings["EventHubPolicyKey"], ConfigurationManager.AppSettings["EventHubNamespace"], "servicebus.windows.net", //suffix for servicebus fqdn ConfigurationManager.AppSettings["EventHubName"], "true")); topologyBuilder.SetJavaBolt( "EventHubBolt", constructor, partitionCount). //Parallelism hint uses partition count shuffleGrouping("Spout"); //Consume data from spout StormConfig config = new StormConfig(); config.setNumWorkers(1); //Set the number of workers topologyBuilder.SetTopologyConfig(config); return topologyBuilder; }
public ITopologyBuilder GetTopologyBuilder() { var topologyBuilder = new TopologyBuilder(typeof(EventHubWriterTopology).Name + DateTime.Now.ToString("yyyyMMddHHmmss")); topologyBuilder.SetSpout( typeof(IISLogGeneratorSpout).Name, //Set task name IISLogGeneratorSpout.Get, new Dictionary<string, List<string>>() { {Constants.DEFAULT_STREAM_ID, IISLogGeneratorSpout.OutputFields} }, 1, //Set number of tasks true //Set enableAck ); topologyBuilder.SetBolt( typeof(LoggerBolt).Name, //Set task name LoggerBolt.Get, //Set task constructor delegate new Dictionary<string, List<string>>(), //Leave empty if the task has no outputSchema defined i.e. no outgoing tuples 1, //Set number of tasks true //Set enableAck ). globalGrouping(typeof(IISLogGeneratorSpout).Name); var EventHubPartitions = ConfigurationManager.AppSettings["EventHubPartitions"]; if (String.IsNullOrWhiteSpace(EventHubPartitions)) { throw new ArgumentException("A required AppSetting cannot be null or empty", "EventHubPartitions"); } var partitionCount = int.Parse(EventHubPartitions); topologyBuilder.SetBolt( typeof(EventHubBolt).Name, //Set task name EventHubBolt.Get, //Set task constructor delegate new Dictionary<string, List<string>>(), //Leave empty if the task has no outputSchema defined i.e. no outgoing tuples partitionCount, //Set number of tasks true //Set enableAck ). globalGrouping(typeof(IISLogGeneratorSpout).Name); //Set the topology config var topologyConfig = new StormConfig(); topologyConfig.setNumWorkers(1); //Set number of worker processes topologyConfig.setMaxSpoutPending(512); //Set maximum pending tuples from spout topologyConfig.setWorkerChildOps("-Xmx768m"); //Set Java Heap Size topologyBuilder.SetTopologyConfig(topologyConfig); return topologyBuilder; }
public ITopologyBuilder GetTopologyBuilder() { var topologyBuilder = new TopologyBuilder(typeof(DocumentDbReaderTopology).Name + DateTime.Now.ToString("yyyyMMddHHmmss")); topologyBuilder.SetSpout( typeof(VehicleRecordGeneratorSpout).Name, //Set task name VehicleRecordGeneratorSpout.Get, //Set task constructor delegate new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, VehicleRecordGeneratorSpout.OutputFields } }, 1, true); topologyBuilder.SetBolt( typeof(DocumentDbLookupBolt).Name, //Set task name DocumentDbLookupBolt.Get, //Set task constructor delegate //Set the output field names - As DocumentDb return a JSON object, we will be expecting only 1 field new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, VehicleRecordGeneratorSpout.OutputFields } }, //Or, new Dictionary<string, List<string>>() { { Constants.DEFAULT_STREAM_ID, new List<string>() { "Vehicle" } }, 1, true). globalGrouping(typeof(VehicleRecordGeneratorSpout).Name); //Log the looked up records topologyBuilder.SetBolt( typeof(DocumentDbLookupBolt).Name + typeof(LoggerBolt).Name, //Set task name LoggerBolt.Get, //Set task constructor delegate new Dictionary <string, List <string> >(), //Leave empty if the task has no outputSchema defined i.e. no outgoing tuples 1, true). globalGrouping(typeof(DocumentDbLookupBolt).Name); //Set the topology config var topologyConfig = new StormConfig(); topologyConfig.setNumWorkers(1); //Set number of worker processes topologyConfig.setMaxSpoutPending(512); //Set maximum pending tuples from spout topologyConfig.setWorkerChildOps("-Xmx768m"); //Set Java Heap Size topologyBuilder.SetTopologyConfig(topologyConfig); return(topologyBuilder); }
/// <summary> /// Use Topology Specification API to describe the topology /// </summary> /// <returns></returns> public ITopologyBuilder GetTopologyBuilder() { // Use TopologyBuilder to define a Non-Tx topology // And define each spouts/bolts one by one TopologyBuilder topologyBuilder = new TopologyBuilder("HelloWorld"); // Set a User customized config (Generator.config) for the Generator topologyBuilder.SetSpout( "generator", Generator.Get, new Dictionary<string, List<string>>() { {Constants.DEFAULT_STREAM_ID, new List<string>(){"sentence"}} }, 1, "Generator.config"); topologyBuilder.SetBolt( "splitter", Splitter.Get, new Dictionary<string, List<string>>() { {Constants.DEFAULT_STREAM_ID, new List<string>(){"word", "firstLetterOfWord"}} }, 1).shuffleGrouping("generator"); // Use scp-field-group from Splitter to Counter, // and specify the second field in the Output schema of Splitter (Input schema of Counter) as the field grouping target // by passing the index array [1] (index start from 0) topologyBuilder.SetBolt( "counter", Counter.Get, new Dictionary<string, List<string>>() { {Constants.DEFAULT_STREAM_ID, new List<string>(){"word", "count"}} }, 1).fieldsGrouping("splitter", new List<int>() {1}); // Demo how to set topology config topologyBuilder.SetTopologyConfig(new Dictionary<string, string>() { {"topology.kryo.register","[\"[B\"]"} }); return topologyBuilder; }
public ITopologyBuilder GetTopologyBuilder() { var topologyBuilder = new TopologyBuilder(typeof(SqlAzureWriterTopology).Name + DateTime.Now.ToString("yyyyMMddHHmmss")); //Component tasks expect output field names in TopologyBuilder topologyBuilder.SetSpout( typeof(IISLogGeneratorSpout).Name, //Set task name IISLogGeneratorSpout.Get, //Set task constructor delegate new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, IISLogGeneratorSpout.OutputFields } }, 1, //Set number of tasks true //Set enableAck ); topologyBuilder.SetBolt( typeof(LoggerBolt).Name, //Set task name LoggerBolt.Get, //Set task constructor delegate new Dictionary <string, List <string> >(), //Leave empty if the task has no outputSchema defined i.e. no outgoing tuples 1, //Set number of tasks true //Set enableAck ). globalGrouping(typeof(IISLogGeneratorSpout).Name); topologyBuilder.SetBolt( typeof(SqlAzureBolt).Name, //Set task name SqlAzureBolt.Get, //Set task constructor delegate new Dictionary <string, List <string> >(), //Leave empty if the task has no outputSchema defined i.e. no outgoing tuples 1, //Set number of tasks true //Set enableAck ). globalGrouping(typeof(IISLogGeneratorSpout).Name); //Set the topology config var topologyConfig = new StormConfig(); topologyConfig.setNumWorkers(1); //Set number of worker processes topologyConfig.setMaxSpoutPending(512); //Set maximum pending tuples from spout topologyConfig.setWorkerChildOps("-Xmx768m"); //Set Java Heap Size topologyBuilder.SetTopologyConfig(topologyConfig); return(topologyBuilder); }
public ITopologyBuilder GetTopologyBuilder() { var topologyBuilder = new TopologyBuilder(typeof(HBaseWriterTopology).Name + DateTime.Now.ToString("yyyyMMddHHmmss")); topologyBuilder.SetSpout( typeof(VehicleRecordGeneratorSpout).Name, //Set task name VehicleRecordGeneratorSpout.Get, //Set task constructor delegate new Dictionary<string, List<string>>() { { Constants.DEFAULT_STREAM_ID, VehicleRecordGeneratorSpout.OutputFields } }, 1, //Set number of tasks true //Set enableAck ); topologyBuilder.SetBolt( typeof(VehicleRecordGeneratorSpout).Name + typeof(LoggerBolt).Name, //Set task name LoggerBolt.Get, //Set task constructor delegate new Dictionary<string, List<string>>(), //Leave empty if the task has no outputSchema defined i.e. no outgoing tuples 1, //Set number of tasks true //Set enableAck ). globalGrouping(typeof(VehicleRecordGeneratorSpout).Name); var boltConfig = new StormConfig(); boltConfig.Set("topology.tick.tuple.freq.secs", "5"); topologyBuilder.SetBolt( typeof(HBaseBolt).Name, //Set task name HBaseBolt.Get, //Set task constructor delegate new Dictionary<string, List<string>>(), //Leave empty if the task has no outputSchema defined i.e. no outgoing tuples 1, //Set number of tasks true //Set enableAck ). globalGrouping(typeof(VehicleRecordGeneratorSpout).Name). addConfigurations(boltConfig); //Set the topology config var topologyConfig = new StormConfig(); topologyConfig.setNumWorkers(1); //Set number of worker processes topologyConfig.setMaxSpoutPending(512); //Set maximum pending tuples from spout topologyConfig.setWorkerChildOps("-Xmx768m"); //Set Java Heap Size topologyBuilder.SetTopologyConfig(topologyConfig); return topologyBuilder; }
public ITopologyBuilder GetTopologyBuilder() { string pluginName = string.Format("{0}.exe", GetType().Assembly.GetName().Name); TopologyBuilder topologyBuilder = new TopologyBuilder("HelloWorld"); topologyBuilder.SetSpout( "generator", pluginName, new List<string>() { "generator" }, new Dictionary<string, List<string>>() { {Constants.DEFAULT_STREAM_ID, new List<string>(){"sentence"}} }, 1); topologyBuilder.SetBolt( "splitter", pluginName, new List<string>() { "splitter" }, new Dictionary<string, List<string>>() { {Constants.DEFAULT_STREAM_ID, new List<string>(){"word", "firstLetterOfWord"}} }, 1).shuffleGrouping("generator"); topologyBuilder.SetBolt( "counter", pluginName, new List<string>() { "counter" }, new Dictionary<string, List<string>>() { {Constants.DEFAULT_STREAM_ID, new List<string>(){"word", "count"}} }, 1).fieldsGrouping("splitter", new List<int>() { 1 }); topologyBuilder.SetTopologyConfig(new Dictionary<string, string>() { {"topology.kryo.register","[\"[B\"]"} }); return topologyBuilder; }
/// <summary> /// Defines and configures the topology /// </summary> /// <returns></returns> public ITopologyBuilder GetTopologyBuilder() { //Define a new topology named "EventTopology" TopologyBuilder topologyBuilder = new TopologyBuilder("EventTopology"); //The spout, which emits events topologyBuilder.SetSpout( "Spout", Spout.Get, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, new List <string>() { "id", "event", "eventtime" } } }, 1); //A bolt that is used to look up previous events for the same session from HBase //If this is an end event, the time span between the start and end events is //emitted as 'duration' topologyBuilder.SetBolt( "Lookup", HBaseLookupBolt.Get, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, new List <string>() { "id", "event", "eventtime", "duration" } } }, 1).shuffleGrouping("Spout"); //A bolt that writes events to HBase topologyBuilder.SetBolt( "Store", HBaseBolt.Get, new Dictionary <string, List <string> >(), 1).shuffleGrouping("Lookup"); return(topologyBuilder); }
public ITopologyBuilder GetTopologyBuilder() { TopologyBuilder topologyBuilder = new TopologyBuilder(typeof(TwitterTopology).Name + DateTime.Now.ToString("-yyyyMMddHHmmss")); topologyBuilder.SetSpout( typeof(TwitterSpout).Name, TwitterSpout.Get, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, new List <string>() { "tweet" } } }, 1); topologyBuilder.SetBolt( typeof(TwitterBolt).Name, TwitterBolt.Get, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, new List <string>() { "count", "tweet" } } }, 1).shuffleGrouping(typeof(TwitterSpout).Name); topologyBuilder.SetBolt( typeof(SqlAzureBolt).Name, SqlAzureBolt.Get, new Dictionary <string, List <string> >(), 1).shuffleGrouping(typeof(TwitterBolt).Name); topologyBuilder.SetBolt( typeof(SignalRBroadcastBolt).Name, SignalRBroadcastBolt.Get, new Dictionary <string, List <string> >(), 1).shuffleGrouping(typeof(TwitterBolt).Name); return(topologyBuilder); }
public ITopologyBuilder GetTopologyBuilder() { var topologyBuilder = new TopologyBuilder(typeof(HBaseLookupTopology).Name + DateTime.Now.ToString("yyyyMMddHHmmss")); topologyBuilder.SetSpout( typeof(VehicleRecordGeneratorSpoutForHBase).Name, //Set task name VehicleRecordGeneratorSpoutForHBase.Get, //Set task constructor delegate new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, VehicleRecordGeneratorSpoutForHBase.OutputFields } }, 1, //Set number of tasks true //Set enableAck ); topologyBuilder.SetBolt( typeof(HBaseLookupBolt).Name, //Set task name HBaseLookupBolt.Get, //Set task constructor delegate new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, VehicleRecordGeneratorSpoutForHBase.OutputFields } }, 1, //Set number of tasks true //Set enableAck ). globalGrouping(typeof(VehicleRecordGeneratorSpoutForHBase).Name); //Set the topology config var topologyConfig = new StormConfig(); topologyConfig.setNumWorkers(1); //Set number of worker processes topologyConfig.setMaxSpoutPending(512); //Set maximum pending tuples from spout topologyConfig.setWorkerChildOps("-Xmx768m"); //Set Java Heap Size topologyBuilder.SetTopologyConfig(topologyConfig); return(topologyBuilder); }
public ITopologyBuilder GetTopologyBuilder() { TopologyBuilder topologyBuilder = new TopologyBuilder("SensorStream" + DateTime.Now.ToString("yyyyMMddHHmmss")); topologyBuilder.SetSpout( "Spout", Spout.Get, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, new List <string>() { "count" } } }, 1); topologyBuilder.SetBolt( "Bolt", Bolt.Get, new Dictionary <string, List <string> >(), 1).shuffleGrouping("Spout"); return(topologyBuilder); }
public ITopologyBuilder GetTopologyBuilder() { var topologyBuilder = new TopologyBuilder(typeof(DocumentDBWriterTopology).Name + DateTime.Now.ToString("yyyyMMddHHmmss")); topologyBuilder.SetSpout( typeof(VehicleRecordGeneratorSpoutForDocumentDB).Name, //Set task name VehicleRecordGeneratorSpoutForDocumentDB.Get, //Set task constructor delegate new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, VehicleRecordGeneratorSpoutForDocumentDB.OutputFields } }, 1, //Set number of tasks true //Set enableAck ); //Store the incoming Vehicle records in DocumentDb topologyBuilder.SetBolt( typeof(DocumentDbBolt).Name, //Set task name DocumentDbBolt.Get, //Set task constructor delegate new Dictionary <string, List <string> >(), //Leave empty if the task has no outputSchema defined i.e. no outgoing tuples 1, //Set number of tasks true //Set enableAck ). globalGrouping(typeof(VehicleRecordGeneratorSpoutForDocumentDB).Name); //Choose grouping //Set the topology config var topologyConfig = new StormConfig(); topologyConfig.setNumWorkers(1); //Set number of worker processes topologyConfig.setMaxSpoutPending(512); //Set maximum pending tuples from spout topologyConfig.setWorkerChildOps("-Xmx768m"); //Set Java Heap Size topologyBuilder.SetTopologyConfig(topologyConfig); return(topologyBuilder); }
public ITopologyBuilder GetTopologyBuilder() { string pluginName = string.Format("{0}.exe", GetType().Assembly.GetName().Name); TopologyBuilder topologyBuilder = new TopologyBuilder("HelloWorld"); topologyBuilder.SetSpout( "generator", pluginName, new List <string>() { "generator" }, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, new List <string>() { "sentence" } } }, 1); topologyBuilder.SetBolt( "splitter", pluginName, new List <string>() { "splitter" }, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, new List <string>() { "word", "firstLetterOfWord" } } }, 1).shuffleGrouping("generator"); topologyBuilder.SetBolt( "counter", pluginName, new List <string>() { "counter" }, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, new List <string>() { "word", "count" } } }, 1).fieldsGrouping("splitter", new List <int>() { 1 }); topologyBuilder.SetTopologyConfig(new Dictionary <string, string>() { { "topology.kryo.register", "[\"[B\"]" } }); return(topologyBuilder); }
public ITopologyBuilder GetTopologyBuilder() { TopologyBuilder topologyBuilder = new TopologyBuilder("HybridTopology_csharpSpout_javaBolt"); // Demo how to set a customized JSON Deserializer to deserialize a JSON string into Java object (to send to a Java Bolt) // Here, fullname of the Java JSON Deserializer class and target deserialized class are required List<string> javaDeserializerInfo = new List<string>() { "microsoft.scp.storm.multilang.CustomizedInteropJSONDeserializer", "microsoft.scp.example.HybridTopology.Person"}; topologyBuilder.SetSpout( "generator", Generator.Get, new Dictionary<string, List<string>>() { {Constants.DEFAULT_STREAM_ID, new List<string>(){"person"}} }, 1, null).DeclareCustomizedJavaDeserializer(javaDeserializerInfo); // Demo how to set parameters to initialize the constructor of Java Spout/Bolt List<object> constructorParams = new List<object>() { 100, "test", string.Empty }; List<string> paramTypes = new List<string>() { "int", "java.lang.String", "java.lang.String" }; JavaComponentConstructor constructor = new JavaComponentConstructor("microsoft.scp.example.HybridTopology.Displayer", constructorParams, paramTypes); topologyBuilder.SetJavaBolt( "displayer", constructor, 1).shuffleGrouping("generator"); // Demo how to set topology config topologyBuilder.SetTopologyConfig(new Dictionary<string, string>() { {"topology.kryo.register","[\"[B\"]"} }); return topologyBuilder; }
/// <summary> /// Get a topology builder for this topology /// </summary> /// <returns></returns> public ITopologyBuilder GetTopologyBuilder() { // Create a new topology, with a name of "WordCount" and the current date TopologyBuilder topologyBuilder = new TopologyBuilder("WordCount" + DateTime.Now.ToString("yyyyMMddHHmmss")); // Add the spout to the topology. // Name the component 'sentences' // Name the field that is emitted as 'sentence' topologyBuilder.SetSpout( "sentences", Spout.Get, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, new List <string>() { "sentence" } } }, 1); // Add the splitter bolt. // Name the component 'splitter' // Name the field that is emitted 'word' // Use shuffleGrouping to distribute incoming tuples // from the 'sentences' spout across instances of // the splitter topologyBuilder.SetBolt( "splitter", Splitter.Get, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, new List <string>() { "word" } } }, 1).shuffleGrouping("sentences"); // Add the counter bolt. // Name the component 'counter'. // Name the fields that are emitted 'word' and 'count' // Use fieldsGrouping to ensure that tuples are routed // to counter instances based on the contents of field // position 0 ('word'). This could also be List<string>(){"word"} // Instead of position. // This ensures that words go to the same instance. For example, 'jumped' // will always go to the same instance, while 'cow' might always go to another instance. topologyBuilder.SetBolt( "counter", Counter.Get, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, new List <string>() { "word", "count" } } }, 1).fieldsGrouping("splitter", new List <int>() { 0 }); // Return the builder return(topologyBuilder); }
public ITopologyBuilder GetTopologyBuilder() { // Create a new topology named 'WordCount' TopologyBuilder topologyBuilder = new TopologyBuilder("WordCount"); // Add the spout to the topology. // Name the component 'sentences' // Name the field that is emitted as 'sentence' topologyBuilder.SetSpout( "sentences", Spout.Get, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, new List <string>() { "sentence" } } }, 1); // Add the splitter bolt to the topology. // Name the component 'splitter' // Name the field that is emitted 'word' // Use suffleGrouping to distribute incoming tuples // from the 'sentences' spout across instances // of the splitter topologyBuilder.SetBolt( "splitter", Splitter.Get, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, new List <string>() { "word" } } }, 1).shuffleGrouping("sentences"); // Add the counter bolt to the topology. // Name the component 'counter' // Name the fields that are emitted 'word' and 'count' // Use fieldsGrouping to ensure that tuples are routed // to counter instances based on the contents of field // position 0 (the word). This could also have been // List<string>(){"word"}. // This ensures that the word 'jumped', for example, will always // go to the same instance topologyBuilder.SetBolt( "counter", Counter.Get, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, new List <string>() { "word", "count" } } }, 1).fieldsGrouping("splitter", new List <int>() { 0 }); //NOTE: This tends to work with parallelism hint set to 1. //If you increase this, you should pre-create the dataset //used by the bolt, as multiple instances of the bolt all //trying to create a new dataset will sometimes create //multiple datasets in Power BI, all with the same name. topologyBuilder.SetBolt( "PowerBI", PowerBiBolt.Get, new Dictionary <string, List <string> >(), 1).fieldsGrouping("counter", new List <int>() { 0 }); // Add topology config topologyBuilder.SetTopologyConfig(new Dictionary <string, string>() { { "topology.kryo.register", "[\"[B\"]" } }); return(topologyBuilder); }
public ITopologyBuilder GetTopologyBuilder() { // Create a new topology named 'WordCount' TopologyBuilder topologyBuilder = new TopologyBuilder("WordCount"); // Add the spout to the topology. // Name the component 'sentences' // Name the field that is emitted as 'sentence' topologyBuilder.SetSpout( "sentences", Spout.Get, new Dictionary<string, List<string>>() { {Constants.DEFAULT_STREAM_ID, new List<string>(){"sentence"}} }, 1); // Add the splitter bolt to the topology. // Name the component 'splitter' // Name the field that is emitted 'word' // Use suffleGrouping to distribute incoming tuples // from the 'sentences' spout across instances // of the splitter topologyBuilder.SetBolt( "splitter", Splitter.Get, new Dictionary<string, List<string>>() { {Constants.DEFAULT_STREAM_ID, new List<string>(){"word"}}, // a default stream with a named tuple field {"cowbells", new List<string>(){"cowbell"}} // a named stream with a named tuple field }, 1).shuffleGrouping("sentences"); // Add the counter bolt to the topology. // Name the component 'counter' // Name the fields that are emitted 'word' and 'count' // Use fieldsGrouping to ensure that tuples are routed // to counter instances based on the contents of field // position 0 (the word). This could also have been // List<string>(){"word"}. // This ensures that the word 'jumped', for example, will always // go to the same instance topologyBuilder.SetBolt( "counter", Counter.Get, new Dictionary<string, List<string>>() { {Constants.DEFAULT_STREAM_ID, new List<string>(){"word", "count"}} }, 1).fieldsGrouping("splitter", Constants.DEFAULT_STREAM_ID, new List<int>() { 0 }); // Add the cowbell bolt, which reads from the cowbell stream topologyBuilder.SetBolt( "cowbellbolt", CowBell.Get, new Dictionary<string, List<string>>() { {Constants.DEFAULT_STREAM_ID, new List<string>(){"cowbellout"}} // emit a stream so we can see the cowbell }, 1).shuffleGrouping("splitter", "cowbells"); //subscribe to the stream named 'cowbell' // Add topology config topologyBuilder.SetTopologyConfig(new Dictionary<string, string>() { {"topology.kryo.register","[\"[B\"]"} }); return topologyBuilder; }
public ITopologyBuilder GetTopologyBuilder() { // Create a new topology named 'WordCount' TopologyBuilder topologyBuilder = new TopologyBuilder("WordCount" + DateTime.Now.ToString("yyyyMMddHHmmss")); // Add the spout to the topology. // Name the component 'sentences' // Name the field that is emitted as 'sentence' topologyBuilder.SetSpout( "sentences", Spout.Get, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, new List <string>() { "sentence" } } }, 1); // Add the splitter bolt to the topology. // Name the component 'splitter' // Name the field that is emitted 'word' // Use suffleGrouping to distribute incoming tuples // from the 'sentences' spout across instances // of the splitter topologyBuilder.SetBolt( "splitter", Splitter.Get, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, new List <string>() { "word" } } }, 1).shuffleGrouping("sentences"); // Add the counter bolt to the topology. // Name the component 'counter' // Name the fields that are emitted 'word' and 'count' // Use fieldsGrouping to ensure that tuples are routed // to counter instances based on the contents of field // position 0 (the word). This could also have been // List<string>(){"word"}. // This ensures that the word 'jumped', for example, will always // go to the same instance topologyBuilder.SetBolt( "counter", Counter.Get, new Dictionary <string, List <string> >() { { Constants.DEFAULT_STREAM_ID, new List <string>() { "word", "count" } } }, 1).fieldsGrouping("splitter", new List <int>() { 0 }); // Add topology config topologyBuilder.SetTopologyConfig(new Dictionary <string, string>() { { "topology.kryo.register", "[\"[B\"]" } }); return(topologyBuilder); }
public ITopologyBuilder GetTopologyBuilder() { appConfig = new AppConfig(); TopologyBuilder topologyBuilder = new TopologyBuilder(this.GetType().Name); topologyBuilder.SetSpout( typeof(EventGenerator).Name, EventGenerator.Get, new Dictionary<string, List<string>>() { {Constants.DEFAULT_STREAM_ID, new List<string>(){"Event"}} }, appConfig.EventHubPartitions ); topologyBuilder.SetBolt( typeof(EventHubWriter).Name, EventHubWriter.Get, new Dictionary<string, List<string>>(), appConfig.EventHubPartitions ). shuffleGrouping(typeof(EventGenerator).Name); var topologyConfig = new StormConfig(); topologyConfig.setNumWorkers(8); topologyConfig.setMaxSpoutPending(1600); topologyBuilder.SetTopologyConfig(topologyConfig); return topologyBuilder; }