Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-19420

Implement Connection Hooking in NetworkInterfaceASIO

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.1.7
    • Affects Version/s: None
    • Component/s: Networking
    • None
    • Fully Compatible
    • Platform 8 08/28/15, Platform 7 08/10/15

      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);
      
      

            Assignee:
            adam.midvidy Adam Midvidy
            Reporter:
            adam.midvidy Adam Midvidy
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: