ijuma commented on code in PR #13039:
URL: https://github.com/apache/kafka/pull/13039#discussion_r1059505967


##########
storage/src/main/java/org/apache/kafka/server/log/internals/SnapshotFile.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * 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.kafka.server.log.internals;
+
+import org.apache.kafka.common.utils.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+
+public class SnapshotFile {
+    private static final Logger log = 
LoggerFactory.getLogger(SnapshotFile.class);
+
+    public static long offsetFromFileName(String fileName) {

Review Comment:
   Looks like this is duplicating some logic that is also present in 
`UnifiedLog`. Would it make sense to move it to a `LogFileUtils` class?



##########
clients/src/main/java/org/apache/kafka/common/utils/Utils.java:
##########
@@ -1488,4 +1488,12 @@ public static String toLogDateTimeFormat(long timestamp) 
{
         return 
Instant.ofEpochMilli(timestamp).atZone(ZoneId.systemDefault()).format(dateTimeFormatter);
     }
 
+    /**
+     * Replace the given string suffix with the new suffix. If the string 
doesn't end with the given suffix throw an exception.
+     */
+    public static String replaceSuffix(String name, String oldSuffix, String 
newSuffix) {

Review Comment:
   Nit: `name` should probably be `s` or something that makes it clear that it 
can be any string, not just a name.
   
   Also, can we replace `CoreUtils.replaceSuffix` with this method and ensure 
we have unit tests for this new method?



##########
storage/src/main/java/org/apache/kafka/server/log/internals/SnapshotFile.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * 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.kafka.server.log.internals;
+
+import org.apache.kafka.common.utils.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+
+public class SnapshotFile {
+    private static final Logger log = 
LoggerFactory.getLogger(SnapshotFile.class);
+
+    public static long offsetFromFileName(String fileName) {
+        return Long.parseLong(fileName.substring(0, fileName.indexOf('.')));
+    }
+
+    private volatile File file;
+    public final long offset;

Review Comment:
   Nit: let's place `public` fields first.



-- 
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: jira-unsubscr...@kafka.apache.org

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

Reply via email to