[grid] Stopping a session by invalidating its cache entry
We already have the login in the `removalListener`, so we
only need to invalidate the cache entry to trigger the
logic happening inside the `SessionSlot`.
@@ -150,12 +150,12 @@ private LocalNode(
.expireAfterAccess(sessionTimeout)
.ticker(ticker)
.removalListener((RemovalListener<SessionId, SessionSlot>) notification -> {
- // If we were invoked explicitly, then return: we know what we're doing.
- if (!notification.wasEvicted()) {
- return;
+ // Attempt to stop the session
+ SessionSlot slot = notification.getValue();
+ if (!slot.isAvailable()) {
+ slot.stop();
}
- killSession(notification.getValue());
})
.build();
@@ -434,7 +434,7 @@ public void stop(SessionId id) throws NoSuchSessionException {
throw new NoSuchSessionException("Cannot find session with id: " + id);
}
- killSession(slot);
+ currentSessions.invalidate(id);
tempFileSystems.invalidate(id);
}
@@ -474,14 +474,6 @@ private URI rewrite(String path) {
}
}
- private void killSession(SessionSlot slot) {
- currentSessions.invalidate(slot.getSession().getId());
- // Attempt to stop the session
- if (!slot.isAvailable()) {
- slot.stop();
- }
- }
-
@Override
public NodeStatus getStatus() {
Set<Slot> slots = factories.stream()
