Exemple #1
0
        public override void InformLeaderElected(Id leaderId, bool isHealthyCluster, bool isLocalNodeLeading)
        {
            Logger.Info($"DIRECTORY: Leader elected: {leaderId}");

            if (isLocalNodeLeading)
            {
                _leading = true;
                Logger.Debug("DIRECTORY: Assigned leadership; starting processing.");
                _directoryService.AssignLeadership();
            }
            else
            {
                _leading = false;
                Logger.Debug($"DIRECTORY: Remote node assigned leadership: {leaderId}");

                // prevent split brain in case another leader pushes in. if this node
                // is not currently leading this operation will have no harm.
                _directoryService.RelinquishLeadership();
            }
        }