2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-23 01:53:28 +00:00

Fix double connect on logging change

When logging was changed from none to full, it would always
start and immediately abort connecting to start again.
Change this by deciding which connection liveness strategy
to use based on how many settings changed.  If just logging
changes, then connect only if not connected or connecting.
If more changes, then skip that kinder strategy and go straight
to reconnecting.
This commit is contained in:
Jarrod Johnon 2014-09-30 11:21:01 -04:00
parent 8728007d1e
commit 37549481b6

View File

@ -99,7 +99,15 @@ class _ConsoleHandler(object):
except KeyError:
pass
if logvalue in ('full', ''):
self._alwayson()
# if the *only* thing to change is the log,
# then let always on handle reconnect if needed,
# since we want to avoid a senseless disconnect
# if already connected
# if other things change, then unconditionally reconnect
onlylogging = len(nodeattribs[self.node]) == 1
self._alwayson(doconnect=onlylogging)
if onlylogging:
return
else:
self._ondemand()
if logvalue == 'none':
@ -112,8 +120,10 @@ class _ConsoleHandler(object):
return
self.logger.log(*args, **kwargs)
def _alwayson(self):
def _alwayson(self, doconnect=True):
self._isondemand = False
if not doconnect:
return
if not self._console and not self.connectionthread:
self._connect()
else: