mimaison commented on code in PR #17042: URL: https://github.com/apache/kafka/pull/17042#discussion_r1760327357
########## storage/src/main/java/org/apache/kafka/storage/internals/log/LocalLog.java: ########## @@ -0,0 +1,330 @@ +/* + * 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.storage.internals.log; + +import org.apache.kafka.common.TopicPartition; +import org.apache.kafka.common.errors.KafkaStorageException; +import org.apache.kafka.common.record.FileLogInputStream; +import org.apache.kafka.common.record.FileRecords; +import org.apache.kafka.common.utils.Time; +import org.apache.kafka.common.utils.Utils; +import org.apache.kafka.server.util.Scheduler; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Set; +import java.util.function.Supplier; +import java.util.stream.Collectors; + +import static org.apache.kafka.common.utils.Utils.require; +import static org.apache.kafka.storage.internals.log.LogFileUtils.CLEANED_FILE_SUFFIX; +import static org.apache.kafka.storage.internals.log.LogFileUtils.DELETED_FILE_SUFFIX; +import static org.apache.kafka.storage.internals.log.LogFileUtils.SWAP_FILE_SUFFIX; +import static org.apache.kafka.storage.internals.log.LogFileUtils.isLogFile; + +public class LocalLog { + + private static final Logger LOG = LoggerFactory.getLogger(LocalLog.class); + + /** + * Invokes the provided function and handles any IOException raised by the function by marking the + * provided directory offline. + * + * @param logDirFailureChannel Used to asynchronously handle log directory failure. + * @param logDir The log directory to be marked offline during an IOException. + * @param errorMsgSupplier The supplier for the error message to be used when marking the log directory offline. + * @param function The function to be executed. + * @return The value returned by the function after a successful invocation + */ + public static <T> T maybeHandleIOException(LogDirFailureChannel logDirFailureChannel, Review Comment: Ah right, I see what you meant now. Done -- 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]
