public class KetchLeaderCache
extends java.lang.Object
Ketch only assigns a leader to a repository when needed. If
get(Repository)
is called for a repository that does not have a
leader, the leader is created and added to the cache.
Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.ConcurrentMap<java.lang.String,KetchLeader> |
leaders |
private java.util.concurrent.locks.Lock |
startLock |
private KetchSystem |
system |
Constructor and Description |
---|
KetchLeaderCache(KetchSystem system)
Initialize a new leader cache.
|
Modifier and Type | Method and Description |
---|---|
private static java.lang.String |
computeKey(Repository repo) |
KetchLeader |
get(Repository repo)
Lookup the leader instance for a given repository.
|
private KetchLeader |
startLeader(java.lang.String key,
Repository repo) |
private final KetchSystem system
private final java.util.concurrent.ConcurrentMap<java.lang.String,KetchLeader> leaders
private final java.util.concurrent.locks.Lock startLock
public KetchLeaderCache(KetchSystem system)
system
- system configuration for the leaderspublic KetchLeader get(Repository repo) throws java.net.URISyntaxException
repo
- repository to get the leader for.java.net.URISyntaxException
- remote configuration contains an invalid URL.private KetchLeader startLeader(java.lang.String key, Repository repo) throws java.net.URISyntaxException
java.net.URISyntaxException
private static java.lang.String computeKey(Repository repo)