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 javax.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.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
21 public class WakeupOnNode implements DataTreeChangeListener<Table> {
23 private static final Logger LOG = LoggerFactory.getLogger(WakeupOnNode.class);
24 private LearningSwitchHandler learningSwitchHandler;
27 public void onDataTreeChanged(@Nonnull Collection<DataTreeModification<Table>> modifications) {
28 Short requiredTableId = 0;
31 for (DataTreeModification<Table> modification : modifications) {
32 if (modification.getRootNode().getModificationType() == ModificationType.SUBTREE_MODIFIED) {
33 DataObject table = modification.getRootNode().getDataAfter();
34 if (table instanceof Table) {
35 Table tableSure = (Table) table;
36 LOG.trace("table: {}", table);
38 if (requiredTableId.equals(tableSure.getId())) {
39 InstanceIdentifier<Table> tablePath =
40 modification.getRootPath().getRootIdentifier();
41 learningSwitchHandler.onSwitchAppeared(tablePath);
49 * Sets the LearningSwitchHandler.
51 * @param learningSwitchHandler the learningSwitchHandler to set
53 public void setLearningSwitchHandler(
54 LearningSwitchHandler learningSwitchHandler) {
55 this.learningSwitchHandler = learningSwitchHandler;