geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/HandShake.java
public ServerQueueStatus handshakeWithSubscriptionFeed(Socket sock, boolean isPrimary)
      throws IOException, AuthenticationRequiredException, AuthenticationFailedException,
      ServerRefusedConnectionException, ClassNotFoundException {
    ServerQueueStatus sqs = null;
    try {
      DataOutputStream dos = new DataOutputStream(sock.getOutputStream());
      final InputStream in = sock.getInputStream();
      DataInputStream dis = new DataInputStream(in);
      DistributedMember member = getIDForSocket(sock);
      if (!this.multiuserSecureMode) {
        this.credentials = getCredentials(member);
      }
      CommunicationMode mode = isPrimary ? CommunicationMode.PrimaryServerToClient
          : CommunicationMode.SecondaryServerToClient;
      write(dos, dis, mode, REPLY_OK, 0, new ArrayList(), this.credentials, member, true);

      // Wait here for a reply before continuing. This ensures that the client
      // updater is registered with the server before continuing.
      byte acceptanceCode = dis.readByte();
      if (acceptanceCode == (byte) 21 && !(sock instanceof SSLSocket)) {
        // This is likely the case of server setup with SSL and client not using
        // SSL
        throw new AuthenticationRequiredException(
            LocalizedStrings.HandShake_SERVER_EXPECTING_SSL_CONNECTION.toLocalizedString());
      }

      // No need to check for return value since DataInputStream already throws
      // EOFException in case of EOF
      byte qType = dis.readByte();
      // read and ignore qSize flag
      int qSize = dis.readInt();
      sqs = new ServerQueueStatus(qType, qSize, member);

      // Read the message (if any)
      readMessage(dis, dos, acceptanceCode, member);

      // [sumedh] nothing more to be done for older clients used in tests
      // there is a difference in serializer map registration for >= 6.5.1.6
      // clients but that is not used in tests
      if (currentClientVersion.compareTo(Version.GFE_61) < 0) {
        return sqs;
      }
      HashMap instantiatorMap = DataSerializer.readHashMap(dis);
      for (Iterator itr = instantiatorMap.entrySet().iterator(); itr.hasNext();) {
        Map.Entry instantiator = (Map.Entry) itr.next();
        Integer id = (Integer) instantiator.getKey();
        ArrayList instantiatorArguments = (ArrayList) instantiator.getValue();
        InternalInstantiator.register((String) instantiatorArguments.get(0),
            (String) instantiatorArguments.get(1), id, false);
      }

      HashMap dataSerializersMap = DataSerializer.readHashMap(dis);
      for (Iterator itr = dataSerializersMap.entrySet().iterator(); itr.hasNext();) {
        Map.Entry dataSerializer = (Map.Entry) itr.next();
        Integer id = (Integer) dataSerializer.getKey();
        InternalDataSerializer.register((String) dataSerializer.getValue(), false, null, null, id);
      }
      HashMap<Integer, ArrayList<String>> dsToSupportedClassNames = DataSerializer.readHashMap(dis);
      InternalDataSerializer.updateSupportedClassesMap(dsToSupportedClassNames);
    } catch (IOException ex) {
      CancelCriterion stopper = this.system.getCancelCriterion();
      stopper.checkCancelInProgress(null);
      throw ex;
    } catch (ClassNotFoundException ex) {
      CancelCriterion stopper = this.system.getCancelCriterion();
      stopper.checkCancelInProgress(null);
      throw ex;
    }
    return sqs;
  }
/**
   * Used by client-side CacheClientUpdater to handshake with a server in order to receive messages
   * generated by subscriptions (register-interest, continuous query)
   */
Used by client-side CacheClientUpdater to handshake with a server in order to receive messages
generated by subscriptions (register-interest, continuous query)
Used by client - side CacheClientUpdater to handshake with a server in order to receive messages generated by subscriptions ( register - interest continuous query )
public ServerQueueStatus handshakeWithSubscriptionFeed(Socket sock, boolean isPrimary)
      throws IOException, AuthenticationRequiredException, AuthenticationFailedException,
      ServerRefusedConnectionException, ClassNotFoundException {
    ServerQueueStatus sqs = null;
    try {
      DataOutputStream dos = new DataOutputStream(sock.getOutputStream());
      final InputStream in = sock.getInputStream();
      DataInputStream dis = new DataInputStream(in);
      DistributedMember member = getIDForSocket(sock);
      if (!this.multiuserSecureMode) {
        this.credentials = getCredentials(member);
      }
      CommunicationMode mode = isPrimary ? CommunicationMode.PrimaryServerToClient
          : CommunicationMode.SecondaryServerToClient;
      write(dos, dis, mode, REPLY_OK, 0, new ArrayList(), this.credentials, member, true);
      byte acceptanceCode = dis.readByte();
      if (acceptanceCode == (byte) 21 && !(sock instanceof SSLSocket)) {
        throw new AuthenticationRequiredException(
            LocalizedStrings.HandShake_SERVER_EXPECTING_SSL_CONNECTION.toLocalizedString());
      }
      byte qType = dis.readByte();
      int qSize = dis.readInt();
      sqs = new ServerQueueStatus(qType, qSize, member);
      readMessage(dis, dos, acceptanceCode, member);
      if (currentClientVersion.compareTo(Version.GFE_61) < 0) {
        return sqs;
      }
      HashMap instantiatorMap = DataSerializer.readHashMap(dis);
      for (Iterator itr = instantiatorMap.entrySet().iterator(); itr.hasNext();) {
        Map.Entry instantiator = (Map.Entry) itr.next();
        Integer id = (Integer) instantiator.getKey();
        ArrayList instantiatorArguments = (ArrayList) instantiator.getValue();
        InternalInstantiator.register((String) instantiatorArguments.get(0),
            (String) instantiatorArguments.get(1), id, false);
      }
      HashMap dataSerializersMap = DataSerializer.readHashMap(dis);
      for (Iterator itr = dataSerializersMap.entrySet().iterator(); itr.hasNext();) {
        Map.Entry dataSerializer = (Map.Entry) itr.next();
        Integer id = (Integer) dataSerializer.getKey();
        InternalDataSerializer.register((String) dataSerializer.getValue(), false, null, null, id);
      }
      HashMap<Integer, ArrayList<String>> dsToSupportedClassNames = DataSerializer.readHashMap(dis);
      InternalDataSerializer.updateSupportedClassesMap(dsToSupportedClassNames);
    } catch (IOException ex) {
      CancelCriterion stopper = this.system.getCancelCriterion();
      stopper.checkCancelInProgress(null);
      throw ex;
    } catch (ClassNotFoundException ex) {
      CancelCriterion stopper = this.system.getCancelCriterion();
      stopper.checkCancelInProgress(null);
      throw ex;
    }
    return sqs;
  }
