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,
                                      Credentials credentials)
        Connect to a Couchbase cluster with custom Credentials.
        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 Cluster.
      • connect

        public static Cluster connect​(ClusterEnvironment environment)
        Connect to a Couchbase cluster with a custom ClusterEnvironment.
        Parameters:
        environment - the custom environment with its properties used to connect to 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!

      • 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.
      • shutdown

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

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