2 * Copyright (c) 2013 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.openflow.md.core.session;
11 import java.util.HashMap;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatus;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
18 * Wrapper for bandwidth extracting utilities
23 public class PortFeaturesUtil {
25 private static PortFeaturesUtil instance = new PortFeaturesUtil();
27 private final Map<Short, IGetBandwith> portVersionBandwidth;
28 protected static final Logger LOG = LoggerFactory.getLogger(PortFeaturesUtil.class);
30 private PortFeaturesUtil() {
31 this.portVersionBandwidth = new HashMap<>();
33 portVersionBandwidth.put((short) 1, FeaturesV10Bandwidth.getInstance());
34 portVersionBandwidth.put((short) 4, FeaturesV13Bandwidth.getInstance());
41 public static PortFeaturesUtil getInstance() {
47 * @param msg {@link org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatus}
48 * @return port bandwidth
50 public Boolean getPortBandwidth(PortStatus msg) {
52 if(portVersionBandwidth.containsKey(msg.getVersion()) == true) {
54 return portVersionBandwidth.get(msg.getVersion()).getBandwidth(msg);
55 } catch (NullPointerException e) {
56 LOG.warn("error while getting port features: {}", e.getMessage());
57 LOG.debug("error while getting port features.. ", e);
61 LOG.warn("unknown port version: {}", msg.getVersion());