public void TestSetup() { state = Substitute.For <IStreamState>(); state.Name.Returns(StreamName); state.BufferPool.Returns(pool = Substitute.For <IBufferPool>()); state.Statistics.Returns(stats = Substitute.For <IStatisticsCollector>()); state.Settings.Returns(settings = new StreamSettings()); batcher = new BufferSnapshotBatcher(1); contentFactory = new RequestContentFactory(new BufferPool()); responseAnalyzer = new ResponseAnalyzer(ResponseAnalysisContext.Stream); statusAnalyzer = new StatusAnalyzer(); requestSender = Substitute.For <IGateRequestSender>(); sender = new StreamSender( () => GlobalApiKey, state, batcher, contentFactory, requestSender, responseAnalyzer, statusAnalyzer, new SynchronousConsoleLog()); cancellation = new CancellationTokenSource(); SetupBuffers(50, 100, 150); SetupResponses(HerculesStatus.Success); }
public void TestSetup() { factory = Substitute.For <IStreamStateFactory>(); factory.Create(Arg.Any <string>()).Returns(_ => state); state = Substitute.For <IStreamState>(); state.BufferPool.Returns(_ => pool); state.Statistics.Returns(_ => stats); state.RecordWriter.Returns(_ => writer); state.SendSignal.Returns(new AsyncManualResetEvent(false)); buffer = Substitute.For <IBuffer>(); writer = Substitute.For <IRecordWriter>(); stats = Substitute.For <IStatisticsCollector>(); daemon = Substitute.For <IDaemon>(); pool = Substitute.For <IBufferPool>(); pool.TryAcquire(out _) .Returns( info => { info[0] = buffer; return(true); }); log = new SynchronousConsoleLog(); sink = new HerculesSink(factory, daemon, log); }
public POCViewModel(IWebSocketClient client, string clientName, BoundingBoxRequest bbr, string clientIndex) { this.client = client; this.ClientName = clientName; IDToEntity = new Dictionary <string, Entity>(); triggerStatisticsCollector = new NumberStatisticsCollector(); redisStatisticsCollector = new NumberStatisticsCollector(); entitiesAmountStatisticsCollector = new NumberStatisticsCollector(); csvExporter = new CsvHelperCsvExporter(clientIndex); generator = new ZoomChangeGenerator(this, bbr); generator.Start(); workQueue = new BlockingCollection <DistributionWorkItem>(); workers = new List <DistributionWorker>(); for (int i = 0; i < ConfigData.Instance.Workers; i++) { var worker = new DistributionWorker(client, triggerStatisticsCollector, redisStatisticsCollector, entitiesAmountStatisticsCollector, workQueue); workers.Add(worker); worker.Start(); } }
public void TestSetup() { baseWriter = Substitute.For <IRecordWriter>(); statistics = Substitute.For <IStatisticsCollector>(); signal = new AsyncManualResetEvent(false); signalingWriter = new SignalingWriter(baseWriter, statistics, signal, 100, 0.25, 0.70); }
internal ConnectionPoolSettings(int maxIdleConnectionPoolSize, TimeSpan connectionIdleTimeout, IStatisticsCollector statisticsCollector = null) { Throw.ArgumentNullException.IfNull(maxIdleConnectionPoolSize, nameof(maxIdleConnectionPoolSize)); Throw.ArgumentNullException.IfNull(connectionIdleTimeout, nameof(connectionIdleTimeout)); MaxIdleConnectionPoolSize = maxIdleConnectionPoolSize; ConnectionIdleTimeout = connectionIdleTimeout; StatisticsCollector = statisticsCollector; }
public RequestRouter(QuandlApiOptions options, IStatisticsCollector statisticsCollector) { _options = options; _statisticsCollector = statisticsCollector; _client = new HttpClient() { BaseAddress = new Uri(Endpoints.QuandlApiBase) }; }
public TestModel(IWorkersFabric workersFabric, IBrockersFabric brockersFabric, IStatisticsCollector statisticsCollector) { StatisticsCollector = statisticsCollector; _brockersFabric = brockersFabric; _workersRepository = new WorkersRepository(statisticsCollector); _workersFabric = workersFabric; }
/// <summary> /// Инициализирует экземпляр <see cref="TestAnswerProcessing"/> /// </summary> /// <param name="telegramBotClient">Клиент telegram.</param> /// <param name="testStateController">Контроллер состояния пользователя.</param> /// <param name="tasksStorage">Хранилище задач.</param> /// <param name="tasksProcessing">Обработчик задач.</param> /// <param name="statisticsCollector">Сборщик статистики.</param> public TestAnswerProcessing(ITelegramBotClient telegramBotClient, ITestStateController testStateController, ITasksStorage tasksStorage, ITasksProcessing tasksProcessing, IStatisticsCollector statisticsCollector) { _subStates = new Dictionary <int, UserTestState>(); _telegramBotClient = telegramBotClient; _tasksProcessing = tasksProcessing; _testStateController = testStateController; _tasksStorage = tasksStorage; _statisticsCollector = statisticsCollector; }
public DistributionWorker(IWebSocketClient client, IStatisticsCollector <double> triggerStatisticsCollector, IStatisticsCollector <double> redisStatisticsCollector, IStatisticsCollector <double> entitiesAmountStatisticsCollector, BlockingCollection <DistributionWorkItem> pendingQueue) { this.client = client; this.pendingQueue = pendingQueue; this.triggerStatisticsCollector = triggerStatisticsCollector; this.redisStatisticsCollector = redisStatisticsCollector; this.entitiesAmountStatisticsCollector = entitiesAmountStatisticsCollector; }
public MainWindowViewModel() { _timer = new Timer(UpdateStatistics); _statisticsCollector = new BaseStatisticsCollector(); //_model = new TestModel(new NanoWorkersFabric(), new NanoBrockersFabric(), _statisticsCollector); //_model = new TestModel(new NetMQWorkersFabric(), new NetMQBrockersFabric(), _statisticsCollector); _model = new TestModel(new AsyncWorkersFabric(), new AsyncBrockersFabric(), _statisticsCollector); //_model = new TestModel(new FanWorkersFabric(), new FanBrockersFabric(), _statisticsCollector); StartCommand = new DelegateCommand(ExecuteMethod, () => !_isStarted); StopCommand = new DelegateCommand(() => _model.Stop(), () => _isStarted); }
public StreamState( [NotNull] string name, [NotNull] IBufferPool bufferPool, [NotNull] IMemoryAnalyzer memoryAnalyzer, [NotNull] IRecordWriter recordWriter, [NotNull] IStatisticsCollector statistics, [NotNull] AsyncManualResetEvent sendSignal) { Name = name ?? throw new ArgumentNullException(nameof(name)); BufferPool = bufferPool ?? throw new ArgumentNullException(nameof(bufferPool)); Statistics = statistics ?? throw new ArgumentNullException(nameof(statistics)); RecordWriter = recordWriter ?? throw new ArgumentNullException(nameof(recordWriter)); SendSignal = sendSignal ?? throw new ArgumentNullException(nameof(sendSignal)); MemoryAnalyzer = memoryAnalyzer ?? throw new ArgumentNullException(nameof(memoryAnalyzer)); }
public SignalingWriter( IRecordWriter baseWriter, IStatisticsCollector statistics, AsyncManualResetEvent signal, long sizeLimit, double transitionSignalFraction, double constantSignalFraction) { this.baseWriter = baseWriter; this.statistics = statistics; this.signal = signal; transitionSignalThreshold = (long)(sizeLimit * transitionSignalFraction); constantSignalThreshold = (long)(sizeLimit * constantSignalFraction); }
public Application( ICloudLayouter layouter, IVisualizer visualizer, IFileReader fileReader, IImageSaver imageSaver, IStatisticsCollector statisticsCollector, IWordFilter wordFilter, ISizeScheme sizeScheme, IWordProcessor wordProcessor) { this.layouter = layouter; this.visualizer = visualizer; this.fileReader = fileReader; this.imageSaver = imageSaver; this.statisticsCollector = statisticsCollector; this.wordFilter = wordFilter; this.sizeScheme = sizeScheme; this.wordProcessor = wordProcessor; }
public void Execute( String[] filePaths, ILogManager logManager, IStreamReaderFactory streamReaderFactory, IRecordReader recordReader, IRecordMatchExpression expression, IRecordWriter recordWriter, IStatisticsCollector statisticsCollector, IStatisticsReporter statisticsReporter) { logManager.VerifyThatObjectIsNotNull("Parameter 'logManager' is null."); try { this.logManager = logManager; statisticsCollector.VerifyThatObjectIsNotNull("Parameter 'statisticsCollector' is null."); this.statisticsCollector = statisticsCollector; statisticsReporter.VerifyThatObjectIsNotNull("Parameter 'statisticsReporter' is null."); this.statisticsReporter = statisticsReporter; this.logManager.WriteMessagesToLogs("Run Started..."); Action<IStreamReader, Record> writeMatchedRecordMethod, writeUnmatchedRecordMethod; this.DetermineOutputMethods(recordWriter, out writeMatchedRecordMethod, out writeUnmatchedRecordMethod); this.Process(filePaths, streamReaderFactory, recordReader, expression, writeMatchedRecordMethod, writeUnmatchedRecordMethod); recordWriter.Close(); this.statisticsReporter.WriteToLog(this.logManager); this.logManager.WriteMessagesToLogs("Run Finished."); } catch (Exception exception) { logManager.WriteMessageToApplicationLog("EXCEPTION: " + exception.Message); logManager.WriteMessageToApplicationLog("STACK: " + exception.StackTrace); throw exception; } }
public OneFileRecordWriter(String matchedFilePath, String unmatchedFilePath, IStatisticsCollector statisticsCollector) { statisticsCollector.VerifyThatObjectIsNotNull("Parameter 'statisticsCollector' is null."); this.statisticsCollector = statisticsCollector; if (!String.IsNullOrEmpty(matchedFilePath)) { this.matchedFilePath = matchedFilePath; this.DoWriteMatchedRecords = true; } if (!String.IsNullOrEmpty(unmatchedFilePath)) { this.unmatchedFilePath = unmatchedFilePath; this.DoWriteUnmatchedRecords = true; } // TODO: Should check that the paths are legal. }
private IRecordWriter CreateRecordWriter(string name, IStatisticsCollector statistics, AsyncManualResetEvent signal) { IRecordWriter writer = new RecordWriter( log.ForContext(name), () => PreciseDateTime.UtcNow, Constants.EventProtocolVersion, settings.MaximumRecordSize); writer = new ReportingWriter(writer, statistics); writer = new SignalingWriter( writer, statistics, signal, settings.MaximumPerStreamMemoryConsumption, SignalTransitionThreshold, SignalConstantThreshold); return(writer); }
public async Task Collect(IStatisticsCollector collector) { var operationContext = new StatisticsCollectorOperationContext(); using (collector) { for (int i = 0; i < collector.OperationsCount; i++) { var operation = collector.GetOperation(i); await operation.Execute(operationContext); if (operationContext.OperationState != OperationState.Ok) { _logger.LogWarning( $"Operation '{operation.GetType()}' was terminate because of its state '{operationContext.OperationState}': {operationContext.OperationStateMessage}"); break; } else { _logger.LogInformation($"Operation '{operation.GetType()}'; done with message '{operationContext.OperationStateMessage}'"); } } } }
public ReportingWriter(IRecordWriter baseWriter, IStatisticsCollector statistics) { this.baseWriter = baseWriter; this.statistics = statistics; }
public WorkersRepository([NotNull]IStatisticsCollector statisticsCollector) { _statisticsCollector = statisticsCollector; }
public void SetStatisticsCollector(IStatisticsCollector statisticsCollector) { StatisticsCollector = statisticsCollector; }
public InputFileRecordWriter(IStatisticsCollector statisticsCollector, Boolean doWriteMatchedRecords, Boolean doWriteUnmatchedRecords) { this.statisticsCollector = statisticsCollector; this.DoWriteMatchedRecords = doWriteMatchedRecords; this.DoWriteUnmatchedRecords = doWriteUnmatchedRecords; }
public void TestSetup() { baseWriter = Substitute.For <IRecordWriter>(); statistics = Substitute.For <IStatisticsCollector>(); reportingWriter = new ReportingWriter(baseWriter, statistics); }