def synch_topologies(self):
self.state_managers = statemanagerfactory.get_all_state_managers(self.config.statemgr_config)<EOL>try:<EOL><INDENT>for state_manager in self.state_managers:<EOL><INDENT>state_manager.start()<EOL><DEDENT><DEDENT>except Exception as ex:<EOL><INDENT>Log.error("<STR_LIT>" % ex)<EOL>traceback.print_exc()<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>def on_topologies_watch(state_manager, topologies):<EOL><INDENT>"""<STR_LIT>"""<EOL>Log.info("<STR_LIT>")<EOL>Log.debug("<STR_LIT>" + str(topologies))<EOL>existingTopologies = self.getTopologiesForStateLocation(state_manager.name)<EOL>existingTopNames = map(lambda t: t.name, existingTopologies)<EOL>Log.debug("<STR_LIT>" + str(existingTopNames))<EOL>for name in existingTopNames:<EOL><INDENT>if name not in topologies:<EOL><INDENT>Log.info("<STR_LIT>",<EOL>name, state_manager.rootpath)<EOL>self.removeTopology(name, state_manager.name)<EOL><DEDENT><DEDENT>for name in topologies:<EOL><INDENT>if name not in existingTopNames:<EOL><INDENT>self.addNewTopology(state_manager, name)<EOL><DEDENT><DEDENT><DEDENT>for state_manager in self.state_managers:<EOL><INDENT>onTopologiesWatch = partial(on_topologies_watch, state_manager)<EOL>state_manager.get_topologies(onTopologiesWatch)<EOL><DEDENT>
Sync the topologies with the statemgrs.