You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by ka...@apache.org on 2017/12/26 20:54:32 UTC
storm git commit: Address handling activate/deactivate in multilang
module files
Repository: storm
Updated Branches:
refs/heads/1.1.x-branch d70bf4b9e -> fa753bffc
Address handling activate/deactivate in multilang module files
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/fa753bff
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/fa753bff
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/fa753bff
Branch: refs/heads/1.1.x-branch
Commit: fa753bffcf2168f4617e0d5630072cb4e0514824
Parents: d70bf4b
Author: Jan Schmidle <ja...@cospired.com>
Authored: Wed Dec 20 00:17:12 2017 +0100
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Wed Dec 27 05:53:19 2017 +0900
----------------------------------------------------------------------
.../multilang/resources/randomsentence.js | 8 ++++++++
.../main/resources/resources/randomsentence.js | 8 ++++++++
storm-core/src/dev/resources/tester_spout.js | 8 ++++++++
.../src/main/resources/resources/storm.js | 20 ++++++++++++++++++++
.../src/main/resources/resources/storm.py | 10 ++++++++++
.../ruby/src/main/resources/resources/storm.rb | 8 ++++++++
6 files changed, 62 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/fa753bff/examples/storm-starter/multilang/resources/randomsentence.js
----------------------------------------------------------------------
diff --git a/examples/storm-starter/multilang/resources/randomsentence.js b/examples/storm-starter/multilang/resources/randomsentence.js
index b121915..7fcf5e1 100644
--- a/examples/storm-starter/multilang/resources/randomsentence.js
+++ b/examples/storm-starter/multilang/resources/randomsentence.js
@@ -62,6 +62,14 @@ RandomSentenceSpout.prototype.nextTuple = function(done) {
},100);
}
+RandomSentenceSpout.prototype.activate = function(done) {
+ done();
+}
+
+RandomSentenceSpout.prototype.deactivate = function(done) {
+ done();
+}
+
RandomSentenceSpout.prototype.createNextTupleId = function() {
var id = this.runningTupleId;
this.runningTupleId++;
http://git-wip-us.apache.org/repos/asf/storm/blob/fa753bff/external/flux/flux-wrappers/src/main/resources/resources/randomsentence.js
----------------------------------------------------------------------
diff --git a/external/flux/flux-wrappers/src/main/resources/resources/randomsentence.js b/external/flux/flux-wrappers/src/main/resources/resources/randomsentence.js
index b121915..7fcf5e1 100644
--- a/external/flux/flux-wrappers/src/main/resources/resources/randomsentence.js
+++ b/external/flux/flux-wrappers/src/main/resources/resources/randomsentence.js
@@ -62,6 +62,14 @@ RandomSentenceSpout.prototype.nextTuple = function(done) {
},100);
}
+RandomSentenceSpout.prototype.activate = function(done) {
+ done();
+}
+
+RandomSentenceSpout.prototype.deactivate = function(done) {
+ done();
+}
+
RandomSentenceSpout.prototype.createNextTupleId = function() {
var id = this.runningTupleId;
this.runningTupleId++;
http://git-wip-us.apache.org/repos/asf/storm/blob/fa753bff/storm-core/src/dev/resources/tester_spout.js
----------------------------------------------------------------------
diff --git a/storm-core/src/dev/resources/tester_spout.js b/storm-core/src/dev/resources/tester_spout.js
index 269234f..e3658c3 100644
--- a/storm-core/src/dev/resources/tester_spout.js
+++ b/storm-core/src/dev/resources/tester_spout.js
@@ -44,6 +44,14 @@ TesterSpout.prototype.nextTuple = function(done) {
done();
}
+TesterSpout.prototype.activate = function(done) {
+ done();
+}
+
+TesterSpout.prototype.deactivate = function(done) {
+ done();
+}
+
TesterSpout.prototype.createNextTupleId = function() {
var id = this.runningTupleId;
this.runningTupleId++;
http://git-wip-us.apache.org/repos/asf/storm/blob/fa753bff/storm-multilang/javascript/src/main/resources/resources/storm.js
----------------------------------------------------------------------
diff --git a/storm-multilang/javascript/src/main/resources/resources/storm.js b/storm-multilang/javascript/src/main/resources/resources/storm.js
index 25e0a6d..a131eed 100755
--- a/storm-multilang/javascript/src/main/resources/resources/storm.js
+++ b/storm-multilang/javascript/src/main/resources/resources/storm.js
@@ -354,6 +354,18 @@ Spout.prototype = Object.create(Storm.prototype);
Spout.prototype.constructor = Spout;
/**
+ * This method will be called when a spout has been activated out of a deactivated mode.
+ * @param done Call this method when finished and ready to receive tuples.
+ */
+Spout.prototype.activate = function(done) {};
+
+/**
+ * This method will be called when a spout has been deactivated.
+ * @param done Call this method when finished.
+ */
+Spout.prototype.deactivate = function(done) {};
+
+/**
* This method will be called when an ack is received for preciously sent tuple. One may implement it.
* @param id The id of the tuple.
* @param done Call this method when finished and ready to receive more tuples.
@@ -380,6 +392,14 @@ Spout.prototype.handleNewCommand = function(command) {
self.sync();
}
+ if (command['command'] === 'activate') {
+ this.activate(callback);
+ }
+
+ if (command['command'] === 'deactivate') {
+ this.deactivate(callback);
+ }
+
if (command['command'] === 'next') {
this.nextTuple(callback);
}
http://git-wip-us.apache.org/repos/asf/storm/blob/fa753bff/storm-multilang/python/src/main/resources/resources/storm.py
----------------------------------------------------------------------
diff --git a/storm-multilang/python/src/main/resources/resources/storm.py b/storm-multilang/python/src/main/resources/resources/storm.py
index 224ed12..42b6378 100755
--- a/storm-multilang/python/src/main/resources/resources/storm.py
+++ b/storm-multilang/python/src/main/resources/resources/storm.py
@@ -232,6 +232,12 @@ class Spout(object):
def initialize(self, conf, context):
pass
+ def activate(self):
+ pass
+
+ def deactivate(self):
+ pass
+
def ack(self, id):
pass
@@ -249,6 +255,10 @@ class Spout(object):
self.initialize(conf, context)
while True:
msg = readCommand()
+ if msg["command"] == "activate":
+ self.activate()
+ if msg["command"] == "deactivate":
+ self.deactivate()
if msg["command"] == "next":
self.nextTuple()
if msg["command"] == "ack":
http://git-wip-us.apache.org/repos/asf/storm/blob/fa753bff/storm-multilang/ruby/src/main/resources/resources/storm.rb
----------------------------------------------------------------------
diff --git a/storm-multilang/ruby/src/main/resources/resources/storm.rb b/storm-multilang/ruby/src/main/resources/resources/storm.rb
index 816694e..5e955cc 100644
--- a/storm-multilang/ruby/src/main/resources/resources/storm.rb
+++ b/storm-multilang/ruby/src/main/resources/resources/storm.rb
@@ -205,6 +205,10 @@ module Storm
def open(conf, context); end
+ def activate; end
+
+ def deactivate; end
+
def nextTuple; end
def ack(id); end
@@ -219,6 +223,10 @@ module Storm
while true
msg = read_command
case msg['command']
+ when 'activate'
+ activate
+ when 'deactivate'
+ deactivate
when 'next'
nextTuple
when 'ack'