Migrate ElanUtils to use NamedLocks 07/82607/2
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 20 Jun 2019 17:59:40 +0000 (19:59 +0200)
committerStephen Kitt <skitt@redhat.com>
Mon, 24 Jun 2019 09:10:32 +0000 (09:10 +0000)
commitbe1b0517d62d3aa1a21062363b21f6d9f4da4fba
tree81e7c5b53189a53d21d4123392cd747ad3956b68
parente045f53e199e25cdd37601c34dfbbe011684153e
Migrate ElanUtils to use NamedLocks

This use was missed by previous translation due to indirection
created by utility methods.

getElanMacDPNKey() is serving two purposes, really, which is as
a job key for JobCoordinator and also as the locking object.

This patch moves the first use to ElanPacketInHandler, which is
the sole user and removes the intern() call, as JobCoordinator
works on equality.

Second use case is locking of elans, which is migrated to NamedLocks,
as there do not seem to be any other callers who would be using
magic strings involved there. Rather than using strings, we expose
a lockElanMacDPN() method, which looks up and acquires the specific
lock, returning the handle back to caller. Callers are converted
to use normal try-with-resources to ensure the lock is released when
no longer needed.

JIRA: NETVIRT-1510
Change-Id: I0292e0e9a4e51ab98e62be5f01d59cb337ff1421
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
elanmanager/impl/src/main/java/org/opendaylight/netvirt/elan/evpn/utils/ElanEvpnFlowUtils.java
elanmanager/impl/src/main/java/org/opendaylight/netvirt/elan/internal/ElanInterfaceManager.java
elanmanager/impl/src/main/java/org/opendaylight/netvirt/elan/internal/ElanPacketInHandler.java
elanmanager/impl/src/main/java/org/opendaylight/netvirt/elan/utils/ElanUtils.java