Commit 57f8d9ab authored by Vincent Pelletier's avatar Vincent Pelletier

It has no meaning to require to send cluster name when changing it state: a...

It has no meaning to require to send cluster name when changing it state: a connection can be made to only one cluster at a time, and cluster name coherency is checked upon initial handshake.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@1013 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 3612e024
...@@ -81,11 +81,10 @@ class AdminEventHandler(EventHandler): ...@@ -81,11 +81,10 @@ class AdminEventHandler(EventHandler):
msg_id = master_conn.ask(p) msg_id = master_conn.ask(p)
self.app.dispatcher.register(msg_id, conn, {'msg_id' : packet.getId()}) self.app.dispatcher.register(msg_id, conn, {'msg_id' : packet.getId()})
def handleSetClusterState(self, conn, packet, name, state): def handleSetClusterState(self, conn, packet, state):
self.checkClusterName(name)
# forward to primary # forward to primary
master_conn = self.app.master_conn master_conn = self.app.master_conn
p = protocol.setClusterState(name, state) p = protocol.setClusterState(state)
msg_id = master_conn.ask(p) msg_id = master_conn.ask(p)
self.app.dispatcher.register(msg_id, conn, {'msg_id' : packet.getId()}) self.app.dispatcher.register(msg_id, conn, {'msg_id' : packet.getId()})
......
...@@ -351,7 +351,7 @@ class EventHandler(object): ...@@ -351,7 +351,7 @@ class EventHandler(object):
def handleAnswerClusterState(self, conn, packet, state): def handleAnswerClusterState(self, conn, packet, state):
raise UnexpectedPacketError raise UnexpectedPacketError
def handleSetClusterState(self, conn, packet, name, state): def handleSetClusterState(self, conn, packet, state):
raise UnexpectedPacketError raise UnexpectedPacketError
def handleNotifyClusterInformation(self, conn, packet, state): def handleNotifyClusterInformation(self, conn, packet, state):
......
...@@ -34,8 +34,7 @@ class AdministrationHandler(MasterHandler): ...@@ -34,8 +34,7 @@ class AdministrationHandler(MasterHandler):
# I'm the primary # I'm the primary
conn.answer(protocol.answerPrimaryMaster(app.uuid, []), packet) conn.answer(protocol.answerPrimaryMaster(app.uuid, []), packet)
def handleSetClusterState(self, conn, packet, name, state): def handleSetClusterState(self, conn, packet, state):
self.checkClusterName(name)
self.app.changeClusterState(state) self.app.changeClusterState(state)
p = protocol.noError('cluster state changed') p = protocol.noError('cluster state changed')
conn.answer(p, packet) conn.answer(p, packet)
......
...@@ -1069,9 +1069,8 @@ decode_table[ANSWER_CLUSTER_STATE] = _decodeAnswerClusterState ...@@ -1069,9 +1069,8 @@ decode_table[ANSWER_CLUSTER_STATE] = _decodeAnswerClusterState
@handle_errors @handle_errors
def _decodeSetClusterState(body): def _decodeSetClusterState(body):
(state, ) = unpack('!H', body[:2]) (state, ) = unpack('!H', body[:2])
(name, _) = _readString(body, 'name', offset=2)
state = _decodeClusterState(state) state = _decodeClusterState(state)
return (name, state) return (state, )
decode_table[SET_CLUSTER_STATE] = _decodeSetClusterState decode_table[SET_CLUSTER_STATE] = _decodeSetClusterState
@handle_errors @handle_errors
...@@ -1438,9 +1437,8 @@ def answerClusterState(state): ...@@ -1438,9 +1437,8 @@ def answerClusterState(state):
body = pack('!H', state) body = pack('!H', state)
return Packet(ANSWER_CLUSTER_STATE, body) return Packet(ANSWER_CLUSTER_STATE, body)
def setClusterState(name, state): def setClusterState(state):
body = [pack('!HL', state, len(name)), name] body = pack('!H', state)
body = ''.join(body)
return Packet(SET_CLUSTER_STATE, body) return Packet(SET_CLUSTER_STATE, body)
def notifyClusterInformation(state): def notifyClusterInformation(state):
......
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