totalSessions() + numSessionsBeingCreated + 1 /* For pool maintenance thread */; poolMaintainer.close(); readSessions.clear(); writePreparedSessions.clear();
totalSessions() + numSessionsBeingCreated + 1 /* For pool maintenance thread */; poolMaintainer.close(); readSessions.clear(); writePreparedSessions.clear();
void maintainPool() { synchronized (lock) { if (isClosed()) { return; } running = true; } Instant currTime = clock.instant(); closeIdleSessions(currTime); // Now go over all the remaining sessions and see if they need to be kept alive explicitly. keepAliveSessions(currTime); replenishPool(); synchronized (lock) { running = false; if (isClosed()) { decrementPendingClosures(); } } }
private SessionPool( SessionPoolOptions options, ExecutorFactory<ScheduledExecutorService> executorFactory, ScheduledExecutorService executor, DatabaseId db, SpannerImpl spanner, Clock clock) { this.options = options; this.executorFactory = executorFactory; this.executor = executor; this.db = db; this.spanner = spanner; this.clock = clock; this.poolMaintainer = new PoolMaintainer(); }
private void initPool() { synchronized (lock) { poolMaintainer.init(); for (int i = 0; i < options.getMinSessions(); i++) { createSession(); } } }
@Override public void run() { maintainPool(); } },
void maintainPool() { synchronized (lock) { if (isClosed()) { return; } running = true; } Instant currTime = clock.instant(); closeIdleSessions(currTime); // Now go over all the remaining sessions and see if they need to be kept alive explicitly. keepAliveSessions(currTime); replenishPool(); synchronized (lock) { running = false; if (isClosed()) { decrementPendingClosures(); } } }
private SessionPool( SessionPoolOptions options, ExecutorFactory<ScheduledExecutorService> executorFactory, ScheduledExecutorService executor, DatabaseId db, SpannerImpl spanner, Clock clock) { this.options = options; this.executorFactory = executorFactory; this.executor = executor; this.db = db; this.spanner = spanner; this.clock = clock; this.poolMaintainer = new PoolMaintainer(); }
void runMaintainanceLoop(FakeClock clock, SessionPool pool, long numCycles) { for (int i = 0; i < numCycles; i++) { pool.poolMaintainer.maintainPool(); clock.currentTimeMillis += SessionPool.PoolMaintainer.LOOP_FREQUENCY; } }
@Override public void run() { maintainPool(); } },
private void initPool() { synchronized (lock) { poolMaintainer.init(); for (int i = 0; i < options.getMinSessions(); i++) { createSession(); } } }