SourabhBadhya commented on code in PR #4032: URL: https://github.com/apache/hive/pull/4032#discussion_r1105762692
########## ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/handler/Handler.java: ########## @@ -0,0 +1,179 @@ +/* + * 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.hive.ql.txn.compactor.handler; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.hive.conf.HiveConf; +import org.apache.hadoop.hive.metastore.api.MetaException; +import org.apache.hadoop.hive.metastore.api.Partition; +import org.apache.hadoop.hive.metastore.api.Table; +import org.apache.hadoop.hive.metastore.conf.MetastoreConf; +import org.apache.hadoop.hive.metastore.txn.CompactionInfo; +import org.apache.hadoop.hive.metastore.txn.TxnStore; +import org.apache.hadoop.hive.ql.io.AcidDirectory; +import org.apache.hadoop.hive.ql.txn.compactor.CleaningRequest; +import org.apache.hadoop.hive.ql.txn.compactor.CompactorUtil; +import org.apache.thrift.TBase; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Arrays; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; + +import static org.apache.hadoop.hive.metastore.HMSHandler.getMSForConf; +import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.getDefaultCatalog; + +/** + * An abstract class which defines the list of utility methods for performing cleanup activities. + */ +public abstract class Handler { + + private static final Logger LOG = LoggerFactory.getLogger(Handler.class.getName()); + protected final TxnStore txnHandler; + protected final HiveConf conf; + protected final boolean metricsEnabled; + private Optional<Cache<String, TBase>> metaCache; + + Handler(HiveConf conf, TxnStore txnHandler, boolean metricsEnabled) { + this.conf = conf; + this.txnHandler = txnHandler; + boolean tableCacheOn = MetastoreConf.getBoolVar(this.conf, MetastoreConf.ConfVars.COMPACTOR_CLEANER_TABLECACHE_ON); + this.metaCache = initializeCache(tableCacheOn); + this.metricsEnabled = metricsEnabled; + } + + public HiveConf getConf() { + return conf; + } + + public TxnStore getTxnHandler() { + return txnHandler; + } + + public boolean isMetricsEnabled() { + return metricsEnabled; + } + + /** + * Find the list of objects which are ready for cleaning. + * @return Cleaning requests + */ + public abstract List<CleaningRequest> findReadyToClean() throws MetaException; + + /** + * Execute just before cleanup + * @param cleaningRequest - Cleaning request + */ + public abstract void beforeExecutingCleaningRequest(CleaningRequest cleaningRequest) throws MetaException; + + /** + * Execute just after cleanup + * @param cleaningRequest Cleaning request + * @param deletedFiles List of deleted files + * @throws MetaException + */ + public abstract void afterExecutingCleaningRequest(CleaningRequest cleaningRequest, List<Path> deletedFiles) throws MetaException; + + /** + * Execute in the event of failure + * @param cleaningRequest Cleaning request + * @param ex Failure exception + * @throws MetaException + */ + public abstract void failureExecutingCleaningRequest(CleaningRequest cleaningRequest, Exception ex) throws MetaException; Review Comment: Discussed it with @veghlaci05 and concluded that this might not be required right now, since handler must be aware of what needs to be done in case of failure and this doesnt require notifying all observers in case of exception. -- 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: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org