wchevreuil commented on a change in pull request #3751: URL: https://github.com/apache/hbase/pull/3751#discussion_r731321476
########## File path: hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/FileBasedStoreFileCleanerStatusResource.java ########## @@ -0,0 +1,74 @@ +/* + * + * 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.hadoop.hbase.rest; + +import org.apache.hadoop.hbase.rest.model.FileBasedStoreFileCleanerStatusesModel; +import org.apache.yetus.audience.InterfaceAudience; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import javax.ws.rs.GET; +import javax.ws.rs.Produces; +import javax.ws.rs.core.CacheControl; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.ResponseBuilder; +import javax.ws.rs.core.UriInfo; +import java.io.IOException; + +@InterfaceAudience.Private +public class FileBasedStoreFileCleanerStatusResource extends ResourceBase { Review comment: Same as above for the FileBaseStoreFileCleaner. ########## File path: hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/storefiletracker/StoreFileTracker.java ########## @@ -85,4 +85,11 @@ void replace(Collection<StoreFileInfo> compactedFiles, Collection<StoreFileInfo> * @param builder The table descriptor builder for the given table. */ TableDescriptorBuilder updateWithTrackerConfigs(TableDescriptorBuilder builder); + + /** + * Whether the implementation of this tracker requires you to write to temp directory first, i.e, + * does not allow broken store files under the actual data directory. + */ + boolean requireWritingToTmpDirFirst(); Review comment: Instead of exposing this, would it work if the file cleaner is placed on storefiletracker package? ########## File path: hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/FileBasedStoreFileCleaner.java ########## @@ -0,0 +1,200 @@ +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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.hadoop.hbase.regionserver; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileStatus; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.hbase.ScheduledChore; +import org.apache.hadoop.hbase.Stoppable; +import org.apache.hadoop.hbase.io.HFileLink; +import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; +import org.apache.hadoop.ipc.RemoteException; +import org.apache.yetus.audience.InterfaceAudience; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicLong; + +/** + * This Chore, every time it runs, will clear the unsused HFiles in the data + * folder. + */ +@InterfaceAudience.Private public class FileBasedStoreFileCleaner extends ScheduledChore { Review comment: Shouldn't we have an abstract StoreFileCleaner to concentrate common logic, and then for each SFT implementation specific, we would have an individual cleaner? Because we can't assume that FilaBasedStoreFileTracker would always be on. ########## File path: hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/DefaultCompactor.java ########## @@ -63,22 +63,30 @@ public StoreFileWriter createWriter(InternalScanner scanner, } @Override - protected List<Path> commitWriter(StoreFileWriter writer, FileDetails fd, + protected List<Path> commitWriter(FileDetails fd, CompactionRequestImpl request) throws IOException { List<Path> newFiles = Lists.newArrayList(writer.getPath()); writer.appendMetadata(fd.maxSeqId, request.isAllFiles(), request.getFiles()); writer.close(); + writer = null; Review comment: Why are we nulling this here? Shouldn't it throw IllegalArgumentException if a closed writer is tried to be used? ########## File path: hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/storefiletracker/MigrationStoreFileTracker.java ########## @@ -60,7 +60,7 @@ public MigrationStoreFileTracker(Configuration conf, boolean isPrimaryReplica, S } @Override - protected boolean requireWritingToTmpDirFirst() { + public boolean requireWritingToTmpDirFirst() { Review comment: Same as above. ########## File path: hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java ########## @@ -1895,6 +1976,23 @@ private void initializeThreads() { this.storefileRefresher = new StorefileRefresherChore(storefileRefreshPeriod, onlyMetaRefresh, this, this); } + + int fileBasedStoreFileCleanerPeriod = conf.getInt( + FileBasedStoreFileCleaner.FILEBASED_STOREFILE_CLEANER_PERIOD, + FileBasedStoreFileCleaner.DEFAULT_FILEBASED_STOREFILE_CLEANER_PERIOD); + int fileBasedStoreFileCleanerDelay = conf.getInt( + FileBasedStoreFileCleaner.FILEBASED_STOREFILE_CLEANER_DELAY, + FileBasedStoreFileCleaner.DEFAULT_FILEBASED_STOREFILE_CLEANER_DELAY); + double fileBasedStoreFileCleanerDelayJitter = conf.getDouble( + FileBasedStoreFileCleaner.FILEBASED_STOREFILE_CLEANER_DELAY_JITTER, + FileBasedStoreFileCleaner.DEFAULT_FILEBASED_STOREFILE_CLEANER_DELAY_JITTER); Review comment: What if FileBasedStoreFileTracker isn't set? ########## File path: hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/storefiletracker/FileBasedStoreFileTracker.java ########## @@ -95,7 +95,7 @@ public FileBasedStoreFileTracker(Configuration conf, boolean isPrimaryReplica, S } @Override - protected boolean requireWritingToTmpDirFirst() { + public boolean requireWritingToTmpDirFirst() { Review comment: Does it make sense to set it to public here, since FileBasedStoreFileTracker is package private? -- 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: issues-unsubscr...@hbase.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org