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
9 package org.opendaylight.openflowplugin.learningswitch;
11 import java.util.Collection;
12 import javax.annotation.Nonnull;
13 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType;
14 import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
15 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
17 import org.opendaylight.yangtools.yang.binding.DataObject;
18 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
25 public class WakeupOnNode implements DataTreeChangeListener<Table> {
27 private static final Logger LOG = LoggerFactory.getLogger(WakeupOnNode.class);
28 private LearningSwitchHandler learningSwitchHandler;
31 public void onDataTreeChanged(@Nonnull Collection<DataTreeModification<Table>> modifications) {
32 Short requiredTableId = 0;
35 for (DataTreeModification modification : modifications) {
36 if (modification.getRootNode().getModificationType() == ModificationType.SUBTREE_MODIFIED) {
37 DataObject table = modification.getRootNode().getDataAfter();
38 if (table instanceof Table) {
39 Table tableSure = (Table) table;
40 LOG.trace("table: {}", table);
42 if (requiredTableId.equals(tableSure.getId())) {
43 InstanceIdentifier<Table> tablePath = (InstanceIdentifier<Table>) modification.getRootPath().getRootIdentifier();
44 learningSwitchHandler.onSwitchAppeared(tablePath);
52 * @param learningSwitchHandler the learningSwitchHandler to set
54 public void setLearningSwitchHandler(
55 LearningSwitchHandler learningSwitchHandler) {
56 this.learningSwitchHandler = learningSwitchHandler;