Removed accounting-lib as test dependency
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-publishing/document-store-lib-couchbase@152924 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
0dbaeb4c63
commit
dc4e1b8a34
6
pom.xml
6
pom.xml
|
@ -75,12 +75,6 @@
|
|||
<artifactId>common-authorization</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.accounting</groupId>
|
||||
<artifactId>accounting-lib</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -7,11 +7,10 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.gcube.accounting.datamodel.AggregatedUsageRecord;
|
||||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
import org.gcube.documentstore.persistence.connections.Connection;
|
||||
import org.gcube.documentstore.persistence.connections.Connections;
|
||||
import org.gcube.documentstore.persistence.connections.Nodes;
|
||||
import org.gcube.documentstore.records.AggregatedRecord;
|
||||
import org.gcube.documentstore.records.DSMapper;
|
||||
import org.gcube.documentstore.records.Record;
|
||||
import org.gcube.documentstore.records.RecordUtility;
|
||||
|
@ -36,14 +35,12 @@ public class PersistenceCouchBase extends PersistenceBackend {
|
|||
private static final Logger logger = LoggerFactory.getLogger(PersistenceCouchBase.class);
|
||||
|
||||
public static final String URL_PROPERTY_KEY = "URL";
|
||||
// public static final String USERNAME_PROPERTY_KEY = "username";
|
||||
public static final String PASSWORD_PROPERTY_KEY = "password";
|
||||
public static final String BUCKET_NAME_PROPERTY_KEY = "bucketName";
|
||||
|
||||
public static final long TIMEOUT_BUCKET = TimeUnit.SECONDS.toMillis(180);
|
||||
public static final long ALIVE_INTERVAL = TimeUnit.HOURS.toMillis(1);
|
||||
|
||||
private final static String AGGREGATED_PREFIX = "Aggregated";
|
||||
protected Map<String, String> bucketNames;
|
||||
|
||||
/* The environment configuration */
|
||||
|
@ -55,8 +52,8 @@ public class PersistenceCouchBase extends PersistenceBackend {
|
|||
|
||||
static {
|
||||
ENV = DefaultCouchbaseEnvironment.builder()
|
||||
.connectTimeout(TIMEOUT_BUCKET * 1000)
|
||||
.keepAliveInterval(ALIVE_INTERVAL * 1000)
|
||||
.connectTimeout(TIMEOUT_BUCKET)
|
||||
.keepAliveInterval(ALIVE_INTERVAL)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -74,14 +71,13 @@ public class PersistenceCouchBase extends PersistenceBackend {
|
|||
Map<String, Class<? extends Record>> recordClasses = RecordUtility.getRecordClassesFound();
|
||||
for (Class<? extends Record> recordClass : recordClasses.values()) {
|
||||
Record recordInstance = recordClass.newInstance();
|
||||
if (recordInstance instanceof UsageRecord && !(recordInstance instanceof AggregatedUsageRecord<?,?>)) {
|
||||
if (recordInstance instanceof Record && !(recordInstance instanceof AggregatedRecord<?,?>)) {
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends UsageRecord> usageRecordClazz = (Class<? extends UsageRecord>) recordClass;
|
||||
logger.debug("Trying to get the Bucket for {}", usageRecordClazz);
|
||||
Class<? extends Record> recordClazz = (Class<? extends Record>) recordClass;
|
||||
logger.debug("Trying to get the Bucket for {}", recordClazz);
|
||||
String recordType = recordInstance.getRecordType();
|
||||
String bucketName = configuration.getProperty(AGGREGATED_PREFIX + recordType);
|
||||
logger.debug("Bucket for {} is {}.", usageRecordClazz, bucketName);
|
||||
String bucketName = configuration.getProperty(recordType);
|
||||
logger.debug("Bucket for {} is {}.", recordClazz, bucketName);
|
||||
bucketNames.put(recordType, bucketName);
|
||||
|
||||
}catch (Exception e) {
|
||||
|
@ -120,20 +116,15 @@ public class PersistenceCouchBase extends PersistenceBackend {
|
|||
}
|
||||
|
||||
protected Bucket getBucketConnection(String recordType) {
|
||||
// Bucket bucket = connectionMap.get(recordType);
|
||||
|
||||
Bucket bucket = null;
|
||||
synchronized (Connections.connectionsMap) {
|
||||
bucket = Connections.connectionsMap.get(nodes).getBucketsMap().get(bucketNames.get(recordType));
|
||||
try {
|
||||
// logger.debug("PersistenceCouchBase getBucketConnection
|
||||
// recordType:{}, bucket
|
||||
// name:{}",recordType,bucketNames.get(recordType));
|
||||
if (bucket == null) {
|
||||
// bucket = cluster.openBucket(recordType, password);
|
||||
bucket = Connections.connectionsMap.get(nodes).getCluster().openBucket(bucketNames.get(recordType),
|
||||
password);
|
||||
logger.trace("PersistenceCouchBase getBucketConnection bucket close, open:{}", bucket.toString());
|
||||
// connectionMap.put(recordType, bucket);
|
||||
Connections.connectionsMap.get(nodes).getBucketsMap().put(bucketNames.get(recordType), bucket);
|
||||
logger.trace("PersistenceCouchBase getBucketConnection connectionMap:{}",
|
||||
Connections.connectionsMap.get(nodes).getBucketsMap());
|
||||
|
|
|
@ -33,6 +33,7 @@ public class PersistenceCouchBaseTest extends ScopedTest {
|
|||
PersistenceBackend persistenceBackend = PersistenceBackendFactory.rediscoverPersistenceBackend(fallbackPersistenceBackend, ScopedTest.getCurrentContext());
|
||||
|
||||
Assert.assertTrue(persistenceBackend instanceof PersistenceCouchBase);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in New Issue