[Ace-users] [tao-users] How to set the NS multicast discovery timeout
Steve Totten
totten_s at ociweb.com
Mon Feb 4 21:39:16 CST 2008
Hi Keith,
Douglas C. Schmidt wrote:
> Hi Keith,
>
>> When using the multicast discovery feature for the naming service, a
>> client will wait 10 sec before giving up if the NS isn't found. We'd
>> like the client to fail quicker (say, after waiting for 1 sec). Is
>> there a command-line option to specify the discovery timeout?
>
> I don't think so, but there's no reason that one couldn't be added. If
> you folks would like to do the work and contribute this back to us that
> would be great!
The "service discovery timeout" is controlled by the following
macro definition in $TAO_ROOT/tao/orbconf.h:
// The default timeout receiving the location request to the TAO
// Naming, Trading and other servicesService.
#if !defined (TAO_DEFAULT_SERVICE_RESOLUTION_TIMEOUT)
#define TAO_DEFAULT_SERVICE_RESOLUTION_TIMEOUT 10
#endif /* TAO_DEFAULT_SERVICE_RESOLUTION_TIMEOUT */
So, you could #define TAO_DEFAULT_SERVICE_RESOLUTION_TIMEOUT to
your preferred value in ace/config.h file and recompile.
Obviously, that does not provide the same flexibility as a
run-time option would provide.
You can also override the value of the service resolution timeout
in code by passing it as the optional 2nd parameter to
CORBA::ORB::resolve_initial_references(). The 2nd parameter
defaults to zero (really, a null ACE_Time_Value), causing the ORB
to use the value specified by the above macro. See
$TAO_ROOT/tao/ORB.h:
/**
* This method acts as a mini-bootstrapping Naming Service,
which is
* provided by the ORB for certain well-known object
references. TAO
* supports the "NameService", "TradingService", "RootPOA",
* "ImplRepo", and "POACurrent" via this method. The @c timeout
* value bounds the amount of time the ORB blocks waiting to
* resolve the service. This is most useful for bootstrapping
* remote services, such as the "NameService" or
"TradingService",
* that are commonly resolved via multicast. By default, the
* value is 0, which means "use the @c
* TAO_DEFAULT_SERVICE_RESOLUTION_TIMEOUT timeout period".
*
* @note By using a default value for the @c timeout parameter,
* TAO will remains compliant with the CORBA
* resolve_initial_references() specification.
*/
CORBA::Object_ptr resolve_initial_references (
const char *name,
ACE_Time_Value *timeout = 0);
So, for a one-second timeout, you could just call:
CORBA::Object_var obj =
orb->resolve_initial_references(
"NameService", ACE_Time_Value(1));
You could easily turn the value into a command-line parameter to
your application (and it shouldn't be much harder to make it an
ORB initialization option).
The above call to resolve_initial_references() is, of course,
a TAO extension to the CORBA specification.
HTH,
Steve
--
----------------------------------------------------------------
Steve Totten, Principal Software Engineer and Partner
Object Computing, Inc. (OCI), St. Louis, MO, USA
http://www.ociweb.com/ http://www.theaceorb.com/
----------------------------------------------------------------
More information about the Ace-users
mailing list