blob: 0631fca6a322bb988511da73f38a0fc0c70e3b21 (
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
|
// Copyright 2018 Yahoo Holdings. 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.config.provision.SystemName;
import com.yahoo.config.provision.Zone;
import com.yahoo.vespa.config.server.ApplicationRepository;
import com.yahoo.vespa.curator.Curator;
import java.time.Duration;
/**
* Removes inactive sessions
* <p>
* Note: Unit test is in ApplicationRepositoryTest
*
* @author hmusum
*/
public class SessionsMaintainer extends Maintainer {
private final boolean hostedVespa;
SessionsMaintainer(ApplicationRepository applicationRepository, Curator curator, Duration interval) {
super(applicationRepository, curator, interval);
this.hostedVespa = applicationRepository.configserverConfig().hostedVespa();
}
@Override
protected void maintain() {
applicationRepository.deleteExpiredLocalSessions();
// Expired remote sessions are not expected to exist, they should have been deleted when
// a deployment happened or when the application was deleted. We still see them from time to time,
// probably due to some race or another bug
if (hostedVespa) {
Duration expiryTime = Duration.ofDays(30);
Zone zone = applicationRepository.zone();
// TODO: Delete in all zones
boolean deleteFromZooKeeper = zone.system() == SystemName.cd ||
zone.environment().isTest() ||
zone.region().value().equals("us-central-1");
applicationRepository.deleteExpiredRemoteSessions(expiryTime, deleteFromZooKeeper);
}
}
}
|