本文整理汇总了Python中interface.services.coi.iresource_registry_service.ResourceRegistryServiceProcessClient类的典型用法代码示例。如果您正苦于以下问题:Python ResourceRegistryServiceProcessClient类的具体用法?Python ResourceRegistryServiceProcessClient怎么用?Python ResourceRegistryServiceProcessClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ResourceRegistryServiceProcessClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_start
def on_start(self):
self.query = self.CFG.get_safe('process.query',{})
self.delivery_format = self.CFG.get_safe('process.delivery_format',{})
self.datastore_name = self.CFG.get_safe('process.datastore_name','dm_datastore')
definition_id = self.delivery_format.get('definition_id')
rrsc = ResourceRegistryServiceProcessClient(process=self, node=self.container.node)
definition = rrsc.read(definition_id)
self.definition = definition.container
self.fields = self.delivery_format.get('fields',None)
self.view_name = self.CFG.get_safe('process.view_name','datasets/dataset_by_id')
self.key_id = self.CFG.get_safe('process.key_id')
self.stream_id = self.CFG.get_safe('process.publish_streams.output')
if not self.stream_id:
raise Inconsistent('The replay process requires a stream id. Invalid configuration!')
self.data_stream_id = self.definition.data_stream_id
self.encoding_id = self.definition.identifiables[self.data_stream_id].encoding_id
self.element_type_id = self.definition.identifiables[self.data_stream_id].element_type_id
self.element_count_id = self.definition.identifiables[self.data_stream_id].element_count_id
self.data_record_id = self.definition.identifiables[self.element_type_id].data_record_id
self.field_ids = self.definition.identifiables[self.data_record_id].field_ids
self.domain_ids = self.definition.identifiables[self.data_record_id].domain_ids
self.time_id = self.definition.identifiables[self.domain_ids[0]].temporal_coordinate_vector_id
示例2: delete_indexes
def delete_indexes(self):
ims_cli = IndexManagementServiceProcessClient(process=self)
rr_cli = ResourceRegistryServiceProcessClient(process=self)
#--------------------------------------------------------------------------------
# Standard Indexes
#--------------------------------------------------------------------------------
for index,resources in STD_INDEXES.iteritems():
index_ids, _ = rr_cli.find_resources(name=index,restype=RT.ElasticSearchIndex, id_only=True)
for index_id in index_ids:
ims_cli.delete_index(index_id)
#--------------------------------------------------------------------------------
# CouchDB Indexes
#--------------------------------------------------------------------------------
for index,datastore in COUCHDB_INDEXES.iteritems():
index_ids, _ = rr_cli.find_resources(name=index, restype=RT.CouchDBIndex, id_only=True)
for index_id in index_ids:
ims_cli.delete_index(index_id)
#--------------------------------------------------------------------------------
# Edge Indexes
#--------------------------------------------------------------------------------
index_ids, _ = rr_cli.find_resources(name='%s_resources_index' % self.sysname,restype=RT.ElasticSearchIndex, id_only=True)
for index_id in index_ids:
ims_cli.delete_index(index_id)
index_ids, _ = rr_cli.find_resources(name='%s_events_index' % self.sysname, restype=RT.ElasticSearchIndex, id_only=True)
for index_id in index_ids:
ims_cli.delete_index(index_id)
示例3: on_start
def on_start(self):
rr_cli = ResourceRegistryServiceProcessClient(process=self, node=self.container.node)
pubsub_cli = PubsubManagementServiceProcessClient(process=self, node=self.container.node)
# Get the stream(s)
data_product_id = self.CFG.get_safe('dispatcher.data_product_id','')
stream_ids,_ = rr_cli.find_objects(subject=data_product_id, predicate=PRED.hasStream, id_only=True)
log.info('Got Stream Ids: "%s"', stream_ids)
assert stream_ids, 'No streams found for this data product!'
exchange_name = 'dispatcher_%s' % str(os.getpid())
subscription_id = pubsub_cli.create_subscription(
name='SampleSubscription',
exchange_name=exchange_name,
stream_ids=stream_ids,
description='Sample Subscription Description'
)
stream_defs = {}
def message_received(message, stream_route, stream_id):
granule = message
stream_id = granule.stream_resource_id
data_stream_id = granule.data_stream_id
data_stream = granule.identifiables[data_stream_id]
tstamp = get_datetime(data_stream.timestamp.value)
records = granule.identifiables['record_count'].value
log.info('Received a message from stream %s with time stamp %s and %d records' % (stream_id, tstamp, records))
if stream_id not in stream_defs:
stream_defs[stream_id] = pubsub_cli.find_stream_definition(stream_id, id_only=False).container
stream_def = stream_defs.get(stream_id)
sp = PointSupplementStreamParser(stream_definition=stream_def, stream_granule=granule)
last_data = {}
for field in sp.list_field_names():
last_data[field] = sp.get_values(field)[-1]
log.info('Last values in the message: %s' % str(last_data))
subscriber = StreamSubscriber(process=self, exchange_name=exchange_name, callback=message_received)
subscriber.start()
pubsub_cli.activate_subscription(subscription_id)
示例4: delete_attachment
def delete_attachment(attachment_id):
try:
rr_client = ResourceRegistryServiceProcessClient(process=service_gateway_instance)
ret = rr_client.delete_attachment(attachment_id)
return gateway_json_response(ret)
except Exception as e:
log.exception("Error deleting attachment")
return build_error_response(e)
示例5: get_attachment
def get_attachment(attachment_id):
try:
# Create client to interface with the viz service
rr_client = ResourceRegistryServiceProcessClient(process=service_gateway_instance)
attachment = rr_client.read_attachment(attachment_id, include_content=True)
return service_gateway_app.response_class(attachment.content, mimetype=attachment.content_type)
except Exception as e:
return build_error_response(e)
示例6: get_attachment
def get_attachment(attachment_id):
try:
# Create client to interface with the viz service
rr_client = ResourceRegistryServiceProcessClient(node=Container.instance.node, process=service_gateway_instance)
attachment = rr_client.read_attachment(attachment_id)
return app.response_class(attachment.content,mimetype=attachment.content_type)
except Exception, e:
return build_error_response(e)
示例7: list_resources_by_type
def list_resources_by_type(resource_type):
result = None
client = ResourceRegistryServiceProcessClient(node=Container.instance.node, process=service_gateway_instance)
try:
#Resource Types are not in unicode
res_list,_ = client.find_resources(restype=convert_unicode(resource_type) )
return json_response({ GATEWAY_RESPONSE :res_list } )
except Exception, e:
return build_error_response(e)
示例8: list_resources_by_type
def list_resources_by_type(resource_type):
ret = None
client = ResourceRegistryServiceProcessClient(node=Container.instance.node, process=service_gateway_instance)
try:
res_list,_ = client.find_resources(restype=resource_type )
result = []
for res in res_list:
result.append(res)
ret = simplejson.dumps(result, default=ion_object_encoder)
except Exception, e:
ret = "Error: %s" % e
示例9: get_resource
def get_resource(resource_id):
ret = None
client = ResourceRegistryServiceProcessClient(node=Container.instance.node, process=service_gateway_instance)
if resource_id != '':
try:
result = client.read(resource_id)
if not result:
raise NotFound("No resource found for id: %s " % resource_id)
ret = simplejson.dumps(result, default=ion_object_encoder)
except Exception, e:
ret = "Error: %s" % e
示例10: get_resource
def get_resource(resource_id):
result = None
client = ResourceRegistryServiceProcessClient(node=Container.instance.node, process=service_gateway_instance)
if resource_id != '':
try:
#Database object IDs are not unicode
result = client.read(convert_unicode(resource_id))
if not result:
raise NotFound("No resource found for id: %s " % resource_id)
return json_response({ GATEWAY_RESPONSE :result } )
except Exception, e:
return build_error_response(e)
示例11: find_resources_by_type
def find_resources_by_type(resource_type):
try:
client = ResourceRegistryServiceProcessClient(node=Container.instance.node, process=service_gateway_instance)
#Validate requesting user and expiry and add governance headers
ion_actor_id, expiry = get_governance_info_from_request()
ion_actor_id, expiry = validate_request(ion_actor_id, expiry)
#Resource Types are not in unicode
res_list,_ = client.find_resources(restype=convert_unicode(resource_type) )
return gateway_json_response(res_list)
except Exception, e:
return build_error_response(e)
示例12: on_initial_bootstrap
def on_initial_bootstrap(self, process, config, **kwargs):
self.pds_client = ProcessDispatcherServiceProcessClient(process=process)
self.resource_registry = ResourceRegistryServiceProcessClient(process=process)
self.ingestion_worker(process,config)
self.replay_defs(process,config)
self.notification_worker(process,config)
self.registration_worker(process,config)
示例13: setUp
def setUp(self):
# Start container
self._start_container()
#Load a deploy file that also loads basic policy.
self.container.start_rel_from_url('res/deploy/r2gov.yml')
process=FakeProcess()
self.rr_client = ResourceRegistryServiceProcessClient(node=self.container.node, process=process)
self.id_client = IdentityManagementServiceProcessClient(node=self.container.node, process=process)
self.org_client = OrgManagementServiceProcessClient(node=self.container.node, process=process)
self.ims_client = InstrumentManagementServiceProcessClient(node=self.container.node, process=process)
self.ion_org = self.org_client.find_org()
self.system_actor = self.id_client.find_actor_identity_by_name(name=CFG.system.system_actor)
log.debug('system actor:' + self.system_actor._id)
sa_header_roles = get_role_message_headers(self.org_client.find_all_roles_by_user(self.system_actor._id))
self.sa_user_header = {'ion-actor-id': self.system_actor._id, 'ion-actor-roles': sa_header_roles }
示例14: on_start
def on_start(self):
super(VizTransformProcForMatplotlibGraphs,self).on_start()
#assert len(self.streams)==1
self.initDataFlag = True
self.graph_data = {} # Stores a dictionary of variables : [List of values]
# Need some clients
self.rr_cli = ResourceRegistryServiceProcessClient(process = self, node = self.container.node)
self.pubsub_cli = PubsubManagementServiceClient(node=self.container.node)
# extract the various parameters passed to the transform process
self.out_stream_id = self.CFG.get('process').get('publish_streams').get('visualization_service_submit_stream_id')
# Create a publisher on the output stream
#stream_route = self.pubsub_cli.register_producer(stream_id=self.out_stream_id)
out_stream_pub_registrar = StreamPublisherRegistrar(process=self.container, node=self.container.node)
self.out_stream_pub = out_stream_pub_registrar.create_publisher(stream_id=self.out_stream_id)
self.data_product_id = self.CFG.get('data_product_id')
self.stream_def_id = self.CFG.get("stream_def_id")
self.stream_def = self.rr_cli.read(self.stream_def_id)
# Start the thread responsible for keeping track of time and generating graphs
# Mutex for ensuring proper concurrent communications between threads
self.lock = RLock()
self.rendering_proc = Greenlet(self.rendering_thread)
self.rendering_proc.start()
示例15: on_start
def on_start(self):
#print ">>>>>>>>>>>>>>>>>>>>>> MPL CFG = ", self.CFG
self.pubsub_management = PubsubManagementServiceProcessClient(process=self)
self.ssclient = SchedulerServiceProcessClient(process=self)
self.rrclient = ResourceRegistryServiceProcessClient(process=self)
self.data_retriever_client = DataRetrieverServiceProcessClient(process=self)
self.dsm_client = DatasetManagementServiceProcessClient(process=self)
self.pubsub_client = PubsubManagementServiceProcessClient(process = self)
self.stream_info = self.CFG.get_safe('process.publish_streams',{})
self.stream_names = self.stream_info.keys()
self.stream_ids = self.stream_info.values()
if not self.stream_names:
raise BadRequest('MPL Transform has no output streams.')
graph_time_periods= self.CFG.get_safe('graph_time_periods')
# If this is meant to be an event driven process, schedule an event to be generated every few minutes/hours
self.event_timer_interval = self.CFG.get_safe('graph_gen_interval')
if self.event_timer_interval:
event_origin = "Interval_Timer_Matplotlib"
sub = EventSubscriber(event_type="ResourceEvent", callback=self.interval_timer_callback, origin=event_origin)
sub.start()
self.interval_timer_id = self.ssclient.create_interval_timer(start_time="now" , interval=self._str_to_secs(self.event_timer_interval),
event_origin=event_origin, event_subtype="")
super(VizTransformMatplotlibGraphs,self).on_start()