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;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatus;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
19 * Wrapper for bandwidth extracting utilities
24 public class PortFeaturesUtil {
26 private static PortFeaturesUtil instance = new PortFeaturesUtil();
28 private final Map<Short, IGetBandwith> portVersionBandwidth;
29 protected static final Logger LOG = LoggerFactory.getLogger(PortFeaturesUtil.class);
31 private PortFeaturesUtil() {
32 this.portVersionBandwidth = new HashMap<>();
34 portVersionBandwidth.put((short) 1, FeaturesV10Bandwidth.getInstance());
35 portVersionBandwidth.put((short) 4, FeaturesV13Bandwidth.getInstance());
42 public static PortFeaturesUtil getInstance() {
48 * @param msg {@link org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatus}
49 * @return port bandwidth
51 public Boolean getPortBandwidth(PortStatus msg) {
53 if(portVersionBandwidth.containsKey(msg.getVersion()) == true) {
55 return portVersionBandwidth.get(msg.getVersion()).getBandwidth(msg);
56 } catch (NullPointerException e) {
57 LOG.error("error while getting port features {}", e);
61 LOG.warn("unknown port version: {}", msg.getVersion());