From 7e98568a30f329ae6f84da2ade5fe4bbfdf2a352 Mon Sep 17 00:00:00 2001 From: Gary Wu Date: Fri, 14 Apr 2017 13:44:13 -0700 Subject: 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 --- .../sdc/common/transaction/mngr/TransactionManager.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'catalog-be/src') 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 transactions; + private Queue 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 queue = EvictingQueue + .create(TransactionUtils.MAX_SIZE_TRANSACTION_LIST); + // make thread-safe + transactions = Queues.synchronizedQueue(queue); } } -- cgit 1.2.3-korg