Package com.couchbase.client.core.node
Class Node
java.lang.Object
com.couchbase.client.core.node.Node
public class Node extends Object implements Stateful<NodeState>
-
Constructor Summary
Constructors Modifier Constructor Description protected
Node(CoreContext ctx, NodeIdentifier identifier, Optional<String> alternateAddress)
-
Method Summary
Modifier and Type Method Description Mono<Void>
addService(ServiceType type, int port, Optional<String> bucket)
static Node
create(CoreContext ctx, NodeIdentifier identifier, Optional<String> alternateAddress)
protected Service
createService(ServiceType serviceType, int port, Optional<String> bucket)
Helper method to create theService
based on the service type provided.Stream<EndpointDiagnostics>
diagnostics()
Mono<Void>
disconnect()
Instruct thisNode
to disconnect.boolean
equals(Object o)
int
hashCode()
boolean
hasServicesEnabled()
NodeIdentifier
identifier()
Returns the node identifier.Mono<Void>
removeService(ServiceType type, Optional<String> bucket)
<R extends Request<? extends Response>>
voidsend(R request)
Sends the request into thisNode
.protected <R extends Request<? extends Response>>
voidsendIntoRetry(R request)
Retries the request.boolean
serviceEnabled(ServiceType type)
If a givenServiceType
is enabled on this node.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.NodeState
state()
Returns the current state of the stateful component.Flux<NodeState>
states()
Returns a stream of states for this component as they change.String
toString()
-
Constructor Details
-
Node
-
-
Method Details
-
create
public static Node create(CoreContext ctx, NodeIdentifier identifier, Optional<String> alternateAddress) -
disconnect
Instruct thisNode
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
- Parameters:
type
- the type of the service.port
- the port of the service.bucket
- the bucket name (if present).- Returns:
- a
Mono
that completes once the service is added.
-
removeService
- Parameters:
type
- the type of service.bucket
- the bucket name if present.- Returns:
- a mono once completed.
-
states
Description copied from interface:Stateful
Returns a stream of states for this component as they change. -
state
Description copied from interface:Stateful
Returns the current state of the stateful component. -
serviceState
If present, returns a flux that allows to monitor the state changes of a specific service.- Parameters:
type
- the type of service.bucket
- the bucket, if present.- Returns:
- if found, a flux with the service states.
-
send
Sends the request into thisNode
.Note that there is no guarantee that the request will actually dispatched, based on the state this node is in.
- Parameters:
request
- the request to send.
-
sendIntoRetry
Retries the request.This is a separate method because in test it is overridden to do easy assertions.
- Parameters:
request
- the request to retry.
-
identifier
Returns the node identifier. -
serviceEnabled
If a givenServiceType
is enabled on this node.- Parameters:
type
- the service type to check.- Returns:
- true if enabled, false otherwise.
-
hasServicesEnabled
public boolean hasServicesEnabled() -
createService
Helper method to create theService
based on the service type provided.- Parameters:
serviceType
- the type of service to create.port
- the port for that service.bucket
- optionally the bucket name.- Returns:
- a created service, but not yet connected or anything.
-
diagnostics
-
equals
-
hashCode
public int hashCode() -
toString
-