-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support deploy multiple shuffle servers in a single node (#166)
### What changes were proposed in this pull request? 1.Sufflle server with same ip will not be assigned to same partition 2.Check whether port is in use in start script of shuffle server ### Why are the changes needed? If we have a lot of memory(more than 1T) per host, so we need deploy multiple shuffle servers in a single node. #77 ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? already added
- Loading branch information
1 parent
0645ebe
commit f1cb43f
Showing
10 changed files
with
241 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
coordinator/src/main/java/org/apache/uniffle/coordinator/AbstractAssignmentStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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.uniffle.coordinator; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
import static org.apache.uniffle.coordinator.CoordinatorConf.COORDINATOR_ASSGINMENT_HOST_STRATEGY; | ||
|
||
public abstract class AbstractAssignmentStrategy implements AssignmentStrategy { | ||
protected final CoordinatorConf conf; | ||
private final HostAssignmentStrategy assignmentHostStrategy; | ||
|
||
public AbstractAssignmentStrategy(CoordinatorConf conf) { | ||
this.conf = conf; | ||
assignmentHostStrategy = conf.get(COORDINATOR_ASSGINMENT_HOST_STRATEGY); | ||
} | ||
|
||
protected List<ServerNode> getCandidateNodes(List<ServerNode> allNodes, int expectNum) { | ||
switch (assignmentHostStrategy) { | ||
case MUST_DIFF: return getCandidateNodesWithDiffHost(allNodes, expectNum); | ||
case PREFER_DIFF: return tryGetCandidateNodesWithDiffHost(allNodes, expectNum); | ||
case NONE: return allNodes.subList(0, expectNum); | ||
default: throw new RuntimeException("Unsupported host assignment strategy:" + assignmentHostStrategy); | ||
} | ||
} | ||
|
||
protected List<ServerNode> tryGetCandidateNodesWithDiffHost(List<ServerNode> allNodes, int expectNum) { | ||
List<ServerNode> candidatesNodes = getCandidateNodesWithDiffHost(allNodes, expectNum); | ||
Set<ServerNode> candidatesNodeSet = candidatesNodes.stream().collect(Collectors.toSet()); | ||
if (candidatesNodes.size() < expectNum) { | ||
for (ServerNode node : allNodes) { | ||
if (candidatesNodeSet.contains(node)) { | ||
continue; | ||
} | ||
candidatesNodes.add(node); | ||
if (candidatesNodes.size() >= expectNum) { | ||
break; | ||
} | ||
} | ||
} | ||
return candidatesNodes; | ||
} | ||
|
||
protected List<ServerNode> getCandidateNodesWithDiffHost(List<ServerNode> allNodes, int expectNum) { | ||
List<ServerNode> candidatesNodes = new ArrayList<>(); | ||
Set<String> hostIpCandidate = new HashSet<>(); | ||
for (ServerNode node : allNodes) { | ||
if (hostIpCandidate.contains(node.getIp())) { | ||
continue; | ||
} | ||
hostIpCandidate.add(node.getIp()); | ||
candidatesNodes.add(node); | ||
if (candidatesNodes.size() >= expectNum) { | ||
break; | ||
} | ||
} | ||
return candidatesNodes; | ||
} | ||
|
||
|
||
public enum HostAssignmentStrategy { | ||
MUST_DIFF, | ||
PREFER_DIFF, | ||
NONE | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.