aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java/org
diff options
context:
space:
mode:
authorGary Wu <gary.i.wu@huawei.com>2017-04-14 13:44:13 -0700
committerGary Wu <gary.i.wu@huawei.com>2017-07-12 19:03:01 +0000
commit7e98568a30f329ae6f84da2ade5fe4bbfdf2a352 (patch)
treef09cae301f6e2646367f9ac0e1cc7dcb8da98e81 /catalog-be/src/main/java/org
parentdd60339b06d252fcb1382aa97ab3d65b37dad021 (diff)
Replace CapList with EvictingQueue
The functionality of CapList is already provided by com.google.common.collect.EvictingQueue, so there's no need to implement our own. This change replaces CapList with a synchronized EvictingQueue. Change-Id: I2f7b72bf27169bb90d0bd20f289686685e7f06bf Signed-off-by: Gary Wu <gary.i.wu@huawei.com>
Diffstat (limited to 'catalog-be/src/main/java/org')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/common/transaction/mngr/TransactionManager.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/common/transaction/mngr/TransactionManager.java b/catalog-be/src/main/java/org/openecomp/sdc/common/transaction/mngr/TransactionManager.java
index c401586383..c05431ac7f 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/common/transaction/mngr/TransactionManager.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/common/transaction/mngr/TransactionManager.java
@@ -20,14 +20,13 @@
package org.openecomp.sdc.common.transaction.mngr;
-import java.util.List;
+import java.util.Queue;
import java.util.concurrent.atomic.AtomicInteger;
import javax.annotation.Resource;
import org.openecomp.sdc.be.dao.impl.ESCatalogDAO;
import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
-import org.openecomp.sdc.common.datastructure.CapList;
import org.openecomp.sdc.common.transaction.api.ITransactionSdnc;
import org.openecomp.sdc.common.transaction.api.TransactionUtils;
import org.openecomp.sdc.common.transaction.api.TransactionUtils.ActionTypeEnum;
@@ -35,6 +34,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
+import com.google.common.collect.EvictingQueue;
+import com.google.common.collect.Queues;
+
@Component("transactionManager")
public class TransactionManager {
@@ -42,7 +44,7 @@ public class TransactionManager {
private AtomicInteger transactionIDCounter = new AtomicInteger(0);
- private List<ITransactionSdnc> transactions;
+ private Queue<ITransactionSdnc> transactions;
@Resource
private ESCatalogDAO esCatalogDao;
@Resource
@@ -91,7 +93,10 @@ public class TransactionManager {
private synchronized void init() {
if (transactions == null) {
log.info("TransactionManager Initialized");
- transactions = new CapList<>(TransactionUtils.MAX_SIZE_TRANSACTION_LIST);
+ EvictingQueue<ITransactionSdnc> queue = EvictingQueue
+ .<ITransactionSdnc>create(TransactionUtils.MAX_SIZE_TRANSACTION_LIST);
+ // make thread-safe
+ transactions = Queues.synchronizedQueue(queue);
}
}