Beispiel #1
0
    def test_perl_spout(self):
        # Make sure ShellBolt.spec works
        class PerlWordCount(Topology):
            word_spout = ShellSpout.spec(
                command="perl", script="count_words.pl", par=2, outputs=["word"]
            )
            word_bolt = WordCountBolt.spec(
                inputs={word_spout: Grouping.fields("word")}, par=8
            )

        self.assertEqual(len(PerlWordCount.specs), 2)
        self.assertEqual(
            list(PerlWordCount.word_bolt.inputs.keys()),
            [PerlWordCount.word_spout["default"]],
        )
        self.assertEqual(
            PerlWordCount.thrift_spouts["word_spout"].common.parallelism_hint, 2
        )
        self.assertEqual(
            PerlWordCount.thrift_bolts["word_bolt"].common.parallelism_hint, 8
        )
        self.assertEqual(
            PerlWordCount.word_bolt.inputs[PerlWordCount.word_spout["default"]],
            Grouping.fields("word"),
        )
Beispiel #2
0
 class PerlWordCount(Topology):
     word_spout = WordSpout.spec(par=2)
     word_bolt = ShellBolt.spec(
         script="count_words.pl",
         inputs={word_spout: Grouping.fields("word")},
         par=8,
         outputs=["word", "count"],
     )
Beispiel #3
0
 class JavaWordCount(Topology):
     word_spout = JavaSpout.spec(
         full_class_name="com.bar.foo.counter.WordSpout",
         args_list=[u"foo", 1, b"\x09\x10", True, 3.14159],
         par=8,
         outputs=["word"],
     )
     word_bolt = WordCountBolt.spec(
         inputs={word_spout: Grouping.fields("word")}, par=8)
Beispiel #4
0
 class JavaWordCount(Topology):
     word_spout = WordSpout.spec(par=2)
     word_bolt = JavaBolt.spec(
         full_class_name="com.bar.foo.counter.WordCountBolt",
         args_list=[{"foo": "bar"}, 1],
         inputs={word_spout: Grouping.fields("word")},
         par=8,
         outputs=["word", "count"],
     )
Beispiel #5
0
 class JavaWordCount(Topology):
     word_spout = JavaSpout.spec(
         full_class_name='com.bar.foo.counter.WordSpout',
         args_list=[{
             'foo': 'bar'
         }, 1],
         par=8,
         outputs=['word'])
     word_bolt = WordCountBolt.spec(
         inputs={word_spout: Grouping.fields("word")}, par=8)
Beispiel #6
0
    def test_basic_spec(self):
        class WordCount(Topology):
            word_spout = WordSpout.spec(par=2)
            word_bolt = WordCountBolt.spec(inputs={word_spout:
                                                   Grouping.fields("word")},
                                           par=8)

        self.assertEqual(len(WordCount.specs), 2)
        self.assertEqual(list(WordCount.word_bolt.inputs.keys())[0],
                         WordCount.word_spout['default'])
        self.assertEqual(WordCount.word_bolt.inputs[WordCount.word_spout['default']],
                         Grouping.fields('word'))
Beispiel #7
0
    def test_basic_spec(self):
        class WordCount(Topology):
            word_spout = WordSpout.spec(par=2)
            word_bolt = WordCountBolt.spec(
                inputs={word_spout: Grouping.fields("word")}, par=8)

        self.assertEqual(len(WordCount.specs), 2)
        self.assertEqual(
            list(WordCount.word_bolt.inputs.keys())[0],
            WordCount.word_spout['default'])
        self.assertEqual(
            WordCount.word_bolt.inputs[WordCount.word_spout['default']],
            Grouping.fields('word'))
Beispiel #8
0
    def test_basic_spec(self):
        class WordCount(Topology):
            word_spout = WordSpout.spec(par=2)
            word_bolt = WordCountBolt.spec(inputs={word_spout:
                                                   Grouping.fields("word")},
                                           par=8)

        self.assertEqual(len(WordCount.specs), 2)
        self.assertEqual(list(WordCount.word_bolt.inputs.keys()),
                         [WordCount.word_spout['default']])
        self.assertEqual(WordCount.thrift_spouts['word_spout'].common.parallelism_hint,
                         2)
        self.assertEqual(WordCount.thrift_bolts['word_bolt'].common.parallelism_hint,
                         8)
        self.assertEqual(WordCount.word_bolt.inputs[WordCount.word_spout['default']],
                         Grouping.fields('word'))
