Esempio n. 1
0
    def __init__(self, service: MagmaService,
                 garbage_collector: GarbageCollector,
                 grpc_client_manager: GRPCClientManager):
        sync_interval = service.config.get('sync_interval',
                                           DEFAULT_SYNC_INTERVAL)
        super().__init__(sync_interval, service.loop)
        self._service = service
        # Garbage collector to propagate deletions back to Orchestrator
        self._garbage_collector = garbage_collector
        # In memory mapping of states to version
        self._state_versions = {}
        # Set of keys from current replication iteration - used to track
        # keys to delete from _state_versions dict
        self._state_keys_from_current_iteration = set()
        # Redis clients for each type of state to replicate
        self._redis_dicts = []
        self._redis_dicts.extend(get_proto_redis_dicts(service.config))
        self._redis_dicts.extend(get_json_redis_dicts(service.config))
        # _grpc_client_manager to manage grpc client recyclings
        self._grpc_client_manager = grpc_client_manager

        # Flag to indicate if resync has completed successfully.
        # Replication cannot proceed until this flag is True
        self._has_resync_completed = False

        # Track replication iteration to track when to trigger garbage
        # collection
        self._replication_iteration = 0
Esempio n. 2
0
    def __init__(self, service: MagmaService,
                 grpc_client_manager: GRPCClientManager):
        self._service = service
        # Redis dicts for each type of state to replicate
        self._redis_dicts = []
        self._redis_dicts.extend(get_proto_redis_dicts(service.config))
        self._redis_dicts.extend(get_json_redis_dicts(service.config))

        # _grpc_client_manager to manage grpc client recyclings
        self._grpc_client_manager = grpc_client_manager
Esempio n. 3
0
    def __init__(
        self,
        service: MagmaService,
        garbage_collector: GarbageCollector,
        grpc_client_manager: GRPCClientManager,
    ):
        # Sync_interval is in seconds
        sync_interval = service.mconfig.sync_interval
        service_config_sync_interval = service.config.get('sync_interval')
        # TODO(#8806): remove this once we confirm partners no longer set sync_interval service configs.
        # We will honor service config sync_intervals under 10 seconds but this is being deprecated
        # The interval should be set in Orc8r via the rest endpoint.
        if (service_config_sync_interval is not None
                and service_config_sync_interval < 10
                and service_config_sync_interval < sync_interval):
            sync_interval = service_config_sync_interval
        super().__init__(sync_interval, service.loop)
        self._service = service
        # Garbage collector to propagate deletions back to Orchestrator
        self._garbage_collector = garbage_collector
        # In memory mapping of states to version
        self._state_versions = {}
        # Set of keys from current replication iteration - used to track
        # keys to delete from _state_versions dict
        self._state_keys_from_current_iteration = set()
        # Redis clients for each type of state to replicate
        self._redis_dicts = []
        self._redis_dicts.extend(get_proto_redis_dicts(service.config))
        self._redis_dicts.extend(get_json_redis_dicts(service.config))
        # _grpc_client_manager to manage grpc client recyclings
        self._grpc_client_manager = grpc_client_manager

        # Flag to indicate if resync has completed successfully.
        # Replication cannot proceed until this flag is True
        self._has_resync_completed = False

        # Track replication iteration to track when to trigger garbage
        # collection
        self._replication_iteration = 0
    def __init__(
        self,
        service: MagmaService,
        garbage_collector: GarbageCollector,
        grpc_client_manager: GRPCClientManager,
        print_grpc_payload: bool = False,
    ):

        sync_interval = _resolve_sync_interval(service)
        logging.info("state service sync interval set to %s", sync_interval)
        super().__init__(sync_interval, service.loop)
        self._service = service
        # Garbage collector to propagate deletions back to Orchestrator
        self._garbage_collector = garbage_collector
        # In memory mapping of states to version
        self._state_versions = {}
        # Set of keys from current replication iteration - used to track
        # keys to delete from _state_versions dict
        self._state_keys_from_current_iteration = set()
        # Redis clients for each type of state to replicate
        self._redis_dicts = []
        self._redis_dicts.extend(get_proto_redis_dicts(service.config))
        self._redis_dicts.extend(get_json_redis_dicts(service.config))
        # _grpc_client_manager to manage grpc client recyclings
        self._grpc_client_manager = grpc_client_manager

        # Flag to indicate if resync has completed successfully.
        # Replication cannot proceed until this flag is True
        self._has_resync_completed = False

        # Track replication iteration to track when to trigger garbage
        # collection
        self._replication_iteration = 0
        self._print_grpc_payload = print_grpc_payload

        if self._print_grpc_payload:
            logging.info("Printing GRPC messages")