X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-rest-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fstreams%2Flisteners%2FNotificator.java;h=17565a6b8c082d314f5b4e90715be18ca3536a8c;hp=99bd8c5aafa88759847eda70c61d8d10c23923da;hb=eb887b1c2c8cd2768f8b4c2ed2b5054f97798466;hpb=69eca29208f36b9a02992319cc36d1d221189ff0 diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/listeners/Notificator.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/listeners/Notificator.java index 99bd8c5aaf..17565a6b8c 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/listeners/Notificator.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/streams/listeners/Notificator.java @@ -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 listenersByStreamName = new ConcurrentHashMap<>(); - private static Map 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();