You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2020/02/19 22:52:08 UTC

[GitHub] [hadoop-ozone] avijayanhwx commented on a change in pull request #546: HDDS-2847. Add Recon tasks for tracking missing containers (FSCK) and syncing deleted pipelines from SCM.

avijayanhwx commented on a change in pull request #546: HDDS-2847. Add Recon tasks for tracking missing containers (FSCK) and syncing deleted pipelines from SCM.
URL: https://github.com/apache/hadoop-ozone/pull/546#discussion_r381593756
 
 

 ##########
 File path: hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/scm/ReconScmTask.java
 ##########
 @@ -0,0 +1,103 @@
+/**
+ * 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.scm;
+
+import org.hadoop.ozone.recon.schema.tables.daos.ReconTaskStatusDao;
+import org.hadoop.ozone.recon.schema.tables.pojos.ReconTaskStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.Inject;
+
+/**
+ * Any background task that keeps SCM's metadata up to date.
+ */
+public abstract class ReconScmTask {
+
+  private static final Logger LOG = LoggerFactory.getLogger(ReconScmTask.class);
+  private Thread taskThread;
+  private ReconTaskStatusDao reconTaskStatusDao;
+  private volatile boolean running;
+
+  @Inject
+  public ReconScmTask(ReconTaskStatusDao reconTaskStatusDao) {
+    this.reconTaskStatusDao = reconTaskStatusDao;
+  }
+
+  public void register() {
+    String taskName = getClass().getSimpleName();
+    ReconTaskStatus reconTaskStatusRecord = new ReconTaskStatus(
+        taskName, 0L, 0L);
+    if (!reconTaskStatusDao.existsById(taskName)) {
+      reconTaskStatusDao.insert(reconTaskStatusRecord);
+      LOG.info("Registered {} task ", taskName);
+    }
+  }
+
+  public synchronized void start() {
+    if (!isRunning()) {
+      LOG.info("Starting {} Thread.", getTaskName());
+      running = true;
+      taskThread = new Thread(this::run);
+      taskThread.setName(getTaskName());
+      taskThread.setDaemon(true);
+      taskThread.start();
+    } else {
+      LOG.info("{} Thread is already running.", getTaskName());
+    }
+  }
+
+  /**
+   * Stops Replication Monitor thread.
 
 Review comment:
   Will remove.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

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