blob: 7482980e2217b74ab3edfaa919943c60e745e35a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.maintenance;
import com.yahoo.vespa.config.server.ApplicationRepository;
import com.yahoo.vespa.curator.Curator;
import com.yahoo.vespa.flags.FlagSource;
import java.time.Duration;
import java.util.logging.Level;
/**
* Removes expired sessions and locks
* <p>
* Note: Unit test is in ApplicationRepositoryTest
*
* @author hmusum
*/
public class SessionsMaintainer extends ConfigServerMaintainer {
private final boolean hostedVespa;
private int iteration = 0;
SessionsMaintainer(ApplicationRepository applicationRepository, Curator curator, Duration interval, FlagSource flagSource) {
super(applicationRepository, curator, flagSource, applicationRepository.clock().instant(), interval);
this.hostedVespa = applicationRepository.configserverConfig().hostedVespa();
}
@Override
protected boolean maintain() {
if (iteration % 10 == 0)
log.log(Level.INFO, () -> "Running " + SessionsMaintainer.class.getSimpleName() + ", iteration " + iteration);
applicationRepository.deleteExpiredLocalSessions();
if (hostedVespa) {
Duration expiryTime = Duration.ofMinutes(90);
int deleted = applicationRepository.deleteExpiredRemoteSessions(expiryTime);
log.log(Level.FINE, () -> "Deleted " + deleted + " expired remote sessions older than " + expiryTime);
}
iteration++;
return true;
}
}
|