Example #1
0
 public void DisableGroup(string groupName)
 {
     using (RegistryKey registryKey = this.OpenGroupConfigKey(groupName, true))
     {
         RegUtils.SetProperty <bool>(registryKey, "IsAutomaticActionsAllowed", false);
     }
 }
Example #2
0
        public InstanceGroupConfig GetGroupConfig(string groupName, bool isFillDefaultValueIfNotExist = false)
        {
            InstanceGroupConfig instanceGroupConfig = null;

            groupName = this.ResolveGroupName(groupName);
            if (string.IsNullOrEmpty(groupName) && isFillDefaultValueIfNotExist)
            {
                groupName = "B1563499-EA40-4101-A9E6-59A8EB26FF1E";
            }
            using (RegistryKey registryKey = this.OpenGroupConfigKey(groupName, false))
            {
                if (registryKey != null || isFillDefaultValueIfNotExist)
                {
                    instanceGroupConfig = new InstanceGroupConfig();
                    instanceGroupConfig.NameResolver            = this;
                    instanceGroupConfig.Self                    = this.Self;
                    instanceGroupConfig.ComponentName           = this.componentName;
                    instanceGroupConfig.IsZeroboxMode           = this.isZeroboxMode;
                    instanceGroupConfig.Name                    = groupName;
                    instanceGroupConfig.IsExistInConfigProvider = (registryKey != null);
                    instanceGroupConfig.Identity                = string.Format("Group/{0}/{1}/{2}", this.componentName, groupName, this.Self);
                    string defaultGroupName = this.GetDefaultGroupName();
                    instanceGroupConfig.IsAutomaticActionsAllowed        = RegUtils.GetBoolProperty(registryKey, "IsAutomaticActionsAllowed", false);
                    instanceGroupConfig.IsRestartRequested               = RegUtils.GetBoolProperty(registryKey, "IsRestartRequested", false);
                    instanceGroupConfig.IsConfigurationManagedExternally = RegUtils.GetBoolProperty(registryKey, "IsConfigurationManagedExternally", false);
                    instanceGroupConfig.ConfigInProgressExpiryTime       = RegUtils.GetTimeProperty(registryKey, "ConfigInProgressExpiryTime");
                    instanceGroupConfig.IsDefaultGroup       = Utils.IsEqual(groupName, defaultGroupName, StringComparison.OrdinalIgnoreCase);
                    instanceGroupConfig.IsConfigurationReady = (DateTimeOffset.Now > instanceGroupConfig.ConfigInProgressExpiryTime);
                    instanceGroupConfig.Members  = this.GetGroupMemberConfigs(groupName);
                    instanceGroupConfig.Settings = this.GetGroupSettings(groupName);
                }
            }
            return(instanceGroupConfig);
        }
Example #3
0
 public void SetDefaultGroupName(string groupName)
 {
     using (RegistryKey registryKey = this.OpenGroupsContainerKey(true))
     {
         RegUtils.SetProperty <string>(registryKey, "DefaultGroupName", groupName);
     }
 }
Example #4
0
 public void SetRestartRequired(string groupName, bool isRestartRequired)
 {
     lock (this.locker)
     {
         using (RegistryKey registryKey = this.OpenGroupConfigKey(groupName, true))
         {
             RegUtils.SetProperty <bool>(registryKey, "IsRestartRequested", isRestartRequired);
         }
     }
 }
Example #5
0
        public string GetDefaultGroupName()
        {
            string property;

            using (RegistryKey registryKey = this.OpenGroupsContainerKey(false))
            {
                property = RegUtils.GetProperty <string>(registryKey, "DefaultGroupName", string.Empty);
            }
            return(property);
        }
Example #6
0
        internal static DateTimeOffset GetTimeProperty(RegistryKey key, string propertyName, DateTimeOffset defaultValue)
        {
            string         property = RegUtils.GetProperty <string>(key, propertyName, string.Empty);
            DateTimeOffset result;

            if (!DateTimeOffset.TryParse(property, out result))
            {
                result = defaultValue;
            }
            return(result);
        }
