This is an automated email from the ASF dual-hosted git repository. dlmarion pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/main by this push: new cbd689f Use ServerContext.getScheduledExecutor where appropriate (#2593) cbd689f is described below commit cbd689fbce9f3d4d0c521ef896e5787970733fbe Author: Dave Marion <dlmar...@apache.org> AuthorDate: Tue Mar 29 16:07:37 2022 -0400 Use ServerContext.getScheduledExecutor where appropriate (#2593) Reviewed the direct usage of ThreadPools.createGeneralScheduledExecutorService and compared it to the usage of Timer and SimpleTimer in version 2.0.1. Found and fixed a case in SessionManager where a new SheduledThreadPool was being created in each SessionManager but a shared instance of SimpleTimer was being used in the previous version. --- .../src/main/java/org/apache/accumulo/server/ServerContext.java | 5 ++--- .../java/org/apache/accumulo/tserver/session/SessionManager.java | 6 ++++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/server/base/src/main/java/org/apache/accumulo/server/ServerContext.java b/server/base/src/main/java/org/apache/accumulo/server/ServerContext.java index 835430b..16b841e 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/ServerContext.java +++ b/server/base/src/main/java/org/apache/accumulo/server/ServerContext.java @@ -455,9 +455,8 @@ public class ServerContext extends ClientContext { */ public synchronized ScheduledThreadPoolExecutor getScheduledExecutor() { if (sharedScheduledThreadPool == null) { - sharedScheduledThreadPool = - (ScheduledThreadPoolExecutor) ThreadPools.getServerThreadPools().createExecutorService( - getConfiguration(), Property.GENERAL_SIMPLETIMER_THREADPOOL_SIZE, true); + sharedScheduledThreadPool = ThreadPools.getServerThreadPools() + .createGeneralScheduledExecutorService(getConfiguration()); } return sharedScheduledThreadPool; } diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/session/SessionManager.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/session/SessionManager.java index 8c21c1d..d608f29 100644 --- a/server/tserver/src/main/java/org/apache/accumulo/tserver/session/SessionManager.java +++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/session/SessionManager.java @@ -65,8 +65,10 @@ public class SessionManager { private final List<Session> idleSessions = new ArrayList<>(); private final Long expiredSessionMarker = (long) -1; private final AccumuloConfiguration aconf; + private final ServerContext ctx; 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); @@ -279,8 +281,8 @@ public class SessionManager { } }; - ScheduledFuture<?> future = ThreadPools.getServerThreadPools() - .createGeneralScheduledExecutorService(aconf).schedule(r, delay, TimeUnit.MILLISECONDS); + ScheduledFuture<?> future = + ctx.getScheduledExecutor().schedule(r, delay, TimeUnit.MILLISECONDS); ThreadPools.watchNonCriticalScheduledTask(future); } }