Migrate ntfbenchmark to MDSAL APIs
[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
12 public class NtfbenchBlockingProducer extends AbstractNtfbenchProducer {
13
14     public NtfbenchBlockingProducer(final NotificationPublishService publishService, final int iterations,
15             final int payloadSize) {
16         super(publishService, iterations, payloadSize);
17     }
18
19     @Override
20     @SuppressWarnings("checkstyle:illegalCatch")
21     public void run() {
22         int ntfOk = 0;
23         int ntfError = 0;
24
25         for (int i = 0; i < this.iterations; i++) {
26             try {
27                 this.publishService.putNotification(this.ntf);
28                 ntfOk++;
29             } catch (final Exception e) {
30                 ntfError++;
31             }
32         }
33
34         this.ntfOk = ntfOk;
35         this.ntfError = ntfError;
36     }
37 }