Bump upstream versions
[lispflowmapping.git] / mappingservice / neutron / src / main / java / org / opendaylight / lispflowmapping / neutron / mappingmanager / mappers / HostIdToPortDataMapper.java
1 /*
2  * Copyright (c) 2017 Cisco Systems, Inc.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.lispflowmapping.neutron.mappingmanager.mappers;
9
10 import java.util.concurrent.ConcurrentHashMap;
11 import org.opendaylight.lispflowmapping.neutron.mappingmanager.PortData;
12 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory;
14
15 /**
16  * Created by Shakib Ahmed on 2/5/17.
17  */
18 public class HostIdToPortDataMapper {
19     private static final Logger LOG = LoggerFactory.getLogger(HostIdToPortDataMapper.class);
20
21     private final ConcurrentHashMap<String, PortUuidToPortDataMapper> mapper = new ConcurrentHashMap<>();
22
23     public HostIdToPortDataMapper() {
24
25     }
26
27     public synchronized void addMapping(String hostId, PortData portData) {
28         PortUuidToPortDataMapper uuidToEidMapper = mapper.get(hostId);
29
30         if (uuidToEidMapper == null) {
31             uuidToEidMapper = new PortUuidToPortDataMapper();
32             mapper.put(hostId, uuidToEidMapper);
33         }
34
35         uuidToEidMapper.addUnprocessedUuidToPortDataMapping(portData.getPortUuid(), portData);
36         LOG.debug("Adding " + portData.getPortEid().getAddress() + " as EID of "
37                 + portData.getPortUuid() + " belonging to " + hostId);
38     }
39
40     public final PortUuidToPortDataMapper getAllPortData(String hostId) {
41         return mapper.get(hostId);
42     }
43
44 }