public RebuildProjectionEngine(
            EventUnwinder eventUnwinder,
            IConcurrentCheckpointTracker checkpointTracker,
            IProjection[] projections,
            IRebuildContext rebuildContext,
            ProjectionEngineConfig config,
            ProjectionEventInspector projectionInspector,
            ILoggerThreadContextManager loggerThreadContextManager)
        {
            _eventUnwinder       = eventUnwinder;
            _checkpointTracker   = checkpointTracker;
            _rebuildContext      = rebuildContext;
            _config              = config;
            _projectionInspector = projectionInspector;

            if (_config.Slots[0] != "*")
            {
                projections = projections
                              .Where(x => _config.Slots.Any(y => y == x.Info.SlotName))
                              .ToArray();
            }

            _allProjections    = projections;
            _projectionsBySlot = projections
                                 .GroupBy(x => x.Info.SlotName)
                                 .ToDictionary(x => x.Key, x => x.OrderByDescending(p => p.Priority).ToArray());

            _metrics = new ProjectionMetrics(_allProjections);
            _loggerThreadContextManager = loggerThreadContextManager;

            HealthChecks.RegisterHealthCheck("RebuildProjectionEngine", (Func <HealthCheckResult>)HealthCheck);
        }
Esempio n. 2
0
        public RebuildProjectionEngine(
            EventUnwinder eventUnwinder,
            IConcurrentCheckpointTracker checkpointTracker,
            IProjection[] projections,
            IRebuildContext rebuildContext,
            ProjectionEngineConfig config,
            ProjectionEventInspector projectionInspector)
        {
            _eventUnwinder       = eventUnwinder;
            _checkpointTracker   = checkpointTracker;
            _rebuildContext      = rebuildContext;
            _config              = config;
            _projectionInspector = projectionInspector;

            if (_config.Slots[0] != "*")
            {
                projections = projections
                              .Where(x => _config.Slots.Any(y => y == x.GetSlotName()))
                              .ToArray();
            }

            _allProjections    = projections;
            _projectionsBySlot = projections
                                 .GroupBy(x => x.GetSlotName())
                                 .ToDictionary(x => x.Key, x => x.OrderByDescending(p => p.Priority).ToArray());

            _metrics = new ProjectionMetrics(_allProjections);
        }
Esempio n. 3
0
        public ConcurrentProjectionsEngine(
            IConcurrentCheckpointTracker checkpointTracker,
            IProjection[] projections,
            IPollingClient client,
            IHousekeeper housekeeper,
            IRebuildContext rebuildContext,
            INotifyCommitHandled notifyCommitHandled,
            ProjectionEngineConfig config)
        {
            _checkpointTracker   = checkpointTracker;
            _client              = client;
            _housekeeper         = housekeeper;
            _rebuildContext      = rebuildContext;
            _notifyCommitHandled = notifyCommitHandled;
            _config              = config;

            if (_config.Slots[0] != "*")
            {
                projections = projections
                              .Where(x => _config.Slots.Any(y => y == x.GetSlotName()))
                              .ToArray();
            }

            _allProjections    = projections;
            _projectionsBySlot = projections
                                 .GroupBy(x => x.GetSlotName())
                                 .ToDictionary(x => x.Key, x => x.OrderByDescending(p => p.Priority).ToArray());

            _metrics = new ProjectionMetrics(_allProjections);
        }
        public ProjectionEngine(
            Func <IPersistStreams, CommitPollingClient> pollingClientFactory,
            IConcurrentCheckpointTracker checkpointTracker,
            IProjection[] projections,
            IHousekeeper housekeeper,
            IRebuildContext rebuildContext,
            INotifyCommitHandled notifyCommitHandled,
            ProjectionEngineConfig config)
        {
            _pollingClientFactory = pollingClientFactory;
            _checkpointTracker    = checkpointTracker;
            _housekeeper          = housekeeper;
            _rebuildContext       = rebuildContext;
            _notifyCommitHandled  = notifyCommitHandled;
            _config = config;

            if (_config.Slots[0] != "*")
            {
                projections = projections
                              .Where(x => _config.Slots.Any(y => y == x.GetSlotName()))
                              .ToArray();
            }

            _allProjections    = projections;
            _projectionsBySlot = projections
                                 .GroupBy(x => x.GetSlotName())
                                 .ToDictionary(x => x.Key, x => x.OrderByDescending(p => p.Priority).ToArray());

            _metrics        = new ProjectionMetrics(_allProjections);
            _clients        = new List <CommitPollingClient>();
            _bucketToClient = new Dictionary <BucketInfo, CommitPollingClient>();
        }
Esempio n. 5
0
 public PollingObserveCommits(IPersistStreams persistStreams, int interval, string checkpointToken, ICommitEnhancer enhancer, bool boost, IConcurrentCheckpointTracker tracker)
 {
     _persistStreams  = persistStreams;
     _checkpointToken = checkpointToken;
     _enhancer        = enhancer;
     _interval        = interval;
     _boost           = boost;
     _tracker         = tracker;
 }
 public RebuildProjectionSlotDispatcher(
     IExtendedLogger logger,
     String slotName,
     ProjectionEngineConfig config,
     IEnumerable <IProjection> projections,
     IConcurrentCheckpointTracker checkpointTracker,
     Int64 lastCheckpointDispatched)
 {
     SlotName                 = slotName;
     _logger                  = logger;
     _config                  = config;
     _projections             = projections;
     _metrics                 = new ProjectionMetrics(projections);
     _checkpointTracker       = checkpointTracker;
     _maxCheckpointDispatched = lastCheckpointDispatched;
     _lastCheckpointRebuilded = 0;
 }
