Class ProtocolHelloHandler

java.lang.Object
com.loomcache.server.network.ProtocolHelloHandler

public final class ProtocolHelloHandler extends Object
Server-side handler for the PROTOCOL_HELLO opcode introduced in BLK-2026-04-22-007 Day 1.

When a peer sends PROTOCOL_HELLO with its advertised HelloPayload, this handler runs the bidirectional version compatibility check through ProtocolNegotiator. Success: the peer's negotiated protocol version + feature bitmap are stamped on the ConnectionContext and a PROTOCOL_HELLO_ACK response is returned carrying this build's own HelloPayload so the initiator can validate symmetrically. Failure: a RESPONSE_ERROR is returned with an actionable message and the connection is left open — the caller decides whether to close based on policy (strict vs. permissive).

This handler is invoked only after the frame has passed MessageCodec decoding, so it cannot downgrade or adapt older wire versions. Legacy peers keep working only if they already speak the same MessageCodec.PROTOCOL_VERSION and simply omit HELLO.

Thread-safety: stateless. Safe to invoke from any handler thread.

  • Constructor Details

    • ProtocolHelloHandler

      public ProtocolHelloHandler(EnumSet<ProtocolFeatures> localFeatures)
      Parameters:
      localFeatures - the features this build advertises (non-null, may be empty)
  • Method Details

    • handle

      public Message handle(Message request, ConnectionContext sender)
      Handle an incoming PROTOCOL_HELLO request.
      Parameters:
      request - the request message (non-null, opcode must be PROTOCOL_HELLO)
      sender - the originating connection — stamped with negotiated metadata on success
      Returns:
      a PROTOCOL_HELLO_ACK on success or RESPONSE_ERROR on failure