Commit 8bee3858 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Save listenning connection reference in a class variable. Open the listening

socket after the primary master connection succeed, because we don't want to any
incoming connections during bootstrap stage.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@729 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 254243f5
...@@ -68,6 +68,7 @@ class Application(object): ...@@ -68,6 +68,7 @@ class Application(object):
self.primary_master_node = None self.primary_master_node = None
self.replicator = None self.replicator = None
self.listening_conn = None
self.dm.setup(reset) self.dm.setup(reset)
self.loadConfiguration() self.loadConfiguration()
...@@ -128,18 +129,22 @@ class Application(object): ...@@ -128,18 +129,22 @@ class Application(object):
for server in self.master_node_list: for server in self.master_node_list:
self.nm.add(MasterNode(server = server)) self.nm.add(MasterNode(server = server))
# Make a listening port.
ListeningConnection(self.em, None, addr = self.server,
connector_handler = self.connector_handler)
# Connect to a primary master node, verify data, and # Connect to a primary master node, verify data, and
# start the operation. This cycle will be executed permentnly, # start the operation. This cycle will be executed permentnly,
# until the user explicitly requests a shutdown. # until the user explicitly requests a shutdown.
while 1: while 1:
self.operational = False self.operational = False
# refuse any incoming connections for now
if self.listening_conn is not None:
self.listening_conn.close()
self.listening_conn = None
# look for the primary master
self.connectToPrimaryMaster() self.connectToPrimaryMaster()
if self.uuid == INVALID_UUID: if self.uuid == INVALID_UUID:
raise RuntimeError, 'No UUID supplied from the primary master' raise RuntimeError, 'No UUID supplied from the primary master'
# Make a listening port when connected to the primary
self.listening_conn = ListeningConnection(self.em, None,
addr=self.server, connector_handler=self.connector_handler)
try: try:
while 1: while 1:
try: try:
...@@ -175,7 +180,8 @@ class Application(object): ...@@ -175,7 +180,8 @@ class Application(object):
self.loadPartitionTable() self.loadPartitionTable()
self.ptid = self.dm.getPTID() self.ptid = self.dm.getPTID()
handler = BootstrapEventHandler(self) # bootstrap handler, only for outgoing connections
handler BootstrapEventHandler(self)
em = self.em em = self.em
nm = self.nm nm = self.nm
...@@ -184,10 +190,6 @@ class Application(object): ...@@ -184,10 +190,6 @@ class Application(object):
if not isinstance(conn, ListeningConnection): if not isinstance(conn, ListeningConnection):
conn.close() conn.close()
# Make sure that every connection has the boostrap event handler.
for conn in em.getConnectionList():
conn.setHandler(handler)
index = 0 index = 0
self.trying_master_node = None self.trying_master_node = None
t = 0 t = 0
......
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