diff options
author | Ossama Othman <ossama-othman@users.noreply.github.com> | 2000-04-21 21:51:27 +0000 |
---|---|---|
committer | Ossama Othman <ossama-othman@users.noreply.github.com> | 2000-04-21 21:51:27 +0000 |
commit | a52aa073951582d2cb96a760997496da5d1f9308 (patch) | |
tree | c57a8cc172c1ef67cd0fd1768358883460ffa88e | |
parent | ea450e35bda3cbeed50a7eba82746caf9cda1e6b (diff) | |
download | ATCD-a52aa073951582d2cb96a760997496da5d1f9308.tar.gz |
ChangeLogTag:Fri Apr 21 14:16:15 2000 Ossama Othman <ossama@uci.edu>
28 files changed, 400 insertions, 334 deletions
diff --git a/TAO/orbsvcs/orbsvcs/DSI_ForwardingProxy.cpp b/TAO/orbsvcs/orbsvcs/DSI_ForwardingProxy.cpp index 17a8628a787..851de3a88d0 100644 --- a/TAO/orbsvcs/orbsvcs/DSI_ForwardingProxy.cpp +++ b/TAO/orbsvcs/orbsvcs/DSI_ForwardingProxy.cpp @@ -7,19 +7,23 @@ ACE_RCSID(orbsvcs, DSI_ForwardingProxy, "$Id$") -DSI_ForwardingProxy::DSI_ForwardingProxy (LoadBalancer_Impl *lb, - const char *id) +TAO_LB_DSI_ForwardingProxy::TAO_LB_DSI_ForwardingProxy ( + TAO_LB_LoadBalancer *lb, + const char *id) : load_balancer_ (lb), // Hopefully these pointers won't be zero! interface_id_ (id) { // @@ Ossama: why is this comment useful? + // @@ Carlos: You are correct. It servers no purpose other than to + // take up space. It is simply there to make it easier for me to + // spot the function body. It is just my coding style. // Nothing else } void -DSI_ForwardingProxy::invoke (CORBA::ServerRequest_ptr /* request */, - CORBA::Environment &ACE_TRY_ENV) +TAO_LB_DSI_ForwardingProxy::invoke (CORBA::ServerRequest_ptr /* request */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, PortableServer::ForwardRequest)) { @@ -37,7 +41,7 @@ DSI_ForwardingProxy::invoke (CORBA::ServerRequest_ptr /* request */, } CORBA::RepositoryId -DSI_ForwardingProxy::_primary_interface ( +TAO_LB_DSI_ForwardingProxy::_primary_interface ( const PortableServer::ObjectId &, PortableServer::POA_ptr, CORBA::Environment &) diff --git a/TAO/orbsvcs/orbsvcs/DSI_ForwardingProxy.h b/TAO/orbsvcs/orbsvcs/DSI_ForwardingProxy.h index 26b2322dd80..7c2bf07a98b 100644 --- a/TAO/orbsvcs/orbsvcs/DSI_ForwardingProxy.h +++ b/TAO/orbsvcs/orbsvcs/DSI_ForwardingProxy.h @@ -18,19 +18,23 @@ #ifndef DSI_FORWARDING_PROXY_H #define DSI_FORWARDING_PROXY_H +#include "ace/pre.h" + #include "orbsvcs/LoadBalancingS.h" +#include "LoadBalancing_export.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ // Forward declaration. -class LoadBalancer_Impl; +class TAO_LB_LoadBalancer; // @@ Ossama: we have to change the implementation to use a // ServantLocator, that can actually raise the ForwardingRequest // exception. -// @@ Also: please remember to use the '#pragma once' madness, prefix -// the names of your classes and don't forget the TAO_XXXX_Export -// macros. -class DSI_ForwardingProxy : public PortableServer::DynamicImplementation +class TAO_LoadBalancing_Export TAO_LB_DSI_ForwardingProxy : public PortableServer::DynamicImplementation { // = TITLE // Class that provides request forwarding. @@ -42,8 +46,8 @@ class DSI_ForwardingProxy : public PortableServer::DynamicImplementation // client should redirect its requests. public: - DSI_ForwardingProxy (LoadBalancer_Impl *load_balancer, - const char *interface_id); + TAO_LB_DSI_ForwardingProxy (TAO_LB_LoadBalancer *load_balancer, + const char *interface_id); // Constructor that sets the interface repository ID this DSI object // is associated with. @@ -61,7 +65,7 @@ public: ACE_THROW_SPEC (()); private: - LoadBalancer_Impl *load_balancer_; + TAO_LB_LoadBalancer *load_balancer_; // The load balancer implementation. CORBA::String_var interface_id_; diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancer_i.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancer_i.cpp index f4dc0bee6a7..b7b48b52aff 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancer_i.cpp +++ b/TAO/orbsvcs/orbsvcs/LoadBalancer_i.cpp @@ -2,89 +2,95 @@ // $Id$ -#include "orbsvcs/LoadBalancing/LoadBalancer_i.h" -#include "orbsvcs/LoadBalancing/ReplicaProxy.h" +#include "LoadBalancer_i.h" +#include "ReplicaProxy.h" -ACE_RCSID(orbsvcs, Load_Balancer_i, "$Id$") +ACE_RCSID(orbsvcs, LoadBalancer, "$Id$") #if !defined (__ACE_INLINE__) #include "LoadBalancer_i.i" #endif /* __ACE_INLINE__ */ -LoadBalancer_Impl::LoadBalancer_Impl (const char *interface_id, - Load_Balancing_Strategy *strategy, - PortableServer::POA_ptr poa) +TAO_LB_LoadBalancer::TAO_LB_LoadBalancer ( + const char *interface_id, + TAO_LB_LoadBalancing_Strategy *strategy, + PortableServer::POA_ptr poa) : redirector_ (this, interface_id), strategy_ (strategy), poa_ (PortableServer::POA::_duplicate (poa)) { - // @@ Ossama: in general it is a bad idea to perform operations like - // this in the constructor, the behavior on platforms with exception - // and without native exception support is simply too different. - - // Nothing else - - ACE_TRY_NEW_ENV - { - PortableServer::ObjectId_var oid = - this->poa_->activate_object (&this->redirector_, - ACE_TRY_ENV); - ACE_TRY_CHECK; - - this->group_identity_ = - this->poa_->id_to_reference (oid.in (), - ACE_TRY_ENV); - ACE_TRY_CHECK; - } - ACE_CATCHANY - { - } - ACE_ENDTRY; + (void) this->init (); } -LoadBalancer_Impl::~LoadBalancer_Impl (void) +TAO_LB_LoadBalancer::~TAO_LB_LoadBalancer (void) { // Nothing else } LoadBalancing::ReplicaProxy_ptr -LoadBalancer_Impl::connect (LoadBalancing::ReplicaControl_ptr control, - CORBA::Object_ptr replica, - CORBA::Environment &ACE_TRY_ENV) +TAO_LB_LoadBalancer::connect (LoadBalancing::ReplicaControl_ptr control, + CORBA::Object_ptr replica, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((LoadBalancing::ReplicaProxy::NilControl, LoadBalancing::ReplicaProxy::NilReplica, CORBA::SystemException)) { - ReplicaProxy_Impl *impl = 0; - ACE_NEW_THROW_EX (impl, - ReplicaProxy_Impl, - CORBA::NO_MEMORY ()); + TAO_LB_ReplicaProxy *proxy = 0; + ACE_NEW_THROW_EX (proxy, + TAO_LB_ReplicaProxy, + CORBA::NO_MEMORY ( + CORBA_SystemException::_tao_minor_code ( + TAO_DEFAULT_MINOR_CODE, + ENOMEM), + CORBA::COMPLETED_NO)); ACE_CHECK_RETURN (LoadBalancing::ReplicaProxy::_nil ()); - PortableServer::ServantBase_var proxy_servant = impl; + PortableServer::ServantBase_var proxy_servant = proxy; - impl->connect (this, control, replica, ACE_TRY_ENV); + proxy->connect (this, control, replica, ACE_TRY_ENV); ACE_CHECK_RETURN (LoadBalancing::ReplicaProxy::_nil ()); - if (this->strategy_->insert (impl) == -1) + if (this->strategy_->insert (proxy) == -1) { ACE_THROW_RETURN (CORBA::INTERNAL (), LoadBalancing::ReplicaProxy::_nil ()); } - return impl->_this (ACE_TRY_ENV); + return proxy->_this (ACE_TRY_ENV); } CORBA::Object_ptr -LoadBalancer_Impl::group_identity (CORBA::Environment &) +TAO_LB_LoadBalancer::group_identity (CORBA::Environment &) ACE_THROW_SPEC ((CORBA::SystemException)) { return CORBA::Object::_duplicate (this->group_identity_.in ()); } void -LoadBalancer_Impl::load_changed (ReplicaProxy_Impl *proxy, - CORBA::Environment &ACE_TRY_ENV) +TAO_LB_LoadBalancer::load_changed (TAO_LB_ReplicaProxy *proxy, + CORBA::Environment &ACE_TRY_ENV) { this->strategy_->load_changed (proxy, ACE_TRY_ENV); } + +int +TAO_LB_LoadBalancer::init (void) +{ + ACE_TRY_NEW_ENV + { + PortableServer::ObjectId_var oid = + this->poa_->activate_object (&this->redirector_, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + this->group_identity_ = + this->poa_->id_to_reference (oid.in (), + ACE_TRY_ENV); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + // @@ Should we do anything here? + } + ACE_ENDTRY; +} diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancer_i.h b/TAO/orbsvcs/orbsvcs/LoadBalancer_i.h index 11486171bdd..7eefaed0072 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancer_i.h +++ b/TAO/orbsvcs/orbsvcs/LoadBalancer_i.h @@ -19,14 +19,15 @@ #define TAO_LOADBALANCER_I_H #include "orbsvcs/LoadBalancingS.h" -#include "orbsvcs/LoadBalancing/ReplicaProxy.h" -#include "orbsvcs/LoadBalancing/DSI_ForwardingProxy.h" -#include "orbsvcs/LoadBalancing/LoadBalancing_Strategy.h" +#include "ReplicaProxy.h" +#include "DSI_ForwardingProxy.h" +#include "LoadBalancing_Strategy.h" +#include "LoadBalancing_export.h" -// @@ Ossama: please always remember the #pragma once. +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ -// @@ Ossama: The name of this class should be TAO_XXX_LoadBalancer, -// or something similar (i vote for XXX == LB) // @@ Ossama: the name of the file and the class are inconsistent. // @@ Ossama: now is when your idea of keeping the strategy separate // pays off: we could add strategies to detect misbehaving replicas, @@ -35,16 +36,16 @@ // removing. I'm sure there are other aspects of the system that // could be strategized. -class TAO_LoadBalancing_Export LoadBalancer_Impl : public virtual POA_LoadBalancing::LoadBalancer +class TAO_LoadBalancing_Export TAO_LB_LoadBalancer : public virtual POA_LoadBalancing::LoadBalancer { public: - LoadBalancer_Impl (const char *interface_id, - Load_Balancing_Strategy *strategy, - PortableServer::POA_ptr poa); + TAO_LB_LoadBalancer (const char *interface_id, + TAO_LB_LoadBalancing_Strategy *strategy, + PortableServer::POA_ptr poa); // Constructor that initializes this Load Balancer for use with a // Replica that has the specified interface repository ID. - ~LoadBalancer_Impl (void); + ~TAO_LB_LoadBalancer (void); // Destructor. // Local methods @@ -55,13 +56,13 @@ public: // that should let us keep the average load (and other similar // things) pre-computed. // - void load_changed (ReplicaProxy_Impl *proxy, + void load_changed (TAO_LB_ReplicaProxy *proxy, CORBA::Environment &ACE_TRY_ENV); // The load for <proxy> has changed, the LoadBalancer can use this // opportunity to determine if the load on one of the services is // too high. - void disconnect (ReplicaProxy_Impl *proxy, + void disconnect (TAO_LB_ReplicaProxy *proxy, CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException)); // Disconnect proxy from the Load Balancer. @@ -83,11 +84,15 @@ public: ACE_THROW_SPEC ((CORBA::SystemException)); private: - DSI_ForwardingProxy redirector_; + int init (void); + // Initialize the <redirector_> DSI forwarding proxy. + +private: + TAO_LB_DSI_ForwardingProxy redirector_; // The object that tells the invoking client to forward its requests // from the LoadBalancer to an actual replica. - Load_Balancing_Strategy *strategy_; + TAO_LB_LoadBalancing_Strategy *strategy_; // The underlying load balancing strategy. PortableServer::POA_var poa_; @@ -99,7 +104,6 @@ private: #if defined (__ACE_INLINE__) #include "LoadBalancer_i.i" -// @@ Ossama: notice that i use relative paths! #endif /* __ACE_INLINE__ */ #endif /* TAO_LOADBALANCER_I_H */ diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancer_i.i b/TAO/orbsvcs/orbsvcs/LoadBalancer_i.i index 4944020b1b1..88ab6a81532 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancer_i.i +++ b/TAO/orbsvcs/orbsvcs/LoadBalancer_i.i @@ -4,8 +4,8 @@ ACE_INLINE void -LoadBalancer_Impl::disconnect (ReplicaProxy_Impl *proxy, - CORBA::Environment &ACE_TRY_ENV) +TAO_LB_LoadBalancer::disconnect (TAO_LB_ReplicaProxy *proxy, + CORBA::Environment &ACE_TRY_ENV) { if (this->strategy_->remove (proxy) != 0) ACE_THROW (LoadBalancing::LoadBalancer::InvalidReplicaProxy ()); @@ -13,7 +13,7 @@ LoadBalancer_Impl::disconnect (ReplicaProxy_Impl *proxy, ACE_INLINE CORBA::Object_ptr -LoadBalancer_Impl::replica (CORBA::Environment &ACE_TRY_ENV) +TAO_LB_LoadBalancer::replica (CORBA::Environment &ACE_TRY_ENV) { return this->strategy_->replica (ACE_TRY_ENV); } diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/DSI_ForwardingProxy.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing/DSI_ForwardingProxy.cpp index 17a8628a787..851de3a88d0 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/DSI_ForwardingProxy.cpp +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/DSI_ForwardingProxy.cpp @@ -7,19 +7,23 @@ ACE_RCSID(orbsvcs, DSI_ForwardingProxy, "$Id$") -DSI_ForwardingProxy::DSI_ForwardingProxy (LoadBalancer_Impl *lb, - const char *id) +TAO_LB_DSI_ForwardingProxy::TAO_LB_DSI_ForwardingProxy ( + TAO_LB_LoadBalancer *lb, + const char *id) : load_balancer_ (lb), // Hopefully these pointers won't be zero! interface_id_ (id) { // @@ Ossama: why is this comment useful? + // @@ Carlos: You are correct. It servers no purpose other than to + // take up space. It is simply there to make it easier for me to + // spot the function body. It is just my coding style. // Nothing else } void -DSI_ForwardingProxy::invoke (CORBA::ServerRequest_ptr /* request */, - CORBA::Environment &ACE_TRY_ENV) +TAO_LB_DSI_ForwardingProxy::invoke (CORBA::ServerRequest_ptr /* request */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, PortableServer::ForwardRequest)) { @@ -37,7 +41,7 @@ DSI_ForwardingProxy::invoke (CORBA::ServerRequest_ptr /* request */, } CORBA::RepositoryId -DSI_ForwardingProxy::_primary_interface ( +TAO_LB_DSI_ForwardingProxy::_primary_interface ( const PortableServer::ObjectId &, PortableServer::POA_ptr, CORBA::Environment &) diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/DSI_ForwardingProxy.h b/TAO/orbsvcs/orbsvcs/LoadBalancing/DSI_ForwardingProxy.h index 26b2322dd80..7c2bf07a98b 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/DSI_ForwardingProxy.h +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/DSI_ForwardingProxy.h @@ -18,19 +18,23 @@ #ifndef DSI_FORWARDING_PROXY_H #define DSI_FORWARDING_PROXY_H +#include "ace/pre.h" + #include "orbsvcs/LoadBalancingS.h" +#include "LoadBalancing_export.h" + +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ // Forward declaration. -class LoadBalancer_Impl; +class TAO_LB_LoadBalancer; // @@ Ossama: we have to change the implementation to use a // ServantLocator, that can actually raise the ForwardingRequest // exception. -// @@ Also: please remember to use the '#pragma once' madness, prefix -// the names of your classes and don't forget the TAO_XXXX_Export -// macros. -class DSI_ForwardingProxy : public PortableServer::DynamicImplementation +class TAO_LoadBalancing_Export TAO_LB_DSI_ForwardingProxy : public PortableServer::DynamicImplementation { // = TITLE // Class that provides request forwarding. @@ -42,8 +46,8 @@ class DSI_ForwardingProxy : public PortableServer::DynamicImplementation // client should redirect its requests. public: - DSI_ForwardingProxy (LoadBalancer_Impl *load_balancer, - const char *interface_id); + TAO_LB_DSI_ForwardingProxy (TAO_LB_LoadBalancer *load_balancer, + const char *interface_id); // Constructor that sets the interface repository ID this DSI object // is associated with. @@ -61,7 +65,7 @@ public: ACE_THROW_SPEC (()); private: - LoadBalancer_Impl *load_balancer_; + TAO_LB_LoadBalancer *load_balancer_; // The load balancer implementation. CORBA::String_var interface_id_; diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancer_i.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancer_i.cpp index f4dc0bee6a7..b7b48b52aff 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancer_i.cpp +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancer_i.cpp @@ -2,89 +2,95 @@ // $Id$ -#include "orbsvcs/LoadBalancing/LoadBalancer_i.h" -#include "orbsvcs/LoadBalancing/ReplicaProxy.h" +#include "LoadBalancer_i.h" +#include "ReplicaProxy.h" -ACE_RCSID(orbsvcs, Load_Balancer_i, "$Id$") +ACE_RCSID(orbsvcs, LoadBalancer, "$Id$") #if !defined (__ACE_INLINE__) #include "LoadBalancer_i.i" #endif /* __ACE_INLINE__ */ -LoadBalancer_Impl::LoadBalancer_Impl (const char *interface_id, - Load_Balancing_Strategy *strategy, - PortableServer::POA_ptr poa) +TAO_LB_LoadBalancer::TAO_LB_LoadBalancer ( + const char *interface_id, + TAO_LB_LoadBalancing_Strategy *strategy, + PortableServer::POA_ptr poa) : redirector_ (this, interface_id), strategy_ (strategy), poa_ (PortableServer::POA::_duplicate (poa)) { - // @@ Ossama: in general it is a bad idea to perform operations like - // this in the constructor, the behavior on platforms with exception - // and without native exception support is simply too different. - - // Nothing else - - ACE_TRY_NEW_ENV - { - PortableServer::ObjectId_var oid = - this->poa_->activate_object (&this->redirector_, - ACE_TRY_ENV); - ACE_TRY_CHECK; - - this->group_identity_ = - this->poa_->id_to_reference (oid.in (), - ACE_TRY_ENV); - ACE_TRY_CHECK; - } - ACE_CATCHANY - { - } - ACE_ENDTRY; + (void) this->init (); } -LoadBalancer_Impl::~LoadBalancer_Impl (void) +TAO_LB_LoadBalancer::~TAO_LB_LoadBalancer (void) { // Nothing else } LoadBalancing::ReplicaProxy_ptr -LoadBalancer_Impl::connect (LoadBalancing::ReplicaControl_ptr control, - CORBA::Object_ptr replica, - CORBA::Environment &ACE_TRY_ENV) +TAO_LB_LoadBalancer::connect (LoadBalancing::ReplicaControl_ptr control, + CORBA::Object_ptr replica, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((LoadBalancing::ReplicaProxy::NilControl, LoadBalancing::ReplicaProxy::NilReplica, CORBA::SystemException)) { - ReplicaProxy_Impl *impl = 0; - ACE_NEW_THROW_EX (impl, - ReplicaProxy_Impl, - CORBA::NO_MEMORY ()); + TAO_LB_ReplicaProxy *proxy = 0; + ACE_NEW_THROW_EX (proxy, + TAO_LB_ReplicaProxy, + CORBA::NO_MEMORY ( + CORBA_SystemException::_tao_minor_code ( + TAO_DEFAULT_MINOR_CODE, + ENOMEM), + CORBA::COMPLETED_NO)); ACE_CHECK_RETURN (LoadBalancing::ReplicaProxy::_nil ()); - PortableServer::ServantBase_var proxy_servant = impl; + PortableServer::ServantBase_var proxy_servant = proxy; - impl->connect (this, control, replica, ACE_TRY_ENV); + proxy->connect (this, control, replica, ACE_TRY_ENV); ACE_CHECK_RETURN (LoadBalancing::ReplicaProxy::_nil ()); - if (this->strategy_->insert (impl) == -1) + if (this->strategy_->insert (proxy) == -1) { ACE_THROW_RETURN (CORBA::INTERNAL (), LoadBalancing::ReplicaProxy::_nil ()); } - return impl->_this (ACE_TRY_ENV); + return proxy->_this (ACE_TRY_ENV); } CORBA::Object_ptr -LoadBalancer_Impl::group_identity (CORBA::Environment &) +TAO_LB_LoadBalancer::group_identity (CORBA::Environment &) ACE_THROW_SPEC ((CORBA::SystemException)) { return CORBA::Object::_duplicate (this->group_identity_.in ()); } void -LoadBalancer_Impl::load_changed (ReplicaProxy_Impl *proxy, - CORBA::Environment &ACE_TRY_ENV) +TAO_LB_LoadBalancer::load_changed (TAO_LB_ReplicaProxy *proxy, + CORBA::Environment &ACE_TRY_ENV) { this->strategy_->load_changed (proxy, ACE_TRY_ENV); } + +int +TAO_LB_LoadBalancer::init (void) +{ + ACE_TRY_NEW_ENV + { + PortableServer::ObjectId_var oid = + this->poa_->activate_object (&this->redirector_, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + this->group_identity_ = + this->poa_->id_to_reference (oid.in (), + ACE_TRY_ENV); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + // @@ Should we do anything here? + } + ACE_ENDTRY; +} diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancer_i.h b/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancer_i.h index 11486171bdd..7eefaed0072 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancer_i.h +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancer_i.h @@ -19,14 +19,15 @@ #define TAO_LOADBALANCER_I_H #include "orbsvcs/LoadBalancingS.h" -#include "orbsvcs/LoadBalancing/ReplicaProxy.h" -#include "orbsvcs/LoadBalancing/DSI_ForwardingProxy.h" -#include "orbsvcs/LoadBalancing/LoadBalancing_Strategy.h" +#include "ReplicaProxy.h" +#include "DSI_ForwardingProxy.h" +#include "LoadBalancing_Strategy.h" +#include "LoadBalancing_export.h" -// @@ Ossama: please always remember the #pragma once. +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ -// @@ Ossama: The name of this class should be TAO_XXX_LoadBalancer, -// or something similar (i vote for XXX == LB) // @@ Ossama: the name of the file and the class are inconsistent. // @@ Ossama: now is when your idea of keeping the strategy separate // pays off: we could add strategies to detect misbehaving replicas, @@ -35,16 +36,16 @@ // removing. I'm sure there are other aspects of the system that // could be strategized. -class TAO_LoadBalancing_Export LoadBalancer_Impl : public virtual POA_LoadBalancing::LoadBalancer +class TAO_LoadBalancing_Export TAO_LB_LoadBalancer : public virtual POA_LoadBalancing::LoadBalancer { public: - LoadBalancer_Impl (const char *interface_id, - Load_Balancing_Strategy *strategy, - PortableServer::POA_ptr poa); + TAO_LB_LoadBalancer (const char *interface_id, + TAO_LB_LoadBalancing_Strategy *strategy, + PortableServer::POA_ptr poa); // Constructor that initializes this Load Balancer for use with a // Replica that has the specified interface repository ID. - ~LoadBalancer_Impl (void); + ~TAO_LB_LoadBalancer (void); // Destructor. // Local methods @@ -55,13 +56,13 @@ public: // that should let us keep the average load (and other similar // things) pre-computed. // - void load_changed (ReplicaProxy_Impl *proxy, + void load_changed (TAO_LB_ReplicaProxy *proxy, CORBA::Environment &ACE_TRY_ENV); // The load for <proxy> has changed, the LoadBalancer can use this // opportunity to determine if the load on one of the services is // too high. - void disconnect (ReplicaProxy_Impl *proxy, + void disconnect (TAO_LB_ReplicaProxy *proxy, CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException)); // Disconnect proxy from the Load Balancer. @@ -83,11 +84,15 @@ public: ACE_THROW_SPEC ((CORBA::SystemException)); private: - DSI_ForwardingProxy redirector_; + int init (void); + // Initialize the <redirector_> DSI forwarding proxy. + +private: + TAO_LB_DSI_ForwardingProxy redirector_; // The object that tells the invoking client to forward its requests // from the LoadBalancer to an actual replica. - Load_Balancing_Strategy *strategy_; + TAO_LB_LoadBalancing_Strategy *strategy_; // The underlying load balancing strategy. PortableServer::POA_var poa_; @@ -99,7 +104,6 @@ private: #if defined (__ACE_INLINE__) #include "LoadBalancer_i.i" -// @@ Ossama: notice that i use relative paths! #endif /* __ACE_INLINE__ */ #endif /* TAO_LOADBALANCER_I_H */ diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancer_i.i b/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancer_i.i index 4944020b1b1..88ab6a81532 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancer_i.i +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancer_i.i @@ -4,8 +4,8 @@ ACE_INLINE void -LoadBalancer_Impl::disconnect (ReplicaProxy_Impl *proxy, - CORBA::Environment &ACE_TRY_ENV) +TAO_LB_LoadBalancer::disconnect (TAO_LB_ReplicaProxy *proxy, + CORBA::Environment &ACE_TRY_ENV) { if (this->strategy_->remove (proxy) != 0) ACE_THROW (LoadBalancing::LoadBalancer::InvalidReplicaProxy ()); @@ -13,7 +13,7 @@ LoadBalancer_Impl::disconnect (ReplicaProxy_Impl *proxy, ACE_INLINE CORBA::Object_ptr -LoadBalancer_Impl::replica (CORBA::Environment &ACE_TRY_ENV) +TAO_LB_LoadBalancer::replica (CORBA::Environment &ACE_TRY_ENV) { return this->strategy_->replica (ACE_TRY_ENV); } diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancing_Strategy.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancing_Strategy.cpp index bb90a27e7c8..a64cf50f4b7 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancing_Strategy.cpp +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancing_Strategy.cpp @@ -12,13 +12,13 @@ ACE_RCSID(orbsvcs, LoadBalancing_Strategy, "$Id$") -Load_Balancing_Strategy::~Load_Balancing_Strategy (void) +TAO_LB_LoadBalancing_Strategy::~TAO_LB_LoadBalancing_Strategy (void) { } void -Load_Balancing_Strategy::load_changed (ReplicaProxy_Impl *, - CORBA::Environment &) +TAO_LB_LoadBalancing_Strategy::load_changed (TAO_LB_ReplicaProxy *, + CORBA::Environment &) { } @@ -26,14 +26,14 @@ Load_Balancing_Strategy::load_changed (ReplicaProxy_Impl *, // used in two strategies, but it sound kind of silly... #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) -template class ACE_Node<ReplicaProxy_Impl*>; -template class ACE_Unbounded_Set<ReplicaProxy_Impl*>; -template class ACE_Unbounded_Set_Iterator<ReplicaProxy_Impl*>; +template class ACE_Node<TAO_LB_ReplicaProxy *>; +template class ACE_Unbounded_Set<TAO_LB_ReplicaProxy *>; +template class ACE_Unbounded_Set_Iterator<TAO_LB_ReplicaProxy *>; #elif defined(ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) -#pragma instantiate ACE_Node<ReplicaProxy_Impl*> -#pragma instantiate ACE_Unbounded_Set<ReplicaProxy_Impl*> -#pragma instantiate ACE_Unbounded_Set_Iterator<ReplicaProxy_Impl*> +#pragma instantiate ACE_Node<TAO_LB_ReplicaProxy *> +#pragma instantiate ACE_Unbounded_Set<TAO_LB_ReplicaProxy *> +#pragma instantiate ACE_Unbounded_Set_Iterator<TAO_LB_ReplicaProxy *> #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancing_Strategy.h b/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancing_Strategy.h index 72b580e6919..916e7357bc1 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancing_Strategy.h +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancing_Strategy.h @@ -19,15 +19,17 @@ #define LOAD_BALANCING_STRATEGY_H #include "orbsvcs/LoadBalancingS.h" +#include "LoadBalancing_export.h" -// @@ Ossama: the general comments on filenames, class names, -// TAO_XXX_Export an other things like that apply. +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ -class ReplicaProxy_Impl; +class TAO_LB_ReplicaProxy; // The abstract load balancing strategy class. -class Load_Balancing_Strategy +class TAO_LoadBalancing_Export TAO_LB_LoadBalancing_Strategy { // = TITLE // Load balancing strategy abstract base class. @@ -37,7 +39,7 @@ class Load_Balancing_Strategy // strategies should implement. public: - virtual ~Load_Balancing_Strategy (void); + virtual ~TAO_LB_LoadBalancing_Strategy (void); // Destructor // @@ The name of the method should be more meaningful, what about: @@ -48,14 +50,14 @@ public: // Return the object reference to the Replica to which requests should // be redirected. - virtual int insert (ReplicaProxy_Impl *) = 0; + virtual int insert (TAO_LB_ReplicaProxy *) = 0; // Insert ReplicaProxy servant into the set of replica proxies upon // which the load balancing algorithm is performed. - virtual int remove (ReplicaProxy_Impl *) = 0; + virtual int remove (TAO_LB_ReplicaProxy *) = 0; // Remove ReplicaProxy servant from the set of replica proxies. - virtual void load_changed (ReplicaProxy_Impl *impl, + virtual void load_changed (TAO_LB_ReplicaProxy *proxy, CORBA::Environment &ACE_TRY_ENV); // The load on one proxy has changed. // @@ Ossama: see my comments on LoadBalancing_i about changing the diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/Minimum_Dispersion.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing/Minimum_Dispersion.cpp index a7c758be4cb..c7f87a6d00f 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/Minimum_Dispersion.cpp +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/Minimum_Dispersion.cpp @@ -9,18 +9,18 @@ ACE_RCSID(orbsvcs, Minimum_Dispersion, "$Id$") -Minimum_Dispersion_Strategy::Minimum_Dispersion_Strategy (void) +TAO_LB_Minimum_Dispersion_Strategy::TAO_LB_Minimum_Dispersion_Strategy (void) : proxies_ () { } -Minimum_Dispersion_Strategy::~Minimum_Dispersion_Strategy (void) +TAO_LB_Minimum_Dispersion_Strategy::~TAO_LB_Minimum_Dispersion_Strategy (void) { // @@ Ossama: more code that is not thread safe - ReplicaProxySetIterator begin = this->proxies_.begin (); - ReplicaProxySetIterator end = this->proxies_.end (); + TAO_LB_ReplicaProxySetIterator begin = this->proxies_.begin (); + TAO_LB_ReplicaProxySetIterator end = this->proxies_.end (); - for (ReplicaProxySetIterator i = begin; + for (TAO_LB_ReplicaProxySetIterator i = begin; i != end; ++i) { @@ -30,16 +30,16 @@ Minimum_Dispersion_Strategy::~Minimum_Dispersion_Strategy (void) } CORBA::Object_ptr -Minimum_Dispersion_Strategy::replica (CORBA::Environment &ACE_TRY_ENV) +TAO_LB_Minimum_Dispersion_Strategy::replica (CORBA::Environment &ACE_TRY_ENV) { // @@ Ossama: more code that is not thread safe while (!this->proxies_.is_empty ()) { - ReplicaProxySetIterator begin = this->proxies_.begin (); - ReplicaProxySetIterator end = this->proxies_.end (); + TAO_LB_ReplicaProxySetIterator begin = this->proxies_.begin (); + TAO_LB_ReplicaProxySetIterator end = this->proxies_.end (); - ReplicaProxySetIterator i = begin; - ReplicaProxy_Impl * proxy = (*i); + TAO_LB_ReplicaProxySetIterator i = begin; + TAO_LB_ReplicaProxy * proxy = (*i); float d = (*i)->current_load (); for (++i ; i != end; ++i) @@ -80,44 +80,43 @@ Minimum_Dispersion_Strategy::replica (CORBA::Environment &ACE_TRY_ENV) // @@ What do we do if the set is empty? ACE_THROW_RETURN (CORBA::OBJECT_NOT_EXIST (), CORBA::Object::_nil ()); - } int -Minimum_Dispersion_Strategy::insert (ReplicaProxy_Impl *proxy) +TAO_LB_Minimum_Dispersion_Strategy::insert (TAO_LB_ReplicaProxy *proxy) { // @@ Ossama: more code that is not thread safe return this->proxies_.insert (proxy); } int -Minimum_Dispersion_Strategy::remove (ReplicaProxy_Impl *proxy) +TAO_LB_Minimum_Dispersion_Strategy::remove (TAO_LB_ReplicaProxy *proxy) { // @@ Ossama: more code that is not thread safe return this->proxies_.remove (proxy); } void -Minimum_Dispersion_Strategy::load_changed (ReplicaProxy_Impl *proxy, - CORBA::Environment &ACE_TRY_ENV) +TAO_LB_Minimum_Dispersion_Strategy::load_changed (TAO_LB_ReplicaProxy *proxy, + CORBA::Environment &ACE_TRY_ENV) { // @@ Ossama: more code that is not thread safe if (this->proxies_.is_empty ()) return; - ReplicaProxySetIterator begin = this->proxies_.begin (); - ReplicaProxySetIterator end = this->proxies_.end (); + TAO_LB_ReplicaProxySetIterator begin = this->proxies_.begin (); + TAO_LB_ReplicaProxySetIterator end = this->proxies_.end (); float s = 0; CORBA::ULong n = 0; - ReplicaProxySetIterator i = begin; + TAO_LB_ReplicaProxySetIterator i = begin; for (;i != end; ++i) { s += (*i)->current_load (); n++; } - float avg = s / n; + float avg = (n == 0 ? s : s / n); float cl = proxy->current_load (); if (avg == 0) diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/Minimum_Dispersion.h b/TAO/orbsvcs/orbsvcs/LoadBalancing/Minimum_Dispersion.h index 213eb22b443..99b119034c0 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/Minimum_Dispersion.h +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/Minimum_Dispersion.h @@ -11,7 +11,7 @@ // Minimum_Dispersion_Strategy.h // // = AUTHOR -// Ossama Othman <ossama@uci.edu> +// Carlos O'Ryan <coryan@uci.edu> // // ============================================================================ @@ -22,43 +22,46 @@ #include "orbsvcs/LoadBalancingS.h" #include "ace/Containers.h" +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + // @@ Ossama: my class names suck too, any idea on what would be a // good name for this strategy? It basically tries to keep all the // loads "close to the average", if one server is much higher than // the load it is deemed too loaded and the advisory is sent. // Forward declarations -class ReplicaProxy_Impl; +class TAO_LB_ReplicaProxy; -typedef ACE_Unbounded_Set<ReplicaProxy_Impl *> ReplicaProxySet; -typedef ACE_Unbounded_Set_Iterator<ReplicaProxy_Impl *> ReplicaProxySetIterator; +typedef ACE_Unbounded_Set<TAO_LB_ReplicaProxy *> TAO_LB_ReplicaProxySet; +typedef ACE_Unbounded_Set_Iterator<TAO_LB_ReplicaProxy *> TAO_LB_ReplicaProxySetIterator; -class TAO_LoadBalancing_Export Minimum_Dispersion_Strategy : public Load_Balancing_Strategy +class TAO_LoadBalancing_Export TAO_LB_Minimum_Dispersion_Strategy : public TAO_LB_LoadBalancing_Strategy { // = TITLE - // Round Robin load balancing strategy + // Minimum Dispersion load balancing strategy // = DESCRIPTION - // Simple load balancing strategy that causes requests to be - // forwarded to next Replica in the set, i.e. in a "round robin" - // fashion. + // public: - Minimum_Dispersion_Strategy (void); + TAO_LB_Minimum_Dispersion_Strategy (void); // Constructor. - ~Minimum_Dispersion_Strategy (void); + ~TAO_LB_Minimum_Dispersion_Strategy (void); // Destructor - // = The Load_Balancing_Strategy methods - virtual CORBA::Object_ptr replica (CORBA_Environment &ACE_TRY_ENV); - virtual int insert (ReplicaProxy_Impl *); - virtual int remove (ReplicaProxy_Impl *); - virtual void load_changed (ReplicaProxy_Impl *, + // = The TAO_LB_LoadBalancing_Strategy methods + virtual CORBA::Object_ptr replica (CORBA_Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException)); + virtual int insert (TAO_LB_ReplicaProxy *); + virtual int remove (TAO_LB_ReplicaProxy *); + virtual void load_changed (TAO_LB_ReplicaProxy *, CORBA::Environment &ACE_TRY_ENV); private: - ReplicaProxySet proxies_; + TAO_LB_ReplicaProxySet proxies_; // Set containing the ReplicaProxy servants. }; diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaProxy.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaProxy.cpp index 1b8ce2171cb..f4d6e33e3d1 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaProxy.cpp +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaProxy.cpp @@ -11,7 +11,7 @@ ACE_RCSID(orbsvcs, ReplicaProxy, "$Id$") -ReplicaProxy_Impl::ReplicaProxy_Impl (void) +TAO_LB_ReplicaProxy::TAO_LB_ReplicaProxy (void) : has_high_load_ (0), balancer_ (0), current_load_ (0), @@ -21,8 +21,8 @@ ReplicaProxy_Impl::ReplicaProxy_Impl (void) } void -ReplicaProxy_Impl::current_load (CORBA::Float load, - CORBA::Environment &ACE_TRY_ENV) +TAO_LB_ReplicaProxy::current_load (CORBA::Float load, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((LoadBalancing::ReplicaProxy::InvalidLoad, CORBA::SystemException)) { @@ -39,7 +39,7 @@ ReplicaProxy_Impl::current_load (CORBA::Float load, } void -ReplicaProxy_Impl::disconnect (CORBA::Environment &ACE_TRY_ENV) +TAO_LB_ReplicaProxy::disconnect (CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((LoadBalancing::ReplicaProxy::NotConnected, CORBA::SystemException)) { @@ -58,10 +58,10 @@ ReplicaProxy_Impl::disconnect (CORBA::Environment &ACE_TRY_ENV) } } -void ReplicaProxy_Impl::connect (LoadBalancer_Impl *balancer, - LoadBalancing::ReplicaControl_ptr control, - CORBA::Object_ptr replica, - CORBA::Environment &ACE_TRY_ENV) +void TAO_LB_ReplicaProxy::connect (TAO_LB_LoadBalancer *balancer, + LoadBalancing::ReplicaControl_ptr control, + CORBA::Object_ptr replica, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((LoadBalancing::ReplicaProxy::NilControl, LoadBalancing::ReplicaProxy::NilReplica, CORBA::SystemException)) @@ -74,14 +74,14 @@ void ReplicaProxy_Impl::connect (LoadBalancer_Impl *balancer, if (balancer == 0) ACE_THROW (CORBA::BAD_PARAM ( CORBA_SystemException::_tao_minor_code ( - TAO_NULL_POINTER_MINOR_CODE, - 0), + TAO_DEFAULT_MINOR_CODE, + EINVAL), CORBA::COMPLETED_NO)); else this->balancer_ = balancer; if (!CORBA::is_nil (control)) - this->control_ = LoadBalancing::ReplicaControl::_duplicate (control); + this->control_ = LoadBalancing::ReplicaControl::_duplicate (control); else ACE_THROW (LoadBalancing::ReplicaProxy::NilControl ()); diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaProxy.h b/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaProxy.h index fa4679be71e..a183e7135b6 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaProxy.h +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaProxy.h @@ -19,6 +19,11 @@ #define TAO_REPLICAPROXY_H #include "orbsvcs/LoadBalancingS.h" +#include "LoadBalancing_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ #if defined(_MSC_VER) #if (_MSC_VER >= 1200) @@ -27,17 +32,17 @@ #pragma warning(disable:4250) #endif /* _MSC_VER */ -class LoadBalancer_Impl; +class TAO_LB_LoadBalancer; // Forward declaration -class TAO_LoadBalancing_Export ReplicaProxy_Impl : +class TAO_LoadBalancing_Export TAO_LB_ReplicaProxy : public virtual POA_LoadBalancing::ReplicaProxy, public virtual PortableServer::RefCountServantBase { - friend LoadBalancer_Impl; + friend TAO_LB_LoadBalancer; public: - ReplicaProxy_Impl (void); + TAO_LB_ReplicaProxy (void); CORBA::Float current_load (void) const; // Read the stored load of the Object being load balanced from the @@ -78,7 +83,7 @@ public: private: - void connect (LoadBalancer_Impl *balancer, + void connect (TAO_LB_LoadBalancer *balancer, LoadBalancing::ReplicaControl_ptr control, CORBA::Object_ptr replica, CORBA::Environment &ACE_TRY_ENV) @@ -92,7 +97,7 @@ private: CORBA::Object_var replica_; // Reference to the Object being load balanced. - LoadBalancer_Impl *balancer_; + TAO_LB_LoadBalancer *balancer_; // Pointer to the Load Balancer this ReplicaProxy is registered // with. diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaProxy.i b/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaProxy.i index ab649f09952..c5ab4d03157 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaProxy.i +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaProxy.i @@ -1,13 +1,14 @@ +// -*- C++ -*- // $Id$ ACE_INLINE CORBA::Float -ReplicaProxy_Impl::current_load (void) const +TAO_LB_ReplicaProxy::current_load (void) const { return this->current_load_; } ACE_INLINE CORBA::Object_ptr -ReplicaProxy_Impl::replica (void) +TAO_LB_ReplicaProxy::replica (void) { return CORBA::Object::_duplicate (this->replica_.in ()); } diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/Round_Robin_Strategy.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing/Round_Robin_Strategy.cpp index 4b995d286e8..8f5ded977d3 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/Round_Robin_Strategy.cpp +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/Round_Robin_Strategy.cpp @@ -9,22 +9,22 @@ ACE_RCSID(orbsvcs, Round_Robin_Strategy, "$Id$") -Round_Robin_Strategy::Round_Robin_Strategy (void) +TAO_LB_Round_Robin_Strategy::TAO_LB_Round_Robin_Strategy (void) : proxies_ (), next_replica_ (this->proxies_.begin ()) { } -Round_Robin_Strategy::~Round_Robin_Strategy (void) +TAO_LB_Round_Robin_Strategy::~TAO_LB_Round_Robin_Strategy (void) { // @@ Are the objects deactivated from the POA? And shouldn't this // be done by the LoadBalancing strategy *before* the destructor is // invoked? - ReplicaProxySetIterator begin = this->proxies_.begin (); - ReplicaProxySetIterator end = this->proxies_.end (); + TAO_LB_ReplicaProxySetIterator begin = this->proxies_.begin (); + TAO_LB_ReplicaProxySetIterator end = this->proxies_.end (); - for (ReplicaProxySetIterator i = begin; + for (TAO_LB_ReplicaProxySetIterator i = begin; i != end; ++i) { @@ -34,7 +34,7 @@ Round_Robin_Strategy::~Round_Robin_Strategy (void) } CORBA::Object_ptr -Round_Robin_Strategy::replica (CORBA::Environment &ACE_TRY_ENV) +TAO_LB_Round_Robin_Strategy::replica (CORBA::Environment &ACE_TRY_ENV) { // @@ Ossama: more code that is not thread safe if (this->proxies_.is_empty ()) @@ -53,7 +53,7 @@ Round_Robin_Strategy::replica (CORBA::Environment &ACE_TRY_ENV) if (this->next_replica_ == this->proxies_.end ()) this->next_replica_ = this->proxies_.begin (); - ReplicaProxy_Impl * proxy_servant = *(this->next_replica_); + TAO_LB_ReplicaProxy * proxy_servant = *(this->next_replica_); // Advance to the next Replica in the set in preparation for the // next call to this method. @@ -74,7 +74,7 @@ Round_Robin_Strategy::replica (CORBA::Environment &ACE_TRY_ENV) } int -Round_Robin_Strategy::insert (ReplicaProxy_Impl *proxy) +TAO_LB_Round_Robin_Strategy::insert (TAO_LB_ReplicaProxy *proxy) { // @@ Ossama: more code that is not thread safe int r = this->proxies_.insert (proxy); @@ -83,7 +83,7 @@ Round_Robin_Strategy::insert (ReplicaProxy_Impl *proxy) } int -Round_Robin_Strategy::remove (ReplicaProxy_Impl *proxy) +TAO_LB_Round_Robin_Strategy::remove (TAO_LB_ReplicaProxy *proxy) { // @@ Ossama: more code that is not thread safe int r = this->proxies_.remove (proxy); diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/Round_Robin_Strategy.h b/TAO/orbsvcs/orbsvcs/LoadBalancing/Round_Robin_Strategy.h index a279071a46f..e0fe5485b84 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/Round_Robin_Strategy.h +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/Round_Robin_Strategy.h @@ -22,8 +22,12 @@ #include "orbsvcs/LoadBalancingS.h" #include "ace/Containers.h" +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + // Forward declarations -class ReplicaProxy_Impl; +class TAO_LB_ReplicaProxy; // @@ Ossama: is this the kind of data structure that you want to use // in this case? I mean the iterator is invalidated on each insertion @@ -32,10 +36,10 @@ class ReplicaProxy_Impl; // servers should be small (say around 10), and additions/removals // rare, so the data structure is probably not a real problem. -typedef ACE_Unbounded_Set<ReplicaProxy_Impl *> ReplicaProxySet; -typedef ACE_Unbounded_Set_Iterator<ReplicaProxy_Impl *> ReplicaProxySetIterator; +typedef ACE_Unbounded_Set<TAO_LB_ReplicaProxy *> TAO_LB_ReplicaProxySet; +typedef ACE_Unbounded_Set_Iterator<TAO_LB_ReplicaProxy *> TAO_LB_ReplicaProxySetIterator; -class TAO_LoadBalancing_Export Round_Robin_Strategy : public Load_Balancing_Strategy +class TAO_LoadBalancing_Export TAO_LB_Round_Robin_Strategy : public TAO_LB_LoadBalancing_Strategy { // = TITLE // Round Robin load balancing strategy @@ -46,22 +50,23 @@ class TAO_LoadBalancing_Export Round_Robin_Strategy : public Load_Balancing_Stra // fashion. public: - Round_Robin_Strategy (void); + TAO_LB_Round_Robin_Strategy (void); // Constructor. - ~Round_Robin_Strategy (void); + ~TAO_LB_Round_Robin_Strategy (void); // Destructor // = The Load_Balancing_Strategy methods - virtual CORBA::Object_ptr replica (CORBA_Environment &ACE_TRY_ENV); - virtual int insert (ReplicaProxy_Impl *); - virtual int remove (ReplicaProxy_Impl *); + virtual CORBA::Object_ptr replica (CORBA_Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException)); + virtual int insert (TAO_LB_ReplicaProxy *); + virtual int remove (TAO_LB_ReplicaProxy *); private: - ReplicaProxySet proxies_; + TAO_LB_ReplicaProxySet proxies_; // Set containing the ReplicaProxy servants. - ACE_Unbounded_Set_Iterator<ReplicaProxy_Impl*> next_replica_; + ACE_Unbounded_Set_Iterator<TAO_LB_ReplicaProxy *> next_replica_; }; #endif /* ROUND_ROBIN_STRATEGY_H */ diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing_Strategy.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing_Strategy.cpp index bb90a27e7c8..a64cf50f4b7 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing_Strategy.cpp +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing_Strategy.cpp @@ -12,13 +12,13 @@ ACE_RCSID(orbsvcs, LoadBalancing_Strategy, "$Id$") -Load_Balancing_Strategy::~Load_Balancing_Strategy (void) +TAO_LB_LoadBalancing_Strategy::~TAO_LB_LoadBalancing_Strategy (void) { } void -Load_Balancing_Strategy::load_changed (ReplicaProxy_Impl *, - CORBA::Environment &) +TAO_LB_LoadBalancing_Strategy::load_changed (TAO_LB_ReplicaProxy *, + CORBA::Environment &) { } @@ -26,14 +26,14 @@ Load_Balancing_Strategy::load_changed (ReplicaProxy_Impl *, // used in two strategies, but it sound kind of silly... #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) -template class ACE_Node<ReplicaProxy_Impl*>; -template class ACE_Unbounded_Set<ReplicaProxy_Impl*>; -template class ACE_Unbounded_Set_Iterator<ReplicaProxy_Impl*>; +template class ACE_Node<TAO_LB_ReplicaProxy *>; +template class ACE_Unbounded_Set<TAO_LB_ReplicaProxy *>; +template class ACE_Unbounded_Set_Iterator<TAO_LB_ReplicaProxy *>; #elif defined(ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) -#pragma instantiate ACE_Node<ReplicaProxy_Impl*> -#pragma instantiate ACE_Unbounded_Set<ReplicaProxy_Impl*> -#pragma instantiate ACE_Unbounded_Set_Iterator<ReplicaProxy_Impl*> +#pragma instantiate ACE_Node<TAO_LB_ReplicaProxy *> +#pragma instantiate ACE_Unbounded_Set<TAO_LB_ReplicaProxy *> +#pragma instantiate ACE_Unbounded_Set_Iterator<TAO_LB_ReplicaProxy *> #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing_Strategy.h b/TAO/orbsvcs/orbsvcs/LoadBalancing_Strategy.h index 72b580e6919..916e7357bc1 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing_Strategy.h +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing_Strategy.h @@ -19,15 +19,17 @@ #define LOAD_BALANCING_STRATEGY_H #include "orbsvcs/LoadBalancingS.h" +#include "LoadBalancing_export.h" -// @@ Ossama: the general comments on filenames, class names, -// TAO_XXX_Export an other things like that apply. +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ -class ReplicaProxy_Impl; +class TAO_LB_ReplicaProxy; // The abstract load balancing strategy class. -class Load_Balancing_Strategy +class TAO_LoadBalancing_Export TAO_LB_LoadBalancing_Strategy { // = TITLE // Load balancing strategy abstract base class. @@ -37,7 +39,7 @@ class Load_Balancing_Strategy // strategies should implement. public: - virtual ~Load_Balancing_Strategy (void); + virtual ~TAO_LB_LoadBalancing_Strategy (void); // Destructor // @@ The name of the method should be more meaningful, what about: @@ -48,14 +50,14 @@ public: // Return the object reference to the Replica to which requests should // be redirected. - virtual int insert (ReplicaProxy_Impl *) = 0; + virtual int insert (TAO_LB_ReplicaProxy *) = 0; // Insert ReplicaProxy servant into the set of replica proxies upon // which the load balancing algorithm is performed. - virtual int remove (ReplicaProxy_Impl *) = 0; + virtual int remove (TAO_LB_ReplicaProxy *) = 0; // Remove ReplicaProxy servant from the set of replica proxies. - virtual void load_changed (ReplicaProxy_Impl *impl, + virtual void load_changed (TAO_LB_ReplicaProxy *proxy, CORBA::Environment &ACE_TRY_ENV); // The load on one proxy has changed. // @@ Ossama: see my comments on LoadBalancing_i about changing the diff --git a/TAO/orbsvcs/orbsvcs/Minimum_Dispersion.cpp b/TAO/orbsvcs/orbsvcs/Minimum_Dispersion.cpp index a7c758be4cb..c7f87a6d00f 100644 --- a/TAO/orbsvcs/orbsvcs/Minimum_Dispersion.cpp +++ b/TAO/orbsvcs/orbsvcs/Minimum_Dispersion.cpp @@ -9,18 +9,18 @@ ACE_RCSID(orbsvcs, Minimum_Dispersion, "$Id$") -Minimum_Dispersion_Strategy::Minimum_Dispersion_Strategy (void) +TAO_LB_Minimum_Dispersion_Strategy::TAO_LB_Minimum_Dispersion_Strategy (void) : proxies_ () { } -Minimum_Dispersion_Strategy::~Minimum_Dispersion_Strategy (void) +TAO_LB_Minimum_Dispersion_Strategy::~TAO_LB_Minimum_Dispersion_Strategy (void) { // @@ Ossama: more code that is not thread safe - ReplicaProxySetIterator begin = this->proxies_.begin (); - ReplicaProxySetIterator end = this->proxies_.end (); + TAO_LB_ReplicaProxySetIterator begin = this->proxies_.begin (); + TAO_LB_ReplicaProxySetIterator end = this->proxies_.end (); - for (ReplicaProxySetIterator i = begin; + for (TAO_LB_ReplicaProxySetIterator i = begin; i != end; ++i) { @@ -30,16 +30,16 @@ Minimum_Dispersion_Strategy::~Minimum_Dispersion_Strategy (void) } CORBA::Object_ptr -Minimum_Dispersion_Strategy::replica (CORBA::Environment &ACE_TRY_ENV) +TAO_LB_Minimum_Dispersion_Strategy::replica (CORBA::Environment &ACE_TRY_ENV) { // @@ Ossama: more code that is not thread safe while (!this->proxies_.is_empty ()) { - ReplicaProxySetIterator begin = this->proxies_.begin (); - ReplicaProxySetIterator end = this->proxies_.end (); + TAO_LB_ReplicaProxySetIterator begin = this->proxies_.begin (); + TAO_LB_ReplicaProxySetIterator end = this->proxies_.end (); - ReplicaProxySetIterator i = begin; - ReplicaProxy_Impl * proxy = (*i); + TAO_LB_ReplicaProxySetIterator i = begin; + TAO_LB_ReplicaProxy * proxy = (*i); float d = (*i)->current_load (); for (++i ; i != end; ++i) @@ -80,44 +80,43 @@ Minimum_Dispersion_Strategy::replica (CORBA::Environment &ACE_TRY_ENV) // @@ What do we do if the set is empty? ACE_THROW_RETURN (CORBA::OBJECT_NOT_EXIST (), CORBA::Object::_nil ()); - } int -Minimum_Dispersion_Strategy::insert (ReplicaProxy_Impl *proxy) +TAO_LB_Minimum_Dispersion_Strategy::insert (TAO_LB_ReplicaProxy *proxy) { // @@ Ossama: more code that is not thread safe return this->proxies_.insert (proxy); } int -Minimum_Dispersion_Strategy::remove (ReplicaProxy_Impl *proxy) +TAO_LB_Minimum_Dispersion_Strategy::remove (TAO_LB_ReplicaProxy *proxy) { // @@ Ossama: more code that is not thread safe return this->proxies_.remove (proxy); } void -Minimum_Dispersion_Strategy::load_changed (ReplicaProxy_Impl *proxy, - CORBA::Environment &ACE_TRY_ENV) +TAO_LB_Minimum_Dispersion_Strategy::load_changed (TAO_LB_ReplicaProxy *proxy, + CORBA::Environment &ACE_TRY_ENV) { // @@ Ossama: more code that is not thread safe if (this->proxies_.is_empty ()) return; - ReplicaProxySetIterator begin = this->proxies_.begin (); - ReplicaProxySetIterator end = this->proxies_.end (); + TAO_LB_ReplicaProxySetIterator begin = this->proxies_.begin (); + TAO_LB_ReplicaProxySetIterator end = this->proxies_.end (); float s = 0; CORBA::ULong n = 0; - ReplicaProxySetIterator i = begin; + TAO_LB_ReplicaProxySetIterator i = begin; for (;i != end; ++i) { s += (*i)->current_load (); n++; } - float avg = s / n; + float avg = (n == 0 ? s : s / n); float cl = proxy->current_load (); if (avg == 0) diff --git a/TAO/orbsvcs/orbsvcs/Minimum_Dispersion.h b/TAO/orbsvcs/orbsvcs/Minimum_Dispersion.h index 213eb22b443..99b119034c0 100644 --- a/TAO/orbsvcs/orbsvcs/Minimum_Dispersion.h +++ b/TAO/orbsvcs/orbsvcs/Minimum_Dispersion.h @@ -11,7 +11,7 @@ // Minimum_Dispersion_Strategy.h // // = AUTHOR -// Ossama Othman <ossama@uci.edu> +// Carlos O'Ryan <coryan@uci.edu> // // ============================================================================ @@ -22,43 +22,46 @@ #include "orbsvcs/LoadBalancingS.h" #include "ace/Containers.h" +# if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +# endif /* ACE_LACKS_PRAGMA_ONCE */ + // @@ Ossama: my class names suck too, any idea on what would be a // good name for this strategy? It basically tries to keep all the // loads "close to the average", if one server is much higher than // the load it is deemed too loaded and the advisory is sent. // Forward declarations -class ReplicaProxy_Impl; +class TAO_LB_ReplicaProxy; -typedef ACE_Unbounded_Set<ReplicaProxy_Impl *> ReplicaProxySet; -typedef ACE_Unbounded_Set_Iterator<ReplicaProxy_Impl *> ReplicaProxySetIterator; +typedef ACE_Unbounded_Set<TAO_LB_ReplicaProxy *> TAO_LB_ReplicaProxySet; +typedef ACE_Unbounded_Set_Iterator<TAO_LB_ReplicaProxy *> TAO_LB_ReplicaProxySetIterator; -class TAO_LoadBalancing_Export Minimum_Dispersion_Strategy : public Load_Balancing_Strategy +class TAO_LoadBalancing_Export TAO_LB_Minimum_Dispersion_Strategy : public TAO_LB_LoadBalancing_Strategy { // = TITLE - // Round Robin load balancing strategy + // Minimum Dispersion load balancing strategy // = DESCRIPTION - // Simple load balancing strategy that causes requests to be - // forwarded to next Replica in the set, i.e. in a "round robin" - // fashion. + // public: - Minimum_Dispersion_Strategy (void); + TAO_LB_Minimum_Dispersion_Strategy (void); // Constructor. - ~Minimum_Dispersion_Strategy (void); + ~TAO_LB_Minimum_Dispersion_Strategy (void); // Destructor - // = The Load_Balancing_Strategy methods - virtual CORBA::Object_ptr replica (CORBA_Environment &ACE_TRY_ENV); - virtual int insert (ReplicaProxy_Impl *); - virtual int remove (ReplicaProxy_Impl *); - virtual void load_changed (ReplicaProxy_Impl *, + // = The TAO_LB_LoadBalancing_Strategy methods + virtual CORBA::Object_ptr replica (CORBA_Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException)); + virtual int insert (TAO_LB_ReplicaProxy *); + virtual int remove (TAO_LB_ReplicaProxy *); + virtual void load_changed (TAO_LB_ReplicaProxy *, CORBA::Environment &ACE_TRY_ENV); private: - ReplicaProxySet proxies_; + TAO_LB_ReplicaProxySet proxies_; // Set containing the ReplicaProxy servants. }; diff --git a/TAO/orbsvcs/orbsvcs/ReplicaProxy.cpp b/TAO/orbsvcs/orbsvcs/ReplicaProxy.cpp index 1b8ce2171cb..f4d6e33e3d1 100644 --- a/TAO/orbsvcs/orbsvcs/ReplicaProxy.cpp +++ b/TAO/orbsvcs/orbsvcs/ReplicaProxy.cpp @@ -11,7 +11,7 @@ ACE_RCSID(orbsvcs, ReplicaProxy, "$Id$") -ReplicaProxy_Impl::ReplicaProxy_Impl (void) +TAO_LB_ReplicaProxy::TAO_LB_ReplicaProxy (void) : has_high_load_ (0), balancer_ (0), current_load_ (0), @@ -21,8 +21,8 @@ ReplicaProxy_Impl::ReplicaProxy_Impl (void) } void -ReplicaProxy_Impl::current_load (CORBA::Float load, - CORBA::Environment &ACE_TRY_ENV) +TAO_LB_ReplicaProxy::current_load (CORBA::Float load, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((LoadBalancing::ReplicaProxy::InvalidLoad, CORBA::SystemException)) { @@ -39,7 +39,7 @@ ReplicaProxy_Impl::current_load (CORBA::Float load, } void -ReplicaProxy_Impl::disconnect (CORBA::Environment &ACE_TRY_ENV) +TAO_LB_ReplicaProxy::disconnect (CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((LoadBalancing::ReplicaProxy::NotConnected, CORBA::SystemException)) { @@ -58,10 +58,10 @@ ReplicaProxy_Impl::disconnect (CORBA::Environment &ACE_TRY_ENV) } } -void ReplicaProxy_Impl::connect (LoadBalancer_Impl *balancer, - LoadBalancing::ReplicaControl_ptr control, - CORBA::Object_ptr replica, - CORBA::Environment &ACE_TRY_ENV) +void TAO_LB_ReplicaProxy::connect (TAO_LB_LoadBalancer *balancer, + LoadBalancing::ReplicaControl_ptr control, + CORBA::Object_ptr replica, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((LoadBalancing::ReplicaProxy::NilControl, LoadBalancing::ReplicaProxy::NilReplica, CORBA::SystemException)) @@ -74,14 +74,14 @@ void ReplicaProxy_Impl::connect (LoadBalancer_Impl *balancer, if (balancer == 0) ACE_THROW (CORBA::BAD_PARAM ( CORBA_SystemException::_tao_minor_code ( - TAO_NULL_POINTER_MINOR_CODE, - 0), + TAO_DEFAULT_MINOR_CODE, + EINVAL), CORBA::COMPLETED_NO)); else this->balancer_ = balancer; if (!CORBA::is_nil (control)) - this->control_ = LoadBalancing::ReplicaControl::_duplicate (control); + this->control_ = LoadBalancing::ReplicaControl::_duplicate (control); else ACE_THROW (LoadBalancing::ReplicaProxy::NilControl ()); diff --git a/TAO/orbsvcs/orbsvcs/ReplicaProxy.h b/TAO/orbsvcs/orbsvcs/ReplicaProxy.h index fa4679be71e..a183e7135b6 100644 --- a/TAO/orbsvcs/orbsvcs/ReplicaProxy.h +++ b/TAO/orbsvcs/orbsvcs/ReplicaProxy.h @@ -19,6 +19,11 @@ #define TAO_REPLICAPROXY_H #include "orbsvcs/LoadBalancingS.h" +#include "LoadBalancing_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ #if defined(_MSC_VER) #if (_MSC_VER >= 1200) @@ -27,17 +32,17 @@ #pragma warning(disable:4250) #endif /* _MSC_VER */ -class LoadBalancer_Impl; +class TAO_LB_LoadBalancer; // Forward declaration -class TAO_LoadBalancing_Export ReplicaProxy_Impl : +class TAO_LoadBalancing_Export TAO_LB_ReplicaProxy : public virtual POA_LoadBalancing::ReplicaProxy, public virtual PortableServer::RefCountServantBase { - friend LoadBalancer_Impl; + friend TAO_LB_LoadBalancer; public: - ReplicaProxy_Impl (void); + TAO_LB_ReplicaProxy (void); CORBA::Float current_load (void) const; // Read the stored load of the Object being load balanced from the @@ -78,7 +83,7 @@ public: private: - void connect (LoadBalancer_Impl *balancer, + void connect (TAO_LB_LoadBalancer *balancer, LoadBalancing::ReplicaControl_ptr control, CORBA::Object_ptr replica, CORBA::Environment &ACE_TRY_ENV) @@ -92,7 +97,7 @@ private: CORBA::Object_var replica_; // Reference to the Object being load balanced. - LoadBalancer_Impl *balancer_; + TAO_LB_LoadBalancer *balancer_; // Pointer to the Load Balancer this ReplicaProxy is registered // with. diff --git a/TAO/orbsvcs/orbsvcs/ReplicaProxy.i b/TAO/orbsvcs/orbsvcs/ReplicaProxy.i index ab649f09952..c5ab4d03157 100644 --- a/TAO/orbsvcs/orbsvcs/ReplicaProxy.i +++ b/TAO/orbsvcs/orbsvcs/ReplicaProxy.i @@ -1,13 +1,14 @@ +// -*- C++ -*- // $Id$ ACE_INLINE CORBA::Float -ReplicaProxy_Impl::current_load (void) const +TAO_LB_ReplicaProxy::current_load (void) const { return this->current_load_; } ACE_INLINE CORBA::Object_ptr -ReplicaProxy_Impl::replica (void) +TAO_LB_ReplicaProxy::replica (void) { return CORBA::Object::_duplicate (this->replica_.in ()); } diff --git a/TAO/orbsvcs/orbsvcs/Round_Robin_Strategy.cpp b/TAO/orbsvcs/orbsvcs/Round_Robin_Strategy.cpp index 4b995d286e8..8f5ded977d3 100644 --- a/TAO/orbsvcs/orbsvcs/Round_Robin_Strategy.cpp +++ b/TAO/orbsvcs/orbsvcs/Round_Robin_Strategy.cpp @@ -9,22 +9,22 @@ ACE_RCSID(orbsvcs, Round_Robin_Strategy, "$Id$") -Round_Robin_Strategy::Round_Robin_Strategy (void) +TAO_LB_Round_Robin_Strategy::TAO_LB_Round_Robin_Strategy (void) : proxies_ (), next_replica_ (this->proxies_.begin ()) { } -Round_Robin_Strategy::~Round_Robin_Strategy (void) +TAO_LB_Round_Robin_Strategy::~TAO_LB_Round_Robin_Strategy (void) { // @@ Are the objects deactivated from the POA? And shouldn't this // be done by the LoadBalancing strategy *before* the destructor is // invoked? - ReplicaProxySetIterator begin = this->proxies_.begin (); - ReplicaProxySetIterator end = this->proxies_.end (); + TAO_LB_ReplicaProxySetIterator begin = this->proxies_.begin (); + TAO_LB_ReplicaProxySetIterator end = this->proxies_.end (); - for (ReplicaProxySetIterator i = begin; + for (TAO_LB_ReplicaProxySetIterator i = begin; i != end; ++i) { @@ -34,7 +34,7 @@ Round_Robin_Strategy::~Round_Robin_Strategy (void) } CORBA::Object_ptr -Round_Robin_Strategy::replica (CORBA::Environment &ACE_TRY_ENV) +TAO_LB_Round_Robin_Strategy::replica (CORBA::Environment &ACE_TRY_ENV) { // @@ Ossama: more code that is not thread safe if (this->proxies_.is_empty ()) @@ -53,7 +53,7 @@ Round_Robin_Strategy::replica (CORBA::Environment &ACE_TRY_ENV) if (this->next_replica_ == this->proxies_.end ()) this->next_replica_ = this->proxies_.begin (); - ReplicaProxy_Impl * proxy_servant = *(this->next_replica_); + TAO_LB_ReplicaProxy * proxy_servant = *(this->next_replica_); // Advance to the next Replica in the set in preparation for the // next call to this method. @@ -74,7 +74,7 @@ Round_Robin_Strategy::replica (CORBA::Environment &ACE_TRY_ENV) } int -Round_Robin_Strategy::insert (ReplicaProxy_Impl *proxy) +TAO_LB_Round_Robin_Strategy::insert (TAO_LB_ReplicaProxy *proxy) { // @@ Ossama: more code that is not thread safe int r = this->proxies_.insert (proxy); @@ -83,7 +83,7 @@ Round_Robin_Strategy::insert (ReplicaProxy_Impl *proxy) } int -Round_Robin_Strategy::remove (ReplicaProxy_Impl *proxy) +TAO_LB_Round_Robin_Strategy::remove (TAO_LB_ReplicaProxy *proxy) { // @@ Ossama: more code that is not thread safe int r = this->proxies_.remove (proxy); diff --git a/TAO/orbsvcs/orbsvcs/Round_Robin_Strategy.h b/TAO/orbsvcs/orbsvcs/Round_Robin_Strategy.h index a279071a46f..e0fe5485b84 100644 --- a/TAO/orbsvcs/orbsvcs/Round_Robin_Strategy.h +++ b/TAO/orbsvcs/orbsvcs/Round_Robin_Strategy.h @@ -22,8 +22,12 @@ #include "orbsvcs/LoadBalancingS.h" #include "ace/Containers.h" +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + // Forward declarations -class ReplicaProxy_Impl; +class TAO_LB_ReplicaProxy; // @@ Ossama: is this the kind of data structure that you want to use // in this case? I mean the iterator is invalidated on each insertion @@ -32,10 +36,10 @@ class ReplicaProxy_Impl; // servers should be small (say around 10), and additions/removals // rare, so the data structure is probably not a real problem. -typedef ACE_Unbounded_Set<ReplicaProxy_Impl *> ReplicaProxySet; -typedef ACE_Unbounded_Set_Iterator<ReplicaProxy_Impl *> ReplicaProxySetIterator; +typedef ACE_Unbounded_Set<TAO_LB_ReplicaProxy *> TAO_LB_ReplicaProxySet; +typedef ACE_Unbounded_Set_Iterator<TAO_LB_ReplicaProxy *> TAO_LB_ReplicaProxySetIterator; -class TAO_LoadBalancing_Export Round_Robin_Strategy : public Load_Balancing_Strategy +class TAO_LoadBalancing_Export TAO_LB_Round_Robin_Strategy : public TAO_LB_LoadBalancing_Strategy { // = TITLE // Round Robin load balancing strategy @@ -46,22 +50,23 @@ class TAO_LoadBalancing_Export Round_Robin_Strategy : public Load_Balancing_Stra // fashion. public: - Round_Robin_Strategy (void); + TAO_LB_Round_Robin_Strategy (void); // Constructor. - ~Round_Robin_Strategy (void); + ~TAO_LB_Round_Robin_Strategy (void); // Destructor // = The Load_Balancing_Strategy methods - virtual CORBA::Object_ptr replica (CORBA_Environment &ACE_TRY_ENV); - virtual int insert (ReplicaProxy_Impl *); - virtual int remove (ReplicaProxy_Impl *); + virtual CORBA::Object_ptr replica (CORBA_Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException)); + virtual int insert (TAO_LB_ReplicaProxy *); + virtual int remove (TAO_LB_ReplicaProxy *); private: - ReplicaProxySet proxies_; + TAO_LB_ReplicaProxySet proxies_; // Set containing the ReplicaProxy servants. - ACE_Unbounded_Set_Iterator<ReplicaProxy_Impl*> next_replica_; + ACE_Unbounded_Set_Iterator<TAO_LB_ReplicaProxy *> next_replica_; }; #endif /* ROUND_ROBIN_STRATEGY_H */ |