Renkai commented on a change in pull request #9096:
URL: https://github.com/apache/pulsar/pull/9096#discussion_r554901542



##########
File path: 
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/LedgerOffloader.java
##########
@@ -35,6 +39,78 @@
 @InterfaceStability.Evolving
 public interface LedgerOffloader {
 
+    @ToString
+    class SegmentInfo {
+        public SegmentInfo(UUID uuid, long beginLedger, long beginEntry, 
String driverName,
+                           Map<String, String> driverMetadata) {
+            this.uuid = uuid;
+            this.beginLedger = beginLedger;
+            this.beginEntry = beginEntry;
+            this.driverName = driverName;
+            this.driverMetadata = driverMetadata;
+        }
+
+
+        public final UUID uuid;
+        public final long beginLedger;
+        public final long beginEntry;
+        public final String driverName;
+        volatile private long endLedger;
+        volatile private long endEntry;
+        volatile boolean closed = false;
+        public final Map<String, String> driverMetadata;
+
+        public boolean isClosed() {
+            return closed;
+        }
+
+        public void closeSegment(long endLedger, long endEntry) {
+            this.endLedger = endLedger;
+            this.endEntry = endEntry;
+            this.closed = true;
+        }
+
+        public OffloadResult result() {
+            return new OffloadResult(beginLedger, beginEntry, endLedger, 
endEntry);
+        }
+    }
+
+
+    class OffloadResult {
+        public final long beginLedger;
+        public final long beginEntry;
+        public final long endLedger;
+        public final long endEntry;
+
+        public OffloadResult(long beginLedger, long beginEntry, long 
endLedger, long endEntry) {
+            this.beginLedger = beginLedger;
+            this.beginEntry = beginEntry;
+            this.endLedger = endLedger;
+            this.endEntry = endEntry;
+        }
+    }
+
+    /**
+     * Used to store driver info, buffer entries, mark progress, etc.
+     * Create one per second.
+     */
+    interface OffloaderHandle {
+
+        /**
+         * return true when both buffer have enough size and ledger/entry id 
is next to the current one.
+         * @param size
+         * @return
+         */
+        boolean canOffer(long size);
+
+        PositionImpl lastOffered();
+
+        boolean offerEntry(EntryImpl entry) throws 
OffloadSegmentClosedException,
+                ManagedLedgerException.OffloadNotConsecutiveException;

Review comment:
       @codelipenghui managedledger can do a full in-depth check use for ledger 
information, but managed ledger will also use a naive check(if ledger id equals 
and entry id is consecutive, then it is consecutive, that's most common case), 
that can be used to spot bugs when managedledger not work properly.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to