From b7ff905e595ca0bf72d55ec272d48edaa6403df5 Mon Sep 17 00:00:00 2001 From: Terrtia Date: Tue, 30 Nov 2021 18:08:48 +0100 Subject: [PATCH] chg: [sync UI] dashboard, show nb of imported items + launch/kill ail servers when a queue is subscribed/unsubscribed --- bin/core/Sync_importer.py | 10 ++++++++-- bin/core/ail_2_ail.py | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/bin/core/Sync_importer.py b/bin/core/Sync_importer.py index 7ed7a8f0..d393c226 100755 --- a/bin/core/Sync_importer.py +++ b/bin/core/Sync_importer.py @@ -22,10 +22,16 @@ sys.path.append(os.environ['AIL_BIN']) # Import Project packages ################################## from core import ail_2_ail +from lib.ConfigLoader import ConfigLoader from modules.abstract_module import AbstractModule from packages.Item import Item from packages import Tag +#### CONFIG #### +config_loader = ConfigLoader() +server_cache = config_loader.get_redis_conn("Redis_Log_submit") +config_loader = None +#### ------ #### class Sync_importer(AbstractModule): """ @@ -79,8 +85,8 @@ class Sync_importer(AbstractModule): print(message) self.send_message_to_queue(message, 'Mixer') - # # increase nb of paste by feeder name - # server_cache.hincrby("mixer_cache:list_feeder", Sync, 1) + # increase nb of item by ail sync + server_cache.hincrby("mixer_cache:list_feeder", 'AIL_Sync', 1) if __name__ == '__main__': diff --git a/bin/core/ail_2_ail.py b/bin/core/ail_2_ail.py index 7cb32e69..027eb791 100755 --- a/bin/core/ail_2_ail.py +++ b/bin/core/ail_2_ail.py @@ -945,15 +945,21 @@ def is_queue_registred_by_ail_instance(queue_uuid, ail_uuid): return r_serv_sync.sismember(f'ail:instance:sync_queue:{ail_uuid}', queue_uuid) def register_ail_to_sync_queue(ail_uuid, queue_uuid): + is_linked = is_ail_instance_linked_to_sync_queue(ail_uuid) r_serv_sync.sadd(f'ail2ail:sync_queue:ail_instance:{queue_uuid}', ail_uuid) r_serv_sync.sadd(f'ail:instance:sync_queue:{ail_uuid}', queue_uuid) set_last_updated_sync_config() + if not is_linked: + refresh_ail_instance_connection(ail_uuid) # # # FIXME: TODO: delete sync queue ???????????????????????????????????????????????????? def unregister_ail_to_sync_queue(ail_uuid, queue_uuid): r_serv_sync.srem(f'ail2ail:sync_queue:ail_instance:{queue_uuid}', ail_uuid) r_serv_sync.srem(f'ail:instance:sync_queue:{ail_uuid}', queue_uuid) set_last_updated_sync_config() + is_linked = is_ail_instance_linked_to_sync_queue(ail_uuid) + if not is_linked: + refresh_ail_instance_connection(ail_uuid) def get_all_unregistred_queue_by_ail_instance(ail_uuid): return r_serv_sync.sdiff('ail2ail:sync_queue:all', f'ail:instance:sync_queue:{ail_uuid}')