Commit a18a5e01 authored by Vincent Pelletier's avatar Vincent Pelletier

Make _initNodeConnection expect a node, not a cell (just as the name implies).

Add a getConnForCell method to ConnectionPool class.
Use getConnForCell instead of getConnForNode in each place where a Cell is placed instead of a node.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@642 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 0f1164d9
...@@ -56,9 +56,8 @@ class ConnectionPool(object): ...@@ -56,9 +56,8 @@ class ConnectionPool(object):
self.connection_lock_acquire = l.acquire self.connection_lock_acquire = l.acquire
self.connection_lock_release = l.release self.connection_lock_release = l.release
def _initNodeConnection(self, cell): def _initNodeConnection(self, node):
"""Init a connection to a given storage node.""" """Init a connection to a given storage node."""
node = cell.getNode()
addr = node.getServer() addr = node.getServer()
if addr is None: if addr is None:
return None return None
...@@ -141,6 +140,9 @@ class ConnectionPool(object): ...@@ -141,6 +140,9 @@ class ConnectionPool(object):
conn.lock() conn.lock()
return conn return conn
def getConnForCell(self, cell):
return self.getConnForNode(cell.getNode())
def getConnForNode(self, node): def getConnForNode(self, node):
"""Return a locked connection object to a given node """Return a locked connection object to a given node
If no connection exists, create a new one""" If no connection exists, create a new one"""
...@@ -469,7 +471,7 @@ class Application(object): ...@@ -469,7 +471,7 @@ class Application(object):
for cell in cell_list: for cell in cell_list:
logging.debug('trying to load %s from %s', logging.debug('trying to load %s from %s',
dump(oid), dump(cell.getUUID())) dump(oid), dump(cell.getUUID()))
conn = self.cp.getConnForNode(cell) conn = self.cp.getConnForCell(cell)
if conn is None: if conn is None:
continue continue
...@@ -602,7 +604,7 @@ class Application(object): ...@@ -602,7 +604,7 @@ class Application(object):
self.local_var.object_stored_counter = 0 self.local_var.object_stored_counter = 0
for cell in cell_list: for cell in cell_list:
#logging.info("storing object %s %s" %(cell.getServer(),cell.getState())) #logging.info("storing object %s %s" %(cell.getServer(),cell.getState()))
conn = self.cp.getConnForNode(cell) conn = self.cp.getConnForCell(cell)
if conn is None: if conn is None:
continue continue
...@@ -651,7 +653,7 @@ class Application(object): ...@@ -651,7 +653,7 @@ class Application(object):
self.local_var.voted_counter = 0 self.local_var.voted_counter = 0
for cell in cell_list: for cell in cell_list:
logging.info("voting object %s %s" %(cell.getServer(), cell.getState())) logging.info("voting object %s %s" %(cell.getServer(), cell.getState()))
conn = self.cp.getConnForNode(cell) conn = self.cp.getConnForCell(cell)
if conn is None: if conn is None:
continue continue
...@@ -685,7 +687,7 @@ class Application(object): ...@@ -685,7 +687,7 @@ class Application(object):
# cancel transaction one all those nodes # cancel transaction one all those nodes
for cell in cell_set: for cell in cell_set:
conn = self.cp.getConnForNode(cell) conn = self.cp.getConnForCell(cell)
if conn is None: if conn is None:
continue continue
try: try:
...@@ -742,7 +744,7 @@ class Application(object): ...@@ -742,7 +744,7 @@ class Application(object):
cell_list = self._getCellListForID(transaction_id, writable=True) cell_list = self._getCellListForID(transaction_id, writable=True)
shuffle(cell_list) shuffle(cell_list)
for cell in cell_list: for cell in cell_list:
conn = self.cp.getConnForNode(cell) conn = self.cp.getConnForCell(cell)
if conn is None: if conn is None:
continue continue
...@@ -887,7 +889,7 @@ class Application(object): ...@@ -887,7 +889,7 @@ class Application(object):
shuffle(cell_list) shuffle(cell_list)
for cell in cell_list: for cell in cell_list:
conn = self.cp.getConnForNode(cell) conn = self.cp.getConnForCell(cell)
if conn is None: if conn is None:
continue continue
...@@ -917,7 +919,7 @@ class Application(object): ...@@ -917,7 +919,7 @@ class Application(object):
shuffle(cell_list) shuffle(cell_list)
for cell in cell_list: for cell in cell_list:
conn = self.cp.getConnForNode(cell) conn = self.cp.getConnForCell(cell)
if conn is None: if conn is None:
continue continue
......
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