Example #1
0
        private unsafe void CreateNewTable()
        {
            // Initialize table.
            _tableHeaderStorage.Create();
            _logsStorage.Create();
            _logsDataStorage.Create();
            _categoriesStorage.Create();

            var datetime = DateTime.UtcNow;

            var now = datetime.ToTimestamp();

            _tableHeaderStructure = new RaxTableHeader
            {
                MinTimestamp           = now,
                MaxTimestamp           = now,
                TotalLogsCount         = 0,
                CategoriesCount        = 0,
                LogsDataNextFreeOffset = 0
            };

            GetOrCreateYearIndexStorage(datetime.Year);
            _tableHeaderStorage.WriteStructure(ref _tableHeaderStructure);

            CreateInitialCategories();
            void CreateInitialCategories()
            {
                var categoryBuffer = ArrayPool <byte> .Shared.Rent(_catSize);

                WriteCategoryToStorage(categoryBuffer, CreateCategory("TRACE"));
                WriteCategoryToStorage(categoryBuffer, CreateCategory("DEBUG"));
                WriteCategoryToStorage(categoryBuffer, CreateCategory("INFO"));
                WriteCategoryToStorage(categoryBuffer, CreateCategory("WARNING"));
                WriteCategoryToStorage(categoryBuffer, CreateCategory("ERROR"));
                WriteCategoryToStorage(categoryBuffer, CreateCategory("CRITICAL"));
                ArrayPool <byte> .Shared.Return(categoryBuffer);
            }

            AppendLogs(new RaxNewLog[]
            {
                new RaxNewLog
                {
                    Message    = "SYSTEM READY.".ToCharArray(),
                    Categories = new[] { "@SYS_INFO" },
                    Timestamp  = now
                }
            });
        }
Example #2
0
        public override void Create()
        {
            _indexAndHeaderStorage.Create();
            _appendOnlyDataStorage.Create();
            _compressedStorage.Create();

            _header = new CompressedStorageHeader
            {
                CompressedBlocksCount               = 0,
                NextCompressedBlockOffseet          = 0,
                TotalCompressedBytesCount           = 0,
                TotalProcessedBytesCount            = 0,
                RemainingBytesInUncompressedStorage = 0
            };
            _indexAndHeaderStorage.WriteStructure(0, ref _header);

            Initialize();
        }