diff options
author | jai <jai@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2007-01-20 23:16:41 +0000 |
---|---|---|
committer | jai <jai@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2007-01-20 23:16:41 +0000 |
commit | 807c7c81fd564e7ea07bac60cbecb0f5012421c3 (patch) | |
tree | a7e805a9747464ac3e0b809d9c03505ed90a5fa1 | |
parent | b781933f7a8f4ba88c7873620ee62541f0ca2614 (diff) | |
download | ATCD-807c7c81fd564e7ea07bac60cbecb0f5012421c3.tar.gz |
checking diffserv policy library
-rw-r--r-- | TAO/tao/DiffServPolicy/Client_Network_Priority_Policy.cpp | 146 | ||||
-rw-r--r-- | TAO/tao/DiffServPolicy/Client_Network_Priority_Policy.h | 115 | ||||
-rw-r--r-- | TAO/tao/DiffServPolicy/DiffServPolicy.pidl | 61 | ||||
-rw-r--r-- | TAO/tao/DiffServPolicy/DiffServPolicy_Export.h | 58 | ||||
-rw-r--r-- | TAO/tao/DiffServPolicy/DiffServPolicy_Factory.cpp | 109 | ||||
-rw-r--r-- | TAO/tao/DiffServPolicy/DiffServPolicy_Factory.h | 71 | ||||
-rw-r--r-- | TAO/tao/DiffServPolicy/DiffServPolicy_ORBInitializer.cpp | 85 | ||||
-rw-r--r-- | TAO/tao/DiffServPolicy/DiffServPolicy_ORBInitializer.h | 80 | ||||
-rw-r--r-- | TAO/tao/DiffServPolicy/Server_Network_Priority_Policy.cpp | 165 | ||||
-rw-r--r-- | TAO/tao/DiffServPolicy/Server_Network_Priority_Policy.h | 126 |
10 files changed, 1016 insertions, 0 deletions
diff --git a/TAO/tao/DiffServPolicy/Client_Network_Priority_Policy.cpp b/TAO/tao/DiffServPolicy/Client_Network_Priority_Policy.cpp new file mode 100644 index 00000000000..72f1908f746 --- /dev/null +++ b/TAO/tao/DiffServPolicy/Client_Network_Priority_Policy.cpp @@ -0,0 +1,146 @@ +// $Id$ + +#include "tao/Client_Network_Priority_Policy.h" +#include "tao/DiffServPolicyC.h" +#include "tao/SystemException.h" + +ACE_RCSID (DiffServPolicy, + Client_Network_Priority_Policy, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +TAO_Client_Network_Priority_Policy::TAO_Client_Network_Priority_Policy (void) + : ::CORBA::Object () + , ::CORBA::Policy () + , ::CORBA::LocalObject () + , TAO::NetworkPriorityPolicy () + , TAO_Local_RefCounted_Object () + , request_diffserv_codepoint_ (0) + , reply_diffserv_codepoint_ (0) + , network_priority_model_ (TAO::NO_NETWORK_PRIORITY) +{ +} + +TAO_Client_Network_Priority_Policy::TAO_Client_Network_Priority_Policy ( + const TAO::DiffservCodepoint &request_diffserv_codepoint, + const TAO::DiffservCodepoint &reply_diffserv_codepoint, + TAO::NetworkPriorityModel &network_priority_model) + : ::CORBA::Object () + , ::CORBA::Policy () + , ::CORBA::LocalObject () + , TAO::NetworkPriorityPolicy () + , TAO_Local_RefCounted_Object () + , request_diffserv_codepoint_ (request_diffserv_codepoint) + , reply_diffserv_codepoint_ (reply_diffserv_codepoint) + , network_priority_model_ (network_priority_model) +{ +} + +TAO_Client_Network_Priority_Policy::TAO_Client_Network_Priority_Policy ( + const TAO_Client_Network_Priority_Policy &rhs) + : ::CORBA::Object () + , ::CORBA::Policy () + , ::CORBA::LocalObject () + , TAO::NetworkPriorityPolicy () + , TAO_Local_RefCounted_Object () + , request_diffserv_codepoint_ (rhs.request_diffserv_codepoint_) + , reply_diffserv_codepoint_ (rhs.reply_diffserv_codepoint_) + , network_priority_model_ (rhs.network_priority_model_) +{ +} + +CORBA::PolicyType +TAO_Client_Network_Priority_Policy::policy_type ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return TAO::CLIENT_NETWORK_PRIORITY_TYPE; +} + +TAO_Client_Network_Priority_Policy * +TAO_Client_Network_Priority_Policy::clone (void) const +{ + TAO_Client_Network_Priority_Policy *copy = 0; + ACE_NEW_RETURN (copy, + TAO_Client_Network_Priority_Policy (*this), + 0); + return copy; +} + +TAO::DiffservCodepoint +TAO_Client_Network_Priority_Policy::request_diffserv_codepoint ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return this->request_diffserv_codepoint_; +} + +void +TAO_Client_Network_Priority_Policy::request_diffserv_codepoint ( + TAO::DiffservCodepoint req_dscp + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->request_diffserv_codepoint_ = req_dscp; +} + +TAO::DiffservCodepoint +TAO_Client_Network_Priority_Policy::reply_diffserv_codepoint ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return this->reply_diffserv_codepoint_; +} + +void +TAO_Client_Network_Priority_Policy::reply_diffserv_codepoint ( + TAO::DiffservCodepoint reply_dscp + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->reply_diffserv_codepoint_ = reply_dscp; +} + +TAO::NetworkPriorityModel +TAO_Client_Network_Priority_Policy::network_priority_model ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return this->network_priority_model_; +} + +CORBA::Policy_ptr +TAO_Client_Network_Priority_Policy::copy (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + TAO_Client_Network_Priority_Policy* servant = 0; + ACE_NEW_THROW_EX (servant, + TAO_Client_Network_Priority_Policy (*this), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (CORBA::Policy::_nil ()); + + return servant; +} + +void +TAO_Client_Network_Priority_Policy::destroy (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +TAO_Cached_Policy_Type +TAO_Client_Network_Priority_Policy::_tao_cached_type (void) const +{ + return TAO_CACHED_POLICY_CLIENT_NETWORK_PRIORITY; +} + +TAO_Policy_Scope +TAO_Client_Network_Priority_Policy::_tao_scope (void) const +{ + return static_cast<TAO_Policy_Scope> (TAO_POLICY_DEFAULT_SCOPE | + TAO_POLICY_CLIENT_EXPOSED); +} + + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/DiffServPolicy/Client_Network_Priority_Policy.h b/TAO/tao/DiffServPolicy/Client_Network_Priority_Policy.h new file mode 100644 index 00000000000..01e17c5290c --- /dev/null +++ b/TAO/tao/DiffServPolicy/Client_Network_Priority_Policy.h @@ -0,0 +1,115 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Client_Network_Priority_Policy.h + * + * $Id$ + * + * + */ +//============================================================================= + + +#ifndef TAO_CLIENT_NETWORK_PRIORITY_POLICY_H +#define TAO_CLIENT_NETWORK_PRIORITY_POLICY_H + +#include /**/ "ace/pre.h" + +#include "tao/orbconf.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/LocalObject.h" +#include "tao/Basic_Types.h" +#include "ace/SString.h" +#include "tao/DiffServPolicyC.h" + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class TAO_Client_Network_Priority_Policy + * + * @brief Implementation class for TAO-specific Network Priority Policy. + * + * This policy is used to control the network priority assigned to the + * requests and replies, processed by the ORB. + */ +class TAO_Export TAO_Client_Network_Priority_Policy + : public TAO::NetworkPriorityPolicy, + public TAO_Local_RefCounted_Object +{ +public: + /// Constructor. + TAO_Client_Network_Priority_Policy (void); + + /// Constructor. + TAO_Client_Network_Priority_Policy ( + const TAO::DiffservCodepoint &request_diffserv_codepoint, + const TAO::DiffservCodepoint &reply_diffserv_codepoint, + TAO::NetworkPriorityModel &network_priority_model); + + /// Copy constructor. + TAO_Client_Network_Priority_Policy ( + const TAO_Client_Network_Priority_Policy &rhs); + + /// Returns a copy of <this>. + TAO_Client_Network_Priority_Policy *clone (void) const; + + TAO::DiffservCodepoint request_diffserv_codepoint (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void request_diffserv_codepoint ( + TAO::DiffservCodepoint req_dscp + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + TAO::DiffservCodepoint reply_diffserv_codepoint (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void reply_diffserv_codepoint ( + TAO::DiffservCodepoint reply_dscp + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + TAO::NetworkPriorityModel network_priority_model ( + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + CORBA::PolicyType policy_type (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + CORBA::Policy_ptr copy (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void destroy (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // Return the cached policy type for this policy. + TAO_Cached_Policy_Type _tao_cached_type (void) const; + + // Returns the scope at which this policy can be applied. See orbconf.h. + TAO_Policy_Scope _tao_scope (void) const; + +private: + /// The attribute + TAO::DiffservCodepoint request_diffserv_codepoint_; + TAO::DiffservCodepoint reply_diffserv_codepoint_; + TAO::NetworkPriorityModel network_priority_model_; +}; + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#include /**/ "ace/post.h" +#endif /* TAO_CLIENT_NETWORK_PRIORITY_POLICY_H */ diff --git a/TAO/tao/DiffServPolicy/DiffServPolicy.pidl b/TAO/tao/DiffServPolicy/DiffServPolicy.pidl new file mode 100644 index 00000000000..86aba431cc3 --- /dev/null +++ b/TAO/tao/DiffServPolicy/DiffServPolicy.pidl @@ -0,0 +1,61 @@ +// -*- IDL -*- + +// ================================================================ +/** + * @file DiffServPolicy.pidl + * + * $Id$ + * + * This file contains TAO-specific idl interfaces for adding + * network priority or DiffServ support (not part of CORBA + * 2.6). + * + * The steps to regenerate the code are as follows: + * + * 1. Run the tao_idl compiler on the pidl file. The command used for + * this is: + * + * tao_idl + * -o orig -Gp -Gd -Ge 1 -GA -SS -Sci + * -Wb,export_macro=TAO_Export + * -Wb,pre_include="ace/pre.h" + * -Wb,post_include="ace/post.h" + * TAO_Network_Priority_Policy.pidl + * + * 2. The files are ready to use + */ +// ================================================================ + +#ifndef TAO_DIFFSERV_POLICY_IDL +#define TAO_DIFFSERV_POLICY_IDL + +#include "tao/Policy.pidl" + +#pragma prefix "tao" + +module TAO +{ + typedef long DiffservCodepoint; + + enum NetworkPriorityModel + { + CLIENT_PROPAGATED_NETWORK_PRIORITY, + SERVER_DECLARED_NETWORK_PRIORITY, + NO_NETWORK_PRIORITY + }; + + const CORBA::PolicyType SERVER_NETWORK_PRIORITY_TYPE = 85; + const CORBA::PolicyType CLIENT_NETWORK_PRIORITY_TYPE = 86; + const CORBA::PolicyType NETWORK_PRIORITY_TYPE = 87; + + local interface NetworkPriorityPolicy : CORBA::Policy + { + readonly attribute NetworkPriorityModel network_priority_model; + attribute DiffservCodepoint request_diffserv_codepoint; + attribute DiffservCodepoint reply_diffserv_codepoint; + }; +}; + +#pragma prefix "" + +#endif /* TAO_DIFFSERV_POLICY_IDL */ diff --git a/TAO/tao/DiffServPolicy/DiffServPolicy_Export.h b/TAO/tao/DiffServPolicy/DiffServPolicy_Export.h new file mode 100644 index 00000000000..2c6f69d9411 --- /dev/null +++ b/TAO/tao/DiffServPolicy/DiffServPolicy_Export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl -s TAO_DiffServPolicy +// ------------------------------ +#ifndef TAO_DIFFSERVPOLICY_EXPORT_H +#define TAO_DIFFSERVPOLICY_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (TAO_DIFFSERVPOLICY_HAS_DLL) +# define TAO_DIFFSERVPOLICY_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && TAO_DIFFSERVPOLICY_HAS_DLL */ + +#if !defined (TAO_DIFFSERVPOLICY_HAS_DLL) +# define TAO_DIFFSERVPOLICY_HAS_DLL 1 +#endif /* ! TAO_DIFFSERVPOLICY_HAS_DLL */ + +#if defined (TAO_DIFFSERVPOLICY_HAS_DLL) && (TAO_DIFFSERVPOLICY_HAS_DLL == 1) +# if defined (TAO_DIFFSERVPOLICY_BUILD_DLL) +# define TAO_DiffServPolicy_Export ACE_Proper_Export_Flag +# define TAO_DIFFSERVPOLICY_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define TAO_DIFFSERVPOLICY_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* TAO_DIFFSERVPOLICY_BUILD_DLL */ +# define TAO_DiffServPolicy_Export ACE_Proper_Import_Flag +# define TAO_DIFFSERVPOLICY_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define TAO_DIFFSERVPOLICY_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* TAO_DIFFSERVPOLICY_BUILD_DLL */ +#else /* TAO_DIFFSERVPOLICY_HAS_DLL == 1 */ +# define TAO_DiffServPolicy_Export +# define TAO_DIFFSERVPOLICY_SINGLETON_DECLARATION(T) +# define TAO_DIFFSERVPOLICY_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* TAO_DIFFSERVPOLICY_HAS_DLL == 1 */ + +// Set TAO_DIFFSERVPOLICY_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (TAO_DIFFSERVPOLICY_NTRACE) +# if (ACE_NTRACE == 1) +# define TAO_DIFFSERVPOLICY_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define TAO_DIFFSERVPOLICY_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !TAO_DIFFSERVPOLICY_NTRACE */ + +#if (TAO_DIFFSERVPOLICY_NTRACE == 1) +# define TAO_DIFFSERVPOLICY_TRACE(X) +#else /* (TAO_DIFFSERVPOLICY_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define TAO_DIFFSERVPOLICY_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (TAO_DIFFSERVPOLICY_NTRACE == 1) */ + +#endif /* TAO_DIFFSERVPOLICY_EXPORT_H */ + +// End of auto generated file. diff --git a/TAO/tao/DiffServPolicy/DiffServPolicy_Factory.cpp b/TAO/tao/DiffServPolicy/DiffServPolicy_Factory.cpp new file mode 100644 index 00000000000..cd80662c192 --- /dev/null +++ b/TAO/tao/DiffServPolicy/DiffServPolicy_Factory.cpp @@ -0,0 +1,109 @@ +#include "tao/RTCORBA/RT_PolicyFactory.h" + +#if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0 + +ACE_RCSID (RTCORBA, + RT_PolicyFactory, + "$Id$") + +#include "tao/RTCORBA/RT_Policy_i.h" + +#include "tao/PolicyC.h" +#include "tao/ORB_Constants.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +CORBA::Policy_ptr +TAO_RT_PolicyFactory::create_policy ( + CORBA::PolicyType type, + const CORBA::Any &value + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + CORBA::PolicyError)) +{ + if (type == RTCORBA::PRIORITY_MODEL_POLICY_TYPE) + return TAO_PriorityModelPolicy::create (value + ACE_ENV_ARG_PARAMETER); + + if (type == RTCORBA::THREADPOOL_POLICY_TYPE) + return TAO_ThreadpoolPolicy::create (value + ACE_ENV_ARG_PARAMETER); + + if (type == RTCORBA::SERVER_PROTOCOL_POLICY_TYPE) + return TAO_ServerProtocolPolicy::create (value + ACE_ENV_ARG_PARAMETER); + + if (type == RTCORBA::CLIENT_PROTOCOL_POLICY_TYPE) + return TAO_ClientProtocolPolicy::create (value + ACE_ENV_ARG_PARAMETER); + + if (type == RTCORBA::PRIVATE_CONNECTION_POLICY_TYPE) + return TAO_PrivateConnectionPolicy::create (value + ACE_ENV_ARG_PARAMETER); + + if (type == RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE) + return TAO_PriorityBandedConnectionPolicy::create (value + ACE_ENV_ARG_PARAMETER); + + ACE_THROW_RETURN (CORBA::PolicyError (CORBA::BAD_POLICY_TYPE), + CORBA::Policy::_nil ()); +} + +CORBA::Policy_ptr +TAO_RT_PolicyFactory::_create_policy ( + CORBA::PolicyType type + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + CORBA::PolicyError)) +{ + CORBA::Policy_ptr policy = CORBA::Policy::_nil (); + + if (type == RTCORBA::PRIORITY_MODEL_POLICY_TYPE) + { + ACE_NEW_THROW_EX (policy, + TAO_PriorityModelPolicy, + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO::VMCID, + ENOMEM), + CORBA::COMPLETED_NO)); + ACE_CHECK_RETURN (CORBA::Policy::_nil ()); + + return policy; + } + + if (type == RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE) + { + ACE_NEW_THROW_EX (policy, + TAO_PriorityBandedConnectionPolicy, + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO::VMCID, + ENOMEM), + CORBA::COMPLETED_NO)); + ACE_CHECK_RETURN (CORBA::Policy::_nil ()); + + return policy; + } + + if (type == RTCORBA::CLIENT_PROTOCOL_POLICY_TYPE) + { + ACE_NEW_THROW_EX (policy, + TAO_ClientProtocolPolicy, + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO::VMCID, + ENOMEM), + CORBA::COMPLETED_NO)); + ACE_CHECK_RETURN (CORBA::Policy::_nil ()); + + return policy; + } + + ACE_THROW_RETURN (CORBA::PolicyError (CORBA::BAD_POLICY_TYPE), + CORBA::Policy::_nil ()); +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif /* TAO_HAS_CORBA_MESSAGING && TAO_HAS_CORBA_MESSAGING != 0 */ diff --git a/TAO/tao/DiffServPolicy/DiffServPolicy_Factory.h b/TAO/tao/DiffServPolicy/DiffServPolicy_Factory.h new file mode 100644 index 00000000000..0d7877c9489 --- /dev/null +++ b/TAO/tao/DiffServPolicy/DiffServPolicy_Factory.h @@ -0,0 +1,71 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file RT_PolicyFactory.h + * + * $Id$ + * + * @author Angelo Corsaro <corsaro@cs.wustl.edu> + * @author Ossama Othman <ossama@uci.edu> + */ +//============================================================================= + + +#ifndef TAO_RT_POLICY_FACTORY_H +#define TAO_RT_POLICY_FACTORY_H + +#include /**/ "ace/pre.h" + +#include "tao/orbconf.h" + +#if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0 + +#include "tao/RTCORBA/rtcorba_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/PI/PI.h" +#include "tao/LocalObject.h" + +// This is to remove "inherits via dominance" warnings from MSVC. +// MSVC is being a little too paranoid. +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +/// Policy factory for all RTCORBA related policies. +class TAO_RT_PolicyFactory + : public virtual PortableInterceptor::PolicyFactory, + public virtual TAO_Local_RefCounted_Object +{ +public: + + CORBA::Policy_ptr create_policy (CORBA::PolicyType type, + const CORBA::Any &value + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + CORBA::PolicyError)); + + CORBA::Policy_ptr _create_policy (CORBA::PolicyType type + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + CORBA::PolicyError)); +}; + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#endif /* TAO_HAS_CORBA_MESSAGING && TAO_HAS_CORBA_MESSAGING != 0 */ + +#include /**/ "ace/post.h" + +#endif /* TAO_RT_POLICY_FACTORY_H */ diff --git a/TAO/tao/DiffServPolicy/DiffServPolicy_ORBInitializer.cpp b/TAO/tao/DiffServPolicy/DiffServPolicy_ORBInitializer.cpp new file mode 100644 index 00000000000..f21ae48ee30 --- /dev/null +++ b/TAO/tao/DiffServPolicy/DiffServPolicy_ORBInitializer.cpp @@ -0,0 +1,85 @@ +// $Id$ + +#include "tao/DiffServPolicy/EndpointPolicy_ORBInitializer.h" +#include "tao/DiffServPolicy/EndpointPolicyC.h" +#include "tao/DiffServPolicy/EndpointPolicy_Factory.h" +#include "tao/ORB_Core.h" +#include "tao/PI/ORBInitInfo.h" + +ACE_RCSID (EndpointPolicy, + EndpointPolicy_ORBInitializer, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +void +TAO_EndpointPolicy_ORBInitializer::pre_init ( + PortableInterceptor::ORBInitInfo_ptr + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +void +TAO_EndpointPolicy_ORBInitializer::post_init ( + PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->register_policy_factories (info + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +TAO_EndpointPolicy_ORBInitializer::register_policy_factories ( + PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL) +{ + TAO_ORBInitInfo * local_info = dynamic_cast <TAO_ORBInitInfo *> (info); + TAO_ORB_Core * the_orb_core = local_info->orb_core (); + + // Register the EndpointPolicy policy factories. + PortableInterceptor::PolicyFactory_ptr policy_factory_ptr; + ACE_NEW_THROW_EX (policy_factory_ptr, + TAO_EndpointPolicy_Factory(the_orb_core), + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO::VMCID, + ENOMEM), + CORBA::COMPLETED_NO)); + ACE_CHECK; + + + PortableInterceptor::PolicyFactory_var policy_factory = + policy_factory_ptr; + + ACE_TRY + { + info->register_policy_factory (EndpointPolicy::ENDPOINT_POLICY_TYPE, + policy_factory.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCH (CORBA::BAD_INV_ORDER, ex) + { + if (ex.minor () == (CORBA::OMGVMCID | 16)) + { + // The factory is already there, it happens because the + // magic initializer in Messaging.cpp registers with the + // ORB multiple times. This is an indication that we + // should do no more work in this ORBInitializer. + return; + } + ACE_RE_THROW; + } + ACE_CATCHANY + { + // Rethrow any other exceptions... + ACE_RE_THROW; + } + ACE_ENDTRY; + ACE_CHECK; +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/DiffServPolicy/DiffServPolicy_ORBInitializer.h b/TAO/tao/DiffServPolicy/DiffServPolicy_ORBInitializer.h new file mode 100644 index 00000000000..26ae4346612 --- /dev/null +++ b/TAO/tao/DiffServPolicy/DiffServPolicy_ORBInitializer.h @@ -0,0 +1,80 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file DiffServPolicy_ORBInitializer.h + * + * $Id$ + * + * @author Jaiganesh Balasubramanian <jai@dre.vanderbilt.edu> + * Johnny Willemsen <jwillemsen@remedy.nl> + */ +//============================================================================= + + +#ifndef TAO_DIFFSERVPOLICY_ORB_INITIALIZER_H +#define TAO_DIFFSERVPOLICY_ORB_INITIALIZER_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/PI/PI.h" +#include "tao/LocalObject.h" + +// This is to remove "inherits via dominance" warnings from MSVC. +// MSVC is being a little too paranoid. +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +/// DiffServPolicy ORB initializer. +class TAO_DiffServPolicy_ORBInitializer + : public virtual PortableInterceptor::ORBInitializer, + public virtual TAO_Local_RefCounted_Object +{ +public: + + /** + * @name PortableInterceptor::ORBInitializer Methods + * + * The following methods are required by the + * PortableInterceptor::ORBInitializer interface. + */ + //@{ + + virtual void pre_init (PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void post_init (PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + //@} + +private: + + /// Register DiffServ policy factories. + void register_policy_factories ( + PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL); + +}; + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#include /**/ "ace/post.h" + +#endif /* TAO_DIFFSERVPOLICY_ORB_INITIALIZER_H */ diff --git a/TAO/tao/DiffServPolicy/Server_Network_Priority_Policy.cpp b/TAO/tao/DiffServPolicy/Server_Network_Priority_Policy.cpp new file mode 100644 index 00000000000..e5d895a8b83 --- /dev/null +++ b/TAO/tao/DiffServPolicy/Server_Network_Priority_Policy.cpp @@ -0,0 +1,165 @@ +// $Id$ + +#include "tao/Server_Network_Priority_Policy.h" +#include "tao/DiffServPolicyC.h" +#include "tao/SystemException.h" + +ACE_RCSID (DiffServPolicy, + Server_Network_Priority_Policy, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +TAO_Server_Network_Priority_Policy::TAO_Server_Network_Priority_Policy (void) + : ::CORBA::Object () + , ::CORBA::Policy () + , ::CORBA::LocalObject () + , TAO::NetworkPriorityPolicy () + , TAO_Local_RefCounted_Object () + , request_diffserv_codepoint_ (0) + , reply_diffserv_codepoint_ (0) + , network_priority_model_ (TAO::NO_NETWORK_PRIORITY) +{ +} + +TAO_Server_Network_Priority_Policy::~TAO_Server_Network_Priority_Policy (void) +{ +} + +TAO_Server_Network_Priority_Policy::TAO_Server_Network_Priority_Policy ( + const TAO::DiffservCodepoint &request_diffserv_codepoint, + const TAO::DiffservCodepoint &reply_diffserv_codepoint, + TAO::NetworkPriorityModel &network_priority_model) + : ::CORBA::Object () + , ::CORBA::Policy () + , ::CORBA::LocalObject () + , TAO::NetworkPriorityPolicy () + , TAO_Local_RefCounted_Object () + , request_diffserv_codepoint_ (request_diffserv_codepoint) + , reply_diffserv_codepoint_ (reply_diffserv_codepoint) + , network_priority_model_ (network_priority_model) +{ +} + +TAO_Server_Network_Priority_Policy::TAO_Server_Network_Priority_Policy ( + const TAO_Server_Network_Priority_Policy &rhs) + : ::CORBA::Object () + , ::CORBA::Policy () + , ::CORBA::LocalObject () + , TAO::NetworkPriorityPolicy () + , TAO_Local_RefCounted_Object () + , request_diffserv_codepoint_ (rhs.request_diffserv_codepoint_) + , reply_diffserv_codepoint_ (rhs.reply_diffserv_codepoint_) + , network_priority_model_ (rhs.network_priority_model_) +{ +} + +CORBA::PolicyType +TAO_Server_Network_Priority_Policy::policy_type ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return TAO::NETWORK_PRIORITY_TYPE; +} + +TAO_Server_Network_Priority_Policy * +TAO_Server_Network_Priority_Policy::clone (void) const +{ + TAO_Server_Network_Priority_Policy *copy = 0; + ACE_NEW_RETURN (copy, + TAO_Server_Network_Priority_Policy (*this), + 0); + return copy; +} + +TAO::DiffservCodepoint +TAO_Server_Network_Priority_Policy::request_diffserv_codepoint ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return this->request_diffserv_codepoint_; +} + +void +TAO_Server_Network_Priority_Policy::request_diffserv_codepoint ( + TAO::DiffservCodepoint req_dscp + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->request_diffserv_codepoint_ = req_dscp; +} + +TAO::DiffservCodepoint +TAO_Server_Network_Priority_Policy::reply_diffserv_codepoint ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return this->reply_diffserv_codepoint_; +} + +void +TAO_Server_Network_Priority_Policy::reply_diffserv_codepoint ( + TAO::DiffservCodepoint reply_dscp + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->reply_diffserv_codepoint_ = reply_dscp; +} + +TAO::NetworkPriorityModel +TAO_Server_Network_Priority_Policy::network_priority_model ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return this->network_priority_model_; +} + +CORBA::Policy_ptr +TAO_Server_Network_Priority_Policy::copy (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + TAO_Server_Network_Priority_Policy* servant = 0; + ACE_NEW_THROW_EX (servant, + TAO_Server_Network_Priority_Policy (*this), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (CORBA::Policy::_nil ()); + + return servant; +} + +void +TAO_Server_Network_Priority_Policy::destroy (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +TAO_Cached_Policy_Type +TAO_Server_Network_Priority_Policy::_tao_cached_type (void) const +{ + return TAO_CACHED_POLICY_NETWORK_PRIORITY; +} + +TAO_Policy_Scope +TAO_Server_Network_Priority_Policy::_tao_scope (void) const +{ + return static_cast<TAO_Policy_Scope> (TAO_POLICY_DEFAULT_SCOPE | + TAO_POLICY_CLIENT_EXPOSED); +} + +CORBA::Boolean +TAO_Server_Network_Priority_Policy::_tao_encode (TAO_OutputCDR &out_cdr) +{ + return ((out_cdr << request_diffserv_codepoint_) && + (out_cdr << reply_diffserv_codepoint_) && + (out_cdr << network_priority_model_)); +} + +CORBA::Boolean +TAO_Server_Network_Priority_Policy::_tao_decode (TAO_InputCDR &in_cdr) +{ + return ((in_cdr >> request_diffserv_codepoint_) && + (in_cdr >> reply_diffserv_codepoint_) && + (in_cdr >> network_priority_model_)); +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/DiffServPolicy/Server_Network_Priority_Policy.h b/TAO/tao/DiffServPolicy/Server_Network_Priority_Policy.h new file mode 100644 index 00000000000..a3e7c01adc4 --- /dev/null +++ b/TAO/tao/DiffServPolicy/Server_Network_Priority_Policy.h @@ -0,0 +1,126 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Server_Network_Priority_Policy.h + * + * $Id$ + * + * + */ +//============================================================================= + + +#ifndef TAO_SERVER_NETWORK_PRIORITY_POLICY_H +#define TAO_SERVER_NETWORK_PRIORITY_POLICY_H + +#include /**/ "ace/pre.h" + +#include "tao/DiffServPolicyC.h" +#include "tao/orbconf.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/LocalObject.h" +#include "ace/SString.h" +#include "tao/Basic_Types.h" + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +/** + * @class TAO_Server_Network_Priority_Policy + * + * @brief Implementation class for TAO-specific Network Priority Policy. + * + * This policy is used to control the network priority assigned to the + * requests and replies, processed by the ORB. + */ +class TAO_Export TAO_Server_Network_Priority_Policy + : public TAO::NetworkPriorityPolicy, + public TAO_Local_RefCounted_Object +{ +public: + + /// default constructor. + TAO_Server_Network_Priority_Policy (void); + + /// Constructor. + TAO_Server_Network_Priority_Policy ( + const TAO::DiffservCodepoint &request_diffserv_codepoint, + const TAO::DiffservCodepoint &reply_diffserv_codepoint, + TAO::NetworkPriorityModel &network_priority_model); + + /// Copy constructor. + TAO_Server_Network_Priority_Policy ( + const TAO_Server_Network_Priority_Policy &rhs); + + /// Returns a copy of <this>. + TAO_Server_Network_Priority_Policy *clone (void) const; + + TAO::DiffservCodepoint request_diffserv_codepoint (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void request_diffserv_codepoint ( + TAO::DiffservCodepoint req_dscp + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + TAO::DiffservCodepoint reply_diffserv_codepoint (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void reply_diffserv_codepoint ( + TAO::DiffservCodepoint reply_dscp + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + TAO::NetworkPriorityModel network_priority_model ( + ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + CORBA::PolicyType policy_type (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + CORBA::Policy_ptr copy (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void destroy (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // Return the cached policy type for this policy. + TAO_Cached_Policy_Type _tao_cached_type (void) const; + + // Returns the scope at which this policy can be applied. See orbconf.h. + TAO_Policy_Scope _tao_scope (void) const; + + /// This method writes a CDR representation of the object state. + CORBA::Boolean _tao_encode (TAO_OutputCDR &out_cdr); + + /// This method reads the object state from a CDR representation. + CORBA::Boolean _tao_decode (TAO_InputCDR &in_cdr); + +protected: + + virtual ~TAO_Server_Network_Priority_Policy (void); + +private: + /// The attributes + TAO::DiffservCodepoint request_diffserv_codepoint_; + TAO::DiffservCodepoint reply_diffserv_codepoint_; + TAO::NetworkPriorityModel network_priority_model_; +}; + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#include /**/ "ace/post.h" +#endif /* TAO_SERVER_NETWORK_PRIORITY_POLICY_H */ |