From: Robert Varga Date: Tue, 5 Feb 2019 16:29:43 +0000 (+0100) Subject: Switch to MD-SAL APIs X-Git-Tag: release/sodium~57 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=cfe3a97837951ebbedb337dc988027f10c49f714;p=openflowplugin.git Switch to MD-SAL APIs This mass-converts all components to use MD-SAL APIs. Change-Id: Ied51c12836fc1fc91038557e66f02f4d9f0d6b0d Signed-off-by: Robert Varga --- diff --git a/applications/bulk-o-matic/pom.xml b/applications/bulk-o-matic/pom.xml index e5581253f7..7a49679fc2 100644 --- a/applications/bulk-o-matic/pom.xml +++ b/applications/bulk-o-matic/pom.xml @@ -15,12 +15,8 @@ openflowplugin-api - org.opendaylight.controller - sal-binding-api - - - org.opendaylight.controller - sal-binding-broker-impl + org.opendaylight.mdsal + mdsal-binding-api org.opendaylight.controller.model diff --git a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowReader.java b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowReader.java index 424a166a1b..edf3dded44 100644 --- a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowReader.java +++ b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowReader.java @@ -7,13 +7,13 @@ */ package org.opendaylight.openflowplugin.applications.bulk.o.matic; -import com.google.common.base.Optional; +import java.util.Optional; +import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.ReadTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table; @@ -79,13 +79,12 @@ public final class FlowReader implements Runnable, FlowCounterMBean { String flowId = "Flow-" + dpId + "." + tableId + "." + sourceIp; InstanceIdentifier flowIid = getFlowInstanceIdentifier(dpId, tableId, flowId); - try (ReadOnlyTransaction readOnlyTransaction = dataBroker.newReadOnlyTransaction()) { + try (ReadTransaction readOnlyTransaction = dataBroker.newReadOnlyTransaction()) { Optional flowOptional; if (isConfigDs) { - flowOptional = readOnlyTransaction.read(LogicalDatastoreType.CONFIGURATION, flowIid) - .checkedGet(); + flowOptional = readOnlyTransaction.read(LogicalDatastoreType.CONFIGURATION, flowIid).get(); } else { - flowOptional = readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, flowIid).checkedGet(); + flowOptional = readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, flowIid).get(); } if (flowOptional.isPresent()) { @@ -98,7 +97,7 @@ public final class FlowReader implements Runnable, FlowCounterMBean { LOG.info("Flow: {} not found", flowIid); } } - } catch (ReadFailedException e) { + } catch (InterruptedException | ExecutionException e) { readOpStatus.set(FlowCounter.OperationStatus.FAILURE.status()); LOG.error("Error {}", e); } diff --git a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterConcurrent.java b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterConcurrent.java index d86cecdde5..ae73a6248c 100644 --- a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterConcurrent.java +++ b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterConcurrent.java @@ -8,15 +8,13 @@ package org.opendaylight.openflowplugin.applications.bulk.o.matic; import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.MoreExecutors; - import java.util.concurrent.ExecutorService; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @@ -133,7 +131,7 @@ public class FlowWriterConcurrent implements FlowCounterMBean { calculatedTableId = (short) ((calculatedTableId + numberA) % numberB + startTableId); } } - Futures.addCallback(writeTransaction.submit(), + writeTransaction.commit().addCallback( new DsCallBack(dpId, tableId, calculatedTableId, sourceIp), MoreExecutors.directExecutor()); // Wrap around tableId = (short) ((calculatedTableId + 1) % (short) (endTableId - startTableId + 1) + startTableId); @@ -159,7 +157,7 @@ public class FlowWriterConcurrent implements FlowCounterMBean { } } - private class DsCallBack implements FutureCallback { + private class DsCallBack implements FutureCallback { private final String dpId; private final int sourceIp; private final short endTableId; diff --git a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterDirectOFRpc.java b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterDirectOFRpc.java index 5632425239..dba068981b 100644 --- a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterDirectOFRpc.java +++ b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterDirectOFRpc.java @@ -7,19 +7,19 @@ */ package org.opendaylight.openflowplugin.applications.bulk.o.matic; -import com.google.common.base.Optional; import java.util.Collections; import java.util.HashSet; import java.util.List; +import java.util.Optional; import java.util.Set; +import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; import org.opendaylight.infrautils.utils.concurrent.JdkFutures; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.ReadTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput; @@ -77,9 +77,8 @@ public class FlowWriterDirectOFRpc { Set nodeIds = new HashSet<>(); InstanceIdentifier nodes = InstanceIdentifier.create(Nodes.class); - try (ReadOnlyTransaction readOnlyTransaction = dataBroker.newReadOnlyTransaction()) { - Optional nodesDataNode = readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, nodes) - .checkedGet(); + try (ReadTransaction readOnlyTransaction = dataBroker.newReadOnlyTransaction()) { + Optional nodesDataNode = readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, nodes).get(); if (nodesDataNode.isPresent()) { List nodesCollection = nodesDataNode.get().getNode(); if (nodesCollection != null && !nodesCollection.isEmpty()) { @@ -93,8 +92,8 @@ public class FlowWriterDirectOFRpc { } else { return Collections.emptySet(); } - } catch (ReadFailedException rdFailedException) { - LOG.error("Failed to read connected nodes {}", rdFailedException); + } catch (InterruptedException | ExecutionException e) { + LOG.error("Failed to read connected nodes {}", e); } return nodeIds; } diff --git a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterSequential.java b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterSequential.java index 21b3cb3ad6..7a319c5b5f 100644 --- a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterSequential.java +++ b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterSequential.java @@ -8,14 +8,13 @@ package org.opendaylight.openflowplugin.applications.bulk.o.matic; import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.MoreExecutors; import java.util.concurrent.ExecutorService; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @@ -133,7 +132,7 @@ public class FlowWriterSequential implements FlowCounterMBean { LOG.debug("Submitting Txn for dpId: {}, begin tableId: {}, end tableId: {}, sourceIp: {}", dpId, tableId, calculatedTableId, sourceIp); - Futures.addCallback(writeTransaction.submit(), new DsCallBack(dpId, sourceIp, calculatedTableId), + writeTransaction.commit().addCallback(new DsCallBack(dpId, sourceIp, calculatedTableId), MoreExecutors.directExecutor()); } @@ -148,7 +147,7 @@ public class FlowWriterSequential implements FlowCounterMBean { } } - private class DsCallBack implements FutureCallback { + private class DsCallBack implements FutureCallback { private final String dpId; private int sourceIp; private final Short tableId; @@ -162,7 +161,7 @@ public class FlowWriterSequential implements FlowCounterMBean { } @Override - public void onSuccess(Void notUsed) { + public void onSuccess(Object notUsed) { if (sourceIp > flowsPerDpn) { long dur = System.nanoTime() - startTime; LOG.info("Completed all flows installation for: dpid: {}, tableId: {}, sourceIp: {} in {}ns", dpId, @@ -205,7 +204,7 @@ public class FlowWriterSequential implements FlowCounterMBean { } LOG.debug("OnSuccess: Submitting Txn for dpId: {}, begin tableId: {}, end tableId: {}, sourceIp: {}", dpId, tableId, calculatedTableId, sourceIp); - Futures.addCallback(writeTransaction.submit(), new DsCallBack(dpId, sourceIp, calculatedTableId), + writeTransaction.commit().addCallback(new DsCallBack(dpId, sourceIp, calculatedTableId), MoreExecutors.directExecutor()); } diff --git a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterTxChain.java b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterTxChain.java index 09a0329a9d..b8333bf135 100644 --- a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterTxChain.java +++ b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterTxChain.java @@ -8,18 +8,16 @@ package org.opendaylight.openflowplugin.applications.bulk.o.matic; import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.MoreExecutors; import java.util.concurrent.ExecutorService; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; -import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChain; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.Transaction; +import org.opendaylight.mdsal.binding.api.TransactionChain; +import org.opendaylight.mdsal.binding.api.TransactionChainListener; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @@ -86,7 +84,7 @@ public class FlowWriterTxChain implements FlowCounterMBean { private final boolean isCreateParents; private final AtomicInteger remainingTxReturn = new AtomicInteger(0); - private BindingTransactionChain txChain; + private TransactionChain txChain; FlowHandlerTask(final String dpId, final int flowsPerDpn, @@ -144,7 +142,7 @@ public class FlowWriterTxChain implements FlowCounterMBean { } LOG.debug("Submitting Txn for dpId: {}, begin tableId: {}, end tableId: {}, sourceIp: {}", dpId, tableId, calculatedTableId, sourceIp - 1); - Futures.addCallback(writeTransaction.submit(), + writeTransaction.commit().addCallback( new DsCallBack(dpId, tableId, calculatedTableId, sourceIp, txChain), MoreExecutors.directExecutor()); // Wrap around @@ -162,15 +160,15 @@ public class FlowWriterTxChain implements FlowCounterMBean { } @Override - public void onTransactionChainFailed(TransactionChain transactionChain, - AsyncTransaction asyncTransaction, Throwable throwable) { + public void onTransactionChainFailed(TransactionChain transactionChain, + Transaction asyncTransaction, Throwable throwable) { LOG.error("Transaction chain: {} FAILED at asyncTransaction: {} due to: ", transactionChain, asyncTransaction.getIdentifier(), throwable); transactionChain.close(); } @Override - public void onTransactionChainSuccessful(TransactionChain transactionChain) { + public void onTransactionChainSuccessful(TransactionChain transactionChain) { LOG.info("Transaction chain: {} closed successfully.", transactionChain); } @@ -185,15 +183,15 @@ public class FlowWriterTxChain implements FlowCounterMBean { } } - private class DsCallBack implements FutureCallback { + private class DsCallBack implements FutureCallback { private final String dpId; private final int sourceIp; private final short endTableId; private final short beginTableId; - private final BindingTransactionChain txChain; + private final TransactionChain txChain; DsCallBack(String dpId, Short beginTableId, Short endTableId, Integer sourceIp, - BindingTransactionChain txChain) { + TransactionChain txChain) { this.dpId = dpId; this.sourceIp = sourceIp; this.endTableId = endTableId; @@ -202,7 +200,7 @@ public class FlowWriterTxChain implements FlowCounterMBean { } @Override - public void onSuccess(Void notUsed) { + public void onSuccess(Object notUsed) { if (remainingTxReturn.decrementAndGet() <= 0) { long dur = System.nanoTime() - startTime; LOG.info("Completed all flows installation for: dpid: {} in {}ns", dpId, dur); diff --git a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/SalBulkFlowServiceImpl.java b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/SalBulkFlowServiceImpl.java index 70c259a399..7b44a53d15 100644 --- a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/SalBulkFlowServiceImpl.java +++ b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/SalBulkFlowServiceImpl.java @@ -29,10 +29,10 @@ import javax.management.MBeanServer; import javax.management.MalformedObjectNameException; import javax.management.NotCompliantMBeanException; import javax.management.ObjectName; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.infrautils.utils.concurrent.JdkFutures; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsDsInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsDsOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsRpcInput; @@ -110,7 +110,7 @@ public class SalBulkFlowServiceImpl implements SalBulkFlowService { flowBuilder.build(), createParents); createParents = createParentsNextTime; } - ListenableFuture submitFuture = writeTransaction.submit(); + ListenableFuture submitFuture = writeTransaction.commit(); return Futures.transform(handleResultFuture(Futures.allAsList(submitFuture)), voidRpcResult -> { if (voidRpcResult.isSuccessful()) { return RpcResultBuilder.success().build(); @@ -133,7 +133,7 @@ public class SalBulkFlowServiceImpl implements SalBulkFlowService { for (BulkFlowDsItem bulkFlow : input.getBulkFlowDsItem()) { writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, getFlowInstanceIdentifier(bulkFlow)); } - return Futures.transform(handleResultFuture(Futures.allAsList(writeTransaction.submit())), voidRpcResult -> { + return Futures.transform(handleResultFuture(Futures.allAsList(writeTransaction.commit())), voidRpcResult -> { if (voidRpcResult.isSuccessful()) { return RpcResultBuilder.success().build(); } else { diff --git a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/TableWriter.java b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/TableWriter.java index 65986cd1db..18e34a892c 100644 --- a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/TableWriter.java +++ b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/TableWriter.java @@ -8,16 +8,15 @@ package org.opendaylight.openflowplugin.applications.bulk.o.matic; import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.MoreExecutors; import java.util.concurrent.ExecutorService; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey; @@ -99,9 +98,9 @@ public class TableWriter implements FlowCounterMBean { wtx.delete(LogicalDatastoreType.CONFIGURATION, tableIId); } - Futures.addCallback(wtx.submit(), new FutureCallback() { + wtx.commit().addCallback(new FutureCallback() { @Override - public void onSuccess(Void voidParameter) { + public void onSuccess(Object voidParameter) { if (successfulWrites.incrementAndGet() == totalTables) { if (failedWrites.get() > 0) { writeOpStatus.set(FlowCounter.OperationStatus.FAILURE.status()); diff --git a/applications/bulk-o-matic/src/main/resources/OSGI-INF/blueprint/bulk-o-matic.xml b/applications/bulk-o-matic/src/main/resources/OSGI-INF/blueprint/bulk-o-matic.xml index f7ee5ef211..5b3c410740 100644 --- a/applications/bulk-o-matic/src/main/resources/OSGI-INF/blueprint/bulk-o-matic.xml +++ b/applications/bulk-o-matic/src/main/resources/OSGI-INF/blueprint/bulk-o-matic.xml @@ -3,7 +3,7 @@ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0" odl:use-default-for-reference-types="true"> - + @@ -14,4 +14,4 @@ - \ No newline at end of file + diff --git a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowReaderTest.java b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowReaderTest.java index 174fadbee2..5e074ea5c3 100644 --- a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowReaderTest.java +++ b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowReaderTest.java @@ -5,25 +5,24 @@ * 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.openflowplugin.applications.bulk.o.matic; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.when; -import com.google.common.base.Optional; -import com.google.common.util.concurrent.Futures; +import java.util.Optional; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.ReadTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.util.concurrent.FluentFutures; /** * Test for {@link FlowReader}. @@ -34,7 +33,7 @@ public class FlowReaderTest { @Mock private DataBroker mockDataBroker; @Mock - private ReadOnlyTransaction readOnlyTransaction; + private ReadTransaction readOnlyTransaction; @Mock private Node node; @@ -42,8 +41,8 @@ public class FlowReaderTest { @Before public void setUp() throws Exception { - when(readOnlyTransaction.read(Mockito.any(LogicalDatastoreType.class), Mockito.>any())) - .thenReturn(Futures.immediateCheckedFuture(Optional.of(node))); + doReturn(FluentFutures.immediateFluentFuture(Optional.of(node))).when(readOnlyTransaction) + .read(any(LogicalDatastoreType.class), any()); when(mockDataBroker.newReadOnlyTransaction()).thenReturn(readOnlyTransaction); flowReader = FlowReader.getNewInstance(mockDataBroker, 2, 5, true, false, (short) 1, (short) 2); } diff --git a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterConcurrentTest.java b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterConcurrentTest.java index 124a98c0b4..59c5bf3692 100644 --- a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterConcurrentTest.java +++ b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterConcurrentTest.java @@ -1,16 +1,14 @@ -/** +/* * Copyright (c) 2016, 2017 Cisco Systems, Inc. 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.openflowplugin.applications.bulk.o.matic; import static org.mockito.Mockito.doReturn; -import com.google.common.util.concurrent.Futures; import java.util.concurrent.ExecutorService; import org.junit.Before; import org.junit.Test; @@ -18,23 +16,20 @@ import org.junit.runner.RunWith; import org.mockito.ArgumentMatchers; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.CommitInfo; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Test for {@link FlowWriterConcurrent}. */ @RunWith(MockitoJUnitRunner.class) public class FlowWriterConcurrentTest { - - private static final Logger LOG = LoggerFactory.getLogger(FlowWriterConcurrentTest.class); private static final int FLOWS_PER_DPN = 100; @Mock @@ -52,7 +47,7 @@ public class FlowWriterConcurrentTest { public void setUp() throws Exception { doReturn(writeTransaction).when(mockDataBroker).newWriteOnlyTransaction(); - Mockito.when(writeTransaction.submit()).thenReturn(Futures.immediateCheckedFuture(null)); + doReturn(CommitInfo.emptyFluentFuture()).when(writeTransaction).commit(); Mockito.doAnswer(invocation -> { ((Runnable) invocation.getArguments()[0]).run(); diff --git a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterDirectOFRpcTest.java b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterDirectOFRpcTest.java index 2cda1ad5b2..f7ba8e1353 100644 --- a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterDirectOFRpcTest.java +++ b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterDirectOFRpcTest.java @@ -1,21 +1,19 @@ -/** +/* * Copyright (c) 2016, 2017 Cisco Systems, Inc. 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.openflowplugin.applications.bulk.o.matic; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.when; -import com.google.common.base.Optional; -import com.google.common.util.concurrent.Futures; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import java.util.concurrent.ExecutorService; import org.junit.Before; import org.junit.Test; @@ -23,17 +21,17 @@ import org.junit.runner.RunWith; import org.mockito.ArgumentMatchers; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.ReadTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.util.concurrent.FluentFutures; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,7 +52,7 @@ public class FlowWriterDirectOFRpcTest { @Mock private ExecutorService mockFlowPusher; @Mock - private ReadOnlyTransaction readOnlyTransaction; + private ReadTransaction readOnlyTransaction; @Mock private Nodes mockNodes; @@ -74,9 +72,8 @@ public class FlowWriterDirectOFRpcTest { when(mockNodes.getNode()).thenReturn(nodes); - when(readOnlyTransaction.read(Mockito.any(LogicalDatastoreType.class), - Mockito.>any())) - .thenReturn(Futures.immediateCheckedFuture(Optional.of(mockNodes))); + doReturn(FluentFutures.immediateFluentFuture(Optional.of(mockNodes))).when(readOnlyTransaction) + .read(any(LogicalDatastoreType.class), any()); Mockito.doAnswer(invocation -> { ((Runnable)invocation.getArguments()[0]).run(); diff --git a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterSequentialTest.java b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterSequentialTest.java index 780fc4adb0..24eb56f73b 100644 --- a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterSequentialTest.java +++ b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterSequentialTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2016, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the @@ -10,7 +10,6 @@ package org.opendaylight.openflowplugin.applications.bulk.o.matic; import static org.mockito.Mockito.doReturn; -import com.google.common.util.concurrent.Futures; import java.util.concurrent.ExecutorService; import org.junit.Before; import org.junit.Test; @@ -18,22 +17,19 @@ import org.junit.runner.RunWith; import org.mockito.ArgumentMatchers; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.CommitInfo; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Test for {@link FlowWriterSequential}. */ @RunWith(MockitoJUnitRunner.class) public class FlowWriterSequentialTest { - - private static final Logger LOG = LoggerFactory.getLogger(FlowWriterSequentialTest.class); private static final int FLOWS_PER_DPN = 100; @Mock @@ -49,7 +45,7 @@ public class FlowWriterSequentialTest { public void setUp() throws Exception { doReturn(writeTransaction).when(mockDataBroker).newWriteOnlyTransaction(); - Mockito.when(writeTransaction.submit()).thenReturn(Futures.immediateCheckedFuture(null)); + doReturn(CommitInfo.emptyFluentFuture()).when(writeTransaction).commit(); Mockito.doAnswer(invocation -> { ((Runnable) invocation.getArguments()[0]).run(); diff --git a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterTxChainTest.java b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterTxChainTest.java index d1cd249c87..9c4882b699 100644 --- a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterTxChainTest.java +++ b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterTxChainTest.java @@ -1,18 +1,16 @@ -/** +/* * Copyright (c) 2016, 2017 Cisco Systems, Inc. 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.openflowplugin.applications.bulk.o.matic; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import com.google.common.util.concurrent.Futures; import java.util.concurrent.ExecutorService; import org.junit.Before; import org.junit.Test; @@ -20,12 +18,13 @@ import org.junit.runner.RunWith; import org.mockito.ArgumentMatchers; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.TransactionChain; +import org.opendaylight.mdsal.binding.api.TransactionChainListener; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.CommitInfo; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; @@ -57,12 +56,12 @@ public class FlowWriterTxChainTest { return null; }).when(mockFlowPusher).execute(ArgumentMatchers.any()); - final BindingTransactionChain mockedTxChain = mock(BindingTransactionChain.class); + final TransactionChain mockedTxChain = mock(TransactionChain.class); when(mockedTxChain.newWriteOnlyTransaction()).thenReturn(writeTransaction); doReturn(mockedTxChain).when(mockDataBroker) .createTransactionChain(ArgumentMatchers.any()); - when(writeTransaction.submit()).thenReturn(Futures.immediateCheckedFuture(null)); + doReturn(CommitInfo.emptyFluentFuture()).when(writeTransaction).commit(); flowWriterTxChain = new FlowWriterTxChain(mockDataBroker, mockFlowPusher); } diff --git a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/SalBulkFlowServiceImplTest.java b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/SalBulkFlowServiceImplTest.java index f68501acdf..91db78d547 100644 --- a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/SalBulkFlowServiceImplTest.java +++ b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/SalBulkFlowServiceImplTest.java @@ -1,22 +1,23 @@ -/** +/* * Copyright (c) 2016, 2017 Cisco Systems, Inc. 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.openflowplugin.applications.bulk.o.matic; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import com.google.common.base.Optional; -import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -26,11 +27,12 @@ import org.mockito.ArgumentMatchers; import org.mockito.Captor; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.ReadTransaction; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.CommitInfo; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsDsInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsDsInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsRpcInput; @@ -66,11 +68,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalF import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; +import org.opendaylight.yangtools.util.concurrent.FluentFutures; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Test for {@link SalBulkFlowServiceImpl}. @@ -78,8 +79,6 @@ import org.slf4j.LoggerFactory; @RunWith(MockitoJUnitRunner.class) public class SalBulkFlowServiceImplTest { - private static final Logger LOG = LoggerFactory.getLogger(SalBulkFlowServiceImplTest.class); - @Mock private DataBroker mockDataBroker; @Mock @@ -87,7 +86,7 @@ public class SalBulkFlowServiceImplTest { @Mock private WriteTransaction writeTransaction; @Mock - private ReadOnlyTransaction readOnlyTransaction; + private ReadTransaction readOnlyTransaction; @Mock private Nodes mockNodes; @Mock @@ -101,15 +100,15 @@ public class SalBulkFlowServiceImplTest { public void setUp() throws Exception { when(mockDataBroker.newWriteOnlyTransaction()).thenReturn(writeTransaction); when(mockDataBroker.newReadOnlyTransaction()).thenReturn(readOnlyTransaction); - Mockito.lenient().when(readOnlyTransaction.read(Mockito.any(LogicalDatastoreType.class), - Mockito.>any())) - .thenReturn(Futures.immediateCheckedFuture(Optional.of(mockNode))); + + lenient().doReturn(FluentFutures.immediateFluentFuture(Optional.of(mockNode))).when(readOnlyTransaction) + .read(any(LogicalDatastoreType.class), any()); salBulkFlowService = new SalBulkFlowServiceImpl(mockSalFlowService, mockDataBroker); } @Test public void testAddRemoveFlowsDs() throws Exception { - Mockito.when(writeTransaction.submit()).thenReturn(Futures.immediateCheckedFuture(null)); + doReturn(CommitInfo.emptyFluentFuture()).when(writeTransaction).commit(); final BulkFlowDsItemBuilder bulkFlowDsItemBuilder = new BulkFlowDsItemBuilder().setFlowId(new FlowId("1")) .setTableId((short) 2); @@ -127,7 +126,7 @@ public class SalBulkFlowServiceImplTest { final AddFlowsDsInput addFlowsDsInput = addFlowsDsInputBuilder.build(); salBulkFlowService.addFlowsDs(addFlowsDsInput); - verify(writeTransaction).submit(); + verify(writeTransaction).commit(); verify(writeTransaction).put(ArgumentMatchers.any(), ArgumentMatchers.>any(), flowArgumentCaptor.capture(), Mockito.anyBoolean()); @@ -144,7 +143,7 @@ public class SalBulkFlowServiceImplTest { salBulkFlowService.removeFlowsDs(removeFlowsDsInput); verify(writeTransaction).delete(ArgumentMatchers.any(), ArgumentMatchers.>any()); - verify(writeTransaction, times(2)).submit(); + verify(writeTransaction, times(2)).commit(); } @Test @@ -194,9 +193,8 @@ public class SalBulkFlowServiceImplTest { @Test public void testFlowRpcAddTest() throws Exception { - when(readOnlyTransaction.read(Mockito.any(LogicalDatastoreType.class), - Mockito.>any())) - .thenReturn(Futures.immediateCheckedFuture(Optional.of(mockNodes))); + doReturn(FluentFutures.immediateFluentFuture(Optional.of(mockNodes))).when(readOnlyTransaction) + .read(any(LogicalDatastoreType.class), any()); final FlowRpcAddTestInputBuilder flowRpcAddTestInputBuilder = new FlowRpcAddTestInputBuilder().setFlowCount(1L) .setDpnId("1").setRpcBatchSize(1L); @@ -246,9 +244,8 @@ public class SalBulkFlowServiceImplTest { @Test public void testFlowRpcAddMultiple() throws Exception { - when(readOnlyTransaction.read(Mockito.any(LogicalDatastoreType.class), - Mockito.>any())) - .thenReturn(Futures.immediateCheckedFuture(Optional.of(mockNodes))); + doReturn(FluentFutures.immediateFluentFuture(Optional.of(mockNodes))).when(readOnlyTransaction) + .read(any(LogicalDatastoreType.class), any()); final FlowRpcAddMultipleInputBuilder flowRpcAddMultipleInputBuilder = new FlowRpcAddMultipleInputBuilder() .setFlowCount(1L).setRpcBatchSize(1L); diff --git a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/TableWriterTest.java b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/TableWriterTest.java index 5ca5a58206..4bdd74361e 100644 --- a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/TableWriterTest.java +++ b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/TableWriterTest.java @@ -1,16 +1,14 @@ -/** +/* * Copyright (c) 2017 Cisco Systems, Inc. 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.openflowplugin.applications.bulk.o.matic; import static org.mockito.Mockito.doReturn; -import com.google.common.util.concurrent.Futures; import java.util.concurrent.ExecutorService; import org.junit.Before; import org.junit.Test; @@ -18,22 +16,19 @@ import org.junit.runner.RunWith; import org.mockito.ArgumentMatchers; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.CommitInfo; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Test for {@link FlowWriterSequential}. */ @RunWith(MockitoJUnitRunner.class) public class TableWriterTest { - private static final Logger LOG = LoggerFactory.getLogger(TableWriterTest.class); - private static final int TABLES_PER_DPN = 100; private static final int DPN_COUNT = 1; private static final short START_TABLE_ID = 0; @@ -52,7 +47,7 @@ public class TableWriterTest { public void setUp() throws Exception { doReturn(writeTransaction).when(mockDataBroker).newWriteOnlyTransaction(); - Mockito.when(writeTransaction.submit()).thenReturn(Futures.immediateCheckedFuture(null)); + doReturn(CommitInfo.emptyFluentFuture()).when(writeTransaction).commit(); Mockito.doAnswer(invocation -> { ((Runnable) invocation.getArguments()[0]).run(); diff --git a/applications/forwardingrules-manager/pom.xml b/applications/forwardingrules-manager/pom.xml index df8f7abe35..0fca131cc3 100644 --- a/applications/forwardingrules-manager/pom.xml +++ b/applications/forwardingrules-manager/pom.xml @@ -21,8 +21,8 @@ true - org.opendaylight.controller - sal-binding-api + org.opendaylight.mdsal + mdsal-binding-api org.opendaylight.serviceutils @@ -41,10 +41,6 @@ org.opendaylight.yangtools yang-common - - org.opendaylight.controller - sal-common-util - org.opendaylight.mdsal mdsal-singleton-common-api @@ -74,13 +70,13 @@ test - org.opendaylight.controller - sal-binding-broker-impl + org.opendaylight.mdsal + mdsal-binding-dom-adapter test - org.opendaylight.controller - sal-binding-broker-impl + org.opendaylight.mdsal + mdsal-binding-dom-adapter test test-jar diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/FlowCapableNodeConnectorCommitter.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/FlowCapableNodeConnectorCommitter.java index b52e9bfd24..23d93e321b 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/FlowCapableNodeConnectorCommitter.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/FlowCapableNodeConnectorCommitter.java @@ -1,14 +1,13 @@ -/** +/* * Copyright (c) 2015 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.openflowplugin.applications.frm; -import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; +import org.opendaylight.mdsal.binding.api.DataTreeChangeListener; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/ForwardingRulesCommiter.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/ForwardingRulesCommiter.java index 967d3e48d8..0e37eaf5b7 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/ForwardingRulesCommiter.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/ForwardingRulesCommiter.java @@ -1,15 +1,14 @@ -/** +/* * Copyright (c) 2014 Cisco Systems, Inc. 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.openflowplugin.applications.frm; import java.util.concurrent.Future; -import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener; +import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/ForwardingRulesManager.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/ForwardingRulesManager.java index db7131f304..67242f46b0 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/ForwardingRulesManager.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/ForwardingRulesManager.java @@ -1,14 +1,13 @@ -/** +/* * Copyright (c) 2014, 2017 Cisco Systems, Inc. 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.openflowplugin.applications.frm; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; +import org.opendaylight.mdsal.binding.api.ReadTransaction; import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationListener; import org.opendaylight.openflowplugin.applications.frm.impl.DevicesGroupRegistry; import org.opendaylight.openflowplugin.applications.frm.impl.FlowNodeConnectorInventoryTranslatorImpl; @@ -70,7 +69,7 @@ public interface ForwardingRulesManager extends ConfigurationListener, AutoClose * * @return ReadOnlyTransaction */ - ReadOnlyTransaction getReadTransaction(); + ReadTransaction getReadTransaction(); /** * Flow RPC service. diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/AbstractListeningCommiter.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/AbstractListeningCommiter.java index 5d137465ae..de3be9103e 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/AbstractListeningCommiter.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/AbstractListeningCommiter.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the @@ -9,9 +9,9 @@ package org.opendaylight.openflowplugin.applications.frm.impl; import com.google.common.base.Preconditions; import java.util.Collection; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataObjectModification; +import org.opendaylight.mdsal.binding.api.DataTreeModification; import org.opendaylight.openflowplugin.applications.frm.ForwardingRulesCommiter; import org.opendaylight.openflowplugin.applications.frm.ForwardingRulesManager; import org.opendaylight.openflowplugin.applications.frm.NodeConfigurator; @@ -23,7 +23,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * AbstractChangeListner implemented basic {@link org.opendaylight.controller.md.sal.binding.api.DataTreeModification} + * AbstractChangeListner implemented basic {@link org.opendaylight.mdsal.binding.api.DataTreeModification} * processing for flow node subDataObject (flows, groups and meters). */ public abstract class AbstractListeningCommiter implements ForwardingRulesCommiter, diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/AbstractNodeConnectorCommitter.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/AbstractNodeConnectorCommitter.java index 6e642b6332..bbc910831b 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/AbstractNodeConnectorCommitter.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/AbstractNodeConnectorCommitter.java @@ -1,17 +1,16 @@ -/** +/* * Copyright (c) 2015 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.openflowplugin.applications.frm.impl; import com.google.common.base.Preconditions; import java.util.Collection; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.binding.api.DataObjectModification; +import org.opendaylight.mdsal.binding.api.DataTreeModification; import org.opendaylight.openflowplugin.applications.frm.FlowCapableNodeConnectorCommitter; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector; import org.opendaylight.yangtools.yang.binding.DataObject; diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/BundleFlowForwarder.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/BundleFlowForwarder.java index 2110297361..9fcc08440f 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/BundleFlowForwarder.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/BundleFlowForwarder.java @@ -5,7 +5,6 @@ * 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.openflowplugin.applications.frm.impl; import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.buildGroupInstanceIdentifier; @@ -14,7 +13,6 @@ import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getN import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.isFlowDependentOnGroup; import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.isGroupExistsOnDevice; -import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; @@ -24,11 +22,12 @@ import com.google.common.util.concurrent.SettableFuture; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Optional; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.infrautils.utils.concurrent.JdkFutures; +import org.opendaylight.mdsal.binding.api.ReadTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.applications.frm.ForwardingRulesManager; import org.opendaylight.openflowplugin.applications.frm.NodeConfigurator; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri; @@ -150,9 +149,8 @@ public class BundleFlowForwarder { LOG.trace("The dependent group {} isn't programmed yet. Pushing the group", groupId); InstanceIdentifier groupIdent = buildGroupInstanceIdentifier(nodeIdent, groupId); LOG.info("Reading the group from config inventory: {}", groupId); - try (ReadOnlyTransaction readTransaction = forwardingRulesManager.getReadTransaction()) { - Optional group = readTransaction - .read(LogicalDatastoreType.CONFIGURATION, groupIdent).get(); + try (ReadTransaction readTransaction = forwardingRulesManager.getReadTransaction()) { + Optional group = readTransaction.read(LogicalDatastoreType.CONFIGURATION, groupIdent).get(); if (group.isPresent()) { final AddGroupInputBuilder builder = new AddGroupInputBuilder(group.get()); builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class))); diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/DeviceMastership.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/DeviceMastership.java index 71f39e424e..cb88353e61 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/DeviceMastership.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/DeviceMastership.java @@ -8,18 +8,21 @@ package org.opendaylight.openflowplugin.applications.frm.impl; +import com.google.common.collect.ImmutableSet; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import java.util.concurrent.atomic.AtomicBoolean; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; +import org.eclipse.jdt.annotation.NonNull; +import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService; import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.frm.reconciliation.service.rev180227.FrmReconciliationService; +import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.slf4j.Logger; @@ -36,15 +39,15 @@ public class DeviceMastership implements ClusterSingletonService, AutoCloseable private final AtomicBoolean isDeviceInOperDS = new AtomicBoolean(false); private final InstanceIdentifier fcnIID; private final KeyedInstanceIdentifier path; - private final RoutedRpcRegistration routedRpcReg; - public DeviceMastership(final NodeId nodeId, final RoutedRpcRegistration routedRpcReg) { + private ObjectRegistration<@NonNull FrmReconciliationService> reg; + + public DeviceMastership(final NodeId nodeId) { this.nodeId = nodeId; this.identifier = ServiceGroupIdentifier.create(nodeId.getValue()); fcnIID = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(nodeId)) .augmentation(FlowCapableNode.class); path = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(nodeId)); - this.routedRpcReg = routedRpcReg; } @Override @@ -73,7 +76,7 @@ public class DeviceMastership implements ClusterSingletonService, AutoCloseable return deviceMastered.get(); } - public void setDeviceOperationalStatus(boolean inOperDS) { + public void setDeviceOperationalStatus(final boolean inOperDS) { isDeviceInOperDS.set(inOperDS); } @@ -81,13 +84,24 @@ public class DeviceMastership implements ClusterSingletonService, AutoCloseable deviceMastered.set(true); } - public void registerReconciliationRpc() { - LOG.debug("The path is registered : {}", path); - routedRpcReg.registerPath(NodeContext.class, path); + public void registerReconciliationRpc(final RpcProviderService rpcProviderService, + final FrmReconciliationService reconcliationService) { + if (reg == null) { + LOG.debug("The path is registered : {}", path); + reg = rpcProviderService.registerRpcImplementation(FrmReconciliationService.class, reconcliationService, + ImmutableSet.of(path)); + } else { + LOG.debug("The path is already registered : {}", path); + } } public void deregisterReconciliationRpc() { - LOG.debug("The path is unregistered : {}", path); - routedRpcReg.unregisterPath(NodeContext.class, path); + if (reg != null) { + reg.close(); + reg = null; + LOG.debug("The path is unregistered : {}", path); + } else { + LOG.debug("The path is already unregistered : {}", path); + } } } diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/DeviceMastershipManager.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/DeviceMastershipManager.java index 6ec636b773..d7fd461d46 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/DeviceMastershipManager.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/DeviceMastershipManager.java @@ -1,11 +1,10 @@ -/** +/* * Copyright (c) 2016, 2017 Pantheon Technologies 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.openflowplugin.applications.frm.impl; import com.google.common.annotations.VisibleForTesting; @@ -17,13 +16,13 @@ import java.util.Collections; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import javax.annotation.Nonnull; -import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; +import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataObjectModification; +import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.binding.api.RpcProviderService; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeRegistration; @@ -36,6 +35,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.frm.reconciliation.service.rev180227.FrmReconciliationService; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; @@ -53,19 +53,25 @@ public class DeviceMastershipManager implements ClusteredDataTreeChangeListener< private final ClusterSingletonServiceProvider clusterSingletonService; private final FlowNodeReconciliation reconcliationAgent; private final DataBroker dataBroker; - private final ConcurrentHashMap deviceMasterships = new ConcurrentHashMap(); + private final ConcurrentHashMap deviceMasterships = new ConcurrentHashMap<>(); private final Object lockObj = new Object(); + private final RpcProviderService rpcProviderService; + private final FrmReconciliationService reconcliationService; + private ListenerRegistration listenerRegistration; private Set> activeNodes = Collections.emptySet(); - private RoutedRpcRegistration routedRpcReg; private MastershipChangeRegistration mastershipChangeServiceRegistration; public DeviceMastershipManager(final ClusterSingletonServiceProvider clusterSingletonService, final FlowNodeReconciliation reconcliationAgent, final DataBroker dataBroker, - final MastershipChangeServiceManager mastershipChangeServiceManager) { + final MastershipChangeServiceManager mastershipChangeServiceManager, + final RpcProviderService rpcProviderService, + final FrmReconciliationService reconciliationService) { this.clusterSingletonService = clusterSingletonService; this.reconcliationAgent = reconcliationAgent; + this.rpcProviderService = rpcProviderService; + this.reconcliationService = reconciliationService; this.dataBroker = dataBroker; registerNodeListener(); this.mastershipChangeServiceRegistration = mastershipChangeServiceManager.register(this); @@ -88,7 +94,7 @@ public class DeviceMastershipManager implements ClusteredDataTreeChangeListener< } @Override - public void onDataTreeChanged(@Nonnull Collection> changes) { + public void onDataTreeChanged(@Nonnull final Collection> changes) { Preconditions.checkNotNull(changes, "Changes may not be null!"); for (DataTreeModification change : changes) { @@ -116,8 +122,8 @@ public class DeviceMastershipManager implements ClusteredDataTreeChangeListener< } } - public void remove(InstanceIdentifier identifier, FlowCapableNode del, - InstanceIdentifier nodeIdent) { + public void remove(final InstanceIdentifier identifier, final FlowCapableNode del, + final InstanceIdentifier nodeIdent) { if (compareInstanceIdentifierTail(identifier, II_TO_FLOW_CAPABLE_NODE)) { if (LOG.isDebugEnabled()) { LOG.debug("Node removed: {}", nodeIdent.firstKeyOf(Node.class).getId().getValue()); @@ -136,8 +142,8 @@ public class DeviceMastershipManager implements ClusteredDataTreeChangeListener< } } - public void add(InstanceIdentifier identifier, FlowCapableNode add, - InstanceIdentifier nodeIdent) { + public void add(final InstanceIdentifier identifier, final FlowCapableNode add, + final InstanceIdentifier nodeIdent) { if (compareInstanceIdentifierTail(identifier, II_TO_FLOW_CAPABLE_NODE)) { if (LOG.isDebugEnabled()) { LOG.debug("Node added: {}", nodeIdent.firstKeyOf(Node.class).getId().getValue()); @@ -168,13 +174,13 @@ public class DeviceMastershipManager implements ClusteredDataTreeChangeListener< } } - private boolean compareInstanceIdentifierTail(InstanceIdentifier identifier1, - InstanceIdentifier identifier2) { + private boolean compareInstanceIdentifierTail(final InstanceIdentifier identifier1, + final InstanceIdentifier identifier2) { return Iterables.getLast(identifier1.getPathArguments()) .equals(Iterables.getLast(identifier2.getPathArguments())); } - private void setNodeOperationalStatus(InstanceIdentifier nodeIid, boolean status) { + private void setNodeOperationalStatus(final InstanceIdentifier nodeIid, final boolean status) { NodeId nodeId = nodeIid.firstKeyOf(Node.class).getId(); if (nodeId != null && deviceMasterships.containsKey(nodeId)) { deviceMasterships.get(nodeId).setDeviceOperationalStatus(status); @@ -182,17 +188,13 @@ public class DeviceMastershipManager implements ClusteredDataTreeChangeListener< } } - public void setRoutedRpcReg(RoutedRpcRegistration routedRpcReg) { - this.routedRpcReg = routedRpcReg; - } - @SuppressWarnings("IllegalCatch") private void registerNodeListener() { final InstanceIdentifier flowNodeWildCardIdentifier = InstanceIdentifier.create(Nodes.class) .child(Node.class).augmentation(FlowCapableNode.class); - final DataTreeIdentifier treeId = new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, + final DataTreeIdentifier treeId = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, flowNodeWildCardIdentifier); try { @@ -212,13 +214,13 @@ public class DeviceMastershipManager implements ClusteredDataTreeChangeListener< public void onBecomeOwner(@Nonnull final DeviceInfo deviceInfo) { LOG.debug("Mastership role notification received for device : {}", deviceInfo.getDatapathId()); DeviceMastership membership = deviceMasterships.computeIfAbsent(deviceInfo.getNodeId(), - device -> new DeviceMastership(deviceInfo.getNodeId(), routedRpcReg)); + device -> new DeviceMastership(deviceInfo.getNodeId())); membership.reconcile(); - membership.registerReconciliationRpc(); + membership.registerReconciliationRpc(rpcProviderService, reconcliationService); } @Override - public void onLoseOwnership(@Nonnull DeviceInfo deviceInfo) { + public void onLoseOwnership(@Nonnull final DeviceInfo deviceInfo) { final DeviceMastership mastership = deviceMasterships.remove(deviceInfo.getNodeId()); if (mastership != null) { mastership.deregisterReconciliationRpc(); diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowForwarder.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowForwarder.java index 58ccf15600..170fa5551c 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowForwarder.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowForwarder.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the @@ -14,21 +14,22 @@ import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getN import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.isFlowDependentOnGroup; import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.isGroupExistsOnDevice; -import com.google.common.base.Optional; import com.google.common.base.Preconditions; +import com.google.common.util.concurrent.FluentFuture; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.SettableFuture; +import java.util.Optional; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.infrautils.utils.concurrent.JdkFutures; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; +import org.opendaylight.mdsal.binding.api.ReadTransaction; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.applications.frm.ForwardingRulesManager; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; @@ -71,10 +72,10 @@ import org.slf4j.LoggerFactory; /** * FlowForwarder It implements - * {@link org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener} + * {@link org.opendaylight.mdsal.binding.api.DataTreeChangeListener} * for WildCardedPath to {@link Flow} and ForwardingRulesCommiter interface for * methods: add, update and remove {@link Flow} processing for - * {@link org.opendaylight.controller.md.sal.binding.api.DataTreeModification}. + * {@link org.opendaylight.mdsal.binding.api.DataTreeModification}. */ public class FlowForwarder extends AbstractListeningCommiter { @@ -93,7 +94,7 @@ public class FlowForwarder extends AbstractListeningCommiter { @Override @SuppressWarnings("IllegalCatch") public void registerListener() { - final DataTreeIdentifier treeId = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, + final DataTreeIdentifier treeId = DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, getWildCardPath()); try { listenerRegistration = dataBroker.registerDataTreeChangeListener(treeId, FlowForwarder.this); @@ -304,14 +305,14 @@ public class FlowForwarder extends AbstractListeningCommiter { writeTransaction.put(LogicalDatastoreType.CONFIGURATION, getStaleFlowInstanceIdentifier(staleFlow, nodeIdent), staleFlow, false); - ListenableFuture submitFuture = writeTransaction.submit(); + FluentFuture submitFuture = writeTransaction.commit(); handleStaleFlowResultFuture(submitFuture); } - private void handleStaleFlowResultFuture(ListenableFuture submitFuture) { - Futures.addCallback(submitFuture, new FutureCallback() { + private void handleStaleFlowResultFuture(FluentFuture submitFuture) { + submitFuture.addCallback(new FutureCallback() { @Override - public void onSuccess(Void result) { + public void onSuccess(Object result) { LOG.debug("Stale Flow creation success"); } @@ -341,7 +342,7 @@ public class FlowForwarder extends AbstractListeningCommiter { InstanceIdentifier groupIdent = buildGroupInstanceIdentifier(nodeIdent, groupId); ListenableFuture> resultFuture; LOG.info("Reading the group from config inventory: {}", groupId); - try (ReadOnlyTransaction readTransaction = provider.getReadTransaction()) { + try (ReadTransaction readTransaction = provider.getReadTransaction()) { Optional group = readTransaction.read(LogicalDatastoreType.CONFIGURATION, groupIdent).get(); if (group.isPresent()) { final AddGroupInputBuilder builder = new AddGroupInputBuilder(group.get()); diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeConnectorInventoryTranslatorImpl.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeConnectorInventoryTranslatorImpl.java index 811fdfc367..1a4f15bf53 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeConnectorInventoryTranslatorImpl.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeConnectorInventoryTranslatorImpl.java @@ -1,11 +1,10 @@ -/** +/* * Copyright (c) 2015, 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.openflowplugin.applications.frm.impl; import com.google.common.base.Preconditions; @@ -14,9 +13,9 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Multimap; import com.google.common.collect.Multimaps; import java.math.BigInteger; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.applications.frm.FlowNodeConnectorInventoryTranslator; import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector; @@ -52,7 +51,7 @@ public class FlowNodeConnectorInventoryTranslatorImpl extends AbstractNodeConnec Preconditions.checkNotNull(dataBroker, "DataBroker can not be null!"); final DataTreeIdentifier treeId = - new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, getWildCardPath()); + DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, getWildCardPath()); try { SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(ForwardingRulesManagerImpl.STARTUP_LOOP_TICK, ForwardingRulesManagerImpl.STARTUP_LOOP_MAX_RETRIES); diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeReconciliationImpl.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeReconciliationImpl.java index bde8214ca8..9366b2c58e 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeReconciliationImpl.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeReconciliationImpl.java @@ -1,16 +1,15 @@ -/** +/* * Copyright (c) 2014, 2017 Cisco Systems, Inc. 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.openflowplugin.applications.frm.impl; -import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; +import com.google.common.util.concurrent.FluentFuture; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.JdkFutureAdapters; @@ -24,6 +23,7 @@ import java.util.HashMap; import java.util.List; import java.util.ListIterator; import java.util.Map; +import java.util.Optional; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; @@ -31,10 +31,10 @@ import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicLong; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.ReadTransaction; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.OFConstants; import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; import org.opendaylight.openflowplugin.applications.frm.FlowNodeReconciliation; @@ -176,11 +176,11 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation { @Override public Boolean call() { String node = nodeIdentity.firstKeyOf(Node.class).getId().getValue(); - Optional flowNode = Optional.absent(); + Optional flowNode = Optional.empty(); BundleId bundleIdValue = new BundleId(BUNDLE_ID.getAndIncrement()); BigInteger dpnId = getDpnIdFromNodeName(node); LOG.info("Triggering bundle based reconciliation for device : {}", dpnId); - try (ReadOnlyTransaction trans = provider.getReadTransaction()) { + try (ReadTransaction trans = provider.getReadTransaction()) { flowNode = trans.read(LogicalDatastoreType.CONFIGURATION, nodeIdentity).get(); } catch (ExecutionException | InterruptedException e) { LOG.error("Error occurred while reading the configuration data store for node {}", nodeIdentity, e); @@ -313,7 +313,7 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation { Optional flowNode; // initialize the counter int counter = 0; - try (ReadOnlyTransaction trans = provider.getReadTransaction()) { + try (ReadTransaction trans = provider.getReadTransaction()) { flowNode = trans.read(LogicalDatastoreType.CONFIGURATION, nodeIdentity).get(); } catch (ExecutionException | InterruptedException e) { LOG.warn("Fail with read Config/DS for Node {} !", nodeIdentity, e); @@ -544,9 +544,9 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation { List> staleGroupsToBeBulkDeleted = Lists.newArrayList(); List> staleMetersToBeBulkDeleted = Lists.newArrayList(); - Optional flowNode = Optional.absent(); + Optional flowNode = Optional.empty(); - try (ReadOnlyTransaction trans = provider.getReadTransaction()) { + try (ReadTransaction trans = provider.getReadTransaction()) { flowNode = trans.read(LogicalDatastoreType.CONFIGURATION, nodeIdent).get(); } catch (ExecutionException | InterruptedException e) { LOG.warn("Reconciliation Pre-Processing Fail with read Config/DS for Node {} !", nodeIdent, e); @@ -637,7 +637,7 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation { writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, staleFlowIId); } - ListenableFuture submitFuture = writeTransaction.submit(); + FluentFuture submitFuture = writeTransaction.commit(); handleStaleEntityDeletionResultFuture(submitFuture); } @@ -648,7 +648,7 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation { writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, staleGroupIId); } - ListenableFuture submitFuture = writeTransaction.submit(); + FluentFuture submitFuture = writeTransaction.commit(); handleStaleEntityDeletionResultFuture(submitFuture); } @@ -659,7 +659,7 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation { writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, staleMeterIId); } - ListenableFuture submitFuture = writeTransaction.submit(); + FluentFuture submitFuture = writeTransaction.commit(); handleStaleEntityDeletionResultFuture(submitFuture); } @@ -683,10 +683,10 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation { return nodeIdent.child(StaleMeter.class, new StaleMeterKey(new MeterId(staleMeter.getMeterId()))); } - private void handleStaleEntityDeletionResultFuture(ListenableFuture submitFuture) { - Futures.addCallback(submitFuture, new FutureCallback() { + private void handleStaleEntityDeletionResultFuture(FluentFuture submitFuture) { + submitFuture.addCallback(new FutureCallback() { @Override - public void onSuccess(Void result) { + public void onSuccess(Object result) { LOG.debug("Stale entity removal success"); } diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/ForwardingRulesManagerImpl.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/ForwardingRulesManagerImpl.java index 361b6e9715..b243df5379 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/ForwardingRulesManagerImpl.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/ForwardingRulesManagerImpl.java @@ -1,11 +1,10 @@ -/** +/* * Copyright (c) 2014, 2017 Cisco Systems, Inc. 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.openflowplugin.applications.frm.impl; import com.google.common.annotations.VisibleForTesting; @@ -21,10 +20,11 @@ import javax.annotation.PreDestroy; import javax.inject.Inject; import javax.inject.Singleton; import org.apache.aries.blueprint.annotation.service.Reference; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.ReadTransaction; +import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry; +import org.opendaylight.mdsal.binding.api.RpcProviderService; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService; import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeServiceManager; @@ -50,7 +50,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.Sal import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.SalBundleService; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.arbitrator.reconcile.service.rev180227.ArbitratorReconcileService; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.forwardingrules.manager.config.rev160511.ForwardingRulesManagerConfig; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.frm.reconciliation.service.rev180227.FrmReconciliationService; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.rf.state.rev170713.ResultState; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures; @@ -85,7 +84,7 @@ public class ForwardingRulesManagerImpl implements ForwardingRulesManager { private final SalBundleService salBundleService; private final AutoCloseable configurationServiceRegistration; private final MastershipChangeServiceManager mastershipChangeServiceManager; - private final RpcProviderRegistry rpcRegistry; + private final RpcProviderService rpcProviderService; private ForwardingRulesCommiter flowListener; private ForwardingRulesCommiter groupListener; private ForwardingRulesCommiter meterListener; @@ -97,7 +96,7 @@ public class ForwardingRulesManagerImpl implements ForwardingRulesManager { private final ReconciliationManager reconciliationManager; private DevicesGroupRegistry devicesGroupRegistry; private NodeConfigurator nodeConfigurator; - private ArbitratorReconcileService arbitratorReconciliationManager; + private final ArbitratorReconcileService arbitratorReconciliationManager; private boolean disableReconciliation; private boolean staleMarkingEnabled; private int reconciliationRetryCount; @@ -107,7 +106,8 @@ public class ForwardingRulesManagerImpl implements ForwardingRulesManager { @Inject public ForwardingRulesManagerImpl(@Reference final DataBroker dataBroker, - @Reference final RpcProviderRegistry rpcRegistry, + @Reference final RpcConsumerRegistry rpcRegistry, + @Reference final RpcProviderService rpcProviderService, final ForwardingRulesManagerConfig config, @Reference final MastershipChangeServiceManager mastershipChangeServiceManager, @Reference final ClusterSingletonServiceProvider clusterSingletonService, @@ -124,7 +124,7 @@ public class ForwardingRulesManagerImpl implements ForwardingRulesManager { this.clusterSingletonServiceProvider = Preconditions.checkNotNull(clusterSingletonService, "ClusterSingletonService provider can not be null"); this.reconciliationManager = reconciliationManager; - this.rpcRegistry = rpcRegistry; + this.rpcProviderService = rpcProviderService; this.mastershipChangeServiceManager = mastershipChangeServiceManager; Preconditions.checkArgument(rpcRegistry != null, "RpcProviderRegistry can not be null !"); @@ -163,9 +163,8 @@ public class ForwardingRulesManagerImpl implements ForwardingRulesManager { LOG.debug("Reconciliation is enabled by user and successfully registered to the reconciliation framework"); } this.deviceMastershipManager = new DeviceMastershipManager(clusterSingletonServiceProvider, this.nodeListener, - dataService, mastershipChangeServiceManager); - this.deviceMastershipManager.setRoutedRpcReg(rpcRegistry.addRoutedRpcImplementation( - FrmReconciliationService.class, new FrmReconciliationServiceImpl(this))); + dataService, mastershipChangeServiceManager, rpcProviderService, + new FrmReconciliationServiceImpl(this)); flowNodeConnectorInventoryTranslatorImpl = new FlowNodeConnectorInventoryTranslatorImpl(dataService); this.flowListener = new FlowForwarder(this, dataService); @@ -210,7 +209,7 @@ public class ForwardingRulesManagerImpl implements ForwardingRulesManager { } @Override - public ReadOnlyTransaction getReadTransaction() { + public ReadTransaction getReadTransaction() { return dataService.newReadOnlyTransaction(); } @@ -220,18 +219,18 @@ public class ForwardingRulesManagerImpl implements ForwardingRulesManager { } @Override - public boolean isNodeActive(InstanceIdentifier ident) { + public boolean isNodeActive(final InstanceIdentifier ident) { return deviceMastershipManager.isNodeActive(ident.firstKeyOf(Node.class).getId()); } @Override - public boolean checkNodeInOperationalDataStore(InstanceIdentifier ident) { + public boolean checkNodeInOperationalDataStore(final InstanceIdentifier ident) { boolean result = false; InstanceIdentifier nodeIid = ident.firstIdentifierOf(Node.class); - try (ReadOnlyTransaction transaction = dataService.newReadOnlyTransaction()) { - ListenableFuture> future = transaction + try (ReadTransaction transaction = dataService.newReadOnlyTransaction()) { + ListenableFuture> future = transaction .read(LogicalDatastoreType.OPERATIONAL, nodeIid); - com.google.common.base.Optional optionalDataObject = future.get(); + Optional optionalDataObject = future.get(); if (optionalDataObject.isPresent()) { result = true; } else { @@ -315,7 +314,7 @@ public class ForwardingRulesManagerImpl implements ForwardingRulesManager { } @Override - public void addRecoverableListener(RecoverableListener recoverableListener) { + public void addRecoverableListener(final RecoverableListener recoverableListener) { serviceRecoveryRegistry.addRecoverableListener(openflowServiceRecoveryHandler.buildServiceRegistryKey(), recoverableListener); } @@ -340,7 +339,7 @@ public class ForwardingRulesManagerImpl implements ForwardingRulesManager { } @Override - public boolean isNodeOwner(InstanceIdentifier ident) { + public boolean isNodeOwner(final InstanceIdentifier ident) { return Objects.nonNull(ident) && deviceMastershipManager.isDeviceMastered(ident.firstKeyOf(Node.class).getId()); } diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/GroupForwarder.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/GroupForwarder.java index 0553c45cb4..e2ec86f67b 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/GroupForwarder.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/GroupForwarder.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the @@ -10,16 +10,17 @@ package org.opendaylight.openflowplugin.applications.frm.impl; import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getActiveBundle; import static org.opendaylight.openflowplugin.applications.frm.util.FrmUtil.getNodeIdFromNodeIdentifier; +import com.google.common.util.concurrent.FluentFuture; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import java.util.concurrent.Future; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.infrautils.utils.concurrent.JdkFutures; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.applications.frm.ForwardingRulesManager; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; @@ -52,10 +53,10 @@ import org.slf4j.LoggerFactory; /** * GroupForwarder It implements - * {@link org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener} + * {@link org.opendaylight.mdsal.binding.api.DataTreeChangeListener} * for WildCardedPath to {@link Group} and ForwardingRulesCommiter interface for * methods: add, update and remove {@link Group} processing for - * {@link org.opendaylight.controller.md.sal.binding.api.DataTreeModification}. + * {@link org.opendaylight.mdsal.binding.api.DataTreeModification}. */ public class GroupForwarder extends AbstractListeningCommiter { @@ -71,7 +72,7 @@ public class GroupForwarder extends AbstractListeningCommiter { @SuppressWarnings("IllegalCatch") @Override public void registerListener() { - final DataTreeIdentifier treeId = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, + final DataTreeIdentifier treeId = DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, getWildCardPath()); try { @@ -215,14 +216,14 @@ public class GroupForwarder extends AbstractListeningCommiter { writeTransaction.put(LogicalDatastoreType.CONFIGURATION, getStaleGroupInstanceIdentifier(staleGroup, nodeIdent), staleGroup, false); - ListenableFuture submitFuture = writeTransaction.submit(); + FluentFuture submitFuture = writeTransaction.commit(); handleStaleGroupResultFuture(submitFuture); } - private void handleStaleGroupResultFuture(ListenableFuture submitFuture) { - Futures.addCallback(submitFuture, new FutureCallback() { + private void handleStaleGroupResultFuture(FluentFuture submitFuture) { + submitFuture.addCallback(new FutureCallback() { @Override - public void onSuccess(Void result) { + public void onSuccess(Object result) { LOG.debug("Stale Group creation success"); } diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/MeterForwarder.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/MeterForwarder.java index 880508ac08..f4675947ca 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/MeterForwarder.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/MeterForwarder.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the @@ -7,16 +7,15 @@ */ package org.opendaylight.openflowplugin.applications.frm.impl; +import com.google.common.util.concurrent.FluentFuture; import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import java.util.concurrent.Future; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.infrautils.utils.concurrent.JdkFutures; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.applications.frm.ForwardingRulesManager; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; @@ -45,10 +44,10 @@ import org.slf4j.LoggerFactory; /** * MeterForwarder It implements - * {@link org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener} + * {@link org.opendaylight.mdsal.binding.api.DataTreeChangeListener} * for WildCardedPath to {@link Meter} and ForwardingRulesCommiter interface for * methods: add, update and remove {@link Meter} processing for - * {@link org.opendaylight.controller.md.sal.binding.api.DataTreeModification}. + * {@link org.opendaylight.mdsal.binding.api.DataTreeModification}. * */ public class MeterForwarder extends AbstractListeningCommiter { @@ -63,7 +62,7 @@ public class MeterForwarder extends AbstractListeningCommiter { @SuppressWarnings("IllegalCatch") @Override public void registerListener() { - final DataTreeIdentifier treeId = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, + final DataTreeIdentifier treeId = DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, getWildCardPath()); try { @@ -168,14 +167,14 @@ public class MeterForwarder extends AbstractListeningCommiter { writeTransaction.put(LogicalDatastoreType.CONFIGURATION, getStaleMeterInstanceIdentifier(staleMeter, nodeIdent), staleMeter, false); - ListenableFuture submitFuture = writeTransaction.submit(); + FluentFuture submitFuture = writeTransaction.commit(); handleStaleMeterResultFuture(submitFuture); } - private void handleStaleMeterResultFuture(ListenableFuture submitFuture) { - Futures.addCallback(submitFuture, new FutureCallback() { + private void handleStaleMeterResultFuture(FluentFuture submitFuture) { + submitFuture.addCallback(new FutureCallback() { @Override - public void onSuccess(Void result) { + public void onSuccess(Object result) { LOG.debug("Stale Meter creation success"); } diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/TableForwarder.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/TableForwarder.java index 146b0d8535..79e17883d9 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/TableForwarder.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/TableForwarder.java @@ -5,16 +5,15 @@ * 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.openflowplugin.applications.frm.impl; import com.google.common.util.concurrent.Futures; import java.util.Collections; import java.util.concurrent.Future; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.infrautils.utils.concurrent.JdkFutures; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.applications.frm.ForwardingRulesManager; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; @@ -45,7 +44,7 @@ public class TableForwarder extends AbstractListeningCommiter { @SuppressWarnings("IllegalCatch") @Override public void registerListener() { - final DataTreeIdentifier treeId = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, + final DataTreeIdentifier treeId = DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, getWildCardPath()); try { diff --git a/applications/forwardingrules-manager/src/test/java/org/opendaylight/openflowplugin/applications/frm/impl/DeviceMastershipManagerTest.java b/applications/forwardingrules-manager/src/test/java/org/opendaylight/openflowplugin/applications/frm/impl/DeviceMastershipManagerTest.java index 55de43760c..701b9f270b 100644 --- a/applications/forwardingrules-manager/src/test/java/org/opendaylight/openflowplugin/applications/frm/impl/DeviceMastershipManagerTest.java +++ b/applications/forwardingrules-manager/src/test/java/org/opendaylight/openflowplugin/applications/frm/impl/DeviceMastershipManagerTest.java @@ -1,11 +1,10 @@ -/** +/* * Copyright (c) 2016, 2017 Pantheon Technologies 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.openflowplugin.applications.frm.impl; import org.junit.Assert; @@ -15,9 +14,9 @@ import org.junit.runner.RunWith; import org.mockito.ArgumentMatchers; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration; @@ -25,6 +24,7 @@ import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeServiceManager; import org.opendaylight.openflowplugin.applications.frm.FlowNodeReconciliation; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.frm.reconciliation.service.rev180227.FrmReconciliationService; /** * Test for {@link DeviceMastershipManager}. @@ -41,19 +41,20 @@ public class DeviceMastershipManagerTest { @Mock private DataBroker dataBroker; @Mock - private RoutedRpcRegistration routedRpcReg; - @Mock private MastershipChangeServiceManager mastershipChangeServiceManager; @Mock private DeviceInfo deviceInfo; @Mock private NodeId nodeId; + @Mock + private RpcProviderService rpcProviderService; + @Mock + private FrmReconciliationService reconciliationService; @Before public void setUp() throws Exception { deviceMastershipManager = new DeviceMastershipManager(clusterSingletonService, reconciliationAgent, dataBroker, - mastershipChangeServiceManager); - deviceMastershipManager.setRoutedRpcReg(routedRpcReg); + mastershipChangeServiceManager, rpcProviderService, reconciliationService); Mockito.lenient().when(clusterSingletonService .registerClusterSingletonService(ArgumentMatchers.any())) .thenReturn(registration); diff --git a/applications/forwardingrules-manager/src/test/java/org/opendaylight/openflowplugin/applications/frm/impl/DeviceMastershipTest.java b/applications/forwardingrules-manager/src/test/java/org/opendaylight/openflowplugin/applications/frm/impl/DeviceMastershipTest.java index b4df924249..b92fa18bcb 100644 --- a/applications/forwardingrules-manager/src/test/java/org/opendaylight/openflowplugin/applications/frm/impl/DeviceMastershipTest.java +++ b/applications/forwardingrules-manager/src/test/java/org/opendaylight/openflowplugin/applications/frm/impl/DeviceMastershipTest.java @@ -1,20 +1,17 @@ -/** +/* * Copyright (c) 2016, 2017 Pantheon Technologies 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.openflowplugin.applications.frm.impl; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; +import org.mockito.junit.MockitoJUnitRunner; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; /** @@ -24,12 +21,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; public class DeviceMastershipTest { private static final NodeId NODE_ID = new NodeId("testNode"); private DeviceMastership deviceMastership; - @Mock - private RoutedRpcRegistration routedRpcRegistration; @Before public void setUp() throws Exception { - deviceMastership = new DeviceMastership(NODE_ID, routedRpcRegistration); + deviceMastership = new DeviceMastership(NODE_ID); } @Test diff --git a/applications/forwardingrules-manager/src/test/java/test/mock/FlowListenerTest.java b/applications/forwardingrules-manager/src/test/java/test/mock/FlowListenerTest.java index 1bfebd1da2..ccf8c8810f 100644 --- a/applications/forwardingrules-manager/src/test/java/test/mock/FlowListenerTest.java +++ b/applications/forwardingrules-manager/src/test/java/test/mock/FlowListenerTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the @@ -13,17 +13,15 @@ import static org.junit.Assert.assertEquals; import java.util.Collections; import java.util.List; - import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeServiceManager; import org.opendaylight.openflowplugin.applications.frm.impl.DeviceMastershipManager; @@ -64,7 +62,7 @@ public class FlowListenerTest extends FRMTest { private ForwardingRulesManagerImpl forwardingRulesManager; private static final NodeId NODE_ID = new NodeId("testnode:1"); private static final NodeKey NODE_KEY = new NodeKey(NODE_ID); - RpcProviderRegistry rpcProviderRegistryMock = new RpcProviderRegistryMock(); + RpcProviderRegistryMock rpcProviderRegistryMock = new RpcProviderRegistryMock(); TableKey tableKey = new TableKey((short) 2); @Mock ClusterSingletonServiceProvider clusterSingletonService; @@ -81,9 +79,10 @@ public class FlowListenerTest extends FRMTest { @Before public void setUp() { - forwardingRulesManager = new ForwardingRulesManagerImpl(getDataBroker(), rpcProviderRegistryMock, getConfig(), - mastershipChangeServiceManager, clusterSingletonService, getConfigurationService(), - reconciliationManager, openflowServiceRecoveryHandler, serviceRecoveryRegistry); + forwardingRulesManager = new ForwardingRulesManagerImpl(getDataBroker(), rpcProviderRegistryMock, + rpcProviderRegistryMock, getConfig(), mastershipChangeServiceManager, clusterSingletonService, + getConfigurationService(), reconciliationManager, openflowServiceRecoveryHandler, + serviceRecoveryRegistry); forwardingRulesManager.start(); // TODO consider tests rewrite (added because of complicated access) @@ -106,7 +105,7 @@ public class FlowListenerTest extends FRMTest { WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, tableII, table); writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow); - assertCommit(writeTx.submit()); + assertCommit(writeTx.commit()); SalFlowServiceMock salFlowService = (SalFlowServiceMock) forwardingRulesManager.getSalFlowService(); await().until(listSize(salFlowService.getAddFlowCalls()), equalTo(1)); List addFlowCalls = salFlowService.getAddFlowCalls(); @@ -119,7 +118,7 @@ public class FlowListenerTest extends FRMTest { flow = new FlowBuilder().withKey(flowKey).setTableId((short) 2).build(); writeTx = getDataBroker().newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow); - assertCommit(writeTx.submit()); + assertCommit(writeTx.commit()); salFlowService = (SalFlowServiceMock) forwardingRulesManager.getSalFlowService(); await().until(listSize(salFlowService.getAddFlowCalls()), equalTo(2)); addFlowCalls = salFlowService.getAddFlowCalls(); @@ -144,7 +143,7 @@ public class FlowListenerTest extends FRMTest { WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, tableII, table); writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow); - assertCommit(writeTx.submit()); + assertCommit(writeTx.commit()); SalFlowServiceMock salFlowService = (SalFlowServiceMock) forwardingRulesManager.getSalFlowService(); await().until(listSize(salFlowService.getAddFlowCalls()), equalTo(1)); @@ -158,7 +157,7 @@ public class FlowListenerTest extends FRMTest { flow = new FlowBuilder().withKey(flowKey).setTableId((short) 2).setOutGroup((long) 5).build(); writeTx = getDataBroker().newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow); - assertCommit(writeTx.submit()); + assertCommit(writeTx.commit()); salFlowService = (SalFlowServiceMock) forwardingRulesManager.getSalFlowService(); await().until(listSize(salFlowService.getUpdateFlowCalls()), equalTo(1)); List updateFlowCalls = salFlowService.getUpdateFlowCalls(); @@ -186,7 +185,7 @@ public class FlowListenerTest extends FRMTest { WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, tableII, table); writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow); - assertCommit(writeTx.submit()); + assertCommit(writeTx.commit()); SalFlowServiceMock salFlowService = (SalFlowServiceMock) forwardingRulesManager.getSalFlowService(); await().until(listSize(salFlowService.getAddFlowCalls()), equalTo(1)); List addFlowCalls = salFlowService.getAddFlowCalls(); @@ -201,7 +200,7 @@ public class FlowListenerTest extends FRMTest { flow = new FlowBuilder().setMatch(match).withKey(flowKey).setTableId((short) 2).build(); writeTx = getDataBroker().newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow); - assertCommit(writeTx.submit()); + assertCommit(writeTx.commit()); salFlowService = (SalFlowServiceMock) forwardingRulesManager.getSalFlowService(); await().until(listSize(salFlowService.getUpdateFlowCalls()), equalTo(1)); List updateFlowCalls = salFlowService.getUpdateFlowCalls(); @@ -226,7 +225,7 @@ public class FlowListenerTest extends FRMTest { WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, tableII, table); writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow); - assertCommit(writeTx.submit()); + assertCommit(writeTx.commit()); SalFlowServiceMock salFlowService = (SalFlowServiceMock) forwardingRulesManager.getSalFlowService(); await().until(listSize(salFlowService.getAddFlowCalls()), equalTo(1)); List addFlowCalls = salFlowService.getAddFlowCalls(); @@ -235,7 +234,7 @@ public class FlowListenerTest extends FRMTest { writeTx = getDataBroker().newWriteOnlyTransaction(); writeTx.delete(LogicalDatastoreType.CONFIGURATION, flowII); - assertCommit(writeTx.submit()); + assertCommit(writeTx.commit()); salFlowService = (SalFlowServiceMock) forwardingRulesManager.getSalFlowService(); await().until(listSize(salFlowService.getRemoveFlowCalls()), equalTo(1)); List removeFlowCalls = salFlowService.getRemoveFlowCalls(); @@ -261,7 +260,7 @@ public class FlowListenerTest extends FRMTest { WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, tableII, table); writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow); - assertCommit(writeTx.submit()); + assertCommit(writeTx.commit()); } @After diff --git a/applications/forwardingrules-manager/src/test/java/test/mock/GroupListenerTest.java b/applications/forwardingrules-manager/src/test/java/test/mock/GroupListenerTest.java index 4b6d5bce52..de3076fd42 100644 --- a/applications/forwardingrules-manager/src/test/java/test/mock/GroupListenerTest.java +++ b/applications/forwardingrules-manager/src/test/java/test/mock/GroupListenerTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the @@ -18,10 +18,9 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeServiceManager; import org.opendaylight.openflowplugin.applications.frm.impl.DeviceMastershipManager; @@ -54,7 +53,7 @@ public class GroupListenerTest extends FRMTest { private ForwardingRulesManagerImpl forwardingRulesManager; private static final NodeId NODE_ID = new NodeId("testnode:1"); private static final NodeKey NODE_KEY = new NodeKey(NODE_ID); - RpcProviderRegistry rpcProviderRegistryMock = new RpcProviderRegistryMock(); + RpcProviderRegistryMock rpcProviderRegistryMock = new RpcProviderRegistryMock(); @Mock ClusterSingletonServiceProvider clusterSingletonService; @Mock @@ -73,6 +72,7 @@ public class GroupListenerTest extends FRMTest { forwardingRulesManager = new ForwardingRulesManagerImpl( getDataBroker(), rpcProviderRegistryMock, + rpcProviderRegistryMock, getConfig(), mastershipChangeServiceManager, clusterSingletonService, @@ -98,7 +98,7 @@ public class GroupListenerTest extends FRMTest { WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, groupII, group); - assertCommit(writeTx.submit()); + assertCommit(writeTx.commit()); SalGroupServiceMock salGroupService = (SalGroupServiceMock) forwardingRulesManager.getSalGroupService(); await().until(listSize(salGroupService.getAddGroupCalls()), equalTo(1)); List addGroupCalls = salGroupService.getAddGroupCalls(); @@ -111,7 +111,7 @@ public class GroupListenerTest extends FRMTest { group = new GroupBuilder().withKey(groupKey).setGroupName("Group1").build(); writeTx = getDataBroker().newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, groupII, group); - assertCommit(writeTx.submit()); + assertCommit(writeTx.commit()); salGroupService = (SalGroupServiceMock) forwardingRulesManager.getSalGroupService(); await().until(listSize(salGroupService.getAddGroupCalls()), equalTo(2)); addGroupCalls = salGroupService.getAddGroupCalls(); @@ -130,7 +130,7 @@ public class GroupListenerTest extends FRMTest { WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, groupII, group); - assertCommit(writeTx.submit()); + assertCommit(writeTx.commit()); SalGroupServiceMock salGroupService = (SalGroupServiceMock) forwardingRulesManager.getSalGroupService(); await().until(listSize(salGroupService.getAddGroupCalls()), equalTo(1)); List addGroupCalls = salGroupService.getAddGroupCalls(); @@ -140,7 +140,7 @@ public class GroupListenerTest extends FRMTest { group = new GroupBuilder().withKey(groupKey).setGroupName("Group2").build(); writeTx = getDataBroker().newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, groupII, group); - assertCommit(writeTx.submit()); + assertCommit(writeTx.commit()); salGroupService = (SalGroupServiceMock) forwardingRulesManager.getSalGroupService(); await().until(listSize(salGroupService.getUpdateGroupCalls()), equalTo(1)); List updateGroupCalls = salGroupService.getUpdateGroupCalls(); @@ -159,7 +159,7 @@ public class GroupListenerTest extends FRMTest { WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, groupII, group); - assertCommit(writeTx.submit()); + assertCommit(writeTx.commit()); SalGroupServiceMock salGroupService = (SalGroupServiceMock) forwardingRulesManager.getSalGroupService(); await().until(listSize(salGroupService.getAddGroupCalls()), equalTo(1)); List addGroupCalls = salGroupService.getAddGroupCalls(); @@ -168,7 +168,7 @@ public class GroupListenerTest extends FRMTest { writeTx = getDataBroker().newWriteOnlyTransaction(); writeTx.delete(LogicalDatastoreType.CONFIGURATION, groupII); - assertCommit(writeTx.submit()); + assertCommit(writeTx.commit()); salGroupService = (SalGroupServiceMock) forwardingRulesManager.getSalGroupService(); await().until(listSize(salGroupService.getRemoveGroupCalls()), equalTo(1)); List removeGroupCalls = salGroupService.getRemoveGroupCalls(); @@ -187,7 +187,7 @@ public class GroupListenerTest extends FRMTest { WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, groupII, group); - assertCommit(writeTx.submit()); + assertCommit(writeTx.commit()); } @After diff --git a/applications/forwardingrules-manager/src/test/java/test/mock/MeterListenerTest.java b/applications/forwardingrules-manager/src/test/java/test/mock/MeterListenerTest.java index f0bca69194..acb4612760 100644 --- a/applications/forwardingrules-manager/src/test/java/test/mock/MeterListenerTest.java +++ b/applications/forwardingrules-manager/src/test/java/test/mock/MeterListenerTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the @@ -16,10 +16,9 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeServiceManager; import org.opendaylight.openflowplugin.applications.frm.impl.DeviceMastershipManager; @@ -52,7 +51,7 @@ public class MeterListenerTest extends FRMTest { private ForwardingRulesManagerImpl forwardingRulesManager; private static final NodeId NODE_ID = new NodeId("testnode:1"); private static final NodeKey NODE_KEY = new NodeKey(NODE_ID); - RpcProviderRegistry rpcProviderRegistryMock = new RpcProviderRegistryMock(); + RpcProviderRegistryMock rpcProviderRegistryMock = new RpcProviderRegistryMock(); @Mock ClusterSingletonServiceProvider clusterSingletonService; @Mock @@ -71,6 +70,7 @@ public class MeterListenerTest extends FRMTest { forwardingRulesManager = new ForwardingRulesManagerImpl( getDataBroker(), rpcProviderRegistryMock, + rpcProviderRegistryMock, getConfig(), mastershipChangeServiceManager, clusterSingletonService, @@ -96,7 +96,7 @@ public class MeterListenerTest extends FRMTest { WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, meterII, meter); - assertCommit(writeTx.submit()); + assertCommit(writeTx.commit()); SalMeterServiceMock salMeterService = (SalMeterServiceMock) forwardingRulesManager.getSalMeterService(); List addMeterCalls = salMeterService.getAddMeterCalls(); assertEquals(1, addMeterCalls.size()); @@ -108,7 +108,7 @@ public class MeterListenerTest extends FRMTest { meter = new MeterBuilder().withKey(meterKey).setMeterName("meter_two").setBarrier(true).build(); writeTx = getDataBroker().newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, meterII, meter); - assertCommit(writeTx.submit()); + assertCommit(writeTx.commit()); salMeterService = (SalMeterServiceMock) forwardingRulesManager.getSalMeterService(); addMeterCalls = salMeterService.getAddMeterCalls(); assertEquals(2, addMeterCalls.size()); @@ -127,7 +127,7 @@ public class MeterListenerTest extends FRMTest { WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, meterII, meter); - assertCommit(writeTx.submit()); + assertCommit(writeTx.commit()); SalMeterServiceMock salMeterService = (SalMeterServiceMock) forwardingRulesManager.getSalMeterService(); List addMeterCalls = salMeterService.getAddMeterCalls(); assertEquals(1, addMeterCalls.size()); @@ -136,7 +136,7 @@ public class MeterListenerTest extends FRMTest { meter = new MeterBuilder().withKey(meterKey).setMeterName("meter_two").setBarrier(true).build(); writeTx = getDataBroker().newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, meterII, meter); - assertCommit(writeTx.submit()); + assertCommit(writeTx.commit()); salMeterService = (SalMeterServiceMock) forwardingRulesManager.getSalMeterService(); List updateMeterCalls = salMeterService.getUpdateMeterCalls(); assertEquals(1, updateMeterCalls.size()); @@ -155,7 +155,7 @@ public class MeterListenerTest extends FRMTest { WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, meterII, meter); - assertCommit(writeTx.submit()); + assertCommit(writeTx.commit()); SalMeterServiceMock salMeterService = (SalMeterServiceMock) forwardingRulesManager.getSalMeterService(); List addMeterCalls = salMeterService.getAddMeterCalls(); assertEquals(1, addMeterCalls.size()); @@ -163,7 +163,7 @@ public class MeterListenerTest extends FRMTest { writeTx = getDataBroker().newWriteOnlyTransaction(); writeTx.delete(LogicalDatastoreType.CONFIGURATION, meterII); - assertCommit(writeTx.submit()); + assertCommit(writeTx.commit()); salMeterService = (SalMeterServiceMock) forwardingRulesManager.getSalMeterService(); List removeMeterCalls = salMeterService.getRemoveMeterCalls(); assertEquals(1, removeMeterCalls.size()); @@ -182,7 +182,7 @@ public class MeterListenerTest extends FRMTest { WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, meterII, meter); - assertCommit(writeTx.submit()); + assertCommit(writeTx.commit()); } @After diff --git a/applications/forwardingrules-manager/src/test/java/test/mock/NodeListenerTest.java b/applications/forwardingrules-manager/src/test/java/test/mock/NodeListenerTest.java index 33a78e3ea2..bec4dee8fa 100644 --- a/applications/forwardingrules-manager/src/test/java/test/mock/NodeListenerTest.java +++ b/applications/forwardingrules-manager/src/test/java/test/mock/NodeListenerTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the @@ -15,8 +15,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.mockito.junit.MockitoJUnitRunner; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeServiceManager; import org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerImpl; @@ -36,7 +35,7 @@ import test.mock.util.RpcProviderRegistryMock; public class NodeListenerTest extends FRMTest { private ForwardingRulesManagerImpl forwardingRulesManager; private static final NodeKey NODE_KEY = new NodeKey(new NodeId("testnode:1")); - RpcProviderRegistry rpcProviderRegistryMock = new RpcProviderRegistryMock(); + RpcProviderRegistryMock rpcProviderRegistryMock = new RpcProviderRegistryMock(); @Mock ClusterSingletonServiceProvider clusterSingletonService; @Mock @@ -53,6 +52,7 @@ public class NodeListenerTest extends FRMTest { forwardingRulesManager = new ForwardingRulesManagerImpl( getDataBroker(), rpcProviderRegistryMock, + rpcProviderRegistryMock, getConfig(), mastershipChangeServiceManager, clusterSingletonService, diff --git a/applications/forwardingrules-manager/src/test/java/test/mock/TableFeaturesListenerTest.java b/applications/forwardingrules-manager/src/test/java/test/mock/TableFeaturesListenerTest.java index 461580f13e..c0f02dae7c 100644 --- a/applications/forwardingrules-manager/src/test/java/test/mock/TableFeaturesListenerTest.java +++ b/applications/forwardingrules-manager/src/test/java/test/mock/TableFeaturesListenerTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the @@ -16,10 +16,9 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeServiceManager; import org.opendaylight.openflowplugin.applications.frm.impl.DeviceMastershipManager; @@ -47,7 +46,7 @@ public class TableFeaturesListenerTest extends FRMTest { private ForwardingRulesManagerImpl forwardingRulesManager; private static final NodeId NODE_ID = new NodeId("testnode:1"); private static final NodeKey NODE_KEY = new NodeKey(NODE_ID); - RpcProviderRegistry rpcProviderRegistryMock = new RpcProviderRegistryMock(); + RpcProviderRegistryMock rpcProviderRegistryMock = new RpcProviderRegistryMock(); @Mock ClusterSingletonServiceProvider clusterSingletonService; @Mock @@ -63,9 +62,10 @@ public class TableFeaturesListenerTest extends FRMTest { @Before public void setUp() { - forwardingRulesManager = new ForwardingRulesManagerImpl(getDataBroker(), rpcProviderRegistryMock, getConfig(), - mastershipChangeServiceManager, clusterSingletonService, getConfigurationService(), - reconciliationManager, openflowServiceRecoveryHandler, serviceRecoveryRegistry); + forwardingRulesManager = new ForwardingRulesManagerImpl(getDataBroker(), rpcProviderRegistryMock, + rpcProviderRegistryMock, getConfig(), mastershipChangeServiceManager, clusterSingletonService, + getConfigurationService(), reconciliationManager, openflowServiceRecoveryHandler, + serviceRecoveryRegistry); forwardingRulesManager.start(); // TODO consider tests rewrite (added because of complicated access) @@ -86,12 +86,12 @@ public class TableFeaturesListenerTest extends FRMTest { .child(TableFeatures.class, tableFeaturesKey); WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, tableFeaturesII, tableFeaturesData); - assertCommit(writeTx.submit()); + assertCommit(writeTx.commit()); tableFeaturesData = new TableFeaturesBuilder().withKey(tableFeaturesKey).setName("dummy name").build(); writeTx = getDataBroker().newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, tableFeaturesII, tableFeaturesData); - assertCommit(writeTx.submit()); + assertCommit(writeTx.commit()); SalTableServiceMock salTableServiceMock = (SalTableServiceMock) forwardingRulesManager.getSalTableService(); List updateTableInputs = salTableServiceMock.getUpdateTableInput(); diff --git a/applications/forwardingrules-manager/src/test/java/test/mock/util/FRMTest.java b/applications/forwardingrules-manager/src/test/java/test/mock/util/FRMTest.java index fb2bceb2bf..e25853a736 100644 --- a/applications/forwardingrules-manager/src/test/java/test/mock/util/FRMTest.java +++ b/applications/forwardingrules-manager/src/test/java/test/mock/util/FRMTest.java @@ -7,14 +7,16 @@ */ package test.mock.util; +import com.google.common.util.concurrent.FluentFuture; +import com.google.common.util.concurrent.ListenableFuture; import java.util.Collections; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import org.mockito.Mockito; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTest; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder; @@ -48,14 +50,20 @@ public abstract class FRMTest extends AbstractDataBrokerTest { writeTx.put(LogicalDatastoreType.OPERATIONAL, flowNodeIdentifier, nodeBuilder.build()); writeTx.put(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(Nodes.class), nodes); writeTx.put(LogicalDatastoreType.CONFIGURATION, flowNodeIdentifier, nodeBuilder.build()); - assertCommit(writeTx.submit()); + assertCommit(writeTx.commit()); + } + + // TODO: remove with mdsal-3.0.7 or later + @SuppressWarnings("unchecked") + protected static final void assertCommit(FluentFuture future) { + assertCommit((ListenableFuture) future); } public void removeNode(NodeKey nodeKey) throws ExecutionException, InterruptedException { WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction(); writeTx.delete(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey)); - writeTx.submit().get(); + writeTx.commit().get(); } public void addTable(final TableKey tableKey, final NodeKey nodeKey) { @@ -65,7 +73,7 @@ public abstract class FRMTest extends AbstractDataBrokerTest { InstanceIdentifier tableII = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey) .augmentation(FlowCapableNode.class).child(Table.class, tableKey); writeTx.put(LogicalDatastoreType.CONFIGURATION, tableII, table); - assertCommit(writeTx.submit()); + assertCommit(writeTx.commit()); } public ForwardingRulesManagerConfig getConfig() { diff --git a/applications/forwardingrules-manager/src/test/java/test/mock/util/RpcProviderRegistryMock.java b/applications/forwardingrules-manager/src/test/java/test/mock/util/RpcProviderRegistryMock.java index a51b3741f2..cf40882c4b 100644 --- a/applications/forwardingrules-manager/src/test/java/test/mock/util/RpcProviderRegistryMock.java +++ b/applications/forwardingrules-manager/src/test/java/test/mock/util/RpcProviderRegistryMock.java @@ -7,37 +7,29 @@ */ package test.mock.util; -import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier; +import java.util.Set; +import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry; +import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.SalBundleService; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.arbitrator.reconcile.service.rev180227.ArbitratorReconcileService; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService; -import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.RpcService; -public class RpcProviderRegistryMock implements RpcProviderRegistry { +public class RpcProviderRegistryMock implements RpcConsumerRegistry, RpcProviderService { @Override - public BindingAwareBroker.RpcRegistration addRpcImplementation(Class serviceInterface, - T implementation) throws IllegalStateException { + public ObjectRegistration registerRpcImplementation(Class type, + T implementation) { return null; } @Override - public BindingAwareBroker.RoutedRpcRegistration addRoutedRpcImplementation( - Class serviceInterface, T implementation) throws IllegalStateException { - return null; - } - - @Override - public >> ListenerRegistration registerRouteChangeListener( - L listener) { + public ObjectRegistration registerRpcImplementation(Class type, + T implementation, Set> paths) { return null; } @@ -59,4 +51,6 @@ public class RpcProviderRegistryMock implements RpcProviderRegistry { return null; } } + + } diff --git a/applications/forwardingrules-sync/pom.xml b/applications/forwardingrules-sync/pom.xml index 59537716dc..40d602dc0f 100644 --- a/applications/forwardingrules-sync/pom.xml +++ b/applications/forwardingrules-sync/pom.xml @@ -12,13 +12,8 @@ - org.opendaylight.controller - sal-binding-api - - - - org.opendaylight.controller - sal-common-api + org.opendaylight.mdsal + mdsal-binding-api @@ -41,11 +36,6 @@ concepts - - org.opendaylight.controller - sal-common-util - - org.opendaylight.mdsal mdsal-singleton-common-api @@ -62,14 +52,14 @@ - org.opendaylight.controller - sal-binding-broker-impl + org.opendaylight.mdsal + mdsal-binding-dom-adapter test - org.opendaylight.controller - sal-binding-broker-impl + org.opendaylight.mdsal + mdsal-binding-dom-adapter test test-jar diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/NodeListener.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/NodeListener.java index 920737b450..76199a9af1 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/NodeListener.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/NodeListener.java @@ -1,18 +1,18 @@ -/** +/* * Copyright (c) 2016 Cisco Systems, Inc. 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.openflowplugin.applications.frsync; -import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener; +import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener; import org.opendaylight.yangtools.yang.binding.DataObject; /** * Unifying listener for data and event changes on node. */ public interface NodeListener extends ClusteredDataTreeChangeListener { + } diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/dao/FlowCapableNodeCachedDao.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/dao/FlowCapableNodeCachedDao.java index b94bc1e473..19a0543f76 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/dao/FlowCapableNodeCachedDao.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/dao/FlowCapableNodeCachedDao.java @@ -1,14 +1,13 @@ -/** +/* * Copyright (c) 2016 Cisco Systems, Inc. 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.openflowplugin.applications.frsync.dao; -import com.google.common.base.Optional; +import java.util.Optional; import javax.annotation.Nonnull; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; @@ -27,6 +26,7 @@ public class FlowCapableNodeCachedDao implements FlowCapableNodeDao { this.odlDao = odlDao; } + @Override public Optional loadByNodeId(@Nonnull NodeId nodeId) { final Optional node = snapshotDao.loadByNodeId(nodeId); @@ -36,5 +36,4 @@ public class FlowCapableNodeCachedDao implements FlowCapableNodeDao { return odlDao.loadByNodeId(nodeId); } - } diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/dao/FlowCapableNodeDao.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/dao/FlowCapableNodeDao.java index 7340fcccee..9baf1d52c9 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/dao/FlowCapableNodeDao.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/dao/FlowCapableNodeDao.java @@ -1,14 +1,13 @@ -/** +/* * Copyright (c) 2016 Cisco Systems, Inc. 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.openflowplugin.applications.frsync.dao; -import com.google.common.base.Optional; +import java.util.Optional; import javax.annotation.Nonnull; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/dao/FlowCapableNodeOdlDao.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/dao/FlowCapableNodeOdlDao.java index 3cd3488ed8..67b0bfe8bc 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/dao/FlowCapableNodeOdlDao.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/dao/FlowCapableNodeOdlDao.java @@ -1,21 +1,20 @@ -/** +/* * Copyright (c) 2016 Cisco Systems, Inc. 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.openflowplugin.applications.frsync.dao; -import com.google.common.base.Optional; +import java.util.Optional; +import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import javax.annotation.Nonnull; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.ReadTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; @@ -43,15 +42,15 @@ public class FlowCapableNodeOdlDao implements FlowCapableNodeDao { @Override public Optional loadByNodeId(@Nonnull NodeId nodeId) { - try (ReadOnlyTransaction roTx = dataBroker.newReadOnlyTransaction()) { + try (ReadTransaction roTx = dataBroker.newReadOnlyTransaction()) { final InstanceIdentifier path = NODES_IID.child(Node.class, new NodeKey(nodeId)).augmentation(FlowCapableNode.class); - return roTx.read(logicalDatastoreType, path).checkedGet(5000, TimeUnit.MILLISECONDS); - } catch (ReadFailedException | TimeoutException e) { + return roTx.read(logicalDatastoreType, path).get(5000, TimeUnit.MILLISECONDS); + } catch (TimeoutException | InterruptedException | ExecutionException e) { LOG.error("error reading {}", nodeId.getValue(), e); } - return Optional.absent(); + return Optional.empty(); } } diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/dao/FlowCapableNodeSnapshotDao.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/dao/FlowCapableNodeSnapshotDao.java index 4f7835aacc..76805af1a0 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/dao/FlowCapableNodeSnapshotDao.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/dao/FlowCapableNodeSnapshotDao.java @@ -1,14 +1,13 @@ -/** +/* * Copyright (c) 2016 Cisco Systems, Inc. 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.openflowplugin.applications.frsync.dao; -import com.google.common.base.Optional; +import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; import javax.annotation.Nonnull; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; @@ -29,9 +28,9 @@ public class FlowCapableNodeSnapshotDao implements FlowCapableNodeDao { } } + @Override public Optional loadByNodeId(@Nonnull NodeId nodeId) { final FlowCapableNode node = cache.get(nodeId.getValue()); - return Optional.fromNullable(node); + return Optional.ofNullable(node); } - } diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/AbstractFrmSyncListener.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/AbstractFrmSyncListener.java index 5130c9ae15..0dfc60a470 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/AbstractFrmSyncListener.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/AbstractFrmSyncListener.java @@ -1,22 +1,21 @@ -/** +/* * Copyright (c) 2016 Cisco Systems, Inc. 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.openflowplugin.applications.frsync.impl; -import com.google.common.base.Optional; import com.google.common.util.concurrent.ListenableFuture; import java.util.Collection; +import java.util.Optional; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import javax.annotation.Nonnull; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.applications.frsync.NodeListener; import org.opendaylight.openflowplugin.applications.frsync.util.PathUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/ForwardingRulesSyncProvider.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/ForwardingRulesSyncProvider.java index 726673a734..dfe0f45b4b 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/ForwardingRulesSyncProvider.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/ForwardingRulesSyncProvider.java @@ -1,11 +1,10 @@ -/** +/* * Copyright (c) 2016 Cisco Systems, Inc. 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.openflowplugin.applications.frsync.impl; import com.google.common.base.Preconditions; @@ -15,10 +14,10 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder; import java.util.Objects; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; +import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; import org.opendaylight.openflowplugin.applications.frsync.NodeListener; import org.opendaylight.openflowplugin.applications.frsync.SyncPlanPushStrategy; @@ -81,9 +80,9 @@ public class ForwardingRulesSyncProvider implements AutoCloseable { this.flatBatchService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalFlatBatchService.class), "RPC SalFlatBatchService not found."); - nodeConfigDataTreePath = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, + nodeConfigDataTreePath = DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, FLOW_CAPABLE_NODE_WC_PATH); - nodeOperationalDataTreePath = new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, NODE_WC_PATH); + nodeOperationalDataTreePath = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, NODE_WC_PATH); final ExecutorService executorService = Executors.newCachedThreadPool(new ThreadFactoryBuilder() .setNameFormat(FRS_EXECUTOR_PREFIX + "%d") diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedConfigListener.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedConfigListener.java index daac0a8449..595a85d27f 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedConfigListener.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedConfigListener.java @@ -1,20 +1,19 @@ -/** +/* * Copyright (c) 2016 Cisco Systems, Inc. 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.openflowplugin.applications.frsync.impl; -import com.google.common.base.Optional; import com.google.common.util.concurrent.ListenableFuture; import java.util.Collection; +import java.util.Optional; import javax.annotation.Nonnull; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.DataObjectModification; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.applications.frsync.SyncReactor; import org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeDao; import org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeSnapshotDao; @@ -59,12 +58,12 @@ public class SimplifiedConfigListener extends AbstractFrmSyncListener nodePath = modification.getRootPath().getRootIdentifier(); final NodeId nodeId = PathUtil.digNodeId(nodePath); - configSnapshot.updateCache(nodeId, Optional.fromNullable(modification.getRootNode().getDataAfter())); + configSnapshot.updateCache(nodeId, Optional.ofNullable(modification.getRootNode().getDataAfter())); final Optional operationalNode = operationalDao.loadByNodeId(nodeId); if (!operationalNode.isPresent()) { LOG.debug("Skip syncup, {} operational is not present", nodeId.getValue()); - return Optional.absent(); + return Optional.empty(); } final DataObjectModification configModification = modification.getRootNode(); diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalListener.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalListener.java index f7f51b4753..b1aa44c6e4 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalListener.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalListener.java @@ -1,14 +1,12 @@ -/** +/* * Copyright (c) 2016 Cisco Systems, Inc. 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.openflowplugin.applications.frsync.impl; -import com.google.common.base.Optional; import com.google.common.util.concurrent.ListenableFuture; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -16,10 +14,11 @@ import java.util.Collection; import java.util.Date; import java.util.List; import java.util.Objects; +import java.util.Optional; import javax.annotation.Nonnull; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.DataObjectModification; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.applications.frsync.SyncReactor; import org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeDao; import org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeSnapshotDao; @@ -82,11 +81,11 @@ public class SimplifiedOperationalListener extends AbstractFrmSyncListener final DataObjectModification nodeModification = modification.getRootNode(); if (isDelete(nodeModification) || isDeleteLogical(nodeModification)) { - operationalSnapshot.updateCache(nodeId, Optional.absent()); + operationalSnapshot.updateCache(nodeId, Optional.empty()); deviceMastershipManager.onDeviceDisconnected(nodeId); result = skipModification(modification); } else { - operationalSnapshot.updateCache(nodeId, Optional.fromNullable( + operationalSnapshot.updateCache(nodeId, Optional.ofNullable( ModificationUtil.flowCapableNodeAfter(modification))); final boolean isAdd = isAdd(nodeModification) || isAddLogical(nodeModification); @@ -114,7 +113,7 @@ public class SimplifiedOperationalListener extends AbstractFrmSyncListener modification.getRootNode().getDataBefore() == null ? "null" : "nonnull", modification.getRootNode().getDataAfter() == null ? "null" : "nonnull"); } - return Optional.absent(); + return Optional.empty(); } private boolean isDelete(final DataObjectModification nodeModification) { diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/ModificationUtil.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/ModificationUtil.java index 2c87661f5e..dcd5fff6e2 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/ModificationUtil.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/ModificationUtil.java @@ -1,15 +1,14 @@ -/** +/* * Copyright (c) 2016 Cisco Systems, Inc. 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.openflowplugin.applications.frsync.util; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.binding.api.DataObjectModification; +import org.opendaylight.mdsal.binding.api.DataTreeModification; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/SyncupEntry.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/SyncupEntry.java index ee76cc9daa..abe4da9abb 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/SyncupEntry.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/SyncupEntry.java @@ -1,14 +1,13 @@ -/** +/* * Copyright (c) 2016 Cisco Systems, Inc. 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.openflowplugin.applications.frsync.util; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; /** diff --git a/applications/forwardingrules-sync/src/main/resources/OSGI-INF/blueprint/forwardingrules-sync.xml b/applications/forwardingrules-sync/src/main/resources/OSGI-INF/blueprint/forwardingrules-sync.xml index 24b7bacbe6..d0474367a6 100644 --- a/applications/forwardingrules-sync/src/main/resources/OSGI-INF/blueprint/forwardingrules-sync.xml +++ b/applications/forwardingrules-sync/src/main/resources/OSGI-INF/blueprint/forwardingrules-sync.xml @@ -10,8 +10,8 @@ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0" odl:use-default-for-reference-types="true"> - - + + dataTreeModification; @Mock @@ -76,7 +76,7 @@ public class SimplifiedConfigListenerTest { .augmentation(FlowCapableNode.class); final DataTreeIdentifier dataTreeIdentifier = - new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, fcNodePath); + DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, fcNodePath); Mockito.when(db.newReadOnlyTransaction()).thenReturn(roTx); Mockito.when(dataTreeModification.getRootPath()).thenReturn(dataTreeIdentifier); @@ -130,8 +130,8 @@ public class SimplifiedConfigListenerTest { @Test public void testOnDataTreeChangedSkip() { - Mockito.when(roTx.read(LogicalDatastoreType.OPERATIONAL, fcNodePath)) - .thenReturn(Futures.immediateCheckedFuture(Optional.absent())); + Mockito.doReturn(FluentFutures.immediateFluentFuture(Optional.empty())).when(roTx) + .read(LogicalDatastoreType.OPERATIONAL, fcNodePath); nodeListenerConfig.onDataTreeChanged(Collections.singleton(dataTreeModification)); @@ -142,8 +142,8 @@ public class SimplifiedConfigListenerTest { private SyncupEntry loadOperationalDSAndPrepareSyncupEntry(final FlowCapableNode after, final LogicalDatastoreType dsTypeAfter, final FlowCapableNode before, final LogicalDatastoreType dsTypeBefore) { - Mockito.when(roTx.read(LogicalDatastoreType.OPERATIONAL, fcNodePath)) - .thenReturn(Futures.immediateCheckedFuture(Optional.of(dataBefore))); + Mockito.doReturn(FluentFutures.immediateFluentFuture(Optional.of(dataBefore))).when(roTx) + .read(LogicalDatastoreType.OPERATIONAL, fcNodePath); final SyncupEntry syncupEntry = new SyncupEntry(after, dsTypeAfter, before, dsTypeBefore); Mockito.when(reactor.syncup(ArgumentMatchers.>any(), Mockito.eq(syncupEntry))).thenReturn(Futures.immediateFuture(Boolean.TRUE)); diff --git a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalListenerTest.java b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalListenerTest.java index fec3204045..edc3b25f44 100644 --- a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalListenerTest.java +++ b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalListenerTest.java @@ -1,19 +1,18 @@ -/** +/* * Copyright (c) 2016 Cisco Systems, Inc. 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.openflowplugin.applications.frsync.impl; -import com.google.common.base.Optional; import com.google.common.util.concurrent.Futures; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Collections; import java.util.List; +import java.util.Optional; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -21,13 +20,13 @@ import org.junit.runner.RunWith; import org.mockito.ArgumentMatchers; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataObjectModification; +import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.binding.api.ReadTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.applications.frsync.SyncReactor; import org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeCachedDao; import org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeDao; @@ -44,6 +43,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; +import org.opendaylight.yangtools.util.concurrent.FluentFutures; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** @@ -63,7 +63,7 @@ public class SimplifiedOperationalListenerTest { @Mock private SyncReactor reactor; @Mock - private ReadOnlyTransaction roTx; + private ReadTransaction roTx; @Mock private DataTreeModification dataTreeModification; @Mock @@ -102,7 +102,7 @@ public class SimplifiedOperationalListenerTest { fcNodePath = nodePath.augmentation(FlowCapableNode.class); final DataTreeIdentifier dataTreeIdentifier = - new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, nodePath); + DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, nodePath); Mockito.when(db.newReadOnlyTransaction()).thenReturn(roTx); Mockito.when(operationalNode.getId()).thenReturn(NODE_ID); @@ -244,8 +244,8 @@ public class SimplifiedOperationalListenerTest { operationalUpdate(); prepareFreshOperational(true); - Mockito.when(roTx.read(LogicalDatastoreType.CONFIGURATION, fcNodePath)) - .thenReturn(Futures.immediateCheckedFuture(Optional.absent())); + Mockito.doReturn(FluentFutures.immediateFluentFuture(Optional.empty())).when(roTx) + .read(LogicalDatastoreType.CONFIGURATION, fcNodePath); nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification)); @@ -286,8 +286,9 @@ public class SimplifiedOperationalListenerTest { private SyncupEntry loadConfigDSAndPrepareSyncupEntry(final FlowCapableNode after, final LogicalDatastoreType dsTypeAfter, final FlowCapableNode before, final LogicalDatastoreType dsTypeBefore) { - Mockito.when(roTx.read(LogicalDatastoreType.CONFIGURATION, fcNodePath)) - .thenReturn(Futures.immediateCheckedFuture(Optional.of(configNode))); + + Mockito.doReturn(FluentFutures.immediateFluentFuture(Optional.of(configNode))).when(roTx) + .read(LogicalDatastoreType.CONFIGURATION, fcNodePath); final SyncupEntry syncupEntry = new SyncupEntry(after, dsTypeAfter, before, dsTypeBefore); Mockito.when(reactor.syncup(ArgumentMatchers.>any(), Mockito.eq(syncupEntry))).thenReturn(Futures.immediateFuture(Boolean.TRUE)); diff --git a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorFutureZipDecoratorTest.java b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorFutureZipDecoratorTest.java index 875aaf9284..d6aacc6196 100644 --- a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorFutureZipDecoratorTest.java +++ b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorFutureZipDecoratorTest.java @@ -1,11 +1,10 @@ -/** +/* * Copyright (c) 2016 Cisco Systems, Inc. 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.openflowplugin.applications.frsync.impl; import com.google.common.util.concurrent.Futures; @@ -27,8 +26,8 @@ import org.mockito.ArgumentMatchers; import org.mockito.InOrder; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.applications.frsync.SyncReactor; import org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; diff --git a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorImplTest.java b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorImplTest.java index 48a43a2e46..f0ce7c0ff7 100644 --- a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorImplTest.java +++ b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorImplTest.java @@ -1,11 +1,10 @@ -/** +/* * Copyright (c) 2016 Cisco Systems, Inc. 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.openflowplugin.applications.frsync.impl; import com.google.common.util.concurrent.ListenableFuture; @@ -20,9 +19,9 @@ import org.mockito.ArgumentMatchers; import org.mockito.Captor; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.applications.frsync.SyncPlanPushStrategy; import org.opendaylight.openflowplugin.applications.frsync.impl.strategy.SynchronizationDiffInput; import org.opendaylight.openflowplugin.applications.frsync.util.ReconcileUtil; diff --git a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyIncrementalImplTest.java b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyIncrementalImplTest.java index 12cb05445c..97bc51305d 100644 --- a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyIncrementalImplTest.java +++ b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyIncrementalImplTest.java @@ -1,11 +1,10 @@ -/** +/* * Copyright (c) 2016 Cisco Systems, Inc. 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.openflowplugin.applications.frsync.impl.strategy; import com.google.common.collect.Lists; @@ -26,9 +25,9 @@ import org.mockito.Captor; import org.mockito.InOrder; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.mockito.stubbing.Answer; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.openflowplugin.applications.frsync.impl.DSInputFactory; import org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox; import org.opendaylight.openflowplugin.applications.frsync.util.SyncCrudCounters; diff --git a/applications/lldp-speaker/pom.xml b/applications/lldp-speaker/pom.xml index 3e1ef02fb4..16b63115a6 100644 --- a/applications/lldp-speaker/pom.xml +++ b/applications/lldp-speaker/pom.xml @@ -15,12 +15,8 @@ openflowplugin-api - org.opendaylight.controller - sal-binding-api - - - org.opendaylight.controller - sal-binding-broker-impl + org.opendaylight.mdsal + mdsal-binding-api org.opendaylight.controller.model diff --git a/applications/lldp-speaker/src/main/java/org/opendaylight/openflowplugin/applications/lldpspeaker/NodeConnectorInventoryEventTranslator.java b/applications/lldp-speaker/src/main/java/org/opendaylight/openflowplugin/applications/lldpspeaker/NodeConnectorInventoryEventTranslator.java index 3e2e67c9a7..0e5c97f4a6 100644 --- a/applications/lldp-speaker/src/main/java/org/opendaylight/openflowplugin/applications/lldpspeaker/NodeConnectorInventoryEventTranslator.java +++ b/applications/lldp-speaker/src/main/java/org/opendaylight/openflowplugin/applications/lldpspeaker/NodeConnectorInventoryEventTranslator.java @@ -5,7 +5,6 @@ * 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.openflowplugin.applications.lldpspeaker; import com.google.common.collect.ImmutableSet; @@ -15,12 +14,12 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; import javax.annotation.Nonnull; -import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataTreeChangeListener; +import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder; @@ -64,10 +63,10 @@ public class NodeConnectorInventoryEventTranslator @SuppressWarnings("IllegalCatch") public NodeConnectorInventoryEventTranslator(DataBroker dataBroker, NodeConnectorEventsObserver... observers) { this.observers = ImmutableSet.copyOf(observers); - final DataTreeIdentifier dtiToNodeConnector = new DataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, - II_TO_FLOW_CAPABLE_NODE_CONNECTOR); - final DataTreeIdentifier dtiToNodeConnectorState = new DataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, - II_TO_STATE); + final DataTreeIdentifier dtiToNodeConnector = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, + II_TO_FLOW_CAPABLE_NODE_CONNECTOR); + final DataTreeIdentifier dtiToNodeConnectorState = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, + II_TO_STATE); final SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES); try { listenerOnPortRegistration = looper.loopUntilNoException(() -> diff --git a/applications/lldp-speaker/src/main/resources/OSGI-INF/blueprint/lldp-speaker.xml b/applications/lldp-speaker/src/main/resources/OSGI-INF/blueprint/lldp-speaker.xml index 2e397c3448..4baf347829 100644 --- a/applications/lldp-speaker/src/main/resources/OSGI-INF/blueprint/lldp-speaker.xml +++ b/applications/lldp-speaker/src/main/resources/OSGI-INF/blueprint/lldp-speaker.xml @@ -3,7 +3,7 @@ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0" odl:use-default-for-reference-types="true"> - + identifier = new DataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, ii); + DataTreeIdentifier identifier = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, ii); when(dataTreeModification.getRootNode().getModificationType()).thenReturn(type); when(dataTreeModification.getRootPath()).thenReturn(identifier); when(dataTreeModification.getRootNode().getDataAfter()).thenReturn(connector); diff --git a/applications/notification-supplier/pom.xml b/applications/notification-supplier/pom.xml index ca96c2b82e..7e7b7d130f 100644 --- a/applications/notification-supplier/pom.xml +++ b/applications/notification-supplier/pom.xml @@ -15,12 +15,8 @@ openflowplugin-api - org.opendaylight.controller - sal-binding-api - - - org.opendaylight.controller - sal-binding-broker-impl + org.opendaylight.mdsal + mdsal-binding-api org.opendaylight.controller.model diff --git a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/NotificationProvider.java b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/NotificationProvider.java index 6432c98f06..be483d8199 100644 --- a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/NotificationProvider.java +++ b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/NotificationProvider.java @@ -5,7 +5,6 @@ * 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.openflowplugin.applications.notification.supplier; import com.google.common.annotations.VisibleForTesting; @@ -13,8 +12,8 @@ import com.google.common.base.Preconditions; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.NodeConnectorNotificationSupplierImpl; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.NodeNotificationSupplierImpl; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.item.FlowNotificationSupplierImpl; @@ -65,7 +64,7 @@ public class NotificationProvider implements AutoCloseable { private final DataBroker db; private final NotificationProviderConfig config; - private final NotificationProviderService nps; + private final NotificationPublishService nps; /* Supplier List property help for easy close method implementation and testing */ private List> supplierList; @@ -99,7 +98,7 @@ public class NotificationProvider implements AutoCloseable { * @param groupStatSupp - Group Stat Support Flag * @param queueStatSupp - Queue Stat Support Flag */ - public NotificationProvider(final NotificationProviderService nps, final DataBroker db, boolean flowSupp, + public NotificationProvider(final NotificationPublishService nps, final DataBroker db, boolean flowSupp, boolean meterSupp, boolean groupSupp, boolean connectorStatSupp, boolean flowStatSupp, boolean flowTableStatSupp, boolean meterStatSupp, boolean groupStatSupp, boolean queueStatSupp) { diff --git a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/NotificationSupplierDefinition.java b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/NotificationSupplierDefinition.java index 6017e7d7f6..3e59568f6f 100644 --- a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/NotificationSupplierDefinition.java +++ b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/NotificationSupplierDefinition.java @@ -5,16 +5,15 @@ * 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.openflowplugin.applications.notification.supplier; -import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; +import org.opendaylight.mdsal.binding.api.DataTreeChangeListener; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** * Default definition for every Notification Supplier. Migration from notification - * to {@link org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener} has one + * to {@link DataTreeChangeListener} has one * keyed component - WildCarded Path which represent a changes checker in DataStoreTreeNode * * @param - {@link DataObject} represent Data Tree Item from DataStore diff --git a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/AbstractNotificationSupplierBase.java b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/AbstractNotificationSupplierBase.java index 937b00d360..fc9a227a6b 100644 --- a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/AbstractNotificationSupplierBase.java +++ b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/AbstractNotificationSupplierBase.java @@ -5,14 +5,13 @@ * 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.openflowplugin.applications.notification.supplier.impl; import com.google.common.base.Preconditions; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataTreeChangeListener; +import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.applications.notification.supplier.NotificationSupplierDefinition; import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; @@ -29,7 +28,7 @@ import org.slf4j.LoggerFactory; /** * Public abstract basic Supplier implementation contains code for a make Supplier instance, - * registration Supplier like {@link org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener} + * registration Supplier like {@link DataTreeChangeListener} * and close method. In additional case, it contains help methods for all Supplier implementations. * * @param - data tree item Object extends {@link DataObject} @@ -45,7 +44,7 @@ public abstract class AbstractNotificationSupplierBase imp private static final int STARTUP_LOOP_MAX_RETRIES = 8; - final DataTreeIdentifier treeId = new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, getWildCardPath()); + final DataTreeIdentifier treeId = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, getWildCardPath()); /** * Default constructor for all Notification Supplier implementation. diff --git a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/AbstractNotificationSupplierForItemRoot.java b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/AbstractNotificationSupplierForItemRoot.java index 92f05a2723..bd58e15e0d 100644 --- a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/AbstractNotificationSupplierForItemRoot.java +++ b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/AbstractNotificationSupplierForItemRoot.java @@ -5,15 +5,14 @@ * 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.openflowplugin.applications.notification.supplier.impl; import com.google.common.base.Preconditions; import java.util.Collection; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataObjectModification; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.applications.notification.supplier.NotificationSupplierForItemRoot; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @@ -30,7 +29,7 @@ import org.opendaylight.yangtools.yang.binding.Notification; public abstract class AbstractNotificationSupplierForItemRoot extends AbstractNotificationSupplierBase implements NotificationSupplierForItemRoot { - private final NotificationProviderService notificationProviderService; + private final NotificationPublishService notificationProviderService; /** * Default constructor for all Root Item Notification Supplier implementation. @@ -39,7 +38,7 @@ public abstract class AbstractNotificationSupplierForItemRoot clazz) { super(db, clazz); this.notificationProviderService = Preconditions.checkNotNull(notificationProviderService); @@ -75,23 +74,25 @@ public abstract class AbstractNotificationSupplierForItemRoot identifier, O add) { - - final C notif = createNotification(add, identifier); - if (notif != null) { - notificationProviderService.publish(notif); - } + putNotification(createNotification(add, identifier)); } public void remove(InstanceIdentifier identifier, O del) { - final D notif = deleteNotification(identifier.firstIdentifierOf(clazz)); - if (notif != null) { - notificationProviderService.publish(notif); - } + putNotification(deleteNotification(identifier.firstIdentifierOf(clazz))); } public void update(InstanceIdentifier identifier, O before, O after) { //EMPTY NO-OP } + private void putNotification(Notification notif) { + if (notif != null) { + try { + notificationProviderService.putNotification(notif); + } catch (InterruptedException e) { + throw new IllegalStateException("Interrupted while publishing " + notif, e); + } + } + } } diff --git a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/NodeConnectorNotificationSupplierImpl.java b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/NodeConnectorNotificationSupplierImpl.java index a855408bea..9009b1ec69 100644 --- a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/NodeConnectorNotificationSupplierImpl.java +++ b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/NodeConnectorNotificationSupplierImpl.java @@ -5,12 +5,11 @@ * 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.openflowplugin.applications.notification.supplier.impl; import com.google.common.base.Preconditions; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorUpdated; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorUpdatedBuilder; @@ -35,10 +34,10 @@ public class NodeConnectorNotificationSupplierImpl extends /** * Constructor register supplier as DataTreeChangeListener and create wildCarded InstanceIdentifier. * - * @param notifProviderService - {@link NotificationProviderService} + * @param notifProviderService - {@link NotificationPublishService} * @param db - {@link DataBroker} */ - public NodeConnectorNotificationSupplierImpl(final NotificationProviderService notifProviderService, + public NodeConnectorNotificationSupplierImpl(final NotificationPublishService notifProviderService, final DataBroker db) { super(notifProviderService, db, FlowCapableNodeConnector.class); } diff --git a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/NodeNotificationSupplierImpl.java b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/NodeNotificationSupplierImpl.java index f86a7dc17c..9c71bd02cf 100644 --- a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/NodeNotificationSupplierImpl.java +++ b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/NodeNotificationSupplierImpl.java @@ -5,12 +5,11 @@ * 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.openflowplugin.applications.notification.supplier.impl; import com.google.common.base.Preconditions; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdated; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdatedBuilder; @@ -35,10 +34,10 @@ public class NodeNotificationSupplierImpl extends AbstractNotificationSupplierFo /** * Constructor register supplier as DataTreeChangeListener and create wildCarded InstanceIdentifier. * - * @param notifProviderService - {@link NotificationProviderService} + * @param notifProviderService - {@link NotificationPublishService} * @param db - {@link DataBroker} */ - public NodeNotificationSupplierImpl(final NotificationProviderService notifProviderService, final DataBroker db) { + public NodeNotificationSupplierImpl(final NotificationPublishService notifProviderService, final DataBroker db) { super(notifProviderService, db, FlowCapableNode.class); } diff --git a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/AbstractNotificationSupplierForItem.java b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/AbstractNotificationSupplierForItem.java index da8aaed3db..70992eeee0 100644 --- a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/AbstractNotificationSupplierForItem.java +++ b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/AbstractNotificationSupplierForItem.java @@ -5,15 +5,14 @@ * 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.openflowplugin.applications.notification.supplier.impl.item; import com.google.common.base.Preconditions; import java.util.Collection; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataObjectModification; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.applications.notification.supplier.NotificationSupplierForItem; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.AbstractNotificationSupplierBase; import org.opendaylight.yangtools.yang.binding.DataObject; @@ -33,7 +32,7 @@ public abstract class AbstractNotificationSupplierForItem extends AbstractNotificationSupplierBase implements NotificationSupplierForItem { - private final NotificationProviderService notificationProviderService; + private final NotificationPublishService notificationProviderService; /** * Default constructor for all item Notification Supplier implementation. @@ -42,7 +41,7 @@ public abstract class AbstractNotificationSupplierForItem clazz) { super(db, clazz); this.notificationProviderService = Preconditions.checkNotNull(notifProviderService); @@ -77,24 +76,24 @@ public abstract class AbstractNotificationSupplierForItem identifier, O add) { - final C notif = createNotification(add, identifier); - if (notif != null) { - notificationProviderService.publish(notif); - } + putNotification(createNotification(add, identifier)); } public void remove(InstanceIdentifier identifier, O del) { - final D notif = deleteNotification(identifier.firstIdentifierOf(clazz)); - if (notif != null) { - notificationProviderService.publish(notif); - } + putNotification(deleteNotification(identifier.firstIdentifierOf(clazz))); } public void update(InstanceIdentifier identifier, O before, O after) { + putNotification(updateNotification(after, identifier)); + } - final U notif = updateNotification(after, identifier); + private void putNotification(Notification notif) { if (notif != null) { - notificationProviderService.publish(notif); + try { + notificationProviderService.putNotification(notif); + } catch (InterruptedException e) { + throw new IllegalStateException("Interrupted while publishing " + notif, e); + } } } } diff --git a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/FlowNotificationSupplierImpl.java b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/FlowNotificationSupplierImpl.java index ebd4ccd90b..9d2e9fdfcb 100644 --- a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/FlowNotificationSupplierImpl.java +++ b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/FlowNotificationSupplierImpl.java @@ -5,12 +5,11 @@ * 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.openflowplugin.applications.notification.supplier.impl.item; import com.google.common.base.Preconditions; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow; @@ -36,10 +35,10 @@ public class FlowNotificationSupplierImpl extends AbstractNotificationSupplierFo /** * Constructor register supplier as DataTreeChangeListener and create wildCarded InstanceIdentifier. * - * @param notifProviderService - {@link NotificationProviderService} + * @param notifProviderService - {@link NotificationPublishService} * @param db - {@link DataBroker} */ - public FlowNotificationSupplierImpl(final NotificationProviderService notifProviderService, final DataBroker db) { + public FlowNotificationSupplierImpl(final NotificationPublishService notifProviderService, final DataBroker db) { super(notifProviderService, db, Flow.class); } diff --git a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/GroupNotificationSupplierImpl.java b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/GroupNotificationSupplierImpl.java index a8b05a6c00..50e4345df5 100644 --- a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/GroupNotificationSupplierImpl.java +++ b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/GroupNotificationSupplierImpl.java @@ -5,12 +5,11 @@ * 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.openflowplugin.applications.notification.supplier.impl.item; import com.google.common.base.Preconditions; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupAdded; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupAddedBuilder; @@ -35,10 +34,10 @@ public class GroupNotificationSupplierImpl extends AbstractNotificationSupplierF /** * Constructor register supplier as DataTreeChangeListener and create wildCarded InstanceIdentifier. * - * @param notifProviderService - {@link NotificationProviderService} + * @param notifProviderService - {@link NotificationPublishService} * @param db - {@link DataBroker} */ - public GroupNotificationSupplierImpl(final NotificationProviderService notifProviderService, final DataBroker db) { + public GroupNotificationSupplierImpl(final NotificationPublishService notifProviderService, final DataBroker db) { super(notifProviderService, db, Group.class); } diff --git a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/MeterNotificationSupplierImpl.java b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/MeterNotificationSupplierImpl.java index 51af021b08..ecd1fd51f2 100644 --- a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/MeterNotificationSupplierImpl.java +++ b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/MeterNotificationSupplierImpl.java @@ -5,12 +5,11 @@ * 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.openflowplugin.applications.notification.supplier.impl.item; import com.google.common.base.Preconditions; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterAdded; @@ -35,10 +34,10 @@ public class MeterNotificationSupplierImpl extends /** * Constructor register supplier as DataTreeChangeListener and create wildCarded InstanceIdentifier. * - * @param notifProviderService - {@link NotificationProviderService} + * @param notifProviderService - {@link NotificationPublishService} * @param db - {@link DataBroker} */ - public MeterNotificationSupplierImpl(final NotificationProviderService notifProviderService, final DataBroker db) { + public MeterNotificationSupplierImpl(final NotificationPublishService notifProviderService, final DataBroker db) { super(notifProviderService, db, Meter.class); } diff --git a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/AbstractNotificationSupplierForItemStat.java b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/AbstractNotificationSupplierForItemStat.java index 59cbef0142..c2fa646e29 100644 --- a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/AbstractNotificationSupplierForItemStat.java +++ b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/AbstractNotificationSupplierForItemStat.java @@ -5,15 +5,14 @@ * 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.openflowplugin.applications.notification.supplier.impl.item.stat; import com.google.common.base.Preconditions; import java.util.Collection; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataObjectModification; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.applications.notification.supplier.NotificationSupplierForItemStat; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.AbstractNotificationSupplierBase; import org.opendaylight.yangtools.yang.binding.DataObject; @@ -30,7 +29,7 @@ import org.opendaylight.yangtools.yang.binding.Notification; public abstract class AbstractNotificationSupplierForItemStat extends AbstractNotificationSupplierBase implements NotificationSupplierForItemStat { - private final NotificationProviderService notifProviderService; + private final NotificationPublishService notifProviderService; /** * Default constructor for all Statistic Notification Supplier implementation. @@ -39,7 +38,7 @@ public abstract class AbstractNotificationSupplierForItemStat clazz) { super(db, clazz); this.notifProviderService = Preconditions.checkNotNull(notifProviderService); @@ -77,7 +76,11 @@ public abstract class AbstractNotificationSupplierForItemStat identifier, O add) { final N notif = createNotification(add, identifier); if (notif != null) { - notifProviderService.publish(notif); + try { + notifProviderService.putNotification(notif); + } catch (InterruptedException e) { + throw new IllegalStateException("Interrupted while publishing " + notif, e); + } } } diff --git a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/FlowStatNotificationSupplierImpl.java b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/FlowStatNotificationSupplierImpl.java index 01d4f62da8..5309bb854b 100644 --- a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/FlowStatNotificationSupplierImpl.java +++ b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/FlowStatNotificationSupplierImpl.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.openflowplugin.applications.notification.supplier.impl.item.stat; import com.google.common.base.Preconditions; import java.util.Collections; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow; @@ -38,10 +37,10 @@ public class FlowStatNotificationSupplierImpl extends AbstractNotificationSuppli /** * Constructor register supplier as DataTreeChangeListener and create wildCarded InstanceIdentifier. * - * @param notifProviderService - {@link NotificationProviderService} + * @param notifProviderService - {@link NotificationPublishService} * @param db - {@link DataBroker} */ - public FlowStatNotificationSupplierImpl(final NotificationProviderService notifProviderService, + public FlowStatNotificationSupplierImpl(final NotificationPublishService notifProviderService, final DataBroker db) { super(notifProviderService, db, FlowStatistics.class); } diff --git a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/FlowTableStatNotificationSupplierImpl.java b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/FlowTableStatNotificationSupplierImpl.java index 971547c434..4d8061707a 100644 --- a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/FlowTableStatNotificationSupplierImpl.java +++ b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/FlowTableStatNotificationSupplierImpl.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.openflowplugin.applications.notification.supplier.impl.item.stat; import com.google.common.base.Preconditions; import java.util.Collections; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsData; @@ -38,10 +37,10 @@ public class FlowTableStatNotificationSupplierImpl extends /** * Constructor register supplier as DataTreeChangeListener and create wildCarded InstanceIdentifier. * - * @param notifProviderService - {@link NotificationProviderService} + * @param notifProviderService - {@link NotificationPublishService} * @param db - {@link DataBroker} */ - public FlowTableStatNotificationSupplierImpl(final NotificationProviderService notifProviderService, + public FlowTableStatNotificationSupplierImpl(final NotificationPublishService notifProviderService, final DataBroker db) { super(notifProviderService, db, FlowTableStatistics.class); } diff --git a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/GroupStatNotificationSupplierImpl.java b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/GroupStatNotificationSupplierImpl.java index a03c3a8999..ff38acbe4d 100644 --- a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/GroupStatNotificationSupplierImpl.java +++ b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/GroupStatNotificationSupplierImpl.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.openflowplugin.applications.notification.supplier.impl.item.stat; import com.google.common.base.Preconditions; import java.util.Collections; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdatedBuilder; @@ -36,10 +35,10 @@ public class GroupStatNotificationSupplierImpl extends AbstractNotificationSuppl /** * Constructor register supplier as DataTreeChangeListener and create wildCarded InstanceIdentifier. * - * @param notifProviderService - {@link NotificationProviderService} + * @param notifProviderService - {@link NotificationPublishService} * @param db - {@link DataBroker} */ - public GroupStatNotificationSupplierImpl(final NotificationProviderService notifProviderService, + public GroupStatNotificationSupplierImpl(final NotificationPublishService notifProviderService, final DataBroker db) { super(notifProviderService, db, GroupStatistics.class); } diff --git a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/MeterStatNotificationSupplierImpl.java b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/MeterStatNotificationSupplierImpl.java index 545b65fdd2..0462ceb70f 100644 --- a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/MeterStatNotificationSupplierImpl.java +++ b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/MeterStatNotificationSupplierImpl.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.openflowplugin.applications.notification.supplier.impl.item.stat; import com.google.common.base.Preconditions; import java.util.Collections; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector; @@ -36,10 +35,10 @@ public class MeterStatNotificationSupplierImpl extends AbstractNotificationSuppl /** * Constructor register supplier as DataTreeChangeListener and create wildCarded InstanceIdentifier. * - * @param notifProviderService - {@link NotificationProviderService} + * @param notifProviderService - {@link NotificationPublishService} * @param db - {@link DataBroker} */ - public MeterStatNotificationSupplierImpl(final NotificationProviderService notifProviderService, + public MeterStatNotificationSupplierImpl(final NotificationPublishService notifProviderService, final DataBroker db) { super(notifProviderService, db, MeterStatistics.class); } diff --git a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/NodeConnectorStatNotificationSupplierImpl.java b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/NodeConnectorStatNotificationSupplierImpl.java index f9bd34d2f8..953079cc40 100644 --- a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/NodeConnectorStatNotificationSupplierImpl.java +++ b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/NodeConnectorStatNotificationSupplierImpl.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.openflowplugin.applications.notification.supplier.impl.item.stat; import com.google.common.base.Preconditions; import java.util.Collections; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey; @@ -36,10 +35,10 @@ public class NodeConnectorStatNotificationSupplierImpl extends /** * Constructor register supplier as DataTreeChangeListener and create wildCarded InstanceIdentifier. * - * @param notifProviderService - {@link NotificationProviderService} + * @param notifProviderService - {@link NotificationPublishService} * @param db - {@link DataBroker} */ - public NodeConnectorStatNotificationSupplierImpl(final NotificationProviderService notifProviderService, + public NodeConnectorStatNotificationSupplierImpl(final NotificationPublishService notifProviderService, final DataBroker db) { super(notifProviderService, db, FlowCapableNodeConnectorStatistics.class); } diff --git a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/QueueStatNotificationSupplierImpl.java b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/QueueStatNotificationSupplierImpl.java index c626a0d7a1..28281a1e44 100644 --- a/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/QueueStatNotificationSupplierImpl.java +++ b/applications/notification-supplier/src/main/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/QueueStatNotificationSupplierImpl.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.openflowplugin.applications.notification.supplier.impl.item.stat; import com.google.common.base.Preconditions; import java.util.Collections; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector; @@ -38,10 +37,10 @@ public class QueueStatNotificationSupplierImpl extends /** * Constructor register supplier as DataTreeChangeListener and create wildCarded InstanceIdentifier. * - * @param notifProviderService - {@link NotificationProviderService} + * @param notifProviderService - {@link NotificationPublishService} * @param db - {@link DataBroker} */ - public QueueStatNotificationSupplierImpl(final NotificationProviderService notifProviderService, + public QueueStatNotificationSupplierImpl(final NotificationPublishService notifProviderService, final DataBroker db) { super(notifProviderService, db, FlowCapableNodeConnectorQueueStatisticsData.class); } diff --git a/applications/notification-supplier/src/main/resources/OSGI-INF/blueprint/notification-supplier.xml b/applications/notification-supplier/src/main/resources/OSGI-INF/blueprint/notification-supplier.xml index 2cad558103..6bbb771956 100644 --- a/applications/notification-supplier/src/main/resources/OSGI-INF/blueprint/notification-supplier.xml +++ b/applications/notification-supplier/src/main/resources/OSGI-INF/blueprint/notification-supplier.xml @@ -3,9 +3,9 @@ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0" odl:use-default-for-reference-types="true"> - + - + @@ -31,4 +31,4 @@ - \ No newline at end of file + diff --git a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/NotificationProviderTest.java b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/NotificationProviderTest.java index 8d39252a35..631a2834a2 100644 --- a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/NotificationProviderTest.java +++ b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/NotificationProviderTest.java @@ -14,20 +14,20 @@ import static org.mockito.Mockito.mock; import java.util.List; import org.junit.Before; import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.applications.notification.supplier.tools.NotificationProviderConfig; import org.opendaylight.openflowplugin.applications.notification.supplier.tools.NotificationProviderConfig.NotificationProviderConfigBuilder; public class NotificationProviderTest { - private NotificationProviderService notificationProviderService; + private NotificationPublishService notificationProviderService; private DataBroker dataBroker; @Before public void initialization() { dataBroker = mock(DataBroker.class); - notificationProviderService = mock(NotificationProviderService.class); + notificationProviderService = mock(NotificationPublishService.class); } @Test diff --git a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/NodeConnectorNotificationSupplierImplTest.java b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/NodeConnectorNotificationSupplierImplTest.java index a75c5858c1..a14d6e2e2e 100644 --- a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/NodeConnectorNotificationSupplierImplTest.java +++ b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/NodeConnectorNotificationSupplierImplTest.java @@ -19,10 +19,10 @@ import java.util.ArrayList; import java.util.Collection; import org.junit.Before; import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataObjectModification; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestChangeEventBuildHelper; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestSupplierVerifyHelper; @@ -44,12 +44,12 @@ public class NodeConnectorNotificationSupplierImplTest { private static final String FLOW_NODE_ID = "openflow:111"; private static final String FLOW_CODE_CONNECTOR_ID = "test-con-111"; private NodeConnectorNotificationSupplierImpl notifSupplierImpl; - private NotificationProviderService notifProviderService; + private NotificationPublishService notifProviderService; private DataBroker dataBroker; @Before public void initalization() { - notifProviderService = mock(NotificationProviderService.class); + notifProviderService = mock(NotificationPublishService.class); dataBroker = mock(DataBroker.class); notifSupplierImpl = new NodeConnectorNotificationSupplierImpl(notifProviderService, dataBroker); TestSupplierVerifyHelper.verifyDataTreeChangeListenerRegistration(dataBroker); @@ -84,14 +84,13 @@ public class NodeConnectorNotificationSupplierImplTest { } @Test - public void testCreateChangeEvent() { - final TestData testData = new TestData(createTestFlowCapableConnectorNodePath(), null, - createTestFlowCapableNodeConnecor(), - DataObjectModification.ModificationType.WRITE); + public void testCreateChangeEvent() throws InterruptedException { + final TestData testData = new TestData<>(createTestFlowCapableConnectorNodePath(), + null, createTestFlowCapableNodeConnecor(), DataObjectModification.ModificationType.WRITE); Collection> collection = new ArrayList<>(); collection.add(testData); notifSupplierImpl.onDataTreeChanged(collection); - verify(notifProviderService, times(1)).publish(any(NodeConnectorUpdated.class)); + verify(notifProviderService, times(1)).putNotification(any(NodeConnectorUpdated.class)); } @Test(expected = IllegalArgumentException.class) @@ -117,14 +116,13 @@ public class NodeConnectorNotificationSupplierImplTest { } @Test - public void testDeleteChangeEvent() { - final TestData testData = new TestData(createTestFlowCapableConnectorNodePath(), - createTestFlowCapableNodeConnecor(), null, - DataObjectModification.ModificationType.DELETE); + public void testDeleteChangeEvent() throws InterruptedException { + final TestData testData = new TestData<>(createTestFlowCapableConnectorNodePath(), + createTestFlowCapableNodeConnecor(), null, DataObjectModification.ModificationType.DELETE); Collection> collection = new ArrayList<>(); collection.add(testData); notifSupplierImpl.onDataTreeChanged(collection); - verify(notifProviderService, times(1)).publish(any(NodeConnectorRemoved.class)); + verify(notifProviderService, times(1)).putNotification(any(NodeConnectorRemoved.class)); } @Test(expected = IllegalArgumentException.class) diff --git a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/NodeNotificationSupplierImplTest.java b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/NodeNotificationSupplierImplTest.java index 1b3e2665f1..570b0983c6 100644 --- a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/NodeNotificationSupplierImplTest.java +++ b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/NodeNotificationSupplierImplTest.java @@ -19,10 +19,10 @@ import java.util.ArrayList; import java.util.Collection; import org.junit.Before; import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataObjectModification; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestChangeEventBuildHelper; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestSupplierVerifyHelper; @@ -40,12 +40,12 @@ public class NodeNotificationSupplierImplTest { private static final String FLOW_NODE_ID = "openflow:111"; private NodeNotificationSupplierImpl notifSupplierImpl; - private NotificationProviderService notifProviderService; + private NotificationPublishService notifProviderService; private DataBroker dataBroker; @Before public void initalization() { - notifProviderService = mock(NotificationProviderService.class); + notifProviderService = mock(NotificationPublishService.class); dataBroker = mock(DataBroker.class); notifSupplierImpl = new NodeNotificationSupplierImpl(notifProviderService, dataBroker); TestSupplierVerifyHelper.verifyDataTreeChangeListenerRegistration(dataBroker); @@ -77,13 +77,13 @@ public class NodeNotificationSupplierImplTest { } @Test - public void testCreateChangeEvent() { - final TestData testData = new TestData(createTestFlowCapableNodePath(), null, createTestFlowCapableNode(), - DataObjectModification.ModificationType.WRITE); + public void testCreateChangeEvent() throws InterruptedException { + final TestData testData = new TestData<>(createTestFlowCapableNodePath(), null, + createTestFlowCapableNode(), DataObjectModification.ModificationType.WRITE); Collection> collection = new ArrayList<>(); collection.add(testData); notifSupplierImpl.onDataTreeChanged(collection); - verify(notifProviderService, times(1)).publish(any(NodeUpdated.class)); + verify(notifProviderService, times(1)).putNotification(any(NodeUpdated.class)); } @Test(expected = IllegalArgumentException.class) @@ -105,13 +105,13 @@ public class NodeNotificationSupplierImplTest { } @Test - public void testDeleteChangeEvent() { - final TestData testData = new TestData(createTestFlowCapableNodePath(), createTestFlowCapableNode(), null, - DataObjectModification.ModificationType.DELETE); + public void testDeleteChangeEvent() throws InterruptedException { + final TestData testData = new TestData<>(createTestFlowCapableNodePath(), + createTestFlowCapableNode(), null, DataObjectModification.ModificationType.DELETE); Collection> collection = new ArrayList<>(); collection.add(testData); notifSupplierImpl.onDataTreeChanged(collection); - verify(notifProviderService, times(1)).publish(any(NodeRemoved.class)); + verify(notifProviderService, times(1)).putNotification(any(NodeRemoved.class)); } @Test(expected = IllegalArgumentException.class) diff --git a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/helper/TestData.java b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/helper/TestData.java index 2a9420e3a7..70cbe4f7c3 100644 --- a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/helper/TestData.java +++ b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/helper/TestData.java @@ -5,22 +5,21 @@ * 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.openflowplugin.applications.notification.supplier.impl.helper; import java.util.Collection; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.DataObjectModification; +import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yangtools.yang.binding.Augmentation; import org.opendaylight.yangtools.yang.binding.ChildOf; +import org.opendaylight.yangtools.yang.binding.ChoiceIn; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.Identifiable; import org.opendaylight.yangtools.yang.binding.Identifier; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; /** * Created by eshuvka on 6/7/2016. @@ -32,17 +31,15 @@ public class TestData implements DataTreeModification { public TestData(final InstanceIdentifier path, final T dataBefore, final T dataAfter, DataObjectModification.ModificationType modType) { - this.path = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, path); - this.rootNode = new Test(dataBefore, dataAfter, modType); + this.path = DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, path); + this.rootNode = new Test<>(dataBefore, dataAfter, modType); } - @Nonnull @Override public DataTreeIdentifier getRootPath() { return path; } - @Nonnull @Override public DataObjectModification getRootNode() { return rootNode; @@ -61,65 +58,80 @@ public class TestData implements DataTreeModification { } @Override - public InstanceIdentifier.PathArgument getIdentifier() { + public PathArgument getIdentifier() { return null; } - @Nonnull @Override public Class getDataType() { return null; } - @Nonnull @Override public ModificationType getModificationType() { return modification; } - @Nullable @Override public T getDataBefore() { return dataObjBefore; } - @Nullable @Override public T getDataAfter() { return dataObjAfter; } - @Nonnull @Override public Collection> getModifiedChildren() { return null; } - @Nullable @Override - public > DataObjectModification getModifiedChildContainer( - @Nonnull Class theClass) { + public > Collection> getModifiedChildren( + Class childType) { + return null; + } + + @Override + public & DataObject, C extends ChildOf> + Collection> getModifiedChildren(Class caseType, Class childType) { + return null; + } + + @Override + public > DataObjectModification getModifiedChildContainer(Class theClass) { + return null; + } + + @Override + public & DataObject, C extends ChildOf> DataObjectModification + getModifiedChildContainer(Class caseType, Class child) { return null; } - @Nullable @Override public & DataObject> DataObjectModification getModifiedAugmentation( - @Nonnull Class theClass) { + Class theClass) { return null; } @Override public & ChildOf, K extends Identifier> DataObjectModification - getModifiedChildListItem(@Nonnull Class theClass, @Nonnull K listKey) { + getModifiedChildListItem(Class theClass, K listKey) { + return null; + } + + @Override + public & DataObject, C extends Identifiable & ChildOf, + K extends Identifier> DataObjectModification getModifiedChildListItem(Class caseType, + Class listItem, K listKey) { return null; } - @Nullable @Override - public DataObjectModification getModifiedChild( - InstanceIdentifier.PathArgument pathArgument) { + public DataObjectModification getModifiedChild(PathArgument pathArgument) { return null; } } -} \ No newline at end of file +} diff --git a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/helper/TestSupplierVerifyHelper.java b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/helper/TestSupplierVerifyHelper.java index 662d78d292..627d43127d 100644 --- a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/helper/TestSupplierVerifyHelper.java +++ b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/helper/TestSupplierVerifyHelper.java @@ -5,14 +5,13 @@ * 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.openflowplugin.applications.notification.supplier.impl.helper; import org.mockito.ArgumentMatchers; import org.mockito.Mockito; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataTreeChangeListener; +import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; public final class TestSupplierVerifyHelper { diff --git a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/FlowNotificationSupplierImplTest.java b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/FlowNotificationSupplierImplTest.java index 103d13f200..accd5362c3 100644 --- a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/FlowNotificationSupplierImplTest.java +++ b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/FlowNotificationSupplierImplTest.java @@ -5,7 +5,6 @@ * 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.openflowplugin.applications.notification.supplier.impl.item; import static org.junit.Assert.assertEquals; @@ -19,10 +18,10 @@ import java.util.ArrayList; import java.util.Collection; import org.junit.Before; import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataObjectModification; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestChangeEventBuildHelper; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestSupplierVerifyHelper; @@ -54,12 +53,12 @@ public class FlowNotificationSupplierImplTest { private static final String FLOW_ID = "test-flow-111"; private static final String UPDATED_FLOW_ID = "test-flow-100"; private FlowNotificationSupplierImpl notifSupplierImpl; - private NotificationProviderService notifProviderService; + private NotificationPublishService notifProviderService; private DataBroker dataBroker; @Before public void initalization() { - notifProviderService = mock(NotificationProviderService.class); + notifProviderService = mock(NotificationPublishService.class); dataBroker = mock(DataBroker.class); notifSupplierImpl = new FlowNotificationSupplierImpl(notifProviderService, dataBroker); TestSupplierVerifyHelper.verifyDataTreeChangeListenerRegistration(dataBroker); @@ -93,13 +92,13 @@ public class FlowNotificationSupplierImplTest { } @Test - public void testCreateChangeEvent() { - final TestData testData = new TestData(createTestFlowPath(), null, createTestFlow(), - DataObjectModification.ModificationType.WRITE); + public void testCreateChangeEvent() throws InterruptedException { + final TestData testData = new TestData<>(createTestFlowPath(), null, createTestFlow(), + DataObjectModification.ModificationType.WRITE); Collection> collection = new ArrayList<>(); collection.add(testData); notifSupplierImpl.onDataTreeChanged(collection); - verify(notifProviderService, times(1)).publish(any(FlowAdded.class)); + verify(notifProviderService, times(1)).putNotification(any(FlowAdded.class)); } @Test(expected = IllegalArgumentException.class) @@ -125,13 +124,13 @@ public class FlowNotificationSupplierImplTest { } @Test - public void testUpdateChangeEvent() { - final TestData testData = new TestData(createTestFlowPath(), createTestFlow(), createUpdatedTestFlow(), - DataObjectModification.ModificationType.SUBTREE_MODIFIED); + public void testUpdateChangeEvent() throws InterruptedException { + final TestData testData = new TestData<>(createTestFlowPath(), createTestFlow(), createUpdatedTestFlow(), + DataObjectModification.ModificationType.SUBTREE_MODIFIED); Collection> collection = new ArrayList<>(); collection.add(testData); notifSupplierImpl.onDataTreeChanged(collection); - verify(notifProviderService, times(1)).publish(any(FlowUpdated.class)); + verify(notifProviderService, times(1)).putNotification(any(FlowUpdated.class)); } @Test(expected = IllegalArgumentException.class) @@ -157,13 +156,13 @@ public class FlowNotificationSupplierImplTest { } @Test - public void testDeleteChangeEvent() { - final TestData testData = new TestData(createTestFlowPath(), createTestFlow(), null, - DataObjectModification.ModificationType.DELETE); + public void testDeleteChangeEvent() throws InterruptedException { + final TestData testData = new TestData<>(createTestFlowPath(), createTestFlow(), null, + DataObjectModification.ModificationType.DELETE); Collection> collection = new ArrayList<>(); collection.add(testData); notifSupplierImpl.onDataTreeChanged(collection); - verify(notifProviderService, times(1)).publish(any(FlowRemoved.class)); + verify(notifProviderService, times(1)).putNotification(any(FlowRemoved.class)); } @Test(expected = IllegalArgumentException.class) diff --git a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/GroupNotificationSupplierImplTest.java b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/GroupNotificationSupplierImplTest.java index bef02498ed..154c1302b2 100644 --- a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/GroupNotificationSupplierImplTest.java +++ b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/GroupNotificationSupplierImplTest.java @@ -5,7 +5,6 @@ * 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.openflowplugin.applications.notification.supplier.impl.item; import static org.junit.Assert.assertEquals; @@ -19,10 +18,10 @@ import java.util.ArrayList; import java.util.Collection; import org.junit.Before; import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataObjectModification; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestChangeEventBuildHelper; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestSupplierVerifyHelper; @@ -50,12 +49,12 @@ public class GroupNotificationSupplierImplTest { private static final Long UPDATED_GROUP_ID = 100L; private GroupNotificationSupplierImpl notifSupplierImpl; - private NotificationProviderService notifProviderService; + private NotificationPublishService notifProviderService; private DataBroker dataBroker; @Before public void initalization() { - notifProviderService = mock(NotificationProviderService.class); + notifProviderService = mock(NotificationPublishService.class); dataBroker = mock(DataBroker.class); notifSupplierImpl = new GroupNotificationSupplierImpl(notifProviderService, dataBroker); TestSupplierVerifyHelper.verifyDataTreeChangeListenerRegistration(dataBroker); @@ -89,13 +88,13 @@ public class GroupNotificationSupplierImplTest { } @Test - public void testCreateChangeEvent() { - final TestData testData = new TestData(createTestGroupPath(), null, createTestGroup(), - DataObjectModification.ModificationType.WRITE); + public void testCreateChangeEvent() throws InterruptedException { + final TestData testData = new TestData<>(createTestGroupPath(), null, createTestGroup(), + DataObjectModification.ModificationType.WRITE); Collection> collection = new ArrayList<>(); collection.add(testData); notifSupplierImpl.onDataTreeChanged(collection); - verify(notifProviderService, times(1)).publish(any(GroupAdded.class)); + verify(notifProviderService, times(1)).putNotification(any(GroupAdded.class)); } @Test(expected = IllegalArgumentException.class) @@ -122,13 +121,14 @@ public class GroupNotificationSupplierImplTest { } @Test - public void testUpdateChangeEvent() { - final TestData testData = new TestData(createTestGroupPath(), createTestGroup(), createUpdatedTestGroup(), - DataObjectModification.ModificationType.SUBTREE_MODIFIED); + public void testUpdateChangeEvent() throws InterruptedException { + final TestData testData = new TestData<>(createTestGroupPath(), createTestGroup(), + createUpdatedTestGroup(), + DataObjectModification.ModificationType.SUBTREE_MODIFIED); Collection> collection = new ArrayList<>(); collection.add(testData); notifSupplierImpl.onDataTreeChanged(collection); - verify(notifProviderService, times(1)).publish(any(GroupUpdated.class)); + verify(notifProviderService, times(1)).putNotification(any(GroupUpdated.class)); } @Test(expected = IllegalArgumentException.class) @@ -154,13 +154,13 @@ public class GroupNotificationSupplierImplTest { } @Test - public void testDeleteChangeEvent() { - final TestData testData = new TestData(createTestGroupPath(), createTestGroup(), null, - DataObjectModification.ModificationType.DELETE); + public void testDeleteChangeEvent() throws InterruptedException { + final TestData testData = new TestData<>(createTestGroupPath(), createTestGroup(), null, + DataObjectModification.ModificationType.DELETE); Collection> collection = new ArrayList<>(); collection.add(testData); notifSupplierImpl.onDataTreeChanged(collection); - verify(notifProviderService, times(1)).publish(any(GroupRemoved.class)); + verify(notifProviderService, times(1)).putNotification(any(GroupRemoved.class)); } @Test(expected = IllegalArgumentException.class) diff --git a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/MeterNotificationSupplierImplTest.java b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/MeterNotificationSupplierImplTest.java index c5bdd1a41d..e786f99eb9 100644 --- a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/MeterNotificationSupplierImplTest.java +++ b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/MeterNotificationSupplierImplTest.java @@ -5,7 +5,6 @@ * 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.openflowplugin.applications.notification.supplier.impl.item; import static org.junit.Assert.assertEquals; @@ -19,10 +18,10 @@ import java.util.ArrayList; import java.util.Collection; import org.junit.Before; import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataObjectModification; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestChangeEventBuildHelper; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestSupplierVerifyHelper; @@ -51,12 +50,12 @@ public class MeterNotificationSupplierImplTest { private static final Long UPDATED_METER_ID = 100L; private MeterNotificationSupplierImpl notifSupplierImpl; - private NotificationProviderService notifProviderService; + private NotificationPublishService notifProviderService; private DataBroker dataBroker; @Before public void initalization() { - notifProviderService = mock(NotificationProviderService.class); + notifProviderService = mock(NotificationPublishService.class); dataBroker = mock(DataBroker.class); notifSupplierImpl = new MeterNotificationSupplierImpl(notifProviderService, dataBroker); TestSupplierVerifyHelper.verifyDataTreeChangeListenerRegistration(dataBroker); @@ -90,13 +89,13 @@ public class MeterNotificationSupplierImplTest { } @Test - public void testCreateChangeEvent() { - final TestData testData = new TestData(createTestMeterPath(), null, createTestMeter(), - DataObjectModification.ModificationType.WRITE); + public void testCreateChangeEvent() throws InterruptedException { + final TestData testData = new TestData<>(createTestMeterPath(), null, createTestMeter(), + DataObjectModification.ModificationType.WRITE); Collection> collection = new ArrayList<>(); collection.add(testData); notifSupplierImpl.onDataTreeChanged(collection); - verify(notifProviderService, times(1)).publish(any(MeterAdded.class)); + verify(notifProviderService, times(1)).putNotification(any(MeterAdded.class)); } @Test(expected = IllegalArgumentException.class) @@ -123,13 +122,14 @@ public class MeterNotificationSupplierImplTest { } @Test - public void testUdateChangeEvent() { - final TestData testData = new TestData(createTestMeterPath(), createTestMeter(), createUpdatedTestMeter(), - DataObjectModification.ModificationType.SUBTREE_MODIFIED); + public void testUdateChangeEvent() throws InterruptedException { + final TestData testData = new TestData<>(createTestMeterPath(), createTestMeter(), + createUpdatedTestMeter(), + DataObjectModification.ModificationType.SUBTREE_MODIFIED); Collection> collection = new ArrayList<>(); collection.add(testData); notifSupplierImpl.onDataTreeChanged(collection); - verify(notifProviderService, times(1)).publish(any(MeterUpdated.class)); + verify(notifProviderService, times(1)).putNotification(any(MeterUpdated.class)); } @Test(expected = IllegalArgumentException.class) @@ -155,13 +155,13 @@ public class MeterNotificationSupplierImplTest { } @Test - public void testDeleteChangeEvent() { - final TestData testData = new TestData(createTestMeterPath(), createTestMeter(), null, - DataObjectModification.ModificationType.DELETE); + public void testDeleteChangeEvent() throws InterruptedException { + final TestData testData = new TestData<>(createTestMeterPath(), createTestMeter(), null, + DataObjectModification.ModificationType.DELETE); Collection> collection = new ArrayList<>(); collection.add(testData); notifSupplierImpl.onDataTreeChanged(collection); - verify(notifProviderService, times(1)).publish(any(MeterRemoved.class)); + verify(notifProviderService, times(1)).putNotification(any(MeterRemoved.class)); } @Test(expected = IllegalArgumentException.class) diff --git a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/FlowStatNotificationSupplierImplTest.java b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/FlowStatNotificationSupplierImplTest.java index 02deebd592..e4bb99ef5e 100644 --- a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/FlowStatNotificationSupplierImplTest.java +++ b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/FlowStatNotificationSupplierImplTest.java @@ -19,10 +19,10 @@ import java.util.ArrayList; import java.util.Collection; import org.junit.Before; import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataObjectModification; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestChangeEventBuildHelper; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestSupplierVerifyHelper; @@ -48,12 +48,12 @@ public class FlowStatNotificationSupplierImplTest { private static final Short FLOW_TABLE_ID = 111; private static final String FLOW_ID = "test-flow-111"; private FlowStatNotificationSupplierImpl notifSupplierImpl; - private NotificationProviderService notifProviderService; + private NotificationPublishService notifProviderService; private DataBroker dataBroker; @Before public void initalization() { - notifProviderService = mock(NotificationProviderService.class); + notifProviderService = mock(NotificationPublishService.class); dataBroker = mock(DataBroker.class); notifSupplierImpl = new FlowStatNotificationSupplierImpl(notifProviderService, dataBroker); TestSupplierVerifyHelper.verifyDataTreeChangeListenerRegistration(dataBroker); @@ -83,13 +83,13 @@ public class FlowStatNotificationSupplierImplTest { } @Test - public void testCreateChangeEvent() { - final TestData testData = new TestData(createTestFlowStatPath(), null, createTestFlowStat(), - DataObjectModification.ModificationType.WRITE); + public void testCreateChangeEvent() throws InterruptedException { + final TestData testData = new TestData<>(createTestFlowStatPath(), null, createTestFlowStat(), + DataObjectModification.ModificationType.WRITE); Collection> collection = new ArrayList<>(); collection.add(testData); notifSupplierImpl.onDataTreeChanged(collection); - verify(notifProviderService, times(1)).publish(any(FlowsStatisticsUpdate.class)); + verify(notifProviderService, times(1)).putNotification(any(FlowsStatisticsUpdate.class)); } @Test(expected = IllegalArgumentException.class) diff --git a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/FlowTableStatNotificationSupplierImplTest.java b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/FlowTableStatNotificationSupplierImplTest.java index 30871057ff..bf59a3d785 100644 --- a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/FlowTableStatNotificationSupplierImplTest.java +++ b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/FlowTableStatNotificationSupplierImplTest.java @@ -5,7 +5,6 @@ * 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.openflowplugin.applications.notification.supplier.impl.item.stat; import static org.junit.Assert.assertEquals; @@ -19,10 +18,10 @@ import java.util.ArrayList; import java.util.Collection; import org.junit.Before; import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataObjectModification; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestChangeEventBuildHelper; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestSupplierVerifyHelper; @@ -45,12 +44,12 @@ public class FlowTableStatNotificationSupplierImplTest { private static final Short FLOW_TABLE_ID = 111; private static final String FLOW_ID = "test-flow-111"; private FlowTableStatNotificationSupplierImpl notifSupplierImpl; - private NotificationProviderService notifProviderService; + private NotificationPublishService notifProviderService; private DataBroker dataBroker; @Before public void initalization() { - notifProviderService = mock(NotificationProviderService.class); + notifProviderService = mock(NotificationPublishService.class); dataBroker = mock(DataBroker.class); notifSupplierImpl = new FlowTableStatNotificationSupplierImpl(notifProviderService, dataBroker); TestSupplierVerifyHelper.verifyDataTreeChangeListenerRegistration(dataBroker); @@ -80,13 +79,14 @@ public class FlowTableStatNotificationSupplierImplTest { } @Test - public void testCreateChangeEvent() { - final TestData testData = new TestData(createTestFlowTableStatPath(), null, createTestFlowTableStat(), - DataObjectModification.ModificationType.WRITE); + public void testCreateChangeEvent() throws InterruptedException { + final TestData testData = new TestData<>(createTestFlowTableStatPath(), null, + createTestFlowTableStat(), + DataObjectModification.ModificationType.WRITE); Collection> collection = new ArrayList<>(); collection.add(testData); notifSupplierImpl.onDataTreeChanged(collection); - verify(notifProviderService, times(1)).publish(any(FlowTableStatisticsUpdate.class)); + verify(notifProviderService, times(1)).putNotification(any(FlowTableStatisticsUpdate.class)); } @Test(expected = IllegalArgumentException.class) diff --git a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/GroupStatNotificationSupplierImplTest.java b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/GroupStatNotificationSupplierImplTest.java index aeafe292ee..adaa3cbb08 100644 --- a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/GroupStatNotificationSupplierImplTest.java +++ b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/GroupStatNotificationSupplierImplTest.java @@ -5,7 +5,6 @@ * 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.openflowplugin.applications.notification.supplier.impl.item.stat; import static org.junit.Assert.assertEquals; @@ -19,10 +18,10 @@ import java.util.ArrayList; import java.util.Collection; import org.junit.Before; import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataObjectModification; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestChangeEventBuildHelper; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestSupplierVerifyHelper; @@ -45,12 +44,12 @@ public class GroupStatNotificationSupplierImplTest { private static final String FLOW_NODE_ID = "openflow:111"; private static final Long FLOW_TABLE_ID = 111L; private GroupStatNotificationSupplierImpl notifSupplierImpl; - private NotificationProviderService notifProviderService; + private NotificationPublishService notifProviderService; private DataBroker dataBroker; @Before public void initalization() { - notifProviderService = mock(NotificationProviderService.class); + notifProviderService = mock(NotificationPublishService.class); dataBroker = mock(DataBroker.class); notifSupplierImpl = new GroupStatNotificationSupplierImpl(notifProviderService, dataBroker); TestSupplierVerifyHelper.verifyDataTreeChangeListenerRegistration(dataBroker); @@ -80,13 +79,13 @@ public class GroupStatNotificationSupplierImplTest { } @Test - public void testCreateChangeEvent() { - final TestData testData = new TestData(createTestGroupStatPath(), null, createTestGroupStat(), - DataObjectModification.ModificationType.WRITE); + public void testCreateChangeEvent() throws InterruptedException { + final TestData testData = new TestData<>(createTestGroupStatPath(), null, + createTestGroupStat(), DataObjectModification.ModificationType.WRITE); Collection> collection = new ArrayList<>(); collection.add(testData); notifSupplierImpl.onDataTreeChanged(collection); - verify(notifProviderService, times(1)).publish(any(GroupStatisticsUpdated.class)); + verify(notifProviderService, times(1)).putNotification(any(GroupStatisticsUpdated.class)); } @Test(expected = IllegalArgumentException.class) diff --git a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/MeterStatNotificationSupplierImplTest.java b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/MeterStatNotificationSupplierImplTest.java index 6d6ea50751..090f4872fa 100644 --- a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/MeterStatNotificationSupplierImplTest.java +++ b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/MeterStatNotificationSupplierImplTest.java @@ -5,7 +5,6 @@ * 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.openflowplugin.applications.notification.supplier.impl.item.stat; import static org.junit.Assert.assertEquals; @@ -19,10 +18,10 @@ import java.util.ArrayList; import java.util.Collection; import org.junit.Before; import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataObjectModification; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestChangeEventBuildHelper; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestSupplierVerifyHelper; @@ -45,12 +44,12 @@ public class MeterStatNotificationSupplierImplTest { private static final String FLOW_NODE_ID = "openflow:111"; private static final Long FLOW_METER_ID = 111L; private MeterStatNotificationSupplierImpl notifSupplierImpl; - private NotificationProviderService notifProviderService; + private NotificationPublishService notifProviderService; private DataBroker dataBroker; @Before public void initalization() { - notifProviderService = mock(NotificationProviderService.class); + notifProviderService = mock(NotificationPublishService.class); dataBroker = mock(DataBroker.class); notifSupplierImpl = new MeterStatNotificationSupplierImpl(notifProviderService, dataBroker); TestSupplierVerifyHelper.verifyDataTreeChangeListenerRegistration(dataBroker); @@ -80,13 +79,13 @@ public class MeterStatNotificationSupplierImplTest { } @Test - public void testCreateChangeEvent() { - final TestData testData = new TestData(createTestMeterStatPath(),null,createTestMeterStat(), + public void testCreateChangeEvent() throws InterruptedException { + final TestData testData = new TestData<>(createTestMeterStatPath(),null,createTestMeterStat(), DataObjectModification.ModificationType.WRITE); Collection> collection = new ArrayList<>(); collection.add(testData); notifSupplierImpl.onDataTreeChanged(collection); - verify(notifProviderService, times(1)).publish(any(MeterStatisticsUpdated.class)); + verify(notifProviderService, times(1)).putNotification(any(MeterStatisticsUpdated.class)); } @Test(expected = IllegalArgumentException.class) diff --git a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/NodeConnectorStatNotificationSupplierImplTest.java b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/NodeConnectorStatNotificationSupplierImplTest.java index cd765c4f51..12ac9bf778 100644 --- a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/NodeConnectorStatNotificationSupplierImplTest.java +++ b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/NodeConnectorStatNotificationSupplierImplTest.java @@ -19,10 +19,10 @@ import java.util.ArrayList; import java.util.Collection; import org.junit.Before; import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataObjectModification; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestChangeEventBuildHelper; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestSupplierVerifyHelper; @@ -44,12 +44,12 @@ public class NodeConnectorStatNotificationSupplierImplTest { private static final String FLOW_NODE_ID = "openflow:111"; private static final String FLOW_CODE_CONNECTOR_ID = "test-con-111"; private NodeConnectorStatNotificationSupplierImpl notifSupplierImpl; - private NotificationProviderService notifProviderService; + private NotificationPublishService notifProviderService; private DataBroker dataBroker; @Before public void initalization() { - notifProviderService = mock(NotificationProviderService.class); + notifProviderService = mock(NotificationPublishService.class); dataBroker = mock(DataBroker.class); notifSupplierImpl = new NodeConnectorStatNotificationSupplierImpl(notifProviderService, dataBroker); TestSupplierVerifyHelper.verifyDataTreeChangeListenerRegistration(dataBroker); @@ -80,13 +80,13 @@ public class NodeConnectorStatNotificationSupplierImplTest { } @Test - public void testCreateChangeEvent() { - final TestData testData = new TestData(createTestConnectorStatPath(), null, createTestConnectorStat(), - DataObjectModification.ModificationType.WRITE); + public void testCreateChangeEvent() throws InterruptedException { + final TestData testData = new TestData<>(createTestConnectorStatPath(), + null, createTestConnectorStat(), DataObjectModification.ModificationType.WRITE); Collection> collection = new ArrayList<>(); collection.add(testData); notifSupplierImpl.onDataTreeChanged(collection); - verify(notifProviderService, times(1)).publish(any(NodeConnectorStatisticsUpdate.class)); + verify(notifProviderService, times(1)).putNotification(any(NodeConnectorStatisticsUpdate.class)); } @Test(expected = IllegalArgumentException.class) diff --git a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/QueueStatNotificationSupplierImplTest.java b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/QueueStatNotificationSupplierImplTest.java index 6604b31c57..a13987a58b 100644 --- a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/QueueStatNotificationSupplierImplTest.java +++ b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/QueueStatNotificationSupplierImplTest.java @@ -19,10 +19,10 @@ import java.util.ArrayList; import java.util.Collection; import org.junit.Before; import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataObjectModification; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestChangeEventBuildHelper; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData; import org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestSupplierVerifyHelper; @@ -46,12 +46,12 @@ public class QueueStatNotificationSupplierImplTest { private static final String FLOW_NODE_ID = "openflow:111"; private static final String FLOW_CODE_CONNECTOR_ID = "test-con-111"; private QueueStatNotificationSupplierImpl notifSupplierImpl; - private NotificationProviderService notifProviderService; + private NotificationPublishService notifProviderService; private DataBroker dataBroker; @Before public void initalization() { - notifProviderService = mock(NotificationProviderService.class); + notifProviderService = mock(NotificationPublishService.class); dataBroker = mock(DataBroker.class); notifSupplierImpl = new QueueStatNotificationSupplierImpl(notifProviderService, dataBroker); TestSupplierVerifyHelper.verifyDataTreeChangeListenerRegistration(dataBroker); @@ -82,13 +82,13 @@ public class QueueStatNotificationSupplierImplTest { } @Test - public void testCreateChangeEvent() { - final TestData testData = new TestData(createTestQueueStatPath(), null, createTestQueueStat(), - DataObjectModification.ModificationType.WRITE); + public void testCreateChangeEvent() throws InterruptedException { + final TestData testData = new TestData<>(createTestQueueStatPath(), + null, createTestQueueStat(), DataObjectModification.ModificationType.WRITE); Collection> collection = new ArrayList<>(); collection.add(testData); notifSupplierImpl.onDataTreeChanged(collection); - verify(notifProviderService, times(1)).publish(any(QueueStatisticsUpdate.class)); + verify(notifProviderService, times(1)).putNotification(any(QueueStatisticsUpdate.class)); } @Test(expected = IllegalArgumentException.class) diff --git a/applications/of-switch-config-pusher/pom.xml b/applications/of-switch-config-pusher/pom.xml index 18a98c0200..23cbb5dba5 100644 --- a/applications/of-switch-config-pusher/pom.xml +++ b/applications/of-switch-config-pusher/pom.xml @@ -15,12 +15,8 @@ openflowplugin-api - org.opendaylight.controller - sal-binding-api - - - org.opendaylight.controller - sal-binding-broker-impl + org.opendaylight.mdsal + mdsal-binding-api org.opendaylight.controller.model diff --git a/applications/of-switch-config-pusher/src/main/java/org/opendaylight/openflowplugin/openflow/ofswitch/config/DefaultConfigPusher.java b/applications/of-switch-config-pusher/src/main/java/org/opendaylight/openflowplugin/openflow/ofswitch/config/DefaultConfigPusher.java index 9ae9e180fa..93ef7e82f4 100644 --- a/applications/of-switch-config-pusher/src/main/java/org/opendaylight/openflowplugin/openflow/ofswitch/config/DefaultConfigPusher.java +++ b/applications/of-switch-config-pusher/src/main/java/org/opendaylight/openflowplugin/openflow/ofswitch/config/DefaultConfigPusher.java @@ -17,13 +17,13 @@ import javax.annotation.PreDestroy; import javax.inject.Inject; import javax.inject.Singleton; import org.apache.aries.blueprint.annotation.service.Reference; -import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.infrautils.utils.concurrent.JdkFutures; +import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType; +import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.OFConstants; import org.opendaylight.openflowplugin.applications.deviceownershipservice.DeviceOwnershipService; import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper; @@ -66,7 +66,7 @@ public class DefaultConfigPusher implements AutoCloseable, ClusteredDataTreeChan try { final InstanceIdentifier path = InstanceIdentifier.create(Nodes.class).child(Node.class) .augmentation(FlowCapableNode.class); - final DataTreeIdentifier identifier = new DataTreeIdentifier<>( + final DataTreeIdentifier identifier = DataTreeIdentifier.create( LogicalDatastoreType.OPERATIONAL, path); final SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES); listenerRegistration = looper.loopUntilNoException( diff --git a/applications/of-switch-config-pusher/src/test/java/org/opendaylight/openflowplugin/openflow/ofswitch/config/DefaultConfigPusherTest.java b/applications/of-switch-config-pusher/src/test/java/org/opendaylight/openflowplugin/openflow/ofswitch/config/DefaultConfigPusherTest.java index 48958ec855..6066452bab 100644 --- a/applications/of-switch-config-pusher/src/test/java/org/opendaylight/openflowplugin/openflow/ofswitch/config/DefaultConfigPusherTest.java +++ b/applications/of-switch-config-pusher/src/test/java/org/opendaylight/openflowplugin/openflow/ofswitch/config/DefaultConfigPusherTest.java @@ -23,12 +23,12 @@ import org.mockito.Captor; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataObjectModification; +import org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType; +import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.OFConstants; import org.opendaylight.openflowplugin.applications.deviceownershipservice.DeviceOwnershipService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; @@ -64,8 +64,8 @@ public class DefaultConfigPusherTest { doReturn(RpcResultBuilder.success().buildFuture()).when(nodeConfigService).setConfig(any()); defaultConfigPusher = new DefaultConfigPusher(nodeConfigService, Mockito.mock(DataBroker.class), deviceOwnershipService); - final DataTreeIdentifier identifier = - new DataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, NODE_IID); + final DataTreeIdentifier identifier = DataTreeIdentifier.create( + LogicalDatastoreType.OPERATIONAL, NODE_IID.augmentation(FlowCapableNode.class)); Mockito.when(dataTreeModification.getRootPath()).thenReturn(identifier); Mockito.when(dataTreeModification.getRootNode()).thenReturn(Mockito.mock(DataObjectModification.class)); Mockito.when(dataTreeModification.getRootNode().getModificationType()).thenReturn(ModificationType.WRITE); diff --git a/applications/reconciliation-framework/pom.xml b/applications/reconciliation-framework/pom.xml index ae9bf50ecd..5d1544d091 100644 --- a/applications/reconciliation-framework/pom.xml +++ b/applications/reconciliation-framework/pom.xml @@ -20,8 +20,8 @@ junit - org.opendaylight.controller - sal-binding-api + org.opendaylight.mdsal + mdsal-binding-api org.opendaylight.openflowplugin @@ -35,10 +35,6 @@ org.opendaylight.yangtools yang-common - - org.opendaylight.controller - sal-common-util - org.opendaylight.mdsal mdsal-singleton-common-api @@ -53,13 +49,13 @@ test - org.opendaylight.controller - sal-binding-broker-impl + org.opendaylight.mdsal + mdsal-binding-dom-adapter test - org.opendaylight.controller - sal-binding-broker-impl + org.opendaylight.mdsal + mdsal-binding-dom-adapter test test-jar diff --git a/applications/southbound-cli/pom.xml b/applications/southbound-cli/pom.xml index 37e046c374..c414ae75fb 100644 --- a/applications/southbound-cli/pom.xml +++ b/applications/southbound-cli/pom.xml @@ -20,8 +20,8 @@ junit - org.opendaylight.controller - sal-binding-api + org.opendaylight.mdsal + mdsal-binding-api org.opendaylight.openflowplugin @@ -35,10 +35,6 @@ org.opendaylight.yangtools yang-common - - org.opendaylight.controller - sal-common-util - org.opendaylight.mdsal mdsal-singleton-common-api @@ -53,13 +49,13 @@ test - org.opendaylight.controller - sal-binding-broker-impl + org.opendaylight.mdsal + mdsal-binding-dom-adapter test - org.opendaylight.controller - sal-binding-broker-impl + org.opendaylight.mdsal + mdsal-binding-dom-adapter test test-jar diff --git a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/ReconciliationServiceImpl.java b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/ReconciliationServiceImpl.java index 93a0674238..ad2d12166b 100644 --- a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/ReconciliationServiceImpl.java +++ b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/ReconciliationServiceImpl.java @@ -12,7 +12,6 @@ import static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.o import static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.reconciliation.service.rev180227.NodeReconcileState.State.FAILED; import static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.reconciliation.service.rev180227.NodeReconcileState.State.INPROGRESS; -import com.google.common.base.Optional; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.SettableFuture; import java.math.BigInteger; @@ -20,15 +19,16 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Optional; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.stream.Collectors; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.ReadTransaction; +import org.opendaylight.mdsal.binding.api.ReadWriteTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.applications.southboundcli.alarm.AlarmAgent; import org.opendaylight.openflowplugin.applications.southboundcli.util.OFNode; import org.opendaylight.openflowplugin.applications.southboundcli.util.ShellUtil; @@ -141,13 +141,13 @@ public class ReconciliationServiceImpl implements ReconciliationService, AutoClo InstanceIdentifier instanceIdentifier = InstanceIdentifier .builder(ReconciliationState.class).child(ReconciliationStateList.class, new ReconciliationStateListKey(new BigInteger(String.valueOf(nodeId)))).build(); - try (ReadOnlyTransaction tx = broker.newReadOnlyTransaction()) { + try (ReadTransaction tx = broker.newReadOnlyTransaction()) { return tx.read(LogicalDatastoreType.OPERATIONAL, instanceIdentifier).get(); } catch (InterruptedException | ExecutionException e) { LOG.error("Exception while reading reconciliation state for {}", nodeId, e); } - return Optional.absent(); + return Optional.empty(); } private ListenableFuture> buildErrorResponse(String msg) { @@ -232,7 +232,7 @@ public class ReconciliationServiceImpl implements ReconciliationService, AutoClo } try { tx.merge(LogicalDatastoreType.OPERATIONAL, instanceIdentifier, counterBuilder.build(), true); - tx.submit().get(); + tx.commit().get(); } catch (InterruptedException | ExecutionException e) { LOG.error("Exception while submitting counter for {}", nodeId, e); } @@ -245,7 +245,7 @@ public class ReconciliationServiceImpl implements ReconciliationService, AutoClo } catch (InterruptedException | ExecutionException e) { LOG.error("Exception while reading counter for node: {}", nodeId, e); } - return Optional.absent(); + return Optional.empty(); } private void updateReconciliationState(State state) { @@ -258,7 +258,7 @@ public class ReconciliationServiceImpl implements ReconciliationService, AutoClo .setState(state); try { tx.merge(LogicalDatastoreType.OPERATIONAL, instanceIdentifier, stateBuilder.build(), true); - tx.submit().get(); + tx.commit().get(); } catch (InterruptedException | ExecutionException e) { LOG.error("Exception while updating reconciliation state: {}", nodeId, e); } diff --git a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/cli/GetAllNodesCommandProvider.java b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/cli/GetAllNodesCommandProvider.java index 6ce3071bbe..5517d9ffbc 100644 --- a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/cli/GetAllNodesCommandProvider.java +++ b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/cli/GetAllNodesCommandProvider.java @@ -11,7 +11,7 @@ import java.util.Formatter; import java.util.List; import org.apache.felix.gogo.commands.Command; import org.apache.karaf.shell.console.OsgiCommandSupport; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.openflowplugin.applications.southboundcli.util.OFNode; import org.opendaylight.openflowplugin.applications.southboundcli.util.ShellUtil; import org.slf4j.Logger; diff --git a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/cli/ReconciliationCount.java b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/cli/ReconciliationCount.java index 7a6270a1f2..ae322c3d4b 100644 --- a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/cli/ReconciliationCount.java +++ b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/cli/ReconciliationCount.java @@ -12,7 +12,7 @@ import java.util.Formatter; import java.util.List; import org.apache.karaf.shell.commands.Command; import org.apache.karaf.shell.console.OsgiCommandSupport; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.openflowplugin.applications.southboundcli.util.ShellUtil; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.reconciliation.service.rev180227.reconciliation.counter.ReconcileCounter; diff --git a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/cli/ShowNodeCommandProvider.java b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/cli/ShowNodeCommandProvider.java index e44684bc83..b0bd7f4716 100644 --- a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/cli/ShowNodeCommandProvider.java +++ b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/cli/ShowNodeCommandProvider.java @@ -11,7 +11,7 @@ import java.util.Formatter; import org.apache.karaf.shell.commands.Command; import org.apache.karaf.shell.commands.Option; import org.apache.karaf.shell.console.OsgiCommandSupport; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.openflowplugin.applications.southboundcli.util.OFNode; import org.opendaylight.openflowplugin.applications.southboundcli.util.ShellUtil; diff --git a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/util/ShellUtil.java b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/util/ShellUtil.java index 086f4a3613..731d27b68e 100644 --- a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/util/ShellUtil.java +++ b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/util/ShellUtil.java @@ -8,15 +8,15 @@ package org.opendaylight.openflowplugin.applications.southboundcli.util; -import com.google.common.base.Optional; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Optional; import java.util.concurrent.ExecutionException; import javax.annotation.Nonnull; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.ReadTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; @@ -42,7 +42,7 @@ public final class ShellUtil { public static List getAllNodes(final DataBroker broker) { List nodes = null; InstanceIdentifier path = InstanceIdentifier.builder(Nodes.class).build(); - try (ReadOnlyTransaction tx = broker.newReadOnlyTransaction()) { + try (ReadTransaction tx = broker.newReadOnlyTransaction()) { Optional result = tx.read(LogicalDatastoreType.OPERATIONAL, path).get(); if (result.isPresent()) { nodes = result.get().getNode(); @@ -97,7 +97,7 @@ public final class ShellUtil { InstanceIdentifier path = InstanceIdentifier.builder(Nodes.class) .child(Node.class, new NodeKey(new NodeId(NODE_PREFIX + nodeId))).build(); - try (ReadOnlyTransaction tx = broker.newReadOnlyTransaction()) { + try (ReadTransaction tx = broker.newReadOnlyTransaction()) { Optional result = tx.read(LogicalDatastoreType.OPERATIONAL, path).get(); if (result.isPresent()) { Node node = result.get(); @@ -138,7 +138,7 @@ public final class ShellUtil { InstanceIdentifier instanceIdentifier = InstanceIdentifier .builder(ReconciliationCounter.class).build(); List output = Collections.emptyList(); - try (ReadOnlyTransaction tx = dataBroker.newReadOnlyTransaction()) { + try (ReadTransaction tx = dataBroker.newReadOnlyTransaction()) { Optional result = tx.read(LogicalDatastoreType.OPERATIONAL, instanceIdentifier).get(); if (result.isPresent()) { diff --git a/applications/southbound-cli/src/main/resources/OSGI-INF/blueprint/southbound-cli.xml b/applications/southbound-cli/src/main/resources/OSGI-INF/blueprint/southbound-cli.xml index 5a02135c48..658cc12355 100644 --- a/applications/southbound-cli/src/main/resources/OSGI-INF/blueprint/southbound-cli.xml +++ b/applications/southbound-cli/src/main/resources/OSGI-INF/blueprint/southbound-cli.xml @@ -5,7 +5,7 @@ odl:use-default-for-reference-types="true"> + interface="org.opendaylight.mdsal.binding.api.DataBroker"/> @@ -47,4 +47,4 @@ - \ No newline at end of file + diff --git a/applications/table-miss-enforcer/pom.xml b/applications/table-miss-enforcer/pom.xml index 302634184a..a1c613c0f8 100644 --- a/applications/table-miss-enforcer/pom.xml +++ b/applications/table-miss-enforcer/pom.xml @@ -20,12 +20,8 @@ - org.opendaylight.controller - sal-binding-api - - - org.opendaylight.controller - sal-binding-broker-impl + org.opendaylight.mdsal + mdsal-binding-api org.opendaylight.controller.model diff --git a/applications/table-miss-enforcer/src/main/java/org/opendaylight/openflowplugin/applications/tablemissenforcer/LLDPPacketPuntEnforcer.java b/applications/table-miss-enforcer/src/main/java/org/opendaylight/openflowplugin/applications/tablemissenforcer/LLDPPacketPuntEnforcer.java index 4ff687b063..f4eaeea901 100644 --- a/applications/table-miss-enforcer/src/main/java/org/opendaylight/openflowplugin/applications/tablemissenforcer/LLDPPacketPuntEnforcer.java +++ b/applications/table-miss-enforcer/src/main/java/org/opendaylight/openflowplugin/applications/tablemissenforcer/LLDPPacketPuntEnforcer.java @@ -15,13 +15,13 @@ import java.util.Collection; import java.util.List; import java.util.concurrent.Future; import javax.annotation.Nonnull; -import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.infrautils.utils.concurrent.JdkFutures; +import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType; +import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.OFConstants; import org.opendaylight.openflowplugin.applications.deviceownershipservice.DeviceOwnershipService; import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper; @@ -82,7 +82,7 @@ public class LLDPPacketPuntEnforcer implements AutoCloseable, ClusteredDataTreeC public void start() { final InstanceIdentifier path = InstanceIdentifier.create(Nodes.class).child(Node.class) .augmentation(FlowCapableNode.class); - final DataTreeIdentifier identifier = new DataTreeIdentifier<>( + final DataTreeIdentifier identifier = DataTreeIdentifier.create( LogicalDatastoreType.OPERATIONAL, path); SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES); try { diff --git a/applications/table-miss-enforcer/src/main/resources/OSGI-INF/blueprint/table-miss-enforcer.xml b/applications/table-miss-enforcer/src/main/resources/OSGI-INF/blueprint/table-miss-enforcer.xml index a2d736894f..dee7a071de 100644 --- a/applications/table-miss-enforcer/src/main/resources/OSGI-INF/blueprint/table-miss-enforcer.xml +++ b/applications/table-miss-enforcer/src/main/resources/OSGI-INF/blueprint/table-miss-enforcer.xml @@ -3,7 +3,7 @@ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0" odl:use-default-for-reference-types="true"> - + @@ -14,4 +14,4 @@ - \ No newline at end of file + diff --git a/applications/table-miss-enforcer/src/test/java/org/opendaylight/openflowplugin/applications/tablemissenforcer/LLDPDataTreeChangeListenerTest.java b/applications/table-miss-enforcer/src/test/java/org/opendaylight/openflowplugin/applications/tablemissenforcer/LLDPDataTreeChangeListenerTest.java index 3ba16ab8c5..26d9ba9558 100644 --- a/applications/table-miss-enforcer/src/test/java/org/opendaylight/openflowplugin/applications/tablemissenforcer/LLDPDataTreeChangeListenerTest.java +++ b/applications/table-miss-enforcer/src/test/java/org/opendaylight/openflowplugin/applications/tablemissenforcer/LLDPDataTreeChangeListenerTest.java @@ -24,13 +24,13 @@ import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataObjectModification; +import org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType; +import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.applications.deviceownershipservice.DeviceOwnershipService; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action; @@ -70,8 +70,8 @@ public class LLDPDataTreeChangeListenerTest { doReturn(RpcResultBuilder.success().buildFuture()).when(flowService).addFlow(any()); lldpPacketPuntEnforcer = new LLDPPacketPuntEnforcer(flowService, Mockito.mock(DataBroker.class), deviceOwnershipService); - final DataTreeIdentifier identifier = new DataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, - NODE_IID); + final DataTreeIdentifier identifier = DataTreeIdentifier.create( + LogicalDatastoreType.OPERATIONAL, NODE_IID.augmentation(FlowCapableNode.class)); Mockito.when(dataTreeModification.getRootPath()).thenReturn(identifier); Mockito.when(dataTreeModification.getRootNode()).thenReturn(Mockito.mock(DataObjectModification.class)); Mockito.when(dataTreeModification.getRootNode().getModificationType()).thenReturn(ModificationType.WRITE); diff --git a/applications/topology-lldp-discovery/pom.xml b/applications/topology-lldp-discovery/pom.xml index e3627d2c37..7ab83ff2c0 100644 --- a/applications/topology-lldp-discovery/pom.xml +++ b/applications/topology-lldp-discovery/pom.xml @@ -26,8 +26,8 @@ commons-lang - org.opendaylight.controller - sal-binding-api + org.opendaylight.mdsal + mdsal-binding-api org.opendaylight.mdsal diff --git a/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPActivator.java b/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPActivator.java index ff1daf03c8..5733c6a185 100644 --- a/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPActivator.java +++ b/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPActivator.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the @@ -12,7 +12,7 @@ import javax.annotation.PreDestroy; import javax.inject.Inject; import javax.inject.Singleton; import org.apache.aries.blueprint.annotation.service.Reference; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.NotificationService; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.lldp.discovery.config.rev160511.TopologyLldpDiscoveryConfig; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.binding.NotificationListener; @@ -29,7 +29,7 @@ public class LLDPActivator implements AutoCloseable { @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD") @Inject - public LLDPActivator(@Reference NotificationProviderService notificationService, + public LLDPActivator(@Reference NotificationService notificationService, LLDPDiscoveryListener lldpDiscoveryListener, TopologyLldpDiscoveryConfig topologyLldpDiscoveryConfig) { lldpSecureKey = topologyLldpDiscoveryConfig.getLldpSecureKey(); diff --git a/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPDiscoveryListener.java b/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPDiscoveryListener.java index b5363da4b7..aba6fd942a 100644 --- a/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPDiscoveryListener.java +++ b/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPDiscoveryListener.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the @@ -10,7 +10,7 @@ package org.opendaylight.openflowplugin.applications.topology.lldp; import javax.inject.Inject; import javax.inject.Singleton; import org.apache.aries.blueprint.annotation.service.Reference; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService; import org.opendaylight.openflowplugin.applications.topology.lldp.utils.LLDPDiscoveryUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkDiscovered; @@ -28,11 +28,11 @@ public class LLDPDiscoveryListener implements PacketProcessingListener { private static final Logger LOG = LoggerFactory.getLogger(LLDPDiscoveryListener.class); private final LLDPLinkAger lldpLinkAger; - private final NotificationProviderService notificationService; + private final NotificationPublishService notificationService; private final EntityOwnershipService eos; @Inject - public LLDPDiscoveryListener(@Reference final NotificationProviderService notificationService, + public LLDPDiscoveryListener(@Reference final NotificationPublishService notificationService, final LLDPLinkAger lldpLinkAger, @Reference final EntityOwnershipService entityOwnershipService) { this.notificationService = notificationService; this.lldpLinkAger = lldpLinkAger; @@ -54,7 +54,11 @@ public class LLDPDiscoveryListener implements PacketProcessingListener { lldpLinkAger.put(ld); if (LLDPDiscoveryUtils.isEntityOwned(this.eos, nodeKey.getId().getValue())) { LOG.debug("Publish add event for link {}", ld); - notificationService.publish(ld); + try { + notificationService.putNotification(ld); + } catch (InterruptedException e) { + LOG.warn("Interrupted while publishing notification {}", ld, e); + } } else { LOG.trace("Skip publishing the add event for link because controller is non-owner of the " + "node {}. Link : {}", nodeKey.getId().getValue(), ld); diff --git a/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPLinkAger.java b/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPLinkAger.java index 22ffb11b11..a87ccad0e2 100644 --- a/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPLinkAger.java +++ b/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPLinkAger.java @@ -20,12 +20,13 @@ import javax.annotation.PreDestroy; import javax.inject.Inject; import javax.inject.Singleton; import org.apache.aries.blueprint.annotation.service.Reference; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService; import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationListener; import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService; import org.opendaylight.openflowplugin.applications.topology.lldp.utils.LLDPDiscoveryUtils; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkDiscovered; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkRemoved; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkRemovedBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; @@ -39,7 +40,7 @@ public class LLDPLinkAger implements ConfigurationListener, AutoCloseable { private final long linkExpirationTime; private final Map linkToDate; private final Timer timer; - private final NotificationProviderService notificationService; + private final NotificationPublishService notificationService; private final AutoCloseable configurationServiceRegistration; private final EntityOwnershipService eos; @@ -48,7 +49,7 @@ public class LLDPLinkAger implements ConfigurationListener, AutoCloseable { */ @Inject public LLDPLinkAger(final TopologyLldpDiscoveryConfig topologyLldpDiscoveryConfig, - @Reference final NotificationProviderService notificationService, + @Reference final NotificationPublishService notificationService, @Reference final ConfigurationService configurationService, @Reference final EntityOwnershipService entityOwnershipService) { this.linkExpirationTime = topologyLldpDiscoveryConfig.getTopologyLldpExpirationInterval().getValue(); @@ -92,7 +93,12 @@ public class LLDPLinkAger implements ConfigurationListener, AutoCloseable { linkToDate.remove(link); if (nodeKey != null && LLDPDiscoveryUtils.isEntityOwned(eos, nodeKey.getId().getValue())) { LOG.info("Publish Link Remove event for the link {}", link); - notificationService.publish(lrb.build()); + final LinkRemoved lr = lrb.build(); + try { + notificationService.putNotification(lr); + } catch (InterruptedException e) { + LOG.warn("Interrupted while publishing notification {}", lr, e); + } } else { LOG.trace("Skip publishing Link Remove event for the link {} because link destination " + "node is not owned by the controller", link); diff --git a/applications/topology-lldp-discovery/src/test/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPLinkAgerTest.java b/applications/topology-lldp-discovery/src/test/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPLinkAgerTest.java index 5b91031d29..f94fac3fad 100644 --- a/applications/topology-lldp-discovery/src/test/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPLinkAgerTest.java +++ b/applications/topology-lldp-discovery/src/test/java/org/opendaylight/openflowplugin/applications/topology/lldp/LLDPLinkAgerTest.java @@ -14,14 +14,13 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.verify; import java.util.Optional; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.mdsal.eos.binding.api.Entity; import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService; import org.opendaylight.mdsal.eos.common.api.EntityOwnershipState; @@ -61,7 +60,7 @@ public class LLDPLinkAgerTest { @Mock private LinkDiscovered link; @Mock - private NotificationProviderService notificationService; + private NotificationPublishService notificationService; @Mock private EntityOwnershipService eos; @Mock @@ -96,7 +95,7 @@ public class LLDPLinkAgerTest { public void testLLDPAgingTask() throws InterruptedException { lldpLinkAger.put(link); Thread.sleep(SLEEP); - verify(notificationService).publish(any(LinkRemoved.class)); + verify(notificationService).putNotification(any(LinkRemoved.class)); } private TopologyLldpDiscoveryConfig getConfig() { diff --git a/applications/topology-manager/pom.xml b/applications/topology-manager/pom.xml index 5c8b5c411b..4221ff9b14 100644 --- a/applications/topology-manager/pom.xml +++ b/applications/topology-manager/pom.xml @@ -18,12 +18,8 @@ guava - org.opendaylight.controller - sal-binding-api - - - org.opendaylight.controller - sal-binding-util + org.opendaylight.mdsal + mdsal-binding-api org.opendaylight.mdsal diff --git a/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/DataTreeChangeListenerImpl.java b/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/DataTreeChangeListenerImpl.java index b01b80187e..c2e1a387fa 100644 --- a/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/DataTreeChangeListenerImpl.java +++ b/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/DataTreeChangeListenerImpl.java @@ -7,10 +7,10 @@ */ package org.opendaylight.openflowplugin.applications.topology.manager; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataTreeChangeListener; +import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; @@ -40,7 +40,7 @@ public abstract class DataTreeChangeListenerImpl implement @SuppressWarnings("checkstyle:IllegalCatch") public DataTreeChangeListenerImpl(final OperationProcessor operationProcessor, final DataBroker dataBroker, final InstanceIdentifier ii) { - final DataTreeIdentifier identifier = new DataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, ii); + final DataTreeIdentifier identifier = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, ii); final SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES); try { listenerRegistration = looper.loopUntilNoException( diff --git a/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/FlowCapableTopologyExporter.java b/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/FlowCapableTopologyExporter.java index 176df70557..423e404c69 100644 --- a/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/FlowCapableTopologyExporter.java +++ b/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/FlowCapableTopologyExporter.java @@ -9,10 +9,10 @@ package org.opendaylight.openflowplugin.applications.topology.manager; import static org.opendaylight.openflowplugin.applications.topology.manager.FlowCapableNodeMapping.toTopologyLink; -import com.google.common.base.Optional; import com.google.common.base.Preconditions; +import java.util.Optional; import java.util.concurrent.ExecutionException; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.common.txchain.TransactionChainManager; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.FlowTopologyDiscoveryListener; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkDiscovered; @@ -64,7 +64,7 @@ class FlowCapableTopologyExporter implements FlowTopologyDiscoveryListener { processor.enqueueOperation(new TopologyOperation() { @Override public void applyOperation(final TransactionChainManager manager) { - Optional linkOptional = Optional.absent(); + Optional linkOptional = Optional.empty(); try { // read that checks if link exists (if we do not do this we might get an exception on delete) linkOptional = manager.readFromTransaction(LogicalDatastoreType.OPERATIONAL, diff --git a/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/FlowCapableTopologyProvider.java b/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/FlowCapableTopologyProvider.java index b17c1159d8..6d418c8e2f 100644 --- a/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/FlowCapableTopologyProvider.java +++ b/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/FlowCapableTopologyProvider.java @@ -7,9 +7,9 @@ */ package org.opendaylight.openflowplugin.applications.topology.manager; -import com.google.common.base.Optional; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; +import java.util.Optional; import java.util.concurrent.ExecutionException; import javax.annotation.Nonnull; import javax.annotation.PostConstruct; @@ -17,9 +17,9 @@ import javax.annotation.PreDestroy; import javax.inject.Inject; import javax.inject.Singleton; import org.apache.aries.blueprint.annotation.service.Reference; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationService; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration; @@ -43,7 +43,7 @@ public class FlowCapableTopologyProvider implements ClusterSingletonService, Aut static final String TOPOLOGY_ID = "flow:1"; private final DataBroker dataBroker; - private final NotificationProviderService notificationService; + private final NotificationService notificationService; private final OperationProcessor processor; private final ClusterSingletonServiceProvider clusterSingletonServiceProvider; private InstanceIdentifier topologyPathIID; @@ -53,7 +53,7 @@ public class FlowCapableTopologyProvider implements ClusterSingletonService, Aut @Inject public FlowCapableTopologyProvider(@Reference final DataBroker dataBroker, - @Reference final NotificationProviderService notificationService, + @Reference final NotificationService notificationService, final OperationProcessor processor, @Reference final ClusterSingletonServiceProvider clusterSingletonServiceProvider) { diff --git a/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/NodeChangeListenerImpl.java b/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/NodeChangeListenerImpl.java index 596e671aa4..156d9745ae 100644 --- a/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/NodeChangeListenerImpl.java +++ b/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/NodeChangeListenerImpl.java @@ -13,9 +13,9 @@ import javax.annotation.PreDestroy; import javax.inject.Inject; import javax.inject.Singleton; import org.apache.aries.blueprint.annotation.service.Reference; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; diff --git a/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/OperationProcessor.java b/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/OperationProcessor.java index 8a9963f30a..3312779c8e 100644 --- a/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/OperationProcessor.java +++ b/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/OperationProcessor.java @@ -14,7 +14,7 @@ import javax.annotation.PreDestroy; import javax.inject.Inject; import javax.inject.Singleton; import org.apache.aries.blueprint.annotation.service.Reference; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.openflowplugin.common.txchain.TransactionChainManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -28,7 +28,7 @@ public final class OperationProcessor implements AutoCloseable, Runnable { private final BlockingQueue queue = new LinkedBlockingQueue<>(OPERATION_QUEUE_DEPTH); private final Thread thread; - private TransactionChainManager transactionChainManager; + private final TransactionChainManager transactionChainManager; private volatile boolean finishing = false; @Inject diff --git a/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/TerminationPointChangeListenerImpl.java b/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/TerminationPointChangeListenerImpl.java index e166bd6e83..6831af0bcb 100644 --- a/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/TerminationPointChangeListenerImpl.java +++ b/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/TerminationPointChangeListenerImpl.java @@ -15,9 +15,9 @@ import javax.annotation.PreDestroy; import javax.inject.Inject; import javax.inject.Singleton; import org.apache.aries.blueprint.annotation.service.Reference; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; @@ -91,8 +91,7 @@ public class TerminationPointChangeListenerImpl extends DataTreeChangeListenerIm .topology.topology.Node> nodeOptional = Optional.empty(); try { - nodeOptional = Optional.ofNullable( - manager.readFromTransaction(LogicalDatastoreType.OPERATIONAL, node).get().orNull()); + nodeOptional = manager.readFromTransaction(LogicalDatastoreType.OPERATIONAL, node).get(); } catch (InterruptedException | ExecutionException e) { LOG.warn("Error occurred when trying to read NodeConnector: {}", e.getMessage()); LOG.debug("Error occurred when trying to read NodeConnector.. ", e); @@ -130,9 +129,9 @@ public class TerminationPointChangeListenerImpl extends DataTreeChangeListenerIm private void removeLinks(final FlowCapableNodeConnector flowCapNodeConnector, final TerminationPoint point) { operationProcessor.enqueueOperation(manager -> { - if ((flowCapNodeConnector.getState() != null && flowCapNodeConnector.getState().isLinkDown()) || ( - flowCapNodeConnector.getConfiguration() != null && flowCapNodeConnector.getConfiguration() - .isPORTDOWN())) { + if (flowCapNodeConnector.getState() != null && flowCapNodeConnector.getState().isLinkDown() + || flowCapNodeConnector.getConfiguration() != null + && flowCapNodeConnector.getConfiguration().isPORTDOWN()) { TopologyManagerUtil.removeAffectedLinks(point.getTpId(), manager, II_TO_TOPOLOGY); } }); diff --git a/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/TopologyManagerUtil.java b/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/TopologyManagerUtil.java index d2577e25df..88b6dfc7b5 100644 --- a/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/TopologyManagerUtil.java +++ b/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/TopologyManagerUtil.java @@ -7,11 +7,11 @@ */ package org.opendaylight.openflowplugin.applications.topology.manager; -import com.google.common.base.Optional; import java.util.Collections; import java.util.List; +import java.util.Optional; import java.util.concurrent.ExecutionException; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.common.txchain.TransactionChainManager; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId; @@ -30,7 +30,7 @@ final class TopologyManagerUtil { static void removeAffectedLinks(final NodeId id, final TransactionChainManager manager, InstanceIdentifier topology) { - Optional topologyOptional = Optional.absent(); + Optional topologyOptional = Optional.empty(); try { topologyOptional = manager.readFromTransaction(LogicalDatastoreType.OPERATIONAL, topology).get(); } catch (InterruptedException | ExecutionException e) { @@ -60,7 +60,7 @@ final class TopologyManagerUtil { static void removeAffectedLinks(final TpId id, final TransactionChainManager manager, final InstanceIdentifier topology) { - Optional topologyOptional = Optional.absent(); + Optional topologyOptional = Optional.empty(); try { topologyOptional = manager.readFromTransaction(LogicalDatastoreType.OPERATIONAL, topology).get(); } catch (InterruptedException | ExecutionException e) { diff --git a/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/DataTreeChangeListenerBase.java b/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/DataTreeChangeListenerBase.java index db653707c3..a53ddc789a 100644 --- a/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/DataTreeChangeListenerBase.java +++ b/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/DataTreeChangeListenerBase.java @@ -18,14 +18,14 @@ import org.junit.After; import org.junit.Before; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataObjectModification; +import org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType; +import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.binding.api.TransactionChain; +import org.opendaylight.mdsal.binding.api.TransactionChainListener; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig; @@ -47,7 +47,7 @@ public abstract class DataTreeChangeListenerBase { @Mock private DataBroker mockDataBroker; @Mock - protected BindingTransactionChain mockTxChain; + protected TransactionChain mockTxChain; @Before public void setUp() { @@ -78,10 +78,10 @@ public abstract class DataTreeChangeListenerBase { return builder.build(); } - protected DataTreeModification setupDataTreeChange(final ModificationType type, + protected DataTreeModification setupDataTreeChange(final ModificationType type, final InstanceIdentifier ii) { final DataTreeModification dataTreeModification = mock(DataTreeModification.class); - final DataTreeIdentifier identifier = new DataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, ii); + final DataTreeIdentifier identifier = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, ii); when(dataTreeModification.getRootNode()).thenReturn(mock(DataObjectModification.class)); when(dataTreeModification.getRootNode().getModificationType()).thenReturn(type); when(dataTreeModification.getRootPath()).thenReturn(identifier); diff --git a/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/FlowCapableTopologyExporterTest.java b/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/FlowCapableTopologyExporterTest.java index b9ed578c09..7ca06ca0c3 100644 --- a/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/FlowCapableTopologyExporterTest.java +++ b/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/FlowCapableTopologyExporterTest.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.openflowplugin.applications.topology.manager; import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.any; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; @@ -24,8 +23,7 @@ import static org.opendaylight.openflowplugin.applications.topology.manager.Test import static org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.setupStubbedSubmit; import static org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.waitForSubmit; -import com.google.common.base.Optional; -import com.google.common.util.concurrent.Futures; +import java.util.Optional; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -35,11 +33,11 @@ import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.ReadWriteTransaction; +import org.opendaylight.mdsal.binding.api.TransactionChain; +import org.opendaylight.mdsal.binding.api.TransactionChainListener; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkDiscoveredBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkRemovedBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef; @@ -50,6 +48,7 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology. import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.LinkKey; +import org.opendaylight.yangtools.util.concurrent.FluentFutures; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class FlowCapableTopologyExporterTest { @@ -61,7 +60,7 @@ public class FlowCapableTopologyExporterTest { @Mock private DataBroker mockDataBroker; @Mock - private BindingTransactionChain mockTxChain; + private TransactionChain mockTxChain; @Before public void setUp() { @@ -144,7 +143,7 @@ public class FlowCapableTopologyExporterTest { ReadWriteTransaction mockTx = mock(ReadWriteTransaction.class); final CountDownLatch submitLatch = setupStubbedSubmit(mockTx); doReturn(mockTx).when(mockTxChain).newReadWriteTransaction(); - doReturn(Futures.immediateCheckedFuture(Optional.of(link))).when(mockTx) + doReturn(FluentFutures.immediateFluentFuture(Optional.of(link))).when(mockTx) .read(LogicalDatastoreType.OPERATIONAL, topologyIID.child(Link.class, new LinkKey(new LinkId(sourceNodeConnKey.getId())))); @@ -176,7 +175,7 @@ public class FlowCapableTopologyExporterTest { ReadWriteTransaction mockTx = mock(ReadWriteTransaction.class); final CountDownLatch submitLatch = setupStubbedSubmit(mockTx); doReturn(mockTx).when(mockTxChain).newReadWriteTransaction(); - doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockTx) + doReturn(FluentFutures.immediateFluentFuture(Optional.empty())).when(mockTx) .read(LogicalDatastoreType.OPERATIONAL, topologyIID.child(Link.class, new LinkKey(new LinkId(sourceNodeConnKey.getId())))); diff --git a/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/NodeChangeListenerImplTest.java b/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/NodeChangeListenerImplTest.java index dd0848d755..526012ddde 100644 --- a/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/NodeChangeListenerImplTest.java +++ b/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/NodeChangeListenerImplTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the @@ -13,8 +13,8 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType.DELETE; -import static org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType.WRITE; +import static org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType.DELETE; +import static org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType.WRITE; import static org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.assertDeletedIDs; import static org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newDestNode; import static org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newInvNodeKey; @@ -27,19 +27,17 @@ import static org.opendaylight.openflowplugin.applications.topology.manager.Test import static org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.waitForDeletes; import static org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.waitForSubmit; -import com.google.common.base.Optional; -import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.SettableFuture; import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Optional; import java.util.concurrent.CountDownLatch; import org.junit.Test; import org.mockito.ArgumentCaptor; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.binding.api.ReadWriteTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.topology.inventory.rev131030.InventoryNode; @@ -50,6 +48,7 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology. import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey; +import org.opendaylight.yangtools.util.concurrent.FluentFutures; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class NodeChangeListenerImplTest extends DataTreeChangeListenerBase { @@ -81,13 +80,11 @@ public class NodeChangeListenerImplTest extends DataTreeChangeListenerBase { SettableFuture> readFuture = SettableFuture.create(); readFuture.set(Optional.of(topology)); ReadWriteTransaction mockTx1 = mock(ReadWriteTransaction.class); - doReturn(Futures.makeChecked(readFuture, ReadFailedException.MAPPER)).when(mockTx1) - .read(LogicalDatastoreType.OPERATIONAL, topologyIID); + doReturn(readFuture).when(mockTx1).read(LogicalDatastoreType.OPERATIONAL, topologyIID); SettableFuture> readFutureNode = SettableFuture.create(); readFutureNode.set(Optional.of(topoNode)); - doReturn(Futures.makeChecked(readFutureNode, ReadFailedException.MAPPER)).when(mockTx1) - .read(LogicalDatastoreType.OPERATIONAL, topoNodeII); + doReturn(readFutureNode).when(mockTx1).read(LogicalDatastoreType.OPERATIONAL, topoNodeII); final CountDownLatch submitLatch1 = setupStubbedSubmit(mockTx1); @@ -132,14 +129,12 @@ public class NodeChangeListenerImplTest extends DataTreeChangeListenerBase { }; ReadWriteTransaction mockTx = mock(ReadWriteTransaction.class); - doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockTx) + doReturn(FluentFutures.immediateFluentFuture(Optional.empty())).when(mockTx) .read(LogicalDatastoreType.OPERATIONAL, topologyIID); final CountDownLatch submitLatch = setupStubbedSubmit(mockTx); - SettableFuture> readFutureNode = SettableFuture.create(); - readFutureNode.set(Optional.of(topoNode)); - doReturn(Futures.makeChecked(readFutureNode, ReadFailedException.MAPPER)).when(mockTx) - .read(LogicalDatastoreType.OPERATIONAL, topoNodeII); + doReturn(FluentFutures.immediateFluentFuture(Optional.of(topoNode))).when(mockTx) + .read(LogicalDatastoreType.OPERATIONAL, topoNodeII); CountDownLatch deleteLatch = new CountDownLatch(1); ArgumentCaptor deletedLinkIDs = diff --git a/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/TerminationPointChangeListenerImplTest.java b/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/TerminationPointChangeListenerImplTest.java index f471e66b66..a7b7f7dbe0 100644 --- a/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/TerminationPointChangeListenerImplTest.java +++ b/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/TerminationPointChangeListenerImplTest.java @@ -15,8 +15,8 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import static org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType.DELETE; -import static org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType.WRITE; +import static org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType.DELETE; +import static org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType.WRITE; import static org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.assertDeletedIDs; import static org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newDestTp; import static org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newInvNodeConnKey; @@ -31,19 +31,17 @@ import static org.opendaylight.openflowplugin.applications.topology.manager.Test import static org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.waitForDeletes; import static org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.waitForSubmit; -import com.google.common.base.Optional; -import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.SettableFuture; import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Optional; import java.util.concurrent.CountDownLatch; import org.junit.Test; import org.mockito.ArgumentCaptor; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.binding.api.ReadWriteTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.topology.inventory.rev131030.InventoryNodeConnector; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; @@ -56,6 +54,7 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology. import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey; +import org.opendaylight.yangtools.util.concurrent.FluentFutures; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class TerminationPointChangeListenerImplTest extends DataTreeChangeListenerBase { @@ -93,13 +92,11 @@ public class TerminationPointChangeListenerImplTest extends DataTreeChangeListen final SettableFuture> readFuture = SettableFuture.create(); readFuture.set(Optional.of(topology)); ReadWriteTransaction mockTx1 = mock(ReadWriteTransaction.class); - doReturn(Futures.makeChecked(readFuture, ReadFailedException.MAPPER)).when(mockTx1) - .read(LogicalDatastoreType.OPERATIONAL, topologyIID); + doReturn(readFuture).when(mockTx1).read(LogicalDatastoreType.OPERATIONAL, topologyIID); SettableFuture> readFutureNode = SettableFuture.create(); readFutureNode.set(Optional.of(topoNode)); - doReturn(Futures.makeChecked(readFutureNode, ReadFailedException.MAPPER)).when(mockTx1) - .read(LogicalDatastoreType.OPERATIONAL, topoNodeII); + doReturn(readFutureNode).when(mockTx1).read(LogicalDatastoreType.OPERATIONAL, topoNodeII); final CountDownLatch submitLatch1 = setupStubbedSubmit(mockTx1); @@ -149,13 +146,11 @@ public class TerminationPointChangeListenerImplTest extends DataTreeChangeListen }; ReadWriteTransaction mockTx = mock(ReadWriteTransaction.class); - doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockTx) + doReturn(FluentFutures.immediateFluentFuture(Optional.empty())).when(mockTx) .read(LogicalDatastoreType.OPERATIONAL, topologyIID); final CountDownLatch submitLatch = setupStubbedSubmit(mockTx); - SettableFuture> readFutureNode = SettableFuture.create(); - readFutureNode.set(Optional.of(topoNode)); - doReturn(Futures.makeChecked(readFutureNode, ReadFailedException.MAPPER)).when(mockTx) + doReturn(FluentFutures.immediateFluentFuture(Optional.of(topoNode))).when(mockTx) .read(LogicalDatastoreType.OPERATIONAL, topoNodeII); CountDownLatch deleteLatch = new CountDownLatch(1); @@ -227,7 +222,7 @@ public class TerminationPointChangeListenerImplTest extends DataTreeChangeListen Topology topology = new TopologyBuilder().setLink(linkList).build(); ReadWriteTransaction mockTx = mock(ReadWriteTransaction.class); - doReturn(Futures.immediateCheckedFuture(Optional.of(topology))).when(mockTx) + doReturn(FluentFutures.immediateFluentFuture(Optional.of(topology))).when(mockTx) .read(LogicalDatastoreType.OPERATIONAL, topologyIID); setupStubbedSubmit(mockTx); @@ -272,7 +267,7 @@ public class TerminationPointChangeListenerImplTest extends DataTreeChangeListen Topology topology = new TopologyBuilder().setLink(linkList).build(); ReadWriteTransaction mockTx = mock(ReadWriteTransaction.class); - doReturn(Futures.immediateCheckedFuture(Optional.of(topology))).when(mockTx) + doReturn(FluentFutures.immediateFluentFuture(Optional.of(topology))).when(mockTx) .read(LogicalDatastoreType.OPERATIONAL, topologyIID); setupStubbedSubmit(mockTx); diff --git a/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/TestUtils.java b/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/TestUtils.java index 1a4e60289d..33cb82e5df 100644 --- a/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/TestUtils.java +++ b/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/TestUtils.java @@ -17,18 +17,18 @@ import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.never; -import com.google.common.base.Optional; -import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.SettableFuture; import com.google.common.util.concurrent.Uninterruptibles; import java.util.HashSet; +import java.util.Optional; import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import org.mockito.ArgumentCaptor; import org.mockito.InOrder; -import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.ReadWriteTransaction; +import org.opendaylight.mdsal.common.api.CommitInfo; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey; @@ -51,7 +51,7 @@ public final class TestUtils { static void verifyMockTx(ReadWriteTransaction mockTx) { InOrder inOrder = inOrder(mockTx); - inOrder.verify(mockTx, atLeast(0)).submit(); + inOrder.verify(mockTx, atLeast(0)).commit(); inOrder.verify(mockTx, never()).delete(eq(LogicalDatastoreType.OPERATIONAL), any(InstanceIdentifier.class)); } @@ -86,8 +86,8 @@ public final class TestUtils { final CountDownLatch latch = new CountDownLatch(1); doAnswer(invocation -> { latch.countDown(); - return Futures.immediateCheckedFuture(null); - }).when(mockTx).submit(); + return CommitInfo.emptyFluentFuture(); + }).when(mockTx).commit(); return latch; } diff --git a/drop-test-karaf/pom.xml b/drop-test-karaf/pom.xml index 9cf32be419..455e49d5fe 100644 --- a/drop-test-karaf/pom.xml +++ b/drop-test-karaf/pom.xml @@ -27,12 +27,8 @@ guava - org.opendaylight.controller - sal-binding-api - - - org.opendaylight.controller - sal-binding-broker-impl + org.opendaylight.mdsal + mdsal-binding-api org.opendaylight.openflowplugin.model diff --git a/drop-test-karaf/src/main/java/org/opendaylight/openflowplugin/droptestkaraf/DropTestProviderImpl.java b/drop-test-karaf/src/main/java/org/opendaylight/openflowplugin/droptestkaraf/DropTestProviderImpl.java index 828e8b3a4a..5196ef62bb 100644 --- a/drop-test-karaf/src/main/java/org/opendaylight/openflowplugin/droptestkaraf/DropTestProviderImpl.java +++ b/drop-test-karaf/src/main/java/org/opendaylight/openflowplugin/droptestkaraf/DropTestProviderImpl.java @@ -9,8 +9,8 @@ package org.opendaylight.openflowplugin.droptestkaraf; import com.google.common.base.Preconditions; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.NotificationService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationService; import org.opendaylight.openflowplugin.testcommon.DropTestDsProvider; import org.opendaylight.openflowplugin.testcommon.DropTestRpcProvider; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService; diff --git a/drop-test-karaf/src/main/resources/OSGI-INF/blueprint/drop-test-karaf.xml b/drop-test-karaf/src/main/resources/OSGI-INF/blueprint/drop-test-karaf.xml index 855d2d95cb..a3e81b550b 100644 --- a/drop-test-karaf/src/main/resources/OSGI-INF/blueprint/drop-test-karaf.xml +++ b/drop-test-karaf/src/main/resources/OSGI-INF/blueprint/drop-test-karaf.xml @@ -3,8 +3,8 @@ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0" odl:use-default-for-reference-types="true"> - - + + @@ -14,4 +14,4 @@ - \ No newline at end of file + diff --git a/openflowplugin-api/pom.xml b/openflowplugin-api/pom.xml index 0b2d8a53b2..8ed7c3a6e7 100644 --- a/openflowplugin-api/pom.xml +++ b/openflowplugin-api/pom.xml @@ -26,8 +26,8 @@ model-flow-statistics - org.opendaylight.controller - sal-binding-api + org.opendaylight.mdsal + mdsal-binding-api ${project.groupId}.openflowjava @@ -37,10 +37,6 @@ ${project.groupId}.openflowjava openflow-protocol-spi - - org.opendaylight.controller - sal-common-api - org.opendaylight.mdsal mdsal-singleton-common-api diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OpenFlowPluginProvider.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OpenFlowPluginProvider.java index cef86f8b0f..94519348f9 100644 --- a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OpenFlowPluginProvider.java +++ b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OpenFlowPluginProvider.java @@ -5,10 +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.openflowplugin.api.openflow; -import org.opendaylight.controller.md.sal.binding.api.BindingService; +import org.opendaylight.mdsal.binding.api.BindingService; /** * Plugin services provider. diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceContext.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceContext.java index 073bc13106..5e8cbcba3d 100644 --- a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceContext.java +++ b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceContext.java @@ -5,11 +5,10 @@ * 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.openflowplugin.api.openflow.device; import java.util.List; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.api.openflow.OFPContext; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceReplyProcessor; diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceManager.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceManager.java index 69eb320225..69deccb03f 100644 --- a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceManager.java +++ b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceManager.java @@ -5,7 +5,6 @@ * 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.openflowplugin.api.openflow.device; import com.google.common.util.concurrent.ListenableFuture; @@ -32,8 +31,7 @@ public interface DeviceManager extends */ void initialize(); - ListenableFuture removeDeviceFromOperationalDS( - @Nonnull KeyedInstanceIdentifier ii); + ListenableFuture removeDeviceFromOperationalDS(@Nonnull KeyedInstanceIdentifier ii); DeviceContext createContext(@Nonnull ConnectionContext connectionContext); diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/TxFacade.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/TxFacade.java index 21fb67a86a..79e033abbc 100644 --- a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/TxFacade.java +++ b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/TxFacade.java @@ -5,11 +5,10 @@ * 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.openflowplugin.api.openflow.device; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.ReadTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @@ -57,7 +56,7 @@ public interface TxFacade { * as write transaction in this context. * @return readOnlyTransaction - Don't forget to close it after finish reading */ - ReadOnlyTransaction getReadTransaction(); + ReadTransaction getReadTransaction(); /** * Method returns true if transaction chain manager is enabled. diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/registry/flow/DeviceFlowRegistry.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/registry/flow/DeviceFlowRegistry.java index 80fbd69253..706c359d6b 100644 --- a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/registry/flow/DeviceFlowRegistry.java +++ b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/registry/flow/DeviceFlowRegistry.java @@ -5,12 +5,11 @@ * 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.openflowplugin.api.openflow.registry.flow; -import com.google.common.base.Optional; import com.google.common.util.concurrent.ListenableFuture; import java.util.List; +import java.util.Optional; import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.opendaylight.openflowplugin.api.openflow.registry.CommonDeviceRegistry; diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/statistics/compatibility/BackwardCompatibleAtomicService.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/statistics/compatibility/BackwardCompatibleAtomicService.java index c6f96a2033..fb26f4ba81 100644 --- a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/statistics/compatibility/BackwardCompatibleAtomicService.java +++ b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/statistics/compatibility/BackwardCompatibleAtomicService.java @@ -5,11 +5,10 @@ * 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.openflowplugin.api.openflow.statistics.compatibility; import com.google.common.util.concurrent.ListenableFuture; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.yangtools.yang.common.RpcResult; /** diff --git a/openflowplugin-common/pom.xml b/openflowplugin-common/pom.xml index c6f4c51004..c4b8dc74a9 100644 --- a/openflowplugin-common/pom.xml +++ b/openflowplugin-common/pom.xml @@ -22,8 +22,8 @@ slf4j-api - org.opendaylight.controller - sal-binding-api + org.opendaylight.mdsal + mdsal-binding-api diff --git a/openflowplugin-common/src/main/java/org/opendaylight/openflowplugin/common/txchain/TransactionChainManager.java b/openflowplugin-common/src/main/java/org/opendaylight/openflowplugin/common/txchain/TransactionChainManager.java index 32be30f054..1332571423 100755 --- a/openflowplugin-common/src/main/java/org/opendaylight/openflowplugin/common/txchain/TransactionChainManager.java +++ b/openflowplugin-common/src/main/java/org/opendaylight/openflowplugin/common/txchain/TransactionChainManager.java @@ -1,16 +1,15 @@ -/** +/* * Copyright (c) 2015 Cisco Systems, Inc. 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.openflowplugin.common.txchain; import com.google.common.base.Preconditions; +import com.google.common.util.concurrent.FluentFuture; import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import java.util.Objects; @@ -21,16 +20,16 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import javax.annotation.Nonnull; import javax.annotation.concurrent.GuardedBy; -import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChain; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainClosedException; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.ReadWriteTransaction; +import org.opendaylight.mdsal.binding.api.Transaction; +import org.opendaylight.mdsal.binding.api.TransactionChain; +import org.opendaylight.mdsal.binding.api.TransactionChainClosedException; +import org.opendaylight.mdsal.binding.api.TransactionChainListener; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.CommitInfo; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.mdsal.common.api.TransactionCommitFailedException; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; @@ -41,7 +40,7 @@ import org.slf4j.LoggerFactory; * package protected class for controlling {@link WriteTransaction} life cycle. It is * a {@link TransactionChainListener} and provide package protected methods for writeToTransaction * method (wrapped {@link WriteTransaction#put(LogicalDatastoreType, InstanceIdentifier, DataObject)}) - * and submitTransaction method (wrapped {@link WriteTransaction#submit()}). + * and submitTransaction method (wrapped {@link WriteTransaction#commit()}). */ public class TransactionChainManager implements TransactionChainListener, AutoCloseable { @@ -55,11 +54,11 @@ public class TransactionChainManager implements TransactionChainListener, AutoCl @GuardedBy("txLock") private ReadWriteTransaction writeTx; @GuardedBy("txLock") - private BindingTransactionChain transactionChain; + private TransactionChain transactionChain; @GuardedBy("txLock") private boolean submitIsEnabled; @GuardedBy("txLock") - private ListenableFuture lastSubmittedFuture; + private FluentFuture lastSubmittedFuture; private volatile boolean initCommit; @@ -70,12 +69,12 @@ public class TransactionChainManager implements TransactionChainListener, AutoCl @Nonnull final String deviceIdentifier) { this.dataBroker = dataBroker; this.nodeId = deviceIdentifier; - this.lastSubmittedFuture = Futures.immediateFuture(null); + this.lastSubmittedFuture = CommitInfo.emptyFluentFuture(); } @GuardedBy("txLock") private void createTxChain() { - BindingTransactionChain txChainFactoryTemp = transactionChain; + TransactionChain txChainFactoryTemp = transactionChain; transactionChain = dataBroker.createTransactionChain(TransactionChainManager.this); Optional.ofNullable(txChainFactoryTemp).ifPresent(TransactionChain::close); } @@ -115,20 +114,20 @@ public class TransactionChainManager implements TransactionChainListener, AutoCl * Call this method for SLAVE only. * @return Future */ - public ListenableFuture deactivateTransactionManager() { + public FluentFuture deactivateTransactionManager() { if (LOG.isDebugEnabled()) { LOG.debug("deactivateTransactionManager for node {}", this.nodeId); } - final ListenableFuture future; + final FluentFuture future; synchronized (txLock) { if (TransactionChainManagerStatus.WORKING == transactionChainManagerStatus) { transactionChainManagerStatus = TransactionChainManagerStatus.SLEEPING; future = txChainShuttingDown(); Preconditions.checkState(writeTx == null, "We have some unexpected WriteTransaction."); - Futures.addCallback(future, new FutureCallback() { + future.addCallback(new FutureCallback() { @Override - public void onSuccess(final Void result) { + public void onSuccess(final CommitInfo result) { closeTransactionChain(); } @@ -139,7 +138,7 @@ public class TransactionChainManager implements TransactionChainListener, AutoCl }, MoreExecutors.directExecutor()); } else { // ignoring redundant deactivate invocation - future = Futures.immediateFuture(null); + future = CommitInfo.emptyFluentFuture(); } } return future; @@ -177,7 +176,7 @@ public class TransactionChainManager implements TransactionChainListener, AutoCl Preconditions.checkState(TransactionChainManagerStatus.WORKING == transactionChainManagerStatus, "we have here Uncompleted Transaction for node {} and we are not MASTER", this.nodeId); - final ListenableFuture submitFuture = writeTx.submit(); + final FluentFuture submitFuture = writeTx.commit(); lastSubmittedFuture = submitFuture; writeTx = null; @@ -193,9 +192,9 @@ public class TransactionChainManager implements TransactionChainListener, AutoCl return true; } - Futures.addCallback(submitFuture, new FutureCallback() { + submitFuture.addCallback(new FutureCallback() { @Override - public void onSuccess(final Void result) { + public void onSuccess(final CommitInfo result) { //NOOP } @@ -260,7 +259,7 @@ public class TransactionChainManager implements TransactionChainListener, AutoCl } } - public ListenableFuture> + public ListenableFuture> readFromTransaction(final LogicalDatastoreType store, final InstanceIdentifier path) { synchronized (txLock) { ensureTransaction(); @@ -274,8 +273,8 @@ public class TransactionChainManager implements TransactionChainListener, AutoCl } @Override - public void onTransactionChainFailed(final TransactionChain chain, - final AsyncTransaction transaction, final Throwable cause) { + public void onTransactionChainFailed(final TransactionChain chain, + final Transaction transaction, final Throwable cause) { synchronized (txLock) { if (TransactionChainManagerStatus.WORKING == transactionChainManagerStatus && chain.equals(this.transactionChain)) { @@ -288,7 +287,7 @@ public class TransactionChainManager implements TransactionChainListener, AutoCl } @Override - public void onTransactionChainSuccessful(final TransactionChain chain) { + public void onTransactionChainSuccessful(final TransactionChain chain) { // NOOP } @@ -307,7 +306,7 @@ public class TransactionChainManager implements TransactionChainListener, AutoCl } } - public ListenableFuture shuttingDown() { + public ListenableFuture shuttingDown() { if (LOG.isDebugEnabled()) { LOG.debug("TxManager is going SHUTTING_DOWN for node {}", this.nodeId); } @@ -318,14 +317,14 @@ public class TransactionChainManager implements TransactionChainListener, AutoCl } @GuardedBy("txLock") - private ListenableFuture txChainShuttingDown() { + private FluentFuture txChainShuttingDown() { boolean wasSubmitEnabled = submitIsEnabled; submitIsEnabled = false; - ListenableFuture future; + FluentFuture future; if (!wasSubmitEnabled || transactionChain == null) { // stay with actual thread - future = Futures.immediateFuture(null); + future = CommitInfo.emptyFluentFuture(); if (writeTx != null) { writeTx.cancel(); @@ -339,7 +338,7 @@ public class TransactionChainManager implements TransactionChainListener, AutoCl LOG.debug("Submitting all transactions for Node {}", this.nodeId); } // hijack md-sal thread - future = writeTx.submit(); + future = writeTx.commit(); writeTx = null; } diff --git a/openflowplugin-impl/pom.xml b/openflowplugin-impl/pom.xml index b6de89fde2..ac937d7de4 100644 --- a/openflowplugin-impl/pom.xml +++ b/openflowplugin-impl/pom.xml @@ -45,12 +45,12 @@ model-inventory - org.opendaylight.controller - sal-binding-api + org.opendaylight.mdsal + mdsal-binding-api - org.opendaylight.controller - sal-binding-broker-impl + org.opendaylight.mdsal + mdsal-binding-spi ${project.groupId}.openflowjava @@ -108,18 +108,10 @@ slf4j-log4j12 test - - org.opendaylight.controller - sal-common-util - ${project.groupId}.openflowjava openflowjava-util - - org.opendaylight.controller - sal-common-api - ${project.groupId}.openflowjava openflow-protocol-impl diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/ForwardingPingPongDataBroker.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/ForwardingPingPongDataBroker.java index ad58e044a2..36e84e11d2 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/ForwardingPingPongDataBroker.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/ForwardingPingPongDataBroker.java @@ -7,8 +7,8 @@ */ package org.opendaylight.openflowplugin.impl; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ForwardingDataBroker; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.spi.ForwardingDataBroker; /** * Delegating {@link PingPongDataBroker} implementation. diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java index db8cb59585..4934a86aa6 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java @@ -41,12 +41,12 @@ import javax.management.NotCompliantMBeanException; import javax.management.ObjectName; import org.apache.aries.blueprint.annotation.service.Reference; import org.apache.aries.blueprint.annotation.service.Service; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; import org.opendaylight.infrautils.diagstatus.ServiceState; import org.opendaylight.infrautils.ready.SystemReadyListener; import org.opendaylight.infrautils.ready.SystemReadyMonitor; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; @@ -114,7 +114,7 @@ public class OpenFlowPluginProviderImpl implements private final Collection switchConnectionProviders; private final DeviceInitializerProvider deviceInitializerProvider; private final ConvertorManager convertorManager; - private final RpcProviderRegistry rpcProviderRegistry; + private final RpcProviderService rpcProviderRegistry; private final ClusterSingletonServiceProvider singletonServicesProvider; private final OpenflowProviderConfig config; private final EntityOwnershipService entityOwnershipService; @@ -137,7 +137,7 @@ public class OpenFlowPluginProviderImpl implements public OpenFlowPluginProviderImpl(final ConfigurationService configurationService, final SwitchConnectionProviderList switchConnectionProviders, final PingPongDataBroker pingPongDataBroker, - final @Reference RpcProviderRegistry rpcProviderRegistry, + final @Reference RpcProviderService rpcProviderRegistry, final @Reference NotificationPublishService notificationPublishService, final @Reference ClusterSingletonServiceProvider singletonServiceProvider, final @Reference EntityOwnershipService entityOwnershipService, diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/PingPongDataBroker.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/PingPongDataBroker.java index 009fa5aa25..757a077d49 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/PingPongDataBroker.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/PingPongDataBroker.java @@ -7,11 +7,13 @@ */ package org.opendaylight.openflowplugin.impl; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataBroker; /** * An odl:type="pingpong" {@link DataBroker}. * * @author Michael Vorburger.ch */ -public interface PingPongDataBroker extends DataBroker {} +public interface PingPongDataBroker extends DataBroker { + +} diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/AbstractMultipartWriter.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/AbstractMultipartWriter.java index 6173ddc532..9ea9b60c9b 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/AbstractMultipartWriter.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/AbstractMultipartWriter.java @@ -5,10 +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.openflowplugin.impl.datastore.multipart; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.openflow.device.TxFacade; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yangtools.yang.binding.DataContainer; diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java index 12f470df70..c44a2605bb 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the @@ -27,10 +27,10 @@ import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicBoolean; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.ReadTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter; import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; @@ -218,7 +218,7 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi } @Override - public ReadOnlyTransaction getReadTransaction() { + public ReadTransaction getReadTransaction() { return dataBroker.newReadOnlyTransaction(); } @@ -557,8 +557,8 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi } @Override - public ListenableFuture closeServiceInstance() { - final ListenableFuture listenableFuture = initialized.get() + public ListenableFuture closeServiceInstance() { + final ListenableFuture listenableFuture = initialized.get() ? transactionChainManager.deactivateTransactionManager() : Futures.immediateFuture(null); @@ -595,11 +595,11 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi deviceFlowRegistry.close(); deviceMeterRegistry.close(); - final ListenableFuture txChainShuttingDown = transactionChainManager.shuttingDown(); + final ListenableFuture txChainShuttingDown = transactionChainManager.shuttingDown(); - Futures.addCallback(txChainShuttingDown, new FutureCallback() { + Futures.addCallback(txChainShuttingDown, new FutureCallback() { @Override - public void onSuccess(@Nullable final Void result) { + public void onSuccess(final Object result) { transactionChainManager.close(); transactionChainManager = null; } @@ -663,7 +663,7 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi deviceInfo.toString())); } - final ListenableFuture>> deviceFlowRegistryFill = + final ListenableFuture>> deviceFlowRegistryFill = getDeviceFlowRegistry().fill(); Futures.addCallback(deviceFlowRegistryFill, new DeviceFlowRegistryCallback(deviceFlowRegistryFill, contextChainMastershipWatcher), @@ -708,20 +708,19 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi hasState.set(true); } - private class DeviceFlowRegistryCallback implements FutureCallback>> { - private final ListenableFuture>> deviceFlowRegistryFill; + private class DeviceFlowRegistryCallback implements FutureCallback>> { + private final ListenableFuture>> deviceFlowRegistryFill; private final ContextChainMastershipWatcher contextChainMastershipWatcher; DeviceFlowRegistryCallback( - ListenableFuture>> deviceFlowRegistryFill, + ListenableFuture>> deviceFlowRegistryFill, ContextChainMastershipWatcher contextChainMastershipWatcher) { this.deviceFlowRegistryFill = deviceFlowRegistryFill; this.contextChainMastershipWatcher = contextChainMastershipWatcher; } @Override - public void onSuccess(@Nullable List> result) { + public void onSuccess(@Nullable List> result) { if (LOG.isDebugEnabled()) { // Count all flows we read from datastore for debugging purposes. // This number do not always represent how many flows were actually added @@ -732,7 +731,8 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi .stream() .flatMap(Collection::stream) .filter(Objects::nonNull) - .flatMap(flowCapableNodeOptional -> flowCapableNodeOptional.asSet().stream()) + .flatMap(flowCapableNodeOptional + -> com.google.common.base.Optional.fromJavaUtil(flowCapableNodeOptional).asSet().stream()) .filter(Objects::nonNull) .filter(flowCapableNode -> Objects.nonNull(flowCapableNode.getTable())) .flatMap(flowCapableNode -> flowCapableNode.getTable().stream()) diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImpl.java index 8077678966..0aeda1a8ce 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImpl.java @@ -16,10 +16,10 @@ import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; import javax.annotation.Nonnull; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandlerRegistration; import org.opendaylight.openflowplugin.api.openflow.OFPContext; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; @@ -122,12 +122,11 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi } @Override - public ListenableFuture removeDeviceFromOperationalDS( - @Nonnull final KeyedInstanceIdentifier ii) { + public ListenableFuture removeDeviceFromOperationalDS(@Nonnull final KeyedInstanceIdentifier ii) { final WriteTransaction delWtx = dataBroker.newWriteOnlyTransaction(); delWtx.delete(LogicalDatastoreType.OPERATIONAL, ii); - return delWtx.submit(); + return delWtx.commit(); } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/initialization/AbstractDeviceInitializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/initialization/AbstractDeviceInitializer.java index f07ca2f0cf..df9c458c76 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/initialization/AbstractDeviceInitializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/initialization/AbstractDeviceInitializer.java @@ -5,7 +5,6 @@ * 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.openflowplugin.impl.device.initialization; import com.google.common.base.Preconditions; @@ -14,7 +13,7 @@ import java.util.Collections; import java.util.concurrent.Future; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.ConnectionException; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; import org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProvider; diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/initialization/OF10DeviceInitializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/initialization/OF10DeviceInitializer.java index a7290f4cfe..1e04acbf23 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/initialization/OF10DeviceInitializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/initialization/OF10DeviceInitializer.java @@ -5,7 +5,6 @@ * 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.openflowplugin.impl.device.initialization; import com.google.common.base.Function; @@ -17,7 +16,7 @@ import com.google.common.util.concurrent.MoreExecutors; import java.util.concurrent.Future; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImpl.java index 83fd9b367f..1e2818ac4d 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImpl.java @@ -8,29 +8,30 @@ package org.opendaylight.openflowplugin.impl.registry.flow; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Optional; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import com.google.common.collect.Maps; -import com.google.common.util.concurrent.CheckedFuture; +import com.google.common.util.concurrent.FluentFuture; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; import javax.annotation.Nonnull; import javax.annotation.concurrent.ThreadSafe; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.ReadTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.mdsal.common.api.ReadFailedException; import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry; import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor; import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey; @@ -40,6 +41,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.ta import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNodesNodeTableFlow; +import org.opendaylight.yangtools.util.concurrent.FluentFutures; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.slf4j.Logger; @@ -85,13 +87,13 @@ public class DeviceFlowRegistryImpl implements DeviceFlowRegistry { final InstanceIdentifier path = instanceIdentifier.augmentation(FlowCapableNode.class); // First, try to fill registry with flows from DS/Configuration - final CheckedFuture, ReadFailedException> configFuture = + final FluentFuture> configFuture = fillFromDatastore(LogicalDatastoreType.CONFIGURATION, path); // Now, try to fill registry with flows from DS/Operational // in case of cluster fail over, when clients are not using DS/Configuration // for adding flows, but only RPCs - final CheckedFuture, ReadFailedException> operationalFuture = + final FluentFuture> operationalFuture = fillFromDatastore(LogicalDatastoreType.OPERATIONAL, path); // And at last, chain and return futures created above. @@ -103,32 +105,30 @@ public class DeviceFlowRegistryImpl implements DeviceFlowRegistry { return lastFillFuture; } - private CheckedFuture, ReadFailedException> - fillFromDatastore(final LogicalDatastoreType logicalDatastoreType, + private FluentFuture> fillFromDatastore(final LogicalDatastoreType logicalDatastoreType, final InstanceIdentifier path) { // Create new read-only transaction - final ReadOnlyTransaction transaction = dataBroker.newReadOnlyTransaction(); + final ReadTransaction transaction = dataBroker.newReadOnlyTransaction(); // Bail out early if transaction is null if (transaction == null) { - return Futures.immediateFailedCheckedFuture( + return FluentFutures.immediateFailedFluentFuture( new ReadFailedException("Read transaction is null")); } // Prepare read operation from datastore for path - final CheckedFuture, ReadFailedException> future = - transaction.read(logicalDatastoreType, path); + final FluentFuture> future = transaction.read(logicalDatastoreType, path); // Bail out early if future is null if (future == null) { - return Futures.immediateFailedCheckedFuture( + return FluentFutures.immediateFailedFluentFuture( new ReadFailedException("Future from read transaction is null")); } - Futures.addCallback(future, new FutureCallback>() { + future.addCallback(new FutureCallback>() { @Override public void onSuccess(@Nonnull Optional result) { - result.asSet().stream() + result.map(Collections::singleton).orElse(Collections.emptySet()).stream() .filter(Objects::nonNull) .filter(flowCapableNode -> Objects.nonNull(flowCapableNode.getTable())) .flatMap(flowCapableNode -> flowCapableNode.getTable().stream()) diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcContextImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcContextImpl.java index d7e2bb8c52..93e26c0523 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcContextImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcContextImpl.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the @@ -9,6 +9,7 @@ package org.opendaylight.openflowplugin.impl.rpc; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Function; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterators; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; @@ -20,9 +21,8 @@ import java.util.concurrent.ConcurrentMap; import java.util.concurrent.Semaphore; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; @@ -34,9 +34,9 @@ import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.Messa import org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider; import org.opendaylight.openflowplugin.impl.util.MdSalRegistrationUtils; import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; +import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.binding.RpcService; import org.slf4j.Logger; @@ -44,13 +44,14 @@ import org.slf4j.LoggerFactory; class RpcContextImpl implements RpcContext { private static final Logger LOG = LoggerFactory.getLogger(RpcContextImpl.class); - private final RpcProviderRegistry rpcProviderRegistry; + private final RpcProviderService rpcProviderRegistry; private final MessageSpy messageSpy; private final Semaphore tracker; - private boolean isStatisticsRpcEnabled; + private final boolean isStatisticsRpcEnabled; // TODO: add private Sal salBroker - private final ConcurrentMap, RoutedRpcRegistration> rpcRegistrations = new ConcurrentHashMap<>(); + private final ConcurrentMap, ObjectRegistration> rpcRegistrations = + new ConcurrentHashMap<>(); private final KeyedInstanceIdentifier nodeInstanceIdentifier; private final DeviceInfo deviceInfo; private final DeviceContext deviceContext; @@ -59,7 +60,7 @@ class RpcContextImpl implements RpcContext { private final NotificationPublishService notificationPublishService; private ContextChainMastershipWatcher contextChainMastershipWatcher; - RpcContextImpl(@Nonnull final RpcProviderRegistry rpcProviderRegistry, + RpcContextImpl(@Nonnull final RpcProviderService rpcProviderRegistry, final int maxRequests, @Nonnull final DeviceContext deviceContext, @Nonnull final ExtensionConverterProvider extensionConverterProvider, @@ -82,9 +83,8 @@ class RpcContextImpl implements RpcContext { public void registerRpcServiceImplementation(final Class serviceClass, final S serviceInstance) { if (!rpcRegistrations.containsKey(serviceClass)) { - final RoutedRpcRegistration routedRpcReg = - rpcProviderRegistry.addRoutedRpcImplementation(serviceClass, serviceInstance); - routedRpcReg.registerPath(NodeContext.class, nodeInstanceIdentifier); + final ObjectRegistration routedRpcReg = rpcProviderRegistry.registerRpcImplementation(serviceClass, + serviceInstance, ImmutableSet.of(nodeInstanceIdentifier)); rpcRegistrations.put(serviceClass, routedRpcReg); if (LOG.isDebugEnabled()) { LOG.debug("Registration of service {} for device {}.", @@ -96,7 +96,7 @@ class RpcContextImpl implements RpcContext { @Override public S lookupRpcService(final Class serviceClass) { - RoutedRpcRegistration registration = rpcRegistrations.get(serviceClass); + ObjectRegistration registration = rpcRegistrations.get(serviceClass); final RpcService rpcService = registration.getInstance(); return serviceClass.cast(rpcService); } @@ -107,15 +107,14 @@ class RpcContextImpl implements RpcContext { } private void unregisterRPCs() { - for (final Iterator, RoutedRpcRegistration>> iterator = Iterators + for (final Iterator, ObjectRegistration>> iterator = Iterators .consumingIterator(rpcRegistrations.entrySet().iterator()); iterator.hasNext(); ) { - final RoutedRpcRegistration rpcRegistration = iterator.next().getValue(); - rpcRegistration.unregisterPath(NodeContext.class, nodeInstanceIdentifier); + final ObjectRegistration rpcRegistration = iterator.next().getValue(); rpcRegistration.close(); if (LOG.isDebugEnabled()) { LOG.debug("Closing RPC Registration of service {} for device {}.", - rpcRegistration.getServiceType().getSimpleName(), + rpcRegistration.getInstance().getClass().getSimpleName(), nodeInstanceIdentifier.getKey().getId().getValue()); } } @@ -154,9 +153,8 @@ class RpcContextImpl implements RpcContext { public void unregisterRpcServiceImplementation(final Class serviceClass) { LOG.trace("Try to unregister serviceClass {} for Node {}", serviceClass, nodeInstanceIdentifier.getKey().getId()); - final RoutedRpcRegistration rpcRegistration = rpcRegistrations.remove(serviceClass); + final ObjectRegistration rpcRegistration = rpcRegistrations.remove(serviceClass); if (rpcRegistration != null) { - rpcRegistration.unregisterPath(NodeContext.class, nodeInstanceIdentifier); rpcRegistration.close(); LOG.debug("Un-registration serviceClass {} for Node {}", serviceClass.getSimpleName(), nodeInstanceIdentifier.getKey().getId().getValue()); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcManagerImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcManagerImpl.java index f5794de7a7..28ed3c378d 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcManagerImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcManagerImpl.java @@ -13,8 +13,8 @@ import java.util.Iterator; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import javax.annotation.Nonnull; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext; @@ -29,14 +29,14 @@ public class RpcManagerImpl implements RpcManager { private static final Logger LOG = LoggerFactory.getLogger(RpcManagerImpl.class); private final OpenflowProviderConfig config; - private final RpcProviderRegistry rpcProviderRegistry; + private final RpcProviderService rpcProviderRegistry; private final ConcurrentMap contexts = new ConcurrentHashMap<>(); private final ExtensionConverterProvider extensionConverterProvider; private final ConvertorExecutor convertorExecutor; private final NotificationPublishService notificationPublishService; public RpcManagerImpl(final OpenflowProviderConfig config, - final RpcProviderRegistry rpcProviderRegistry, + final RpcProviderService rpcProviderRegistry, final ExtensionConverterProvider extensionConverterProvider, final ConvertorExecutor convertorExecutor, final NotificationPublishService notificationPublishService) { diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtils.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtils.java index b0d6c14583..253d380c9d 100755 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtils.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtils.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.openflowplugin.impl.statistics; import com.google.common.base.Function; -import com.google.common.base.Optional; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; @@ -19,12 +17,13 @@ import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Objects; +import java.util.Optional; import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainClosedException; +import org.opendaylight.mdsal.binding.api.ReadTransaction; +import org.opendaylight.mdsal.binding.api.TransactionChainClosedException; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; import org.opendaylight.openflowplugin.api.openflow.device.DeviceRegistry; import org.opendaylight.openflowplugin.api.openflow.device.TxFacade; @@ -169,7 +168,7 @@ public final class StatisticsGatheringUtils { } final ListenableFuture> future; - try (ReadOnlyTransaction readTx = txFacade.getReadTransaction()) { + try (ReadTransaction readTx = txFacade.getReadTransaction()) { future = readTx.read(LogicalDatastoreType.OPERATIONAL, instanceIdentifier); } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImpl.java index 6d15aa2827..c3645b7f3d 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImpl.java @@ -5,7 +5,6 @@ * 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.openflowplugin.impl.statistics; import com.google.common.base.Preconditions; @@ -15,8 +14,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.Semaphore; import javax.annotation.Nonnull; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext; @@ -32,6 +30,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.GetStatisticsWorkModeOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.StatisticsManagerControlService; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.StatisticsWorkMode; +import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; @@ -46,19 +45,19 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag private final ConvertorExecutor converterExecutor; private final ConcurrentMap contexts = new ConcurrentHashMap<>(); private final Semaphore workModeGuard = new Semaphore(1, true); - private final BindingAwareBroker.RpcRegistration controlServiceRegistration; + private final ObjectRegistration controlServiceRegistration; private final ListeningExecutorService executorService; private final StatisticsWorkMode workMode = StatisticsWorkMode.COLLECTALL; private boolean isStatisticsFullyDisabled; public StatisticsManagerImpl(@Nonnull final OpenflowProviderConfig config, - @Nonnull final RpcProviderRegistry rpcProviderRegistry, + @Nonnull final RpcProviderService rpcProviderRegistry, final ConvertorExecutor convertorExecutor, @Nonnull final ListeningExecutorService executorService) { this.config = config; this.converterExecutor = convertorExecutor; this.controlServiceRegistration = Preconditions.checkNotNull(rpcProviderRegistry - .addRpcImplementation(StatisticsManagerControlService.class, this)); + .registerRpcImplementation(StatisticsManagerControlService.class, this)); this.executorService = executorService; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowTableStatisticsServiceImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowTableStatisticsServiceImpl.java index 67eae3a624..874346766d 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowTableStatisticsServiceImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowTableStatisticsServiceImpl.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the @@ -11,7 +11,7 @@ import com.google.common.util.concurrent.ListenableFuture; import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicLong; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack; import org.opendaylight.openflowplugin.api.openflow.device.Xid; diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightGroupStatisticsServiceImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightGroupStatisticsServiceImpl.java index 4199186dcd..1f56925a9a 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightGroupStatisticsServiceImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightGroupStatisticsServiceImpl.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the @@ -9,7 +9,7 @@ package org.opendaylight.openflowplugin.impl.statistics.services; import com.google.common.util.concurrent.ListenableFuture; import java.util.concurrent.atomic.AtomicLong; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack; import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor; diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightMeterStatisticsServiceImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightMeterStatisticsServiceImpl.java index 5e00bce0b2..981b50d5a0 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightMeterStatisticsServiceImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightMeterStatisticsServiceImpl.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the @@ -9,7 +9,7 @@ package org.opendaylight.openflowplugin.impl.statistics.services; import com.google.common.util.concurrent.ListenableFuture; import java.util.concurrent.atomic.AtomicLong; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack; import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor; diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightPortStatisticsServiceImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightPortStatisticsServiceImpl.java index 3971f7f60b..2199c612da 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightPortStatisticsServiceImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightPortStatisticsServiceImpl.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the @@ -9,7 +9,7 @@ package org.opendaylight.openflowplugin.impl.statistics.services; import com.google.common.util.concurrent.ListenableFuture; import java.util.concurrent.atomic.AtomicLong; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack; import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInput; diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightQueueStatisticsServiceImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightQueueStatisticsServiceImpl.java index 91a9f44ff8..d04aef97d2 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightQueueStatisticsServiceImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightQueueStatisticsServiceImpl.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the @@ -9,7 +9,7 @@ package org.opendaylight.openflowplugin.impl.statistics.services; import com.google.common.util.concurrent.ListenableFuture; import java.util.concurrent.atomic.AtomicLong; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack; import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInput; diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/AbstractCompatibleStatService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/AbstractCompatibleStatService.java index 606ad25bb5..07bfe8f28c 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/AbstractCompatibleStatService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/AbstractCompatibleStatService.java @@ -5,7 +5,6 @@ * 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.openflowplugin.impl.statistics.services.compatibility; import com.google.common.util.concurrent.FutureCallback; @@ -16,7 +15,7 @@ import java.math.BigInteger; import java.util.List; import java.util.concurrent.atomic.AtomicLong; import javax.annotation.Nullable; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack; import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion; diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/OpendaylightFlowStatisticsServiceDelegateImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/OpendaylightFlowStatisticsServiceDelegateImpl.java index b0f9378da9..ff9bbee23c 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/OpendaylightFlowStatisticsServiceDelegateImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/OpendaylightFlowStatisticsServiceDelegateImpl.java @@ -9,7 +9,7 @@ package org.opendaylight.openflowplugin.impl.statistics.services.compatibility; import com.google.common.util.concurrent.ListenableFuture; import java.util.concurrent.atomic.AtomicLong; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack; import org.opendaylight.openflowplugin.impl.statistics.services.AggregateFlowsInTableService; diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/DeviceInitializationUtil.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/DeviceInitializationUtil.java index caccf3c407..cc1de12977 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/DeviceInitializationUtil.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/DeviceInitializationUtil.java @@ -5,16 +5,15 @@ * 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.openflowplugin.impl.util; import java.net.InetSocketAddress; import java.util.Collections; import java.util.Optional; import java.util.concurrent.ExecutionException; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; import org.opendaylight.openflowplugin.api.openflow.device.TxFacade; @@ -56,7 +55,7 @@ public final class DeviceInitializationUtil { tx.merge(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class), new NodesBuilder() .setNode(Collections.emptyList()) .build()); - tx.submit().get(); + tx.commit().get(); } catch (ExecutionException | InterruptedException e) { LOG.error("Creation of node failed.", e); throw new IllegalStateException(e); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/MdSalRegistrationUtils.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/MdSalRegistrationUtils.java index c20d978fe5..ced0513226 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/MdSalRegistrationUtils.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/MdSalRegistrationUtils.java @@ -10,7 +10,7 @@ package org.opendaylight.openflowplugin.impl.util; import com.google.common.base.Preconditions; import java.util.concurrent.atomic.AtomicLong; import javax.annotation.Nonnull; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext; import org.opendaylight.openflowplugin.api.openflow.statistics.compatibility.Delegator; diff --git a/openflowplugin-impl/src/main/resources/OSGI-INF/blueprint/openflowplugin-impl.xml b/openflowplugin-impl/src/main/resources/OSGI-INF/blueprint/openflowplugin-impl.xml index 4bda6dff35..85726b4273 100644 --- a/openflowplugin-impl/src/main/resources/OSGI-INF/blueprint/openflowplugin-impl.xml +++ b/openflowplugin-impl/src/main/resources/OSGI-INF/blueprint/openflowplugin-impl.xml @@ -23,7 +23,7 @@ - + diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImplTest.java index 437550d38d..24383c5469 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImplTest.java @@ -5,11 +5,11 @@ * 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.openflowplugin.impl; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -19,12 +19,12 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.mockito.junit.MockitoJUnitRunner; import org.opendaylight.infrautils.ready.SystemReadyMonitor; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.RpcProviderService; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.CommitInfo; import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipListenerRegistration; import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; @@ -34,6 +34,7 @@ import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationP import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService; import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeServiceManager; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.StatisticsManagerControlService; +import org.opendaylight.yangtools.concepts.ObjectRegistration; @RunWith(MockitoJUnitRunner.class) public class OpenFlowPluginProviderImplTest { @@ -42,7 +43,7 @@ public class OpenFlowPluginProviderImplTest { PingPongDataBroker dataBroker; @Mock - RpcProviderRegistry rpcProviderRegistry; + RpcProviderService rpcProviderRegistry; @Mock NotificationPublishService notificationPublishService; @@ -63,7 +64,7 @@ public class OpenFlowPluginProviderImplTest { EntityOwnershipListenerRegistration entityOwnershipListenerRegistration; @Mock - BindingAwareBroker.RpcRegistration controlServiceRegistration; + ObjectRegistration controlServiceRegistration; @Mock SwitchConnectionProvider switchConnectionProvider; @@ -89,9 +90,9 @@ public class OpenFlowPluginProviderImplTest { @Before public void setUp() throws Exception { when(dataBroker.newWriteOnlyTransaction()).thenReturn(writeTransaction); - when(writeTransaction.submit()).thenReturn(Futures.immediateCheckedFuture(null)); + doReturn(CommitInfo.emptyFluentFuture()).when(writeTransaction).commit(); when(entityOwnershipService.registerListener(any(), any())).thenReturn(entityOwnershipListenerRegistration); - when(rpcProviderRegistry.addRpcImplementation(eq(StatisticsManagerControlService.class), any())) + when(rpcProviderRegistry.registerRpcImplementation(eq(StatisticsManagerControlService.class), any())) .thenReturn(controlServiceRegistration); when(switchConnectionProvider.startup()).thenReturn(Futures.immediateFuture(true)); when(switchConnectionProvider.shutdown()).thenReturn(Futures.immediateFuture(true)); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImplTest.java index 5424dce47e..2b10f3f091 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImplTest.java @@ -5,7 +5,6 @@ * 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.openflowplugin.impl.device; import static org.junit.Assert.assertEquals; @@ -19,28 +18,28 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import com.google.common.base.Optional; import com.google.common.collect.Lists; -import com.google.common.util.concurrent.CheckedFuture; +import com.google.common.util.concurrent.FluentFuture; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.SettableFuture; import io.netty.util.HashedWheelTimer; import java.math.BigInteger; +import java.util.Optional; import java.util.concurrent.atomic.AtomicLong; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.ReadTransaction; +import org.opendaylight.mdsal.binding.api.ReadWriteTransaction; +import org.opendaylight.mdsal.binding.api.TransactionChain; +import org.opendaylight.mdsal.common.api.CommitInfo; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter; import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowplugin.api.OFConstants; @@ -107,6 +106,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived; import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceivedBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SalRoleService; +import org.opendaylight.yangtools.util.concurrent.FluentFutures; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; @@ -139,9 +139,9 @@ public class DeviceContextImplTest { @Mock private ReadWriteTransaction writeTx; @Mock - private ReadOnlyTransaction readTx; + private ReadTransaction readTx; @Mock - private BindingTransactionChain txChainFactory; + private TransactionChain txChainFactory; @Mock private HashedWheelTimer timer; @Mock @@ -182,8 +182,8 @@ public class DeviceContextImplTest { @Before public void setUp() throws Exception { - final CheckedFuture, ReadFailedException> noExistNodeFuture = - Futures.immediateCheckedFuture(Optional.absent()); + final FluentFuture> noExistNodeFuture = + FluentFutures.immediateFluentFuture(Optional.empty()); Mockito.lenient().when(readTx.read(LogicalDatastoreType.OPERATIONAL, nodeKeyIdent)) .thenReturn(noExistNodeFuture); Mockito.when(dataBroker.newReadOnlyTransaction()).thenReturn(readTx); @@ -279,13 +279,13 @@ public class DeviceContextImplTest { @Test public void testInitialSubmitTransaction() throws Exception { - Mockito.when(writeTx.submit()).thenReturn(Futures.immediateCheckedFuture(null)); + Mockito.doReturn(CommitInfo.emptyFluentFuture()).when(writeTx).commit(); final InstanceIdentifier dummyII = InstanceIdentifier.create(Nodes.class); ((DeviceContextImpl) deviceContext).getTransactionChainManager().activateTransactionManager() ; ((DeviceContextImpl) deviceContext).getTransactionChainManager().initialSubmitWriteTransaction(); deviceContext.addDeleteToTxChain(LogicalDatastoreType.CONFIGURATION, dummyII); deviceContext.initialSubmitTransaction(); - verify(writeTx).submit(); + verify(writeTx).commit(); } private ConnectionContext prepareConnectionContext() { diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImplTest.java index 2a0a6f3ce3..a0bf7482d8 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImplTest.java @@ -5,19 +5,18 @@ * 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.openflowplugin.impl.device; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.FluentFuture; import com.google.common.util.concurrent.ListenableFuture; import io.netty.util.HashedWheelTimer; import java.lang.reflect.Field; @@ -29,13 +28,14 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.TransactionChain; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.CommitInfo; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.mdsal.common.api.TransactionCommitFailedException; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; @@ -57,6 +57,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.NonZeroUint16Type; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.NonZeroUint32Type; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfigBuilder; +import org.opendaylight.yangtools.util.concurrent.FluentFutures; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; @RunWith(MockitoJUnitRunner.class) @@ -70,7 +71,7 @@ public class DeviceManagerImplTest { .createNodeInstanceIdentifier(DUMMY_NODE_ID); @Mock - private CheckedFuture mockedFuture; + private FluentFuture mockedFuture; @Mock private FeaturesReply mockFeatures; @Mock @@ -90,7 +91,7 @@ public class DeviceManagerImplTest { @Mock private WriteTransaction writeTransaction; @Mock - private BindingTransactionChain transactionChain; + private TransactionChain transactionChain; @Mock private Capabilities capabilities; @Mock @@ -111,7 +112,7 @@ public class DeviceManagerImplTest { when(deviceInfo.getNodeId()).thenReturn(DUMMY_NODE_ID); when(mockedFuture.isDone()).thenReturn(true); - when(writeTransaction.submit()).thenReturn(mockedFuture); + doReturn(mockedFuture).when(writeTransaction).commit(); when(dataBroker.newWriteOnlyTransaction()).thenReturn(writeTransaction); deviceManager = new DeviceManagerImpl( @@ -134,7 +135,7 @@ public class DeviceManagerImplTest { deviceManager.setTranslatorLibrary(translatorLibrary); verify(dataBroker).newWriteOnlyTransaction(); verify(writeTransaction).merge(eq(LogicalDatastoreType.OPERATIONAL), any(), any()); - verify(writeTransaction).submit(); + verify(writeTransaction).commit(); } @Test @@ -146,7 +147,7 @@ public class DeviceManagerImplTest { @Test public void removeDeviceFromOperationalDS() throws Exception { - final ListenableFuture future = deviceManager + final ListenableFuture future = deviceManager .removeDeviceFromOperationalDS(DUMMY_IDENTIFIER); future.get(); @@ -156,12 +157,10 @@ public class DeviceManagerImplTest { @Test(expected = ExecutionException.class) public void removeDeviceFromOperationalDSException() throws Exception { - final CheckedFuture failedFuture = - Futures.immediateFailedCheckedFuture( + final FluentFuture failedFuture = FluentFutures.immediateFailedFluentFuture( new TransactionCommitFailedException("Test failed transaction")); - Mockito.when(writeTransaction.submit()).thenReturn(failedFuture); - final ListenableFuture future = deviceManager - .removeDeviceFromOperationalDS(DUMMY_IDENTIFIER); + Mockito.doReturn(failedFuture).when(writeTransaction).commit(); + final ListenableFuture future = deviceManager.removeDeviceFromOperationalDS(DUMMY_IDENTIFIER); future.get(); assertTrue(future.isDone()); verify(writeTransaction).delete(LogicalDatastoreType.OPERATIONAL, DUMMY_IDENTIFIER); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/TransactionChainManagerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/TransactionChainManagerTest.java index 16cf635ba1..9d3f1f721b 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/TransactionChainManagerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/TransactionChainManagerTest.java @@ -5,31 +5,26 @@ * 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.openflowplugin.impl.device; import static org.mockito.ArgumentMatchers.any; -import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.Futures; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChain; -import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.ReadTransaction; +import org.opendaylight.mdsal.binding.api.ReadWriteTransaction; +import org.opendaylight.mdsal.binding.api.Transaction; +import org.opendaylight.mdsal.binding.api.TransactionChain; +import org.opendaylight.mdsal.binding.api.TransactionChainListener; +import org.opendaylight.mdsal.common.api.CommitInfo; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.mdsal.common.api.TransactionCommitFailedException; import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; import org.opendaylight.openflowplugin.common.txchain.TransactionChainManager; import org.opendaylight.openflowplugin.impl.util.DeviceStateUtil; @@ -38,6 +33,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; +import org.opendaylight.yangtools.util.concurrent.FluentFutures; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; @@ -47,11 +43,11 @@ public class TransactionChainManagerTest { @Mock private DataBroker dataBroker; @Mock - private BindingTransactionChain txChain; + private TransactionChain txChain; @Mock private ReadWriteTransaction writeTx; @Mock - private TransactionChain transactionChain; + private TransactionChain transactionChain; @Mock DeviceInfo deviceInfo; @@ -64,9 +60,7 @@ public class TransactionChainManagerTest { @Before public void setUp() throws Exception { - final ReadOnlyTransaction readOnlyTx = Mockito.mock(ReadOnlyTransaction.class); - final CheckedFuture, ReadFailedException> noExistNodeFuture = Futures - .immediateCheckedFuture(Optional.absent()); + final ReadTransaction readOnlyTx = Mockito.mock(ReadTransaction.class); Mockito.when(dataBroker.createTransactionChain(any(TransactionChainListener.class))) .thenReturn(txChain); nodeId = new NodeId("h2g2:42"); @@ -75,8 +69,7 @@ public class TransactionChainManagerTest { Mockito.when(txChain.newReadWriteTransaction()).thenReturn(writeTx); path = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(nodeId)); - Mockito.when(writeTx.submit()) - .thenReturn(Futures.immediateCheckedFuture(null)); + Mockito.doReturn(CommitInfo.emptyFluentFuture()).when(writeTx).commit(); txChainManager.activateTransactionManager(); } @@ -106,7 +99,7 @@ public class TransactionChainManagerTest { Mockito.verify(txChain).newReadWriteTransaction(); Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data, false); - Mockito.verify(writeTx).submit(); + Mockito.verify(writeTx).commit(); } /** @@ -120,14 +113,13 @@ public class TransactionChainManagerTest { Mockito.verify(txChain).newReadWriteTransaction(); Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data, false); - Mockito.verify(writeTx, Mockito.never()).submit(); + Mockito.verify(writeTx, Mockito.never()).commit(); } @Test public void testSubmitTransactionFailed() throws Exception { - Mockito.when(writeTx.submit()).thenReturn( - Futures.immediateFailedCheckedFuture( - new TransactionCommitFailedException("mock"))); + Mockito.doReturn(FluentFutures.immediateFailedFluentFuture(new TransactionCommitFailedException("mock"))) + .when(writeTx).commit(); final Node data = new NodeBuilder().setId(nodeId).build(); txChainManager.initialSubmitWriteTransaction(); txChainManager.writeToTransaction(LogicalDatastoreType.CONFIGURATION, path, data, false); @@ -135,7 +127,7 @@ public class TransactionChainManagerTest { Mockito.verify(txChain).newReadWriteTransaction(); Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data, false); - Mockito.verify(writeTx).submit(); + Mockito.verify(writeTx).commit(); } /** @@ -149,13 +141,13 @@ public class TransactionChainManagerTest { Mockito.verify(txChain).newReadWriteTransaction(); Mockito.verify(writeTx, Mockito.times(2)).put(LogicalDatastoreType.CONFIGURATION, path, data, false); - Mockito.verify(writeTx, Mockito.never()).submit(); + Mockito.verify(writeTx, Mockito.never()).commit(); } @Test public void testOnTransactionChainFailed() throws Exception { - txChainManager - .onTransactionChainFailed(txChain, Mockito.mock(AsyncTransaction.class), Mockito.mock(Throwable.class)); + txChainManager.onTransactionChainFailed(txChain, Mockito.mock(Transaction.class), + Mockito.mock(Throwable.class)); Mockito.verify(txChain).close(); Mockito.verify(dataBroker, Mockito.times(2)).createTransactionChain(txChainManager); } @@ -191,7 +183,7 @@ public class TransactionChainManagerTest { Mockito.verify(txChain).newReadWriteTransaction(); Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data, false); - Mockito.verify(writeTx, Mockito.never()).submit(); + Mockito.verify(writeTx, Mockito.never()).commit(); Mockito.verify(writeTx).cancel(); Mockito.verify(txChain).close(); } @@ -205,7 +197,7 @@ public class TransactionChainManagerTest { Mockito.verify(txChain).newReadWriteTransaction(); Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data, false); - Mockito.verify(writeTx).submit(); + Mockito.verify(writeTx).commit(); } @Test diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/initialization/OF10DeviceInitializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/initialization/OF10DeviceInitializerTest.java index c61702f5cf..d7da59d728 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/initialization/OF10DeviceInitializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/initialization/OF10DeviceInitializerTest.java @@ -5,7 +5,6 @@ * 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.openflowplugin.impl.device.initialization; import static org.mockito.ArgumentMatchers.any; @@ -20,8 +19,8 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; import org.opendaylight.openflowplugin.api.openflow.connection.OutboundQueueProvider; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/initialization/OF13DeviceInitializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/initialization/OF13DeviceInitializerTest.java index d641a1f9e4..3491d0a832 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/initialization/OF13DeviceInitializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/initialization/OF13DeviceInitializerTest.java @@ -5,7 +5,6 @@ * 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.openflowplugin.impl.device.initialization; import static org.mockito.ArgumentMatchers.any; @@ -21,8 +20,8 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; import org.opendaylight.openflowplugin.api.openflow.connection.OutboundQueueProvider; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImplTest.java index 5998817c55..4a907c3262 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImplTest.java @@ -5,22 +5,21 @@ * 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.openflowplugin.impl.registry.flow; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import com.google.common.base.Optional; -import com.google.common.util.concurrent.Futures; import java.math.BigInteger; import java.util.Collections; import java.util.Map; +import java.util.Optional; import java.util.concurrent.atomic.AtomicInteger; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -30,10 +29,10 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InOrder; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.ReadTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.OFConstants; import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor; import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey; @@ -50,6 +49,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; +import org.opendaylight.yangtools.util.concurrent.FluentFutures; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; @@ -69,7 +69,7 @@ public class DeviceFlowRegistryImplTest { @Mock private DataBroker dataBroker; @Mock - private ReadOnlyTransaction readOnlyTransaction; + private ReadTransaction readOnlyTransaction; @Before public void setUp() throws Exception { @@ -162,8 +162,8 @@ public class DeviceFlowRegistryImplTest { private Map fillRegistry(final InstanceIdentifier path, final FlowCapableNode flowCapableNode) throws Exception { - when(readOnlyTransaction.read(any(), any())) - .thenReturn(Futures.immediateCheckedFuture(Optional.fromNullable(flowCapableNode))); + doReturn(FluentFutures.immediateFluentFuture(Optional.ofNullable(flowCapableNode))).when(readOnlyTransaction) + .read(any(), any()); deviceFlowRegistry.fill().get(); return deviceFlowRegistry.getAllFlowDescriptors(); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/RpcContextImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/RpcContextImplTest.java index 9ca563094f..9de76edf55 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/RpcContextImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/RpcContextImplTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the @@ -10,18 +10,20 @@ package org.opendaylight.openflowplugin.impl.rpc; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.mockito.ArgumentMatchers.anySet; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import com.google.common.collect.ImmutableSet; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; import org.opendaylight.openflowplugin.api.openflow.device.DeviceState; @@ -30,11 +32,11 @@ import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext; import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy; import org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider; import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; +import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.binding.RpcService; @@ -47,7 +49,7 @@ public class RpcContextImplTest { @Mock - private RpcProviderRegistry rpcProviderRegistry; + private RpcProviderService rpcProviderRegistry; @Mock private DeviceState deviceState; @Mock @@ -55,7 +57,7 @@ public class RpcContextImplTest { @Mock private DeviceContext deviceContext; @Mock - private BindingAwareBroker.RoutedRpcRegistration routedRpcReg; + private ObjectRegistration routedRpcReg; @Mock private NotificationPublishService notificationPublishService; @@ -88,7 +90,7 @@ public class RpcContextImplTest { convertorExecutor, notificationPublishService, true); - when(rpcProviderRegistry.addRoutedRpcImplementation(TestRpcService.class, serviceInstance)) + when(rpcProviderRegistry.registerRpcImplementation(eq(TestRpcService.class), eq(serviceInstance), anySet())) .thenReturn(routedRpcReg); } @@ -138,8 +140,8 @@ public class RpcContextImplTest { public void testRegisterRpcServiceImplementation() { rpcContext.registerRpcServiceImplementation(TestRpcService.class, serviceInstance); - verify(rpcProviderRegistry, Mockito.times(1)).addRoutedRpcImplementation(TestRpcService.class,serviceInstance); - verify(routedRpcReg,Mockito.times(1)).registerPath(NodeContext.class,nodeInstanceIdentifier); + verify(rpcProviderRegistry, Mockito.times(1)).registerRpcImplementation(TestRpcService.class, serviceInstance, + ImmutableSet.of(nodeInstanceIdentifier)); assertEquals(rpcContext.isEmptyRpcRegistrations(), false); } @@ -153,8 +155,7 @@ public class RpcContextImplTest { @Test public void testClose() { - Class serviceClass = TestRpcService.class; - when(routedRpcReg.getServiceType()).thenReturn(serviceClass); + when(routedRpcReg.getInstance()).thenReturn(serviceInstance); rpcContext.registerRpcServiceImplementation(TestRpcService.class, serviceInstance); rpcContext.close(); assertEquals(rpcContext.isEmptyRpcRegistrations(), true); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/RpcManagerImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/RpcManagerImplTest.java index 722c766697..90c920f6f7 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/RpcManagerImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/RpcManagerImplTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the @@ -17,10 +17,9 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.openflowplugin.api.OFConstants; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; @@ -37,10 +36,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.NonZeroUint16Type; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfigBuilder; +import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.binding.RpcService; - @RunWith(MockitoJUnitRunner.class) public class RpcManagerImplTest { @@ -48,11 +47,11 @@ public class RpcManagerImplTest { private RpcManagerImpl rpcManager; @Mock - private RpcProviderRegistry rpcProviderRegistry; + private RpcProviderService rpcProviderRegistry; @Mock private DeviceContext deviceContext; @Mock - private BindingAwareBroker.RoutedRpcRegistration routedRpcRegistration; + private ObjectRegistration routedRpcRegistration; @Mock private DeviceState deviceState; @Mock diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/MultipartRequestOnTheFlyCallbackTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/MultipartRequestOnTheFlyCallbackTest.java index 158fed166b..61c5148a3f 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/MultipartRequestOnTheFlyCallbackTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/MultipartRequestOnTheFlyCallbackTest.java @@ -18,8 +18,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; -import com.google.common.util.concurrent.Futures; import java.math.BigInteger; import java.util.Collections; import java.util.List; @@ -29,10 +27,9 @@ import org.junit.runner.RunWith; import org.mockito.ArgumentMatchers; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.ReadTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.OFConstants; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; @@ -106,7 +103,7 @@ public class MultipartRequestOnTheFlyCallbackTest { @Mock private FlowDescriptor mockedFlowDescriptor; @Mock - private ReadOnlyTransaction mockedReadOnlyTx; + private ReadTransaction mockedReadOnlyTx; private AbstractRequestContext> dummyRequestContext; private final EventIdentifier dummyEventIdentifier = new EventIdentifier(DUMMY_EVENT_NAME, DUMMY_DEVICE_ID); @@ -135,8 +132,6 @@ public class MultipartRequestOnTheFlyCallbackTest { final FlowCapableNodeBuilder flowNodeBuilder = new FlowCapableNodeBuilder(); flowNodeBuilder.setTable(Collections.
emptyList()); final Optional flowNodeOpt = Optional.of(flowNodeBuilder.build()); - final CheckedFuture, ReadFailedException> flowNodeFuture = - Futures.immediateCheckedFuture(flowNodeOpt); dummyRequestContext = new AbstractRequestContext>(DUMMY_XID) { @Override @@ -227,8 +222,6 @@ public class MultipartRequestOnTheFlyCallbackTest { tableDataBld.setId(tableId); flowNodeBuilder.setTable(Collections.singletonList(tableDataBld.build())); final Optional flowNodeOpt = Optional.of(flowNodeBuilder.build()); - final CheckedFuture, ReadFailedException> flowNodeFuture = Futures - .immediateCheckedFuture(flowNodeOpt); multipartRequestOnTheFlyCallback.onSuccess(mpReplyMessage.build()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/ServiceMocking.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/ServiceMocking.java index f096ce8c50..2b0016a109 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/ServiceMocking.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/ServiceMocking.java @@ -17,8 +17,8 @@ import org.junit.Before; import org.junit.runner.RunWith; import org.mockito.Matchers; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter; import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue; import org.opendaylight.openflowplugin.api.OFConstants; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalTableServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalTableServiceImplTest.java index 2743236acd..5464043d6c 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalTableServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalTableServiceImplTest.java @@ -23,7 +23,7 @@ import org.mockito.ArgumentMatchers; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.stubbing.Answer; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier; import org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProviderFactory; import org.opendaylight.openflowplugin.impl.services.ServiceMocking; @@ -48,7 +48,7 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder; public class SalTableServiceImplTest extends ServiceMocking { @Mock - RpcProviderRegistry mockedRpcProviderRegistry; + RpcProviderService mockedRpcProviderRegistry; private SettableFuture handleResultFuture; private SalTableServiceImpl salTableService; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpMockInitiation.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpMockInitiation.java index 3fdd2e054c..4cef7168a5 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpMockInitiation.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpMockInitiation.java @@ -33,8 +33,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; - -class StatisticsContextImpMockInitiation { +public class StatisticsContextImpMockInitiation { Boolean isTable = false; Boolean isFlow = false; Boolean isGroup = false; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplTest.java index aa3bbad44c..02962122f4 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplTest.java @@ -5,7 +5,6 @@ * 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.openflowplugin.impl.statistics; import static org.junit.Assert.assertEquals; @@ -24,7 +23,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.opendaylight.openflowplugin.api.openflow.device.RequestContext; import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier; import org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProviderFactory; @@ -48,7 +47,7 @@ public class StatisticsContextImplTest extends StatisticsContextImpMockInitiatio private StatisticsContextImpl statisticsContext; private ConvertorManager convertorManager; @Mock - private OpenflowProviderConfig config = + private final OpenflowProviderConfig config = Mockito.mock(OpenflowProviderConfig.class); @Before diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtilsTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtilsTest.java index e20411a953..ead35ef8a1 100755 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtilsTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtilsTest.java @@ -5,23 +5,22 @@ * 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.openflowplugin.impl.statistics; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import com.google.common.base.Optional; import com.google.common.collect.Lists; -import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import java.math.BigInteger; import java.util.Collections; import java.util.List; +import java.util.Optional; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -34,10 +33,9 @@ import org.mockito.ArgumentMatchers; import org.mockito.InOrder; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.ReadTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.OFConstants; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; @@ -132,11 +130,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStatsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsData; import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.flow.capable.node.connector.statistics.FlowCapableNodeConnectorStatistics; +import org.opendaylight.yangtools.util.concurrent.FluentFutures; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; - @RunWith(MockitoJUnitRunner.class) public class StatisticsGatheringUtilsTest { @@ -162,7 +160,7 @@ public class StatisticsGatheringUtilsTest { @Mock private GetFeaturesOutput features; @Mock - private ReadOnlyTransaction readTx; + private ReadTransaction readTx; @Mock private ConnectionContext connectionAdapter; @Mock @@ -425,9 +423,8 @@ public class StatisticsGatheringUtilsTest { final FlowCapableNodeBuilder flowNodeBuilder = new FlowCapableNodeBuilder(); flowNodeBuilder.setTable(Collections.singletonList(tableDataBld.build())); final Optional flowNodeOpt = Optional.of(flowNodeBuilder.build()); - final CheckedFuture, ReadFailedException> flowNodeFuture = - Futures.immediateCheckedFuture(flowNodeOpt); - when(readTx.read(LogicalDatastoreType.OPERATIONAL, nodePath)).thenReturn(flowNodeFuture); + doReturn(FluentFutures.immediateFluentFuture(flowNodeOpt)).when(readTx) + .read(LogicalDatastoreType.OPERATIONAL, nodePath); when(flowDescriptor.getFlowId()).thenReturn(flowId); final org.opendaylight.yang.gen.v1.urn @@ -544,9 +541,8 @@ public class StatisticsGatheringUtilsTest { final FlowCapableNodeBuilder flowNodeBuilder = new FlowCapableNodeBuilder(); flowNodeBuilder.setTable(Collections.singletonList(tableDataBld.build())); final Optional flowNodeOpt = Optional.of(flowNodeBuilder.build()); - final CheckedFuture, ReadFailedException> flowNodeFuture = - Futures.immediateCheckedFuture(flowNodeOpt); - when(readTx.read(LogicalDatastoreType.OPERATIONAL, nodePath)).thenReturn(flowNodeFuture); + doReturn(FluentFutures.immediateFluentFuture(flowNodeOpt)).when(readTx) + .read(LogicalDatastoreType.OPERATIONAL, nodePath); StatisticsGatheringUtils.deleteAllKnownFlows(deviceContext, deviceInfo.getNodeInstanceIdentifier() .augmentation(FlowCapableNode.class), deviceFlowRegistry); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImplTest.java index 03a4d44769..ac53e5a2c8 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImplTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the @@ -26,10 +26,9 @@ import org.junit.runner.RunWith; import org.mockito.ArgumentMatchers; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter; import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; @@ -56,12 +55,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.GetStatisticsWorkModeOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.StatisticsManagerControlService; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.StatisticsWorkMode; +import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - @RunWith(MockitoJUnitRunner.class) public class StatisticsManagerImplTest { @@ -84,13 +83,13 @@ public class StatisticsManagerImplTest { @Mock private DeviceInfo mockedDeviceInfo; @Mock - private RpcProviderRegistry rpcProviderRegistry; + private RpcProviderService rpcProviderRegistry; @Mock private OutboundQueue outboundQueue; @Mock private MultiMsgCollector multiMagCollector; @Mock - private BindingAwareBroker.RpcRegistration serviceControlRegistration; + private ObjectRegistration serviceControlRegistration; @Mock private DeviceInfo deviceInfo; @Mock @@ -108,9 +107,9 @@ public class StatisticsManagerImplTest { .create(Nodes.class) .child(Node.class, new NodeKey(new NodeId("openflow:10"))); - when(rpcProviderRegistry.addRpcImplementation( + when(rpcProviderRegistry.registerRpcImplementation( eq(StatisticsManagerControlService.class), - ArgumentMatchers.any())).thenReturn(serviceControlRegistration); + ArgumentMatchers.any())).thenReturn(serviceControlRegistration); final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager(); final long basicTimerDelay = 3000L; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/AbstractSingleStatsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/AbstractSingleStatsServiceTest.java index c021c7cf94..e1dd5f3ac3 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/AbstractSingleStatsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/AbstractSingleStatsServiceTest.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.openflowplugin.impl.statistics.services; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.stubbing.Answer; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.api.openflow.device.RequestContext; import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext; import org.opendaylight.yangtools.yang.common.RpcResult; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/AbstractCompatibleStatServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/AbstractCompatibleStatServiceTest.java index 16d7f35aa1..1c3450dfa3 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/AbstractCompatibleStatServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/AbstractCompatibleStatServiceTest.java @@ -23,7 +23,7 @@ import org.mockito.Captor; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.stubbing.Answer; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.api.OFConstants; import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; import org.opendaylight.openflowplugin.api.openflow.device.DeviceState; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/OpendaylightFlowStatisticsServiceDelegateImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/OpendaylightFlowStatisticsServiceDelegateImplTest.java index aa8bf5526d..651e51e0a4 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/OpendaylightFlowStatisticsServiceDelegateImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/OpendaylightFlowStatisticsServiceDelegateImplTest.java @@ -5,7 +5,6 @@ * 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.openflowplugin.impl.statistics.services.compatibility; import static org.mockito.ArgumentMatchers.any; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/FlowDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/FlowDirectStatisticsServiceTest.java index d763332497..41efadf426 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/FlowDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/FlowDirectStatisticsServiceTest.java @@ -5,7 +5,6 @@ * 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.openflowplugin.impl.statistics.services.direct.multilayer; import static org.junit.Assert.assertEquals; @@ -19,7 +18,7 @@ import static org.mockito.Mockito.when; import java.math.BigInteger; import java.util.Collections; import java.util.List; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.openflow.device.Xid; import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry; import org.opendaylight.openflowplugin.impl.registry.flow.FlowDescriptorFactory; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/GroupDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/GroupDirectStatisticsServiceTest.java index 8358a7a658..5798df5881 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/GroupDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/GroupDirectStatisticsServiceTest.java @@ -5,7 +5,6 @@ * 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.openflowplugin.impl.statistics.services.direct.multilayer; import static org.junit.Assert.assertEquals; @@ -20,7 +19,7 @@ import static org.mockito.Mockito.when; import java.math.BigInteger; import java.util.Collections; import java.util.List; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.openflow.device.Xid; import org.opendaylight.openflowplugin.impl.statistics.services.direct.AbstractDirectStatisticsServiceTest; import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetGroupStatisticsInput; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/MeterDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/MeterDirectStatisticsServiceTest.java index 8cc436ae05..4990c249ca 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/MeterDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/MeterDirectStatisticsServiceTest.java @@ -5,7 +5,6 @@ * 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.openflowplugin.impl.statistics.services.direct.multilayer; import static org.junit.Assert.assertEquals; @@ -19,7 +18,7 @@ import static org.mockito.Mockito.when; import java.math.BigInteger; import java.util.Collections; import java.util.List; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.openflow.device.Xid; import org.opendaylight.openflowplugin.impl.statistics.services.direct.AbstractDirectStatisticsServiceTest; import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetMeterStatisticsInput; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/NodeConnectorDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/NodeConnectorDirectStatisticsServiceTest.java index e17fe48437..3ec5f6c3a5 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/NodeConnectorDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/NodeConnectorDirectStatisticsServiceTest.java @@ -5,7 +5,6 @@ * 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.openflowplugin.impl.statistics.services.direct.multilayer; import static org.junit.Assert.assertEquals; @@ -20,7 +19,7 @@ import static org.mockito.Mockito.when; import java.math.BigInteger; import java.util.Collections; import java.util.List; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.openflow.device.Xid; import org.opendaylight.openflowplugin.impl.statistics.services.direct.AbstractDirectStatisticsServiceTest; import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsInput; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/QueueDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/QueueDirectStatisticsServiceTest.java index 45706f1175..c2ce06a194 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/QueueDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/QueueDirectStatisticsServiceTest.java @@ -5,7 +5,6 @@ * 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.openflowplugin.impl.statistics.services.direct.multilayer; import static org.junit.Assert.assertEquals; @@ -21,7 +20,7 @@ import java.math.BigInteger; import java.util.Collections; import java.util.List; import org.junit.Test; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.openflow.device.Xid; import org.opendaylight.openflowplugin.impl.statistics.services.direct.AbstractDirectStatisticsServiceTest; import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetQueueStatisticsInput; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/FlowDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/FlowDirectStatisticsServiceTest.java index 95759a287c..bcb761a8af 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/FlowDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/FlowDirectStatisticsServiceTest.java @@ -5,7 +5,6 @@ * 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.openflowplugin.impl.statistics.services.direct.singlelayer; import static org.junit.Assert.assertEquals; @@ -19,7 +18,7 @@ import static org.mockito.Mockito.when; import java.math.BigInteger; import java.util.Collections; import java.util.List; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.openflow.device.Xid; import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry; import org.opendaylight.openflowplugin.impl.registry.flow.FlowDescriptorFactory; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/GroupDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/GroupDirectStatisticsServiceTest.java index 55f29132a8..72d2533b02 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/GroupDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/GroupDirectStatisticsServiceTest.java @@ -5,7 +5,6 @@ * 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.openflowplugin.impl.statistics.services.direct.singlelayer; import static org.junit.Assert.assertEquals; @@ -19,7 +18,7 @@ import static org.mockito.Mockito.when; import java.util.Collections; import java.util.List; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.openflow.device.Xid; import org.opendaylight.openflowplugin.impl.statistics.services.direct.AbstractDirectStatisticsServiceTest; import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetGroupStatisticsInput; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/MeterDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/MeterDirectStatisticsServiceTest.java index 6b5b5dbfff..cb9d144aae 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/MeterDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/MeterDirectStatisticsServiceTest.java @@ -5,7 +5,6 @@ * 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.openflowplugin.impl.statistics.services.direct.singlelayer; import static org.junit.Assert.assertEquals; @@ -20,7 +19,7 @@ import static org.mockito.Mockito.when; import java.math.BigInteger; import java.util.Collections; import java.util.List; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.openflow.device.Xid; import org.opendaylight.openflowplugin.impl.statistics.services.direct.AbstractDirectStatisticsServiceTest; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/NodeConnectorDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/NodeConnectorDirectStatisticsServiceTest.java index b7fe1136f4..f5c5615055 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/NodeConnectorDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/NodeConnectorDirectStatisticsServiceTest.java @@ -5,7 +5,6 @@ * 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.openflowplugin.impl.statistics.services.direct.singlelayer; import static org.junit.Assert.assertEquals; @@ -19,7 +18,7 @@ import static org.mockito.Mockito.when; import java.util.Collections; import java.util.List; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.openflow.device.Xid; import org.opendaylight.openflowplugin.impl.statistics.services.direct.AbstractDirectStatisticsServiceTest; import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsInput; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/QueueDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/QueueDirectStatisticsServiceTest.java index f53dd84dd0..eda1e8e8b5 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/QueueDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/QueueDirectStatisticsServiceTest.java @@ -5,7 +5,6 @@ * 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.openflowplugin.impl.statistics.services.direct.singlelayer; import static org.junit.Assert.assertEquals; @@ -21,7 +20,7 @@ import java.math.BigInteger; import java.util.Collections; import java.util.List; import org.junit.Test; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.openflow.device.Xid; import org.opendaylight.openflowplugin.impl.statistics.services.direct.AbstractDirectStatisticsServiceTest; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/PacketReceivedTranslatorTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/PacketReceivedTranslatorTest.java index 225ffb12cf..d5487950ef 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/PacketReceivedTranslatorTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/PacketReceivedTranslatorTest.java @@ -17,8 +17,8 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.openflowplugin.api.OFConstants; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/DeviceInitializationUtilTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/DeviceInitializationUtilTest.java index 75adf0cfad..1078df83c0 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/DeviceInitializationUtilTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/DeviceInitializationUtilTest.java @@ -5,27 +5,27 @@ * 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.openflowplugin.impl.util; import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import com.google.common.util.concurrent.Futures; import java.net.InetSocketAddress; import java.util.Collections; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.WriteTransaction; +import org.opendaylight.mdsal.common.api.CommitInfo; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter; import org.opendaylight.openflowplugin.api.OFConstants; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; @@ -71,7 +71,7 @@ public class DeviceInitializationUtilTest { @Before public void setUp() throws Exception { when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(NODE_II); - when(writeTransaction.submit()).thenReturn(Futures.immediateCheckedFuture(null)); + doReturn(CommitInfo.emptyFluentFuture()).when(writeTransaction).commit(); when(dataBroker.newWriteOnlyTransaction()).thenReturn(writeTransaction); when(connectionAdapter.getRemoteAddress()).thenReturn(INET_SOCKET_ADDRESS); when(featuresReply.getTables()).thenReturn(TABLES); @@ -90,7 +90,7 @@ public class DeviceInitializationUtilTest { .create(Nodes.class), new NodesBuilder() .setNode(Collections.emptyList()) .build()); - verify(writeTransaction).submit(); + verify(writeTransaction).commit(); } @Test diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MdSalRegistrationUtilsTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MdSalRegistrationUtilsTest.java index 94643b753b..bdf0a2a918 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MdSalRegistrationUtilsTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MdSalRegistrationUtilsTest.java @@ -18,8 +18,8 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.mockito.junit.MockitoJUnitRunner; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; diff --git a/openflowplugin/pom.xml b/openflowplugin/pom.xml index 0556e5b199..b277b015e9 100644 --- a/openflowplugin/pom.xml +++ b/openflowplugin/pom.xml @@ -45,12 +45,8 @@ model-inventory - org.opendaylight.controller - sal-binding-api - - - org.opendaylight.controller - sal-binding-broker-impl + org.opendaylight.mdsal + mdsal-binding-api @@ -87,10 +83,6 @@ org.opendaylight.controller sal-common-util - - org.opendaylight.controller - sal-common-api - ${project.groupId}.openflowjava openflowjava-util diff --git a/samples/learning-switch/pom.xml b/samples/learning-switch/pom.xml index c6d05fdbde..a8ef202573 100644 --- a/samples/learning-switch/pom.xml +++ b/samples/learning-switch/pom.xml @@ -34,8 +34,8 @@ model-inventory - org.opendaylight.controller - sal-binding-api + org.opendaylight.mdsal + mdsal-binding-api org.opendaylight.mdsal diff --git a/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/DataTreeChangeListenerRegistrationHolder.java b/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/DataTreeChangeListenerRegistrationHolder.java index 1fa1ef2e9a..39feb47b6e 100644 --- a/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/DataTreeChangeListenerRegistrationHolder.java +++ b/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/DataTreeChangeListenerRegistrationHolder.java @@ -8,11 +8,11 @@ package org.opendaylight.openflowplugin.learningswitch; -import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; +import org.opendaylight.mdsal.binding.api.DataTreeChangeListener; import org.opendaylight.yangtools.concepts.ListenerRegistration; /** - * Holder for {@link org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener} registration. + * Holder for {@link DataTreeChangeListener} registration. */ public interface DataTreeChangeListenerRegistrationHolder { diff --git a/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/FlowCommitWrapper.java b/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/FlowCommitWrapper.java index 060dbdb9f6..349ee02936 100644 --- a/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/FlowCommitWrapper.java +++ b/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/FlowCommitWrapper.java @@ -1,11 +1,10 @@ -/** +/* * Copyright (c) 2014 Cisco Systems, Inc. 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.openflowplugin.learningswitch; import com.google.common.util.concurrent.ListenableFuture; @@ -21,6 +20,6 @@ public interface FlowCommitWrapper { * @param flowBody the flow body * @return transaction commit */ - ListenableFuture writeFlowToConfig(InstanceIdentifier flowPath, Flow flowBody); + ListenableFuture writeFlowToConfig(InstanceIdentifier flowPath, Flow flowBody); } diff --git a/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/FlowCommitWrapperImpl.java b/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/FlowCommitWrapperImpl.java index b6458aac28..0b44181f7e 100644 --- a/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/FlowCommitWrapperImpl.java +++ b/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/FlowCommitWrapperImpl.java @@ -1,17 +1,16 @@ -/** +/* * Copyright (c) 2014 Cisco Systems, Inc. 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.openflowplugin.learningswitch; import com.google.common.util.concurrent.ListenableFuture; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.ReadWriteTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @@ -24,10 +23,10 @@ public class FlowCommitWrapperImpl implements FlowCommitWrapper { } @Override - public ListenableFuture writeFlowToConfig(InstanceIdentifier flowPath, Flow flowBody) { + public ListenableFuture writeFlowToConfig(InstanceIdentifier flowPath, Flow flowBody) { ReadWriteTransaction addFlowTransaction = dataBrokerService.newReadWriteTransaction(); addFlowTransaction.put(LogicalDatastoreType.CONFIGURATION, flowPath, flowBody, true); - return addFlowTransaction.submit(); + return addFlowTransaction.commit(); } } diff --git a/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/LearningSwitchManager.java b/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/LearningSwitchManager.java index fb9f6fc454..005e2944f7 100644 --- a/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/LearningSwitchManager.java +++ b/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/LearningSwitchManager.java @@ -1,15 +1,14 @@ -/** +/* * Copyright (c) 2014 Cisco Systems, Inc. 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.openflowplugin.learningswitch; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.sal.binding.api.NotificationService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationService; import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService; public interface LearningSwitchManager { diff --git a/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/LearningSwitchManagerSimpleImpl.java b/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/LearningSwitchManagerSimpleImpl.java index 3e59b0646c..a3955bd247 100644 --- a/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/LearningSwitchManagerSimpleImpl.java +++ b/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/LearningSwitchManagerSimpleImpl.java @@ -7,11 +7,11 @@ */ package org.opendaylight.openflowplugin.learningswitch; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.sal.binding.api.NotificationService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataTreeChangeListener; +import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; +import org.opendaylight.mdsal.binding.api.NotificationService; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; @@ -90,7 +90,7 @@ public class LearningSwitchManagerSimpleImpl .augmentation(FlowCapableNode.class) .child(Table.class); final DataTreeIdentifier
dataTreeIdentifier = - new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, instanceIdentifier); + DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, instanceIdentifier); dataTreeChangeListenerRegistration = data.registerDataTreeChangeListener(dataTreeIdentifier, wakeupListener); LOG.debug("start() <--"); } diff --git a/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/WakeupOnNode.java b/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/WakeupOnNode.java index fc101a07b1..b88883f4d7 100644 --- a/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/WakeupOnNode.java +++ b/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/WakeupOnNode.java @@ -1,18 +1,17 @@ -/** +/* * Copyright (c) 2014 Cisco Systems, Inc. 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.openflowplugin.learningswitch; import java.util.Collection; import javax.annotation.Nonnull; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType; -import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType; +import org.opendaylight.mdsal.binding.api.DataTreeChangeListener; +import org.opendaylight.mdsal.binding.api.DataTreeModification; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @@ -29,7 +28,7 @@ public class WakeupOnNode implements DataTreeChangeListener
{ Short requiredTableId = 0; // TODO add flow - for (DataTreeModification modification : modifications) { + for (DataTreeModification
modification : modifications) { if (modification.getRootNode().getModificationType() == ModificationType.SUBTREE_MODIFIED) { DataObject table = modification.getRootNode().getDataAfter(); if (table instanceof Table) { diff --git a/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/multi/LearningSwitchManagerMultiImpl.java b/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/multi/LearningSwitchManagerMultiImpl.java index 10808af671..3b489b727f 100644 --- a/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/multi/LearningSwitchManagerMultiImpl.java +++ b/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/multi/LearningSwitchManagerMultiImpl.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the @@ -7,11 +7,11 @@ */ package org.opendaylight.openflowplugin.learningswitch.multi; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.sal.binding.api.NotificationService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataTreeChangeListener; +import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; +import org.opendaylight.mdsal.binding.api.NotificationService; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.learningswitch.DataTreeChangeListenerRegistrationHolder; import org.opendaylight.openflowplugin.learningswitch.FlowCommitWrapper; import org.opendaylight.openflowplugin.learningswitch.FlowCommitWrapperImpl; @@ -97,7 +97,7 @@ public class LearningSwitchManagerMultiImpl implements DataTreeChangeListenerReg .augmentation(FlowCapableNode.class) .child(Table.class); final DataTreeIdentifier
dataTreeIdentifier = - new DataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, instanceIdentifier); + DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, instanceIdentifier); dataTreeChangeListenerRegistration = data.registerDataTreeChangeListener(dataTreeIdentifier, wakeupListener); LOG.debug("start() <--"); } diff --git a/samples/learning-switch/src/main/resources/OSGI-INF/blueprint/learning-switch.xml b/samples/learning-switch/src/main/resources/OSGI-INF/blueprint/learning-switch.xml index c969ef9d86..0d102ea6aa 100644 --- a/samples/learning-switch/src/main/resources/OSGI-INF/blueprint/learning-switch.xml +++ b/samples/learning-switch/src/main/resources/OSGI-INF/blueprint/learning-switch.xml @@ -3,8 +3,8 @@ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0" odl:use-default-for-reference-types="true"> - - + + diff --git a/samples/sample-bundles/pom.xml b/samples/sample-bundles/pom.xml index 811c3b65b7..5e8e963277 100644 --- a/samples/sample-bundles/pom.xml +++ b/samples/sample-bundles/pom.xml @@ -42,8 +42,8 @@ model-inventory - org.opendaylight.controller - sal-binding-api + org.opendaylight.mdsal + mdsal-binding-api org.opendaylight.mdsal diff --git a/samples/sample-bundles/src/main/java/org/opendaylight/openflowplugin/samples/sample/bundles/SampleFlowCapableNodeListener.java b/samples/sample-bundles/src/main/java/org/opendaylight/openflowplugin/samples/sample/bundles/SampleFlowCapableNodeListener.java index b81f3ef005..97c6100af1 100644 --- a/samples/sample-bundles/src/main/java/org/opendaylight/openflowplugin/samples/sample/bundles/SampleFlowCapableNodeListener.java +++ b/samples/sample-bundles/src/main/java/org/opendaylight/openflowplugin/samples/sample/bundles/SampleFlowCapableNodeListener.java @@ -17,12 +17,12 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import javax.annotation.Nonnull; -import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType; +import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; +import org.opendaylight.mdsal.binding.api.DataTreeModification; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder; @@ -120,7 +120,7 @@ public class SampleFlowCapableNodeListener implements ClusteredDataTreeChangeLis final InstanceIdentifier path = InstanceIdentifier.create(Nodes.class).child(Node.class) .augmentation(FlowCapableNode.class); final DataTreeIdentifier identifier = - new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, path); + DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, path); listenerReg = dataBroker.registerDataTreeChangeListener(identifier, SampleFlowCapableNodeListener.this); } diff --git a/samples/sample-bundles/src/main/resources/OSGI-INF/blueprint/bundle-blueprint.xml b/samples/sample-bundles/src/main/resources/OSGI-INF/blueprint/bundle-blueprint.xml index 9412061e49..f5e8846edc 100644 --- a/samples/sample-bundles/src/main/resources/OSGI-INF/blueprint/bundle-blueprint.xml +++ b/samples/sample-bundles/src/main/resources/OSGI-INF/blueprint/bundle-blueprint.xml @@ -3,7 +3,7 @@ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0" odl:use-default-for-reference-types="true"> - + diff --git a/samples/sample-consumer/pom.xml b/samples/sample-consumer/pom.xml index 87558f9b65..df2d36d136 100644 --- a/samples/sample-consumer/pom.xml +++ b/samples/sample-consumer/pom.xml @@ -38,8 +38,8 @@ org.opendaylight.controller.model - org.opendaylight.controller - sal-binding-api + org.opendaylight.mdsal + mdsal-binding-api org.opendaylight.mdsal diff --git a/test-common/pom.xml b/test-common/pom.xml index 1fba7a4da8..fb7039cbf1 100644 --- a/test-common/pom.xml +++ b/test-common/pom.xml @@ -21,8 +21,8 @@ guava - org.opendaylight.controller - sal-binding-api + org.opendaylight.mdsal + mdsal-binding-api org.opendaylight.openflowplugin.model diff --git a/test-common/src/main/java/org/opendaylight/openflowplugin/testcommon/DropTestCommiter.java b/test-common/src/main/java/org/opendaylight/openflowplugin/testcommon/DropTestCommiter.java index cb0bf74788..463118f38a 100644 --- a/test-common/src/main/java/org/opendaylight/openflowplugin/testcommon/DropTestCommiter.java +++ b/test-common/src/main/java/org/opendaylight/openflowplugin/testcommon/DropTestCommiter.java @@ -9,10 +9,10 @@ package org.opendaylight.openflowplugin.testcommon; import java.math.BigInteger; import java.util.concurrent.atomic.AtomicLong; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.NotificationService; -import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationService; +import org.opendaylight.mdsal.binding.api.ReadWriteTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId; @@ -110,7 +110,7 @@ public class DropTestCommiter extends AbstractDropTest { LOG.debug("onPacketReceived - About to write flow {}", flow); } transaction.put(LogicalDatastoreType.CONFIGURATION, flowInstanceId, flow, true); - transaction.submit(); + transaction.commit(); LOG.debug("onPacketReceived - About to write flow commited"); } diff --git a/test-common/src/main/java/org/opendaylight/openflowplugin/testcommon/DropTestDsProvider.java b/test-common/src/main/java/org/opendaylight/openflowplugin/testcommon/DropTestDsProvider.java index 9efdf4b346..79ef8cc97e 100644 --- a/test-common/src/main/java/org/opendaylight/openflowplugin/testcommon/DropTestDsProvider.java +++ b/test-common/src/main/java/org/opendaylight/openflowplugin/testcommon/DropTestDsProvider.java @@ -7,8 +7,8 @@ */ package org.opendaylight.openflowplugin.testcommon; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.NotificationService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/test-common/src/main/java/org/opendaylight/openflowplugin/testcommon/DropTestRpcProvider.java b/test-common/src/main/java/org/opendaylight/openflowplugin/testcommon/DropTestRpcProvider.java index 0b181b7f0f..5eaa3a03ff 100644 --- a/test-common/src/main/java/org/opendaylight/openflowplugin/testcommon/DropTestRpcProvider.java +++ b/test-common/src/main/java/org/opendaylight/openflowplugin/testcommon/DropTestRpcProvider.java @@ -7,7 +7,7 @@ */ package org.opendaylight.openflowplugin.testcommon; -import org.opendaylight.controller.md.sal.binding.api.NotificationService; +import org.opendaylight.mdsal.binding.api.NotificationService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/test-common/src/main/java/org/opendaylight/openflowplugin/testcommon/DropTestRpcSender.java b/test-common/src/main/java/org/opendaylight/openflowplugin/testcommon/DropTestRpcSender.java index d11f5a85d2..fac568b683 100644 --- a/test-common/src/main/java/org/opendaylight/openflowplugin/testcommon/DropTestRpcSender.java +++ b/test-common/src/main/java/org/opendaylight/openflowplugin/testcommon/DropTestRpcSender.java @@ -13,7 +13,7 @@ import com.google.common.util.concurrent.JdkFutureAdapters; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import java.math.BigInteger; -import org.opendaylight.controller.md.sal.binding.api.NotificationService; +import org.opendaylight.mdsal.binding.api.NotificationService; import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder; diff --git a/test-provider/pom.xml b/test-provider/pom.xml index b8c84f9928..044a68612e 100644 --- a/test-provider/pom.xml +++ b/test-provider/pom.xml @@ -19,8 +19,8 @@ guava - org.opendaylight.controller - sal-binding-api + org.opendaylight.mdsal + mdsal-binding-api org.opendaylight.openflowplugin.model diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowPluginBulkGroupTransactionProvider.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowPluginBulkGroupTransactionProvider.java index 0f45855999..e183029cf8 100644 --- a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowPluginBulkGroupTransactionProvider.java +++ b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowPluginBulkGroupTransactionProvider.java @@ -5,22 +5,19 @@ * 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.openflowplugin.test; import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import java.math.BigInteger; import java.util.ArrayList; import java.util.List; import org.eclipse.osgi.framework.console.CommandInterpreter; import org.eclipse.osgi.framework.console.CommandProvider; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.sal.binding.api.NotificationService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationService; +import org.opendaylight.mdsal.binding.api.ReadWriteTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.ControllerActionCaseBuilder; @@ -716,10 +713,9 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid .child(Group.class, new GroupKey(group1.getGroupId())); modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode12), testNode12, true); modification.merge(LogicalDatastoreType.CONFIGURATION, path2, group1, true); - ListenableFuture commitFuture = modification.submit(); - Futures.addCallback(commitFuture, new FutureCallback() { + modification.commit().addCallback(new FutureCallback() { @Override - public void onSuccess(Void notUsed) { + public void onSuccess(Object notUsed) { ci.println("Status of Group Data Loaded Transaction: success."); } @@ -742,10 +738,9 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid .child(Group.class, new GroupKey(group1.getGroupId())); modification.delete(LogicalDatastoreType.OPERATIONAL, path2); modification.delete(LogicalDatastoreType.CONFIGURATION, path2); - ListenableFuture commitFuture = modification.submit(); - Futures.addCallback(commitFuture, new FutureCallback() { + modification.commit().addCallback(new FutureCallback() { @Override - public void onSuccess(Void notUsed) { + public void onSuccess(Object notUsed) { ci.println("Status of Group Data Loaded Transaction: success."); } diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowPluginBulkTransactionProvider.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowPluginBulkTransactionProvider.java index c761ae5498..a933089209 100644 --- a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowPluginBulkTransactionProvider.java +++ b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowPluginBulkTransactionProvider.java @@ -5,22 +5,19 @@ * 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.openflowplugin.test; import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import java.math.BigInteger; import java.util.ArrayList; import java.util.List; import org.eclipse.osgi.framework.console.CommandInterpreter; import org.eclipse.osgi.framework.console.CommandProvider; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.sal.binding.api.NotificationService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationService; +import org.opendaylight.mdsal.binding.api.ReadWriteTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6FlowLabel; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri; @@ -650,10 +647,9 @@ public class OpenflowPluginBulkTransactionProvider implements CommandProvider { modification.delete(LogicalDatastoreType.OPERATIONAL, path4); modification.delete(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(tn)); modification.delete(LogicalDatastoreType.CONFIGURATION, path4); - ListenableFuture commitFuture = modification.submit(); - Futures.addCallback(commitFuture, new FutureCallback() { + modification.commit().addCallback(new FutureCallback() { @Override - public void onSuccess(Void notUsed) { + public void onSuccess(Object notUsed) { ci.println("Status of Group Data Loaded Transaction: success."); } @@ -707,10 +703,9 @@ public class OpenflowPluginBulkTransactionProvider implements CommandProvider { modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true); modification.merge(LogicalDatastoreType.CONFIGURATION, path4, flow3.build(), true); - ListenableFuture commitFuture = modification.submit(); - Futures.addCallback(commitFuture, new FutureCallback() { + modification.commit().addCallback(new FutureCallback() { @Override - public void onSuccess(Void notUsed) { + public void onSuccess(Object notUsed) { ci.println("Status of Group Data Loaded Transaction: success."); } diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginGroupTestCommandProvider.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginGroupTestCommandProvider.java index 743711ac75..2c47a55b8a 100644 --- a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginGroupTestCommandProvider.java +++ b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginGroupTestCommandProvider.java @@ -5,21 +5,18 @@ * 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.openflowplugin.test; import com.google.common.base.Preconditions; import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import java.util.ArrayList; import java.util.List; import org.eclipse.osgi.framework.console.CommandInterpreter; import org.eclipse.osgi.framework.console.CommandProvider; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.ReadWriteTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder; @@ -584,10 +581,9 @@ public class OpenflowpluginGroupTestCommandProvider implements CommandProvider { InstanceIdentifier path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.key()) .augmentation(FlowCapableNode.class).child(Group.class, new GroupKey(gbuilder.getGroupId())); modification.delete(LogicalDatastoreType.CONFIGURATION, path1); - ListenableFuture commitFuture = modification.submit(); - Futures.addCallback(commitFuture, new FutureCallback() { + modification.commit().addCallback(new FutureCallback() { @Override - public void onSuccess(Void notUsed) { + public void onSuccess(Object notUsed) { ci.println("Status of Group Data Loaded Transaction: success."); } @@ -619,10 +615,9 @@ public class OpenflowpluginGroupTestCommandProvider implements CommandProvider { .child(Group.class, new GroupKey(group.getGroupId())); modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true); modification.merge(LogicalDatastoreType.CONFIGURATION, path1, group, true); - ListenableFuture commitFuture = modification.submit(); - Futures.addCallback(commitFuture, new FutureCallback() { + modification.commit().addCallback(new FutureCallback() { @Override - public void onSuccess(Void notUsed) { + public void onSuccess(Object notUsed) { ci.println("Status of Group Data Loaded Transaction: success."); } diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginGroupTestServiceProvider.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginGroupTestServiceProvider.java index b1c69012d4..7f12e32b60 100644 --- a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginGroupTestServiceProvider.java +++ b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginGroupTestServiceProvider.java @@ -1,17 +1,16 @@ -/** +/* * Copyright (c) 2013 Cisco Systems, Inc. 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.openflowplugin.test; +import com.google.common.collect.ImmutableSet; import com.google.common.util.concurrent.ListenableFuture; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput; @@ -19,7 +18,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.Rem import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; @@ -27,7 +25,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder; import org.opendaylight.yangtools.yang.common.RpcResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,23 +34,22 @@ public class OpenflowpluginGroupTestServiceProvider implements AutoCloseable, private static final Logger LOG = LoggerFactory .getLogger(OpenflowpluginGroupTestServiceProvider.class); - private RoutedRpcRegistration groupRegistration; - private NotificationProviderService notificationService; + private ObjectRegistration groupRegistration; + private NotificationPublishService notificationService; /** * Get group registration. * * @return {@link #groupRegistration} */ - public RoutedRpcRegistration getGroupRegistration() { + public ObjectRegistration getGroupRegistration() { return groupRegistration; } /** * Set {@link #groupRegistration}. */ - public void setGroupRegistration( - final RoutedRpcRegistration groupRegistration) { + public void setGroupRegistration(final ObjectRegistration groupRegistration) { this.groupRegistration = groupRegistration; } @@ -62,15 +58,14 @@ public class OpenflowpluginGroupTestServiceProvider implements AutoCloseable, * * @return {@link #notificationService} */ - public NotificationProviderService getNotificationService() { + public NotificationPublishService getNotificationService() { return notificationService; } /** * Set {@link #notificationService}. */ - public void setNotificationService( - final NotificationProviderService notificationService) { + public void setNotificationService(final NotificationPublishService notificationService) { this.notificationService = notificationService; } @@ -138,28 +133,15 @@ public class OpenflowpluginGroupTestServiceProvider implements AutoCloseable, return null; } - public ObjectRegistration register( - final RpcProviderRegistry rpcRegistry) { - RoutedRpcRegistration addRoutedRpcImplementation = rpcRegistry.addRoutedRpcImplementation( - SalGroupService.class, this); - setGroupRegistration(addRoutedRpcImplementation); - - InstanceIdentifierBuilder builder1 = InstanceIdentifier - .builder(Nodes.class); - - NodeId nodeId = new NodeId(OpenflowpluginTestActivator.NODE_ID); - NodeKey nodeKey = new NodeKey(nodeId); + public ObjectRegistration register(final RpcProviderService rpcRegistry) { + setGroupRegistration(rpcRegistry.registerRpcImplementation(SalGroupService.class, this, ImmutableSet.of( + InstanceIdentifier.create(Nodes.class) + .child(Node.class, new NodeKey(new NodeId(OpenflowpluginTestActivator.NODE_ID)))))); - InstanceIdentifierBuilder nodeIndentifier = builder1 - .child(Node.class, nodeKey); - InstanceIdentifier instance = nodeIndentifier.build(); - groupRegistration.registerPath(NodeContext.class, instance); - RoutedRpcRegistration groupRegistration1 = this - .getGroupRegistration(); return new AbstractObjectRegistration(this) { @Override protected void removeRegistration() { - groupRegistration1.close(); + groupRegistration.close(); } }; } diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginMeterTestCommandProvider.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginMeterTestCommandProvider.java index 2ca6c7a3d8..98f9aa22c6 100644 --- a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginMeterTestCommandProvider.java +++ b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginMeterTestCommandProvider.java @@ -5,21 +5,18 @@ * 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.openflowplugin.test; import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import java.util.ArrayList; import java.util.List; import org.eclipse.osgi.framework.console.CommandInterpreter; import org.eclipse.osgi.framework.console.CommandProvider; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.sal.binding.api.NotificationService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationService; +import org.opendaylight.mdsal.binding.api.ReadWriteTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder; @@ -229,10 +226,9 @@ public class OpenflowpluginMeterTestCommandProvider implements CommandProvider { InstanceIdentifier path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.key()) .augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(testMeter.getMeterId())); modification.delete(LogicalDatastoreType.CONFIGURATION, path1); - ListenableFuture commitFuture = modification.submit(); - Futures.addCallback(commitFuture, new FutureCallback() { + modification.commit().addCallback(new FutureCallback() { @Override - public void onSuccess(Void notUsed) { + public void onSuccess(Object notUsed) { ci.println("Status of Group Data Loaded Transaction: success."); } @@ -311,10 +307,9 @@ public class OpenflowpluginMeterTestCommandProvider implements CommandProvider { break; } - ListenableFuture commitFuture = modification.submit(); - Futures.addCallback(commitFuture, new FutureCallback() { + modification.commit().addCallback(new FutureCallback() { @Override - public void onSuccess(Void notUsed) { + public void onSuccess(Object notUsed) { ci.println("Status of Group Data Loaded Transaction: success."); } @@ -384,10 +379,9 @@ public class OpenflowpluginMeterTestCommandProvider implements CommandProvider { .augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(meter.getMeterId())); modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true); modification.merge(LogicalDatastoreType.CONFIGURATION, path1, meter, true); - ListenableFuture commitFuture = modification.submit(); - Futures.addCallback(commitFuture, new FutureCallback() { + modification.commit().addCallback(new FutureCallback() { @Override - public void onSuccess(Void notUsed) { + public void onSuccess(Object notUsed) { ci.println("Status of Group Data Loaded Transaction: success."); } @@ -409,10 +403,9 @@ public class OpenflowpluginMeterTestCommandProvider implements CommandProvider { modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true); modification.merge(LogicalDatastoreType.CONFIGURATION, path2, meter1, true); - ListenableFuture commitFuture = modification.submit(); - Futures.addCallback(commitFuture, new FutureCallback() { + modification.commit().addCallback(new FutureCallback() { @Override - public void onSuccess(Void notUsed) { + public void onSuccess(Object notUsed) { ci.println("Status of Group Data Loaded Transaction: success."); } diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginMeterTestServiceProvider.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginMeterTestServiceProvider.java index cf89034d30..453b41f66b 100644 --- a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginMeterTestServiceProvider.java +++ b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginMeterTestServiceProvider.java @@ -1,19 +1,17 @@ -/** +/* * Copyright (c) 2013 Cisco Systems, Inc. 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.openflowplugin.test; +import com.google.common.collect.ImmutableSet; import com.google.common.util.concurrent.ListenableFuture; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; @@ -28,7 +26,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.Upd import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder; import org.opendaylight.yangtools.yang.common.RpcResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,8 +35,8 @@ public class OpenflowpluginMeterTestServiceProvider implements AutoCloseable, private static final Logger LOG = LoggerFactory .getLogger(OpenflowpluginMeterTestServiceProvider.class); private DataBroker dataService; - private RoutedRpcRegistration meterRegistration; - private NotificationProviderService notificationService; + private ObjectRegistration meterRegistration; + private NotificationPublishService notificationService; /** * Gets the data service. @@ -62,15 +59,14 @@ public class OpenflowpluginMeterTestServiceProvider implements AutoCloseable, * * @return {@link #meterRegistration} */ - public RoutedRpcRegistration getMeterRegistration() { + public ObjectRegistration getMeterRegistration() { return this.meterRegistration; } /** * Sets the {@link #meterRegistration}. */ - public void setMeterRegistration( - final RoutedRpcRegistration meterRegistration) { + public void setMeterRegistration(final ObjectRegistration meterRegistration) { this.meterRegistration = meterRegistration; } @@ -79,15 +75,14 @@ public class OpenflowpluginMeterTestServiceProvider implements AutoCloseable, * * @return {@link #notificationService} */ - public NotificationProviderService getNotificationService() { + public NotificationPublishService getNotificationService() { return this.notificationService; } /** * Sets the {@link #notificationService}. */ - public void setNotificationService( - final NotificationProviderService notificationService) { + public void setNotificationService(final NotificationPublishService notificationService) { this.notificationService = notificationService; } @@ -155,35 +150,16 @@ public class OpenflowpluginMeterTestServiceProvider implements AutoCloseable, return null; } - public ObjectRegistration register( - final RpcProviderRegistry rpcRegistry) { - - RoutedRpcRegistration addRoutedRpcImplementation = rpcRegistry.addRoutedRpcImplementation( - SalMeterService.class, this); - - setMeterRegistration(addRoutedRpcImplementation); - - InstanceIdentifierBuilder builder1 = InstanceIdentifier - .builder(Nodes.class); - - NodeId nodeId = new NodeId(OpenflowpluginTestActivator.NODE_ID); - NodeKey nodeKey = new NodeKey(nodeId); - - InstanceIdentifierBuilder nodeIndentifier = builder1 - .child(Node.class, nodeKey); - - InstanceIdentifier instance = nodeIndentifier.build(); - - meterRegistration.registerPath(NodeContext.class, instance); - - RoutedRpcRegistration meterRegistration1 = this - .getMeterRegistration(); + public ObjectRegistration register(final RpcProviderService rpcRegistry) { + setMeterRegistration(rpcRegistry.registerRpcImplementation(SalMeterService.class, this, ImmutableSet.of( + InstanceIdentifier.create(Nodes.class) + .child(Node.class, new NodeKey(new NodeId(OpenflowpluginTestActivator.NODE_ID)))))); return new AbstractObjectRegistration(this) { @Override protected void removeRegistration() { - meterRegistration1.close(); + meterRegistration.close(); } }; } diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginStatsTestCommandProvider.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginStatsTestCommandProvider.java index 0a0a8e74c0..b0d70dc3e9 100644 --- a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginStatsTestCommandProvider.java +++ b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginStatsTestCommandProvider.java @@ -5,14 +5,13 @@ * 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.openflowplugin.test; import java.util.List; import org.eclipse.osgi.framework.console.CommandInterpreter; import org.eclipse.osgi.framework.console.CommandProvider; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.ReadTransaction; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter; @@ -65,7 +64,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { for (Node node2 : nodes) { NodeKey nodeKey = node2.key(); InstanceIdentifier nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey); - ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction(); + ReadTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction(); Node node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef); if (node != null) { if (node.getNodeConnector() != null) { @@ -107,7 +106,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { NodeKey nodeKey = node2.key(); InstanceIdentifier nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey); - ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction(); + ReadTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction(); Node node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef); if (node != null) { if (node.getNodeConnector() != null) { @@ -152,7 +151,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { InstanceIdentifier nodeRef = InstanceIdentifier.create(Nodes.class) .child(Node.class, nodeKey).augmentation(FlowCapableNode.class); - ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction(); + ReadTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction(); FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef); if (node != null) { @@ -207,7 +206,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { InstanceIdentifier nodeRef = InstanceIdentifier.create(Nodes.class) .child(Node.class, nodeKey).augmentation(FlowCapableNode.class); - ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction(); + ReadTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction(); FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef); if (node != null) { List
tables = node.getTable(); @@ -246,7 +245,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { NodeKey nodeKey = node2.key(); InstanceIdentifier nodeRef = InstanceIdentifier.create(Nodes.class) .child(Node.class, nodeKey).augmentation(FlowCapableNode.class); - ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction(); + ReadTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction(); FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef); if (node != null) { if (node.getGroup() != null) { @@ -287,7 +286,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { NodeKey nodeKey = node2.key(); InstanceIdentifier nodeRef = InstanceIdentifier.create(Nodes.class) .child(Node.class, nodeKey).augmentation(FlowCapableNode.class); - ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction(); + ReadTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction(); FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef); if (node != null) { @@ -329,7 +328,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { NodeKey nodeKey = node2.key(); InstanceIdentifier nodeRef = InstanceIdentifier.create(Nodes.class) .child(Node.class, nodeKey).augmentation(FlowCapableNode.class); - ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction(); + ReadTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction(); FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef); if (node != null) { if (node.getMeter() != null) { @@ -370,7 +369,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { NodeKey nodeKey = node2.key(); InstanceIdentifier nodeRef = InstanceIdentifier.create(Nodes.class) .child(Node.class, nodeKey).augmentation(FlowCapableNode.class); - ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction(); + ReadTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction(); FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef); if (node != null) { if (node.getMeter() != null) { @@ -411,7 +410,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { NodeKey nodeKey = node2.key(); InstanceIdentifier nodeRef = InstanceIdentifier.create(Nodes.class) .child(Node.class, nodeKey).augmentation(FlowCapableNode.class); - ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction(); + ReadTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction(); FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef); if (node != null) { List
tables = node.getTable(); @@ -450,7 +449,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { NodeKey nodeKey = node2.key(); InstanceIdentifier nodeRef = InstanceIdentifier.create(Nodes.class) .child(Node.class, nodeKey).augmentation(FlowCapableNode.class); - ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction(); + ReadTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction(); FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef); if (node != null) { if (null != node.getHardware() && null != node.getManufacturer() && null != node.getSoftware()) { @@ -469,7 +468,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { } private List getNodes() { - ReadOnlyTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction(); + ReadTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction(); InstanceIdentifier nodesID = InstanceIdentifier.create(Nodes.class); Nodes nodes = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodesID); if (nodes == null) { diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTableFeaturesTestCommandProvider.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTableFeaturesTestCommandProvider.java index 33cb8e3b10..686e754016 100644 --- a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTableFeaturesTestCommandProvider.java +++ b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTableFeaturesTestCommandProvider.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014, 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved. * * This program and the accompanying materials are made available under the @@ -8,9 +8,7 @@ package org.opendaylight.openflowplugin.test; import com.google.common.base.Preconditions; -import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.MoreExecutors; import java.math.BigInteger; import java.util.ArrayList; @@ -18,10 +16,9 @@ import java.util.Arrays; import java.util.List; import org.eclipse.osgi.framework.console.CommandInterpreter; import org.eclipse.osgi.framework.console.CommandProvider; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.ReadWriteTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder; @@ -600,10 +597,9 @@ public class OpenflowpluginTableFeaturesTestCommandProvider implements CommandPr modification.merge(LogicalDatastoreType.OPERATIONAL, path1, tableFeatures, true); modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true); modification.merge(LogicalDatastoreType.CONFIGURATION, path1, tableFeatures, true); - CheckedFuture commitFuture = modification.submit(); - Futures.addCallback(commitFuture, new FutureCallback() { + modification.commit().addCallback(new FutureCallback() { @Override - public void onSuccess(Void notUsed) { + public void onSuccess(Object notUsed) { ci.println("Status of Group Data Loaded Transaction: success."); } diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTableFeaturesTestServiceProvider.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTableFeaturesTestServiceProvider.java index c2c14c7a3b..92593bf1be 100644 --- a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTableFeaturesTestServiceProvider.java +++ b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTableFeaturesTestServiceProvider.java @@ -1,18 +1,16 @@ -/** +/* * Copyright (c) 2013 Cisco Systems, Inc. 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.openflowplugin.test; +import com.google.common.collect.ImmutableSet; import com.google.common.util.concurrent.ListenableFuture; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; @@ -23,7 +21,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.Upd import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder; import org.opendaylight.yangtools.yang.common.RpcResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,23 +30,22 @@ public class OpenflowpluginTableFeaturesTestServiceProvider implements private static final Logger LOG = LoggerFactory .getLogger(OpenflowpluginTableFeaturesTestServiceProvider.class); - private RoutedRpcRegistration tableRegistration; - private NotificationProviderService notificationService; + private ObjectRegistration tableRegistration; + private NotificationPublishService notificationService; /** * Get table registration. * * @return {@link #tableRegistration} */ - public RoutedRpcRegistration getTableRegistration() { + public ObjectRegistration getTableRegistration() { return this.tableRegistration; } /** * Set {@link #tableRegistration}. */ - public void setTableRegistration( - final RoutedRpcRegistration tableRegistration) { + public void setTableRegistration(final ObjectRegistration tableRegistration) { this.tableRegistration = tableRegistration; } @@ -58,15 +54,14 @@ public class OpenflowpluginTableFeaturesTestServiceProvider implements * * @return {@link #notificationService} */ - public NotificationProviderService getNotificationService() { + public NotificationPublishService getNotificationService() { return this.notificationService; } /** * Set {@link #notificationService}. */ - public void setNotificationService( - final NotificationProviderService notificationService) { + public void setNotificationService(final NotificationPublishService notificationService) { this.notificationService = notificationService; } @@ -104,32 +99,15 @@ public class OpenflowpluginTableFeaturesTestServiceProvider implements } public ObjectRegistration register( - final RpcProviderRegistry rpcRegistry) { - RoutedRpcRegistration addRoutedRpcImplementation = rpcRegistry.addRoutedRpcImplementation( - SalTableService.class, this); - - setTableRegistration(addRoutedRpcImplementation); - - InstanceIdentifierBuilder builder1 = InstanceIdentifier - .builder(Nodes.class); - - NodeId nodeId = new NodeId(OpenflowpluginTestActivator.NODE_ID); - NodeKey nodeKey = new NodeKey(nodeId); - - InstanceIdentifierBuilder nodeIndentifier = builder1 - .child(Node.class, nodeKey); - - InstanceIdentifier instance = nodeIndentifier.build(); - - tableRegistration.registerPath(NodeContext.class, instance); - - RoutedRpcRegistration tableRegistration1 = this - .getTableRegistration(); + final RpcProviderService rpcRegistry) { + setTableRegistration(rpcRegistry.registerRpcImplementation(SalTableService.class, this, ImmutableSet.of( + InstanceIdentifier.create(Nodes.class) + .child(Node.class, new NodeKey(new NodeId(OpenflowpluginTestActivator.NODE_ID)))))); return new AbstractObjectRegistration(this) { @Override protected void removeRegistration() { - tableRegistration1.close(); + tableRegistration.close(); } }; } diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestActivator.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestActivator.java index a62774cef3..404a1bd21b 100644 --- a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestActivator.java +++ b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestActivator.java @@ -1,20 +1,20 @@ -/** +/* * Copyright (c) 2013 Cisco Systems, Inc. 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.openflowplugin.test; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import javax.inject.Singleton; import org.apache.aries.blueprint.annotation.service.Reference; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.NotificationService; +import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.osgi.framework.BundleContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -24,9 +24,7 @@ public class OpenflowpluginTestActivator implements AutoCloseable { private static final Logger LOG = LoggerFactory .getLogger(OpenflowpluginTestActivator.class); - private DataBroker dataBroker; - private NotificationProviderService notificationService; - private RpcProviderRegistry rpcRegistry; + private RpcProviderService rpcRegistry; private final OpenflowpluginTestServiceProvider provider; private final OpenflowpluginGroupTestServiceProvider groupProvider = new OpenflowpluginGroupTestServiceProvider(); private final OpenflowpluginMeterTestServiceProvider meterProvider = new OpenflowpluginMeterTestServiceProvider(); @@ -54,8 +52,9 @@ public class OpenflowpluginTestActivator implements AutoCloseable { public static final String NODE_ID = "foo:node:1"; public OpenflowpluginTestActivator(@Reference DataBroker dataBroker, - @Reference NotificationProviderService notificationService, BundleContext ctx) { - provider = new OpenflowpluginTestServiceProvider(dataBroker, notificationService); + @Reference NotificationService notificationService, + @Reference NotificationPublishService notificationPublishService, BundleContext ctx) { + provider = new OpenflowpluginTestServiceProvider(dataBroker, notificationPublishService); OpenflowpluginTestCommandProvider openflowpluginTestCommandProvider = new OpenflowpluginTestCommandProvider( dataBroker, notificationService, ctx); this.cmdProvider = openflowpluginTestCommandProvider; diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestCommandProvider.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestCommandProvider.java index f8a7081648..838e1e999b 100644 --- a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestCommandProvider.java +++ b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestCommandProvider.java @@ -5,12 +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.openflowplugin.test; import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import java.math.BigInteger; import java.util.ArrayList; @@ -20,10 +17,10 @@ import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import org.eclipse.osgi.framework.console.CommandInterpreter; import org.eclipse.osgi.framework.console.CommandProvider; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.sal.binding.api.NotificationService; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationService; +import org.opendaylight.mdsal.binding.api.ReadWriteTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Dscp; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6FlowLabel; @@ -3151,10 +3148,9 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider { .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf.getTableId())) .child(Flow.class, tf.key()); modification.delete(LogicalDatastoreType.CONFIGURATION, path1); - final ListenableFuture commitFuture = modification.submit(); - Futures.addCallback(commitFuture, new FutureCallback() { + modification.commit().addCallback(new FutureCallback() { @Override - public void onSuccess(final Void notUsed) { + public void onSuccess(final Object notUsed) { ci.println("Status of Group Data Loaded Transaction: success."); } @@ -3191,10 +3187,9 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider { modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true); modification.merge(LogicalDatastoreType.CONFIGURATION, path1, flow.build(), true); - final ListenableFuture commitFuture = modification.submit(); - Futures.addCallback(commitFuture, new FutureCallback() { + modification.commit().addCallback(new FutureCallback() { @Override - public void onSuccess(final Void notUsed) { + public void onSuccess(final Object notUsed) { ci.println("Status of Group Data Loaded Transaction: success."); } diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestNodeConnectorNotification.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestNodeConnectorNotification.java index d40e741593..75f775a858 100644 --- a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestNodeConnectorNotification.java +++ b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestNodeConnectorNotification.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014, 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved. * * This program and the accompanying materials are made available under the @@ -9,7 +9,7 @@ package org.opendaylight.openflowplugin.test; import java.util.ArrayList; import java.util.List; -import org.opendaylight.controller.sal.binding.api.NotificationService; +import org.opendaylight.mdsal.binding.api.NotificationService; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemoved; diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestServiceProvider.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestServiceProvider.java index 3aa5ecf58f..41855a95ce 100644 --- a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestServiceProvider.java +++ b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestServiceProvider.java @@ -1,18 +1,17 @@ -/** +/* * Copyright (c) 2013 Cisco Systems, Inc. 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.openflowplugin.test; +import com.google.common.collect.ImmutableSet; import com.google.common.util.concurrent.ListenableFuture; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput; @@ -20,7 +19,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.Remo import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; @@ -28,7 +26,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder; import org.opendaylight.yangtools.yang.common.RpcResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,11 +37,11 @@ public class OpenflowpluginTestServiceProvider implements AutoCloseable, .getLogger(OpenflowpluginTestServiceProvider.class); private final DataBroker dataService; - private RoutedRpcRegistration flowRegistration; - private final NotificationProviderService notificationProviderService; + private ObjectRegistration flowRegistration; + private final NotificationPublishService notificationProviderService; public OpenflowpluginTestServiceProvider(DataBroker dataService, - NotificationProviderService notificationProviderService) { + NotificationPublishService notificationProviderService) { this.dataService = dataService; this.notificationProviderService = notificationProviderService; } @@ -63,15 +60,14 @@ public class OpenflowpluginTestServiceProvider implements AutoCloseable, * * @return {@link #flowRegistration} */ - public RoutedRpcRegistration getFlowRegistration() { + public ObjectRegistration getFlowRegistration() { return flowRegistration; } /** * Set {@link #flowRegistration}. */ - public void setFlowRegistration( - final RoutedRpcRegistration flowRegistration) { + public void setFlowRegistration(final ObjectRegistration flowRegistration) { this.flowRegistration = flowRegistration; } @@ -80,7 +76,7 @@ public class OpenflowpluginTestServiceProvider implements AutoCloseable, * * @return {@link #notificationProviderService} */ - public NotificationProviderService getNotificationService() { + public NotificationPublishService getNotificationService() { return notificationProviderService; } @@ -141,31 +137,15 @@ public class OpenflowpluginTestServiceProvider implements AutoCloseable, return null; } - public ObjectRegistration register(RpcProviderRegistry rpcRegistry) { - RoutedRpcRegistration addRoutedRpcImplementation = - rpcRegistry.addRoutedRpcImplementation(SalFlowService.class, this); - - setFlowRegistration(addRoutedRpcImplementation); - - InstanceIdentifierBuilder builderII = InstanceIdentifier - .builder(Nodes.class); - - NodeId nodeId = new NodeId(OpenflowpluginTestActivator.NODE_ID); - NodeKey nodeKey = new NodeKey(nodeId); - - InstanceIdentifierBuilder nodeIdentifier = builderII - .child(Node.class, nodeKey); - - InstanceIdentifier instance = nodeIdentifier.build(); - - flowRegistration.registerPath(NodeContext.class, instance); - - RoutedRpcRegistration flowRegistration2 = getFlowRegistration(); + public ObjectRegistration register(RpcProviderService rpcRegistry) { + setFlowRegistration(rpcRegistry.registerRpcImplementation(SalFlowService.class, this, ImmutableSet.of( + InstanceIdentifier.create(Nodes.class) + .child(Node.class, new NodeKey(new NodeId(OpenflowpluginTestActivator.NODE_ID)))))); return new AbstractObjectRegistration(this) { @Override protected void removeRegistration() { - flowRegistration2.close(); + flowRegistration.close(); } }; } diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestTopologyNotification.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestTopologyNotification.java index 45f80b4853..8760cb05a6 100644 --- a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestTopologyNotification.java +++ b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestTopologyNotification.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014, 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved. * * This program and the accompanying materials are made available under the @@ -7,7 +7,7 @@ */ package org.opendaylight.openflowplugin.test; -import org.opendaylight.controller.sal.binding.api.NotificationService; +import org.opendaylight.mdsal.binding.api.NotificationService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.FlowTopologyDiscoveryListener; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkDiscovered; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkOverutilized; diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/TestProviderTransactionUtil.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/TestProviderTransactionUtil.java index faa82b6b1c..be5ea6b7de 100644 --- a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/TestProviderTransactionUtil.java +++ b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/TestProviderTransactionUtil.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.openflowplugin.test; -import com.google.common.base.Optional; +import java.util.Optional; import java.util.concurrent.ExecutionException; -import org.opendaylight.controller.md.sal.binding.api.ReadTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.ReadTransaction; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger;