示例#1
0
 public TaskProducerWorker(ILogger logger, ICacheAside cacheAside, IVolumeHandler volumeHandler, IResolver resolver, IBatchLoggerFactory batchLoggerFactory) : base("TaskProducer", logger)
 {
     _cacheAside         = cacheAside;
     _volumeHandler      = volumeHandler;
     _resolver           = resolver;
     _batchLoggerFactory = batchLoggerFactory;
 }
示例#2
0
文件: Bus.cs 项目: mohsin019/BusPOC
        public Bus(IEntityFactory entityFactory, IVolumeHandler volumeHandler, IPubSubFactory pubSubFactory, IStateManager stateManager, IProcessDataStorage storage,
                   IDistributedMutexFactory distributedMutexFactory, IResolver resolver, IBatchLoggerFactory batchLoggerFactory)
        {
            EntityFactory           = entityFactory;
            VolumeHandler           = volumeHandler;
            PubSubFactory           = pubSubFactory;
            _stateManager           = stateManager;
            _storage                = storage;
            DistributedMutexFactory = distributedMutexFactory;
            _resolver               = resolver;
            _batchLoggerFactory     = batchLoggerFactory;
            _cts = new CancellationTokenSource();
            _cancellationToken = _cts.Token;
            HookExceptionEvents();

            _logger         = batchLoggerFactory.GetSystemLogger();
            EventAggregator = new TinyEventAggregator();

            var wrapper = new BusStateManager(_stateManager, _logger, resolver);

            _stateManager = wrapper;

            var originalStorage = _storage;

            _storage = new CacheBusWrapper(_logger, originalStorage, resolver);
            _cacheCommandPipeline = new CacheStoragePipeline(_logger, _cancellationToken, originalStorage);


            _cacheAside = new CacheAside(_stateManager, _storage, EventAggregator, _logger, batchLoggerFactory);

            _processRepository = _resolver.Resolve <IProcessRepository>();
            //var taskListener = resolver.Resolve<ITaskListener>();
            //if (!ReferenceEquals(taskListener, _processRepository))
            //{
            //    Console.WriteLine("ALERT");
            //}

            _taskExecutorsRepo = new TaskExecutorsPool(_logger, _cacheAside, _cancellationToken, _stateManager, _processRepository, EventAggregator, resolver, _logger);


            //BuildCommandHandlerPipeline();
            _statePersistencePipeline = new StatePersistencePipeline(_logger, _cancellationToken);
            this._databasePipeline    = new DatabasePipeline(_logger, _cancellationToken, 0);//todo 500

            _taskProcessorPipeline = GetTaskProcessorPipeLine();
            //_grouPipeline=new GroupHandlerPipeline(_stateManager, _logger, _branchEngineSubscriber);

            //_volumePipeline = new ProcessVolumePipeline(_cancellationToken, _logger, _stateManager, _cacheAside, _processRepository, VolumeHandler, resolver, EventAggregator, _branchEngineSubscriber);
            _branchEngineSubscriber = new BatchEngineSubscribers();

            //_watchDog = new ProcessWatchDog(_logger, StateManager, _branchEngineSubscriber, _cacheAside, SerializersFactory.Instance, EntityFactory, EventAggregator, Storage);
            //watchDog.Start(_cancellationToken);//todo
            // _grouPipeline = new Pipeline<GroupMessage>(_watchDog);
            //_watchDogPipeline = new Pipeline<IWatchDogMessage>(_watchDog);

            _taskProducer = new TaskProducerWorker(_logger, _cacheAside, VolumeHandler, resolver, batchLoggerFactory);

            _leaderManager = DistributedMutexFactory.CreateDistributedMutex(NodeSettings.Instance.LockKey, RunLocalWatchDog, () => SwitchToPubSubWatchDog(null), batchLoggerFactory.GetSystemLogger());
        }
            //private readonly Action<ProcessExecutionContext, bool> _invokeProcessCompletion;


            public VolumeGenerator(IBaseProcess process, IStateManager stateManager, IVolumeHandler volumeHandler,
                                   IResolver resolver, CancellationToken cancellationToken, IProcessRepository registeredProcesses,
                                   IBatchEngineSubscribers batchEngineSubscribers, IFrameworkLogger logger)
            {
                _process                = process;
                _stateManager           = stateManager;
                this._volumeHandler     = volumeHandler;
                _resolver               = resolver;
                _cancellationToken      = cancellationToken;
                _registeredProcesses    = registeredProcesses;
                _batchEngineSubscribers = batchEngineSubscribers;
                _logger = logger;
            }
 public ProcessVolumeRequestHandler(IFrameworkLogger logger, IStateManager stateManager, ICacheAside cacheAside,
                                    IProcessRepository registeredProcesses, IVolumeHandler volumeHandler, CancellationToken token,
                                    IResolver resolver, IEventAggregator eventAggregator, IBatchEngineSubscribers batchEngineSubscribers)
 {
     _logger              = logger;
     _stateManager        = stateManager;
     _cacheAside          = cacheAside;
     _registeredProcesses = registeredProcesses;
     _volumeHandler       = volumeHandler;
     _token                  = token;
     _resolver               = resolver;
     _eventAggregator        = eventAggregator;
     _batchEngineSubscribers = batchEngineSubscribers;
 }
示例#5
0
        void IBaseProcess.HandleVolume(IVolumeHandler handler, IProcessExecutionContextWithVolume processContext,
                                       CancellationToken cancellationToken)
        {
            var volumeGenerated = processContext.ProcessState.IsVolumeGenerated;

            if (!volumeGenerated || CanRegenerateVolume)
            {
                var volume = GetVolume(processContext);
                if (volume != null)
                {
                    handler.Handle(volume, processContext, cancellationToken); //volume visitor
                }
            }
        }
示例#6
0
 public ProcessVolumePipeline(CancellationToken token, IFrameworkLogger logger, IStateManager stateManager,
                              ICacheAside cacheAside, IProcessRepository processRepository, IVolumeHandler volumeHandler,
                              IResolver resolver, IEventAggregator eventAggregator, IBatchEngineSubscribers batchEngineSubscribers)
     : base(new ProcessVolumeRequestHandler(logger, stateManager, cacheAside, processRepository, volumeHandler,
                                            token, resolver, eventAggregator, batchEngineSubscribers))
 {
     RegisterFeatureDecorator(new ConsumerFilter <ProcessExecutionContext>(token, logger, "VolumeGeneratorConsumer"));
 }