예제 #1
0
파일: Chunk.cs 프로젝트: zzms/estore
        private Chunk(string filename, ChunkManager chunkManager, ChunkManagerConfig chunkConfig, bool isMemoryChunk)
        {
            Ensure.NotNullOrEmpty(filename, "filename");
            Ensure.NotNull(chunkManager, "chunkManager");
            Ensure.NotNull(chunkConfig, "chunkConfig");

            _filename       = filename;
            _chunkManager   = chunkManager;
            _chunkConfig    = chunkConfig;
            _isMemoryChunk  = isMemoryChunk;
            _lastActiveTime = DateTime.Now;
        }
예제 #2
0
파일: ChunkManager.cs 프로젝트: zzms/estore
        public ChunkManager(string name, ChunkManagerConfig config, string relativePath = null)
        {
            Ensure.NotNull(name, "name");
            Ensure.NotNull(config, "config");

            Name    = name;
            _config = config;
            if (string.IsNullOrEmpty(relativePath))
            {
                _chunkPath = _config.BasePath;
            }
            else
            {
                _chunkPath = Path.Combine(_config.BasePath, relativePath);
            }
            _chunks          = new ConcurrentDictionary <int, Chunk>();
            _scheduleService = ObjectContainer.Resolve <IScheduleService>();
        }
예제 #3
0
파일: Chunk.cs 프로젝트: zzms/estore
        public static Chunk FromOngoingFile <T>(string filename, ChunkManager chunkManager, ChunkManagerConfig config, Func <byte[], T> readRecordFunc, bool isMemoryChunk = false) where T : ILogRecord
        {
            var chunk = new Chunk(filename, chunkManager, config, isMemoryChunk);

            try
            {
                chunk.InitOngoing(readRecordFunc);
            }
            catch (OutOfMemoryException)
            {
                chunk.Dispose();
                throw;
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("Chunk {0} init from ongoing file failed.", chunk), ex);
                chunk.Dispose();
                throw;
            }

            return(chunk);
        }
예제 #4
0
파일: Chunk.cs 프로젝트: zzms/estore
        public static Chunk FromCompletedFile(string filename, ChunkManager chunkManager, ChunkManagerConfig config, bool isMemoryChunk = false)
        {
            var chunk = new Chunk(filename, chunkManager, config, isMemoryChunk);

            try
            {
                chunk.InitCompleted();
            }
            catch (OutOfMemoryException)
            {
                chunk.Dispose();
                throw;
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("Chunk {0} init from completed file failed.", chunk), ex);
                chunk.Dispose();
                throw;
            }

            return(chunk);
        }
예제 #5
0
파일: Chunk.cs 프로젝트: zzms/estore
        public static Chunk CreateNew(string filename, int chunkNumber, ChunkManager chunkManager, ChunkManagerConfig config, bool isMemoryChunk = false)
        {
            var chunk = new Chunk(filename, chunkManager, config, isMemoryChunk);

            try
            {
                chunk.InitNew(chunkNumber);
            }
            catch (OutOfMemoryException)
            {
                chunk.Dispose();
                throw;
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("Chunk {0} create failed.", chunk), ex);
                chunk.Dispose();
                throw;
            }

            return(chunk);
        }