internal AppInstanceEtlFileDataReader( string directory, ServicePackageTableBackup tableBackup, ServicePackageTableManager.AddOrUpdateHandler addOrUpdateServicePackageHandler, ServicePackageTableManager.RemoveHandler removeServicePackageHandler) : base(addOrUpdateServicePackageHandler, removeServicePackageHandler) { this.etlDirectory = directory; this.tableBackup = tableBackup; this.currentEtlReadIntervalMillisec = TimeSpan.MaxValue; this.currentEtlFileFlushInterval = TimeSpan.MaxValue; this.currentAppEtwTracesDeletionAgeMinutes = TimeSpan.MaxValue; // Start reading events from the ETL file. this.etlReadTimer = new DcaTimer( AppInstanceEtlReadTimerId, this.Read, this.GetEtlReadInterval()); this.etlReadTimer.Start(); // Create a timer to periodically delete old ETL files var oldDataDeletionInterval = TimeSpan.FromSeconds(Utility.GetUnencryptedConfigValue( ConfigReader.DiagnosticsSectionName, TestOnlyAppDataDeletionIntervalSecondsParamName, (int)DefaultOldDataDeletionInterval.TotalSeconds)); Utility.TraceSource.WriteInfo( TraceType, "Interval at which we check for old data to delete: {0} seconds.", oldDataDeletionInterval); this.oldDataDeletionTimer = new DcaTimer( OldDataDeletionTimerId, this.DeleteOldEtlFiles, oldDataDeletionInterval); this.oldDataDeletionTimer.Start(); }
internal ServicePackageTableManager(AppInstanceManager appInstanceMgr) { this.applicationInstanceManager = appInstanceMgr; this.servicePackageTable = new ServicePackageTable(); // Get the interval at which we need to read ETL files int servicePackageNotificationIntervalSeconds = Utility.GetUnencryptedConfigValue( HostingSectionName, ServicePackageNotificationIntervalInSecondsParamName, DefaultServicePackageNotificationIntervalInSeconds); this.maxServicePackageInactiveTimeSeconds = servicePackageNotificationIntervalSeconds * MaxServicePackageInactiveTimeMultiplier; Utility.TraceSource.WriteInfo( TraceType, "Interval at which we check for inactive service packages: {0} seconds.", servicePackageNotificationIntervalSeconds); Utility.TraceSource.WriteInfo( TraceType, "Maximum time for which a service package can remain inactive before being deleted: {0} seconds.", this.maxServicePackageInactiveTimeSeconds); // Create the folder where the backup files are stored string tableBackupDirectory = Path.Combine( Utility.LogDirectory, AppInstanceDataDirName, AppInstanceTableDirName); FabricDirectory.CreateDirectory(tableBackupDirectory); // Initialize the application activation table AppActivationTable.Initialize(tableBackupDirectory); // Retrieve the file where we last saved the service package table this.tableBackup = new ServicePackageTableBackup( tableBackupDirectory, this.AddOrUpdateServicePackage); // Initialize the service package table from the file that we last saved. if (false == this.tableBackup.Read()) { Utility.TraceSource.WriteError( TraceType, "Unable to initialize service package table from backup file on disk."); } // Initialize the timestamp up to which ETW events can be read Utility.ApplicationEtwTracesEndTime = this.tableBackup.LatestBackupTime.Timestamp; // Compute the directory containing ETL files containing information about // application instances string etlFileDirectory = Path.Combine( Utility.LogDirectory, AppInstanceDataDirName, AppInstanceDataEtlDirName); FabricDirectory.CreateDirectory(etlFileDirectory); #if !DotNetCoreClrLinux // Create the object that reads events from ETL files. this.etlFileReader = new AppInstanceEtlFileDataReader( etlFileDirectory, this.tableBackup, this.AddOrUpdateServicePackage, this.RemoveServicePackage); #endif long inactiveServicePackageScanIntervalMillisec = ((long)servicePackageNotificationIntervalSeconds) * 1000; this.inactiveServicePackageScanTimer = new DcaTimer( InactiveServicePackageScanTimerId, this.MarkInactiveServicePackagesForDeletion, inactiveServicePackageScanIntervalMillisec); this.inactiveServicePackageScanTimer.Start(); }