Commit 18f8d2b3 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Bug fix: Set right default handler on the master connection, must be the handler

responsible of asynchronous packets.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@580 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 56bcd323
...@@ -238,7 +238,7 @@ class Application(object): ...@@ -238,7 +238,7 @@ class Application(object):
self.num_partitions = 0 self.num_partitions = 0
self.storage_handler = StorageAnswersHandler(self, self.dispatcher) self.storage_handler = StorageAnswersHandler(self, self.dispatcher)
self.primary_handler = PrimaryAnswersHandler(self, self.dispatcher) self.primary_handler = PrimaryAnswersHandler(self, self.dispatcher)
self.notifications_handler = PrimaryNotificationsHandler(self) self.notifications_handler = PrimaryNotificationsHandler(self, self.dispatcher)
# Internal attribute distinct between thread # Internal attribute distinct between thread
self.local_var = ThreadContext() self.local_var = ThreadContext()
# Lock definition : # Lock definition :
...@@ -943,7 +943,7 @@ class Application(object): ...@@ -943,7 +943,7 @@ class Application(object):
sleep(1) sleep(1)
logging.info("connected to primary master node %s" % self.primary_master_node) logging.info("connected to primary master node %s" % self.primary_master_node)
conn.setHandler(PrimaryAnswersHandler(self, self.dispatcher)) conn.setHandler(PrimaryNotificationsHandler(self, self.dispatcher))
self.master_conn = conn self.master_conn = conn
finally: finally:
......
...@@ -63,7 +63,7 @@ class BaseHandler(EventHandler): ...@@ -63,7 +63,7 @@ class BaseHandler(EventHandler):
class PrimaryBootstrapHandler(BaseHandler): class PrimaryBootstrapHandler(BaseHandler):
# Bootstrap handler used when looking for the primary master """ Bootstrap handler used when looking for the primary master """
def connectionFailed(self, conn): def connectionFailed(self, conn):
if self.app.primary_master_node is None: if self.app.primary_master_node is None:
...@@ -256,15 +256,9 @@ class PrimaryBootstrapHandler(BaseHandler): ...@@ -256,15 +256,9 @@ class PrimaryBootstrapHandler(BaseHandler):
pt.setCell(offset, node, state) pt.setCell(offset, node, state)
class PrimaryNotificationsHandler(BaseHandler):
class PrimaryNotificationsHandler(EventHandler):
""" Handler that process the notifications from the primary master """ """ Handler that process the notifications from the primary master """
# For notifications we do not need a dispatcher
def __init__(self, app):
self.app = app
EventHandler.__init__(self)
def connectionClosed(self, conn): def connectionClosed(self, conn):
logging.critical("connection to primary master node closed") logging.critical("connection to primary master node closed")
# Close connection # Close connection
...@@ -273,17 +267,17 @@ class PrimaryNotificationsHandler(EventHandler): ...@@ -273,17 +267,17 @@ class PrimaryNotificationsHandler(EventHandler):
app.master_conn = None app.master_conn = None
app.primary_master_node = None app.primary_master_node = None
app.connectToPrimaryMasterNode() app.connectToPrimaryMasterNode()
EventHandler.connectionClosed(self, conn) BaseHandler.connectionClosed(self, conn)
def timeoutExpired(self, conn): def timeoutExpired(self, conn):
logging.critical("connection timeout to primary master node expired") logging.critical("connection timeout to primary master node expired")
self.app.connectToPrimaryMasterNode() self.app.connectToPrimaryMasterNode()
EventHandler.timeoutExpired(self, conn) BaseHandler.timeoutExpired(self, conn)
def peerBroken(self, conn): def peerBroken(self, conn):
logging.critical("primary master node is broken") logging.critical("primary master node is broken")
self.app.connectToPrimaryMasterNode() self.app.connectToPrimaryMasterNode()
EventHandler.peerBroken(self, conn) BaseHandler.peerBroken(self, conn)
def handleStopOperation(self, conn, packet): def handleStopOperation(self, conn, packet):
logging.critical("master node ask to stop operation") logging.critical("master node ask to stop operation")
......
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