Beispiel #9
0
    def test_basic_spec(self):
        class WordCount(Topology):
            word_spout = WordSpout.spec(par=2)
            word_bolt = WordCountBolt.spec(
                inputs={word_spout: Grouping.fields("word")}, par=8)

        self.assertEqual(len(WordCount.specs), 2)
        self.assertEqual(list(WordCount.word_bolt.inputs.keys()),
                         [WordCount.word_spout['default']])
        self.assertEqual(
            WordCount.thrift_spouts['word_spout'].common.parallelism_hint, 2)
        self.assertEqual(
            WordCount.thrift_bolts['word_bolt'].common.parallelism_hint, 8)
        self.assertEqual(
            WordCount.word_bolt.inputs[WordCount.word_spout['default']],
            Grouping.fields('word'))
Beispiel #10
0
 def test_perl_spout(self):
     # Make sure ShellBolt.spec works
     class PerlWordCount(Topology):
         word_spout = ShellSpout.spec(command='perl',
                                      script='count_words.pl', par=2,
                                      outputs=['word'])
         word_bolt = WordCountBolt.spec(inputs={word_spout: Grouping.fields("word")},
                                        par=8)
     self.assertEqual(len(PerlWordCount.specs), 2)
     self.assertEqual(list(PerlWordCount.word_bolt.inputs.keys()),
                      [PerlWordCount.word_spout['default']])
     self.assertEqual(PerlWordCount.thrift_spouts['word_spout'].common.parallelism_hint,
                      2)
     self.assertEqual(PerlWordCount.thrift_bolts['word_bolt'].common.parallelism_hint,
                      8)
     self.assertEqual(PerlWordCount.word_bolt.inputs[PerlWordCount.word_spout['default']],
                      Grouping.fields('word'))
Beispiel #11
0
    def test_perl_bolt(self):
        # Make sure ShellBolt.spec works
        class PerlWordCount(Topology):
            word_spout = WordSpout.spec(par=2)
            word_bolt = ShellBolt.spec(command='perl', script='count_words.pl',
                                       inputs={word_spout: Grouping.fields("word")},
                                       par=8, outputs=['word', 'count'])

        self.assertEqual(len(PerlWordCount.specs), 2)
        self.assertEqual(list(PerlWordCount.word_bolt.inputs.keys()),
                         [PerlWordCount.word_spout['default']])
        self.assertEqual(PerlWordCount.thrift_spouts['word_spout'].common.parallelism_hint,
                         2)
        self.assertEqual(PerlWordCount.thrift_bolts['word_bolt'].common.parallelism_hint,
                         8)
        self.assertEqual(PerlWordCount.word_bolt.inputs[PerlWordCount.word_spout['default']],
                         Grouping.fields('word'))
Beispiel #12
0
 class WordCount(Topology):
     word_spout = WordSpout.spec(par=2)
     word_bolt = WordCountBolt.spec(
         inputs={word_spout: Grouping.fields("word")}, par=8)
Beispiel #13
0
 class PerlWordCount(Topology):
     word_spout = ShellSpout.spec(script='count_words.pl',
                                  par=8,
                                  outputs=['word'])
     word_bolt = WordCountBolt.spec(
         inputs={word_spout: Grouping.fields("word")}, par=8)
Beispiel #14
0
 class PerlWordCount(Topology):
     word_spout = WordSpout.spec(par=2)
     word_bolt = ShellBolt.spec(command='perl', script='count_words.pl',
                                inputs={word_spout: Grouping.fields("word")},
                                par=8, outputs=['word', 'count'])
Beispiel #15
0
 class WordCount(Topology):
     word_spout = WordSpout.spec()
     word_bolt = WordCountBolt.spec(
         inputs={'word_spout': Grouping.fields('word')})
Beispiel #16
0
 class WordCount(Topology):
     word_spout = WordSpout.spec()
     word_bolt = WordCountBolt.spec(
         inputs={word_spout: Grouping.fields("foo")})
Beispiel #17
0
 class JavaWordCount(Topology):
     word_spout = JavaSpout.spec(serialized_java=serialized_java,
                                 par=8,
                                 outputs=['word'])
     word_bolt = WordCountBolt.spec(
         inputs={word_spout: Grouping.fields("word")}, par=8)
Beispiel #18
0
 class PerlWordCount(Topology):
     word_spout = ShellSpout.spec(command='perl',
                                  par=8,
                                  outputs=['word'])
     word_bolt = WordCountBolt.spec(
         inputs={word_spout: Grouping.fields("word")}, par=8)