diff options
author | PrakashH <pbhandar@techmahindra.com> | 2019-01-28 20:49:02 +0000 |
---|---|---|
committer | PrakashH <pbhandar@techmahindra.com> | 2019-01-28 20:49:02 +0000 |
commit | a86243058c2daa560aebaecdb096ff63788a6f44 (patch) | |
tree | 68d29b8ec0545792d50785b0105914d00c73d884 /miss_htbt_service/cbs_polling.py | |
parent | 20110ffeb5071193e7b437e797636d9d6318dcd4 (diff) |
Heartbeat Microservice Support
Heartbeat service monitors missing HB notification
Issue-ID: DCAEGEN2-267
Change-Id: I0fd191b2a3495202e22f633ada4a1350a97557ad
Signed-off-by: PrakashH <pbhandar@techmahindra.com>
Diffstat (limited to 'miss_htbt_service/cbs_polling.py')
-rw-r--r-- | miss_htbt_service/cbs_polling.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/miss_htbt_service/cbs_polling.py b/miss_htbt_service/cbs_polling.py index 4212ab7..233cdb5 100644 --- a/miss_htbt_service/cbs_polling.py +++ b/miss_htbt_service/cbs_polling.py @@ -32,8 +32,8 @@ _logger = get_logger.get_logger(__name__) def pollCBS(current_pid): - - ip_address, port_num, user_name, password, db_name, cbs_polling_required, cbs_polling_interval = db.read_hb_properties() + jsfile = db.fetch_json_file() + ip_address, port_num, user_name, password, db_name, cbs_polling_required, cbs_polling_interval = db.read_hb_properties(jsfile) hbc_pid, hbc_state, hbc_srcName, hbc_time = db.read_hb_common(user_name,password,ip_address,port_num,db_name) msg="CBSP:Main process ID in hb_common is %d",hbc_pid _logger.info(msg) @@ -41,12 +41,15 @@ def pollCBS(current_pid): _logger.info(msg) msg="CBSP:CBS Polling interval is %d", cbs_polling_interval _logger.info(msg) - time.sleep(cbs_polling_interval) + envPytest = os.getenv('pytest', "") + if (envPytest == 'test'): + cbs_polling_interval = "30" + time.sleep(int(cbs_polling_interval)) hbc_pid, hbc_state, hbc_srcName, hbc_time = db.read_hb_common(user_name,password,ip_address,port_num,db_name) #connection_db = pm.postgres_db_open(user_name,password,ip_address,port_num,db_name) #cur = connection_db.cursor() source_name = socket.gethostname() - source_name = source_name + "-" + str(os.getenv('SERVICE_NAME')) + source_name = source_name + "-" + str(os.getenv('SERVICE_NAME', "")) result= True if(int(current_pid)==int(hbc_pid) and source_name==hbc_srcName and hbc_state == "RUNNING"): _logger.info("CBSP:ACTIVE Instance:Change the state to RECONFIGURATION") |