Exemple #1
0
        internal EventStore(string dbname, long lastcommittedcommandsn)
        {
            DatabaseName = dbname;

            LastExecutedCommandSN = lastcommittedcommandsn;

            JournalReader _jreader = new JournalReader(Configuration.BasePath, dbname);
            long          jsn      = LoadUncommittedEventsFromJournal(_jreader);

            _jreader.CloseFile();

            _eventHandlerThread = new Thread(new ThreadStart(ExecuteEventCommands));
            _eventHandlerThread.Start();

            _jwriter = new JournalWriter(Configuration.BasePath, dbname);

            if (Configuration.EnableOperationsLog)
            {
                _operationsLog = new JournalWriter(Configuration.BasePath, dbname, true);
            }

            // The journal can be empty so i have to evaluate the last committed command serial number
            // and reset Command Serial number in the journal to ensure command execution coherency.
            _jwriter.CommandSN = Math.Max(jsn, lastcommittedcommandsn);
        }
Exemple #2
0
        public static void ShutDown()
        {
            JournalWriter.RaiseCloseEvent();
            ShuttingDown = true;
            ShutDownEvent.Set();
            if (_saveDBThread != null)
            {
                _saveDBThread.Join((int)new TimeSpan(0, 5, 0).TotalMilliseconds);
            }

            // remove all Event Store
            lock (_eventStore)
                _eventStore.Clear();
            lock (_stores)
                _stores.Clear();

            _started = false;
        }
Exemple #3
0
    internal EventStore(string dbname, long lastcommittedcommandsn)
    {
      DatabaseName = dbname;

      LastExecutedCommandSN = lastcommittedcommandsn;

      JournalReader _jreader = new JournalReader(Configuration.BasePath, dbname);
      long jsn = LoadUncommittedEventsFromJournal(_jreader);
      _jreader.CloseFile();

      _eventHandlerThread = new Thread(new ThreadStart(ExecuteEventCommands));
      _eventHandlerThread.Start();

      _jwriter = new JournalWriter(Configuration.BasePath, dbname);

      if (Configuration.EnableOperationsLog)
        _operationsLog = new JournalWriter(Configuration.BasePath, dbname, true);

      // The journal can be empty so i have to evaluate the last committed command serial number 
      // and reset Command Serial number in the journal to ensure command execution coherency.
      _jwriter.CommandSN = Math.Max(jsn, lastcommittedcommandsn);
    }