Beispiel #1
0
        protected Engine(Model model, EngineConfiguration config)
        {
            _config = config;

            _synchronizer = _config.CreateSynchronizer();
            _authorizer   = _config.CreateAuthorizer();

            IsolatedReturnTypes.AddRange(_config.IsolatedTypes);
            _config.Isolation.Commands.SetFormatter(_config.CreateFormatter(FormatterUsage.Messages));
            _config.Isolation.ReturnValues.SetFormatter(_config.CreateFormatter(FormatterUsage.Results));

            Configure(model);

            if (_config.SnapshotBehavior == SnapshotBehavior.AfterRestore)
            {
                Logger.Info("Starting snaphot job on threadpool");

                ThreadPool.QueueUserWorkItem(_ => CreateSnapshot());

                //Give the snapshot thread a chance to start and aquire the readlock
                Thread.Sleep(TimeSpan.FromMilliseconds(10));
            }

            if (_config.PersistenceMode == PersistenceMode.SnapshotPerTransaction)
            {
                CommandExecuted += (s, e) => CreateSnapshot();
            }

            model.Starting(this);
            Core.Config.Engines.AddEngine(config.JournalPath, this);
        }
Beispiel #2
0
 public StreamJournalWriter(EngineConfiguration config, Func <ulong, Stream> streamFactory)
 {
     _streamProvider   = streamFactory;
     _journalFormatter = config.CreateFormatter(FormatterUsage.Journal);
     _rolloverStrategy = config.CreateRolloverStrategy();
 }
Beispiel #3
0
 public RoyalFoodTaster(EngineConfiguration config, Model model)
     : base(config, model)
 {
     _formatter  = config.CreateFormatter(FormatterUsage.Snapshot);
     _foodTaster = _formatter.Clone(_model);
 }
Beispiel #4
0
 /// <summary>
 /// Serialize the current model to a stream
 /// </summary>
 /// <param name="stream">A writeable stream</param>
 /// <param name="formatter">A specific formatter, otherwise the default formatter</param>
 public void WriteSnapshotToStream(Stream stream, IFormatter formatter = null)
 {
     formatter = formatter ?? _config.CreateFormatter(FormatterUsage.Snapshot);
     _kernel.Read(model => formatter.Serialize(stream, model));
 }
Beispiel #5
0
 protected Kernel(EngineConfiguration config, Model model)
 {
     _resultFormatter = config.CreateFormatter(FormatterUsage.Results);
     _synchronizer    = config.CreateSynchronizer();
     _model           = model;
 }