public LttProducer( DiskSpaceManager diskSpaceManager, ITraceEventSourceFactory traceEventSourceFactory, ProducerInitializationParameters initParam) { this.logSourceId = string.Concat(initParam.ApplicationInstanceId, "_", initParam.SectionName); this.AppInstanceId = initParam.ApplicationInstanceId; this.traceSource = traceEventSourceFactory.CreateTraceEventSource(FabricEvents.Tasks.FabricDCA); this.serviceConfigSections = new List <string>(); this.consumerSinks = initParam.ConsumerSinks; // Read the timer config value from dca section var configReader = new ConfigReader(initParam.ApplicationInstanceId); long lttReadIntervalMinutes = configReader.GetUnencryptedConfigValue( initParam.SectionName, LttProducerConstants.LttReadIntervalParamName, LttProducerConstants.DefaultLttReadIntervalMinutes); if (initParam.ApplicationInstanceId == Utility.WindowsFabricApplicationInstanceId) { this.CreateWindowsFabricLttProducerWorkerInfo(initParam, lttReadIntervalMinutes); } else { this.CreateAppProducerWorkerInfo(initParam, lttReadIntervalMinutes); } }
protected EventProcessor(ITraceEventSourceFactory traceEventSourceFactory, string logSourceId) { this.TraceSource = traceEventSourceFactory.CreateTraceEventSource(FabricEvents.Tasks.FabricDCA); this.LogSourceId = logSourceId; this.Stopping = false; this.Filter = null; this.FilterLock = new object(); this.EtlProducerLock = new object(); // Initialize pending events this.pendingEtwEvents.EventList = new Queue <DecodedEventWrapper>(); this.ResetPendingEvents(); }
internal EtlInMemoryProducer( DiskSpaceManager diskSpaceManager, IEtlInMemoryProducerConfigReaderFactory configReaderFactory, ITraceFileEventReaderFactory traceFileEventReaderFactory, ITraceEventSourceFactory traceEventSourceFactory, ProducerInitializationParameters initParam) { this.diskSpaceManager = diskSpaceManager; this.traceFileEventReaderFactory = traceFileEventReaderFactory; // Initialization this.traceSource = traceEventSourceFactory.CreateTraceEventSource(FabricEvents.Tasks.FabricDCA); this.logSourceId = string.Concat(initParam.ApplicationInstanceId, "_", initParam.SectionName); this.consumerSinks = initParam.ConsumerSinks; // Read settings var configReader = configReaderFactory.CreateEtlInMemoryProducerConfigReader(this.traceSource, this.logSourceId); this.etlInMemoryProducerSettings = configReader.GetSettings(); // ETL in-memory file processing is not enabled or we are not processing // winfab etl files, so return immediately if (false == this.etlInMemoryProducerSettings.Enabled || false == this.etlInMemoryProducerSettings.ProcessingWinFabEtlFiles) { return; } // Create a new worker object var newWorkerParam = new EtlInMemoryProducerWorker.EtlInMemoryProducerWorkerParameters() { TraceSource = this.traceSource, LogDirectory = initParam.LogDirectory, ProducerInstanceId = this.logSourceId, EtlInMemoryProducer = this, LatestSettings = this.etlInMemoryProducerSettings }; var newWorker = new EtlInMemoryProducerWorker( newWorkerParam, this.diskSpaceManager, this.traceFileEventReaderFactory); this.producerWorker = newWorker; }
internal EtlProducer( DiskSpaceManager diskSpaceManager, IEtlProducerConfigReaderFactory configReaderFactory, ITraceFileEventReaderFactory traceFileEventReaderFactory, ITraceEventSourceFactory traceEventSourceFactory, ProducerInitializationParameters initParam) { this.diskSpaceManager = diskSpaceManager; this.traceFileEventReaderFactory = traceFileEventReaderFactory; // Initialization this.logSourceId = string.Concat(initParam.ApplicationInstanceId, "_", initParam.SectionName); this.traceSource = traceEventSourceFactory.CreateTraceEventSource(FabricEvents.Tasks.FabricDCA); this.serviceConfigSections = new List <string>(); this.logDirectory = initParam.LogDirectory; this.consumerSinks = initParam.ConsumerSinks; // Read instance-specific settings from the settings file var configReader = configReaderFactory.CreateEtlProducerConfigReader(this.traceSource, this.logSourceId); this.etlProducerSettings = configReader.GetSettings(); if (false == this.etlProducerSettings.Enabled) { // ETL file processing is not enabled, so return immediately return; } if (!this.etlProducerSettings.ProcessingWinFabEtlFiles) { // If we are collecting ETW events on behalf of an app, then we will // need information from the <ETW> section of the service manifest. this.serviceConfigSections.Add(ServiceConfig.EtwElement); // Check if we can use an existing worker object string applicationType = this.etlProducerSettings.ApplicationType; lock (ProducerWorkers) { EtlProducerWorkerInfo workerInfo = ProducerWorkers.FirstOrDefault(w => w.ApplicationType.Equals( applicationType, StringComparison.Ordinal)); if (null != workerInfo) { // Existing worker object is available. this.traceSource.WriteInfo( this.logSourceId, "Existing ETL producer worker object for application type {0} is available. Restarting the worker object now.", applicationType); // Restart the worker object workerInfo.ProducerWorker.Dispose(); workerInfo.ProducerWorker = null; List <EtlProducer> etlProducers = new List <EtlProducer>(workerInfo.EtlProducers) { this }; EtlProducerWorker.EtlProducerWorkerParameters newWorkerParam = new EtlProducerWorker.EtlProducerWorkerParameters() { TraceSource = this.traceSource, IsReadingFromApplicationManifest = !this.etlProducerSettings.ProcessingWinFabEtlFiles, ApplicationType = applicationType, LogDirectory = initParam.LogDirectory, ProducerInstanceId = applicationType, EtlProducers = etlProducers, LatestSettings = this.etlProducerSettings }; try { EtlProducerWorker newWorker = new EtlProducerWorker( newWorkerParam, this.diskSpaceManager, this.traceFileEventReaderFactory); workerInfo.EtlProducers.Add(this); workerInfo.ProducerWorker = newWorker; } catch (InvalidOperationException) { this.traceSource.WriteError( this.logSourceId, "Failed to restart ETL producer worker object for application type {0}.", applicationType); } } else { // Create a new worker object this.traceSource.WriteInfo( this.logSourceId, "Creating ETL producer worker object for application type {0} ...", applicationType); List <EtlProducer> etlProducers = new List <EtlProducer> { this }; EtlProducerWorker.EtlProducerWorkerParameters newWorkerParam = new EtlProducerWorker.EtlProducerWorkerParameters() { TraceSource = this.traceSource, IsReadingFromApplicationManifest = !this.etlProducerSettings.ProcessingWinFabEtlFiles, ApplicationType = applicationType, LogDirectory = initParam.LogDirectory, ProducerInstanceId = applicationType, EtlProducers = etlProducers, LatestSettings = this.etlProducerSettings }; try { EtlProducerWorker newWorker = new EtlProducerWorker( newWorkerParam, this.diskSpaceManager, this.traceFileEventReaderFactory); workerInfo = new EtlProducerWorkerInfo() { ApplicationType = applicationType, EtlProducers = new List <EtlProducer>(), ProducerWorker = newWorker }; workerInfo.EtlProducers.Add(this); ProducerWorkers.Add(workerInfo); } catch (InvalidOperationException) { this.traceSource.WriteError( this.logSourceId, "Failed to create ETL producer worker object for application type {0}.", applicationType); } } } } else { // Create a new worker object List <EtlProducer> etlProducers = new List <EtlProducer> { this }; EtlProducerWorker.EtlProducerWorkerParameters newWorkerParam = new EtlProducerWorker.EtlProducerWorkerParameters() { TraceSource = this.traceSource, IsReadingFromApplicationManifest = !this.etlProducerSettings.ProcessingWinFabEtlFiles, ApplicationType = string.Empty, LogDirectory = initParam.LogDirectory, ProducerInstanceId = this.logSourceId, EtlProducers = etlProducers, LatestSettings = this.etlProducerSettings }; try { EtlProducerWorker newWorker = new EtlProducerWorker( newWorkerParam, this.diskSpaceManager, this.traceFileEventReaderFactory); this.producerWorker = newWorker; } catch (InvalidOperationException) { } } }
public LttProducer( DiskSpaceManager diskSpaceManager, ITraceEventSourceFactory traceEventSourceFactory, ProducerInitializationParameters initParam) { this.logSourceId = string.Concat(initParam.ApplicationInstanceId, "_", initParam.SectionName); this.traceSource = traceEventSourceFactory.CreateTraceEventSource(FabricEvents.Tasks.FabricDCA); this.serviceConfigSections = new List <string>(); this.consumerSinks = initParam.ConsumerSinks; // Read the timer config value from dca section var configReader = new ConfigReader(initParam.ApplicationInstanceId); long newLttReadIntervalMinutes = configReader.GetUnencryptedConfigValue( initParam.SectionName, LttProducerConstants.LttReadIntervalParamName, LttProducerConstants.DefaultLttReadIntervalMinutes); lock (ProducerWorkers) { LttProducerWorkerInfo workerInfo = ProducerWorkers.FirstOrDefault(); if (null != workerInfo) { // Existing worker object is available. this.traceSource.WriteInfo( this.logSourceId, "Existing Ltt producer worker object. Restarting the worker object now."); // Save the old value for comparision long oldLttReadIntervalMinutes = workerInfo.ProducerWorker.LttReadIntervalMinutes; // Restart the worker object workerInfo.ProducerWorker.Dispose(); workerInfo.ProducerWorker = null; // Keep the smaller value intact // as this worker handles both producers Ltt trace conversion and table events if (oldLttReadIntervalMinutes < newLttReadIntervalMinutes) { newLttReadIntervalMinutes = oldLttReadIntervalMinutes; } List <LttProducer> LttProducers = new List <LttProducer>(workerInfo.LttProducers) { this }; LttProducerWorker.LttProducerWorkerParameters newWorkerParam = new LttProducerWorker.LttProducerWorkerParameters() { TraceSource = this.traceSource, LogDirectory = initParam.LogDirectory, ProducerInstanceId = this.logSourceId, LttProducers = LttProducers, LatestSettings = initParam, LttReadIntervalMinutes = newLttReadIntervalMinutes }; try { LttProducerWorker newWorker = new LttProducerWorker(newWorkerParam); workerInfo.LttProducers.Add(this); workerInfo.ProducerWorker = newWorker; } catch (InvalidOperationException) { this.traceSource.WriteError( this.logSourceId, "Failed to restart Ltt producer worker object."); } } else { // Create a new worker object this.traceSource.WriteInfo( this.logSourceId, "Creating Ltt producer worker object ..."); List <LttProducer> LttProducers = new List <LttProducer> { this }; LttProducerWorker.LttProducerWorkerParameters newWorkerParam = new LttProducerWorker.LttProducerWorkerParameters() { TraceSource = this.traceSource, LogDirectory = initParam.LogDirectory, ProducerInstanceId = this.logSourceId, LttProducers = LttProducers, LatestSettings = initParam, LttReadIntervalMinutes = newLttReadIntervalMinutes }; try { LttProducerWorker newWorker = new LttProducerWorker(newWorkerParam); workerInfo = new LttProducerWorkerInfo() { LttProducers = new List <LttProducer>(), ProducerWorker = newWorker }; workerInfo.LttProducers.Add(this); ProducerWorkers.Add(workerInfo); } catch (InvalidOperationException) { this.traceSource.WriteError( this.logSourceId, "Failed to create Ltt producer worker object."); } } } }