@@ -54,6 +54,8 @@ public class DbStats {
5454 private final long totalUploads ;
5555 private final long totalUploadFailures ;
5656 private final boolean replicaMode ;
57+ private final long primaryEpoch ;
58+ private final long seenEpoch ;
5759 private final long uwalBytesWritten ;
5860 private final long walBytesWritten ;
5961 private final long flushBytesWritten ;
@@ -75,6 +77,7 @@ public DbStats(int numColumnFamilies, long totalMemory, long availableMemory,
7577 long localCacheBytesUsed , long localCacheBytesMax , int localCacheNumFiles ,
7678 long lastUploadedGeneration , long uploadQueueDepth ,
7779 long totalUploads , long totalUploadFailures , boolean replicaMode ,
80+ long primaryEpoch , long seenEpoch ,
7881 long uwalBytesWritten , long walBytesWritten , long flushBytesWritten ,
7982 long compactionBytesWritten , long compactionBytesRead , long userBytesWritten ,
8083 long flushCount , long compactionCount ) {
@@ -109,6 +112,8 @@ public DbStats(int numColumnFamilies, long totalMemory, long availableMemory,
109112 this .totalUploads = totalUploads ;
110113 this .totalUploadFailures = totalUploadFailures ;
111114 this .replicaMode = replicaMode ;
115+ this .primaryEpoch = primaryEpoch ;
116+ this .seenEpoch = seenEpoch ;
112117 this .uwalBytesWritten = uwalBytesWritten ;
113118 this .walBytesWritten = walBytesWritten ;
114119 this .flushBytesWritten = flushBytesWritten ;
@@ -243,6 +248,27 @@ public boolean isReplicaMode() {
243248 return replicaMode ;
244249 }
245250
251+ /**
252+ * Gets the lease epoch this primary currently holds (object-store single-writer fencing).
253+ * Returns 0 when this node is not a primary or holds no lease. A promotion that takes
254+ * effect bumps this value.
255+ *
256+ * @return the current primary lease epoch, or 0 if not a primary
257+ */
258+ public long getPrimaryEpoch () {
259+ return primaryEpoch ;
260+ }
261+
262+ /**
263+ * Gets the highest lease epoch this node has observed (object-store single-writer fencing).
264+ * A fenced primary sees {@link #isReplicaMode()} flip back to true once a newer epoch is seen.
265+ *
266+ * @return the highest observed lease epoch
267+ */
268+ public long getSeenEpoch () {
269+ return seenEpoch ;
270+ }
271+
246272 /**
247273 * Gets the framed bytes appended to the shared unified WAL (lifetime since open).
248274 * Returns 0 when unified memtable mode is off.
@@ -355,6 +381,8 @@ public String toString() {
355381 ", totalUploads=" + totalUploads +
356382 ", totalUploadFailures=" + totalUploadFailures +
357383 ", replicaMode=" + replicaMode +
384+ ", primaryEpoch=" + primaryEpoch +
385+ ", seenEpoch=" + seenEpoch +
358386 ", uwalBytesWritten=" + uwalBytesWritten +
359387 ", walBytesWritten=" + walBytesWritten +
360388 ", flushBytesWritten=" + flushBytesWritten +
0 commit comments