Example #7
0
 public void SetGroupMemberConfig(string groupName, InstanceGroupMemberConfig cfg)
 {
     lock (this.locker)
     {
         using (RegistryKey registryKey = this.OpenGroupMemberConfigKey(groupName, cfg.Name, true))
         {
             RegUtils.SetProperty <bool>(registryKey, "IsWitness", cfg.IsWitness);
             if (!string.IsNullOrEmpty(cfg.NetworkAddress))
             {
                 RegUtils.SetProperty <string>(registryKey, "NetworkAddress", cfg.NetworkAddress);
             }
         }
     }
 }
Example #8
0
 public void GetInheritableSettings(string keyName, CommonSettings settings, CommonSettings defaultSettings)
 {
     using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(keyName))
     {
         settings.InstanceProcessName                         = RegUtils.GetProperty <string>(registryKey, "InstanceProcessName", defaultSettings.InstanceProcessName);
         settings.TruncationLimit                             = RegUtils.GetProperty <int>(registryKey, "TruncationLimit", defaultSettings.TruncationLimit);
         settings.TruncationPaddingLength                     = RegUtils.GetProperty <int>(registryKey, "TruncationPaddingLength", defaultSettings.TruncationPaddingLength);
         settings.DurationToWaitBeforeRestart                 = RegUtils.GetLongPropertyAsTimeSpan(registryKey, "DurationToWaitBeforeRestartInMSec", defaultSettings.DurationToWaitBeforeRestart);
         settings.AccessEndpointPortNumber                    = RegUtils.GetProperty <int>(registryKey, "AccessEndpointPortNumber", defaultSettings.AccessEndpointPortNumber);
         settings.AccessEndpointProtocolName                  = RegUtils.GetProperty <string>(registryKey, "AccessEndpointProtocolName", defaultSettings.AccessEndpointProtocolName);
         settings.InstanceEndpointPortNumber                  = RegUtils.GetProperty <int>(registryKey, "InstanceEndpointPortNumber", defaultSettings.InstanceEndpointPortNumber);
         settings.InstanceEndpointProtocolName                = RegUtils.GetProperty <string>(registryKey, "InstanceEndpointProtocolName", defaultSettings.InstanceEndpointProtocolName);
         settings.IsAllowDynamicReconfig                      = RegUtils.GetBoolProperty(registryKey, "IsAllowDynamicReconfig", defaultSettings.IsAllowDynamicReconfig);
         settings.IsAppendOnlyMembership                      = RegUtils.GetBoolProperty(registryKey, "IsAppendOnlyMembership", defaultSettings.IsAppendOnlyMembership);
         settings.IsKillInstanceProcessWhenParentDies         = RegUtils.GetBoolProperty(registryKey, "IsKillInstanceProcessWhenParentDies", defaultSettings.IsKillInstanceProcessWhenParentDies);
         settings.StoreAccessWcfTimeout                       = RegUtils.GetWcfTimeoutProperty(registryKey, "StoreAccessWcfTimeout", defaultSettings.StoreAccessWcfTimeout);
         settings.StoreAccessHttpTimeoutInMSec                = RegUtils.GetProperty <int>(registryKey, "StoreAccessHttpTimeoutInMSec", defaultSettings.StoreAccessHttpTimeoutInMSec);
         settings.StoreInstanceWcfTimeout                     = RegUtils.GetWcfTimeoutProperty(registryKey, "StoreInstanceWcfTimeout", defaultSettings.StoreInstanceWcfTimeout);
         settings.TruncationPeriodicCheckInterval             = RegUtils.GetLongPropertyAsTimeSpan(registryKey, "TruncationPeriodicCheckIntervalInMSec", defaultSettings.TruncationPeriodicCheckInterval);
         settings.InstanceHealthCheckPeriodicInterval         = RegUtils.GetLongPropertyAsTimeSpan(registryKey, "InstanceHealthCheckPeriodicIntervalInMSec", defaultSettings.InstanceHealthCheckPeriodicInterval);
         settings.StateMachineStopTimeout                     = RegUtils.GetLongPropertyAsTimeSpan(registryKey, "StateMachineStopTimeoutInMSec", defaultSettings.StateMachineStopTimeout);
         settings.LeaderPromotionTimeout                      = RegUtils.GetLongPropertyAsTimeSpan(registryKey, "LeaderPromotionTimeoutInMSec", defaultSettings.LeaderPromotionTimeout);
         settings.PaxosCommandExecutionTimeout                = RegUtils.GetLongPropertyAsTimeSpan(registryKey, "PaxosCommandExecutionTimeoutInMSec", defaultSettings.PaxosCommandExecutionTimeout);
         settings.GroupHealthCheckDuration                    = RegUtils.GetLongPropertyAsTimeSpan(registryKey, "GroupHealthCheckDurationInMSec", defaultSettings.GroupHealthCheckDuration);
         settings.GroupHealthCheckAggressiveDuration          = RegUtils.GetLongPropertyAsTimeSpan(registryKey, "GroupHealthCheckAggressiveDurationInMSec", defaultSettings.GroupHealthCheckAggressiveDuration);
         settings.GroupStatusWaitTimeout                      = RegUtils.GetLongPropertyAsTimeSpan(registryKey, "GroupStatusWaitTimeoutInMSec", defaultSettings.GroupStatusWaitTimeout);
         settings.MemberReconfigureTimeout                    = RegUtils.GetLongPropertyAsTimeSpan(registryKey, "MemberReconfigureTimeoutInMSec", defaultSettings.MemberReconfigureTimeout);
         settings.PaxosUpdateTimeout                          = RegUtils.GetLongPropertyAsTimeSpan(registryKey, "PaxosUpdateTimeoutInMSec", defaultSettings.PaxosUpdateTimeout);
         settings.SnapshotUpdateInterval                      = RegUtils.GetLongPropertyAsTimeSpan(registryKey, "SnapshotUpdateIntervalInMSec", defaultSettings.SnapshotUpdateInterval);
         settings.PeriodicExceptionLoggingDuration            = RegUtils.GetLongPropertyAsTimeSpan(registryKey, "PeriodicExceptionLoggingDurationInMSec", defaultSettings.PeriodicExceptionLoggingDuration);
         settings.PeriodicTimeoutLoggingDuration              = RegUtils.GetLongPropertyAsTimeSpan(registryKey, "PeriodicTimeoutLoggingDurationInMSec", defaultSettings.PeriodicTimeoutLoggingDuration);
         settings.ServiceHostCloseTimeout                     = RegUtils.GetLongPropertyAsTimeSpan(registryKey, "ServiceHostCloseTimeoutInMSec", defaultSettings.ServiceHostCloseTimeout);
         settings.MaxAllowedLagToCatchup                      = RegUtils.GetProperty <int>(registryKey, "MaxAllowedLagToCatchup", defaultSettings.MaxAllowedLagToCatchup);
         settings.DefaultSnapshotFileName                     = RegUtils.GetProperty <string>(registryKey, "DefaultSnapshotFileName", defaultSettings.DefaultSnapshotFileName);
         settings.MaxEntriesToKeep                            = RegUtils.GetProperty <int>(registryKey, "MaxEntriesToKeep", defaultSettings.MaxEntriesToKeep);
         settings.MaximumAllowedInstanceNumberLag             = RegUtils.GetProperty <int>(registryKey, "MaximumAllowedInstanceNumberLag", defaultSettings.MaximumAllowedInstanceNumberLag);
         settings.DefaultHealthCheckRequiredNodePercent       = RegUtils.GetProperty <int>(registryKey, "DefaultHealthCheckRequiredNodePercent", defaultSettings.DefaultHealthCheckRequiredNodePercent);
         settings.AdditionalLogOptions                        = (LogOptions)RegUtils.GetProperty <int>(registryKey, "AdditionalLogOptions", defaultSettings.AdditionalLogOptionsAsInt);
         settings.InstanceStartSilenceDuration                = RegUtils.GetLongPropertyAsTimeSpan(registryKey, "InstanceStartSilenceDurationInMSec", defaultSettings.InstanceStartSilenceDuration);
         settings.InstanceStartHoldupDurationMaxAllowedStarts = RegUtils.GetProperty <int>(registryKey, "InstanceStartHoldupDurationMaxAllowedStarts", defaultSettings.InstanceStartHoldupDurationMaxAllowedStarts);
         settings.InstanceStartHoldUpDuration                 = RegUtils.GetLongPropertyAsTimeSpan(registryKey, "InstanceStartHoldUpDurationInMSec", defaultSettings.InstanceStartHoldUpDuration);
         settings.InstanceMemoryCommitSizeLimitInMb           = RegUtils.GetProperty <int>(registryKey, "InstanceMemoryCommitSizeLimitInMb", defaultSettings.InstanceMemoryCommitSizeLimitInMb);
         settings.IsUseHttpTransportForInstanceCommunication  = RegUtils.GetBoolProperty(registryKey, "IsUseHttpTransportForInstanceCommunication", defaultSettings.IsUseHttpTransportForInstanceCommunication);
         settings.IsUseHttpTransportForClientCommunication    = RegUtils.GetBoolProperty(registryKey, "IsUseHttpTransportForClientCommunication", defaultSettings.IsUseHttpTransportForClientCommunication);
         settings.IsUseBinarySerializerForClientCommunication = RegUtils.GetBoolProperty(registryKey, "IsUseBinarySerializerForClientCommunication", defaultSettings.IsUseBinarySerializerForClientCommunication);
         settings.IsUseEncryption                             = RegUtils.GetBoolProperty(registryKey, "IsUseEncryption", defaultSettings.IsUseEncryption);
         settings.StartupDelay = RegUtils.GetLongPropertyAsTimeSpan(registryKey, "StartupDelayInMSec", defaultSettings.StartupDelay);
     }
 }
