Class BaseEndpoint

    • Method Detail

      • context

        public EndpointContext context()
        Description copied from interface: Endpoint
        Returns the context for this endpoint.
        Specified by:
        context in interface Endpoint
        Returns:
        the context.
      • pipelineInitializer

        protected abstract PipelineInitializer pipelineInitializer()
        Returns the initialize which adds endpoint-specific handlers to the pipeline.
      • connect

        public void connect()
        Starts the connect process of this endpoint.

        Note that if the current state is not EndpointState.DISCONNECTED, this method will do nothing.

        Specified by:
        connect in interface Endpoint
      • remoteAddress

        protected SocketAddress remoteAddress()
        Helper method to create the remote address this endpoint will (re)connect to.

        Note that this method has been refactored out so it can be overridden for local testing.

      • disconnect

        public void disconnect()
        Description copied from interface: Endpoint
        Instruct this Endpoint to disconnect.

        This method is async and will return immediately. Use the other methods available to inspect the current state of the endpoint, signaling potential successful disconnection attempts.

        Specified by:
        disconnect in interface Endpoint
      • receivedDisconnectSignal

        public boolean receivedDisconnectSignal()
        Description copied from interface: Endpoint
        On this endpoint Endpoint.disconnect() has been called on.

        This is different from an endpoint just being disconnected on the remote side and continuing reconnect attempts. Once this returns true, it is never coming back.

        Specified by:
        receivedDisconnectSignal in interface Endpoint
        Returns:
        true if Endpoint.disconnect() has been called.
      • remoteHostname

        public String remoteHostname()
        Description copied from interface: Endpoint
        Returns the remote hostname this endpoint is connected to (without the port).
        Specified by:
        remoteHostname in interface Endpoint
      • remotePort

        public int remotePort()
        Description copied from interface: Endpoint
        Returns the remotePort this endpoint is connected to.
        Specified by:
        remotePort in interface Endpoint
      • notifyChannelInactive

        @Internal
        public void notifyChannelInactive()
        This method is called from inside the channel to tell the endpoint hat it got inactive.

        The endpoint needs to perform certain steps when the channel is inactive so that it quickly tries to reconnect, as long as it should (i.e. don't do it if already disconnected)

      • send

        public <R extends Request<? extends Response>> void send​(R request)
        Description copied from interface: Endpoint
        Sends the request into this Endpoint.

        Note that there is no guarantee that the request will actually dispatched, based on the state this endpoint is in.

        Specified by:
        send in interface Endpoint
        Parameters:
        request - the request to send.
      • freeToWrite

        public boolean freeToWrite()
        Description copied from interface: Endpoint
        If new requests can be written to this endpoint
        Specified by:
        freeToWrite in interface Endpoint
        Returns:
        true if free, false otherwise.
      • outstandingRequests

        public long outstandingRequests()
        Description copied from interface: Endpoint
        If this endpoint has one or more outstanding requests.
        Specified by:
        outstandingRequests in interface Endpoint
        Returns:
        the number of outstanding requests
      • lastResponseReceived

        public long lastResponseReceived()
        Description copied from interface: Endpoint
        Holds the timestamp of the last response received (or 0 if no request ever sent).
        Specified by:
        lastResponseReceived in interface Endpoint
        Returns:
        the timestamp of the last response received, in nanoseconds.
      • markRequestCompletion

        @Internal
        public void markRequestCompletion()
        Called from the event loop handlers to mark a request as being completed.

        We need to make this call explicitly from the outside and cannot just listen on the request response callback because with streaming responses the actual completion might happen much later.

      • decrementOutstandingRequests

        @Internal
        public void decrementOutstandingRequests()
        Helper method to decrement outstanding requests, even if they haven't finished yet.
      • lastConnectedAt

        @Internal
        public long lastConnectedAt()
        Description copied from interface: Endpoint
        Returns the timestamp when the endpoint was last connected successfully (nanoseconds).
        Specified by:
        lastConnectedAt in interface Endpoint
        Returns:
        the timestamp when the endpoint was last connected, in nanoseconds.
      • channelFutureIntoMono

        protected Mono<com.couchbase.client.core.deps.io.netty.channel.Channel> channelFutureIntoMono​(com.couchbase.client.core.deps.io.netty.channel.ChannelFuture channelFuture)
        Helper method to convert a netty ChannelFuture into an async Mono.

        This method can be overridden in tests to fake certain responses from a connect attempt.

        Parameters:
        channelFuture - the future to convert/wrap.
        Returns:
        the created mono.
      • pipelined

        public boolean pipelined()
        Returns true if this endpoint is pipelined, false otherwise.