def __init__(self, receiver, spawnArgs=None): # Service class initializer. Basic config, but no yields allowed. BaseService.__init__(self, receiver, spawnArgs) self.spawn_args['backend_class'] = self.spawn_args.get('backend_class', CONF.getValue('backend_class', default='ion.data.store.Store')) self.spawn_args['backend_args'] = self.spawn_args.get('backend_args', CONF.getValue('backend_args', default={})) logging.info('AttributeStoreService.__init__()')
def __init__(self, receiver, spawnArgs=None): """ @brief Init method for the DataStore Frontend service @param frontend - an instance of a CAStore Frontend """ # Service class initializer. Basic config, but no yields allowed. self.frontend = spawnArgs['MyFrontend'] BaseService.__init__(self, receiver, spawnArgs) logging.info('DataStoreService.__init__()')
def __init__(self, receiver, spawnArgs=None): # Service class initializer. Basic config, but no yields allowed. BaseService.__init__(self, receiver, spawnArgs) self.spawn_args['backend_class'] = self.spawn_args.get( 'backend_class', CONF.getValue('backend_class', default='ion.data.store.Store')) self.spawn_args['backend_args'] = self.spawn_args.get( 'backend_args', CONF.getValue('backend_args', default={})) logging.info('AttributeStoreService.__init__()')
class ExchangeRegistryService(BaseService): """Exchange registry service interface """ # Declaration of service declare = BaseService.service_declare(name='exchange_registry', version='0.1.0', dependencies=[]) def op_define_exchange_space(self, content, headers, msg): """Service operation: . """ def op_join_exchange_space(self, content, headers, msg): """Service operation: """ def op_leave_exchange_space(self, content, headers, msg): """Service operation: """ def op_define_exchange_name(self, content, headers, msg): """Service operation: Create or update a name in an exchange space """ def op_add_broker(self, content, headers, msg): """Service operation: Add a message broker to the federation """ def op_remove_broker(self, content, headers, msg): """Service operation: Remove a message broker from the federatione
class ProxyService(BaseService): """ Proxy service. Stub, really, since the proxy listens on a plain tcp port. """ # Declaration of service declare = BaseService.service_declare(name='proxy', version='0.1.0', dependencies=['controller']) @defer.inlineCallbacks def slc_init(self): """ Use this hook to bind to listener TCP port. """ logging.info('starting proxy on port %d' % PROXY_PORT) self.proxy_port = yield reactor.listenTCP(PROXY_PORT, DAPProxyFactory()) logging.info('Proxy listener running.') @defer.inlineCallbacks def slc_shutdown(self): """ Close TCP listener """ logging.info('Shutting down proxy') yield self.proxy_port.stopListening()
class AuthorizationService(BaseService): """Authorization service interface """ # Declaration of service declare = BaseService.service_declare(name='authorization', version='0.1.0', dependencies=[]) def op_authorize(self, content, headers, msg): """Service operation: """ """ Begin experimental methods RU create backend module.py files if needed. keep the "business logic" separate from the message interface """ def op_authenticate_user(self, content, headers, msg): """ RU Service operation: . """ def op_authenticate_service_provider(self, content, headers, msg): """ RU Service operation: . """ def op_add_service_provider(self, content, headers, msg): """ RU Service operation: . """ def op_update_service_provider(self, content, headers, msg): """ RU Service operation: . """ def op_revoke_service_provider(self, content, headers, msg): """ RU Service operation: .
class DataProductRegistryService(registry.BaseRegistryService): """ Service that provides a registry for data products etc. Data products are for instance created as a pipeline of refining raw data through automatic and manual QAQC processes. Based on the BaseRegistryService. """ # Declaration of service declare = BaseService.service_declare(name='data_product_registry', version='0.1.0', dependencies=[]) op_clear_data_product_registry = registry.BaseRegistryService.base_clear_registry """ Service operation: Clears all records from the data product registry. """ op_register_data_product = registry.BaseRegistryService.base_register_resource """ Service operation: Register a data product with the registry. """ op_get_data_product = registry.BaseRegistryService.base_get_resource """ Service operation: Get a data product. """ op_find_data_product = registry.BaseRegistryService.base_find_resource """
class DataProcessingService(BaseService): """Data processing service interface """ # Declaration of service declare = BaseService.service_declare(name='data_processing', version='0.1.0', dependencies=[]) def op_define_process(self, content, headers, msg): """ Service operation: Create or update a data process. A data process works on data messages and is assumed to have parameterizable input and output """ self.reply_err(msg, "Not yet implemented") def op_schedule_processing(self, content, headers, msg): """ Service operation: Defines processing based on schedule or event trigger, given a data process and required input and output streams. """ self.reply_err(msg, "Not yet implemented") def op_cancel_processing(self, content, headers, msg): """ Service operation: Remove scheduled processing. """ self.reply_err(msg, "Not yet implemented")
class RetrieverService(FetcherService): """ Preservation service retriever - subclass of ion.services.sa.fetcher OOI front end for a local DAP server. Uses DAP to talk to locally-running instance of the DAP server, which is responsible for netcdf->dap transformation. Any dap server should work that can present netcdf files; we often use pydap for testing. Because we rely on the DAP server to do that transformation, this can be a thin layer of code. @see ion.services.dm.url_manipulation for the rewrite_url routine and its unit tests. """ declare = BaseService.service_declare(name='retriever', version='0.0.2', dependencies=[]) def op_get_url(self, content, headers, msg): """ Rewrite the URL, forward the request to the DAP server """ src_url = content new_url = rewrite_url(src_url) logging.debug('Old url: %s New url: %s' % (src_url, new_url)) # Note that _http_op is inherited fetcher code... return self._http_op('GET', new_url, msg)
class DataAcquisitionService(BaseService): """ Data acquisition service interface. Data acquisition is the service coordinating the acquisition of samples packets and external block data for preparation into the ingestion service. """ # Declaration of service declare = BaseService.service_declare(name='data_acquisition', version='0.1.0', dependencies=[]) def slc_init(self): self.irc = InstrumentRegistryClient() self.dprc = DataProductRegistryClient() @defer.inlineCallbacks def op_acquire_block(self, content, headers, msg): """ Service operation: Acquire an entire, fully described version of a data set. """ logging.info('op_acquire_block: ' + str(content)) yield self.reply_ok( msg, {'value': 'op_acquire_block_respond,' + str(content)}, {}) @defer.inlineCallbacks def op_acquire_message(self, content, headers, msg): """ Service operation: Acquire an increment of a data set. """ logging.info('op_acquire_message: ' + str(content)) yield self.reply_ok( msg, {'value': 'op_acquire_message_respond, ' + str(content)}, {})
class DataPubsubRegistryService(registry.BaseRegistryService): """ @Brief A very simple registry for Data Pub Sub @TODO make the interface more specific for different kinds of pubsub objects Need to specify topic, publisher, subscriber """ # Declaration of service declare = BaseService.service_declare(name='datapubsub_registry', version='0.1.0', dependencies=[]) op_clear_registry = registry.BaseRegistryService.base_clear_registry """ Service operation: clear registry """ op_register = registry.BaseRegistryService.base_register_resource """ Service operation: Create or update a pubsub. """ op_get = registry.BaseRegistryService.base_get_resource """ Service operation: Get pubsub """ op_find = registry.BaseRegistryService.base_find_resource """
class ResourceRegistryService(registry.BaseRegistryService): """ Resource registry service interface The Resource Registry Service uses an IStore interface to a backend Key Value Store to store to track version controlled objects. The store will share a name space and share objects depending on configuration when it is created. The resource are retrieved as complete objects from the store. The built-in encode method is used to store and transmit them using the COI messaging. """ # Declaration of service declare = BaseService.service_declare(name='resource_registry', version='0.1.0', dependencies=[]) op_clear_registry = registry.BaseRegistryService.base_clear_registry op_register_resource_instance = registry.BaseRegistryService.base_register_resource """ Service operation: Register a resource instance with the registry. """ op_get_resource_instance = registry.BaseRegistryService.base_get_resource """ Service operation: Get a resource instance. """ op_register_resource_definition = registry.BaseRegistryService.base_register_resource """ Service operation: Create or update a resource definition with the registry. """ op_get_resource_definition = registry.BaseRegistryService.base_get_resource """ Service operation: Get a resource definition. """ op_set_resource_lcstate = registry.BaseRegistryService.base_set_resource_lcstate """ Service operation: Set a resource life cycle state """ op_find_registered_resource_definition_from_resource = registry.BaseRegistryService.base_find_resource """ Service operation: Find the registered definition of a resource """ op_find_registered_resource_definitions_from_description = registry.BaseRegistryService.base_find_resource """ Service operation: find all registered resources which match the attributes of description """ op_find_registered_resource_instance_from_instance = registry.BaseRegistryService.base_find_resource """ Service operation: Find the registered instances that matches the service class """ op_find_registered_resource_instance_from_description = registry.BaseRegistryService.base_find_resource """
class PresentationService(BaseService): """Presentation service interface """ # Declaration of service declare = BaseService.service_declare(name='presentation_service', version='0.1.0', dependencies=[]) def op_present_catalog(self, content, headers, msg): """Service operation: TBD
class ProvisionerService(BaseService): """Provisioner service interface """ # Declaration of service declare = BaseService.service_declare(name='provisioner', version='0.1.0', dependencies=[]) def op_provision(self, content, headers, msg): """Service operation: Provision a taskable resource """ def op_terminate(self, content, headers, msg): """Service operation: Terminate a taskable resource
class RegistryService(BaseRegistryService): """ @Brief Example Registry Service implementation using the base class """ # Declaration of service declare = BaseService.service_declare(name='registry_service', version='0.1.0', dependencies=[]) op_clear_registry = BaseRegistryService.base_clear_registry op_register_resource = BaseRegistryService.base_register_resource op_get_resource = BaseRegistryService.base_get_resource op_get_resource_by_id = BaseRegistryService.base_get_resource_by_id op_set_resource_lcstate = BaseRegistryService.base_set_resource_lcstate op_find_resource = BaseRegistryService.base_find_resource
class IdentityRegistryService(BaseRegistryService): # Declaration of service declare = BaseService.service_declare(name='identity_service', version='0.1.0', dependencies=[]) op_clear_identity_registry = BaseRegistryService.base_clear_registry op_register_user = BaseRegistryService.base_register_resource op_update_user = BaseRegistryService.base_register_resource op_get_user = BaseRegistryService.base_get_resource op_set_identity_lcstate = BaseRegistryService.base_set_resource_lcstate op_find_users = BaseRegistryService.base_find_resource
class ServiceRegistryService(registry.BaseRegistryService): """ Service registry service interface @todo a service is a resource and should also be living in the resource registry """ # Declaration of service declare = BaseService.service_declare(name='service_registry', version='0.1.0', dependencies=[]) op_clear_registry = registry.BaseRegistryService.base_clear_registry op_register_service_definition = registry.BaseRegistryService.base_register_resource """ Service operation: Register a service definition with the registry. """ op_get_service_definition = registry.BaseRegistryService.base_get_resource """ Service operation: Get a service definition. """ op_register_service_instance = registry.BaseRegistryService.base_register_resource """ Service operation: Register a service instance with the registry. """ op_get_service_instance = registry.BaseRegistryService.base_get_resource """ Service operation: Get a service instance. """ op_set_service_lcstate = registry.BaseRegistryService.base_set_resource_lcstate """ Service operation: Set a service life cycle state """ op_find_registered_service_definition_from_service = registry.BaseRegistryService.base_find_resource """ Service operation: Find the definition of a service """ op_find_registered_service_definition_from_description = registry.BaseRegistryService.base_find_resource """ Service operation: Find service definitions which meet a description """ op_find_registered_service_instance_from_service = registry.BaseRegistryService.base_find_resource """ Service operation: Find the registered instance that matches the service instance """ op_find_registered_service_instance_from_description = registry.BaseRegistryService.base_find_resource """
class DataStoreService(BaseService): """ Example service interface """ # Declaration of service declare = BaseService.service_declare(name='DataStoreService', version='0.1.0', dependencies=[]) def __init__(self, receiver, spawnArgs=None): """ @brief Init method for the DataStore Frontend service @param frontend - an instance of a CAStore Frontend """ # Service class initializer. Basic config, but no yields allowed. self.frontend = spawnArgs['MyFrontend'] BaseService.__init__(self, receiver, spawnArgs) logging.info('DataStoreService.__init__()') # @defer.inlineCallbacks def slc_init(self): pass @defer.inlineCallbacks def op_push(self, content, headers, msg): logging.info('op_push: ' + str(content) + ', Remote Frontend:' + self.frontend) # The following line shows how to reply to a message yield self.reply_ok(msg) @defer.inlineCallbacks def op_pull(self, content, headers, msg): logging.info('op_pull: ' + str(content) + ', Remote Frontend:' + self.frontend) # The following line shows how to reply to a message yield self.reply_ok(msg) @defer.inlineCallbacks def op_clone(self, content, headers, msg): logging.info('op_clone: ' + str(content) + ', Remote Frontend:' + self.frontend) # The following line shows how to reply to a message yield self.reply_ok(msg)
class InstrumentRegistryService(registry.BaseRegistryService): """ Service that provides a registry for instrument devices, types etc. Based on the BaseRegistryService. """ # Declaration of service declare = BaseService.service_declare(name='instrument_registry', version='0.1.0', dependencies=[]) op_clear_instrument_registry = registry.BaseRegistryService.base_clear_registry """ Service operation: Clears all records from the instrument registry. """ op_register_instrument_instance = registry.BaseRegistryService.base_register_resource """ Service operation: Create or update an instrument instance with the registry. """ op_register_instrument_type = registry.BaseRegistryService.base_register_resource """ Service operation: Create or update an instrument type with the registry. """ op_get_instrument_instance = registry.BaseRegistryService.base_get_resource """ Service operation: Get a instrument instance. """ op_get_instrument_by_id = registry.BaseRegistryService.base_get_resource_by_id op_get_instrument_type = registry.BaseRegistryService.base_get_resource #changed """ Service operation: Get a instrument type. """ op_find_instrument_instance = registry.BaseRegistryService.base_find_resource """ Service operation: find instrument instances by characteristics """ op_find_instrument_type = registry.BaseRegistryService.base_find_resource """
class PreservationRegistryService(registry.BaseRegistryService): """ @Brief Preservation registry service interface """ # Declaration of service declare = BaseService.service_declare(name='preservation_registry', version='0.1.0', dependencies=[]) op_define_archive = registry.BaseRegistryService.base_register_resource """ Service operation: Create or update a archive resource. """ op_get_archive = registry.BaseRegistryService.base_get_resource """ Service operation: Get an archive resource """ op_find_archive = registry.BaseRegistryService.base_find_resource """
class IngestionRegistryService(registry.BaseRegistryService): """ @Brief Ingestion registry service interface """ # Declaration of service declare = BaseService.service_declare(name='ingestion_registry', version='0.1.0', dependencies=[]) op_define_ingestion_stream = registry.BaseRegistryService.base_register_resource """ Service operation: Create or update a ingestion_stream resource. """ op_get_ingestion_stream = registry.BaseRegistryService.base_get_resource """ Service operation: Get an ingestion_stream resource """ op_find_ingestion_stream = registry.BaseRegistryService.base_find_resource """
class ComputationPlannerService(BaseService): """Provisioner service interface """ # Declaration of service declare = BaseService.service_declare(name='computation_planner', version='0.1.0', dependencies=[]) def op_request_computation(self, content, headers, msg): """Service operation: Request computation resources """ def op_schedule_computation(self, content, headers, msg): """Service operation: Request computation with given schedule """ def op_set_policy(self, content, headers, msg): """Service operation: Sets the policy that influences the planning of
class CoordinatorService(BaseService): """ Refactor this into a BaseService that provides dap data on a looping call Make the url a parameter of the process - one per url... Brains behind preservation, and also the primary interface. """ # Define ourselves for the CC declare = BaseService.service_declare(name='coordinator', version='0.1.0', dependencies=['fetcher']) def slc_init(self): """ Service life cycle state. Initialize service here. Can use yields. @todo Create instances of clients here for later - fetcher, attr store, etc """ logging.debug('Preservation coordinator SLC init') self.fc = FetcherClient(proc=self) @defer.inlineCallbacks def op_get_url(self, content, headers, msg): """ @brief Method for proxy - request a (DAP) URL @param content URL to fetch @param headers conv-id and reply-to should point to proxy/requester @param msg Not used @todo Cache logic - right now just trapdoors all reqs to fetcher """ logging.debug('Coordinator forwarding URL request to fetcher') yield self.fc.forward_get_url(content, headers) @defer.inlineCallbacks def op_get_dap_dataset(self, content, headers, msg): """ @brief Similar to op_get_url. Fetches an entire DAP dataset. @param content URL to fetch @param headers conv-id and reply-to should point to proxy/requester @param msg Not used @todo Cache logic - right now just trapdoors all reqs to fetcher """ yield self.fc.forward_get_dap_dataset(content, headers)
class DataRegistryService(registry.BaseRegistryService): """ @Brief Dataset registry service interface """ # Declaration of service declare = BaseService.service_declare(name='data_registry', version='0.1.0', dependencies=[]) op_define_data = registry.BaseRegistryService.base_register_resource """ Service operation: Create or update a data resource. """ op_get_data = registry.BaseRegistryService.base_get_resource """ Service operation: Get data description """ op_find_data = registry.BaseRegistryService.base_find_resource """
class HostStatusService(BaseService): """ Host status interface """ # Declaration of service declare = BaseService.service_declare(name='host_status', version='0.1.0', dependencies=[]) def slc_init(self): self.INTERVAL = 1 # seconds self.COUNT = 1 self.count = self.COUNT self.client = xmlrpc.Proxy('http://localhost:9010') self.lc = task.LoopingCall(self.report) self.lc.start(self.INTERVAL) @defer.inlineCallbacks def report(self): self.count -= 1 if self.count < 0: logging.debug('Shutting down host status looping call') self.lc.stop() return logging.debug('Starting report query') status = yield self.client.callRemote("getStatusString", "all") logging.debug('Received report') print status def isRunning(self): return self.lc.running def op_config(self, content, headers, msg): pass @defer.inlineCallbacks def op_sendstatus(self, content, headers, msg): yield self.reply_ok(msg)
class StateRepositoryService(BaseService): """Repository for service state service interface. Service state is information shared between many processes. """ # Declaration of service declare = BaseService.service_declare(name='state_repository', version='0.1.0', dependencies=[]) def op_define_state(self, content, headers, msg): """Service operation: Create a new state object (session) or update an existing one by replacing """ def op_update_state(self, content, headers, msg): """Service operation: Provide an incremental update to the service state. """ def op_retrieve_state(self, content, headers, msg): """Service operation: TBD
class AttributeStoreService(store_service.StoreService): """ Service to store and retrieve key/value pairs. The Implementation is in ion.data.backends.store_service """ # Declaration of service declare = BaseService.service_declare(name='attributestore', version='0.1.0', dependencies=[]) def __init__(self, receiver, spawnArgs=None): # Service class initializer. Basic config, but no yields allowed. BaseService.__init__(self, receiver, spawnArgs) self.spawn_args['backend_class'] = self.spawn_args.get( 'backend_class', CONF.getValue('backend_class', default='ion.data.store.Store')) self.spawn_args['backend_args'] = self.spawn_args.get( 'backend_args', CONF.getValue('backend_args', default={})) logging.info('AttributeStoreService.__init__()')
class ResponseService(BaseService): """Example service implementation """ # Declaration of service declare = BaseService.service_declare(name='responder', version='0.1.0', dependencies=[]) def slc_init(self): pass @defer.inlineCallbacks def op_respond(self, content, headers, msg): logging.info('op_respond: ' + str(content)) obj = dataobject.DataObject.decode(content) logging.info(obj) response = obj.encode() # The following line shows how to reply to a message yield self.reply_ok(msg, response)
class LoggerService(BaseService): """Logger service interface """ # Declaration of service declare = BaseService.service_declare( name='logger', version='0.1.0', dependencies=[] ) def slc_init(self): logging.info("LoggingService initialized") def op_config(self, content, headers, msg): pass @defer.inlineCallbacks def op_logmsg(self, content, headers, msg): level = content.get('level','info') logmsg = content.get('msg','#NO MESSAGE#') # need to do something reasonable with these soon # lfrom = headers.get('sender','') # ltime = content.get('logtime') if level == 'debug': logserv.debug(logmsg) elif level == 'info': logserv.info(logmsg) elif level == 'warn': logserv.warn(logmsg) elif level == 'error': logserv.error(logmsg) elif level == 'critical': logserv.critical(logmsg) else: logging.error('Invalid log level: '+str(level)) yield self.reply_ok(msg)
class WorkerProcess(BaseService): """Worker process """ # Declaration of service declare = BaseService.service_declare(name='worker', version='0.1.0', dependencies=[]) @defer.inlineCallbacks def slc_init(self): msg_name = self.spawn_args['service-name'] scope = self.spawn_args['scope'] logging.info("slc_init name received:" + msg_name) msg_name1 = self.get_scoped_name(scope, msg_name) logging.info("slc_init name used:" + msg_name1) workReceiver = Receiver(__name__, msg_name1) self.workReceiver = workReceiver self.workReceiver.handle(self.receive) logging.info("slc_init worker receiver spawning") id = yield spawn(workReceiver) logging.info("slc_init worker receiver spawned:" + str(id)) @defer.inlineCallbacks def op_work(self, content, headers, msg): yield self._work(content) yield self.reply(msg, 'result', {'work-id': content['work-id']}, {}) @defer.inlineCallbacks def _work(self, content): myid = self.proc_name + ":" + self.receiver.spawned.id.local workid = str(content['work-id']) waittime = float(content['work']) logging.info("worker=" + myid + " job=" + workid + " work=" + str(waittime)) yield pu.asleep(waittime) logging.info("worker=" + myid + " job=" + workid + " done at=" + str(pu.currenttime_ms()))
class TaskableResourceRegistryService(BaseService): """Taskable resource registry and definition repository service interface """ # Declaration of service declare = BaseService.service_declare(name='taskable_resource_registry', version='0.1.0', dependencies=[]) def op_define_resource(self, content, headers, msg): """Service operation: Create or update taskable resource description """ def op_find_resource(self, content, headers, msg): """Service operation: Create or update taskable resource description """ def op_store_resource(self, content, headers, msg): """Service operation: Store the definition of a taskable resource, e.g. source code, virtual machine image (or a pointer to it) """ def op_retrieve_resource(self, content, headers, msg): """Service operation: Retrieve the definition of a taskable resource
def __init__(self, receiver, spawnArgs=None): BaseService.__init__(self, receiver, spawnArgs) logging.info('Fetcher starting')
def __init__(self, receiver, spawnArgs=None): # Service class initializer. Basic config, but no yields allowed. BaseService.__init__(self, receiver, spawnArgs) logging.info("HelloService.__init__()")