Example #9
0
        internal static bool GetBoolProperty(RegistryKey key, string propertyName, bool defaultValue = false)
        {
            bool   result   = defaultValue;
            object property = RegUtils.GetProperty <object>(key, propertyName, null);

            if (property is int)
            {
                result = ((int)property > 0);
            }
            else if (property is string && !bool.TryParse(property as string, out result))
            {
                result = defaultValue;
            }
            return(result);
        }
Example #10
0
        public InstanceGroupMemberConfig[] GetGroupMemberConfigs(string groupName)
        {
            List <InstanceGroupMemberConfig> list = new List <InstanceGroupMemberConfig>();

            string[] groupMemberNames = this.GetGroupMemberNames(groupName);
            foreach (string text in groupMemberNames)
            {
                InstanceGroupMemberConfig instanceGroupMemberConfig = new InstanceGroupMemberConfig
                {
                    Name = text
                };
                using (RegistryKey registryKey = this.OpenGroupMemberConfigKey(groupName, text, false))
                {
                    instanceGroupMemberConfig.NetworkAddress      = RegUtils.GetProperty <string>(registryKey, "NetworkAddress", string.Empty);
                    instanceGroupMemberConfig.IsWitness           = RegUtils.GetBoolProperty(registryKey, "IsWitness", false);
                    instanceGroupMemberConfig.IsManagedExternally = RegUtils.GetBoolProperty(registryKey, "IsManagedExternally", false);
                    list.Add(instanceGroupMemberConfig);
                }
            }
            return(list.ToArray());
        }
