Improve subscriber tracking 31/108831/12
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 3 Nov 2023 07:06:15 +0000 (08:06 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 8 Nov 2023 10:14:05 +0000 (11:14 +0100)
commit7f4cf202a23bc829987e014ec9826ed71a6f57cd
tree98839dc7374538c67e10b5bd87e7c6a8144c4faf
parent8c000662f952c05860c81238971695829e485347
Improve subscriber tracking

Create a dedicated immutable Subscribers object, which tracks handlers
and their corresponding formatters.

Subscribers are structured, so multiple subscribers with the same
formatter with reuse the same formatted message.

Each RestconfStream starts with Subscribers.empty(), indicating a first
subscriber is required. When we lose the last subscriber, Subscribers
will become null and we trigger stream removal.

This improves on the HashSet tracking in terms of memory footprint, as
we typically will have 0 or 1 subscribers.

The newly introduced indirection through Subscriber allows the
subscriber to dictate the actual formatter which we will use in upcoming
patches.

JIRA: NETCONF-1102
Change-Id: I75e581ed7615b883e65ea60285cd4c1ba09d109e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/AbstractNotificationStream.java
restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/DataTreeChangeStream.java
restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/RestconfStream.java
restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/SSESessionHandler.java
restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/Subscriber.java [new file with mode: 0644]
restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/Subscribers.java [new file with mode: 0644]
restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/WebSocketSessionHandler.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/streams/DataTreeChangeStreamTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/streams/SSESessionHandlerTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/streams/WebSocketSessionHandlerTest.java