@Export(name="max-segment-timestamp", doc = "Timestamp of max segment written to record log directory") public long getMaxSegmentTimestamp() { return getSegmentPath(getMaxSegment()).lastModified(); }
/** * Creates a new segment file and flushes buffered writes to disk. * Provided metadata is written to record_log_directory_root/metadata.json * * @param metadata a mutable map of metadata to be written, may be empty. * @throws IOException if an I/O error occurs */ public synchronized void flushWriter(@Nonnull Map<String, String> metadata) throws IOException { writer.roll(); maxSegment = (int)(lastPosition >>> (64-RecordLogDirectory.DEFAULT_FILE_INDEX_BITS)); metadata.put(LAST_POSITION_KEY, String.valueOf(lastPosition)); metadata.put(MAX_SEGMENT_KEY, String.valueOf(maxSegment)); writeStringToFile(metadataPath, mapper.writeValueAsString(metadata)); writeStringToFile(lastPositionPath, String.valueOf(lastPosition)); writeStringToFile(maxSegmentPath, String.valueOf(maxSegment)); }
metadataPath = new File(file, "metadata.json"); if (metadataPath.exists()) { Map<String, String> metadata = readMetadata(metadataPath, mapper); if (metadataRef != null) metadataRef.set(metadata); lastPosition = Long.parseLong(metadata.get(LAST_POSITION_KEY)); log.info("maxsegment: "+maxSegment); } else { lastPosition = readLongFromFile(lastPositionPath, 0); maxSegment = -1;
@Export(name="max-segment-timestring", doc = "Same as max-segment-timestamp but just in human readable form") public String getMaxSegmentTimestring() { return new DateTime(getMaxSegmentTimestamp()).toString(); }
metadataPath = new File(file, "metadata.json"); if (metadataPath.exists()) { Map<String, String> metadata = readMetadata(metadataPath, mapper); if (metadataRef != null) metadataRef.set(metadata); lastPosition = Long.parseLong(metadata.get(LAST_POSITION_KEY)); log.info("maxsegment: "+maxSegment); } else { lastPosition = readLongFromFile(lastPositionPath, 0); maxSegment = -1;
@Export(name="max-segment-timestring", doc = "Same as max-segment-timestamp but just in human readable form") public String getMaxSegmentTimestring() { return new DateTime(getMaxSegmentTimestamp()).toString(); }
@Export(name="max-segment-timestamp", doc = "Timestamp of max segment written to record log directory") public long getMaxSegmentTimestamp() { return getSegmentPath(getMaxSegment()).lastModified(); }
/** * Creates a new segment file and flushes buffered writes to disk. * Provided metadata is written to record_log_directory_root/metadata.json * * @param metadata a mutable map of metadata to be written, may be empty. * @throws IOException if an I/O error occurs */ public synchronized void flushWriter(@Nonnull Map<String, String> metadata) throws IOException { writer.roll(); maxSegment = (int)(lastPosition >>> (64-RecordLogDirectory.DEFAULT_FILE_INDEX_BITS)); metadata.put(LAST_POSITION_KEY, String.valueOf(lastPosition)); metadata.put(MAX_SEGMENT_KEY, String.valueOf(maxSegment)); writeStringToFile(metadataPath, mapper.writeValueAsString(metadata)); writeStringToFile(lastPositionPath, String.valueOf(lastPosition)); writeStringToFile(maxSegmentPath, String.valueOf(maxSegment)); }