2 * Copyright (c) 2016 Brocade Communications 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;
10 import java.util.List;
11 import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
12 import org.opendaylight.mdsal.binding.api.DataTreeModification;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.Cars;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
18 * Provides a basic DTCL implementation for performance testing reasons. Emits a rudimentary
19 * summary of the changes that occurred.
21 * @author Ryan Goulding (ryandgoulding@gmail.com)
23 public final class CarDataTreeChangeListener implements DataTreeChangeListener<Cars> {
24 private static final Logger LOG = LoggerFactory.getLogger(CarDataTreeChangeListener.class);
27 public void onDataTreeChanged(final List<DataTreeModification<Cars>> changes) {
28 if (LOG.isTraceEnabled()) {
29 for (var change : changes) {
30 outputChanges(change);
35 private static void outputChanges(final DataTreeModification<Cars> change) {
36 final var rootNode = change.getRootNode();
37 final var modificationType = rootNode.modificationType();
38 final var rootIdentifier = change.getRootPath().path();
39 switch (modificationType) {
40 case WRITE, SUBTREE_MODIFIED -> {
41 LOG.trace("onDataTreeChanged - Cars config with path {} was added or changed from {} to {}",
42 rootIdentifier, rootNode.dataBefore(), rootNode.dataAfter());
45 LOG.trace("onDataTreeChanged - Cars config with path {} was deleted", rootIdentifier);
48 LOG.trace("onDataTreeChanged called with unknown modificationType: {}", modificationType);