You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "aaron-ai (via GitHub)" <gi...@apache.org> on 2023/05/30 08:58:40 UTC

[GitHub] [rocketmq] aaron-ai commented on a diff in pull request #6781: [ISSUE #6633] [RIP-65] Improving Tiered Storage Implementation

aaron-ai commented on code in PR #6781:
URL: https://github.com/apache/rocketmq/pull/6781#discussion_r1209691904


##########
tieredstore/src/main/java/org/apache/rocketmq/tieredstore/provider/posix/PosixFileSegment.java:
##########
@@ -46,47 +47,49 @@
  * this class is experimental and may change without notice.
  */
 public class PosixFileSegment extends TieredFileSegment {
+
     private static final Logger logger = LoggerFactory.getLogger(TieredStoreUtil.TIERED_STORE_LOGGER_NAME);
 
+    private static final String UNDERLINE = "_";
     private static final String OPERATION_POSIX_READ = "read";
     private static final String OPERATION_POSIX_WRITE = "write";
 
-    private final String basePath;
-    private final String filepath;
-
+    private final String fullPath;
     private volatile File file;
     private volatile FileChannel readFileChannel;
     private volatile FileChannel writeFileChannel;
 
-    public PosixFileSegment(FileSegmentType fileType, MessageQueue messageQueue,
-        long baseOffset, TieredMessageStoreConfig storeConfig) {
-        super(fileType, messageQueue, baseOffset, storeConfig);
+    public PosixFileSegment(TieredMessageStoreConfig storeConfig,
+        FileSegmentType fileType, String filePath, long baseOffset) {
+
+        super(storeConfig, fileType, filePath, baseOffset);
+
+        // basePath
+        String basePath = StringUtils.defaultString(storeConfig.getTieredStoreFilePath(),
+            StringUtils.appendIfMissing(storeConfig.getTieredStoreFilePath(), File.separator));
+
+        // fullPath: basePath/hash_cluster/broker/topic/queueId/fileType/baseOffset
+        String brokerClusterName = storeConfig.getBrokerClusterName();
+        String clusterBasePath = TieredStoreUtil.getHash(brokerClusterName) + UNDERLINE + brokerClusterName;
+        this.fullPath = Paths.get(File.separator, basePath, clusterBasePath, filePath,
+                fileType.toString(), TieredStoreUtil.offset2FileName(baseOffset)).toString();
 
-        String basePath = storeConfig.getTieredStoreFilepath();
-        if (StringUtils.isBlank(basePath) || basePath.endsWith(File.separator)) {
-            this.basePath = basePath;
-        } else {
-            this.basePath = basePath + File.separator;
-        }
-        this.filepath = this.basePath
-            + TieredStoreUtil.getHash(storeConfig.getBrokerClusterName()) + "_" + storeConfig.getBrokerClusterName() + File.separator
-            + messageQueue.getBrokerName() + File.separator
-            + messageQueue.getTopic() + File.separator
-            + messageQueue.getQueueId() + File.separator
-            + fileType + File.separator
-            + TieredStoreUtil.offset2FileName(baseOffset);
         createFile();
     }
 
     protected AttributesBuilder newAttributesBuilder() {
+        //return TieredStoreMetricsManager.newAttributesBuilder()
+        //    .put(LABEL_TOPIC, getMessageQueue().getTopic())

Review Comment:
   Remote the outdated code here.



##########
tieredstore/src/main/java/org/apache/rocketmq/tieredstore/file/CompositeAccess.java:
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.rocketmq.tieredstore.file;
+
+import java.nio.ByteBuffer;
+import java.util.concurrent.CompletableFuture;
+import org.apache.rocketmq.store.DispatchRequest;
+import org.apache.rocketmq.tieredstore.common.AppendResult;
+import org.apache.rocketmq.tieredstore.common.BoundaryType;
+
+interface CompositeAccess {
+
+    /**
+     * Initializes the offset for the flat file.

Review Comment:
   Since we have extracted `CompositeAccess` from `CompositeQueueFlatFile`, could we replace the `CompositeQueueFlatFile` with `CompositeAccess` to avoid exposing some details? such as the return value of `TieredFlatFileManager#deepCopyFlatFileToList`.



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

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org