BUG-7976: Race between peer removal and routes update
[bgpcep.git] / bgp / rib-impl / src / main / java / org / opendaylight / protocol / bgp / rib / impl / spi / PeerExportGroupRegistry.java
diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/PeerExportGroupRegistry.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/PeerExportGroupRegistry.java
new file mode 100644 (file)
index 0000000..844ec94
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.bgp.rib.impl.spi;
+
+import com.google.common.annotations.Beta;
+import org.opendaylight.protocol.bgp.rib.spi.PeerExportGroup;
+import org.opendaylight.protocol.concepts.AbstractRegistration;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.PeerId;
+
+/**
+ * PeerExportGroup Registry. Register should be maintained in blocking mode to avoid race between
+ * updating the routes and notify to a peer which doesn't longer exist. BUG-7676
+ */
+@Beta
+public interface PeerExportGroupRegistry extends PeerExportGroup {
+    /**
+     * Register peer to this exportGroup
+     *
+     * @param peerId         Peer Id
+     * @param peerExporTuple Peer Export Tuple
+     * @return registration ticket which take allows to unregister peer
+     */
+    AbstractRegistration registerPeer(PeerId peerId, PeerExporTuple peerExporTuple);
+
+    /**
+     * @return true if none peer is registered.
+     */
+    boolean isEmpty();
+}