diff options
author | Ossama Othman <ossama-othman@users.noreply.github.com> | 2002-10-08 18:58:42 +0000 |
---|---|---|
committer | Ossama Othman <ossama-othman@users.noreply.github.com> | 2002-10-08 18:58:42 +0000 |
commit | 4ab2e70cfd4ec49f2f522045b7f926603ab91a6d (patch) | |
tree | 53161712030f0fb29855ceef9b3ad4b0f8c6e5bd /TAO/orbsvcs/orbsvcs/LoadBalancing | |
parent | 2e02d06a859b23dbd0f4fec6fc17aae38c9f5551 (diff) | |
download | ATCD-4ab2e70cfd4ec49f2f522045b7f926603ab91a6d.tar.gz |
ChangeLogTag:Tue Oct 8 11:56:39 2002 Ossama Othman <ossama@uci.edu>
Diffstat (limited to 'TAO/orbsvcs/orbsvcs/LoadBalancing')
16 files changed, 1 insertions, 1263 deletions
diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ORBInitializer.h b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ORBInitializer.h index c59f5b9b6a7..8d450a1176e 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ORBInitializer.h +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ORBInitializer.h @@ -92,7 +92,7 @@ private: /// The CosLoadBalancing::LoadAlert servant to be used at this /// location. /** - * This is the servant supplied with TAO's Load Balancer. It is + * This is the servant supplied by TAO's Load Balancer. It is * used out of convencience. */ TAO_LB_LoadAlert load_alert_; diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancer_i.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancer_i.cpp deleted file mode 100644 index 66515a35186..00000000000 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancer_i.cpp +++ /dev/null @@ -1,156 +0,0 @@ -// -*- C++ -*- - -// $Id$ - -#include "LoadBalancer_i.h" -#include "ReplicaProxy.h" - -ACE_RCSID(orbsvcs, LoadBalancer, "$Id$") - -#if !defined (__ACE_INLINE__) -#include "LoadBalancer_i.i" -#endif /* __ACE_INLINE__ */ - -TAO_LB_LoadBalancer::TAO_LB_LoadBalancer ( - const char * interface_id, - TAO_LB_LoadBalancing_Strategy *strategy, - PortableServer::POA_ptr root_poa) - : locator_ (this), - strategy_ (strategy), - poa_ () -{ - (void) this->init (interface_id, root_poa); -} - -TAO_LB_LoadBalancer::~TAO_LB_LoadBalancer (void) -{ - // Nothing else -} - -LoadBalancing::ReplicaProxy_ptr -TAO_LB_LoadBalancer::connect (LoadBalancing::ReplicaControl_ptr control, - CORBA::Object_ptr replica - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((LoadBalancing::ReplicaProxy::NilControl, - LoadBalancing::ReplicaProxy::NilReplica, - CORBA::SystemException)) -{ - 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 = proxy; - - proxy->connect (this, control, replica ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (LoadBalancing::ReplicaProxy::_nil ()); - - if (this->strategy_->insert (proxy) == -1) - { - ACE_THROW_RETURN (CORBA::INTERNAL (), - LoadBalancing::ReplicaProxy::_nil ()); - } - - return proxy->_this (ACE_ENV_SINGLE_ARG_PARAMETER); -} - -CORBA::Object_ptr -TAO_LB_LoadBalancer::group_identity (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - return CORBA::Object::_duplicate (this->group_identity_.in ()); -} - -void -TAO_LB_LoadBalancer::load_changed (TAO_LB_ReplicaProxy *proxy - ACE_ENV_ARG_DECL) -{ - this->strategy_->load_changed (proxy ACE_ENV_ARG_PARAMETER); -} - -int -TAO_LB_LoadBalancer::init (const char * repository_id, - PortableServer::POA_ptr root_poa) -{ - ACE_TRY_NEW_ENV - { - // Create the appropriate RequestProcessingPolicy - // (USE_SERVANT_MANAGER) and ServantRetentionPolicy (NON_RETAIN) - // for a ServantLocator. - PortableServer::RequestProcessingPolicy_var request = - root_poa->create_request_processing_policy ( - PortableServer::USE_SERVANT_MANAGER - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - PortableServer::ServantRetentionPolicy_var retention = - root_poa->create_servant_retention_policy ( - PortableServer::NON_RETAIN - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Create the PolicyList. - CORBA::PolicyList policy_list; - policy_list.length (2); - policy_list[0] = - PortableServer::RequestProcessingPolicy::_duplicate ( - request.in ()); - policy_list[1] = - PortableServer::ServantRetentionPolicy::_duplicate ( - retention. in ()); - - // Create the child POA with the ServantManager (ReplicaLocator) - // above policies. - PortableServer::POAManager_var poa_manager = - root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - this->poa_ = root_poa->create_POA ("TAO_LB_ReplicaLocator_POA", - poa_manager.in (), - policy_list - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Activate the child POA. - poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - request->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - retention->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Now set the ReplicaLocator as the child POA's Servant - // Manager. - this->poa_->set_servant_manager (&this->locator_ - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // @@ What ObjectId should be used? - PortableServer::ObjectId_var oid = - PortableServer::string_to_ObjectId ("TAO_LB_ObjectGroup"); - - this->group_identity_ = - this->poa_->create_reference_with_id (oid.in (), - repository_id - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } - ACE_CATCHANY - { - // @@ Should we do anything here? - - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "(%P|%t) Load Balancer initialization:"); - - return -1; - } - ACE_ENDTRY; - - return 0; -} diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancer_i.h b/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancer_i.h deleted file mode 100644 index 7437c529fab..00000000000 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancer_i.h +++ /dev/null @@ -1,114 +0,0 @@ -// -*- C++ -*- - -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO_LoadBalancing -// -// = FILENAME -// LoadBalancer_i.h -// -// = AUTHOR -// Ossama Othman <ossama@uci.edu> -// -// ============================================================================ - -#ifndef TAO_LOADBALANCER_I_H -#define TAO_LOADBALANCER_I_H - -#include "ace/pre.h" - -#include "orbsvcs/LoadBalancingS.h" -#include "ReplicaProxy.h" -#include "ReplicaLocator.h" -#include "LoadBalancing_Strategy.h" -#include "LoadBalancing_export.h" - -# if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -# endif /* ACE_LACKS_PRAGMA_ONCE */ - -// @@ 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, -// for example, if they don't send any updates in X seconds then they -// are removed, or maybe we poll them (using _non_existent) before -// removing. I'm sure there are other aspects of the system that -// could be strategized. - -class TAO_LoadBalancing_Export TAO_LB_LoadBalancer : public virtual POA_LoadBalancing::LoadBalancer -{ -public: - TAO_LB_LoadBalancer (const char *interface_id, - TAO_LB_LoadBalancing_Strategy *strategy, - PortableServer::POA_ptr root_poa); - // Constructor that initializes this Load Balancer for use with a - // Replica that has the specified interface repository ID. - - ~TAO_LB_LoadBalancer (void); - // Destructor. - - // Local methods - - // @@ Ossama: this method is something of my own invention, but i - // think we need to change the interface, to something like: - // load_changed (float old_load, float new_load, proxy) - // that should let us keep the average load (and other similar - // things) pre-computed. - // - void load_changed (TAO_LB_ReplicaProxy *proxy - ACE_ENV_ARG_DECL); - // 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 (TAO_LB_ReplicaProxy *proxy - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)); - // Disconnect proxy from the Load Balancer. - - CORBA::Object_ptr replica (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)); - // Return a reference to the Replica to which client requests should - // be redirected next. - - // = See the descriptions in LoadBalancing.idl - virtual LoadBalancing::ReplicaProxy_ptr connect ( - LoadBalancing::ReplicaControl_ptr control, - CORBA::Object_ptr replica - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((LoadBalancing::ReplicaProxy::NilControl, - LoadBalancing::ReplicaProxy::NilReplica, - CORBA::SystemException)); - virtual CORBA::Object_ptr group_identity (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)); - -private: - int init (const char * repository_id, - PortableServer::POA_ptr root_poa); - // Initialize the <locator_> ReplicaLocator. - -private: - TAO_LB_ReplicaLocator locator_; - // The object that tells the invoking client to forward its requests - // from the LoadBalancer to an actual replica. - - TAO_LB_LoadBalancing_Strategy *strategy_; - // The underlying load balancing strategy. - - PortableServer::POA_var poa_; - // The POA that dispatches requests to the ReplicaLocator. - - CORBA::Object_var group_identity_; - // The group identity -}; - -#if defined (__ACE_INLINE__) -#include "LoadBalancer_i.i" -#endif /* __ACE_INLINE__ */ - -#include "ace/post.h" - -#endif /* TAO_LOADBALANCER_I_H */ diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancer_i.i b/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancer_i.i deleted file mode 100644 index a806f7dfead..00000000000 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancer_i.i +++ /dev/null @@ -1,29 +0,0 @@ -// -*- C++ -*- - -// $Id$ - - -ACE_INLINE void -TAO_LB_LoadBalancer::disconnect (TAO_LB_ReplicaProxy *proxy - ACE_ENV_ARG_DECL_NOT_USED) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - // @@ Ossama, what is the we cannot raise that exception here! - - (void) this->strategy_->remove (proxy); - - // @@ Deactivate the proxy servant. - -#if 0 - if (this->strategy_->remove (proxy) != 0) - ACE_THROW (LoadBalancing::LoadBalancer::InvalidReplicaProxy ()); -#endif /* 0 */ -} - - -ACE_INLINE CORBA::Object_ptr -TAO_LB_LoadBalancer::replica (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - return this->strategy_->replica (ACE_ENV_SINGLE_ARG_PARAMETER); -} diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancing_Strategy.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancing_Strategy.cpp deleted file mode 100644 index 55d9e4ae6fb..00000000000 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancing_Strategy.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// -*- C++ -*- - -// $Id$ - - -#include "LoadBalancing_Strategy.h" -#include "ace/Containers.h" - -#if defined (__ACE_INLINE__) -#include "LoadBalancing_Strategy.i" -#endif /* __ACE_INLINE__ */ - -ACE_RCSID(orbsvcs, LoadBalancing_Strategy, "$Id$") - -TAO_LB_LoadBalancing_Strategy::~TAO_LB_LoadBalancing_Strategy (void) -{ -} - -void -TAO_LB_LoadBalancing_Strategy::load_changed (TAO_LB_ReplicaProxy * - ACE_ENV_ARG_DECL_NOT_USED) -{ -} - -// @@ Ossama: i had to instantiate the template here because it is -// used in two strategies, but it sound kind of silly... -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) - -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<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 deleted file mode 100644 index 0e197de508f..00000000000 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancing_Strategy.h +++ /dev/null @@ -1,75 +0,0 @@ -// -*- C++ -*- - -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO_LoadBalancing -// -// = FILENAME -// LoadBalancing_Strategy.h -// -// = AUTHOR -// Ossama Othman <ossama@uci.edu> -// -// ============================================================================ - -#ifndef LOAD_BALANCING_STRATEGY_H -#define LOAD_BALANCING_STRATEGY_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 */ - -class TAO_LB_ReplicaProxy; - -// The abstract load balancing strategy class. - -class TAO_LoadBalancing_Export TAO_LB_LoadBalancing_Strategy -{ - // = TITLE - // Load balancing strategy abstract base class. - - // = DESCRIPTION - // This abstract base class defines the interface load balancing - // strategies should implement. - -public: - virtual ~TAO_LB_LoadBalancing_Strategy (void); - // Destructor - - // @@ The name of the method should be more meaningful, what about: - // select_replica(), select_unloaded_replica() or something like - // that? - virtual CORBA::Object_ptr replica (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) = 0; - // Return the object reference to the Replica to which requests should - // be redirected. - - 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 (TAO_LB_ReplicaProxy *) = 0; - // Remove ReplicaProxy servant from the set of replica proxies. - - virtual void load_changed (TAO_LB_ReplicaProxy *proxy - ACE_ENV_ARG_DECL); - // The load on one proxy has changed. - // @@ Ossama: see my comments on LoadBalancing_i about changing the - // signature of this method. -}; - -#if !defined (__ACE_INLINE__) -#include "LoadBalancing_Strategy.i" -#endif /* __ACE_INLINE__ */ - -#include "ace/post.h" - -#endif /* LOAD_BALANCING_STRATEGY_H */ diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancing_Strategy.i b/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancing_Strategy.i deleted file mode 100644 index aa25cd5a09f..00000000000 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancing_Strategy.i +++ /dev/null @@ -1,3 +0,0 @@ -// -*- C++ -*- - -// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/Minimum_Dispersion.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing/Minimum_Dispersion.cpp deleted file mode 100644 index c3e9ae40930..00000000000 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/Minimum_Dispersion.cpp +++ /dev/null @@ -1,205 +0,0 @@ -// -*- C++ -*- - -// $Id$ - - -#include "Minimum_Dispersion.h" -#include "ReplicaProxy.h" - -ACE_RCSID(orbsvcs, Minimum_Dispersion, "$Id$") - - -TAO_LB_Minimum_Dispersion_Strategy::TAO_LB_Minimum_Dispersion_Strategy (void) - : proxies_ (), - lock_ () -{ -} - -TAO_LB_Minimum_Dispersion_Strategy::~TAO_LB_Minimum_Dispersion_Strategy (void) -{ - ACE_MT (ACE_GUARD (TAO_SYNCH_MUTEX, - guard, - this->lock_)); - - TAO_LB_ReplicaProxySetIterator begin = this->proxies_.begin (); - TAO_LB_ReplicaProxySetIterator end = this->proxies_.end (); - - // @@ Bad deactivation! - - for (TAO_LB_ReplicaProxySetIterator i = begin; - i != end; - ++i) - { - // Decrease reference count on each proxy servant in the set. - (*i)->_remove_ref (); - } -} - -CORBA::Object_ptr -TAO_LB_Minimum_Dispersion_Strategy::replica (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - for ( ; ; ) - { - ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, - guard, - this->lock_, - CORBA::Object::_nil ()); - - if (this->proxies_.is_empty ()) - // @@ What do we do if the set is empty? - ACE_THROW_RETURN (CORBA::OBJECT_NOT_EXIST (), - CORBA::Object::_nil ()); - - TAO_LB_ReplicaProxySetIterator begin = this->proxies_.begin (); - TAO_LB_ReplicaProxySetIterator end = this->proxies_.end (); - - TAO_LB_ReplicaProxySetIterator i = begin; - TAO_LB_ReplicaProxy * proxy = (*i); - float d = (*i)->current_load (); - - for (++i ; i != end; ++i) - { - if (d > (*i)->current_load ()) - { - proxy = *i; - d = (*i)->current_load (); - } - } - - // Before returning an object reference to the client - // validate it first. - CORBA::Object_var object = - proxy->replica (); - - { - ACE_Reverse_Lock<TAO_SYNCH_MUTEX> reverse_lock (this->lock_); - - ACE_GUARD_RETURN (ACE_Reverse_Lock<TAO_SYNCH_MUTEX>, - reverse_guard, - reverse_lock, - CORBA::Object::_nil ()); - - // @@ Ossama: we should setup a timeout policy here... - ACE_TRY - { - CORBA::Boolean non_existent = - object->_non_existent (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - if (!non_existent) - { - return object._retn (); - } - } - ACE_CATCHANY - { - } - ACE_ENDTRY; - } - - // @@ Ossama: a bit melodramatic, we remove the object if *any* - // exception is thrown. If the object really does not exist (we - // get non_existent==1) then this is exactly what we want to do, - // but if we get something like TRANSIENT we may want to do - // something less drastic, or at least strategize it ;-) - this->proxies_.remove (proxy); - } -} - -int -TAO_LB_Minimum_Dispersion_Strategy::insert (TAO_LB_ReplicaProxy *proxy) -{ - ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, - guard, - this->lock_, - -1)); - - return this->proxies_.insert (proxy); -} - -int -TAO_LB_Minimum_Dispersion_Strategy::remove (TAO_LB_ReplicaProxy *proxy) -{ - ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, - guard, - this->lock_, - -1)); - - return this->proxies_.remove (proxy); -} - -void -TAO_LB_Minimum_Dispersion_Strategy::load_changed (TAO_LB_ReplicaProxy *proxy - ACE_ENV_ARG_DECL) -{ - int send_load_advisory = 0; - - { - ACE_MT (ACE_GUARD (TAO_SYNCH_MUTEX, - guard, - this->lock_)); - - if (this->proxies_.is_empty ()) - return; - - TAO_LB_ReplicaProxySetIterator begin = this->proxies_.begin (); - TAO_LB_ReplicaProxySetIterator end = this->proxies_.end (); - - float s = 0; - CORBA::ULong n = 0; - TAO_LB_ReplicaProxySetIterator i = begin; - for (;i != end; ++i) - { - s += (*i)->current_load (); - n++; - } - - float avg = (n == 0 ? s : s / n); - float cl = proxy->current_load (); - - if (avg == 0) - return; - - float relative_load = cl / avg; - - // @@ Ossama: Make the 1.5 factor adjustable, it is how much - // dispersion we tolerate before starting to send advisories. - if (relative_load > 1 + 1.5F / n) - { - proxy->has_high_load_ = 1; - send_load_advisory = 2; // 2 == Send high load advisory - } - - if (send_load_advisory == 1 && relative_load < 1 + 0.9F / n) - { - proxy->has_high_load_ = 0; - send_load_advisory = 1; // 1 == Send nominal load advisory - } - } - - // @@ Ossama: no debug messages in production code, my fault.... - // ACE_DEBUG ((LM_DEBUG, "Load[%x] %f %f %f\n", - // proxy, cl, avg, relative_load)); - - // @@ Ossama: Make the 1.5 factor adjustable, it is how much - // dispersion we tolerate before starting to send advisories. - if (send_load_advisory == 2) - { - proxy->control_->high_load_advisory (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK; - - return; // We may not throw an exception, so explicitly return. - } - - // @@ Ossama: notice that we wait until the load is signifcantly - // lower before sending the nominal load advisory, it does not - // matter that much because the replicas automatically restart after - // rejecting one client.... - // @@ Ossama: make the 0.9 factor adjustable, at least at - // construction time... - if (send_load_advisory == 1) - { - proxy->control_->nominal_load_advisory (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK; - } -} diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/Minimum_Dispersion.h b/TAO/orbsvcs/orbsvcs/LoadBalancing/Minimum_Dispersion.h deleted file mode 100644 index 938b7ba0ecc..00000000000 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/Minimum_Dispersion.h +++ /dev/null @@ -1,77 +0,0 @@ -// -*- C++ -*- - -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO_LoadBalancing -// -// = FILENAME -// Minimum_Dispersion_Strategy.h -// -// = AUTHOR -// Carlos O'Ryan <coryan@uci.edu> -// -// ============================================================================ - -#ifndef MINIMUM_DISPERSION_H -#define MINIMUM_DISPERSION_H - -#include "ace/pre.h" - -#include "LoadBalancing_Strategy.h" -#include "orbsvcs/LoadBalancingS.h" -#include "ace/Containers.h" -#include "ace/Synch.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 TAO_LB_ReplicaProxy; - -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 TAO_LB_Minimum_Dispersion_Strategy : public TAO_LB_LoadBalancing_Strategy -{ - // = TITLE - // Minimum Dispersion load balancing strategy - - // = DESCRIPTION - // - -public: - TAO_LB_Minimum_Dispersion_Strategy (void); - // Constructor. - - ~TAO_LB_Minimum_Dispersion_Strategy (void); - // Destructor - - // = The TAO_LB_LoadBalancing_Strategy methods - virtual CORBA::Object_ptr replica (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)); - virtual int insert (TAO_LB_ReplicaProxy *); - virtual int remove (TAO_LB_ReplicaProxy *); - virtual void load_changed (TAO_LB_ReplicaProxy * - ACE_ENV_ARG_DECL); - -private: - TAO_LB_ReplicaProxySet proxies_; - // Set containing the ReplicaProxy servants. - - TAO_SYNCH_MUTEX lock_; - // Lock used to ensure atomic access to state retained by this - // class. -}; - -#include "ace/post.h" - -#endif /* MINIMUM_DISPERSION_H */ diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaLocator.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaLocator.cpp deleted file mode 100644 index e42168ee991..00000000000 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaLocator.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// -*- C++ -*- - -// $Id$ - -#include "ReplicaLocator.h" -#include "LoadBalancer_i.h" - -ACE_RCSID(orbsvcs, ReplicaLocator, "$Id$") - -TAO_LB_ReplicaLocator::TAO_LB_ReplicaLocator (TAO_LB_LoadBalancer *lb) - : load_balancer_ (lb) // This pointer shouldn't be zero! -{ - // Nothing else -} - -PortableServer::Servant -TAO_LB_ReplicaLocator::preinvoke ( - const PortableServer::ObjectId & /* oid */, - PortableServer::POA_ptr /* adapter */, - const char * /* operation */, - PortableServer::ServantLocator::Cookie & /* the_cookie */ - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - PortableServer::ForwardRequest)) -{ - if (this->load_balancer_ == 0) - ACE_THROW_RETURN (CORBA::INTERNAL (), 0); - - CORBA::Object_var replica = - this->load_balancer_->replica (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK_RETURN (0); - - // Throw a forward exception to force the client to redirect its - // requests to the Replica chosen by the LoadBalancer. - ACE_THROW_RETURN (PortableServer::ForwardRequest ( - replica.in ()), - 0); -} - -void -TAO_LB_ReplicaLocator::postinvoke ( - const PortableServer::ObjectId & /* oid */, - PortableServer::POA_ptr /* adapter */, - const char * /* operation */, - PortableServer::ServantLocator::Cookie /* the_cookie */, - PortableServer::Servant /* the_servant */ - ACE_ENV_ARG_DECL_NOT_USED) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - // No-op -} diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaLocator.h b/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaLocator.h deleted file mode 100644 index 0507fd23d50..00000000000 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaLocator.h +++ /dev/null @@ -1,73 +0,0 @@ -// -*- C++ -*- - -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO_LoadBalancing -// -// = FILENAME -// ReplicaLocator.h -// -// = AUTHOR -// Ossama Othman <ossama@uci.edu> -// -// ============================================================================ - -#ifndef TAO_REPLICA_LOCATOR_H -#define TAO_REPLICA_LOCATOR_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 TAO_LB_LoadBalancer; - -class TAO_LoadBalancing_Export TAO_LB_ReplicaLocator - : public virtual PortableServer::ServantLocator -{ - // = TITLE - // Class that provides request forwarding. - - // = DESCRIPTION - // This is a Servant Locator implementation that forwards - // requests to a replica returned by the Load Balancer. - -public: - TAO_LB_ReplicaLocator (TAO_LB_LoadBalancer *load_balancer); - // Constructor - - // = The ServantLocator methods - virtual PortableServer::Servant preinvoke ( - const PortableServer::ObjectId &oid, - PortableServer::POA_ptr adapter, - const char *operation, - PortableServer::ServantLocator::Cookie & the_cookie - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - PortableServer::ForwardRequest)); - - virtual void postinvoke ( - const PortableServer::ObjectId &oid, - PortableServer::POA_ptr adapter, - const char *operation, - PortableServer::ServantLocator::Cookie the_cookie, - PortableServer::Servant the_servant - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)); - -private: - TAO_LB_LoadBalancer *load_balancer_; - // The load balancer implementation. -}; - -#include "ace/post.h" - -#endif /* TAO_REPLICA_LOCATOR_H */ diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaProxy.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaProxy.cpp deleted file mode 100644 index f111819e7f8..00000000000 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaProxy.cpp +++ /dev/null @@ -1,97 +0,0 @@ -// -*- C++ -*- - -// $Id$ - -#include "ReplicaProxy.h" -#include "LoadBalancer_i.h" - -#if !defined(__ACE_INLINE__) -#include "ReplicaProxy.i" -#endif /* __ACE_INLINE__ */ - -ACE_RCSID(orbsvcs, ReplicaProxy, "$Id$") - -TAO_LB_ReplicaProxy::TAO_LB_ReplicaProxy (void) - : has_high_load_ (0), - lock_ (), - balancer_ (0), - current_load_ (0), - connected_ (0) -{ - // Nothing as yet -} - -void -TAO_LB_ReplicaProxy::current_load (CORBA::Float load - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - // @@ Ossama: this is the point were the load dampening should - // happen. Probably strategized.... - - // Do not lock here. Locking is done in the load_changed() method, - // below. - - this->current_load_ = load; - // ACE_DEBUG ((LM_DEBUG, "Load[%x] = %f\n", long(this), load)); - - this->balancer_->load_changed (this ACE_ENV_ARG_PARAMETER); -} - -void -TAO_LB_ReplicaProxy::disconnect (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((LoadBalancing::ReplicaProxy::NotConnected, - CORBA::SystemException)) -{ - ACE_MT (ACE_GUARD (TAO_SYNCH_MUTEX, - guard, - this->lock_)); - - if (this->connected_) - { - this->balancer_->disconnect (this ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - this->connected_ = 0; - } - else - { - ACE_THROW (LoadBalancing::ReplicaProxy::NotConnected ()); - } -} - -void -TAO_LB_ReplicaProxy::connect (TAO_LB_LoadBalancer *balancer, - LoadBalancing::ReplicaControl_ptr control, - CORBA::Object_ptr replica - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((LoadBalancing::ReplicaProxy::NilControl, - LoadBalancing::ReplicaProxy::NilReplica, - CORBA::SystemException)) -{ - ACE_MT (ACE_GUARD (TAO_SYNCH_MUTEX, - guard, - this->lock_)); - - if (balancer == 0) - ACE_THROW (CORBA::BAD_PARAM ( - CORBA_SystemException::_tao_minor_code ( - TAO_DEFAULT_MINOR_CODE, - EINVAL), - CORBA::COMPLETED_NO)); - else - this->balancer_ = balancer; - - if (!CORBA::is_nil (control)) - this->control_ = LoadBalancing::ReplicaControl::_duplicate (control); - else - ACE_THROW (LoadBalancing::ReplicaProxy::NilControl ()); - - if (!CORBA::is_nil (control)) - this->replica_ = CORBA::Object::_duplicate (replica); - else - ACE_THROW (LoadBalancing::ReplicaProxy::NilReplica ()); - - // Now indicate that connection to LoadBalancer has been made. - this->connected_ = 1; -} diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaProxy.h b/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaProxy.h deleted file mode 100644 index 8f29e644a6d..00000000000 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaProxy.h +++ /dev/null @@ -1,133 +0,0 @@ -// -*- C++ -*- - -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO_LoadBalancing -// -// = FILENAME -// ReplicaProxy.h -// -// = AUTHOR -// Ossama Othman <ossama@uci.edu> -// -// ============================================================================ - -#ifndef TAO_REPLICAPROXY_H -#define TAO_REPLICAPROXY_H - -#include "ace/pre.h" - -#include "ace/Synch.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) -#pragma warning(push) -#endif /* _MSC_VER >= 1200 */ -#pragma warning(disable:4250) -#endif /* _MSC_VER */ - -class TAO_LB_LoadBalancer; -// Forward declaration - -class TAO_LoadBalancing_Export TAO_LB_ReplicaProxy : - public virtual POA_LoadBalancing::ReplicaProxy, - public virtual PortableServer::RefCountServantBase -{ - friend class TAO_LB_LoadBalancer; -public: - - TAO_LB_ReplicaProxy (void); - - CORBA::Float current_load (void) const; - // Read the stored load of the Object being load balanced from the - // ReplicaProxy. - - CORBA::Object_ptr replica (void); - // Return a reference to the Replica. - - virtual void current_load (CORBA::Float load - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)); - // Send the value of the current load on the Object being load - // balanced, where the definition of "load" is load balancing - // algorithm specific. - // @@ Ossama: i had to implement dampening mechanisms in the load, - // otherwise the spikes where killing me, but i'm not sure if that - // should be implemented in the client or the server. - // @@ I think that the 'Right Thing' is to have the client send - // 'instantaneous load' and get the load balancing service to do the - // dampening... that way we can modify the algorithm in the server, - // without affecting the client, or detect rapid raises in load and - // react proactively to those... - - virtual void disconnect (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((LoadBalancing::ReplicaProxy::NotConnected, - CORBA::SystemException)); - // Send a request to disconnect from the LoadBalancer. - - // @@ Ossama: could you please fix the mess i left here? it is my - // fault, but i was running short on time. - int has_high_load_; - // Has the high load advisory been sent - // @@ Ossama: i added this flag to avoid multiple nomimal load - // advisories and high load advisories to be sent. - - LoadBalancing::ReplicaControl_var control_; - // Reference to the ReplicaControl. - -private: - - ~TAO_LB_ReplicaProxy (void); - // Destructor is private to ensure that this object is allocated on - // the heap. - - void connect (TAO_LB_LoadBalancer *balancer, - LoadBalancing::ReplicaControl_ptr control, - CORBA::Object_ptr replica - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((LoadBalancing::ReplicaProxy::NilControl, - LoadBalancing::ReplicaProxy::NilReplica, - CORBA::SystemException)); - // Register the ReplicaControl and the Object being load balanced - // with the ReplicaProxy. - -private: - - TAO_SYNCH_MUTEX lock_; - // Mutex used to ensure access ReplicaProxy state is atomic. - - CORBA::Object_var replica_; - // Reference to the Object being load balanced. - - TAO_LB_LoadBalancer *balancer_; - // Pointer to the Load Balancer this ReplicaProxy is registered - // with. - - CORBA::Float current_load_; - // The current load on the Object being load balanced. - - CORBA::Boolean connected_; - // 1 == currently connected to load balancer - // 0 == currently disconnected from load balancer -}; - -#if defined(__ACE_INLINE__) -#include "ReplicaProxy.i" -#endif /* __ACE_INLINE__ */ - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -#pragma warning(pop) -#endif /* _MSC_VER */ - -#include "ace/post.h" - -#endif /* TAO_REPLICAPROXY_H */ diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaProxy.i b/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaProxy.i deleted file mode 100644 index b5a8fcaabd7..00000000000 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaProxy.i +++ /dev/null @@ -1,20 +0,0 @@ -// -*- C++ -*- -// $Id$ - -ACE_INLINE -TAO_LB_ReplicaProxy::~TAO_LB_ReplicaProxy (void) -{ - // Nada -} - -ACE_INLINE CORBA::Float -TAO_LB_ReplicaProxy::current_load (void) const -{ - return this->current_load_; -} - -ACE_INLINE CORBA::Object_ptr -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 deleted file mode 100644 index d587a309dfa..00000000000 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/Round_Robin_Strategy.cpp +++ /dev/null @@ -1,110 +0,0 @@ -// -*- C++ -*- - -// $Id$ - - -#include "Round_Robin_Strategy.h" -#include "ReplicaProxy.h" - -ACE_RCSID(orbsvcs, Round_Robin_Strategy, "$Id$") - - -TAO_LB_Round_Robin_Strategy::TAO_LB_Round_Robin_Strategy (void) - : proxies_ (), - next_replica_ (this->proxies_.begin ()), - lock_ () -{ -} - -TAO_LB_Round_Robin_Strategy::~TAO_LB_Round_Robin_Strategy (void) -{ - ACE_MT (ACE_GUARD (TAO_SYNCH_MUTEX, - guard, - this->lock_)); - - // @@ Are the objects deactivated from the POA? And shouldn't this - // be done by the LoadBalancing strategy *before* the destructor is - // invoked? - - TAO_LB_ReplicaProxySetIterator begin = this->proxies_.begin (); - TAO_LB_ReplicaProxySetIterator end = this->proxies_.end (); - - for (TAO_LB_ReplicaProxySetIterator i = begin; - i != end; - ++i) - { - // Decrease reference count on each proxy servant in the set. - (*i)->_remove_ref (); - } -} - -CORBA::Object_ptr -TAO_LB_Round_Robin_Strategy::replica (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, - guard, - this->lock_, - CORBA::Object::_nil ()); - - if (this->proxies_.is_empty ()) - { - // @@ What do we do if the set is empty? - // @@ Ossama: i'm throwing the OBJECT_NOT_EXIST exception, but - // maybe TRANSIENT is a better choice.... please read the - // relevant section of the CORBA spec and let me know what you - // think. - ACE_THROW_RETURN (CORBA::OBJECT_NOT_EXIST (), - CORBA::Object::_nil ()); - } - - // If we're at the end of the Replica set, then rewind to the - // beginning of the set. - if (this->next_replica_ == this->proxies_.end ()) - this->next_replica_ = this->proxies_.begin (); - - 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. - this->next_replica_++; - - // @@ Ossama: once we select a replica, shouldn't we temporarily - // change its load so it does not get swamped with all the new - // clients. Think about the current scenario: - // - Replica A has the lowest load, by far. - // - 5 clients connect at the same time. - // - If the load on A does not grow fast enough all 5 clients will - // end up on replica A, and then they will be kicked out and - // shuffled around. - // While if we bump the load for a few seconds then the next client - // will go to other place. Or set a flag that says 'load - // invalidated, waiting for an update' (i like the latter better). - return proxy_servant->replica (); -} - -int -TAO_LB_Round_Robin_Strategy::insert (TAO_LB_ReplicaProxy *proxy) -{ - ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, - guard, - this->lock_, - -1)); - - int r = this->proxies_.insert (proxy); - this->next_replica_ = this->proxies_.begin (); - return r; -} - -int -TAO_LB_Round_Robin_Strategy::remove (TAO_LB_ReplicaProxy *proxy) -{ - ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, - guard, - this->lock_, - -1)); - - int r = this->proxies_.remove (proxy); - this->next_replica_ = this->proxies_.begin (); - return r; -} diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/Round_Robin_Strategy.h b/TAO/orbsvcs/orbsvcs/LoadBalancing/Round_Robin_Strategy.h deleted file mode 100644 index 988e18ea25e..00000000000 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/Round_Robin_Strategy.h +++ /dev/null @@ -1,80 +0,0 @@ -// -*- C++ -*- - -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO_LoadBalancing -// -// = FILENAME -// Round_Robin_Strategy.h -// -// = AUTHOR -// Ossama Othman <ossama@uci.edu> -// -// ============================================================================ - -#ifndef ROUND_ROBIN_STRATEGY_H -#define ROUND_ROBIN_STRATEGY_H - -#include "ace/pre.h" - -#include "LoadBalancing_Strategy.h" -#include "orbsvcs/LoadBalancingS.h" -#include "ace/Containers.h" -#include "ace/Synch.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -// Forward declarations -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 -// and extraction, the class is not thread safe and it is hard to find -// the element with the least load... Then again the number of -// 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<TAO_LB_ReplicaProxy *> TAO_LB_ReplicaProxySet; -typedef ACE_Unbounded_Set_Iterator<TAO_LB_ReplicaProxy *> TAO_LB_ReplicaProxySetIterator; - -class TAO_LoadBalancing_Export TAO_LB_Round_Robin_Strategy : public TAO_LB_LoadBalancing_Strategy -{ - // = TITLE - // Round Robin 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: - TAO_LB_Round_Robin_Strategy (void); - // Constructor. - - ~TAO_LB_Round_Robin_Strategy (void); - // Destructor - - // = The Load_Balancing_Strategy methods - virtual CORBA::Object_ptr replica (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException)); - virtual int insert (TAO_LB_ReplicaProxy *); - virtual int remove (TAO_LB_ReplicaProxy *); - -private: - TAO_LB_ReplicaProxySet proxies_; - // Set containing the ReplicaProxy servants. - - ACE_Unbounded_Set_Iterator<TAO_LB_ReplicaProxy *> next_replica_; - - TAO_SYNCH_MUTEX lock_; - // Lock used to ensure access to state within this class is atomic. -}; - -#include "ace/post.h" - -#endif /* ROUND_ROBIN_STRATEGY_H */ |