public FaultAnalysisServiceImpl()
        {
            System.Fabric.Common.NativeConfigStore configStore = System.Fabric.Common.NativeConfigStore.FabricGetConfigStore();
            TestabilityTrace.TraceSource.WriteInfo(TraceType, "'{0}', '{1}'", FASConstants.FaultAnalysisServiceConfigSectionName, FASConstants.StopNodeMinDurationInSecondsName);
            string minStopDurationAsString = configStore.ReadUnencryptedString(FASConstants.FaultAnalysisServiceConfigSectionName, FASConstants.StopNodeMinDurationInSecondsName);

            this.minStopDurationInSeconds = string.IsNullOrEmpty(minStopDurationAsString) ? FASConstants.DefaultStopNodeMinDurationInSeconds : int.Parse(minStopDurationAsString);

            TestabilityTrace.TraceSource.WriteInfo(TraceType, "'{0}', '{1}', '{2}'", FASConstants.FaultAnalysisServiceConfigSectionName, FASConstants.StopNodeMinDurationInSecondsName, this.minStopDurationInSeconds);

            string maxStopDurationAsString = configStore.ReadUnencryptedString(FASConstants.FaultAnalysisServiceConfigSectionName, FASConstants.StopNodeMaxDurationInSecondsName);

            this.maxStopDurationInSeconds = string.IsNullOrEmpty(maxStopDurationAsString) ? FASConstants.DefaultStopNodeMaxDurationInSeconds : int.Parse(maxStopDurationAsString);
            TestabilityTrace.TraceSource.WriteInfo(TraceType, "'{0}', '{1}', '{2}'", FASConstants.FaultAnalysisServiceConfigSectionName, FASConstants.StopNodeMaxDurationInSecondsName, this.maxStopDurationInSeconds);
        }
Esempio n. 2
0
        private static StatefulServiceBase ReadConfiguration(StatefulServiceContext context)
        {
            GatewayResourceManagerTrace.TraceSource.WriteInfo(TraceType, "ReadConfiguration");
            System.Fabric.Common.NativeConfigStore configStore   = System.Fabric.Common.NativeConfigStore.FabricGetConfigStore();
            string fabricGatewayResourceManagerReplicatorAddress = configStore.ReadUnencryptedString("FabricNode", "GatewayResourceManagerReplicatorAddress");

            return(new FabricGatewayResourceManager(context, fabricGatewayResourceManagerReplicatorAddress));
        }
Esempio n. 3
0
        private static StatefulServiceBase ReadConfiguration(StatefulServiceContext context)
        {
            System.Fabric.Common.NativeConfigStore configStore = System.Fabric.Common.NativeConfigStore.FabricGetConfigStore();
            string faultAnalysisServiceReplicatorAddress       = configStore.ReadUnencryptedString("FabricNode", "FaultAnalysisServiceReplicatorAddress");
            bool   flag = EnableEndpointV2Utility.GetValue(configStore);

            return(new FaultAnalysisService(context, faultAnalysisServiceReplicatorAddress, flag));
        }
