Skip to content

Commit

Permalink
Modified SessionManager to recognize session idle property updates (a…
Browse files Browse the repository at this point in the history
…pache#5239)

Reverted changes in apache#4780, which marked the properties as not mutable.
Passed the ServerContext to the sweep method instead of the property
values. The property values are resolved at sweep method execution
time.

Closes apache#4723
  • Loading branch information
dlmarion authored Jan 9, 2025
1 parent 25dcfbf commit 6fe8b0c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1898,8 +1898,7 @@ public static boolean isValidTablePropertyKey(String key) {
COMPACTOR_MINTHREADS_TIMEOUT,

// others
TSERV_NATIVEMAP_ENABLED, TSERV_SCAN_MAX_OPENFILES, MANAGER_RECOVERY_WAL_EXISTENCE_CACHE_TIME,
TSERV_SESSION_MAXIDLE, TSERV_UPDATE_SESSION_MAXIDLE);
TSERV_NATIVEMAP_ENABLED, TSERV_SCAN_MAX_OPENFILES, MANAGER_RECOVERY_WAL_EXISTENCE_CACHE_TIME);

/**
* Checks if the given property may be changed via Zookeeper, but not recognized until the restart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,15 @@ public class SessionManager {

private static final SecureRandom random = new SecureRandom();
private final ConcurrentMap<Long,Session> sessions = new ConcurrentHashMap<>();
private final long maxIdle;
private final long maxUpdateIdle;
private final BlockingQueue<Session> deferredCleanupQueue = new ArrayBlockingQueue<>(5000);
private final Long expiredSessionMarker = (long) -1;
private final AccumuloConfiguration aconf;
private final ServerContext ctx;
private volatile LongConsumer zombieCountConsumer = null;

public SessionManager(ServerContext context) {
this.ctx = context;
this.aconf = context.getConfiguration();
maxUpdateIdle = aconf.getTimeInMillis(Property.TSERV_UPDATE_SESSION_MAXIDLE);
maxIdle = aconf.getTimeInMillis(Property.TSERV_SESSION_MAXIDLE);

Runnable r = () -> sweep(maxIdle, maxUpdateIdle);

long maxIdle = ctx.getConfiguration().getTimeInMillis(Property.TSERV_SESSION_MAXIDLE);
Runnable r = () -> sweep(ctx);
ThreadPools.watchCriticalScheduledTask(context.getScheduledExecutor().scheduleWithFixedDelay(r,
0, Math.max(maxIdle / 2, 1000), TimeUnit.MILLISECONDS));
}
Expand All @@ -107,7 +100,7 @@ public long createSession(Session session, boolean reserve) {
}

public long getMaxIdleTime() {
return maxIdle;
return ctx.getConfiguration().getTimeInMillis(Property.TSERV_SESSION_MAXIDLE);
}

/**
Expand Down Expand Up @@ -309,7 +302,10 @@ private void cleanup(Session session) {
cleanup(deferredCleanupQueue, session);
}

private void sweep(final long maxIdle, final long maxUpdateIdle) {
private void sweep(final ServerContext context) {
final AccumuloConfiguration conf = context.getConfiguration();
final long maxUpdateIdle = conf.getTimeInMillis(Property.TSERV_UPDATE_SESSION_MAXIDLE);
final long maxIdle = conf.getTimeInMillis(Property.TSERV_SESSION_MAXIDLE);
List<Session> sessionsToCleanup = new LinkedList<>();
Iterator<Session> iter = sessions.values().iterator();
while (iter.hasNext()) {
Expand Down

0 comments on commit 6fe8b0c

Please sign in to comment.