This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // service-worker.js | |
| // Path is relative to the origin. | |
| const OFFLINE_PAGE_URL = 'offline/offline.html'; | |
| // We’ll add more URIs to this array later. | |
| const ASSETS_TO_BE_CACHED = [OFFLINE_PAGE_URL]; | |
| self.addEventListener('install', event => { | |
| event.waitUntil( | |
| // The Cache API is domain specific and allows an app to create & name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class RandomDigitSpout extends BaseRichSpout | |
| { | |
| // To output tuples from spout to the next stage bolt | |
| SpoutOutputCollector collector; | |
| public void nextTuple() | |
| { | |
| int randomDigit = ThreadLocalRandom.current().nextInt(0, 10); | |
| // Emit the digit to the next stage bolt | |
| collector.emit(new Values(randomDigit)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class EvenDigitBolt extends BaseRichBolt | |
| { | |
| // To output tuples from this bolt to the next bolt. | |
| OutputCollector collector; | |
| public void execute(Tuple tuple) | |
| { | |
| // Get the 1st column 'random-digit' from the tuple | |
| int randomDigit = tuple.getInt(0); | |
| if (randomDigit % 2 == 0) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class MultiplyByTenBolt extends BaseRichBolt | |
| { | |
| OutputCollector collector; | |
| public void execute(Tuple tuple) | |
| { | |
| // Get 'even-digit' from the tuple. | |
| int evenDigit = tuple.getInt(0); | |
| collector.emit(new Values(evenDigit * 10)); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package packagename | |
| // … | |
| public class OurSimpleTopology { | |
| public static void main(String[] args) throws Exception | |
| { | |
| // Create the topology | |
| TopologyBuilder builder = new TopologyBuilder(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| version: '3.2' | |
| services: | |
| zookeeper: | |
| build: ./zookeeper | |
| # Keep it running. | |
| tty: true | |
| storm-nimbus: | |
| build: ./storm-nimbus |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # The Nimbus needs to know where the Zookeeper is. This specifies the list of the | |
| # hosts in the Zookeeper cluster. We're using just one node, of course. | |
| # 'zookeeper' is the Docker Compose network reference. | |
| storm.zookeeper.servers: | |
| - "zookeeper" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Telling the Supervisor where the Zookeeper is. | |
| storm.zookeeper.servers: | |
| - "zookeeper" | |
| # The worker nodes need to know which machine(s) are the candidate of master | |
| # in order to download the topology jars. | |
| nimbus.seeds : ["storm-nimbus"] | |
| # For each Supervisor, we configure how many workers run on that machine. | |
| # Each worker uses a single port for receiving messages, and this setting |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static void main(String[] args) throws Exception | |
| { | |
| TopologyBuilder builder = new TopologyBuilder(); | |
| builder.setSpout("word", new TestWordSpout(), 10); | |
| builder.setBolt("exclaim1", new ExclamationBolt(), 3).shuffleGrouping("word"); | |
| builder.setBolt("exclaim2", new ExclamationBolt(), 2).shuffleGrouping("exclaim1"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const EventEmitter = require('events'); | |
| const myEmitter = new EventEmitter(); | |
| module.exports = myEmitter; |