b086910f1ccc84764dc4c5c9387fd009b4317d88
[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     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 }