summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwilson_d <wilson_d@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-11-07 17:51:48 +0000
committerwilson_d <wilson_d@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-11-07 17:51:48 +0000
commitcc083a870253ae0fe8e8b529edccc2375b244434 (patch)
treee3113e7c80df17b289b45023260002347340e8c8
parent6cbf9c540fad6e962e2e8d0bc37db6619cd6fb32 (diff)
downloadATCD-cc083a870253ae0fe8e8b529edccc2375b244434.tar.gz
ChangeLogTag: Thu Nov 6 13:03:17 2003 Dale Wilson <wilson_d@ociweb.com>
-rw-r--r--TAO/ChangeLog53
-rw-r--r--TAO/orbsvcs/orbsvcs/FT_CORBA.idl2
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup.idl123
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_Default_Property_Validator.cpp4
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_Default_Property_Validator.h14
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.cpp706
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.h248
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_Factory_Map.cpp20
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_Factory_Map.h6
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_Factory_Set.h3
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.cpp215
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.h28
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Guard.cpp7
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Guard.h8
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.cpp186
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.h67
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroup_Map.cpp24
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroup_Map.h14
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp374
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h329
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Map.cpp116
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Map.h110
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Decoder.cpp166
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Decoder.h78
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Encoder.cpp68
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Encoder.h46
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_PropertyManager.cpp76
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_PropertyManager.h11
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_Property_Utils.cpp9
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_Utils.cpp169
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PG_Utils.h53
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PortableGroup_Loader.h4
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/PortableGroup_Request_Dispatcher.h1
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/Portable_Group_Map.h10
-rw-r--r--TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Acceptor.h2
35 files changed, 3039 insertions, 311 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index 074a4631419..febced1ce82 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,56 @@
+Thu Nov 6 13:03:17 2003 Dale Wilson <wilson_d@ociweb.com>
+
+ * orbsvcs/orbsvcs/FT_CORBA.idl:
+ * orbsvcs/orbsvcs/PortableGroup.idl:
+
+ * orbsvcs/orbsvcs/PortableGroup/PG_Default_Property_Validator.h:
+ * orbsvcs/orbsvcs/PortableGroup/PG_Default_Property_Validator.cpp:
+ * orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.h:
+ * orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.cpp:
+ * orbsvcs/orbsvcs/PortableGroup/PG_Factory_Map.h:
+ * orbsvcs/orbsvcs/PortableGroup/PG_Factory_Map.cpp:
+ * orbsvcs/orbsvcs/PortableGroup/PG_Factory_Set.h:
+ * orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.h:
+ * orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.cpp:
+ * orbsvcs/orbsvcs/PortableGroup/PG_Group_Guard.h:
+ * orbsvcs/orbsvcs/PortableGroup/PG_Group_Guard.cpp:
+ * orbsvcs/orbsvcs/PortableGroup/PG_Location_Equal_To.h:
+ * orbsvcs/orbsvcs/PortableGroup/PG_Location_Hash.h:
+ * orbsvcs/orbsvcs/PortableGroup/PG_Location_Map.h:
+ * orbsvcs/orbsvcs/PortableGroup/PG_MemberInfo.h:
+ * orbsvcs/orbsvcs/PortableGroup/PG_Null_Property_Validator.h:
+ * orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.h:
+ * orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.cpp:
+ * orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroup_Map.h:
+ * orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroup_Map.cpp:
+ * orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h:
+ * orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp:
+ * orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Map.h:
+ * orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Map.cpp:
+ * orbsvcs/orbsvcs/PortableGroup/PG_Operators.h:
+ * orbsvcs/orbsvcs/PortableGroup/PG_Properties_Decoder.h:
+ * orbsvcs/orbsvcs/PortableGroup/PG_Properties_Decoder.cpp:
+ * orbsvcs/orbsvcs/PortableGroup/PG_Properties_Encoder.h:
+ * orbsvcs/orbsvcs/PortableGroup/PG_Properties_Encoder.cpp:
+ * orbsvcs/orbsvcs/PortableGroup/PG_PropertyManager.h:
+ * orbsvcs/orbsvcs/PortableGroup/PG_PropertyManager.cpp:
+ * orbsvcs/orbsvcs/PortableGroup/PG_Property_Utils.h:
+ * orbsvcs/orbsvcs/PortableGroup/PG_Property_Utils.cpp:
+ * orbsvcs/orbsvcs/PortableGroup/PG_Utils.h:
+ * orbsvcs/orbsvcs/PortableGroup/PG_Utils.cpp:
+ * orbsvcs/orbsvcs/PortableGroup/PG_conf.h:
+ * orbsvcs/orbsvcs/PortableGroup/POA_Hooks.h:
+ * orbsvcs/orbsvcs/PortableGroup/PortableGroup_Acceptor_Registry.h:
+ * orbsvcs/orbsvcs/PortableGroup/PortableGroup_Loader.h:
+ * orbsvcs/orbsvcs/PortableGroup/PortableGroup_ORBInitializer.h:
+ * orbsvcs/orbsvcs/PortableGroup/PortableGroup_Request_Dispatcher.h:
+ * orbsvcs/orbsvcs/PortableGroup/Portable_Group_Map.h:
+ * orbsvcs/orbsvcs/PortableGroup/UIPMC_Acceptor.h:
+ * orbsvcs/orbsvcs/PortableGroup/UIPMC_Acceptor.cpp:
+ * orbsvcs/orbsvcs/PortableGroup/UIPMC_Profile.cpp:
+ * orbsvcs/orbsvcs/PortableGroup/miopconf.h:
+ Next merge PortableGroup and make it build in the oci_haft2 branch.
+
Wed Nov 5 16:30:32 2003 Dale Wilson <wilson_d@ociweb.com>
* tao/PortableInterceptor.pidl:
diff --git a/TAO/orbsvcs/orbsvcs/FT_CORBA.idl b/TAO/orbsvcs/orbsvcs/FT_CORBA.idl
index 7e287b6f389..80dbeb6e45a 100644
--- a/TAO/orbsvcs/orbsvcs/FT_CORBA.idl
+++ b/TAO/orbsvcs/orbsvcs/FT_CORBA.idl
@@ -81,7 +81,7 @@ module FT
const FaultMonitoringGranularityValue LOC = 1;
const FaultMonitoringGranularityValue LOC_AND_TYPE = 2;
typedef FactoryInfos FactoriesValue;
- typedef unsigned short InitialNumberReplicasValue;
+ typedef unsigned short InitialNumberMembersValue;
typedef unsigned short MinimumNumberReplicasValue;
struct FaultMonitoringIntervalAndTimeoutValue {
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup.idl b/TAO/orbsvcs/orbsvcs/PortableGroup.idl
index e9351869313..ecaed060f14 100644
--- a/TAO/orbsvcs/orbsvcs/PortableGroup.idl
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup.idl
@@ -11,7 +11,7 @@
#ifndef _PORTABLEGROUP_IDL_
#define _PORTABLEGROUP_IDL_
-#include <CosNaming.idl>
+#include <orbsvcs/CosNaming.idl>
#include <tao/IOP.pidl>
#include <tao/GIOP.pidl>
#include <orb.idl>
@@ -20,6 +20,18 @@ module PortableGroup
{
typeprefix PortableGroup "omg.org";
+ /// MembershipStyle
+ const string PG_MEMBERSHIP_STYLE = "org.omg.PortableGroup.MembershipStyle";
+
+ /// InitialNumberMembers
+ const string PG_INITIAL_NUMBER_MEMBERS = "org.omg.PortableGroup.InitialNumberMembers";
+
+ /// MinimumNumberMembers
+ const string PG_MINIMUM_NUMBER_MEMBERS = "org.omg.PortableGroup.MinimumNumberMembers";
+
+ /// Factories
+ const string PG_FACTORIES = "org.omg.PortableGroup.Factories";
+
// Specification for Interoperable Object Group References
typedef string GroupDomainId;
typedef unsigned long long ObjectGroupId;
@@ -74,6 +86,8 @@ module PortableGroup
exception MemberAlreadyPresent {};
exception ObjectNotCreated {};
exception ObjectNotAdded {};
+ /// TAO Specific: TypeConfict exception
+ exception TypeConflict {};
exception UnsupportedProperty {
Name nam;
Value val;
@@ -166,6 +180,11 @@ module PortableGroup
in Location loc)
raises (ObjectGroupNotFound, MemberNotFound);
+ // TAO-specific extension.
+ ObjectGroup get_object_group_ref_from_id (
+ in ObjectGroupId group_id)
+ raises (ObjectGroupNotFound);
+
}; // end ObjectGroupManager
@@ -187,6 +206,108 @@ module PortableGroup
}; // end GenericFactory
+ ///////////////////////
+ // The following FactoryRegistry interface is not included in the OMG PortableGroup IDL.
+ // It's an extension needed as part of implementing the FT CORBA specification.
+
+
+ /**
+ * a name for the role the object will play
+ * This allows multiple objects that implement the same interface (TypeId)
+ * to exist at a location as long as they play different roles.
+ */
+ typedef CORBA::Identifier RoleName;
+
+ /**
+ * Reserved criteria name for specifing role.
+ */
+ const string role_criterion = "org.omg.portablegroup.Role";
+
+ /**
+ * Interface to allow generic factories for replicas to register themselves.
+ * Factories are distinguished by the role to be played by the created-object (role) and the
+ * location at which they create the object (FactoryInfo.the_location)
+ *
+ * Because this is an extension to the FT CORBA specification applications that wish to
+ * adhere to the specification as written should use the type id as the role name when
+ * interacting with the FactoryRegistry.
+ */
+ interface FactoryRegistry
+ {
+ /**
+ * register a factory to create objects of the given type
+ * at the location given in the FactoryInfo.
+ *
+ * @param role the role the object-to-be-created plays.
+ * @param type_id type id of the object-to-be-created.
+ * @param factory_info information about the factory including its location.
+ * @throws MemberAlreadyPresent if there is already a factory for this type of object
+ * at this location.
+ * @throws TypeConflict if the specified type_id is different from the type_id previously
+ * registered for this role.
+ */
+ void register_factory(in RoleName role, in _TypeId type_id, in FactoryInfo factory_info)
+ raises (MemberAlreadyPresent, TypeConflict);
+
+ /**
+ * Remove the registration of a factory.
+ * @param role the role played by the object formerly created by this factory.
+ * @param location where the factory formerly created objects.
+ * @throws MemberNotPresent if no factory is available for the given role at this location.
+ */
+ void unregister_factory(in RoleName role, in Location location)
+ raises (MemberNotFound);
+
+ /**
+ * Remove the registration of all factories that create a particular type of object.
+ * If no factories exist for the given type, the registry is unchanged.
+ * This is not an error.
+ * @param type_id the type of object formerly created by the factories to be unregistered.
+ */
+ void unregister_factory_by_role(in RoleName role);
+
+ /**
+ * Remove the registration of all factories that create objects at a particular location.
+ * If the location is unknown the registry is unchanged.
+ * This is not an error.
+ * @param location where the factories formerly created objects.
+ */
+ void unregister_factory_by_location(in Location location);
+
+ /**
+ * List all the factories that create objects that fill a given role
+ * If the role is unknown, an empty list is returned. This is not an error.
+ * @param role the type of object the factories create.
+ * @param type_id what type of object is created to fill this role.
+ */
+ FactoryInfos list_factories_by_role(in RoleName role, out _TypeId type_id);
+
+ /**
+ * List all the factories that create a objects at a given location.
+ * If no factories are registered for this location, an empty list is returned.
+ * This is not an error.
+ * @param location where the factories create objects.
+ */
+ FactoryInfos list_factories_by_location(in Location location);
+
+ }; // end of FactoryRegistry
+
+
+ const string TAO_UPDATE_OBJECT_GROUP_METHOD_NAME = "tao_update_object_group";
+
+ interface TAO_UpdateObjectGroup {
+ /**
+ * Pseudo used method to update IOGR in Object Group Members
+ * TAO specific. The CORBA spec. doesn't address the issue.
+ */
+ void tao_update_object_group (
+ in string iogr,
+ in PortableGroup::ObjectGroupRefVersion version,
+ in boolean is_primary);
+ };
+
+
+
}; // end PortableGroup
#endif /* _PORTABLEGROUP_IDL_ */
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Default_Property_Validator.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Default_Property_Validator.cpp
index f1dcc072034..eefa86f14c7 100644
--- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Default_Property_Validator.cpp
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Default_Property_Validator.cpp
@@ -18,6 +18,10 @@ TAO_PG_Default_Property_Validator::TAO_PG_Default_Property_Validator (void)
this->factories_[0].id = CORBA::string_dup ("org.omg.PortableGroup.Factories");
}
+TAO_PG_Default_Property_Validator::~TAO_PG_Default_Property_Validator (void)
+{
+}
+
void
TAO_PG_Default_Property_Validator::validate_property (
const PortableGroup::Properties & props
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Default_Property_Validator.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Default_Property_Validator.h
index 8f591870bcb..d8371b44469 100644
--- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Default_Property_Validator.h
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Default_Property_Validator.h
@@ -28,7 +28,8 @@
* @brief Default property validator implementation.
*
* This Property_Validator verifies that all properties defined in the
- * PortableGroup IDL module are valid.
+ * PortableGroup IDL module are valid. This property validator can be
+ * subclassed to validate a different property set.
*/
class TAO_PortableGroup_Export TAO_PG_Default_Property_Validator
{
@@ -37,10 +38,13 @@ public:
/// Constructor.
TAO_PG_Default_Property_Validator (void);
+ /// Destructor
+ virtual ~TAO_PG_Default_Property_Validator (void);
+
/// Validate the given properties. Throw an exception when the
/// first invalid property is encountered. The remaining properties
/// will not be validated.
- void validate_property (const PortableGroup::Properties & props
+ virtual void validate_property (const PortableGroup::Properties & props
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
PortableGroup::InvalidProperty,
@@ -49,7 +53,7 @@ public:
/// Validate the given properties/criteria. All criteria
/// will be validated regardless of whether or not an invalid
/// property was encountered.
- void validate_criteria (const PortableGroup::Properties & criteria
+ virtual void validate_criteria (const PortableGroup::Properties & criteria
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
PortableGroup::InvalidCriteria,
@@ -61,8 +65,8 @@ private:
* @name Pre-initialize property Names.
*
* These properties are pre-initialized once to reduce property
- * validation overhead. Note that the InitialNumberMembers and
- * MinimumNumberMembers properties are not validated since there are
+ * validation overhead. Note that the InitialNumberReplicas and
+ * MinimumNumberReplicas properties are not validated since there are
* no restrictions imposed by TAO's PortableGroup implementation
* regarding the number of such members.
*/
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.cpp
new file mode 100644
index 00000000000..8ae7dd18ecc
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.cpp
@@ -0,0 +1,706 @@
+// -*- C++ -*-
+//
+// $Id$
+
+#include "PG_FactoryRegistry.h"
+
+#include <ace/Get_Opt.h>
+#include <ace/Vector_T.h>
+#include <tao/PortableServer/ORB_Manager.h>
+#include "PG_Operators.h" // operator == on CosNaming::Name
+
+// Use this macro at the beginning of CORBA methods
+// to aid in debugging.
+#define METHOD_ENTRY(name) \
+ if (TAO_debug_level <= 6){} else \
+ ACE_DEBUG (( LM_DEBUG, \
+ "Enter %s\n", #name \
+ ))
+
+// Use this macro to return from CORBA methods
+// to aid in debugging. Note that you can specify
+// the return value after the macro, for example:
+// METHOD_RETURN(Plugh::plover) xyzzy; is equivalent
+// to return xyzzy;
+// METHOD_RETURN(Plugh::troll); is equivalent to
+// return;
+// WARNING: THIS GENERATES TWO STATEMENTS!!! THE FOLLOWING
+// will not do what you want it to:
+// if (cave_is_closing) METHOD_RETURN(Plugh::pirate) aarrggh;
+// Moral: Always use braces.
+#define METHOD_RETURN(name) \
+ if (TAO_debug_level <= 6){} else \
+ ACE_DEBUG (( LM_DEBUG, \
+ "Leave %s\n", #name \
+ )); \
+ return /* value goes here */
+
+TAO::PG_FactoryRegistry::PG_FactoryRegistry (const char * name)
+ : identity_(name)
+ , ior_output_file_(0)
+ , ns_name_(0)
+ , quit_on_idle_(0)
+ , quit_state_(LIVE)
+ , linger_(0)
+ , this_obj_(0)
+{
+}
+
+TAO::PG_FactoryRegistry::~PG_FactoryRegistry (void)
+{
+}
+
+//////////////////////////////////////////////////////
+// PG_FactoryRegistry public, non-CORBA methods
+
+int TAO::PG_FactoryRegistry::parse_args (int argc, char * argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, "o:n:q");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ {
+ switch (c)
+ {
+ case 'o':
+ {
+ this->ior_output_file_ = get_opts.opt_arg ();
+ break;
+ }
+ case 'n':
+ {
+ this->ns_name_ = get_opts.opt_arg();
+ break;
+ }
+ case 'q':
+ {
+ this->quit_on_idle_ = 1;
+ break;
+ }
+
+ case '?':
+ // fall thru
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s"
+ " -o <registry ior file>"
+ " -n <name to use to register with name service>"
+ " -q{uit on idle}"
+ "\n",
+ argv [0]),
+ -1);
+ break;
+ }
+ }
+ // Indicates sucessful parsing of the command line
+ return 0;
+}
+
+const char * TAO::PG_FactoryRegistry::identity () const
+{
+ return this->identity_.c_str();
+}
+
+
+void TAO::PG_FactoryRegistry::_remove_ref (ACE_ENV_SINGLE_ARG_DECL)
+{
+ this->quit_state_ = GONE;
+}
+
+int TAO::PG_FactoryRegistry::idle (int & result)
+{
+ result = 0;
+ int quit = 0;
+ if (this->quit_state_ == GONE)
+ {
+ if (linger_ < 2)
+ {
+ ++linger_;
+ }
+ else
+ {
+ quit = 1;
+ }
+ }
+ return quit;
+}
+
+
+int TAO::PG_FactoryRegistry::fini (ACE_ENV_SINGLE_ARG_DECL)
+{
+ if (this->ior_output_file_ != 0)
+ {
+ ACE_OS::unlink (this->ior_output_file_);
+ this->ior_output_file_ = 0;
+ }
+ if (this->ns_name_ != 0)
+ {
+ this->naming_context_->unbind (this_name_
+ ACE_ENV_ARG_PARAMETER);
+ this->ns_name_ = 0;
+ }
+ return 0;
+}
+
+int TAO::PG_FactoryRegistry::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL)
+{
+ int result = 0;
+
+ this->orb_ = orb;
+
+ // Use the ROOT POA for now
+ CORBA::Object_var poa_object =
+ this->orb_->resolve_initial_references (TAO_OBJID_ROOTPOA
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (-1);
+
+ if (CORBA::is_nil (poa_object.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT (" (%P|%t) Unable to initialize the POA.\n")),
+ -1);
+
+ // Get the POA object.
+ this->poa_ =
+ PortableServer::POA::_narrow (poa_object.in ()
+ ACE_ENV_ARG_PARAMETER);
+
+ ACE_CHECK_RETURN (-1);
+
+ if (CORBA::is_nil(this->poa_))
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT (" (%P|%t) Unable to narrow the POA.\n")),
+ -1);
+ }
+
+ PortableServer::POAManager_var poa_manager =
+ this->poa_->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_CHECK_RETURN(-1);
+
+ poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_CHECK_RETURN(-1);
+
+ // Register with the POA.
+ this->object_id_ = this->poa_->activate_object (this ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN(-1);
+
+ // find my identity as a corba object
+ this->this_obj_ =
+ this->poa_->id_to_reference (object_id_.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN(-1);
+
+
+ // and create a ior string
+ this->ior_ = this->orb_->object_to_string (this->this_obj_.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN(-1);
+
+
+ if (this->ior_output_file_ != 0)
+ {
+ this->identity_ = "file:";
+ this->identity_ += this->ior_output_file_;
+ result = write_ior_file (this->ior_output_file_, this->ior_);
+ }
+
+ if (this->ns_name_ != 0)
+ {
+ this->identity_ = "name:";
+ this->identity_ += this->ns_name_;
+
+ CORBA::Object_var naming_obj =
+ this->orb_->resolve_initial_references ("NameService" ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN(-1);
+
+ if (CORBA::is_nil(naming_obj.in ())){
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%T %n (%P|%t) Unable to find the Naming Service\n"),
+ 1);
+ }
+
+ this->naming_context_ =
+ CosNaming::NamingContext::_narrow (naming_obj.in () ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN(-1);
+
+ this->this_name_.length (1);
+ this->this_name_[0].id = CORBA::string_dup (this->ns_name_);
+
+ this->naming_context_->rebind (this->this_name_, this->this_obj_.in() //CORBA::Object::_duplicate(this_obj)
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN(-1);
+ }
+
+ return result;
+}
+
+
+::PortableGroup::FactoryRegistry_ptr TAO::PG_FactoryRegistry::reference()
+{
+ // narrow and duplicate
+ return ::PortableGroup::FactoryRegistry::_narrow(this->this_obj_);
+}
+
+
+//////////////////////////////////////////
+// PG_FactoryRegistry CORBA methods
+
+/* Reference:info
+ typedef CosNaming::Name Name;
+ typedef Name Location;
+ struct FactoryInfo {
+ GenericFactory the_factory;
+ Location the_location;
+ Criteria the_criteria;
+ };
+ typedef sequence<FactoryInfo> FactoryInfos;
+*/
+
+TAO::PG_FactoryRegistry::RoleInfo::RoleInfo(size_t estimated_number_entries)
+ : infos_(estimated_number_entries)
+{
+}
+
+
+void TAO::PG_FactoryRegistry::register_factory (
+ const char * role,
+ const char * type_id,
+ const PortableGroup::FactoryInfo & factory_info
+ ACE_ENV_ARG_DECL
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException
+ , PortableGroup::MemberAlreadyPresent
+ , PortableGroup::TypeConflict))
+{
+ METHOD_ENTRY(TAO::PG_FactoryRegistry::register_factory);
+
+ RoleInfo * role_info;
+ auto_ptr<RoleInfo> safe_entry;
+ if (this->registry_.find(role, role_info) != 0)
+ {
+ ACE_DEBUG(( LM_DEBUG,
+ "%s: adding new role: %s:%s\n", this->identity_.c_str(), role, type_id
+ ));
+ // Note the 5. It's a guess about the number of factories
+ // that might exist for any particular role object.
+ // todo: make it a parameter.
+ ACE_NEW_THROW_EX (role_info, RoleInfo(5),
+ CORBA::NO_MEMORY());
+ safe_entry = auto_ptr<RoleInfo>(role_info);
+ role_info->type_id_ = type_id;
+ }
+ else
+ {
+ if (role_info->type_id_ != type_id)
+ {
+ ACE_THROW ( PortableGroup::TypeConflict() );
+ }
+ }
+
+ PortableGroup::FactoryInfos & infos = role_info->infos_;;
+ size_t length = infos.length();
+ for (size_t nInfo = 0; nInfo < length; ++nInfo)
+ {
+ PortableGroup::FactoryInfo & info = infos[nInfo];
+ if (info.the_location == factory_info.the_location)
+ {
+ ACE_ERROR(( LM_ERROR,
+ "%s: Attempt to register duplicate location %s for role: %s\n" ,
+ this->identity_.c_str(),
+ ACE_static_cast(const char *, info.the_location[0].id),
+ role));
+ ACE_THROW (PortableGroup::MemberAlreadyPresent() );
+ }
+ }
+
+ infos.length(length + 1);
+ infos[length] = factory_info;
+
+ if (safe_entry.get() != 0)
+ {
+ this->registry_.bind(role, safe_entry.release());
+ }
+
+ ACE_DEBUG(( LM_DEBUG,
+ "%s: Added factory: [%d] %s@%s \n",
+ this->identity_.c_str(),
+ ACE_static_cast(int,length + 1),
+ role,
+ ACE_static_cast(const char *, factory_info.the_location[0].id)
+ ));
+
+ METHOD_RETURN(TAO::PG_FactoryRegistry::register_factory);
+}
+
+void TAO::PG_FactoryRegistry::unregister_factory (
+ const char * role,
+ const PortableGroup::Location & location
+ ACE_ENV_ARG_DECL
+ )
+ ACE_THROW_SPEC ((CORBA::SystemException, PortableGroup::MemberNotFound))
+{
+ METHOD_ENTRY(TAO::PG_FactoryRegistry::unregister_factory);
+
+ RoleInfo * role_info;
+ if (this->registry_.find(role, role_info) == 0)
+ {
+ PortableGroup::FactoryInfos & infos = role_info->infos_;
+ int found = 0;
+ size_t length = infos.length();
+ for (size_t nInfo = 0; !found && nInfo < length; ++nInfo)
+ {
+ PortableGroup::FactoryInfo & info = infos[nInfo];
+ if (info.the_location == location)
+ {
+ found = 1;
+
+ ACE_ERROR(( LM_INFO,
+ "%s: Unregistering factory %s@%s\n",
+ this->identity_.c_str(),
+ role,
+ ACE_static_cast(const char *, location[0].id)
+ ));
+ if (length > 1)
+ {
+ while (nInfo + 1 < length)
+ {
+ ACE_ERROR((LM_INFO,
+ "%s: Unregister_factory: Compress table: [%d] %s to [%d]\n",
+ this->identity_.c_str(),
+ (int)nInfo + 1, location, (int)nInfo
+ ));
+ infos[nInfo] = infos[nInfo + 1];
+ nInfo += 1;
+ }
+ ACE_ERROR((LM_INFO,
+ "%s: unregister_factory: New length [%d] %s\n",
+ this->identity_.c_str(),
+ (int)nInfo, role
+ ));
+ infos.length(nInfo);
+ }
+ else
+ {
+ ACE_ASSERT ( length == 1 );
+ if (this->registry_.unbind (role) == 0)
+ {
+ ACE_DEBUG(( LM_DEBUG,
+ "%s: No more factories registered for %s\n",
+ this->identity_.c_str(),
+ role
+ ));
+ delete role_info;
+ }
+ else
+ {
+ ACE_ERROR ((LM_ERROR,
+ "%s: LOGIC ERROR AT " __FILE__ " (%d): Entry to be deleted disappeared\n",
+ this->identity_.c_str(),
+ __LINE__));
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ ACE_ERROR(( LM_ERROR,
+ "%s, Attempt to unregister factory for unknown role %s\n",
+ this->identity_.c_str(),
+ role
+ ));
+ ACE_THROW ( PortableGroup::MemberNotFound() );
+ }
+
+ //////////////////////
+ // request complete
+ // check quit-on-idle
+ if (registry_.current_size() == 0 && quit_state_ == LIVE)
+ {
+ ACE_ERROR(( LM_INFO,
+ "%s is idle\n",
+ identity()
+ ));
+ if (quit_on_idle_)
+ {
+ this->poa_->deactivate_object (this->object_id_.in ()
+ ACE_ENV_ARG_PARAMETER);
+ quit_state_ = DEACTIVATED;
+ }
+ }
+
+ METHOD_RETURN(TAO::PG_FactoryRegistry::unregister_factory);
+}
+
+void TAO::PG_FactoryRegistry::unregister_factory_by_role (
+ const char * role
+ ACE_ENV_ARG_DECL
+ )
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ METHOD_ENTRY(TAO::PG_FactoryRegistry::unregister_factory_by_role);
+
+ RoleInfo * role_info;
+ if (this->registry_.unbind(role, role_info) == 0)
+ {
+ ACE_DEBUG(( LM_DEBUG,
+ "%s: Unregistering all factories for role %s\n",
+ this->identity_.c_str(),
+ role
+ ));
+ // delete the entire set of factories for this location.
+ delete role_info;
+ }
+ else
+ {
+ ACE_ERROR(( LM_INFO,
+ "%s: Unregister_factory_by_role: unknown role: %s\n",
+ this->identity_.c_str(),
+ role
+ ));
+ }
+
+ /////////////////////
+ // Function complete
+ // check quit options
+ if (registry_.current_size() == 0 && quit_state_ == LIVE)
+ {
+ ACE_ERROR(( LM_INFO,
+ "%s is idle\n",
+ identity()
+ ));
+ if (quit_on_idle_)
+ {
+ this->poa_->deactivate_object (this->object_id_.in ()
+ ACE_ENV_ARG_PARAMETER);
+ quit_state_ = DEACTIVATED;
+ }
+ }
+
+ METHOD_RETURN(TAO::PG_FactoryRegistry::unregister_factory_by_role);
+}
+
+void TAO::PG_FactoryRegistry::unregister_factory_by_location (
+ const PortableGroup::Location & location
+ ACE_ENV_ARG_DECL
+ )
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ METHOD_ENTRY(TAO::PG_FactoryRegistry::unregister_factory_by_location);
+
+ ////////////////////////////////////////////
+ // a vector of roles that need to be deleted.
+ ACE_Vector<ACE_CString> emptyRoles;
+
+ // iterate through the registery
+ for (RegistryType_Iterator it = this->registry_.begin();
+ it != this->registry_.end();
+ ++it)
+ {
+ RegistryType_Entry & entry = *it;
+ ACE_CString & role = entry.ext_id_;
+ RoleInfo * role_info = entry.int_id_;
+
+ PortableGroup::FactoryInfos & infos = role_info->infos_;
+ // ACE_ERROR((LM_INFO, "unregister_factory_by_location: Checking role %s\n", role.c_str() ));
+
+ int found = 0;
+ size_t length = infos.length();
+ for (size_t nInfo = 0; !found && nInfo < length; ++nInfo)
+ {
+ PortableGroup::FactoryInfo & info = infos[nInfo];
+ if (info.the_location == location)
+ {
+
+ ACE_ERROR((LM_INFO,
+ "%s: Unregister_factory_by_location: Removing: [%d] %s@%s\n",
+ this->identity_.c_str(),
+ (int)nInfo, role.c_str(), location[0].id
+ ));
+ found = 1;
+ if (length > 1)
+ {
+ while (nInfo + 1 < length)
+ {
+ ACE_ERROR((LM_INFO,
+ "%s: Unregister_factory_by_location: Move: [%d] %s to [%d]\n",
+ this->identity_.c_str(),
+ (int)nInfo + 1, role.c_str(), (int)nInfo
+ ));
+ infos[nInfo] = infos[nInfo + 1];
+ nInfo += 1;
+ }
+ ACE_ERROR((LM_INFO,
+ "%s: unregister_factory_by_location: New length [%d] %s\n",
+ this->identity_.c_str(),
+ (int)nInfo, role.c_str()
+ ));
+ infos.length(nInfo);
+ }
+ else
+ {
+ ACE_ERROR((LM_INFO,
+ "%s: Removed all entries for %s\n",
+ this->identity_.c_str(),
+ role.c_str()
+ ));
+ ACE_ASSERT ( length == 1 );
+ // remember entries to be deleted
+ emptyRoles.push_back(entry.ext_id_);
+ }
+ }
+ }
+ }
+
+ // now remove any roles that became empty
+
+ for (size_t nRole = 0; nRole < emptyRoles.size(); ++nRole)
+ {
+ ACE_ERROR((LM_INFO,
+ "%s: Remove role %s\n",
+ this->identity_.c_str(),
+ emptyRoles[nRole].c_str()
+ ));
+ RoleInfo * role_info;
+ if (this->registry_.unbind(emptyRoles[nRole], role_info) == 0)
+ {
+ delete role_info;
+ }
+ else
+ {
+ ACE_ERROR ((LM_ERROR,
+ "%s: LOGIC ERROR AT " __FILE__ " (%d): Role to be deleted disappeared\n",
+ this->identity_.c_str(),
+ __LINE__));
+ }
+ }
+ //////////////////////////
+ // If all types are gone...
+ if (registry_.current_size() == 0 && quit_state_ == LIVE)
+ {
+ ACE_ERROR(( LM_INFO,
+ "%s is idle\n",
+ identity()
+ ));
+ if (quit_on_idle_)
+ {
+ this->poa_->deactivate_object (this->object_id_.in ()
+ ACE_ENV_ARG_PARAMETER);
+ quit_state_ = DEACTIVATED;
+ }
+ }
+
+ METHOD_RETURN(TAO::PG_FactoryRegistry::unregister_factory_by_location);
+}
+
+::PortableGroup::FactoryInfos * TAO::PG_FactoryRegistry::list_factories_by_role (
+ const char * role,
+ CORBA::String_out type_id
+ ACE_ENV_ARG_DECL
+ )
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ METHOD_ENTRY(TAO::PG_FactoryRegistry::list_factories_by_role);
+
+ // allocate stucture to be returned.
+ PortableGroup::FactoryInfos_var result = 0;
+ ACE_NEW_THROW_EX (result, ::PortableGroup::FactoryInfos(),
+ CORBA::NO_MEMORY (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_NO));
+
+ RoleInfo * role_info = 0;
+ if (this->registry_.find(role, role_info) == 0)
+ {
+ type_id = CORBA::string_dup(role_info->type_id_.c_str());
+ (*result) = role_info->infos_;
+ }
+ else
+ {
+ type_id = CORBA::string_dup("");
+ ACE_ERROR(( LM_INFO,
+ "%s: list_factories_by_role: unknown role %s\n",
+ this->identity_.c_str(),
+ role
+ ));
+ }
+ METHOD_RETURN(TAO::PG_FactoryRegistry::list_factories_by_role) result._retn();
+}
+
+::PortableGroup::FactoryInfos * TAO::PG_FactoryRegistry::list_factories_by_location (
+ const PortableGroup::Location & location
+ ACE_ENV_ARG_DECL
+ )
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ METHOD_ENTRY(TAO::PG_FactoryRegistry::list_factories_by_location);
+ ::PortableGroup::FactoryInfos_var result;
+ ACE_NEW_THROW_EX (result, ::PortableGroup::FactoryInfos(this->registry_.current_size()),
+ CORBA::NO_MEMORY (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_NO));
+
+ size_t result_length = 0;
+
+ // iterate through the registery
+ for (RegistryType_Iterator it = this->registry_.begin();
+ it != this->registry_.end();
+ ++it)
+ {
+ RegistryType_Entry & entry = *it;
+ RoleInfo * role_info = entry.int_id_;
+
+ PortableGroup::FactoryInfos & found_infos = role_info->infos_;
+ // iterate through the entry for this type
+ int found = 0;
+ size_t length = found_infos.length();
+ for (size_t nInfo = 0; !found && nInfo < length; ++nInfo)
+ {
+ PortableGroup::FactoryInfo & info = found_infos[nInfo];
+ if (info.the_location == location)
+ {
+ found = 1;
+ result_length += 1;
+ result->length(result_length);
+ (*result)[result_length-1] = info;
+ }
+ }
+ }
+
+ METHOD_RETURN(TAO::PG_FactoryRegistry::list_factories_by_location) result._retn();
+}
+
+//////////////////////////////
+// Implementation methods
+
+int TAO::PG_FactoryRegistry::write_ior_file(const char * outputFile, const char * ior)
+{
+ int result = -1;
+ FILE* out = ACE_OS::fopen (outputFile, "w");
+ if (out)
+ {
+ ACE_OS::fprintf (out, "%s", ior);
+ ACE_OS::fclose (out);
+ result = 0;
+ }
+ else
+ {
+ ACE_ERROR ((LM_ERROR,
+ "Open failed for %s\n", outputFile
+ ));
+ }
+ return result;
+}
+
+#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
+
+ template class ACE_Hash_Map_Manager <ACE_CString, TAO::PG_FactoryRegistry::RoleInfo *, MapMutex>;
+ template class ACE_Hash_Map_Entry <ACE_CString, TAO::PG_FactoryRegistry::RoleInfo *>;
+ template class ACE_Hash_Map_Iterator <ACE_CString, TAO::PG_FactoryRegistry::RoleInfo *>;
+ template class ACE_Vector<ACE_CString>;
+
+#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
+
+# pragma instantiate ACE_Hash_Map_Manager <ACE_CString, TAO::PG_FactoryRegistry::RoleInfo *, MapMutex>
+# pragma instantiate ACE_Hash_Map_Entry <ACE_CString, TAO::PG_FactoryRegistry::RoleInfo *>
+# pragma instantiate ACE_Hash_Map_Iterator <ACE_CString, TAO::PG_FactoryRegistry::RoleInfo *, MapMutex>
+# pragma instantiate ACE_Vector<ACE_CString>
+
+#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.h
new file mode 100644
index 00000000000..d44eb4427d6
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.h
@@ -0,0 +1,248 @@
+// -*- C++ -*-
+//=============================================================================
+/**
+ * @file PG_FactoryRegistry.h
+ *
+ * $Id$
+ *
+ * This file declares the implementation of PortableGroup::FactoryRegistry.
+ * Eventually this should be folded into the Fault Tolerance ReplicationManager
+ *
+ * @author Dale Wilson <wilson_d@ociweb.com>
+ */
+//=============================================================================
+
+#ifndef TAO_PG_FACTORYREGISTRY_H_
+#define TAO_PG_FACTORYREGISTRY_H_
+#include /**/ <ace/pre.h>
+#include <ace/ACE.h>
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+//////////////////////////////////
+// Classes declared in this header
+namespace TAO
+{
+ class PG_FactoryRegistry;
+}
+
+/////////////////////////////////
+// Includes needed by this header
+#include <orbsvcs/PortableGroupS.h>
+#include <ace/Hash_Map_Manager.h>
+
+
+/////////////////////
+// Forward references
+
+namespace TAO
+{
+ /**
+ * Implement the PortableGroup::FactoryRegistry interface
+ * Note FactoryRegistry is not part of the OMG standard. It was added
+ * as part of the TAO implementation of Fault Tolerant CORBA
+ */
+ class TAO_PortableGroup_Export PG_FactoryRegistry : public virtual POA_PortableGroup::FactoryRegistry
+ {
+ struct RoleInfo
+ {
+ ACE_CString type_id_;
+ PortableGroup::FactoryInfos infos_;
+
+ RoleInfo(size_t estimated_number_entries = 5);
+ };
+ typedef ACE_Null_Mutex MapMutex;
+ typedef ACE_Hash_Map_Manager <ACE_CString, RoleInfo *, MapMutex> RegistryType;
+ typedef ACE_Hash_Map_Entry <ACE_CString, RoleInfo *> RegistryType_Entry;
+ typedef ACE_Hash_Map_Iterator <ACE_CString, RoleInfo *, MapMutex> RegistryType_Iterator;
+
+ //////////////////////
+ // non-CORBA interface
+ public:
+ /// Constructor
+ PG_FactoryRegistry (const char * name = "FactoryRegistry");
+
+ /// virtual Destructor
+ virtual ~PG_FactoryRegistry (void);
+
+ /**
+ * Parse command line arguments.
+ * @param argc traditional C argc
+ * @param argv traditional C argv
+ * @return zero for success; nonzero is process return code for failure.
+ */
+ int parse_args (int argc, char * argv[]);
+
+ /**
+ * Initialize this object.
+ * @param orbManager our ORB -- we keep var to it.
+ * @return zero for success; nonzero is process return code for failure.
+ */
+ int init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL);
+
+ /**
+ * Prepare to exit.
+ * @return zero for success; nonzero is process return code for failure.
+ */
+ int fini (ACE_ENV_SINGLE_ARG_DECL);
+
+ /**
+ * Processing to happen when the ORB's event loop is idle.
+ * @param result is a place to return status to be returned by the process
+ * @returns 0 to continue. 1 to quit.
+ */
+ int idle(int & result);
+
+ /**
+ * Identify this object.
+ * @return a string to identify this object for logging/console message purposes.
+ */
+ const char * identity () const;
+
+ /**
+ * An object reference to the this object.
+ * Duplicated by the call so it may (and probably should) be assigned to a _var..
+ */
+ ::PortableGroup::FactoryRegistry_ptr reference();
+
+ ////////////////////////////////
+ // override servant base methods
+ virtual void _remove_ref (ACE_ENV_SINGLE_ARG_DECL);
+
+ //////////////////
+ // CORBA interface
+ // See IDL for documentation
+
+ virtual void register_factory (
+ const char * role,
+ const char * type_id,
+ const PortableGroup::FactoryInfo & factory_info
+ ACE_ENV_ARG_DECL
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException
+ , PortableGroup::MemberAlreadyPresent
+ , PortableGroup::TypeConflict));
+
+ virtual void unregister_factory (
+ const char * role,
+ const PortableGroup::Location & location
+ ACE_ENV_ARG_DECL
+ )
+ ACE_THROW_SPEC ((CORBA::SystemException, PortableGroup::MemberNotFound));
+
+ virtual void unregister_factory_by_role (
+ const char * role
+ ACE_ENV_ARG_DECL
+ )
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+
+ virtual void unregister_factory_by_location (
+ const PortableGroup::Location & location
+ ACE_ENV_ARG_DECL
+ )
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual ::PortableGroup::FactoryInfos * list_factories_by_role (
+ const char * role,
+ CORBA::String_out type_id
+ ACE_ENV_ARG_DECL
+ )
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual ::PortableGroup::FactoryInfos * list_factories_by_location (
+ const PortableGroup::Location & location
+ ACE_ENV_ARG_DECL
+ )
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ /////////////////////////
+ // Implementation methods
+ private:
+ /**
+ * Write this factory's IOR to a file
+ */
+ int write_ior_file (const char * outputFile, const char * ior);
+
+ ///////////////
+ // Data Members
+ private:
+
+ /**
+ * A human-readable string to distinguish this from other Notifiers.
+ */
+ ACE_CString identity_;
+
+ /**
+ * Protect internal state.
+ * Mutex should be locked by corba methods, or by
+ * external (public) methods before calling implementation
+ * methods.
+ * Implementation methods should assume the mutex is
+ * locked if necessary.
+ */
+ ACE_Mutex internals_;
+ typedef ACE_Guard<ACE_Mutex> InternalGuard;
+
+ /**
+ * The orb
+ */
+ CORBA::ORB_var orb_;
+
+ /**
+ * The POA used to activate this object.
+ */
+ PortableServer::POA_var poa_;
+
+ /**
+ * The CORBA object id assigned to this object.
+ */
+ PortableServer::ObjectId_var object_id_;
+
+ /**
+ * This objects identity as a CORBA object.
+ */
+ CORBA::Object_var this_obj_;
+
+ /**
+ * IOR of this object as assigned by poa.
+ */
+ CORBA::String_var ior_;
+
+ /**
+ * A file to which the factory's IOR should be written.
+ */
+ const char * ior_output_file_;
+
+ /**
+ * A name to be used to register the factory with the name service.
+ */
+ const char * ns_name_;
+
+ CosNaming::NamingContext_var naming_context_;
+
+ CosNaming::Name this_name_;
+
+ /**
+ * Quit on idle flag.
+ */
+ int quit_on_idle_;
+
+ /**
+ * State of the quit process
+ */
+ enum {LIVE, DEACTIVATED, GONE} quit_state_;
+
+ int linger_;
+
+ RegistryType registry_;
+
+ };
+} // namespace TAO
+
+#include /**/ <ace/post.h>
+
+#endif // TAO_PG_FACTORYREGISTRY_H_
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Factory_Map.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Factory_Map.cpp
index a2214cc57e3..a106f168d16 100644
--- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Factory_Map.cpp
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Factory_Map.cpp
@@ -10,18 +10,18 @@ ACE_RCSID (PortableGroup,
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
-template class ACE_Hash_Map_Entry<ACE_UINT32, TAO_PG_Factory_Set>;
-template class ACE_Hash_Map_Manager_Ex<ACE_UINT32, TAO_PG_Factory_Set, ACE_Hash<ACE_UINT32>, ACE_Equal_To<ACE_UINT32>, ACE_Null_Mutex>;
-template class ACE_Hash_Map_Iterator_Base_Ex<ACE_UINT32, TAO_PG_Factory_Set, ACE_Hash<ACE_UINT32>, ACE_Equal_To<ACE_UINT32>, ACE_Null_Mutex>;
-template class ACE_Hash_Map_Iterator_Ex<ACE_UINT32, TAO_PG_Factory_Set, ACE_Hash<ACE_UINT32>, ACE_Equal_To<ACE_UINT32>, ACE_Null_Mutex>;
-template class ACE_Hash_Map_Reverse_Iterator_Ex<ACE_UINT32, TAO_PG_Factory_Set, ACE_Hash<ACE_UINT32>, ACE_Equal_To<ACE_UINT32>, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Entry<PortableGroup::ObjectGroupId, TAO_PG_Factory_Set>;
+template class ACE_Hash_Map_Manager_Ex<PortableGroup::ObjectGroupId, TAO_PG_Factory_Set, ACE_Hash<PortableGroup::ObjectGroupId>, ACE_Equal_To<PortableGroup::ObjectGroupId>, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Iterator_Base_Ex<PortableGroup::ObjectGroupId, TAO_PG_Factory_Set, ACE_Hash<PortableGroup::ObjectGroupId>, ACE_Equal_To<PortableGroup::ObjectGroupId>, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Iterator_Ex<PortableGroup::ObjectGroupId, TAO_PG_Factory_Set, ACE_Hash<PortableGroup::ObjectGroupId>, ACE_Equal_To<PortableGroup::ObjectGroupId>, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Reverse_Iterator_Ex<PortableGroup::ObjectGroupId, TAO_PG_Factory_Set, ACE_Hash<PortableGroup::ObjectGroupId>, ACE_Equal_To<PortableGroup::ObjectGroupId>, ACE_Null_Mutex>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
-#pragma instantiate ACE_Hash_Map_Entry<ACE_UINT32, TAO_PG_Factory_Set>
-#pragma instantiate ACE_Hash_Map_Manager_Ex<ACE_UINT32, TAO_PG_Factory_Set, ACE_Hash<ACE_UINT32>, ACE_Equal_To<ACE_UINT32>, ACE_Null_Mutex>
-#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<ACE_UINT32, TAO_PG_Factory_Set, ACE_Hash<ACE_UINT32>, ACE_Equal_To<ACE_UINT32>, ACE_Null_Mutex>
-#pragma instantiate ACE_Hash_Map_Iterator_Ex<ACE_UINT32, TAO_PG_Factory_Set, ACE_Hash<ACE_UINT32>, ACE_Equal_To<ACE_UINT32>, ACE_Null_Mutex>
-#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<ACE_UINT32, TAO_PG_Factory_Set, ACE_Hash<ACE_UINT32>, ACE_Equal_To<ACE_UINT32>, ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Entry<PortableGroup::ObjectGroupId, TAO_PG_Factory_Set>
+#pragma instantiate ACE_Hash_Map_Manager_Ex<PortableGroup::ObjectGroupId, TAO_PG_Factory_Set, ACE_Hash<PortableGroup::ObjectGroupId>, ACE_Equal_To<PortableGroup::ObjectGroupId>, ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<PortableGroup::ObjectGroupId, TAO_PG_Factory_Set, ACE_Hash<PortableGroup::ObjectGroupId>, ACE_Equal_To<PortableGroup::ObjectGroupId>, ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Iterator_Ex<PortableGroup::ObjectGroupId, TAO_PG_Factory_Set, ACE_Hash<PortableGroup::ObjectGroupId>, ACE_Equal_To<PortableGroup::ObjectGroupId>, ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<PortableGroup::ObjectGroupId, TAO_PG_Factory_Set, ACE_Hash<PortableGroup::ObjectGroupId>, ACE_Equal_To<PortableGroup::ObjectGroupId>, ACE_Null_Mutex>
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Factory_Map.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Factory_Map.h
index 09df905cf90..d3747ef190d 100644
--- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Factory_Map.h
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Factory_Map.h
@@ -31,10 +31,10 @@
/// Factory hash map.
typedef ACE_Hash_Map_Manager_Ex<
- ACE_UINT32,
+ PortableGroup::ObjectGroupId,
TAO_PG_Factory_Set,
- ACE_Hash<ACE_UINT32>,
- ACE_Equal_To<ACE_UINT32>,
+ ACE_Hash<PortableGroup::ObjectGroupId>,
+ ACE_Equal_To<PortableGroup::ObjectGroupId>,
ACE_Null_Mutex> TAO_PG_Factory_Map;
#include /**/ "ace/post.h"
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Factory_Set.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Factory_Set.h
index 3bca619031f..9f99094f2bf 100644
--- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Factory_Set.h
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Factory_Set.h
@@ -43,6 +43,9 @@ struct TAO_PG_Factory_Node
/// Member factory information.
PortableGroup::FactoryInfo factory_info;
+ /// The ObjectGroupId to which this member belongs
+ PortableGroup::ObjectGroupId object_group_id;
+
/// FactoryCreationId assigned to the member.
PortableGroup::GenericFactory::FactoryCreationId_var factory_creation_id;
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.cpp
index 74ce8b32233..59e81608a93 100644
--- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.cpp
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.cpp
@@ -4,6 +4,9 @@
#include "PG_PropertyManager.h"
#include "PG_Property_Utils.h"
#include "PG_conf.h"
+#include "orbsvcs/PortableGroupC.h"
+#include "PG_Properties_Encoder.h"
+#include "PG_Properties_Decoder.h"
ACE_RCSID (PortableGroup,
@@ -15,6 +18,7 @@ TAO_PG_GenericFactory::TAO_PG_GenericFactory (
TAO_PG_ObjectGroupManager & object_group_manager,
TAO_PG_PropertyManager & property_manager)
: poa_ (),
+// next_group_id_(0),
object_group_manager_ (object_group_manager),
property_manager_ (property_manager),
factory_map_ (TAO_PG_MAX_OBJECT_GROUPS),
@@ -22,6 +26,8 @@ TAO_PG_GenericFactory::TAO_PG_GenericFactory (
lock_ ()
{
this->object_group_manager_.generic_factory (this);
+ this->domain_id_ = "default-domain";
+
}
TAO_PG_GenericFactory::~TAO_PG_GenericFactory (void)
@@ -65,6 +71,10 @@ TAO_PG_GenericFactory::create_object (
PortableGroup::InvalidProperty,
PortableGroup::CannotMeetCriteria))
{
+
+ PortableGroup::ObjectGroup_var object_group = PortableGroup::ObjectGroup::_nil();
+
+
PortableGroup::Properties_var properties =
this->property_manager_.get_type_properties (type_id
ACE_ENV_ARG_PARAMETER);
@@ -85,56 +95,39 @@ TAO_PG_GenericFactory::create_object (
the_criteria,
membership_style,
factory_infos,
- initial_number_members,
+ minimum_number_members,
minimum_number_members
ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (CORBA::Object::_nil ());
- CORBA::ULong fcid = 0;
- {
- ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
- guard,
- this->lock_,
- CORBA::Object::_nil ());
+ PortableGroup::ObjectGroupId group_id;
+// PortableGroup::ObjectGroup_var
+ object_group =
+ this->object_group_manager_.create_object_group (type_id, // in
+ this->domain_id_, // in
+ the_criteria, // in
+ group_id // out
+ ACE_ENV_ARG_PARAMETER);
- // Start out with an initial value.
- fcid = this->next_fcid_;
+ ACE_CHECK_RETURN (CORBA::Object::_nil ());
+
+ // Allocate a new FactoryCreationId for use as an "out" parameter.
+ PortableGroup::GenericFactory::FactoryCreationId_var factory_id = 0;
+ ACE_NEW_THROW_EX (factory_id,
+ PortableGroup::GenericFactory::FactoryCreationId,
+ CORBA::NO_MEMORY (
+ CORBA::SystemException::_tao_minor_code (
+ TAO_DEFAULT_MINOR_CODE,
+ ENOMEM),
+ CORBA::COMPLETED_NO));
+ ACE_CHECK_RETURN (CORBA::Object::_nil ());
+ *factory_id <<= group_id;
- // Loop until a free FactoryCreationId is found, being careful to
- // search through the range of FactoryCreationIds only once.
- while (this->factory_map_.find (this->next_fcid_) == 0)
- {
- this->next_fcid_++;
-
- // If this is true, then no FactoryCreationIds are available.
- // This is highly unlikely since TAO implements a
- // FactoryCreationId as a 32 bit unsigned integer, meaning
- // that over 4 billion object groups are being managed by this
- // generic factory!
- if (this->next_fcid_ == fcid)
- ACE_THROW_RETURN (PortableGroup::ObjectNotCreated (),
- CORBA::Object::_nil ());
- }
- // Just in case this->next_fcid_ was modified in the above search,
- // reassign the value.
- fcid = this->next_fcid_;
- }
-
- // The ObjectId for the newly created object group is comprised
- // solely of the FactoryCreationId.
- PortableServer::ObjectId_var oid;
- this->get_ObjectId (fcid, oid.out ());
-
- PortableGroup::ObjectGroup_var object_group =
- this->object_group_manager_.create_object_group (fcid,
- oid.in (),
- type_id,
- the_criteria
- ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (CORBA::Object::_nil ());
+
TAO_PG_Factory_Set factory_set;
const CORBA::ULong factory_infos_count = factory_infos.length ();
@@ -147,30 +140,24 @@ TAO_PG_GenericFactory::create_object (
this->populate_object_group (object_group.in (),
type_id,
factory_infos,
- initial_number_members,
+ minimum_number_members,
factory_set
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
- if (this->factory_map_.bind (fcid, factory_set) != 0)
- ACE_TRY_THROW (PortableGroup::ObjectNotCreated ());
- }
- // Allocate a new FactoryCreationId for use as an "out" parameter.
- PortableGroup::GenericFactory::FactoryCreationId * tmp = 0;
- ACE_NEW_THROW_EX (tmp,
- PortableGroup::GenericFactory::FactoryCreationId,
- CORBA::NO_MEMORY (
- CORBA::SystemException::_tao_minor_code (
- TAO_DEFAULT_MINOR_CODE,
- ENOMEM),
- CORBA::COMPLETED_NO));
- ACE_CHECK_RETURN (CORBA::Object::_nil ());
+ CORBA::ULong fcid = 0;
+
+ ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
+ guard,
+ this->lock_,
+ CORBA::Object::_nil ());
- factory_creation_id = tmp;
- *tmp <<= fcid;
+ if (this->factory_map_.bind (group_id, factory_set) != 0)
+ ACE_TRY_THROW (PortableGroup::ObjectNotCreated ());
+ }
}
ACE_CATCHANY
{
@@ -179,7 +166,7 @@ TAO_PG_GenericFactory::create_object (
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
- this->object_group_manager_.destroy_object_group (oid.in ()
+ this->object_group_manager_.destroy_object_group (group_id
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
@@ -188,16 +175,7 @@ TAO_PG_GenericFactory::create_object (
ACE_ENDTRY;
ACE_CHECK_RETURN (CORBA::Object::_nil ());
- {
- ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
- guard,
- this->lock_,
- CORBA::Object::_nil ());
-
- // Object group was successfully created. Increment the next
- // FactoryCreationId in preparation for the next object group.
- this->next_fcid_++;
- }
+ factory_creation_id = factory_id._retn();
return object_group._retn ();
}
@@ -210,9 +188,9 @@ TAO_PG_GenericFactory::delete_object (
ACE_THROW_SPEC ((CORBA::SystemException,
PortableGroup::ObjectNotFound))
{
- CORBA::ULong fcid = 0;
+ PortableGroup::ObjectGroupId group_id;
- if (factory_creation_id >>= fcid) // Extract the actual FactoryCreationId.
+ if (factory_creation_id >>= group_id) // Extract the actual FactoryCreationId.
{
// Successfully extracted the FactoryCreationId. Now find the
// TAO_PG_Factory_Set corresponding to it.
@@ -222,34 +200,30 @@ TAO_PG_GenericFactory::delete_object (
// If no entry exists in the factory map, infrastructure
// controlled membership was not used.
TAO_PG_Factory_Map::ENTRY *entry = 0;
- if (this->factory_map_.find (fcid, entry) == 0)
+ if (this->factory_map_.find (group_id, entry) == 0)
{
TAO_PG_Factory_Set & factory_set = entry->int_id_;
+
this->delete_object_i (factory_set,
0 /* Do not ignore exceptions */
ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
- if (this->factory_map_.unbind (fcid) != 0)
+ if (this->factory_map_.unbind (group_id) != 0)
ACE_THROW (CORBA::INTERNAL ());
+
+ // Destroy the object group entry.
+ this->object_group_manager_.destroy_object_group (
+ group_id
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
}
}
else
ACE_THROW (PortableGroup::ObjectNotFound ()); // @@
// CORBA::BAD_PARAM
// instead?
-
- // The ObjectId for the newly created object group is comprised
- // solely of the FactoryCreationId.
- PortableServer::ObjectId_var oid;
- this->get_ObjectId (fcid, oid.out ());
-
- // Destroy the object group entry.
- this->object_group_manager_.destroy_object_group (
- oid.in ()
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
}
void
@@ -305,7 +279,7 @@ TAO_PG_GenericFactory::delete_object_i (TAO_PG_Factory_Set & factory_set,
void
TAO_PG_GenericFactory::delete_member (
- CORBA::ULong group_id,
+ PortableGroup::ObjectGroupId group_id,
const PortableGroup::Location & location
ACE_ENV_ARG_DECL)
{
@@ -378,7 +352,7 @@ TAO_PG_GenericFactory::populate_object_group (
PortableGroup::ObjectGroup_ptr object_group,
const char * type_id,
const PortableGroup::FactoryInfos & factory_infos,
- PortableGroup::InitialNumberMembersValue initial_number_members,
+ PortableGroup::MinimumNumberMembersValue minimum_number_members,
TAO_PG_Factory_Set & factory_set
ACE_ENV_ARG_DECL)
{
@@ -391,7 +365,7 @@ TAO_PG_GenericFactory::populate_object_group (
const PortableGroup::FactoryInfo &factory_info = factory_infos[j];
- if (j < ACE_static_cast (CORBA::ULong, initial_number_members))
+ if (j < ACE_static_cast (CORBA::ULong, minimum_number_members))
{
PortableGroup::GenericFactory_ptr factory =
factory_info.the_factory.in ();
@@ -421,41 +395,6 @@ TAO_PG_GenericFactory::populate_object_group (
}
void
-TAO_PG_GenericFactory::get_ObjectId (
- CORBA::ULong fcid,
- PortableServer::ObjectId_out oid)
-{
- // Since the POA used by the LoadManager uses the NON_RETAIN
- // policy, explicitly choose an ObjectId that is unique to a given
- // type.
-
- // Make the ObjectId be the next value of the number of types that
- // have been registered with the LoadManager. For example, if two
- // types of objects have been registered with the LoadManager, then
- // the ObjectId for the object currently being registered will be
- // "3" since the object will be the third type of object registered
- // with the LoadManager. Previously used values will not be reused
- // to ensure that a ServantLocator does not inadvertently return a
- // reference to an object that had a previously used ObjectId.
- // Specifcally, the numerical value used for the ObjectId increases
- // monotonically.
-
- // 4294967295UL -- Largest 32 bit unsigned integer
- // 123456789012 -- 10 digits
- // + 2 for "UL" (unnecessary, but let's be safe)
- // + 1 for null terminator
- // + 1 for good luck. :-)
- const size_t MAX_OID_LEN = 14;
-
- char oid_str[MAX_OID_LEN] = { 0 };
- ACE_OS::sprintf (oid_str,
- "%ul",
- fcid);
-
- oid = PortableServer::string_to_ObjectId (oid_str);
-}
-
-void
TAO_PG_GenericFactory::process_criteria (
const char * type_id,
const PortableGroup::Criteria & criteria,
@@ -485,25 +424,22 @@ TAO_PG_GenericFactory::process_criteria (
name.length (1);
PortableGroup::Value value;
- PortableGroup::Value value1;
- PortableGroup::Value value2;
- PortableGroup::Value value3;
// MembershipStyle
- name[0].id = CORBA::string_dup ("org.omg.PortableGroup.MembershipStyle");
+ name[0].id = CORBA::string_dup (PortableGroup::PG_MEMBERSHIP_STYLE);
if (TAO_PG::get_property_value (name, props.in (), value)
&& (!(value >>= membership_style)
|| (membership_style != PortableGroup::MEMB_APP_CTRL
&& membership_style != PortableGroup::MEMB_INF_CTRL)))
{
- // This only occurs if extraction of the actual value from the
- // Any fails.
ACE_THROW (PortableGroup::InvalidProperty (name, value));
}
// Factories
const PortableGroup::FactoryInfos * factory_infos_tmp = 0;
- name[0].id = CORBA::string_dup ("org.omg.PortableGroup.Factories");
+
+ PortableGroup::Value value1;
+ name[0].id = CORBA::string_dup (PortableGroup::PG_FACTORIES);
if (TAO_PG::get_property_value (name, props.in (), value1)
&& !(value1 >>= factory_infos_tmp))
{
@@ -515,9 +451,10 @@ TAO_PG_GenericFactory::process_criteria (
const CORBA::ULong factory_infos_count =
(factory_infos_tmp == 0 ? 0 : factory_infos_tmp->length ());
+ PortableGroup::Value value2;
// InitialNumberMembers
name[0].id =
- CORBA::string_dup ("org.omg.PortableGroup.InitialNumberMembers");
+ CORBA::string_dup (PortableGroup::PG_INITIAL_NUMBER_MEMBERS);
if (TAO_PG::get_property_value (name, props.in (), value2)
&& !(value2 >>= initial_number_members))
{
@@ -533,7 +470,7 @@ TAO_PG_GenericFactory::process_criteria (
// possibly be created.
if (factory_infos_count < ACE_static_cast (CORBA::ULong,
- initial_number_members))
+ minimum_number_members))
{
unmet_criteria[uc].nam = name;
unmet_criteria[uc++].val = value2;
@@ -541,6 +478,7 @@ TAO_PG_GenericFactory::process_criteria (
}
// MinimumNumberMembers
+ PortableGroup::Value value3;
name[0].id =
CORBA::string_dup ("org.omg.PortableGroup.MinimumNumberMembers");
if (TAO_PG::get_property_value (name, props.in (), value3)
@@ -560,7 +498,7 @@ TAO_PG_GenericFactory::process_criteria (
// changed.
if (membership_style == PortableGroup::MEMB_INF_CTRL)
{
- if (minimum_number_members < initial_number_members
+ if (minimum_number_members > initial_number_members
|| ACE_static_cast (CORBA::ULong,
minimum_number_members) > factory_infos_count)
{
@@ -589,11 +527,21 @@ TAO_PG_GenericFactory::process_criteria (
void
TAO_PG_GenericFactory::check_minimum_number_members (
PortableGroup::ObjectGroup_ptr object_group,
- CORBA::ULong group_id,
+ PortableGroup::ObjectGroupId group_id,
const char * type_id
ACE_ENV_ARG_DECL)
{
- // Check if we've dropped below the MinimumNumberMembers threshold.
+
+ //TODO - Fix this code. The original implementation for the load balancer assumed
+ // that the factory-creation-id was the same as the object-group-id. This
+ // is not longer true. The find below is supposed to be a factory-creation-id.
+{
+ int _todo_fix_temporarily_disabled_code_;
+}
+ return;
+
+#if 0
+ // Check if we've dropped below the MinimumNumberMembers threshold.
// If so, attempt to create enough new members to fill the gap.
// If no entry exists in the factory map, infrastructure (this
@@ -617,7 +565,7 @@ TAO_PG_GenericFactory::check_minimum_number_members (
// MinimumNumberMembers
name[0].id =
- CORBA::string_dup ("org.omg.PortableGroup.MinimumNumberMembers");
+ CORBA::string_dup (PG_MINIMUM_NUMBER_MEMBERS);
PortableGroup::MinimumNumberMembersValue minimum_number_members;
@@ -692,6 +640,7 @@ TAO_PG_GenericFactory::check_minimum_number_members (
// threshold gap hasn't been filled, what do we do? Throw
// a CORBA::TRANSIENT?
}
+#endif
}
PortableGroup::GenericFactory::FactoryCreationId *
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.h
index 5037ace92f1..d7ae4be28fd 100644
--- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.h
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.h
@@ -119,21 +119,21 @@ public:
* This method is only used by the TAO_PG_ObjectGroupManager class
* when ObjectGroupManager::remove_member() is explicitly called.
*/
- void delete_member (CORBA::ULong group_id,
+ void delete_member (PortableGroup::ObjectGroupId group_id,
const PortableGroup::Location & location
ACE_ENV_ARG_DECL);
- /// Verify that the MinimumNumberMembers criterion is satisfied.
+ /// Verify that the MinimumNumberReplicas criterion is satisfied.
/**
* If the current number of members in the given object group is
- * less than the MinimumNumberMembers criterion in effect for that
+ * less than the MinimumNumberReplicas criterion in effect for that
* group, the infrastructure will attempt create and add more
* members to the group by invoking any unused application-supplied
* GenericFactorys.
*/
void check_minimum_number_members (
PortableGroup::ObjectGroup_ptr object_group,
- CORBA::ULong group_id,
+ PortableGroup::ObjectGroupId group_id,
const char * type_id
ACE_ENV_ARG_DECL);
@@ -154,7 +154,7 @@ public:
PortableGroup::InvalidCriteria,
PortableGroup::InvalidProperty,
PortableGroup::CannotMeetCriteria,
- PortableGroup::MemberAlreadyPresent));
+ PortableGroup::MemberAlreadyPresent));
private:
@@ -169,20 +169,12 @@ private:
TAO_PG_Factory_Set & factory_set
ACE_ENV_ARG_DECL);
- /// Get a new ObjectId to be used when creating a new ObjectGroup.
- /**
- * An ObjectId created by this method will never be reused within
- * the scope of a given ReplicationManager. A value suitable for
- * use in a map association <ext_id> is also returned.
- */
- void get_ObjectId (CORBA::ULong fcid,
- PortableServer::ObjectId_out oid);
/// Process criteria to be applied to the object group being
/// created.
/**
- * Only the MemberShipStyle, Factories, InitialNumberMembers and
- * MinimumNumberMembers criteria/properties are defined by the
+ * Only the MemberShipStyle, Factories, InitialNumberReplicas and
+ * MinimumNumberReplicas criteria/properties are defined by the
* PortableGroup IDL. Other services that implement the
* GenericFactory interface, such as load balancing and fault
* tolerance, may choose to support more.
@@ -204,6 +196,10 @@ private:
/// Reference to the POA used to create object group references.
PortableServer::POA_var poa_;
+ /// The GroupCreationId that will be assigned to the next object
+ /// group that is created.
+// PortableGroup::ObjectGroupId next_group_id_;
+
/// Reference to the ObjectGroup map.
TAO_PG_ObjectGroupManager & object_group_manager_;
@@ -234,6 +230,8 @@ private:
*/
CORBA::ULong next_fcid_;
+ const char * domain_id_;
+
/// Lock used to synchronize access to the factory creation id
/// index (i.e. next_fcid_).
TAO_SYNCH_MUTEX lock_;
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Guard.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Guard.cpp
index 7a7c359da50..a4318e9b8fe 100644
--- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Guard.cpp
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Guard.cpp
@@ -13,11 +13,11 @@ TAO_PG_Group_Guard::TAO_PG_Group_Guard (
TAO_PG_GenericFactory & generic_factory,
TAO_PG_Factory_Set & factory_set,
TAO_PG_ObjectGroupManager & group_manager,
- const PortableServer::ObjectId & oid)
+ const PortableGroup::ObjectGroupId group_id)
: generic_factory_ (generic_factory),
factory_set_ (factory_set),
group_manager_ (group_manager),
- oid_ (oid),
+ group_id_ (group_id),
released_ (0)
{
}
@@ -36,7 +36,7 @@ TAO_PG_Group_Guard::~TAO_PG_Group_Guard (void)
// This should never throw an exception if this Guard is
// used properly.
- this->group_manager_.destroy_object_group (this->oid_
+ this->group_manager_.destroy_object_group (this->group_id_
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
}
@@ -53,4 +53,3 @@ TAO_PG_Group_Guard::release (void)
{
this->released_ = 1;
}
-
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Guard.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Guard.h
index eaa065a6d6c..ac32fbf6a2a 100644
--- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Guard.h
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Guard.h
@@ -54,7 +54,7 @@ public:
TAO_PG_Group_Guard (TAO_PG_GenericFactory & generic_factory,
TAO_PG_Factory_Set & factory_set,
TAO_PG_ObjectGroupManager & group_manager,
- const PortableServer::ObjectId & oid);
+ const PortableGroup::ObjectGroupId group_id);
/// Destructor.
~TAO_PG_Group_Guard (void);
@@ -76,15 +76,15 @@ private:
/// object group map.
TAO_PG_ObjectGroupManager & group_manager_;
- /// Reference to the ObjectId that is the map key necessary to
+ /// Reference to the ObjectGroupId that is the map key necessary to
/// unbind the corresponding object group map entry from the map
/// upon destruction.
- const PortableServer::ObjectId & oid_;
+ const PortableGroup::ObjectGroupId group_id_;
/// Flag that dictates whether or not the destructor will perform
/// cleanup.
int released_;
-
+
};
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.cpp
index 52a2a4d9bd5..9255610bcb7 100644
--- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.cpp
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.cpp
@@ -2,6 +2,7 @@
#include "PG_GenericFactory.h"
#include "PG_conf.h"
#include "PG_Operators.h"
+#include "PG_Utils.h"
#include "tao/debug.h"
@@ -18,7 +19,9 @@ TAO_PG_ObjectGroupManager::TAO_PG_ObjectGroupManager (void)
object_group_map_ (TAO_PG_MAX_OBJECT_GROUPS),
location_map_ (TAO_PG_MAX_LOCATIONS),
generic_factory_ (0),
- lock_ ()
+ lock_ (),
+ lock_ogid_ (),
+ next_ogid_ (1) // don't use ogid 0
{
}
@@ -468,23 +471,98 @@ TAO_PG_ObjectGroupManager::get_member_ref (
CORBA::Object::_nil ());
}
+PortableGroup::ObjectGroup_ptr
+TAO_PG_ObjectGroupManager::get_object_group_ref_from_id (
+ PortableGroup::ObjectGroupId group_id
+ ACE_ENV_ARG_DECL
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException
+ , PortableGroup::ObjectGroupNotFound
+ ))
+{
+ //@@ If we change the PG's concept of ObjectGroupId from
+ // PortableServer::ObjectId to PortableGroup::ObjectGroupId, can
+ // just call TAO_PG_ObjectGroupManager::object_group() here.
+
+ TAO_PG_ObjectGroup_Map_Entry * group_entry = 0;
+ {
+ ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
+ guard,
+ this->lock_,
+ PortableGroup::ObjectGroup::_nil ());
+
+ if (this->object_group_map_.find (group_id, group_entry) != 0)
+ ACE_THROW_RETURN (PortableGroup::ObjectGroupNotFound (),
+ PortableGroup::ObjectGroup::_nil ());
+ }
+
+ if (group_entry == 0)
+ ACE_THROW_RETURN (CORBA::INTERNAL (),
+ PortableGroup::ObjectGroup::_nil ());
+
+ return
+ PortableGroup::ObjectGroup::_duplicate (group_entry->object_group.in ());
+}
+
+
+
+void TAO_PG_ObjectGroupManager::allocate_ogid (PortableGroup::ObjectGroupId & ogid)
+{
+ ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->lock_ogid_);
+ //@@ NOTE: as always, ACE_GUARD_XXXX does the wrong thing if the lock fails
+
+ // The numerical value used for the ObjectId increases
+ // monotonically.
+
+ ogid = this->next_ogid_;
+ this->next_ogid_ += 1;
+}
+
+PortableServer::ObjectId * TAO_PG_ObjectGroupManager::convert_ogid_to_oid (PortableGroup::ObjectGroupId ogid)
+{
+ // 4294967295 -- Largest 32 bit unsigned integer
+ char oid_str[11];
+ ACE_OS::snprintf (oid_str, sizeof(oid_str),
+ "%lu",
+ ACE_static_cast (ACE_UINT32,ogid));
+ oid_str[sizeof(oid_str) - 1] = '\0';
+
+ return PortableServer::string_to_ObjectId (oid_str);
+}
PortableGroup::ObjectGroup_ptr
TAO_PG_ObjectGroupManager::create_object_group (
- CORBA::ULong group_id,
- const PortableServer::ObjectId &oid,
const char * type_id,
- const PortableGroup::Criteria & the_criteria
+ const char * domain_id,
+ const PortableGroup::Criteria & the_criteria,
+ PortableGroup::ObjectGroupId & group_id
ACE_ENV_ARG_DECL)
{
+ allocate_ogid(group_id);
+ PortableServer::ObjectId_var oid = convert_ogid_to_oid (group_id);
+
// Create a reference for the ObjectGroup corresponding to the
// RepositoryId of the object being created.
CORBA::Object_var object_group =
- this->poa_->create_reference_with_id (oid,
+ this->poa_->create_reference_with_id (group_id,
type_id
ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (CORBA::Object::_nil ());
+ PortableGroup::TagGroupTaggedComponent tag_component;
+
+ tag_component.component_version.major = (CORBA::Octet) 1;
+ tag_component.component_version.minor = (CORBA::Octet) 0;
+ tag_component.group_domain_id = domain_id;
+ tag_component.object_group_id = group_id;
+ tag_component.object_group_ref_version = 0;
+
+ // Set the property
+ TAO::PG_Utils::set_tagged_component (object_group,
+ tag_component);
+ ACE_CHECK_RETURN (CORBA::Object::_nil ());
+
TAO_PG_ObjectGroup_Map_Entry * group_entry = 0;
ACE_NEW_THROW_EX (group_entry,
TAO_PG_ObjectGroup_Map_Entry,
@@ -507,19 +585,18 @@ TAO_PG_ObjectGroupManager::create_object_group (
CORBA::ULong len = the_criteria.length ();
group_entry->properties.length (len);
+
for (CORBA::ULong i = 0; i < len; ++i)
group_entry->properties[i] = the_criteria[i];
- {
- ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
- guard,
- this->lock_,
- 0);
+ ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
+ guard,
+ this->lock_,
+ 0);
- if (this->object_group_map_.bind (oid, group_entry) != 0)
- ACE_THROW_RETURN (PortableGroup::ObjectNotCreated (),
- PortableGroup::ObjectGroup::_nil ());
- }
+ if (this->object_group_map_.bind (group_id, group_entry) != 0)
+ ACE_THROW_RETURN (PortableGroup::ObjectNotCreated (),
+ PortableGroup::ObjectGroup::_nil ());
(void) safe_group_entry.release ();
@@ -528,13 +605,13 @@ TAO_PG_ObjectGroupManager::create_object_group (
void
TAO_PG_ObjectGroupManager::destroy_object_group (
- const PortableServer::ObjectId & oid
+ const PortableGroup::ObjectGroupId group_id
ACE_ENV_ARG_DECL)
{
ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->lock_);
TAO_PG_ObjectGroup_Map_Entry * group_entry = 0;
- if (this->object_group_map_.unbind (oid, group_entry) != 0)
+ if (this->object_group_map_.unbind (group_id, group_entry) != 0)
ACE_THROW (PortableGroup::ObjectNotFound ());
delete group_entry;
@@ -559,7 +636,7 @@ TAO_PG_ObjectGroupManager::type_id (
}
PortableGroup::ObjectGroup_ptr
-TAO_PG_ObjectGroupManager::object_group (const PortableServer::ObjectId & oid)
+TAO_PG_ObjectGroupManager::object_group (const PortableGroup::ObjectGroupId ogid)
{
ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
guard,
@@ -567,7 +644,7 @@ TAO_PG_ObjectGroupManager::object_group (const PortableServer::ObjectId & oid)
PortableGroup::ObjectGroup::_nil ());
TAO_PG_ObjectGroup_Map_Entry * group_entry = 0;
- if (this->object_group_map_.find (oid, group_entry) == 0)
+ if (this->object_group_map_.find (ogid, group_entry) == 0)
return
PortableGroup::ObjectGroup::_duplicate (group_entry->object_group.in ());
else
@@ -594,13 +671,27 @@ TAO_PG_ObjectGroupManager::member_count (
return ACE_static_cast (CORBA::ULong, group_entry->member_infos.size ());
}
-void
-TAO_PG_ObjectGroupManager::poa (PortableServer::POA_ptr p)
+int
+TAO_PG_ObjectGroupManager::init (CORBA::ORB_ptr orb, PortableServer::POA_ptr p)
{
- ACE_ASSERT (CORBA::is_nil (this->poa_.in ())
- && !CORBA::is_nil (p));
+ ACE_ASSERT (CORBA::is_nil (this->orb_.in ()) && !CORBA::is_nil (orb));
+ this->orb_ = CORBA::ORB::_duplicate (orb);
+ ACE_ASSERT (CORBA::is_nil (this->poa_.in ()) && !CORBA::is_nil (p));
this->poa_ = PortableServer::POA::_duplicate (p);
+
+ int result = 0;
+
+ // Get an object reference for the ORBs IORManipulation object!
+ CORBA::Object_var IORM = this->orb_->resolve_initial_references (
+ TAO_OBJID_IORMANIPULATION, 0 ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ this->iorm_ = TAO_IOP::TAO_IOR_Manipulation::_narrow (
+ IORM.in () ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ return result;
}
@@ -640,6 +731,27 @@ TAO_PG_ObjectGroupManager::get_properties (
return safe_properties._retn ();
}
+
+PortableGroup::Properties *
+TAO_PG_ObjectGroupManager::get_dynamic_properties (
+ PortableGroup::ObjectGroup_ptr object_group
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ PortableGroup::ObjectGroupNotFound))
+{
+ ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
+ guard,
+ this->lock_,
+ 0);
+
+ TAO_PG_ObjectGroup_Map_Entry * group_entry =
+ this->get_group_entry (object_group
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ return & group_entry->properties;
+}
+
TAO_PG_ObjectGroup_Map_Entry *
TAO_PG_ObjectGroupManager::get_group_entry (
CORBA::Object_ptr object_group
@@ -650,32 +762,16 @@ TAO_PG_ObjectGroupManager::get_group_entry (
if (CORBA::is_nil (this->poa_.in ()))
ACE_THROW_RETURN (CORBA::INTERNAL (), 0);
- PortableServer::ObjectId_var oid;
- ACE_TRY
- {
- oid = this->poa_->reference_to_id (object_group
- ACE_ENV_ARG_PARAMETER);
- ACE_TRY_CHECK;
- }
- ACE_CATCH (PortableServer::POA::WrongAdapter, ex)
- {
- if (TAO_debug_level > 0)
- ACE_PRINT_EXCEPTION (ex, "TAO_PG (%P|%t) Unexpected exception\n");
-
- ACE_TRY_THROW (CORBA::INTERNAL ());
- }
- ACE_CATCH (PortableServer::POA::WrongPolicy, ex)
- {
- if (TAO_debug_level > 0)
- ACE_PRINT_EXCEPTION (ex, "TAO_PG (%P|%t) Unexpected exception\n");
+ // { int _TODO_replace_this_with_commemted_out_version_; }
+ // extract the group_id from the object group reference
+ PortableGroup::TagGroupTaggedComponent tc;
+ TAO::PG_Utils::get_tagged_component (object_group,
+ tc);
- ACE_TRY_THROW (CORBA::INTERNAL ());
- }
- ACE_ENDTRY;
- ACE_CHECK_RETURN (0);
+ PortableGroup::ObjectGroupId group_id = tc.object_group_id;
TAO_PG_ObjectGroup_Map_Entry * group_entry = 0;
- if (this->object_group_map_.find (oid.in (), group_entry) != 0)
+ if (this->object_group_map_.find (group_id, group_entry) != 0)
ACE_THROW_RETURN (PortableGroup::ObjectGroupNotFound (),
0);
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.h
index ab17a05ce25..64f1500b8ba 100644
--- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.h
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.h
@@ -25,9 +25,10 @@
#include "PG_ObjectGroup_Map.h"
#include "PG_Location_Map.h"
+
#include "tao/PortableServer/Key_Adapters.h"
#include "tao/PortableServer/PortableServerC.h"
-
+#include "tao/IORManipulation/IORManip_Loader.h"
/// Forward declarations
class TAO_PG_GenericFactory;
@@ -50,7 +51,7 @@ public:
TAO_PG_ObjectGroupManager (void);
/// Destructor.
- ~TAO_PG_ObjectGroupManager (void);
+ virtual ~TAO_PG_ObjectGroupManager (void);
/**
* @name PortableGroup::ObjectGroupManager methods
@@ -139,6 +140,19 @@ public:
PortableGroup::ObjectGroupNotFound,
PortableGroup::MemberNotFound));
+ /**
+ * TAO-specific extension.
+ * Return the ObjectGroup reference for the given ObjectGroupId.
+ */
+ virtual PortableGroup::ObjectGroup_ptr get_object_group_ref_from_id (
+ PortableGroup::ObjectGroupId group_id
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS
+ )
+ ACE_THROW_SPEC ((
+ CORBA::SystemException
+ , PortableGroup::ObjectGroupNotFound
+ ));
+
//@}
/// TAO-specific member addition method.
@@ -159,25 +173,24 @@ public:
PortableGroup::MemberAlreadyPresent,
PortableGroup::NoFactory));
- /// Create object group hash map entry that represents an actual
- /// ObjectGroup.
+ /// Create object an empty object.
/**
* @note This method is used mainly by the
* GenericFactory::create_object() method.
*/
PortableGroup::ObjectGroup_ptr create_object_group (
- CORBA::ULong group_id,
- const PortableServer::ObjectId &oid,
const char * type_id,
- const PortableGroup::Criteria & the_criteria
+ const char * domain_id,
+ const PortableGroup::Criteria & the_criteria,
+ PortableGroup::ObjectGroupId & group_id
ACE_ENV_ARG_DECL);
- /// Destroy the object group corresponding to the given ObjectId.
+ /// Destroy the object group corresponding to the given ObjectGroupId.
/**
* @note This method is used mainly by the
* GenericFactory::delete_object() method.
*/
- void destroy_object_group (const PortableServer::ObjectId & oid
+ void destroy_object_group (const PortableGroup::ObjectGroupId group_id
ACE_ENV_ARG_DECL);
/// Return the properties set when the object group was created, and
@@ -188,6 +201,13 @@ public:
ACE_THROW_SPEC ((CORBA::SystemException,
PortableGroup::ObjectGroupNotFound));
+ /// Return the dynamic properties for the given group.
+ PortableGroup::Properties * get_dynamic_properties (
+ PortableGroup::ObjectGroup_ptr object_group
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ PortableGroup::ObjectGroupNotFound));
+
/// Return the type_id for the given object group.
char * type_id (PortableGroup::ObjectGroup_ptr object_group
ACE_ENV_ARG_DECL);
@@ -198,7 +218,7 @@ public:
* group corresponding to the given ObjectId exists.
*/
PortableGroup::ObjectGroup_ptr object_group (
- const PortableServer::ObjectId & oid);
+ const PortableGroup::ObjectGroupId ogid);
/// Return the number of members in the given object group.
CORBA::ULong member_count (PortableGroup::ObjectGroup_ptr group
@@ -206,9 +226,8 @@ public:
ACE_THROW_SPEC ((CORBA::SystemException,
PortableGroup::ObjectGroupNotFound));
- /// Set the POA to use when converting object group references to
- /// ObjectIds.
- void poa (PortableServer::POA_ptr p);
+ /// Initializes the group manager.
+ int init (CORBA::ORB_ptr orb, PortableServer::POA_ptr p);
/// Set the pointer to the GenericFactory associated with this
/// ObjectGroupManager.
@@ -265,11 +284,27 @@ protected:
CORBA::Object_ptr member
ACE_ENV_ARG_DECL);
+ /**
+ * Allocate an ogid for a new object group
+ */
+ void allocate_ogid (PortableGroup::ObjectGroupId & ogid);
+
+ /**
+ * convert numeric OGID to Sequence<Octet> oid
+ */
+ PortableServer::ObjectId * convert_ogid_to_oid (PortableGroup::ObjectGroupId ogid);
+
private:
+ /// The orb
+ CORBA::ORB_var orb_;
+
/// Reference to the POA that created the object group references.
PortableServer::POA_var poa_;
+ /// The ORBs IORManipulation object
+ TAO_IOP::TAO_IOR_Manipulation_var iorm_;
+
/// The underlying table that contains all object group
/// information.
TAO_PG_ObjectGroup_Map object_group_map_;
@@ -285,6 +320,12 @@ private:
/// Lock used to synchronize access to the underlying tables.
TAO_SYNCH_MUTEX lock_;
+ /// Lock used to synchronize access to next_ogid_.
+ TAO_SYNCH_MUTEX lock_ogid_;
+
+ /// Next ogid to be allocated.
+ PortableGroup::ObjectGroupId next_ogid_;
+
};
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroup_Map.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroup_Map.cpp
index 3c0f111538a..3cf6b42ede6 100644
--- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroup_Map.cpp
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroup_Map.cpp
@@ -8,22 +8,18 @@ ACE_RCSID (PortableGroup,
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
-template class ACE_Hash_Map_Entry<PortableServer::ObjectId, TAO_PG_ObjectGroup_Map_Entry *>;
-template class ACE_Hash_Map_Manager_Ex<PortableServer::ObjectId, TAO_PG_ObjectGroup_Map_Entry *, TAO_ObjectId_Hash, ACE_Equal_To<PortableServer::ObjectId>, ACE_Null_Mutex>;
-template class ACE_Hash_Map_Iterator_Base_Ex<PortableServer::ObjectId, TAO_PG_ObjectGroup_Map_Entry *, TAO_ObjectId_Hash, ACE_Equal_To<PortableServer::ObjectId>, ACE_Null_Mutex>;
-template class ACE_Hash_Map_Iterator_Ex<PortableServer::ObjectId, TAO_PG_ObjectGroup_Map_Entry *, TAO_ObjectId_Hash, ACE_Equal_To<PortableServer::ObjectId>, ACE_Null_Mutex>;
-template class ACE_Hash_Map_Reverse_Iterator_Ex<PortableServer::ObjectId, TAO_PG_ObjectGroup_Map_Entry *, TAO_ObjectId_Hash, ACE_Equal_To<PortableServer::ObjectId>, ACE_Null_Mutex>;
-
-template class ACE_Equal_To<PortableServer::ObjectId>;
+template class ACE_Hash_Map_Entry<PortableGroup::ObjectGroupId, TAO_PG_ObjectGroup_Map_Entry *>;
+template class ACE_Hash_Map_Manager_Ex<PortableGroup::ObjectGroupId, TAO_PG_ObjectGroup_Map_Entry *, ACE_Hash<ACE_UINT64>, ACE_Equal_To<ACE_UINT64>, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Iterator_Base_Ex<PortableGroup::ObjectGroupId, TAO_PG_ObjectGroup_Map_Entry *, ACE_Hash<ACE_UINT64>, ACE_Equal_To<ACE_UINT64>, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Iterator_Ex<PortableGroup::ObjectGroupId, TAO_PG_ObjectGroup_Map_Entry *, ACE_Hash<ACE_UINT64>, ACE_Equal_To<ACE_UINT64>, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Reverse_Iterator_Ex<PortableGroup::ObjectGroupId, TAO_PG_ObjectGroup_Map_Entry *, ACE_Hash<ACE_UINT64>, ACE_Equal_To<ACE_UINT64>, ACE_Null_Mutex>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
-#pragma instantiate ACE_Hash_Map_Entry<PortableServer::ObjectId, TAO_PG_ObjectGroup_Map_Entry *>
-#pragma instantiate ACE_Hash_Map_Manager_Ex<PortableServer::ObjectId, TAO_PG_ObjectGroup_Map_Entry *, TAO_ObjectId_Hash, ACE_Equal_To<PortableServer::ObjectId>, ACE_Null_Mutex>
-#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<PortableServer::ObjectId, TAO_PG_ObjectGroup_Map_Entry *, TAO_ObjectId_Hash, ACE_Equal_To<PortableServer::ObjectId>, ACE_Null_Mutex>
-#pragma instantiate ACE_Hash_Map_Iterator_Ex<PortableServer::ObjectId, TAO_PG_ObjectGroup_Map_Entry *, TAO_ObjectId_Hash, ACE_Equal_To<PortableServer::ObjectId>, ACE_Null_Mutex>
-#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<PortableServer::ObjectId, TAO_PG_ObjectGroup_Map_Entry *, TAO_ObjectId_Hash, ACE_Equal_To<PortableServer::ObjectId>, ACE_Null_Mutex>
-
-#pragma instantiate ACE_Equal_To<PortableServer::ObjectId>
+#pragma instantiate ACE_Hash_Map_Entry<PortableGroup::ObjectGroupId, TAO_PG_ObjectGroup_Map_Entry *>
+#pragma instantiate ACE_Hash_Map_Manager_Ex<PortableGroup::ObjectGroupId, TAO_PG_ObjectGroup_Map_Entry *, ACE_Hash<ACE_UINT64>, ACE_Equal_To<ACE_UINT64>, ACE_Null_Mutex>;
+#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<PortableGroup::ObjectGroupId, TAO_PG_ObjectGroup_Map_Entry *, ACE_Hash<ACE_UINT64>, ACE_Equal_To<ACE_UINT64>, ACE_Null_Mutex>;
+#pragma instantiate ACE_Hash_Map_Iterator_Ex<PortableGroup::ObjectGroupId, TAO_PG_ObjectGroup_Map_Entry *, ACE_Hash<ACE_UINT64>, ACE_Equal_To<ACE_UINT64>, ACE_Null_Mutex>;
+#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<PortableGroup::ObjectGroupId, TAO_PG_ObjectGroup_Map_Entry *, ACE_Hash<ACE_UINT64>, ACE_Equal_To<ACE_UINT64>, ACE_Null_Mutex>;
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroup_Map.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroup_Map.h
index f33a0e344cd..d210a19925d 100644
--- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroup_Map.h
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroup_Map.h
@@ -46,13 +46,7 @@ public:
CORBA::String_var type_id;
/// This is the PortableGroup::ObjectGroupId.
- /**
- * The spec states that PortableGroup::ObjectGroupId is a
- * CORBA::ULongLong. However, the over 4 billion group IDs that can
- * be represented by a CORBA::ULong should be plenty for any
- * application.
- */
- CORBA::ULong group_id;
+ PortableGroup::ObjectGroupId group_id;
/// Reference to the ObjectGroup.
PortableGroup::ObjectGroup_var object_group;
@@ -69,10 +63,10 @@ public:
/// ObjectId hash map typedef.
typedef ACE_Hash_Map_Manager_Ex<
- PortableServer::ObjectId,
+ PortableGroup::ObjectGroupId,
TAO_PG_ObjectGroup_Map_Entry *,
- TAO_ObjectId_Hash,
- ACE_Equal_To<PortableServer::ObjectId>,
+ ACE_Hash<ACE_UINT64>,
+ ACE_Equal_To<ACE_UINT64>,
ACE_Null_Mutex> TAO_PG_ObjectGroup_Map;
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp
new file mode 100644
index 00000000000..2514df9dabc
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp
@@ -0,0 +1,374 @@
+// -*- C++ -*-
+//
+// $Id$
+
+#include "PG_Object_Group.h"
+
+#include <ace/Get_Opt.h>
+#include <ace/Vector_T.h>
+#include <tao/PortableServer/ORB_Manager.h>
+#include <orbsvcs/PortableGroup/PG_Operators.h> // Borrow operator == on CosNaming::Name
+
+/**
+ * The single POA used to manage object groups
+ */
+//static
+PortableServer::POA_var TAO::PG_Object_Group::poa_;
+
+
+TAO::PG_Object_Group::MemberInfo::MemberInfo (
+ CORBA::Object_ptr member,
+ const PortableGroup::Location & location)
+ : member_ (CORBA::Object::_duplicate (member))
+ , location_ (location)
+ , factory_(PortableGroup::GenericFactory::_nil())
+ , is_primary_ (0)
+{
+}
+
+TAO::PG_Object_Group::MemberInfo::MemberInfo (
+ CORBA::Object_ptr member,
+ const PortableGroup::Location & location,
+ PortableGroup::GenericFactory_ptr factory,
+ PortableGroup::GenericFactory::FactoryCreationId factory_id)
+ : member_ (CORBA::Object::_duplicate (member))
+ , factory_ (PortableGroup::GenericFactory::_duplicate (factory))
+ , factory_id_ (factory_id)
+ , location_ (location)
+ , is_primary_ (0)
+{
+}
+
+TAO::PG_Object_Group::MemberInfo::~MemberInfo ()
+{
+ if( ! CORBA::is_nil (factory_))
+ {
+ ACE_TRY_NEW_ENV
+ {
+ factory_->delete_object (factory_id_);
+ }
+ ACE_CATCHANY;
+ {
+ // ignore this. It may have faulted and gone away.
+ // (and besides, we're in a destructor.
+ }
+ ACE_ENDTRY;
+ }
+}
+
+/*
+TAO::PG_Object_Group::PG_Object_Group ()
+ : role_ ("")
+ , type_id_ ("")
+ , group_id_( 0)
+ , reference_ (0)
+ , primary_location_(0)
+ , properties_ (0)
+{
+}
+*/
+
+TAO::PG_Object_Group::PG_Object_Group (
+ CORBA::ORB_ptr orb,
+ PortableGroup::ObjectGroupId oid,
+ const char * type_id,
+ PortableGroup::Criteria the_criteria)
+ : orb_ (CORBA::ORB::_duplicate (orb))
+ , role_ (type_id)
+ , type_id_ (CORBA::string_dup(type_id))
+ , group_id_(oid)
+ , reference_ (0)
+ , primary_location_(0)
+ , properties_ (the_criteria)
+{
+}
+
+TAO::PG_Object_Group::~PG_Object_Group ()
+{
+ for (MemberMap_Iterator it = this->members_.begin();
+ it != this->members_.end();
+ this->members_.begin())
+ {
+ MemberInfo * member = (*it).int_id_;
+ delete member;
+ members_.unbind((*it).ext_id_);
+ }
+}
+
+
+void dump_ior (const char * base, const char * ext, unsigned long version, const char * iogr)
+{
+ char filename[1000];
+ sprintf(filename, "%s_%lu.%s", base, version, ext );
+
+ FILE * iorfile = fopen(filename, "w");
+ fwrite (iogr, 1, strlen(iogr), iorfile);
+ fclose (iorfile);
+}
+
+
+void TAO::PG_Object_Group::set_reference (
+ PortableGroup::ObjectGroup_ptr reference,
+ PortableGroup::ObjectGroupRefVersion version,
+ int distribute
+ ACE_ENV_ARG_DECL)
+{
+ this->reference_ = PortableGroup::ObjectGroup::_duplicate (reference);
+ this->version_ = version;
+ this->IOGR_ = this->orb_->object_to_string (reference ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ if (distribute)
+ {
+ size_t n_rep = 0; // for dump_ior below
+ for ( MemberMap_Iterator it = members_.begin();
+ it != members_.end();
+ ++it)
+ {
+ MemberInfo const * info = (*it).int_id_;
+ //
+ // Unchecked narrow means the member doesn't have to actually implement the TAO_UpdateObjectGroup interface
+ // PortableGroup::TAO_UpdateObjectGroup_var uog = PortableGroup::TAO_UpdateObjectGroup::_unchecked_narrow ( info->member_);
+ // but it doesn work: error message at replica is:
+ // TAO-FT (2996|976) - Wrong version information within the interceptor [1 | 0]
+ // TAO_Perfect_Hash_OpTable:find for operation 'tao_update_object_group' (length=23) failed
+ // back to using _narrow
+ PortableGroup::TAO_UpdateObjectGroup_var uog = PortableGroup::TAO_UpdateObjectGroup::_narrow ( info->member_);
+ if (! CORBA::is_nil (uog) )
+ {
+ ACE_TRY_NEW_ENV
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "PG (%P|%t) - Object_Group pushing IOGR to %s member: %s@%s.\n",
+ (info->is_primary_ ? "Primary" : "Backup"),
+ this->role_.c_str(),
+ ACE_static_cast(const char *, info->location_[0].id)
+ ));
+ dump_ior ("group", "iogr", this->version_, this->IOGR_);
+ CORBA::String_var replica_ior = this->orb_->object_to_string(uog.in() ACE_ENV_ARG_PARAMETER);
+ dump_ior (info->location_[0].id, "ior", (this->version_ * 100) + n_rep++, replica_ior);
+
+ uog->tao_update_object_group (this->IOGR_, this->version_, info->is_primary_);
+ }
+ ACE_CATCHANY
+ {
+ // we expect an exception
+ // tao_update_object_group is not a real method
+ }
+ ACE_ENDTRY;
+ }
+ else
+ {
+ ACE_ERROR ((LM_ERROR,
+ "TAO::PG_Object_Group::set_reference can't narrow member reference to PortableGroup::TAO_UpdateObjectGroup.\n"
+ ));
+ }
+ }
+ }
+}
+
+
+PortableGroup::ObjectGroup_ptr TAO::PG_Object_Group::reference()const
+{
+ return PortableGroup::ObjectGroup::_duplicate (this->reference_);
+}
+
+void TAO::PG_Object_Group::set_membership_style (PortableGroup::MembershipStyleValue style)
+{
+ this->membership_style_ = style;
+}
+
+PortableGroup::MembershipStyleValue TAO::PG_Object_Group::membership_style () const
+{
+ return this->membership_style_;
+}
+
+void TAO::PG_Object_Group::initial_number_members (PortableGroup::InitialNumberMembersValue count)
+{
+ this->initial_number_members_ = count;
+}
+
+PortableGroup::InitialNumberMembersValue TAO::PG_Object_Group::initial_number_members () const
+{
+ return this->initial_number_members_;
+}
+
+void TAO::PG_Object_Group::set_minimum_number_members (PortableGroup::MinimumNumberMembersValue count)
+{
+ this->minimum_number_members_ = count;
+}
+
+PortableGroup::MinimumNumberMembersValue TAO::PG_Object_Group::minimum_number_members ()const
+{
+ return this->minimum_number_members_;
+}
+
+void TAO::PG_Object_Group::set_group_specific_factories (const PortableGroup::FactoryInfos & infos)
+{
+ this->group_specific_factories_ = infos;
+}
+
+
+void TAO::PG_Object_Group::group_specific_factories (PortableGroup::FactoryInfos & result) const
+{
+ // copy is needed to have some semblance of thread safeness.
+ // if performance is an issue avoid this method.
+ result = this->group_specific_factories_;
+}
+
+
+void TAO::PG_Object_Group::set_primary_location (
+ const PortableGroup::Location & location
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((PortableGroup::MemberNotFound))
+{
+ MemberInfo * info;
+ if (this->members_.find (location, info) == 0)
+ {
+ int cleared = 0;
+ this->primary_location_ = location;
+ for (MemberMap_Iterator it = this->members_.begin();
+ !cleared && it != this->members_.end();
+ ++it)
+ {
+ cleared = (*it).int_id_->is_primary_;
+ (*it).int_id_->is_primary_ = 0;
+ }
+ info->is_primary_ = 1;
+ }
+ else
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO-PG (%P|%t) - set_primary_location throwing MemberNotFound.\n"
+ ));
+ ACE_THROW (PortableGroup::MemberNotFound())
+ ACE_CHECK;
+ }
+}
+
+const PortableGroup::Location & TAO::PG_Object_Group::primary_location() const
+{
+ return this->primary_location_;
+}
+
+#ifdef NOT_IMPLEMENTED
+void TAO::PG_Object_Group::create_member (
+ const PortableGroup::Location & the_location,
+ const char * type_id,
+ const PortableGroup::Criteria & the_criteria
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((
+ CORBA::SystemException,
+ PortableGroup::MemberAlreadyPresent,
+ PortableGroup::ObjectNotCreated,
+ PortableGroup::InvalidCriteria,
+ PortableGroup::CannotMeetCriteria))
+{
+ ACE_ASSERT(0);
+ int todo;
+}
+#endif
+
+void TAO::PG_Object_Group::add_member (
+ const PortableGroup::Location & the_location,
+ CORBA::Object_ptr member
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((
+ CORBA::SystemException,
+ PortableGroup::MemberAlreadyPresent,
+ PortableGroup::ObjectNotAdded))
+{
+ MemberInfo * info = 0;
+ ACE_NEW_THROW_EX (info, MemberInfo(member, the_location),
+ CORBA::NO_MEMORY());
+
+ if (members_.bind (the_location, info) != 0)
+ {
+ ACE_THROW(CORBA::NO_MEMORY());
+ ACE_CHECK;
+ }
+}
+
+#ifdef NOT_IMPLEMENTED
+void TAO::PG_Object_Group::remove_member (
+ const PortableGroup::Location & the_location
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((
+ CORBA::SystemException,
+ PortableGroup::MemberNotFound))
+{
+ ACE_ASSERT(0);
+ int todo;
+}
+#endif
+
+#ifdef NOT_IMPLEMENTED
+void TAO::PG_Object_Group::locations_of_members (
+ PortableGroup::Locations & locations
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ ACE_ASSERT(0);
+ int todo;
+}
+#endif
+
+PortableGroup::ObjectGroupId TAO::PG_Object_Group::get_object_group_id () const
+{
+ return this->group_id_;
+}
+
+#ifdef NOT_IMPLEMENTED
+
+CORBA::Object_ptr TAO::PG_Object_Group::get_member_ref (
+ const PortableGroup::Location & loc
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((
+ CORBA::SystemException,
+ PortableGroup::MemberNotFound))
+{
+ CORBA::Object_ptr result = CORBA::Object::_nil();
+ ACE_ASSERT(0);
+ int todo;
+ return result;
+}
+#endif
+
+void TAO::PG_Object_Group::set_properties_dynamically (
+ const PortableGroup::Properties & overrides
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ PortableGroup::InvalidProperty,
+ PortableGroup::UnsupportedProperty))
+{
+ this->properties_ = overrides;
+ int todo_parse_properties_for_special_value;
+ int todo_override_rather_than_replace_question;
+}
+
+void TAO::PG_Object_Group::get_properties (PortableGroup::Properties_var & result) const
+{
+ (*result) = this->properties_;
+}
+
+
+PortableGroup::TypeId TAO::PG_Object_Group::get_type_id () const
+{
+ return CORBA::string_dup(this->type_id_);
+}
+
+
+
+#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
+
+ template ACE_Hash_Map_Manager_Ex <PortableGroup::Location, MemberInfo *, TAO_PG_Location_Hash, TAO_PG_Location_Equal_To, MapMutex>;
+ template ACE_Hash_Map_Entry <PortableGroup::Location, MemberInfo *>;
+ template ACE_Hash_Map_Iterator_Ex <PortableGroup::Location, MemberInfo *, TAO_PG_Location_Hash, TAO_PG_Location_Equal_To, MapMutex>;
+
+#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
+
+# pragma instantiate ACE_Hash_Map_Manager_Ex <PortableGroup::Location, MemberInfo *, TAO_PG_Location_Hash, TAO_PG_Location_Equal_To, MapMutex>
+# pragma instantiate ACE_Hash_Map_Entry <PortableGroup::Location, MemberInfo *>
+# pragma instantiate ACE_Hash_Map_Iterator_Ex <PortableGroup::Location, MemberInfo *, TAO_PG_Location_Hash, TAO_PG_Location_Equal_To, MapMutex>
+
+#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h
new file mode 100644
index 00000000000..fff5bc866f7
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h
@@ -0,0 +1,329 @@
+// -*- C++ -*-
+//=============================================================================
+/**
+ * @file PG_Object_Group.h
+ *
+ * $Id$
+ *
+ * Manage all information related to an object group.
+ * @@ Note: the above description is optimistic. The hope is to eventually
+ * @@ consolidate all information related to an object group into this object.
+ * @@ however at the moment GenericFactory, ObjectGroupManager, and FT_ReplicationManager
+ * @@ have parallel collections of object group information.
+ *
+ * @author Dale Wilson <wilson_d@ociweb.com>
+ */
+//=============================================================================
+
+#ifndef TAO_PG_OBJECT_GROUP_H_
+#define TAO_PG_OBJECT_GROUP_H_
+#include /**/ <ace/pre.h>
+#include <ace/ACE.h>
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+//////////////////////////////////
+// Classes declared in this header
+namespace TAO
+{
+ class PG_Object_Group;
+}
+
+/////////////////////////////////
+// Includes needed by this header
+#include <orbsvcs/PortableGroupC.h>
+#include <tao/PortableServer/PortableServer.h>
+#include <ace/Hash_Map_Manager_T.h>
+#include "PG_Location_Hash.h"
+#include "PG_Location_Equal_To.h"
+
+
+/////////////////////
+// Forward references
+
+namespace TAO
+{
+ /**
+ */
+ class TAO_PortableGroup_Export PG_Object_Group
+ {
+
+ // Information about an object group member
+ struct MemberInfo
+ {
+ /// Reference to the member.
+ CORBA::Object_var member_;
+
+ /// The factory that was used to create this object
+ /// nil if application created.
+ PortableGroup::GenericFactory_var factory_;
+
+ /// FactoryCreationId assigned to the member. Empty if application created
+ PortableGroup::GenericFactory::FactoryCreationId factory_id_;
+
+ /// Location where this member exists
+ PortableGroup::Location location_;
+
+
+ /// TRUE if this is primary member
+ CORBA::Boolean is_primary_;
+
+
+ ///////////////
+ // Methods
+
+ /// Construct an application-supplied member.
+ MemberInfo (CORBA::Object_ptr member, const PortableGroup::Location & location);
+
+ /// Construct a infrastructure-created member.
+ MemberInfo (
+ CORBA::Object_ptr member,
+ const PortableGroup::Location & location,
+ PortableGroup::GenericFactory_ptr factory,
+ PortableGroup::GenericFactory::FactoryCreationId factory_id);
+
+ /// Destructor
+ ~MemberInfo();
+ };
+
+ typedef TAO_SYNCH_MUTEX MemberMapMutex;
+ typedef ACE_Hash_Map_Manager_Ex <
+ PortableGroup::Location,
+ MemberInfo *,
+ TAO_PG_Location_Hash,
+ TAO_PG_Location_Equal_To,
+ MemberMapMutex> MemberMap;
+ typedef ACE_Hash_Map_Entry <PortableGroup::Location, MemberInfo *> MemberMap_Entry;
+ typedef ACE_Hash_Map_Iterator_Ex <
+ PortableGroup::Location,
+ MemberInfo *,
+ TAO_PG_Location_Hash,
+ TAO_PG_Location_Equal_To,
+ MemberMapMutex> MemberMap_Iterator;
+
+ public:
+ /// Constructor
+ PG_Object_Group (
+ CORBA::ORB_ptr orb,
+ PortableGroup::ObjectGroupId oid,
+ const char * type_id,
+ PortableGroup::Criteria the_criteria);
+
+ /// Destructor
+ ~PG_Object_Group ();
+
+ /////////////////
+ // public methods
+
+ public:
+
+ /// Set object group id
+ void set_oid (PortableGroup::ObjectGroupId oid);
+ /// Set type ID
+
+ void set_typeid (PortableGroup::TypeId type_id);
+
+ /// Set a reference to the group (IOGR)
+ /// @param reference the new IOGR for this group.
+ /// @param version of this IOGR
+ /// @param distribute bool if true, distribute IOGR to all members
+ void set_reference (
+ PortableGroup::ObjectGroup_ptr reference,
+ PortableGroup::ObjectGroupRefVersion version,
+ int distribute
+ ACE_ENV_ARG_DECL);
+
+ /// return a duplicated reference to this group (IOGR)
+ PortableGroup::ObjectGroup_ptr reference()const;
+
+ void set_membership_style (PortableGroup::MembershipStyleValue style);
+ PortableGroup::MembershipStyleValue membership_style () const;
+
+ void initial_number_members (PortableGroup::InitialNumberMembersValue count);
+ PortableGroup::InitialNumberMembersValue initial_number_members () const;
+
+ void set_minimum_number_members (PortableGroup::MinimumNumberMembersValue count);
+ PortableGroup::MinimumNumberMembersValue minimum_number_members ()const;
+
+ void set_group_specific_factories (const PortableGroup::FactoryInfos & infos);
+
+ /**
+ * Note the caller receives a copy of the factoryinfos in the result argument.
+ * inefficient, but thread safe.
+ */
+ void group_specific_factories (PortableGroup::FactoryInfos & result) const;
+
+ /**
+ * Set the member at "location" to be primary.
+ *
+ * Note: primary location is a concept from FT CORBA.
+ * It doesn't hurt other PortableGroup-based services to
+ * have these two methods and the underlying members.
+ */
+ void set_primary_location (
+ const PortableGroup::Location & location
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((PortableGroup::MemberNotFound));
+
+ /**
+ * get location of primary member
+ */
+ const PortableGroup::Location & primary_location() const;
+
+ /**
+ * returns a duplicate
+ * caller must release
+ */
+ PortableGroup::TypeId get_type_id ()const;
+
+ void get_properties (PortableGroup::Properties_var & result) const;
+
+ /////////////////////////////////////////////
+ // Applicable ObjectGroupManager(OGM) methods
+ // The following methods in OGM all have an object group as the
+ // first parameter. The OGM should implement these methods by finding
+ // the corresponding TAO_PG_Object_Group and delegating to these methods.
+#ifdef NOT_IMPLEMENTED
+ void create_member (
+ const PortableGroup::Location & the_location,
+ const char * type_id,
+ const PortableGroup::Criteria & the_criteria
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((
+ CORBA::SystemException,
+ PortableGroup::MemberAlreadyPresent,
+ PortableGroup::ObjectNotCreated,
+ PortableGroup::InvalidCriteria,
+ PortableGroup::CannotMeetCriteria));
+#endif
+
+ void add_member (
+ const PortableGroup::Location & the_location,
+ CORBA::Object_ptr member
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((
+ CORBA::SystemException,
+ PortableGroup::MemberAlreadyPresent,
+ PortableGroup::ObjectNotAdded));
+
+#ifdef NOT_IMPLEMENTED
+ void remove_member (
+ const PortableGroup::Location & the_location
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((
+ CORBA::SystemException,
+ PortableGroup::MemberNotFound));
+#endif
+
+#ifdef NOT_IMPLEMENTED
+ void locations_of_members (
+ PortableGroup::Locations & locations
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+#endif
+
+ PortableGroup::ObjectGroupId get_object_group_id () const;
+
+#ifdef NOT_IMPLEMENTED
+ CORBA::Object_ptr get_member_ref (
+ const PortableGroup::Location & loc
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((
+ CORBA::SystemException,
+ PortableGroup::MemberNotFound));
+#endif
+
+ void set_properties_dynamically (
+ const PortableGroup::Properties & overrides
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ PortableGroup::InvalidProperty,
+ PortableGroup::UnsupportedProperty));
+
+ /////////////////////////
+ // Implementation methods
+ private:
+
+ /////////////////////////
+ // Forbidden methods
+ private:
+ PG_Object_Group ();
+ PG_Object_Group (const PG_Object_Group & rhs);
+ PG_Object_Group & operator = (const PG_Object_Group & rhs);
+
+
+ /////////////////
+ // Static Methods
+ public:
+ /**
+ * Set the poa to be used to manage object groups
+ * Note: this is NOT the poa used to create object group members.
+ * @param poa a reference to a var to avoid reference count confusion.
+ */
+ void set_poa (PortableServer::POA_var & poa);
+
+ ///////////////
+ // Static Data
+ private:
+ /**
+ * The POA used to manage object groups
+ */
+ static PortableServer::POA_var poa_;
+
+
+ ///////////////
+ // Data Members
+ private:
+
+ /**
+ * Protect internal state.
+ * Implementation methods should assume the mutex is
+ * locked if necessary.
+ */
+ ACE_SYNCH_MUTEX internals_;
+ typedef ACE_Guard<ACE_SYNCH_MUTEX> InternalGuard;
+
+ CORBA::ORB_var orb_;
+
+ ACE_CString role_;
+ PortableGroup::TypeId type_id_;
+ PortableGroup::ObjectGroupId group_id_;
+ /**
+ * the reference (IOGR) to this group
+ */
+ PortableGroup::ObjectGroup_var reference_;
+
+ CORBA::String_var IOGR_;
+ PortableGroup::ObjectGroupRefVersion version_;
+
+
+
+ /**
+ * The CORBA object id assigned to this object group
+ */
+ PortableServer::ObjectId_var object_id_;
+
+ // group members
+ MemberMap members_;
+
+ PortableGroup::Location primary_location_;
+
+ // Cached property information
+
+ PortableGroup::MembershipStyleValue membership_style_;
+ PortableGroup::InitialNumberMembersValue initial_number_members_;
+ PortableGroup::MinimumNumberMembersValue minimum_number_members_;
+ PortableGroup::FactoryInfos group_specific_factories_;
+
+ // Miscellaneous properties passed to create_object when this group
+ // was initially created. To be used to create new members.
+ PortableGroup::Properties properties_;
+
+ };
+} // namespace TAO
+
+#include /**/ <ace/post.h>
+
+#endif // TAO_PG_OBJECT_GROUP_H_
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Map.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Map.cpp
new file mode 100644
index 00000000000..92e1a34ceb0
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Map.cpp
@@ -0,0 +1,116 @@
+// -*- C++ -*-
+//
+//=============================================================================
+/**
+ * @file PG_Object_Group_Map.cpp
+ *
+ * $Id$
+ *
+ * Container for TAO::PG_Object_Groups indexed by ObjectGroupId
+ * Note this was developed as part of FT CORBA
+ * @@ For now its but one of several parallel containers for object group information
+ * @@ TODO: Combine these parallel containers into a single one that consolidates everything
+ * @@ known about object groups.
+ * @author Dale Wilson <wilson_d@ociweb.com>
+ */
+//=============================================================================
+
+#include "PG_Object_Group_Map.h"
+#include "PG_Object_Group.h"
+#include <orbsvcs/orbsvcs/PortableGroup/PG_Utils.h>
+
+TAO::PG_Object_Group_Map::PG_Object_Group_Map ()
+{
+}
+
+TAO::PG_Object_Group_Map::~PG_Object_Group_Map ()
+{
+ // todo: destroy all members
+}
+
+//////////////////////////////////////////////////////
+// PG_Object_Group_Map public methods
+
+
+ // insert group. Take ownership
+int TAO::PG_Object_Group_Map::insert_group ( ::TAO::PG_Object_Group * group)
+{
+ return insert_group (group->get_object_group_id(), group);
+}
+
+int TAO::PG_Object_Group_Map::insert_group (PortableGroup::ObjectGroupId group_id, ::TAO::PG_Object_Group * group)
+{
+ return (this->bind (group_id, group) == 0);
+}
+
+int TAO::PG_Object_Group_Map::find_group (PortableGroup::ObjectGroupId group_id, ::TAO::PG_Object_Group *& group) const
+{
+ return (this->find (group_id , group) == 0);
+}
+
+int TAO::PG_Object_Group_Map::find_group (PortableGroup::ObjectGroup_ptr object_group, ::TAO::PG_Object_Group *& group) const
+{
+ PortableGroup::TagGroupTaggedComponent tc;
+ TAO::PG_Utils::get_tagged_component (object_group, tc);
+ return find_group (tc.object_group_id, group);
+}
+
+int TAO::PG_Object_Group_Map::destroy_group (PortableGroup::ObjectGroupId group_id)
+{
+ ::TAO::PG_Object_Group * group;
+ int result = (this->unbind (group_id, group) == 0);
+ if (result)
+ {
+ delete group;
+ }
+ return result;
+}
+
+int TAO::PG_Object_Group_Map::destroy_group (PortableGroup::ObjectGroup_ptr object_group)
+{
+ PortableGroup::TagGroupTaggedComponent tc;
+ TAO::PG_Utils::get_tagged_component (object_group, tc);
+ return destroy_group (tc.object_group_id);
+}
+
+#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
+
+ template class ACE_Hash_Map_Manager_Ex<
+ PortableGroup::ObjectGroupId,
+ ::TAO::PG_Object_Group *,
+ ACE_Hash<ACE_UINT64>,
+ ACE_Equal_To<ACE_UINT64>,
+ TAO_Synch_Mutex>;
+
+ template class ACE_Hash_Map_Entry <
+ PortableGroup::ObjectGroupId,
+ ::TAO::PG_Object_Group *>;
+
+ template class ACE_Hash_Map_Iterator_Ex <
+ PortableGroup::ObjectGroupId,
+ ::TAO::PG_Object_Group *,
+ ACE_Hash<ACE_UINT64>,
+ ACE_Equal_To<ACE_UINT64>,
+ TAO_Synch_Mutex>;
+
+#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
+
+# pragma instantiate ACE_Hash_Map_Manager_Ex<
+ PortableGroup::ObjectGroupId,
+ ::TAO::PG_Object_Group *,
+ ACE_Hash<ACE_UINT64>,
+ ACE_Equal_To<ACE_UINT64>,
+ TAO_Synch_Mutex>;
+
+# pragma instantiate ACE_Hash_Map_Entry <
+ PortableGroup::ObjectGroupId,
+ ::TAO::PG_Object_Group *>;
+
+# pragma instantiate ACE_Hash_Map_Iterator_Ex <
+ PortableGroup::ObjectGroupId,
+ ::TAO::PG_Object_Group *,
+ ACE_Hash<ACE_UINT64>,
+ ACE_Equal_To<ACE_UINT64>,
+ TAO_Synch_Mutex>;
+
+#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Map.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Map.h
new file mode 100644
index 00000000000..53043af9fab
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Map.h
@@ -0,0 +1,110 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file PG_Object_Group_Map.h
+ *
+ * $Id$
+ *
+ * Container for TAO::PG_Object_Groups indexed by ObjectGroupId
+ * Note this was developed as part of FT CORBA
+ * @@ For now its but one of several parallel containers for object group information
+ * @@ TODO: Combine these parallel containers into a single one that consolidates everything
+ * @@ known about object groups.
+ * @author Dale Wilson <wilson_d@ociweb.com>
+ */
+//=============================================================================
+
+
+#ifndef TAO_PG_OBJECT_GROUP_MAP_H
+#define TAO_PG_OBJECT_GROUP_MAP_H
+
+#include /**/ "ace/pre.h"
+#include "orbsvcs/PortableGroupS.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+////////////////////////////////////////////////////
+// Forward reference to class(es) defined in this header
+namespace TAO
+{
+ class PG_Object_Group_Map;
+} // namespace TAO
+
+//#include "PG_Object_Group.h"
+namespace TAO
+{
+ class PG_Object_Group;
+} // namespace TAO
+
+namespace TAO
+{
+ /**
+ * class TAO::PG_Object_Group_Map
+ * A container of Object_Groups indexed by ObjectGroupId
+ */
+ class TAO_PortableGroup_Export PG_Object_Group_Map
+ : public ACE_Hash_Map_Manager_Ex<
+ PortableGroup::ObjectGroupId,
+ ::TAO::PG_Object_Group *,
+ ACE_Hash<ACE_UINT64>,
+ ACE_Equal_To<ACE_UINT64>,
+ TAO_SYNCH_MUTEX>
+ {
+ public:
+ typedef ACE_Hash_Map_Entry <PortableGroup::ObjectGroupId, ::TAO::PG_Object_Group *> Entry;
+ typedef ACE_Hash_Map_Iterator_Ex <
+ PortableGroup::ObjectGroupId,
+ ::TAO::PG_Object_Group *,
+ ACE_Hash<ACE_UINT64>,
+ ACE_Equal_To<ACE_UINT64>,
+ TAO_SYNCH_MUTEX> Iterator;
+
+ /// Constructor.
+ PG_Object_Group_Map ();
+
+ /// Destructor.
+ virtual ~PG_Object_Group_Map ();
+
+ /// insert existing group. Take ownership
+ /// note: uses group id extracted from group object
+ /// @return bool true if insertion successful
+ int insert_group ( ::TAO::PG_Object_Group * group);
+
+ /// insert group. Take ownership
+ /// @return bool true if insertion successful
+ int insert_group (PortableGroup::ObjectGroupId group_id, ::TAO::PG_Object_Group * group);
+
+ /// find group
+ /// @return bool true if found
+ int find_group (PortableGroup::ObjectGroupId group_id, ::TAO::PG_Object_Group *& group) const;
+
+ /// find group
+ /// note: uses group id extracted from object_group
+ /// @return bool true if found
+ int find_group (PortableGroup::ObjectGroup_ptr object_group, ::TAO::PG_Object_Group *& group) const;
+
+ /// remove group from map and delete it.
+ /// @return bool true if found
+ int destroy_group (PortableGroup::ObjectGroupId object_group_id);
+
+ /// remove group from map and delete it.
+ /// note: uses group id extracted from object_group
+ /// @return bool true if found
+ int destroy_group (PortableGroup::ObjectGroup_ptr object_group);
+
+ ////////////////////////////
+ // Implementation methods
+ private:
+
+ ///////
+ // Data
+ private:
+ };
+} // namespace TAO
+
+#include /**/ "ace/post.h"
+
+#endif /* TAO_PG_OBJECT_GROUP_MAP_H */
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Decoder.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Decoder.cpp
new file mode 100644
index 00000000000..777ef0762d6
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Decoder.cpp
@@ -0,0 +1,166 @@
+/* -*- C++ -*- */
+//=============================================================================
+/**
+ * @file PG_Properties_Decoder.cpp
+ *
+ * $Id$
+ *
+ * This file implements classes to help manage the Properties
+ * defined in the Portable Object Group.
+ *
+ * @author Dale Wilson <wilson_d@ociweb.com>
+ */
+//=============================================================================
+#include /**/ "ace/pre.h"
+#include "PG_Properties_Decoder.h"
+
+
+//////////////////////
+// Properties_Decoder
+TAO_PG::Properties_Decoder::Properties_Decoder (const PortableGroup::Properties & property_set)
+{
+ size_t count = property_set.length();
+ for (size_t nItem = 0; nItem < count; ++nItem)
+ {
+ const PortableGroup::Property & property = property_set[nItem];
+ const CosNaming::Name & nsName = property.nam;
+ // note assumption one level name with no kind
+ // TODO: fix this
+ const CosNaming::NameComponent & nc = nsName[0];
+ ACE_CString name = nc.id;
+ if (0 != values_.bind(name, & property.val))
+ {
+ ACE_ERROR ((LM_ERROR,
+ "%n\n%T: Property_set: bind failed.\n"
+ ));
+ }
+ }
+}
+
+TAO_PG::Properties_Decoder::~Properties_Decoder ()
+{
+}
+
+int TAO_PG::Properties_Decoder::find (
+ const ACE_CString & key,
+ PortableGroup::Value *& pValue)const
+{
+ int found = 0;
+ if (0 == values_.find(key, pValue))
+ {
+ found = 1;
+ }
+ return found;
+}
+
+//#define PG_PS_UNIT_TEST
+#ifdef PG_PS_UNIT_TEST
+#include "PG_Properties_Encoder.h"
+
+int TAO_PG::test_encode_decode ()
+{
+ int result = 1;
+ static const long testLong = 123456L;
+ static const char * testLongKey = "MyLong";
+
+ static const char * testString = "Now is the time for all good people.";
+ static const char * testStringKey = "plover";
+
+ static const double testDouble = 3.1415;
+ static const char * testDoubleKey = "pi";
+
+ PortableGroup::Properties_var property_set = new PortableGroup::Properties;
+ //scope encoder to be sure its gone before decoding
+ {
+ TAO_PG::Encoder encoder;
+ PortableGroup::Value value;
+ value <<= (CORBA::Long) testLong;
+ encoder.add (testLongKey, value);
+
+ value <<= testString;
+ encoder.add (testStringKey, value);
+
+ value <<= (CORBA::Double) testDouble;
+ encoder.add (testDoubleKey, value);
+
+ encoder.encode(property_set);
+ }
+
+ TAO_PG::Properties_Decoder decoder(property_set);
+
+ CORBA::Long longResult = 0;
+ if (find (decoder, testLongKey, longResult) )
+ {
+ if (longResult != testLong)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "%n\n%T: %s = %d expecting %d\n",
+ testLongKey,
+ (int)longResult,
+ (int)testLong
+ ));
+ result = 0;
+ }
+ }
+ else
+ {
+ ACE_ERROR ((LM_ERROR,
+ "%n\n%T: Can't find value for %s\n", testLongKey
+ ));
+ result = 0;
+ }
+
+ const char * stringResult = "";
+ if (find (decoder, testStringKey, stringResult))
+ {
+ if(0 != ACE_OS::strcmp(testString, stringResult))
+ {
+ ACE_ERROR ((LM_ERROR,
+ "%n\n%T: %s = \"%s\" expecting \"%s\"\n",
+ testStringKey,
+ (int)stringResult,
+ (int)testString
+ ));
+ result = 0;
+ }
+ }
+ else
+ {
+ ACE_ERROR ((LM_ERROR,
+ "%n\n%T: Can't find value for %s\n", testStringKey
+ ));
+ result = 0;
+ }
+
+
+ CORBA::Double doubleResult = 0.0;
+ if (find (decoder, testDoubleKey, doubleResult))
+ {
+ if(doubleResult != testDouble)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "%n\n%T: %s = \"%f\" expecting \"%f\"\n",
+ testDoubleKey,
+ doubleResult,
+ testDouble
+ ));
+ result = 0;
+ }
+ }
+ else
+ {
+ ACE_ERROR ((LM_ERROR,
+ "%n\n%T: Can't find value for %s\n", testDoubleKey
+ ));
+ result = 0;
+ }
+
+ return result;
+}
+#endif // PG_PS_UNIT_TEST
+
+#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
+ template ACE_Hash_Map_Manager<ACE_CString, PortableGroup::Value *, ACE_SYNCH_NULL_MUTEX>;
+#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
+# pragma instantiate ACE_Hash_Map_Manager<ACE_CString, PortableGroup::Value *, ACE_SYNCH_NULL_MUTEX>
+#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Decoder.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Decoder.h
new file mode 100644
index 00000000000..ac472ee596a
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Decoder.h
@@ -0,0 +1,78 @@
+/* -*- C++ -*- */
+//=============================================================================
+/**
+ * @file PG_Properties_Decoder.h
+ *
+ * $Id$
+ *
+ * This file declares classes to help manage the Properties
+ * defined in the Portable Object Group.
+ *
+ * @author Dale Wilson <wilson_d@ociweb.com>
+ */
+//=============================================================================
+#ifndef TAO_PG_PROPERTIES_DECODER_H
+#define TAO_PG_PROPERTIES_DECODER_H
+#include "orbsvcs/PortableGroupS.h"
+#include "orbsvcs/CosNamingC.h"
+#include "portablegroup_export.h"
+
+#include "ace/Map_T.h"
+
+namespace TAO_PG
+{
+ class TAO_PortableGroup_Export Properties_Decoder
+ {
+ typedef ACE_Hash_Map_Manager<ACE_CString, const PortableGroup::Value *, ACE_SYNCH_NULL_MUTEX> ValueMap;
+ public:
+ Properties_Decoder (const PortableGroup::Properties & property_set);
+ ~Properties_Decoder ();
+
+ // general purpose method
+ int find (const ACE_CString & key, PortableGroup::Value *& pValue)const;
+
+ // if templated methods were available:
+ // template <typename TYPE >
+ // int find (const ACE_CString & key, TYPE & value) const;
+ // instead, see global function below
+
+ private:
+ Properties_Decoder();
+ Properties_Decoder(const Properties_Decoder & rhs);
+ Properties_Decoder & operator = (const Properties_Decoder & rhs);
+
+ private:
+ ValueMap values_;
+ PortableGroup::Properties_var property_set_;
+ };
+
+ /**
+ * Find a value in a Properties::Properties_Decoder.
+ * This is a work-around for the lack of
+ * templated methods.
+ */
+ template <typename TYPE>
+ int find (Properties_Decoder & decoder, const ACE_CString & key, TYPE & value)
+ {
+ int result = 0;
+ PortableGroup::Value * any;
+ if ( decoder.find (key, any))
+ {
+ result = ((*any) >>= value);
+ }
+ return result;
+ }
+
+#ifdef PG_PS_UNIT_TEST
+
+ /**
+ * unit test: encode and decode properties.
+ * Initialize CORBA before calling this function.
+ * Success is silent, failure prints on cerr.
+ * @returns 1 if test passed; 0 if test failed.
+ */
+ int test_encode_decode();
+#endif // PG_PS_UNIT_TEST
+} //namespace TAO_PG
+
+#endif // TAO_PG_PROPERTIES_DECODER_H
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Encoder.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Encoder.cpp
new file mode 100644
index 00000000000..a38e855b742
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Encoder.cpp
@@ -0,0 +1,68 @@
+/* -*- C++ -*- */
+//=============================================================================
+/**
+ * @file PG_Properties_Encoder.cpp
+ *
+ * $Id$
+ *
+ * This file implements classes to help manage the Properties
+ * defined in the Portable Object Group.
+ *
+ * @author Dale Wilson <wilson_d@ociweb.com>
+ */
+//=============================================================================
+#include "ace/pre.h"
+#include "PG_Properties_Encoder.h"
+
+//////////
+// Properties_Encoder
+TAO_PG::Properties_Encoder::Properties_Encoder ()
+{
+}
+
+TAO_PG::Properties_Encoder::~Properties_Encoder ()
+{
+}
+
+
+void TAO_PG::Properties_Encoder::add (
+ const char * name,
+ const PortableGroup::Value & value)
+{
+ NamedValue nv(name, value);
+ values_.push_back(nv);
+}
+
+void TAO_PG::Properties_Encoder::encode (
+ PortableGroup::Properties_var & property_set) const
+{
+ size_t count = values_.size();
+ property_set->length(count);
+ for( size_t nItem = 0; nItem < count; ++nItem )
+ {
+ const NamedValue & nv = values_[nItem];
+ PortableGroup::Property & property = property_set[nItem];
+ PortableGroup::Name & nsName = property.nam;
+ PortableGroup::Value & anyValue = property.val;
+ // assign the value
+ anyValue = (nv.second());
+
+ // assign the name
+ // TODO: This restricts the name to a single level with no "kind"
+ // TODO: remove this restriction (?)
+ nsName.length(1);
+ CosNaming::NameComponent & nc = nsName[0];
+
+ nc.id = CORBA::string_dup (nv.first().c_str());
+ // nc.kind defaults to empty. Leave it that way (for now)
+
+ }
+}
+
+#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
+ template ACE_Pair< ACE_CString, PortableGroup::Value>;
+ template ACE_Vector< NamedValue, 10 >;
+#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
+# pragma instantiate ACE_Pair< ACE_CString, PortableGroup::Value>
+# pragma instantiate ACE_Vector< NamedValue, 10 >
+#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Encoder.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Encoder.h
new file mode 100644
index 00000000000..431d0fc25f5
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Encoder.h
@@ -0,0 +1,46 @@
+/* -*- C++ -*- */
+//=============================================================================
+/**
+ * @file PG_Properties_Encoder.h
+ *
+ * $Id$
+ *
+ * This file declares a class to help manage PortableGroup::Properties
+ *
+ * @author Dale Wilson <wilson_d@ociweb.com>
+ */
+//=============================================================================
+#ifndef TAO_PG_PROPERTIES_ENCODER_H
+#define TAO_PG_PROPERTIES_ENCODER_H
+#include "orbsvcs/PortableGroupS.h"
+#include "orbsvcs/CosNamingC.h"
+#include "portablegroup_export.h"
+
+#include "ace/Vector_T.h"
+#include "ace/Pair_T.h"
+
+namespace TAO_PG
+{
+ class TAO_PortableGroup_Export Properties_Encoder
+ {
+ typedef ACE_Pair< ACE_CString, PortableGroup::Value> NamedValue;
+ typedef ACE_Vector< NamedValue, 10 > NamedValueVec;
+
+ public:
+ Properties_Encoder ();
+ ~Properties_Encoder ();
+
+ void add (const char * name, const PortableGroup::Value & value);
+
+ void encode (PortableGroup::Properties_var & property_set) const;
+
+ private:
+ Properties_Encoder (const Properties_Encoder & rhs);
+ Properties_Encoder & operator = (const Properties_Encoder & rhs);
+ private:
+ NamedValueVec values_;
+ };
+
+} //namespace TAO_PG
+
+#endif // TAO_PG_PROPERTIES_ENCODER_H
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_PropertyManager.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_PropertyManager.cpp
index ff191f50869..942490421c6 100644
--- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_PropertyManager.cpp
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_PropertyManager.cpp
@@ -16,12 +16,32 @@ TAO_PG_PropertyManager::TAO_PG_PropertyManager (
default_properties_ (),
type_properties_ (),
lock_ (),
- property_validator_ ()
+ property_validator_ (0)
{
}
void
+TAO_PG_PropertyManager::init (
+ TAO_PG_Default_Property_Validator * property_validator )
+{
+ if (property_validator)
+ {
+ property_validator_ = property_validator;
+ }
+ else
+ {
+ ACE_NEW_THROW_EX (
+ property_validator_,
+ TAO_PG_Default_Property_Validator,
+ CORBA::NO_MEMORY ()
+ );
+ ACE_CHECK;
+ }
+}
+
+
+void
TAO_PG_PropertyManager::set_default_properties (
const PortableGroup::Properties & props
ACE_ENV_ARG_DECL)
@@ -46,7 +66,7 @@ TAO_PG_PropertyManager::set_default_properties (
property.val));
}
- this->property_validator_.validate_property (props
+ this->property_validator_->validate_property (props
ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
@@ -106,7 +126,7 @@ TAO_PG_PropertyManager::set_type_properties (
PortableGroup::InvalidProperty,
PortableGroup::UnsupportedProperty))
{
- this->property_validator_.validate_property (overrides
+ this->property_validator_->validate_property (overrides
ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
@@ -118,11 +138,16 @@ TAO_PG_PropertyManager::set_type_properties (
ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->lock_);
Type_Prop_Table::ENTRY * entry;
- if (this->type_properties_.find (type_id, entry) != 0)
- ACE_THROW (CORBA::BAD_PARAM ());
-
- PortableGroup::Properties & props = entry->int_id_;
- props = overrides;
+ if (this->type_properties_.find (type_id, entry) == 0)
+ {
+ PortableGroup::Properties & props = entry->int_id_;
+ props = overrides;
+ }
+ else
+ {
+ if (this->type_properties_.bind (type_id, overrides) != 0)
+ ACE_THROW (CORBA::UNKNOWN ());
+ }
}
@@ -203,41 +228,28 @@ TAO_PG_PropertyManager::remove_type_properties (
void
TAO_PG_PropertyManager::set_properties_dynamically (
- PortableGroup::ObjectGroup_ptr /* object_group */,
- const PortableGroup::Properties & /* overrides */
+ PortableGroup::ObjectGroup_ptr object_group,
+ const PortableGroup::Properties & overrides
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
PortableGroup::ObjectGroupNotFound,
PortableGroup::InvalidProperty,
PortableGroup::UnsupportedProperty))
{
-#if 0
- // First verify that the "InitialNumberMembers" property is not in
- // the Properties sequence. According to the spec, it is not
- // allowed to be set as part of the default properties.
- PortableGroup::Name factories;
- factories.length (1);
- factories[0].id =
- CORBA::string_dup ("org.omg.PortableGroup.InitialNumberMembers");
- CORBA::ULong len = props.length ();
- for (CORBA::ULong i = 0; i < len; ++i)
- {
- PortableGroup::Property property = props[i];
-
- if (property.nam == factories)
- ACE_THROW (PortableGroup::InvalidProperty (property.nam,
- property.val));
- }
-
- this->property_validator_.validate_property (overrides
+ this->property_validator_->validate_property (overrides
ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
- // @todo Set the properties in the object group map entry.
-#endif /* 0 */
+ ACE_GUARD (TAO_SYNCH_MUTEX, property_map_guard, this->lock_);
+
+ PortableGroup::Properties * dynamic_properties =
+ this->object_group_manager_.get_dynamic_properties (object_group
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
- ACE_THROW (CORBA::NO_IMPLEMENT ());
+ // Now override the dynamic (object group) properties with the new values
+ TAO_PG::override_properties (overrides, *dynamic_properties);
}
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_PropertyManager.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_PropertyManager.h
index c0121e9c022..5230e0127fd 100644
--- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_PropertyManager.h
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_PropertyManager.h
@@ -55,6 +55,10 @@ public:
/// Constructor.
TAO_PG_PropertyManager (TAO_PG_ObjectGroupManager & object_group_manager);
+ /// Specifies the property validator to use (0 means: use the default)
+ virtual void init (
+ TAO_PG_Default_Property_Validator * property_validator );
+
/**
* @name PortableGroup::PropertyManager methods
*
@@ -115,7 +119,7 @@ public:
/**
* Dynamically set the properties associated with a given object
- * group as the load balancer and replicas are being executed.
+ * group as the replicas are being executed.
* These properties override the type-specific and default
* properties.
*/
@@ -178,10 +182,7 @@ private:
TAO_SYNCH_MUTEX lock_;
/// The property validator.
- /**
- * @todo Strategize the validator, or use template policies.
- */
- TAO_PG_Default_Property_Validator property_validator_;
+ TAO_PG_Default_Property_Validator * property_validator_;
};
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Property_Utils.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Property_Utils.cpp
index 895c5bc8ad3..8b17a4425f6 100644
--- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Property_Utils.cpp
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Property_Utils.cpp
@@ -34,14 +34,7 @@ TAO_PG::override_properties (
return;
const CORBA::ULong old_length = properties.length ();
-
- const CORBA::ULong new_length =
- (num_overrides > old_length ? num_overrides : old_length);
-
- // Increase the length wholesale as much as possible. The idea is
- // to keep the cost of the incremental growth that may occur below
- // to a minimum.
- properties.length (new_length);
+ // const CORBA::ULong new_length = old_length;
// @@ Slow O(n^2) operation. Note that it may be slower than O(n^2)
// if the length of the property sequence must be increased
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Utils.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Utils.cpp
new file mode 100644
index 00000000000..5eb48d6ff1f
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Utils.cpp
@@ -0,0 +1,169 @@
+#include "PG_Utils.h"
+#include "tao/MProfile.h"
+#include "tao/Profile.h"
+#include "tao/Stub.h"
+#include "tao/Tagged_Components.h"
+
+ACE_RCSID (PortableGroup,
+ PG_Utils,
+ "$Id$")
+namespace TAO
+{
+ /*static*/ CORBA::Boolean
+ PG_Utils::set_tagged_component (
+ PortableGroup::ObjectGroup *&ior,
+ PortableGroup::TagGroupTaggedComponent &tg)
+ {
+ if (ior->_stubobj () == 0)
+ return 0;
+
+ // We need to apply the property for every profile in the IOR
+ TAO_MProfile &tmp_pfiles =
+ ior->_stubobj ()->base_profiles ();
+
+ // Create the output CDR stream
+ TAO_OutputCDR cdr;
+
+ IOP::TaggedComponent tagged_components;
+ tagged_components.tag = IOP::TAG_FT_GROUP;
+
+ // Encode the property in to the tagged_components
+ CORBA::Boolean retval =
+ PG_Utils::encode_properties (cdr,
+ tg);
+
+ if (retval == 0)
+ return retval;
+
+ // Get the length of the CDR stream
+ CORBA::ULong length = ACE_static_cast (CORBA::ULong,
+ cdr.total_length ());
+
+ // Set the length
+ tagged_components.component_data.length (length);
+
+ // Get the pointer to the underlying buffer
+ CORBA::Octet *buf =
+ tagged_components.component_data.get_buffer ();
+
+ for (const ACE_Message_Block *i = cdr.begin ();
+ i != 0;
+ i = i->cont ())
+ {
+
+ ACE_OS::memcpy (buf, i->rd_ptr (), i->length ());
+ buf += i->length ();
+ }
+ const IOP::TaggedComponent &tmp_tc = tagged_components;
+
+ // Get the profile count.
+ CORBA::ULong count =
+ ior->_stubobj ()->base_profiles ().profile_count ();
+
+ // Go through every profile and set the TaggedComponent field
+ for (CORBA::ULong p_idx = 0; p_idx < count ; ++p_idx)
+ {
+ // Get the tagged components in the profile
+ TAO_Tagged_Components &tag_comp =
+ tmp_pfiles.get_profile (p_idx)->tagged_components ();
+
+ // Finally set the <tagged_component> in the
+ // <TAO_Tagged_Component>
+ tag_comp.set_component (tmp_tc);
+ }
+
+ // Success
+ return 1;
+ }
+
+ /*static*/ CORBA::Boolean
+ PG_Utils::get_tagged_component (
+ PortableGroup::ObjectGroup *&ior,
+ PortableGroup::TagGroupTaggedComponent &tg)
+ {
+ if (ior->_stubobj () == 0)
+ return 0;
+
+ TAO_MProfile &mprofile =
+ ior->_stubobj ()->base_profiles ();
+
+ // Looking for a tagged component with a TAG_FT_GROUP flag.
+ IOP::TaggedComponent tc;
+ tc.tag = IOP::TAG_FT_GROUP;
+
+ CORBA::ULong count =
+ mprofile.profile_count ();
+
+ for (CORBA::ULong i = 0;
+ i < count;
+ i++)
+ {
+
+ // Get the Tagged Components
+ const TAO_Tagged_Components &pfile_tagged =
+ mprofile.get_profile (i)->tagged_components ();
+
+ // Look for the primary
+ if (pfile_tagged.get_component (tc) == 1)
+ {
+ TAO_InputCDR cdr (ACE_reinterpret_cast (
+ const char*,
+ tc.component_data.get_buffer ()),
+ tc.component_data.length ());
+
+ CORBA::Boolean byte_order;
+
+ cdr >> ACE_InputCDR::to_boolean (byte_order);
+
+ if (!cdr.good_bit ())
+ return 0;
+
+ cdr.reset_byte_order (ACE_static_cast (int,byte_order));
+
+ cdr >> tg;
+
+ if (cdr.good_bit ())
+ return 1;
+ }
+ }
+
+ return 0;
+ }
+
+ CORBA::Boolean
+ PG_Utils::encode_properties (
+ TAO_OutputCDR &cdr,
+ PortableGroup::TagGroupTaggedComponent &tg)
+ {
+ cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER);
+
+ if (!cdr.good_bit ())
+ return 0;
+
+ // the version info
+ cdr << tg.component_version;
+
+ if (!cdr.good_bit ())
+ return 0;
+
+ // the domain id
+ cdr << tg.group_domain_id.in ();
+
+ if (!cdr.good_bit ())
+ return 0;
+
+ // Object group id
+ cdr << tg.object_group_id;
+
+ if (!cdr.good_bit ())
+ return 0;
+
+ // Object group reference version
+ cdr << tg.object_group_ref_version;
+
+ if (!cdr.good_bit ())
+ return 0;
+
+ return cdr.good_bit ();
+ }
+}
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Utils.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Utils.h
new file mode 100644
index 00000000000..27c548d94c5
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Utils.h
@@ -0,0 +1,53 @@
+/* -*- C++ -*- */
+//=============================================================================
+/**
+ * @file PG_Utils.h
+ *
+ * $Id$
+ *
+ * Utility methods
+ *
+ * @author Balachandran Natarajan <bala@dre.vanderbilt.edu>
+ */
+//=============================================================================
+#ifndef TAO_PORTABLEGROUP_UTILS_H
+#define TAO_PORTABLEGROUP_UTILS_H
+#include /**/ "ace/pre.h"
+#include "orbsvcs/PortableGroupC.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+namespace TAO
+{
+ /**
+ * @class PG_Utils
+ *
+ * @brief Simple utility class
+ */
+ class TAO_PortableGroup_Export PG_Utils
+ {
+ public:
+
+ /// Set tagged component for the object group
+ static CORBA::Boolean set_tagged_component (
+ PortableGroup::ObjectGroup *&ior,
+ PortableGroup::TagGroupTaggedComponent &t);
+
+ /// Get tagged component for the object group
+ static CORBA::Boolean get_tagged_component (
+ PortableGroup::ObjectGroup *&ior,
+ PortableGroup::TagGroupTaggedComponent &t);
+
+ private:
+ static CORBA::Boolean encode_properties (
+ TAO_OutputCDR &cdr,
+ PortableGroup::TagGroupTaggedComponent &tg);
+ };
+}
+
+
+
+#include /**/ "ace/post.h"
+#endif /*TAO_PORTABLEGROUP_UTILS_H*/
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PortableGroup_Loader.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PortableGroup_Loader.h
index de96b0bf840..ceb1912e470 100644
--- a/TAO/orbsvcs/orbsvcs/PortableGroup/PortableGroup_Loader.h
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PortableGroup_Loader.h
@@ -33,7 +33,7 @@
* This class acts as a facade for the PortableGroup library to the
* ORB.
*/
-class TAO_PortableGroup_Export TAO_PortableGroup_Loader
+class TAO_PortableGroup_Export TAO_PortableGroup_Loader
: public ACE_Service_Object
{
friend class TAO_POA_Hooks;
@@ -58,7 +58,7 @@ ACE_FACTORY_DECLARE (TAO_PortableGroup, TAO_PortableGroup_Loader)
typedef int (*TAO_Module_Initializer) (void);
static TAO_Module_Initializer
-TAO_Requires_PortableGroup_Initializer =
+TAO_Requires_PortableGroup_Initializer =
&TAO_PortableGroup_Loader::Initializer;
#else
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PortableGroup_Request_Dispatcher.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PortableGroup_Request_Dispatcher.h
index 23144844275..0837d9989db 100644
--- a/TAO/orbsvcs/orbsvcs/PortableGroup/PortableGroup_Request_Dispatcher.h
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PortableGroup_Request_Dispatcher.h
@@ -4,6 +4,7 @@
/**
* @file PortableGroup_Request_Dispatcher.h
*
+
* $Id$
*
* A class that strategizes the request dispatching procedure.
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/Portable_Group_Map.h b/TAO/orbsvcs/orbsvcs/PortableGroup/Portable_Group_Map.h
index d0a3fa4d2bc..185cad17d0d 100644
--- a/TAO/orbsvcs/orbsvcs/PortableGroup/Portable_Group_Map.h
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/Portable_Group_Map.h
@@ -67,11 +67,11 @@ class TAO_PortableGroup_Export TAO_Portable_Group_Map
{
public:
- /**
- * @struct Map_Entry
- *
- * @brief Value field of the portable group map.
- */
+ /**
+ * @struct Map_Entry
+ *
+ * @brief Value field of the portable group map.
+ */
struct Map_Entry
{
/// The key.
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Acceptor.h b/TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Acceptor.h
index c259c04f960..5be819f9668 100644
--- a/TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Acceptor.h
+++ b/TAO/orbsvcs/orbsvcs/PortableGroup/UIPMC_Acceptor.h
@@ -106,7 +106,7 @@ protected:
* virtual to allow a derived class implementation to be invoked
* instead.
*/
- virtual int open_i (const ACE_INET_Addr &addr,
+ virtual int open_i (const ACE_INET_Addr &addr,
ACE_Reactor *reactor);
/// Parse protocol specific options.