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