Beispiel #1
0
 /// <summary>
 /// 初始化一个新的Leader选举管理器
 /// </summary>
 /// <param name="serviceName">服务名,参与Leader选举的多个程序应该使用相同的服务名</param>
 /// <param name="serviceId">服务Id,参与Leader选举的每个程序应该有唯一的服务Id</param>
 /// <param name="options"></param>
 public LeaderElectionManager(string serviceName, string serviceId, LeaderElectionOptions options)
 {
     _defaultOfflineConfirmNumber = options.LeaderOfflineConfirmNumber;
     _offlineConfirmNumber        = _defaultOfflineConfirmNumber;
     _currentServiceId            = serviceId;
     _election = new LeaderElectionFactory().Create(options);
     _election.Register(serviceName, serviceId, options);
 }
        public LeaderElector(
            ILogger <LeaderElector> logger,
            OperatorSettings settings,
            ILeaderElection election,
            IKubernetesClient client)
        {
            _logger   = logger;
            _settings = settings;
            _election = election;
            _client   = client;

            _leaseName = $"{_settings.Name}-leadership";
            _hostname  = Environment.MachineName;
        }
Beispiel #3
0
 public Orchestrator(IAutoCraneConfig config, ILoggerFactory loggerFactory, IFailingPodGetter failingPodGetter, IPodEvicter podEvicter, IPodDataRequestGetter podGetter, IDataRepositoryManifestFetcher manifestFetcher, IPodAnnotationPutter podAnnotationPutter, IDataRepositoryKnownGoodAccessor knownGoodAccessor, IDataRepositoryLatestVersionAccessor upgradeAccessor, IDataRepositoryUpgradeOracleFactory upgradeOracleFactory, IClock clock, ILeaderElection leaderElection, IExpiredObjectDeleter expiredObjectDeleter)
 {
     this.config               = config;
     this.failingPodGetter     = failingPodGetter;
     this.podEvicter           = podEvicter;
     this.dataRequestGetter    = podGetter;
     this.manifestFetcher      = manifestFetcher;
     this.podAnnotationPutter  = podAnnotationPutter;
     this.knownGoodAccessor    = knownGoodAccessor;
     this.upgradeAccessor      = upgradeAccessor;
     this.upgradeOracleFactory = upgradeOracleFactory;
     this.clock                = clock;
     this.leaderElection       = leaderElection;
     this.expiredObjectDeleter = expiredObjectDeleter;
     this.logger               = loggerFactory.CreateLogger <Orchestrator>();
 }
 public ResourceServices(
     ILoggerFactory loggerFactory,
     IKubernetesClient client,
     IResourceCache<TEntity> resourceCache,
     IResourceEventQueue<TEntity> eventQueue,
     Lazy<IEnumerable<IResourceFinalizer>> finalizers,
     OperatorSettings settings,
     ILeaderElection leaderElection)
 {
     LoggerFactory = loggerFactory;
     Client = client;
     ResourceCache = resourceCache;
     EventQueue = eventQueue;
     Finalizers = finalizers;
     Settings = settings;
     LeaderElection = leaderElection;
 }
 public LeaderElectionHostedService(ILogger <LeaderElectionHostedService> logger, ILeaderElection leaderElection)
 {
     _logger         = logger;
     _leaderElection = leaderElection;
 }