2 * Copyright (c) 2014 Cisco 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.openflowplugin.learningswitch;
10 import java.util.Collection;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType;
13 import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
14 import org.opendaylight.mdsal.binding.api.DataTreeModification;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
16 import org.opendaylight.yangtools.yang.binding.DataObject;
17 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
18 import org.opendaylight.yangtools.yang.common.Uint8;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
22 public class WakeupOnNode implements DataTreeChangeListener<Table> {
24 private static final Logger LOG = LoggerFactory.getLogger(WakeupOnNode.class);
25 private LearningSwitchHandler learningSwitchHandler;
28 public void onDataTreeChanged(@NonNull Collection<DataTreeModification<Table>> modifications) {
29 Uint8 requiredTableId = Uint8.ZERO;
32 for (DataTreeModification<Table> modification : modifications) {
33 if (modification.getRootNode().getModificationType() == ModificationType.SUBTREE_MODIFIED) {
34 DataObject table = modification.getRootNode().getDataAfter();
35 if (table instanceof Table) {
36 Table tableSure = (Table) table;
37 LOG.trace("table: {}", table);
39 if (requiredTableId.equals(tableSure.getId())) {
40 InstanceIdentifier<Table> tablePath =
41 modification.getRootPath().getRootIdentifier();
42 learningSwitchHandler.onSwitchAppeared(tablePath);
50 * Sets the LearningSwitchHandler.
52 * @param learningSwitchHandler the learningSwitchHandler to set
54 public void setLearningSwitchHandler(
55 LearningSwitchHandler learningSwitchHandler) {
56 this.learningSwitchHandler = learningSwitchHandler;