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): ...@@ -60,7 +60,8 @@ class ConnectionPool(object):
def _initNodeConnection(self, cell): def _initNodeConnection(self, cell):
"""Init a connection to a given storage node.""" """Init a connection to a given storage node."""
addr = cell.getNode().getServer() node = cell.getNode()
addr = node.getServer()
if addr is None: if addr is None:
return None return None
...@@ -71,7 +72,7 @@ class ConnectionPool(object): ...@@ -71,7 +72,7 @@ class ConnectionPool(object):
# Loop until a connection is obtained. # Loop until a connection is obtained.
while 1: 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 app.local_var.node_not_ready = 0
conn = MTClientConnection(app.em, app.handler, addr, conn = MTClientConnection(app.em, app.handler, addr,
connector_handler=app.connector_handler) connector_handler=app.connector_handler)
...@@ -79,7 +80,7 @@ class ConnectionPool(object): ...@@ -79,7 +80,7 @@ class ConnectionPool(object):
try: try:
if conn.getConnector() is None: if conn.getConnector() is None:
# This happens, if a connection could not be established. # 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 return None
msg_id = conn.getNextId() msg_id = conn.getNextId()
...@@ -96,15 +97,15 @@ class ConnectionPool(object): ...@@ -96,15 +97,15 @@ class ConnectionPool(object):
try: try:
app._waitMessage(conn, msg_id) app._waitMessage(conn, msg_id)
except NEOStorageError: except NEOStorageError:
logging.error('Connection to storage node %s failed', addr) logging.error('Connection to storage node %s failed', node)
return None return None
if app.local_var.node_not_ready: if app.local_var.node_not_ready:
# Connection failed, notify primary master node # Connection failed, notify primary master node
logging.info('Storage node %s not ready', addr) logging.info('Storage node %s not ready', node)
return None return None
else: else:
logging.info('connected to storage node %s:%d', *addr) logging.info('connected to storage node %s', node)
return conn return conn
sleep(1) sleep(1)
...@@ -982,7 +983,7 @@ class Application(object): ...@@ -982,7 +983,7 @@ class Application(object):
break break
sleep(1) 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 self.master_conn = conn
finally: finally:
self._connecting_to_master_node_release() self._connecting_to_master_node_release()
...@@ -169,7 +169,7 @@ class Application(object): ...@@ -169,7 +169,7 @@ class Application(object):
for node in nm.getMasterNodeList(): for node in nm.getMasterNodeList():
if node.getState() == TEMPORARILY_DOWN_STATE \ if node.getState() == TEMPORARILY_DOWN_STATE \
and node.getLastStateChange() + expiration < current_time: and node.getLastStateChange() + expiration < current_time:
logging.info('%s:%d is down' % node.getServer()) logging.info('%s is down' % (node, ))
node.setState(DOWN_STATE) node.setState(DOWN_STATE)
self.unconnected_master_node_set.discard(node.getServer()) self.unconnected_master_node_set.discard(node.getServer())
...@@ -400,8 +400,7 @@ class Application(object): ...@@ -400,8 +400,7 @@ class Application(object):
else: else:
# Obtain a partition table. It is necessary to split this # Obtain a partition table. It is necessary to split this
# message, because the packet size can be huge. # message, because the packet size can be huge.
logging.debug('asking a partition table to %s:%d', logging.debug('asking a partition table to %s', node)
*(node.getServer()))
start = 0 start = 0
size = self.num_partitions size = self.num_partitions
while size: while size:
...@@ -678,7 +677,7 @@ class Application(object): ...@@ -678,7 +677,7 @@ class Application(object):
for node in nm.getStorageNodeList(): for node in nm.getStorageNodeList():
if node.getState() == TEMPORARILY_DOWN_STATE \ if node.getState() == TEMPORARILY_DOWN_STATE \
and node.getLastStateChange() + expiration < current_time: and node.getLastStateChange() + expiration < current_time:
logging.info('%s:%d is down' % node.getServer()) logging.info('%s is down' % (node, ))
node.setState(DOWN_STATE) node.setState(DOWN_STATE)
self.broadcastNodeInformation(node) self.broadcastNodeInformation(node)
cell_list = self.pt.dropNode(node) cell_list = self.pt.dropNode(node)
......
...@@ -259,7 +259,7 @@ class ElectionEventHandler(MasterEventHandler): ...@@ -259,7 +259,7 @@ class ElectionEventHandler(MasterEventHandler):
node = app.nm.getNodeByUUID(uuid) node = app.nm.getNodeByUUID(uuid)
app.primary = False app.primary = False
app.primary_master_node = node 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): def handleReelectPrimaryMaster(self, conn, packet):
raise ElectionFailure, 'reelection requested' 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