public int getMaxSegmentNum() throws IOException { return getMaxSegmentNum(dir); }
public int getMaxSegmentNum() throws IOException { return getMaxSegmentNum(dir); }
@Export(name = "max-segment-num", doc = "The max segment number that exists in directory") public int getMaxSegmentNum() throws IOException { return recordLogDirectory.getMaxSegmentNum(); }
@Export(name = "max-segment-num", doc = "The max segment number that exists in directory") public int getMaxSegmentNum() throws IOException { return recordLogDirectory.getMaxSegmentNum(); }
public static int getMaxSegmentNum(File path) throws IOException { int maxSegmentNum = -1; int maxDir = -1; if (path.exists()) { for (File f : path.listFiles()) { final String name = f.getName(); if (name.matches("\\d+") && f.isDirectory()) { final int dirNum = Integer.parseInt(name); if (dirNum > maxDir) maxDir = dirNum; } else if (name.matches("\\d+\\.rec")) { final int segmentNum = Integer.parseInt(name.substring(0, name.length()-4)); if (segmentNum > maxSegmentNum) maxSegmentNum = segmentNum; } } if (maxSegmentNum >= 0) return maxSegmentNum; if (maxDir >= 0) return getMaxSegmentNum(new File(path, String.format("%03d", maxDir))); } return -1; }
public static int getMaxSegmentNum(File path) throws IOException { int maxSegmentNum = -1; int maxDir = -1; if (path.exists()) { for (File f : path.listFiles()) { final String name = f.getName(); if (name.matches("\\d+") && f.isDirectory()) { final int dirNum = Integer.parseInt(name); if (dirNum > maxDir) maxDir = dirNum; } else if (name.matches("\\d+\\.rec")) { final int segmentNum = Integer.parseInt(name.substring(0, name.length()-4)); if (segmentNum > maxSegmentNum) maxSegmentNum = segmentNum; } } if (maxSegmentNum >= 0) return maxSegmentNum; if (maxDir >= 0) return getMaxSegmentNum(new File(path, String.format("%03d", maxDir))); } return -1; }
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(); }