예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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)
            };
        }
예제 #7
0
        public TestModel(IWorkersFabric workersFabric,
                         IBrockersFabric brockersFabric,
                         IStatisticsCollector statisticsCollector)
        {
            StatisticsCollector = statisticsCollector;

            _brockersFabric = brockersFabric;
            _workersRepository = new WorkersRepository(statisticsCollector);
            _workersFabric = workersFabric;
        }
예제 #8
0
 /// <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;
 }
예제 #9
0
 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;
 }
예제 #10
0
        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);
        }
예제 #11
0
 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));
 }
예제 #12
0
        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);
        }
예제 #13
0
파일: Application.cs 프로젝트: lamanoff/fp
 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;
 }
예제 #14
0
파일: Engine.cs 프로젝트: toyners/Siftan
        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;
              }
        }
예제 #15
0
        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.
        }
예제 #16
0
        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}'");
                    }
                }
            }
        }
예제 #18
0
 public ReportingWriter(IRecordWriter baseWriter, IStatisticsCollector statistics)
 {
     this.baseWriter = baseWriter;
     this.statistics = statistics;
 }
예제 #19
0
 public WorkersRepository([NotNull]IStatisticsCollector statisticsCollector)
 {
     _statisticsCollector = statisticsCollector;
 }
예제 #20
0
 public void SetStatisticsCollector(IStatisticsCollector statisticsCollector)
 {
     StatisticsCollector = statisticsCollector;
 }
예제 #21
0
 public InputFileRecordWriter(IStatisticsCollector statisticsCollector, Boolean doWriteMatchedRecords, Boolean doWriteUnmatchedRecords)
 {
     this.statisticsCollector = statisticsCollector;
       this.DoWriteMatchedRecords = doWriteMatchedRecords;
       this.DoWriteUnmatchedRecords = doWriteUnmatchedRecords;
 }
예제 #22
0
 public void TestSetup()
 {
     baseWriter      = Substitute.For <IRecordWriter>();
     statistics      = Substitute.For <IStatisticsCollector>();
     reportingWriter = new ReportingWriter(baseWriter, statistics);
 }