swagle commented on a change in pull request #546: HDDS-2847. Recon should 
track containers that are missing along with …
URL: https://github.com/apache/hadoop-ozone/pull/546#discussion_r379737011
 
 

 ##########
 File path: 
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/fsck/MissingContainerTask.java
 ##########
 @@ -0,0 +1,152 @@
+/**
+ * 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.ozone.recon.fsck;
+
+import java.util.Set;
+
+import org.apache.hadoop.hdds.scm.container.ContainerID;
+import org.apache.hadoop.hdds.scm.container.ContainerManager;
+import org.apache.hadoop.hdds.scm.container.ContainerNotFoundException;
+import org.apache.hadoop.hdds.scm.container.ContainerReplica;
+import org.apache.hadoop.hdds.scm.server.OzoneStorageContainerManager;
+import org.apache.hadoop.ozone.recon.scm.ReconStorageContainerManagerFacade;
+import org.apache.hadoop.util.ExitUtil;
+import org.apache.hadoop.util.Time;
+import org.hadoop.ozone.recon.schema.tables.daos.MissingContainersDao;
+import org.hadoop.ozone.recon.schema.tables.daos.ReconTaskStatusDao;
+import org.hadoop.ozone.recon.schema.tables.pojos.MissingContainers;
+import org.hadoop.ozone.recon.schema.tables.pojos.ReconTaskStatus;
+import org.jooq.Configuration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.util.CollectionUtils;
+
+/**
+ * Class that scans the list of containers and keeps track of containers with
+ * no replicas in a SQL table.
+ */
+public class MissingContainerTask {
+
+  private static final Logger LOG =
+      LoggerFactory.getLogger(MissingContainerTask.class);
+
+  private OzoneStorageContainerManager scm;
+  private MissingContainersDao missingContainersDao;
+  private ReconTaskStatusDao reconTaskStatusDao;
+  private static final long INTERVAL = 5 * 60 * 1000L;
+
+  private Thread fsckMonitor;
+  private volatile boolean running;
+
+  public MissingContainerTask(ReconStorageContainerManagerFacade scm,
+                              Configuration sqlConfiguration) {
+    this.scm = scm;
+    this.missingContainersDao = new MissingContainersDao(sqlConfiguration);
+    this.reconTaskStatusDao = new ReconTaskStatusDao(sqlConfiguration);
+    String taskName = getClass().getSimpleName();
+    ReconTaskStatus reconTaskStatusRecord = new ReconTaskStatus(
+        taskName, 0L, 0L);
+    if (!reconTaskStatusDao.existsById(taskName)) {
+      reconTaskStatusDao.insert(reconTaskStatusRecord);
+      LOG.info("Registered {} task ", taskName);
+    }
+  }
+
+  public void start() {
+    if (!isRunning()) {
+      LOG.info("Starting Missing Container Monitor Thread.");
+      running = true;
+      fsckMonitor = new Thread(this::run);
 
 Review comment:
   Why not use a single-threaded executor?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: ozone-issues-h...@hadoop.apache.org

Reply via email to