diff --git a/neo/admin/handler.py b/neo/admin/handler.py index b507b48d20a54f1d8b83ab425d587aaf9ebf58f2..956185638dd42b7b3bf5a7472132c9e300d877d9 100644 --- a/neo/admin/handler.py +++ b/neo/admin/handler.py @@ -63,7 +63,7 @@ class AdminEventHandler(EventHandler): raise protocol.ProtocolError('invalid uuid') if node.getState() == state and modify_partition_table is False: # no change - p = protocol.noError('no change') + p = protocol.ack('no change') conn.answer(p, packet.getId()) return # forward to primary master node @@ -216,8 +216,8 @@ class MasterRequestEventHandler(EventHandler): self.__answerNeoCTL(packet.getId(), Packets.AnswerNodeState(uuid, state)) - def noError(self, conn, packet, msg): - self.__answerNeoCTL(packet.getId(), protocol.noError(msg)) + def ack(self, conn, packet, msg): + self.__answerNeoCTL(packet.getId(), protocol.ack(msg)) def protocolError(self, conn, packet, msg): self.__answerNeoCTL(packet.getId(), protocol.protocolError(msg)) diff --git a/neo/handler.py b/neo/handler.py index 8dffd4014831e24d55275e0f4ece0b25756f0ac2..ebc1920da32110f2466c64496de4eefb805e22ff 100644 --- a/neo/handler.py +++ b/neo/handler.py @@ -363,7 +363,7 @@ class EventHandler(object): def brokenNodeDisallowedError(self, conn, packet, message): raise RuntimeError, 'broken node disallowed error: %s' % (message,) - def noError(self, conn, packet, message): + def ack(self, conn, packet, message): logging.debug("no error message : %s" % (message)) @@ -443,7 +443,7 @@ class EventHandler(object): def __initErrorDispatchTable(self): d = {} - d[ErrorCodes.NO_ERROR] = self.noError + d[ErrorCodes.ACK] = self.ack d[ErrorCodes.NOT_READY] = self.notReady d[ErrorCodes.OID_NOT_FOUND] = self.oidNotFound d[ErrorCodes.TID_NOT_FOUND] = self.tidNotFound diff --git a/neo/master/handlers/administration.py b/neo/master/handlers/administration.py index 5fe54311f30e82d7bebfc1688252319728fb92a9..e4116084bb43539150f986cdec7d967c05e27385 100644 --- a/neo/master/handlers/administration.py +++ b/neo/master/handlers/administration.py @@ -36,7 +36,7 @@ class AdministrationHandler(MasterHandler): def setClusterState(self, conn, packet, state): self.app.changeClusterState(state) - p = protocol.noError('cluster state changed') + p = protocol.ack('cluster state changed') conn.answer(p, packet.getId()) if state == ClusterStates.STOPPING: self.app.cluster_state = state @@ -54,13 +54,13 @@ class AdministrationHandler(MasterHandler): node.setState(state) # get message for self if state != NodeStates.RUNNING: - p = protocol.noError('node state changed') + p = protocol.ack('node state changed') conn.answer(p, packet.getId()) app.shutdown() if node.getState() == state: # no change, just notify admin node - p = protocol.noError('node state changed') + p = protocol.ack('node state changed') conn.answer(p, packet.getId()) return @@ -87,7 +87,7 @@ class AdministrationHandler(MasterHandler): # /!\ send the node information *after* the partition table change node.setState(state) - p = protocol.noError('state changed') + p = protocol.ack('state changed') conn.answer(p, packet.getId()) app.broadcastNodesInformation([node]) @@ -107,7 +107,7 @@ class AdministrationHandler(MasterHandler): # nothing to do if not uuid_set: logging.warning('No nodes added') - p = protocol.noError('no nodes added') + p = protocol.ack('no nodes added') conn.answer(p, packet.getId()) return uuids = ', '.join([dump(uuid) for uuid in uuid_set]) @@ -126,5 +126,5 @@ class AdministrationHandler(MasterHandler): s_conn.notify(Packets.StartOperation()) # broadcast the new partition table app.broadcastPartitionChanges(cell_list) - p = protocol.noError('node added') + p = protocol.ack('node added') conn.answer(p, packet.getId()) diff --git a/neo/neoctl/handler.py b/neo/neoctl/handler.py index 50402c8c1c4c490c6d9711e7407447e58f5c8b1e..af14fb1c5fb413edd6801464cbc8f7a70c7f2af8 100644 --- a/neo/neoctl/handler.py +++ b/neo/neoctl/handler.py @@ -53,8 +53,8 @@ class CommandEventHandler(EventHandler): def __answer(self, conn, packet, *args): self.__respond((packet.getType(), ) + args) - def noError(self, conn, packet, msg): - self.__respond((packet.getType(), ErrorCodes.NO_ERROR, msg)) + def ack(self, conn, packet, msg): + self.__respond((packet.getType(), ErrorCodes.ACK, msg)) def notReady(self, conn, packet, msg): self.__respond((packet.getType(), ErrorCodes.NOT_READY, msg)) diff --git a/neo/neoctl/neoctl.py b/neo/neoctl/neoctl.py index b4738d6133352e89ad0464625caae44945bcd52d..b65ec19f5b7e2cb81b96978fa7e7cae6ebcf0253 100644 --- a/neo/neoctl/neoctl.py +++ b/neo/neoctl/neoctl.py @@ -70,7 +70,7 @@ class NeoCTL(object): packet = Packets.AddPendingNodes(uuid_list) response = self.__ask(packet) assert response[0] == Packets.Error - assert response[1] == ErrorCodes.NO_ERROR + assert response[1] == ErrorCodes.ACK def setClusterState(self, state): """ @@ -79,7 +79,7 @@ class NeoCTL(object): packet = Packets.SetClusterState(state) response = self.__ask(packet) assert response[0] == Packets.Error - assert response[1] == ErrorCodes.NO_ERROR + assert response[1] == ErrorCodes.ACK def setNodeState(self, node, state, update_partition_table=False): """ @@ -92,7 +92,7 @@ class NeoCTL(object): packet = Packets.SetNodeState(node, state, update_partition_table) response = self.__ask(packet) assert response[0] == Packets.Error - assert response[1] == ErrorCodes.NO_ERROR + assert response[1] == ErrorCodes.ACK def getClusterState(self): """ diff --git a/neo/protocol.py b/neo/protocol.py index 4e0174cdf64e1aae36913d1758fbe8c176f869df..3899343342eea3aa469c04970a4d05112aed0eb3 100644 --- a/neo/protocol.py +++ b/neo/protocol.py @@ -29,7 +29,7 @@ MAX_PACKET_SIZE = 0x4000000 PACKET_HEADER_SIZE = 10 class ErrorCodes(Enum): - NO_ERROR = Enum.Item(0) + ACK = Enum.Item(0) NOT_READY = Enum.Item(1) OID_NOT_FOUND = Enum.Item(2) TID_NOT_FOUND = Enum.Item(3) @@ -1337,8 +1337,8 @@ Packets = PacketRegistry() def _error(error_code, error_message): return Error(error_code, error_message) -def noError(message): - return _error(ErrorCodes.NO_ERROR, message) +def ack(message): + return _error(ErrorCodes.ACK, message) def protocolError(error_message): return _error(ErrorCodes.PROTOCOL_ERROR, 'protocol error: ' + error_message)