2 * Copyright (c) 2015 Cisco Systems and others. All rights reserved.
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
8 package ntfbenchmark.impl;
10 import com.google.common.collect.ImmutableMap;
11 import com.google.common.collect.ImmutableMap.Builder;
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 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbench.payload.rev150709.payload.PayloadKey;
19 public abstract class AbstractNtfbenchProducer implements Runnable {
20 protected final NotificationPublishService publishService;
21 protected final int iterations;
22 protected final Ntfbench ntf;
24 protected int ntfOk = 0;
25 protected int ntfError = 0;
28 * Return number of successful notifications.
32 public int getNtfOk() {
37 * Return number of unsuccessful notifications.
39 * @return the ntfError
41 public int getNtfError() {
45 public AbstractNtfbenchProducer(final NotificationPublishService publishService, final int iterations,
46 final int payloadSize) {
47 this.publishService = publishService;
48 this.iterations = iterations;
50 final Builder<PayloadKey, Payload> listVals = ImmutableMap.builderWithExpectedSize(payloadSize);
51 for (int i = 0; i < payloadSize; i++) {
52 final PayloadKey key = new PayloadKey(i);
53 listVals.put(key, new PayloadBuilder().withKey(key).build());
56 ntf = new NtfbenchBuilder().setPayload(listVals.build()).build();