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
8 package ntfbenchmark.impl;
10 import com.google.common.util.concurrent.ListenableFuture;
11 import com.google.common.util.concurrent.SettableFuture;
12 import java.util.concurrent.ExecutionException;
13 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
15 public class NtfbenchNonblockingProducer extends AbstractNtfbenchProducer {
17 private final SettableFuture<?> lastDeliveryFuture = SettableFuture.create();
20 public NtfbenchNonblockingProducer(final NotificationPublishService publishService, final int iterations,
21 final int payloadSize) {
22 super(publishService, iterations, payloadSize);
27 @SuppressWarnings("checkstyle:illegalCatch")
31 ListenableFuture<?> lastOkFuture = null;
32 for (int i = 0; i < this.iterations; i++) {
34 final ListenableFuture<?> result = this.publishService.offerNotification(this.ntf);
35 if (NotificationPublishService.REJECTED == result) {
39 lastOkFuture = result;
41 } catch (final Exception e) {
47 this.ntfError = ntfError;
48 // We wait for last notification to be delivered to listeners.
49 if (lastOkFuture != null) {
52 } catch (InterruptedException | ExecutionException e) {
53 throw new RuntimeException(e);