2 * Copyright (c) 2017 Cisco Systems, Inc. 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.lispflowmapping.neutron.mappingmanager.mappers;
10 import java.util.concurrent.ConcurrentHashMap;
11 import org.opendaylight.lispflowmapping.neutron.mappingmanager.PortData;
12 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory;
16 * Created by Shakib Ahmed on 2/5/17.
18 public class HostIdToPortDataMapper {
19 private static final Logger LOG = LoggerFactory.getLogger(HostIdToPortDataMapper.class);
21 private final ConcurrentHashMap<String, PortUuidToPortDataMapper> mapper = new ConcurrentHashMap<>();
23 public HostIdToPortDataMapper() {
27 public synchronized void addMapping(String hostId, PortData portData) {
28 PortUuidToPortDataMapper uuidToEidMapper = mapper.get(hostId);
30 if (uuidToEidMapper == null) {
31 uuidToEidMapper = new PortUuidToPortDataMapper();
32 mapper.put(hostId, uuidToEidMapper);
35 uuidToEidMapper.addUnprocessedUuidToPortDataMapping(portData.getPortUuid(), portData);
36 LOG.debug("Adding " + portData.getPortEid().getAddress() + " as EID of "
37 + portData.getPortUuid() + " belonging to " + hostId);
40 public final PortUuidToPortDataMapper getAllPortData(String hostId) {
41 return mapper.get(hostId);