blob: 6002619201e0a9a041ad5afb243fd85f9e1acdaa (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.zookeeper;
import com.yahoo.config.provision.TenantName;
import com.yahoo.vespa.config.server.tenant.TenantRepository;
import com.yahoo.vespa.curator.Curator;
/**
* A counter keeping track of session ids in an atomic fashion across multiple config servers.
*
* @author Ulf Lilleengen
*/
public class SessionCounter extends InitializedCounter {
public SessionCounter(Curator curator, TenantName tenantName) {
super(curator,
TenantRepository.getTenantPath(tenantName).append("sessionCounter"),
TenantRepository.getSessionsPath(tenantName));
}
/**
* Atomically increment and return next session id.
*
* @return a new session id.
*/
public long nextSessionId() {
return counter.next();
}
}
|