Class Core
- java.lang.Object
-
- com.couchbase.client.core.Core
-
- All Implemented Interfaces:
CoreCouchbaseOps
,AutoCloseable
@Volatile public class Core extends Object implements CoreCouchbaseOps, AutoCloseable
The main entry point into the core layer.This class has been around behind a facade in the 1.x days, but here it is just a plain simple class that can be instantiated and is used across the upper language bindings.
- Since:
- 2.0.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Core.ResponseMetricIdentifier
-
Constructor Summary
Constructors Modifier Constructor Description protected
Core(CoreEnvironment environment, Authenticator authenticator, ConnectionString connectionString)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description CoreBucketManagerOps
bucketManager()
void
close()
ClusterConfig
clusterConfig()
This API provides access to the current config that is published throughout the core.CoreSearchIndexManager
clusterSearchIndexManager()
CoreCollectionManager
collectionManager(String bucketName)
ConfigurationProvider
configurationProvider()
Returns the attached configuration provider.CoreContext
context()
Returns theCoreContext
of this core instance.static Core
create(CoreEnvironment environment, Authenticator authenticator, ConnectionString connectionString)
static Core
create(CoreEnvironment environment, Authenticator authenticator, Set<SeedNode> seedNodes)
Deprecated.Please usecreate(CoreEnvironment, Authenticator, ConnectionString)
instead.protected Node
createNode(NodeIdentifier identifier, Optional<String> alternateAddress)
Create aNode
from the given identifier.Stream<EndpointDiagnostics>
diagnostics()
Mono<Void>
ensureServiceAt(NodeIdentifier identifier, ServiceType serviceType, int port, Optional<String> bucket, Optional<String> alternateAddress)
This method can be used by a caller to make sure a certain service is enabled at the given target node.CoreEnvironment
environment()
CoreHttpClient
httpClient(RequestTarget target)
Returns a client for issuing HTTP requests to servers in the cluster.void
initGlobalConfig()
Instructs the client to, if possible, load and initialize the global config.Stream<InternalEndpointDiagnostics>
internalDiagnostics()
boolean
isProtostellar()
CoreKvBinaryOps
kvBinaryOps(CoreKeyspace keyspace)
CoreKvOps
kvOps(CoreKeyspace keyspace)
void
openBucket(String name)
Attempts to open a bucket and fails theMono
if there is a persistent error as the reason.CoreProtostellar
protostellar()
CoreQueryOps
queryOps()
ValueRecorder
responseMetric(Core.ResponseMetricIdentifier rmi)
ValueRecorder
responseMetric(Request<?> request)
CoreSearchIndexManager
scopeSearchIndexManager(CoreBucketAndScope scope)
CoreSearchOps
searchOps(CoreBucketAndScope scope)
<R extends Response>
voidsend(Request<R> request)
Sends a command into the core layer and registers the request with the timeout timer.<R extends Response>
voidsend(Request<R> request, boolean registerForTimeout)
Sends a command into the core layer and allows to avoid timeout registration.Optional<Flux<ServiceState>>
serviceState(NodeIdentifier nodeIdentifier, ServiceType type, Optional<String> bucket)
If present, returns a flux that allows to monitor the state changes of a specific service.Mono<Void>
shutdown()
Mono<Void>
shutdown(Duration timeout)
Shuts down this core and all associated, owned resources.CoreTransactionsCleanup
transactionsCleanup()
CoreTransactionsContext
transactionsContext()
CompletableFuture<Void>
waitUntilReady(Set<ServiceType> serviceTypes, Duration timeout, ClusterState desiredState, String bucketName)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.couchbase.client.core.api.CoreCouchbaseOps
asCore
-
-
-
-
Constructor Detail
-
Core
protected Core(CoreEnvironment environment, Authenticator authenticator, ConnectionString connectionString)
-
-
Method Detail
-
create
@Deprecated public static Core create(CoreEnvironment environment, Authenticator authenticator, Set<SeedNode> seedNodes)
Deprecated.Please usecreate(CoreEnvironment, Authenticator, ConnectionString)
instead.
-
create
public static Core create(CoreEnvironment environment, Authenticator authenticator, ConnectionString connectionString)
-
protostellar
@Internal public CoreProtostellar protostellar()
-
configurationProvider
@Internal public ConfigurationProvider configurationProvider()
Returns the attached configuration provider.Internal API, use with care!
-
send
public <R extends Response> void send(Request<R> request)
Sends a command into the core layer and registers the request with the timeout timer.- Parameters:
request
- the request to dispatch.
-
send
@Internal public <R extends Response> void send(Request<R> request, boolean registerForTimeout)
Sends a command into the core layer and allows to avoid timeout registration.Usually you want to use
send(Request)
instead, this method should only be used during retry situations where the request has already been registered with a timeout timer before.- Parameters:
request
- the request to dispatch.registerForTimeout
- if the request should be registered with a timeout.
-
context
public CoreContext context()
Returns theCoreContext
of this core instance.
-
httpClient
@Internal public CoreHttpClient httpClient(RequestTarget target)
Returns a client for issuing HTTP requests to servers in the cluster.
-
diagnostics
@Internal public Stream<EndpointDiagnostics> diagnostics()
-
internalDiagnostics
@Internal public Stream<InternalEndpointDiagnostics> internalDiagnostics()
-
serviceState
@Internal public Optional<Flux<ServiceState>> serviceState(NodeIdentifier nodeIdentifier, ServiceType type, Optional<String> bucket)
If present, returns a flux that allows to monitor the state changes of a specific service.- Parameters:
nodeIdentifier
- the node identifier for the node.type
- the type of service.bucket
- the bucket, if present.- Returns:
- if found, a flux with the service states.
-
initGlobalConfig
@Internal public void initGlobalConfig()
Instructs the client to, if possible, load and initialize the global config.Since global configs are an "optional" feature depending on the cluster version, if an error happens this method will not fail. Rather it will log the exception (with some logic dependent on the type of error) and will allow the higher level components to move on where possible.
-
openBucket
@Internal public void openBucket(String name)
Attempts to open a bucket and fails theMono
if there is a persistent error as the reason.
-
clusterConfig
@Internal public ClusterConfig clusterConfig()
This API provides access to the current config that is published throughout the core.Note that this is internal API and might change at any time.
-
ensureServiceAt
@Internal public Mono<Void> ensureServiceAt(NodeIdentifier identifier, ServiceType serviceType, int port, Optional<String> bucket, Optional<String> alternateAddress)
This method can be used by a caller to make sure a certain service is enabled at the given target node.This is advanced, internal functionality and should only be used if the caller knows what they are doing.
- Parameters:
identifier
- the node to check.serviceType
- the service type to enable if not enabled already.port
- the port where the service is listening on.bucket
- if the service is bound to a bucket, it needs to be provided.alternateAddress
- if an alternate address is present, needs to be provided since it is passed down to the node and its services.- Returns:
- a
Mono
which completes once initiated.
-
responseMetric
@Internal public ValueRecorder responseMetric(Request<?> request)
-
responseMetric
@Internal public ValueRecorder responseMetric(Core.ResponseMetricIdentifier rmi)
-
createNode
protected Node createNode(NodeIdentifier identifier, Optional<String> alternateAddress)
Create aNode
from the given identifier.This method is here so it can be overridden in tests.
- Parameters:
identifier
- the identifier for the node.alternateAddress
- the alternate address if present.- Returns:
- the created node instance.
-
shutdown
@Internal public Mono<Void> shutdown(Duration timeout)
Shuts down this core and all associated, owned resources.- Specified by:
shutdown
in interfaceCoreCouchbaseOps
-
transactionsCleanup
@Internal public CoreTransactionsCleanup transactionsCleanup()
-
transactionsContext
@Internal public CoreTransactionsContext transactionsContext()
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
-
isProtostellar
@Internal public boolean isProtostellar()
-
kvOps
@Internal public CoreKvOps kvOps(CoreKeyspace keyspace)
- Specified by:
kvOps
in interfaceCoreCouchbaseOps
-
queryOps
@Internal public CoreQueryOps queryOps()
- Specified by:
queryOps
in interfaceCoreCouchbaseOps
-
searchOps
@Internal public CoreSearchOps searchOps(@Nullable CoreBucketAndScope scope)
- Specified by:
searchOps
in interfaceCoreCouchbaseOps
-
kvBinaryOps
@Internal public CoreKvBinaryOps kvBinaryOps(CoreKeyspace keyspace)
- Specified by:
kvBinaryOps
in interfaceCoreCouchbaseOps
-
bucketManager
@Internal public CoreBucketManagerOps bucketManager()
- Specified by:
bucketManager
in interfaceCoreCouchbaseOps
-
collectionManager
@Internal public CoreCollectionManager collectionManager(String bucketName)
- Specified by:
collectionManager
in interfaceCoreCouchbaseOps
-
clusterSearchIndexManager
public CoreSearchIndexManager clusterSearchIndexManager()
- Specified by:
clusterSearchIndexManager
in interfaceCoreCouchbaseOps
-
scopeSearchIndexManager
public CoreSearchIndexManager scopeSearchIndexManager(CoreBucketAndScope scope)
- Specified by:
scopeSearchIndexManager
in interfaceCoreCouchbaseOps
-
environment
public CoreEnvironment environment()
- Specified by:
environment
in interfaceCoreCouchbaseOps
-
waitUntilReady
public CompletableFuture<Void> waitUntilReady(Set<ServiceType> serviceTypes, Duration timeout, ClusterState desiredState, @Nullable String bucketName)
- Specified by:
waitUntilReady
in interfaceCoreCouchbaseOps
-
-