bgp: use hub.Event to wait for the core_service boot instead of sleep
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
77a6afa309
commit
e772be8717
@ -37,9 +37,10 @@ def start(**kwargs):
|
||||
raise RuntimeConfigError('Current context has to be stopped to start '
|
||||
'a new context.')
|
||||
|
||||
waiter = kwargs.pop('waiter')
|
||||
common_config = CommonConf(**kwargs)
|
||||
eventlet.spawn(CORE_MANAGER.start, *[], **{'common_conf': common_config})
|
||||
eventlet.sleep(2)
|
||||
eventlet.spawn(CORE_MANAGER.start, *[], **{'common_conf': common_config,
|
||||
'waiter' : waiter})
|
||||
return True
|
||||
|
||||
|
||||
|
@ -20,6 +20,8 @@ import imp
|
||||
import logging
|
||||
import traceback
|
||||
|
||||
from ryu.lib import hub
|
||||
|
||||
from ryu.services.protocols.bgp.api.base import call
|
||||
from ryu.services.protocols.bgp.base import add_bgp_error_metadata
|
||||
from ryu.services.protocols.bgp.base import BGPSException
|
||||
@ -150,11 +152,9 @@ class BaseApplication(object):
|
||||
common_settings[LABEL_RANGE] = label_range
|
||||
|
||||
# Start BGPS core service
|
||||
call('core.start', **common_settings)
|
||||
# Give chance for core to start running
|
||||
|
||||
# TODO(Team): How to wait for core start to happen?!
|
||||
eventlet.sleep(3)
|
||||
waiter = hub.Event()
|
||||
call('core.start', waiter=waiter, **common_settings)
|
||||
waiter.wait()
|
||||
|
||||
LOG.debug('Core started %s' % CORE_MANAGER.started)
|
||||
# Core manager started add configured neighbor and vrfs
|
||||
|
@ -215,6 +215,8 @@ class CoreService(Factory, Activity):
|
||||
# Reactively establish bgp-session with peer by listening on
|
||||
# server port for connection requests.
|
||||
server_addr = (CORE_IP, self._common_config.bgp_server_port)
|
||||
waiter = kwargs.pop('waiter')
|
||||
waiter.set()
|
||||
server_thread = self._listen_tcp(server_addr, self.start_protocol)
|
||||
|
||||
server_thread.wait()
|
||||
|
@ -41,7 +41,8 @@ class _CoreManager(Activity):
|
||||
self._core_service = CoreService(self._common_conf,
|
||||
self._neighbors_conf,
|
||||
self._vrfs_conf)
|
||||
core_activity = self._spawn_activity(self._core_service)
|
||||
waiter = kwargs.pop('waiter')
|
||||
core_activity = self._spawn_activity(self._core_service, waiter=waiter)
|
||||
core_activity.wait()
|
||||
|
||||
def get_core_service(self):
|
||||
|
Loading…
Reference in New Issue
Block a user