2 * Copyright (c) 2016 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
9 package org.opendaylight.lispflowmapping.implementation.timebucket.containers;
11 import java.util.concurrent.ConcurrentHashMap;
13 import org.opendaylight.lispflowmapping.implementation.MappingSystem;
14 import org.opendaylight.lispflowmapping.lisp.type.MappingData;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
20 * Created by Shakib Ahmed on 12/1/16.
22 public class TimeBucket {
23 private static final Logger LOG = LoggerFactory.getLogger(TimeBucket.class);
25 private final ConcurrentHashMap<Eid, MappingData> bucketElements;
27 private final MappingSystem mappingSystem;
29 public TimeBucket(MappingSystem mappingSystem) {
30 bucketElements = new ConcurrentHashMap<>();
31 this.mappingSystem = mappingSystem;
34 public void add(Eid key, MappingData mappingData) {
35 bucketElements.put(key, mappingData);
38 public void removeFromBucketOnly(Eid key) {
39 MappingData mappingData = bucketElements.get(key);
41 if (mappingData != null) {
42 bucketElements.remove(key);
46 public void clearBucket() {
47 bucketElements.forEach((key, mappingData) -> {
48 mappingSystem.handleSbExpiredMapping(key, null, mappingData);