Class 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 Detail

      • 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)