def _run_letter2(self): messaging_system = ZMQMessagingSystem("localhost", self.registry_port, 9002) messager = Messager() letter2_stream = messager.get_stream(messaging_system, "letter2", StringMessage) configuration_stream = messager.get_stream(messaging_system, "configuration", ConfigurationMessage) letter2_metrics_stream = messager.get_stream(messaging_system, "letter2_metrics", Metrics) service_runner_factory = ServiceRunnerFactory(messager) letter2_generator_service_runner = service_runner_factory.get_service_runner( LetterGeneratorService, { "name": "letter2_generator_service", "endpoint": letter2_stream.get_write_endpoint() }, configuration_stream=configuration_stream, metrics_stream=letter2_metrics_stream) letter2_generator_service_runner.start() self.letter2_stopped = False while not self.letter2_stopped: time.sleep(1) letter2_generator_service_runner.terminate() logging.debug("THREAD _run_letter2 terminates.")
def test(self): messaging_system = QueueMessagingSystem() messager = Messager() numbers_endpoint = messager.get_endpoint(messaging_system, "numbers", StringMessage) number_generator_service = NumberGeneratorService(numbers_endpoint) number_generator_service_container = ServiceContainer(number_generator_service, messager) number_generator_service_container.start() time.sleep(10) number_generator_service_container.terminate() number_generator_service_container.wait()
def test(self): messaging_system = QueueMessagingSystem() messager = Messager() numbers_endpoint = messager.get_endpoint(messaging_system, "numbers", StringMessage) parameters = {'name': 'number_service', 'endpoint': numbers_endpoint} configuration_endpoint = messager.get_endpoint(messaging_system, "configuration", ConfigurationMessage) configuration_adapter = ConfigurationAdapter(NumberGeneratorService, parameters, configuration_endpoint) number_generator_service_runner = ServiceRunner( configuration_adapter, messager) number_generator_service_runner.start() time.sleep(10) configuration_message = ConfigurationMessage({}) messager.publish(configuration_endpoint, configuration_message) time.sleep(10) number_generator_service_runner.terminate() number_generator_service_runner.wait()
def _run_monitor(self): messaging_system = ZMQMessagingSystem("localhost", self.registry_port, 9005) messager = Messager() letter1_metrics_stream = messager.get_stream(messaging_system, "letter1_metrics", Metrics) letter2_metrics_stream = messager.get_stream(messaging_system, "letter2_metrics", Metrics) concatenator_metrics_stream = messager.get_stream( messaging_system, "concatenator_metrics", Metrics) writer_metrics_stream = messager.get_stream(messaging_system, "writer_metrics", Metrics) monitor_service = GenericMonitorService("generic_monitor_service", [ letter1_metrics_stream.get_read_endpoint(), letter2_metrics_stream.get_read_endpoint(), concatenator_metrics_stream.get_read_endpoint(), writer_metrics_stream.get_read_endpoint() ]) monitor_service_runner = ServiceRunner(monitor_service, messager) monitor_service_runner.start() self.monitor_stopped = False while not self.monitor_stopped: time.sleep(1) monitor_service_runner.terminate() logging.debug("THREAD _run_monitor terminates.")
def _run_writer(self): messaging_system = ZMQMessagingSystem("localhost", self.registry_port, 9004) messager = Messager() concatenation_stream = messager.get_stream(messaging_system, "concatenation", StringMessage) control_stream = messager.get_stream(messaging_system, "control", StringMessage) configuration_stream = messager.get_stream(messaging_system, "configuration", ConfigurationMessage) writer_metrics_stream = messager.get_stream(messaging_system, "writer_metrics", Metrics) service_runner_factory = ServiceRunnerFactory(messager) string_writer_service_runner = service_runner_factory.get_service_runner( StringWriterService, { "name": "string_writer_service", "string_endpoint": concatenation_stream.get_read_endpoint(), "control_endpoint": control_stream.get_read_endpoint() }, configuration_stream=configuration_stream, metrics_stream=writer_metrics_stream) string_writer_service_runner.start() self.writer_stopped = False while not self.writer_stopped: time.sleep(1) string_writer_service_runner.terminate() logging.debug("THREAD _run_writer terminates.")
def test(self): messaging_system = QueueMessagingSystem() messager = Messager() datagram_endpoint = messager.get_endpoint(messaging_system, "datagram", VisibilityDatagram) string_endpoint = messager.get_endpoint(messaging_system, "string", StringMessage) control_endpoint = messager.get_endpoint(messaging_system, "control", StringMessage) to_string_service = ToStringService(datagram_endpoint, string_endpoint, control_endpoint) to_string_service_container = ServiceContainer(to_string_service, messager) to_string_service_container.start() time.sleep(5) messager.publish(control_endpoint, StringMessage("Start")) time.sleep(10) messager.publish(control_endpoint, StringMessage("Stop")) time.sleep(5) to_string_service_container.terminate() to_string_service_container.wait()
def test(self): messaging_system = QueueMessagingSystem() messager = Messager() string_endpoint = messager.get_endpoint(messaging_system, "string", StringMessage) control_endpoint = messager.get_endpoint(messaging_system, "control", StringMessage) string_writer_service = StringWriterService(string_endpoint, control_endpoint, "output.txt") string_writer_service_container = ServiceContainer( string_writer_service, messager) string_writer_service_container.start() time.sleep(5) messager.publish(control_endpoint, StringMessage("Start")) time.sleep(10) messager.publish(control_endpoint, StringMessage("Stop")) time.sleep(5) string_writer_service_container.terminate() string_writer_service_container.wait()
def test(self): messaging_system = QueueMessagingSystem() messager = Messager() service_runner_factory = ServiceRunnerFactory(messager) configuration_stream = messager.get_stream(messaging_system, "configuration", ConfigurationMessage) control_stream = messager.get_stream(messaging_system, "control", StringMessage) metadata_stream = messager.get_stream(messaging_system, "metadata", TOSMetadata) metadata_metrics_stream = messager.get_stream(messaging_system, "metadatametrics", Metrics) ice_metadata_source_service_runner = service_runner_factory.get_service_runner( IceMetadataSourceService, { "name": "ice_metadata_source_service", "metadata_endpoint": metadata_stream.get_write_endpoint(), "control_endpoint": control_stream.get_read_endpoint() }, metrics_stream=metadata_metrics_stream, configuration_stream=configuration_stream) datagram_stream = messager.get_stream(messaging_system, "datagram", VisibilityDatagram) datagram_metrics_stream = messager.get_stream(messaging_system, "datagrammetrics", Metrics) visibility_datagram_source_service_runner = service_runner_factory.get_service_runner( VisibilityDatagramSourceService, { "name": "visibility_datagram_source_service", "visibility_datagram_endpoint": datagram_stream.get_write_endpoint(), "control_endpoint": control_stream.get_read_endpoint() }, metrics_stream=datagram_metrics_stream, configuration_stream=configuration_stream) # set up the align service chunk_stream = messager.get_stream(messaging_system, "chunk", VisibilityChunk) align_metrics_stream = messager.get_stream(messaging_system, "alignmetrics", Metrics) align_service_runner = service_runner_factory.get_service_runner( AlignService, { "name": "align_service", "datagram_endpoint": datagram_stream.get_read_endpoint(), "metadata_endpoint": metadata_stream.get_read_endpoint(), "chunk_endpoint": chunk_stream.get_write_endpoint(), "control_endpoint": control_stream.get_read_endpoint() }, metrics_stream=align_metrics_stream, configuration_stream=configuration_stream) # set up the uvwcalculation service uvw_chunk_stream = messager.get_stream(messaging_system, "uvwchunk", UVWChunk) uvw_calculation_metrics_stream = messager.get_stream( messaging_system, "uvwcalcmetrics", Metrics) uvw_calculation_service_runner = service_runner_factory.get_service_runner( UVWCalculationService, { "name": "uvw_calculation_service", "observatory_name": "ASKAP", "visibility_chunk_endpoint": chunk_stream.get_read_endpoint(), "metadata_endpoint": metadata_stream.get_read_endpoint(), "uvw_chunk_endpoint": uvw_chunk_stream.get_write_endpoint(), "control_endpoint": control_stream.get_read_endpoint() }, metrics_stream=uvw_calculation_metrics_stream, configuration_stream=configuration_stream) uvw_chunk_string_stream = messager.get_stream(messaging_system, "chunkstring", StringMessage) to_string_metrics_stream = messager.get_stream(messaging_system, "to_stringmetrics", Metrics) to_string_service_runner = service_runner_factory.get_service_runner( ToStringService, { "name": "to_string_service", "input_endpoint": uvw_chunk_stream.get_read_endpoint(), "output_endpoint": uvw_chunk_string_stream.get_write_endpoint(), "control_endpoint": control_stream.get_read_endpoint() }, metrics_stream=to_string_metrics_stream, configuration_stream=configuration_stream) string_writer_metrics_stream = messager.get_stream( messaging_system, "stringwritermetrics", Metrics) string_writer_service_runner = service_runner_factory.get_service_runner( StringWriterService, { "name": "string_writer_service", "string_endpoint": uvw_chunk_string_stream.get_read_endpoint(), "control_endpoint": control_stream.get_read_endpoint() }, metrics_stream=string_writer_metrics_stream, configuration_stream=configuration_stream) monitor_service = GenericMonitorService("generic_monitor_service", [ datagram_metrics_stream.get_read_endpoint(), metadata_metrics_stream.get_read_endpoint(), align_metrics_stream.get_read_endpoint(), uvw_calculation_metrics_stream.get_read_endpoint(), to_string_metrics_stream.get_read_endpoint(), string_writer_metrics_stream.get_read_endpoint() ]) monitor_service_runner = ServiceRunner(monitor_service, messager) configuration_control_stream = messager.get_stream( messaging_system, "configurationcontrol", StringMessage) configuration_service = HardConfigurationService( "configuration_service", configuration_control_stream.get_read_endpoint(), configuration_stream.get_write_endpoint()) configuration_service_runner = ServiceRunner(configuration_service, messager) # start Ice logging.info("Starting Ice") ice_runner = IceRunner("testbed_data") ice_runner.start() logging.info("Starting services") configuration_service_runner.start() monitor_service_runner.start() visibility_datagram_source_service_runner.start() ice_metadata_source_service_runner.start() align_service_runner.start() uvw_calculation_service_runner.start() to_string_service_runner.start() string_writer_service_runner.start() logging.info("Publishing configuration") mainline_configuration_control_endpoint = configuration_control_stream.get_write_endpoint( ) logging.info("Issuing configuration") messager.publish(mainline_configuration_control_endpoint, StringMessage("Start")) time.sleep(10) logging.info("Starting processing") mainline_control_endpoint = control_stream.get_write_endpoint() messager.publish(mainline_control_endpoint, StringMessage("Start")) # start playback logging.info("Starting playback") playback = Playback("testbed_data") playback.playback("data/ade1card.ms") playback.wait() time.sleep(10) messager.publish(mainline_control_endpoint, StringMessage("Stop")) time.sleep(10) ice_metadata_source_service_runner.terminate() visibility_datagram_source_service_runner.terminate() align_service_runner.terminate() uvw_calculation_service_runner.terminate() to_string_service_runner.terminate() string_writer_service_runner.terminate() monitor_service_runner.terminate() configuration_service_runner.terminate() # stop Ice logging.info("stopping Ice") ice_runner.stop()
def test(self): messaging_system = QueueMessagingSystem() messager = Messager() upper_endpoint = messager.get_endpoint(messaging_system, "upper", StringMessage) upper_metrics_endpoint = messager.get_endpoint(messaging_system, "upper_metrics", Metrics) lower_endpoint = messager.get_endpoint(messaging_system, "lower", StringMessage) lower_metrics_endpoint = messager.get_endpoint(messaging_system, "lower_metrics", Metrics) concatenation_endpoint = messager.get_endpoint(messaging_system, "concatenation", StringMessage) concatenator_control_endpoint = messager.get_endpoint(messaging_system, "concatenator_control", StringMessage) concatenator_metrics_endpoint = messager.get_endpoint(messaging_system, "concatenator_metrics", Metrics) writer_control_endpoint = messager.get_endpoint(messaging_system, "writer_control", StringMessage) writer_metrics_endpoint = messager.get_endpoint(messaging_system, "writer_metrics", Metrics) uppercase_letter_generator_service = LetterGeneratorService(upper_endpoint, upper=True) uppercase_letter_generator_monitor_adapter = MonitorAdapter(uppercase_letter_generator_service, "uppercase_letter_generator_service", upper_metrics_endpoint) uppercase_letter_generator_service_container = ServiceContainer(uppercase_letter_generator_monitor_adapter, messager) lowercase_letter_generator_service = LetterGeneratorService(lower_endpoint) lowercase_letter_generator_monitor_adapter = MonitorAdapter(lowercase_letter_generator_service, "lowercase_letter_generator_service", lower_metrics_endpoint) lowercase_letter_generator_service_container = ServiceContainer(lowercase_letter_generator_monitor_adapter, messager) string_concatenator_service = StringConcatenatorService(upper_endpoint, lower_endpoint, concatenation_endpoint, concatenator_control_endpoint) string_concatenator_monitor_adapter = MonitorAdapter(string_concatenator_service, "string_concatenator_service", concatenator_metrics_endpoint) string_concatenator_service_container = ServiceContainer(string_concatenator_monitor_adapter, messager) string_writer_service = StringWriterService(concatenation_endpoint, writer_control_endpoint, "output.txt") string_writer_monitor_adapter = MonitorAdapter(string_writer_service, "string_writer_service", writer_metrics_endpoint) string_writer_service_container = ServiceContainer(string_writer_monitor_adapter, messager) monitor_service = GenericMonitorService([upper_metrics_endpoint, lower_metrics_endpoint, concatenator_metrics_endpoint, writer_metrics_endpoint]) monitor_service_container = ServiceContainer(monitor_service, messager) # start them, wait ten seconds, stop them logging.info("starting services") monitor_service_container.start() string_writer_service_container.start() string_concatenator_service_container.start() uppercase_letter_generator_service_container.start() lowercase_letter_generator_service_container.start() time.sleep(1) logging.info("starting processing") messager.publish(writer_control_endpoint, StringMessage("Start")) messager.publish(concatenator_control_endpoint, StringMessage("Start")) logging.info("sleeping") time.sleep(10) logging.info("stopping processing") messager.publish(writer_control_endpoint, StringMessage("Stop")) messager.publish(concatenator_control_endpoint, StringMessage("Stop")) time.sleep(1) logging.info("stopping services") uppercase_letter_generator_service_container.terminate() lowercase_letter_generator_service_container.terminate() string_concatenator_service_container.terminate() string_writer_service_container.terminate() monitor_service_container.terminate()
def test(self): messaging_system = QueueMessagingSystem() messager = Messager() configuration_stream = messager.get_stream(messaging_system, "configuration", ConfigurationMessage) control_stream = messager.get_stream(messaging_system, "control", StringMessage) input_stream = messager.get_stream(messaging_system, "input", StringMessage) output_stream = messager.get_stream(messaging_system, "output", StringMessage) service_runner_factory = ServiceRunnerFactory(messager) socket_writer_service_runner = service_runner_factory.get_service_runner( SocketWriterService, { "name": "socket_writer_service", "input_endpoint": input_stream.get_read_endpoint(), "control_endpoint": control_stream.get_read_endpoint(), "input_class": StringMessage }, configuration_stream=configuration_stream) socket_reader_service_runner = service_runner_factory.get_service_runner( SocketReaderService, { "name": "socket_reader_service", "output_endpoint": output_stream.get_write_endpoint(), "control_endpoint": control_stream.get_read_endpoint(), "output_class": StringMessage }, configuration_stream=configuration_stream) # start them, wait ten seconds, stop them logging.info("starting services") socket_writer_service_runner.start() socket_reader_service_runner.start() time.sleep(5) logging.info("Publishing ConfigurationMessage") mainline_configuration_endpoint = configuration_stream.get_write_endpoint( ) configuration_message = ConfigurationMessage({ "socket_writer_service": { "host": "localhost", "port": "10001" }, "socket_reader_service": { "host": "localhost", "port": "10001" } }) messager.publish(mainline_configuration_endpoint, configuration_message) time.sleep(5) logging.info("Publishing 'Start' control message") mainline_control_endpoint = control_stream.get_write_endpoint() messager.publish(mainline_control_endpoint, StringMessage("Start")) time.sleep(5) mainline_input_endpoint = input_stream.get_write_endpoint() mainline_output_endpoint = output_stream.get_read_endpoint() logging.info("Publishing messagse to socket writer...") messager.publish(mainline_input_endpoint, StringMessage("Message 1")) messager.publish(mainline_input_endpoint, StringMessage("Message 2")) messager.publish(mainline_input_endpoint, StringMessage("Message 3")) messager.publish(mainline_input_endpoint, StringMessage("Message 4")) messager.publish(mainline_input_endpoint, StringMessage("Message 5")) messager.publish(mainline_input_endpoint, StringMessage("Message 6")) messager.publish(mainline_input_endpoint, StringMessage("Message 7")) messager.publish(mainline_input_endpoint, StringMessage("Message 8")) messager.publish(mainline_input_endpoint, StringMessage("Message 9")) messager.publish(mainline_input_endpoint, StringMessage("Message 10")) time.sleep(5) logging.info("Checking for message at socket reader...") for i in range(20): message = messager.poll(mainline_output_endpoint) if message is None: logging.info("No message.") time.sleep(1) else: logging.info("Message is '{}'".format(message.get_payload())) logging.info("Publishing 'Stop' control message") messager.publish(mainline_control_endpoint, StringMessage("Stop")) time.sleep(5) logging.info("Stopping services") socket_writer_service_runner.terminate() socket_reader_service_runner.terminate()
def test(self): messaging_system = QueueMessagingSystem() messager = Messager() configuration_stream = messager.get_stream(messaging_system, "configuration", ConfigurationMessage) control_stream = messager.get_stream(messaging_system, "control", StringMessage) service_runner_factory = ServiceRunnerFactory(messager) visibility_stream = messager.get_stream(messaging_system, "visibility", VisibilityDatagram) visibility_datagram_source_service_runner = service_runner_factory.get_service_runner( VisibilityDatagramSourceService, { "name": "visibility_datagram_source_service", "visibility_datagram_endpoint": visibility_stream.get_endpoint(), "control_endpoint": control_stream.get_endpoint() }, configuration_stream=configuration_stream) visibility_string_stream = messager.get_stream(messaging_system, "visibilitystring", StringMessage) tostring_service_runner = service_runner_factory.get_service_runner( ToStringService, { "name": "tostring_service", "input_endpoint": visibility_stream.get_endpoint(), "output_endpoint": visibility_string_stream.get_endpoint(), "control_endpoint": control_stream.get_endpoint() }, configuration_stream=configuration_stream) string_writer_service_runner = service_runner_factory.get_service_runner( StringWriterService, { "name": "string_writer_service", "string_endpoint": visibility_string_stream.get_endpoint(), "control_endpoint": control_stream.get_endpoint() }, configuration_stream=configuration_stream) # start Ice logging.info("Starting Ice") ice_runner = IceRunner("testbed_data") ice_runner.start() time.sleep(5) logging.info("Starting services") string_writer_service_runner.start() tostring_service_runner.start() visibility_datagram_source_service_runner.start() time.sleep(5) logging.info("Publishing configuration") mainline_configuration_endpoint = configuration_stream.get_endpoint() configuration_message = ConfigurationMessage({ "antennas": { "ant2": { "name": "ak02", "itrf": (-2556109.976515, 5097388.699862, -2848440.12097248) }, "ant4": { "name": "ak04", "itrf": (-2556087.396082, 5097423.589662, -2848396.867933) }, "ant5": { "name": "ak05", "itrf": (-2556028.607336, 5097451.468188, -2848399.83113161) }, "ant10": { "name": "ak10", "itrf": (-2556059.228687, 5097560.766055, -2848178.119367) }, "ant12": { "name": "ak12", "itrf": (-2556496.237175, 5097333.724901, -2848187.33832738) }, # other to get 12-antennas "ant7": { "name": "ak07", "itrf": (-2556282.880670, 5097252.290820, -2848527.104272) }, "ant11": { "name": "ak11", "itrf": (-2556397.233607, 5097421.429903, -2848124.497319) }, # old BETA antennas "ant1": { "name": "ak01", "itrf": (-2556084.669, 5097398.337, -2848424.133) }, "ant15": { "name": "ak15", "itrf": (-2555389.850372, 5097664.627578, -2848561.95991566) }, "ant3": { "name": "ak03", "itrf": (-2556118.109261, 5097384.719695, -2848417.19642608) }, "ant6": { "name": "ak06", "itrf": (-2556227.878593, 5097380.442223, -2848323.44598377) }, "ant8": { "name": "ak08", "itrf": (-2556002.509816, 5097320.293832, -2848637.482106) }, "ant9": { "name": "ak09", "itrf": (-2555888.891875, 5097552.280516, -2848324.679547) } }, "metadata_source": { "host": "localhost", "port": "4061", "topicmanager": "IceStorm/[email protected]", "topic": "metadata", "adapter": "IngestPipeline" }, "datagram_source": { "host": "localhost", "port": "3000" }, "correlation_modes": { "standard": { "channel_width": "18.518518", "interval": "5000000", "number_of_channels": "216", "stokes": ["XX", "XY", "YX", "YY"] } }, "maximum_number_of_beams": "36", "string_writer_service.output_path": "output.txt" }) messager.publish(mainline_configuration_endpoint, configuration_message) logging.info("Starting processing") mainline_control_endpoint = control_stream.get_endpoint() messager.publish(mainline_control_endpoint, StringMessage("Start")) # start playback logging.info("Starting playback") playback = Playback("testbed_data") playback.playback("data/ade1card.ms") playback.wait() time.sleep(10) messager.publish(mainline_control_endpoint, StringMessage("Stop")) time.sleep(10) visibility_datagram_source_service_runner.terminate() tostring_service_runner.terminate() string_writer_service_runner.terminate() # stop Ice logging.info("stopping Ice") ice_runner.stop()
def test(self): messaging_system = QueueMessagingSystem() messager = Messager() metrics_endpoint = messager.get_endpoint(messaging_system, "metrics", Metrics) first_endpoint = messager.get_endpoint(messaging_system, "first", StringMessage) second_endpoint = messager.get_endpoint(messaging_system, "second", StringMessage) concatenation_endpoint = messager.get_endpoint(messaging_system, "concatenation", StringMessage) control_endpoint = messager.get_endpoint(messaging_system, "control", StringMessage) string_concatenator_service = StringConcatenatorService( first_endpoint, second_endpoint, concatenation_endpoint, control_endpoint) monitor_adapter = MonitorAdapter(string_concatenator_service, metrics_endpoint) service_container = ServiceContainer(monitor_adapter, messager) service_container.start() time.sleep(5) logging.info("Publishing 'Start' control message") messager.publish(control_endpoint, StringMessage("Start")) time.sleep(10) logging.info("Publishing 'Stop' control message") messager.publish(control_endpoint, StringMessage("Stop")) time.sleep(5) service_container.terminate() service_container.wait()
def test(self): messaging_system = QueueMessagingSystem() messager = Messager() metrics_endpoint = messager.get_endpoint(messaging_system, "metrics", Metrics) first_endpoint = messager.get_endpoint(messaging_system, "first", StringMessage) second_endpoint = messager.get_endpoint(messaging_system, "second", StringMessage) concatenation_endpoint = messager.get_endpoint(messaging_system, "concatenation", StringMessage) control_endpoint = messager.get_endpoint(messaging_system, "control", StringMessage) parameters = { "name": "string_concatenator_service", "first_endpoint": first_endpoint, "second_endpoint": second_endpoint, "concatenation_endpoint": concatenation_endpoint, "control_endpoint": control_endpoint } configuration_endpoint = messager.get_endpoint(messaging_system, "configuration", ConfigurationMessage) configuration_adapter = ConfigurationAdapter(StringConcatenatorService, parameters, configuration_endpoint) monitor_adapter = MonitorAdapter(configuration_adapter, metrics_endpoint) service_runner = ServiceRunner(monitor_adapter, messager) service_runner.start() time.sleep(5) logging.info("Publishing ConfigurationMessage") configuration_message = ConfigurationMessage({}) messager.publish(configuration_endpoint, configuration_message) time.sleep(5) logging.info("Publishing 'Start' control message") messager.publish(control_endpoint, StringMessage("Start")) time.sleep(5) logging.info("Publishing 'Stop' control message") messager.publish(control_endpoint, StringMessage("Stop")) time.sleep(5) service_runner.terminate() service_runner.wait()
def test(self): messaging_system = QueueMessagingSystem() messager = Messager() string_endpoint = messager.get_endpoint(messaging_system, "string", StringMessage) control_endpoint = messager.get_endpoint(messaging_system, "control", StringMessage) parameters = { "name": "string_writer_service", "string_endpoint": string_endpoint, "control_endpoint": control_endpoint } configuration_endpoint = messager.get_endpoint(messaging_system, "configuration", ConfigurationMessage) configuration_adapter = ConfigurationAdapter(StringWriterService, parameters, configuration_endpoint) service_runner = ServiceRunner(configuration_adapter, messager) service_runner.start() time.sleep(5) logging.info("Publishing ConfigurationMessage") configuration_message = ConfigurationMessage( {"string_writer_service.output_path": "output.txt"}) messager.publish(configuration_endpoint, configuration_message) time.sleep(5) logging.info("Publishing 'Start' control message") messager.publish(control_endpoint, StringMessage("Start")) time.sleep(10) logging.info("Publishing 'Stop' control message") messager.publish(control_endpoint, StringMessage("Stop")) time.sleep(5) service_runner.terminate() service_runner.wait()
def test(self): messaging_system = QueueMessagingSystem() messager = Messager() metadata_endpoint = messager.get_endpoint(messaging_system, "metadata", TOSMetadata) metadata_control_endpoint = messager.get_endpoint( messaging_system, "metadatacontrol", StringMessage) metadata_metrics_endpoint = messager.get_endpoint( messaging_system, "metadatametrics", Metrics) datagram_endpoint = messager.get_endpoint(messaging_system, "datagram", VisibilityDatagram) datagram_control_endpoint = messager.get_endpoint( messaging_system, "datagramcontrol", StringMessage) datagram_metrics_endpoint = messager.get_endpoint( messaging_system, "datagrammetrics", Metrics) chunk_endpoint = messager.get_endpoint(messaging_system, "chunk", VisibilityChunk) align_control_endpoint = messager.get_endpoint(messaging_system, "aligncontrol", StringMessage) align_metrics_endpoint = messager.get_endpoint(messaging_system, "alignmetrics", Metrics) chunk_string_endpoint = messager.get_endpoint(messaging_system, "chunkstring", StringMessage) to_string_control_endpoint = messager.get_endpoint( messaging_system, "to_stringcontrol", StringMessage) to_string_metrics_endpoint = messager.get_endpoint( messaging_system, "to_stringmetrics", Metrics) string_writer_control_endpoint = messager.get_endpoint( messaging_system, "stringwritercontrol", StringMessage) string_writer_metrics_endpoint = messager.get_endpoint( messaging_system, "stringwritermetrics", Metrics) # start Ice logging.info("Starting Ice") ice_runner = IceRunner("testbed_data") ice_runner.start() # set up the ice metadata source service ice_metadata_source_service = IceMetadataSourceService( "localhost", 4061, "IceStorm/[email protected]", "metadata", "IngestPipeline", metadata_endpoint, metadata_control_endpoint) ice_metadata_source_monitor_adapter = MonitorAdapter( ice_metadata_source_service, "ice_metadata_source_service", metadata_metrics_endpoint) ice_metadata_source_service_container = ServiceContainer( ice_metadata_source_monitor_adapter, messager) # set up the visibility datagram source service visibility_datagram_source_service = VisibilityDatagramSourceService( "localhost", 3000, datagram_endpoint, datagram_control_endpoint) visibility_datagram_source_monitor_adapter = MonitorAdapter( visibility_datagram_source_service, "visibility_datagram_source_service", datagram_metrics_endpoint) visibility_datagram_source_service_container = ServiceContainer( visibility_datagram_source_monitor_adapter, messager) # set up the align service align_service = AlignService(metadata_endpoint, datagram_endpoint, chunk_endpoint, align_control_endpoint) align_monitor_adapter = MonitorAdapter(align_service, "align_service", align_metrics_endpoint) align_service_container = ServiceContainer(align_monitor_adapter, messager) to_string_service = ToStringService(chunk_endpoint, chunk_string_endpoint, to_string_control_endpoint) to_string_monitor_adapter = MonitorAdapter(to_string_service, "to_string_service", to_string_metrics_endpoint) to_string_service_container = ServiceContainer( to_string_monitor_adapter, messager) string_writer_service = StringWriterService( chunk_string_endpoint, string_writer_control_endpoint, "output.txt") string_writer_monitor_adapter = MonitorAdapter( string_writer_service, "string_writer_service", string_writer_metrics_endpoint) string_writer_service_container = ServiceContainer( string_writer_monitor_adapter, messager) monitor_service = GenericMonitorService([ datagram_metrics_endpoint, metadata_metrics_endpoint, align_metrics_endpoint, to_string_metrics_endpoint, string_writer_metrics_endpoint ]) monitor_service_container = ServiceContainer(monitor_service, messager) logging.info("Starting services") monitor_service_container.start() visibility_datagram_source_service_container.start() ice_metadata_source_service_container.start() align_service_container.start() to_string_service_container.start() string_writer_service_container.start() logging.info("Starting processing") messager.publish(datagram_control_endpoint, StringMessage("Start")) messager.publish(metadata_control_endpoint, StringMessage("Start")) messager.publish(align_control_endpoint, StringMessage("Start")) messager.publish(to_string_control_endpoint, StringMessage("Start")) messager.publish(string_writer_control_endpoint, StringMessage("Start")) # start playback logging.info("Starting playback") playback = Playback("testbed_data") playback.playback("data/ade1card.ms") playback.wait() time.sleep(10) messager.publish(datagram_control_endpoint, StringMessage("Stop")) time.sleep(5) messager.publish(metadata_control_endpoint, StringMessage("Stop")) time.sleep(5) messager.publish(align_control_endpoint, StringMessage("Stop")) time.sleep(5) messager.publish(to_string_control_endpoint, StringMessage("Stop")) time.sleep(5) messager.publish(string_writer_control_endpoint, StringMessage("Stop")) ice_metadata_source_service_container.terminate() visibility_datagram_source_service_container.terminate() align_service_container.terminate() to_string_service_container.terminate() string_writer_service_container.terminate() monitor_service_container.terminate() # stop Ice logging.info("stopping Ice") ice_runner.stop()
def test(self): self.registry_port = 9000 registry = ZMQMessagingSystemRegistry(self.registry_port) registry.start() time.sleep(1) logging.info("starting services") letter1_thread = threading.Thread(target=self._run_letter1) letter1_thread.start() letter2_thread = threading.Thread(target=self._run_letter2) letter2_thread.start() concatenator_thread = threading.Thread(target=self._run_concatenator) concatenator_thread.start() writer_thread = threading.Thread(target=self._run_writer) writer_thread.start() monitor_thread = threading.Thread(target=self._run_monitor) monitor_thread.start() time.sleep(5) logging.info("Setting up messaging system") messaging_system = ZMQMessagingSystem("localhost", self.registry_port, 9006) messager = Messager() control_stream = messager.get_stream(messaging_system, "control", StringMessage) configuration_stream = messager.get_stream(messaging_system, "configuration", ConfigurationMessage) logging.info("Registering to publish on 'configuration' topic.") configuration_endpoint = configuration_stream.get_write_endpoint() time.sleep(5) logging.info("Publishing ConfigurationMessage") configuration_message = ConfigurationMessage({ "letter1_generator_service.upper": True, "string_writer_service.output_path": "output.txt" }) messager.publish(configuration_endpoint, configuration_message) time.sleep(5) logging.info("Registering to publish on 'control' topic") control_endpoint = control_stream.get_write_endpoint() time.sleep(5) logging.info("Publishing 'Start' control message") messager.publish(control_endpoint, StringMessage("Start")) time.sleep(20) logging.info("Publishing 'Stop' control message") messager.publish(control_endpoint, StringMessage("Stop")) time.sleep(5) logging.info("Stopping services") self.letter1_stopped = True self.letter2_stopped = True self.concatenator_stopped = True self.writer_stopped = True self.monitor_stopped = True time.sleep(10) registry.stop()
def test(self): messaging_system = QueueMessagingSystem() messager = Messager() configuration_stream = messager.get_stream(messaging_system, "configuration", ConfigurationMessage) control_stream = messager.get_stream(messaging_system, "control", StringMessage) service_runner_factory = ServiceRunnerFactory(messager) letter1_stream = messager.get_stream(messaging_system, "letter1", StringMessage) letter1_metrics_stream = messager.get_stream(messaging_system, "letter1_metrics", Metrics) letter1_generator_service_runner = service_runner_factory.get_service_runner( LetterGeneratorService, { "name": "letter1_generator_service", "endpoint": letter1_stream.get_write_endpoint() }, configuration_stream=configuration_stream, metrics_stream=letter1_metrics_stream) letter2_stream = messager.get_stream(messaging_system, "letter2", StringMessage) letter2_metrics_stream = messager.get_stream(messaging_system, "letter2_metrics", Metrics) letter2_generator_service_runner = service_runner_factory.get_service_runner( LetterGeneratorService, { "name": "letter2_generator_service", "endpoint": letter2_stream.get_write_endpoint() }, configuration_stream=configuration_stream, metrics_stream=letter2_metrics_stream) concatenation_stream = messager.get_stream(messaging_system, "concatenation", StringMessage) concatenator_metrics_stream = messager.get_stream( messaging_system, "concatenator_metrics", Metrics) string_concatenator_service_runner = service_runner_factory.get_service_runner( StringConcatenatorService, { "name": "string_concatenator_service", "first_endpoint": letter1_stream.get_read_endpoint(), "second_endpoint": letter2_stream.get_read_endpoint(), "concatenation_endpoint": concatenation_stream.get_write_endpoint(), "control_endpoint": control_stream.get_read_endpoint() }, configuration_stream=configuration_stream, metrics_stream=concatenator_metrics_stream) writer_metrics_stream = messager.get_stream(messaging_system, "writer_metrics", Metrics) string_writer_service_runner = service_runner_factory.get_service_runner( StringWriterService, { "name": "string_writer_service", "string_endpoint": concatenation_stream.get_read_endpoint(), "control_endpoint": control_stream.get_read_endpoint() }, configuration_stream=configuration_stream, metrics_stream=writer_metrics_stream) monitor_service = GenericMonitorService("generic_monitor_service", [ letter1_metrics_stream.get_read_endpoint(), letter2_metrics_stream.get_read_endpoint(), concatenator_metrics_stream.get_read_endpoint(), writer_metrics_stream.get_read_endpoint() ]) monitor_service_runner = ServiceRunner(monitor_service, messager) # start them, wait ten seconds, stop them logging.info("starting services") monitor_service_runner.start() string_writer_service_runner.start() string_concatenator_service_runner.start() letter1_generator_service_runner.start() letter2_generator_service_runner.start() time.sleep(5) logging.info("Publishing ConfigurationMessage") mainline_configuration_endpoint = configuration_stream.get_write_endpoint( ) configuration_message = ConfigurationMessage({ "letter1_generator_service.upper": True, "string_writer_service.output_path": "output.txt" }) messager.publish(mainline_configuration_endpoint, configuration_message) time.sleep(5) mainline_control_endpoint = control_stream.get_write_endpoint() logging.info("Publishing 'Start' control message") messager.publish(mainline_control_endpoint, StringMessage("Start")) time.sleep(5) logging.info("Publishing 'Stop' control message") messager.publish(mainline_control_endpoint, StringMessage("Stop")) time.sleep(5) logging.info("Stopping services") letter1_generator_service_runner.terminate() letter2_generator_service_runner.terminate() string_concatenator_service_runner.terminate() string_writer_service_runner.terminate() monitor_service_runner.terminate()
def test(self): messaging_system = QueueMessagingSystem() messager = Messager() visibility_endpoint = messager.get_endpoint(messaging_system, "visibility", VisibilityDatagram) visibility_control_endpoint = messager.get_endpoint(messaging_system, "visibilitycontrol", StringMessage) visibility_string_endpoint = messager.get_endpoint(messaging_system, "visibilitystring", StringMessage) tostring_control_endpoint = messager.get_endpoint(messaging_system, "tostringcontrol", StringMessage) string_writer_control_endpoint = messager.get_endpoint(messaging_system, "stringwritercontrol", StringMessage) # set up the visibility datagram source service visibility_datagram_source_service = VisibilityDatagramSourceService("localhost", 3000, visibility_endpoint, visibility_control_endpoint) visibility_datagram_source_service_container = ServiceContainer(visibility_datagram_source_service, messager) tostring_service = ToStringService(visibility_endpoint, visibility_string_endpoint, tostring_control_endpoint) tostring_service_container = ServiceContainer(tostring_service, messager) string_writer_service = StringWriterService(visibility_string_endpoint, string_writer_control_endpoint, "output.txt") string_writer_service_container = ServiceContainer(string_writer_service, messager) # start Ice logging.info("Starting Ice") ice_runner = IceRunner("testbed_data") ice_runner.start() logging.info("Starting services") string_writer_service_container.start() tostring_service_container.start() visibility_datagram_source_service_container.start() logging.info("Starting processing") messager.publish(string_writer_control_endpoint, StringMessage("Start")) messager.publish(tostring_control_endpoint, StringMessage("Start")) messager.publish(visibility_control_endpoint, StringMessage("Start")) # start playback logging.info("Starting playback") playback = Playback("testbed_data") playback.playback("data/ade1card.ms") playback.wait() time.sleep(10) messager.publish(visibility_control_endpoint, StringMessage("Stop")) time.sleep(10) messager.publish(tostring_control_endpoint, StringMessage("Stop")) time.sleep(10) messager.publish(string_writer_control_endpoint, StringMessage("Stop")) time.sleep(10) visibility_datagram_source_service_container.terminate() tostring_service_container.terminate() string_writer_service_container.terminate() # stop Ice logging.info("stopping Ice") ice_runner.stop()
def test(self): messaging_system = QueueMessagingSystem() messager = Messager() metadata_endpoint = messager.get_endpoint(messaging_system, "metadata", TOSMetadata) metadata_control_endpoint = messager.get_endpoint(messaging_system, " metadatacontrol", StringMessage) metadata_string_endpoint = messager.get_endpoint(messaging_system, "metadatastring", StringMessage) tostring_control_endpoint = messager.get_endpoint(messaging_system, "tostringcontrol", StringMessage) string_writer_control_endpoint = messager.get_endpoint(messaging_system, "stringwritercontrol", StringMessage) # start Ice logging.info("Starting Ice") ice_runner = IceRunner("testbed_data") ice_runner.start() # set up the ice metadata source service ice_metadata_source_service = IceMetadataSourceService("localhost", 4061, "IceStorm/[email protected]", "metadata", "IngestPipeline", metadata_endpoint, metadata_control_endpoint) ice_metadata_source_service_container = ServiceContainer(ice_metadata_source_service, messager) tostring_service = ToStringService(metadata_endpoint, metadata_string_endpoint, tostring_control_endpoint) tostring_service_container = ServiceContainer(tostring_service, messager) string_writer_service = StringWriterService(metadata_string_endpoint, string_writer_control_endpoint, "output.txt") string_writer_service_container = ServiceContainer(string_writer_service, messager) logging.info("Starting services") string_writer_service_container.start() tostring_service_container.start() ice_metadata_source_service_container.start() logging.info("Starting processing") messager.publish(string_writer_control_endpoint, StringMessage("Start")) messager.publish(tostring_control_endpoint, StringMessage("Start")) messager.publish(metadata_control_endpoint, StringMessage("Start")) # start playback logging.info("Starting playback") playback = Playback("testbed_data") playback.playback("data/ade1card.ms") playback.wait() time.sleep(10) messager.publish(metadata_control_endpoint, StringMessage("Stop")) time.sleep(10) messager.publish(tostring_control_endpoint, StringMessage("Stop")) time.sleep(10) messager.publish(string_writer_control_endpoint, StringMessage("Stop")) time.sleep(10) ice_metadata_source_service_container.terminate() tostring_service_container.terminate() string_writer_service_container.terminate() # stop Ice logging.info("stopping Ice") ice_runner.stop()
def test(self): messager = Messager() for messaging_system in [ QueueMessagingSystem(), AsciiFileMessagingSystem(), BlockingQueueMessagingSystem(100) ]: logging.info("Testing class {}...".format( messaging_system.__class__.__name__)) stream_a = messager.get_stream(messaging_system, "topic a", StringMessage) stream_b = messager.get_stream(messaging_system, "topic b", StringMessage) out_message_a1 = StringMessage("a1") out_message_b1 = StringMessage("b1") out_message_a2 = StringMessage("a2") out_message_b2 = StringMessage("b2") out_endpoint_a = stream_a.get_endpoint() out_endpoint_b = stream_b.get_endpoint() in_endpoint_a = stream_a.get_endpoint() in_endpoint_b = stream_b.get_endpoint() messager.publish(out_endpoint_a, out_message_a1) messager.publish(out_endpoint_b, out_message_b1) messager.publish(out_endpoint_a, out_message_a2) messager.publish(out_endpoint_b, out_message_b2) in_message_a1 = None while in_message_a1 is None: time.sleep(1) in_message_a1 = messager.poll(in_endpoint_a) assert in_message_a1.get_payload() == out_message_a1.get_payload() in_message_b1 = None while in_message_b1 is None: time.sleep(1) in_message_b1 = messager.poll(in_endpoint_b) assert in_message_b1.get_payload() == out_message_b1.get_payload() in_message_a2 = None while in_message_a2 is None: time.sleep(1) in_message_a2 = messager.poll(in_endpoint_a) assert in_message_a2.get_payload() == out_message_a2.get_payload() in_message_b2 = None while in_message_b2 is None: time.sleep(1) in_message_b2 = messager.poll(in_endpoint_b) assert in_message_b2.get_payload() == out_message_b2.get_payload()
def test(self): messaging_system = QueueMessagingSystem() messager = Messager() datagram_endpoint = messager.get_endpoint(messaging_system, "datagram", VisibilityDatagram) string_endpoint = messager.get_endpoint(messaging_system, "string", StringMessage) control_endpoint = messager.get_endpoint(messaging_system, "control", StringMessage) parameters = { "name": "to_string_service", "input_endpoint": datagram_endpoint, "output_endpoint": string_endpoint, "control_endpoint": control_endpoint } configuration_endpoint = messager.get_endpoint(messaging_system, "configuration", ConfigurationMessage) configuration_adapter = ConfigurationAdapter(ToStringService, parameters, configuration_endpoint) service_runner = ServiceRunner(configuration_adapter, messager) service_runner.start() time.sleep(5) logging.info("Publishing ConfigurationMessage") configuration_message = ConfigurationMessage({}) messager.publish(configuration_endpoint, configuration_message) time.sleep(5) logging.info("Publishing 'Start' control message") messager.publish(control_endpoint, StringMessage("Start")) time.sleep(5) logging.info("Publishing 'Stop' control message") messager.publish(control_endpoint, StringMessage("Stop")) time.sleep(5) service_runner.terminate() service_runner.wait()