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.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType;
12 import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
13 import org.opendaylight.mdsal.binding.api.DataTreeModification;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
15 import org.opendaylight.yangtools.yang.common.Uint8;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
19 public class WakeupOnNode implements DataTreeChangeListener<Table> {
20 private static final Logger LOG = LoggerFactory.getLogger(WakeupOnNode.class);
22 private LearningSwitchHandler learningSwitchHandler = null;
25 public void onDataTreeChanged(final Collection<DataTreeModification<Table>> modifications) {
26 Uint8 requiredTableId = Uint8.ZERO;
29 for (var modification : modifications) {
30 if (modification.getRootNode().getModificationType() == ModificationType.SUBTREE_MODIFIED) {
31 var table = modification.getRootNode().getDataAfter();
33 LOG.trace("table: {}", table);
34 if (requiredTableId.equals(table.getId())) {
35 learningSwitchHandler.onSwitchAppeared(modification.getRootPath().getRootIdentifier());
43 * Sets the LearningSwitchHandler.
45 * @param learningSwitchHandler the learningSwitchHandler to set
47 public void setLearningSwitchHandler(final LearningSwitchHandler learningSwitchHandler) {
48 this.learningSwitchHandler = learningSwitchHandler;