You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@uniffle.apache.org by "kaijchen (via GitHub)" <gi...@apache.org> on 2023/02/17 15:52:34 UTC
[GitHub] [incubator-uniffle] kaijchen commented on pull request #606: [#80][Part-1] feat: Add decommisson logic to shuffle server
kaijchen commented on PR #606:
URL: https://github.com/apache/incubator-uniffle/pull/606#issuecomment-1434836378
> Will it better to use a ExecutorService and use future.cancel() and ExecutorService.shutdownNow() for termination?
Hi @xianjingfeng, sorry for not saying it clearly. Maybe `ForkJoinPool.commonPool()` is more appropriate here.
```diff
diff --git a/server/src/main/java/org/apache/uniffle/server/ShuffleServer.java b/server/src/main/java/org/apache/uniffle/server/ShuffleServer.java
index ee8f0775..0c5ecd46 100644
--- a/server/src/main/java/org/apache/uniffle/server/ShuffleServer.java
+++ b/server/src/main/java/org/apache/uniffle/server/ShuffleServer.java
@@ -20,8 +20,8 @@ package org.apache.uniffle.server;
import java.util.Collections;
import java.util.List;
import java.util.Set;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
+import java.util.concurrent.ForkJoinPool;
+import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean;
import com.google.common.annotations.VisibleForTesting;
@@ -46,7 +46,6 @@ import org.apache.uniffle.common.security.SecurityContextFactory;
import org.apache.uniffle.common.util.Constants;
import org.apache.uniffle.common.util.ExitUtils;
import org.apache.uniffle.common.util.RssUtils;
-import org.apache.uniffle.common.util.ThreadUtils;
import org.apache.uniffle.common.web.CommonMetricsServlet;
import org.apache.uniffle.common.web.JettyServer;
import org.apache.uniffle.server.buffer.ShuffleBufferManager;
@@ -88,7 +87,7 @@ public class ShuffleServer {
private MetricReporter metricReporter;
private volatile ServerStatus serverStatus = ServerStatus.ACTIVE;
private volatile boolean running;
- private ExecutorService executorService;
+ Future<?> decommissionFuture;
public ShuffleServer(ShuffleServerConf shuffleServerConf) throws Exception {
this.shuffleServerConf = shuffleServerConf;
@@ -287,11 +286,7 @@ public class ShuffleServer {
}
serverStatus = ServerStatus.DECOMMISSIONING;
LOG.info("Shuffle Server is decommissioning.");
- if (executorService == null) {
- executorService = Executors.newSingleThreadExecutor(
- ThreadUtils.getThreadFactory("shuffle-server-decommission-%d"));
- }
- executorService.submit(this::waitDecommissionFinish);
+ decommissionFuture = ForkJoinPool.commonPool().submit(this::waitDecommissionFinish);
}
private void waitDecommissionFinish() {
@@ -332,8 +327,12 @@ public class ShuffleServer {
LOG.info("Shuffle server is not decommissioning. Nothing needs to be done.");
return;
}
- serverStatus = ServerStatus.ACTIVE;
- LOG.info("Decommission canceled.");
+ if (decommissionFuture.cancel(true)) {
+ serverStatus = ServerStatus.ACTIVE;
+ LOG.info("Decommission canceled.");
+ } else {
+ LOG.warn("Failed to cancel decommission.");
+ }
}
public String getIp() {
```
--
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: issues-unsubscribe@uniffle.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org