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