Class Cluster


  • public class Cluster
    extends Object
    The Cluster is the main entry point when connecting to a Couchbase cluster.
    • Method Detail

      • connect

        public static Cluster 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 Cluster.
      • connect

        public static Cluster connect​(String connectionString,
                                      ClusterOptions options)
        Connect to a Couchbase cluster with custom Authenticator.
        Parameters:
        connectionString - connection string used to locate the Couchbase cluster.
        options - custom options when creating the cluster.
        Returns:
        if properly connected, returns a Cluster.
      • core

        @Volatile
        public Core core()
        Provides access to the underlying Core.

        This is advanced API, use with care!

      • searchIndexes

        @Volatile
        public SearchIndexManager searchIndexes()
        Provides access to the Full Text Search index management services.
      • query

        public QueryResult query​(String statement)
        Performs a N1QL query with default QueryOptions.
        Parameters:
        statement - the N1QL query statement as a raw string.
        Returns:
        the QueryResult once the response arrives successfully.
      • query

        public QueryResult query​(String statement,
                                 QueryOptions options)
        Performs a N1QL query with custom QueryOptions.
        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.
      • analyticsQuery

        public AnalyticsResult analyticsQuery​(String statement)
        Performs an analytics query with default AnalyticsOptions.
        Parameters:
        statement - the query statement as a raw string.
        Returns:
        the AnalyticsResult once the response arrives successfully.
      • bucket

        public Bucket bucket​(String name)
        Opens a Bucket with the given name.
        Parameters:
        name - the name of the bucket to open.
        Returns:
        a Bucket once opened.
      • disconnect

        public void disconnect()
        Performs a non-reversible disconnect of this Cluster.
      • disconnect

        public void disconnect​(Duration timeout)
        Performs a non-reversible disconnect of this Cluster.
        Parameters:
        timeout - overriding the default disconnect timeout if needed.