def main(): """ Starts the momqueryservice.GetObjectDetails service """ logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', level=logging.INFO) # Check the invocation arguments parser = OptionParser("%prog [options]", description='runs the momqueryservice') parser.add_option('-b', '--broker', dest='broker', type='string', default=DEFAULT_BROKER, help='Address of the messaging broker, default: %default') parser.add_option("-e", "--exchange", dest="exchange", type="string", default=DEFAULT_BUSNAME, help="Name of the bus exchange on the broker, [default: %default]") parser.add_option_group(dbcredentials.options_group(parser)) parser.set_defaults(dbcredentials="MoM") (options, args) = parser.parse_args() dbcreds = dbcredentials.parse_options(options) logger.info("Using dbcreds: %s", dbcreds.stringWithHiddenPassword()) with RPCService(service_name=DEFAULT_MOMQUERY_SERVICENAME, handler_type=MoMQueryServiceMessageHandler, handler_kwargs={'dbcreds': dbcreds}, broker=options.broker, exchange=options.exchange, num_threads=6): waitForInterrupt()
def createService(exchange=DEFAULT_BUSNAME, broker=DEFAULT_BROKER, dbcreds=None): return RPCService(DEFAULT_RADB_SERVICENAME, RADBServiceMessageHandler, handler_kwargs={'dbcreds': dbcreds}, exchange=exchange, broker=broker, num_threads=4)
def createService(exchange=DEFAULT_BUSNAME, broker=DEFAULT_BROKER, cache_manager=None): return RPCService(service_name=DEFAULT_STORAGEQUERY_SERVICENAME, handler_type=StorageQueryHandler, handler_kwargs={'cache_manager': cache_manager}, exchange=exchange, broker=broker, num_threads=12)
def createService(exchange=DEFAULT_BUSNAME, broker=DEFAULT_BROKER, mountpoint=CEP4_DATA_MOUNTPOINT): return RPCService(DEFAULT_CLEANUP_SERVICENAME, handler_type=CleanupHandler, handler_kwargs={'mountpoint': mountpoint}, exchange=exchange, broker=broker, num_threads=4)
def setUp(self): # Create a random bus self.tmp_queue = TemporaryQueue(__class__.__name__) self.tmp_queue.open() self.addCleanup(self.tmp_queue.close) self.notification_bus = self.tmp_queue.create_tobus() self.notification_bus.open() self.addCleanup(self.notification_bus.close) # ================================ # Global state to manipulate # ================================ global otdb_predecessors otdb_predecessors = { 1: [2, 3, 4], 2: [3], 3: [], 4: [], } global otdb_status otdb_status = { 1: "scheduled", # cannot start, since predecessor 2 hasn't finished 2: "scheduled", # can start, since predecessor 3 has finished 3: "finished", 4: "scheduled", # can start, because no predecessors } # Setup mock otdb service service = RPCService( service_name=DEFAULT_OTDB_SERVICENAME, handler_type=MockOTDBService, handler_kwargs={"notification_bus": self.notification_bus}) service.start_listening() self.addCleanup(service.stop_listening) # ================================ # Setup mock ra service # # Note that RA IDs are the same as # OTDB IDs + 1000 in this test. # ================================ service = RPCService(service_name=DEFAULT_RAS_SERVICENAME, handler_type=MockRAService, handler_kwargs={ "predecessors": otdb_predecessors, "status": otdb_status }) service.start_listening() self.addCleanup(service.stop_listening)
def main(): with RPCService(service_name=TRIGGER_SERVICENAME, handler_type=TriggerServiceMessageHandler, exchange=DEFAULT_BUSNAME, num_threads=4): # next to RT events, also (independently) handle vo events with ALERTHandler( broker_host=ALERT_BROKER_HOST, broker_port=ALERT_BROKER_PORT, filter_for=ALERT_PACKET_TYPE_FILTER) as alert_handler: waitForInterrupt()
def main(): # make sure we run in UTC timezone import os os.environ['TZ'] = 'UTC' # Check the invocation arguments parser = OptionParser("%prog [options]", description='runs the observationcontrol service') parser.add_option('-b', '--broker', dest='broker', type='string', default=DEFAULT_BROKER, help='Address of the qpid broker, default: %default') parser.add_option( "-e", "--exchange", dest="exchange", type="string", default=DEFAULT_BUSNAME, help="Name of the exchange on the qpid broker, default: %default") parser.add_option('-V', '--verbose', dest='verbose', action='store_true', help='verbose logging') (options, args) = parser.parse_args() logging.basicConfig( format='%(asctime)s %(levelname)s %(message)s', level=logging.DEBUG if options.verbose else logging.INFO) with RPCService( service_name=config.DEFAULT_OBSERVATION_CONTROL_SERVICE_NAME, handler_type=ObservationControlHandler, broker=options.broker, exchange=options.exchange): waitForInterrupt()
def create_service(busname=DEFAULT_BUSNAME, broker=DEFAULT_BROKER): return RPCService(SPECIFICATION_SERVICENAME, SpecificationHandler, exchange=busname, broker=broker)
def createService(exchange=DEFAULT_BUSNAME, broker=DEFAULT_BROKER): return RPCService(service_name=DEFAULT_SERVICENAME, handler_type=TaskManagementHandler, exchange=exchange, broker=broker, num_threads=1)
def create_service(busname=DEFAULT_BUSNAME, broker=DEFAULT_BROKER): return RPCService(VALIDATION_SERVICENAME, ValidationHandler, exchange=busname, broker=broker)
def setUp(self): self.temp_exchange = TemporaryExchange(__class__.__name__) self.temp_exchange.open() self.addCleanup(self.temp_exchange.close) self.notification_bus = self.temp_exchange.create_tobus() self.notification_bus.open() self.addCleanup(self.notification_bus.close) # Patch SLURM class MockSlurm(object): def __init__(self): self.scheduled_jobs = {} def submit(self, job_name, *args, **kwargs): logger.info("Schedule SLURM job '%s': %s, %s", job_name, args, kwargs) self.scheduled_jobs[job_name] = (args, kwargs) # Return fake job ID return "42" def isQueuedOrRunning(self, otdb_id): return str(otdb_id) in self.scheduled_jobs self.mock_slurm = MockSlurm() patcher = patch('lofar.mac.PipelineControl.Slurm') patcher.start().return_value = self.mock_slurm self.addCleanup(patcher.stop) # Catch functions to prevent running executables patcher = patch('lofar.mac.PipelineControl.Parset.dockerImage') patcher.start().return_value = "lofar-pipeline:trunk" self.addCleanup(patcher.stop) # ================================ # Global state to manipulate # ================================ global otdb_predecessors otdb_predecessors = { 1: [2, 3, 4], 2: [3], 3: [], 4: [], } global otdb_status otdb_status = { 1: "prescheduled", 2: "prescheduled", 3: "prescheduled", 4: "prescheduled", } service = RPCService( service_name=DEFAULT_OTDB_SERVICENAME, exchange=self.temp_exchange.address, handler_type=MockOTDBService, handler_kwargs={"notification_bus": self.notification_bus}) service.start_listening() self.addCleanup(service.stop_listening) # ================================ # Setup mock ra service # ================================ service = RPCService(service_name=DEFAULT_RAS_SERVICENAME, exchange=self.temp_exchange.address, handler_type=MockRAService, handler_kwargs={ "predecessors": otdb_predecessors, "status": otdb_status }) service.start_listening() self.addCleanup(service.stop_listening)
def createService(exchange=DEFAULT_BUSNAME, broker=DEFAULT_BROKER): return RPCService(service_name=DEFAULT_RESOURCEESTIMATOR_SERVICENAME, handler_type=ResourceEstimatorHandler, exchange=exchange, broker=broker, num_threads=1)