Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Collectors.toList method occur duplicate key problem#4645 #4646

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ public List<EngineNode> listEngines(String user) {
List<NodeMetrics> nodeMetrics = nodeMetricManagerPersistence.getNodeMetrics(nodes);
Map<String, NodeMetrics> metricses =
nodeMetrics.stream()
.collect(Collectors.toMap(m -> m.getServiceInstance().toString(), m -> m));
.collect(
Collectors.toMap(
m -> m.getServiceInstance().toString(),
m -> m,
(existingValue, newValue) -> newValue));

nodes.forEach(
node -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ public EMNode[] getAllEM() {

Map<ServiceInstance, RMNode> resourceInfoMap =
resourceInfo.getResourceInfo().stream()
.collect(Collectors.toMap(r -> r.getServiceInstance(), r -> r));
.collect(
Collectors.toMap(
r -> r.getServiceInstance(), r -> r, (existingValue, newValue) -> newValue));

return instances.stream()
.map(emNodeManager::getEM)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ private List<EngineNode> getEngineNodes(List<EngineNode> nodes) {
Map<String, RMNode> resourceInfoMap =
rmNodes.stream()
.collect(
Collectors.toMap(entry -> entry.getServiceInstance().toString(), entry -> entry));
Collectors.toMap(
entry -> entry.getServiceInstance().toString(),
entry -> entry,
(existingValue, newValue) -> newValue));
nodes.forEach(
node -> {
RMNode rmNode = resourceInfoMap.get(node.getServiceInstance().toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ public List<Map<String, Object>> getECResourceInfoList(
// map k:v---> instanceName:PersistencerEcNodeInfo
Map<String, PersistencerEcNodeInfo> persistencerEcNodeInfoMap =
ecNodesInfo.stream()
.collect(Collectors.toMap(PersistencerEcNodeInfo::getInstance, item -> item));
.collect(
Collectors.toMap(
PersistencerEcNodeInfo::getInstance,
item -> item,
(existingValue, newValue) -> newValue));

List<String> instanceList =
ecNodesInfo.stream().map(e -> e.getInstance()).collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ public static Map<ScoreServiceInstance, List<PersistenceLabel>> normalizeAndOutp
labelScoreServiceInstance.setScore(scoreCalculate);
return Pair.of(labelScoreServiceInstance, outNodeDegree.get(node));
})
.collect(Collectors.toMap(Pair::getKey, Pair::getValue));
.collect(
Collectors.toMap(
Pair::getKey, Pair::getValue, (existingValue, newValue) -> newValue));

rawOutput
.keySet()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,11 @@ public void removeLabelsFromNode(ServiceInstance instance, List<Label<?>> labels
List<PersistenceLabel> labelList = labelManagerPersistence.getLabelByServiceInstance(instance);
Map<String, PersistenceLabel> dbLabels =
labelList.stream()
.collect(Collectors.toMap(PersistenceLabel::getLabelKey, Function.identity()));
.collect(
Collectors.toMap(
PersistenceLabel::getLabelKey,
Function.identity(),
(existingValue, newValue) -> newValue));

List<Integer> labelIds =
labels.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,11 @@ private EngineNode[] getEngineNodes(String user, boolean withResource) {
List<NodeMetrics> nodeMetrics = nodeMetricManagerPersistence.getNodeMetrics(nodes);
Map<String, NodeMetrics> metrics =
nodeMetrics.stream()
.collect(Collectors.toMap(m -> m.getServiceInstance().toString(), m -> m));
.collect(
Collectors.toMap(
m -> m.getServiceInstance().toString(),
m -> m,
(existingValue, newValue) -> newValue));

Map<String, Resource> configurationMap = new HashMap<>();

Expand Down Expand Up @@ -825,7 +829,11 @@ public Map<String, List<EngineNode>> getEngineNodesByUserList(

Map<String, NodeMetrics> metrics =
nodeMetricManagerPersistence.getNodeMetrics(engineNodesList).stream()
.collect(Collectors.toMap(m -> m.getServiceInstance().toString(), Function.identity()));
.collect(
Collectors.toMap(
m -> m.getServiceInstance().toString(),
Function.identity(),
(existingValue, newValue) -> newValue));

Map<String, List<Label<?>>> labelsMap =
nodeLabelService.getNodeLabelsByInstanceList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ public void removeResourceByLabels(List<PersistenceLabel> labels) {
Map<String, Map<String, String>> keyValueMaps =
blankIds.stream()
.map(PersistenceUtils::entryToTunple)
.collect(Collectors.toMap(Tunple::getKey, Tunple::getValue));
.collect(
Collectors.toMap(
Tunple::getKey, Tunple::getValue, (existingValue, newValue) -> newValue));
// labelManagerMapper.batchDeleteResourceByLabelKeyValuesMaps(keyValueMaps);
}
}
Expand Down