예제 #1
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);
        }
예제 #2
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);
            }
        }