From d17ec47881fc2e5cdba562a8bc39b1ee94f62b1c Mon Sep 17 00:00:00 2001 From: Jakub Milkiewicz Date: Sun, 19 Nov 2023 11:36:12 +0100 Subject: [PATCH] removing filtering --- .../lighter/application/sessions/SessionHandler.java | 6 ++---- .../application/sessions/SessionHandlerTest.groovy | 12 +++--------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/server/src/main/java/com/exacaster/lighter/application/sessions/SessionHandler.java b/server/src/main/java/com/exacaster/lighter/application/sessions/SessionHandler.java index 27307524..6203dd71 100644 --- a/server/src/main/java/com/exacaster/lighter/application/sessions/SessionHandler.java +++ b/server/src/main/java/com/exacaster/lighter/application/sessions/SessionHandler.java @@ -144,7 +144,7 @@ private Waitable launchSession(Application session) { @Scheduled(fixedRate = "${lighter.session.track-running-interval}") public void trackRunning() { assertLocked(); - var running = sessionService.fetchRunning(); + var running = sessionService.fetchRunningSession(); var idleAndRunning = running.stream() .collect(Collectors.groupingBy(statementStatusChecker::hasWaitingStatement)); @@ -160,10 +160,8 @@ public void handleTimeout() { var sessionConfiguration = appConfiguration.getSessionConfiguration(); var timeoutInterval = sessionConfiguration.getTimeoutInterval(); if (timeoutInterval != null && !timeoutInterval.isZero()) { - sessionService.fetchRunning() + sessionService.fetchRunningSession() .stream() - //TODO here we can delete is as we would only care about PERMANENT_SESSION - .filter(s -> isNotPermanent(sessionConfiguration, s)) .filter(s -> sessionConfiguration.shouldTimeoutActive() || !sessionService.isActive(s)) .filter(s -> sessionService.lastUsed(s.getId()).isBefore(LocalDateTime.now().minus(timeoutInterval))) .peek(s -> LOG.info("Killing because of timeout {}, session: {}", timeoutInterval, s)) diff --git a/server/src/test/groovy/com/exacaster/lighter/application/sessions/SessionHandlerTest.groovy b/server/src/test/groovy/com/exacaster/lighter/application/sessions/SessionHandlerTest.groovy index f518358a..d9432e15 100644 --- a/server/src/test/groovy/com/exacaster/lighter/application/sessions/SessionHandlerTest.groovy +++ b/server/src/test/groovy/com/exacaster/lighter/application/sessions/SessionHandlerTest.groovy @@ -38,14 +38,9 @@ class SessionHandlerTest extends Specification { def newSession = app() service.lastUsed(newSession.id) >> newSession.createdAt - def permanentSession = ApplicationBuilder.builder(oldSession) - .setId(conf.sessionConfiguration.permanentSessions.iterator().next().id) - .build() - - 1 * service.fetchRunning() >> [ + 1 * service.fetchRunningSession() >> [ oldSession, newSession, - permanentSession ] when: @@ -54,7 +49,6 @@ class SessionHandlerTest extends Specification { then: 1 * service.killOne(oldSession) 0 * service.killOne(newSession) - 0 * service.killOne(permanentSession) } def "preserves active timeouted sessions"() { @@ -63,7 +57,7 @@ class SessionHandlerTest extends Specification { service.lastUsed(oldSession.id) >> LocalDateTime.now() - conf.sessionConfiguration.timeoutInterval.plusMinutes(1) service.isActive(oldSession) >> true - 1 * service.fetchRunning() >> [ + 1 * service.fetchRunningSession() >> [ oldSession, ] @@ -82,7 +76,7 @@ class SessionHandlerTest extends Specification { .setState(ApplicationState.STARTING) .setId(conf.sessionConfiguration.permanentSessions.iterator().next().id) .build() - service.fetchRunning() >> [session, session2, permanentSession] + service.fetchRunningSession() >> [session, session2, permanentSession] statementHandler.hasWaitingStatement(session) >> false statementHandler.hasWaitingStatement(session2) >> true statementHandler.hasWaitingStatement(permanentSession) >> false