Bump MRI upstreams
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / services / singlelayer / SingleLayerTableMultipartService.java
index 3d08bfd541365ae66f79aec949649bf266aeb80c..66825f9bb24153eb53f61de4c458cf1915700ade 100644 (file)
@@ -10,17 +10,15 @@ package org.opendaylight.openflowplugin.impl.services.singlelayer;
 
 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.math.BigInteger;
 import java.util.List;
-import java.util.concurrent.Future;
-import java.util.stream.Collectors;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProvider;
 import org.opendaylight.openflowplugin.impl.services.AbstractTableMultipartService;
-import org.opendaylight.openflowplugin.impl.services.util.ServiceException;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartRequestBuilder;
@@ -30,9 +28,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.Upd
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeatures;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.request.multipart.request.body.MultipartRequestTableFeaturesBuilder;
-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.Uint64;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -40,15 +40,15 @@ public class SingleLayerTableMultipartService extends AbstractTableMultipartServ
 
     private static final Logger LOG = LoggerFactory.getLogger(SingleLayerTableMultipartService.class);
 
-    public SingleLayerTableMultipartService(RequestContextStack requestContextStack,
-                                            DeviceContext deviceContext,
-                                            MultipartWriterProvider multipartWriterProvider) {
+    public SingleLayerTableMultipartService(final RequestContextStack requestContextStack,
+                                            final DeviceContext deviceContext,
+                                            final MultipartWriterProvider multipartWriterProvider) {
         super(requestContextStack, deviceContext, multipartWriterProvider);
     }
 
 
     @Override
-    protected OfHeader buildRequest(final Xid xid, final UpdateTableInput input) throws ServiceException {
+    protected OfHeader buildRequest(final Xid xid, final UpdateTableInput input) {
         return new MultipartRequestBuilder()
                 .setXid(xid.getValue())
                 .setVersion(getVersion())
@@ -59,7 +59,7 @@ public class SingleLayerTableMultipartService extends AbstractTableMultipartServ
     }
 
     @Override
-    public Future<RpcResult<UpdateTableOutput>> handleAndReply(UpdateTableInput input) {
+    public ListenableFuture<RpcResult<UpdateTableOutput>> handleAndReply(final UpdateTableInput input) {
         final SettableFuture<RpcResult<UpdateTableOutput>> finalFuture = SettableFuture.create();
 
         Futures.addCallback(handleServiceCall(input), new FutureCallback<RpcResult<List<MultipartReply>>>() {
@@ -76,7 +76,7 @@ public class SingleLayerTableMultipartService extends AbstractTableMultipartServ
                         finalFuture.set(RpcResultBuilder
                             .success(new UpdateTableOutputBuilder()
                                 .setTransactionId(
-                                        new TransactionId(BigInteger.valueOf(multipartReplies.get(0).getXid())))
+                                        new TransactionId(Uint64.valueOf(multipartReplies.get(0).getXid())))
                                 .build())
                             .build());
 
@@ -85,11 +85,10 @@ public class SingleLayerTableMultipartService extends AbstractTableMultipartServ
                                 .stream()
                                 .map(MultipartReply::getMultipartReplyBody)
                                 .filter(MultipartReplyTableFeatures.class::isInstance)
-                                .flatMap(multipartReplyBody -> MultipartReplyTableFeatures.class
-                                    .cast(multipartReplyBody)
-                                    .getTableFeatures()
+                                .flatMap(multipartReplyBody -> ((MultipartReplyTableFeatures) multipartReplyBody)
+                                    .nonnullTableFeatures().values()
                                     .stream())
-                                .collect(Collectors.toList()));
+                                .collect(BindingMap.toOrderedMap()));
                         } catch (Exception e) {
                             LOG.warn("Not able to write to operational datastore: {}", e.getMessage());
                         }
@@ -103,13 +102,13 @@ public class SingleLayerTableMultipartService extends AbstractTableMultipartServ
             }
 
             @Override
-            public void onFailure(Throwable throwable) {
-                LOG.error("Failure multipart response for table features request. Exception: {}", throwable);
+            public void onFailure(final Throwable throwable) {
+                LOG.error("Failure multipart response for table features request", throwable);
                 finalFuture.set(RpcResultBuilder.<UpdateTableOutput>failed()
                     .withError(ErrorType.RPC, "Future error", throwable).build());
             }
-        });
+        }, MoreExecutors.directExecutor());
 
         return finalFuture;
     }
-}
\ No newline at end of file
+}