Package com.couchbase.client.java
Class AsyncCluster
- java.lang.Object
-
- com.couchbase.client.java.AsyncCluster
-
public class AsyncCluster extends Object
TheAsyncCluster
is the main entry point when connecting to a Couchbase cluster.Note that most of the time you want to use the blocking
Cluster
or the powerful reactiveReactiveCluster
API instead. Use this API if you know what you are doing and you want to build low-level, even faster APIs on top.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AsyncAnalyticsIndexManager
analyticsIndexes()
Returns a manager for Analytics services.CompletableFuture<AnalyticsResult>
analyticsQuery(String statement)
Performs an Analytics query with defaultAnalyticsOptions
.CompletableFuture<AnalyticsResult>
analyticsQuery(String statement, AnalyticsOptions options)
Performs an Analytics query with customAnalyticsOptions
.CompletableFuture<AsyncBucket>
bucket(String name)
Opens aAsyncBucket
with the given name.AsyncBucketManager
buckets()
static CompletableFuture<AsyncCluster>
connect(ClusterEnvironment environment)
Connect to a Couchbase cluster with a customClusterEnvironment
.static CompletableFuture<AsyncCluster>
connect(String connectionString, Credentials credentials)
Connect to a Couchbase cluster with customCredentials
.static CompletableFuture<AsyncCluster>
connect(String connectionString, String username, String password)
Connect to a Couchbase cluster with a username and a password as credentials.Core
core()
Provides access to the underlyingCore
.ClusterEnvironment
environment()
Provides access to the configuredClusterEnvironment
for this cluster.CompletableFuture<QueryResult>
query(String statement)
Performs a N1QL query with defaultQueryOptions
.CompletableFuture<QueryResult>
query(String statement, QueryOptions options)
Performs a N1QL query with customQueryOptions
.AsyncSearchIndexManager
searchIndexes()
Provides access to the index management capabilities.CompletableFuture<SearchResult>
searchQuery(SearchQuery query)
Performs a Full Text Search (FTS) query with defaultSearchOptions
.CompletableFuture<SearchResult>
searchQuery(SearchQuery query, SearchOptions options)
Performs a Full Text Search (FTS) query with customSearchOptions
.CompletableFuture<Void>
shutdown()
Performs a non-reversible shutdown of thisAsyncCluster
.CompletableFuture<Void>
shutdown(Duration timeout)
Performs a non-reversible shutdown of thisAsyncCluster
.AsyncUserManager
users()
Provides access to the user management capabilities.
-
-
-
Method Detail
-
connect
public static CompletableFuture<AsyncCluster> connect(String connectionString, String username, String password)
Connect to a Couchbase cluster with a username and a password as credentials.- Parameters:
connectionString
- connection string used to locate the Couchbase cluster.username
- the name of the user with appropriate permissions on the cluster.password
- the password of the user with appropriate permissions on the cluster.- Returns:
- if properly connected, returns a
AsyncCluster
.
-
connect
public static CompletableFuture<AsyncCluster> connect(String connectionString, Credentials credentials)
Connect to a Couchbase cluster with customCredentials
.- Parameters:
connectionString
- connection string used to locate the Couchbase cluster.credentials
- custom credentials used when connecting to the cluster.- Returns:
- if properly connected, returns a
AsyncCluster
.
-
connect
public static CompletableFuture<AsyncCluster> connect(ClusterEnvironment environment)
Connect to a Couchbase cluster with a customClusterEnvironment
.- Parameters:
environment
- the custom environment with its properties used to connect to the cluster.- Returns:
- if properly connected, returns a
AsyncCluster
.
-
environment
public ClusterEnvironment environment()
Provides access to the configuredClusterEnvironment
for this cluster.
-
core
@Volatile public Core core()
Provides access to the underlyingCore
.This is advanced API, use with care!
-
searchIndexes
@Volatile public AsyncSearchIndexManager searchIndexes()
Provides access to the index management capabilities.
-
users
@Volatile public AsyncUserManager users()
Provides access to the user management capabilities.
-
buckets
@Volatile public AsyncBucketManager buckets()
-
query
public CompletableFuture<QueryResult> query(String statement)
Performs a N1QL query with defaultQueryOptions
.- Parameters:
statement
- the N1QL query statement as a raw string.- Returns:
- the
QueryResult
once the response arrives successfully.
-
query
public CompletableFuture<QueryResult> query(String statement, QueryOptions options)
Performs a N1QL query with customQueryOptions
.- Parameters:
statement
- the N1QL query statement as a raw string.options
- the custom options for this query.- Returns:
- the
QueryResult
once the response arrives successfully.
-
analyticsIndexes
public AsyncAnalyticsIndexManager analyticsIndexes()
Returns a manager for Analytics services.
-
analyticsQuery
public CompletableFuture<AnalyticsResult> analyticsQuery(String statement)
Performs an Analytics query with defaultAnalyticsOptions
.- Parameters:
statement
- the Analytics query statement as a raw string.- Returns:
- the
AnalyticsResult
once the response arrives successfully.
-
analyticsQuery
public CompletableFuture<AnalyticsResult> analyticsQuery(String statement, AnalyticsOptions options)
Performs an Analytics query with customAnalyticsOptions
.- Parameters:
statement
- the Analytics query statement as a raw string.options
- the custom options for this analytics query.- Returns:
- the
AnalyticsResult
once the response arrives successfully.
-
searchQuery
public CompletableFuture<SearchResult> searchQuery(SearchQuery query)
Performs a Full Text Search (FTS) query with defaultSearchOptions
.- Parameters:
query
- the query, in the form of aSearchQuery
- Returns:
- the
SearchRequest
once the response arrives successfully, inside aCompletableFuture
-
searchQuery
public CompletableFuture<SearchResult> searchQuery(SearchQuery query, SearchOptions options)
Performs a Full Text Search (FTS) query with customSearchOptions
.- Parameters:
query
- the query, in the form of aSearchQuery
options
- the custom options for this query.- Returns:
- the
SearchRequest
once the response arrives successfully, inside aCompletableFuture
-
bucket
public CompletableFuture<AsyncBucket> bucket(String name)
Opens aAsyncBucket
with the given name.- Parameters:
name
- the name of the bucket to open.- Returns:
- a
AsyncBucket
once opened.
-
shutdown
public CompletableFuture<Void> shutdown()
Performs a non-reversible shutdown of thisAsyncCluster
.
-
shutdown
public CompletableFuture<Void> shutdown(Duration timeout)
Performs a non-reversible shutdown of thisAsyncCluster
.- Parameters:
timeout
- overriding the default disconnect timeout if needed.
-
-