Separate ShardRecoveryCoordinator implementations
[controller.git] / opendaylight / md-sal / samples / clustering-test-app / provider / src / main / java / org / opendaylight / controller / clustering / it / provider / CarDataChangeListener.java
1 /*
2  * Copyright (c) 2016 Brocade Communications Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.clustering.it.provider;
9
10 import java.util.Collections;
11 import java.util.Map;
12 import java.util.Set;
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;
19
20 /**
21  * Provides a basic DCL implementation for performance testing reasons.  Emits a summary
22  * of the changes that occurred.
23  *
24  * @author Ryan Goulding (ryandgoulding@gmail.com)
25  */
26 public class CarDataChangeListener implements DataChangeListener {
27     private static final Logger LOG = LoggerFactory.getLogger(CarDataChangeListener.class);
28
29     @Override
30     public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
31         if (LOG.isTraceEnabled()) {
32             LOG.trace("onDataChanged invoked");
33             outputChanges(change);
34         }
35     }
36
37     private static 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);
48     }
49 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.