Bump MRI upstreams
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / services / multilayer / MultiLayerTableMultipartService.java
index 2d0cd7a5b6ff350f09976a732346b0b8d30edc31..d39de7398c55e9ae9b5f0763e0efd0f81954d32a 100644 (file)
@@ -13,12 +13,10 @@ 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.math.BigInteger;
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.Map;
 import java.util.Optional;
-import javax.annotation.Nonnull;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
@@ -40,9 +38,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.Upd
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
-import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
+import org.opendaylight.yangtools.yang.binding.util.BindingMap;
+import org.opendaylight.yangtools.yang.common.ErrorType;
 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.Uint64;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -52,10 +53,10 @@ public class MultiLayerTableMultipartService extends AbstractTableMultipartServi
     private final VersionConvertorData data;
     private final ConvertorExecutor convertorExecutor;
 
-    public MultiLayerTableMultipartService(RequestContextStack requestContextStack,
-                                           DeviceContext deviceContext,
-                                           ConvertorExecutor convertorExecutor,
-                                           MultipartWriterProvider multipartWriterProvider) {
+    public MultiLayerTableMultipartService(final RequestContextStack requestContextStack,
+                                           final DeviceContext deviceContext,
+                                           final ConvertorExecutor convertorExecutor,
+                                           final MultipartWriterProvider multipartWriterProvider) {
         super(requestContextStack, deviceContext, multipartWriterProvider);
         this.convertorExecutor = convertorExecutor;
         data = new VersionConvertorData(getVersion());
@@ -79,14 +80,14 @@ public class MultiLayerTableMultipartService extends AbstractTableMultipartServi
     }
 
     @Override
-    public ListenableFuture<RpcResult<UpdateTableOutput>> handleAndReply(UpdateTableInput input) {
+    public ListenableFuture<RpcResult<UpdateTableOutput>> handleAndReply(final UpdateTableInput input) {
         final ListenableFuture<RpcResult<List<MultipartReply>>> multipartFuture = handleServiceCall(input);
         final SettableFuture<RpcResult<UpdateTableOutput>> finalFuture = SettableFuture.create();
 
         class CallBackImpl implements FutureCallback<RpcResult<List<MultipartReply>>> {
             @Override
             @SuppressWarnings("checkstyle:IllegalCatch")
-            public void onSuccess(@Nonnull final RpcResult<List<MultipartReply>> result) {
+            public void onSuccess(final RpcResult<List<MultipartReply>> result) {
 
                 if (result.isSuccessful()) {
                     final List<MultipartReply> multipartReplies = result.getResult();
@@ -95,13 +96,13 @@ public class MultiLayerTableMultipartService extends AbstractTableMultipartServi
                         finalFuture.set(RpcResultBuilder.<UpdateTableOutput>failed()
                             .withError(ErrorType.RPC, "Multipart reply list is empty.").build());
                     } else {
-                        final Long xid = multipartReplies.get(0).getXid();
+                        final Uint32 xid = multipartReplies.get(0).getXid();
                         LOG.debug(
                             "OnSuccess, rpc result successful,"
                                     + " multipart response for rpc update-table with xid {} obtained.",
                             xid);
                         final UpdateTableOutputBuilder updateTableOutputBuilder = new UpdateTableOutputBuilder();
-                        updateTableOutputBuilder.setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
+                        updateTableOutputBuilder.setTransactionId(new TransactionId(Uint64.valueOf(xid)));
                         finalFuture.set(RpcResultBuilder.success(updateTableOutputBuilder.build()).build());
                         try {
                             storeStatistics(convertToSalTableFeatures(multipartReplies));
@@ -119,7 +120,7 @@ public class MultiLayerTableMultipartService extends AbstractTableMultipartServi
 
             @Override
             public void onFailure(final Throwable throwable) {
-                LOG.error("Failure multipart response for table features request. Exception: {}", throwable);
+                LOG.error("Failure multipart response for table features request", throwable);
                 finalFuture.set(RpcResultBuilder.<UpdateTableOutput>failed()
                     .withError(ErrorType.RPC, "Future error", throwable).build());
             }
@@ -130,12 +131,13 @@ public class MultiLayerTableMultipartService extends AbstractTableMultipartServi
         return finalFuture;
     }
 
-    protected List<org.opendaylight.yang.gen.v1.urn
-            .opendaylight.table.types.rev131026.table.features.TableFeatures> convertToSalTableFeatures(
-            final List<MultipartReply> multipartReplies) {
-        final List<org.opendaylight.yang.gen.v1.urn
-                .opendaylight.table.types.rev131026.table.features.TableFeatures> salTableFeaturesAll =
-                new ArrayList<>();
+    protected Map<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey,
+                  org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures>
+                        convertToSalTableFeatures(final List<MultipartReply> multipartReplies) {
+        final var salTableFeaturesAll = BindingMap.<
+            org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey,
+            org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures>
+                orderedBuilder();
         for (final MultipartReply multipartReply : multipartReplies) {
             if (multipartReply.getType().equals(MultipartType.OFPMPTABLEFEATURES)) {
                 final MultipartReplyBody multipartReplyBody = multipartReply.getMultipartReplyBody();
@@ -155,6 +157,6 @@ public class MultiLayerTableMultipartService extends AbstractTableMultipartServi
             }
         }
 
-        return salTableFeaturesAll;
+        return salTableFeaturesAll.build();
     }
 }