Skip to content

Commit

Permalink
removing filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
jmilkiewicz committed Nov 19, 2023
1 parent 787ecc9 commit d17ec47
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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"() {
Expand All @@ -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,
]

Expand All @@ -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
Expand Down

0 comments on commit d17ec47

Please sign in to comment.