From a7ba91828c9eb44748e5c030fbcb0323541c9ce5 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Wed, 7 Aug 2024 18:15:25 +0200 Subject: [PATCH 1/3] Refactor DependencyQueue Rather than having a static single-threaded executor, allocate it in HwvtepConnectionManager, matching their lifecycle. This fixes the problem that a restarted HwvtepConnectionManager would end up talking to a shutdown ExecutorService. It also removes one instance of modifying a static final field. Change-Id: I4d6252d0147e3866cd9387c28eaf78071b743b38 Signed-off-by: Robert Varga --- .../HwvtepConnectionInstance.java | 2 +- .../HwvtepConnectionManager.java | 24 +++++- .../hwvtepsouthbound/HwvtepDeviceInfo.java | 7 +- .../transact/DependencyQueue.java | 76 +++++++++---------- .../DataChangeListenerTestBase.java | 62 +++++++-------- .../HwvtepDataChangeListenerTest.java | 19 ++--- .../SameThreadScheduledExecutor.java | 28 ------- .../transact/DependencyQueueTest.java | 12 +-- 8 files changed, 99 insertions(+), 131 deletions(-) delete mode 100644 hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/SameThreadScheduledExecutor.java diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepConnectionInstance.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepConnectionInstance.java index 6162ac520..c685e817f 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepConnectionInstance.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepConnectionInstance.java @@ -96,7 +96,7 @@ public class HwvtepConnectionInstance { this.client = client; this.instanceIdentifier = iid; this.txInvoker = txInvoker; - this.deviceInfo = new HwvtepDeviceInfo(this); + this.deviceInfo = new HwvtepDeviceInfo(hwvtepConnectionManager.dependencyExecutor(), this); this.dataBroker = dataBroker; this.hwvtepTableReader = new HwvtepTableReader(this); } diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepConnectionManager.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepConnectionManager.java index 58bd11daa..a9b7d641f 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepConnectionManager.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepConnectionManager.java @@ -10,10 +10,12 @@ package org.opendaylight.ovsdb.hwvtepsouthbound; import static java.util.Objects.requireNonNull; import static org.opendaylight.ovsdb.lib.operations.Operations.op; +import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Maps; import com.google.common.util.concurrent.FluentFuture; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.MoreExecutors; +import com.google.common.util.concurrent.ThreadFactoryBuilder; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.net.ConnectException; import java.net.InetAddress; @@ -25,6 +27,9 @@ import java.util.Map; import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutionException; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.eclipse.jdt.annotation.NonNull; @@ -42,7 +47,6 @@ import org.opendaylight.ovsdb.hwvtepsouthbound.reconciliation.ReconciliationMana import org.opendaylight.ovsdb.hwvtepsouthbound.reconciliation.ReconciliationTask; import org.opendaylight.ovsdb.hwvtepsouthbound.reconciliation.configuration.HwvtepReconciliationTask; import org.opendaylight.ovsdb.hwvtepsouthbound.reconciliation.connection.ConnectionReconciliationTask; -import org.opendaylight.ovsdb.hwvtepsouthbound.transact.DependencyQueue; import org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md.HwvtepGlobalRemoveCommand; import org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md.TransactionInvoker; import org.opendaylight.ovsdb.lib.OvsdbClient; @@ -74,6 +78,9 @@ public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoClo private static final int DB_FETCH_TIMEOUT = 1000; private static final int TRANSACTION_HISTORY_CAPACITY = 10000; private static final int TRANSACTION_HISTORY_WATERMARK = 7500; + private static final ThreadFactory DEPENDENCY_THREAD_FACTORY = new ThreadFactoryBuilder() + .setNameFormat("hwvtep-waiting-job-%d") + .build(); private final DataBroker db; private final TransactionInvoker txInvoker; @@ -89,16 +96,19 @@ public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoClo private final Map, TransactionHistory> deviceUpdateHistory = new ConcurrentHashMap<>(); private final OvsdbConnection ovsdbConnectionService; private final Map alreadyProcessedClients = new ConcurrentHashMap<>(); + private final ScheduledExecutorService dependencyExecutor; public HwvtepConnectionManager(final DataBroker db, final TransactionInvoker txInvoker, final EntityOwnershipService entityOwnershipService, final OvsdbConnection ovsdbConnectionService) { this.db = db; this.txInvoker = txInvoker; this.entityOwnershipService = entityOwnershipService; - hwvtepDeviceEntityOwnershipListener = new HwvtepDeviceEntityOwnershipListener(this,entityOwnershipService); + this.ovsdbConnectionService = ovsdbConnectionService; + dependencyExecutor = Executors.newSingleThreadScheduledExecutor(DEPENDENCY_THREAD_FACTORY); + + hwvtepDeviceEntityOwnershipListener = new HwvtepDeviceEntityOwnershipListener(this, entityOwnershipService); reconciliationManager = new ReconciliationManager(db); hwvtepOperGlobalListener = new HwvtepOperGlobalListener(db, this); - this.ovsdbConnectionService = ovsdbConnectionService; } @Override @@ -113,7 +123,8 @@ public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoClo for (HwvtepConnectionInstance client : clients.values()) { client.disconnect(); } - DependencyQueue.close(); + + dependencyExecutor.shutdown(); } @Override @@ -719,4 +730,9 @@ public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoClo */ ON_DISCONNECT } + + @VisibleForTesting + public ScheduledExecutorService dependencyExecutor() { + return dependencyExecutor; + } } diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepDeviceInfo.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepDeviceInfo.java index b555be074..8b4d691f8 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepDeviceInfo.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepDeviceInfo.java @@ -14,6 +14,7 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.atomic.AtomicInteger; import org.opendaylight.ovsdb.hwvtepsouthbound.transact.DependencyQueue; import org.opendaylight.ovsdb.hwvtepsouthbound.transact.DependentJob; @@ -150,9 +151,9 @@ public class HwvtepDeviceInfo { private TransactionHistory controllerTxHistory = null; private TransactionHistory deviceUpdateHistory = null; - public HwvtepDeviceInfo(HwvtepConnectionInstance hwvtepConnectionInstance) { - this.connectionInstance = hwvtepConnectionInstance; - this.dependencyQueue = new DependencyQueue(this); + public HwvtepDeviceInfo(ScheduledExecutorService dependencyExecutor, HwvtepConnectionInstance connectionInstance) { + this.connectionInstance = connectionInstance; + this.dependencyQueue = new DependencyQueue(dependencyExecutor, this); } public LogicalSwitch getLogicalSwitch(UUID uuid) { diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/DependencyQueue.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/DependencyQueue.java index c1df1d0ab..51ea67f35 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/DependencyQueue.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/DependencyQueue.java @@ -7,12 +7,11 @@ */ package org.opendaylight.ovsdb.hwvtepsouthbound.transact; -import com.google.common.util.concurrent.ThreadFactoryBuilder; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.concurrent.Executors; +import java.util.concurrent.Executor; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; @@ -27,23 +26,22 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class DependencyQueue { - private static final Logger LOG = LoggerFactory.getLogger(DependencyQueue.class); - private static final ScheduledExecutorService EXECUTOR_SERVICE = Executors.newSingleThreadScheduledExecutor( - new ThreadFactoryBuilder().setNameFormat("hwvtep-waiting-job-%d").build()); private final LinkedBlockingQueue configWaitQueue = new LinkedBlockingQueue<>( HwvtepSouthboundConstants.WAITING_QUEUE_CAPACITY); private final LinkedBlockingQueue opWaitQueue = new LinkedBlockingQueue<>( HwvtepSouthboundConstants.WAITING_QUEUE_CAPACITY); private final HwvtepDeviceInfo deviceInfo; + private final Executor executor; @SuppressWarnings("checkstyle:IllegalCatch") - public DependencyQueue(HwvtepDeviceInfo hwvtepDeviceInfo) { + public DependencyQueue(final ScheduledExecutorService executor, HwvtepDeviceInfo hwvtepDeviceInfo) { + this.executor = executor; this.deviceInfo = hwvtepDeviceInfo; final AtomicReference> expiredTasksMonitorJob = new AtomicReference<>(); - expiredTasksMonitorJob.set(EXECUTOR_SERVICE.scheduleWithFixedDelay(() -> { + expiredTasksMonitorJob.set(executor.scheduleWithFixedDelay(() -> { try { LOG.debug("Processing dependencies"); if (!deviceInfo.getConnectionInstance().getOvsdbClient().isActive()) { @@ -101,41 +99,39 @@ public class DependencyQueue { @SuppressFBWarnings(value = "RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT") private void processReadyJobs(final HwvtepConnectionInstance hwvtepConnectionInstance, LinkedBlockingQueue queue) { - final List readyJobs = getReadyJobs(queue); - readyJobs.forEach((job) -> { - EXECUTOR_SERVICE.execute(() -> - hwvtepConnectionInstance.transact(new TransactCommand() { - HwvtepOperationalState operationalState = new HwvtepOperationalState(hwvtepConnectionInstance); - AtomicInteger retryCount = new AtomicInteger(5); - - @Override - public boolean retry() { - return retryCount.decrementAndGet() > 0; - } + final var readyJobs = getReadyJobs(queue); + readyJobs.forEach(job -> { + executor.execute(() -> hwvtepConnectionInstance.transact(new TransactCommand() { + final HwvtepOperationalState operationalState = new HwvtepOperationalState(hwvtepConnectionInstance); + final AtomicInteger retryCount = new AtomicInteger(5); + + @Override + public boolean retry() { + return retryCount.decrementAndGet() > 0; + } - @Override - public void execute(TransactionBuilder transactionBuilder) { - deviceInfo.clearKeyFromDependencyQueue(job.getKey()); - if (operationalState.getConnectionInstance() != null - && operationalState.getConnectionInstance().isActive()) { - job.onDependencyResolved(operationalState, transactionBuilder); - } + @Override + public void execute(TransactionBuilder transactionBuilder) { + deviceInfo.clearKeyFromDependencyQueue(job.getKey()); + if (operationalState.getConnectionInstance() != null + && operationalState.getConnectionInstance().isActive()) { + job.onDependencyResolved(operationalState, transactionBuilder); } + } - @Override - @SuppressFBWarnings(value = "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR") - public void onFailure(TransactionBuilder tx) { - job.onFailure(); - operationalState.clearIntransitKeys(); + @Override + public void onFailure(TransactionBuilder tx) { + job.onFailure(); + operationalState.clearIntransitKeys(); - } + } - @Override - public void onSuccess(TransactionBuilder tx) { - job.onSuccess(); - operationalState.getDeviceInfo().onOperDataAvailable(); - } - })); + @Override + public void onSuccess(TransactionBuilder tx) { + job.onSuccess(); + operationalState.getDeviceInfo().onOperDataAvailable(); + } + })); }); } @@ -159,11 +155,7 @@ public class DependencyQueue { return readyJobs; } - public static void close() { - EXECUTOR_SERVICE.shutdown(); - } - public void submit(Runnable runnable) { - EXECUTOR_SERVICE.execute(runnable); + executor.execute(runnable); } } diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/DataChangeListenerTestBase.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/DataChangeListenerTestBase.java index 8ab8a2939..d4baf518f 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/DataChangeListenerTestBase.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/DataChangeListenerTestBase.java @@ -98,7 +98,7 @@ public class DataChangeListenerTestBase extends AbstractDataBrokerTest { OvsdbConnectionInfo connectionInfo; Operations operations; HwvtepDataChangeListener hwvtepDataChangeListener; - HwvtepConnectionManager hwvtepConnectionManager; + protected HwvtepConnectionManager hwvtepConnectionManager; protected HwvtepConnectionInstance connectionInstance; ArgumentCaptor insertOpCapture; @@ -119,8 +119,34 @@ public class DataChangeListenerTestBase extends AbstractDataBrokerTest { ls1Iid = nodeIid.augmentation(HwvtepGlobalAugmentation.class).child(LogicalSwitches.class, new LogicalSwitchesKey(new HwvtepNodeName("ls1"))); loadSchema(); - mockConnectionInstance(); - mockConnectionManager(); + + transactionInvoker = new TransactionInvokerImpl(getDataBroker()); + hwvtepConnectionManager = spy(new HwvtepConnectionManager(getDataBroker(), transactionInvoker, + entityOwnershipService, mock(OvsdbConnection.class))); + + connectionInfo = mock(OvsdbConnectionInfo.class); + doReturn(mock(InetAddress.class)).when(connectionInfo).getRemoteAddress(); + + ovsdbClient = mock(OvsdbClient.class); + doReturn(true).when(ovsdbClient).isActive(); + doReturn(connectionInfo).when(ovsdbClient).getConnectionInfo(); + doReturn(listenableDbSchema).when(ovsdbClient).getSchema(anyString()); + + connectionInstance = new HwvtepConnectionInstance(hwvtepConnectionManager, null, ovsdbClient, nodeIid, + transactionInvoker, getDataBroker()); + connectionInstance.reconciliationFt.set(Boolean.TRUE); + connectionInstance.firstUpdateTriggered.set(true); + connectionInstance.setControllerTxHistory(new TransactionHistory(10000, 7500)); + connectionInstance.setDeviceUpdateHistory(new TransactionHistory(10000, 7500)); + connectionInstance.createTransactInvokers(); + + doReturn(connectionInstance).when(hwvtepConnectionManager).getConnectionInstance( + any(HwvtepPhysicalSwitchAttributes.class)); + doReturn(connectionInstance).when(hwvtepConnectionManager).getConnectionInstance(any(Node.class)); + doReturn(connectionInstance).when(hwvtepConnectionManager).getConnectionInstanceFromNodeIid( + any(InstanceIdentifier.class)); + + mockOperations(); addNode(LogicalDatastoreType.OPERATIONAL); @@ -167,36 +193,6 @@ public class DataChangeListenerTestBase extends AbstractDataBrokerTest { } } - private void mockConnectionManager() throws IllegalAccessException { - hwvtepConnectionManager = spy(new HwvtepConnectionManager(getDataBroker(), transactionInvoker, - entityOwnershipService, mock(OvsdbConnection.class))); - doReturn(connectionInstance).when(hwvtepConnectionManager).getConnectionInstance( - any(HwvtepPhysicalSwitchAttributes.class)); - doReturn(connectionInstance).when(hwvtepConnectionManager).getConnectionInstance(any(Node.class)); - doReturn(connectionInstance).when(hwvtepConnectionManager).getConnectionInstanceFromNodeIid( - any(InstanceIdentifier.class)); - } - - void mockConnectionInstance() { - connectionInfo = mock(OvsdbConnectionInfo.class); - doReturn(mock(InetAddress.class)).when(connectionInfo).getRemoteAddress(); - - ovsdbClient = mock(OvsdbClient.class); - doReturn(true).when(ovsdbClient).isActive(); - doReturn(connectionInfo).when(ovsdbClient).getConnectionInfo(); - doReturn(listenableDbSchema).when(ovsdbClient).getSchema(anyString()); - - transactionInvoker = new TransactionInvokerImpl(getDataBroker()); - - connectionInstance = new HwvtepConnectionInstance(null, null, ovsdbClient, nodeIid, transactionInvoker, - getDataBroker()); - connectionInstance.reconciliationFt.set(Boolean.TRUE); - connectionInstance.firstUpdateTriggered.set(true); - connectionInstance.setControllerTxHistory(new TransactionHistory(10000, 7500)); - connectionInstance.setDeviceUpdateHistory(new TransactionHistory(10000, 7500)); - connectionInstance.createTransactInvokers(); - } - void mockOperations() { resetOperations(); } diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepDataChangeListenerTest.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepDataChangeListenerTest.java index 8557b0f1d..219f0b1d7 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepDataChangeListenerTest.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepDataChangeListenerTest.java @@ -5,13 +5,12 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.ovsdb.hwvtepsouthbound; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.timeout; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -23,10 +22,8 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentMatchers; -import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.ovsdb.hwvtepsouthbound.transact.DependencyQueue; import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.lib.schema.typed.TypedBaseTable; import org.opendaylight.ovsdb.schema.hardwarevtep.LogicalSwitch; @@ -91,8 +88,6 @@ public class HwvtepDataChangeListenerTest extends DataChangeListenerTestBase { @Before public void setupListener() throws Exception { - setFinalStatic(DependencyQueue.class, "EXECUTOR_SERVICE", mock(SameThreadScheduledExecutor.class, - Mockito.CALLS_REAL_METHODS)); opDataChangeListener = new HwvtepOperationalDataChangeListener(getDataBroker(), hwvtepConnectionManager, connectionInstance); } @@ -267,26 +262,26 @@ public class HwvtepDataChangeListenerTest extends DataChangeListenerTestBase { resetOperations(); addData(LogicalDatastoreType.CONFIGURATION, TerminationPoint.class, terminationPoints); addData(LogicalDatastoreType.CONFIGURATION, RemoteUcastMacs.class, ucastMacs); - verify(Operations.op, times(4)).insert(any(UcastMacsRemote.class)); + verify(Operations.op, times(4)).insert(any(UcastMacsRemote.class)); resetOperations(); addData(LogicalDatastoreType.CONFIGURATION, RemoteMcastMacs.class, mcastMacs); //2 mcast mac + 2 locator sets ( termination point already added ) - verify(Operations.op, times(0)).insert(ArgumentMatchers.any()); + verify(Operations.op, times(0)).insert(ArgumentMatchers.any()); resetOperations(); addData(LogicalDatastoreType.OPERATIONAL, TerminationPoint.class, terminationPoints); addData(LogicalDatastoreType.OPERATIONAL, RemoteUcastMacs.class, ucastMacs); connectionInstance.getDeviceInfo().onOperDataAvailable(); //2 mcast mac + 2 locator sets ( termination point already added ) - verify(Operations.op, times(4)).insert(ArgumentMatchers.any()); + verify(Operations.op, timeout(2000).times(4)).insert(ArgumentMatchers.any()); resetOperations(); addData(LogicalDatastoreType.CONFIGURATION, RemoteMcastMacs.class, mcastMac2); - verify(Operations.op, times(0)).insert(ArgumentMatchers.any()); + verify(Operations.op, times(0)).insert(ArgumentMatchers.any()); addData(LogicalDatastoreType.OPERATIONAL, RemoteMcastMacs.class, mcastMacs); connectionInstance.getDeviceInfo().onOperDataAvailable(); - verify(Operations.op, times(2)).insert(ArgumentMatchers.any()); - verify(Operations.op, times(2)).update(ArgumentMatchers.any()); + verify(Operations.op, timeout(2000).times(2)).insert(ArgumentMatchers.any()); + verify(Operations.op, times(2)).update(ArgumentMatchers.any()); } private void verifyThatLogicalSwitchCreated() { diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/SameThreadScheduledExecutor.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/SameThreadScheduledExecutor.java deleted file mode 100644 index ed7df7348..000000000 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/SameThreadScheduledExecutor.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2017 Ericsson India Global Services Pvt Ltd. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.ovsdb.hwvtepsouthbound; - -import com.google.common.util.concurrent.SettableFuture; -import java.util.concurrent.Future; -import java.util.concurrent.ScheduledExecutorService; - -public abstract class SameThreadScheduledExecutor implements ScheduledExecutorService { - - @Override - public void execute(Runnable runnable) { - runnable.run(); - } - - @Override - public Future submit(Runnable runnable) { - runnable.run(); - SettableFuture ft = SettableFuture.create(); - ft.set(null); - return ft; - } -} diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/DependencyQueueTest.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/DependencyQueueTest.java index aeef2444c..49602158e 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/DependencyQueueTest.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/DependencyQueueTest.java @@ -14,11 +14,9 @@ import java.util.Map; import java.util.concurrent.CountDownLatch; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.ovsdb.hwvtepsouthbound.DataChangeListenerTestBase; -import org.opendaylight.ovsdb.hwvtepsouthbound.SameThreadScheduledExecutor; import org.opendaylight.ovsdb.hwvtepsouthbound.TestBuilders; import org.opendaylight.ovsdb.lib.notation.UUID; import org.opendaylight.ovsdb.lib.operations.TransactionBuilder; @@ -56,8 +54,6 @@ public class DependencyQueueTest extends DataChangeListenerTestBase { .child(LogicalSwitches.class, new LogicalSwitchesKey(new HwvtepNodeName("ls0"))); macIid = nodeIid.augmentation(HwvtepGlobalAugmentation.class) .child(RemoteMcastMacs.class, new RemoteMcastMacsKey(mac.key())); - setFinalStatic(DependencyQueue.class, "EXECUTOR_SERVICE", Mockito.mock(SameThreadScheduledExecutor.class, - Mockito.CALLS_REAL_METHODS)); } @Test @@ -69,8 +65,8 @@ public class DependencyQueueTest extends DataChangeListenerTestBase { final CountDownLatch latch = new CountDownLatch(1); opState.getDeviceInfo().addJobToQueue(new DependentJob.ConfigWaitingJob(macIid, mac, unMetDependencies) { @Override - protected void onDependencyResolved(HwvtepOperationalState operationalState, - TransactionBuilder transactionBuilder) { + protected void onDependencyResolved(final HwvtepOperationalState operationalState, + final TransactionBuilder transactionBuilder) { latch.countDown(); } }); @@ -90,8 +86,8 @@ public class DependencyQueueTest extends DataChangeListenerTestBase { opState.getDeviceInfo().addJobToQueue(new DependentJob.OpWaitingJob( macIid, mac, (Map)unMetDependencies, 0) { @Override - protected void onDependencyResolved(HwvtepOperationalState operationalState, - TransactionBuilder transactionBuilder) { + protected void onDependencyResolved(final HwvtepOperationalState operationalState, + final TransactionBuilder transactionBuilder) { latch.countDown(); } }); -- 2.43.0 From 3d2b623d70c6b6e069fa386de5e5fb81ec5b0f1a Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Mon, 8 Jul 2024 23:43:22 +0200 Subject: [PATCH 2/3] WIP: Eliminate static Operations wiring Operations.op is a static field, from whence everybody is getting their operations. This is not exactly nice, as it makes library not really a library and it means tests are relying on changing a static final field -- which is a huge no-no with Java 21. This patch turns Operations into an interface, provided by DefaultOperations. Everybody is then taught to get Operations injected, eliminating the need for statics. // FIXME: deal with failing tests Change-Id: Ied3fbfe062f081f2ea9d8640d09513fabeab9268 Signed-off-by: Robert Varga --- .../hwvtepsouthbound-impl/pom.xml | 8 +- .../HwvtepConnectionInstance.java | 9 +- .../HwvtepConnectionManager.java | 9 +- .../HwvtepSouthboundProvider.java | 5 +- .../hwvtepsouthbound/HwvtepTableReader.java | 11 +-- .../transact/AbstractTransactCommand.java | 5 + .../transact/LogicalRouterRemoveCommand.java | 4 +- .../transact/LogicalRouterUpdateCommand.java | 4 +- .../LogicalSwitchUcastsRemoveCommand.java | 4 +- .../transact/LogicalSwitchUpdateCommand.java | 3 +- .../transact/McastMacsLocalRemoveCommand.java | 4 +- .../transact/McastMacsLocalUpdateCommand.java | 5 +- .../McastMacsRemoteRemoveCommand.java | 6 +- .../McastMacsRemoteUpdateCommand.java | 6 +- .../transact/PhysicalPortRemoveCommand.java | 4 +- .../transact/PhysicalPortUpdateCommand.java | 4 +- .../transact/PhysicalSwitchRemoveCommand.java | 4 +- .../transact/PhysicalSwitchUpdateCommand.java | 8 +- .../transact/PlainLogicalSwitchRemoveCmd.java | 4 +- .../transact/TransactUtils.java | 8 +- .../transact/UcastMacsLocalRemoveCommand.java | 4 +- .../transact/UcastMacsLocalUpdateCommand.java | 4 +- .../UcastMacsRemoteRemoveCommand.java | 4 +- .../UcastMacsRemoteUpdateCommand.java | 6 +- .../DataChangeListenerTestBase.java | 55 ++--------- .../HwvtepDataChangeListenerTest.java | 49 +++++---- .../lib/operations/DefaultOperations.java | 99 +++++++++++++++++++ .../ovsdb/lib/operations/Operations.java | 64 +++--------- .../ovsdbclient/OvsdbClientTestIT.java | 1 - .../ovsdbclient/OvsdbClientTestTypedIT.java | 1 - .../schema/HardwareVTEPIT.java | 1 - .../integrationtest/schema/OpenVSwitchIT.java | 1 - .../opendaylight/ovsdb/lib/it/LibraryIT.java | 1 - .../lib/it/LibraryIntegrationTestBase.java | 4 + .../southbound/OvsdbConnectionInstance.java | 27 ++--- .../southbound/OvsdbConnectionManager.java | 14 +-- .../OvsdbDataTreeChangeListener.java | 2 +- .../ovsdb/southbound/SouthboundProvider.java | 12 ++- .../transact/AbstractTransactCommand.java | 20 ++++ .../transact/AutoAttachRemovedCommand.java | 20 ++-- .../transact/AutoAttachUpdateCommand.java | 20 ++-- .../ovsdb/transact/BridgeRemovedCommand.java | 12 ++- .../ovsdb/transact/BridgeUpdateCommand.java | 29 +++--- .../transact/ControllerRemovedCommand.java | 16 +-- .../transact/ControllerUpdateCommand.java | 12 ++- .../transact/OpenVSwitchBridgeAddCommand.java | 10 +- .../transact/OvsdbNodeUpdateCommand.java | 19 ++-- .../transact/ProtocolRemovedCommand.java | 15 +-- .../ovsdb/transact/ProtocolUpdateCommand.java | 12 ++- .../ovsdb/transact/QosRemovedCommand.java | 14 +-- .../ovsdb/transact/QosUpdateCommand.java | 10 +- .../ovsdb/transact/QueueRemovedCommand.java | 15 +-- .../ovsdb/transact/QueueUpdateCommand.java | 10 +- .../TerminationPointCreateCommand.java | 21 ++-- .../TerminationPointDeleteCommand.java | 11 ++- .../TerminationPointUpdateCommand.java | 12 ++- .../transact/TransactCommandAggregator.java | 15 ++- .../ovsdb/transact/TransactUtils.java | 11 +-- .../BridgeConfigReconciliationTask.java | 2 +- ...minationPointConfigReconciliationTask.java | 6 +- .../OvsdbConnectionInstanceTest.java | 4 +- .../OvsdbConnectionManagerTest.java | 13 ++- .../OvsdbDataTreeChangeListenerTest.java | 6 +- .../southbound/SouthboundProviderTest.java | 7 +- .../OpenVSwitchBridgeAddCommandTest.java | 7 +- .../transact/OvsdbNodeUpdateCommandTest.java | 14 +-- .../TerminationPointCreateCommandTest.java | 10 +- .../TerminationPointUpdateCommandTest.java | 9 +- .../TransactCommandAggregatorTest.java | 3 +- .../ovsdb/transact/TransactUtilsTest.java | 21 ++-- 70 files changed, 491 insertions(+), 379 deletions(-) create mode 100644 library/impl/src/main/java/org/opendaylight/ovsdb/lib/operations/DefaultOperations.java create mode 100644 southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/AbstractTransactCommand.java diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/pom.xml b/hwvtepsouthbound/hwvtepsouthbound-impl/pom.xml index 725a05c8d..91bc02c14 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/pom.xml +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/pom.xml @@ -114,15 +114,9 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.apache.maven.plugins maven-surefire-plugin + 1 false - - - - @{argLine} - --add-opens java.base/java.lang=ALL-UNNAMED - --add-opens java.base/java.lang.reflect=ALL-UNNAMED - diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepConnectionInstance.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepConnectionInstance.java index c685e817f..ba694437e 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepConnectionInstance.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepConnectionInstance.java @@ -45,6 +45,7 @@ import org.opendaylight.ovsdb.lib.message.TableUpdates; import org.opendaylight.ovsdb.lib.notation.Row; import org.opendaylight.ovsdb.lib.operations.Operation; import org.opendaylight.ovsdb.lib.operations.OperationResult; +import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.lib.operations.TransactionBuilder; import org.opendaylight.ovsdb.lib.schema.DatabaseSchema; import org.opendaylight.ovsdb.lib.schema.GenericTableSchema; @@ -77,6 +78,7 @@ public class HwvtepConnectionInstance { private HwvtepGlobalAugmentation initialCreatedData = null; private final HwvtepDeviceInfo deviceInfo; private final DataBroker dataBroker; + private final Operations ops; private final HwvtepConnectionManager hwvtepConnectionManager; private static final ScheduledExecutorService SCHEDULED_EXECUTOR_SERVICE = Executors .newSingleThreadScheduledExecutor(new ThreadFactoryBuilder() @@ -90,7 +92,7 @@ public class HwvtepConnectionInstance { HwvtepConnectionInstance(final HwvtepConnectionManager hwvtepConnectionManager, final ConnectionInfo key, final OvsdbClient client, final InstanceIdentifier iid, final TransactionInvoker txInvoker, - final DataBroker dataBroker) { + final DataBroker dataBroker, final Operations ops) { this.hwvtepConnectionManager = hwvtepConnectionManager; this.connectionInfo = key; this.client = client; @@ -98,6 +100,7 @@ public class HwvtepConnectionInstance { this.txInvoker = txInvoker; this.deviceInfo = new HwvtepDeviceInfo(hwvtepConnectionManager.dependencyExecutor(), this); this.dataBroker = dataBroker; + this.ops = ops; this.hwvtepTableReader = new HwvtepTableReader(this); } @@ -410,4 +413,8 @@ public class HwvtepConnectionInstance { public TransactionInvoker getTxInvoker() { return txInvoker; } + + public Operations ops() { + return ops; + } } diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepConnectionManager.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepConnectionManager.java index a9b7d641f..010850052 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepConnectionManager.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepConnectionManager.java @@ -8,7 +8,6 @@ package org.opendaylight.ovsdb.hwvtepsouthbound; import static java.util.Objects.requireNonNull; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Maps; @@ -54,6 +53,7 @@ import org.opendaylight.ovsdb.lib.OvsdbConnection; import org.opendaylight.ovsdb.lib.OvsdbConnectionListener; import org.opendaylight.ovsdb.lib.operations.Operation; import org.opendaylight.ovsdb.lib.operations.OperationResult; +import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.lib.operations.Select; import org.opendaylight.ovsdb.lib.schema.GenericTableSchema; import org.opendaylight.ovsdb.lib.schema.typed.TypedDatabaseSchema; @@ -84,6 +84,7 @@ public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoClo private final DataBroker db; private final TransactionInvoker txInvoker; + private final Operations ops; private final Map> instanceIdentifiers = new ConcurrentHashMap<>(); private final Map entityConnectionMap = new ConcurrentHashMap<>(); private final EntityOwnershipService entityOwnershipService; @@ -98,10 +99,11 @@ public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoClo private final Map alreadyProcessedClients = new ConcurrentHashMap<>(); private final ScheduledExecutorService dependencyExecutor; - public HwvtepConnectionManager(final DataBroker db, final TransactionInvoker txInvoker, + public HwvtepConnectionManager(final DataBroker db, final TransactionInvoker txInvoker, final Operations ops, final EntityOwnershipService entityOwnershipService, final OvsdbConnection ovsdbConnectionService) { this.db = db; this.txInvoker = txInvoker; + this.ops = ops; this.entityOwnershipService = entityOwnershipService; this.ovsdbConnectionService = ovsdbConnectionService; dependencyExecutor = Executors.newSingleThreadScheduledExecutor(DEPENDENCY_THREAD_FACTORY); @@ -277,7 +279,7 @@ public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoClo } hwvtepConnectionInstance = new HwvtepConnectionInstance(this, key, - externalClient, getInstanceIdentifier(key), txInvoker, db); + externalClient, getInstanceIdentifier(key), txInvoker, db, ops); hwvtepConnectionInstance.createTransactInvokers(); return hwvtepConnectionInstance; } @@ -465,6 +467,7 @@ public class HwvtepConnectionManager implements OvsdbConnectionListener, AutoClo } GenericTableSchema hwvtepSchema = dbSchema.getTableSchema(Global.class); + final var op = connectionInstance.ops(); Select selectOperation = op.select(hwvtepSchema); selectOperation.setColumns(hwvtepSchema.getColumnList()); diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepSouthboundProvider.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepSouthboundProvider.java index 14497292e..1ce0fcc08 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepSouthboundProvider.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepSouthboundProvider.java @@ -32,6 +32,7 @@ import org.opendaylight.mdsal.eos.common.api.EntityOwnershipStateChange; import org.opendaylight.ovsdb.hwvtepsouthbound.reconciliation.configuration.HwvtepReconciliationManager; import org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md.TransactionInvoker; import org.opendaylight.ovsdb.lib.OvsdbConnection; +import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.utils.mdsal.utils.Scheduler; import org.opendaylight.ovsdb.utils.mdsal.utils.TransactionHistory; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology; @@ -74,7 +75,7 @@ public final class HwvtepSouthboundProvider @Reference final EntityOwnershipService entityOwnership, @Reference final OvsdbConnection ovsdbConnection, @Reference final DOMSchemaService schemaService, @Reference final BindingNormalizedNodeSerializer serializer, - @Reference final TransactionInvoker txInvoker) { + @Reference final TransactionInvoker txInvoker, @Reference final Operations ops) { this.dataBroker = dataBroker; entityOwnershipService = entityOwnership; registration = null; @@ -82,7 +83,7 @@ public final class HwvtepSouthboundProvider // FIXME: eliminate this static wiring HwvtepSouthboundUtil.setInstanceIdentifierCodec(new InstanceIdentifierCodec(schemaService, serializer)); LOG.info("HwvtepSouthboundProvider ovsdbConnectionService: {}", ovsdbConnection); - cm = new HwvtepConnectionManager(dataBroker, txInvoker, entityOwnershipService, ovsdbConnection); + cm = new HwvtepConnectionManager(dataBroker, txInvoker, ops, entityOwnershipService, ovsdbConnection); hwvtepDTListener = new HwvtepDataChangeListener(dataBroker, cm); hwvtepReconciliationManager = new HwvtepReconciliationManager(dataBroker, cm); //Register listener for entityOnwership changes diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepTableReader.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepTableReader.java index 24ca4b90b..df7a650e3 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepTableReader.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepTableReader.java @@ -8,7 +8,6 @@ package org.opendaylight.ovsdb.hwvtepsouthbound; import static java.util.Objects.requireNonNull; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; import com.google.common.collect.ImmutableClassToInstanceMap; import com.google.common.collect.ImmutableClassToInstanceMap.Builder; @@ -268,7 +267,7 @@ public class HwvtepTableReader { final Class> tableClass = TABLE_MAP.get(cls); final GenericTableSchema hwvtepSchema = dbSchema.getTableSchema(tableClass); - final Select selectOperation = op.select(hwvtepSchema); + final Select selectOperation = connectionInstance.ops().select(hwvtepSchema); selectOperation.setColumns(hwvtepSchema.getColumnList()); if (existingUUID == null) { @@ -329,7 +328,7 @@ public class HwvtepTableReader { final Class> tableClass = TABLE_MAP.get(cls); final GenericTableSchema hwvtepSchema = dbSchema.getTableSchema(tableClass); - final Select selectOperation = op.select(hwvtepSchema); + final Select selectOperation = connectionInstance.ops().select(hwvtepSchema); selectOperation.setColumns(hwvtepSchema.getColumnList()); final List results; @@ -364,7 +363,7 @@ public class HwvtepTableReader { TypedDatabaseSchema dbSchema = connectionInstance.getSchema(HwvtepSchemaConstants.HARDWARE_VTEP).get(); List operations = Arrays.stream(ALL_TABLES) .map(tableClass -> dbSchema.getTableSchema(tableClass)) - .map(HwvtepTableReader::buildSelectOperationFor) + .map(this::buildSelectOperationFor) .collect(Collectors.toList()); List results = connectionInstance.transact(dbSchema, operations).get(); @@ -409,8 +408,8 @@ public class HwvtepTableReader { } } - private static Select buildSelectOperationFor(final GenericTableSchema tableSchema) { - Select selectOperation = op.select(tableSchema); + private Select buildSelectOperationFor(final GenericTableSchema tableSchema) { + Select selectOperation = connectionInstance.ops().select(tableSchema); selectOperation.setColumns(tableSchema.getColumnList()); return selectOperation; } diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/AbstractTransactCommand.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/AbstractTransactCommand.java index 428cd351b..83aa920d6 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/AbstractTransactCommand.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/AbstractTransactCommand.java @@ -30,6 +30,7 @@ import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepDeviceInfo; import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundUtil; import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepTableReader; import org.opendaylight.ovsdb.lib.notation.UUID; +import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.lib.operations.TransactionBuilder; import org.opendaylight.ovsdb.lib.schema.typed.TypedBaseTable; import org.opendaylight.ovsdb.utils.mdsal.utils.TransactionType; @@ -76,6 +77,10 @@ public abstract class AbstractTransactCommand & DataObject return changes; } + public Operations ops() { + return getOperationalState().getConnectionInstance().ops(); + } + void updateCurrentTxDeleteData(final Class cls, final InstanceIdentifier key, final T data) { hwvtepOperationalState.updateCurrentTxDeleteData(cls, key); diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/LogicalRouterRemoveCommand.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/LogicalRouterRemoveCommand.java index abd99c9e3..18fb2af77 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/LogicalRouterRemoveCommand.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/LogicalRouterRemoveCommand.java @@ -7,8 +7,6 @@ */ package org.opendaylight.ovsdb.hwvtepsouthbound.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; - import java.util.Collection; import java.util.Collections; import java.util.List; @@ -75,6 +73,8 @@ public class LogicalRouterRemoveCommand private void removeLogicalRouter(final TransactionBuilder transaction, final InstanceIdentifier instanceIdentifier, final List routerList) { + final var op = ops(); + for (LogicalRouters lrouter: routerList) { LOG.debug("Removing logical router named: {}", lrouter.getHwvtepNodeName().getValue()); Optional operationalRouterOptional = diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/LogicalRouterUpdateCommand.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/LogicalRouterUpdateCommand.java index 060f587b6..3240cebb8 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/LogicalRouterUpdateCommand.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/LogicalRouterUpdateCommand.java @@ -7,8 +7,6 @@ */ package org.opendaylight.ovsdb.hwvtepsouthbound.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; - import java.util.Collection; import java.util.HashMap; import java.util.List; @@ -57,6 +55,8 @@ public class LogicalRouterUpdateCommand private void updateLogicalRouter(final TransactionBuilder transaction, final InstanceIdentifier instanceIdentifier, final List routerList) { + final var op = ops(); + for (LogicalRouters lrouter: routerList) { final InstanceIdentifier routerKey = instanceIdentifier .augmentation(HwvtepGlobalAugmentation.class).child(LogicalRouters.class, lrouter.key()); diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/LogicalSwitchUcastsRemoveCommand.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/LogicalSwitchUcastsRemoveCommand.java index 63cb5ad8f..fdaa0fb48 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/LogicalSwitchUcastsRemoveCommand.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/LogicalSwitchUcastsRemoveCommand.java @@ -7,8 +7,6 @@ */ package org.opendaylight.ovsdb.hwvtepsouthbound.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; - import java.util.Collection; import java.util.HashMap; import java.util.HashSet; @@ -70,7 +68,9 @@ public final class LogicalSwitchUcastsRemoveCommand InstanceIdentifier lsKey = nodeIid.augmentation(HwvtepGlobalAugmentation.class) .child(LogicalSwitches.class, logicalSwitches.key()); HwvtepDeviceInfo.DeviceData deviceData = super.fetchDeviceData(LogicalSwitches.class, lsKey); + if (deviceData != null && deviceData.getUuid() != null) { + final var op = ops(); UUID logicalSwitchUuid = deviceData.getUuid(); diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/LogicalSwitchUpdateCommand.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/LogicalSwitchUpdateCommand.java index 2538c0716..d5c50db61 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/LogicalSwitchUpdateCommand.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/LogicalSwitchUpdateCommand.java @@ -8,7 +8,6 @@ package org.opendaylight.ovsdb.hwvtepsouthbound.transact; import static org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundUtil.schemaMismatchLog; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; import java.util.Collection; import java.util.HashSet; @@ -84,6 +83,8 @@ public class LogicalSwitchUpdateCommand setDescription(logicalSwitch, lswitch); setTunnelKey(logicalSwitch, lswitch); setReplicationMode(logicalSwitch, lswitch); + final var op = ops(); + if (operationalSwitchOptional == null) { setName(logicalSwitch, lswitch); LOG.trace("execute: creating LogicalSwitch entry: {}", logicalSwitch); diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsLocalRemoveCommand.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsLocalRemoveCommand.java index 5e65c7754..30abe59ee 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsLocalRemoveCommand.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsLocalRemoveCommand.java @@ -7,8 +7,6 @@ */ package org.opendaylight.ovsdb.hwvtepsouthbound.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; - import java.util.Collection; import java.util.List; import java.util.Map; @@ -49,6 +47,8 @@ public class McastMacsLocalRemoveCommand private void removeMcastMacLocal(final TransactionBuilder transaction, final InstanceIdentifier instanceIdentifier, final List macList) { + final var op = ops(); + for (LocalMcastMacs mac: macList) { LOG.debug("Removing localMcastMacs, mac address: {}", mac.getMacEntryKey().getValue()); Optional operationalMacOptional = diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsLocalUpdateCommand.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsLocalUpdateCommand.java index 862fce0c2..c6a80d43d 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsLocalUpdateCommand.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsLocalUpdateCommand.java @@ -5,11 +5,8 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.ovsdb.hwvtepsouthbound.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; - import java.util.Collection; import java.util.List; import java.util.Map; @@ -53,6 +50,8 @@ public class McastMacsLocalUpdateCommand private void updateMcastMacsLocal(final TransactionBuilder transaction, final InstanceIdentifier instanceIdentifier, final List localMcastMacs) { + final var op = ops(); + for (LocalMcastMacs localMcastMac: localMcastMacs) { LOG.debug("Creating localMcastMac, mac address: {}", localMcastMac.getMacEntryKey().getValue()); final Optional operationalMacOptional = diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsRemoteRemoveCommand.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsRemoteRemoveCommand.java index 12db813a3..6cb08faf8 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsRemoteRemoveCommand.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsRemoteRemoveCommand.java @@ -7,8 +7,6 @@ */ package org.opendaylight.ovsdb.hwvtepsouthbound.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; - import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -104,7 +102,7 @@ public class McastMacsRemoteRemoveCommand && ((McastMacsRemote)deviceData.getData()).getLogicalSwitchColumn() != null) { UUID logicalSwitchUid = ((McastMacsRemote)deviceData.getData()).getLogicalSwitchColumn().getData(); if (logicalSwitchUid != null) { - transaction.add(op.delete(mcastMacsRemote.getSchema()) + transaction.add(ops().delete(mcastMacsRemote.getSchema()) .where(mcastMacsRemote.getLogicalSwitchColumn().getSchema().opEqual(logicalSwitchUid)).build()); deleted = true; updateCurrentTxDeleteData(RemoteMcastMacs.class, macIid, mac); @@ -120,7 +118,7 @@ public class McastMacsRemoteRemoveCommand if (macEntryUUID != null) { mcastMacsRemote.getUuidColumn().setData(macEntryUUID); updateCurrentTxDeleteData(RemoteMcastMacs.class, macIid, mac); - transaction.add(op.delete(mcastMacsRemote.getSchema()) + transaction.add(ops().delete(mcastMacsRemote.getSchema()) .where(mcastMacsRemote.getUuidColumn().getSchema().opEqual(macEntryUUID)).build()); updateControllerTxHistory(TransactionType.DELETE, new StringBuilder(mcastMacsRemote.toString()) .append(": Mac : ").append(macEntryUUID)); diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsRemoteUpdateCommand.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsRemoteUpdateCommand.java index bc8a5f966..0ce24d612 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsRemoteUpdateCommand.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsRemoteUpdateCommand.java @@ -7,8 +7,6 @@ */ package org.opendaylight.ovsdb.hwvtepsouthbound.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; - import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Lists; import com.google.common.collect.Sets; @@ -107,7 +105,7 @@ public class McastMacsRemoteUpdateCommand HwvtepDeviceInfo.DeviceData deviceData = super.fetchDeviceData(RemoteMcastMacs.class, macIid); if (deviceData == null) { setLocatorSet(transaction, mcastMacsRemote, mac); - transaction.add(op.insert(mcastMacsRemote)); + transaction.add(ops().insert(mcastMacsRemote)); updateCurrentTxData(RemoteMcastMacs.class, macIid, new UUID("uuid"), mac); updateControllerTxHistory(TransactionType.ADD, mcastMacsRemote); LOG.info("CONTROLLER - {} {}", TransactionType.ADD, mcastMacsRemote); @@ -116,7 +114,7 @@ public class McastMacsRemoteUpdateCommand UUID macEntryUUID = deviceData.getUuid(); McastMacsRemote extraMac = transaction.getTypedRowSchema(McastMacsRemote.class); extraMac.getUuidColumn().setData(macEntryUUID); - transaction.add(op.update(mcastMacsRemote) + transaction.add(ops().update(mcastMacsRemote) .where(extraMac.getUuidColumn().getSchema().opEqual(macEntryUUID)) .build()); updateControllerTxHistory(TransactionType.UPDATE, mcastMacsRemote); diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PhysicalPortRemoveCommand.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PhysicalPortRemoveCommand.java index af31c6011..8037c085a 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PhysicalPortRemoveCommand.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PhysicalPortRemoveCommand.java @@ -7,8 +7,6 @@ */ package org.opendaylight.ovsdb.hwvtepsouthbound.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; - import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -52,6 +50,8 @@ public class PhysicalPortRemoveCommand extends AbstractTransactCommand { private void updatePhysicalPort(final TransactionBuilder transaction, final InstanceIdentifier psNodeiid, final List listPort) { + final var op = ops(); + for (HwvtepPhysicalPortAugmentation port : listPort) { LOG.debug("Updating a physical port named: {}", port.getHwvtepNodeName().getValue()); Optional operationalPhysicalPortOptional = diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PhysicalPortUpdateCommand.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PhysicalPortUpdateCommand.java index 733695420..b903917c0 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PhysicalPortUpdateCommand.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PhysicalPortUpdateCommand.java @@ -7,8 +7,6 @@ */ package org.opendaylight.ovsdb.hwvtepsouthbound.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; - import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -148,6 +146,8 @@ public class PhysicalPortUpdateCommand TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), PhysicalPort.class); extraPhyscialPort.setName(""); LOG.trace("execute: updating physical port: {} {}", nodeId, physicalPort); + final var op = ops(); + transaction.add(op.update(physicalPort) .where(extraPhyscialPort.getNameColumn().getSchema().opEqual(existingPhysicalPortName)) .build()); diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PhysicalSwitchRemoveCommand.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PhysicalSwitchRemoveCommand.java index 45ddde080..8c84fb231 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PhysicalSwitchRemoveCommand.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PhysicalSwitchRemoveCommand.java @@ -7,8 +7,6 @@ */ package org.opendaylight.ovsdb.hwvtepsouthbound.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; - import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -59,6 +57,8 @@ public class PhysicalSwitchRemoveCommand extends AbstractTransactCommand { UUID physicalSwitchUuid = new UUID(operationalPhysicalSwitchOptional.orElseThrow() .getPhysicalSwitchUuid().getValue()); Global global = transaction.getTypedRowSchema(Global.class); + final var op = ops(); + transaction.add(op.delete(physicalSwitch.getSchema()) .where(physicalSwitch.getUuidColumn().getSchema().opEqual(physicalSwitchUuid)).build()); transaction.add(op.comment("Physical Switch: Deleting " diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PhysicalSwitchUpdateCommand.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PhysicalSwitchUpdateCommand.java index 2b22dd078..74887ae8f 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PhysicalSwitchUpdateCommand.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PhysicalSwitchUpdateCommand.java @@ -5,11 +5,9 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.ovsdb.hwvtepsouthbound.transact; import static org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundUtil.schemaMismatchLog; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; import com.google.common.collect.ImmutableMap; import java.util.Collection; @@ -96,6 +94,8 @@ public final class PhysicalSwitchUpdateCommand extends AbstractTransactCommand { schemaMismatchLog("tunnels", "Physical_Switch", e); } if (!operationalPhysicalSwitchOptional.isPresent()) { + final var op = ops(); + //create a physical switch setName(physicalSwitch, physicalSwitchAugmentation, operationalPhysicalSwitchOptional); String pswitchUuid = "PhysicalSwitch_" + HwvtepSouthboundMapper.getRandomUUID(); @@ -128,6 +128,8 @@ public final class PhysicalSwitchUpdateCommand extends AbstractTransactCommand { PhysicalSwitch extraPhysicalSwitch = transaction.getTypedRowWrapper(PhysicalSwitch.class); extraPhysicalSwitch.setName(""); LOG.trace("execute: updating physical switch: {}", physicalSwitch); + final var op = ops(); + transaction.add(op.update(physicalSwitch) .where(extraPhysicalSwitch.getNameColumn().getSchema().opEqual(existingPhysicalSwitchName)) .build()); @@ -181,6 +183,8 @@ public final class PhysicalSwitchUpdateCommand extends AbstractTransactCommand { private void setTunnels(final TransactionBuilder transaction, final InstanceIdentifier iid, final PhysicalSwitch physicalSwitch, final PhysicalSwitchAugmentation physicalSwitchAugmentation, final boolean switchExists) { + final var op = ops(); + //TODO: revisit this code for optimizations //TODO: needs more testing for (Tunnels tunnel : physicalSwitchAugmentation.nonnullTunnels().values()) { diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PlainLogicalSwitchRemoveCmd.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PlainLogicalSwitchRemoveCmd.java index bd4a180da..10c32a5b3 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PlainLogicalSwitchRemoveCmd.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PlainLogicalSwitchRemoveCmd.java @@ -7,8 +7,6 @@ */ package org.opendaylight.ovsdb.hwvtepsouthbound.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; - import java.util.Collection; import java.util.Map; import java.util.Objects; @@ -50,7 +48,7 @@ public final class PlainLogicalSwitchRemoveCmd public void execute(final TransactionBuilder transaction) { LogicalSwitch logicalSwitch = TyperUtils.getTypedRowWrapper( transaction.getDatabaseSchema(), LogicalSwitch.class, null); - transaction.add(op.delete(logicalSwitch.getSchema()) + transaction.add(ops().delete(logicalSwitch.getSchema()) .where(logicalSwitch.getNameColumn().getSchema().opEqual( logicalSwitches.getHwvtepNodeName().getValue())).build()); } diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/TransactUtils.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/TransactUtils.java index 02e76b5e7..bc6550afe 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/TransactUtils.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/TransactUtils.java @@ -7,8 +7,6 @@ */ package org.opendaylight.ovsdb.hwvtepsouthbound.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; - import java.util.Collection; import java.util.HashMap; import java.util.HashSet; @@ -141,7 +139,8 @@ public final class TransactUtils { PhysicalLocatorSet physicalLocatorSet = transaction.getTypedRowWrapper(PhysicalLocatorSet.class); physicalLocatorSet.setLocators(locators); String locatorSetUuid = "PhysicalLocatorSet_" + HwvtepSouthboundMapper.getRandomUUID(); - transaction.add(op.insert(physicalLocatorSet).withId(locatorSetUuid)); + transaction.add(hwvtepOperationalState.getConnectionInstance().ops() + .insert(physicalLocatorSet).withId(locatorSetUuid)); hwvtepOperationalState.getDeviceInfo().addToControllerTx(TransactionType.ADD, new StringBuilder(physicalLocatorSet.toString()).append(" Uuid ").append(locatorSetUuid) .append(" ").append(locatorsInfo.toString())); @@ -183,7 +182,8 @@ public final class TransactUtils { setEncapsulationType(physicalLocator, inputLocator); setDstIp(physicalLocator, inputLocator); String locatorUuid = "PhysicalLocator_" + HwvtepSouthboundMapper.getRandomUUID(); - transaction.add(op.insert(physicalLocator).withId(locatorUuid)); + transaction.add(hwvtepOperationalState.getConnectionInstance().ops() + .insert(physicalLocator).withId(locatorUuid)); hwvtepOperationalState.getDeviceInfo().addToControllerTx(TransactionType.ADD, new StringBuilder(physicalLocator.toString()).append(" Uuid ").append(locatorUuid)); LOG.info("CONTROLLER - {} {}", TransactionType.ADD, diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsLocalRemoveCommand.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsLocalRemoveCommand.java index b5b69ea12..30bae44c2 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsLocalRemoveCommand.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsLocalRemoveCommand.java @@ -7,8 +7,6 @@ */ package org.opendaylight.ovsdb.hwvtepsouthbound.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; - import java.util.Collection; import java.util.List; import java.util.Map; @@ -49,6 +47,8 @@ public class UcastMacsLocalRemoveCommand private void removeUcastMacLocal(final TransactionBuilder transaction, final InstanceIdentifier instanceIdentifier, final List macList) { + final var op = ops(); + for (LocalUcastMacs mac: macList) { LOG.debug("Removing remoteUcastMacs, mac address: {}", mac.getMacEntryKey().getValue()); Optional operationalMacOptional = diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsLocalUpdateCommand.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsLocalUpdateCommand.java index b3417df7b..967c1af15 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsLocalUpdateCommand.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsLocalUpdateCommand.java @@ -7,8 +7,6 @@ */ package org.opendaylight.ovsdb.hwvtepsouthbound.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; - import java.util.Collection; import java.util.List; import java.util.Map; @@ -55,6 +53,8 @@ public class UcastMacsLocalUpdateCommand private void updateUcastMacsLocal(final TransactionBuilder transaction, final InstanceIdentifier instanceIdentifier, final List localUcastMacs) { + final var op = ops(); + for (LocalUcastMacs localUcastMac: localUcastMacs) { LOG.debug("Creating localUcastMacs, mac address: {}", localUcastMac.getMacEntryKey().getValue()); final Optional operationalMacOptional = diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsRemoteRemoveCommand.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsRemoteRemoveCommand.java index 8be5952fe..b5ac30713 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsRemoteRemoveCommand.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsRemoteRemoveCommand.java @@ -7,8 +7,6 @@ */ package org.opendaylight.ovsdb.hwvtepsouthbound.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; - import com.google.common.collect.Lists; import java.util.Collection; import java.util.List; @@ -85,6 +83,8 @@ public class UcastMacsRemoteRemoveCommand final InstanceIdentifier instanceIdentifier, final List macList) { String nodeId = instanceIdentifier.firstKeyOf(Node.class).getNodeId().getValue(); + final var op = ops(); + for (RemoteUcastMacs mac: macList) { final InstanceIdentifier macIid = instanceIdentifier.augmentation(HwvtepGlobalAugmentation.class) diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsRemoteUpdateCommand.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsRemoteUpdateCommand.java index be27d9909..1973807f8 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsRemoteUpdateCommand.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsRemoteUpdateCommand.java @@ -7,8 +7,6 @@ */ package org.opendaylight.ovsdb.hwvtepsouthbound.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; - import com.google.common.collect.Lists; import java.util.Collection; import java.util.Collections; @@ -99,7 +97,7 @@ public class UcastMacsRemoteUpdateCommand setMac(ucastMacsRemote, remoteUcastMac); LOG.trace("DoDeviceTransaction: creating RemotUcastMac entry: {} txId: {}", macKey, getOperationalState().getTransactionId()); - transaction.add(op.insert(ucastMacsRemote)); + transaction.add(ops().insert(ucastMacsRemote)); updateCurrentTxData(RemoteUcastMacs.class, macKey, new UUID("uuid"), remoteUcastMac); LOG.info("CONTROLLER - {} {}", TransactionType.ADD, ucastMacsRemote); return; @@ -121,7 +119,7 @@ public class UcastMacsRemoteUpdateCommand extraMac.getUuidColumn().setData(macEntryUUID); LOG.trace("doDeviceTransaction: updating RemotUcastMac entry: {} txId: {}", macKey, getOperationalState().getTransactionId()); - transaction.add(op.update(ucastMacsRemote) + transaction.add(ops().update(ucastMacsRemote) .where(extraMac.getUuidColumn().getSchema().opEqual(macEntryUUID)) .build()); LOG.info("CONTROLLER - {} {}", TransactionType.UPDATE, ucastMacsRemote); diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/DataChangeListenerTestBase.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/DataChangeListenerTestBase.java index d4baf518f..7472fdfd0 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/DataChangeListenerTestBase.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/DataChangeListenerTestBase.java @@ -11,6 +11,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.reset; import static org.mockito.Mockito.spy; import com.fasterxml.jackson.databind.JsonNode; @@ -18,14 +19,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.util.concurrent.ListenableFuture; import java.io.IOException; import java.io.InputStream; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.VarHandle; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; import java.net.InetAddress; import java.util.List; import java.util.concurrent.ExecutionException; -import org.apache.commons.lang3.reflect.FieldUtils; import org.junit.After; import org.junit.Before; import org.mockito.ArgumentCaptor; @@ -78,18 +74,6 @@ import org.slf4j.LoggerFactory; public class DataChangeListenerTestBase extends AbstractDataBrokerTest { private static final Logger LOG = LoggerFactory.getLogger(DataChangeListenerTestBase.class); - // Hack to hack into Field.class for now - private static final VarHandle MODIFIERS; - - static { - try { - var lookup = MethodHandles.privateLookupIn(Field.class, MethodHandles.lookup()); - MODIFIERS = lookup.findVarHandle(Field.class, "modifiers", int.class); - } catch (IllegalAccessException | NoSuchFieldException e) { - throw new ExceptionInInitializerError(e); - } - } - EntityOwnershipService entityOwnershipService; OvsdbClient ovsdbClient; TypedDatabaseSchema dbSchema; @@ -109,6 +93,8 @@ public class DataChangeListenerTestBase extends AbstractDataBrokerTest { InstanceIdentifier ls0Iid; InstanceIdentifier ls1Iid; + Operations mockOp; + @Before public void setupTest() throws Exception { entityOwnershipService = mock(EntityOwnershipService.class); @@ -120,8 +106,9 @@ public class DataChangeListenerTestBase extends AbstractDataBrokerTest { new LogicalSwitchesKey(new HwvtepNodeName("ls1"))); loadSchema(); + mockOp = mock(Operations.class); transactionInvoker = new TransactionInvokerImpl(getDataBroker()); - hwvtepConnectionManager = spy(new HwvtepConnectionManager(getDataBroker(), transactionInvoker, + hwvtepConnectionManager = spy(new HwvtepConnectionManager(getDataBroker(), transactionInvoker, mockOp, entityOwnershipService, mock(OvsdbConnection.class))); connectionInfo = mock(OvsdbConnectionInfo.class); @@ -133,7 +120,7 @@ public class DataChangeListenerTestBase extends AbstractDataBrokerTest { doReturn(listenableDbSchema).when(ovsdbClient).getSchema(anyString()); connectionInstance = new HwvtepConnectionInstance(hwvtepConnectionManager, null, ovsdbClient, nodeIid, - transactionInvoker, getDataBroker()); + transactionInvoker, getDataBroker(), mockOp); connectionInstance.reconciliationFt.set(Boolean.TRUE); connectionInstance.firstUpdateTriggered.set(true); connectionInstance.setControllerTxHistory(new TransactionHistory(10000, 7500)); @@ -161,24 +148,6 @@ public class DataChangeListenerTestBase extends AbstractDataBrokerTest { deleteNode(LogicalDatastoreType.CONFIGURATION); } - protected static final void setFinalStatic(final Class cls, final String fieldName, final Object newValue) - throws SecurityException, ReflectiveOperationException { - Field[] fields = FieldUtils.getAllFields(cls); - for (Field field : fields) { - if (fieldName.equals(field.getName())) { - field.setAccessible(true); - - final int mods = field.getModifiers(); - if (Modifier.isFinal(mods)) { - MODIFIERS.set(field, mods & ~Modifier.FINAL); - } - - field.set(null, newValue); - break; - } - } - } - void loadSchema() { try (InputStream resourceAsStream = DataChangeListenerTestBase.class.getResourceAsStream( "hwvtep_schema.json")) { @@ -201,13 +170,15 @@ public class DataChangeListenerTestBase extends AbstractDataBrokerTest { * Resets the captures so that we can validate the captors of the immediate next execution. */ void resetOperations() { + reset(mockOp); + insertOpCapture = ArgumentCaptor.forClass(TypedBaseTable.class); Delete delete = mock(Delete.class); Where where = mock(Where.class); doReturn(where).when(delete).where(any()); Insert insert = mock(Insert.class); doReturn(insert).when(insert).withId(any(String.class)); - Operations mockOp = mock(Operations.class); + doReturn(insert).when(mockOp).insert(insertOpCapture.capture()); Update update = mock(Update.class); doReturn(update).when(mockOp).update(insertOpCapture.capture()); @@ -216,14 +187,6 @@ public class DataChangeListenerTestBase extends AbstractDataBrokerTest { doReturn(where).when(update).where(any()); doReturn(delete).when(mockOp).delete(any()); - - - try { - setFinalStatic(Operations.class, "op", mockOp); - } catch (SecurityException | ReflectiveOperationException e) { - throw new AssertionError("Set of Operations.op field failed", e); - } - ListenableFuture> ft = mock(ListenableFuture.class); transactCaptor = ArgumentCaptor.forClass(List.class); doReturn(ft).when(ovsdbClient).transact(any(DatabaseSchema.class), transactCaptor.capture()); diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepDataChangeListenerTest.java b/hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepDataChangeListenerTest.java index 219f0b1d7..e65280111 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepDataChangeListenerTest.java +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/src/test/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepDataChangeListenerTest.java @@ -24,7 +24,6 @@ import org.junit.runner.RunWith; import org.mockito.ArgumentMatchers; import org.mockito.junit.MockitoJUnitRunner; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.lib.schema.typed.TypedBaseTable; import org.opendaylight.ovsdb.schema.hardwarevtep.LogicalSwitch; import org.opendaylight.ovsdb.schema.hardwarevtep.McastMacsRemote; @@ -109,7 +108,7 @@ public class HwvtepDataChangeListenerTest extends DataChangeListenerTestBase { addData(LogicalDatastoreType.OPERATIONAL, LogicalSwitches.class, logicalSwitches); resetOperations(); deleteData(LogicalDatastoreType.CONFIGURATION, LogicalSwitches.class, logicalSwitches); - verify(Operations.op, times(10)).delete(any()); + verify(mockOp, times(10)).delete(any()); } @Test @@ -120,7 +119,7 @@ public class HwvtepDataChangeListenerTest extends DataChangeListenerTestBase { addData(LogicalDatastoreType.CONFIGURATION, TerminationPoint.class, terminationPoints); addData(LogicalDatastoreType.CONFIGURATION, RemoteUcastMacs.class, ucastMacs); //4 ucast macs + 2 termination points - verify(Operations.op, times(4)).insert(any(UcastMacsRemote.class)); + verify(mockOp, times(4)).insert(any(UcastMacsRemote.class)); //TODO add finer grained validation } @@ -131,7 +130,7 @@ public class HwvtepDataChangeListenerTest extends DataChangeListenerTestBase { resetOperations(); addData(LogicalDatastoreType.CONFIGURATION, RemoteUcastMacs.class, ucastMacs); //4 ucast macs + 2 termination points - verify(Operations.op, times(4)).insert(any(UcastMacsRemote.class)); + verify(mockOp, times(4)).insert(any(UcastMacsRemote.class)); //TODO add finer grained validation } @@ -146,7 +145,7 @@ public class HwvtepDataChangeListenerTest extends DataChangeListenerTestBase { resetOperations(); deleteData(LogicalDatastoreType.CONFIGURATION, RemoteUcastMacs.class, ucastMacs); - verify(Operations.op, times(4)).delete(any()); + verify(mockOp, times(4)).delete(any()); //TODO add finer grained validation } @@ -158,7 +157,7 @@ public class HwvtepDataChangeListenerTest extends DataChangeListenerTestBase { addData(LogicalDatastoreType.CONFIGURATION, TerminationPoint.class, terminationPoints); addData(LogicalDatastoreType.CONFIGURATION, RemoteMcastMacs.class, mcastMacs); //2 mcast macs + 2 locator sets + 3 termination points - verify(Operations.op, times(7)).insert(ArgumentMatchers.any()); + verify(mockOp, times(7)).insert(ArgumentMatchers.any()); } @Test @@ -168,7 +167,7 @@ public class HwvtepDataChangeListenerTest extends DataChangeListenerTestBase { resetOperations(); addData(LogicalDatastoreType.CONFIGURATION, RemoteMcastMacs.class, mcastMacs); //2 mcast macs + 2 locator sets + 3 termination points - verify(Operations.op, times(7)).insert(ArgumentMatchers.any()); + verify(mockOp, times(7)).insert(ArgumentMatchers.any()); } @Test @@ -182,7 +181,7 @@ public class HwvtepDataChangeListenerTest extends DataChangeListenerTestBase { resetOperations(); deleteData(LogicalDatastoreType.CONFIGURATION, RemoteMcastMacs.class, mcastMacs); - verify(Operations.op, times(2)).delete(ArgumentMatchers.any()); + verify(mockOp, times(2)).delete(ArgumentMatchers.any()); } @Test @@ -192,14 +191,14 @@ public class HwvtepDataChangeListenerTest extends DataChangeListenerTestBase { resetOperations(); addData(LogicalDatastoreType.CONFIGURATION, TerminationPoint.class, terminationPoints); addData(LogicalDatastoreType.CONFIGURATION, RemoteUcastMacs.class, ucastMacs); - verify(Operations.op, times(4)).insert(any(UcastMacsRemote.class)); + verify(mockOp, times(4)).insert(any(UcastMacsRemote.class)); addData(LogicalDatastoreType.OPERATIONAL, TerminationPoint.class, terminationPoints); addData(LogicalDatastoreType.OPERATIONAL, RemoteUcastMacs.class, ucastMacs); resetOperations(); addData(LogicalDatastoreType.CONFIGURATION, RemoteMcastMacs.class, mcastMacs); //2 mcast mac + 2 locator sets ( termination point already added ) - verify(Operations.op, times(4)).insert(ArgumentMatchers.any()); + verify(mockOp, times(4)).insert(ArgumentMatchers.any()); } @Test @@ -209,20 +208,20 @@ public class HwvtepDataChangeListenerTest extends DataChangeListenerTestBase { resetOperations(); addData(LogicalDatastoreType.CONFIGURATION, TerminationPoint.class, terminationPoints); addData(LogicalDatastoreType.CONFIGURATION, RemoteUcastMacs.class, ucastMacs); - verify(Operations.op, times(4)).insert(any(UcastMacsRemote.class)); + verify(mockOp, times(4)).insert(any(UcastMacsRemote.class)); addData(LogicalDatastoreType.OPERATIONAL, TerminationPoint.class, terminationPoints); addData(LogicalDatastoreType.OPERATIONAL, RemoteUcastMacs.class, ucastMacs); resetOperations(); addData(LogicalDatastoreType.CONFIGURATION, RemoteMcastMacs.class, mcastMacs); - verify(Operations.op, times(4)).insert(ArgumentMatchers.any()); + verify(mockOp, times(4)).insert(ArgumentMatchers.any()); addData(LogicalDatastoreType.OPERATIONAL, RemoteMcastMacs.class, mcastMacs); resetOperations(); addData(LogicalDatastoreType.CONFIGURATION, RemoteMcastMacs.class, mcastMac2); - verify(Operations.op, times(2)).insert(ArgumentMatchers.any()); - verify(Operations.op, times(2)).update(ArgumentMatchers.any()); - verify(Operations.op, times(0)).delete(ArgumentMatchers.any()); + verify(mockOp, times(2)).insert(ArgumentMatchers.any()); + verify(mockOp, times(2)).update(ArgumentMatchers.any()); + verify(mockOp, times(0)).delete(ArgumentMatchers.any()); } @Test @@ -232,13 +231,13 @@ public class HwvtepDataChangeListenerTest extends DataChangeListenerTestBase { resetOperations(); addData(LogicalDatastoreType.CONFIGURATION, TerminationPoint.class, terminationPoints); addData(LogicalDatastoreType.CONFIGURATION, RemoteUcastMacs.class, ucastMacs); - verify(Operations.op, times(4)).insert(any(UcastMacsRemote.class)); + verify(mockOp, times(4)).insert(any(UcastMacsRemote.class)); addData(LogicalDatastoreType.OPERATIONAL, TerminationPoint.class, terminationPoints); addData(LogicalDatastoreType.OPERATIONAL, RemoteUcastMacs.class, ucastMacs); resetOperations(); addData(LogicalDatastoreType.CONFIGURATION, RemoteMcastMacs.class, mcastMacs); - verify(Operations.op, times(4)).insert(ArgumentMatchers.any()); + verify(mockOp, times(4)).insert(ArgumentMatchers.any()); addData(LogicalDatastoreType.OPERATIONAL, RemoteMcastMacs.class, mcastMacs); resetOperations(); @@ -252,7 +251,7 @@ public class HwvtepDataChangeListenerTest extends DataChangeListenerTestBase { augIid.child(RemoteMcastMacs.class, new RemoteMcastMacsKey(TestBuilders.buildLogicalSwitchesRef(nodeIid, "ls1"), macAddr)) .child(LocatorSet.class)); - verify(Operations.op, times(2)).delete(ArgumentMatchers.any()); + verify(mockOp, times(2)).delete(ArgumentMatchers.any()); } @Test @@ -262,32 +261,32 @@ public class HwvtepDataChangeListenerTest extends DataChangeListenerTestBase { resetOperations(); addData(LogicalDatastoreType.CONFIGURATION, TerminationPoint.class, terminationPoints); addData(LogicalDatastoreType.CONFIGURATION, RemoteUcastMacs.class, ucastMacs); - verify(Operations.op, times(4)).insert(any(UcastMacsRemote.class)); + verify(mockOp, times(4)).insert(any(UcastMacsRemote.class)); resetOperations(); addData(LogicalDatastoreType.CONFIGURATION, RemoteMcastMacs.class, mcastMacs); //2 mcast mac + 2 locator sets ( termination point already added ) - verify(Operations.op, times(0)).insert(ArgumentMatchers.any()); + verify(mockOp, times(0)).insert(ArgumentMatchers.any()); resetOperations(); addData(LogicalDatastoreType.OPERATIONAL, TerminationPoint.class, terminationPoints); addData(LogicalDatastoreType.OPERATIONAL, RemoteUcastMacs.class, ucastMacs); connectionInstance.getDeviceInfo().onOperDataAvailable(); //2 mcast mac + 2 locator sets ( termination point already added ) - verify(Operations.op, timeout(2000).times(4)).insert(ArgumentMatchers.any()); + verify(mockOp, timeout(2000).times(4)).insert(ArgumentMatchers.any()); resetOperations(); addData(LogicalDatastoreType.CONFIGURATION, RemoteMcastMacs.class, mcastMac2); - verify(Operations.op, times(0)).insert(ArgumentMatchers.any()); + verify(mockOp, times(0)).insert(ArgumentMatchers.any()); addData(LogicalDatastoreType.OPERATIONAL, RemoteMcastMacs.class, mcastMacs); connectionInstance.getDeviceInfo().onOperDataAvailable(); - verify(Operations.op, timeout(2000).times(2)).insert(ArgumentMatchers.any()); - verify(Operations.op, times(2)).update(ArgumentMatchers.any()); + verify(mockOp, timeout(2000).times(2)).insert(ArgumentMatchers.any()); + verify(mockOp, times(2)).update(ArgumentMatchers.any()); } private void verifyThatLogicalSwitchCreated() { //The transactions could be firing in two different mdsal updates intermittently //verify(ovsdbClient, times(1)).transact(any(DatabaseSchema.class), any(List.class)); - verify(Operations.op, times(2)).insert(any(LogicalSwitch.class)); + verify(mockOp, times(2)).insert(any(LogicalSwitch.class)); assertNotNull(insertOpCapture.getAllValues()); assertTrue(insertOpCapture.getAllValues().size() == 2); diff --git a/library/impl/src/main/java/org/opendaylight/ovsdb/lib/operations/DefaultOperations.java b/library/impl/src/main/java/org/opendaylight/ovsdb/lib/operations/DefaultOperations.java new file mode 100644 index 000000000..aeee02e07 --- /dev/null +++ b/library/impl/src/main/java/org/opendaylight/ovsdb/lib/operations/DefaultOperations.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2024 PANTHEON.tech, s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.ovsdb.lib.operations; + +import javax.inject.Inject; +import javax.inject.Singleton; +import org.opendaylight.ovsdb.lib.notation.Row; +import org.opendaylight.ovsdb.lib.schema.TableSchema; +import org.opendaylight.ovsdb.lib.schema.typed.TypedBaseTable; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; + +/** + * Default implementation of {@link Operations}. + */ +@Singleton +@Component +public final class DefaultOperations implements Operations { + @Inject + @Activate + public DefaultOperations() { + // Nothing else + } + + @Override + public > Insert insert(final TableSchema schema) { + return new Insert<>(schema); + } + + @Override + public > Insert insert(final TypedBaseTable typedTable) { + return new Insert<>(typedTable); + } + + @Override + public > Insert insert(final TableSchema schema, final Row row) { + return new Insert<>(schema, row); + } + + @Override + public > Update update(final TableSchema schema) { + return new Update<>(schema); + } + + @Override + public > Update update(final TypedBaseTable typedTable) { + return new Update<>(typedTable); + } + + @Override + public > Update update(final TableSchema schema, final Row row) { + return new Update<>(schema, row); + } + + @Override + public > Delete delete(final TableSchema schema) { + return new Delete<>(schema); + } + + @Override + public > Mutate mutate(final TableSchema schema) { + return new Mutate<>(schema); + } + + @Override + public > Mutate mutate(final TypedBaseTable typedTable) { + return new Mutate<>(typedTable.getSchema()); + } + + @Override + public Commit commit(final Boolean durable) { + return new Commit(durable); + } + + @Override + public Abort abort() { + return new Abort(); + } + + @Override + public > Select select(final TableSchema schema) { + return new Select<>(schema); + } + + @Override + public Comment comment(final String comment) { + return new Comment(comment); + } + + @Override + public Assert assertion(final String lock) { + return new Assert(lock); + } +} diff --git a/library/impl/src/main/java/org/opendaylight/ovsdb/lib/operations/Operations.java b/library/impl/src/main/java/org/opendaylight/ovsdb/lib/operations/Operations.java index 99056cb62..685db4c43 100644 --- a/library/impl/src/main/java/org/opendaylight/ovsdb/lib/operations/Operations.java +++ b/library/impl/src/main/java/org/opendaylight/ovsdb/lib/operations/Operations.java @@ -5,74 +5,42 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.ovsdb.lib.operations; import org.opendaylight.ovsdb.lib.notation.Row; import org.opendaylight.ovsdb.lib.schema.TableSchema; import org.opendaylight.ovsdb.lib.schema.typed.TypedBaseTable; -public class Operations { - @SuppressWarnings("checkstyle:ConstantName") - public static final Operations op = new Operations(); +public interface Operations { - public > Insert insert(TableSchema schema) { - return new Insert<>(schema); - } + > Insert insert(TableSchema schema); - public > Insert insert(TypedBaseTable typedTable) { - return new Insert<>(typedTable); - } + > Insert insert(TypedBaseTable typedTable); - public > Insert insert(TableSchema schema, Row row) { - return new Insert<>(schema, row); - } + > Insert insert(TableSchema schema, Row row); - public > Update update(TableSchema schema) { - return new Update<>(schema); - } + > Update update(TableSchema schema); - public > Update update(TypedBaseTable typedTable) { - return new Update<>(typedTable); - } + > Update update(TypedBaseTable typedTable); - public > Update update(TableSchema schema, Row row) { - return new Update<>(schema, row); - } + > Update update(TableSchema schema, Row row); - public > Delete delete(TableSchema schema) { - return new Delete<>(schema); - } + > Delete delete(TableSchema schema); - public > Mutate mutate(TableSchema schema) { - return new Mutate<>(schema); - } + > Mutate mutate(TableSchema schema); - public > Mutate mutate(TypedBaseTable typedTable) { - return new Mutate<>(typedTable.getSchema()); - } + > Mutate mutate(TypedBaseTable typedTable); - public Commit commit(Boolean durable) { - return new Commit(durable); - } + Commit commit(Boolean durable); - public Abort abort() { - return new Abort(); - } + Abort abort(); - public > Select select(TableSchema schema) { - return new Select<>(schema); - } + > Select select(TableSchema schema); - public Comment comment(String comment) { - return new Comment(comment); - } + Comment comment(String comment); /* - * Could not use Java keyword "assert" which clashes with the ovsdb json-rpc method. - * using assertion instead. + * Could not use Java keyword "assert" which clashes with the ovsdb json-rpc method. using assertion instead. */ - public Assert assertion(String lock) { - return new Assert(lock); - } + Assert assertion(String lock); } diff --git a/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/OvsdbClientTestIT.java b/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/OvsdbClientTestIT.java index c3627bdb7..ac84e4d89 100644 --- a/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/OvsdbClientTestIT.java +++ b/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/OvsdbClientTestIT.java @@ -13,7 +13,6 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Sets; diff --git a/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/OvsdbClientTestTypedIT.java b/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/OvsdbClientTestTypedIT.java index af1cdc01f..350443b9a 100644 --- a/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/OvsdbClientTestTypedIT.java +++ b/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/ovsdbclient/OvsdbClientTestTypedIT.java @@ -11,7 +11,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; import com.google.common.collect.ImmutableMap; import com.google.common.util.concurrent.ListenableFuture; diff --git a/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/schema/HardwareVTEPIT.java b/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/schema/HardwareVTEPIT.java index 8e96c2948..4c7f3fe2e 100644 --- a/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/schema/HardwareVTEPIT.java +++ b/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/schema/HardwareVTEPIT.java @@ -10,7 +10,6 @@ package org.opendaylight.ovsdb.integrationtest.schema; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assume.assumeTrue; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; import java.util.Collections; import java.util.List; diff --git a/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/schema/OpenVSwitchIT.java b/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/schema/OpenVSwitchIT.java index da1c237b8..5846073eb 100644 --- a/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/schema/OpenVSwitchIT.java +++ b/library/it/src/test/java/org/opendaylight/ovsdb/integrationtest/schema/OpenVSwitchIT.java @@ -15,7 +15,6 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeTrue; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; diff --git a/library/it/src/test/java/org/opendaylight/ovsdb/lib/it/LibraryIT.java b/library/it/src/test/java/org/opendaylight/ovsdb/lib/it/LibraryIT.java index 41022ff5b..8919c98e2 100644 --- a/library/it/src/test/java/org/opendaylight/ovsdb/lib/it/LibraryIT.java +++ b/library/it/src/test/java/org/opendaylight/ovsdb/lib/it/LibraryIT.java @@ -11,7 +11,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; import com.google.common.collect.ImmutableMap; import com.google.common.util.concurrent.ListenableFuture; diff --git a/library/it/src/test/java/org/opendaylight/ovsdb/lib/it/LibraryIntegrationTestBase.java b/library/it/src/test/java/org/opendaylight/ovsdb/lib/it/LibraryIntegrationTestBase.java index e72fee3da..99ee19662 100644 --- a/library/it/src/test/java/org/opendaylight/ovsdb/lib/it/LibraryIntegrationTestBase.java +++ b/library/it/src/test/java/org/opendaylight/ovsdb/lib/it/LibraryIntegrationTestBase.java @@ -41,7 +41,9 @@ import org.opendaylight.ovsdb.lib.message.TableUpdates; import org.opendaylight.ovsdb.lib.notation.Row; import org.opendaylight.ovsdb.lib.notation.UUID; import org.opendaylight.ovsdb.lib.notation.Version; +import org.opendaylight.ovsdb.lib.operations.DefaultOperations; import org.opendaylight.ovsdb.lib.operations.OperationResult; +import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.lib.operations.TransactionBuilder; import org.opendaylight.ovsdb.lib.schema.DatabaseSchema; import org.opendaylight.ovsdb.lib.schema.GenericTableSchema; @@ -72,6 +74,8 @@ public abstract class LibraryIntegrationTestBase extends AbstractMdsalTestBase { private static boolean monitorReady = false; public String schema; + protected final Operations op = new DefaultOperations(); + protected static Map> getTableCache() { return tableCache; } diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionInstance.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionInstance.java index b0c5e0dc2..9942f9905 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionInstance.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionInstance.java @@ -7,8 +7,6 @@ */ package org.opendaylight.ovsdb.southbound; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; - import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableSet; import com.google.common.util.concurrent.ListenableFuture; @@ -41,6 +39,7 @@ import org.opendaylight.ovsdb.lib.notation.UUID; import org.opendaylight.ovsdb.lib.operations.Mutate; import org.opendaylight.ovsdb.lib.operations.Operation; import org.opendaylight.ovsdb.lib.operations.OperationResult; +import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.lib.operations.TransactionBuilder; import org.opendaylight.ovsdb.lib.schema.DatabaseSchema; import org.opendaylight.ovsdb.lib.schema.GenericTableSchema; @@ -83,6 +82,7 @@ public class OvsdbConnectionInstance { private final OvsdbClient client; private ConnectionInfo connectionInfo; + private final Operations ops; private final TransactionInvoker txInvoker; private Map transactInvokers = null; private MonitorCallBack callback = null; @@ -94,12 +94,12 @@ public class OvsdbConnectionInstance { private final Map> ports = new ConcurrentHashMap<>(); private final Map> portInterfaces = new ConcurrentHashMap<>(); - OvsdbConnectionInstance(final ConnectionInfo key, final OvsdbClient client, final TransactionInvoker txInvoker, - final InstanceIdentifier iid) { - connectionInfo = key; + OvsdbConnectionInstance(final ConnectionInfo connectionInfo, final OvsdbClient client, final Operations ops, + final TransactionInvoker txInvoker, final InstanceIdentifier iid) { + this.connectionInfo = connectionInfo; this.client = client; + this.ops = ops; this.txInvoker = txInvoker; - // this.key = key; instanceIdentifier = iid; } @@ -166,7 +166,7 @@ public class OvsdbConnectionInstance { public void registerCallbacks(final InstanceIdentifierCodec instanceIdentifierCodec) { if (callback == null) { if (initialCreateData != null) { - this.updateConnectionAttributes(instanceIdentifierCodec); + updateConnectionAttributes(instanceIdentifierCodec); } try { @@ -246,7 +246,7 @@ public class OvsdbConnectionInstance { ovs.setExternalIds( YangUtils.convertYangKeyValueListToMap(externalIds, OpenvswitchExternalIds::requireExternalIdKey, OpenvswitchExternalIds::requireExternalIdValue)); - Mutate mutate = op.mutate(ovs) + Mutate mutate = ops.mutate(ovs) .addMutation(ovs.getExternalIdsColumn().getSchema(), Mutator.INSERT, ovs.getExternalIdsColumn().getData()); transaction.add(mutate); @@ -256,7 +256,7 @@ public class OvsdbConnectionInstance { if (otherConfigs != null) { ovs.setOtherConfig(YangUtils.convertYangKeyValueListToMap(otherConfigs, OpenvswitchOtherConfigs::requireOtherConfigKey, OpenvswitchOtherConfigs::requireOtherConfigValue)); - transaction.add(op.mutate(ovs).addMutation(ovs.getOtherConfigColumn().getSchema(), + transaction.add(ops.mutate(ovs).addMutation(ovs.getOtherConfigColumn().getSchema(), Mutator.INSERT, ovs.getOtherConfigColumn().getData())); } @@ -264,12 +264,12 @@ public class OvsdbConnectionInstance { } } - private static void stampInstanceIdentifier(final TransactionBuilder transaction,final InstanceIdentifier iid, + private void stampInstanceIdentifier(final TransactionBuilder transaction,final InstanceIdentifier iid, final InstanceIdentifierCodec instanceIdentifierCodec) { OpenVSwitch ovs = transaction.getTypedRowWrapper(OpenVSwitch.class); ovs.setExternalIds(Collections.emptyMap()); - TransactUtils.stampInstanceIdentifier(transaction, iid, ovs.getSchema(), ovs.getExternalIdsColumn().getSchema(), - instanceIdentifierCodec); + TransactUtils.stampInstanceIdentifier(ops, transaction, iid, ovs.getSchema(), + ovs.getExternalIdsColumn().getSchema(), instanceIdentifierCodec); } private static void invoke(final TransactionBuilder txBuilder) { @@ -428,4 +428,7 @@ public class OvsdbConnectionInstance { return client; } + public Operations ops() { + return ops; + } } diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionManager.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionManager.java index 7cbd5b2e7..a85d63ff3 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionManager.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionManager.java @@ -8,7 +8,6 @@ package org.opendaylight.ovsdb.southbound; import static java.util.Objects.requireNonNull; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; import com.google.common.annotations.VisibleForTesting; import com.google.common.util.concurrent.FluentFuture; @@ -41,6 +40,7 @@ import org.opendaylight.ovsdb.lib.OvsdbConnection; import org.opendaylight.ovsdb.lib.OvsdbConnectionListener; import org.opendaylight.ovsdb.lib.operations.Operation; import org.opendaylight.ovsdb.lib.operations.OperationResult; +import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.lib.operations.Select; import org.opendaylight.ovsdb.lib.schema.GenericTableSchema; import org.opendaylight.ovsdb.lib.schema.typed.TypedDatabaseSchema; @@ -76,6 +76,7 @@ public class OvsdbConnectionManager implements OvsdbConnectionListener, AutoClos new ConcurrentHashMap<>(); private final ConcurrentMap entityConnectionMap = new ConcurrentHashMap<>(); private final DataBroker db; + private final Operations ops; private final TransactionInvoker txInvoker; private final EntityOwnershipService entityOwnershipService; private final OvsdbDeviceEntityOwnershipListener ovsdbDeviceEntityOwnershipListener; @@ -83,13 +84,14 @@ public class OvsdbConnectionManager implements OvsdbConnectionListener, AutoClos private final ReconciliationManager reconciliationManager; private final InstanceIdentifierCodec instanceIdentifierCodec; - public OvsdbConnectionManager(final DataBroker db,final TransactionInvoker txInvoker, + public OvsdbConnectionManager(final DataBroker db, final Operations ops, final TransactionInvoker txInvoker, final EntityOwnershipService entityOwnershipService, final OvsdbConnection ovsdbConnection, final InstanceIdentifierCodec instanceIdentifierCodec, final List reconcileBridgeInclusionList, final List reconcileBridgeExclusionList) { this.db = db; + this.ops = ops; this.txInvoker = txInvoker; this.entityOwnershipService = entityOwnershipService; ovsdbDeviceEntityOwnershipListener = new OvsdbDeviceEntityOwnershipListener(this, entityOwnershipService); @@ -164,7 +166,7 @@ public class OvsdbConnectionManager implements OvsdbConnectionListener, AutoClos stopBridgeConfigReconciliationIfActive(ovsdbConnectionInstance.getInstanceIdentifier()); } - ovsdbConnectionInstance = new OvsdbConnectionInstance(key, externalClient, txInvoker, + ovsdbConnectionInstance = new OvsdbConnectionInstance(key, externalClient, ops, txInvoker, getInstanceIdentifier(key)); ovsdbConnectionInstance.createTransactInvokers(); return ovsdbConnectionInstance; @@ -520,7 +522,7 @@ public class OvsdbConnectionManager implements OvsdbConnectionListener, AutoClos } - private static OpenVSwitch getOpenVswitchTableEntry(final OvsdbConnectionInstance connectionInstance) { + private OpenVSwitch getOpenVswitchTableEntry(final OvsdbConnectionInstance connectionInstance) { final TypedDatabaseSchema dbSchema; try { dbSchema = connectionInstance.getSchema(OvsdbSchemaContants.DATABASE_NAME).get(); @@ -531,12 +533,12 @@ public class OvsdbConnectionManager implements OvsdbConnectionListener, AutoClos } final GenericTableSchema openVSwitchSchema = dbSchema.getTableSchema(OpenVSwitch.class); - final Select selectOperation = op.select(openVSwitchSchema); + final Select selectOperation = ops.select(openVSwitchSchema); selectOperation.setColumns(openVSwitchSchema.getColumnList()); List operations = new ArrayList<>(); operations.add(selectOperation); - operations.add(op.comment("Fetching Open_VSwitch table rows")); + operations.add(ops.comment("Fetching Open_VSwitch table rows")); final List results; try { results = connectionInstance.transact(dbSchema, operations).get(); diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbDataTreeChangeListener.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbDataTreeChangeListener.java index d25e27e9f..b93fde241 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbDataTreeChangeListener.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbDataTreeChangeListener.java @@ -227,7 +227,7 @@ public final class OvsdbDataTreeChangeListener implements DataTreeChangeListener changesPerConnectionInstance(changes).entrySet()) { OvsdbConnectionInstance connectionInstance = connectionInstanceEntry.getKey(); Collection> clientChanges = connectionInstanceEntry.getValue(); - connectionInstance.transact(new TransactCommandAggregator(), + connectionInstance.transact(new TransactCommandAggregator(connectionInstance.ops()), new BridgeOperationalState(db, clientChanges), clientChanges, instanceIdentifierCodec); } } diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/SouthboundProvider.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/SouthboundProvider.java index d62cde5dc..f0cb1a006 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/SouthboundProvider.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/SouthboundProvider.java @@ -38,6 +38,7 @@ import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService; import org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException; import org.opendaylight.mdsal.eos.common.api.EntityOwnershipStateChange; import org.opendaylight.ovsdb.lib.OvsdbConnection; +import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.southbound.transactions.md.TransactionInvoker; import org.opendaylight.ovsdb.southbound.transactions.md.TransactionInvokerImpl; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology; @@ -97,9 +98,10 @@ public class SouthboundProvider implements DataTreeChangeListener, Aut final DOMSchemaService schemaService, final BindingNormalizedNodeSerializer bindingNormalizedNodeSerializer, final SystemReadyMonitor systemReadyMonitor, - final DiagStatusService diagStatusService) { + final DiagStatusService diagStatusService, + final Operations ops) { this(dataBroker, entityOwnershipServiceDependency, ovsdbConnection, schemaService, - bindingNormalizedNodeSerializer, systemReadyMonitor, diagStatusService, false, List.of(), List.of()); + bindingNormalizedNodeSerializer, systemReadyMonitor, diagStatusService, ops, false, List.of(), List.of()); } @Activate @@ -110,9 +112,10 @@ public class SouthboundProvider implements DataTreeChangeListener, Aut @Reference final BindingNormalizedNodeSerializer bindingNormalizedNodeSerializer, @Reference final SystemReadyMonitor systemReadyMonitor, @Reference final DiagStatusService diagStatusService, + @Reference final Operations ops, final Configuration configuration) { this(dataBroker, entityOwnershipServiceDependency, ovsdbConnection, schemaService, - bindingNormalizedNodeSerializer, systemReadyMonitor, diagStatusService, + bindingNormalizedNodeSerializer, systemReadyMonitor, diagStatusService, ops, configuration.skip$_$monitoring$_$manager$_$status(), getBridgesList(configuration.bridge$_$reconciliation$_$inclusion$_$list()), getBridgesList(configuration.bridge$_$reconciliation$_$exclusion$_$list())); @@ -127,6 +130,7 @@ public class SouthboundProvider implements DataTreeChangeListener, Aut final BindingNormalizedNodeSerializer bindingNormalizedNodeSerializer, final SystemReadyMonitor systemReadyMonitor, final DiagStatusService diagStatusService, + final Operations ops, final boolean skipMonitoringManagerStatus, final List bridgeReconciliationInclusionList, final List bridgeReconciliationExclusionList) { @@ -148,7 +152,7 @@ public class SouthboundProvider implements DataTreeChangeListener, Aut ovsdbStatusProvider.reportStatus(ServiceState.STARTING, "OVSDB initialization in progress"); txInvoker = new TransactionInvokerImpl(dataBroker); - cm = new OvsdbConnectionManager(dataBroker, txInvoker, entityOwnershipService, ovsdbConnection, + cm = new OvsdbConnectionManager(dataBroker, ops, txInvoker, entityOwnershipService, ovsdbConnection, instanceIdentifierCodec, bridgeReconciliationInclusionList, bridgeReconciliationExclusionList); ovsdbDataTreeChangeListener = new OvsdbDataTreeChangeListener(dataBroker, cm, instanceIdentifierCodec); ovsdbOperGlobalListener = new OvsdbOperGlobalListener(dataBroker, cm, txInvoker); diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/AbstractTransactCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/AbstractTransactCommand.java new file mode 100644 index 000000000..fcabaec11 --- /dev/null +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/AbstractTransactCommand.java @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2024 PANTHEON.tech, s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.ovsdb.southbound.ovsdb.transact; + +import static java.util.Objects.requireNonNull; + +import org.opendaylight.ovsdb.lib.operations.Operations; + +abstract class AbstractTransactCommand implements TransactCommand { + final Operations op; + + AbstractTransactCommand(final Operations op) { + this.op = requireNonNull(op); + } +} diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/AutoAttachRemovedCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/AutoAttachRemovedCommand.java index 8037fa63d..8c92101a5 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/AutoAttachRemovedCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/AutoAttachRemovedCommand.java @@ -7,8 +7,6 @@ */ package org.opendaylight.ovsdb.southbound.ovsdb.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; - import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.Collection; import java.util.Collections; @@ -20,6 +18,7 @@ import org.opendaylight.mdsal.binding.api.ReadTransaction; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.ovsdb.lib.notation.Mutator; import org.opendaylight.ovsdb.lib.notation.UUID; +import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.lib.operations.TransactionBuilder; import org.opendaylight.ovsdb.schema.openvswitch.AutoAttach; import org.opendaylight.ovsdb.schema.openvswitch.Bridge; @@ -38,9 +37,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; @SuppressFBWarnings("UPM_UNCALLED_PRIVATE_METHOD") -public class AutoAttachRemovedCommand implements TransactCommand { +public class AutoAttachRemovedCommand extends AbstractTransactCommand { private static final Logger LOG = LoggerFactory.getLogger(AutoAttachRemovedCommand.class); + public AutoAttachRemovedCommand(final Operations op) { + super(op); + } + @Override public void execute(final TransactionBuilder transaction, final BridgeOperationalState state, final Collection> modifications, @@ -56,9 +59,9 @@ public class AutoAttachRemovedCommand implements TransactCommand { TransactUtils.extractUpdated(events, OvsdbNodeAugmentation.class)); } - private static void execute(final TransactionBuilder transaction, final BridgeOperationalState state, - final Map, OvsdbNodeAugmentation> original, - final Map, OvsdbNodeAugmentation> updated) { + private void execute(final TransactionBuilder transaction, final BridgeOperationalState state, + final Map, OvsdbNodeAugmentation> original, + final Map, OvsdbNodeAugmentation> updated) { for (var originalEntry : original.entrySet()) { final InstanceIdentifier ovsdbNodeIid = originalEntry.getKey(); final OvsdbNodeAugmentation ovsdbNodeAugmentation = originalEntry.getValue(); @@ -89,9 +92,8 @@ public class AutoAttachRemovedCommand implements TransactCommand { } } - private static void deleteAutoAttach(final BridgeOperationalState state, final TransactionBuilder transaction, - final InstanceIdentifier ovsdbNodeIid, - final Uuid autoattachUuid) { + private void deleteAutoAttach(final BridgeOperationalState state, final TransactionBuilder transaction, + final InstanceIdentifier ovsdbNodeIid, final Uuid autoattachUuid) { LOG.debug("Received request to delete Autoattach entry {}", autoattachUuid); final OvsdbBridgeAugmentation bridgeAugmentation = getBridge(state, ovsdbNodeIid, autoattachUuid); diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/AutoAttachUpdateCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/AutoAttachUpdateCommand.java index 8c6833a87..cd57ae568 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/AutoAttachUpdateCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/AutoAttachUpdateCommand.java @@ -7,8 +7,6 @@ */ package org.opendaylight.ovsdb.southbound.ovsdb.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; - import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.Collection; import java.util.HashMap; @@ -20,6 +18,7 @@ import org.opendaylight.mdsal.binding.api.ReadTransaction; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.ovsdb.lib.notation.Mutator; import org.opendaylight.ovsdb.lib.notation.UUID; +import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.lib.operations.TransactionBuilder; import org.opendaylight.ovsdb.schema.openvswitch.AutoAttach; import org.opendaylight.ovsdb.schema.openvswitch.Bridge; @@ -47,9 +46,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; @SuppressFBWarnings("UPM_UNCALLED_PRIVATE_METHOD") -public class AutoAttachUpdateCommand implements TransactCommand { +public class AutoAttachUpdateCommand extends AbstractTransactCommand { private static final Logger LOG = LoggerFactory.getLogger(AutoAttachUpdateCommand.class); + public AutoAttachUpdateCommand(final Operations op) { + super(op); + } + @Override public void execute(final TransactionBuilder transaction, final BridgeOperationalState state, final DataChangeEvent events, final InstanceIdentifierCodec instanceIdentifierCodec) { @@ -60,19 +63,20 @@ public class AutoAttachUpdateCommand implements TransactCommand { public void execute(final TransactionBuilder transaction, final BridgeOperationalState state, final Collection> modifications, final InstanceIdentifierCodec instanceIdentifierCodec) { - execute(transaction, state, TransactUtils.extractCreatedOrUpdated(modifications, OvsdbNodeAugmentation.class)); + execute(transaction, state, + TransactUtils.extractCreatedOrUpdated(modifications, OvsdbNodeAugmentation.class)); } - private static void execute(final TransactionBuilder transaction, final BridgeOperationalState state, + private void execute(final TransactionBuilder transaction, + final BridgeOperationalState state, final Map, OvsdbNodeAugmentation> createdOrUpdated) { for (var ovsdbNodeEntry : createdOrUpdated.entrySet()) { updateAutoAttach(transaction, state, ovsdbNodeEntry.getKey(), ovsdbNodeEntry.getValue()); } } - private static void updateAutoAttach(final TransactionBuilder transaction, final BridgeOperationalState state, - final InstanceIdentifier iid, - final OvsdbNodeAugmentation ovsdbNode) { + private void updateAutoAttach(final TransactionBuilder transaction, final BridgeOperationalState state, + final InstanceIdentifier iid, final OvsdbNodeAugmentation ovsdbNode) { if (!state.getBridgeNode(iid).isPresent()) { return; diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/BridgeRemovedCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/BridgeRemovedCommand.java index 77c215e61..415d94f82 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/BridgeRemovedCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/BridgeRemovedCommand.java @@ -7,8 +7,6 @@ */ package org.opendaylight.ovsdb.southbound.ovsdb.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; - import java.util.Collection; import java.util.Collections; import java.util.Map; @@ -17,6 +15,7 @@ import java.util.Set; import org.opendaylight.mdsal.binding.api.DataTreeModification; import org.opendaylight.ovsdb.lib.notation.Mutator; import org.opendaylight.ovsdb.lib.notation.UUID; +import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.lib.operations.TransactionBuilder; import org.opendaylight.ovsdb.schema.openvswitch.Bridge; import org.opendaylight.ovsdb.schema.openvswitch.OpenVSwitch; @@ -27,9 +26,13 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class BridgeRemovedCommand implements TransactCommand { +public class BridgeRemovedCommand extends AbstractTransactCommand { private static final Logger LOG = LoggerFactory.getLogger(BridgeRemovedCommand.class); + public BridgeRemovedCommand(final Operations op) { + super(op); + } + @Override public void execute(final TransactionBuilder transaction, final BridgeOperationalState state, final DataChangeEvent events, final InstanceIdentifierCodec instanceIdentifierCodec) { @@ -45,7 +48,7 @@ public class BridgeRemovedCommand implements TransactCommand { TransactUtils.extractOriginal(modifications, OvsdbBridgeAugmentation.class)); } - private static void execute(final TransactionBuilder transaction, final BridgeOperationalState state, + private void execute(final TransactionBuilder transaction, final BridgeOperationalState state, final Set> removed, final Map, OvsdbBridgeAugmentation> originals) { for (InstanceIdentifier ovsdbManagedNodeIid: removed) { @@ -71,7 +74,6 @@ public class BridgeRemovedCommand implements TransactCommand { LOG.warn("Unable to delete bridge {} because it was not found in the operational store, " + "and thus we cannot retrieve its UUID", ovsdbManagedNodeIid); } - } } } diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/BridgeUpdateCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/BridgeUpdateCommand.java index 478c0e15b..4de708787 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/BridgeUpdateCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/BridgeUpdateCommand.java @@ -7,8 +7,6 @@ */ package org.opendaylight.ovsdb.southbound.ovsdb.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; - import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.Collection; import java.util.Collections; @@ -22,6 +20,7 @@ import org.opendaylight.mdsal.binding.api.DataTreeModification; import org.opendaylight.ovsdb.lib.notation.UUID; import org.opendaylight.ovsdb.lib.operations.Insert; import org.opendaylight.ovsdb.lib.operations.Mutate; +import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.lib.operations.TransactionBuilder; import org.opendaylight.ovsdb.lib.schema.GenericTableSchema; import org.opendaylight.ovsdb.schema.openvswitch.Bridge; @@ -40,9 +39,13 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class BridgeUpdateCommand implements TransactCommand { +public class BridgeUpdateCommand extends AbstractTransactCommand { private static final Logger LOG = LoggerFactory.getLogger(BridgeUpdateCommand.class); + public BridgeUpdateCommand(final Operations op) { + super(op); + } + @Override public void execute(final TransactionBuilder transaction, final BridgeOperationalState state, final DataChangeEvent events, final InstanceIdentifierCodec instanceIdentifierCodec) { @@ -54,12 +57,11 @@ public class BridgeUpdateCommand implements TransactCommand { public void execute(final TransactionBuilder transaction, final BridgeOperationalState state, final Collection> modifications, final InstanceIdentifierCodec instanceIdentifierCodec) { - execute(transaction, state, - TransactUtils.extractCreatedOrUpdated(modifications, OvsdbBridgeAugmentation.class), + execute(transaction, state, TransactUtils.extractCreatedOrUpdated(modifications, OvsdbBridgeAugmentation.class), instanceIdentifierCodec); } - private static void execute(final TransactionBuilder transaction, final BridgeOperationalState state, + private void execute(final TransactionBuilder transaction, final BridgeOperationalState state, final Map, OvsdbBridgeAugmentation> createdOrUpdated, final InstanceIdentifierCodec instanceIdentifierCodec) { for (Entry, OvsdbBridgeAugmentation> ovsdbManagedNodeEntry : @@ -69,7 +71,7 @@ public class BridgeUpdateCommand implements TransactCommand { } } - private static void updateBridge(final TransactionBuilder transaction, final BridgeOperationalState state, + private void updateBridge(final TransactionBuilder transaction, final BridgeOperationalState state, final InstanceIdentifier iid, final OvsdbBridgeAugmentation ovsdbManagedNode, final InstanceIdentifierCodec instanceIdentifierCodec) { LOG.debug("Received request to create ovsdb bridge name: {} uuid: {}", @@ -154,10 +156,10 @@ public class BridgeUpdateCommand implements TransactCommand { } } - private static void setPort(final TransactionBuilder transaction, final Bridge bridge, + private void setPort(final TransactionBuilder transaction, final Bridge bridge, final OvsdbBridgeAugmentation ovsdbManagedNode) { - Insert interfaceInsert = setInterface(transaction,ovsdbManagedNode); + Insert interfaceInsert = setInterface(transaction, ovsdbManagedNode); // Port part String portNamedUuid = "Port_" + SouthboundMapper.getRandomUuid(); Port port = transaction.getTypedRowWrapper(Port.class); @@ -167,7 +169,7 @@ public class BridgeUpdateCommand implements TransactCommand { bridge.setPorts(Set.of(new UUID(portNamedUuid))); } - private static Insert setInterface(final TransactionBuilder transaction, + private Insert setInterface(final TransactionBuilder transaction, final OvsdbBridgeAugmentation ovsdbManagedNode) { // Interface part String interfaceNamedUuid = "Interface_" + SouthboundMapper.getRandomUuid(); @@ -179,8 +181,7 @@ public class BridgeUpdateCommand implements TransactCommand { return result; } - private static void setFailMode(final Bridge bridge, - final OvsdbBridgeAugmentation ovsdbManagedNode) { + private static void setFailMode(final Bridge bridge, final OvsdbBridgeAugmentation ovsdbManagedNode) { if (ovsdbManagedNode.getFailMode() != null && SouthboundConstants.OVSDB_FAIL_MODE_MAP.get(ovsdbManagedNode.getFailMode()) != null) { bridge.setFailMode(Set.of( @@ -188,13 +189,13 @@ public class BridgeUpdateCommand implements TransactCommand { } } - private static void stampInstanceIdentifier(final TransactionBuilder transaction, + private void stampInstanceIdentifier(final TransactionBuilder transaction, final InstanceIdentifier iid, final String bridgeName, final InstanceIdentifierCodec instanceIdentifierCodec) { Bridge bridge = transaction.getTypedRowWrapper(Bridge.class); bridge.setName(bridgeName); bridge.setExternalIds(Collections.emptyMap()); - Mutate mutate = TransactUtils.stampInstanceIdentifierMutation(transaction, iid, bridge.getSchema(), + Mutate mutate = TransactUtils.stampInstanceIdentifierMutation(op, transaction, iid, bridge.getSchema(), bridge.getExternalIdsColumn().getSchema(), instanceIdentifierCodec); transaction.add(mutate .where(bridge.getNameColumn().getSchema().opEqual(bridgeName)) diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/ControllerRemovedCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/ControllerRemovedCommand.java index 8347f91c7..d01987435 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/ControllerRemovedCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/ControllerRemovedCommand.java @@ -7,8 +7,6 @@ */ package org.opendaylight.ovsdb.southbound.ovsdb.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; - import java.util.Collection; import java.util.Collections; import java.util.Map; @@ -17,6 +15,7 @@ import java.util.Set; import org.opendaylight.mdsal.binding.api.DataTreeModification; import org.opendaylight.ovsdb.lib.notation.Mutator; import org.opendaylight.ovsdb.lib.notation.UUID; +import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.lib.operations.TransactionBuilder; import org.opendaylight.ovsdb.schema.openvswitch.Bridge; import org.opendaylight.ovsdb.southbound.InstanceIdentifierCodec; @@ -27,9 +26,13 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ControllerRemovedCommand implements TransactCommand { +public class ControllerRemovedCommand extends AbstractTransactCommand { private static final Logger LOG = LoggerFactory.getLogger(ControllerRemovedCommand.class); + public ControllerRemovedCommand(final Operations op) { + super(op); + } + @Override public void execute(final TransactionBuilder transaction, final BridgeOperationalState state, final DataChangeEvent events, final InstanceIdentifierCodec instanceIdentifierCodec) { @@ -45,10 +48,9 @@ public class ControllerRemovedCommand implements TransactCommand { TransactUtils.extractCreatedOrUpdatedOrRemoved(modifications, OvsdbBridgeAugmentation.class)); } - private static void execute(final TransactionBuilder transaction, final BridgeOperationalState state, - final Set> removedControllers, - final Map, OvsdbBridgeAugmentation> - modifiedBridges) { + private void execute(final TransactionBuilder transaction, final BridgeOperationalState state, + final Set> removedControllers, + final Map, OvsdbBridgeAugmentation> modifiedBridges) { for (InstanceIdentifier controllerIid : removedControllers) { LOG.debug("Removing Registered...ODL controller : {} ", controllerIid); InstanceIdentifier bridgeIid = diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/ControllerUpdateCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/ControllerUpdateCommand.java index 98e62de3c..17bff0ccd 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/ControllerUpdateCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/ControllerUpdateCommand.java @@ -7,8 +7,6 @@ */ package org.opendaylight.ovsdb.southbound.ovsdb.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; - import java.util.Collection; import java.util.Collections; import java.util.Map; @@ -17,6 +15,7 @@ import java.util.Optional; import org.opendaylight.mdsal.binding.api.DataTreeModification; import org.opendaylight.ovsdb.lib.notation.Mutator; import org.opendaylight.ovsdb.lib.notation.UUID; +import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.lib.operations.TransactionBuilder; import org.opendaylight.ovsdb.schema.openvswitch.Bridge; import org.opendaylight.ovsdb.schema.openvswitch.Controller; @@ -29,9 +28,13 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ControllerUpdateCommand implements TransactCommand { +public class ControllerUpdateCommand extends AbstractTransactCommand { private static final Logger LOG = LoggerFactory.getLogger(ControllerUpdateCommand.class); + public ControllerUpdateCommand(final Operations op) { + super(op); + } + @Override public void execute(final TransactionBuilder transaction, final BridgeOperationalState state, final DataChangeEvent events, final InstanceIdentifierCodec instanceIdentifierCodec) { @@ -47,7 +50,7 @@ public class ControllerUpdateCommand implements TransactCommand { TransactUtils.extractCreatedOrUpdated(modifications, OvsdbBridgeAugmentation.class)); } - private static void execute(final TransactionBuilder transaction, final BridgeOperationalState state, + private void execute(final TransactionBuilder transaction, final BridgeOperationalState state, final Map, ControllerEntry> controllers, final Map, OvsdbBridgeAugmentation> bridges) { LOG.info("Register ODL controllers : {} bridges detail : {}", @@ -94,6 +97,5 @@ public class ControllerUpdateCommand implements TransactCommand { } } LOG.trace("Executed transaction: {}", transaction.build()); - } } diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/OpenVSwitchBridgeAddCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/OpenVSwitchBridgeAddCommand.java index 1c22c33d6..996b936d2 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/OpenVSwitchBridgeAddCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/OpenVSwitchBridgeAddCommand.java @@ -7,21 +7,23 @@ */ package org.opendaylight.ovsdb.southbound.ovsdb.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; - import java.util.Collection; import java.util.Collections; import java.util.List; import org.opendaylight.mdsal.binding.api.DataTreeModification; import org.opendaylight.ovsdb.lib.notation.Mutator; import org.opendaylight.ovsdb.lib.operations.Insert; +import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.lib.operations.TransactionBuilder; import org.opendaylight.ovsdb.schema.openvswitch.Bridge; import org.opendaylight.ovsdb.schema.openvswitch.OpenVSwitch; import org.opendaylight.ovsdb.southbound.InstanceIdentifierCodec; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node; -public class OpenVSwitchBridgeAddCommand implements TransactCommand { +public class OpenVSwitchBridgeAddCommand extends AbstractTransactCommand { + public OpenVSwitchBridgeAddCommand(final Operations op) { + super(op); + } @Override public void execute(final TransactionBuilder transaction, final BridgeOperationalState state, @@ -36,7 +38,7 @@ public class OpenVSwitchBridgeAddCommand implements TransactCommand { execute(transaction); } - private static void execute(final TransactionBuilder transaction) { + private void execute(final TransactionBuilder transaction) { Bridge bridge = transaction.getTypedRowWrapper(Bridge.class); List inserts = TransactUtils.extractInsert(transaction, bridge.getSchema()); for (Insert insert : inserts) { diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/OvsdbNodeUpdateCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/OvsdbNodeUpdateCommand.java index e47c3e715..10985ce5a 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/OvsdbNodeUpdateCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/OvsdbNodeUpdateCommand.java @@ -7,8 +7,6 @@ */ package org.opendaylight.ovsdb.southbound.ovsdb.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; - import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.Collection; import java.util.Collections; @@ -17,6 +15,7 @@ import java.util.Map.Entry; import org.opendaylight.mdsal.binding.api.DataTreeModification; import org.opendaylight.ovsdb.lib.notation.Mutator; import org.opendaylight.ovsdb.lib.operations.Mutate; +import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.lib.operations.TransactionBuilder; import org.opendaylight.ovsdb.lib.schema.GenericTableSchema; import org.opendaylight.ovsdb.schema.openvswitch.OpenVSwitch; @@ -31,9 +30,13 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class OvsdbNodeUpdateCommand implements TransactCommand { +public class OvsdbNodeUpdateCommand extends AbstractTransactCommand { private static final Logger LOG = LoggerFactory.getLogger(OvsdbNodeUpdateCommand.class); + public OvsdbNodeUpdateCommand(final Operations op) { + super(op); + } + @Override public void execute(final TransactionBuilder transaction, final BridgeOperationalState state, final DataChangeEvent events, final InstanceIdentifierCodec instanceIdentifierCodec) { @@ -50,7 +53,7 @@ public class OvsdbNodeUpdateCommand implements TransactCommand { } @SuppressFBWarnings("DCN_NULLPOINTER_EXCEPTION") - private static void execute(final TransactionBuilder transaction, + private void execute(final TransactionBuilder transaction, final Map, OvsdbNodeAugmentation> updated, final InstanceIdentifierCodec instanceIdentifierCodec) { for (Entry, OvsdbNodeAugmentation> ovsdbNodeEntry: @@ -82,8 +85,6 @@ public class OvsdbNodeUpdateCommand implements TransactCommand { LOG.warn("Incomplete OVSDB Node external IDs", e); } - - Map otherConfigs = ovsdbNode.getOpenvswitchOtherConfigs(); if (otherConfigs != null) { @@ -100,11 +101,11 @@ public class OvsdbNodeUpdateCommand implements TransactCommand { } } - private static void stampInstanceIdentifier(final TransactionBuilder transaction, - final InstanceIdentifier iid, final InstanceIdentifierCodec instanceIdentifierCodec) { + private void stampInstanceIdentifier(final TransactionBuilder transaction, final InstanceIdentifier iid, + final InstanceIdentifierCodec instanceIdentifierCodec) { OpenVSwitch ovs = transaction.getTypedRowWrapper(OpenVSwitch.class); ovs.setExternalIds(Collections.emptyMap()); - TransactUtils.stampInstanceIdentifier(transaction, iid, ovs.getSchema(), + TransactUtils.stampInstanceIdentifier(op, transaction, iid, ovs.getSchema(), ovs.getExternalIdsColumn().getSchema(), instanceIdentifierCodec); } } diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/ProtocolRemovedCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/ProtocolRemovedCommand.java index 946af1b45..90c6c56d0 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/ProtocolRemovedCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/ProtocolRemovedCommand.java @@ -7,7 +7,6 @@ */ package org.opendaylight.ovsdb.southbound.ovsdb.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; import static org.opendaylight.ovsdb.southbound.SouthboundUtil.schemaMismatchLog; import java.util.Collection; @@ -18,6 +17,7 @@ import java.util.Set; import org.opendaylight.mdsal.binding.api.DataTreeModification; import org.opendaylight.ovsdb.lib.error.SchemaVersionMismatchException; import org.opendaylight.ovsdb.lib.notation.Mutator; +import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.lib.operations.TransactionBuilder; import org.opendaylight.ovsdb.schema.openvswitch.Bridge; import org.opendaylight.ovsdb.southbound.InstanceIdentifierCodec; @@ -29,10 +29,13 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ProtocolRemovedCommand implements TransactCommand { - +public class ProtocolRemovedCommand extends AbstractTransactCommand { private static final Logger LOG = LoggerFactory.getLogger(ProtocolRemovedCommand.class); + public ProtocolRemovedCommand(final Operations op) { + super(op); + } + @Override public void execute(final TransactionBuilder transaction, final BridgeOperationalState state, final DataChangeEvent events, final InstanceIdentifierCodec instanceIdentifierCodec) { @@ -48,8 +51,8 @@ public class ProtocolRemovedCommand implements TransactCommand { TransactUtils.extractCreatedOrUpdatedOrRemoved(modifications, OvsdbBridgeAugmentation.class)); } - private static void execute(final TransactionBuilder transaction, final BridgeOperationalState state, - final Set> removed, + private void execute(final TransactionBuilder transaction, + final BridgeOperationalState state, final Set> removed, final Map, OvsdbBridgeAugmentation> updatedBridges) { for (InstanceIdentifier protocolIid : removed) { InstanceIdentifier bridgeIid = @@ -76,7 +79,5 @@ public class ProtocolRemovedCommand implements TransactCommand { } } } - } - } diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/ProtocolUpdateCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/ProtocolUpdateCommand.java index 16451e954..b0bf511d7 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/ProtocolUpdateCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/ProtocolUpdateCommand.java @@ -5,10 +5,8 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.ovsdb.southbound.ovsdb.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; import static org.opendaylight.ovsdb.southbound.SouthboundUtil.schemaMismatchLog; import java.util.Collection; @@ -19,6 +17,7 @@ import java.util.Optional; import org.opendaylight.mdsal.binding.api.DataTreeModification; import org.opendaylight.ovsdb.lib.error.SchemaVersionMismatchException; import org.opendaylight.ovsdb.lib.notation.Mutator; +import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.lib.operations.TransactionBuilder; import org.opendaylight.ovsdb.schema.openvswitch.Bridge; import org.opendaylight.ovsdb.southbound.InstanceIdentifierCodec; @@ -30,10 +29,13 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ProtocolUpdateCommand implements TransactCommand { - +public class ProtocolUpdateCommand extends AbstractTransactCommand { private static final Logger LOG = LoggerFactory.getLogger(ProtocolUpdateCommand.class); + public ProtocolUpdateCommand(final Operations op) { + super(op); + } + @Override public void execute(final TransactionBuilder transaction, final BridgeOperationalState state, final DataChangeEvent events, final InstanceIdentifierCodec instanceIdentifierCodec) { @@ -49,7 +51,7 @@ public class ProtocolUpdateCommand implements TransactCommand { TransactUtils.extractCreatedOrUpdated(modifications, OvsdbBridgeAugmentation.class)); } - private static void execute(final TransactionBuilder transaction, final BridgeOperationalState state, + private void execute(final TransactionBuilder transaction, final BridgeOperationalState state, final Map, ProtocolEntry> protocols, final Map, OvsdbBridgeAugmentation> bridges) { for (Entry, ProtocolEntry> entry: protocols.entrySet()) { diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/QosRemovedCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/QosRemovedCommand.java index 1191ee90b..3c9c02d3a 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/QosRemovedCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/QosRemovedCommand.java @@ -7,13 +7,12 @@ */ package org.opendaylight.ovsdb.southbound.ovsdb.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; - import java.util.Collection; import java.util.Map; import java.util.NoSuchElementException; import org.opendaylight.mdsal.binding.api.DataTreeModification; import org.opendaylight.ovsdb.lib.notation.UUID; +import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.lib.operations.TransactionBuilder; import org.opendaylight.ovsdb.schema.openvswitch.Qos; import org.opendaylight.ovsdb.southbound.InstanceIdentifierCodec; @@ -26,9 +25,13 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class QosRemovedCommand implements TransactCommand { +public class QosRemovedCommand extends AbstractTransactCommand { private static final Logger LOG = LoggerFactory.getLogger(QosRemovedCommand.class); + public QosRemovedCommand(final Operations op) { + super(op); + } + @Override public void execute(final TransactionBuilder transaction, final BridgeOperationalState state, final DataChangeEvent events, final InstanceIdentifierCodec instanceIdentifierCodec) { @@ -46,11 +49,10 @@ public class QosRemovedCommand implements TransactCommand { TransactUtils.extractUpdated(modifications, OvsdbNodeAugmentation.class)); } - private static void execute(final TransactionBuilder transaction, final BridgeOperationalState state, + private void execute(final TransactionBuilder transaction, final BridgeOperationalState state, final Map, OvsdbNodeAugmentation> originals, final Map, OvsdbNodeAugmentation> updated) { - for (Map.Entry, OvsdbNodeAugmentation> originalEntry : originals - .entrySet()) { + for (var originalEntry : originals.entrySet()) { InstanceIdentifier ovsdbNodeIid = originalEntry.getKey(); OvsdbNodeAugmentation original = originalEntry.getValue(); OvsdbNodeAugmentation update = updated.get(ovsdbNodeIid); diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/QosUpdateCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/QosUpdateCommand.java index bd4ffadbf..a9b4bda13 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/QosUpdateCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/QosUpdateCommand.java @@ -8,7 +8,6 @@ package org.opendaylight.ovsdb.southbound.ovsdb.transact; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.Collection; @@ -17,6 +16,7 @@ import java.util.Map; import java.util.Map.Entry; import org.opendaylight.mdsal.binding.api.DataTreeModification; import org.opendaylight.ovsdb.lib.notation.UUID; +import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.lib.operations.TransactionBuilder; import org.opendaylight.ovsdb.schema.openvswitch.Qos; import org.opendaylight.ovsdb.southbound.InstanceIdentifierCodec; @@ -39,9 +39,13 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class QosUpdateCommand implements TransactCommand { +public class QosUpdateCommand extends AbstractTransactCommand { private static final Logger LOG = LoggerFactory.getLogger(QosUpdateCommand.class); + public QosUpdateCommand(final Operations op) { + super(op); + } + @Override public void execute(final TransactionBuilder transaction, final BridgeOperationalState state, final DataChangeEvent events, final InstanceIdentifierCodec instanceIdentifierCodec) { @@ -58,7 +62,7 @@ public class QosUpdateCommand implements TransactCommand { } @SuppressFBWarnings("DCN_NULLPOINTER_EXCEPTION") - private static void execute(final TransactionBuilder transaction, final BridgeOperationalState state, + private void execute(final TransactionBuilder transaction, final BridgeOperationalState state, final Map, QosEntries> createdOrUpdated, final InstanceIdentifierCodec instanceIdentifierCodec) { for (Entry, QosEntries> qosMapEntry: createdOrUpdated.entrySet()) { diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/QueueRemovedCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/QueueRemovedCommand.java index 2cee3c1d2..c80ae6702 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/QueueRemovedCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/QueueRemovedCommand.java @@ -7,12 +7,11 @@ */ package org.opendaylight.ovsdb.southbound.ovsdb.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; - import java.util.Collection; import java.util.Map; import org.opendaylight.mdsal.binding.api.DataTreeModification; import org.opendaylight.ovsdb.lib.notation.UUID; +import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.lib.operations.TransactionBuilder; import org.opendaylight.ovsdb.schema.openvswitch.Queue; import org.opendaylight.ovsdb.southbound.InstanceIdentifierCodec; @@ -25,9 +24,13 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class QueueRemovedCommand implements TransactCommand { +public class QueueRemovedCommand extends AbstractTransactCommand { private static final Logger LOG = LoggerFactory.getLogger(QueueRemovedCommand.class); + public QueueRemovedCommand(final Operations op) { + super(op); + } + @Override public void execute(final TransactionBuilder transaction, final BridgeOperationalState state, final DataChangeEvent events, final InstanceIdentifierCodec instanceIdentifierCodec) { @@ -43,9 +46,9 @@ public class QueueRemovedCommand implements TransactCommand { TransactUtils.extractUpdated(modifications, OvsdbNodeAugmentation.class)); } - private static void execute(final TransactionBuilder transaction, final BridgeOperationalState state, - final Map, OvsdbNodeAugmentation> originals, - final Map, OvsdbNodeAugmentation> updated) { + private void execute(final TransactionBuilder transaction, final BridgeOperationalState state, + final Map, OvsdbNodeAugmentation> originals, + final Map, OvsdbNodeAugmentation> updated) { for (Map.Entry, OvsdbNodeAugmentation> originalEntry : originals .entrySet()) { InstanceIdentifier ovsdbNodeIid = originalEntry.getKey(); diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/QueueUpdateCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/QueueUpdateCommand.java index 5f7218fb1..bb06206e9 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/QueueUpdateCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/QueueUpdateCommand.java @@ -8,7 +8,6 @@ package org.opendaylight.ovsdb.southbound.ovsdb.transact; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.Collection; @@ -19,6 +18,7 @@ import java.util.Map.Entry; import java.util.Set; import org.opendaylight.mdsal.binding.api.DataTreeModification; import org.opendaylight.ovsdb.lib.notation.UUID; +import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.lib.operations.TransactionBuilder; import org.opendaylight.ovsdb.schema.openvswitch.Queue; import org.opendaylight.ovsdb.southbound.InstanceIdentifierCodec; @@ -36,9 +36,13 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class QueueUpdateCommand implements TransactCommand { +public class QueueUpdateCommand extends AbstractTransactCommand { private static final Logger LOG = LoggerFactory.getLogger(QueueUpdateCommand.class); + public QueueUpdateCommand(final Operations op) { + super(op); + } + @Override public void execute(final TransactionBuilder transaction, final BridgeOperationalState state, final DataChangeEvent events, final InstanceIdentifierCodec instanceIdentifierCodec) { @@ -55,7 +59,7 @@ public class QueueUpdateCommand implements TransactCommand { } @SuppressFBWarnings("DCN_NULLPOINTER_EXCEPTION") - private static void execute(final TransactionBuilder transaction, final BridgeOperationalState state, + private void execute(final TransactionBuilder transaction, final BridgeOperationalState state, final Map, Queues> createdOrUpdated, final InstanceIdentifierCodec instanceIdentifierCodec) { for (Entry, Queues> queueMapEntry : createdOrUpdated.entrySet()) { diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TerminationPointCreateCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TerminationPointCreateCommand.java index 66d43b76c..061573e96 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TerminationPointCreateCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TerminationPointCreateCommand.java @@ -7,7 +7,6 @@ */ package org.opendaylight.ovsdb.southbound.ovsdb.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; import static org.opendaylight.ovsdb.southbound.SouthboundUtil.schemaMismatchLog; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -17,7 +16,6 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Optional; import java.util.Set; import org.opendaylight.mdsal.binding.api.DataTreeModification; @@ -25,6 +23,7 @@ import org.opendaylight.ovsdb.lib.error.SchemaVersionMismatchException; import org.opendaylight.ovsdb.lib.notation.Mutator; import org.opendaylight.ovsdb.lib.notation.UUID; import org.opendaylight.ovsdb.lib.operations.Mutate; +import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.lib.operations.TransactionBuilder; import org.opendaylight.ovsdb.schema.openvswitch.Bridge; import org.opendaylight.ovsdb.schema.openvswitch.Interface; @@ -59,9 +58,13 @@ import org.opendaylight.yangtools.yang.common.Uint32; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class TerminationPointCreateCommand implements TransactCommand { +public class TerminationPointCreateCommand extends AbstractTransactCommand { private static final Logger LOG = LoggerFactory.getLogger(TerminationPointCreateCommand.class); + public TerminationPointCreateCommand(final Operations op) { + super(op); + } + @Override public void execute(final TransactionBuilder transaction, final BridgeOperationalState state, final DataChangeEvent events, final InstanceIdentifierCodec instanceIdentifierCodec) { @@ -78,12 +81,11 @@ public class TerminationPointCreateCommand implements TransactCommand { TransactUtils.extractCreatedOrUpdated(modifications, Node.class), instanceIdentifierCodec); } - private static void execute(final TransactionBuilder transaction, final BridgeOperationalState state, + private void execute(final TransactionBuilder transaction, final BridgeOperationalState state, final Map, OvsdbTerminationPointAugmentation> createdTerminationPoints, final Map, Node> nodes, final InstanceIdentifierCodec instanceIdentifierCodec) { - for (Entry, OvsdbTerminationPointAugmentation> entry : - createdTerminationPoints.entrySet()) { + for (var entry : createdTerminationPoints.entrySet()) { OvsdbTerminationPointAugmentation terminationPoint = entry.getValue(); LOG.debug("Received request to create termination point {}", terminationPoint.getName()); @@ -97,7 +99,8 @@ public class TerminationPointCreateCommand implements TransactCommand { createInterface(terminationPoint, ovsInterface); transaction.add(op.insert(ovsInterface).withId(interfaceUuid)); - stampInstanceIdentifier(transaction, entry.getKey(), ovsInterface.getName(), instanceIdentifierCodec); + stampInstanceIdentifier(op, transaction, entry.getKey(), ovsInterface.getName(), + instanceIdentifierCodec); // Configure port with the above interface details String portUuid = "Port_" + SouthboundMapper.getRandomUuid(); @@ -365,13 +368,13 @@ public class TerminationPointCreateCommand implements TransactCommand { } } - public static void stampInstanceIdentifier(final TransactionBuilder transaction, + public static void stampInstanceIdentifier(final Operations op, final TransactionBuilder transaction, final InstanceIdentifier iid, final String interfaceName, final InstanceIdentifierCodec instanceIdentifierCodec) { Port port = transaction.getTypedRowWrapper(Port.class); port.setName(interfaceName); port.setExternalIds(Collections.emptyMap()); - Mutate mutate = TransactUtils.stampInstanceIdentifierMutation(transaction, iid, port.getSchema(), + Mutate mutate = TransactUtils.stampInstanceIdentifierMutation(op, transaction, iid, port.getSchema(), port.getExternalIdsColumn().getSchema(), instanceIdentifierCodec); transaction.add(mutate .where(port.getNameColumn().getSchema().opEqual(interfaceName)) diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TerminationPointDeleteCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TerminationPointDeleteCommand.java index 71e84853b..3464e55c9 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TerminationPointDeleteCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TerminationPointDeleteCommand.java @@ -7,8 +7,6 @@ */ package org.opendaylight.ovsdb.southbound.ovsdb.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; - import java.util.Collection; import java.util.Collections; import java.util.Map; @@ -17,6 +15,7 @@ import java.util.Set; import org.opendaylight.mdsal.binding.api.DataTreeModification; import org.opendaylight.ovsdb.lib.notation.Mutator; import org.opendaylight.ovsdb.lib.notation.UUID; +import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.lib.operations.TransactionBuilder; import org.opendaylight.ovsdb.schema.openvswitch.Bridge; import org.opendaylight.ovsdb.schema.openvswitch.Port; @@ -33,9 +32,13 @@ import org.slf4j.LoggerFactory; * * @author avishnoi@brocade.com (Anil Vishnoi) */ -public class TerminationPointDeleteCommand implements TransactCommand { +public class TerminationPointDeleteCommand extends AbstractTransactCommand { private static final Logger LOG = LoggerFactory.getLogger(TerminationPointDeleteCommand.class); + public TerminationPointDeleteCommand(final Operations op) { + super(op); + } + @Override public void execute(final TransactionBuilder transaction, final BridgeOperationalState state, final DataChangeEvent events, final InstanceIdentifierCodec instanceIdentifierCodec) { @@ -54,7 +57,7 @@ public class TerminationPointDeleteCommand implements TransactCommand { TransactUtils.extractRemoved(modifications, OvsdbTerminationPointAugmentation.class)); } - private static void execute(final TransactionBuilder transaction, final BridgeOperationalState state, + private void execute(final TransactionBuilder transaction, final BridgeOperationalState state, final Map, OvsdbTerminationPointAugmentation> originals, final Map, Node> originalNodes, diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TerminationPointUpdateCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TerminationPointUpdateCommand.java index a90c5cea6..1404ffcf0 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TerminationPointUpdateCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TerminationPointUpdateCommand.java @@ -8,9 +8,9 @@ package org.opendaylight.ovsdb.southbound.ovsdb.transact; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; import static org.opendaylight.ovsdb.southbound.SouthboundUtil.schemaMismatchLog; +import com.google.common.annotations.VisibleForTesting; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.Collection; import java.util.Collections; @@ -25,6 +25,7 @@ import org.opendaylight.mdsal.binding.api.DataTreeModification; import org.opendaylight.mdsal.binding.api.ReadTransaction; import org.opendaylight.ovsdb.lib.error.SchemaVersionMismatchException; import org.opendaylight.ovsdb.lib.notation.UUID; +import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.lib.operations.TransactionBuilder; import org.opendaylight.ovsdb.schema.openvswitch.Interface; import org.opendaylight.ovsdb.schema.openvswitch.Port; @@ -60,9 +61,13 @@ import org.opendaylight.yangtools.yang.common.Uint32; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class TerminationPointUpdateCommand implements TransactCommand { +public class TerminationPointUpdateCommand extends AbstractTransactCommand { private static final Logger LOG = LoggerFactory.getLogger(TerminationPointUpdateCommand.class); + public TerminationPointUpdateCommand(final Operations op) { + super(op); + } + @Override public void execute(final TransactionBuilder transaction, final BridgeOperationalState state, final DataChangeEvent events, final InstanceIdentifierCodec instanceIdentifierCodec) { @@ -91,6 +96,7 @@ public class TerminationPointUpdateCommand implements TransactCommand { } } + @VisibleForTesting public void updateTerminationPoint(final TransactionBuilder transaction, final BridgeOperationalState state, final InstanceIdentifier iid, final OvsdbTerminationPointAugmentation terminationPoint, @@ -109,7 +115,7 @@ public class TerminationPointUpdateCommand implements TransactCommand { .where(extraInterface.getNameColumn().getSchema().opEqual(terminationPoint.getName())) .build()); - TerminationPointCreateCommand.stampInstanceIdentifier(transaction, + TerminationPointCreateCommand.stampInstanceIdentifier(op, transaction, iid.firstIdentifierOf(OvsdbTerminationPointAugmentation.class), terminationPoint.getName(), instanceIdentifierCodec); final String opendaylightIid = instanceIdentifierCodec.serialize(iid); diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TransactCommandAggregator.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TransactCommandAggregator.java index 5334e3054..11e572ddd 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TransactCommandAggregator.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TransactCommandAggregator.java @@ -8,8 +8,9 @@ package org.opendaylight.ovsdb.southbound.ovsdb.transact; import java.util.Collection; -import java.util.function.Supplier; +import java.util.function.Function; import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.lib.operations.TransactionBuilder; import org.opendaylight.ovsdb.southbound.InstanceIdentifierCodec; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node; @@ -17,9 +18,9 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology. /** * This transactional command aggregates all the Southbound commands. */ -public class TransactCommandAggregator implements TransactCommand { +public class TransactCommandAggregator extends AbstractTransactCommand { // Type capture to allow using an array - private interface CommandSupplier extends Supplier { + private interface CommandSupplier extends Function { } @@ -43,11 +44,15 @@ public class TransactCommandAggregator implements TransactCommand { TerminationPointUpdateCommand::new }; + public TransactCommandAggregator(final Operations op) { + super(op); + } + @Override public void execute(final TransactionBuilder transaction, final BridgeOperationalState state, final DataChangeEvent events, final InstanceIdentifierCodec instanceIdentifierCodec) { for (CommandSupplier supplier : COMMAND_SUPPLIERS) { - supplier.get().execute(transaction, state, events, instanceIdentifierCodec); + supplier.apply(op).execute(transaction, state, events, instanceIdentifierCodec); } } @@ -56,7 +61,7 @@ public class TransactCommandAggregator implements TransactCommand { final Collection> modifications, final InstanceIdentifierCodec instanceIdentifierCodec) { for (CommandSupplier supplier : COMMAND_SUPPLIERS) { - supplier.get().execute(transaction, state, modifications, instanceIdentifierCodec); + supplier.apply(op).execute(transaction, state, modifications, instanceIdentifierCodec); } } } diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TransactUtils.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TransactUtils.java index adbb9b4db..bcae24f22 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TransactUtils.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TransactUtils.java @@ -7,8 +7,6 @@ */ package org.opendaylight.ovsdb.southbound.ovsdb.transact; -import static org.opendaylight.ovsdb.lib.operations.Operations.op; - import com.google.common.base.Predicates; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; @@ -33,6 +31,7 @@ import org.opendaylight.ovsdb.lib.notation.UUID; import org.opendaylight.ovsdb.lib.operations.Insert; import org.opendaylight.ovsdb.lib.operations.Mutate; import org.opendaylight.ovsdb.lib.operations.Operation; +import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.lib.operations.TransactionBuilder; import org.opendaylight.ovsdb.lib.schema.ColumnSchema; import org.opendaylight.ovsdb.lib.schema.GenericTableSchema; @@ -424,15 +423,15 @@ public class TransactUtils { return new UUID(uuidString); } - public static > void stampInstanceIdentifier(final TransactionBuilder transaction, - final InstanceIdentifier iid, final TableSchema tableSchema, + public static > void stampInstanceIdentifier(final Operations op, + final TransactionBuilder transaction, final InstanceIdentifier iid, final TableSchema tableSchema, final ColumnSchema> columnSchema, final InstanceIdentifierCodec instanceIdentifierCodec) { transaction.add( - stampInstanceIdentifierMutation(transaction, iid, tableSchema, columnSchema, instanceIdentifierCodec)); + stampInstanceIdentifierMutation(op, transaction, iid, tableSchema, columnSchema, instanceIdentifierCodec)); } - public static > Mutate stampInstanceIdentifierMutation( + public static > Mutate stampInstanceIdentifierMutation(final Operations op, final TransactionBuilder transaction, final InstanceIdentifier iid, final TableSchema tableSchema, final ColumnSchema> columnSchema, final InstanceIdentifierCodec instanceIdentifierCodec) { diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/reconciliation/configuration/BridgeConfigReconciliationTask.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/reconciliation/configuration/BridgeConfigReconciliationTask.java index 1499b2814..1fe801467 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/reconciliation/configuration/BridgeConfigReconciliationTask.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/reconciliation/configuration/BridgeConfigReconciliationTask.java @@ -266,7 +266,7 @@ public class BridgeConfigReconciliationTask extends ReconciliationTask { } }; - connectionInstance.transact(new TransactCommandAggregator(), + connectionInstance.transact(new TransactCommandAggregator(connectionInstance.ops()), new BridgeOperationalState(reconciliationManager.getDb(), changeEvents), new DataChangesManagedByOvsdbNodeEvent( reconciliationManager.getDb(), diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/reconciliation/configuration/TerminationPointConfigReconciliationTask.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/reconciliation/configuration/TerminationPointConfigReconciliationTask.java index 2fc3c8c82..6596065e6 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/reconciliation/configuration/TerminationPointConfigReconciliationTask.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/reconciliation/configuration/TerminationPointConfigReconciliationTask.java @@ -91,7 +91,7 @@ public class TerminationPointConfigReconciliationTask extends ReconciliationTask } }; - connectionInstance.transact(new TerminationPointCreateCommand(), + connectionInstance.transact(new TerminationPointCreateCommand(connectionInstance.ops()), new BridgeOperationalState(reconciliationManager.getDb(), changeEvents), changeEvents, instanceIdentifierCodec); @@ -158,7 +158,7 @@ public class TerminationPointConfigReconciliationTask extends ReconciliationTask } }; - connectionInstance.transact(new TerminationPointDeleteCommand(), + connectionInstance.transact(new TerminationPointDeleteCommand(connectionInstance.ops()), new BridgeOperationalState(reconciliationManager.getDb(), deleteChangeEvents), deleteChangeEvents, instanceIdentifierCodec); @@ -166,7 +166,7 @@ public class TerminationPointConfigReconciliationTask extends ReconciliationTask } @Override - public void doRetry(boolean wasPreviousAttemptSuccessful) { + public void doRetry(final boolean wasPreviousAttemptSuccessful) { } @Override diff --git a/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionInstanceTest.java b/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionInstanceTest.java index 4f6efe141..964c60d16 100644 --- a/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionInstanceTest.java +++ b/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionInstanceTest.java @@ -40,6 +40,7 @@ import org.opendaylight.ovsdb.lib.MonitorHandle; import org.opendaylight.ovsdb.lib.OvsdbClient; import org.opendaylight.ovsdb.lib.OvsdbConnectionInfo; import org.opendaylight.ovsdb.lib.message.TableUpdates; +import org.opendaylight.ovsdb.lib.operations.DefaultOperations; import org.opendaylight.ovsdb.lib.operations.OperationResult; import org.opendaylight.ovsdb.lib.operations.TransactionBuilder; import org.opendaylight.ovsdb.lib.schema.DatabaseSchema; @@ -77,7 +78,8 @@ public class OvsdbConnectionInstanceTest { @Before public void setUp() throws Exception { - ovsdbConnectionInstance = spy(new OvsdbConnectionInstance(key, client, txInvoker, instanceIdentifier)); + ovsdbConnectionInstance = spy(new OvsdbConnectionInstance(key, client, new DefaultOperations(), txInvoker, + instanceIdentifier)); } @Test diff --git a/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionManagerTest.java b/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionManagerTest.java index 13b419401..512ea34da 100644 --- a/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionManagerTest.java +++ b/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionManagerTest.java @@ -41,6 +41,8 @@ import org.opendaylight.ovsdb.lib.OvsdbClient; import org.opendaylight.ovsdb.lib.OvsdbConnection; import org.opendaylight.ovsdb.lib.OvsdbConnectionInfo; import org.opendaylight.ovsdb.lib.impl.OvsdbConnectionService; +import org.opendaylight.ovsdb.lib.operations.DefaultOperations; +import org.opendaylight.ovsdb.lib.operations.Operations; import org.opendaylight.ovsdb.southbound.reconciliation.ReconciliationManager; import org.opendaylight.ovsdb.southbound.transactions.md.TransactionCommand; import org.opendaylight.ovsdb.southbound.transactions.md.TransactionInvoker; @@ -97,10 +99,12 @@ public class OvsdbConnectionManagerTest { field(OvsdbConnectionManager.class, "alreadyProcessedClients").set(ovsdbConnManager, new ConcurrentHashMap<>()); entityConnectionMap = new ConcurrentHashMap<>(); + InetAddress.getByAddress(new byte[] { 1, 2, 3, 4}); + OvsdbConnectionInfo info = mock(OvsdbConnectionInfo.class); - doReturn(mock(InetAddress.class)).when(info).getRemoteAddress(); + doReturn(InetAddress.getByAddress(new byte[] { 1, 2, 3, 4})).when(info).getRemoteAddress(); doReturn(8080).when(info).getRemotePort(); - doReturn(mock(InetAddress.class)).when(info).getLocalAddress(); + doReturn(InetAddress.getByAddress(new byte[] { 5, 6, 7, 8})).when(info).getLocalAddress(); doReturn(8080).when(info).getLocalPort(); externalClient = mock(OvsdbClient.class, Mockito.RETURNS_DEEP_STUBS); @@ -162,7 +166,7 @@ public class OvsdbConnectionManagerTest { OvsdbConnectionInstance.class)); doNothing().when(client).createTransactInvokers(); PowerMockito.whenNew(OvsdbConnectionInstance.class).withArguments(any(ConnectionInfo.class), - any(OvsdbClient.class), any(TransactionInvoker.class), any(InstanceIdentifier.class)) + any(OvsdbClient.class), any(Operations.class), any(TransactionInvoker.class), any(InstanceIdentifier.class)) .thenReturn(client); assertEquals("Error, did not receive correct OvsdbConnectionInstance object", client, @@ -394,7 +398,8 @@ public class OvsdbConnectionManagerTest { Entity entity = new Entity("entityType", "entityName"); ConnectionInfo key = mock(ConnectionInfo.class); - OvsdbConnectionInstance ovsdbConnInstance = new OvsdbConnectionInstance(key, externalClient, txInvoker, iid); + OvsdbConnectionInstance ovsdbConnInstance = new OvsdbConnectionInstance(key, externalClient, + new DefaultOperations(), txInvoker, iid); entityConnectionMap.put(entity, ovsdbConnInstance); field(OvsdbConnectionManager.class, "entityConnectionMap").set(ovsdbConnManager, entityConnectionMap); diff --git a/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/OvsdbDataTreeChangeListenerTest.java b/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/OvsdbDataTreeChangeListenerTest.java index 4b9827679..4671edc43 100644 --- a/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/OvsdbDataTreeChangeListenerTest.java +++ b/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/OvsdbDataTreeChangeListenerTest.java @@ -22,6 +22,7 @@ import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBro import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService; import org.opendaylight.ovsdb.lib.OvsdbConnection; +import org.opendaylight.ovsdb.lib.operations.DefaultOperations; import org.opendaylight.ovsdb.southbound.transactions.md.TransactionInvokerImpl; import org.opendaylight.ovsdb.utils.southbound.utils.SouthboundUtils; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; @@ -51,8 +52,9 @@ public class OvsdbDataTreeChangeListenerTest extends AbstractConcurrentDataBroke EntityOwnershipService entityOwnershipService = mock(EntityOwnershipService.class); InstanceIdentifierCodec instanceIdentifierCodec = mock(InstanceIdentifierCodec.class); listener = new OvsdbDataTreeChangeListener(dataBroker, - new OvsdbConnectionManager(dataBroker, new TransactionInvokerImpl(dataBroker), entityOwnershipService, - ovsdbConnection, instanceIdentifierCodec, List.of(), List.of()), instanceIdentifierCodec); + new OvsdbConnectionManager(dataBroker, new DefaultOperations(), new TransactionInvokerImpl(dataBroker), + entityOwnershipService, ovsdbConnection, instanceIdentifierCodec, List.of(), List.of()), + instanceIdentifierCodec); } @Test diff --git a/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/SouthboundProviderTest.java b/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/SouthboundProviderTest.java index db73da98b..5ec9ba117 100644 --- a/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/SouthboundProviderTest.java +++ b/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/SouthboundProviderTest.java @@ -39,6 +39,7 @@ import org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException import org.opendaylight.mdsal.eos.common.api.EntityOwnershipState; import org.opendaylight.mdsal.eos.common.api.EntityOwnershipStateChange; import org.opendaylight.ovsdb.lib.OvsdbConnection; +import org.opendaylight.ovsdb.lib.operations.DefaultOperations; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey; @@ -78,7 +79,7 @@ public class SouthboundProviderTest extends AbstractConcurrentDataBrokerTest { Mockito.mock(DOMSchemaService.class), Mockito.mock(BindingNormalizedNodeSerializer.class), new TestSystemReadyMonitor(IMMEDIATE), - diagStatusService)) { + diagStatusService, new DefaultOperations())) { // Verify that at least one listener was registered verify(entityOwnershipService, atLeastOnce()).registerListener( @@ -102,7 +103,7 @@ public class SouthboundProviderTest extends AbstractConcurrentDataBrokerTest { Mockito.mock(DOMSchemaService.class), Mockito.mock(BindingNormalizedNodeSerializer.class), new TestSystemReadyMonitor(IMMEDIATE), - diagStatusService)) { + diagStatusService, new DefaultOperations())) { // Verify that at least one listener was registered verify(entityOwnershipService, atLeastOnce()).registerListener( @@ -132,7 +133,7 @@ public class SouthboundProviderTest extends AbstractConcurrentDataBrokerTest { Mockito.mock(DOMSchemaService.class), Mockito.mock(BindingNormalizedNodeSerializer.class), new TestSystemReadyMonitor(IMMEDIATE), - diagStatusService)) { + diagStatusService, new DefaultOperations())) { // At this point the OVSDB topology must not be present in either tree assertFalse(getDataBroker().newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, diff --git a/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/OpenVSwitchBridgeAddCommandTest.java b/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/OpenVSwitchBridgeAddCommandTest.java index f4691b670..df02bf986 100644 --- a/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/OpenVSwitchBridgeAddCommandTest.java +++ b/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/OpenVSwitchBridgeAddCommandTest.java @@ -11,6 +11,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -21,7 +22,6 @@ import java.util.Set; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Mockito; import org.opendaylight.ovsdb.lib.notation.Column; import org.opendaylight.ovsdb.lib.notation.Mutator; import org.opendaylight.ovsdb.lib.notation.UUID; @@ -43,10 +43,12 @@ import org.powermock.modules.junit4.PowerMockRunner; @PrepareForTest({TransactUtils.class, Operations.class}) public class OpenVSwitchBridgeAddCommandTest { private OpenVSwitchBridgeAddCommand ovsBridgeAddCommand; + private Operations op; @Before public void setUp() { - ovsBridgeAddCommand = mock(OpenVSwitchBridgeAddCommand.class, Mockito.CALLS_REAL_METHODS); + op = mock(Operations.class); + ovsBridgeAddCommand = spy(new OpenVSwitchBridgeAddCommand(op)); } @SuppressWarnings({ "unchecked", "rawtypes" }) @@ -74,7 +76,6 @@ public class OpenVSwitchBridgeAddCommandTest { doNothing().when(ovs).setBridges(any(Set.class)); Mutate mutate = mock(Mutate.class); - Operations op = OvsdbNodeUpdateCommandTest.setOpField(); when(op.mutate(any(OpenVSwitch.class))).thenReturn(mutate); Column> column = mock(Column.class); when(ovs.getBridgesColumn()).thenReturn(column); diff --git a/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/OvsdbNodeUpdateCommandTest.java b/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/OvsdbNodeUpdateCommandTest.java index e6989f10f..66309e316 100644 --- a/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/OvsdbNodeUpdateCommandTest.java +++ b/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/OvsdbNodeUpdateCommandTest.java @@ -11,19 +11,18 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import com.google.common.collect.ImmutableMap; -import java.lang.reflect.Field; import java.util.HashMap; import java.util.Map; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.Mockito; import org.opendaylight.ovsdb.lib.notation.Column; import org.opendaylight.ovsdb.lib.operations.Mutate; import org.opendaylight.ovsdb.lib.operations.Operation; @@ -63,11 +62,12 @@ public class OvsdbNodeUpdateCommandTest { private static final String OTHER_CONFIG_VALUE = "other config value"; @Mock private DataChangeEvent changes; + @Mock private Operations op; private OvsdbNodeUpdateCommand ovsdbNodeUpdateCommand; @Before public void setUp() { - ovsdbNodeUpdateCommand = mock(OvsdbNodeUpdateCommand.class, Mockito.CALLS_REAL_METHODS); + ovsdbNodeUpdateCommand = spy(new OvsdbNodeUpdateCommand(op)); } @SuppressWarnings("unchecked") @@ -106,7 +106,6 @@ public class OvsdbNodeUpdateCommandTest { doNothing().when(ovs).setExternalIds(any(ImmutableMap.class)); Mutate mutate = mock(Mutate.class); - Operations op = setOpField(); Column> column = mock(Column.class); when(ovs.getExternalIdsColumn()).thenReturn(column); when(column.getSchema()).thenReturn(mock(ColumnSchema.class)); @@ -128,11 +127,4 @@ public class OvsdbNodeUpdateCommandTest { verify(ovs, times(2)).getExternalIdsColumn(); verify(transaction, times(2)).add(eq(null)); } - - static Operations setOpField() throws Exception { - Field opField = PowerMockito.field(Operations.class, "op"); - Operations mockOp = mock(Operations.class); - opField.set(Operations.class, mockOp); - return mockOp; - } } diff --git a/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TerminationPointCreateCommandTest.java b/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TerminationPointCreateCommandTest.java index aac1dc3f4..4d42d438e 100644 --- a/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TerminationPointCreateCommandTest.java +++ b/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TerminationPointCreateCommandTest.java @@ -28,6 +28,7 @@ import org.mockito.Mockito; import org.opendaylight.ovsdb.lib.notation.Column; import org.opendaylight.ovsdb.lib.notation.Condition; import org.opendaylight.ovsdb.lib.notation.UUID; +import org.opendaylight.ovsdb.lib.operations.DefaultOperations; import org.opendaylight.ovsdb.lib.operations.Insert; import org.opendaylight.ovsdb.lib.operations.Mutate; import org.opendaylight.ovsdb.lib.operations.Operation; @@ -132,10 +133,11 @@ public class TerminationPointCreateCommandTest { when(column.getSchema()).thenReturn(mock(ColumnSchema.class)); Mutate mutate = mock(Mutate.class); + // FIXME: rather than static mocking, insert a mock Operations PowerMockito.mockStatic(TransactUtils.class); - when(TransactUtils.stampInstanceIdentifierMutation(any(TransactionBuilder.class), any(InstanceIdentifier.class), - any(GenericTableSchema.class), any(ColumnSchema.class), any(InstanceIdentifierCodec.class))).thenReturn( - mutate); + when(TransactUtils.stampInstanceIdentifierMutation(any(Operations.class), any(TransactionBuilder.class), + any(InstanceIdentifier.class), any(GenericTableSchema.class), any(ColumnSchema.class), + any(InstanceIdentifierCodec.class))).thenReturn(mutate); Column nameColumn = mock(Column.class); when(port.getNameColumn()).thenReturn(nameColumn); @@ -153,7 +155,7 @@ public class TerminationPointCreateCommandTest { .child(Node.class, new NodeKey(new NodeId("testNode"))) .child(TerminationPoint.class, new TerminationPointKey(new TpId("testTp"))) .augmentation(OvsdbTerminationPointAugmentation.class); - TerminationPointCreateCommand.stampInstanceIdentifier(transaction, iid, interfaceName, + TerminationPointCreateCommand.stampInstanceIdentifier(new DefaultOperations(), transaction, iid, interfaceName, mock(InstanceIdentifierCodec.class)); verify(port).setName(anyString()); verify(port).getExternalIdsColumn(); diff --git a/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TerminationPointUpdateCommandTest.java b/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TerminationPointUpdateCommandTest.java index de0918e51..687759404 100644 --- a/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TerminationPointUpdateCommandTest.java +++ b/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TerminationPointUpdateCommandTest.java @@ -12,6 +12,7 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -22,7 +23,6 @@ import java.util.Optional; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Mockito; import org.opendaylight.ovsdb.lib.notation.Column; import org.opendaylight.ovsdb.lib.notation.Condition; import org.opendaylight.ovsdb.lib.operations.Operation; @@ -61,13 +61,15 @@ import org.powermock.modules.junit4.PowerMockRunner; Operations.class }) public class TerminationPointUpdateCommandTest { - private static final String TERMINATION_POINT_NAME = "termination point name"; + + private Operations op; private TerminationPointUpdateCommand terminationPointUpdateCommand; @Before public void setUp() { - terminationPointUpdateCommand = mock(TerminationPointUpdateCommand.class, Mockito.CALLS_REAL_METHODS); + op = mock(Operations.class); + terminationPointUpdateCommand = spy(new TerminationPointUpdateCommand(op)); } @SuppressWarnings("unchecked") @@ -126,7 +128,6 @@ public class TerminationPointUpdateCommandTest { when(transaction.getTypedRowWrapper(eq(Interface.class))).thenReturn(extraInterface); doNothing().when(extraInterface).setName(anyString()); - Operations op = OvsdbNodeUpdateCommandTest.setOpField(); Update update = mock(Update.class); when(op.update(any(Interface.class))).thenReturn(update); diff --git a/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TransactCommandAggregatorTest.java b/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TransactCommandAggregatorTest.java index e6e1d37a2..6c3962b0a 100644 --- a/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TransactCommandAggregatorTest.java +++ b/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TransactCommandAggregatorTest.java @@ -20,6 +20,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.ovsdb.lib.operations.DefaultOperations; import org.opendaylight.ovsdb.lib.operations.TransactionBuilder; import org.opendaylight.ovsdb.southbound.InstanceIdentifierCodec; @@ -33,7 +34,7 @@ public class TransactCommandAggregatorTest { @Before public void setUp() throws Exception { - transactCommandAggregator = new TransactCommandAggregator(); + transactCommandAggregator = new TransactCommandAggregator(new DefaultOperations()); //mock commands field commands.add(mock(BridgeUpdateCommand.class)); diff --git a/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TransactUtilsTest.java b/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TransactUtilsTest.java index 6e9778cec..ef9fe638e 100644 --- a/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TransactUtilsTest.java +++ b/southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TransactUtilsTest.java @@ -18,7 +18,6 @@ import static org.mockito.Mockito.when; import com.google.common.base.Predicates; import com.google.common.collect.Maps; -import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -33,6 +32,7 @@ import org.opendaylight.ovsdb.lib.notation.Mutation; import org.opendaylight.ovsdb.lib.notation.Mutator; import org.opendaylight.ovsdb.lib.notation.OvsdbSet; import org.opendaylight.ovsdb.lib.notation.UUID; +import org.opendaylight.ovsdb.lib.operations.DefaultOperations; import org.opendaylight.ovsdb.lib.operations.Insert; import org.opendaylight.ovsdb.lib.operations.Mutate; import org.opendaylight.ovsdb.lib.operations.Operation; @@ -209,13 +209,15 @@ public class TransactUtilsTest { TableSchema tableSchema = mock(TableSchema.class); ColumnSchema> columnSchema = mock(ColumnSchema.class); InstanceIdentifierCodec instanceIdentifierCodec = mock(InstanceIdentifierCodec.class); + Operations ops = new DefaultOperations(); PowerMockito.doReturn(mock(Mutate.class)).when(TransactUtils.class); - TransactUtils.stampInstanceIdentifierMutation(transaction, iid, tableSchema, columnSchema, + TransactUtils.stampInstanceIdentifierMutation(ops, transaction, iid, tableSchema, columnSchema, instanceIdentifierCodec); when(transaction.add(any(Operation.class))).thenReturn(transaction); - TransactUtils.stampInstanceIdentifier(transaction, iid, tableSchema, columnSchema, instanceIdentifierCodec); + TransactUtils.stampInstanceIdentifier(ops, transaction, iid, tableSchema, columnSchema, + instanceIdentifierCodec); verify(transaction).add(any(Operation.class)); } @@ -226,7 +228,7 @@ public class TransactUtilsTest { when(instanceIdentifierCodec.serialize(any(InstanceIdentifier.class))).thenReturn(IID_STRING); Mutate mutate = mock(Mutate.class); - Operations op = (Operations) setField("op"); + Operations op = mock(Operations.class); Mockito.>when(op.mutate(any(TableSchema.class))).thenReturn(mutate); when(mutate.addMutation(any(ColumnSchema.class), any(Mutator.class), any(Map.class))).thenReturn(mutate); @@ -244,14 +246,7 @@ public class TransactUtilsTest { InstanceIdentifier iid = InstanceIdentifier.create(NetworkTopology.class); TransactionBuilder transaction = mock(TransactionBuilder.class); TableSchema tableSchema = mock(TableSchema.class); - assertEquals(mutate, TransactUtils.stampInstanceIdentifierMutation(transaction, iid, tableSchema, columnSchema, - instanceIdentifierCodec)); - } - - private static Object setField(final String fieldName) throws Exception { - Field field = Operations.class.getDeclaredField(fieldName); - field.setAccessible(true); - field.set(field.get(Operations.class), mock(Operations.class)); - return field.get(Operations.class); + assertEquals(mutate, TransactUtils.stampInstanceIdentifierMutation(op, transaction, iid, tableSchema, + columnSchema, instanceIdentifierCodec)); } } -- 2.43.0 From afcc1d0e275bcc08f1ed54f885201500afe4ee12 Mon Sep 17 00:00:00 2001 From: jenkins-releng Date: Wed, 7 Aug 2024 16:53:14 +0000 Subject: [PATCH 3/3] Release Validate --- commons/binding-parent/pom.xml | 2 +- commons/it/pom.xml | 2 +- commons/pom.xml | 2 +- hwvtepsouthbound/hwvtepsouthbound-api/pom.xml | 4 ++-- hwvtepsouthbound/hwvtepsouthbound-artifacts/pom.xml | 2 +- hwvtepsouthbound/hwvtepsouthbound-features/features/pom.xml | 2 +- .../odl-ovsdb-hwvtepsouthbound-api/pom.xml | 2 +- .../odl-ovsdb-hwvtepsouthbound-rest/pom.xml | 2 +- .../odl-ovsdb-hwvtepsouthbound-test/pom.xml | 2 +- .../odl-ovsdb-hwvtepsouthbound-ui/pom.xml | 2 +- .../odl-ovsdb-hwvtepsouthbound/pom.xml | 2 +- hwvtepsouthbound/hwvtepsouthbound-features/pom.xml | 2 +- hwvtepsouthbound/hwvtepsouthbound-impl/pom.xml | 2 +- hwvtepsouthbound/hwvtepsouthbound-it/pom.xml | 2 +- hwvtepsouthbound/hwvtepsouthbound-karaf/pom.xml | 2 +- hwvtepsouthbound/pom.xml | 2 +- library/artifacts/pom.xml | 2 +- library/features/features/pom.xml | 2 +- library/features/odl-ovsdb-library/pom.xml | 2 +- library/features/pom.xml | 2 +- library/impl/pom.xml | 4 ++-- library/it/pom.xml | 6 +++--- library/karaf/pom.xml | 2 +- library/pom.xml | 2 +- pom.xml | 2 +- schemas/hardwarevtep/pom.xml | 4 ++-- schemas/openvswitch/pom.xml | 4 ++-- schemas/pom.xml | 2 +- southbound/pom.xml | 2 +- southbound/southbound-api/pom.xml | 4 ++-- southbound/southbound-artifacts/pom.xml | 2 +- southbound/southbound-features/features/pom.xml | 2 +- .../southbound-features/odl-ovsdb-southbound-api/pom.xml | 2 +- .../odl-ovsdb-southbound-impl-rest/pom.xml | 2 +- .../odl-ovsdb-southbound-impl-ui/pom.xml | 2 +- .../southbound-features/odl-ovsdb-southbound-impl/pom.xml | 2 +- .../southbound-features/odl-ovsdb-southbound-test/pom.xml | 2 +- southbound/southbound-features/pom.xml | 2 +- southbound/southbound-impl/pom.xml | 2 +- southbound/southbound-it/pom.xml | 2 +- southbound/southbound-karaf/pom.xml | 2 +- utils/config/pom.xml | 4 ++-- utils/hwvtepsouthbound-utils/pom.xml | 4 ++-- utils/mdsal-utils/pom.xml | 4 ++-- utils/odl-ovsdb-utils/pom.xml | 2 +- utils/ovsdb-it-utils/pom.xml | 2 +- utils/pom.xml | 2 +- utils/servicehelper/pom.xml | 4 ++-- utils/southbound-utils/pom.xml | 4 ++-- utils/yang-utils/pom.xml | 4 ++-- 50 files changed, 63 insertions(+), 63 deletions(-) diff --git a/commons/binding-parent/pom.xml b/commons/binding-parent/pom.xml index 81ad31b38..1fa573af4 100644 --- a/commons/binding-parent/pom.xml +++ b/commons/binding-parent/pom.xml @@ -17,7 +17,7 @@ org.opendaylight.ovsdb ovsdb-binding-parent - 1.19.0-SNAPSHOT + 1.19.0 pom diff --git a/commons/it/pom.xml b/commons/it/pom.xml index 5b88c51a3..b1f524a14 100644 --- a/commons/it/pom.xml +++ b/commons/it/pom.xml @@ -18,7 +18,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb it - 1.19.0-SNAPSHOT + 1.19.0 pom diff --git a/commons/pom.xml b/commons/pom.xml index cefc5d9d4..3565e5820 100644 --- a/commons/pom.xml +++ b/commons/pom.xml @@ -18,7 +18,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb parents - 1.19.0-SNAPSHOT + 1.19.0 ODL :: ovsdb :: ${project.artifactId} diff --git a/hwvtepsouthbound/hwvtepsouthbound-api/pom.xml b/hwvtepsouthbound/hwvtepsouthbound-api/pom.xml index 868c73049..5983117e6 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-api/pom.xml +++ b/hwvtepsouthbound/hwvtepsouthbound-api/pom.xml @@ -10,14 +10,14 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb ovsdb-binding-parent - 1.19.0-SNAPSHOT + 1.19.0 ../../commons/binding-parent 4.0.0 org.opendaylight.ovsdb hwvtepsouthbound-api - 1.19.0-SNAPSHOT + 1.19.0 bundle diff --git a/hwvtepsouthbound/hwvtepsouthbound-artifacts/pom.xml b/hwvtepsouthbound/hwvtepsouthbound-artifacts/pom.xml index bfa90c062..d111fa3e0 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-artifacts/pom.xml +++ b/hwvtepsouthbound/hwvtepsouthbound-artifacts/pom.xml @@ -19,7 +19,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb hwvtepsouthbound-artifacts - 1.19.0-SNAPSHOT + 1.19.0 pom diff --git a/hwvtepsouthbound/hwvtepsouthbound-features/features/pom.xml b/hwvtepsouthbound/hwvtepsouthbound-features/features/pom.xml index 6d6db3c71..c2585e3f5 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-features/features/pom.xml +++ b/hwvtepsouthbound/hwvtepsouthbound-features/features/pom.xml @@ -18,7 +18,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb hwvtepsouthbound-features - 1.19.0-SNAPSHOT + 1.19.0 feature diff --git a/hwvtepsouthbound/hwvtepsouthbound-features/odl-ovsdb-hwvtepsouthbound-api/pom.xml b/hwvtepsouthbound/hwvtepsouthbound-features/odl-ovsdb-hwvtepsouthbound-api/pom.xml index 548f0137c..09ce22237 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-features/odl-ovsdb-hwvtepsouthbound-api/pom.xml +++ b/hwvtepsouthbound/hwvtepsouthbound-features/odl-ovsdb-hwvtepsouthbound-api/pom.xml @@ -11,7 +11,7 @@ org.opendaylight.ovsdb odl-ovsdb-hwvtepsouthbound-api - 1.19.0-SNAPSHOT + 1.19.0 feature diff --git a/hwvtepsouthbound/hwvtepsouthbound-features/odl-ovsdb-hwvtepsouthbound-rest/pom.xml b/hwvtepsouthbound/hwvtepsouthbound-features/odl-ovsdb-hwvtepsouthbound-rest/pom.xml index f04bc08e8..640a30a38 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-features/odl-ovsdb-hwvtepsouthbound-rest/pom.xml +++ b/hwvtepsouthbound/hwvtepsouthbound-features/odl-ovsdb-hwvtepsouthbound-rest/pom.xml @@ -18,7 +18,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb odl-ovsdb-hwvtepsouthbound-rest - 1.19.0-SNAPSHOT + 1.19.0 feature diff --git a/hwvtepsouthbound/hwvtepsouthbound-impl/pom.xml b/hwvtepsouthbound/hwvtepsouthbound-impl/pom.xml index 91bc02c14..1f9f08cb5 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-impl/pom.xml +++ b/hwvtepsouthbound/hwvtepsouthbound-impl/pom.xml @@ -12,7 +12,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb ovsdb-binding-parent - 1.19.0-SNAPSHOT + 1.19.0 ../../commons/binding-parent diff --git a/hwvtepsouthbound/hwvtepsouthbound-it/pom.xml b/hwvtepsouthbound/hwvtepsouthbound-it/pom.xml index b50f49bde..e12a261cf 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-it/pom.xml +++ b/hwvtepsouthbound/hwvtepsouthbound-it/pom.xml @@ -11,7 +11,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb it - 1.19.0-SNAPSHOT + 1.19.0 ../../commons/it diff --git a/hwvtepsouthbound/hwvtepsouthbound-karaf/pom.xml b/hwvtepsouthbound/hwvtepsouthbound-karaf/pom.xml index 0b62ed060..704ce2784 100644 --- a/hwvtepsouthbound/hwvtepsouthbound-karaf/pom.xml +++ b/hwvtepsouthbound/hwvtepsouthbound-karaf/pom.xml @@ -15,7 +15,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL 4.0.0 org.opendaylight.ovsdb hwvtepsouthbound-karaf - 1.19.0-SNAPSHOT + 1.19.0 pom diff --git a/hwvtepsouthbound/pom.xml b/hwvtepsouthbound/pom.xml index 1409433d3..4f50601e3 100644 --- a/hwvtepsouthbound/pom.xml +++ b/hwvtepsouthbound/pom.xml @@ -17,7 +17,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL org.opendaylight.ovsdb hwvtepsouthbound-aggregator - 1.19.0-SNAPSHOT + 1.19.0 ODL :: ovsdb :: ${project.artifactId} diff --git a/library/artifacts/pom.xml b/library/artifacts/pom.xml index 265a86277..e004dc3ca 100644 --- a/library/artifacts/pom.xml +++ b/library/artifacts/pom.xml @@ -19,7 +19,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb library-artifacts - 1.19.0-SNAPSHOT + 1.19.0 pom diff --git a/library/features/features/pom.xml b/library/features/features/pom.xml index af9a810a9..55b8bc258 100644 --- a/library/features/features/pom.xml +++ b/library/features/features/pom.xml @@ -18,7 +18,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb library-features - 1.19.0-SNAPSHOT + 1.19.0 feature diff --git a/library/features/odl-ovsdb-library/pom.xml b/library/features/odl-ovsdb-library/pom.xml index fd145e786..ff9db01d9 100644 --- a/library/features/odl-ovsdb-library/pom.xml +++ b/library/features/odl-ovsdb-library/pom.xml @@ -18,7 +18,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb odl-ovsdb-library - 1.19.0-SNAPSHOT + 1.19.0 feature ODL :: ovsdb :: ${project.artifactId} diff --git a/library/impl/pom.xml b/library/impl/pom.xml index ca171e037..2f563bbdb 100644 --- a/library/impl/pom.xml +++ b/library/impl/pom.xml @@ -12,14 +12,14 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb ovsdb-binding-parent - 1.19.0-SNAPSHOT + 1.19.0 ../../commons/binding-parent 4.0.0 org.opendaylight.ovsdb library - 1.19.0-SNAPSHOT + 1.19.0 bundle diff --git a/library/it/pom.xml b/library/it/pom.xml index 5c9f7624e..34ea198d6 100644 --- a/library/it/pom.xml +++ b/library/it/pom.xml @@ -11,14 +11,14 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb it - 1.19.0-SNAPSHOT + 1.19.0 ../../commons/it 4.0.0 org.opendaylight.ovsdb library-it - 1.19.0-SNAPSHOT + 1.19.0 jar @@ -27,7 +27,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb library-karaf - 1.19.0-SNAPSHOT + 1.19.0 zip diff --git a/library/karaf/pom.xml b/library/karaf/pom.xml index 773c79310..ab77e0b56 100644 --- a/library/karaf/pom.xml +++ b/library/karaf/pom.xml @@ -15,7 +15,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL 4.0.0 org.opendaylight.ovsdb library-karaf - 1.19.0-SNAPSHOT + 1.19.0 pom diff --git a/library/pom.xml b/library/pom.xml index 8a3b6533b..d5a3de8a9 100644 --- a/library/pom.xml +++ b/library/pom.xml @@ -17,7 +17,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb library-aggregator - 1.19.0-SNAPSHOT + 1.19.0 ODL :: ovsdb :: ${project.artifactId} diff --git a/pom.xml b/pom.xml index 792d64795..b7d262061 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb ovsdb - 1.19.0-SNAPSHOT + 1.19.0 ${project.artifactId} pom diff --git a/schemas/hardwarevtep/pom.xml b/schemas/hardwarevtep/pom.xml index 70c118d26..6c808344f 100644 --- a/schemas/hardwarevtep/pom.xml +++ b/schemas/hardwarevtep/pom.xml @@ -12,13 +12,13 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb ovsdb-binding-parent - 1.19.0-SNAPSHOT + 1.19.0 ../../commons/binding-parent org.opendaylight.ovsdb schema.hardwarevtep - 1.19.0-SNAPSHOT + 1.19.0 bundle diff --git a/schemas/openvswitch/pom.xml b/schemas/openvswitch/pom.xml index a2f5f2703..136c9f0f5 100644 --- a/schemas/openvswitch/pom.xml +++ b/schemas/openvswitch/pom.xml @@ -12,13 +12,13 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb ovsdb-binding-parent - 1.19.0-SNAPSHOT + 1.19.0 ../../commons/binding-parent org.opendaylight.ovsdb schema.openvswitch - 1.19.0-SNAPSHOT + 1.19.0 bundle diff --git a/schemas/pom.xml b/schemas/pom.xml index 1ef50b9b3..c1347a632 100644 --- a/schemas/pom.xml +++ b/schemas/pom.xml @@ -18,7 +18,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb schemas - 1.19.0-SNAPSHOT + 1.19.0 ODL :: ovsdb :: ${project.artifactId} diff --git a/southbound/pom.xml b/southbound/pom.xml index 89cb69d32..56c91eacb 100644 --- a/southbound/pom.xml +++ b/southbound/pom.xml @@ -16,7 +16,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL org.opendaylight.ovsdb southbound-aggregator - 1.19.0-SNAPSHOT + 1.19.0 ODL :: ovsdb :: ${project.artifactId} diff --git a/southbound/southbound-api/pom.xml b/southbound/southbound-api/pom.xml index 36e640f16..3daa6b903 100644 --- a/southbound/southbound-api/pom.xml +++ b/southbound/southbound-api/pom.xml @@ -10,14 +10,14 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb ovsdb-binding-parent - 1.19.0-SNAPSHOT + 1.19.0 ../../commons/binding-parent 4.0.0 org.opendaylight.ovsdb southbound-api - 1.19.0-SNAPSHOT + 1.19.0 bundle diff --git a/southbound/southbound-artifacts/pom.xml b/southbound/southbound-artifacts/pom.xml index c7c054129..5461d577b 100644 --- a/southbound/southbound-artifacts/pom.xml +++ b/southbound/southbound-artifacts/pom.xml @@ -19,7 +19,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb southbound-artifacts - 1.19.0-SNAPSHOT + 1.19.0 pom diff --git a/southbound/southbound-features/features/pom.xml b/southbound/southbound-features/features/pom.xml index 7af66361a..e19830549 100644 --- a/southbound/southbound-features/features/pom.xml +++ b/southbound/southbound-features/features/pom.xml @@ -18,7 +18,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb southbound-features - 1.19.0-SNAPSHOT + 1.19.0 feature diff --git a/southbound/southbound-features/odl-ovsdb-southbound-api/pom.xml b/southbound/southbound-features/odl-ovsdb-southbound-api/pom.xml index 0ccfc5a9d..24201b0bb 100644 --- a/southbound/southbound-features/odl-ovsdb-southbound-api/pom.xml +++ b/southbound/southbound-features/odl-ovsdb-southbound-api/pom.xml @@ -18,7 +18,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb odl-ovsdb-southbound-api - 1.19.0-SNAPSHOT + 1.19.0 feature diff --git a/southbound/southbound-features/odl-ovsdb-southbound-impl-rest/pom.xml b/southbound/southbound-features/odl-ovsdb-southbound-impl-rest/pom.xml index 10c5f257e..3309bc5f9 100644 --- a/southbound/southbound-features/odl-ovsdb-southbound-impl-rest/pom.xml +++ b/southbound/southbound-features/odl-ovsdb-southbound-impl-rest/pom.xml @@ -18,7 +18,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb odl-ovsdb-southbound-impl-rest - 1.19.0-SNAPSHOT + 1.19.0 feature ODL :: ovsdb :: ${project.artifactId} diff --git a/southbound/southbound-impl/pom.xml b/southbound/southbound-impl/pom.xml index 5a958d04b..fd18c319b 100644 --- a/southbound/southbound-impl/pom.xml +++ b/southbound/southbound-impl/pom.xml @@ -12,7 +12,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb ovsdb-binding-parent - 1.19.0-SNAPSHOT + 1.19.0 ../../commons/binding-parent diff --git a/southbound/southbound-it/pom.xml b/southbound/southbound-it/pom.xml index a927273bc..40098492d 100644 --- a/southbound/southbound-it/pom.xml +++ b/southbound/southbound-it/pom.xml @@ -12,7 +12,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb it - 1.19.0-SNAPSHOT + 1.19.0 ../../commons/it 4.0.0 diff --git a/southbound/southbound-karaf/pom.xml b/southbound/southbound-karaf/pom.xml index 3e2b197bc..6093b2119 100644 --- a/southbound/southbound-karaf/pom.xml +++ b/southbound/southbound-karaf/pom.xml @@ -15,7 +15,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL 4.0.0 org.opendaylight.ovsdb southbound-karaf - 1.19.0-SNAPSHOT + 1.19.0 pom diff --git a/utils/config/pom.xml b/utils/config/pom.xml index 5548042d6..d67cfaedc 100644 --- a/utils/config/pom.xml +++ b/utils/config/pom.xml @@ -12,13 +12,13 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb ovsdb-binding-parent - 1.19.0-SNAPSHOT + 1.19.0 ../../commons/binding-parent org.opendaylight.ovsdb utils.config - 1.19.0-SNAPSHOT + 1.19.0 ODL :: ovsdb :: ${project.artifactId} diff --git a/utils/hwvtepsouthbound-utils/pom.xml b/utils/hwvtepsouthbound-utils/pom.xml index fb4586094..a76df9b44 100644 --- a/utils/hwvtepsouthbound-utils/pom.xml +++ b/utils/hwvtepsouthbound-utils/pom.xml @@ -11,13 +11,13 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb ovsdb-binding-parent - 1.19.0-SNAPSHOT + 1.19.0 ../../commons/binding-parent org.opendaylight.ovsdb utils.hwvtepsouthbound-utils - 1.19.0-SNAPSHOT + 1.19.0 bundle diff --git a/utils/mdsal-utils/pom.xml b/utils/mdsal-utils/pom.xml index 67b61b155..c111598f6 100644 --- a/utils/mdsal-utils/pom.xml +++ b/utils/mdsal-utils/pom.xml @@ -11,13 +11,13 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb ovsdb-binding-parent - 1.19.0-SNAPSHOT + 1.19.0 ../../commons/binding-parent org.opendaylight.ovsdb utils.mdsal-utils - 1.19.0-SNAPSHOT + 1.19.0 bundle diff --git a/utils/odl-ovsdb-utils/pom.xml b/utils/odl-ovsdb-utils/pom.xml index c94b22c20..854efd38f 100644 --- a/utils/odl-ovsdb-utils/pom.xml +++ b/utils/odl-ovsdb-utils/pom.xml @@ -18,7 +18,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb odl-ovsdb-utils - 1.19.0-SNAPSHOT + 1.19.0 feature diff --git a/utils/ovsdb-it-utils/pom.xml b/utils/ovsdb-it-utils/pom.xml index b3ca76819..a40d87876 100644 --- a/utils/ovsdb-it-utils/pom.xml +++ b/utils/ovsdb-it-utils/pom.xml @@ -11,7 +11,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb ovsdb-binding-parent - 1.19.0-SNAPSHOT + 1.19.0 ../../commons/binding-parent diff --git a/utils/pom.xml b/utils/pom.xml index efce0a0ef..aa8ba6aaf 100644 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -18,7 +18,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb utils - 1.19.0-SNAPSHOT + 1.19.0 pom diff --git a/utils/servicehelper/pom.xml b/utils/servicehelper/pom.xml index de0ee8ca5..9817b6a13 100644 --- a/utils/servicehelper/pom.xml +++ b/utils/servicehelper/pom.xml @@ -12,13 +12,13 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb ovsdb-binding-parent - 1.19.0-SNAPSHOT + 1.19.0 ../../commons/binding-parent org.opendaylight.ovsdb utils.servicehelper - 1.19.0-SNAPSHOT + 1.19.0 bundle diff --git a/utils/southbound-utils/pom.xml b/utils/southbound-utils/pom.xml index 7f6291acb..f0b256fb2 100644 --- a/utils/southbound-utils/pom.xml +++ b/utils/southbound-utils/pom.xml @@ -11,13 +11,13 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb ovsdb-binding-parent - 1.19.0-SNAPSHOT + 1.19.0 ../../commons/binding-parent org.opendaylight.ovsdb utils.southbound-utils - 1.19.0-SNAPSHOT + 1.19.0 bundle diff --git a/utils/yang-utils/pom.xml b/utils/yang-utils/pom.xml index 35848bfaa..0b48dae62 100644 --- a/utils/yang-utils/pom.xml +++ b/utils/yang-utils/pom.xml @@ -11,13 +11,13 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb ovsdb-binding-parent - 1.19.0-SNAPSHOT + 1.19.0 ../../commons/binding-parent org.opendaylight.ovsdb utils.yang-utils - 1.19.0-SNAPSHOT + 1.19.0 bundle -- 2.43.0