Package org.eclipse.jgit.internal.ketch
Class KetchLeaderCache
- java.lang.Object
-
- org.eclipse.jgit.internal.ketch.KetchLeaderCache
-
public class KetchLeaderCache extends java.lang.Object
A cache of live leader instances, keyed by repository.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.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.ConcurrentMap<java.lang.String,KetchLeader>
leaders
private java.util.concurrent.locks.Lock
startLock
private KetchSystem
system
-
Constructor Summary
Constructors Constructor Description KetchLeaderCache(KetchSystem system)
Initialize a new leader cache.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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)
-
-
-
Field Detail
-
system
private final KetchSystem system
-
leaders
private final java.util.concurrent.ConcurrentMap<java.lang.String,KetchLeader> leaders
-
startLock
private final java.util.concurrent.locks.Lock startLock
-
-
Constructor Detail
-
KetchLeaderCache
public KetchLeaderCache(KetchSystem system)
Initialize a new leader cache.- Parameters:
system
- system configuration for the leaders
-
-
Method Detail
-
get
public KetchLeader get(Repository repo) throws java.net.URISyntaxException
Lookup the leader instance for a given repository.- Parameters:
repo
- repository to get the leader for.- Returns:
- the leader instance for the repository.
- Throws:
java.net.URISyntaxException
- remote configuration contains an invalid URL.
-
startLeader
private KetchLeader startLeader(java.lang.String key, Repository repo) throws java.net.URISyntaxException
- Throws:
java.net.URISyntaxException
-
computeKey
private static java.lang.String computeKey(Repository repo)
-
-