Esempio n. 7
0
        public JarvisPollingClient(IPersistStreams persistStreams, int interval, ICommitEnhancer enhancer, bool boost, IConcurrentCheckpointTracker tracker)
            : base(persistStreams)
        {
            if (persistStreams == null)
            {
                throw new ArgumentNullException("persistStreams");
            }
            if (interval <= 0)
            {
                throw new ArgumentException("interval");

                //                throw new ArgumentException(NEventStore.Messages.MustBeGreaterThanZero.FormatWith("interval"));
            }
            _interval = interval;
            _enhancer = enhancer;
            _boost    = boost;
            _tracker  = tracker;
        }
Esempio n. 8
0
        public ProjectionEngine(
            ICommitPollingClientFactory pollingClientFactory,
            IConcurrentCheckpointTracker checkpointTracker,
            IProjection[] projections,
            IHousekeeper housekeeper,
            IRebuildContext rebuildContext,
            INotifyCommitHandled notifyCommitHandled,
            ProjectionEngineConfig config)
        {
            Logger             = NullLogger.Instance;
            _engineFatalErrors = new ConcurrentBag <string>();

            _pollingClientFactory = pollingClientFactory;
            _checkpointTracker    = checkpointTracker;
            _housekeeper          = housekeeper;
            _rebuildContext       = rebuildContext;
            _notifyCommitHandled  = notifyCommitHandled;
            _config = config;

            if (_config.Slots[0] != "*")
            {
                projections = projections
                              .Where(x => _config.Slots.Any(y => y == x.GetSlotName()))
                              .ToArray();
            }

            _allProjections    = projections;
            _projectionsBySlot = projections
                                 .GroupBy(x => x.GetSlotName())
                                 .ToDictionary(x => x.Key, x => x.OrderByDescending(p => p.Priority).ToArray());

            _metrics        = new ProjectionMetrics(_allProjections);
            _bucketToClient = new Dictionary <BucketInfo, ICommitPollingClient>();

            RegisterHealthCheck();
        }
Esempio n. 9
0
        /// <summary>
        /// This is the basic constructor for the projection engine.
        /// </summary>
        /// <param name="pollingClientFactory"></param>
        /// <param name="persistence"></param>
        /// <param name="checkpointTracker"></param>
        /// <param name="projections"></param>
        /// <param name="housekeeper"></param>
        /// <param name="notifyCommitHandled"></param>
        /// <param name="config"></param>
        /// <param name="logger"></param>
        /// <param name="loggerThreadContextManager"></param>
        public ProjectionEngine(
            ICommitPollingClientFactory pollingClientFactory,
            IPersistence persistence,
            IConcurrentCheckpointTracker checkpointTracker,
            IProjection[] projections,
            IHousekeeper housekeeper,
            INotifyCommitHandled notifyCommitHandled,
            ProjectionEngineConfig config,
            ILogger logger,
            ILoggerThreadContextManager loggerThreadContextManager)
        {
            if (projections == null)
            {
                throw new ArgumentNullException(nameof(projections));
            }

            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            _persistence = persistence ?? throw new ArgumentNullException(nameof(persistence));

            _logger = logger;
            _loggerThreadContextManager = loggerThreadContextManager;

            var configErrors = config.Validate();

            if (!String.IsNullOrEmpty(configErrors))
            {
                throw new ArgumentException(configErrors, nameof(config));
            }

            _engineFatalErrors = new ConcurrentBag <string>();

            _pollingClientFactory = pollingClientFactory ?? throw new ArgumentNullException(nameof(pollingClientFactory));
            _checkpointTracker    = checkpointTracker ?? throw new ArgumentNullException(nameof(checkpointTracker));
            _housekeeper          = housekeeper ?? throw new ArgumentNullException(nameof(housekeeper));
            _notifyCommitHandled  = notifyCommitHandled ?? throw new ArgumentNullException(nameof(notifyCommitHandled));
            _config = config;

            if (_config.Slots[0] != "*")
            {
                projections = projections
                              .Where(x => _config.Slots.Any(y => y == x.Info.SlotName))
                              .ToArray();
            }

            if (OfflineMode.Enabled)
            {
                //In offline mode we already have filtered out the projection.
                _allProjections = projections;
            }
            else
            {
                //we are not in offline mode, just use all projection that are not marked to
                //run only in offline mode
                logger.Info($"Projection engine is NOT in OFFLINE mode, projection engine will run only projection that are not marked for OfflineModel.");
                _allProjections = projections.Where(_ => !_.Info.OfflineProjection).ToArray();
            }

            _projectionsBySlot = projections
                                 .GroupBy(x => x.Info.SlotName)
                                 .ToDictionary(x => x.Key, x => x.OrderByDescending(p => p.Priority).ToArray());

            _bucketToClient = new Dictionary <BucketInfo, ICommitPollingClient>();

            RegisterHealthCheck();
        }
 public PollingClientWrapper(ICommitEnhancer enhancer, bool boost, IConcurrentCheckpointTracker tracker)
 {
     _enhancer = enhancer;
     _boost    = boost;
     _tracker  = tracker;
 }