import org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException;
import org.opendaylight.ovsdb.hwvtepsouthbound.reconciliation.configuration.HwvtepReconciliationManager;
import org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md.TransactionInvoker;
-import org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md.TransactionInvokerImpl;
import org.opendaylight.ovsdb.lib.OvsdbConnection;
import org.opendaylight.ovsdb.utils.mdsal.utils.Scheduler;
import org.opendaylight.ovsdb.utils.mdsal.utils.TransactionHistory;
private final OvsdbConnection ovsdbConnection;
private HwvtepConnectionManager cm;
- private TransactionInvoker txInvoker;
private EntityOwnershipCandidateRegistration registration;
private HwvtepsbPluginInstanceEntityOwnershipListener providerOwnershipChangeListener;
private HwvtepDataChangeListener hwvtepDTListener;
public HwvtepSouthboundProvider(@Reference final DataBroker dataBroker,
@Reference final EntityOwnershipService entityOwnership,
@Reference final OvsdbConnection ovsdbConnection, @Reference final DOMSchemaService schemaService,
- @Reference final BindingNormalizedNodeSerializer serializer) {
+ @Reference final BindingNormalizedNodeSerializer serializer,
+ @Reference final TransactionInvoker txInvoker) {
this.dataBroker = dataBroker;
entityOwnershipService = entityOwnership;
registration = null;
// FIXME: eliminate this static wiring
HwvtepSouthboundUtil.setInstanceIdentifierCodec(new InstanceIdentifierCodec(schemaService, serializer));
LOG.info("HwvtepSouthboundProvider ovsdbConnectionService: {}", ovsdbConnection);
- txInvoker = new TransactionInvokerImpl(dataBroker);
cm = new HwvtepConnectionManager(dataBroker, txInvoker, entityOwnershipService, ovsdbConnection);
hwvtepDTListener = new HwvtepDataChangeListener(dataBroker, cm);
hwvtepReconciliationManager = new HwvtepReconciliationManager(dataBroker, cm);
@Deactivate
@Override
public void close() {
- if (txInvoker != null) {
- txInvoker.close();
- txInvoker = null;
- }
if (cm != null) {
cm.close();
cm = null;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
+import javax.annotation.PreDestroy;
+import javax.inject.Inject;
+import javax.inject.Singleton;
import org.checkerframework.checker.lock.qual.GuardedBy;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
import org.opendaylight.mdsal.binding.api.Transaction;
import org.opendaylight.mdsal.binding.api.TransactionChain;
import org.opendaylight.mdsal.binding.api.TransactionChainListener;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* Copied over as-is from southbound plugin. Good candidate to be common
* when refactoring code.
*/
+@Singleton
+@Component(service = TransactionInvoker.class)
public final class TransactionInvokerImpl implements TransactionInvoker, TransactionChainListener, Runnable,
AutoCloseable, UncaughtExceptionHandler {
private static final Logger LOG = LoggerFactory.getLogger(TransactionInvokerImpl.class);
private volatile ReadWriteTransaction transactionInFlight = null;
private Iterator<TransactionCommand> commandIterator = null;
- public TransactionInvokerImpl(final DataBroker db) {
+ @Inject
+ @Activate
+ public TransactionInvokerImpl(@Reference final DataBroker db) {
this.db = db;
chain = db.createTransactionChain(this);
ThreadFactory threadFact = new ThreadFactoryBuilder().setNameFormat("transaction-invoker-impl-%d")
return result;
}
+ @PreDestroy
+ @Deactivate
@Override
public void close() {
chain.close();