From 7add7643e32bd506062095cc83d1c96086d2e45a Mon Sep 17 00:00:00 2001 From: anthony Date: Tue, 11 Jan 2011 18:58:20 -0800 Subject: [PATCH] bug 7748: need to make sure domr is up before start user VM, if domr is not up within 5 minutes, throw exception status 7748: resolved fixed --- .../VirtualNetworkApplianceManagerImpl.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index 5a4371d666f..a1fd1da0ce4 100644 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -1034,10 +1034,20 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian EventUtils.saveEvent(User.UID_SYSTEM, owner.getAccountId(), EventVO.LEVEL_ERROR, EventTypes.EVENT_ROUTER_CREATE, "router creation failed", startEventId); } - } - - + } State state = router.getState(); + + if ( state == State.Starting ) { + // wait 300 seconds + for ( int i = 0; i < 300; ) { + try { + Thread.sleep(2); + } catch (Exception e) { + } + i += 2; + state = router.getState(); + } + } if (state != State.Starting && state != State.Running) { long startEventId = EventUtils.saveStartedEvent(User.UID_SYSTEM, owner.getId(), EventTypes.EVENT_ROUTER_START, "Starting router : " +router.getName()); router = this.start(router, _accountService.getSystemUser(), _accountService.getSystemAccount()); @@ -1047,7 +1057,11 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian EventUtils.saveEvent(User.UID_SYSTEM, owner.getAccountId(), EventVO.LEVEL_ERROR, EventTypes.EVENT_ROUTER_START, "failed to start router", startEventId); } } - return router; + state = router.getState(); + if ( state == State.Running ) { + return router; + } + throw new CloudRuntimeException(router.getName() + " is not running , it is in " + state); } @Override