コード例 #1
0
 def test_create_network(self):
   """
   Tests creating a network.
   """
   network = vertigo.create_network("test")
   self.assert_equals("test", network.address)
   network.address = "foo"
   self.assert_equals("foo", network.address)
   network.enable_acking()
   self.assert_true(network.acking_enabled())
   network.disable_acking()
   self.assert_false(network.acking_enabled())
   network.num_ackers = 10
   self.assert_equals(10, network.num_ackers)
   network.ack_expire = 50000
   self.assert_equals(50000, network.ack_expire)
   component = network.from_verticle('test_feeder_verticle', main='test_feeder_verticle.py')
   self.assert_equals('test_feeder_verticle', component.name)
   self.assert_equals('test_feeder_verticle.py', component.main)
   component.workers = 4
   self.assert_equals(4, component.workers)
   component2 = component.to_verticle('test_worker_verticle')
   component2.main = 'test_worker_verticle.py'
   self.assert_equals('test_worker_verticle.py', component2.main)
   self.complete()
コード例 #2
0
 def test_batch_send(self):
     """Test sending batch messages between two components."""
     network = vertigo.create_network('test-batch')
     network.add_verticle('sender', main='test_batch_sender.py')
     network.add_verticle('receiver', main='test_batch_receiver.py')
     network.create_connection(('sender', 'out'), ('receiver', 'in'))
     def cluster_handler(error, cluster):
         self.assert_null(error)
         def deploy_handler(error, network):
             self.assert_null(error)
         cluster.deploy_network(network, handler=deploy_handler)
     vertigo.deploy_cluster('test_batch_send', handler=cluster_handler)
コード例 #3
0
 def test_create_network(self):
     """Tests creating a network."""
     network = vertigo.create_network('test')
     self.assert_equals('test', network.name)
     component1 = network.add_verticle('test_verticle1', main='test_verticle1.py')
     self.assert_equals('test_verticle1', component1.name)
     self.assert_equals('test_verticle1.py', component1.main)
     component1.instances = 4
     self.assert_equals(4, component1.instances)
     component2 = network.add_verticle('test_verticle2', main='test_verticle2.py')
     component2.main = 'test_verticle3.py'
     self.assert_equals('test_verticle3.py', component2.main)
     self.complete()
コード例 #4
0
 def _create_ack_network(self, feeder):
   network = vertigo.create_network()
   network.address = "test"
   network.enable_acking()
   network.from_verticle('test_feeder', feeder).to_verticle('test_worker', 'test_acking_worker.py')
   return network
コード例 #5
0
# Copyright 2014 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import vertigo

network = vertigo.create_network('word_count')
network.add_verticle('word_feeder', 'word_count_feeder.py', config={'words': ['apple', 'banana', 'orange']})
network.add_verticle('word_counter', 'word_count_worker.py', instances=2)
network.create_connection(('word_feeder', 'out'), ('word_counter', 'in'), grouping='hash')

def deploy_handler(error, context):
    if error:
        print error.getMessage()

vertigo.deploy_local_network(network, handler=deploy_handler)
コード例 #6
0
# Copyright 2014 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import vertigo

network = vertigo.create_network('word_count')
network.add_verticle('word_feeder',
                     'word_count_feeder.py',
                     config={'words': ['apple', 'banana', 'orange']})
network.add_verticle('word_counter', 'word_count_worker.py', instances=2)
network.create_connection(('word_feeder', 'out'), ('word_counter', 'in'),
                          grouping='hash')


def deploy_handler(error, context):
    if error:
        print error.getMessage()


vertigo.deploy_local_network(network, handler=deploy_handler)