public ServerQueueStatus handshakeWithSubscriptionFeed ( Socket sock , boolean isPrimary ) throws IOException , AuthenticationRequiredException , AuthenticationFailedException , ServerRefusedConnectionException , ClassNotFoundException { ServerQueueStatus sqs = null ; try { DataOutputStream dos = new DataOutputStream ( sock . getOutputStream ( ) ) ; final InputStream in = sock . getInputStream ( ) ; DataInputStream dis = new DataInputStream ( in ) ; DistributedMember member = getIDForSocket ( sock ) ; if ( ! this . multiuserSecureMode ) { this . credentials = getCredentials ( member ) ; } CommunicationMode mode = isPrimary ? CommunicationMode . PrimaryServerToClient : CommunicationMode . SecondaryServerToClient ; write ( dos , dis , mode , REPLY_OK , 0 , new ArrayList ( ) , this . credentials , member , true ) ; byte acceptanceCode = dis . readByte ( ) ; if ( acceptanceCode == ( byte ) 21 && ! ( sock instanceof SSLSocket ) ) { throw new AuthenticationRequiredException ( LocalizedStrings . HandShake_SERVER_EXPECTING_SSL_CONNECTION . toLocalizedString ( ) ) ; } byte qType = dis . readByte ( ) ; int qSize = dis . readInt ( ) ; sqs = new ServerQueueStatus ( qType , qSize , member ) ; readMessage ( dis , dos , acceptanceCode , member ) ; if ( currentClientVersion . compareTo ( Version . GFE_61 ) < 0 ) { return sqs ; } HashMap instantiatorMap = DataSerializer . readHashMap ( dis ) ; for ( Iterator itr = instantiatorMap . entrySet ( ) . iterator ( ) ; itr . hasNext ( ) ; ) { Map . Entry instantiator = ( Map . Entry ) itr . next ( ) ; Integer id = ( Integer ) instantiator . getKey ( ) ; ArrayList instantiatorArguments = ( ArrayList ) instantiator . getValue ( ) ; InternalInstantiator . register ( ( String ) instantiatorArguments . get ( 0 ) , ( String ) instantiatorArguments . get ( 1 ) , id , false ) ; } HashMap dataSerializersMap = DataSerializer . readHashMap ( dis ) ; for ( Iterator itr = dataSerializersMap . entrySet ( ) . iterator ( ) ; itr . hasNext ( ) ; ) { Map . Entry dataSerializer = ( Map . Entry ) itr . next ( ) ; Integer id = ( Integer ) dataSerializer . getKey ( ) ; InternalDataSerializer . register ( ( String ) dataSerializer . getValue ( ) , false , null , null , id ) ; } HashMap < Integer , ArrayList < String > > dsToSupportedClassNames = DataSerializer . readHashMap ( dis ) ; InternalDataSerializer . updateSupportedClassesMap ( dsToSupportedClassNames ) ; } catch ( IOException ex ) { CancelCriterion stopper = this . system . getCancelCriterion ( ) ; stopper . checkCancelInProgress ( null ) ; throw ex ; } catch ( ClassNotFoundException ex ) { CancelCriterion stopper = this . system . getCancelCriterion ( ) ; stopper . checkCancelInProgress ( null ) ; throw ex ; } return sqs ; }
Used by client-side CacheClientUpdater to handshake with a server in order to receive messages
 generated by subscriptions (register-interest, continuous query)
Used by client - side CacheClientUpdater to handshake with a server in order to receive messages generated by subscriptions ( register - interest continuous query )
// Wait here for a reply before continuing. This ensures that the client // updater is registered with the server before continuing. // This is likely the case of server setup with SSL and client not using // SSL // No need to check for return value since DataInputStream already throws // EOFException in case of EOF // read and ignore qSize flag // Read the message (if any) // [sumedh] nothing more to be done for older clients used in tests // there is a difference in serializer map registration for >= 6.5.1.6 // clients but that is not used in tests