Commit 823c9d7a authored by Grégory Wisniewski's avatar Grégory Wisniewski

Split answers and notifications in client handlers.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@576 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent bed32b02
...@@ -70,7 +70,7 @@ class ConnectionPool(object): ...@@ -70,7 +70,7 @@ class ConnectionPool(object):
while True: while True:
logging.info('trying to connect to %s', node) logging.info('trying to connect to %s', node)
app.setNodeReady() app.setNodeReady()
handler = StorageBootstrapEventHandler(app, app.dispatcher) handler = StorageBootstrapHandler(app, app.dispatcher)
conn = MTClientConnection(app.em, handler, addr, conn = MTClientConnection(app.em, handler, addr,
connector_handler=app.connector_handler) connector_handler=app.connector_handler)
conn.lock() conn.lock()
...@@ -236,8 +236,9 @@ class Application(object): ...@@ -236,8 +236,9 @@ class Application(object):
self.ptid = INVALID_PTID self.ptid = INVALID_PTID
self.num_replicas = 0 self.num_replicas = 0
self.num_partitions = 0 self.num_partitions = 0
self.primary_handler = PrimaryEventHandler(self, self.dispatcher) self.storage_handler = StorageAnswersHandler(self, self.dispatcher)
self.storage_handler = StorageEventHandler(self, self.dispatcher) self.primary_handler = PrimaryAnswersHandler(self, self.dispatcher)
self.notifications_handler = PrimaryNotificationsHandler(self)
# Internal attribute distinct between thread # Internal attribute distinct between thread
self.local_var = ThreadContext() self.local_var = ThreadContext()
# Lock definition : # Lock definition :
...@@ -276,6 +277,9 @@ class Application(object): ...@@ -276,6 +277,9 @@ class Application(object):
"""Wait for a message returned by the dispatcher in queues.""" """Wait for a message returned by the dispatcher in queues."""
local_queue = self.local_var.queue local_queue = self.local_var.queue
if handler is None:
handler = self.notifications_handler
while 1: while 1:
try: try:
if msg_id is None: if msg_id is None:
...@@ -862,7 +866,7 @@ class Application(object): ...@@ -862,7 +866,7 @@ class Application(object):
close = __del__ close = __del__
def sync(self): def sync(self):
self._waitMessage(handler=self.storage_handler) self._waitMessage()
def connectToPrimaryMasterNode(self): def connectToPrimaryMasterNode(self):
self.master_conn = None self.master_conn = None
...@@ -880,7 +884,7 @@ class Application(object): ...@@ -880,7 +884,7 @@ class Application(object):
master_index = 0 master_index = 0
conn = None conn = None
# Make application execute remaining message if any # Make application execute remaining message if any
self._waitMessage(handler=self.storage_handler) self._waitMessage()
while True: while True:
self.setNodeReady() self.setNodeReady()
if self.primary_master_node is None: if self.primary_master_node is None:
...@@ -894,7 +898,7 @@ class Application(object): ...@@ -894,7 +898,7 @@ class Application(object):
else: else:
addr, port = self.primary_master_node.getServer() addr, port = self.primary_master_node.getServer()
# Request Node Identification # Request Node Identification
handler = PrimaryBoostrapEventHandler(self, self.dispatcher) handler = PrimaryBootstrapHandler(self, self.dispatcher)
conn = MTClientConnection(self.em, handler, (addr, port), conn = MTClientConnection(self.em, handler, (addr, port),
connector_handler=self.connector_handler) connector_handler=self.connector_handler)
self._nm_acquire() self._nm_acquire()
...@@ -939,7 +943,7 @@ class Application(object): ...@@ -939,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(PrimaryEventHandler(self, self.dispatcher)) conn.setHandler(PrimaryAnswersHandler(self, self.dispatcher))
self.master_conn = conn self.master_conn = conn
finally: finally:
......
This diff is collapsed.
This diff is collapsed.
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