siddhantsangwan commented on code in PR #3738:
URL: https://github.com/apache/ozone/pull/3738#discussion_r964660812
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/ReplicationManager.java:
##########
@@ -248,6 +261,38 @@ public synchronized void stop() {
}
}
+ /**
+ * Create Replication Manager sub services such as Over and Under Replication
+ * processors.
+ */
+ private void createSubServices() {
Review Comment:
> I thought we concluded that these sub-services should not be registered
with the ServiceManager themselves, but just be threads managed within the
replication manager?
Yeah. When implementing that, I realised that we would end up writing code
similar to BackgroundSCMService. `BackgroundThread` implementing Runnable will
have something like:
```
private void run() {
while (running.get()) {
try {
if (shouldRun()) {
try {
periodicalTask.run();
} catch (Throwable e) {
log.error("Caught Unhandled exception in {}. The task will be " +
"re-tried in {}ms", getServiceName(), intervalInMillis, e);
}
}
synchronized (this) {
if (!runImmediately) {
wait(intervalInMillis);
}
runImmediately = false;
}
} catch (InterruptedException e) {
log.warn("{} is interrupted, exit", serviceName);
Thread.currentThread().interrupt();
running.set(false);
}
}
}
```
We can avoid doing this by using BackgroundSCMService. The downside is that
our definition of whether they are RM sub threads or SCM threads becomes hazy.
But we are solving a part of that problem by restricting their visibility to
only RM and SCMServiceManager.
--
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]