devmadhuu commented on code in PR #4817: URL: https://github.com/apache/ozone/pull/4817#discussion_r1214085337
########## hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/QuotaRepairTask.java: ########## @@ -0,0 +1,263 @@ +/* + * 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.ozone.om.service; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import org.apache.hadoop.hdds.utils.db.BatchOperation; +import org.apache.hadoop.hdds.utils.db.Table; +import org.apache.hadoop.hdds.utils.db.TableIterator; +import org.apache.hadoop.ozone.om.OMMetadataManager; +import org.apache.hadoop.ozone.om.helpers.BucketLayout; +import org.apache.hadoop.ozone.om.helpers.OmBucketInfo; +import org.apache.hadoop.ozone.om.helpers.OmDirectoryInfo; +import org.apache.hadoop.ozone.om.helpers.OmKeyInfo; +import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.apache.hadoop.ozone.OzoneConsts.OM_KEY_PREFIX; + +/** + * Quota repair task. + */ +public class QuotaRepairTask { + private static final Logger LOG = LoggerFactory.getLogger( + QuotaRepairTask.class); + private final OMMetadataManager metadataManager; + private final Map<String, OmBucketInfo> nameBucketInfoMap = new HashMap<>(); + private final Map<String, OmBucketInfo> idBucketInfoMap = new HashMap<>(); + private ExecutorService executor; + + public QuotaRepairTask(OMMetadataManager metadataManager) { + this.metadataManager = metadataManager; + } + + public void repair() throws Exception { + LOG.info("Starting quota repair task"); + executor = Executors.newFixedThreadPool(3); + prepareAllVolumeBucketInfo(); + repairCount(); + LOG.info("Completed quota repair task"); + executor.shutdown(); Review Comment: @sumitagrawl Thanks for working on this patch. One small thing, in case of exception, how the executor will be shutdown ? Can we have it in finally block ? -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
