Commit 8dacee1b authored by Vincent Pelletier's avatar Vincent Pelletier

Make use of Node.__str__ to avoid crashes when getServer is None (and in other...

Make use of Node.__str__ to avoid crashes when getServer is None (and in other places for consistency).


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@331 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent cbd26197
......@@ -60,7 +60,8 @@ class ConnectionPool(object):
def _initNodeConnection(self, cell):
"""Init a connection to a given storage node."""
addr = cell.getNode().getServer()
node = cell.getNode()
addr = node.getServer()
if addr is None:
return None
......@@ -71,7 +72,7 @@ class ConnectionPool(object):
# Loop until a connection is obtained.
while 1:
logging.info('trying to connect to %s:%d', *addr)
logging.info('trying to connect to %s', node)
app.local_var.node_not_ready = 0
conn = MTClientConnection(app.em, app.handler, addr,
connector_handler=app.connector_handler)
......@@ -79,7 +80,7 @@ class ConnectionPool(object):
try:
if conn.getConnector() is None:
# This happens, if a connection could not be established.
logging.error('Connection to storage node %s failed', addr)
logging.error('Connection to storage node %s failed', node)
return None
msg_id = conn.getNextId()
......@@ -96,15 +97,15 @@ class ConnectionPool(object):
try:
app._waitMessage(conn, msg_id)
except NEOStorageError:
logging.error('Connection to storage node %s failed', addr)
logging.error('Connection to storage node %s failed', node)
return None
if app.local_var.node_not_ready:
# Connection failed, notify primary master node
logging.info('Storage node %s not ready', addr)
logging.info('Storage node %s not ready', node)
return None
else:
logging.info('connected to storage node %s:%d', *addr)
logging.info('connected to storage node %s', node)
return conn
sleep(1)
......@@ -982,7 +983,7 @@ class Application(object):
break
sleep(1)
logging.info("connected to primary master node %s:%d" % self.primary_master_node.getServer())
logging.info("connected to primary master node %s" % self.primary_master_node)
self.master_conn = conn
finally:
self._connecting_to_master_node_release()
......@@ -169,7 +169,7 @@ class Application(object):
for node in nm.getMasterNodeList():
if node.getState() == TEMPORARILY_DOWN_STATE \
and node.getLastStateChange() + expiration < current_time:
logging.info('%s:%d is down' % node.getServer())
logging.info('%s is down' % (node, ))
node.setState(DOWN_STATE)
self.unconnected_master_node_set.discard(node.getServer())
......@@ -400,8 +400,7 @@ class Application(object):
else:
# Obtain a partition table. It is necessary to split this
# message, because the packet size can be huge.
logging.debug('asking a partition table to %s:%d',
*(node.getServer()))
logging.debug('asking a partition table to %s', node)
start = 0
size = self.num_partitions
while size:
......@@ -678,7 +677,7 @@ class Application(object):
for node in nm.getStorageNodeList():
if node.getState() == TEMPORARILY_DOWN_STATE \
and node.getLastStateChange() + expiration < current_time:
logging.info('%s:%d is down' % node.getServer())
logging.info('%s is down' % (node, ))
node.setState(DOWN_STATE)
self.broadcastNodeInformation(node)
cell_list = self.pt.dropNode(node)
......
......@@ -259,7 +259,7 @@ class ElectionEventHandler(MasterEventHandler):
node = app.nm.getNodeByUUID(uuid)
app.primary = False
app.primary_master_node = node
logging.info('%s:%d is the primary', *(node.getServer()))
logging.info('%s is the primary', node)
def handleReelectPrimaryMaster(self, conn, packet):
raise ElectionFailure, 'reelection requested'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment