PG_GenericFactory.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  * @file  PG_GenericFactory.h
00006  *
00007  * $Id: PG_GenericFactory.h 77001 2007-02-12 07:54:49Z johnnyw $
00008  *
00009  * @author Ossama Othman <ossama@dre.vanderbilt.edu>
00010  */
00011 //=============================================================================
00012 
00013 
00014 #ifndef TAO_PG_GENERIC_FACTORY_H
00015 #define TAO_PG_GENERIC_FACTORY_H
00016 
00017 #include /**/ "ace/pre.h"
00018 
00019 #include "ace/config-all.h"
00020 
00021 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00022 #pragma once
00023 #endif /* ACE_LACKS_PRAGMA_ONCE */
00024 
00025 #include "orbsvcs/PortableGroup/PG_Factory_Map.h"
00026 #include "orbsvcs/PortableGroup/portablegroup_export.h"
00027 #include "tao/PortableServer/PortableServerC.h"
00028 #include "orbsvcs/PortableGroupC.h"
00029 #include "ace/Null_Mutex.h"
00030 
00031 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00032 
00033 /// Forward declarations.
00034 class TAO_PG_ObjectGroupManager;
00035 class TAO_PG_PropertyManager;
00036 
00037 struct TAO_PG_ObjectGroup_Map_Entry;
00038 
00039 
00040 /**
00041  * @class TAO_PG_GenericFactory
00042  *
00043  * @brief PortableGroup::GenericFactory implementation used by the
00044  *        load balancer when creating object groups.
00045  *
00046  * This GenericFactory creates an object group reference for given set
00047  * of replicas.  Those replicas will be created by this GenericFactory
00048  * if the "infrastructure-controlled" membership style is configured.
00049  */
00050 class TAO_PortableGroup_Export TAO_PG_GenericFactory
00051   : public virtual PortableGroup::GenericFactory
00052 {
00053 public:
00054 
00055   /// Constructor.
00056   TAO_PG_GenericFactory (TAO_PG_ObjectGroupManager & object_group_map,
00057                          TAO_PG_PropertyManager & property_manager);
00058 
00059   /// Destructor.
00060   ~TAO_PG_GenericFactory (void);
00061 
00062   /**
00063    * @name TAO_LoadBalancer::GenericFactory methods
00064    */
00065   //@{
00066 
00067   /**
00068    * Create an object of the specified type that adheres to the
00069    * restrictions defined by the provided Criteria.  The out
00070    * FactoryCreationId parameter may be passed to the delete_object()
00071    * method to delete the object.
00072    */
00073   virtual CORBA::Object_ptr create_object (
00074       const char * type_id,
00075       const PortableGroup::Criteria & the_criteria,
00076       PortableGroup::GenericFactory::FactoryCreationId_out
00077         factory_creation_id);
00078 
00079   /**
00080    * Delete the object corresponding to the provided
00081    * FactoryCreationId.  If the object is actually an ObjectGroup,
00082    * then all members within the ObjectGroup will be deleted.
00083    * Afterward, the ObjectGroup itself will be deleted.
00084    */
00085   virtual void delete_object (
00086       const PortableGroup::GenericFactory::FactoryCreationId &
00087         factory_creation_id);
00088 
00089   //@}
00090 
00091   /// Set the POA to use when creating object references.
00092   void poa (PortableServer::POA_ptr p);
00093 
00094   /// Call delete_object() on all factories use to create members in a
00095   /// given object group.
00096   /**
00097    * If ignore_exceptions is true, any exception returned from the
00098    * delete_object() call on the remote factory will be ignored in
00099    * order to allow other objects to be deleted via other registered
00100    * factories.
00101    */
00102   void delete_object_i (TAO_PG_Factory_Set & factory_set,
00103                         CORBA::Boolean ignore_exceptions);
00104 
00105   /// If the member corresponding to the given group ID and location
00106   /// was created by the infrastructure, call delete_object() on the
00107   /// remote GenericFactory that created it.
00108   /**
00109    * This method is only used by the TAO_PG_ObjectGroupManager class
00110    * when ObjectGroupManager::remove_member() is explicitly called.
00111    */
00112   void delete_member (CORBA::ULong group_id,
00113                       const PortableGroup::Location & location);
00114 
00115   /// Verify that the MinimumNumberMembers criterion is satisfied.
00116   /**
00117    * If the current number of members in the given object group is
00118    * less than the MinimumNumberMembers criterion in effect for that
00119    * group, the infrastructure will attempt create and add more
00120    * members to the group by invoking any unused application-supplied
00121    * GenericFactorys.
00122    */
00123   void check_minimum_number_members (
00124     PortableGroup::ObjectGroup_ptr object_group,
00125     CORBA::ULong group_id,
00126     const char * type_id);
00127 
00128   /// Create a new object group member using the supplied FactoryInfo
00129   /// and RepositoryId and add it to the given object group.
00130   /**
00131    * @note This method is only used by the infrastructure.
00132    */
00133   PortableGroup::GenericFactory::FactoryCreationId * create_member (
00134       PortableGroup::ObjectGroup_ptr object_group,
00135       const PortableGroup::FactoryInfo & factory_info,
00136       const char * type_id,
00137       const CORBA::Boolean propagate_member_already_present);
00138 
00139 private:
00140 
00141   /// Populate the object group being created.  Called when the
00142   /// infrastructure-controlled membership style is used for the
00143   /// object group being created.
00144   void populate_object_group (
00145          PortableGroup::ObjectGroup_ptr object_group,
00146          const char * type_id,
00147          const PortableGroup::FactoryInfos &factory_infos,
00148          PortableGroup::InitialNumberMembersValue initial_number_members,
00149          TAO_PG_Factory_Set & factory_set);
00150 
00151   /// Get a new ObjectId to be used when creating a new ObjectGroup.
00152   /**
00153    * An ObjectId created by this method will never be reused within
00154    * the scope of a given ReplicationManager.  A value suitable for
00155    * use in a map association <ext_id> is also returned.
00156    */
00157   void get_ObjectId (CORBA::ULong fcid,
00158                      PortableServer::ObjectId_out oid);
00159 
00160   /// Process criteria to be applied to the object group being
00161   /// created.
00162   /**
00163    * Only the MemberShipStyle, Factories, InitialNumberMembers and
00164    * MinimumNumberMembers criteria/properties are defined by the
00165    * PortableGroup IDL.  Other services that implement the
00166    * GenericFactory interface, such as load balancing and fault
00167    * tolerance, may choose to support more.
00168    * @par
00169    * The extracted criteria are object group-specific.  In particular,
00170    * they are the object group creation time criteria.
00171    */
00172   void process_criteria (
00173     const char * type_id,
00174     const PortableGroup::Criteria & criteria,
00175     PortableGroup::MembershipStyleValue & membership_style,
00176     PortableGroup::FactoriesValue & factory_infos,
00177     PortableGroup::InitialNumberMembersValue & initial_number_members,
00178     PortableGroup::MinimumNumberMembersValue & minimum_number_members);
00179 
00180 private:
00181 
00182   /// Reference to the POA used to create object group references.
00183   PortableServer::POA_var poa_;
00184 
00185   /// Reference to the ObjectGroup map.
00186   TAO_PG_ObjectGroupManager & object_group_manager_;
00187 
00188   /// Reference to the PropertyManager.
00189   TAO_PG_PropertyManager & property_manager_;
00190 
00191   /// Table that maps FactoryCreationId to TAO_PG_Factory_Set.
00192   /**
00193    * The TAO_PG_Factory_Set corresponding to a given FactoryCreationId
00194    * contains the information necessary to clean up objects (members)
00195    * that were created by the infrastructure, i.e. this
00196    * GenericFactory.  For example, this GenericFactory will invoke
00197    * other application defined GenericFactorys when creating new
00198    * object group members.  The information returned from those
00199    * application defined GenericFactorys is stored in a
00200    * TAO_PG_Factory_Set, and thus this table.
00201    */
00202   TAO_PG_Factory_Map factory_map_;
00203 
00204   /// The FactoryCreationId that will be assigned to the next object
00205   /// group that is created.
00206   /**
00207    * Value that is used when assigning a FactoryCreationId to the
00208    * factory that was used to create a given ObjectGroup.  The
00209    * FactoryCreationId is typically comprised of this value in
00210    * addition to another value that makes it unique to a given Load
00211    * Balancer.
00212    */
00213   CORBA::ULong next_fcid_;
00214 
00215   /// Lock used to synchronize access to the factory creation id
00216   /// index (i.e. next_fcid_).
00217   TAO_SYNCH_MUTEX lock_;
00218 
00219 };
00220 
00221 TAO_END_VERSIONED_NAMESPACE_DECL
00222 
00223 #include /**/ "ace/post.h"
00224 
00225 #endif  /* TAO_PG_GENERIC_FACTORY_H */

Generated on Tue Feb 2 17:49:50 2010 for TAO_PortableGroup by  doxygen 1.4.7