Commit c5f970c9 authored by Grégory Wisniewski's avatar Grégory Wisniewski

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