|
@@ -40,24 +40,35 @@ class DataCenter(object):
|
|
|
self._mTrdReader.join()
|
|
|
|
|
|
def prepare_data(self):
|
|
|
- while not self._mquit:
|
|
|
- try:
|
|
|
- # pool = redis.ConnectionPool(host='121.89.223.81', port=57649, db=0)
|
|
|
- pool = redis.ConnectionPool(host='172.26.105.125', port=6379, db=0)
|
|
|
- r = redis.Redis(connection_pool=pool)
|
|
|
- self.read_redis(r, 'nc_channel_monitor_commit', 'commit')
|
|
|
- self.read_redis(r, 'nc_channel_monitor_notify', 'notify')
|
|
|
- break
|
|
|
- except Exception as ex:
|
|
|
- print(ex)
|
|
|
+ try:
|
|
|
+ # pool = redis.ConnectionPool(host='121.89.223.81', port=57649, db=0)
|
|
|
+ pool = redis.ConnectionPool(host='172.26.105.125', port=6379, db=0)
|
|
|
+ r = redis.Redis(connection_pool=pool)
|
|
|
+ self.read_redis(r, 'nc_channel_monitor_commit', 'commit')
|
|
|
+ self.read_redis(r, 'nc_channel_monitor_notify', 'notify')
|
|
|
+ except Exception as ex:
|
|
|
+ print(ex)
|
|
|
+ # while not self._mquit:
|
|
|
+ # try:
|
|
|
+ # # pool = redis.ConnectionPool(host='121.89.223.81', port=57649, db=0)
|
|
|
+ # pool = redis.ConnectionPool(host='172.26.105.125', port=6379, db=0)
|
|
|
+ # r = redis.Redis(connection_pool=pool)
|
|
|
+ # self.read_redis(r, 'nc_channel_monitor_commit', 'commit')
|
|
|
+ # self.read_redis(r, 'nc_channel_monitor_notify', 'notify')
|
|
|
+ # break
|
|
|
+ # except Exception as ex:
|
|
|
+ # print(ex)
|
|
|
# finally:
|
|
|
# time.sleep(60)
|
|
|
pass
|
|
|
|
|
|
def read_redis(self, redis, name, prefix):
|
|
|
+ i = 0
|
|
|
for item in redis.hscan_iter(name):
|
|
|
key = str(item[0], encoding="utf-8")
|
|
|
val = str(item[1], encoding="utf-8")
|
|
|
+ print(f'{prefix}:{i}')
|
|
|
+ i += 1
|
|
|
self.parase(key, val, prefix)
|
|
|
|
|
|
def parase(self, text, val, prefix):
|