コード例 #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
 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);
 }
コード例 #3
0
ファイル: InputBuffer.cs プロジェクト: YHZX2013/exchange_diff
 public InputBuffer(int batchSizeInBytes, long beginOffset, ILogFileInfo logFileInfoObj, ThreadSafeQueue <T> logDataBatchQueue, string prefix, ILogMonitorHelper <T> logMonitorHelper, int messageBatchFlushInterval, CancellationContext cancelContext, int maxBatchCount, string instanceName = null)
 {
     if (batchSizeInBytes <= 0)
     {
         throw new ArgumentOutOfRangeException("batchSizeInByte", "The batch size should be greater than 0.");
     }
     if (beginOffset < 0L)
     {
         throw new ArgumentOutOfRangeException("beginOffset", "The beginOffset should be equal or greater than 0.");
     }
     if (logDataBatchQueue == null)
     {
         throw new ArgumentNullException("logDataBatchQueue cannot be null.");
     }
     if (messageBatchFlushInterval < 0)
     {
         throw new ArgumentOutOfRangeException("messageBatchFlushInterval", "The messageBatchFlushInterval must not be a negative number.");
     }
     ArgumentValidator.ThrowIfNull("logFileInfoObj", logFileInfoObj);
     ArgumentValidator.ThrowIfNull("watermarkFileRef", logFileInfoObj.WatermarkFileObj);
     if (string.IsNullOrEmpty(logFileInfoObj.FullFileName))
     {
         throw new ArgumentException("fullLogName cannot be null or emtpy.");
     }
     ArgumentValidator.ThrowIfNull("cancelContext", cancelContext);
     this.cancellationContext       = cancelContext;
     this.messageBatchFlushInterval = messageBatchFlushInterval;
     this.batchSizeInBytes          = batchSizeInBytes;
     this.logDataBatchQueue         = logDataBatchQueue;
     this.watermarkFileRef          = logFileInfoObj.WatermarkFileObj;
     this.maximumBatchCount         = ((maxBatchCount <= 0) ? int.MaxValue : maxBatchCount);
     this.lastFluchCheckTime        = DateTime.UtcNow;
     this.logMonitorHelper          = logMonitorHelper;
     this.fullLogName         = logFileInfoObj.FullFileName;
     this.instance            = (string.IsNullOrEmpty(instanceName) ? prefix : instanceName);
     this.logPrefix           = prefix;
     this.perfCounterInstance = PerfCountersInstanceCache.GetInstance(this.instance);
     this.shouldBufferBatches = this.ShouldBufferBatches();
     this.CreateNewBatch(beginOffset);
     if (this.shouldBufferBatches)
     {
         MessageBatchBase messageBatchBase = this.activeBatch as MessageBatchBase;
         if (messageBatchBase != null)
         {
             messageBatchBase.MessageBatchFlushInterval = this.messageBatchFlushInterval;
         }
     }
 }
コード例 #4
0
 public DatabaseWriter(ThreadSafeQueue <T> queue, int id, ConfigInstance config, string instanceName)
 {
     this.InitializeDatabaseWriter(queue, id, config, instanceName);
     this.perfCounterInstance = PerfCountersInstanceCache.GetInstance(this.instance);
 }