[SERVER-19420] Implement Connection Hooking in NetworkInterfaceASIO Created: 15/Jul/15  Updated: 19/Sep/15  Resolved: 18/Aug/15

Status: Closed
Project: Core Server
Component/s: Networking
Affects Version/s: None
Fix Version/s: 3.1.7

Type: Task Priority: Major - P3
Reporter: Adam Midvidy Assignee: Adam Midvidy
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-19343 Inject SocketFactory in to NetworkInt... Closed
is depended on by SERVER-19439 Implement connect hook interface in N... Closed
Related
is related to SERVER-20033 Add ShardingNetworkConnectionHook to ... Closed
Backwards Compatibility: Fully Compatible
Sprint: Platform 8 08/28/15, Platform 7 08/10/15
Participants:

 Description   

As per discussion with kaloian.manassiev, we are going to implement hooking in NetworkInterfaceASIO to facilitate running setShardVersion when we connect to a shard.

class ConnectHookInterface {
    /**
     * Runs optional validation logic on an isMaster reply from a remote host.
     * If a non-OK Status is returned, a the ErrorCode 
     * XXXTemporaryNamePHostValidationFailedXXXTemporaryName will be passed to     
     * the command handler associated with the request that caused this       
     * connection to be created. This will be called once for each new   
     * connection that is established 
     * - even if we have previously connected a host with the same   HostAndPort.
     */
    virtual Status validateHost(const HostAndPort&, const BSONObj& isMasterReply) = 0;
 
    /**
     * Generates a command to run on the remote host immediately after        
     * connecting to it. This will be run after socket setup, SSL handshake,          
     * authentication and wire protocol detection occurs.
     */
    virtual RemoteCommandRequest makeRequest(const HostAndPort& remote) = 0;
 
    /**
     * Handles the server's reply to the command generated with makeCommand.
     */
    virtual Status handleReply(StatusWith<RemoteCommandResponse>&& reply) = 0;
};  
 
/**
 * Sets a connect hook for this NetworkInterface. This method can only be  
 * called once, and must be called before startup() - otherwise the result 
 * is undefined.
 */
void NetworkInterfaceASIO::setConnectHook(std::unique_ptr<ConnectionHookInterface> hook);



 Comments   
Comment by Githook User [ 18/Aug/15 ]

Author:

{u'username': u'amidvidy', u'name': u'Adam Midvidy', u'email': u'amidvidy@gmail.com'}

Message: SERVER-19420 don't use exception ptr in network_interface_asio_test
Branch: master
https://github.com/mongodb/mongo/commit/9d2cd34feffcecc1a6cab6953e5f67d6efcf40ff

Comment by Githook User [ 18/Aug/15 ]

Author:

{u'username': u'amidvidy', u'name': u'Adam Midvidy', u'email': u'amidvidy@gmail.com'}

Message: SERVER-19420 implement connection hook API in NetworkInterfaceASIO
Branch: master
https://github.com/mongodb/mongo/commit/e6ddd3da54a42088e5fa524df34f06def842eda9

Comment by Githook User [ 28/Jul/15 ]

Author:

{u'username': u'amidvidy', u'name': u'Adam Midvidy', u'email': u'amidvidy@gmail.com'}

Message: SERVER-19420 add ConnectionHook interface to NetworkInterface, and add stubs
Branch: master
https://github.com/mongodb/mongo/commit/4e2ef9c48e7df15e5e55afcc985f4b501c69e52d

Comment by Githook User [ 23/Jul/15 ]

Author:

{u'username': u'amidvidy', u'name': u'Adam Midvidy', u'email': u'amidvidy@gmail.com'}

Message: SERVER-19420 add ConnectionHook interface to NetworkInterface, and add stubs
Branch: master
https://github.com/mongodb/mongo/commit/4e2ef9c48e7df15e5e55afcc985f4b501c69e52d

Generated at Thu Feb 08 03:50:55 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.