Merge "BUG 1082 Migrate sal-rest-connector to Async Data Broker API"
[controller.git] / opendaylight / md-sal / sal-rest-connector / src / main / java / org / opendaylight / controller / sal / streams / listeners / Notificator.java
index 99bd8c5aafa88759847eda70c61d8d10c23923da..17565a6b8c082d314f5b4e90715be18ca3536a8c 100644 (file)
@@ -15,12 +15,12 @@ import java.util.concurrent.locks.ReentrantLock;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
 /**
- * {@link Notificator} is responsible to create, remove and find {@link ListenerAdapter} listener.
+ * {@link Notificator} is responsible to create, remove and find
+ * {@link ListenerAdapter} listener.
  */
 public class Notificator {
 
     private static Map<String, ListenerAdapter> listenersByStreamName = new ConcurrentHashMap<>();
-    private static Map<YangInstanceIdentifier, ListenerAdapter> listenersByInstanceIdentifier = new ConcurrentHashMap<>();
     private static final Lock lock = new ReentrantLock();
 
     private Notificator() {
@@ -44,26 +44,14 @@ public class Notificator {
         return listenersByStreamName.get(streamName);
     }
 
-    /**
-     * Gets {@link ListenerAdapter} listener specified by {@link YangInstanceIdentifier} path.
-     *
-     * @param path
-     *            Path to data in data repository.
-     * @return ListenerAdapter
-     */
-    public static ListenerAdapter getListenerFor(YangInstanceIdentifier path) {
-        return listenersByInstanceIdentifier.get(path);
-    }
-
     /**
      * Checks if the listener specified by {@link YangInstanceIdentifier} path exist.
      *
-     * @param path
-     *            Path to data in data repository.
+     * @param streamName
      * @return True if the listener exist, false otherwise.
      */
-    public static boolean existListenerFor(YangInstanceIdentifier path) {
-        return listenersByInstanceIdentifier.containsKey(path);
+    public static boolean existListenerFor(String streamName) {
+        return listenersByStreamName.containsKey(streamName);
     }
 
     /**
@@ -79,7 +67,6 @@ public class Notificator {
         ListenerAdapter listener = new ListenerAdapter(path, streamName);
         try {
             lock.lock();
-            listenersByInstanceIdentifier.put(path, listener);
             listenersByStreamName.put(streamName, listener);
         } finally {
             lock.unlock();
@@ -89,16 +76,6 @@ public class Notificator {
 
     /**
      * Looks for listener determined by {@link YangInstanceIdentifier} path and removes it.
-     *
-     * @param path
-     *            InstanceIdentifier
-     */
-    public static void removeListener(YangInstanceIdentifier path) {
-        ListenerAdapter listener = listenersByInstanceIdentifier.get(path);
-        deleteListener(listener);
-    }
-
-    /**
      * Creates String representation of stream name from URI. Removes slash from URI in start and end position.
      *
      * @param uri
@@ -123,7 +100,7 @@ public class Notificator {
      * Removes all listeners.
      */
     public static void removeAllListeners() {
-        for (ListenerAdapter listener : listenersByInstanceIdentifier.values()) {
+        for (ListenerAdapter listener : listenersByStreamName.values()) {
             try {
                 listener.close();
             } catch (Exception e) {
@@ -132,7 +109,6 @@ public class Notificator {
         try {
             lock.lock();
             listenersByStreamName = new ConcurrentHashMap<>();
-            listenersByInstanceIdentifier = new ConcurrentHashMap<>();
         } finally {
             lock.unlock();
         }
@@ -164,7 +140,6 @@ public class Notificator {
             }
             try {
                 lock.lock();
-                listenersByInstanceIdentifier.remove(listener.getPath());
                 listenersByStreamName.remove(listener.getStreamName());
             } finally {
                 lock.unlock();