blob: 4df292dd20493a3a213ddf3c23b0a0ab711ecf98 (
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 2017 Yahoo Holdings. 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.Tenants;
import com.yahoo.vespa.curator.Curator;
/**
* A counter keeping track of session ids in an atomic fashion across multiple config servers.
*
* @author lulf
* @since 5.1
*/
public class SessionCounter extends InitializedCounter {
public SessionCounter(Curator curator, TenantName tenantName) {
super(curator,
Tenants.getTenantPath(tenantName).append("sessionCounter").getAbsolute(),
Tenants.getSessionsPath(tenantName).getAbsolute());
}
/**
* Atomically increment and return next session id.
*
* @return a new session id.
*/
public long nextSessionId() {
return counter.next();
}
}
|