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):
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))
......
......@@ -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
......
......@@ -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())
......@@ -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))
......
......@@ -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):
"""
......
......@@ -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)
......
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