Class AbstractEndpoint

    • Field Detail

      • FORCE_DNS_LOOKUP_ON_RECONNECT

        protected static final boolean FORCE_DNS_LOOKUP_ON_RECONNECT
        A flag which controls whether the endpoint should force a DNS lookup request for the provided hostname in case the socket get disconnect.
    • Constructor Detail

      • AbstractEndpoint

        protected AbstractEndpoint​(String hostname,
                                   String bucket,
                                   String username,
                                   String password,
                                   int port,
                                   CoreContext ctx,
                                   boolean isTransient,
                                   EventLoopGroup ioPool,
                                   boolean pipeline)
        Create a new AbstractEndpoint.
        Parameters:
        hostname - the hostname/ipaddr of the remote channel.
        bucket - the name of the bucket.
        username - the user authorized for bucket access.
        password - the password of the user.
        port - the port of the remote channel.
        ctx - the core context.
    • Method Detail

      • customEndpointHandlers

        protected abstract void customEndpointHandlers​(ChannelPipeline pipeline)
        Add custom endpoint handlers to the ChannelPipeline. This method needs to be implemented by the actual endpoint implementations to add specific handlers to the pipeline depending on the endpoint type and intended behavior.
        Parameters:
        pipeline - the pipeline where to add handlers.
      • connect

        public rx.Observable<LifecycleState> connect()
        Description copied from interface: Endpoint
        Connect the Endpoint to the underlying channel.
        Specified by:
        connect in interface Endpoint
        Returns:
        a Observable with the state after the connect process finishes.
      • connect

        protected rx.Observable<LifecycleState> connect​(boolean bootstrapping)
        An internal alternative to connect() where signalling that this is post-bootstrapping can be done.
        Parameters:
        bootstrapping - is this connect attempt made during bootstrap or after (in which case more error cases are eligible for retries).
      • doConnect

        protected void doConnect​(rx.subjects.Subject<LifecycleState,​LifecycleState> observable,
                                 boolean bootstrapping)
        Helper method to perform the actual connect and reconnect.
        Parameters:
        observable - the Subject which is eventually notified if the connect process succeeded or failed.
        bootstrapping - true if connection attempt is for bootstrapping phase and therefore be less forgiving of some errors (like socket connect timeout).
      • disconnect

        public rx.Observable<LifecycleState> disconnect()
        Description copied from interface: Endpoint
        Disconnect the Endpoint from the underlying channel.
        Specified by:
        disconnect in interface Endpoint
        Returns:
        a Observable with the state after the disconnect process finishes.
      • notifyChannelInactive

        public void notifyChannelInactive()
        Helper method that is called from inside the event loop to notify the upper Endpoint of a disconnect. Note that the connect method is only called if the endpoint is currently connected, since otherwise this would try to connect to a socket which has already been removed on a failover/rebalance out. Subsequent reconnect attempts are triggered from here. A config reload is only signalled if the current endpoint is not in a DISCONNECTED state, avoiding to signal a config reload under the case of a regular, intended channel close (in an unexpected socket close, the endpoint is in a connected or connecting state).
      • notifyResponseDecoded

        public void notifyResponseDecoded​(boolean hidden)
        Called by the underlying channel to notify when the channel finished decoding the current response. If hidden is set to true, the last response time will not be updated.
      • setLastKeepAliveLatency

        public void setLastKeepAliveLatency​(long latency)
        Called by the underlying channel when a keepalive is returned to record how long it took.
      • lastResponse

        public long lastResponse()
        Description copied from interface: Endpoint
        Returns the timestamp of the last response completed.
        Specified by:
        lastResponse in interface Endpoint
      • signalConfigReload

        public void signalConfigReload()
        Signal a "config reload" event to the upper config layers.
      • isFree

        public boolean isFree()
        Description copied from interface: Endpoint
        If this endpoint is free to take a request. This is especially important in non-pipelined endpoint cases since if a request is in-flight this will return false.
        Specified by:
        isFree in interface Endpoint
        Returns:
        true if free to accept a request, false otherwise.
      • bucket

        protected String bucket()
        The name of the bucket.
        Returns:
        the bucket name.
      • username

        protected String username()
        Username of the bucket.
        Returns:
        user authorized for bucket access.
      • password

        protected String password()
        The password of the bucket/user.
        Returns:
        the bucket/user password.
      • responseBuffer

        public com.lmax.disruptor.RingBuffer<ResponseEvent> responseBuffer()
        The RingBuffer response buffer reference.
        Returns:
        the response buffer.
      • remoteAddress

        public String remoteAddress()
        Description copied from interface: Endpoint
        Returns the remote address as String representation. Hostname and port separated by colon.
        Specified by:
        remoteAddress in interface Endpoint
      • logIdent

        protected static RedactableArgument logIdent​(Channel chan,
                                                     Endpoint endpoint)
        Simple log helper to give logs a common prefix.
        Parameters:
        chan - the address.
        endpoint - the endpoint.
        Returns:
        a prefix string for logs.