Example #11
0
        public InstanceManagerConfig GetManagerConfig()
        {
            InstanceManagerConfig instanceManagerConfig = new InstanceManagerConfig();

            instanceManagerConfig.NameResolver   = this;
            instanceManagerConfig.Self           = this.Self;
            instanceManagerConfig.ComponentName  = this.componentName;
            instanceManagerConfig.IsZeroboxMode  = this.isZeroboxMode;
            instanceManagerConfig.NetworkAddress = instanceManagerConfig.NameResolver.ResolveNameBestEffort(this.Self);
            instanceManagerConfig.DefaultTimeout = new WcfTimeout();
            using (RegistryKey registryKey = this.OpenManagerConfigKey(false))
            {
                instanceManagerConfig.BaseStorageDir          = Environment.ExpandEnvironmentVariables(RegUtils.GetProperty <string>(registryKey, "BaseStorageDir", this.DefaultStorageBaseDir));
                instanceManagerConfig.InstanceMonitorInterval = RegUtils.GetLongPropertyAsTimeSpan(registryKey, "InstanceMonitorIntervalInMSec", TimeSpan.FromSeconds(15.0));
                instanceManagerConfig.EndpointPortNumber      = RegUtils.GetProperty <int>(registryKey, "EndpointPortNumber", 808);
                instanceManagerConfig.EndpointProtocolName    = RegUtils.GetProperty <string>(registryKey, "EndpointProtocolName", "net.tcp");
                instanceManagerConfig.DefaultTimeout          = RegUtils.GetWcfTimeoutProperty(registryKey, "DefaultTimeout", new WcfTimeout());
                instanceManagerConfig.ManagerStopTimeout      = RegUtils.GetLongPropertyAsTimeSpan(registryKey, "ManagerStopTimeoutInMSec", TimeSpan.FromMinutes(1.0));
                CommonSettings defaultSettings = this.CreateDefaultCommonSettings(instanceManagerConfig.EndpointPortNumber, instanceManagerConfig.EndpointProtocolName, instanceManagerConfig.DefaultTimeout);
                instanceManagerConfig.Settings = new CommonSettings();
                this.GetInheritableSettings(this.GetManagerSettingsKeyName(), instanceManagerConfig.Settings, defaultSettings);
            }
            return(instanceManagerConfig);
        }
