Пример #1
0
        public static Chunk FromCompletedFile(string filename, ChunkManager chunkManager, ChunkManagerConfig config, bool isMemoryChunk)
        {
            var chunk = new Chunk(filename, chunkManager, config, isMemoryChunk);

            try
            {
                chunk.InitCompleted();
            }
            catch (OutOfMemoryException)
            {
                chunk.Dispose();
                throw;
            }
            catch (Exception ex)
            {
                QueueService.Log.Info(string.Format("Chunk {0} init from completed file failed.", chunk));
                XTrace.WriteException(ex);
                chunk.Dispose();
                throw;
            }

            return(chunk);
        }
Пример #2
0
        public static Chunk FromOngoingFile <T>(string filename, ChunkManager chunkManager, ChunkManagerConfig config, Func <byte[], T> readRecordFunc, bool isMemoryChunk) where T : ILogRecord
        {
            var chunk = new Chunk(filename, chunkManager, config, isMemoryChunk);

            try
            {
                chunk.InitOngoing(readRecordFunc);
            }
            catch (OutOfMemoryException)
            {
                chunk.Dispose();
                throw;
            }
            catch (Exception ex)
            {
                QueueService.Log.Info(string.Format("Chunk {0} init from ongoing file failed.", chunk));
                XTrace.WriteException(ex);
                chunk.Dispose();
                throw;
            }

            return(chunk);
        }
Пример #3
0
        public static Chunk CreateNew(string filename, int chunkNumber, ChunkManager chunkManager, ChunkManagerConfig config, bool isMemoryChunk)
        {
            var chunk = new Chunk(filename, chunkManager, config, isMemoryChunk);

            try
            {
                chunk.InitNew(chunkNumber);
            }
            catch (OutOfMemoryException)
            {
                chunk.Dispose();
                throw;
            }
            catch (Exception ex)
            {
                QueueService.Log.Info(string.Format("Chunk {0} create failed.", chunk));
                XTrace.WriteException(ex);
                chunk.Dispose();
                throw;
            }

            return(chunk);
        }
Пример #4
0
        public ChunkWriter(ChunkManager chunkManager)
        {
            Ensure.NotNull(chunkManager, "chunkManager");

            _chunkManager = chunkManager;
        }