diff options
Diffstat (limited to 'TAO/tao/DiffServPolicy')
5 files changed, 134 insertions, 65 deletions
diff --git a/TAO/tao/DiffServPolicy/DiffServPolicy_ORBInitializer.cpp b/TAO/tao/DiffServPolicy/DiffServPolicy_ORBInitializer.cpp index 88ee37f6d69..100053ff8de 100644 --- a/TAO/tao/DiffServPolicy/DiffServPolicy_ORBInitializer.cpp +++ b/TAO/tao/DiffServPolicy/DiffServPolicy_ORBInitializer.cpp @@ -3,6 +3,7 @@ #include "tao/DiffServPolicy/DiffServPolicy_ORBInitializer.h" #include "tao/DiffServPolicy/DiffServPolicy.h" #include "tao/DiffServPolicy/DiffServPolicy_Factory.h" +#include "tao/DiffServPolicy/DiffServ_Service_Context_Handler.h" #include "tao/DiffServPolicy/DiffServ_Protocols_Hooks.h" #include "tao/ORB_Core.h" #include "tao/PI/ORBInitInfo.h" @@ -15,8 +16,29 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL void TAO_DiffServPolicy_ORBInitializer::pre_init ( - PortableInterceptor::ORBInitInfo_ptr) + PortableInterceptor::ORBInitInfo_ptr info) { + // Narrow to a TAO_ORBInitInfo object to get access to the + // orb_core() TAO extension. + TAO_ORBInitInfo_var tao_info = TAO_ORBInitInfo::_narrow (info); + + if (CORBA::is_nil (tao_info.in ())) + { + if (TAO_debug_level > 0) + ACE_ERROR ((LM_ERROR, + "(%P|%t) TAO_RT_ORBInitializer::pre_init:\n" + "(%P|%t) Unable to narrow " + "\"PortableInterceptor::ORBInitInfo_ptr\" to\n" + "(%P|%t) \"TAO_ORBInitInfo *.\"\n")); + + throw ::CORBA::INTERNAL (); + } + + // Bind the service context handler for Diffserv + TAO_DiffServ_Service_Context_Handler* h = 0; + ACE_NEW (h, + TAO_DiffServ_Service_Context_Handler()); + tao_info->orb_core ()->service_context_registry ().bind (IOP::REP_NWPRIORITY, h); } void diff --git a/TAO/tao/DiffServPolicy/DiffServ_Protocols_Hooks.cpp b/TAO/tao/DiffServPolicy/DiffServ_Protocols_Hooks.cpp index 117e4757961..e6157404590 100644 --- a/TAO/tao/DiffServPolicy/DiffServ_Protocols_Hooks.cpp +++ b/TAO/tao/DiffServPolicy/DiffServ_Protocols_Hooks.cpp @@ -32,57 +32,12 @@ TAO_DS_Network_Priority_Protocols_Hooks::init_hooks (TAO_ORB_Core *orb_core) this->orb_core_ = orb_core; } -void -TAO_DS_Network_Priority_Protocols_Hooks::np_service_context ( - TAO_Stub *stub, - TAO_Service_Context &service_context, - CORBA::Boolean restart) -{ - // 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) - { - CORBA::Policy_var cnpp = - stub->get_cached_policy (TAO_CACHED_POLICY_CLIENT_NETWORK_PRIORITY); - - if (!CORBA::is_nil (cnpp.in ())) - { - TAO::NetworkPriorityPolicy_var cnp = - TAO::NetworkPriorityPolicy::_narrow (cnpp.in ()); - - TAO::DiffservCodepoint reply_diffserv_codepoint; - reply_diffserv_codepoint = cnp->reply_diffserv_codepoint (); - - CORBA::Long rep_dscp_codepoint = reply_diffserv_codepoint; - - this->add_rep_np_service_context_hook (service_context, - rep_dscp_codepoint); - } - } -} - -void -TAO_DS_Network_Priority_Protocols_Hooks::add_rep_np_service_context_hook ( - TAO_Service_Context &service_context, - CORBA::Long &dscp_codepoint) -{ - TAO_OutputCDR cdr; - if ((cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER) == 0) - || (cdr << dscp_codepoint) == 0) - { - throw CORBA::MARSHAL (); - } - - service_context.set_context (IOP::REP_NWPRIORITY, cdr); -} - CORBA::Long TAO_DS_Network_Priority_Protocols_Hooks::get_dscp_codepoint ( TAO_Service_Context &sc) { CORBA::Long dscp_codepoint = 0; - const IOP::ServiceContext *context; + const IOP::ServiceContext *context = 0; if (sc.get_context (IOP::REP_NWPRIORITY, &context) == 1) { diff --git a/TAO/tao/DiffServPolicy/DiffServ_Protocols_Hooks.h b/TAO/tao/DiffServPolicy/DiffServ_Protocols_Hooks.h index 9e935fac90e..6645bc01ce5 100644 --- a/TAO/tao/DiffServPolicy/DiffServ_Protocols_Hooks.h +++ b/TAO/tao/DiffServPolicy/DiffServ_Protocols_Hooks.h @@ -49,7 +49,7 @@ public: CORBA::Long get_dscp_codepoint (TAO_Stub *stub, CORBA::Object *object); /// This function is used by the server side to figure out the - /// DiffServ codepoint that is attached and sent as part of the + /// DiffServ codepoint that is attached and sent as part of the /// service context of the request from the client side. /// Specifically, when CLIENT_PROPAGATED networ priority model /// is followed, the clients sent the DiffServ codepoint, they @@ -58,23 +58,6 @@ public: /// CORBA::Long get_dscp_codepoint (TAO_Service_Context &sc); - /// This function is called from the ORB_Core to add - /// network priority policy specific information on the request - /// service context. Specifically, when CLIENT_PROPAGATED network - /// priority model is used, the DiffServ codepoint that needs to be used - /// by the server side in the reply, is specified as a service context - /// entry, just like how RT-CORBA's CLIENT_PROPAGATED priority model works. - /// - void np_service_context (TAO_Stub *stub, - TAO_Service_Context &service_context, - CORBA::Boolean restart); - - /// Helper function that is used by the np_service_context () method. - /// - void add_rep_np_service_context_hook ( - TAO_Service_Context &service_context, - CORBA::Long &dscp_codepoint); - protected: TAO_ORB_Core *orb_core_; diff --git a/TAO/tao/DiffServPolicy/DiffServ_Service_Context_Handler.cpp b/TAO/tao/DiffServPolicy/DiffServ_Service_Context_Handler.cpp new file mode 100644 index 00000000000..45471cedc42 --- /dev/null +++ b/TAO/tao/DiffServPolicy/DiffServ_Service_Context_Handler.cpp @@ -0,0 +1,66 @@ +// $Id$ + +#include "tao/DiffServPolicy/DiffServ_Service_Context_Handler.h" + +ACE_RCSID (DiffServPolicy, + DiffServ_Service_Context_Handler, + "$Id$") + +#include "tao/DiffServPolicy/Client_Network_Priority_Policy.h" +#include "tao/CDR.h" +#include "tao/TAO_Server_Request.h" +#include "tao/Transport.h" +#include "tao/ORB_Core.h" +#include "tao/GIOP_Message_Base.h" +#include "tao/Operation_Details.h" +#include "tao/Transport_Mux_Strategy.h" +#include "tao/Stub.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +int +TAO_DiffServ_Service_Context_Handler::process_service_context ( + TAO_Transport&, + const IOP::ServiceContext&) +{ + return 0; +} + +int +TAO_DiffServ_Service_Context_Handler::generate_service_context ( + TAO_Stub *stub, + TAO_Transport& transport, + TAO_Operation_Details &opdetails, + TAO_Target_Specification &spec, + TAO_OutputCDR &msg) +{ + if (stub) + { + CORBA::Policy_var cnpp = + stub->get_cached_policy (TAO_CACHED_POLICY_CLIENT_NETWORK_PRIORITY); + + TAO::NetworkPriorityPolicy_var cnp = + TAO::NetworkPriorityPolicy::_narrow (cnpp.in ()); + + if (!CORBA::is_nil (cnp.in ())) + { + TAO::DiffservCodepoint const reply_diffserv_codepoint = + cnp->reply_diffserv_codepoint (); + + CORBA::Long const rep_dscp_codepoint = reply_diffserv_codepoint; + + TAO_OutputCDR cdr; + if (!(cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)) + || !(cdr << rep_dscp_codepoint)) + { + throw CORBA::MARSHAL (); + } + + opdetails.request_service_context ().set_context (IOP::REP_NWPRIORITY, cdr); + } + } + + return 0; +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/DiffServPolicy/DiffServ_Service_Context_Handler.h b/TAO/tao/DiffServPolicy/DiffServ_Service_Context_Handler.h new file mode 100644 index 00000000000..8df73fa9dca --- /dev/null +++ b/TAO/tao/DiffServPolicy/DiffServ_Service_Context_Handler.h @@ -0,0 +1,43 @@ +// -*- C++ -*- + +// =================================================================== +/** + * @file DiffServ_Service_Context_Handler.h + * + * $Id$ + * + * @author Johnny Willemsen <jwillemsen@remedy.nl> + */ +// =================================================================== + +#ifndef TAO_DIFFSERV_SERVICE_CONTEXT_HANDLER_H +#define TAO_DIFFSERV_SERVICE_CONTEXT_HANDLER_H +#include /**/ "ace/pre.h" +#include "tao/DiffServPolicy/DiffServPolicy_Export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/Service_Context_Handler.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +class TAO_DiffServ_Service_Context_Handler : + public TAO_Service_Context_Handler +{ +public: + virtual int process_service_context (TAO_Transport& transport, + const IOP::ServiceContext& context); + virtual int generate_service_context ( + TAO_Stub *stub, + TAO_Transport &transport, + TAO_Operation_Details &opdetails, + TAO_Target_Specification &spec, + TAO_OutputCDR &msg); +}; + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" +#endif /* TAO_DIFFSERV_SERVICE_CONTEXT_HANDLER_H */ |