2 * Copyright (c) 2016 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.applications.frsync.util;
11 import java.util.Date;
13 import java.util.concurrent.ConcurrentHashMap;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
19 * Holder of registration request for reconciliation (fresh operational).
21 public class ReconciliationRegistry {
22 private static final Logger LOG = LoggerFactory.getLogger(ReconciliationRegistry.class);
23 private final Map<NodeId, Date> registration = new ConcurrentHashMap<>();
25 public Date register(NodeId nodeId) {
26 Date timestamp = new Date();
27 registration.put(nodeId, timestamp);
28 LOG.debug("Registered for next consistent operational: {}", nodeId.getValue());
29 // TODO elicit statistics gathering if not running actually
33 public Date unregisterIfRegistered(NodeId nodeId) {
34 Date timestamp = registration.remove(nodeId);
35 if (timestamp != null) {
36 LOG.debug("Unregistered for next consistent operational: {}", nodeId.getValue());
41 public boolean isRegistered(NodeId nodeId) {
42 return registration.get(nodeId) != null;
45 public Date getRegistrationTimestamp(NodeId nodeId) {
46 return registration.get(nodeId);