#include <SCIOP_Connector.h>
Inheritance diagram for TAO_SCIOP_Connector:
Concrete instance of the TAO_Connector class. Responsible for establishing a connection with a server and is called from the Connector_Registory.
Definition at line 48 of file SCIOP_Connector.h.
|
Definition at line 82 of file SCIOP_Connector.h. |
|
Definition at line 71 of file SCIOP_Connector.h. Referenced by open(). |
|
Definition at line 74 of file SCIOP_Connector.h. Referenced by open(). |
|
Definition at line 78 of file SCIOP_Connector.h. |
|
Constructor.
Definition at line 30 of file SCIOP_Connector.cpp. References TAO_TAG_SCIOP_PROFILE.
00031 : TAO_Connector (TAO_TAG_SCIOP_PROFILE), 00032 connect_strategy_ (), 00033 base_connector_ () 00034 { 00035 } |
|
Destructor.
Definition at line 37 of file SCIOP_Connector.cpp.
00038 { 00039 } |
|
Cancel the passed cvs handler from the connector.
Implements TAO_Connector. Definition at line 422 of file SCIOP_Connector.cpp. References ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::cancel().
00424 { 00425 TAO_SCIOP_Connection_Handler* handler= 00426 dynamic_cast<TAO_SCIOP_Connection_Handler*>(svc_handler); 00427 00428 if (handler) 00429 // Cancel from the connector 00430 return this->base_connector_.cancel (handler); 00431 00432 return -1; 00433 } |
|
Implements TAO_Connector. Definition at line 374 of file SCIOP_Connector.cpp. References ACE_OS::strchr(), ACE_OS::strlen(), and ACE_OS::strncasecmp().
00375 { 00376 // Check for a valid string 00377 if (!endpoint || !*endpoint) 00378 return -1; // Failure 00379 00380 const char *protocol[] = { "sciop", "scioploc" }; 00381 00382 size_t slot = ACE_OS::strchr (endpoint, ':') - endpoint; 00383 00384 size_t len0 = ACE_OS::strlen (protocol[0]); 00385 size_t len1 = ACE_OS::strlen (protocol[1]); 00386 00387 // Check for the proper prefix in the IOR. If the proper prefix 00388 // isn't in the IOR then it is not an IOR we can use. 00389 if (slot == len0 00390 && ACE_OS::strncasecmp (endpoint, protocol[0], len0) == 0) 00391 return 0; 00392 else if (slot == len1 00393 && ACE_OS::strncasecmp (endpoint, protocol[1], len1) == 0) 00394 return 0; 00395 00396 return -1; 00397 // Failure: not an SCIOP IOR 00398 // DO NOT throw an exception here. 00399 } |
|
Implements TAO_Connector. Definition at line 78 of file SCIOP_Connector.cpp. References ACE_Strategy_Connector< SVC_HANDLER, >::close(), ACE_Strategy_Connector< SVC_HANDLER, >::concurrency_strategy(), and ACE_Strategy_Connector< SVC_HANDLER, >::creation_strategy().
00079 { 00080 delete this->base_connector_.concurrency_strategy (); 00081 delete this->base_connector_.creation_strategy (); 00082 return this->base_connector_.close (); 00083 } |
|
Implements TAO_Connector. Definition at line 336 of file SCIOP_Connector.cpp. References TAO_Profile::_decr_refcnt(), ACE_NEW_RETURN, and TAO_Profile::decode().
00337 { 00338 TAO_Profile *pfile = 0; 00339 ACE_NEW_RETURN (pfile, 00340 TAO_SCIOP_Profile (this->orb_core ()), 00341 0); 00342 00343 int const r = pfile->decode (cdr); 00344 if (r == -1) 00345 { 00346 pfile->_decr_refcnt (); 00347 pfile = 0; 00348 } 00349 00350 return pfile; 00351 } |
|
Implements TAO_Connector. Definition at line 118 of file SCIOP_Connector.cpp. References TAO_Transport_Descriptor_Interface::endpoint(), make_connection_i(), TAO_Endpoint::next(), and remote_endpoint().
00121 { 00122 TAO_Endpoint *tao_endpoint = desc.endpoint (); 00123 00124 TAO_Transport *transport = 0; 00125 00126 // @@ ATL folks, is this while loop needed? 00127 // TAO_Default_Endpoint_Selector has this code already, i.e., the 00128 // loop. 00129 while (tao_endpoint != 0) 00130 { 00131 TAO_SCIOP_Endpoint *sciop_endpoint = this->remote_endpoint (tao_endpoint); 00132 00133 if (sciop_endpoint != 0) 00134 { 00135 transport = 00136 this->make_connection_i (r, desc, timeout, sciop_endpoint); 00137 if (transport) 00138 { 00139 break; 00140 } 00141 } 00142 tao_endpoint = tao_endpoint->next(); 00143 } 00144 00145 return transport; 00146 } |
|
Try to make a connection to the next endpoint in the list.
Definition at line 150 of file SCIOP_Connector.cpp. References ACE_DEBUG, ACE_ERROR, ACE_TEXT, ACE_TEXT_CHAR_TO_TCHAR, TAO::Profile_Transport_Resolver::blocked_connect(), TAO::Transport_Cache_Manager::cache_transport(), TAO_Connection_Handler::cancel_pending_connection(), TAO_SCIOP_Connection_Handler::close(), TAO_Transport::close_connection(), ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::connect(), TAO_Connection_Handler::connection_pending(), TAO_LF_CH_Event::error_detected(), EWOULDBLOCK, ACE_INET_Addr::get_ip_address(), ACE_INET_Addr::get_port_number(), TAO_SCIOP_Endpoint::host(), TAO_Transport::id(), TAO_Transport::is_connected(), TAO_SCIOP_Endpoint::is_preferred_network(), TAO_LF_Event::keep_waiting(), TAO_ORB_Core::lane_resources(), LM_DEBUG, LM_ERROR, TAO_SCIOP_Endpoint::object_addr(), TAO_Connector::orb_core(), TAO_SCIOP_Endpoint::port(), TAO_SCIOP_Endpoint::preferred_network(), TAO_Transport::purge_entry(), TAO_Wait_Strategy::register_handler(), ACE_Multihomed_INET_Addr::set(), TAO_Connect_Strategy::synch_options(), TAO_debug_level, TAO_Connection_Handler::transport(), TAO_Thread_Lane_Resources::transport_cache(), TAO_Connector::wait_for_connection_completion(), and TAO_Transport::wait_strategy(). Referenced by make_connection().
00154 { 00155 const ACE_INET_Addr &remote_address = 00156 sciop_endpoint->object_addr (); 00157 00158 if (TAO_debug_level > 2) 00159 ACE_DEBUG ((LM_DEBUG, 00160 "TAO (%P|%t) - SCIOP_Connector::make_connection_i, " 00161 "to <%s:%d> which should %s\n", 00162 ACE_TEXT_CHAR_TO_TCHAR(sciop_endpoint->host()), 00163 sciop_endpoint->port(), 00164 r->blocked_connect () ? ACE_TEXT("block") : ACE_TEXT("nonblock"))); 00165 00166 // Get the right synch options 00167 ACE_Synch_Options synch_options; 00168 00169 this->active_connect_strategy_->synch_options (timeout, synch_options); 00170 00171 // The code used to set the timeout to zero, with the intent of 00172 // polling the reactor for connection completion. However, the side-effect 00173 // was to cause the connection to timeout immediately. 00174 00175 TAO_SCIOP_Connection_Handler *svc_handler = 0; 00176 00177 // Connect. 00178 ACE_Multihomed_INET_Addr multihomed; 00179 if (multihomed.set(remote_address.get_port_number(), 00180 remote_address.get_ip_address())) 00181 return 0; 00182 00183 ACE_Multihomed_INET_Addr local_address; 00184 00185 bool pn = 00186 sciop_endpoint->is_preferred_network (); 00187 00188 if (pn) 00189 local_address.set ((u_short) 0, 00190 sciop_endpoint->preferred_network ()); 00191 00192 int result = 00193 this->base_connector_.connect (svc_handler, 00194 multihomed, 00195 synch_options, 00196 local_address); 00197 00198 // This call creates the service handler and bumps the #REFCOUNT# up 00199 // one extra. There are three possibilities: (a) connection 00200 // succeeds immediately - in this case, the #REFCOUNT# on the 00201 // handler is two; (b) connection completion is pending - in this 00202 // case, the #REFCOUNT# on the handler is also two; (c) connection 00203 // fails immediately - in this case, the #REFCOUNT# on the handler 00204 // is one since close() gets called on the handler. 00205 // 00206 // The extra reference count in 00207 // TAO_Connect_Creation_Strategy::make_svc_handler() is needed in 00208 // the case when connection completion is pending and we are going 00209 // to wait on a variable in the handler to changes, signifying 00210 // success or failure. Note, that this increment cannot be done 00211 // once the connect() returns since this might be too late if 00212 // another thread pick up the completion and potentially deletes the 00213 // handler before we get a chance to increment the reference count. 00214 00215 // Make sure that we always do a remove_reference 00216 ACE_Event_Handler_var svc_handler_auto_ptr (svc_handler); 00217 00218 TAO_Transport *transport = svc_handler->transport (); 00219 00220 if (result == -1) 00221 { 00222 // No immediate result, wait for completion 00223 if (errno == EWOULDBLOCK) 00224 { 00225 // Try to wait until connection completion. Incase we block, then we 00226 // get a connected transport or not. In case of non block we get 00227 // a connected or not connected transport 00228 if (!this->wait_for_connection_completion (r, 00229 transport, 00230 timeout)) 00231 { 00232 if (TAO_debug_level > 2) 00233 ACE_ERROR ((LM_ERROR, "TAO (%P|%t) - SCIOP_Connector::" 00234 "make_connection_i, " 00235 "wait for completion failed\n")); 00236 } 00237 } 00238 else 00239 { 00240 // Transport is not usable 00241 transport = 0; 00242 } 00243 } 00244 00245 // In case of errors transport is zero 00246 if (transport == 0) 00247 { 00248 // Give users a clue to the problem. 00249 if (TAO_debug_level) 00250 { 00251 ACE_ERROR ((LM_ERROR, 00252 "TAO (%P|%t) - SCIOP_Connector::make_connection_i, " 00253 "connection to <%s:%d> failed (%p)\n", 00254 sciop_endpoint->host (), sciop_endpoint->port (), 00255 "errno")); 00256 } 00257 00258 return 0; 00259 } 00260 00261 if (svc_handler->keep_waiting ()) 00262 { 00263 svc_handler->connection_pending (); 00264 } 00265 00266 if (svc_handler->error_detected ()) 00267 { 00268 svc_handler->cancel_pending_connection (); 00269 return 0; 00270 } 00271 00272 // At this point, the connection has be successfully connected. 00273 // #REFCOUNT# is one. 00274 if (TAO_debug_level > 2) 00275 ACE_DEBUG ((LM_DEBUG, 00276 "TAO (%P|%t) - SCIOP_Connector::make_connection_i, " 00277 "new %s connection to <%s:%d> on Transport[%d]\n", 00278 transport->is_connected() ? "connected" : "not connected", 00279 sciop_endpoint->host (), sciop_endpoint->port (), 00280 svc_handler->peer ().get_handle ())); 00281 00282 // Add the handler to Cache 00283 int retval = 00284 this->orb_core ()->lane_resources ().transport_cache ().cache_transport (&desc, 00285 transport); 00286 00287 // Failure in adding to cache. 00288 if (retval != 0) 00289 { 00290 // Close the handler. 00291 svc_handler->close (); 00292 00293 if (TAO_debug_level > 0) 00294 { 00295 ACE_ERROR ((LM_ERROR, 00296 "TAO (%P|%t) - SCIOP_Connector::make_connection_i, " 00297 "could not add the new connection to cache\n")); 00298 } 00299 00300 return 0; 00301 } 00302 00303 if (svc_handler->error_detected ()) 00304 { 00305 svc_handler->cancel_pending_connection (); 00306 transport->purge_entry(); 00307 return 0; 00308 } 00309 00310 if (transport->is_connected () && 00311 transport->wait_strategy ()->register_handler () != 0) 00312 { 00313 // Registration failures. 00314 00315 // Purge from the connection cache, if we are not in the cache, this 00316 // just does nothing. 00317 (void) transport->purge_entry (); 00318 00319 // Close the handler. 00320 (void) transport->close_connection (); 00321 00322 if (TAO_debug_level > 0) 00323 ACE_ERROR ((LM_ERROR, 00324 "TAO (%P|%t) - SCIOP_Connector [%d]::make_connection_i, " 00325 "could not register the transport " 00326 "in the reactor.\n", 00327 transport->id ())); 00328 00329 return 0; 00330 } 00331 00332 return transport; 00333 } |
|
More TAO_Connector methods, please check the documentation on Transport_Connector.h Implements TAO_Connector. Definition at line 354 of file SCIOP_Connector.cpp. References ACE_NEW_THROW_EX.
00355 { 00356 // The endpoint should be of the form: 00357 // N.n@host:port/object_key 00358 // or: 00359 // host:port/object_key 00360 00361 TAO_Profile *profile = 0; 00362 ACE_NEW_THROW_EX (profile, 00363 TAO_SCIOP_Profile (this->orb_core ()), 00364 CORBA::NO_MEMORY ( 00365 CORBA::SystemException::_tao_minor_code ( 00366 TAO::VMCID, 00367 ENOMEM), 00368 CORBA::COMPLETED_NO)); 00369 00370 return profile; 00371 } |
|
Implements TAO_Connector. Definition at line 402 of file SCIOP_Connector.cpp.
00403 { 00404 return TAO_SCIOP_Profile::object_key_delimiter_; 00405 } |
|
Our connect creation strategy Our activation strategy Implements TAO_Connector. Definition at line 42 of file SCIOP_Connector.cpp. References ACE_NEW_RETURN, TAO_Connector::create_connect_strategy(), ACE_Strategy_Connector< SVC_HANDLER, >::open(), TAO_Connector::orb_core(), TAO_SCIOP_CONNECT_CONCURRENCY_STRATEGY, TAO_SCIOP_CONNECT_CREATION_STRATEGY, and TAO_ORB_Core::thr_mgr().
00043 { 00044 // @todo: The functionality of the following two statements could 00045 // be done in the constructor, but that involves changing the 00046 // interface of the pluggable transport factory. 00047 00048 // Set the ORB Core 00049 this->orb_core (orb_core); 00050 00051 // Create our connect strategy 00052 if (this->create_connect_strategy () == -1) 00053 return -1; 00054 00055 /// Our connect creation strategy 00056 TAO_SCIOP_CONNECT_CREATION_STRATEGY *connect_creation_strategy = 0; 00057 00058 ACE_NEW_RETURN (connect_creation_strategy, 00059 TAO_SCIOP_CONNECT_CREATION_STRATEGY 00060 (orb_core->thr_mgr (), 00061 orb_core), 00062 -1); 00063 00064 /// Our activation strategy 00065 TAO_SCIOP_CONNECT_CONCURRENCY_STRATEGY *concurrency_strategy = 0; 00066 00067 ACE_NEW_RETURN (concurrency_strategy, 00068 TAO_SCIOP_CONNECT_CONCURRENCY_STRATEGY (orb_core), 00069 -1); 00070 00071 return this->base_connector_.open (this->orb_core ()->reactor (), 00072 connect_creation_strategy, 00073 &this->connect_strategy_, 00074 concurrency_strategy); 00075 } |
|
Return the remote endpoint, a helper function.
Definition at line 408 of file SCIOP_Connector.cpp. References TAO_Endpoint::tag(), and TAO_TAG_SCIOP_PROFILE. Referenced by make_connection(), and set_validate_endpoint().
00409 { 00410 if (endpoint->tag () != TAO_TAG_SCIOP_PROFILE) 00411 return 0; 00412 00413 TAO_SCIOP_Endpoint *sciop_endpoint = 00414 dynamic_cast<TAO_SCIOP_Endpoint *> (endpoint ); 00415 if (sciop_endpoint == 0) 00416 return 0; 00417 00418 return sciop_endpoint; 00419 } |
|
Implements TAO_Connector. Definition at line 86 of file SCIOP_Connector.cpp. References ACE_DEBUG, ACE_TEXT, AF_INET, ACE_Addr::get_type(), LM_DEBUG, TAO_SCIOP_Endpoint::object_addr(), remote_endpoint(), and TAO_debug_level.
00087 { 00088 TAO_SCIOP_Endpoint *sciop_endpoint = 00089 this->remote_endpoint (endpoint); 00090 00091 if (sciop_endpoint == 0) 00092 return -1; 00093 00094 const ACE_INET_Addr &remote_address = 00095 sciop_endpoint->object_addr (); 00096 00097 // Verify that the remote ACE_INET_Addr was initialized properly. 00098 // Failure can occur if hostname lookup failed when initializing the 00099 // remote ACE_INET_Addr. 00100 if (remote_address.get_type () != AF_INET) 00101 { 00102 if (TAO_debug_level > 0) 00103 { 00104 ACE_DEBUG ((LM_DEBUG, 00105 ACE_TEXT ("TAO (%P|%t) SCIOP connection failed.\n") 00106 ACE_TEXT ("TAO (%P|%t) This is most likely ") 00107 ACE_TEXT ("due to a hostname lookup ") 00108 ACE_TEXT ("failure.\n"))); 00109 } 00110 00111 return -1; 00112 } 00113 00114 return 0; 00115 } |
|
The connector initiating connection requests for SCIOP.
Definition at line 118 of file SCIOP_Connector.h. |
|
Our connect strategy.
Definition at line 115 of file SCIOP_Connector.h. |