Example #12
0
        internal static WcfTimeout GetWcfTimeoutProperty(RegistryKey key, string propertyName, WcfTimeout defaultTimeout)
        {
            string property = RegUtils.GetProperty <string>(key, propertyName, string.Empty);

            return(WcfTimeout.Parse(property, defaultTimeout));
        }
Example #13
0
 internal static DateTimeOffset GetTimeProperty(RegistryKey key, string propertyName)
 {
     return(RegUtils.GetTimeProperty(key, propertyName, DateTimeOffset.MinValue));
 }
Example #14
0
        public InstanceGroupSettings GetGroupSettings(string groupName)
        {
            InstanceGroupSettings instanceGroupSettings = new InstanceGroupSettings();

            this.GetInheritableSettings(this.GetGroupSettingsKeyName(groupName), instanceGroupSettings, this.ManagerConfig.Settings);
            using (RegistryKey registryKey = this.OpenGroupSettingsKey(groupName, false))
            {
                instanceGroupSettings.PaxosStorageDir    = Environment.ExpandEnvironmentVariables(RegUtils.GetProperty <string>(registryKey, "PaxosStorageDir", this.ConstructDefaultStorageDir(groupName, "Paxos")));
                instanceGroupSettings.SnapshotStorageDir = Environment.ExpandEnvironmentVariables(RegUtils.GetProperty <string>(registryKey, "SnapshotStorageDir", this.ConstructDefaultStorageDir(groupName, "Snapshot")));
            }
            return(instanceGroupSettings);
        }