Package edu.ie3.datamodel.io.connectors
Class CouchbaseConnector
java.lang.Object
edu.ie3.datamodel.io.connectors.CouchbaseConnector
- All Implemented Interfaces:
DataConnector
Implements a DataConnector for Couchbase. Couchbase is a JSON document based database.
Entities will be persisted in documents which are then mapped by a key.
Entities will be persisted in documents which are then mapped by a key.
-
Constructor Summary
ConstructorDescriptionCouchbaseConnector
(String url, String bucketName, String username, String password) Initializes a new CouchbaseConnector -
Method Summary
Modifier and TypeMethodDescriptionList<CompletableFuture<com.couchbase.client.java.kv.GetResult>>
Returns futures for every key search result, will be executed asychnchronouslyCompletableFuture<com.couchbase.client.java.kv.GetResult>
Returns a future for search result of the given keycom.couchbase.client.java.AsyncCollection
Return the couchbase java sdk equivalent of an asynchronous session - an async collection - to the previously set bucketcom.couchbase.client.java.Collection
Return the couchbase java sdk equivalent of a session - a collection - to the previously set bucketChecks if the database connection is validCompletableFuture<com.couchbase.client.java.kv.MutationResult>
Persist the document to the database and map it to the keyCompletableFuture<com.couchbase.client.java.query.QueryResult>
Returns a future for the result of the given query, will be executed asynchronouslyvoid
shutdown()
-
Constructor Details
-
CouchbaseConnector
Initializes a new CouchbaseConnector- Parameters:
url
- the url to the clusterbucketName
- the name of the bucket to connect tousername
- the user namepassword
- the user password
-
-
Method Details
-
getSession
public com.couchbase.client.java.Collection getSession()Return the couchbase java sdk equivalent of a session - a collection - to the previously set bucket- Returns:
- a couchbase collection
-
getAsyncSession
public com.couchbase.client.java.AsyncCollection getAsyncSession()Return the couchbase java sdk equivalent of an asynchronous session - an async collection - to the previously set bucket- Returns:
- an asynchronous couchbase collection
-
isConnectionValid
Checks if the database connection is valid- Returns:
- true, if the cluster responds to an application based ping
-
shutdown
public void shutdown()- Specified by:
shutdown
in interfaceDataConnector
-
getBucketName
- Returns:
- the bucket name
-
query
Returns a future for the result of the given query, will be executed asynchronously- Parameters:
query
- the query string- Returns:
- a future of the query result
-
bulkGet
Returns futures for every key search result, will be executed asychnchronously- Parameters:
keys
- the keys to get the documents for- Returns:
- list of futures for every key search result
-
get
Returns a future for search result of the given key- Parameters:
key
- the key to get the document for- Returns:
- future of the search result
-
persist
public CompletableFuture<com.couchbase.client.java.kv.MutationResult> persist(String key, Object content) Persist the document to the database and map it to the key- Parameters:
key
- the key for the documentcontent
- the document content- Returns:
- future of the persisting result
-