Commit ad81d3fd authored by Julien Muchembled's avatar Julien Muchembled

Some code cleanup

parent 20964f4f
......@@ -330,7 +330,6 @@ class Application(object):
neo.lib.logging.error('Connection to %s lost',
self.trying_master_node)
self.primary_master_node = None
continue
neo.lib.logging.info("Connected and ready")
return conn
......
......@@ -143,8 +143,7 @@ class EpollEventManager(object):
try:
conn = self.connection_dict[fd]
except KeyError:
pass
else:
continue
conn.lock()
try:
conn.writable()
......@@ -157,8 +156,7 @@ class EpollEventManager(object):
try:
conn = self.connection_dict[fd]
except KeyError:
pass
else:
continue
conn.lock()
try:
conn.readable()
......
......@@ -55,7 +55,7 @@ class Application(object):
self.storage_readiness = set()
master_addresses, connector_name = config.getMasters()
self.connector_handler = getConnectorHandler(connector_name)
for master_address in master_addresses :
for master_address in master_addresses:
self.nm.createMaster(address=master_address)
neo.lib.logging.debug('IP address is %s, port is %d', *(self.server))
......
......@@ -140,7 +140,6 @@ class PartitionTable(PartitionTable):
# update the partition table
cell_list = [self.setCell(offset, node, CellStates.UP_TO_DATE)]
cell_list = [(offset, uuid, CellStates.UP_TO_DATE)]
# If the partition contains a feeding cell, drop it now.
for feeding_cell in self.getCellList(offset):
......
......@@ -357,7 +357,7 @@ class TransactionManager(object):
# will be finished
for txn in self._ttid_dict.itervalues():
txn.registerForNotification(uuid)
return set(self._ttid_dict)
return self._ttid_dict.keys()
def begin(self, node, tid=None):
"""
......
......@@ -70,7 +70,7 @@ class testTransactionManager(NeoUnitTestBase):
callback = Mock()
txnman = TransactionManager(on_commit=callback)
self.assertFalse(txnman.hasPending())
self.assertEqual(txnman.registerForNotification(uuid1), set())
self.assertEqual(txnman.registerForNotification(uuid1), [])
# begin the transaction
ttid = txnman.begin(node)
self.assertTrue(ttid is not None)
......@@ -79,7 +79,7 @@ class testTransactionManager(NeoUnitTestBase):
# prepare the transaction
tid = txnman.prepare(ttid, 1, oid_list, uuid_list, msg_id)
self.assertTrue(txnman.hasPending())
self.assertEqual(txnman.registerForNotification(uuid1), set([ttid]))
self.assertEqual(txnman.registerForNotification(uuid1), [ttid])
txn = txnman[ttid]
self.assertEqual(txn.getTID(), tid)
self.assertEqual(txn.getUUIDList(), list(uuid_list))
......@@ -91,7 +91,7 @@ class testTransactionManager(NeoUnitTestBase):
self.assertEqual(len(callback.getNamedCalls('__call__')), 1)
# transaction finished
txnman.remove(client_uuid, ttid)
self.assertEqual(txnman.registerForNotification(uuid1), set())
self.assertEqual(txnman.registerForNotification(uuid1), [])
def testAbortFor(self):
oid_list = [self.makeOID(1), ]
......@@ -100,18 +100,18 @@ class testTransactionManager(NeoUnitTestBase):
client_uuid, client = self.makeNode(3)
txnman = TransactionManager(lambda tid, txn: None)
# register 4 transactions made by two nodes
self.assertEqual(txnman.registerForNotification(storage_1_uuid), set())
self.assertEqual(txnman.registerForNotification(storage_1_uuid), [])
ttid1 = txnman.begin(client)
tid1 = txnman.prepare(ttid1, 1, oid_list, [storage_1_uuid], 1)
self.assertEqual(txnman.registerForNotification(storage_1_uuid), set([ttid1]))
self.assertEqual(txnman.registerForNotification(storage_1_uuid), [ttid1])
# abort transactions of another node, transaction stays
txnman.abortFor(node2)
self.assertEqual(txnman.registerForNotification(storage_1_uuid), set([ttid1]))
self.assertEqual(txnman.registerForNotification(storage_1_uuid), [ttid1])
# abort transactions of requesting node, transaction is not removed
# because the transaction is prepared and must remains until the end of
# the 2PC
txnman.abortFor(node1)
self.assertEqual(txnman.registerForNotification(storage_1_uuid), set([ttid1]))
self.assertEqual(txnman.registerForNotification(storage_1_uuid), [ttid1])
self.assertTrue(txnman.hasPending())
# ...and the lock is available
txnman.begin(client, self.getNextTID())
......
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