diff options
author | marina <marina@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-12-02 05:12:50 +0000 |
---|---|---|
committer | marina <marina@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-12-02 05:12:50 +0000 |
commit | 9d0ff4088d06460fee5f98816269e390eb7fa24e (patch) | |
tree | 330807e81644ac15ef7d9cd37d59a4b4e4287024 /TAO/tao | |
parent | 680e3007679160e7ab1c10b603fe968dae2d4e8f (diff) | |
download | ATCD-9d0ff4088d06460fee5f98816269e390eb7fa24e.tar.gz |
ChangeLogTag:Fri Dec 01 23:00:32 2000 Marina Spivak <marina@cs.wustl.edu>
Diffstat (limited to 'TAO/tao')
-rw-r--r-- | TAO/tao/Invocation.cpp | 2 | ||||
-rw-r--r-- | TAO/tao/Invocation.h | 22 | ||||
-rw-r--r-- | TAO/tao/Invocation.i | 15 | ||||
-rw-r--r-- | TAO/tao/Invocation_Endpoint_Selectors.cpp | 209 | ||||
-rw-r--r-- | TAO/tao/Invocation_Endpoint_Selectors.h | 10 | ||||
-rw-r--r-- | TAO/tao/Stub.cpp | 90 |
6 files changed, 237 insertions, 111 deletions
diff --git a/TAO/tao/Invocation.cpp b/TAO/tao/Invocation.cpp index 6d45d290095..86deea3bbdf 100644 --- a/TAO/tao/Invocation.cpp +++ b/TAO/tao/Invocation.cpp @@ -88,6 +88,7 @@ TAO_GIOP_Invocation::TAO_GIOP_Invocation (void) transport_ (0), endpoint_selector_ (0), is_selector_initialized_ (0), + inconsistent_policies_ (0), profile_ (0), endpoint_ (0), max_wait_time_ (0), @@ -118,6 +119,7 @@ TAO_GIOP_Invocation::TAO_GIOP_Invocation (TAO_Stub *stub, transport_ (0), endpoint_selector_ (0), is_selector_initialized_ (0), + inconsistent_policies_ (0), profile_ (0), endpoint_ (0), max_wait_time_ (0), diff --git a/TAO/tao/Invocation.h b/TAO/tao/Invocation.h index e42dce2cb5b..822a9c09f26 100644 --- a/TAO/tao/Invocation.h +++ b/TAO/tao/Invocation.h @@ -134,6 +134,15 @@ public: // Establishes a connection to the remote server, initializes // the GIOP headers in the output CDR. + void init_inconsistent_policies (CORBA_Environment &ACE_TRY_ENV = + TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException)); + // Dynamically allocate <inconsistent_policies_> PolicyList. + + CORBA::PolicyList *get_inconsistent_policies (void); + // Return PolicyList stored in <inconsistent_policies_> and give up + // its ownership. User must deallocate memory. + protected: int invoke (CORBA::Boolean is_roundtrip, CORBA_Environment &ACE_TRY_ENV = @@ -204,6 +213,19 @@ protected: #endif /* TAO_HAS_RT_CORBA == 1 */ + CORBA::PolicyList_var inconsistent_policies_; + // If current effective policies cause the invocation to raise + // CORBA::INV_POLICY exception, the conflicting/problematic policies + // are stored in this list. This is used by + // <Object::_validate_connection> method to inform clients about + // causes of invocation failure. + // + // Conflicting policies are only stored in this list if + // <init_inconsistent_policies> method has been called prior to the + // beginning of invocation. This saves extra work of conflicting + // policies 'logging' when it's not needed. + // + TAO_Profile *profile_; // This invocation is using this profile. diff --git a/TAO/tao/Invocation.i b/TAO/tao/Invocation.i index af4c16b81bf..b452cab7aa1 100644 --- a/TAO/tao/Invocation.i +++ b/TAO/tao/Invocation.i @@ -28,6 +28,21 @@ TAO_GIOP_Invocation::restart_flag (CORBA::Boolean flag) this->restart_flag_ = flag; } +ACE_INLINE void +TAO_GIOP_Invocation::init_inconsistent_policies (CORBA::Environment &ACE_TRY_ENV) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_NEW_THROW_EX (this->inconsistent_policies_, + CORBA::PolicyList (0), + CORBA::NO_MEMORY ()); +} + +ACE_INLINE CORBA::PolicyList * +TAO_GIOP_Invocation::get_inconsistent_policies (void) +{ + return this->inconsistent_policies_._retn (); +} + // **************************************************************** ACE_INLINE diff --git a/TAO/tao/Invocation_Endpoint_Selectors.cpp b/TAO/tao/Invocation_Endpoint_Selectors.cpp index f6fa26f4239..8244a62d550 100644 --- a/TAO/tao/Invocation_Endpoint_Selectors.cpp +++ b/TAO/tao/Invocation_Endpoint_Selectors.cpp @@ -34,27 +34,41 @@ TAO_Endpoint_Selector_Factory::get_selector (TAO_GIOP_Invocation if (invocation->endpoint_selector_ != 0) return; - // Initialize Invocation's endpoint selection state. - this->init_state (invocation, ACE_TRY_ENV); + // Initialize selection state with all RTCORBA policies affecting + // endpoint selection. + TAO_Endpoint_Selection_State &state = + invocation->endpoint_selection_state_; + + state.priority_model_policy_ = + invocation->stub_->exposed_priority_model (); + state.private_connection_ = + invocation->stub_->private_connection (); + + this->init_client_protocol (invocation, ACE_TRY_ENV); + ACE_CHECK; + this->init_bands (invocation, ACE_TRY_ENV); ACE_CHECK; // // Look at RTCORBA policies to decide on appropriate selector. // - TAO_PriorityModelPolicy *priority_policy = - invocation->endpoint_selection_state_.priority_model_policy_; - // CASE 2: No PriorityModelPolicy set. - if (priority_policy == 0) + if (state.priority_model_policy_ == 0) { // Bands without priority model do not make sense. - if (invocation->endpoint_selection_state_.bands_policy_ - != 0) - ACE_THROW (CORBA::INV_POLICY ()); + if (state.bands_policy_ != 0) + { + if (invocation->inconsistent_policies_.ptr ()) + { + invocation->inconsistent_policies_->length (1); + invocation->inconsistent_policies_[0u] = + CORBA::Policy::_duplicate (state.bands_policy_); + } + ACE_THROW (CORBA::INV_POLICY ()); + } - if (invocation->endpoint_selection_state_.client_protocol_policy_ - == 0) + if (state.client_protocol_policy_ == 0) invocation->endpoint_selector_ = invocation->orb_core_->default_endpoint_selector (); else @@ -65,41 +79,37 @@ TAO_Endpoint_Selector_Factory::get_selector (TAO_GIOP_Invocation return; } - if (priority_policy->get_priority_model () + if (state.priority_model_policy_->get_priority_model () == RTCORBA::CLIENT_PROPAGATED) { // Get client priority. - if (invocation->orb_core_->get_thread_priority - (invocation->endpoint_selection_state_.client_priority_) + if (invocation->orb_core_->get_thread_priority (state.client_priority_) == -1) ACE_THROW (CORBA::DATA_CONVERSION (1, CORBA::COMPLETED_NO)); } // CASE 3: PriorityBandedConnection Policy is set. - if (invocation->endpoint_selection_state_.bands_policy_ - != 0) + if (state.bands_policy_ != 0) { // Figure out target priority. CORBA::Short p; - if (priority_policy->get_priority_model () + if (state.priority_model_policy_->get_priority_model () == RTCORBA::CLIENT_PROPAGATED) - p = invocation->endpoint_selection_state_.client_priority_; + p = state.client_priority_; else - p = priority_policy->server_priority (); + p = state.priority_model_policy_->server_priority (); // Find the band with the range covering our target priority. RTCORBA::PriorityBands &bands = - invocation->endpoint_selection_state_.bands_policy_->priority_bands_rep (); + state.bands_policy_->priority_bands_rep (); int in_range = 0; for (CORBA::ULong i = 0; i < bands.length (); ++i) if (bands[i].low <= p && bands[i].high >= p) { - invocation->endpoint_selection_state_.min_priority_ = - bands[i].low; - invocation->endpoint_selection_state_.max_priority_ = - bands[i].high; + state.min_priority_ = bands[i].low; + state.max_priority_ = bands[i].high; in_range = 1; break; @@ -107,11 +117,20 @@ TAO_Endpoint_Selector_Factory::get_selector (TAO_GIOP_Invocation // If priority doesn't fall into any of the bands if (!in_range) - ACE_THROW (CORBA::INV_POLICY ()); + { + if (invocation->inconsistent_policies_.ptr ()) + { + invocation->inconsistent_policies_->length (2); + invocation->inconsistent_policies_[0u] = + CORBA::Policy::_duplicate (state.bands_policy_); + invocation->inconsistent_policies_[1u] = + CORBA::Policy::_duplicate (state.priority_model_policy_); + } + ACE_THROW (CORBA::INV_POLICY ()); + } // Matching band found. Instantiate appropriate selector. - if (invocation->endpoint_selection_state_.client_protocol_policy_ - == 0) + if (state.client_protocol_policy_ == 0) invocation->endpoint_selector_ = invocation->orb_core_->bands_endpoint_selector (); else @@ -122,11 +141,10 @@ TAO_Endpoint_Selector_Factory::get_selector (TAO_GIOP_Invocation } // CASE 4: CLIENT_PROPAGATED priority model, no bands. - if (priority_policy->get_priority_model () + if (state.priority_model_policy_->get_priority_model () == RTCORBA::CLIENT_PROPAGATED) { - if (invocation->endpoint_selection_state_.client_protocol_policy_ - == 0) + if (state.client_protocol_policy_ == 0) invocation->endpoint_selector_ = invocation->orb_core_->priority_endpoint_selector (); else @@ -136,8 +154,7 @@ TAO_Endpoint_Selector_Factory::get_selector (TAO_GIOP_Invocation else { // CASE 5: SERVER_DECLARED priority model, no bands. - if (invocation->endpoint_selection_state_.client_protocol_policy_ - == 0) + if (state.client_protocol_policy_ == 0) invocation->endpoint_selector_ = invocation->orb_core_->default_endpoint_selector (); else @@ -227,24 +244,51 @@ check_client_priority_policy (TAO_GIOP_Invocation *invocation, void TAO_Endpoint_Selector_Factory:: -init_state (TAO_GIOP_Invocation *invocation, - CORBA::Environment &ACE_TRY_ENV) +init_client_protocol (TAO_GIOP_Invocation *invocation, + CORBA::Environment &ACE_TRY_ENV) { - // Initialize selection state with all RTCORBA policies affecting - // endpoint selection. - - invocation->endpoint_selection_state_.priority_model_policy_ = - invocation->stub_->exposed_priority_model (); - - invocation->endpoint_selection_state_.client_protocol_policy_ = - invocation->stub_->effective_client_protocol (ACE_TRY_ENV); + ACE_TRY + { + invocation->endpoint_selection_state_.client_protocol_policy_ = + invocation->stub_->effective_client_protocol (ACE_TRY_ENV); + ACE_TRY_CHECK; + } + ACE_CATCH (CORBA::INV_POLICY, ex) + { + if (invocation->inconsistent_policies_.ptr ()) + { + invocation->inconsistent_policies_->length (1); + invocation->inconsistent_policies_[0u] = + invocation->stub_->client_protocol (); + } + ACE_RE_THROW; + } + ACE_ENDTRY; ACE_CHECK; +} - invocation->endpoint_selection_state_.private_connection_ = - invocation->stub_->private_connection (); - - invocation->endpoint_selection_state_.bands_policy_ = - invocation->stub_->effective_priority_banded_connection (ACE_TRY_ENV); +void +TAO_Endpoint_Selector_Factory:: +init_bands (TAO_GIOP_Invocation *invocation, + CORBA::Environment &ACE_TRY_ENV) +{ + ACE_TRY + { + invocation->endpoint_selection_state_.bands_policy_ = + invocation->stub_->effective_priority_banded_connection (ACE_TRY_ENV); + ACE_TRY_CHECK; + } + ACE_CATCH (CORBA::INV_POLICY, ex) + { + if (invocation->inconsistent_policies_.ptr ()) + { + invocation->inconsistent_policies_->length (1); + invocation->inconsistent_policies_[0u] = + invocation->stub_->priority_banded_connection (); + } + ACE_RE_THROW; + } + ACE_ENDTRY; ACE_CHECK; } @@ -415,7 +459,16 @@ TAO_Priority_Endpoint_Selector::select_endpoint (TAO_GIOP_Invocation } else // case b - ACE_THROW (CORBA::INV_POLICY ()); + { + if (invocation->inconsistent_policies_.ptr ()) + { + invocation->inconsistent_policies_->length (1); + invocation->inconsistent_policies_[0u] = + CORBA::Policy::_duplicate (invocation-> + endpoint_selection_state_.priority_model_policy_); + } + ACE_THROW (CORBA::INV_POLICY ()); + } } } } @@ -492,6 +545,13 @@ TAO_Bands_Endpoint_Selector::select_endpoint (TAO_GIOP_Invocation // In both cases throw exception. (We are throwing // exception for case 'a' because the current implementation of // bands is not interoperable.) + if (invocation->inconsistent_policies_.ptr ()) + { + invocation->inconsistent_policies_->length (1); + invocation->inconsistent_policies_[0u] = + CORBA::Policy::_duplicate (invocation-> + endpoint_selection_state_.bands_policy_); + } ACE_THROW (CORBA::INV_POLICY ()); } } @@ -521,7 +581,16 @@ TAO_Protocol_Endpoint_Selector::select_endpoint (TAO_GIOP_Invocation { // Figure out proper exception. if (!invocation->endpoint_selection_state_.valid_endpoint_found_) - ACE_THROW (CORBA::INV_POLICY ()); + { + if (invocation->inconsistent_policies_.ptr ()) + { + invocation->inconsistent_policies_->length (1); + invocation->inconsistent_policies_[0u] = + CORBA::Policy::_duplicate (invocation-> + endpoint_selection_state_.client_protocol_policy_); + } + ACE_THROW (CORBA::INV_POLICY ()); + } else // At least one satisfactory endpoint was found, but // connection could not be established. @@ -634,7 +703,17 @@ TAO_Client_Priority_Policy_Selector::select_endpoint (TAO_GIOP_Invocation { // Figure out proper exception. if (!invocation->endpoint_selection_state_.valid_endpoint_found_) - ACE_THROW (CORBA::INV_POLICY ()); + { + if (invocation->inconsistent_policies_.ptr ()) + { + invocation->inconsistent_policies_->length (1); + invocation->inconsistent_policies_[0u] = + invocation->stub_->get_client_policy + (TAO_CLIENT_PRIORITY_POLICY_TYPE, + ACE_TRY_ENV); + } + ACE_THROW (CORBA::INV_POLICY ()); + } else // At least one satisfactory endpoint was found, but // connection could not be established. @@ -678,7 +757,17 @@ TAO_Client_Priority_Policy_Selector::select_endpoint (TAO_GIOP_Invocation if (invocation->endpoint_ == 0) // Figure out proper exception. if (!invocation->endpoint_selection_state_.valid_endpoint_found_) - ACE_THROW (CORBA::INV_POLICY ()); + { + if (invocation->inconsistent_policies_.ptr ()) + { + invocation->inconsistent_policies_->length (1); + invocation->inconsistent_policies_[0u] = + invocation->stub_->get_client_policy + (TAO_CLIENT_PRIORITY_POLICY_TYPE, + ACE_TRY_ENV); + } + ACE_THROW (CORBA::INV_POLICY ()); + } else // At least one satisfactory endpoint was found, but // connection could not be established. @@ -786,7 +875,16 @@ TAO_Priority_Protocol_Selector::endpoint (TAO_GIOP_Invocation *invocation, } else // case b - ACE_THROW (CORBA::INV_POLICY ()); + { + if (invocation->inconsistent_policies_.ptr ()) + { + invocation->inconsistent_policies_->length (1); + invocation->inconsistent_policies_[0u] = + CORBA::Policy::_duplicate (invocation-> + endpoint_selection_state_.priority_model_policy_); + } + ACE_THROW (CORBA::INV_POLICY ()); + } } } } @@ -849,6 +947,13 @@ TAO_Bands_Protocol_Selector::endpoint (TAO_GIOP_Invocation *invocation, // In both cases throw exception. (We are throwing // exception for case 'a' because the current implementation of // bands is not interoperable.) + if (invocation->inconsistent_policies_.ptr ()) + { + invocation->inconsistent_policies_->length (1); + invocation->inconsistent_policies_[0u] = + CORBA::Policy::_duplicate (invocation-> + endpoint_selection_state_.bands_policy_); + } ACE_THROW (CORBA::INV_POLICY ()); } } diff --git a/TAO/tao/Invocation_Endpoint_Selectors.h b/TAO/tao/Invocation_Endpoint_Selectors.h index 14b537ad36a..22f2551e729 100644 --- a/TAO/tao/Invocation_Endpoint_Selectors.h +++ b/TAO/tao/Invocation_Endpoint_Selectors.h @@ -80,9 +80,15 @@ private: // necessary. WARNING: TAO::Client_Pririority_Policy is // deprecated. See TAO RTCORBA documentation for more details. - void init_state (TAO_GIOP_Invocation *invocation, + void init_client_protocol (TAO_GIOP_Invocation *invocation, + CORBA::Environment &ACE_TRY_ENV); + // Initializes RTCORBA::ClientProtocolPolicy in the endpoint + // selection state. + + void init_bands (TAO_GIOP_Invocation *invocation, CORBA::Environment &ACE_TRY_ENV); - // Initializes <invocation>'s endpoint selection state. + // Initializes RTCORBA::PriorityBandsPolicy in the endpoint + // selection state. #endif /* TAO_HAS_RT_CORBA == 1 */ }; diff --git a/TAO/tao/Stub.cpp b/TAO/tao/Stub.cpp index 7e598f222b9..106079f3dfc 100644 --- a/TAO/tao/Stub.cpp +++ b/TAO/tao/Stub.cpp @@ -634,72 +634,48 @@ CORBA::Boolean TAO_Stub::validate_connection (CORBA::PolicyList_out inconsistent_policies, CORBA::Environment &ACE_TRY_ENV) { - inconsistent_policies = 0; - ACE_UNUSED_ARG (ACE_TRY_ENV); - -#if (TAO_HAS_CLIENT_PRIORITY_POLICY == 1) - - // Check if we care about Client Priority policy, and store the - // result in the variable called <set>. - int set = 1; - TAO::ClientPriorityPolicy *policy = - this->client_priority (); - if (policy == 0) - set = 0; - else - // Policy is set. - { - TAO::PrioritySpecification priority_spec = - policy->priority_specification (ACE_TRY_ENV); - ACE_CHECK_RETURN (0); - TAO::PrioritySelectionMode mode = priority_spec.mode; - - // Don't care about priority. - if (mode == TAO::USE_NO_PRIORITY) - set = 0; - } - // Use Locate Request to establish connection/make sure the object // is there ... TAO_GIOP_Locate_Request_Invocation locate_request (this, this->orb_core_); - //@@ Currently, if we select profiles based on priorities (i.e., - // ClientPriorityPolicy is set), and we get a FORWARD reply to our - // location request, we don't go to the new location - just return - // 0. This is because we don't yet have full support in - // MProfiles & friends for profiles used based on priorities. - // Once the support is there, we should follow a forwarded object - // to track it down, just like in the case where - // ClientPriorityPolicy is not set. At that point, we can remove - // a lot of 'special case' code from this function, along with - // this comment ;-) (marina). - for (;;) - { - locate_request.start (ACE_TRY_ENV); - ACE_CHECK_RETURN (0); - - int status = locate_request.invoke (ACE_TRY_ENV); - ACE_CHECK_RETURN (0); + locate_request.init_inconsistent_policies (ACE_TRY_ENV); + ACE_CHECK_RETURN (0); - // We'll get this only if the object was, in fact, forwarded. - if (status == TAO_INVOKE_RESTART) - if (set) - return 0; - else - continue; - - if (status != TAO_INVOKE_OK) + // @@ For some combinations of RTCORBA policies, location forwarding + // isn't supported. See <forward> method implementations in + // Invocation_Endpoint_Selectors.cpp for more information. + // + ACE_TRY + { + for (;;) { - ACE_THROW_RETURN (CORBA::UNKNOWN (TAO_DEFAULT_MINOR_CODE, - CORBA::COMPLETED_YES), - 0); - + locate_request.start (ACE_TRY_ENV); + ACE_TRY_CHECK; + + int status = locate_request.invoke (ACE_TRY_ENV); + ACE_TRY_CHECK; + + // We'll get this only if the object was, in fact, forwarded. + if (status == TAO_INVOKE_RESTART) + continue; + + if (status != TAO_INVOKE_OK) + { + ACE_TRY_THROW (CORBA::UNKNOWN (TAO_DEFAULT_MINOR_CODE, + CORBA::COMPLETED_YES)); + } + break; } - break; } - -#endif /* TAO_HAS_CLIENT_PRIORITY_POLICY == 1 */ + ACE_CATCH (CORBA::INV_POLICY, ex) + { + inconsistent_policies = + locate_request.get_inconsistent_policies (); + return 0; + } + ACE_ENDTRY; + ACE_CHECK_RETURN (0); return 1; } |