コード例 #1
0
 protected void InitializeDatabaseWriter(ThreadSafeQueue <T> queue, int id, ConfigInstance config, string instanceName)
 {
     ArgumentValidator.ThrowIfNull("queue", queue);
     ArgumentValidator.ThrowIfNull("config", config);
     ArgumentValidator.ThrowIfNullOrEmpty("instanceName", instanceName);
     if (id < 0)
     {
         throw new ArgumentOutOfRangeException("id should be equal or greater than 0.");
     }
     this.queue           = queue;
     this.config          = config;
     this.id              = id;
     this.stopped         = false;
     this.instance        = instanceName;
     this.isStopRequested = false;
 }
コード例 #2
0
ファイル: LogMonitor.cs プロジェクト: YHZX2013/exchange_diff
 public LogMonitor(ConfigInstance config, string logDir, string logPrefixFilter, ILogMonitorHelper <T> logMonitorHelper, string instanceName = null, string wmkFileDiretory = null)
 {
     ArgumentValidator.ThrowIfNull("config", config);
     ArgumentValidator.ThrowIfNull("logDir", logDir);
     ArgumentValidator.ThrowIfNull("logMonitorHelper", logMonitorHelper);
     ArgumentValidator.ThrowIfNullOrEmpty("logPrefix", logPrefixFilter);
     this.logPrefixToBeMonitored = logPrefixFilter;
     this.config                         = config;
     this.logDirectory                   = logDir;
     this.logMonitorHelper               = logMonitorHelper;
     this.logsJustFinishedParsing        = new ConcurrentDictionary <string, LogFileInfo>(StringComparer.InvariantCultureIgnoreCase);
     this.watermarkFileHelper            = new WatermarkFileHelper(this.logDirectory, wmkFileDiretory);
     this.instance                       = (string.IsNullOrWhiteSpace(instanceName) ? this.logPrefixToBeMonitored : instanceName);
     this.batchQueue                     = new ThreadSafeQueue <T>(this.config.QueueCapacity);
     this.knownLogNameToLogFileMap       = new ConcurrentDictionary <string, ILogFileInfo>(StringComparer.InvariantCultureIgnoreCase);
     this.logsNeedProcessing             = new List <LogFileInfo>();
     this.previousLogDirectories         = new HashSet <string>();
     this.reprocessingActiveFileWaitTime = Tools.RandomizeTimeSpan(this.config.WaitTimeToReprocessActiveFile, this.config.WaitTimeToReprocessActiveFileRandomRange);
     this.instanceInstantiateTime        = DateTime.UtcNow;
     this.staleLogs                      = new List <ILogFileInfo>();
     this.veryStaleLogs                  = new List <ILogFileInfo>();
     this.workerThreads                  = new List <Thread>();
     this.maxNumberOfWriterThreads       = config.MaxNumOfWriters;
     this.maxNumberOfReaderThreads       = config.MaxNumOfReaders;
     this.perfCounterInstance            = PerfCountersInstanceCache.GetInstance(this.instance);
     this.perfCounterInstance.TotalIncompleteLogs.RawValue        = 0L;
     this.perfCounterInstance.BatchQueueLength.RawValue           = 0L;
     this.perfCounterInstance.InputBufferBatchCounts.RawValue     = 0L;
     this.perfCounterInstance.InputBufferBackfilledLines.RawValue = 0L;
     this.perfCounterInstance.TotalLogLinesProcessed.RawValue     = 0L;
     if (Tools.IsRawProcessingType <T>())
     {
         this.perfCounterInstance.RawIncompleteBytes.RawValue   = 0L;
         this.perfCounterInstance.RawTotalLogBytes.RawValue     = 0L;
         this.perfCounterInstance.RawWrittenBytes.RawValue      = 0L;
         this.perfCounterInstance.RawReaderParsedBytes.RawValue = 0L;
         return;
     }
     this.perfCounterInstance.IncompleteBytes.RawValue        = 0L;
     this.perfCounterInstance.TotalLogBytes.RawValue          = 0L;
     this.perfCounterInstance.TotalLogBytesProcessed.RawValue = 0L;
     this.perfCounterInstance.ReaderParsedBytes.RawValue      = 0L;
 }
コード例 #3
0
 public DatabaseWriter(ThreadSafeQueue <T> queue, int id, ConfigInstance config, string instanceName)
 {
     this.InitializeDatabaseWriter(queue, id, config, instanceName);
     this.perfCounterInstance = PerfCountersInstanceCache.GetInstance(this.instance);
 }
コード例 #4
0
 public LogReader(ThreadSafeQueue <T> batchQueue, int id, ILogManager logMonitor, ConfigInstance config, string prefix, ILogMonitorHelper <T> logMonitorHelper, string instanceName = null)
 {
     ArgumentValidator.ThrowIfNull("batchQueue", batchQueue);
     ArgumentValidator.ThrowIfNull("logMonitor", logMonitor);
     ArgumentValidator.ThrowIfNull("config", config);
     ArgumentValidator.ThrowIfNull("logMonitorHelper", logMonitorHelper);
     ArgumentValidator.ThrowIfNullOrEmpty("prefix", prefix);
     if (id < 0)
     {
         throw new ArgumentOutOfRangeException("id cannot be negative.");
     }
     this.batchQueue = batchQueue;
     this.id         = id;
     this.logMonitor = logMonitor;
     this.stopped    = false;
     this.logPrefix  = prefix;
     this.config     = config;
     this.instance   = (string.IsNullOrEmpty(instanceName) ? prefix : instanceName);
     this.messageBatchFlushInterval = (int)this.config.BatchFlushInterval.TotalSeconds;
     this.logMonitorHelper          = logMonitorHelper;
     this.lastTimeWhenQeueFull      = DateTime.UtcNow.Ticks;
     this.perfCounterInstance       = PerfCountersInstanceCache.GetInstance(this.instance);
 }