ShadowySpirits commented on code in PR #5875:
URL: https://github.com/apache/rocketmq/pull/5875#discussion_r1069118088


##########
tieredstore/src/main/java/org/apache/rocketmq/store/tiered/util/TieredStoreUtil.java:
##########
@@ -0,0 +1,157 @@
+/*
+ * 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.store.tiered.util;
+
+import java.lang.reflect.Constructor;
+import java.math.BigInteger;
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.util.LinkedList;
+import java.util.List;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.rocketmq.common.topic.TopicValidator;
+import org.apache.rocketmq.logging.org.slf4j.Logger;
+import org.apache.rocketmq.logging.org.slf4j.LoggerFactory;
+import org.apache.rocketmq.store.tiered.common.TieredMessageStoreConfig;
+import org.apache.rocketmq.store.tiered.metadata.TieredMetadataStore;
+
+public class TieredStoreUtil {
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(TieredStoreUtil.TIERED_STORE_LOGGER_NAME);
+
+    private static final long BYTE = 1L;
+    private static final long KB = BYTE << 10;
+    private static final long MB = KB << 10;
+    private static final long GB = MB << 10;
+    private static final long TB = GB << 10;
+    private static final long PB = TB << 10;
+    private static final long EB = PB << 10;
+
+    public static final String TIERED_STORE_LOGGER_NAME = 
"RocketmqTieredStore";
+    public static final String RMQ_SYS_TIERED_STORE_INDEX_TOPIC = 
"rmq_sys_INDEX";
+    public static final String PROXY_HOUSEKEEPING_TOPIC_PREFIX = 
"rocketmq-proxy-";
+    public final static int MSG_ID_LENGTH = 8 + 8;
+
+    private static final DecimalFormat DEC_FORMAT = new DecimalFormat("#.##");
+
+    private final static List<String> SYSTEM_TOPIC_LIST = new 
LinkedList<String>() {
+        {
+            add(RMQ_SYS_TIERED_STORE_INDEX_TOPIC);
+        }
+    };
+
+    private final static List<String> SYSTEM_TOPIC_WHITE_LIST = new 
LinkedList<String>() {
+        {
+        }
+    };
+
+    private volatile static TieredMetadataStore metadataStoreInstance;
+
+    private static String formatSize(long size, long divider, String unitName) 
{
+        return DEC_FORMAT.format((double) size / divider) + unitName;
+    }
+
+    public static String toHumanReadable(long size) {
+        if (size < 0)
+            return String.valueOf(size);
+        if (size >= EB)
+            return formatSize(size, EB, "EB");
+        if (size >= PB)
+            return formatSize(size, PB, "PB");
+        if (size >= TB)
+            return formatSize(size, TB, "TB");
+        if (size >= GB)
+            return formatSize(size, GB, "GB");
+        if (size >= MB)
+            return formatSize(size, MB, "MB");
+        if (size >= KB)
+            return formatSize(size, KB, "KB");
+        return formatSize(size, BYTE, "Bytes");
+    }
+
+    public static String getHash(String str) {
+        try {
+            MessageDigest md = MessageDigest.getInstance("MD5");

Review Comment:
   > hhhhhhhhhhhhhh Does it make sense to explain to a robot?
   
   I meant to explain to the reviewer. ( ̄▽ ̄)"



-- 
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: [email protected]

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

Reply via email to