Commit c225ee37 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Erase database content when the node is asked to switch in DOWN_STATE.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@1261 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 7921bd2f
......@@ -296,9 +296,11 @@ class Application(object):
some_callable, args, kwargs = p()
some_callable(*args, **kwargs)
def shutdown(self):
def shutdown(self, erase=False):
"""Close all connections and exit"""
for c in self.em.getConnectionList():
if not c.isListening():
c.close()
# clear database to avoid polluting the cluster at restart
self.dm.setup(reset=True)
sys.exit("Application has been asked to shut down")
......@@ -55,7 +55,8 @@ class BaseMasterHandler(BaseStorageHandler):
logging.info("I was told I'm %s" %(state))
if state in (DOWN_STATE, TEMPORARILY_DOWN_STATE, BROKEN_STATE):
conn.close()
self.app.shutdown()
erase = state == DOWN_STATE
self.app.shutdown(erase=erase)
elif state == HIDDEN_STATE:
raise OperationFailure
......
......@@ -39,7 +39,8 @@ class HiddenHandler(BaseMasterHandler):
# This is me, do what the master tell me
if state in (DOWN_STATE, TEMPORARILY_DOWN_STATE, BROKEN_STATE):
conn.close()
self.app.shutdown()
erase_db = state == DOWN_STATE
self.app.shutdown(erase=erase_db)
def handleRequestNodeIdentification(self, conn, packet, node_type,
uuid, address, name):
......
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