diff options
30 files changed, 975 insertions, 534 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 4884604b5a1..76edb9c6056 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,94 @@ +Wed Jul 30 12:50:33 2003 Balachandran Natarajan <bala@dre.vanderbilt.edu> + + * tao/Profile.h: + * tao/Profile.cpp: Added two new methods, hash_service_i () and + is_profile_equivalent_i (). These methods are basically hooks + for is_equivalent () and hash () calls declared in the profile + classes. The hook serves to address the following problem + + - services like FTCORBA have additional requirements to decide + whether two objects or profiles are equivalent. This hook + is used by the services, like FTCORBA to their additional + requirements. + + * tao/IIOP_Profile.cpp: + * tao/Strategies/UIOP_Profile.cpp: + * tao/Strategies/DIOP_Profile.cpp: + * tao/Strategies/SHMIOP_Profile.cpp: + * tao/Strategies/SCIOP_Profile.cpp: Calls to hash () and + is_equivalent (), invokes the above new methods in their base + classes in addition to the computations that is already done. + + Thanks to Didier Becu <didier.becu@fr.thalesgroup.com> for + motivating these changes. + + + * orbsvcs/orbsvcs/FaultTolerance/FT_Invocation_Endpoint_Selectors.cpp: + + Fixed a subtle problem which prevented location forwarded IOR's + to be overlooked when trying to search for a primary. + + * orbsvcs/orbsvcs/FT_ORB.bor: Added the new file to the borland + Makefile. + + + Integration from the branch. The relevant ChangeLog entries are: + + Thu Jul 10 11:20:52 2003 Balachandran Natarajan <bala@dre.vanderbilt.edu> + + * orbsvcs/orbsvcs/Makefile.FaulTolerance: Added new files. + + * orbsvcs/orbsvcs/FT_CORBA_ORB.idl: Make the IDL spec compatible. + + Thu Jul 10 11:09:25 2003 Balachandran Natarajan <bala@dre.vanderbilt.edu> + + * orbsvcs/orbsvcs/FaultTolerance/FT_ClientRequest_Interceptor.h: + * orbsvcs/orbsvcs/FaultTolerance/FT_ClientRequest_Interceptor.cpp: + Client side interceptor for FaultTolerance. This interceptor is + now used to modify the service context list that is passed to + the server side. The interceptor is setup using the standard + svc.conf mechanism. This fixes some of the subtle bugs that have + been reported in the past that arose from + + - A new IOGR version showing up from the server through a + location forward mechanism but the service context list + sending older group version information to the server. + + - The policy for request_duration_time not accessible if set on + the PolicyManager. + + * orbsvcs/orbsvcs/FaultTolerance/FT_ORBInitializer.cpp: + * orbsvcs/orbsvcs/FaultTolerance/FT_ORBInitializer.h: Register the + server side and client side interceptors through the + initializer. + + * orbsvcs/orbsvcs/FaultTolerance/FT_Policy_i.cpp: + * orbsvcs/orbsvcs/FaultTolerance/FT_Policy_i.h: The latest specs + changed the attribute in FTRequestDurationPolicy from + request_duration_policy to + request_duration_policy_value. Changed the accesor to match the + IDL file. + + * orbsvcs/orbsvcs/FaultTolerance/FT_Service_Callbacks.cpp: + * orbsvcs/orbsvcs/FaultTolerance/FT_Service_Callbacks.h: Removed + all the callback code used for processing service context + information. We now interceptors to do that. + + * tao/ORB_Core.h: + * tao/ORB_Core.cpp: + * tao/ORB_Core.i: Removed all the callbacks for logging and + service context for FT. + + + * tao/Service_Callbacks.h: + * tao/Service_Callbacks.cpp: The effect of the above + changes. Remove interfaces that are totally irrelevant. + + + * tao/PortableServer/ServantBase.cpp: The effect of the above change. + + + Tue Jul 29 16:27:52 2003 Jeff Parsons <j.parsons@vanderbilt.edu> * orbsvcs/IFR_Service/be_produce.cpp (BE_produce): diff --git a/TAO/orbsvcs/orbsvcs/FT_ORB.bor b/TAO/orbsvcs/orbsvcs/FT_ORB.bor index f928f701657..43a3c4d391f 100644 --- a/TAO/orbsvcs/orbsvcs/FT_ORB.bor +++ b/TAO/orbsvcs/orbsvcs/FT_ORB.bor @@ -27,6 +27,7 @@ OBJFILES = \ $(OBJDIR)\FT_PolicyFactory.obj \ $(OBJDIR)\FT_Service_Activate.obj \ $(OBJDIR)\FT_Service_Callbacks.obj \ + $(OBJDIR)\FT_ClientRequest_Interceptor.obj \ $(OBJDIR)\FT_ORBInitializer.obj RESOURCE = $(OBJDIR)\FaultTolerance.res diff --git a/TAO/orbsvcs/orbsvcs/FaultTolerance/ChangeLog b/TAO/orbsvcs/orbsvcs/FaultTolerance/ChangeLog new file mode 100644 index 00000000000..8ff5d247dd7 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/FaultTolerance/ChangeLog @@ -0,0 +1,46 @@ +Thu Jul 10 11:20:52 2003 Balachandran Natarajan <bala@dre.vanderbilt.edu> + + * orbsvcs/orbsvcs/Makefile.FaulTolerance: Added new files. + + * orbsvcs/orbsvcs/FT_CORBA_ORB.idl: Make the IDL spec compatible. + +Thu Jul 10 11:09:25 2003 Balachandran Natarajan <bala@dre.vanderbilt.edu> + + * orbsvcs/orbsvcs/FaultTolerance/FT_ClientRequest_Interceptor.h: + * orbsvcs/orbsvcs/FaultTolerance/FT_ClientRequest_Interceptor.cpp: + Client side interceptor for FaultTolerance. This interceptor is + now used to modify the service context list that is passed to + the server side. The interceptor is setup using the standard + svc.conf mechanism. + + * orbsvcs/orbsvcs/FaultTolerance/FT_ORBInitializer.cpp: + * orbsvcs/orbsvcs/FaultTolerance/FT_ORBInitializer.h: Register the + server side and client side interceptors through the + initializer. + + * orbsvcs/orbsvcs/FaultTolerance/FT_Policy_i.cpp: + * orbsvcs/orbsvcs/FaultTolerance/FT_Policy_i.h: The latest specs + changed the attribute in FTRequestDurationPolicy from + request_duration_policy to + request_duration_policy_value. Changed the accesor to match the + IDL file. + + * orbsvcs/orbsvcs/FaultTolerance/FT_Service_Callbacks.cpp: + * orbsvcs/orbsvcs/FaultTolerance/FT_Service_Callbacks.h: Removed + all the callback code used for processing service context + information. We now interceptors to do that. + + * tao/ORB_Core.h: + * tao/ORB_Core.cpp: + * tao/ORB_Core.i: Removed all the callbacks for logging and + service context for FT. + + + * tao/Service_Callbacks.h: + * tao/Service_Callbacks.cpp: The effect of the above + changes. Remove interfaces that are totally irrelevant. + + + * tao/PortableServer/ServantBase.cpp: The effect of the above change. + + diff --git a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_ClientRequest_Interceptor.cpp b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_ClientRequest_Interceptor.cpp new file mode 100644 index 00000000000..0bfb4b1f932 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_ClientRequest_Interceptor.cpp @@ -0,0 +1,369 @@ +// $Id$ + +#include "FT_ClientRequest_Interceptor.h" +#include "orbsvcs/orbsvcs/FT_CORBA_ORBC.h" +#include "tao/CORBA_String.h" +#include "ace/UUID.h" + +ACE_RCSID (FaultTolerance, + FT_ORBInitializer, + "$Id$") + +TAO_FT_ClientRequest_Interceptor::TAO_FT_ClientRequest_Interceptor (void) + : name_ ("TAO_FT_ClientRequest_Interceptor") + , uuid_ (ACE_Utils::UUID_GENERATOR::instance ()->generateUUID ()) +{ +} + +TAO_FT_ClientRequest_Interceptor::~TAO_FT_ClientRequest_Interceptor (void) +{ + delete this->uuid_; +} + +char * +TAO_FT_ClientRequest_Interceptor::name (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return CORBA::string_dup (this->name_); +} + + +void +TAO_FT_ClientRequest_Interceptor::destroy (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +void +TAO_FT_ClientRequest_Interceptor::send_poll ( + PortableInterceptor::ClientRequestInfo_ptr + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // Do Nothing +} + +void +TAO_FT_ClientRequest_Interceptor::send_request ( + PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + if (TAO_debug_level > 3) + { + CORBA::String_var op = + ri->operation (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + ACE_DEBUG ((LM_DEBUG, + "TAO_FT (%P|%t): %s called for %s \n", + this->name_, + op.in ())); + } + + this->group_version_context (ri + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->request_service_context (ri + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +TAO_FT_ClientRequest_Interceptor::receive_reply ( + PortableInterceptor::ClientRequestInfo_ptr + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + + // Do Nothing +} + +void +TAO_FT_ClientRequest_Interceptor::receive_other ( + PortableInterceptor::ClientRequestInfo_ptr + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + +} + +void +TAO_FT_ClientRequest_Interceptor::receive_exception ( + PortableInterceptor::ClientRequestInfo_ptr + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ +#if 0 + // @@ Will be used later. + // Do a check for policy in which this can be done.. + PortableInterceptor::ReplyStatus rs = + ri->reply_status (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (rs != PortableInterceptor::SYSTEM_EXCEPTION) + { + return; + } + + CORBA::Any_var ex = + ri->received_exception (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + TAO_OutputCDR cdr; + + if (!ex->impl ()->marshal_value (cdr)) + return; + + // Place for optimization.. + TAO_InputCDR icdr (cdr); + + CORBA::String_var rep_id; + + CORBA::ULong min, cs = 0; + + if (!(icdr.read_string (rep_id.out ()) && + icdr.read_ulong (min) && + icdr.read_ulong (cs))) + ACE_THROW (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE, + CORBA::COMPLETED_MAYBE)); + + cs = CORBA::CompletionStatus (cs); + + // ORB would take care of it + if (cs != CORBA::COMPLETED_MAYBE) + return; + + // If it is COMPLETED_MAYBE, then we will throw a COMPLETED_NO, + // which the ORB should understand + if (ACE_OS_String::strcmp (rep_id.in (), + "IDL:omg.org/CORBA/TRANSIENT:1.0") == 0) + ACE_THROW (CORBA::TRANSIENT (min, + CORBA::COMPLETED_NO)); + else if (ACE_OS_String::strcmp (rep_id.in (), + "IDL:omg.org/CORBA/COMM_FAILURE:1.0") == 0) + ACE_THROW (CORBA::COMM_FAILURE (min, + CORBA::COMPLETED_NO)); + else if (ACE_OS_String::strcmp (rep_id.in (), + "IDL:omg.org/CORBA/NO_REPONSE:1.0") == 0) + ACE_THROW (CORBA::NO_RESPONSE (min, + CORBA::COMPLETED_NO)); + + else if (ACE_OS_String::strcmp (rep_id.in (), + "IDL:omg.org/CORBA/OBJ_ADAPTER:1.0") == 0) + ACE_THROW (CORBA::OBJ_ADAPTER (min, + CORBA::COMPLETED_NO)); + cout << "Didnt throw exception " << endl; +#endif /*if 0*/ + return; +} + + +void +TAO_FT_ClientRequest_Interceptor::group_version_context ( + PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // If the service context is already there dont add new service + // context information.. + ACE_TRY + { + IOP::ServiceContext_var sc = + ri->get_request_service_context (IOP::FT_GROUP_VERSION + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCH (CORBA::BAD_PARAM, ex) + { + // Grab the object group version + // @@ NOTE: This involves an allocation and a dellocation. This is + // really bad. + IOP::TaggedComponent_var tp = + ri->get_effective_component (IOP::TAG_FT_GROUP + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + TAO_InputCDR cdr (ACE_reinterpret_cast (const char*, + tp->component_data.get_buffer () + ), + tp->component_data.length ()); + CORBA::Boolean byte_order; + + if ((cdr >> ACE_InputCDR::to_boolean (byte_order)) == 0) + return; + + cdr.reset_byte_order (ACE_static_cast (int,byte_order)); + + FT::TagFTGroupTaggedComponent fgtc; + + if ((cdr >> fgtc) == 0) + ACE_THROW (CORBA::BAD_PARAM (CORBA::OMGVMCID | 28, + CORBA::COMPLETED_NO)); + + IOP::ServiceContext sc; + sc.context_id = IOP::FT_GROUP_VERSION; + + TAO_OutputCDR ocdr; + if (!(ocdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER))) + ACE_THROW (CORBA::MARSHAL ()); + + if (!(ocdr << fgtc)) + ACE_THROW (CORBA::MARSHAL ()); + + CORBA::ULong length = + ACE_static_cast (CORBA::ULong, ocdr.total_length ()); + sc.context_data.length (length); + CORBA::Octet *buf = sc.context_data.get_buffer (); + + for (const ACE_Message_Block *i = ocdr.begin (); + i != 0; + i = i->cont ()) + { + ACE_OS::memcpy (buf, i->rd_ptr (), i->length ()); + buf += i->length (); + } + + // Add this context to the service context list. + ri->add_request_service_context (sc, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + } + ACE_CATCHANY + { + // Not much can be done anyway. Just throw + ACE_RE_THROW; + } + ACE_ENDTRY; + ACE_CHECK; + + return; +} + +void +TAO_FT_ClientRequest_Interceptor::request_service_context ( + PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // If the service context is already there dont add new service + // context information.. + ACE_TRY + { + IOP::ServiceContext_var sc = + ri->get_request_service_context (IOP::FT_REQUEST + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCH (CORBA::BAD_PARAM, ex) + { + IOP::ServiceContext sc; + sc.context_id = IOP::FT_REQUEST; + + CORBA::Policy_var policy = + ri->get_request_policy (FT::REQUEST_DURATION_POLICY + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // @@ NOTE: This needs fixing if something useful needs to + // happen. + FT::FTRequestServiceContext ftrsc; + ftrsc.client_id = CORBA::string_dup (this->uuid_->to_string ()->c_str ()); + ftrsc.expiration_time = + this->request_expiration_time (policy.in () + ACE_ENV_ARG_PARAMETER); + + ftrsc.retention_id = + ri->request_id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + // @@ NOTE we need to generate a UUID here + + TAO_OutputCDR ocdr; + if (!(ocdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER))) + ACE_THROW (CORBA::MARSHAL ()); + + if (!(ocdr << ftrsc)) + ACE_THROW (CORBA::MARSHAL ()); + + // Make a *copy* of the CDR stream... + CORBA::ULong length = + ACE_static_cast (CORBA::ULong, ocdr.total_length ()); + sc.context_data.length (length); + CORBA::Octet *buf = sc.context_data.get_buffer (); + + for (const ACE_Message_Block *i = ocdr.begin (); + i != 0; + i = i->cont ()) + { + ACE_OS::memcpy (buf, i->rd_ptr (), i->length ()); + buf += i->length (); + } + + // Add this context to the service context list. + ri->add_request_service_context (sc, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + ACE_CATCHANY + { + ACE_RE_THROW; + } + ACE_ENDTRY; + ACE_CHECK; + return; +} + + +TimeBase::TimeT +TAO_FT_ClientRequest_Interceptor::request_expiration_time (CORBA::Policy *policy + ACE_ENV_ARG_DECL) +{ + FT::RequestDurationPolicy_var p; + + if (policy != 0) + { + p = FT::RequestDurationPolicy::_narrow (policy + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + } + + TimeBase::TimeT t = 0; + + if (p.in ()) + { + t = + p->request_duration_policy_value (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + } + else + { + if (TAO_debug_level > 3) + { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) TAO_FT - Using default value", + " of 15 seconds \n")); + } + t = 15 * 1000000; + } + + // Calculaton of the expiration time + + // Grab the localtime on the machine where this is running + ACE_Time_Value time_val = ACE_OS::gettimeofday (); + + TimeBase::TimeT sec_part = time_val.sec () * 10000000; + TimeBase::TimeT usec_part = time_val.usec ()* 10; + + // Now we have the total time + t += (sec_part + usec_part); + + return t; +} diff --git a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_ClientRequest_Interceptor.h b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_ClientRequest_Interceptor.h new file mode 100644 index 00000000000..fb20351b3db --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_ClientRequest_Interceptor.h @@ -0,0 +1,113 @@ +// -*- C++ -*- +//============================================================================= +/** + * @file FT_ClientRequest_Interceptor.h + * + * $Id$ + * + * @author Balachandran Natarajan <bala@dre.vanderbilt.edu> + */ +//============================================================================= +#ifndef TAO_FT_CLIENT_REQUEST_INTERCEPTOR_H +#define TAO_FT_CLIENT_REQUEST_INTERCEPTOR_H +#include "ace/pre.h" + +#include "fault_tol_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/PortableInterceptorC.h" +#include "tao/LocalObject.h" +#include "tao/TimeBaseC.h" + +// This is to remove "inherits via dominance" warnings from MSVC. +// MSVC is being a little too paranoid. +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + + +namespace ACE_Utils +{ + class UUID; +} +/** + * @class TAO_FT_ClientRequest_Interceptor + * + * @brief Interceptors for the client + * + * @@TODO + */ +class TAO_FT_Export TAO_FT_ClientRequest_Interceptor + : public virtual PortableInterceptor::ClientRequestInterceptor, + public virtual TAO_Local_RefCounted_Object +{ +public: + + TAO_FT_ClientRequest_Interceptor (void); + + ~TAO_FT_ClientRequest_Interceptor (void); + + /// Canonical name of the interceptor. + virtual char * name (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void send_poll (PortableInterceptor::ClientRequestInfo_ptr + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void send_request (PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void receive_reply (PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void receive_other (PortableInterceptor::ClientRequestInfo_ptr + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + virtual void receive_exception (PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + +private: + + void group_version_context (PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + + void request_service_context (PortableInterceptor::ClientRequestInfo_ptr ri + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + TimeBase::TimeT request_expiration_time (CORBA::Policy *policy + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + +private: + const char *name_; + + ACE_Utils::UUID *uuid_; +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#include "ace/post.h" +#endif /*TAO_FT_CLIENT_REQUEST_INTERCEPTOR_H*/ diff --git a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Endpoint_Selector_Factory.cpp b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Endpoint_Selector_Factory.cpp index 1ea17bc1001..7b59f7d14c4 100644 --- a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Endpoint_Selector_Factory.cpp +++ b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Endpoint_Selector_Factory.cpp @@ -22,13 +22,21 @@ TAO_Invocation_Endpoint_Selector * TAO_FT_Endpoint_Selector_Factory::get_selector (TAO_GIOP_Invocation * ACE_ENV_ARG_DECL) { - if (this->ft_endpoint_selector_ == 0) + if (this->ft_endpoint_selector_ == 0) { - ACE_NEW_THROW_EX (ft_endpoint_selector_, - TAO_FT_Invocation_Endpoint_Selector (), - CORBA::NO_MEMORY ()); + ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, + guard, + this->mutex_, + 0)); + + // Double checked locking.. + if (this->ft_endpoint_selector_ == 0) + { + ACE_NEW_THROW_EX (ft_endpoint_selector_, + TAO_FT_Invocation_Endpoint_Selector (), + CORBA::NO_MEMORY ()); + } } - return this->ft_endpoint_selector_; } diff --git a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Endpoint_Selector_Factory.h b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Endpoint_Selector_Factory.h index d8fc1e2a673..f1df5fc9fd8 100644 --- a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Endpoint_Selector_Factory.h +++ b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Endpoint_Selector_Factory.h @@ -10,8 +10,6 @@ * */ //============================================================================= - - #ifndef TAO_FT_ENDPOINT_SELECTOR_FACTORY_H #define TAO_FT_ENDPOINT_SELECTOR_FACTORY_H #include /**/ "ace/pre.h" @@ -23,8 +21,6 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "tao/Endpoint_Selector_Factory.h" -// @@todo: Inclusion of this files has been a mystery. Needs -// investigation #include "ace/Service_Config.h" class TAO_FT_Invocation_Endpoint_Selector; @@ -60,6 +56,9 @@ private: /// The possible endpoint selector strategies that can be /// returned by this factory TAO_FT_Invocation_Endpoint_Selector *ft_endpoint_selector_; + + /// Mutex to prevent multiple initializations + TAO_SYNCH_MUTEX mutex_; }; //extern TAO_FT_Export ACE_Static_Svc_Descriptor ace_svc_desc_TAO_FT_Endpoint_Selector_Factory; diff --git a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Invocation_Endpoint_Selectors.cpp b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Invocation_Endpoint_Selectors.cpp index d4582346d99..94c10d7eef9 100644 --- a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Invocation_Endpoint_Selectors.cpp +++ b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Invocation_Endpoint_Selectors.cpp @@ -188,8 +188,22 @@ TAO_FT_Invocation_Endpoint_Selector::select_primary ( ACE_ENV_ARG_DECL) { // Get the current profile - TAO_Profile *temp_profile = - invoc->stub ()->base_profiles ().get_current_profile (); + TAO_Profile *temp_profile = 0; + + // Get the forwarded profile if it exists + if (invoc->stub ()->forward_profiles ()) + { + TAO_MProfile *tmp = + ACE_const_cast (TAO_MProfile *, + invoc->stub ()->forward_profiles ()); + temp_profile = + tmp->get_current_profile (); + } + else + { + temp_profile = + invoc->stub ()->base_profiles ().get_current_profile (); + } int retval = 0; diff --git a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Invocation_Endpoint_Selectors.h b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Invocation_Endpoint_Selectors.h index ba13e700d27..04febd8c9a2 100644 --- a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Invocation_Endpoint_Selectors.h +++ b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Invocation_Endpoint_Selectors.h @@ -9,7 +9,7 @@ * Strategies for selecting profile/endpoint from an IOR for making an * invocation. * - * @author Bala Natarajan <bala@cs.wustl.edu> + * @author Balachandran Natarajan <bala@cs.wustl.edu> */ //============================================================================= diff --git a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_ORBInitializer.cpp b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_ORBInitializer.cpp index 51a9d535a22..a60a981142f 100644 --- a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_ORBInitializer.cpp +++ b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_ORBInitializer.cpp @@ -4,11 +4,14 @@ #include "FT_ORBInitializer.h" #include "FT_PolicyFactory.h" +#include "FT_ClientRequest_Interceptor.h" #include "orbsvcs/FT_CORBA_ORBC.h" #include "tao/Exception.h" -ACE_RCSID (FaultTolerance, FT_ORBInitializer, "$Id$") +ACE_RCSID (FaultTolerance, + FT_ORBInitializer, + "$Id$") void TAO_FT_ORBInitializer::pre_init ( PortableInterceptor::ORBInitInfo_ptr @@ -27,12 +30,24 @@ TAO_FT_ORBInitializer::post_init ( this->register_policy_factories (info ACE_ENV_ARG_PARAMETER); ACE_CHECK; + + this->register_server_request_interceptors (info + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->register_client_request_interceptors (info + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + + } void TAO_FT_ORBInitializer::register_policy_factories ( PortableInterceptor::ORBInitInfo_ptr info ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) { // Register the FTCORBA policy factories. @@ -78,3 +93,33 @@ TAO_FT_ORBInitializer::register_policy_factories ( // Transfer ownership of the policy factory to the registry. (void) policy_factory._retn (); } + +void +TAO_FT_ORBInitializer::register_server_request_interceptors ( + PortableInterceptor::ORBInitInfo_ptr + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + + +void +TAO_FT_ORBInitializer::register_client_request_interceptors ( + PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + PortableInterceptor::ClientRequestInterceptor_ptr cri = + PortableInterceptor::ClientRequestInterceptor::_nil (); + + ACE_NEW_THROW_EX (cri, + TAO_FT_ClientRequest_Interceptor, + CORBA::NO_MEMORY ()); + + PortableInterceptor::ClientRequestInterceptor_var + client_interceptor = cri; + + info->add_client_request_interceptor (client_interceptor.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} diff --git a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_ORBInitializer.h b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_ORBInitializer.h index 8a2bb6c66b2..7381aa86228 100644 --- a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_ORBInitializer.h +++ b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_ORBInitializer.h @@ -6,11 +6,9 @@ * * $Id$ * - * @author Bala Natarajan <bala@cs.wustl.edu> + * @author Balachandran Natarajan <bala@cs.wustl.edu> */ //============================================================================= - - #ifndef TAO_FT_ORB_INITIALIZER_H #define TAO_FT_ORB_INITIALIZER_H @@ -55,8 +53,19 @@ private: /// Register FTCORBA policy factories. void register_policy_factories ( PortableInterceptor::ORBInitInfo_ptr info - ACE_ENV_ARG_DECL); + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /// Register the necessary interceptors. + void register_server_request_interceptors ( + PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + void register_client_request_interceptors ( + PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); }; #if defined(_MSC_VER) && (_MSC_VER >= 1200) diff --git a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Policy_i.cpp b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Policy_i.cpp index 3328034a0cb..59b35423f5a 100644 --- a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Policy_i.cpp +++ b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Policy_i.cpp @@ -4,13 +4,13 @@ #include "tao/debug.h" #if !defined (__ACE_INLINE__) -#include "FT_Policy_i.i" +#include "FT_Policy_i.inl" #endif /* __ACE_INLINE__ */ ACE_RCSID(FaultTolerance, FT_Policy_i, "$Id$") TimeBase::TimeT -TAO_FT_Request_Duration_Policy::request_duration_value (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +TAO_FT_Request_Duration_Policy::request_duration_policy_value (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) ACE_THROW_SPEC ((CORBA::SystemException)) { return this->request_duration_; diff --git a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Policy_i.h b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Policy_i.h index 0b1b93f1866..74417f96e50 100644 --- a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Policy_i.h +++ b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Policy_i.h @@ -5,7 +5,7 @@ * * $Id$ * - * @author Bala Natarajan <bala@cs.wustl.edu> + * @author Balachandran Natarajan <bala@cs.wustl.edu> */ //============================================================================= @@ -23,10 +23,6 @@ #pragma warning(disable:4250) #endif /* _MSC_VER */ -// @@ This class inherits from TAO_Local_RefCounted_Object as the -// functionality outlined in the spec seems to indicate that. I could -// very well be wrong - Bala - /** * @class TAO_FT_Request_Duration_Policy * @@ -63,7 +59,7 @@ public: virtual TAO_FT_Request_Duration_Policy *clone (void) const; // = The FT::RequestDurationPolicy methods - virtual TimeBase::TimeT request_duration_value (ACE_ENV_SINGLE_ARG_DECL) + virtual TimeBase::TimeT request_duration_policy_value (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)); virtual CORBA::PolicyType policy_type ( @@ -209,7 +205,7 @@ private: #endif /* _MSC_VER */ #if defined (__ACE_INLINE__) -#include "FT_Policy_i.i" +#include "FT_Policy_i.inl" #endif /* __ACE_INLINE__ */ diff --git a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Policy_i.inl b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Policy_i.inl new file mode 100644 index 00000000000..579d6c3467b --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Policy_i.inl @@ -0,0 +1,73 @@ +//$Id$ +ACE_INLINE +TAO_FT_Request_Duration_Policy::TAO_FT_Request_Duration_Policy (const TimeBase::TimeT &duration) + :ACE_NESTED_CLASS (CORBA, Object) () + , ACE_NESTED_CLASS (CORBA, Policy) () + , ACE_NESTED_CLASS (CORBA, LocalObject) () + , TAO_Local_RefCounted_Object () + , request_duration_ (duration) +{ +} + +ACE_INLINE +TAO_FT_Request_Duration_Policy::TAO_FT_Request_Duration_Policy (const TAO_FT_Request_Duration_Policy &rhs) + :ACE_NESTED_CLASS (CORBA, Object) () + , ACE_NESTED_CLASS (CORBA, Policy) () + , ACE_NESTED_CLASS (CORBA, LocalObject) () + , FT::RequestDurationPolicy () + , TAO_Local_RefCounted_Object () + , request_duration_ (rhs.request_duration_) +{ +} + +ACE_INLINE +TAO_FT_Heart_Beat_Policy::TAO_FT_Heart_Beat_Policy ( + const CORBA::Boolean heartbeat, + const TimeBase::TimeT &interval, + const TimeBase::TimeT &timeout) + : ACE_NESTED_CLASS (CORBA, Object) () + , ACE_NESTED_CLASS (CORBA, Policy) () + , ACE_NESTED_CLASS (CORBA, LocalObject) () + , TAO_Local_RefCounted_Object () + , heartbeat_ (heartbeat) + , heartbeat_interval_ (interval) + , heartbeat_timeout_ (timeout) +{ +} + +ACE_INLINE +TAO_FT_Heart_Beat_Policy::TAO_FT_Heart_Beat_Policy (const TAO_FT_Heart_Beat_Policy &rhs) + : ACE_NESTED_CLASS (CORBA, Object) () + , ACE_NESTED_CLASS (CORBA, Policy) () + , ACE_NESTED_CLASS (CORBA, LocalObject) () + , FT::HeartbeatPolicy () + , TAO_Local_RefCounted_Object () + , heartbeat_ (rhs.heartbeat_) + , heartbeat_interval_ (rhs.heartbeat_interval_) + , heartbeat_timeout_ (rhs.heartbeat_timeout_) +{ +} + + +ACE_INLINE +TAO_FT_Heart_Beat_Enabled_Policy::TAO_FT_Heart_Beat_Enabled_Policy ( + const CORBA::Boolean heartbeat) + : ACE_NESTED_CLASS (CORBA, Object) () + , ACE_NESTED_CLASS (CORBA, Policy) () + , ACE_NESTED_CLASS (CORBA, LocalObject) () + , TAO_Local_RefCounted_Object () + , heartbeat_enabled_value_ (heartbeat) +{ +} + +ACE_INLINE +TAO_FT_Heart_Beat_Enabled_Policy::TAO_FT_Heart_Beat_Enabled_Policy ( + const TAO_FT_Heart_Beat_Enabled_Policy &rhs) + : ACE_NESTED_CLASS (CORBA, Object) () + , ACE_NESTED_CLASS (CORBA, Policy) () + , ACE_NESTED_CLASS (CORBA, LocalObject) () + , FT::HeartbeatEnabledPolicy () + , TAO_Local_RefCounted_Object () + , heartbeat_enabled_value_ (rhs.heartbeat_enabled_value_) +{ +} diff --git a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Service_Callbacks.cpp b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Service_Callbacks.cpp index 3a55444d597..f3e9ca56942 100644 --- a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Service_Callbacks.cpp +++ b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Service_Callbacks.cpp @@ -40,92 +40,6 @@ TAO_FT_Service_Callbacks::~TAO_FT_Service_Callbacks (void) delete this->profile_lock_; } - -CORBA::Boolean -TAO_FT_Service_Callbacks::select_profile (TAO_MProfile * /*mpfile*/, - TAO_Profile *& /*pfile*/) -{ - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) This method has been deprecated \n")); - - return 0; -} - -CORBA::Boolean -TAO_FT_Service_Callbacks::reselect_profile (TAO_Stub * /*stub*/, - TAO_Profile *& /*pfile*/) -{ -#if 0 - - // @@todo: This needs to go after sometime.. - // Note: We are grabbing the lock very early. We can still delay - // that. I will address this when I get around for the next round of - // improvements. - - // Grab the lock - ACE_MT (ACE_GUARD_RETURN (ACE_Lock, - guard, - *this->profile_lock_, - 0)); - - // This method is essentially called before the Stub Object gives up - // on invocation. We should only do this - // 1) Check whether the first in the list or the profile_in_use () - // is NOT a primary. If it had been so, we would have parsed the - // whole IOR list - // 2) Then set the first profile for invocation - - // A secondary was already selected, so dont do that again. - if (this->secondary_set_) - return 0; - - IOP::TaggedComponent tagged_component; - tagged_component.tag = IOP::TAG_FT_PRIMARY; - - TAO_Profile *profile = stub->profile_in_use (); - - // Get the tagged component from the profile - TAO_Tagged_Components &pfile_tagged = - profile->tagged_components (); - - // Search for the TaggedComponent that we want - if (pfile_tagged.get_component (tagged_component) == 1) - { - // We just return here as we would have parsed the whole IOR list - return 0; - } - - // As the first is not a primary, it should be a secondary, we will - // set that for invocation. - pfile = profile; - - // Set the primary_failed_ flag - this->primary_failed_ = 1; - this->secondary_set_ = 1; - - return 1; - -#endif /*if 0*/ - - return 0; -} - -void -TAO_FT_Service_Callbacks::reset_profile_flags (void) -{ -#if 0 - // Grab the lock - ACE_MT (ACE_GUARD (ACE_Lock, - guard, - *this->profile_lock_)); - - // Reset the flags that we may have - this->primary_failed_ = 0; - this->secondary_set_ = 0; -#endif /*if 0*/ -} - - CORBA::Boolean TAO_FT_Service_Callbacks::object_is_nil (CORBA::Object_ptr obj) { @@ -156,217 +70,99 @@ TAO_FT_Service_Callbacks::object_is_nil (CORBA::Object_ptr obj) } - -void -TAO_FT_Service_Callbacks::service_context_list ( - TAO_Stub *&stub, - IOP::ServiceContextList &service_list, - CORBA::Boolean restart - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) +CORBA::Boolean +TAO_FT_Service_Callbacks::is_profile_equivalent (const TAO_Profile *this_p, + const TAO_Profile *that_p) { + // At this point we assume that all the checks for other things + // within the profiles have been satisfied + const TAO_Tagged_Components &this_comp = + this_p->tagged_components (); - // If the restart flag is true, then this call for a - // reinvocation. We need not prepare the Service Context List once - // again. We can use the already existing one. - if (!restart) - { - // Pack the group version service context - this->group_version_service_context (stub, - service_list - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - // Pack the request service context - this->request_service_context (stub, - service_list - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - } + const TAO_Tagged_Components &that_comp = + that_p->tagged_components (); - return; -} + IOP::TaggedComponent this_tc, that_tc; + this_tc.tag = that_tc.tag = IOP::TAG_FT_GROUP; -void -TAO_FT_Service_Callbacks::request_service_context ( - TAO_Stub *&stub, - IOP::ServiceContextList &service_list - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - TAO_OutputCDR cdr; - if (cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER) - == 0) - ACE_THROW (CORBA::MARSHAL ()); - - // Marshall the data in to the CDR streams - if (cdr << - stub->orb_core ()->fault_tolerance_service ().client_id ().c_str () - == 0) - ACE_THROW (CORBA::MARSHAL ()); - - if (cdr << - stub->orb_core ()->fault_tolerance_service ().retention_id () - == 0) - ACE_THROW (CORBA::MARSHAL ()); - - - // Check whether the FT::RequestDurationPolicy has been set - CORBA::Policy_var policy = - stub->get_policy (FT::REQUEST_DURATION_POLICY - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - // @@ There are two possibilities a) Duration policy has not been - // set b)Duration policy has been set. Point 'b' will give no - // problems. Some issues kick in for point 'a'. The best is to set a - // default value. BUT, what is the "right" value? Need to discuss - // this with Andy when I get a chance. For the present let us assume - // we have 15 seconds. This is purely an assumption.. - - TimeBase::TimeT exp_time = 0; - - // if we have a non-null policy set - if (!CORBA::is_nil (policy.in ()) && - policy->policy_type () == FT::REQUEST_DURATION_POLICY) + if ((this_comp.get_component (this_tc) == 1) && + (that_comp.get_component (that_tc) == 1)) { - FT::RequestDurationPolicy_var duration_policy = - FT::RequestDurationPolicy::_narrow (policy.in ()); - - exp_time = - duration_policy->request_duration_value (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK; + TAO_InputCDR this_cdr (ACE_reinterpret_cast (const char*, + this_tc.component_data.get_buffer ()), + this_tc.component_data.length ()); + + TAO_InputCDR that_cdr (ACE_reinterpret_cast (const char*, + that_tc.component_data.get_buffer ()), + that_tc.component_data.length ()); + + CORBA::Boolean this_byte_order; + CORBA::Boolean that_byte_order; + + if ((this_cdr >> ACE_InputCDR::to_boolean (this_byte_order) == 0) || + (that_cdr >> ACE_InputCDR::to_boolean (that_byte_order) == 0)) + { + // return no equivalent + return 0; + } + + this_cdr.reset_byte_order (ACE_static_cast (int, this_byte_order)); + that_cdr.reset_byte_order (ACE_static_cast (int, that_byte_order)); + + + FT::TagFTGroupTaggedComponent this_group_component; + FT::TagFTGroupTaggedComponent that_group_component; + + this_cdr >> this_group_component; + that_cdr >> that_group_component; + + // check if domain id and group id are the same + if ((ACE_OS::strcmp (this_group_component.ft_domain_id, + that_group_component.ft_domain_id) == 0) && + (this_group_component.object_group_id == + that_group_component.object_group_id)) + { + return 1; + } } - else - { - // The assumption that we are making - exp_time = 15 * 10000000; - } - - // Calculaton of the expiration time - - // @@ Note: This is so poorly defined in the spec. All that the - // @@ spec says is that add the RequestDurationPolicy value with - // @@ the 'local clock value', whatever the local clock - // @@ means. IMHO, we need something like UTC value or a more clear - // @@ definition to send across the wire. - - // Grab the localtime on the machine where this is running - ACE_Time_Value time_val = ACE_OS::gettimeofday (); - - - TimeBase::TimeT sec_part = time_val.sec () * 10000000; - TimeBase::TimeT usec_part = time_val.usec ()* 10; - - // Now we have the total time - exp_time += sec_part + usec_part; - - - // Marshall the TimeBase::TimeT in to the CDR stream - if (cdr << exp_time == 0) - ACE_THROW (CORBA::MARSHAL ()); - - // Add the CDR encapsulation in to the ServiceContextList - CORBA::ULong l = service_list.length (); - service_list.length (l + 1); - service_list[l].context_id = IOP::FT_REQUEST; - - // Make a *copy* of the CDR stream... - CORBA::ULong length = ACE_static_cast (CORBA::ULong, cdr.total_length ()); - service_list[l].context_data.length (length); - CORBA::Octet *buf = service_list[l].context_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 (); - } - - return; -} - - -void -TAO_FT_Service_Callbacks::group_version_service_context ( - TAO_Stub *&stub, - IOP::ServiceContextList &service_list - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - TAO_OutputCDR cdr; - if (cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER) - == 0) - ACE_THROW (CORBA::MARSHAL ()); - - if (!this->group_component_flag_) - this->get_object_group_version (stub->profile_in_use ()); - - // Marshall the data in to the CDR streams - // Marshall the TimeBase::TimeT in to the CDR stream - if (cdr << this->group_component_ == 0) - ACE_THROW (CORBA::MARSHAL ()); - - // Add the CDR encapsulation in to the ServiceContextList - CORBA::ULong l = service_list.length (); - service_list.length (l + 1); - service_list[l].context_id = IOP::FT_GROUP_VERSION; - - // Make a *copy* of the CDR stream... - CORBA::ULong length = ACE_static_cast (CORBA::ULong, cdr.total_length ()); - service_list[l].context_data.length (length); - CORBA::Octet *buf = service_list[l].context_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 (); - } - - return; + return 0; } - -void -TAO_FT_Service_Callbacks::get_object_group_version (TAO_Profile *profile) +CORBA::ULong +TAO_FT_Service_Callbacks::hash_ft (TAO_Profile *p, + CORBA::ULong max) { - // For the group version service context, we need to get the - // ObjectGroupRefVersion. So we just look at the profile in - // use. Look at the TaggedComponents in the profile in use, look for - // the TAG_FT_GROUP and get the properties. This is the general idea. + // At this point we assume that all the checks for other things + // within the profiles have been satisfied + TAO_Tagged_Components &this_comp = + p->tagged_components (); - // Get the TAO_TaggedComponents from the profile - const TAO_Tagged_Components &tagged_components = - profile->tagged_components (); + IOP::TaggedComponent tc; + tc.tag = IOP::TAG_FT_GROUP; - IOP::TaggedComponent tagged; - tagged.tag = IOP::TAG_FT_GROUP; - - // Get the TaggedComponent - // If it doesn't exist then just return - // It just means that the IOR that we got is not from a FT ORB. - if (tagged_components.get_component (tagged) != 1) - return; + if (this_comp.get_component (tc) == 0) + return 0; + // extract the group component TAO_InputCDR cdr (ACE_reinterpret_cast (const char*, - tagged.component_data.get_buffer () - ), - tagged.component_data.length ()); + tc.component_data.get_buffer ()), + tc.component_data.length ()); + CORBA::Boolean byte_order; if ((cdr >> ACE_InputCDR::to_boolean (byte_order)) == 0) - return; + { + return 0; + } + cdr.reset_byte_order (ACE_static_cast(int,byte_order)); - // Extract the group component - cdr >> this->group_component_; + FT::TagFTGroupTaggedComponent group_component; - // Set the flag - this->group_component_flag_ = 1; -} + cdr >> group_component; + return group_component.object_group_id % max; +} int TAO_FT_Service_Callbacks::raise_comm_failure ( @@ -465,28 +261,3 @@ TAO_FT_Service_Callbacks::restart_policy_check ( // Failure return 0; } - - -void -TAO_FT_Service_Callbacks::service_log_msg_rcv ( - TAO_Message_State_Factory & /*state*/) -{ - // Oscar & ANDY to fill up - return; -} - -void -TAO_FT_Service_Callbacks::service_log_msg_pre_upcall ( - TAO_ServerRequest & /*req*/) -{ - // Oscar & ANDY to fill up - return; -} - -void -TAO_FT_Service_Callbacks::service_log_msg_post_upcall ( - TAO_ServerRequest & /*req*/) -{ - // Oscar & ANDY to fill up - return; -} diff --git a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Service_Callbacks.h b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Service_Callbacks.h index 6d75472057b..c6fea69b413 100644 --- a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Service_Callbacks.h +++ b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Service_Callbacks.h @@ -6,7 +6,7 @@ * * A concrete FT service callback implementation * - * @author Bala Natarajan <bala@cs.wustl.edu> + * @author Balachandran Natarajan <bala@cs.wustl.edu> */ //============================================================================= @@ -45,39 +45,16 @@ public: /// Dtor virtual ~TAO_FT_Service_Callbacks (void); - /// @deprecated The following method has been deprecated. Will go after TAO - /// 1.2.1. - /// This method would search the list of <mprofile> to identify a - /// TAG_FT_PRIMARY and set that profile as <pfile>. - virtual CORBA::Boolean select_profile (TAO_MProfile *mprofile, - TAO_Profile *&pfile); - - /// @deprecated The following method has been deprecated. Will go after TAO - /// 1.2.1. - virtual CORBA::Boolean reselect_profile (TAO_Stub* stub, - TAO_Profile *&pfile); - - // This method would search the IOR list for the first non-primary - // in case of primary failure. - - /// @deprecated The following method has been deprecated. Will go after TAO - /// 1.2.1. - /// Reset any of the local flags that we may have - virtual void reset_profile_flags (void); - /// Check whether <obj> is nil or not. FT spec suggests some /// extensions for a CORBA::is_nil () operation. virtual CORBA::Boolean object_is_nil (CORBA::Object_ptr obj); - // Need to do is_equivalent and hash also here - - virtual void service_context_list (TAO_Stub *&stub, - IOP::ServiceContextList &service_list, - CORBA::Boolean restart - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)); - - // Add relevant stuff to the service context list + /// Check for equivalency of the two profiles + virtual CORBA::Boolean is_profile_equivalent (const TAO_Profile *, + const TAO_Profile *); + /// Calculate the hash + virtual CORBA::ULong hash_ft (TAO_Profile *p, + CORBA::ULong m); /// Check whether we need to raise an exception or go for a /// reinvocaton. @@ -93,34 +70,8 @@ public: TAO_Profile *profile ACE_ENV_ARG_DECL); - /// Log the message. The message state is the message on the server - /// after it has been received in the GIOP layer - virtual void service_log_msg_rcv ( - TAO_Message_State_Factory &state); - - virtual void service_log_msg_pre_upcall ( - TAO_ServerRequest &req); - - virtual void service_log_msg_post_upcall ( - TAO_ServerRequest &req); - private: - /// Makes the request service_context list - void request_service_context (TAO_Stub *&stub, - IOP::ServiceContextList &service_list - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)); - - /// Make the group version service context list - void group_version_service_context (TAO_Stub *&stub, - IOP::ServiceContextList &service_list - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)); - - /// Get the ObjectGroupRef version from the profile in use. - void get_object_group_version (TAO_Profile *profile); - /// Check whether the right flags are available so that we can issue a /// restart. CORBA::Boolean restart_policy_check (IOP::ServiceContextList &service_list, diff --git a/TAO/orbsvcs/orbsvcs/Makefile.FTORB b/TAO/orbsvcs/orbsvcs/Makefile.FTORB index 3d5f6060647..cf81fe4e560 100644 --- a/TAO/orbsvcs/orbsvcs/Makefile.FTORB +++ b/TAO/orbsvcs/orbsvcs/Makefile.FTORB @@ -43,6 +43,7 @@ CPP_SRCS += \ FaultTolerance/FT_Invocation_Endpoint_Selectors \ FaultTolerance/FT_Service_Activate \ FaultTolerance/FT_ORBInitializer \ + FaultTolerance/FT_ClientRequest_Interceptor \ FaultTolerance/FT_PolicyFactory \ FaultTolerance/FT_Policy_i diff --git a/TAO/tao/IIOP_Profile.cpp b/TAO/tao/IIOP_Profile.cpp index ac517728ce0..17c9ef31e3a 100644 --- a/TAO/tao/IIOP_Profile.cpp +++ b/TAO/tao/IIOP_Profile.cpp @@ -254,6 +254,9 @@ TAO_IIOP_Profile::is_equivalent (const TAO_Profile *other_profile) return 0; } + if (!TAO_Profile::is_profile_equivalent_i (other_profile)) + return 0; + return 1; } @@ -282,6 +285,8 @@ TAO_IIOP_Profile::hash (CORBA::ULong max hashval += ok[3]; } + hashval += TAO_Profile::hash_service_i (max); + return hashval % max; } diff --git a/TAO/tao/ORB_Core.cpp b/TAO/tao/ORB_Core.cpp index 05c0bba9b85..fbe6916a9ec 100644 --- a/TAO/tao/ORB_Core.cpp +++ b/TAO/tao/ORB_Core.cpp @@ -65,7 +65,6 @@ ACE_RCSID (tao, ORB_Core, "$Id$") - // **************************************************************** CORBA::Environment& @@ -1456,19 +1455,7 @@ TAO_ORB_Core::service_context_list ( CORBA::Boolean restart ACE_ENV_ARG_DECL) { - // @@ We look at the services if they are loaded. But if more - // services offer this feature we may want to keep expanding the - // 'if' conditions with a check for whether a service returned a - // valid Policy object. - if (this->ft_service_.service_callback ()) - { - this->ft_service_.service_callback ()->service_context_list (stub, - service_context.service_info (), - restart - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - } - + // @NOTE: Can use Interceptors instead.. this->protocols_hooks_->rt_service_context (stub, service_context, restart diff --git a/TAO/tao/ORB_Core.h b/TAO/tao/ORB_Core.h index 535e24802ad..6372de12fd6 100644 --- a/TAO/tao/ORB_Core.h +++ b/TAO/tao/ORB_Core.h @@ -825,12 +825,28 @@ public: void reset_service_profile_flags (void); /** - * The loaded service would determineif the CORBA::Object_ptr is - * actually nill or not. This would be useful to accomodate new + * The loaded service would determine if the CORBA::Object_ptr is + * actually nil or not. This would be useful to accomodate new * enhanced definitions as defined by the service specification. */ CORBA::Boolean object_is_nil (CORBA::Object_ptr object); + /// Hook for the services to determine whether the profiles are + /// equivalent or not. + /** + * For details on how this is used please see the FT service + */ + CORBA::Boolean is_profile_equivalent (const TAO_Profile *this_p, + const TAO_Profile *that_p); + + /// Hook for the services to determine the <hash> value of a + /// profile. + /** + * For details on how this is used please see the FT service + */ + CORBA::ULong hash_service (TAO_Profile *this_p, + CORBA::ULong max); + /// Call the service layers with the Service Context to check /// whether they would like to add something to the list. void service_context_list (TAO_Stub *stub, @@ -854,18 +870,6 @@ public: int service_raise_transient_failure (TAO_GIOP_Invocation *invoke, TAO_Profile *profile ACE_ENV_ARG_DECL); - - /// Hook for logging of messages by the Logging & Recovery service - /// of an FT service. - void services_log_msg_rcv (TAO_Message_State_Factory &state); - - /// Hook for logging of messages by the Logging & Recovery service - /// of an FT service. - void services_log_msg_pre_upcall (TAO_ServerRequest &req); - - /// Hook for logging of messages by the Logging & Recovery service - /// of an FT service. - void services_log_msg_post_upcall (TAO_ServerRequest &req); //@} /** diff --git a/TAO/tao/ORB_Core.i b/TAO/tao/ORB_Core.i index 428ed636ff9..478a3586ea9 100644 --- a/TAO/tao/ORB_Core.i +++ b/TAO/tao/ORB_Core.i @@ -124,34 +124,33 @@ TAO_ORB_Core::object_is_nil (CORBA::Object_ptr obj) } - -ACE_INLINE void -TAO_ORB_Core:: services_log_msg_rcv (TAO_Message_State_Factory &state) +ACE_INLINE CORBA::Boolean +TAO_ORB_Core::is_profile_equivalent (const TAO_Profile *this_p, + const TAO_Profile *that_p) { - if (this->ft_service_.service_callback ()) - { - this->ft_service_.service_callback ()->service_log_msg_rcv (state); - } -} + CORBA::Boolean retval = 0; -ACE_INLINE void -TAO_ORB_Core:: services_log_msg_pre_upcall (TAO_ServerRequest &req) -{ - if (this->ft_service_.service_callback ()) - { - this->ft_service_.service_callback ()->service_log_msg_pre_upcall (req); - } + if (this->ft_service_.service_callback ()) + { + retval = + this->ft_service_.service_callback ()->is_profile_equivalent (this_p, + that_p); + } + + return retval; } -ACE_INLINE void -TAO_ORB_Core:: services_log_msg_post_upcall (TAO_ServerRequest &req) +ACE_INLINE CORBA::ULong +TAO_ORB_Core::hash_service (TAO_Profile *p, + CORBA::ULong m) { - if (this->ft_service_.service_callback ()) - { - this->ft_service_.service_callback ()->service_log_msg_post_upcall (req); - } -} + if (this->ft_service_.service_callback ()) + { + return this->ft_service_.service_callback ()->hash_ft (p, m); + } + return 0; +} ACE_INLINE TAO_Fault_Tolerance_Service & TAO_ORB_Core::fault_tolerance_service (void) @@ -159,7 +158,6 @@ TAO_ORB_Core::fault_tolerance_service (void) return this->ft_service_; } - ACE_INLINE ACE_Thread_Manager * TAO_ORB_Core::thr_mgr (void) { diff --git a/TAO/tao/PortableServer/Servant_Base.cpp b/TAO/tao/PortableServer/Servant_Base.cpp index c1b02827c15..6ed972572d8 100644 --- a/TAO/tao/PortableServer/Servant_Base.cpp +++ b/TAO/tao/PortableServer/Servant_Base.cpp @@ -216,16 +216,6 @@ void TAO_ServantBase::synchronous_upcall_dispatch (TAO_ServerRequest &req, ACE_TRY { - // @@ Do we really need the following "callback?" The - // STANDARD receive_request_service_contexts() interception - // point appears to be placed at around the same point in the - // upcall, i.e. just before the upcall is dispatched. It is - // slightly earlier than this callback function(). It also - // potentially provides more information than is available in - // this callback. - // -Ossama - req.orb_core ()->services_log_msg_pre_upcall (req); - // Invoke the skeleton, it will demarshal the arguments, // invoke the right operation on the skeleton class // (<derived_this>), and marshal any results. @@ -238,16 +228,6 @@ void TAO_ServantBase::synchronous_upcall_dispatch (TAO_ServerRequest &req, // It is our job to send the already marshaled reply, but only // send if it is expected and it has not already been sent - // @@ Same here... - // Do we really need the following "callback?" The - // STANDARD send_reply()/send_other()/send_exception - // interception points appear to do the same thing. They - // even provide more information than is available in this - // callback. - // -Ossama - // Log the message state to FT_Service Logging facility - req.orb_core ()->services_log_msg_post_upcall (req); - // We send the reply only if it is NOT a SYNC_WITH_SERVER, a // response is expected and if the reply is not deferred. if (send_reply) @@ -298,16 +278,6 @@ void TAO_ServantBase::asynchronous_upcall_dispatch (TAO_ServerRequest &req, ACE_TRY { - // @@ Do we really need the following "callback?" The - // STANDARD receive_request_service_contexts() interception - // point appears to be placed at around the same point in the - // upcall, i.e. just before the upcall is dispatched. It is - // slightly earlier than this callback function(). It also - // potentially provides more information than is available in - // this callback. - // -Ossama - req.orb_core ()->services_log_msg_pre_upcall (req); - // Invoke the skeleton, it will demarshal the arguments, // invoke the right operation on the skeleton class // (<derived_this>), and marshal any results. @@ -320,16 +290,6 @@ void TAO_ServantBase::asynchronous_upcall_dispatch (TAO_ServerRequest &req, // It is our job to send the already marshaled reply, but only // send if it is expected and it has not already been sent - // @@ Same here... - // Do we really need the following "callback?" The - // STANDARD send_reply()/send_other()/send_exception - // interception points appear to do the same thing. They - // even provide more information than is available in this - // callback. - // -Ossama - // Log the message state to FT_Service Logging facility - req.orb_core ()->services_log_msg_post_upcall (req); - // Return immediately. Do not send a reply; this is an // asunchronous upcall. (unless, of course there is a system // exception. diff --git a/TAO/tao/Profile.cpp b/TAO/tao/Profile.cpp index a74a5a432a8..35dcbc78f46 100644 --- a/TAO/tao/Profile.cpp +++ b/TAO/tao/Profile.cpp @@ -667,6 +667,20 @@ TAO_Profile::parse_string (const char *ior ACE_ENV_ARG_PARAMETER); } +CORBA::Boolean +TAO_Profile::is_profile_equivalent_i (const TAO_Profile *other) +{ + return this->orb_core_->is_profile_equivalent (this, + other); +} + + +CORBA::ULong +TAO_Profile::hash_service_i (CORBA::ULong m) +{ + return this->orb_core_->hash_service (this, m); +} + // **************************************************************** TAO_Unknown_Profile::TAO_Unknown_Profile (CORBA::ULong tag, diff --git a/TAO/tao/Profile.h b/TAO/tao/Profile.h index 881602e9366..50596b1fb75 100644 --- a/TAO/tao/Profile.h +++ b/TAO/tao/Profile.h @@ -13,6 +13,7 @@ #ifndef TAO_PROFILE_H #define TAO_PROFILE_H #include /**/ "ace/pre.h" + #include "tao/Tagged_Components.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) @@ -263,6 +264,12 @@ protected: /// tagged_components. void set_tagged_components (TAO_OutputCDR &cdr); + /// Helper method that tries determining the equivalent profiles for + /// different services. + CORBA::Boolean is_profile_equivalent_i (const TAO_Profile *); + + CORBA::ULong hash_service_i (CORBA::ULong m); + private: /// this object keeps ownership of this object diff --git a/TAO/tao/Service_Callbacks.cpp b/TAO/tao/Service_Callbacks.cpp index def615b2bae..47d3d716d75 100644 --- a/TAO/tao/Service_Callbacks.cpp +++ b/TAO/tao/Service_Callbacks.cpp @@ -45,14 +45,18 @@ TAO_Service_Callbacks::reset_profile_flags (void) } -void -TAO_Service_Callbacks::service_context_list ( - TAO_Stub *& /*stub*/ , - IOP::ServiceContextList & /*service_list*/, - CORBA::Boolean - ACE_ENV_ARG_DECL_NOT_USED) +CORBA::Boolean +TAO_Service_Callbacks::is_profile_equivalent (const TAO_Profile *, + const TAO_Profile *) { - return; + return 0; +} + +CORBA::ULong +TAO_Service_Callbacks::hash_ft (TAO_Profile *, + CORBA::ULong ) +{ + return 0; } int @@ -82,26 +86,3 @@ TAO_Service_Callbacks::raise_transient_failure ( CORBA::COMPLETED_MAYBE), 2); } - -void -TAO_Service_Callbacks::service_log_msg_rcv ( - TAO_Message_State_Factory & /*state*/) -{ - return; -} - - -void -TAO_Service_Callbacks::service_log_msg_pre_upcall ( - TAO_ServerRequest & /*req*/) -{ - return; -} - - -void -TAO_Service_Callbacks::service_log_msg_post_upcall ( - TAO_ServerRequest & /*req*/) -{ - return; -} diff --git a/TAO/tao/Service_Callbacks.h b/TAO/tao/Service_Callbacks.h index 68d1cb27dcf..209398a39b6 100644 --- a/TAO/tao/Service_Callbacks.h +++ b/TAO/tao/Service_Callbacks.h @@ -65,12 +65,13 @@ public: virtual CORBA::Boolean object_is_nil (CORBA::Object_ptr obj); - /// Allow the services to add service specific service context - /// information. - virtual void service_context_list (TAO_Stub *&stub, - IOP::ServiceContextList &service_list, - CORBA::Boolean restart - ACE_ENV_ARG_DECL); + /// Check for equivalency of the two profiles + virtual CORBA::Boolean is_profile_equivalent (const TAO_Profile *, + const TAO_Profile *); + + /// Calculate the hash value.. + virtual CORBA::ULong hash_ft (TAO_Profile *p, + CORBA::ULong m); /// Allow the service layer to decide whether the COMM_FAILURE /// exception should be thrown or a reinvocation is needed @@ -83,29 +84,6 @@ public: virtual int raise_transient_failure (TAO_GIOP_Invocation *invoke, TAO_Profile *profile ACE_ENV_ARG_DECL); - - - /** - * Send the message state to the FT service for logging. This hook - * sends the message state after the server receives the - * message. The message at this point has been verified that it is a - * GIOP message. - */ - virtual void service_log_msg_rcv (TAO_Message_State_Factory &state); - - /** - * Send the message state to the FT service for logging. This hook - * sends the message state after the POA receives upcall but just - * before the call has been dispatched to the servant - */ - virtual void service_log_msg_pre_upcall (TAO_ServerRequest &req); - - /** - * Send the message state to the FT service for logging. This hook - * sends the message state just before the reply is ready to be - * dispatched. - */ - virtual void service_log_msg_post_upcall (TAO_ServerRequest &req); }; diff --git a/TAO/tao/Strategies/DIOP_Profile.cpp b/TAO/tao/Strategies/DIOP_Profile.cpp index 12f9a071c8c..f53249f4450 100644 --- a/TAO/tao/Strategies/DIOP_Profile.cpp +++ b/TAO/tao/Strategies/DIOP_Profile.cpp @@ -245,6 +245,9 @@ TAO_DIOP_Profile::is_equivalent (const TAO_Profile *other_profile) return 0; } + if (!this->is_profile_equivalent_i (other_profile)) + return 0; + return 1; } @@ -273,6 +276,8 @@ TAO_DIOP_Profile::hash (CORBA::ULong max hashval += ok[3]; } + hashval += this->hash_service_i (max); + return hashval % max; } diff --git a/TAO/tao/Strategies/SCIOP_Profile.cpp b/TAO/tao/Strategies/SCIOP_Profile.cpp index c606c75a61a..05e5c7a4776 100644 --- a/TAO/tao/Strategies/SCIOP_Profile.cpp +++ b/TAO/tao/Strategies/SCIOP_Profile.cpp @@ -264,6 +264,9 @@ TAO_SCIOP_Profile::is_equivalent (const TAO_Profile *other_profile) return 0; } + if (!this->is_profile_equivalent_i (other_profile)) + return 0; + return 1; } @@ -292,6 +295,8 @@ TAO_SCIOP_Profile::hash (CORBA::ULong max hashval += ok[3]; } + hashval += this->hash_service_i (max); + return hashval % max; } diff --git a/TAO/tao/Strategies/SHMIOP_Profile.cpp b/TAO/tao/Strategies/SHMIOP_Profile.cpp index ef2656bd55d..e315abe4dd8 100644 --- a/TAO/tao/Strategies/SHMIOP_Profile.cpp +++ b/TAO/tao/Strategies/SHMIOP_Profile.cpp @@ -292,6 +292,9 @@ TAO_SHMIOP_Profile::is_equivalent (const TAO_Profile *other_profile) return 0; } + if (!this->is_profile_equivalent_i (other_profile)) + return 0; + return 1; } @@ -320,6 +323,8 @@ TAO_SHMIOP_Profile::hash (CORBA::ULong max hashval += ok[3]; } + hashval += this->hash_service_i (max); + return hashval % max; } diff --git a/TAO/tao/Strategies/UIOP_Profile.cpp b/TAO/tao/Strategies/UIOP_Profile.cpp index 20cb07c56a0..e21481f8f2f 100644 --- a/TAO/tao/Strategies/UIOP_Profile.cpp +++ b/TAO/tao/Strategies/UIOP_Profile.cpp @@ -169,6 +169,9 @@ TAO_UIOP_Profile::is_equivalent (const TAO_Profile *other_profile) return 0; } + if (!this->is_profile_equivalent_i (other_profile)) + return 0; + return 1; } @@ -197,6 +200,8 @@ TAO_UIOP_Profile::hash (CORBA::ULong max hashval += ok[3]; } + hashval += this->hash_service_i (max); + return hashval % max; } |