Loading src/context/service/database/ConfigModel.py +1 −1 Original line number Diff line number Diff line Loading @@ -11,7 +11,7 @@ from common.orm.fields.PrimaryKeyField import PrimaryKeyField from common.orm.fields.StringField import StringField from common.orm.model.Model import Model from context.proto.context_pb2 import ConfigActionEnum from context.service.database.Tools import fast_hasher, grpc_to_enum, remove_dict_key from .Tools import fast_hasher, grpc_to_enum, remove_dict_key LOGGER = logging.getLogger(__name__) Loading src/context/service/database/EndPointModel.py +2 −2 Original line number Diff line number Diff line Loading @@ -4,8 +4,8 @@ from common.orm.fields.ForeignKeyField import ForeignKeyField from common.orm.fields.PrimaryKeyField import PrimaryKeyField from common.orm.fields.StringField import StringField from common.orm.model.Model import Model from context.service.database.DeviceModel import DeviceModel from context.service.database.TopologyModel import TopologyModel from .DeviceModel import DeviceModel from .TopologyModel import TopologyModel LOGGER = logging.getLogger(__name__) Loading src/context/service/grpc_server/ContextService.py +1 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ class ContextService: self.server = None def start(self): self.endpoint = '{:s}:{:s}'.format(self.address, str(self.port)) self.endpoint = '{:s}:{:s}'.format(str(self.address), str(self.port)) LOGGER.info('Starting Service (tentative endpoint: {:s}, max_workers: {:s})...'.format( str(self.endpoint), str(self.max_workers))) Loading src/device/service/Tools.py→src/device/_old_code/Tools.py +0 −0 File moved. View file src/device/service/DeviceService.py +16 −11 Original line number Diff line number Diff line Loading @@ -4,17 +4,22 @@ from concurrent import futures from grpc_health.v1.health import HealthServicer, OVERALL_HEALTH from grpc_health.v1.health_pb2 import HealthCheckResponse from grpc_health.v1.health_pb2_grpc import add_HealthServicer_to_server from device.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD from device.proto.device_pb2_grpc import add_DeviceServiceServicer_to_server from device.service.DeviceServiceServicerImpl import DeviceServiceServicerImpl from device.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD from device.service.data_cache.DataCache import DataCache from device.service.driver_api.DriverInstanceCache import DriverInstanceCache BIND_ADDRESS = '0.0.0.0' LOGGER = logging.getLogger(__name__) class DeviceService: def __init__(self, database, address=BIND_ADDRESS, port=GRPC_SERVICE_PORT, max_workers=GRPC_MAX_WORKERS, grace_period=GRPC_GRACE_PERIOD): self.database = database def __init__( self, data_cache : DataCache, driver_instance_cache : DriverInstanceCache, address=BIND_ADDRESS, port=GRPC_SERVICE_PORT, max_workers=GRPC_MAX_WORKERS, grace_period=GRPC_GRACE_PERIOD): self.data_cache = data_cache self.driver_instance_cache = driver_instance_cache self.address = address self.port = port self.endpoint = None Loading @@ -26,14 +31,14 @@ class DeviceService: self.server = None def start(self): self.endpoint = '{}:{}'.format(self.address, self.port) LOGGER.debug('Starting Service (tentative endpoint: {}, max_workers: {})...'.format( self.endpoint, self.max_workers)) self.endpoint = '{:s}:{:s}'.format(str(self.address), str(self.port)) LOGGER.info('Starting Service (tentative endpoint: {:s}, max_workers: {:s})...'.format( str(self.endpoint), str(self.max_workers))) self.pool = futures.ThreadPoolExecutor(max_workers=self.max_workers) self.server = grpc.server(self.pool) # , interceptors=(tracer_interceptor,)) self.device_servicer = DeviceServiceServicerImpl(self.database) self.device_servicer = DeviceServiceServicerImpl(self.data_cache, self.driver_instance_cache) add_DeviceServiceServicer_to_server(self.device_servicer, self.server) self.health_servicer = HealthServicer( Loading @@ -41,15 +46,15 @@ class DeviceService: add_HealthServicer_to_server(self.health_servicer, self.server) port = self.server.add_insecure_port(self.endpoint) self.endpoint = '{}:{}'.format(self.address, port) LOGGER.info('Listening on {}...'.format(self.endpoint)) self.endpoint = '{:s}:{:s}'.format(str(self.address), str(port)) LOGGER.info('Listening on {:s}...'.format(str(self.endpoint))) self.server.start() self.health_servicer.set(OVERALL_HEALTH, HealthCheckResponse.SERVING) # pylint: disable=maybe-no-member LOGGER.debug('Service started') def stop(self): LOGGER.debug('Stopping service (grace period {} seconds)...'.format(self.grace_period)) LOGGER.debug('Stopping service (grace period {:s} seconds)...'.format(str(self.grace_period))) self.health_servicer.enter_graceful_shutdown() self.server.stop(self.grace_period) LOGGER.debug('Service stopped') Loading
src/context/service/database/ConfigModel.py +1 −1 Original line number Diff line number Diff line Loading @@ -11,7 +11,7 @@ from common.orm.fields.PrimaryKeyField import PrimaryKeyField from common.orm.fields.StringField import StringField from common.orm.model.Model import Model from context.proto.context_pb2 import ConfigActionEnum from context.service.database.Tools import fast_hasher, grpc_to_enum, remove_dict_key from .Tools import fast_hasher, grpc_to_enum, remove_dict_key LOGGER = logging.getLogger(__name__) Loading
src/context/service/database/EndPointModel.py +2 −2 Original line number Diff line number Diff line Loading @@ -4,8 +4,8 @@ from common.orm.fields.ForeignKeyField import ForeignKeyField from common.orm.fields.PrimaryKeyField import PrimaryKeyField from common.orm.fields.StringField import StringField from common.orm.model.Model import Model from context.service.database.DeviceModel import DeviceModel from context.service.database.TopologyModel import TopologyModel from .DeviceModel import DeviceModel from .TopologyModel import TopologyModel LOGGER = logging.getLogger(__name__) Loading
src/context/service/grpc_server/ContextService.py +1 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ class ContextService: self.server = None def start(self): self.endpoint = '{:s}:{:s}'.format(self.address, str(self.port)) self.endpoint = '{:s}:{:s}'.format(str(self.address), str(self.port)) LOGGER.info('Starting Service (tentative endpoint: {:s}, max_workers: {:s})...'.format( str(self.endpoint), str(self.max_workers))) Loading
src/device/service/DeviceService.py +16 −11 Original line number Diff line number Diff line Loading @@ -4,17 +4,22 @@ from concurrent import futures from grpc_health.v1.health import HealthServicer, OVERALL_HEALTH from grpc_health.v1.health_pb2 import HealthCheckResponse from grpc_health.v1.health_pb2_grpc import add_HealthServicer_to_server from device.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD from device.proto.device_pb2_grpc import add_DeviceServiceServicer_to_server from device.service.DeviceServiceServicerImpl import DeviceServiceServicerImpl from device.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD from device.service.data_cache.DataCache import DataCache from device.service.driver_api.DriverInstanceCache import DriverInstanceCache BIND_ADDRESS = '0.0.0.0' LOGGER = logging.getLogger(__name__) class DeviceService: def __init__(self, database, address=BIND_ADDRESS, port=GRPC_SERVICE_PORT, max_workers=GRPC_MAX_WORKERS, grace_period=GRPC_GRACE_PERIOD): self.database = database def __init__( self, data_cache : DataCache, driver_instance_cache : DriverInstanceCache, address=BIND_ADDRESS, port=GRPC_SERVICE_PORT, max_workers=GRPC_MAX_WORKERS, grace_period=GRPC_GRACE_PERIOD): self.data_cache = data_cache self.driver_instance_cache = driver_instance_cache self.address = address self.port = port self.endpoint = None Loading @@ -26,14 +31,14 @@ class DeviceService: self.server = None def start(self): self.endpoint = '{}:{}'.format(self.address, self.port) LOGGER.debug('Starting Service (tentative endpoint: {}, max_workers: {})...'.format( self.endpoint, self.max_workers)) self.endpoint = '{:s}:{:s}'.format(str(self.address), str(self.port)) LOGGER.info('Starting Service (tentative endpoint: {:s}, max_workers: {:s})...'.format( str(self.endpoint), str(self.max_workers))) self.pool = futures.ThreadPoolExecutor(max_workers=self.max_workers) self.server = grpc.server(self.pool) # , interceptors=(tracer_interceptor,)) self.device_servicer = DeviceServiceServicerImpl(self.database) self.device_servicer = DeviceServiceServicerImpl(self.data_cache, self.driver_instance_cache) add_DeviceServiceServicer_to_server(self.device_servicer, self.server) self.health_servicer = HealthServicer( Loading @@ -41,15 +46,15 @@ class DeviceService: add_HealthServicer_to_server(self.health_servicer, self.server) port = self.server.add_insecure_port(self.endpoint) self.endpoint = '{}:{}'.format(self.address, port) LOGGER.info('Listening on {}...'.format(self.endpoint)) self.endpoint = '{:s}:{:s}'.format(str(self.address), str(port)) LOGGER.info('Listening on {:s}...'.format(str(self.endpoint))) self.server.start() self.health_servicer.set(OVERALL_HEALTH, HealthCheckResponse.SERVING) # pylint: disable=maybe-no-member LOGGER.debug('Service started') def stop(self): LOGGER.debug('Stopping service (grace period {} seconds)...'.format(self.grace_period)) LOGGER.debug('Stopping service (grace period {:s} seconds)...'.format(str(self.grace_period))) self.health_servicer.enter_graceful_shutdown() self.server.stop(self.grace_period) LOGGER.debug('Service stopped')