diff --git a/neo/client/app.py b/neo/client/app.py index 2958303df3b779aabea08628790732ec2052529f..7328226457a144faf9516d1a6c954f116e967f42 100644 --- a/neo/client/app.py +++ b/neo/client/app.py @@ -228,7 +228,7 @@ class Application(ThreadedApplication): node=node, dispatcher=self.dispatcher) p = Packets.RequestIdentification(NodeTypes.CLIENT, - self.uuid, None, self.name, None, (), ()) + self.uuid, None, self.name, None, {}) try: ask(conn, p, handler=handler) except ConnectionClosed: @@ -270,7 +270,7 @@ class Application(ThreadedApplication): conn = MTClientConnection(self, self.storage_event_handler, node, dispatcher=self.dispatcher) p = Packets.RequestIdentification(NodeTypes.CLIENT, - self.uuid, None, self.name, self.id_timestamp, (), ()) + self.uuid, None, self.name, self.id_timestamp, {}) try: self._ask(conn, p, handler=self.storage_bootstrap_handler) except ConnectionClosed: diff --git a/neo/lib/bootstrap.py b/neo/lib/bootstrap.py index 2001b0cbdc2335c19c9fad98a490dd8ab86d6d2a..1e5f1dc41d0a6d728a2683e407ca28876a131014 100644 --- a/neo/lib/bootstrap.py +++ b/neo/lib/bootstrap.py @@ -26,15 +26,14 @@ class BootstrapManager(EventHandler): Manage the bootstrap stage, lookup for the primary master then connect to it """ - def __init__(self, app, node_type, server=None, devpath=(), new_nid=()): + def __init__(self, app, node_type, server=None, **extra): """ Manage the bootstrap stage of a non-master node, it lookup for the primary master node, connect to it then returns when the master node is ready. """ self.server = server - self.devpath = devpath - self.new_nid = new_nid + self.extra = extra self.node_type = node_type app.nm.reset() @@ -43,7 +42,7 @@ class BootstrapManager(EventHandler): def connectionCompleted(self, conn): EventHandler.connectionCompleted(self, conn) conn.ask(Packets.RequestIdentification(self.node_type, self.uuid, - self.server, self.app.name, None, self.devpath, self.new_nid)) + self.server, self.app.name, None, self.extra)) def connectionFailed(self, conn): EventHandler.connectionFailed(self, conn) diff --git a/neo/lib/node.py b/neo/lib/node.py index 21393ee47993752a9d0597479d1d1c059b01ccdc..44e46c582ee4b3d83c0c0be9e33d8a92ad723804 100644 --- a/neo/lib/node.py +++ b/neo/lib/node.py @@ -28,7 +28,7 @@ class Node(object): _connection = None _identified = False - devpath = () + extra = {} id_timestamp = None def __init__(self, manager, address=None, uuid=None, state=NodeStates.DOWN): diff --git a/neo/master/handlers/identification.py b/neo/master/handlers/identification.py index 8b0ed8913faad6f30ad3a2bc0d04f290dd1d48f8..777799ebd14fdfb7d16c78bef699103bece83279 100644 --- a/neo/master/handlers/identification.py +++ b/neo/master/handlers/identification.py @@ -24,7 +24,7 @@ from ..app import monotonic_time class IdentificationHandler(EventHandler): def requestIdentification(self, conn, node_type, uuid, - address, name, id_timestamp, devpath, new_nid): + address, name, id_timestamp, extra): app = self.app self.checkClusterName(name) if address == app.server: @@ -60,6 +60,7 @@ class IdentificationHandler(EventHandler): # cloned/evil/buggy node connecting to us raise ProtocolError('already connected') + new_nid = extra.pop('new_nid', None) state = NodeStates.RUNNING if node_type == NodeTypes.CLIENT: if app.cluster_state == ClusterStates.RUNNING: @@ -111,8 +112,7 @@ class IdentificationHandler(EventHandler): uuid=uuid, address=address) else: node.setUUID(uuid) - if devpath: - node.devpath = tuple(devpath) + node.extra = extra node.id_timestamp = monotonic_time() node.setState(state) app.broadcastNodesInformation([node]) @@ -135,7 +135,7 @@ class IdentificationHandler(EventHandler): class SecondaryIdentificationHandler(EventHandler): def requestIdentification(self, conn, node_type, uuid, - address, name, id_timestamp, devpath, new_nid): + address, name, id_timestamp, extra): app = self.app self.checkClusterName(name) if address == app.server: diff --git a/neo/master/handlers/master.py b/neo/master/handlers/master.py index 76077b94470d554a12d8f30936c4a6998990af55..16c82e93dc474b6a7c16b0905e47e84b146d6261 100644 --- a/neo/master/handlers/master.py +++ b/neo/master/handlers/master.py @@ -40,7 +40,7 @@ class ElectionHandler(SecondaryHandler): super(ElectionHandler, self).connectionCompleted(conn) app = self.app conn.ask(Packets.RequestIdentification(NodeTypes.MASTER, - app.uuid, app.server, app.name, app.election, (), ())) + app.uuid, app.server, app.name, app.election, {})) def connectionFailed(self, conn): super(ElectionHandler, self).connectionFailed(conn) diff --git a/neo/master/pt.py b/neo/master/pt.py index 56fe4f206e6b26d10abc099c3d99c8ffc61cb089..8fdf592903240c57cf27ab9531c221f5d271332a 100644 --- a/neo/master/pt.py +++ b/neo/master/pt.py @@ -250,7 +250,7 @@ class PartitionTable(neo.lib.pt.PartitionTable): devpath_max = [] devpaths = [()] * node_count if repeats > 1: - _devpaths = [x[0].devpath for x in node_list] + _devpaths = [x[0].extra.get('devpath', ()) for x in node_list] max_depth = min(map(len, _devpaths)) depth = 0 while 1: diff --git a/neo/storage/app.py b/neo/storage/app.py index fee7058d019db41e22e44f61974cc7811ed1871f..fb5725adce125cb738fd43014241a411ef423c6e 100644 --- a/neo/storage/app.py +++ b/neo/storage/app.py @@ -252,7 +252,7 @@ class Application(BaseApplication): # search, find, connect and identify to the primary master bootstrap = BootstrapManager(self, NodeTypes.STORAGE, None if self.new_nid else self.server, - self.devpath, self.new_nid) + devpath=self.devpath, new_nid=self.new_nid) self.master_node, self.master_conn = bootstrap.getPrimaryConnection() self.dm.setUUID(self.uuid) diff --git a/neo/storage/checker.py b/neo/storage/checker.py index 2876ecf313a6109d433f26d685be8d0dae264dbc..45b7b10830ce6516b368212262761ce5f408db91 100644 --- a/neo/storage/checker.py +++ b/neo/storage/checker.py @@ -51,7 +51,7 @@ class Checker(object): else: conn = ClientConnection(app, StorageOperationHandler(app), node) conn.ask(Packets.RequestIdentification(NodeTypes.STORAGE, - uuid, app.server, name, app.id_timestamp, (), ())) + uuid, app.server, name, app.id_timestamp, {})) self.conn_dict[conn] = node.isIdentified() conn_set = set(self.conn_dict) conn_set.discard(None) diff --git a/neo/storage/handlers/identification.py b/neo/storage/handlers/identification.py index f7bf8e2fb502f579ba2105ffcc9a568c911cbbf9..1300f2634142998e8a89b5d773415d33eb581042 100644 --- a/neo/storage/handlers/identification.py +++ b/neo/storage/handlers/identification.py @@ -32,7 +32,7 @@ class IdentificationHandler(EventHandler): return self.app.nm def requestIdentification(self, conn, node_type, uuid, address, name, - id_timestamp, devpath, new_nid): + id_timestamp, extra): self.checkClusterName(name) app = self.app # reject any incoming connections if not ready diff --git a/neo/storage/replicator.py b/neo/storage/replicator.py index dbe62eca519bbc70275277d6e0a50a08a2d860c6..813b75d61a59e413cad7126f3f4a8abea5b14216 100644 --- a/neo/storage/replicator.py +++ b/neo/storage/replicator.py @@ -350,7 +350,7 @@ class Replicator(object): try: conn.ask(Packets.RequestIdentification(NodeTypes.STORAGE, None if name else app.uuid, app.server, name or app.name, - app.id_timestamp, (), ())) + app.id_timestamp, {})) except ConnectionClosed: if previous_node is self.current_node: return diff --git a/neo/tests/master/testMasterPT.py b/neo/tests/master/testMasterPT.py index ed970e6a09bbbdf3a2b750e793332988cfcc9d28..5b2b914db1035b6e8dee81816ff8cbf06635d6e2 100644 --- a/neo/tests/master/testMasterPT.py +++ b/neo/tests/master/testMasterPT.py @@ -325,7 +325,7 @@ class MasterPartitionTableTests(NeoUnitTestBase): pt.make(sn) pt.log() for i, s in enumerate(sn, sn_count): - s.devpath = tuple(bin(i)[3:-1]) + s.extra = {'devpath': tuple(bin(i)[3:-1])} self.assertEqual(Counter(x[2] for x in self.tweak(pt)), { CellStates.OUT_OF_DATE: 96, CellStates.FEEDING: 96, @@ -360,12 +360,12 @@ class MasterPartitionTableTests(NeoUnitTestBase): assert len(topo) <= sn_count sn2 = sn[:len(topo)] for s in sn2: - s.devpath = () + s.extra = {} k = (1,7)[even] pt = PartitionTable(np*k, i) pt.make(sn2) for devpath, s in zip(topo, sn2): - s.devpath = tuple(devpath) + s.extra = {'devpath': tuple(devpath)} if type(expected) is tuple: self.assertTrue(self.tweak(pt)) self.update(pt) diff --git a/neo/tests/protocol b/neo/tests/protocol index 9025801373a4fa866c89f1ae41d48479fb4f7e48..f0becfa0d5ebc15efdc76f77754fbe4ea7bfbb93 100644 --- a/neo/tests/protocol +++ b/neo/tests/protocol @@ -89,7 +89,7 @@ Ping() Pong() Repair([int],bool) Replicate(p64,bin,{int:?(bin,int)}) -RequestIdentification(NodeTypes,?int,?(bin,int),bin,?float,any,[int]) +RequestIdentification(NodeTypes,?int,?(bin,int),bin,?float,{bin:any}) SendPartitionTable(?int,int,[[(int,CellStates)]]) SetClusterState(ClusterStates) SetNodeState(int,NodeStates)