[asterisk-scf-commits] asterisk-scf/integration/ice-util-cpp.git branch "basecomponentfix" created.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Mon Sep 26 13:24:40 CDT 2011
branch "basecomponentfix" has been created
at 9d71e8dfcbbe7fb8d6e5d9946c73d0683bbf0fd8 (commit)
- Log -----------------------------------------------------------------
commit 9d71e8dfcbbe7fb8d6e5d9946c73d0683bbf0fd8
Author: Benjamin Oldenburg <benjamin.oldenburg at bericom.eu>
Date: Mon Sep 26 20:21:20 2011 +0200
Fixed ASTSCF-289
diff --git a/src/Component/Component.cpp b/src/Component/Component.cpp
index f654031..dceec56 100644
--- a/src/Component/Component.cpp
+++ b/src/Component/Component.cpp
@@ -17,6 +17,7 @@
#include <boost/lexical_cast.hpp>
#include <Ice/Ice.h>
+#include <IceUtil/Thread.h>
#include <IceBox/IceBox.h>
#include <AsteriskSCF/Helpers/PropertyHelper.h>
@@ -41,7 +42,7 @@ namespace Component
{
static const string ServiceLocatorManagementPropertyName("LocatorServiceManagement.Proxy");
static const string ServiceLocatorPropertyName("LocatorService.Proxy");
-
+
static const string ComponentServiceProxyId("ComponentService");
static const string ReplicaProxyId("Replica");
@@ -748,25 +749,70 @@ void Component::createBackplaneServices()
*/
void Component::initServiceLocatorProxies()
{
- try
- {
- // Get a proxy to the management interface for the Service Locator manager.
- mServiceLocatorManagement =
- ServiceLocatorManagementPrx::checkedCast(mCommunicator->stringToProxy(
- mCommunicator->getProperties()->getPropertyWithDefault(
- ServiceLocatorManagementPropertyName, "LocatorServiceManagement:tcp -p 4412")));
-
- // Get a proxy to the interface for the Service Locator.
- mServiceLocator =
- ServiceLocatorPrx::checkedCast(mCommunicator->stringToProxy(
- mCommunicator->getProperties()->getPropertyWithDefault(
- ServiceLocatorPropertyName, "LocatorService:default -p 4411")));
- }
- catch(const Ice::Exception& e)
- {
- mLogger(Error) << BOOST_CURRENT_FUNCTION << "Unable to obtain proxies to ServiceLocator. Check configuration. " << e.what();
+ int timeout = 0, retryDelay = 0;
+
+ try
+ {
+ timeout = mCommunicator->getProperties()->getPropertyAsIntWithDefault(mName + ".InitServiceLocatorTimeout", 30);
+ retryDelay = mCommunicator->getProperties()->getPropertyAsIntWithDefault(mName + ".InitServiceLocatorRetryDelay", 2);
+ }
+ catch(const Ice::Exception& e)
+ {
+ mLogger(Error) << BOOST_CURRENT_FUNCTION << "Failure to get property." << e.what();
throw;
- }
+ }
+
+ if(timeout < 1)
+ {
+ mLogger(Error) << BOOST_CURRENT_FUNCTION << "The value (=" << timeout << ") of the property '"
+ << mName + ".InitServiceLocatorProxiesTimeout"
+ << "' cannot be less than 1.";
+ throw;
+ }
+
+ if(retryDelay < 1)
+ {
+ mLogger(Error) << BOOST_CURRENT_FUNCTION << "The value (=" << retryDelay << ") of the property '"
+ << mName + ".InitServiceLocatorProxiesRetryDelay"
+ << "' cannot be less than 1.";
+ throw;
+ }
+
+ IceUtil::Time tTimeout = IceUtil::Time::now() + IceUtil::Time::seconds(timeout);
+
+ while( IceUtil::Time::now() < tTimeout)
+ {
+
+ try
+ {
+ // Get a proxy to the management interface for the Service Locator manager.
+ mServiceLocatorManagement =
+ ServiceLocatorManagementPrx::checkedCast(mCommunicator->stringToProxy(
+ mCommunicator->getProperties()->getPropertyWithDefault(
+ ServiceLocatorManagementPropertyName, "LocatorServiceManagement:tcp -p 4412")));
+
+ // Get a proxy to the interface for the Service Locator.
+ mServiceLocator =
+ ServiceLocatorPrx::checkedCast(mCommunicator->stringToProxy(
+ mCommunicator->getProperties()->getPropertyWithDefault(
+ ServiceLocatorPropertyName, "LocatorService:default -p 4411")));
+
+ // If we made it to this point, everything's good.
+ return;
+ }
+ catch(const Ice::Exception& e)
+ {
+ mLogger(Notice) << " Unable to obtain proxies to ServiceLocator. Retry in " << retryDelay << " seconds.";
+ }
+
+ // Wait a little before retrying.
+ IceUtil::ThreadControl::sleep (IceUtil::Time::seconds(retryDelay));
+
+ }
+
+ // Timeout
+ mLogger(Error) << BOOST_CURRENT_FUNCTION << " Unable to obtain proxies to ServiceLocator for " << timeout << " seconds. Timeout!.";
+ throw;
}
void Component::verifyProperties()
-----------------------------------------------------------------------
--
asterisk-scf/integration/ice-util-cpp.git
More information about the asterisk-scf-commits
mailing list