Migrate bulk-o-matic to use Uint types 28/92328/1
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 30 Aug 2020 20:38:09 +0000 (22:38 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Sun, 30 Aug 2020 20:59:39 +0000 (22:59 +0200)
All callers of these method are using a primitive short, hence
change the method signature to take that and explicitly convert
it to Uint8. This fixes one deprecation warning and further eclipse
notices around boxing.

JIRA: OPNFLWPLUG-1099
Change-Id: Iaffc9984322f460129975436d88e8c048ca63fa2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/BulkOMaticUtils.java
applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowReader.java
applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterConcurrent.java
applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterTxChain.java
applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/SalBulkFlowServiceImpl.java
applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/TableWriter.java
applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/SalBulkFlowServiceImplTest.java

index 60114cf99e6a74fd068a69d12dd9690f192cf6bd..19de65f99c4bd5abe80deb1343506e68acf74336 100644 (file)
@@ -24,9 +24,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint8;
 
 public final class BulkOMaticUtils {
 
@@ -48,28 +49,27 @@ public final class BulkOMaticUtils {
     }
 
     public static Match getMatch(final int sourceIp) {
-        Ipv4Match ipv4Match = new Ipv4MatchBuilder().setIpv4Source(new Ipv4Prefix(ipIntToStr(sourceIp))).build();
-        MatchBuilder matchBuilder = new MatchBuilder();
-        matchBuilder.setLayer3Match(ipv4Match);
-        EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
-        EthernetMatchBuilder ethMatchBuilder = new EthernetMatchBuilder();
-        ethTypeBuilder.setType(new EtherType(2048L));
-        ethMatchBuilder.setEthernetType(ethTypeBuilder.build());
-        matchBuilder.setEthernetMatch(ethMatchBuilder.build());
-        return matchBuilder.build();
+        return new MatchBuilder()
+                .setLayer3Match(new Ipv4MatchBuilder().setIpv4Source(new Ipv4Prefix(ipIntToStr(sourceIp))).build())
+                .setEthernetMatch(new EthernetMatchBuilder()
+                    .setEthernetType(new EthernetTypeBuilder().setType(new EtherType(Uint32.valueOf(2048))).build())
+                    .build())
+                .build();
     }
 
-    public static Flow buildFlow(Short tableId, String flowId, Match match) {
-        FlowBuilder flowBuilder = new FlowBuilder();
-        flowBuilder.withKey(new FlowKey(new FlowId(flowId)));
-        flowBuilder.setTableId(tableId);
-        flowBuilder.setMatch(match);
-        return flowBuilder.build();
+    public static Flow buildFlow(short tableId, String flowId, Match match) {
+        return new FlowBuilder()
+                .withKey(new FlowKey(new FlowId(flowId)))
+                .setTableId(Uint8.valueOf(tableId))
+                .setMatch(match)
+                .build();
     }
 
-    public static InstanceIdentifier<Flow> getFlowInstanceIdentifier(Short tableId, String flowId, String dpId) {
-        return InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(new NodeId(dpId)))
-                .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tableId))
+    public static InstanceIdentifier<Flow> getFlowInstanceIdentifier(short tableId, String flowId, String dpId) {
+        return InstanceIdentifier.create(Nodes.class)
+                .child(Node.class, new NodeKey(new NodeId(dpId)))
+                .augmentation(FlowCapableNode.class)
+                .child(Table.class, new TableKey(Uint8.valueOf(tableId)))
                 .child(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow.class,
                         new FlowKey(new FlowId(flowId)));
     }
@@ -78,9 +78,9 @@ public final class BulkOMaticUtils {
         return InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId(dpId))).build();
     }
 
-    public static InstanceIdentifier<Table> getTableId(Short tableId, String dpId) {
+    public static InstanceIdentifier<Table> getTableId(short tableId, String dpId) {
         return InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId(dpId)))
-                .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tableId)).build();
+                .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(Uint8.valueOf(tableId))).build();
     }
 
     public static InstanceIdentifier<Flow> getFlowId(final InstanceIdentifier<Table> tablePath, final String flowId) {
index 77d7816413a3c6b97faf7383dd3d391e0d139ae5..06b9a1ac69645caaf2b8ab18c9787068a0e1b5b5 100644 (file)
@@ -25,6 +25,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.NodeKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Uint8;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -109,9 +110,9 @@ public final class FlowReader implements Runnable, FlowCounterMBean {
         LOG.info("Total Flows read: {}", flowCount);
     }
 
-    private InstanceIdentifier<Flow> getFlowInstanceIdentifier(String dpId, Short tableId, String flowId) {
+    private static InstanceIdentifier<Flow> getFlowInstanceIdentifier(String dpId, short tableId, String flowId) {
         return InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(new NodeId(dpId)))
-                .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tableId))
+                .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(Uint8.valueOf(tableId)))
                 .child(Flow.class, new FlowKey(new FlowId(flowId)));
     }
 
