Exemplo n.º 1
0
        /// <summary>
        /// Creates a segment that stores data in memory mapped files
        /// </summary>
        internal override DefaultPileBase._segment MakeSegment(int segmentNumber)
        {
            var memory = new MMFMemory(DataDirectory, segmentNumber, SegmentSize);
            var result = new DefaultPileBase._segment(this, memory, true);

            return(result);
        }
Exemplo n.º 2
0
        protected override void DoStart()
        {
            if (!Directory.Exists(DataDirectoryRoot))
            {
                throw new PileException(StringConsts.PILE_MMF_NO_DATA_DIRECTORY_ROOT_ERROR.Args(DataDirectoryRoot));
            }

            Directory.CreateDirectory(DataDirectory);

            readCurrentTypeRegistry();

            base.DoStart();

            //load existing data
            var segFiles = MMFMemory.GetSegmentFileNames(DataDirectory);

            var pidx = -1;

            for (var i = 0; i < segFiles.Length; i++)
            {
                var segFile = segFiles[i];
                for (var j = pidx + 1; j < segFile.Value; j++)
                {
                    __addSegmentAtStart(null);
                }
                pidx = segFile.Value;

                var memory  = new MMFMemory(DataDirectory, segFile.Value);
                var segment = new DefaultPileBase._segment(this, memory, false);
                __addSegmentAtStart(segment);
            }

            //1 thread since this is a io-bound operation
            var segments = __getSegmentsAtStart();

            Task.Delay(500).ContinueWith((a) => crawlSegmentsAtStart(segments), TaskContinuationOptions.LongRunning);

            m_ManagerEvent = new Azos.Time.Event(App.EventTimer,
                                                 interval: new TimeSpan(0, 0, 20),
                                                 enabled: true,
                                                 body: _ => AcceptManagerVisit(this, DateTime.UtcNow),
                                                 bodyAsyncModel: Time.EventBodyAsyncModel.AsyncTask)
            {
            };
        }