This article mainly introduces one of the two operations of storm: Local Mode.
The local mode simulates all the functions of a storm cluster in a process, which is very convenient for development and testing. Running topology in local mode is similar to running topology on the cluster.
To create a "cluster" in the process, useLocalClusterObject:
| 123 |
import backtype.storm.LocalCluster; LocalCluster cluster = new LocalCluster(); |
Then you can useLocalClusterObject submitTopology method to submit topology, effect andStormSubmitterThe corresponding methods are the same. The submitTopology method requires three parameters: the name of topology, the configuration of topology, And the topology object. You can usekillTopologyMethod to terminate a topology. A topology name is required as a parameter.
To close a local cluster, simply call:
You can.
Some common configurations in Local Mode
You can see the complete configuration list here:
1. Config. TOPOLOGY_MAX_TASK_PARALLELISM this configuration sets the maximum number of threads for each component (spout, bolt) in topology. Generally, the configuration of the production environment is large (about 100), which is too large for local testing. This configuration can be reduced.
2. If the configuration of Config. TOPOLOGY_DEBUG is set to true, storm will log all messages sent by spout and bolt, which is very useful for debugging.
Recommended reading:
Twitter Storm installation configuration (cluster) Notes
Install a Twitter Storm Cluster
Notes on installing and configuring Twitter Storm (standalone version)
Storm practice and Example 1