Package com.couchbase.client.java.bucket
Interface AsyncBucketManager
-
- All Known Implementing Classes:
DefaultAsyncBucketManager
@Committed @Public public interface AsyncBucketManager
Provides management capabilities for aAsyncBucket. Operations provided on theBucketManagercan be used to perform administrative tasks which require bucket-level credentials like managingDesignDocuments or flushing aBucket.- Since:
- 2.0
- Author:
- Michael Nitschinger
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description rx.Observable<List<String>>buildN1qlDeferredIndexes()Instruct the query engine to trigger the build of indexes that have been deferred.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 publishedDesignDocumentby its name.rx.Observable<DesignDocument>getDesignDocument(String name, boolean development)Loads aDesignDocumentby its name from either development or production.rx.Observable<DesignDocument>getDesignDocuments()Loads all publishedDesignDocuments.rx.Observable<DesignDocument>getDesignDocuments(boolean development)Loads allDesignDocuments from development or production.rx.Observable<BucketInfo>info()Returns information about the connected bucket.rx.Observable<DesignDocument>insertDesignDocument(DesignDocument designDocument)Inserts aDesignDocumentinto production if it does not exist.rx.Observable<DesignDocument>insertDesignDocument(DesignDocument designDocument, boolean development)Inserts aDesignDocumentinto 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 aDesignDocumentfrom development into production.rx.Observable<DesignDocument>publishDesignDocument(String name, boolean overwrite)Publishes aDesignDocumentfrom development into production.rx.Observable<Boolean>removeDesignDocument(String name)Removes aDesignDocumentfrom production by its name.rx.Observable<Boolean>removeDesignDocument(String name, boolean development)Removes aDesignDocumentfrom production or development by its name.rx.Observable<DesignDocument>upsertDesignDocument(DesignDocument designDocument)Upserts (inserts or replaces) aDesignDocumentinto production.rx.Observable<DesignDocument>upsertDesignDocument(DesignDocument designDocument, boolean development)Upserts (inserts or replaces) aDesignDocumentinto 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..
-
-
-
Method Detail
-
info
rx.Observable<BucketInfo> info()
Returns information about the connected bucket. TheObservablecan error under the following conditions: - com.couchbase.client.java.error.TranscodingException: If the server response could not be decoded.- Returns:
- bucket information wrapped in a
BucketInfo.
-
flush
rx.Observable<Boolean> flush()
Flushes the bucket (removes all data). Note that flush needs to be enabled on the bucket, otherwise an exception will be raised. TheObservablecan 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.- Returns:
- true if the bucket was flushed, an failed
Observableotherwise.
-
getDesignDocuments
rx.Observable<DesignDocument> getDesignDocuments()
Loads all publishedDesignDocuments. TheObservablecan error under the following conditions: - com.couchbase.client.java.error.TranscodingException: If the server response could not be parsed.- Returns:
- zero to N invocations containing published
DesignDocuments.
-
getDesignDocuments
rx.Observable<DesignDocument> getDesignDocuments(boolean development)
Loads allDesignDocuments from development or production. TheObservablecan error under the following conditions: - com.couchbase.client.java.error.TranscodingException: If the server response could not be parsed.- Parameters:
development- if theDesignDocuments should be loaded from development or production.- Returns:
- zero to N invocations containing published
DesignDocuments.
-
getDesignDocument
rx.Observable<DesignDocument> getDesignDocument(String name)
Loads a publishedDesignDocumentby its name. TheObservablecan 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: IfDesignDocumentis not found.- Parameters:
name- the name of theDesignDocument.- Returns:
- an observable that resolves into a
DesignDocument.
-
getDesignDocument
rx.Observable<DesignDocument> getDesignDocument(String name, boolean development)
Loads aDesignDocumentby its name from either development or production. TheObservablecan 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: IfDesignDocumentis not found.- Parameters:
name- the name of theDesignDocument.development- if it should be loaded from development or production.- Returns:
- an observable that resolves into a
DesignDocument.
-
insertDesignDocument
rx.Observable<DesignDocument> insertDesignDocument(DesignDocument designDocument)
Inserts aDesignDocumentinto production if it does not exist. Note that inserting aDesignDocumentis not an atomic operation, but instead internally performs agetDesignDocument(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 sameDesignDocument. TheObservablecan 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 theDesignDocumentexists.- Parameters:
designDocument- theDesignDocumentto insert.- Returns:
- the inserted
DesignDocumenton success.
-
insertDesignDocument
rx.Observable<DesignDocument> insertDesignDocument(DesignDocument designDocument, boolean development)
Inserts aDesignDocumentinto development or production if it does not exist. Note that inserting aDesignDocumentis not an atomic operation, but instead internally performs agetDesignDocument(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 sameDesignDocument. TheObservablecan 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 theDesignDocumentexists.- Parameters:
designDocument- theDesignDocumentto insert.development- if it should be inserted into development or production (published).- Returns:
- the inserted
DesignDocumenton success.
-
upsertDesignDocument
rx.Observable<DesignDocument> upsertDesignDocument(DesignDocument designDocument)
Upserts (inserts or replaces) aDesignDocumentinto 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. UsegetDesignDocument(String)to get the old list and add your new view to it before calling this method. TheObservablecan error under the following conditions: - com.couchbase.client.java.error.TranscodingException: If the server response could not be parsed.- Parameters:
designDocument- theDesignDocumentto upsert.- Returns:
- the upserted
DesignDocumenton success.
-
upsertDesignDocument
rx.Observable<DesignDocument> upsertDesignDocument(DesignDocument designDocument, boolean development)
Upserts (inserts or replaces) aDesignDocumentinto 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. UsegetDesignDocument(String)to get the old list and add your new view to it before calling this method. TheObservablecan error under the following conditions: - com.couchbase.client.java.error.TranscodingException: If the server response could not be parsed.- Parameters:
designDocument- theDesignDocumentto upsert.development- if theDesignDocumentshould be upserted into development or production.- Returns:
- the upserted
DesignDocumenton success.
-
removeDesignDocument
rx.Observable<Boolean> removeDesignDocument(String name)
Removes aDesignDocumentfrom production by its name. TheObservablecan error under the following conditions: - com.couchbase.client.java.error.DesignDocumentDoesNotExistException: IfDesignDocumentis not found.- Parameters:
name- the name of theDesignDocument.- Returns:
- true if succeeded, false otherwise.
-
removeDesignDocument
rx.Observable<Boolean> removeDesignDocument(String name, boolean development)
Removes aDesignDocumentfrom production or development by its name. TheObservablecan error under the following conditions: - com.couchbase.client.java.error.DesignDocumentDoesNotExistException: IfDesignDocumentis not found.- Parameters:
name- the name of theDesignDocument.development- if theDesignDocumentshould be removed from development or production.- Returns:
- true if succeeded, false otherwise.
-
publishDesignDocument
rx.Observable<DesignDocument> publishDesignDocument(String name)
Publishes aDesignDocumentfrom development into production. Note that this method does not override a already existingDesignDocument(seepublishDesignDocument(String, boolean)) as an alternative. TheObservablecan error under the following conditions: - com.couchbase.client.java.error.DesignDocumentAlreadyExistsException: If theDesignDocumentalready exists. - com.couchbase.client.java.error.TranscodingException: If the server response could not be parsed. - com.couchbase.client.java.error.DesignDocumentDoesNotExistException: IfDesignDocumentis not found in development.- Parameters:
name- the name of theDesignDocumentto publish.- Returns:
- the published
DesignDocumenton success.
-
publishDesignDocument
rx.Observable<DesignDocument> publishDesignDocument(String name, boolean overwrite)
Publishes aDesignDocumentfrom development into production. TheObservablecan error under the following conditions: - com.couchbase.client.java.error.DesignDocumentAlreadyExistsException: If theDesignDocumentalready 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: IfDesignDocumentis not found in development.- Parameters:
name- the name of theDesignDocumentto publish.overwrite- if an existingDesignDocumentshould be overridden.- Returns:
- the published
DesignDocumenton success.
-
listN1qlIndexes
rx.Observable<IndexInfo> listN1qlIndexes()
List all N1QL GSI indexes that are registered for the current bucket. The index management API only deals with GSI type of indexes, which allows it to uniquely identify indexes by name. TheObservablecan error under the following conditions: -TranscodingExceptionif the server response couldn't be parsed.- Returns:
- an
Observablethat will get notified of each relevantIndexInfo(can be empty if no relevant index is defined for this bucket).
-
createN1qlPrimaryIndex
rx.Observable<Boolean> createN1qlPrimaryIndex(boolean ignoreIfExist, boolean defer)
Create a primary index for the current bucket. The index management API only deals with GSI type of indexes, which allows it to uniquely identify indexes by name. TheObservablecan error under the following conditions: -IndexAlreadyExistsExceptionif the index already exists and ignoreIfExist is set to false. -CouchbaseExceptionif another error occurs during index creation.- Parameters:
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 untilbuildN1qlDeferredIndexes()is called (or a direct call to the corresponding query service API).- Returns:
- an
Observablethat 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.
-
createN1qlPrimaryIndex
rx.Observable<Boolean> createN1qlPrimaryIndex(String customName, boolean ignoreIfExist, boolean defer)
Create a custom-named primary index for the current bucket. The index management API only deals with GSI type of indexes, which allows it to uniquely identify indexes by name. TheObservablecan error under the following conditions: -IndexAlreadyExistsExceptionif the index already exists and ignoreIfExist is set to false. -CouchbaseExceptionif another error occurs during index creation.- Parameters:
customName- 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 untilbuildN1qlDeferredIndexes()is called (or a direct call to the corresponding query service API).- Returns:
- an
Observablethat 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.
-
createN1qlIndex
rx.Observable<Boolean> createN1qlIndex(String indexName, boolean ignoreIfExist, boolean defer, Object... fields)
Create a secondary index for the current bucket. The index management API only deals with GSI type of indexes, which allows it to uniquely identify indexes by name. The convenience of providing fields as a vararg of either String or Expression comes with the limitation that a WHERE clause cannot be provided. SeecreateN1qlIndex(String, List, Expression, boolean, boolean)for that. TheObservablecan error under the following conditions: -IndexAlreadyExistsExceptionif the index already exists and ignoreIfExist is set to false. -CouchbaseExceptionif another error occurs during index creation.- Parameters:
indexName- 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 untilbuildN1qlDeferredIndexes()is called (or a direct call to the corresponding query service API).fields- the JSON fields to index, in eitherExpressionorStringform.- Returns:
- an
Observablethat 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. - See Also:
createN1qlIndex(String, List, Expression, boolean, boolean)
-
createN1qlIndex
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. The index management API only deals with GSI type of indexes, which allows it to uniquely identify indexes by name. TheObservablecan error under the following conditions: -IndexAlreadyExistsExceptionif the index already exists and ignoreIfExist is set to false. -CouchbaseExceptionif another error occurs during index creation.- Parameters:
indexName- the name of the index.fields- the JSON fields to index, in the form of aListcontaining a mix ofExpressionorString.whereClause- theExpressionto 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 untilbuildN1qlDeferredIndexes()is called (or a direct call to the corresponding query service API).- Returns:
- an
Observablethat 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.
-
dropN1qlPrimaryIndex
rx.Observable<Boolean> dropN1qlPrimaryIndex(boolean ignoreIfNotExist)
Drop the default primary index (Index.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. TheObservablecan error under the following conditions: -IndexDoesNotExistExceptionif the primary index doesn't exist and ignoreIfNoExist is set to false. -CouchbaseExceptionif another error occurs during index drop.- Parameters:
ignoreIfNotExist- if true, attempting to drop on a bucket without any primary index won't cause an exception to be propagated.- Returns:
- an
Observablethat will get notified with a single Boolean.TRUE if the index was effectively dropped.
-
dropN1qlPrimaryIndex
rx.Observable<Boolean> dropN1qlPrimaryIndex(String customName, boolean ignoreIfNotExist)
Drop the given custom-named primary index 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. TheObservablecan error under the following conditions: -IndexDoesNotExistExceptionif the primary index doesn't exist and ignoreIfNoExist is set to false. -CouchbaseExceptionif another error occurs during index drop.- Parameters:
customName- 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.- Returns:
- an
Observablethat will get notified with a single Boolean.TRUE if the index was effectively dropped.
-
dropN1qlIndex
rx.Observable<Boolean> dropN1qlIndex(String name, boolean ignoreIfNotExist)
Drop the given secondary index 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. TheObservablecan error under the following conditions: -IndexDoesNotExistExceptionif the secondary index doesn't exist and ignoreIfNoExist is set to false. -CouchbaseExceptionif another error occurs during index drop.- Parameters:
ignoreIfNotExist- if true, attempting to drop on a bucket without the specified index won't cause an exception to be propagated.- Returns:
- an
Observablethat will get notified with a single Boolean.TRUE if the index was effectively dropped.
-
buildN1qlDeferredIndexes
rx.Observable<List<String>> buildN1qlDeferredIndexes()
Instruct the query engine to trigger the build of indexes that have been deferred. This only considers GSI indexes, as the index management API only deals with this type of indexes. This process itself is asynchronous, meaning that the call will immediately return despite indexes still being in a "pending" or "building" state. This method will return a List of the names of indexes whose build has been triggered, in a single emission.- Returns:
- an
Observablethat will get notified with a single List of index names, the names of the indexes that have been triggered. - See Also:
to poll for a list of indexes to become online.
-
watchN1qlIndexes
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.. This only considers GSI indexes, as the index management API only deals with this type of indexes. Note: You can activate DEBUG level logs on the "DefaultAsyncBucketManager.INDEX_WATCH_LOG_NAME" logger to see various stages of the polling. You can also watch a primary index by using theIndex.PRIMARY_NAMEconstant.- Parameters:
watchList- 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.- Returns:
- a stream of the
IndexInfofor 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.
-
-