Exemplo n.º 1
0
        internal void Update(AppConfig appConfig, HashSet <string> changedSections)
        {
            // Figure out whether the data collector is interested in any of the
            // changed sections. If so, it needs to be restarted.
            IEnumerable <string> relevantChanges = Enumerable.Intersect(
                this.dataCollector.RegisteredAppConfigSections,
                changedSections);

            if (0 == relevantChanges.Count())
            {
                Utility.TraceSource.WriteInfo(
                    TraceType,
                    "Configuration change did not require the data collector for application instance {0} to be restarted.",
                    this.applicationInstanceId);
            }

            Utility.TraceSource.WriteInfo(
                TraceType,
                "Data collector for application instance {0} will be restarted because the application configuration has changed.",
                this.applicationInstanceId);

            // Dispose the current data collector
            this.dataCollector.Dispose();

            // Update the configuration
            ConfigReader.AddAppConfig(this.applicationInstanceId, appConfig);

            // Create a new data collector
            this.dataCollector = new FabricDCA(this.applicationInstanceId, this.diskSpaceManager);
        }
Exemplo n.º 2
0
        internal void RemoveService(string servicePackageName)
        {
            ServiceConfig serviceConfig = ConfigReader.GetServiceConfig(
                this.applicationInstanceId,
                servicePackageName);

            if (null == serviceConfig)
            {
                // We are not interested in this service, so there's nothing
                // to do here.
                Utility.TraceSource.WriteInfo(
                    TraceType,
                    "Deactivation of service package {0} does not require the data collector for application instance {1} to be restarted.",
                    servicePackageName,
                    this.applicationInstanceId);
                return;
            }

            Utility.TraceSource.WriteInfo(
                TraceType,
                "Data collector for application instance {0} will be restarted because service package {1} was deactivated.",
                this.applicationInstanceId,
                servicePackageName);

            // Dispose the current data collector
            this.dataCollector.Dispose();

            // Update the configuration
            ConfigReader.RemoveServiceConfig(this.applicationInstanceId, servicePackageName);

            // Create a new data collector
            this.dataCollector = new FabricDCA(this.applicationInstanceId, this.diskSpaceManager);
        }
Exemplo n.º 3
0
        internal AppInstance(string applicationInstanceId, AppConfig appConfig, string servicePackageName, ServiceConfig serviceConfig, DiskSpaceManager diskSpaceManager)
        {
            this.applicationInstanceId = applicationInstanceId;
            this.diskSpaceManager      = diskSpaceManager;

            // Make the configuration available to the application
            ConfigReader.AddAppConfig(this.applicationInstanceId, appConfig);

            if (null != servicePackageName)
            {
                ConfigReader.AddServiceConfig(this.applicationInstanceId, servicePackageName, serviceConfig);
            }

            // Create the data collector for the application instance
            this.dataCollector = new FabricDCA(this.applicationInstanceId, diskSpaceManager);
        }
Exemplo n.º 4
0
        internal void AddService(AppConfig appConfig, string servicePackageName, ServiceConfig serviceConfig)
        {
            bool restartNeeded = false;

            if (this.ServiceConfigHasChanged(servicePackageName, serviceConfig))
            {
                Utility.TraceSource.WriteInfo(
                    TraceType,
                    "Data collector for application instance {0} will be restarted because service package {1} was activated.",
                    this.applicationInstanceId,
                    servicePackageName);
                restartNeeded = true;
            }
            else if (this.AppConfigHasChanged(appConfig))
            {
                Utility.TraceSource.WriteInfo(
                    TraceType,
                    "Data collector for application instance {0} will be restarted because the application configuration has changed.",
                    this.applicationInstanceId);
                restartNeeded = true;
            }
            else
            {
                Utility.TraceSource.WriteInfo(
                    TraceType,
                    "Activation of service package {0} does not require the data collector for application instance {1} to be restarted.",
                    servicePackageName,
                    this.applicationInstanceId);
            }

            if (restartNeeded)
            {
                // Dispose the current data collector
                this.dataCollector.Dispose();

                // Update the configuration
                ConfigReader.AddAppConfig(this.applicationInstanceId, appConfig);
                ConfigReader.AddServiceConfig(this.applicationInstanceId, servicePackageName, serviceConfig);

                // Create a new data collector
                this.dataCollector = new FabricDCA(this.applicationInstanceId, this.diskSpaceManager);
            }
        }