diff options
author | bala <balanatarajan@users.noreply.github.com> | 2000-09-29 17:10:30 +0000 |
---|---|---|
committer | bala <balanatarajan@users.noreply.github.com> | 2000-09-29 17:10:30 +0000 |
commit | 31cb46f0a2ad50cb78ea6b6ec0452accf79fd018 (patch) | |
tree | 98f8b4e38d037cfedd0cd3fad2733244bce99b9f /TAO/orbsvcs | |
parent | 59b6415d1e4fc6fa2b2d59c4981409802e82e054 (diff) | |
download | ATCD-31cb46f0a2ad50cb78ea6b6ec0452accf79fd018.tar.gz |
ChangeLogTag: Fri Sep 29 11:30:13 2000 Balachandran Natarajan <bala@cs.wustl.edu>
Diffstat (limited to 'TAO/orbsvcs')
7 files changed, 483 insertions, 4 deletions
diff --git a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Policy_i.cpp b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Policy_i.cpp new file mode 100644 index 00000000000..58113f94c17 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Policy_i.cpp @@ -0,0 +1,90 @@ +//$Id$ +#include "FT_Policy_i.h" + + +#if !defined (__ACE_INLINE__) +#include "FT_Policy_i.i" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(FaultTolerance, FT_Policy_i, "$Id$") + +TimeBase::TimeT +TAO_FT_Request_Duration_Policy::request_duration_value (CORBA::Environment &) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return this->request_duration_; +} + +CORBA::PolicyType +TAO_FT_Request_Duration_Policy::policy_type (CORBA_Environment &) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return FT::REQUEST_DURATION_POLICY; +} + +CORBA::Policy_ptr +TAO_FT_Request_Duration_Policy::create (const CORBA::Any& val, + CORBA::Environment &ACE_TRY_ENV) +{ + TimeBase::TimeT value; + if ((val >>= value) == 0) + ACE_THROW_RETURN (CORBA::PolicyError (CORBA::BAD_POLICY_TYPE), + CORBA::Policy::_nil ()); + + TAO_FT_Request_Duration_Policy *tmp; + ACE_NEW_THROW_EX (tmp, + TAO_FT_Request_Duration_Policy (value), + CORBA::NO_MEMORY (TAO_DEFAULT_MINOR_CODE, + CORBA::COMPLETED_NO)); + ACE_CHECK_RETURN (CORBA::Policy::_nil ()); + + return tmp; +} + +TAO_FT_Request_Duration_Policy * +TAO_FT_Request_Duration_Policy::clone (void) const +{ + TAO_FT_Request_Duration_Policy *copy = 0; + ACE_NEW_RETURN (copy, + TAO_FT_Request_Duration_Policy (*this), + 0); + return copy; +} + +CORBA::Policy_ptr +TAO_FT_Request_Duration_Policy::copy (CORBA_Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + TAO_FT_Request_Duration_Policy* tmp; + ACE_NEW_THROW_EX (tmp, TAO_FT_Request_Duration_Policy (*this), + CORBA::NO_MEMORY (TAO_DEFAULT_MINOR_CODE, + CORBA::COMPLETED_NO)); + ACE_CHECK_RETURN (CORBA::Policy::_nil ()); + + return tmp; +} + +void +TAO_FT_Request_Duration_Policy::destroy (CORBA_Environment &) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +void +TAO_FT_Request_Duration_Policy::set_time_value (ACE_Time_Value &time_value) +{ + TimeBase::TimeT t = this->request_duration_; + TimeBase::TimeT seconds = t / 10000000u; + TimeBase::TimeT microseconds = (t % 10000000u) / 10; + time_value.set (ACE_U64_TO_U32 (seconds), + ACE_U64_TO_U32 (microseconds)); + + if (TAO_debug_level > 0) + { + CORBA::ULong msecs = + ACE_static_cast(CORBA::ULong, microseconds / 1000); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO (%P|%t) Timeout is <%u>\n"), + msecs)); + } +} diff --git a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Policy_i.h b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Policy_i.h new file mode 100644 index 00000000000..8742a7f30ce --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Policy_i.h @@ -0,0 +1,102 @@ +/* -*- C++ -*- */ +// $Id$ +// +// ============================================================================ +// +// = LIBRARY +// FaultTolerance +// +// = DESCRIPTION +// Implementation classes for the FT related policies +// +// = FILENAME +// FT_Policy_i.h +// +// = AUTHOR +// Bala Natarajan <bala@cs.wustl.edu> +// +// ============================================================================ + +#ifndef TAO_FT_POLICY_I_H +#define TAO_FT_POLICY_I_H +#include "ace/pre.h" + +#include "orbsvcs/FT_CORBAC.h" + +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#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_Export TAO_FT_Request_Duration_Policy: + public FT::RequestDurationPolicy, + public TAO_Local_RefCounted_Object +{ + // = TITLE + // FT::RequestDurationPolicy implementation + // + // = DESCRIPTION + // This policy controls the request duration in the ORB. The + // semantics are like this. On the server side, the server should + // retain the details of the request from the client (and the + // reply sent to it too) atleast for the time period specified by + // this policy value. On the client side, the client uses this + // value to calculate the expiration_id in the RequestService + // context. The expiration_id is a sort of timeout for the client + // to keep trying to connect to server object groups under certain + // conditions + // +public: + + TAO_FT_Request_Duration_Policy (const TimeBase::TimeT& relative_expiry); + // Constructor. + + TAO_FT_Request_Duration_Policy (const TAO_FT_Request_Duration_Policy &rhs); + // Copy constructor. + + static CORBA::Policy_ptr create (const CORBA::Any& val, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()); + // Helper method for the implementation of + // CORBA::ORB::create_policy. + + virtual TAO_FT_Request_Duration_Policy *clone (void) const; + // Returns a copy of <this>. + + // = The FT::RequestDurationPolicy methods + virtual TimeBase::TimeT request_duration_value (CORBA::Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual CORBA::PolicyType policy_type ( + CORBA_Environment &ACE_TRY_ENV = TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual CORBA::Policy_ptr copy ( + CORBA_Environment &ACE_TRY_ENV = TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void destroy ( + CORBA_Environment &ACE_TRY_ENV = TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void set_time_value (ACE_Time_Value &time_value); + // Change the CORBA representation to the ACE representation. + +private: + TimeBase::TimeT request_duration_; + // The attribute +}; + + +#if defined (__ACE_INLINE__) +#include "FT_Policy_i.i" +#endif /* __ACE_INLINE__ */ + + +#include "ace/post.h" +#endif /* TAO_FT_POLICY_I_H */ diff --git a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Policy_i.i b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Policy_i.i new file mode 100644 index 00000000000..86c1d153678 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Policy_i.i @@ -0,0 +1,14 @@ +//$Id$ +ACE_INLINE +TAO_FT_Request_Duration_Policy::TAO_FT_Request_Duration_Policy (const TimeBase::TimeT &duration) + : request_duration_ (duration) +{ +} + +ACE_INLINE +TAO_FT_Request_Duration_Policy::TAO_FT_Request_Duration_Policy (const TAO_FT_Request_Duration_Policy &rhs) + : FT::RequestDurationPolicy (), + TAO_Local_RefCounted_Object (), + request_duration_ (rhs.request_duration_) +{ +} diff --git a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Service_Callbacks.cpp b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Service_Callbacks.cpp index ce8dd7d923f..80d4b2670aa 100644 --- a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Service_Callbacks.cpp +++ b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Service_Callbacks.cpp @@ -2,6 +2,7 @@ #include "tao/MProfile.h" #include "tao/Tagged_Components.h" #include "tao/Stub.h" +#include "FT_Policy_i.h" #if !defined (__ACE_INLINE__) @@ -10,6 +11,10 @@ ACE_RCSID(FaultTolerance, FT_Service_Callbacks, "$Id$") +TAO_FT_Service_Callbacks::~TAO_FT_Service_Callbacks (void) +{ +} + CORBA::Boolean TAO_FT_Service_Callbacks::select_profile (TAO_MProfile *mpfile, TAO_Profile *&pfile) @@ -111,6 +116,8 @@ TAO_FT_Service_Callbacks::reset_profile_flags (void) this->primary_failed_ = 0; this->secondary_set_ = 0; } + + CORBA::Boolean TAO_FT_Service_Callbacks::object_is_nil (CORBA::Object_ptr obj) { @@ -140,3 +147,225 @@ TAO_FT_Service_Callbacks::object_is_nil (CORBA::Object_ptr obj) return 1; } + + +CORBA::Policy_ptr +TAO_FT_Service_Callbacks::service_create_policy ( + CORBA::PolicyType type, + CORBA::Any &val, + CORBA::Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + CORBA::Policy_ptr policy = CORBA::Policy::_nil (); + + if (type == FT::REQUEST_DURATION_POLICY) + { + policy = TAO_FT_Request_Duration_Policy::create (val, + ACE_TRY_ENV); + } + + return policy; +} + +void +TAO_FT_Service_Callbacks::service_context_list ( + TAO_Stub *&stub, + IOP::ServiceContextList &service_list, + CORBA::Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + + // Pack the group version service context + this->group_version_service_context (stub, + service_list, + ACE_TRY_ENV); + ACE_CHECK; + + // Pack the request service context + this->request_service_context (stub, + service_list, + ACE_TRY_ENV); + ACE_CHECK; + + + +} + +void +TAO_FT_Service_Callbacks::request_service_context ( + TAO_Stub *&stub, + IOP::ServiceContextList &service_list, + CORBA::Environment &ACE_TRY_ENV) + 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 ().new_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_TRY_ENV); + 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 ())) + { + FT::RequestDurationPolicy_var duration_policy = + FT::RequestDurationPolicy::_narrow (policy.in ()); + + exp_time = + duration_policy->request_duration_value (ACE_TRY_ENV); + ACE_CHECK; + } + 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 = 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, + CORBA::Environment &ACE_TRY_ENV) + 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 = 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::get_object_group_version (TAO_Profile *profile) +{ + // 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. + + // Get the TAO_TaggedComponents from the profile + const TAO_Tagged_Components &tagged_components = + profile->tagged_components (); + + 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; + + TAO_InputCDR cdr (ACE_reinterpret_cast (const char*, + tagged.component_data.get_buffer () + ), + tagged.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)); + + // Extract the group component + cdr >> this->group_component_; + + // Set the flag + this->group_component_flag_ = 1; +} diff --git a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Service_Callbacks.h b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Service_Callbacks.h index d43c0142075..f7677397524 100644 --- a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Service_Callbacks.h +++ b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Service_Callbacks.h @@ -25,6 +25,8 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "tao/Service_Callbacks.h" +#include "orbsvcs/FT_CORBAC.h" + class TAO_Profile; class TAO_MProfile; @@ -41,6 +43,9 @@ public: TAO_FT_Service_Callbacks (void); // Constructor + virtual ~TAO_FT_Service_Callbacks (void); + // Dtor + virtual CORBA::Boolean select_profile (TAO_MProfile *mprofile, TAO_Profile *&pfile); // This method would search the list of <mprofile> to identify a @@ -59,10 +64,39 @@ public: // Check whether <obj> is nil or not. FT spec suggests some // extensions for a CORBA::is_nil () operation. - // Need to do is_equivalent and hash also here + + virtual CORBA::Policy_ptr service_create_policy ( + CORBA::PolicyType policy, + CORBA::Any &val, + CORBA::Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException)); + // Create a CORBA::Policy from CORBA::Policy + + virtual void service_context_list (TAO_Stub *&stub, + IOP::ServiceContextList &service_list, + CORBA::Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // Add relevant stuff to the service context list + private: + void request_service_context (TAO_Stub *&stub, + IOP::ServiceContextList &service_list, + CORBA::Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException)); + // Makes the request service_context list + + void group_version_service_context (TAO_Stub *&stub, + IOP::ServiceContextList &service_list, + CORBA::Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException)); + // Make the group version service context list + + void get_object_group_version (TAO_Profile *profile); + // Get the ObjectGroupRef version from the profile in use. + CORBA::Boolean primary_failed_; // A flag that indicates that the primary has already failed. So any // more calls to select_profile () should not reset the profile @@ -72,6 +106,13 @@ private: // A flag to indicate that a secondary has been selected for // invocation. We do this only once in the cycle. When we get there // again we dont select a primary again and again. + + FT::TagFTGroupTaggedComponent group_component_; + // FT group component in the IOGR + + CORBA::Boolean group_component_flag_; + // A flag to indicate whether we have extracted the + // <group_component> before. }; #if defined (__ACE_INLINE__) diff --git a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Service_Callbacks.i b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Service_Callbacks.i index 025965d9826..53d071f2e9d 100644 --- a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Service_Callbacks.i +++ b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Service_Callbacks.i @@ -3,7 +3,9 @@ ACE_INLINE TAO_FT_Service_Callbacks::TAO_FT_Service_Callbacks (void) : primary_failed_ (0), - secondary_set_ (0) + secondary_set_ (0), + group_component_ (), + group_component_flag_ (0) { // no-op } diff --git a/TAO/orbsvcs/orbsvcs/Makefile.FaultTolerance b/TAO/orbsvcs/orbsvcs/Makefile.FaultTolerance index c45ac4f4de6..513083c2738 100644 --- a/TAO/orbsvcs/orbsvcs/Makefile.FaultTolerance +++ b/TAO/orbsvcs/orbsvcs/Makefile.FaultTolerance @@ -14,7 +14,7 @@ SHLIB = $(LIBNAME).$(SOEXT) VPATH=.:FaultTolerance -ACE_SHLIBS = -lTAO_IORManip -lTAO_PortableServer -lTAO -lACE +ACE_SHLIBS = -lTAO_CosNaming -lTAO_CosNotification -lTAO_Svc_Utils -lTAO_IORManip -lTAO_PortableServer -lTAO -lACE #---------------------------------------------------------------------------- # Include macros and targets @@ -38,7 +38,8 @@ IDL_FILES += FT_CORBA CPP_SRCS += \ FaultTolerance/FT_Service_Callbacks \ FaultTolerance/FT_IOGR_Property \ - FaultTolerance/FT_Service_Activate + FaultTolerance/FT_Service_Activate \ + FaultTolerance/FT_Policy_i IDL_SRC = \ $(addsuffix S.cpp, $(IDL_FILES)) \ |