summaryrefslogtreecommitdiff
path: root/TAO
diff options
context:
space:
mode:
authorOssama Othman <ossama-othman@users.noreply.github.com>2002-08-12 06:18:23 +0000
committerOssama Othman <ossama-othman@users.noreply.github.com>2002-08-12 06:18:23 +0000
commitebdfdf717dc25260031ae22ffd1314f9be16d69b (patch)
treec9566dbf8ca7520f7c678fdf95e305425b38635e /TAO
parentb05a85fdc953676e863ba676095efeb4c66a0bed (diff)
downloadATCD-ebdfdf717dc25260031ae22ffd1314f9be16d69b.tar.gz
ChangeLogTag:Sun Aug 11 23:17:47 2002 Ossama Othman <ossama@uci.edu>
Diffstat (limited to 'TAO')
-rw-r--r--TAO/ChangeLog22
-rw-r--r--TAO/orbsvcs/orbsvcs/LB_ORT.idl31
-rw-r--r--TAO/orbsvcs/orbsvcs/LoadBalancing/LB_IORInterceptor.cpp80
-rw-r--r--TAO/orbsvcs/orbsvcs/LoadBalancing/LB_IORInterceptor.h115
-rw-r--r--TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectReferenceFactory.cpp118
-rw-r--r--TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectReferenceFactory.h106
6 files changed, 472 insertions, 0 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index 40f90be3a7b..2155b84466b 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,25 @@
+Sun Aug 11 23:17:47 2002 Ossama Othman <ossama@uci.edu>
+
+ * orbsvsc/orbsvcs/LoadBalancing/LB_ORT.idl:
+
+ New IDL file that defines a TAO load balancer specific
+ ObjectReferenceFactory ValueType.
+
+ * orbsvsc/orbsvcs/LoadBalancing/LB_IORInterceptor.h:
+ * orbsvsc/orbsvcs/LoadBalancing/LB_IORInterceptor.cpp:
+
+ New IORInterceptor that sets the TAO load balancer specific
+ ObjectReferenceFactory for a given object adapter.
+
+ * orbsvsc/orbsvcs/LoadBalancing/LB_ObjectReferenceFactory.h:
+ * orbsvsc/orbsvcs/LoadBalancing/LB_ObjectReferenceFactory.cpp:
+
+ TAO load balancer specific ObjectReferenceFactory that creates
+ an object group for a member of the given repository ID (if
+ instructed to do so), creates an "unpublished" reference for
+ that member, and adds it to the object group via the
+ LoadManager.
+
Sat Aug 10 17:09:27 2002 Balachandran Natarajan <bala@cs.wustl.edu>
* orbsvcs/examples/PSS/PSS.dsw:
diff --git a/TAO/orbsvcs/orbsvcs/LB_ORT.idl b/TAO/orbsvcs/orbsvcs/LB_ORT.idl
new file mode 100644
index 00000000000..01550820181
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/LB_ORT.idl
@@ -0,0 +1,31 @@
+// -*- IDL -*-
+
+//=============================================================================
+/**
+ * @file LB_ORT.idl
+ *
+ * $Id$
+ */
+//=============================================================================
+
+
+#ifndef TAO_LB_ORT_IDL
+#define TAO_LB_ORT_IDL
+
+#include "tao/ObjectReferenceTemplate.pidl"
+
+#pragma prefix "tao.lb"
+
+
+module TAO_LB
+{
+
+ valuetype ObjectReferenceFactory
+ : PortableInterceptor::ObjectReferenceFactory {};
+
+};
+
+#pragma prefix ""
+
+
+#endif /* TAO_LB_ORT_IDL */
diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_IORInterceptor.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_IORInterceptor.cpp
new file mode 100644
index 00000000000..520f96e1303
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_IORInterceptor.cpp
@@ -0,0 +1,80 @@
+#include "LB_IORInterceptor.h"
+
+
+ACE_RCSID (LoadBalancing,
+ LB_IORInterceptor,
+ "$Id$")
+
+
+TAO_LB_IORInterceptor::TAO_LB_IORInterceptor (const char * repository_ids)
+ : repository_ids_ (repository_ids)
+{
+}
+
+char *
+TAO_LB_IORInterceptor::name (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ return CORBA::string_dup ("TAO_LB_IORInterceptor");
+}
+
+void
+TAO_LB_IORInterceptor::destroy (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+}
+
+void
+TAO_LB_IORInterceptor::establish_components (
+ PortableInterceptor::IORInfo_ptr
+ ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC (())
+{
+}
+
+void
+TAO_LB_IORInterceptor::components_established (
+ PortableInterceptor::IORInfo_ptr info
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ // Save a copy of the current ObjectReferenceFactory.
+ PortableInterceptor::ObjectReferenceFactory_var old_orf =
+ info->current_factory (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_CHECK;
+
+ PortableInterceptor::ObjectReferenceFactory * tmp;
+ ACE_NEW_THROW_EX (tmp,
+ TAO_LB_ObjectReferenceFactory (old_orf.in (),
+ this->repository_ids_),
+ CORBA::NO_MEMORY (
+ CORBA_SystemException::_tao_minor_code (
+ TAO_DEFAULT_MINOR_CODE,
+ ENOMEM),
+ CORBA::COMPLETED_NO));
+ ACE_CHECK;
+
+ PortableInterceptor::ObjectReferenceFactory_var orf = tmp;
+
+ info->current_factory (orf.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+}
+
+void
+TAO_LB_IORInterceptor::adapter_manager_state_changed (
+ PortableInterceptor::AdapterManagerId,
+ PortableInterceptor::AdapterState
+ ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+}
+
+void
+TAO_LB_IORInterceptor:: adapter_state_changed (
+ const PortableInterceptor::ObjectReferenceTemplateSeq &,
+ PortableInterceptor::AdapterState
+ ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+}
diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_IORInterceptor.h b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_IORInterceptor.h
new file mode 100644
index 00000000000..8330a43d452
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_IORInterceptor.h
@@ -0,0 +1,115 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file LB_IORInterceptor.h
+ *
+ * $Id$
+
+ * @author Ossama Othman <ossama@uci.edu>
+ */
+//=============================================================================
+
+#ifndef LB_IOR_INTERCEPTOR_H
+#define LB_IOR_INTERCEPTOR_H
+
+#include "ace/config-all.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "tao/PortableInterceptorC.h"
+#include "tao/LocalObject.h"
+
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1200)
+#pragma warning(push)
+#endif /* _MSC_VER >= 1200 */
+#pragma warning(disable:4250)
+#endif /* _MSC_VER */
+
+/**
+ * @class TAO_LB_IORInterceptor
+ *
+ * @brief TAO Load Balancer IOR interceptor.
+ *
+ * This IORInterceptor is registered in object group member ORBs.
+ * During creation of the object group member reference, this
+ * IORInterceptor will change the "current_factory" attribute of the
+ * PortableInterceptor::IORInfo object to the Load Balancer's
+ * ObjectReferenceFactory.
+ *
+ * @see LB_ObjectReferenceFactory.h for details.
+ */
+class TAO_LB_IORInterceptor
+ : public virtual PortableInterceptor::IORInterceptor,
+ public virtual TAO_Local_RefCounted_Object
+{
+public:
+
+ /// Constructor.
+ TAO_LB_IORInterceptor (const char * repository_ids);
+
+ /**
+ * @name Methods Required by the IOR Interceptor Interface
+ *
+ * These are methods that must be implemented since they are pure
+ * virtual in the abstract base class. They are the canonical
+ * methods required for all IOR interceptors.
+ */
+ //@{
+ /// Return the name of this IORInterceptor.
+ virtual char * name (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ /// Cleanup resources acquired by this IORInterceptor.
+ virtual void destroy (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ /// Add the tagged components to the IOR.
+ virtual void establish_components (
+ PortableInterceptor::IORInfo_ptr info
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC (());
+
+ virtual void components_established (
+ PortableInterceptor::IORInfo_ptr info
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ virtual void adapter_manager_state_changed (
+ PortableInterceptor::AdapterManagerId id,
+ PortableInterceptor::AdapterState state
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((
+ CORBA::SystemException
+ ));
+
+ virtual void adapter_state_changed (
+ const PortableInterceptor::ObjectReferenceTemplateSeq & templates,
+ PortableInterceptor::AdapterState state
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((
+ CORBA::SystemException
+ ));
+
+ //@}
+
+private:
+
+ /// Space separated list of RepositoryIds corresponding to objects
+ /// that will be load balanced.
+ /**
+ * @note The actual storage for this string is controlled by the
+ * TAO_LB_ORBInitializer.
+ */
+ const char * repository_ids_;
+
+};
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+#pragma warning(pop)
+#endif /* _MSC_VER */
+
+#endif /* LB_IOR_INTERCEPTOR_H */
diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectReferenceFactory.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectReferenceFactory.cpp
new file mode 100644
index 00000000000..884d69cc164
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectReferenceFactory.cpp
@@ -0,0 +1,118 @@
+#include "LB_ObjectReferenceFactory.h"
+
+/**
+ * @todo Change this to "ace/Tokenizer.h" once "ace/Tokenizer.h" is
+ * committed.
+ */
+#include "ace/SString.h"
+
+ACE_RCSID (LoadBalancing,
+ LB_ObjectReferenceFactory,
+ "$Id$")
+
+
+TAO_LB_ObjectReferenceFactory::TAO_LB_ObjectReferenceFactory (
+ PortableInterceptor::ObjectReferenceFactory * old_orf,
+ const char * repository_ids)
+ : old_orf_ (old_orf),
+ repository_ids_ (repository_ids)
+{
+ // Claim ownership of the old ObjectReferenceFactory.
+ CORBA::add_ref (old_orf);
+}
+
+TAO_LB_ObjectReferenceFactory::~TAO_LB_ObjectReferenceFactory (void)
+{
+ // No need to call CORBA::remove_ref() on this->old_orf_. It is a
+ // "_var" object, meaning that will be done automatically.
+}
+
+CORBA::Object_ptr
+TAO_LB_ObjectReferenceFactory::make_object (
+ const char * repository_id,
+ const PortableInterceptor::ObjectId & id
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ CORBA::Object_var obj =
+ this->old_orf_->make_object (repository_id,
+ id
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (CORBA::Object::_nil ());
+
+ PortableGroup::ObjectGroup_var object_group;
+ if (this->find_object_group (repository_id, object_group.out ()))
+ {
+ ACE_TRY
+ {
+ this->lm_->add_member (object_group.in (),
+ this->location_,
+ obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // Return the object group reference instead.
+ return object_group._retn ();
+ }
+ ACE_CATCH (PortableGroup::ObjectGroupNotFound, ex)
+ {
+ if (TAO_debug_level > 0)
+ ACE_PRINT_EXCEPTION (ex,
+ "TAO_LB_ObjectReferenceFactory::make_object"
+ " - LoadManager::add_member()\n");
+
+ ACE_THROW_RETURN (CORBA::BAD_PARAM (),
+ CORBA::Object::_nil ());
+ }
+ ACE_CATCH (PortableGroup::MemberAlreadyPresent, ex)
+ {
+ if (TAO_debug_level > 0)
+ ACE_PRINT_EXCEPTION (ex,
+ "TAO_LB_ObjectReferenceFactory::make_object"
+ " - LoadManager::add_member()\n");
+
+ ACE_THROW_RETURN (CORBA::BAD_INV_ORDER (),
+ CORBA::Object::_nil ());
+
+ }
+ ACE_CATCH (PortableGroup::ObjectNotAdded, ex)
+ {
+ if (TAO_debug_level > 0)
+ ACE_PRINT_EXCEPTION (ex,
+ "TAO_LB_ObjectReferenceFactory::make_object"
+ " - LoadManager::add_member()\n");
+
+ ACE_THROW_RETURN (CORBA::UNKNOWN (),
+ CORBA::Object::_nil ());
+ }
+ ACE_ENDTRY;
+ ACE_CHECK_RETURN (CORBA::Object::_nil ());
+ }
+
+ // Not a load managed object. Simply return the object's actual
+ // object reference.
+ return obj._retn ();
+}
+
+CORBA::Boolean
+TAO_LB_ObjectReferenceFactory::find_object_group (
+ const char * repository_id,
+ PortableGroup::ObjectGroup_out object_group)
+{
+ this->load_managed_object (repository_id)
+ PortableGroup::ObjectGroup_var;
+ if (this->load_balanced_object (repository_id)
+ && this->table_.find (repository_id, object_group) == 0)
+ return 1;
+ else
+ return 0;
+}
+
+CORBA::Boolean
+TAO_LB_ObjectReferenceFactory::load_managed_object (const char * repository_id)
+{
+ CORBA::String_var ids = CORBA::string_dup (this->repository_ids_);
+
+ if (str == this->repository_ids_
+ && str + len
+}
diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectReferenceFactory.h b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectReferenceFactory.h
new file mode 100644
index 00000000000..6bf024c60e2
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectReferenceFactory.h
@@ -0,0 +1,106 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file LB_ObjectReferenceFactory.h
+ *
+ * $Id$
+
+ * @author Ossama Othman <ossama@uci.edu>
+ */
+//=============================================================================
+
+#ifndef TAO_LB_OBJECT_REFERENCE_FACTORY_H
+#define TAO_LB_OBJECT_REFERENCE_FACTORY_H
+
+#include "ace/pre.h"
+
+#include "orbsvcs/LB_ORTC.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1200)
+#pragma warning(push)
+#endif /* _MSC_VER >= 1200 */
+#pragma warning(disable:4250)
+#endif /* _MSC_VER */
+
+
+/**
+ * @class TAO_LB_ObjectReferenceFactory
+ *
+ * @brief Implementation of the PortableInterceptor::ObjectReferenceFactory
+ * interface.
+ *
+ * This ObjectReferenceFactory creates an object group for a member of
+ * the given repository ID (if instructed to do so), creates an
+ * "unpublished" reference for that member, and adds it to the object
+ * group via the LoadManager.
+ */
+class TAO_LB_ObjectReferenceFactory
+ : public virtual CORBA::DefaultValueRefCountBase
+ , public virtual OBV_TAO_LB::ObjectReferenceFactory
+{
+ public:
+
+ /// Constructor
+ TAO_LB_ObjectReferenceFactory (
+ PortableInterceptor::ObjectReferenceFactory * old_orf,
+ const char * repository_ids);
+
+ /**
+ * @name PortableInterceptor::ObjectReferenceFactory Methods
+ *
+ * Methods required by the
+ * PortableInterceptor::ObjectReferenceFactory interface.
+ */
+ //@{
+ virtual CORBA::Object_ptr make_object (
+ const char * repository_id,
+ const PortableInterceptor::ObjectId & id
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+ //@}
+
+protected:
+
+ /// Destructor
+ /**
+ * Protected destructor to enforce proper memory management via
+ * reference counting.
+ */
+ ~TAO_LB_ObjectReferenceFactory (void);
+
+private:
+
+ /// The old ObjectReferenceFactory used to create object references.
+ /**
+ * This ObjectReferenceFactory will be used when creating object
+ * references for non-load balanced objects.
+ */
+ PortableInterceptor::ObjectReferenceFactory_var old_orf_;
+
+ /// Space separated list of RepositoryIds corresponding to objects
+ /// that will be load balanced.
+ /**
+ * @note The actual storage for this string is controlled by the
+ * TAO_LB_ORBInitializer.
+ */
+ const char * repository_ids_;
+
+ /// Table that maps repository ID to object group reference.
+ Table table_;
+
+};
+
+
+#if defined (_MSC_VER) && (_MSC_VER >= 1200)
+#pragma warning(pop)
+#endif /* _MSC_VER */
+
+#include "ace/post.h"
+
+#endif /* TAO_LB_OBJECT_REFERENCE_FACTORY_H */