2 * Copyright (c) 2015 Cisco Systems and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package ntfbenchmark.impl;
11 import com.google.common.util.concurrent.ListenableFuture;
12 import com.google.common.util.concurrent.SettableFuture;
13 import java.util.concurrent.ExecutionException;
14 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
16 public class NtfbenchNonblockingProducer extends AbstractNtfbenchProducer {
18 private final SettableFuture<?> lastDeliveryFuture = SettableFuture.create();
21 public NtfbenchNonblockingProducer(final NotificationPublishService publishService, final int iterations,
22 final int payloadSize) {
23 super(publishService, iterations, payloadSize);
28 @SuppressWarnings("checkstyle:illegalCatch")
32 ListenableFuture<?> lastOkFuture = null;
33 for (int i = 0; i < this.iterations; i++) {
35 final ListenableFuture<?> result = this.publishService.offerNotification(this.ntf);
36 if (NotificationPublishService.REJECTED == result) {
40 lastOkFuture = result;
42 } catch (final Exception e) {
48 this.ntfError = ntfError;
49 // We wait for last notification to be delivered to listeners.
50 if (lastOkFuture != null) {
53 } catch (InterruptedException | ExecutionException e) {
54 throw new RuntimeException(e);