2 * Copyright (c) 2017 Cisco Systems, Inc. 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 org.opendaylight.controller.clustering.it.provider.impl;
10 import static java.util.Objects.requireNonNull;
12 import java.util.concurrent.atomic.AtomicLong;
13 import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnsubscribeYnlOutput;
14 import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnsubscribeYnlOutputBuilder;
15 import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.target.rev170215.IdSequence;
16 import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.target.rev170215.OdlMdsalLowlevelTargetListener;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
20 public class YnlListener implements OdlMdsalLowlevelTargetListener {
21 private static final Logger LOG = LoggerFactory.getLogger(YnlListener.class);
23 private final String id;
25 private final AtomicLong localNumber = new AtomicLong();
26 private final AtomicLong allNot = new AtomicLong();
27 private final AtomicLong idNot = new AtomicLong();
28 private final AtomicLong errNot = new AtomicLong();
30 public YnlListener(final String id) {
31 this.id = requireNonNull(id);
35 public void onIdSequence(final IdSequence notification) {
36 LOG.debug("Received id-sequence notification, : {}", notification);
38 allNot.incrementAndGet();
40 if (notification.getId().equals(id)) {
41 idNot.incrementAndGet();
43 localNumber.getAndUpdate(value -> {
44 if (notification.getSequenceNumber() - value == 1) {
47 errNot.getAndIncrement();
53 public UnsubscribeYnlOutput getOutput() {
54 return new UnsubscribeYnlOutputBuilder()
55 .setAllNot(allNot.get())
56 .setErrNot(errNot.get())
57 .setIdNot(idNot.get())
58 .setLocalNumber(localNumber.get())