Example #1
0
        public static PartitionData <T> CreatePartition <T>(int?recordHint = null, EFileAccess access = EFileAccess.Read, EFileFlags fileFlags = EFileFlags.None)
        {
            var mmFactory = new CompositeFileFactory(fileFlags);

            using (var dbXml = typeof(Quote).Assembly.GetManifestResourceStream(
                       "Apaf.NFSdb.TestShared.Resources.nfsdb.xml"))
            {
                var dbElement = ConfigurationSerializer.ReadConfiguration(dbXml);
                var jconf     = dbElement.Journals.Single(j => j.Class.EndsWith("." + typeof(T).Name));
                if (recordHint.HasValue)
                {
                    jconf.RecordHint = recordHint.Value;
                }
                var journalPath = Path.Combine(FindJournalsPath(), jconf.DefaultPath);
                jconf.DefaultPath = journalPath;

                var metadata       = JournalBuilder.CreateNewJournalMetadata(jconf);
                var startDate      = new DateTime(2013, 10, 1);
                var journalStorage = new ColumnStorage(metadata, jconf.DefaultPath,
                                                       access, 0, mmFactory);

                var part = new Partition(
                    metadata, new CompositeFileFactory(fileFlags),
                    access, new PartitionDate(startDate, 0, metadata.Settings.PartitionType), 0,
                    Path.Combine(jconf.DefaultPath, "2013-10"), new AsyncJournalServer(TimeSpan.FromSeconds(1)));

                return(new PartitionData <T>(part, metadata, journalStorage, journalPath));
            }
        }
Example #2
0
        private static TxLog CreateTxLog()
        {
            var stubFileF = new CompositeFileFactory();

            _logfile = new CompositeRawFile(".\\_tx",
                                            MetadataConstants.PIPE_BIT_HINT, stubFileF,
                                            EFileAccess.ReadWrite, MetadataConstants.SYMBOL_PARTITION_ID,
                                            MetadataConstants.TX_LOG_FILE_ID, MetadataConstants.TX_LOG_FILE_ID, EDataType.Data);

            return(new TxLog(_logfile));
        }
Example #3
0
        public IJournalCore ToJournal()
        {
            var meta        = CreateJournalMetadata(_config);
            var fileFactory = new CompositeFileFactory(_config.FileFlags);

            if (_server != null)
            {
                var partMan = new PartitionManager(meta, _access, fileFactory, _server);
                return(new JournalCore(meta, partMan));
            }
            else
            {
                var server  = new AsyncJournalServer(_serverTasksLatency);
                var partMan = new PartitionManager(meta, _access, fileFactory, server);
                partMan.OnDisposed += server.Dispose;
                return(new JournalCore(meta, partMan));
            }
        }
Example #4
0
        public IJournal <T> ToJournal <T>()
        {
            _config = UpdateConfiguration(_config);
            var serializerFactory =
                JournalSerializerRegistry.Instance.GetSerializer(_config.SerializerName ??
                                                                 MetadataConstants.DEFAULT_SERIALIZER_NAME);
            var meta = new JournalMetadata(_config, serializerFactory, typeof(T));

            var fileFactory = new CompositeFileFactory(_config.FileFlags);

            if (_server != null)
            {
                var partMan = new PartitionManager(meta, _access, fileFactory, _server);
                return(new Journal <T>(meta, partMan, _server));
            }
            else
            {
                var server  = new AsyncJournalServer(_serverTasksLatency);
                var partMan = new PartitionManager(meta, _access, fileFactory, server);
                partMan.OnDisposed += server.Dispose;
                return(new Journal <T>(meta, partMan, _server));
            }
        }