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 18:07:01 UTC

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

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



##########
File path: managed-ledger/src/main/proto/MLDataFormats.proto
##########
@@ -32,12 +32,23 @@ message OffloadDriverMetadata {
 }
 
 message OffloadContext {
-    optional int64 uidMsb = 1;
-    optional int64 uidLsb = 2;
-    optional bool complete = 3;
-    optional bool bookkeeperDeleted = 4;
-    optional int64 timestamp = 5;
-    optional OffloadDriverMetadata driverMetadata = 6;
+  optional int64 uidMsb = 1;
+  optional int64 uidLsb = 2;
+  optional bool complete = 3;
+  optional bool bookkeeperDeleted = 4;
+  optional int64 timestamp = 5;
+  optional OffloadDriverMetadata driverMetadata = 6;
+  repeated OffloadSegment offloadSegment = 7;
+}
+
+message OffloadSegment {
+  optional int64 uidMsb = 1;
+  optional int64 uidLsb = 2;
+  optional bool complete = 3;
+  optional int64 assignedTimestamp = 5; //timestamp in millisecond
+  optional int64 offloadedTimestamp = 6; //timestamp in millisecond
+  optional int64 endEntryId = 7;
+  optional OffloadDriverMetadata driverMetadata = 8;

Review comment:
       The indent could be consistent with others.

##########
File path: managed-ledger/src/main/proto/MLDataFormats.proto
##########
@@ -32,12 +32,23 @@ message OffloadDriverMetadata {
 }
 
 message OffloadContext {
-    optional int64 uidMsb = 1;
-    optional int64 uidLsb = 2;
-    optional bool complete = 3;
-    optional bool bookkeeperDeleted = 4;
-    optional int64 timestamp = 5;
-    optional OffloadDriverMetadata driverMetadata = 6;
+  optional int64 uidMsb = 1;
+  optional int64 uidLsb = 2;
+  optional bool complete = 3;
+  optional bool bookkeeperDeleted = 4;
+  optional int64 timestamp = 5;
+  optional OffloadDriverMetadata driverMetadata = 6;
+  repeated OffloadSegment offloadSegment = 7;
+}
+
+message OffloadSegment {
+  optional int64 uidMsb = 1;
+  optional int64 uidLsb = 2;
+  optional bool complete = 3;
+  optional int64 assignedTimestamp = 5; //timestamp in millisecond

Review comment:
       The filed number is not continuous.

##########
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 {
+
+    /**
+     * Get the content of the index block as InputStream.
+     * Read out in format:
+     *   | index_magic_header | index_block_len | index_entry_count |
+     *   | data_object_size | segment_metadata_length | segment metadata | index entries ... |
+     */
+    IndexInputStream toStream() throws IOException;
+
+    /**
+     * Get the related OffloadIndexEntry that contains the given messageEntryId.
+     *
+     * @param messageEntryId
+     *                      the entry id of message
+     * @return the offload index entry
+     */
+    OffloadIndexEntry getIndexEntryForEntry(long ledgerId, long messageEntryId) throws IOException;
+
+    public long getStartEntryId(long ledgerId);
+
+    /**
+     * Get the entry count that contained in this index Block.
+     */
+    int getEntryCount();
+
+    /**
+     * Get LedgerMetadata.
+     */
+    Map<Long, LedgerMetadata> getLedgerMetadata();

Review comment:
       Does one `StreamingOffloadIndexBlock` will contain multiple ledgers indexes?

##########
File path: managed-ledger/src/main/java/org/apache/bookkeeper/mledger/LedgerOffloader.java
##########
@@ -115,6 +217,16 @@
     CompletableFuture<Void> deleteOffloaded(long ledgerId, UUID uid,
                                             Map<String, String> offloadDriverMetadata);
 
+    default CompletableFuture<ReadHandle> readOffloaded(long ledgerId, MLDataFormats.OffloadContext ledgerContext,
+                                                        Map<String, String> offloadDriverMetadata) {
+        throw new UnsupportedClassVersionError();

Review comment:
       Maybe the exception should be `UnsupportedOperationException`?




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