From c5f970c9cf43f17bb70fef7723ff094f8c19845d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gr=C3=A9gory=20Wisniewski?= <gregory@nexedi.com>
Date: Thu, 28 Jan 2010 16:51:56 +0000
Subject: [PATCH] Rename packet NO_ERROR error packet type to ACK as it's
 confusing.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1538 71dcc9de-d417-0410-9af5-da40c76e7ee4
---
 neo/admin/handler.py                  |  6 +++---
 neo/handler.py                        |  4 ++--
 neo/master/handlers/administration.py | 12 ++++++------
 neo/neoctl/handler.py                 |  4 ++--
 neo/neoctl/neoctl.py                  |  6 +++---
 neo/protocol.py                       |  6 +++---
 6 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/neo/admin/handler.py b/neo/admin/handler.py
index b507b48d..95618563 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 8dffd401..ebc1920d 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 5fe54311..e4116084 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 50402c8c..af14fb1c 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 b4738d61..b65ec19f 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 4e0174cd..38993433 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)
-- 
2.30.9