You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/01/11 04:28:03 UTC

[GitHub] [pulsar] sijie commented on a change in pull request #9096: PIP 76: Streaming Offload(Part I)

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



##########
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 {

Review comment:
       Same question as above. Can we make it an interface?

##########
File path: managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedger.java
##########
@@ -594,4 +593,6 @@ void asyncSetProperties(Map<String, String> properties, final AsyncCallbacks.Upd
      * Get the ManagedLedgerInterceptor for ManagedLedger.
      * */
     ManagedLedgerInterceptor getManagedLedgerInterceptor();
+
+    CompletableFuture<LedgerMetadata> getRawLedgerMetadata(long ledgerId);

Review comment:
       Can you explain why do we need this method? Also, add a comment to this method?

##########
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,

Review comment:
       +1

##########
File path: managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedger.java
##########
@@ -594,4 +593,6 @@ void asyncSetProperties(Map<String, String> properties, final AsyncCallbacks.Upd
      * Get the ManagedLedgerInterceptor for ManagedLedger.
      * */
     ManagedLedgerInterceptor getManagedLedgerInterceptor();
+
+    CompletableFuture<LedgerMetadata> getRawLedgerMetadata(long ledgerId);

Review comment:
       I would like to see if we can avoid adding `LedgerMetadata` here. Because `LedgerMetadata` is a specific interface for bookkeeper. We should avoid binding the metadata format to bookkeeper's ledger metadata. This would simplify tiered storage integration.

##########
File path: tiered-storage/jcloud/src/main/java/org/apache/bookkeeper/mledger/offload/jcloud/StreamingOffloadIndexBlock.java
##########
@@ -0,0 +1,93 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bookkeeper.mledger.offload.jcloud;
+
+import java.io.Closeable;
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+import org.apache.bookkeeper.client.api.LedgerMetadata;
+import org.apache.bookkeeper.common.annotation.InterfaceStability.Unstable;
+
+/**
+ * The Index block abstraction used for offload a ledger to long term storage.
+ */
+@Unstable
+public interface StreamingOffloadIndexBlock extends Closeable {

Review comment:
       +1

##########
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 {

Review comment:
       This should be an interface not a class.

##########
File path: tiered-storage/jcloud/src/test/java/org/apache/bookkeeper/mledger/offload/jcloud/impl/BlobStoreManagedLedgerOffloaderBase.java
##########
@@ -82,7 +71,11 @@ protected static MockZooKeeper createMockZooKeeper() throws Exception {
                 CreateMode.PERSISTENT);
         return zk;
     }
-    
+
+    protected static MockManagedLedger createMockManagedLedger() {

Review comment:
       Can you explain why do you add a "Mock" method in the actual implementation?




----------------------------------------------------------------
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:
users@infra.apache.org