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