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;
12 import java.util.Map.Entry;
14 import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent;
15 import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;
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 DataChangeListener {
27 private static final Logger LOG = LoggerFactory
28 .getLogger(WakeupOnNode.class);
30 private SimpleLearningSwitchHandler learningSwitchHandler;
33 public void onDataChanged(DataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
34 Short requiredTableId = 0;
37 Map<InstanceIdentifier<?>, DataObject> updated = change.getUpdatedOperationalData();
38 for (Entry<InstanceIdentifier<?>, DataObject> updateItem : updated.entrySet()) {
39 DataObject table = updateItem.getValue();
40 if (table instanceof Table) {
41 Table tableSure = (Table) table;
42 LOG.trace("table: {}", table);
44 if (requiredTableId.equals(tableSure.getId())) {
45 @SuppressWarnings("unchecked")
46 InstanceIdentifier<Table> tablePath = (InstanceIdentifier<Table>) updateItem.getKey();
47 learningSwitchHandler.onSwitchAppeared(tablePath);
54 * @param learningSwitchHandler the learningSwitchHandler to set
56 public void setLearningSwitchHandler(
57 SimpleLearningSwitchHandler learningSwitchHandler) {
58 this.learningSwitchHandler = learningSwitchHandler;