blob: 2d95a013da91d68404a264cb6d00fbc160481a7a (
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
|
// 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.path.Path;
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, Path rootPath, Path sessionsDir) {
super(curator, rootPath.append("sessionCounter").getAbsolute(), sessionsDir.getAbsolute());
}
/**
* Atomically increment and return next session id.
*
* @return a new session id.
*/
public long nextSessionId() {
return counter.next();
}
}
|