Skip to content

Commit

Permalink
Merge pull request #4706 from paulmillar/fix/5.0/rb11589
Browse files Browse the repository at this point in the history
pool: fix CDC for repository listener notification
  • Loading branch information
mksahakyan committed Mar 11, 2019
2 parents c29fcad + a663aad commit 92a054c
Showing 1 changed file with 47 additions and 36 deletions.
Expand Up @@ -12,6 +12,8 @@
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;

import dmg.cells.nucleus.CDC;

import org.dcache.pool.repository.EntryChangeEvent;
import org.dcache.pool.repository.StateChangeEvent;
import org.dcache.pool.repository.StateChangeListener;
Expand Down Expand Up @@ -58,20 +60,23 @@ public void remove(StateChangeListener listener)

public void stateChanged(final StateChangeEvent event)
{
CDC callingContext = new CDC();
try {
_executor.execute(() -> {
for (StateChangeListener listener: _listeners) {
try {
listener.stateChanged(event);
} catch (RuntimeException e) {
/* State change notifications are
* important for proper functioning of the
* pool and we cannot risk a problem in an
* event handler causing other event
* handlers not to be called. We therefore
* catch, log and ignore these problems.
*/
_log.error("Unexpected failure during state change notification", e);
try (CDC oldContext = callingContext.restore()) {
for (StateChangeListener listener: _listeners) {
try {
listener.stateChanged(event);
} catch (RuntimeException e) {
/* State change notifications are
* important for proper functioning of the
* pool and we cannot risk a problem in an
* event handler causing other event
* handlers not to be called. We therefore
* catch, log and ignore these problems.
*/
_log.error("Unexpected failure during state change notification", e);
}
}
}
});
Expand All @@ -83,20 +88,23 @@ public void stateChanged(final StateChangeEvent event)

public void accessTimeChanged(final EntryChangeEvent event)
{
CDC callingContext = new CDC();
try {
_executor.execute(() -> {
for (StateChangeListener listener: _listeners) {
try {
listener.accessTimeChanged(event);
} catch (RuntimeException e) {
/* State change notifications are
* important for proper functioning of the
* pool and we cannot risk a problem in an
* event handler causing other event
* handlers not to be called. We therefore
* catch, log and ignore these problems.
*/
_log.error("Unexpected failure during state change notification", e);
try (CDC oldContext = callingContext.restore()) {
for (StateChangeListener listener: _listeners) {
try {
listener.accessTimeChanged(event);
} catch (RuntimeException e) {
/* State change notifications are
* important for proper functioning of the
* pool and we cannot risk a problem in an
* event handler causing other event
* handlers not to be called. We therefore
* catch, log and ignore these problems.
*/
_log.error("Unexpected failure during state change notification", e);
}
}
}
});
Expand All @@ -108,20 +116,23 @@ public void accessTimeChanged(final EntryChangeEvent event)

public void stickyChanged(final StickyChangeEvent event)
{
CDC callingContext = new CDC();
try {
_executor.execute(() -> {
for (StateChangeListener listener: _listeners) {
try {
listener.stickyChanged(event);
} catch (RuntimeException e) {
/* State change notifications are
* important for proper functioning of the
* pool and we cannot risk a problem in an
* event handler causing other event
* handlers not to be called. We therefore
* catch, log and ignore these problems.
*/
_log.error("Unexpected failure during state change notification", e);
try (CDC oldContext = callingContext.restore()) {
for (StateChangeListener listener: _listeners) {
try {
listener.stickyChanged(event);
} catch (RuntimeException e) {
/* State change notifications are
* important for proper functioning of the
* pool and we cannot risk a problem in an
* event handler causing other event
* handlers not to be called. We therefore
* catch, log and ignore these problems.
*/
_log.error("Unexpected failure during state change notification", e);
}
}
}
});
Expand Down

0 comments on commit 92a054c

Please sign in to comment.