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
9 package org.opendaylight.controller.clustering.it.provider;
11 import javax.annotation.Nonnull;
12 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
13 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType;
14 import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
15 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.Cars;
17 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
22 * Provides a basic DTCL implementation for performance testing reasons. Emits a rudimentary
23 * summary of the changes that occurred.
25 * @author Ryan Goulding (ryandgoulding@gmail.com)
27 public class CarDataTreeChangeListener implements DataTreeChangeListener<Cars> {
28 private static final Logger LOG = LoggerFactory.getLogger(CarDataTreeChangeListener.class);
31 public void onDataTreeChanged(@Nonnull final java.util.Collection<DataTreeModification<Cars>> changes) {
32 if (LOG.isTraceEnabled()) {
33 for (DataTreeModification<Cars> change : changes) {
39 private static void ouputChanges(final DataTreeModification<Cars> change) {
40 final DataObjectModification<Cars> rootNode = change.getRootNode();
41 final ModificationType modificationType = rootNode.getModificationType();
42 final InstanceIdentifier<Cars> rootIdentifier = change.getRootPath().getRootIdentifier();
43 switch (modificationType) {
45 case SUBTREE_MODIFIED: {
46 final Cars dataBefore = rootNode.getDataBefore();
47 final Cars dataAfter = rootNode.getDataAfter();
48 LOG.trace("onDataTreeChanged - Cars config with path {} was added or changed from {} to {}",
49 rootIdentifier, dataBefore, dataAfter);
53 LOG.trace("onDataTreeChanged - Cars config with path {} was deleted", rootIdentifier);
57 LOG.trace("onDataTreeChanged called with unknown modificationType: {}", modificationType);