Commit 7ab14ef7 authored by Vincent Pelletier's avatar Vincent Pelletier

Automatically set UUID on connection when setting it on node.

parent 88d76044
......@@ -43,9 +43,7 @@ class PrimaryBootstrapHandler(AnswerBaseHandler):
app.uuid = your_uuid
neo.lib.logging.info('Got an UUID: %s', dump(app.uuid))
node = app.nm.getByAddress(conn.getAddress())
conn.setUUID(uuid)
node.setUUID(uuid)
app.nm.getByAddress(conn.getAddress()).setUUID(uuid)
# Always create partition table
app.pt = PartitionTable(num_partitions, num_replicas)
......
......@@ -57,7 +57,6 @@ class StorageBootstrapHandler(AnswerBaseHandler):
node = self.app.nm.getByAddress(conn.getAddress())
assert node is not None, conn.getAddress()
conn.setUUID(uuid)
node.setUUID(uuid)
assert node.getConnection() is conn, (node.getConnection(), conn)
......
......@@ -119,7 +119,6 @@ class BootstrapManager(EventHandler):
# got an uuid from the primary master
self.uuid = your_uuid
neo.lib.logging.info('Got a new UUID : %s' % dump(self.uuid))
conn.setUUID(uuid)
self.accepted = True
def getPrimaryConnection(self, connector_handler):
......
......@@ -86,6 +86,8 @@ class Node(object):
self._uuid = uuid
self._manager._updateUUID(self, old_uuid)
self._manager._updateIdentified(self)
if self._connection is not None:
self._connection.setUUID(uuid)
def getUUID(self):
return self._uuid
......@@ -104,6 +106,8 @@ class Node(object):
"""
assert connection is not None
assert self._connection is None, attributeTracker.whoSet(self, '_connection')
assert connection.getUUID() in (None, self._uuid), connection
connection.setUUID(self._uuid)
self._connection = connection
connection.setOnClose(self.onConnectionClosed)
self._manager._updateIdentified(self)
......
......@@ -59,7 +59,6 @@ class IdentificationHandler(MasterHandler):
node.setState(state)
node.setConnection(conn)
# set up the connection
conn.setUUID(uuid)
conn.setHandler(handler)
# answer
args = (NodeTypes.MASTER, app.uuid, app.pt.getPartitions(),
......
......@@ -94,8 +94,6 @@ class ReplicationHandler(EventHandler):
def acceptIdentification(self, conn, node_type,
uuid, num_partitions, num_replicas, your_uuid):
# set the UUID on the connection
conn.setUUID(uuid)
self.startReplication(conn)
def startReplication(self, conn):
......
......@@ -78,7 +78,6 @@ class MasterBootstrapHandlerTests(MasterHandlerTests):
self.handler.acceptIdentification(conn, NodeTypes.MASTER, uuid,
partitions, replicas, your_uuid)
self.assertEqual(self.app.uuid, your_uuid)
self.checkUUIDSet(conn, uuid)
self.checkUUIDSet(node, uuid)
self.assertTrue(isinstance(self.app.pt, PartitionTable))
......
......@@ -62,7 +62,6 @@ class StorageBootstrapHandlerTests(NeoUnitTestBase):
self.handler.acceptIdentification(conn, NodeTypes.STORAGE, uuid,
10, 0, None)
self.checkUUIDSet(node, uuid)
self.checkUUIDSet(conn, uuid)
class StorageAnswerHandlerTests(NeoUnitTestBase):
......
......@@ -89,7 +89,6 @@ class StorageIdentificationHandlerTests(NeoUnitTestBase):
self.assertTrue(node.isConnected())
self.assertEqual(node.getUUID(), uuid)
self.assertTrue(node.getConnection() is conn)
self.checkUUIDSet(conn, uuid)
args = self.checkAcceptIdentification(conn, decode=True)
node_type, address, _np, _nr, _uuid = args
self.assertEqual(node_type, NodeTypes.STORAGE)
......
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