#include "tao/Remote_Invocation.h"#include "tao/Profile.h"#include "tao/Profile_Transport_Resolver.h"#include "tao/Stub.h"#include "tao/Connection_Handler.h"#include "tao/operation_details.h"#include "tao/ORB_Core.h"#include "tao/Protocols_Hooks.h"#include "tao/Network_Priority_Protocols_Hooks.h"#include "tao/debug.h"#include "tao/SystemException.h"
Go to the source code of this file.
Functions | |
| ACE_RCSID (tao, Remote_Invocation,"$Id: Remote_Invocation.cpp 84860 2009-03-17 10:17:38Z johnnyw $") 1 namespace TAO | |
| ACE_RCSID | ( | tao | , | |
| Remote_Invocation | , | |||
| "$Id: Remote_Invocation.cpp 84860 2009-03-17 10:17:38Z johnnyw $" | ||||
| ) |
Definition at line 15 of file Remote_Invocation.cpp.
00017 : Remote_Invocation.cpp 84860 2009-03-17 10:17:38Z johnnyw $") 00018 00019 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00020 00021 namespace TAO 00022 { 00023 Remote_Invocation::Remote_Invocation ( 00024 CORBA::Object_ptr otarget, 00025 Profile_Transport_Resolver &resolver, 00026 TAO_Operation_Details &detail, 00027 bool response_expected) 00028 : Invocation_Base (otarget, 00029 resolver.object (), 00030 resolver.stub (), 00031 detail, 00032 response_expected, 00033 true /* request_is_remote */ ) 00034 , resolver_ (resolver) 00035 { 00036 } 00037 00038 void 00039 Remote_Invocation::init_target_spec (TAO_Target_Specification &target_spec, 00040 TAO_OutputCDR &output) 00041 { 00042 // Generate all service contexts 00043 this->resolver_.stub ()->orb_core ()->service_context_registry (). 00044 generate_service_context ( 00045 this->resolver_.stub (), 00046 *this->resolver_.transport (), 00047 this->details_, 00048 target_spec, 00049 output); 00050 00051 TAO_Profile *pfile = this->resolver_.profile (); 00052 00053 // Set the target specification mode 00054 switch (pfile->addressing_mode ()) 00055 { 00056 case TAO_Target_Specification::Key_Addr: 00057 target_spec.target_specifier (pfile->object_key ()); 00058 break; 00059 case TAO_Target_Specification::Profile_Addr: 00060 { 00061 IOP::TaggedProfile *tp = pfile->create_tagged_profile (); 00062 00063 if (tp) 00064 { 00065 target_spec.target_specifier (*tp); 00066 } 00067 } 00068 break; 00069 00070 case TAO_Target_Specification::Reference_Addr: 00071 // We need to call the method seperately. If there is no 00072 // IOP::IOR info, the call would create the info and return the 00073 // index that we need. 00074 CORBA::ULong index = 0; 00075 IOP::IOR *ior_info = 0; 00076 00077 if (this->resolver_.stub ()->create_ior_info (ior_info, index) == -1) 00078 { 00079 if (TAO_debug_level > 0) 00080 { 00081 ACE_ERROR ((LM_ERROR, 00082 ACE_TEXT ("TAO (%P|%t) - ") 00083 ACE_TEXT ("Remote_Invocation::init_target_spec, ") 00084 ACE_TEXT ("Error in finding index for ") 00085 ACE_TEXT ("IOP::IOR\n"))); 00086 } 00087 00088 return; 00089 } 00090 00091 target_spec.target_specifier (*ior_info, index); 00092 break; 00093 } 00094 } 00095 00096 void 00097 Remote_Invocation::write_header (TAO_OutputCDR &out_stream) 00098 { 00099 this->resolver_.transport ()->clear_translators (0, &out_stream); 00100 00101 TAO_Target_Specification spec; 00102 this->init_target_spec (spec, out_stream); 00103 00104 // Send the request for the header 00105 if (this->resolver_.transport ()->generate_request_header (this->details_, 00106 spec, 00107 out_stream) == -1) 00108 { 00109 throw ::CORBA::MARSHAL (); 00110 } 00111 00112 this->resolver_.transport ()->assign_translators (0, &out_stream); 00113 } 00114 00115 void 00116 Remote_Invocation::marshal_data (TAO_OutputCDR &out_stream) 00117 { 00118 // Marshal application data 00119 if (this->details_.marshal_args (out_stream) == false) 00120 { 00121 throw ::CORBA::MARSHAL (); 00122 } 00123 } 00124 00125 Invocation_Status 00126 Remote_Invocation::send_message (TAO_OutputCDR &cdr, 00127 TAO_Message_Semantics message_semantics, 00128 ACE_Time_Value *max_wait_time) 00129 { 00130 TAO_Protocols_Hooks *tph = 00131 this->resolver_.stub ()->orb_core ()->get_protocols_hooks (); 00132 00133 TAO_Network_Priority_Protocols_Hooks *nph = 00134 this->resolver_.stub ()->orb_core ()-> 00135 get_network_priority_protocols_hooks (); 00136 00137 TAO_Connection_Handler *connection_handler = 00138 this->resolver_.transport ()->connection_handler (); 00139 00140 if (nph != 0) 00141 { 00142 // nph = 0, means DiffServ library is not used 00143 // nph = 0, means DiffServ library is used, and 00144 // request DSCP and reply DSCP are set. 00145 // Note that the application could still be using 00146 // RTCORBA, but still setting DIffServ codepoints 00147 // using the DiffServ library takes precedence. 00148 // 00149 CORBA::Long const dscp = nph->get_dscp_codepoint (this->resolver_.stub (), 00150 this->resolver_.object ()); 00151 connection_handler->set_dscp_codepoint (dscp); 00152 } 00153 else if (tph != 0) 00154 { 00155 // If we execute this code, DiffServ library is not used, 00156 // but RTCORBA could be used. 00157 // Which means that using the enable_network_priority flag, 00158 // the application might want to set DiffServ codepoints. 00159 // Check if that is the case. 00160 // 00161 CORBA::Boolean const set_client_network_priority = 00162 tph->set_client_network_priority ( 00163 this->resolver_.transport ()->tag (), 00164 this->resolver_.stub ()); 00165 connection_handler->set_dscp_codepoint (set_client_network_priority); 00166 } 00167 00168 // Note that if noth nph and tph are 0, then we do not make any 00169 // virtual calls any more, because we have removed the default 00170 // implementations. 00171 00172 int const retval = 00173 this->resolver_.transport ()->send_request ( 00174 this->resolver_.stub (), 00175 this->resolver_.stub ()->orb_core (), 00176 cdr, 00177 message_semantics, 00178 max_wait_time); 00179 00180 if (retval == -1) 00181 { 00182 if (errno == ETIME) 00183 { 00184 // We sent a message already and we haven't gotten a 00185 // reply. Just throw TIMEOUT with *COMPLETED_MAYBE*. 00186 throw ::CORBA::TIMEOUT ( 00187 CORBA::SystemException::_tao_minor_code ( 00188 TAO_TIMEOUT_SEND_MINOR_CODE, 00189 errno), 00190 CORBA::COMPLETED_MAYBE); 00191 } 00192 00193 if (TAO_debug_level > 2) 00194 { 00195 ACE_DEBUG ((LM_DEBUG, 00196 ACE_TEXT ("TAO (%P|%t) - ") 00197 ACE_TEXT ("Remote_Invocation::send_message, ") 00198 ACE_TEXT ("failure while sending message\n"))); 00199 } 00200 00201 // Close the transport and all the associated stuff along with 00202 // it. 00203 this->resolver_.transport ()->close_connection (); 00204 this->resolver_.stub ()->reset_profiles (); 00205 return TAO_INVOKE_RESTART; 00206 } 00207 00208 this->resolver_.stub ()->set_valid_profile (); 00209 return TAO_INVOKE_SUCCESS; 00210 } 00211 }
1.6.1