index 1cca45eaf2120d6bac17ad398b8301a32cff6c3e..e8e2c79a44d019b26d7323d789beb522ec7402fa 100644 (file)
@@ -167,7 +167,7 @@ public class FlowWriterConcurrent implements FlowCounterMBean {
             private final short endTableId;
             private final short beginTableId;
 
-            DsCallBack(String dpId, Short beginTableId, Short endTableId, Integer sourceIp) {
+            DsCallBack(String dpId, short beginTableId, short endTableId, int sourceIp) {
                 this.dpId = dpId;
                 this.sourceIp = sourceIp;
                 this.endTableId = endTableId;
index 9f7a7024ab8cfe4b3f303c51b07719c1a6cee64d..91dbcaa471313190fef9e905a68602750579ce6e 100644 (file)
@@ -194,7 +194,7 @@ public class FlowWriterTxChain implements FlowCounterMBean {
             private final short beginTableId;
             private final TransactionChain txChain;
 
-            DsCallBack(String dpId, Short beginTableId, Short endTableId, Integer sourceIp,
+            DsCallBack(String dpId, short beginTableId, short endTableId, int sourceIp,
                     TransactionChain txChain) {
                 this.dpId = dpId;
                 this.sourceIp = sourceIp;
index 48356e0891e11d44b2088ee5f7a22836212143b5..a140f51ab0593ee071741765ced73642f356a81d 100644 (file)
@@ -125,7 +125,7 @@ public class SalBulkFlowServiceImpl implements SalBulkFlowService {
         },MoreExecutors.directExecutor());
     }
 
-    private InstanceIdentifier<Flow> getFlowInstanceIdentifier(BulkFlowDsItem bulkFlow) {
+    private static InstanceIdentifier<Flow> getFlowInstanceIdentifier(BulkFlowDsItem bulkFlow) {
         final NodeRef nodeRef = bulkFlow.getNode();
         return ((InstanceIdentifier<Node>) nodeRef.getValue()).augmentation(FlowCapableNode.class)
                 .child(Table.class, new TableKey(bulkFlow.getTableId()))
@@ -147,7 +147,7 @@ public class SalBulkFlowServiceImpl implements SalBulkFlowService {
         }, MoreExecutors.directExecutor());
     }
 
-    private <T> ListenableFuture<RpcResult<Void>> handleResultFuture(ListenableFuture<List<T>> submitFuture) {
+    private static <T> ListenableFuture<RpcResult<Void>> handleResultFuture(ListenableFuture<List<T>> submitFuture) {
         final SettableFuture<RpcResult<Void>> rpcResult = SettableFuture.create();
         Futures.addCallback(submitFuture, new FutureCallback<List<T>>() {
             @Override
index 1e2bc3a5a0ab864d670c7c38af4ed1dd63becd3b..628a1761d71de06d9286be4c56fc3272522615fe 100644 (file)
@@ -19,6 +19,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.ta
 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;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Uint8;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -87,7 +88,7 @@ public class TableWriter implements FlowCounterMBean {
                 String dpId = BulkOMaticUtils.DEVICE_TYPE_PREFIX + String.valueOf(dpn);
                 for (short tableId = startTableId; tableId <= endTableId; tableId++) {
                     WriteTransaction wtx = dataBroker.newWriteOnlyTransaction();
-                    Table table = new TableBuilder().withKey(new TableKey(tableId)).setId(tableId).build();
+                    Table table = new TableBuilder().withKey(new TableKey(Uint8.valueOf(tableId))).build();
                     InstanceIdentifier<Table> tableIId = BulkOMaticUtils.getTableId(tableId, dpId);
 
                     if (isAdd) {
index f2935470757f32bc2caf4b550ee2052085d3bab3..c7a7173790cea0dfa35306b685010cad850c74c7 100644 (file)
@@ -70,6 +70,8 @@ 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.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint8;
 
 /**
  * Test for {@link SalBulkFlowServiceImpl}.
@@ -109,7 +111,7 @@ public class SalBulkFlowServiceImplTest {
         doReturn(CommitInfo.emptyFluentFuture()).when(writeTransaction).commit();
 
         final BulkFlowDsItemBuilder bulkFlowDsItemBuilder = new BulkFlowDsItemBuilder().setFlowId(new FlowId("1"))
-                .setTableId((short) 2);
+                .setTableId(Uint8.TWO);
 
         final InstanceIdentifier<Node> nodeId = BulkOMaticUtils.getFlowCapableNodeId("1");
         bulkFlowDsItemBuilder.setNode(new NodeRef(nodeId));
@@ -178,8 +180,9 @@ public class SalBulkFlowServiceImplTest {
 
     @Test
     public void testReadFlowTest() throws Exception {
-        final ReadFlowTestInputBuilder readFlowTestInputBuilder = new ReadFlowTestInputBuilder().setDpnCount(1L)
-                .setStartTableId(1L).setEndTableId(2L).setIsConfigDs(false).setFlowsPerDpn(1L).setVerbose(true);
+        final ReadFlowTestInputBuilder readFlowTestInputBuilder = new ReadFlowTestInputBuilder().setDpnCount(Uint32.ONE)
+                .setStartTableId(Uint32.ONE).setEndTableId(Uint32.TWO).setIsConfigDs(false).setFlowsPerDpn(Uint32.ONE)
+                .setVerbose(true);
 
         final ReadFlowTestInput readFlowTestInput = readFlowTestInputBuilder.build();
         final ListenableFuture<RpcResult<ReadFlowTestOutput>> resultFuture
@@ -193,8 +196,8 @@ public class SalBulkFlowServiceImplTest {
         doReturn(FluentFutures.immediateFluentFuture(Optional.of(mockNodes))).when(readOnlyTransaction)
             .read(any(LogicalDatastoreType.class), any());
 
-        final FlowRpcAddTestInputBuilder flowRpcAddTestInputBuilder = new FlowRpcAddTestInputBuilder().setFlowCount(1L)
-                .setDpnId("1").setRpcBatchSize(1L);
+        final FlowRpcAddTestInputBuilder flowRpcAddTestInputBuilder = new FlowRpcAddTestInputBuilder()
+                .setFlowCount(Uint32.ONE).setDpnId("1").setRpcBatchSize(Uint32.ONE);
 
         final FlowRpcAddTestInput flowRpcAddTestInput = flowRpcAddTestInputBuilder.build();
         final ListenableFuture<RpcResult<FlowRpcAddTestOutput>> resultFuture
@@ -205,9 +208,10 @@ public class SalBulkFlowServiceImplTest {
 
     @Test
     public void testFlowTest() throws Exception {
-        final FlowTestInputBuilder flowTestInputBuilder = new FlowTestInputBuilder().setBatchSize(1L).setDpnCount(1L)
-                .setEndTableId(2L).setFlowsPerDpn(1L).setIsAdd(true).setSeq(true).setSleepAfter(20L).setSleepFor(1L)
-                .setStartTableId(1L).setTxChain(true).setCreateParents(true);
+        final FlowTestInputBuilder flowTestInputBuilder = new FlowTestInputBuilder()
+                .setBatchSize(Uint32.ONE).setDpnCount(Uint32.ONE).setEndTableId(Uint32.TWO).setFlowsPerDpn(Uint32.ONE)
+                .setIsAdd(true).setSeq(true).setSleepAfter(Uint32.valueOf(20)).setSleepFor(Uint32.ONE)
+                .setStartTableId(Uint32.ONE).setTxChain(true).setCreateParents(true);
 
         FlowTestInput flowTestInput = flowTestInputBuilder.build();
 
@@ -245,7 +249,7 @@ public class SalBulkFlowServiceImplTest {
             .read(any(LogicalDatastoreType.class), any());
 
         final FlowRpcAddMultipleInputBuilder flowRpcAddMultipleInputBuilder = new FlowRpcAddMultipleInputBuilder()
-                .setFlowCount(1L).setRpcBatchSize(1L);
+                .setFlowCount(Uint32.ONE).setRpcBatchSize(Uint32.ONE);
 
         final FlowRpcAddMultipleInput flowRpcAddMultipleInput = flowRpcAddMultipleInputBuilder.build();
 
@@ -254,8 +258,8 @@ public class SalBulkFlowServiceImplTest {
 
     @Test
     public void testTableTest() throws Exception {
-        final TableTestInputBuilder tableTestInputBuilder = new TableTestInputBuilder().setStartTableId(0L)
-                .setEndTableId(99L).setDpnCount(1L).setOperation(Operation.Add);
+        final TableTestInputBuilder tableTestInputBuilder = new TableTestInputBuilder().setStartTableId(Uint32.ZERO)
+                .setEndTableId(Uint32.valueOf(99)).setDpnCount(Uint32.ONE).setOperation(Operation.Add);
 
         TableTestInput tableTestInput = tableTestInputBuilder.build();