Commit aac0da72 authored by Aurel's avatar Aurel

fix some return code

get only usable partition in most of the cases


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@238 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 61090af0
...@@ -80,6 +80,7 @@ class ConnectionPool(object): ...@@ -80,6 +80,7 @@ class ConnectionPool(object):
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', addr)
return None
else: else:
logging.info('connected to storage node %s:%d', *addr) logging.info('connected to storage node %s:%d', *addr)
return conn return conn
...@@ -96,7 +97,7 @@ class ConnectionPool(object): ...@@ -96,7 +97,7 @@ class ConnectionPool(object):
not self.app.dispatcher.registered(id(conn)): not self.app.dispatcher.registered(id(conn)):
del self.connection_dict[conn.getUUID()] del self.connection_dict[conn.getUUID()]
conn.close() conn.close()
logging.info('connection to storage node %s:%d closed', logging.info('_dropConnections : connection to storage node %s:%d closed',
*(conn.getAddress())) *(conn.getAddress()))
if len(self.connection_dict) <= self.max_pool_size: if len(self.connection_dict) <= self.max_pool_size:
break break
...@@ -423,7 +424,7 @@ class Application(object): ...@@ -423,7 +424,7 @@ class Application(object):
self.tid = None self.tid = None
conn = self.master_conn conn = self.master_conn
if conn is None: if conn is None:
raise NEOStorageError("Connection failed") raise NEOStorageError("Connection to master node failed")
conn.lock() conn.lock()
try: try:
msg_id = conn.getNextId() msg_id = conn.getNextId()
...@@ -453,7 +454,7 @@ class Application(object): ...@@ -453,7 +454,7 @@ class Application(object):
dump(oid), dump(serial)) dump(oid), dump(serial))
# Find which storage node to use # Find which storage node to use
partition_id = u64(oid) % self.num_partitions partition_id = u64(oid) % self.num_partitions
cell_list = self.pt.getCellList(partition_id, False) cell_list = self.pt.getCellList(partition_id, True)
if len(cell_list) == 0: if len(cell_list) == 0:
# FIXME must wait for cluster to be ready # FIXME must wait for cluster to be ready
raise NEOStorageError raise NEOStorageError
...@@ -462,6 +463,7 @@ class Application(object): ...@@ -462,6 +463,7 @@ class Application(object):
compressed_data = compress(ddata) compressed_data = compress(ddata)
checksum = makeChecksum(compressed_data) checksum = makeChecksum(compressed_data)
for cell in cell_list: for cell in cell_list:
logging.info("storing object %s %s" %(cell.getServer(),cell.getState()))
conn = self.cp.getConnForNode(cell) conn = self.cp.getConnForNode(cell)
if conn is None: if conn is None:
continue continue
...@@ -507,8 +509,9 @@ class Application(object): ...@@ -507,8 +509,9 @@ class Application(object):
oid_list = self.txn_data_dict.keys() oid_list = self.txn_data_dict.keys()
# Store data on each node # Store data on each node
partition_id = u64(self.tid) % self.num_partitions partition_id = u64(self.tid) % self.num_partitions
cell_list = self.pt.getCellList(partition_id, False) cell_list = self.pt.getCellList(partition_id, True)
for cell in cell_list: for cell in cell_list:
logging.info("voting object %s %s" %(cell.getServer(), cell.getState()))
conn = self.cp.getConnForNode(cell) conn = self.cp.getConnForNode(cell)
if conn is None: if conn is None:
continue continue
...@@ -546,7 +549,7 @@ class Application(object): ...@@ -546,7 +549,7 @@ class Application(object):
aborted_node_set = set() aborted_node_set = set()
for oid in self.txn_data_dict.iterkeys(): for oid in self.txn_data_dict.iterkeys():
partition_id = u64(oid) % self.num_partitions partition_id = u64(oid) % self.num_partitions
cell_list = self.pt.getCellList(partition_id) cell_list = self.pt.getCellList(partition_id, True)
for cell in cell_list: for cell in cell_list:
if cell.getNode() not in aborted_node_set: if cell.getNode() not in aborted_node_set:
conn = self.cp.getConnForNode(cell) conn = self.cp.getConnForNode(cell)
...@@ -565,7 +568,7 @@ class Application(object): ...@@ -565,7 +568,7 @@ class Application(object):
# Abort in nodes where transaction was stored # Abort in nodes where transaction was stored
partition_id = u64(self.tid) % self.num_partitions partition_id = u64(self.tid) % self.num_partitions
cell_list = self.pt.getCellList(partition_id) cell_list = self.pt.getCellList(partition_id, True)
for cell in cell_list: for cell in cell_list:
if cell.getNode() not in aborted_node_set: if cell.getNode() not in aborted_node_set:
conn = self.cp.getConnForNode(cell) conn = self.cp.getConnForNode(cell)
......
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