Esempio n. 4
0
        private static StatefulServiceBase ReadConfiguration(StatefulServiceContext context)
        {
            UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "ReadConfiguration");
            System.Fabric.Common.NativeConfigStore configStore        = System.Fabric.Common.NativeConfigStore.FabricGetConfigStore();
            string fabricUpgradeOrchestrationServiceReplicatorAddress = configStore.ReadUnencryptedString("FabricNode", "UpgradeOrchestrationServiceReplicatorAddress");
            bool   flag = EnableEndpointV2Utility.GetValue(configStore);

            return(new FabricUpgradeOrchestrationService(context, fabricUpgradeOrchestrationServiceReplicatorAddress, flag));
        }
        internal static StandAloneCluster ConstructClusterFromJson(StandAloneInstallerJsonModelBase jsonModel, FabricNativeConfigStore configStore)
        {
            UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Creating userconfig, cluster topology, adminconfig.");

            var userConfig      = jsonModel.GetUserConfig();
            var clusterTopology = jsonModel.GetClusterTopology();
            var adminConfig     = new StandaloneAdminConfig();
            var logger          = new StandAloneTraceLogger("StandAloneDeploymentManager");

            UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Creating new StandAlone cluster resource.");

            var clusterId       = configStore.ReadUnencryptedString(Constants.SectionName, Constants.ClusterIdParameterName);
            var clusterResource = new StandAloneCluster(adminConfig, userConfig, clusterTopology, clusterId, logger);

            return(clusterResource);
        }
        public bool ReadUnencryptedBool(string sectionName, string keyName, FabricEvents.ExtensionsEvents traceSource, string traceType, bool throwIfInvalid)
        {
            NativeConfigStore configStore      = NativeConfigStore.FabricGetConfigStore();
            string            propertyValueStr = configStore.ReadUnencryptedString(sectionName, keyName);
            bool propertyValue = false;

            traceSource.WriteInfo(traceType, "{0} {1}", keyName, propertyValueStr);
            if (!bool.TryParse(propertyValueStr, out propertyValue))
            {
                string message = string.Format("{0} could not parse: {1}", keyName, propertyValueStr);
                traceSource.WriteError(traceType, message);
                if (throwIfInvalid)
                {
                    throw new InvalidDataException(message);
                }
                else
                {
                    propertyValue = false;
                }
            }

            return(propertyValue);
        }
        private async Task InitializeAsync(CancellationToken cancellationToken)
        {
            System.Fabric.Common.NativeConfigStore configStore = System.Fabric.Common.NativeConfigStore.FabricGetConfigStore();
            string isTestModeEnabled = configStore.ReadUnencryptedString(FASConstants.FaultAnalysisServiceConfigSectionName, "TestModeEnabled");

            if (isTestModeEnabled.ToLowerInvariant() == "true")
            {
                TestabilityTrace.TraceSource.WriteInfo(FaultAnalysisServiceTraceType, "Enabling internal test mode");
                this.IsTestMode = true;
            }

            string apiTestModeString = configStore.ReadUnencryptedString(FASConstants.FaultAnalysisServiceConfigSectionName, "ApiTestMode");
            int    apiTestMode;

            if (!int.TryParse(apiTestModeString, out apiTestMode))
            {
                apiTestMode = 0;
            }

            string requestTimeout = configStore.ReadUnencryptedString(FASConstants.FaultAnalysisServiceConfigSectionName, FASConstants.RequestTimeoutInSecondsName);
            int    requestTimeoutInSecondsAsInt = string.IsNullOrEmpty(requestTimeout) ? FASConstants.DefaultRequestTimeoutInSeconds : int.Parse(requestTimeout);

            string operationTimeout = configStore.ReadUnencryptedString(FASConstants.FaultAnalysisServiceConfigSectionName, FASConstants.OperationTimeoutInSecondsName);
            int    operationTimeoutInSecondsAsInt = string.IsNullOrEmpty(operationTimeout) ? FASConstants.DefaultOperationTimeoutInSeconds : int.Parse(operationTimeout);

            TestabilityTrace.TraceSource.WriteInfo(
                FaultAnalysisServiceTraceType,
                "Setting requestTimeout='{0}' and operationTimeout='{1}'",
                TimeSpan.FromSeconds(requestTimeoutInSecondsAsInt),
                TimeSpan.FromSeconds(operationTimeoutInSecondsAsInt));

            string maxStoredActionCount       = configStore.ReadUnencryptedString(FASConstants.FaultAnalysisServiceConfigSectionName, FASConstants.MaxStoredActionCountName);
            long   maxStoredActionCountAsLong = string.IsNullOrEmpty(maxStoredActionCount) ? FASConstants.DefaultMaxStoredActionCount : long.Parse(maxStoredActionCount);

            string storedActionCleanupIntervalInSeconds      = configStore.ReadUnencryptedString(FASConstants.FaultAnalysisServiceConfigSectionName, FASConstants.StoredActionCleanupIntervalInSecondsName);
            int    storedActionCleanupIntervalInSecondsAsInt = string.IsNullOrEmpty(storedActionCleanupIntervalInSeconds) ? FASConstants.DefaultStoredActionCleanupIntervalInSeconds : int.Parse(storedActionCleanupIntervalInSeconds);

            string completedActionKeepDurationInSeconds      = configStore.ReadUnencryptedString(FASConstants.FaultAnalysisServiceConfigSectionName, FASConstants.CompletedActionKeepDurationInSecondsName);
            int    completedActionKeepDurationInSecondsAsInt = string.IsNullOrEmpty(completedActionKeepDurationInSeconds) ? FASConstants.DefaultCompletedActionKeepDurationInSeconds : int.Parse(completedActionKeepDurationInSeconds);

            TestabilityTrace.TraceSource.WriteInfo(
                FaultAnalysisServiceTraceType,
                "MaxStoredActionCount={0}, StoredActionCleanupIntervalInSeconds={1}, CompletedActionKeepDurationInSecondsName={2}",
                maxStoredActionCountAsLong,
                storedActionCleanupIntervalInSecondsAsInt,
                completedActionKeepDurationInSecondsAsInt);

            string commandStepRetryBackoffInSeconds      = configStore.ReadUnencryptedString(FASConstants.FaultAnalysisServiceConfigSectionName, FASConstants.CommandStepRetryBackoffInSecondsName);
            int    commandStepRetryBackoffInSecondsAsInt = string.IsNullOrEmpty(commandStepRetryBackoffInSeconds) ? FASConstants.DefaultCommandStepRetryBackoffInSeconds : int.Parse(commandStepRetryBackoffInSeconds);

            TestabilityTrace.TraceSource.WriteInfo(FaultAnalysisServiceTraceType, "Read from config commandStepRetryBackoffInSeconds='{0}'", commandStepRetryBackoffInSecondsAsInt);

            string concurrentRequestsAsString = configStore.ReadUnencryptedString(FASConstants.FaultAnalysisServiceConfigSectionName, FASConstants.ConcurrentRequestsName);
            int    concurrentRequests         = string.IsNullOrEmpty(concurrentRequestsAsString) ? FASConstants.DefaultConcurrentRequests : int.Parse(concurrentRequestsAsString);

            TestabilityTrace.TraceSource.WriteInfo(FaultAnalysisServiceTraceType, "Read from config concurrentRequests='{0}'", concurrentRequests);

            string dataLossCheckWaitDurationInSecondsAsString = configStore.ReadUnencryptedString(FASConstants.FaultAnalysisServiceConfigSectionName, FASConstants.DataLossCheckWaitDurationInSecondsName);
            int    dataLossCheckWaitDurationInSeconds         = string.IsNullOrEmpty(dataLossCheckWaitDurationInSecondsAsString) ? FASConstants.DefaultDataLossCheckWaitDurationInSeconds : int.Parse(dataLossCheckWaitDurationInSecondsAsString);

            TestabilityTrace.TraceSource.WriteInfo(FaultAnalysisServiceTraceType, "Read from config dataLossCheckWaitDurationInSeconds='{0}'", dataLossCheckWaitDurationInSeconds);

            string dataLossCheckPollIntervalInSecondsAsString = configStore.ReadUnencryptedString(FASConstants.FaultAnalysisServiceConfigSectionName, FASConstants.DataLossCheckPollIntervalInSecondsName);
            int    dataLossCheckPollIntervalInSeconds         = string.IsNullOrEmpty(dataLossCheckPollIntervalInSecondsAsString) ? FASConstants.DefaultDataLossCheckPollIntervalInSeconds : int.Parse(dataLossCheckPollIntervalInSecondsAsString);

            TestabilityTrace.TraceSource.WriteInfo(FaultAnalysisServiceTraceType, "Read from config dataLossCheckPollIntervalInSeconds='{0}'", dataLossCheckPollIntervalInSeconds);

            string replicaDropWaitDurationInSecondsAsString = configStore.ReadUnencryptedString(FASConstants.FaultAnalysisServiceConfigSectionName, FASConstants.ReplicaDropWaitDurationInSecondsName);
            int    replicaDropWaitDurationInSeconds         = string.IsNullOrEmpty(replicaDropWaitDurationInSecondsAsString) ? FASConstants.DefaultReplicaDropWaitDurationInSeconds : int.Parse(replicaDropWaitDurationInSecondsAsString);

            TestabilityTrace.TraceSource.WriteInfo(FaultAnalysisServiceTraceType, "Read from config replicaDropWaitDurationInSeconds='{0}'", replicaDropWaitDurationInSeconds);

            string chaosTelemetrySamplingProbabilityAsString = configStore.ReadUnencryptedString(FASConstants.FaultAnalysisServiceConfigSectionName, FASConstants.ChaosTelemetrySamplingProbabilityConfigKeyName);
            double chaosTelemetrySamplingProbability         = string.IsNullOrEmpty(chaosTelemetrySamplingProbabilityAsString) ? FASConstants.DefaultChaosTelemetrySamplingProbability : double.Parse(chaosTelemetrySamplingProbabilityAsString);

            TestabilityTrace.TraceSource.WriteInfo(FaultAnalysisServiceTraceType, "Read from config chaosTelemetrySamplingProbability='{0}'", chaosTelemetrySamplingProbability);

            string chaosTelemetryReportPeriodInSecondsAsString = configStore.ReadUnencryptedString(FASConstants.FaultAnalysisServiceConfigSectionName, FASConstants.ChaostelemetryReportPeriodInSecondsConfigKeyName);
            int    chaostelemetryReportPeriodInSeconds         = string.IsNullOrEmpty(chaosTelemetryReportPeriodInSecondsAsString) ? FASConstants.DefaultTelemetryReportPeriodInSeconds : int.Parse(chaosTelemetryReportPeriodInSecondsAsString);

            TestabilityTrace.TraceSource.WriteInfo(FaultAnalysisServiceTraceType, "Read from config chaostelemetryReportPeriodInSeconds='{0}'", chaostelemetryReportPeriodInSeconds);

            TestabilityTrace.TraceSource.WriteInfo(FaultAnalysisServiceTraceType, "Creating action tables");
            var actionTable = await this.StateManager.GetOrAddAsync <IReliableDictionary <Guid, byte[]> >(FASConstants.ActionReliableDictionaryName).ConfigureAwait(false);

            var historyTable = await this.StateManager.GetOrAddAsync <IReliableDictionary <Guid, byte[]> >(FASConstants.HistoryReliableDictionaryName).ConfigureAwait(false);

            var stoppedNodeTable = await this.StateManager.GetOrAddAsync <IReliableDictionary <string, bool> >(FASConstants.StoppedNodeTable);

            TestabilityTrace.TraceSource.WriteInfo(FaultAnalysisServiceTraceType, "Creating ActionStore");
            this.actionStore = new ActionStore(
                this.StateManager,
                this.Partition,
                actionTable,
                historyTable,
                stoppedNodeTable,
                maxStoredActionCountAsLong,
                storedActionCleanupIntervalInSecondsAsInt,
                completedActionKeepDurationInSecondsAsInt,
                this.IsTestMode,
                cancellationToken);

            FabricClient fabricClient = new FabricClient();

            this.engine           = new ReliableFaultsEngine(this.actionStore, this.IsTestMode, this.Partition, commandStepRetryBackoffInSecondsAsInt);
            this.messageProcessor = new FaultAnalysisServiceMessageProcessor(
                this.Partition,
                fabricClient,
                this.engine,
                this.actionStore,
                this.StateManager,
                stoppedNodeTable,
                TimeSpan.FromSeconds(requestTimeoutInSecondsAsInt),
                TimeSpan.FromSeconds(operationTimeoutInSecondsAsInt),
                concurrentRequests,
                dataLossCheckWaitDurationInSeconds,
                dataLossCheckPollIntervalInSeconds,
                replicaDropWaitDurationInSeconds,
                cancellationToken);

            string maxStoredChaosEventCleanupIntervalInSeconds      = configStore.ReadUnencryptedString(FASConstants.FaultAnalysisServiceConfigSectionName, FASConstants.StoredChaosEventCleanupIntervalInSecondsConfigName);
            int    maxStoredChaosEventCleanupIntervalInSecondsAsInt = string.IsNullOrEmpty(maxStoredChaosEventCleanupIntervalInSeconds) ? FASConstants.StoredChaosEventCleanupIntervalInSecondsDefault : int.Parse(maxStoredChaosEventCleanupIntervalInSeconds);

            string maxStoredChaosEventCount      = configStore.ReadUnencryptedString(FASConstants.FaultAnalysisServiceConfigSectionName, FASConstants.MaxStoredChaosEventCountConfigName);
            int    maxStoredChaosEventCountAsInt = string.IsNullOrEmpty(maxStoredChaosEventCount) ? FASConstants.MaxStoredChaosEventCountDefault : int.Parse(maxStoredChaosEventCount);

            this.chaosMessageProcessor = new ChaosMessageProcessor(
                this.StateManager,
                apiTestMode,
                maxStoredChaosEventCleanupIntervalInSecondsAsInt,
                maxStoredChaosEventCountAsInt,
                chaosTelemetrySamplingProbability,
                chaostelemetryReportPeriodInSeconds,
                this.Partition,
                fabricClient,
                this.scheduler,
                cancellationToken);

            await this.messageProcessor.ResumePendingActionsAsync(fabricClient, cancellationToken).ConfigureAwait(false);

            this.faultAnalysisServiceImpl.MessageProcessor = this.messageProcessor;

            this.faultAnalysisServiceImpl.ChaosMessageProcessor = this.chaosMessageProcessor;
            this.faultAnalysisServiceImpl.LoadActionMapping();

            await this.scheduler.InitializeAsync(fabricClient, this.chaosMessageProcessor, cancellationToken).ConfigureAwait(false);

            TestabilityTrace.TraceSource.WriteInfo(FaultAnalysisServiceTraceType, "Done initializing engine");

            await this.InitClusterAnalysisEngineAsync(fabricClient, configStore, cancellationToken).ConfigureAwait(false);
        }