* 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;
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());
}
@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));
// 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);