private Writer( File file, Serializer<E> serializer, CompressionCodec codec, final long rollFrequency, int blockSize, int fileIndexBits, int recordIndexBits, int padBits, int maxSegment ) throws IOException { this.path = file; this.serializer = serializer; this.codec = codec; this.blockSize = blockSize; this.recordIndexBits = recordIndexBits; this.padBits = padBits; segmentShift = 64-fileIndexBits; this.tmpPath = new File(file, "tmp"); this.rollFrequency = rollFrequency; tmpPath.mkdirs(); if (maxSegment < 0) { currentSegmentNum = getMaxSegmentNum(path); if (currentSegmentNum == -1 || verifySegmentIntegrity(path, currentSegmentNum)) currentSegmentNum++; } else { currentSegmentNum = maxSegment+1; } log.info("current segment num: "+currentSegmentNum); currentWriter = createWriter(currentSegmentNum); lastRollTime = System.currentTimeMillis(); }
private Writer( File file, Serializer<E> serializer, CompressionCodec codec, final long rollFrequency, int blockSize, int fileIndexBits, int recordIndexBits, int padBits, int maxSegment ) throws IOException { this.path = file; this.serializer = serializer; this.codec = codec; this.blockSize = blockSize; this.recordIndexBits = recordIndexBits; this.padBits = padBits; segmentShift = 64-fileIndexBits; this.tmpPath = new File(file, "tmp"); this.rollFrequency = rollFrequency; tmpPath.mkdirs(); if (maxSegment < 0) { currentSegmentNum = getMaxSegmentNum(path); if (currentSegmentNum == -1 || verifySegmentIntegrity(path, currentSegmentNum)) currentSegmentNum++; } else { currentSegmentNum = maxSegment+1; } log.info("current segment num: "+currentSegmentNum); currentWriter = createWriter(currentSegmentNum); lastRollTime = System.currentTimeMillis(); }
public void roll() throws IOException { currentWriter.sync(); currentWriter.close(); final File segmentFile = getSegmentPath(path, currentSegmentNum, true); currentWriterPath.renameTo(segmentFile); currentWriter = createWriter(++currentSegmentNum); lastRollTime = System.currentTimeMillis(); }
public void roll() throws IOException { currentWriter.sync(); currentWriter.close(); final File segmentFile = getSegmentPath(path, currentSegmentNum, true); currentWriterPath.renameTo(segmentFile); currentWriter = createWriter(++currentSegmentNum); lastRollTime = System.currentTimeMillis(); }