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.Collections;
13 import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
14 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
15 import org.opendaylight.yangtools.yang.binding.DataObject;
16 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
21 * Provides a basic DCL implementation for performance testing reasons. Emits a summary
22 * of the changes that occurred.
24 * @author Ryan Goulding (ryandgoulding@gmail.com)
26 public class CarDataChangeListener implements DataChangeListener {
27 private static final Logger LOG = LoggerFactory.getLogger(CarDataChangeListener.class);
30 public void onDataChanged(AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
31 if (LOG.isTraceEnabled()) {
32 LOG.trace("onDataChanged invoked");
33 outputChanges(change);
37 private void outputChanges(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
38 final Map<InstanceIdentifier<?>, DataObject> originalData = change.getOriginalData() != null ?
39 change.getOriginalData(): Collections.<InstanceIdentifier<?>, DataObject>emptyMap();
40 final Map<InstanceIdentifier<?>, DataObject> updatedData = change.getUpdatedData() != null ?
41 change.getUpdatedData(): Collections.<InstanceIdentifier<?>, DataObject>emptyMap();
42 final Map<InstanceIdentifier<?>, DataObject> createdData = change.getCreatedData() != null ?
43 change.getCreatedData(): Collections.<InstanceIdentifier<?>, DataObject>emptyMap();
44 final Set<InstanceIdentifier<?>> removedPaths = change.getRemovedPaths() != null ?
45 change.getRemovedPaths(): Collections.<InstanceIdentifier<?>>emptySet();
46 LOG.trace("AsyncDataChangeEvent - originalData={} updatedData={} createdData={} removedPaths={}",
47 originalData, updatedData, createdData, removedPaths);