Пример #1
0
        /// <summary>
        /// returns true if at least one of the endpoints is available.
        /// </summary>
        /// <returns>
        ///   <c>true</c> if [is redis available]; otherwise, <c>false</c>.
        /// </returns>
        private bool IsRedisAvailable(string[] endPoints)
        {
            string redisPassword      = SystemSettings.GetValueFromWebConfig(Rock.SystemKey.SystemSetting.REDIS_PASSWORD) ?? string.Empty;
            int    endPointErrorCount = 0;

            foreach (var endPoint in endPoints)
            {
                endPointErrorCount += RockCache.IsEndPointAvailable(endPoint, redisPassword) == true ? 0 : 1;
            }

            return(endPointErrorCount == endPoints.Length ? false : true);
        }
Пример #2
0
        protected void PopulateRedisView()
        {
            // clear and hide edit
            ClearAndHideRedisEdit();

            RedisEndPointAvailabilityCheck();

            redisView.Visible = true;

            bool enabled = RockCache.IsCacheSerialized;

            if (!enabled)
            {
                DisplayNotification(nbRedisSettings, "Redis is currently not enabled. Review documentation for more information on enabling Redis backplane support.", NotificationBoxType.Info);
                redisEnabled.Visible = false;
                return;
            }

            redisEnabled.Visible = true;

            string redisPassword = SystemSettings.GetValueFromWebConfig(Rock.SystemKey.SystemSetting.REDIS_PASSWORD) ?? string.Empty;

            string serverList = string.Join(
                string.Empty,
                SystemSettings.GetValueFromWebConfig(Rock.SystemKey.SystemSetting.REDIS_ENDPOINT_LIST)
                .Split(',')
                .Select(s =>
                        (
                            RockCache.IsEndPointAvailable(s, redisPassword) == true ?
                            "<span class='label label-success'>" + s + " Endpoint is available </span><br />" :
                            "<span class='label label-warning'>" + s + " Endpoint is not available </span><br />"
                        )));

            // show and populate view
            cbEnabled.Checked      = enabled;
            lEndPointList.Text     = serverList;
            lblPassword.Text       = SystemSettings.GetValueFromWebConfig(Rock.SystemKey.SystemSetting.REDIS_PASSWORD).IsNullOrWhiteSpace() ? string.Empty : "***********";
            lblDatabaseNumber.Text = SystemSettings.GetValueFromWebConfig(Rock.SystemKey.SystemSetting.REDIS_DATABASE_NUMBER);
        }
Пример #3
0
        /// <summary>
        /// Checks the availability of the configured Redis endpoints and updates the status label.
        /// </summary>
        private void RedisEndPointAvailabilityCheck()
        {
            bool redisEnabled = SystemSettings.GetValueFromWebConfig(Rock.SystemKey.SystemSetting.REDIS_ENABLE_CACHE_CLUSTER).AsBooleanOrNull() ?? false;

            if (!redisEnabled)
            {
                spRedisStatus.Visible = false;
                return;
            }

            spRedisStatus.Visible = true;

            string[] endPoints          = SystemSettings.GetValueFromWebConfig(Rock.SystemKey.SystemSetting.REDIS_ENDPOINT_LIST).Split(',');
            int      endPointErrorCount = 0;

            string redisPassword = SystemSettings.GetValueFromWebConfig(Rock.SystemKey.SystemSetting.REDIS_PASSWORD) ?? string.Empty;

            foreach (var endPoint in endPoints)
            {
                endPointErrorCount += RockCache.IsEndPointAvailable(endPoint, redisPassword) == true ? 0 : 1;
            }

            if (endPointErrorCount == 0)
            {
                spRedisStatus.Attributes["class"] = "pull-right label label-success";
                spRedisStatus.InnerText           = "All Redis endpoints are available";
            }
            else if (endPointErrorCount < endPoints.Length)
            {
                spRedisStatus.Attributes["class"] = "pull-right label label-warning";
                spRedisStatus.InnerText           = string.Format("{0} of {1} Redis endpoints cannot connect", endPointErrorCount, endPoints.Length);
            }
            else
            {
                spRedisStatus.Attributes["class"] = "pull-right label label-danger";
                spRedisStatus.InnerText           = string.Format("All {0} {1} cannot connect", endPoints.Length, "endpoint".ToQuantity(endPoints.Length));
            }
        }