Fix deprecation warnings and checkstyle in benchmarks
[controller.git] / benchmark / ntfbenchmark / src / main / java / ntfbenchmark / impl / AbstractNtfbenchProducer.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 java.util.ArrayList;
12 import java.util.List;
13 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbench.payload.rev150709.Ntfbench;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbench.payload.rev150709.NtfbenchBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbench.payload.rev150709.payload.Payload;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbench.payload.rev150709.payload.PayloadBuilder;
18
19 public abstract class AbstractNtfbenchProducer implements Runnable {
20     protected final NotificationPublishService publishService;
21     protected final int iterations;
22     protected final Ntfbench ntf;
23
24     protected int ntfOk = 0;
25     protected int ntfError = 0;
26
27     /**
28      * Return number of successful notifications.
29      *
30      * @return the ntfOk
31      */
32     public int getNtfOk() {
33         return ntfOk;
34     }
35
36     /**
37      * Return number of unsuccessful notifications.
38      *
39      * @return the ntfError
40      */
41     public int getNtfError() {
42         return ntfError;
43     }
44
45     public AbstractNtfbenchProducer(final NotificationPublishService publishService, final int iterations,
46             final int payloadSize) {
47         this.publishService = publishService;
48         this.iterations = iterations;
49
50         final List<Payload> listVals = new ArrayList<>();
51         for (int i = 0; i < payloadSize; i++) {
52             listVals.add(new PayloadBuilder().setId(i).build());
53         }
54
55         ntf = new NtfbenchBuilder().setPayload(listVals).build();
56     }
57 }