private ReliableStateManagerConfiguration( ReliableStateManagerReplicatorSettings replicatorSettings, string configPackageName, string replicatorSecuritySectionName, string replicatorSettingsSectionName, Func<Task> onInitializeStateSerializersEvent) { this.ReplicatorSettings = replicatorSettings; this.ConfigPackageName = configPackageName; this.ReplicatorSecuritySectionName = replicatorSecuritySectionName; this.ReplicatorSettingsSectionName = replicatorSettingsSectionName; this.OnInitializeStateSerializersEvent = onInitializeStateSerializersEvent ?? (() => Task.FromResult(true)); }
/// <summary> /// Checks for equality of setting values. /// </summary> /// <param name="old">Old settings.</param> /// <param name="updated">Updated settings.</param> /// <returns> /// TRUE if the settings are equivalent. /// </returns> private static bool InternalEquals(ReliableStateManagerReplicatorSettings old, ReliableStateManagerReplicatorSettings updated) { // compare only the V2 settings. var areEqual = true; if (!string.IsNullOrEmpty(updated.SharedLogId)) { areEqual = !string.IsNullOrEmpty(old.SharedLogId) && (old.SharedLogId == updated.SharedLogId); } if (areEqual && !string.IsNullOrEmpty(updated.SharedLogPath)) { areEqual = !string.IsNullOrEmpty(old.SharedLogPath) && (old.SharedLogPath == updated.SharedLogPath); } if (areEqual && updated.MaxStreamSizeInMB.HasValue) { areEqual = old.MaxStreamSizeInMB.HasValue && (old.MaxStreamSizeInMB.Value == updated.MaxStreamSizeInMB.Value); } if (areEqual && updated.MaxRecordSizeInKB.HasValue) { areEqual = old.MaxRecordSizeInKB.HasValue && (old.MaxRecordSizeInKB.Value == updated.MaxRecordSizeInKB.Value); } if (areEqual && updated.MaxMetadataSizeInKB.HasValue) { areEqual = old.MaxMetadataSizeInKB.HasValue && (old.MaxMetadataSizeInKB.Value == updated.MaxMetadataSizeInKB.Value); } if (areEqual && updated.OptimizeForLocalSSD.HasValue) { areEqual = old.OptimizeForLocalSSD.HasValue && (old.OptimizeForLocalSSD.Value == updated.OptimizeForLocalSSD.Value); } if (areEqual && updated.OptimizeLogForLowerDiskUsage.HasValue) { areEqual = old.OptimizeLogForLowerDiskUsage.HasValue && (old.OptimizeLogForLowerDiskUsage.Value == updated.OptimizeLogForLowerDiskUsage.Value); } if (areEqual && updated.CheckpointThresholdInMB.HasValue) { areEqual = old.CheckpointThresholdInMB.HasValue && (old.CheckpointThresholdInMB.Value == updated.CheckpointThresholdInMB.Value); } if (areEqual && updated.MaxAccumulatedBackupLogSizeInMB.HasValue) { areEqual = old.MaxAccumulatedBackupLogSizeInMB.HasValue && (old.MaxAccumulatedBackupLogSizeInMB.Value == updated.MaxAccumulatedBackupLogSizeInMB.Value); } if (areEqual && updated.MinLogSizeInMB.HasValue) { areEqual = old.MinLogSizeInMB.HasValue && (old.MinLogSizeInMB.Value == updated.MinLogSizeInMB.Value); } if (areEqual && updated.TruncationThresholdFactor.HasValue) { areEqual = old.TruncationThresholdFactor.HasValue && (old.TruncationThresholdFactor.Value == updated.TruncationThresholdFactor.Value); } if (areEqual && updated.ThrottlingThresholdFactor.HasValue) { areEqual = old.ThrottlingThresholdFactor.HasValue && (old.ThrottlingThresholdFactor.Value == updated.ThrottlingThresholdFactor.Value); } if (areEqual && updated.SlowApiMonitoringDuration.HasValue) { areEqual = old.SlowApiMonitoringDuration.HasValue && (old.SlowApiMonitoringDuration == updated.SlowApiMonitoringDuration); } #if !DotNetCoreClr // 12529905 - Disable new configuration for LogTruncationIntervalSeconds in CoreCLR if (areEqual && updated.LogTruncationIntervalSeconds.HasValue) { areEqual = old.LogTruncationIntervalSeconds.HasValue && (old.LogTruncationIntervalSeconds == updated.LogTruncationIntervalSeconds); } if (areEqual && updated.EnableIncrementalBackupsAcrossReplicas.HasValue) { areEqual = old.EnableIncrementalBackupsAcrossReplicas.HasValue && (old.EnableIncrementalBackupsAcrossReplicas == updated.EnableIncrementalBackupsAcrossReplicas); } #endif return(areEqual); }
private ReliableStateManagerReplicatorSettings LoadReplicatorSettingsFromConfigPackage(bool addChangeListener) { ReliableStateManagerReplicatorSettings settings = null; var configPackage = this.GetConfigurationPackage(); if (configPackage == null) { settings = new ReliableStateManagerReplicatorSettings(); } else { if (string.IsNullOrEmpty(this._configuration.ReplicatorSettingsSectionName) || !configPackage.Settings.Sections.Contains(this._configuration.ReplicatorSettingsSectionName)) { DataImplTrace.Source.WriteWarningWithId( TraceType, this._traceId, "Using default replicator settings, unable to load replicator settings config section named '{0}' from config package named '{1}'.", this._configuration.ReplicatorSettingsSectionName, this._configuration.ConfigPackageName); settings = new ReliableStateManagerReplicatorSettings(); } else { DataImplTrace.Source.WriteInfoWithId( TraceType, this._traceId, "Loading replicator settings using <config package name: '{0}', settings section name: '{1}'>", this._configuration.ConfigPackageName, this._configuration.ReplicatorSettingsSectionName); settings = ReliableStateManagerReplicatorSettingsUtil.LoadFrom( this.InitializationParameters.CodePackageActivationContext, this._configuration.ConfigPackageName, this._configuration.ReplicatorSettingsSectionName); } // SecurityCredentials.LoadFrom doesn't return the correct value when CredentialType is None in config. todo: find bug# // To workaround this bug, only read replicator security settings if CredentialType is present and not explicitly None. const string replicatorCredentialTypeName = "CredentialType"; if (string.IsNullOrEmpty(this._configuration.ReplicatorSecuritySectionName) || !configPackage.Settings.Sections.Contains(this._configuration.ReplicatorSecuritySectionName) || !configPackage.Settings.Sections[this._configuration.ReplicatorSecuritySectionName].Parameters.Contains(replicatorCredentialTypeName) || configPackage.Settings.Sections[this._configuration.ReplicatorSecuritySectionName].Parameters[replicatorCredentialTypeName].Value.Equals( "None", StringComparison.OrdinalIgnoreCase)) { DataImplTrace.Source.WriteWarningWithId( TraceType, this._traceId, "Using default replicator security settings, unable to load replicator security settings config section named '{0}' from config package named '{1}'.", this._configuration.ReplicatorSecuritySectionName, this._configuration.ConfigPackageName); } else { if (addChangeListener) { this.InitializationParameters.CodePackageActivationContext.ConfigurationPackageModifiedEvent += this.OnConfigurationPackageModified; } settings.SecurityCredentials = SecurityCredentials.LoadFrom( this.InitializationParameters.CodePackageActivationContext, this._configuration.ConfigPackageName, this._configuration.ReplicatorSecuritySectionName); } } if (string.IsNullOrWhiteSpace(settings.ReplicatorAddress)) { settings.ReplicatorAddress = this.TryGetDefaultReplicatorAddress(); } return(settings); }
/// <summary> /// Create a new ReliableStateManagerConfiguration. /// </summary> /// <param name="replicatorSettings">Replicator settings used to initialize the ReliableStateManager.</param> /// <param name="onInitializeStateSerializersEvent"> /// Optional callback which will fire when custom serializers should be added. /// Used to set the <see cref="OnInitializeStateSerializersEvent"/> property. /// </param> public ReliableStateManagerConfiguration( ReliableStateManagerReplicatorSettings replicatorSettings, Func<Task> onInitializeStateSerializersEvent = null) : this(replicatorSettings, null, null, null, onInitializeStateSerializersEvent) { }