Beispiel #1
0
        /// <summary>
        /// Initializes a new persistent audit trail.
        /// </summary>
        /// <param name="path">The path to the folder to be used by audit trail.</param>
        /// <param name="recordsPerPartition">The maximum number of log entries that can be stored in the single file called partition.</param>
        /// <param name="configuration">The configuration of the persistent audit trail.</param>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="recordsPerPartition"/> is less than 2.</exception>
        public PersistentState(DirectoryInfo path, int recordsPerPartition, Options?configuration = null)
        {
            if (configuration is null)
            {
                configuration = new Options();
            }
            if (recordsPerPartition < 2L)
            {
                throw new ArgumentOutOfRangeException(nameof(recordsPerPartition));
            }
            if (!path.Exists)
            {
                path.Create();
            }
            backupCompression        = configuration.BackupCompression;
            replayOnInitialize       = configuration.ReplayOnInitialize;
            bufferSize               = configuration.BufferSize;
            location                 = path;
            this.recordsPerPartition = recordsPerPartition;
            initialSize              = configuration.InitialPartitionSize;
            commitEvent              = new AsyncManualResetEvent(false);
            sessionManager           = new DataAccessSessionManager(configuration.MaxConcurrentReads, configuration.GetMemoryAllocator <byte>(), bufferSize);
            syncRoot                 = new AsyncSharedLock(sessionManager.Capacity);
            entryPool                = configuration.GetMemoryAllocator <LogEntry>();
            metadataPool             = configuration.UseCaching ? configuration.GetMemoryAllocator <LogEntryMetadata>() : null;
            nullSegment              = new StreamSegment(Stream.Null);
            initialEntry             = new LogEntry(nullSegment, sessionManager.WriteSession.Buffer, new LogEntryMetadata());

            // sorted dictionary to improve performance of log compaction and snapshot installation procedures
            partitionTable = new SortedDictionary <long, Partition>();

            // load all partitions from file system
            foreach (var file in path.EnumerateFiles())
            {
                if (long.TryParse(file.Name, out var partitionNumber))
                {
                    var partition = new Partition(file.Directory, bufferSize, recordsPerPartition, partitionNumber, metadataPool, sessionManager.Capacity);
                    partition.PopulateCache(sessionManager.WriteSession);
                    partitionTable[partitionNumber] = partition;
                }
            }

            state    = new NodeState(path, AsyncLock.Exclusive(syncRoot));
            snapshot = new Snapshot(path, bufferSize, sessionManager.Capacity);
            snapshot.PopulateCache(sessionManager.WriteSession);
        }
 public PremioPortabilidadeDao(DataAccessSessionManager session) : base(session) { }
Beispiel #3
0
 public PremioDesapropriadoDao(DataAccessSessionManager session) : base(session)
 {
 }
Beispiel #4
0
 public Coberturas(DataAccessSessionManager session)
     : base(session)
 {
 }
Beispiel #5
0
 public Eventos(DataAccessSessionManager session)
     : base(session)
 {
 }
Beispiel #6
0
 public MovimentosProvisao(DataAccessSessionManager session) : base(session)
 {
 }
Beispiel #7
0
 public Premios(DataAccessSessionManager session) : base(session)
 {
 }
Beispiel #8
0
 public ProvisaoCobertura(DataAccessSessionManager session)
     : base(session)
 {
 }
 public HistoricoCobertura(DataAccessSessionManager session)
     : base(session)
 {
 }
Beispiel #10
0
 public PremioAporteDao(DataAccessSessionManager session) : base(session)
 {
 }
Beispiel #11
0
 public CoberturaContratadaHelper(DataAccessSessionManager session)
     : base(session)
 {
 }
Beispiel #12
0
 protected PersistenceBase(DataAccessSessionManager session)
 {
     Session = session;
 }