Bump odlparent to 5.0.0
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / statistics / services / compatibility / AbstractCompatibleStatService.java
index e0340bac59a7275218eda8f7f568aa3a5e68af04..fd7fd93e3f90487db374434d1478e0f9054a6bf9 100644 (file)
@@ -5,17 +5,16 @@
  * 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;
 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.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;
@@ -31,16 +30,19 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * pulled up common functionality of notification emitting stats services (backward compatibility relic)
+ * Pulled up common functionality of notification emitting stats services (backward compatibility relic).
  */
-public abstract class AbstractCompatibleStatService<I extends DataContainer, O, N extends Notification> extends AbstractMultipartService<I, MultipartReply> implements BackwardCompatibleAtomicService<I, O> {
+public abstract class AbstractCompatibleStatService<I extends DataContainer, O, N extends Notification> extends
+        AbstractMultipartService<I, MultipartReply> implements BackwardCompatibleAtomicService<I, O> {
 
     private static final Logger LOG = LoggerFactory.getLogger(AbstractCompatibleStatService.class);
 
     private final AtomicLong compatibilityXidSeed;
     private final OpenflowVersion ofVersion;
 
-    public AbstractCompatibleStatService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+    public AbstractCompatibleStatService(RequestContextStack requestContextStack,
+                                         DeviceContext deviceContext,
+                                         AtomicLong compatibilityXidSeed) {
         super(requestContextStack, deviceContext);
         this.compatibilityXidSeed = compatibilityXidSeed;
         ofVersion = OpenflowVersion.get(getVersion());
@@ -51,7 +53,8 @@ public abstract class AbstractCompatibleStatService<I extends DataContainer, O,
     }
 
     @Override
-    public ListenableFuture<RpcResult<O>> handleAndNotify(final I input, final NotificationPublishService notificationPublishService) {
+    public ListenableFuture<RpcResult<O>> handleAndNotify(final I input,
+                                                          final NotificationPublishService notificationPublishService) {
         // prepare emulated xid
         final long emulatedXid = compatibilityXidSeed.incrementAndGet();
         final TransactionId emulatedTxId = new TransactionId(BigInteger.valueOf(emulatedXid));
@@ -62,23 +65,25 @@ public abstract class AbstractCompatibleStatService<I extends DataContainer, O,
         // hook notification publishing
         Futures.addCallback(rpcResultListenableFuture, new FutureCallback<RpcResult<List<MultipartReply>>>() {
             @Override
-            public void onSuccess(@Nullable RpcResult<List<MultipartReply>> result) {
+            public void onSuccess(RpcResult<List<MultipartReply>> result) {
                 if (result != null && result.isSuccessful()) {
                     // transform rpc result (raw multipart) to notification
                     final N flowNotification = transformToNotification(result.getResult(), emulatedTxId);
                     notificationPublishService.offerNotification(flowNotification);
                 } else {
-                    LOG.debug("compatibility callback failed - NOT emitting notification: {}", input.getClass().getSimpleName());
+                    LOG.debug("compatibility callback failed - NOT emitting notification: {}",
+                            input.getClass().getSimpleName());
                 }
             }
 
             @Override
-            public void onFailure(Throwable t) {
-                LOG.debug("compatibility callback crashed - NOT emitting notification: {}", input.getClass().getSimpleName(), t);
+            public void onFailure(Throwable throwable) {
+                LOG.debug("compatibility callback crashed - NOT emitting notification: {}",
+                        input.getClass().getSimpleName(), throwable);
             }
-        });
+        }, MoreExecutors.directExecutor());
 
-        return RpcResultBuilder.<O>success(buildTxCapableResult(emulatedTxId)).buildFuture();
+        return RpcResultBuilder.success(buildTxCapableResult(emulatedTxId)).buildFuture();
     }
 
     public abstract O buildTxCapableResult(TransactionId emulatedTxId);