git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-publishing/document-store-lib-couchbase@128832 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
b0116fa75c
commit
ccbd722709
|
@ -11,6 +11,8 @@ import org.gcube.documentstore.persistence.PersistenceBackend;
|
|||
import org.gcube.documentstore.persistence.PersistenceBackendConfiguration;
|
||||
import org.gcube.documentstore.records.Record;
|
||||
import org.gcube.documentstore.records.RecordUtility;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.couchbase.client.deps.com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.couchbase.client.deps.com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
@ -50,7 +52,8 @@ public class PersistenceCouchBase extends PersistenceBackend {
|
|||
public static final String BUCKET_TASK_NAME_PROPERTY_KEY="AggregatedTaskUsageRecord";
|
||||
public static final String BUCKET_TASK_TYPE="TaskUsageRecord";
|
||||
|
||||
|
||||
private static final Logger logger = LoggerFactory
|
||||
.getLogger(PersistenceCouchBase.class);
|
||||
|
||||
/* The environment configuration */
|
||||
protected static final CouchbaseEnvironment ENV =
|
||||
|
@ -83,6 +86,8 @@ public class PersistenceCouchBase extends PersistenceBackend {
|
|||
|
||||
private Map <String, Bucket> connectionMap;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -94,6 +99,9 @@ public class PersistenceCouchBase extends PersistenceBackend {
|
|||
|
||||
cluster = CouchbaseCluster.create(ENV, url);
|
||||
|
||||
|
||||
logger.trace("cluster: {}",url);
|
||||
|
||||
bucketNameStorage = configuration.getProperty(BUCKET_STORAGE_NAME_PROPERTY_KEY);
|
||||
bucketNameService = configuration.getProperty(BUCKET_SERVICE_NAME_PROPERTY_KEY);
|
||||
bucketNameJob = configuration.getProperty(BUCKET_JOB_NAME_PROPERTY_KEY);
|
||||
|
@ -119,11 +127,18 @@ public class PersistenceCouchBase extends PersistenceBackend {
|
|||
|
||||
bucket = cluster.openBucket(
|
||||
configuration.getProperty(BUCKET_NAME_PROPERTY_KEY), password);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected JsonDocument createItem(JsonObject jsonObject, String id,String recordType) throws Exception {
|
||||
JsonDocument doc = JsonDocument.create(id, jsonObject);
|
||||
|
||||
logger.trace("record type:{}",recordType);
|
||||
|
||||
|
||||
return connectionMap.get(recordType).upsert(doc);
|
||||
//return bucket.upsert(doc);
|
||||
}
|
||||
|
|
Reference in New Issue