public class DefaultAsyncBucketManager extends Object implements AsyncBucketManager
AsyncBucketManager.| Modifier and Type | Field and Description |
|---|---|
static String |
INDEX_WATCH_LOG_NAME
the name of the logger dedicated to index watching
|
| Modifier and Type | Method and Description |
|---|---|
rx.Observable<List<String>> |
buildN1qlDeferredIndexes()
Instruct the query engine to trigger the build of indexes that have been deferred.
|
static DefaultAsyncBucketManager |
create(String bucket,
String password,
ClusterFacade core,
CouchbaseEnvironment env) |
static DefaultAsyncBucketManager |
create(String bucket,
String username,
String password,
ClusterFacade core,
CouchbaseEnvironment env) |
rx.Observable<Boolean> |
createN1qlIndex(String indexName,
boolean ignoreIfExist,
boolean defer,
Object... fields)
Create a secondary index for the current bucket.
|
rx.Observable<Boolean> |
createN1qlIndex(String indexName,
List<Object> fields,
Expression whereClause,
boolean ignoreIfExist,
boolean defer)
Create a secondary index for the current bucket, with a WHERE clause.
|
rx.Observable<Boolean> |
createN1qlPrimaryIndex(boolean ignoreIfExist,
boolean defer)
Create a primary index for the current bucket.
|
rx.Observable<Boolean> |
createN1qlPrimaryIndex(String customName,
boolean ignoreIfExist,
boolean defer)
Create a custom-named primary index for the current bucket.
|
rx.Observable<Boolean> |
dropN1qlIndex(String name,
boolean ignoreIfNotExist)
Drop the given secondary index associated with the current bucket.
|
rx.Observable<Boolean> |
dropN1qlPrimaryIndex(boolean ignoreIfNotExist)
Drop the default primary index (
Index.PRIMARY_NAME) associated with the current bucket. |
rx.Observable<Boolean> |
dropN1qlPrimaryIndex(String customName,
boolean ignoreIfNotExist)
Drop the given custom-named primary index associated with the current bucket.
|
rx.Observable<Boolean> |
flush()
Flushes the bucket (removes all data).
|
rx.Observable<DesignDocument> |
getDesignDocument(String name)
Loads a published
DesignDocument by its name. |
rx.Observable<DesignDocument> |
getDesignDocument(String name,
boolean development)
Loads a
DesignDocument by its name from either development or production. |
rx.Observable<DesignDocument> |
getDesignDocuments()
Loads all published
DesignDocuments. |
rx.Observable<DesignDocument> |
getDesignDocuments(boolean development)
Loads all
DesignDocuments from development or production. |
rx.Observable<BucketInfo> |
info()
Returns information about the connected bucket.
|
rx.Observable<DesignDocument> |
insertDesignDocument(DesignDocument designDocument)
Inserts a
DesignDocument into production if it does not exist. |
rx.Observable<DesignDocument> |
insertDesignDocument(DesignDocument designDocument,
boolean development)
Inserts a
DesignDocument into development or production if it does not exist. |
rx.Observable<IndexInfo> |
listN1qlIndexes()
List all N1QL GSI indexes that are registered for the current bucket.
|
rx.Observable<DesignDocument> |
publishDesignDocument(String name)
Publishes a
DesignDocument from development into production. |
rx.Observable<DesignDocument> |
publishDesignDocument(String name,
boolean overwrite)
Publishes a
DesignDocument from development into production. |
rx.Observable<Boolean> |
removeDesignDocument(String name)
Removes a
DesignDocument from production by its name. |
rx.Observable<Boolean> |
removeDesignDocument(String name,
boolean development)
Removes a
DesignDocument from production or development by its name. |
rx.Observable<DesignDocument> |
upsertDesignDocument(DesignDocument designDocument)
Upserts (inserts or replaces) a
DesignDocument into production. |
rx.Observable<DesignDocument> |
upsertDesignDocument(DesignDocument designDocument,
boolean development)
Upserts (inserts or replaces) a
DesignDocument into production or development. |
rx.Observable<IndexInfo> |
watchN1qlIndexes(List<String> watchList,
long watchTimeout,
TimeUnit watchTimeUnit)
Watches all given indexes (possibly including the primary one), polling the query service until they become
"online" or the watchTimeout has expired..
|
public static final String INDEX_WATCH_LOG_NAME
public static DefaultAsyncBucketManager create(String bucket, String username, String password, ClusterFacade core, CouchbaseEnvironment env)
public static DefaultAsyncBucketManager create(String bucket, String password, ClusterFacade core, CouchbaseEnvironment env)
public rx.Observable<BucketInfo> info()
AsyncBucketManagerObservable can error under the following conditions:
- com.couchbase.client.java.error.TranscodingException: If the server response could not be decoded.info in interface AsyncBucketManagerBucketInfo.public rx.Observable<Boolean> flush()
AsyncBucketManagerObservable can error under the following conditions:
- com.couchbase.client.java.error.FlushDisabledException: If flush is disabled.
- com.couchbase.client.core.CouchbaseException: If the server response could not be parsed.flush in interface AsyncBucketManagerObservable otherwise.public rx.Observable<DesignDocument> getDesignDocuments()
AsyncBucketManagerDesignDocuments.
The Observable can error under the following conditions:
- com.couchbase.client.java.error.TranscodingException: If the server response could not be parsed.getDesignDocuments in interface AsyncBucketManagerDesignDocuments.public rx.Observable<DesignDocument> getDesignDocuments(boolean development)
AsyncBucketManagerDesignDocuments from development or production.
The Observable can error under the following conditions:
- com.couchbase.client.java.error.TranscodingException: If the server response could not be parsed.getDesignDocuments in interface AsyncBucketManagerdevelopment - if the DesignDocuments should be loaded from development or production.DesignDocuments.public rx.Observable<DesignDocument> getDesignDocument(String name)
AsyncBucketManagerDesignDocument by its name.
The Observable can error under the following conditions:
- com.couchbase.client.java.error.TranscodingException: If the server response could not be parsed.
- com.couchbase.client.java.error.DesignDocumentDoesNotExistException: If DesignDocument is not found.getDesignDocument in interface AsyncBucketManagername - the name of the DesignDocument.DesignDocument.public rx.Observable<DesignDocument> getDesignDocument(String name, boolean development)
AsyncBucketManagerDesignDocument by its name from either development or production.
The Observable can error under the following conditions:
- com.couchbase.client.java.error.TranscodingException: If the server response could not be parsed.
- com.couchbase.client.java.error.DesignDocumentDoesNotExistException: If DesignDocument is not found.getDesignDocument in interface AsyncBucketManagername - the name of the DesignDocument.development - if it should be loaded from development or production.DesignDocument.public rx.Observable<DesignDocument> insertDesignDocument(DesignDocument designDocument)
AsyncBucketManagerDesignDocument into production if it does not exist.
Note that inserting a DesignDocument is not an atomic operation, but instead internally performs a
AsyncBucketManager.getDesignDocument(String) operation first. While expected to be very uncommon, a race condition may
happen if two users at the same time perform this operation with the same DesignDocument.
The Observable can error under the following conditions:
- com.couchbase.client.java.error.TranscodingException: If the server response could not be parsed.
- com.couchbase.client.java.error.DesignDocumentAlreadyExistsException: If the DesignDocument exists.insertDesignDocument in interface AsyncBucketManagerdesignDocument - the DesignDocument to insert.DesignDocument on success.public rx.Observable<DesignDocument> insertDesignDocument(DesignDocument designDocument, boolean development)
AsyncBucketManagerDesignDocument into development or production if it does not exist.
Note that inserting a DesignDocument is not an atomic operation, but instead internally performs a
AsyncBucketManager.getDesignDocument(String) operation first. While expected to be very uncommon, a race condition may
happen if two users at the same time perform this operation with the same DesignDocument.
The Observable can error under the following conditions:
- com.couchbase.client.java.error.TranscodingException: If the server response could not be parsed.
- com.couchbase.client.java.error.DesignDocumentAlreadyExistsException: If the DesignDocument exists.insertDesignDocument in interface AsyncBucketManagerdesignDocument - the DesignDocument to insert.development - if it should be inserted into development or production (published).DesignDocument on success.public rx.Observable<DesignDocument> upsertDesignDocument(DesignDocument designDocument)
AsyncBucketManagerDesignDocument into production.
If you want to add or update view definitions to an existing design document, you need to make sure you have
all the views (including old ones) in the DesignDocument. Use AsyncBucketManager.getDesignDocument(String) to get the
old list and add your new view to it before calling this method.
The Observable can error under the following conditions:
- com.couchbase.client.java.error.TranscodingException: If the server response could not be parsed.upsertDesignDocument in interface AsyncBucketManagerdesignDocument - the DesignDocument to upsert.DesignDocument on success.public rx.Observable<DesignDocument> upsertDesignDocument(DesignDocument designDocument, boolean development)
AsyncBucketManagerDesignDocument into production or development.
If you want to add or update view definitions to an existing design document, you need to make sure you have
all the views (including old ones) in the DesignDocument. Use AsyncBucketManager.getDesignDocument(String) to get the
old list and add your new view to it before calling this method.
The Observable can error under the following conditions:
- com.couchbase.client.java.error.TranscodingException: If the server response could not be parsed.upsertDesignDocument in interface AsyncBucketManagerdesignDocument - the DesignDocument to upsert.development - if the DesignDocument should be upserted into development or production.DesignDocument on success.public rx.Observable<Boolean> removeDesignDocument(String name)
AsyncBucketManagerDesignDocument from production by its name.
The Observable can error under the following conditions:
- com.couchbase.client.java.error.DesignDocumentDoesNotExistException: If DesignDocument is not found.removeDesignDocument in interface AsyncBucketManagername - the name of the DesignDocument.public rx.Observable<Boolean> removeDesignDocument(String name, boolean development)
AsyncBucketManagerDesignDocument from production or development by its name.
The Observable can error under the following conditions:
- com.couchbase.client.java.error.DesignDocumentDoesNotExistException: If DesignDocument is not found.removeDesignDocument in interface AsyncBucketManagername - the name of the DesignDocument.development - if the DesignDocument should be removed from development or production.public rx.Observable<DesignDocument> publishDesignDocument(String name)
AsyncBucketManagerDesignDocument from development into production.
Note that this method does not override a already existing DesignDocument
(see AsyncBucketManager.publishDesignDocument(String, boolean)) as an alternative.
The Observable can error under the following conditions:
- com.couchbase.client.java.error.DesignDocumentAlreadyExistsException: If the DesignDocument already
exists.
- com.couchbase.client.java.error.TranscodingException: If the server response could not be parsed.
- com.couchbase.client.java.error.DesignDocumentDoesNotExistException: If DesignDocument is not found
in development.publishDesignDocument in interface AsyncBucketManagername - the name of the DesignDocument to publish.DesignDocument on success.public rx.Observable<DesignDocument> publishDesignDocument(String name, boolean overwrite)
AsyncBucketManagerDesignDocument from development into production.
The Observable can error under the following conditions:
- com.couchbase.client.java.error.DesignDocumentAlreadyExistsException: If the DesignDocument already
exists and override is set to false.
- com.couchbase.client.java.error.TranscodingException: If the server response could not be parsed.
- com.couchbase.client.java.error.DesignDocumentDoesNotExistException: If DesignDocument is not found
in development.publishDesignDocument in interface AsyncBucketManagername - the name of the DesignDocument to publish.overwrite - if an existing DesignDocument should be overridden.DesignDocument on success.public rx.Observable<IndexInfo> listN1qlIndexes()
AsyncBucketManagerObservable can error under the following conditions:
- TranscodingException if the server response couldn't be parsed.listN1qlIndexes in interface AsyncBucketManagerObservable that will get notified of each relevant IndexInfo (can be empty if no
relevant index is defined for this bucket).public rx.Observable<Boolean> createN1qlPrimaryIndex(boolean ignoreIfExist, boolean defer)
AsyncBucketManagerObservable can error under the following conditions:
- IndexAlreadyExistsException if the index already exists and ignoreIfExist is set to false.
- CouchbaseException if another error occurs during index creation.createN1qlPrimaryIndex in interface AsyncBucketManagerignoreIfExist - if a primary index already exists, an exception will be thrown unless this is set to true.defer - true to defer building of the index until AsyncBucketManager.buildN1qlDeferredIndexes() is called (or a direct call
to the corresponding query service API).Observable that will get notified with a single Boolean.TRUE if the index was effectively created
(even in deferred mode), Boolean.FALSE if the index existed and ignoreIfExist is true.public rx.Observable<Boolean> createN1qlPrimaryIndex(String customName, boolean ignoreIfExist, boolean defer)
AsyncBucketManagerObservable can error under the following conditions:
- IndexAlreadyExistsException if the index already exists and ignoreIfExist is set to false.
- CouchbaseException if another error occurs during index creation.createN1qlPrimaryIndex in interface AsyncBucketManagercustomName - the custom name for the primary index.ignoreIfExist - if a primary index already exists, an exception will be thrown unless this is set to true.defer - true to defer building of the index until AsyncBucketManager.buildN1qlDeferredIndexes() is called (or a direct call
to the corresponding query service API).Observable that will get notified with a single Boolean.TRUE if the index was effectively created
(even in deferred mode), Boolean.FALSE if the index existed and ignoreIfExist is true.public rx.Observable<Boolean> createN1qlIndex(String indexName, boolean ignoreIfExist, boolean defer, Object... fields)
AsyncBucketManagerAsyncBucketManager.createN1qlIndex(String, List, Expression, boolean, boolean) for
that.
The Observable can error under the following conditions:
- IndexAlreadyExistsException if the index already exists and ignoreIfExist is set to false.
- CouchbaseException if another error occurs during index creation.createN1qlIndex in interface AsyncBucketManagerindexName - the name of the index.ignoreIfExist - if a secondary index already exists with that name, an exception will be thrown unless this
is set to true.defer - true to defer building of the index until AsyncBucketManager.buildN1qlDeferredIndexes() is called (or a direct call
to the corresponding query service API).fields - the JSON fields to index, in either Expression or String form.Observable that will get notified with a single Boolean.TRUE if the index was effectively created
(even in deferred mode), Boolean.FALSE if the index existed and ignoreIfExist is true.AsyncBucketManager.createN1qlIndex(String, List, Expression, boolean, boolean)public rx.Observable<Boolean> createN1qlIndex(String indexName, List<Object> fields, Expression whereClause, boolean ignoreIfExist, boolean defer)
AsyncBucketManagerObservable can error under the following conditions:
- IndexAlreadyExistsException if the index already exists and ignoreIfExist is set to false.
- CouchbaseException if another error occurs during index creation.createN1qlIndex in interface AsyncBucketManagerindexName - the name of the index.fields - the JSON fields to index, in the form of a List containing a mix of Expression or String.whereClause - the Expression to use in the WHERE clause of the index.ignoreIfExist - if a secondary index already exists with that name, an exception will be thrown unless this
is set to true.defer - true to defer building of the index until AsyncBucketManager.buildN1qlDeferredIndexes() is called (or a direct call
to the corresponding query service API).Observable that will get notified with a single Boolean.TRUE if the index was effectively created
(even in deferred mode), Boolean.FALSE if the index existed and ignoreIfExist is true.public rx.Observable<Boolean> dropN1qlPrimaryIndex(boolean ignoreIfNotExist)
AsyncBucketManagerIndex.PRIMARY_NAME) associated with the current bucket.
The index management API only deals with GSI type of indexes, which allows it to uniquely identify indexes
by name.
The Observable can error under the following conditions:
- IndexDoesNotExistException if the primary index doesn't exist and ignoreIfNoExist is set to false.
- CouchbaseException if another error occurs during index drop.dropN1qlPrimaryIndex in interface AsyncBucketManagerignoreIfNotExist - if true, attempting to drop on a bucket without any primary index won't cause an exception to be propagated.Observable that will get notified with a single Boolean.TRUE if the index was effectively dropped.public rx.Observable<Boolean> dropN1qlPrimaryIndex(String customName, boolean ignoreIfNotExist)
AsyncBucketManagerObservable can error under the following conditions:
- IndexDoesNotExistException if the primary index doesn't exist and ignoreIfNoExist is set to false.
- CouchbaseException if another error occurs during index drop.dropN1qlPrimaryIndex in interface AsyncBucketManagercustomName - the custom name of the primary index.ignoreIfNotExist - if true, attempting to drop on a bucket without any primary index won't cause an exception to be propagated.Observable that will get notified with a single Boolean.TRUE if the index was effectively dropped.public rx.Observable<Boolean> dropN1qlIndex(String name, boolean ignoreIfNotExist)
AsyncBucketManagerObservable can error under the following conditions:
- IndexDoesNotExistException if the secondary index doesn't exist and ignoreIfNoExist is set to false.
- CouchbaseException if another error occurs during index drop.dropN1qlIndex in interface AsyncBucketManagerignoreIfNotExist - if true, attempting to drop on a bucket without the specified index won't cause an exception to be propagated.Observable that will get notified with a single Boolean.TRUE if the index was effectively dropped.public rx.Observable<List<String>> buildN1qlDeferredIndexes()
AsyncBucketManagerbuildN1qlDeferredIndexes in interface AsyncBucketManagerObservable that will get notified with a single List of index names, the names of the indexes that
have been triggered.to poll for a list of indexes to become online.public rx.Observable<IndexInfo> watchN1qlIndexes(List<String> watchList, long watchTimeout, TimeUnit watchTimeUnit)
AsyncBucketManagerINDEX_WATCH_LOG_NAME" logger
to see various stages of the polling.
You can also watch a primary index by using the Index.PRIMARY_NAME constant.watchN1qlIndexes in interface AsyncBucketManagerwatchList - the names of the SECONDARY indexes to watch (can be empty).watchTimeout - the maximum duration for which to poll for the index to become online.watchTimeUnit - the time unit for the watchTimeout.IndexInfo for the indexes that went online during the watch period. Can be empty
if all indexes where online, no index to watch or no index became online within the watchTimeout timeframe.Copyright © 2015 Couchbase, Inc.