Class Node

All Implemented Interfaces:

public class Node extends Object implements Stateful<NodeState>
  • Constructor Details

  • Method Details

    • create

      public static Node create(CoreContext ctx, NodeIdentifier identifier, Optional<String> alternateAddress)
    • disconnect

      public Mono<Void> disconnect()
      Instruct this Node to disconnect.

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

    • addService

      public Mono<Void> addService(ServiceType type, int port, Optional<String> bucket)
      Adds a Service to this Node.
      type - the type of the service.
      port - the port of the service.
      bucket - the bucket name (if present).
      a Mono that completes once the service is added.
    • removeService

      public Mono<Void> removeService(ServiceType type, Optional<String> bucket)
      Removes a Service from this Node.
      type - the type of service.
      bucket - the bucket name if present.
      a mono once completed.
    • states

      public Flux<NodeState> states()
      Description copied from interface: Stateful
      Returns a stream of states for this component as they change.
      Specified by:
      states in interface Stateful<NodeState>
    • state

      public NodeState state()
      Description copied from interface: Stateful
      Returns the current state of the stateful component.
      Specified by:
      state in interface Stateful<NodeState>
    • serviceState

      public Optional<Flux<ServiceState>> serviceState(ServiceType type, Optional<String> bucket)
      If present, returns a flux that allows to monitor the state changes of a specific service.
      type - the type of service.
      bucket - the bucket, if present.
      if found, a flux with the service states.
    • send

      public <R extends Request<? extends Response>> void send(R request)
      Sends the request into this Node.

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

      request - the request to send.
    • sendIntoRetry

      protected <R extends Request<? extends Response>> void sendIntoRetry(R request)
      Retries the request.

      This is a separate method because in test it is overridden to do easy assertions.

      request - the request to retry.
    • identifier

      public NodeIdentifier identifier()
      Returns the node identifier.
    • serviceEnabled

      public boolean serviceEnabled(ServiceType type)
      If a given ServiceType is enabled on this node.
      type - the service type to check.
      true if enabled, false otherwise.
    • hasServicesEnabled

      public boolean hasServicesEnabled()
    • createService

      protected Service createService(ServiceType serviceType, int port, Optional<String> bucket)
      Helper method to create the Service based on the service type provided.
      serviceType - the type of service to create.
      port - the port for that service.
      bucket - optionally the bucket name.
      a created service, but not yet connected or anything.
    • diagnostics

      public Stream<EndpointDiagnostics> diagnostics()
    • internalDiagnostics

      @Internal public Stream<InternalEndpointDiagnostics> internalDiagnostics()
    • equals

      public boolean equals(Object o)
      equals in class Object
    • hashCode

      public int hashCode()
      hashCode in class Object
    • toString

      public String toString()
      toString in class Object