You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@uniffle.apache.org by GitBox <gi...@apache.org> on 2022/11/17 10:08:10 UTC

[GitHub] [incubator-uniffle] zuston commented on a diff in pull request #334: [ISSUE-328]Cleanup unused shuffle servers after stage completed

zuston commented on code in PR #334:
URL: https://github.com/apache/incubator-uniffle/pull/334#discussion_r1024988638


##########
client/src/main/java/org/apache/uniffle/client/impl/ShuffleWriteClientImpl.java:
##########
@@ -653,9 +666,43 @@ private void throwExceptionIfNecessary(ClientResponse response, String errorMsg)
     }
   }
 
+  Set<ShuffleServerInfo> getAllShuffleServers(String appId) {
+    Map<Integer, Set<ShuffleServerInfo>> appServerMap = shuffleServerInfoMap.get(appId);
+    if (appServerMap == null) {
+      return Collections.EMPTY_SET;
+    }
+    Set<ShuffleServerInfo> serverInfos = Sets.newHashSet();
+    appServerMap.values().forEach((serverSet) -> {
+      serverInfos.addAll(serverSet);
+    });
+    return serverInfos;
+  }
+
   @VisibleForTesting
   public ShuffleServerClient getShuffleServerClient(ShuffleServerInfo shuffleServerInfo) {
     return ShuffleServerClientFactory.getInstance().getShuffleServerClient(clientType, shuffleServerInfo);
   }
 
+  @VisibleForTesting
+  void registerShuffleServer(String appId, int shuffleId, ShuffleServerInfo serverInfo) {
+    Map<Integer, Set<ShuffleServerInfo>> appServerMap = shuffleServerInfoMap.get(appId);
+    if (appServerMap == null) {
+      appServerMap = Maps.newConcurrentMap();
+      shuffleServerInfoMap.put(appId, appServerMap);
+    }
+    Set<ShuffleServerInfo> shuffleServerInfos = appServerMap.get(shuffleId);
+    if (shuffleServerInfos == null) {
+      shuffleServerInfos = Sets.newConcurrentHashSet();
+      appServerMap.put(shuffleId, shuffleServerInfos);
+    }
+    shuffleServerInfos.add(serverInfo);
+  }
+
+  @VisibleForTesting
+  void unRegisterShuffleServer(String appId, int shuffleId) {

Review Comment:
   `removeShuffleServerInfo` ?



##########
client/src/main/java/org/apache/uniffle/client/impl/ShuffleWriteClientImpl.java:
##########
@@ -350,7 +352,7 @@ public void registerShuffle(
     String msg = "Error happened when registerShuffle with appId[" + appId + "], shuffleId[" + shuffleId
         + "], " + shuffleServerInfo;
     throwExceptionIfNecessary(response, msg);
-    shuffleServerInfoSet.add(shuffleServerInfo);
+    registerShuffleServer(appId, shuffleId, shuffleServerInfo);

Review Comment:
   rename to `addShuffleServerInfo` ? The `registerShuffleServer ` in this class looks a RPC method.



-- 
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