Fix sal-remoterpc-connector dependencies
[controller.git] / benchmark / ntfbenchmark / src / main / java / ntfbenchmark / impl / NtfbenchBlockingProducer.java
1 /*
2  * Copyright (c) 2015 Cisco Systems and others.  All rights reserved.
3  *
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
7  */
8 package ntfbenchmark.impl;
9
10 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
11 import org.slf4j.Logger;
12 import org.slf4j.LoggerFactory;
13
14 public class NtfbenchBlockingProducer extends AbstractNtfbenchProducer {
15     private static final Logger LOG = LoggerFactory.getLogger(NtfbenchBlockingProducer.class);
16
17     public NtfbenchBlockingProducer(final NotificationPublishService publishService, final int iterations,
18             final int payloadSize) {
19         super(publishService, iterations, payloadSize);
20     }
21
22     @Override
23     @SuppressWarnings("checkstyle:illegalCatch")
24     public void run() {
25         int ntfOk = 0;
26         int ntfError = 0;
27
28         for (int i = 0; i < iterations; i++) {
29             try {
30                 publishService.putNotification(ntf);
31                 ntfOk++;
32             } catch (final Exception e) {
33                 ntfError++;
34                 LOG.debug("Failed to push notification", e);
35             }
36         }
37
38         this.ntfOk = ntfOk;
39         this.ntfError = ntfError;
40     }
41 }