### Start ActiveMQ Broker Source: https://storm.apache.org/releases/2.8.2/storm-jms-example This command starts the Apache ActiveMQ broker, which is required for the JMS example. Ensure ActiveMQ is installed and ACTIVEMQ_HOME is set correctly. ```shell $ [ACTIVEMQ_HOME]/bin/activemq ``` -------------------------------- ### Build Example Topology with Maven Source: https://storm.apache.org/releases/2.8.2/storm-jms-example Instructions to build the example Storm JMS topology using Maven. This involves navigating to the storm-jms directory and executing the Maven clean install command. ```shell cd storm-jms mvn clean install ``` -------------------------------- ### Setup Virtual Environment for Log Processing Source: https://storm.apache.org/releases/2.8.2/storm-sql-example Creates and activates a Python virtual environment. This isolates the project dependencies, ensuring a consistent environment for running the log processing scripts. It uses `virtualenv` and `source` commands. ```bash $ virtualenv env $ source env/bin/activate ``` -------------------------------- ### Run Storm JMS Example with Maven Source: https://storm.apache.org/releases/2.8.2/storm-jms-example This command executes the Storm JMS example topology using Maven. It assumes you are in the 'examples' directory of the Storm project. ```shell $ mvn exec:java ``` -------------------------------- ### Start Storm Logviewer Source: https://storm.apache.org/releases/2.8.2/Eventlogging This command starts the Storm logviewer service, which is necessary for viewing logged tuples. It should be run from the storm installation directory. ```bash bin/storm logviewer ``` -------------------------------- ### Storm SQL Example Source: https://storm.apache.org/releases/2.8.2/index Provides an example of how to use Storm SQL to query streaming data. This demonstrates practical application of SQL within the Storm framework. ```sql -- Example SQL query for a Storm stream SELECT field1, COUNT(*) FROM my_stream WHERE field2 = 'some_value' GROUP BY field1; ``` -------------------------------- ### Install Apache Log Parser with pip Source: https://storm.apache.org/releases/2.8.2/storm-sql-example Installs the `apache-log-parser` Python library using `pip3`. This library is used to parse Apache log lines into a structured format. Requires Python 3.x and pip3 to be installed. ```bash $ pip3 install apache-log-parser ``` -------------------------------- ### Example: Setting Available GPU Count on Supervisor (YAML) Source: https://storm.apache.org/releases/2.8.2/Generic-resources An example showing how to configure a supervisor node to have 2.0 units of 'gpu.count' available. ```YAML supervisor.resources.map: {"gpu.count" : 2.0} ``` -------------------------------- ### Create Kafka Topics for Apache Logs Source: https://storm.apache.org/releases/2.8.2/storm-sql-example Creates three Kafka topics: `apache-logs`, `apache-errorlogs`, and `apache-slowlogs`. This is necessary to ingest the parsed Apache log data into Storm SQL for processing. Assumes Kafka 0.10.0 is installed via brew. ```bash kafka-topics --create --topic apache-logs --zookeeper localhost:2181 --replication-factor 1 --partitions 5 kafka-topics --create --topic apache-errorlogs --zookeeper localhost:2181 --replication-factor 1 --partitions 5 kafka-topics --create --topic apache-slowlogs --zookeeper localhost:2181 --replication-factor 1 --partitions 5 ``` -------------------------------- ### Example File Name (Text) Source: https://storm.apache.org/releases/2.8.2/storm-hdfs Provides an example of a generated file name based on the default Storm HDFS naming convention: `MyBolt-5-7-1390579837830.txt`. ```Text MyBolt-5-7-1390579837830.txt ``` -------------------------------- ### Example Kafka External Table Source: https://storm.apache.org/releases/2.8.2/storm-sql An example of creating an external table for Kafka, specifying the schema, Kafka location, and producer properties. ```sql CREATE EXTERNAL TABLE FOO (ID INT PRIMARY KEY) LOCATION 'kafka://test?bootstrap-servers=localhost:9092' TBLPROPERTIES '{"producer":{"acks":"1","key.serializer":"org.apache.storm.kafka.IntSerializer"}}' ``` -------------------------------- ### Topology Configuration Example Source: https://storm.apache.org/releases/2.8.2/Clojure-DSL An example of a topology configuration map in Clojure, setting the number of workers to 15 and enabling debug mode using constants from `org.apache.storm.config`. ```Clojure {TOPOLOGY-DEBUG true TOPOLOGY-WORKERS 15} ``` -------------------------------- ### Start Pacemaker Daemon Source: https://storm.apache.org/releases/2.8.2/Pacemaker Command to start the Pacemaker daemon. Ensure Pacemaker servers are configured in the cluster. ```bash $ storm pacemaker ``` -------------------------------- ### DefaultSchedulingPriorityStrategy Example Calculation Source: https://storm.apache.org/releases/2.8.2/Resource_Aware_Scheduler_overview Provides an example calculation for DefaultSchedulingPriorityStrategy scores for topologies A-1 and B-1, demonstrating how resource availability and user guarantees influence priority. ```Java A-1 Score = max(CPU: (100 + 0 - 100)/300, MEM: (1,000 + 0 - 1,000)/4,000) = 0 B-1 Score = max(CPU: (100 + 0 - 200)/300, MEM: (1,000 + 0 - 1,500)/4,000) = -0.125 ``` -------------------------------- ### Example cURL for Rebalance Source: https://storm.apache.org/releases/2.8.2/STORM-UI-REST-API An example of using cURL to rebalance a Storm topology, demonstrating the POST request with headers, cookies, and a JSON payload for rebalance options. ```shell curl -i -b ~/cookiejar.txt -c ~/cookiejar.txt -X POST \ -H "Content-Type: application/json" \ -d '{"rebalanceOptions": {"numWorkers": 2, "executors": { "spout" : "5", "split": 7, "count": 5 }}, "callback":"foo"}' \ http://localhost:8080/api/v1/topology/wordcount-1-1420308665/rebalance/0 ``` -------------------------------- ### Get Blobstore Command Help Source: https://storm.apache.org/releases/2.8.2/distcache-blobstore Displays help information for the blobstore command, outlining all available subcommands and their usage. ```bash storm help blobstore ``` -------------------------------- ### Apache Storm Nimbus Startup Logs Source: https://storm.apache.org/releases/2.8.2/Troubleshooting This snippet shows the typical log output when starting Apache Storm Nimbus, including configuration validation and security status, before a fatal JVM error occurs. ```Log 2024-01-05 18:54:20.404 [o.a.s.v.ConfigValidation] INFO: Will use [class org.apache.storm.DaemonConfig, class org.apache.storm.Config] for validation 2024-01-05 18:54:20.556 [o.a.s.z.AclEnforcement] INFO: SECURITY IS DISABLED NO FURTHER CHECKS... 2024-01-05 18:54:20.740 [o.a.s.m.r.RocksDbStore] INFO: Opening RocksDB from /storm_rocks, storm.metricstore.rocksdb.create_if_missing=true ``` -------------------------------- ### Example: Specifying GPU Count for a Spout (Java) Source: https://storm.apache.org/releases/2.8.2/Generic-resources An example demonstrating how to use the `addResource` method to declare that a 'word' Spout requires 1.0 unit of 'gpu.count'. ```Java SpoutDeclarer s1 = builder.setSpout("word", new TestWordSpout(), 10); s1.addResouce("gpu.count", 1.0); ``` -------------------------------- ### Launch Log Viewer Source: https://storm.apache.org/releases/2.8.2/Command-line-client Starts the Storm log viewer daemon, which provides a web interface for accessing Storm log files. Recommended to run under supervision. ```bash storm logviewer ``` -------------------------------- ### Setup Database Schema for Storm JDBC Source: https://storm.apache.org/releases/2.8.2/storm-jdbc SQL statements to create and populate tables for the Storm JDBC topology. Ensure your database supports these queries. ```SQL create table if not exists user (user_id integer, user_name varchar(100), dept_name varchar(100), create_date date); create table if not exists department (dept_id integer, dept_name varchar(100)); create table if not exists user_department (user_id integer, dept_id integer); insert into department values (1, 'R&D'); insert into department values (2, 'Finance'); insert into department values (3, 'HR'); insert into department values (4, 'Sales'); insert into user_department values (1, 1); insert into user_department values (2, 2); insert into user_department values (3, 3); insert into user_department values (4, 4); select dept_name from department, user_department where department.dept_id = user_department.dept_id and user_department.user_id = ?; ``` -------------------------------- ### Java Stateful Bolt Example (Word Count) Source: https://storm.apache.org/releases/2.8.2/State-checkpointing Example of a Java bolt extending BaseStatefulBolt to manage word counts using KeyValueState. It demonstrates `prepare`, `initState`, and `execute` methods for state management and tuple processing. ```Java public class WordCountBolt extends BaseStatefulBolt> { private KeyValueState wordCounts; private OutputCollector collector; ... @Override public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) { this.collector = collector; } @Override public void initState(KeyValueState state) { wordCounts = state; } @Override public void execute(Tuple tuple) { String word = tuple.getString(0); Integer count = wordCounts.get(word, 0); count++; wordCounts.put(word, count); collector.emit(tuple, new Values(word, count)); collector.ack(tuple); } ... } ``` -------------------------------- ### Java Stream Windowing Examples Source: https://storm.apache.org/releases/2.8.2/Stream-API Provides examples of time-based and count-based sliding windows, as well as tumbling windows, using Java Stream APIs in Apache Storm. ```Java // time based sliding window stream.window(SlidingWindows.of(Duration.minutes(10), Duration.minutes(1))); ``` ```Java // count based sliding window stream.window(SlidingWindows.of(Count.(10), Count.of(2))); ``` ```Java // tumbling window stream.window(TumblingWindows.of(Duration.seconds(10)); ``` ```Java // specifying timestamp field for event time based processing and a late tuple stream. stream.window(TumblingWindows.of(Duration.seconds(10) .withTimestampField("ts") .withLateTupleStream("late_events")); ``` -------------------------------- ### Flux Shell Bolt Configuration Examples Source: https://storm.apache.org/releases/2.8.2/flux Provides examples of configuring FluxShellBolt and other custom bolts (LogInfoBolt, TestWordCounter) in Flux YAML, including parallelism. ```YAML # bolt definitions bolts: - id: "splitsentence" className: "org.apache.storm.flux.wrappers.bolts.FluxShellBolt" constructorArgs: # command line - ["python3", "splitsentence.py"] # output fields - ["word"] parallelism: 1 # ... - id: "log" className: "org.apache.storm.flux.wrappers.bolts.LogInfoBolt" parallelism: 1 # ... - id: "count" className: "org.apache.storm.testing.TestWordCounter" parallelism: 1 # ... ``` -------------------------------- ### Example JAAS Configuration with Specific Keytabs and Principals Source: https://storm.apache.org/releases/2.8.2/SECURITY Provides a concrete example of the JAAS configuration, replacing placeholders with actual keytab file paths and Kerberos principals for Storm and ZooKeeper components. ```java StormServer { com.sun.security.auth.module.Krb5LoginModule required useKeyTab=true keyTab="/keytabs/storm.keytab" storeKey=true useTicketCache=false principal="storm/storm.example.com@STORM.EXAMPLE.COM"; }; StormClient { com.sun.security.auth.module.Krb5LoginModule required useKeyTab=true keyTab="/keytabs/storm.keytab" storeKey=true useTicketCache=false serviceName="storm" principal="storm@STORM.EXAMPLE.COM"; }; Client { com.sun.security.auth.module.Krb5LoginModule required useKeyTab=true keyTab="/keytabs/storm.keytab" storeKey=true useTicketCache=false serviceName="zookeeper" principal="storm@STORM.EXAMPLE.COM"; }; Server { com.sun.security.auth.module.Krb5LoginModule required useKeyTab=true keyTab="/keytabs/zk.keytab" storeKey=true useTicketCache=false serviceName="zookeeper" principal="zookeeper/zk1.example.com@STORM.EXAMPLE.COM"; }; ``` -------------------------------- ### Task Setup and Routing Source: https://storm.apache.org/releases/2.8.2/Lifecycle-of-a-topology Tasks are set up using the 'mk-task' function. This includes configuring routing functions for streams and output tuples, determining which tasks should receive specific tuples. ```clojure mk-task ``` -------------------------------- ### Launch Pacemaker Daemon Source: https://storm.apache.org/releases/2.8.2/Command-line-client Starts the Pacemaker daemon, a critical component for Storm cluster management. It's advised to run this daemon under a supervision tool. ```bash storm pacemaker ``` -------------------------------- ### Display Storm Version Source: https://storm.apache.org/releases/2.8.2/Command-line-client Prints the version number of the currently installed Apache Storm release. ```bash storm version ``` -------------------------------- ### JoinBolt Joining Named Streams Example Source: https://storm.apache.org/releases/2.8.2/Joins An example demonstrating how to join two named streams ('stream1' and 'stream2') using the JoinBolt. It specifies the join keys and selects the output fields. ```Java new JoinBolt(JoinBolt.Selector.STREAM, "stream1", "key1") .join ("stream2", "userId", "stream1" ) .select ("userId, key1, key2") .withTumblingWindow( new Duration(10, TimeUnit.MINUTES) ) ; ``` -------------------------------- ### Starting Topology Activation Source: https://storm.apache.org/releases/2.8.2/Lifecycle-of-a-topology After assignment, topologies are initially deactivated. 'start-storm' writes data to ZooKeeper to activate the topology, allowing spouts to emit tuples. ```clojure start-storm ``` -------------------------------- ### Apache Storm Bolt Metrics API Examples Source: https://storm.apache.org/releases/2.8.2/STORM-UI-REST-API Examples of API endpoints to retrieve topology and bolt metrics from Apache Storm. These URLs can be used to fetch real-time performance data. ```HTTP http://ui-daemon-host-name:8080/api/v1/topology/WordCount3-1-1402960825 ``` ```HTTP http://ui-daemon-host-name:8080/api/v1/topology/WordCount3-1-1402960825?sys=1 ``` ```HTTP http://ui-daemon-host-name:8080/api/v1/topology/WordCount3-1-1402960825?window=600 ``` -------------------------------- ### Storm SQL Example Query Source: https://storm.apache.org/releases/2.8.2/storm-sql-internal This example demonstrates defining external Kafka tables and inserting data into another table using a SELECT query with filtering and projection. It showcases basic Storm SQL DDL and DML operations. ```SQL CREATE EXTERNAL TABLE ORDERS (ID INT PRIMARY KEY, UNIT_PRICE INT, QUANTITY INT) LOCATION 'kafka://...' ... CREATE EXTERNAL TABLE LARGE_ORDERS (ID INT PRIMARY KEY, TOTAL INT) 'kafka://...' ... INSERT INTO LARGE_ORDERS SELECT ID, UNIT_PRICE * QUANTITY AS TOTAL FROM ORDERS WHERE UNIT_PRICE * QUANTITY > 50 ``` -------------------------------- ### SlidingWindowBolt Implementation Example Source: https://storm.apache.org/releases/2.8.2/Windowing A sample implementation of a Storm bolt that uses a sliding window. It demonstrates how to extend `BaseWindowedBolt` and process tuples within the `execute` method. ```Java public class SlidingWindowBolt extends BaseWindowedBolt { private OutputCollector collector; @Override public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) { this.collector = collector; } @Override public void execute(TupleWindow inputWindow) { for(Tuple tuple: inputWindow.get()) { // do the windowing computation ... } // emit the results collector.emit(new Values(computedValue)); } } ``` -------------------------------- ### Start Topology with Blobstore Access Source: https://storm.apache.org/releases/2.8.2/distcache-blobstore Starts a Storm topology and provides access to blobstore files. The '-c' option is used to specify the blobstore mapping, including local file names and uncompression settings. ```bash storm jar /home/y/lib/storm-starter/current/storm-starter-jar-with-dependencies.jar org.apache.storm.starter.clj.word_count test_topo -c topology.blobstore.map='{"key1":{"localname":"blob_file", "uncompress":false},"key2":{}}' ``` -------------------------------- ### Transactional State Update Example Source: https://storm.apache.org/releases/2.8.2/Trident-state Demonstrates the initial state of a key/value database before processing a batch, showing counts and associated transaction IDs. ```text man => [count=3, txid=1] dog => [count=4, txid=3] apple => [count=10, txid=2] ``` -------------------------------- ### Storm Flux YAML Topology Definition Example Source: https://storm.apache.org/releases/2.8.2/flux An example of a simple wordcount topology defined using Apache Storm's Flux YAML DSL. It includes spout, bolt, and stream definitions, along with parallelism and grouping configurations. ```yaml name: "yaml-topology" config: topology.workers: 1 # spout definitions spouts: - id: "spout-1" className: "org.apache.storm.testing.TestWordSpout" parallelism: 1 # bolt definitions bolts: - id: "bolt-1" className: "org.apache.storm.testing.TestWordCounter" parallelism: 1 - id: "bolt-2" className: "org.apache.storm.flux.wrappers.bolts.LogInfoBolt" parallelism: 1 #stream definitions streams: - name: "spout-1 --> bolt-1" # name isn't used (placeholder for logging, UI, etc.) from: "spout-1" to: "bolt-1" grouping: type: FIELDS args: ["word"] - name: "bolt-1 --> bolt2" from: "bolt-1" to: "bolt-2" grouping: type: SHUFFLE # worker hook definitions workerHooks: - id: "base-worker-hook" className: "org.apache.storm.hooks.BaseWorkerHook" ``` -------------------------------- ### Trident Tutorial Source: https://storm.apache.org/releases/2.8.2/index A tutorial covering the basic concepts and a walkthrough of Trident, an alternative interface to Storm that provides exactly-once processing and transactional capabilities. ```java // Example snippet demonstrating Trident's basic concepts // (Actual code would involve Trident API calls for topology definition) public class MyTridentTopology { public static void main(String[] args) { // Define Trident topology here } } ``` -------------------------------- ### Shell Options for State Migration Tool Source: https://storm.apache.org/releases/2.8.2/State-checkpointing List of command-line options available for the Base64ToBinaryStateMigrationUtil, including specifying Redis host, port, password, and namespaces for migration. ```Shell -d,--dbnum Redis DB number (default: 0) -h,--host Redis hostname (default: localhost) -n,--namespace REQUIRED the list of namespace to migrate. -p,--port Redis port (default: 6379) --password Redis password (default: no password) ``` -------------------------------- ### Storm SQL Reference Source: https://storm.apache.org/releases/2.8.2/index A reference guide for Storm SQL, detailing the supported SQL syntax, functions, and data types for querying streaming data in Apache Storm. ```text The Storm SQL reference provides comprehensive documentation on the SQL dialect and functions supported for stream processing. ``` -------------------------------- ### Explain Storm SQL Topology Logical Plan Source: https://storm.apache.org/releases/2.8.2/storm-sql-example This shell command submits a Storm SQL script with the '--explain' flag to display the logical execution plan of the topology without actually running it. It also includes the necessary Kafka artifacts. ```Shell $STORM_DIR/bin/storm sql apache_log_error_filtering.sql --explain --artifacts "org.apache.storm:storm-sql-kafka:2.0.0-SNAPSHOT,org.apache.storm:storm-kafka-client:2.0.0-SNAPSHOT,org.apache.kafka:kafka-clients:1.1.0^org.slf4j:slf4j-log4j12" ``` -------------------------------- ### Custom LocationDB State Implementation Source: https://storm.apache.org/releases/2.8.2/Trident-state Provides an example implementation of the State interface for a custom LocationDB. It includes methods for setting and getting user locations, intended for use within Trident tasks. ```Java public class LocationDB implements State { public void beginCommit(Long txid) { } public void commit(Long txid) { } public void setLocation(long userId, String location) { // code to access database and set location } public String getLocation(long userId) { // code to get location from database } } ``` -------------------------------- ### Worker Process Startup Source: https://storm.apache.org/releases/2.8.2/Lifecycle-of-a-topology Worker processes are started via the 'mk-worker' function. Workers connect to other workers, monitor topology activation status, and launch tasks as threads. ```clojure mk-worker ``` -------------------------------- ### Start Profiler on Worker (GET) Source: https://storm.apache.org/releases/2.8.2/STORM-UI-REST-API Initiates the profiler on a specific worker within a topology. Requires topology ID, worker host-port, and a timeout value. Returns the worker's status and a link to profiler artifacts. ```HTTP GET /api/v1/topology//profiling/start// ``` -------------------------------- ### Launch Storm UI Source: https://storm.apache.org/releases/2.8.2/Setting-up-a-Storm-cluster Command to launch the Storm UI, which provides a web interface for monitoring the cluster and topologies. It should be run under supervision and accessed via a web browser. ```bash bin/storm ui ``` -------------------------------- ### Parse Apache Logs to JSON with Incrementing ID (Python) Source: https://storm.apache.org/releases/2.8.2/storm-sql-example Parses Apache log lines from standard input, adds an incrementing ID, converts the parsed data to uppercase keys, and prints it as JSON to standard output. Uses the `apache_log_parser` library. Requires the `apache-log-parser` library to be installed. ```python import sys import apache_log_parser import json auto_incr_id = 1 parser_format = '%a - - %t %D "%r" %s %b "%{Referer}i" "%{User-Agent}i"' line_parser = apache_log_parser.make_parser(parser_format) while True: # we'll use pipe line = sys.stdin.readline() if not line: break parsed_dict = line_parser(line) parsed_dict['id'] = auto_incr_id auto_incr_id += 1 parsed_dict = {k.upper(): v for k, v in parsed_dict.iteritems() if not k.endswith('datetimeobj')} print(json.dumps(parsed_dict)) ``` -------------------------------- ### Storm JMS Example Log Output Source: https://storm.apache.org/releases/2.8.2/storm-jms-example This log output shows the successful connection to ActiveMQ, message sending, and tuple processing within the Storm JMS example topology. It includes details about message content and acknowledgments. ```log DEBUG (backtype.storm.contrib.jms.bolt.JmsBolt:183) - Connecting JMS.. DEBUG (backtype.storm.contrib.jms.spout.JmsSpout:213) - sending tuple: ActiveMQTextMessage {commandId = 5, responseRequired = true, messageId = ID:budreau.home-51286-1321074044423-2:4:1:1:1, originalDestination = null, originalTransactionId = null, producerId = ID:budreau.home-51286-1321074044423-2:4:1:1, destination = queue://backtype.storm.contrib.example.queue, transactionId = null, expiration = 0, timestamp = 1321735055910, arrival = 0, brokerInTime = 1321735055910, brokerOutTime = 1321735055921, correlationId = , replyTo = null, persistent = true, type = , priority = 0, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = org.apache.activemq.util.ByteSequence@6c27ca12, dataStructure = null, redeliveryCounter = 0, size = 0, properties = {secret=880412b7-de71-45dd-8a80-8132589ccd22}, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = Hello storm-jms!} DEBUG (backtype.storm.contrib.jms.spout.JmsSpout:219) - Requested deliveryMode: CLIENT_ACKNOWLEDGE DEBUG (backtype.storm.contrib.jms.spout.JmsSpout:220) - Our deliveryMode: CLIENT_ACKNOWLEDGE DEBUG (backtype.storm.contrib.jms.spout.JmsSpout:224) - Requesting acks. DEBUG (backtype.storm.contrib.jms.example.GenericBolt:60) - [INTERMEDIATE_BOLT] Received message: source: 1:10, stream: 1, id: {-7100026097570233628=-7100026097570233628}, [Hello storm-jms!] DEBUG (backtype.storm.contrib.jms.example.GenericBolt:66) - [INTERMEDIATE_BOLT] emitting: source: 1:10, stream: 1, id: {-7100026097570233628=-7100026097570233628}, [Hello storm-jms!] DEBUG (backtype.storm.contrib.jms.example.GenericBolt:75) - [INTERMEDIATE_BOLT] ACKing tuple: source: 1:10, stream: 1, id: {-7100026097570233628=-7100026097570233628}, [Hello storm-jms!] DEBUG (backtype.storm.contrib.jms.bolt.JmsBolt:136) - Tuple received. Sending JMS message. DEBUG (backtype.storm.contrib.jms.example.GenericBolt:60) - [FINAL_BOLT] Received message: source: 2:2, stream: 1, id: {-7100026097570233628=-5393763013502927792}, [Hello storm-jms!] DEBUG (backtype.storm.contrib.jms.example.GenericBolt:75) - [FINAL_BOLT] ACKing tuple: source: 2:2, stream: 1, id: {-7100026097570233628=-5393763013502927792}, [Hello storm-jms!] DEBUG (backtype.storm.contrib.jms.bolt.JmsBolt:144) - ACKing tuple: source: 2:2, stream: 1, id: {-7100026097570233628=-9118586029611278300}, [Hello storm-jms!] DEBUG (backtype.storm.contrib.jms.spout.JmsSpout:251) - JMS Message acked: ID:budreau.home-51286-1321074044423-2:4:1:1:1 DEBUG (backtype.storm.contrib.jms.spout.JmsSpout:213) - sending tuple: ActiveMQTextMessage {commandId = 5, responseRequired = true, messageId = ID:budreau.home-60117-1321735025796-0:0:1:1:1, originalDestination = null, originalTransactionId = null, producerId = ID:budreau.home-60117-1321735025796-0:0:1:1, destination = topic://backtype.storm.contrib.example.topic, transactionId = null, expiration = 0, timestamp = 1321735056258, arrival = 0, brokerInTime = 1321735056260, brokerOutTime = 1321735056260, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = source: 2:2, stream: 1, id: {-710002609757023... storm-jms!} DEBUG (backtype.storm.contrib.jms.spout.JmsSpout:219) - Requested deliveryMode: CLIENT_ACKNOWLEDGE DEBUG (backtype.storm.contrib.jms.spout.JmsSpout:220) - Our deliveryMode: CLIENT_ACKNOWLEDGE DEBUG (backtype.storm.contrib.jms.spout.JmsSpout:224) - Requesting acks. ``` -------------------------------- ### Launch UI Daemon Source: https://storm.apache.org/releases/2.8.2/Command-line-client The 'ui' command launches the UI daemon, providing a web interface for monitoring the Storm cluster's status and topology statistics. Supervision is recommended for this process. ```bash storm ui ``` -------------------------------- ### List Running Topologies Source: https://storm.apache.org/releases/2.8.2/Command-line-client Lists all currently running topologies in the Storm cluster along with their statuses. ```bash storm list ``` -------------------------------- ### Storm SQL: Run Query with Explain Mode Source: https://storm.apache.org/releases/2.8.2/storm-sql This command demonstrates how to run a Storm SQL query in explain mode, specifying the SQL file and necessary artifacts. Explain mode analyzes the query and shows the execution plan instead of submitting a topology. ```Shell $ bin/storm sql order_filtering.sql --explain --artifacts "org.apache.storm:storm-sql-kafka:2.0.0-SNAPSHOT,org.apache.storm:storm-kafka-client:2.0.0-SNAPSHOT,org.apache.kafka:kafka-clients:1.1.0^org.slf4j:slf4j-log4j12" ``` -------------------------------- ### Scalar UDF Implementation Example Source: https://storm.apache.org/releases/2.8.2/storm-sql Example Java class for a scalar user-defined function in Storm SQL. The `evaluate` method determines it as a scalar function. ```java public class MyPlus { public static Integer evaluate(Integer x, Integer y) { return x + y; } } ``` -------------------------------- ### Storm Flux Component Definition Example Source: https://storm.apache.org/releases/2.8.2/flux Shows how to define a reusable component in Apache Storm Flux. This example makes an instance of `org.apache.storm.kafka.StringScheme` available under the ID 'stringScheme'. ```yaml components: - id: "stringScheme" className: "org.apache.storm.kafka.StringScheme" ``` -------------------------------- ### Shell Command for Redis State Migration Source: https://storm.apache.org/releases/2.8.2/State-checkpointing Maven command to build the storm-redis-examples and execute the Base64ToBinaryStateMigrationUtil for migrating Redis state data between Storm versions. ```Shell mvn clean install -DskipTests cd examples/storm-redis-examples /bin/storm jar target/storm-redis-examples-*.jar org.apache.storm.redis.tools.Base64ToBinaryStateMigrationUtil [options] ``` -------------------------------- ### Submit Storm SQL Topology with Kafka Artifacts Source: https://storm.apache.org/releases/2.8.2/storm-sql-example This shell command submits a Storm SQL script to execute a topology. It specifies the script file, topology name, and includes necessary Kafka client and Storm SQL Kafka connector artifacts with their versions. ```Shell $STORM_DIR/bin/storm sql apache_log_error_filtering.sql apache_log_error_filtering --artifacts "org.apache.storm:storm-sql-kafka:2.0.0-SNAPSHOT,org.apache.storm:storm-kafka-client:2.0.0-SNAPSHOT,org.apache.kafka:kafka-clients:1.1.0^org.slf4j:slf4j-log4j12" ``` -------------------------------- ### Submit Topology JAR using Storm Client (Shell) Source: https://storm.apache.org/releases/2.8.2/Running-topologies-on-a-production-cluster This shell command demonstrates how to submit a packaged topology JAR to an Apache Storm cluster. It specifies the path to the JAR file, the main class to execute, and any command-line arguments for the topology. ```Shell storm jar path/to/allmycode.jar org.me.MyTopology arg1 arg2 arg3 ``` -------------------------------- ### Storm Flux YAML Property Substitution Example Source: https://storm.apache.org/releases/2.8.2/flux Example of using property substitution in a Storm Flux YAML file. The `${kafka.zookeeper.hosts}` placeholder is replaced with a value from a properties file during parsing. ```yaml - id: "zkHosts" className: "org.apache.storm.kafka.ZkHosts" constructorArgs: - "${kafka.zookeeper.hosts}" ``` -------------------------------- ### Topology Configuration Example Source: https://storm.apache.org/releases/2.8.2/flux Provides a basic Flux topology configuration, setting the topology name and the number of workers. This serves as a foundational structure for defining a Storm topology using Flux. ```YAML --- name: "shell-topology" config: topology.workers: 1 ``` -------------------------------- ### DRPC Function Call (GET without args) Source: https://storm.apache.org/releases/2.8.2/STORM-UI-REST-API Invokes a DRPC function that does not require arguments. This is a GET request to the /drpc/:func endpoint, where an empty string is used for arguments if none are provided. ```HTTP GET /drpc/:func Used when DRPC commands do not require arguments. ``` -------------------------------- ### Nimbus Static State Setup Source: https://storm.apache.org/releases/2.8.2/Lifecycle-of-a-topology Nimbus sets up the static state for a topology, storing jars and configurations in the local filesystem under {nimbus local dir}/stormdist/{topology id}. It also writes task-to-component mappings and heartbeat directories to ZooKeeper. ```clojure setup-storm-static setup-heartbeats ``` -------------------------------- ### DRPC Function Call (GET with args) Source: https://storm.apache.org/releases/2.8.2/STORM-UI-REST-API Invokes a DRPC function with arguments appended to the URL via a GET request to the /drpc/:func/:args endpoint. Be mindful of URL length limitations. ```HTTP GET /drpc/:func/:args Arguments are supplied as part of the URL. ``` -------------------------------- ### Storm Jar Command Options for Dependencies Source: https://storm.apache.org/releases/2.8.2/Classpath-handling Demonstrates how to use the `--jar` and `--artifacts` options with the `storm jar` command to include non-bundled dependencies with a topology. This is particularly useful for commands like `storm sql` which automatically construct topologies. ```bash storm jar --jar my-topology.jar --artifacts dependency1.jar,dependency2.jar ``` -------------------------------- ### Storm Topology Submission with Sliding Window Source: https://storm.apache.org/releases/2.8.2/Windowing Example of how to configure and submit a Storm topology using a `SlidingWindowBolt` with a count-based sliding window of 30 tuples and a sliding interval of 10 tuples. ```Java public static void main(String[] args) { TopologyBuilder builder = new TopologyBuilder(); builder.setSpout("spout", new RandomSentenceSpout(), 1); builder.setBolt("slidingwindowbolt", new SlidingWindowBolt().withWindow(new Count(30), new Count(10)), 1).shuffleGrouping("spout"); Config conf = new Config(); conf.setDebug(true); conf.setNumWorkers(1); StormSubmitter.submitTopologyWithProgressBar(args[0], conf, builder.createTopology()); } ``` -------------------------------- ### File Size Rotation Policy Example (Java) Source: https://storm.apache.org/releases/2.8.2/storm-hdfs Demonstrates creating a `FileSizeRotationPolicy` in Apache Storm HDFS to trigger file rotation when files reach a specific size, using 5.0MB as an example. ```Java FileRotationPolicy rotationPolicy = new FileSizeRotationPolicy(5.0f, Units.MB); ``` -------------------------------- ### Trident Map Function Example Source: https://storm.apache.org/releases/2.8.2/Trident-API-Overview Provides an example of a Trident MapFunction for one-to-one transformations on stream tuples, such as converting strings to uppercase. It shows how to apply the map function and optionally specify output fields. ```Java public class UpperCase extends MapFunction { @Override public Values execute(TridentTuple input) { return new Values(input.getString(0).toUpperCase()); } } ``` ```Java mystream.map(new UpperCase()) ``` ```Java mystream.map(new UpperCase(), new Fields("uppercased")) ``` -------------------------------- ### Launch Development Zookeeper Source: https://storm.apache.org/releases/2.8.2/Command-line-client Launches a Zookeeper server for development and testing purposes. It uses configurations specified in 'dev.zookeeper.path' and 'storm.zookeeper.port'. Not intended for production use. ```bash storm dev-zookeeper ``` -------------------------------- ### Trident Filter Example Source: https://storm.apache.org/releases/2.8.2/Trident-API-Overview Illustrates a custom Trident Filter that determines whether to keep a tuple based on specific field values. The example shows how to apply the filter to a stream using the 'filter' operation. ```Java public class MyFilter extends BaseFilter { public boolean isKeep(TridentTuple tuple) { return tuple.getInteger(0) == 1 && tuple.getInteger(1) == 2; } } ``` ```Java mystream.filter(new MyFilter()) ``` -------------------------------- ### Example of Tuple Counting Metric Naming Convention Source: https://storm.apache.org/releases/2.8.2/Metrics Provides examples of how tuple counting metrics are named differently for spouts and bolts in Apache Storm, depending on whether they represent outgoing or incoming tuple events. ```JSON "__ack-count-split:default": 80080 "__ack-count-default": 12500 ``` -------------------------------- ### Create Production DRPC Client in Java Source: https://storm.apache.org/releases/2.8.2/Command-line-client This Java code snippet demonstrates how to create a production-ready DRPC client using the `DRPCClient` class. It involves configuring the client and executing requests with specified functions and arguments. ```java Config conf = new Config(); try (DRPCClient drpc = DRPCClient.getConfiguredClient(conf)) { //User the drpc client String result = drpc.execute(function, argument); } ``` -------------------------------- ### DRPC ACL Configuration Example Source: https://storm.apache.org/releases/2.8.2/SECURITY This snippet shows an example of the DRPC ACL configuration file format. It defines access permissions for specific DRPC functions, allowing certain users to act as clients and others to invoke the underlying topologies. ```yaml drpc.authorizer.acl: "functionName1": "client.users": - "alice" - "bob" "invocation.user": "bob" ``` -------------------------------- ### Example: Registering a Counter in Java Source: https://storm.apache.org/releases/2.8.2/metrics_v2 Illustrates the process of registering a Counter metric named 'myCounter' using the TopologyContext in Apache Storm. The example shows how the registered metric name is expanded with additional Storm-specific information for unique identification. ```Java Counter myCounter = topologyContext.registerCounter("myCounter"); ``` -------------------------------- ### Build Simple Topology with Storm Source: https://storm.apache.org/releases/2.8.2/Tutorial Defines a basic Apache Storm topology with a spout and two bolts. It illustrates setting components, parallelism, and shuffle groupings for data distribution. ```Java TopologyBuilder builder = new TopologyBuilder(); builder.setSpout("words", new TestWordSpout(), 10); builder.setBolt("exclaim1", new ExclamationBolt(), 3) .shuffleGrouping("words"); builder.setBolt("exclaim2", new ExclamationBolt(), 2) .shuffleGrouping("exclaim1"); ``` -------------------------------- ### Get Topology Information (HTTP) Source: https://storm.apache.org/releases/2.8.2/STORM-UI-REST-API Retrieves topology information and statistics by making a GET request to the /api/v1/topology/ endpoint. The should be replaced with the actual topology ID. Optional parameters include 'window' for metrics duration and 'sys' to include system statistics. ```HTTP GET /api/v1/topology/?window=&sys= ``` -------------------------------- ### Upload Topology Credentials Source: https://storm.apache.org/releases/2.8.2/Command-line-client Uploads credentials to a running Storm topology. Optionally, it can fail with an exception if no credentials are provided. ```bash storm upload_credentials topology-name [credkey credvalue]* ``` ```bash storm upload_credentials topology-name -e ``` -------------------------------- ### Resource Availability Example for Node Sorting Source: https://storm.apache.org/releases/2.8.2/Resource_Aware_Scheduler_overview Illustrates how resource availability (CPU, Memory, Slots) is used to calculate effective resources for nodes, demonstrating the sorting logic when effective resources are equal. ```text Avail Resources: node 1: CPU = 50 Memory = 1024 Slots = 20 node 2: CPU = 50 Memory = 8192 Slots = 40 node 3: CPU = 1000 Memory = 0 Slots = 0 Effective resources for nodes: node 1 = 50 / (50+50+1000) = 0.045 (CPU bound) node 2 = 50 / (50+50+1000) = 0.045 (CPU bound) node 3 = 0 (memory and slots are 0) ``` -------------------------------- ### Retrieve Supervisor Summary by Host or ID Source: https://storm.apache.org/releases/2.8.2/STORM-UI-REST-API This API endpoint allows you to retrieve a summary of supervisors running on a specific host or a summary for a supervisor identified by its ID. The 'host' parameter is used to get all supervisors on a host, while the 'id' parameter filters for a specific supervisor. The 'sys' parameter can be optionally included to get system statistics. ```HTTP GET /api/v1/supervisor?host=supervisor-daemon-host-name GET /api/v1/supervisor?id=f5449110-1daa-43e2-89e3-69917b16dec9-192.168.1.1 ``` -------------------------------- ### Get History Summary Source: https://storm.apache.org/releases/2.8.2/STORM-UI-REST-API Retrieves a list of IDs for all topologies currently running and submitted by the current user in Apache Storm. ```shell curl -X GET "/api/v1/history/summary" ``` -------------------------------- ### Stream Builder Initialization (Java) Source: https://storm.apache.org/releases/2.8.2/Stream-API Shows how to initialize a StreamBuilder and create a new stream from a spout in Apache Storm. ```Java import org.apache.storm.streams.Stream; import org.apache.storm.streams.StreamBuilder; // ... other imports StreamBuilder builder = new StreamBuilder(); Stream sentences = builder.newStream(new TestSentenceSpout()); ```