-
Notifications
You must be signed in to change notification settings - Fork 616
HDDS-10422. Fix some warnings about exposing internal representation in hdds-common #6351
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
Changes from 2 commits
a4dff06
243aac2
95b86b9
ee33aa7
52e26a3
41696d3
71f5786
88b5454
5fd72b9
31b1578
5ce60b2
986ca90
11f0c44
7a7f980
70f8a47
b9ed7e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -222,7 +222,7 @@ public synchronized void setPort(Name name, int port) { | |
| * @return DataNode Ports | ||
| */ | ||
| public synchronized List<Port> getPorts() { | ||
| return ports; | ||
| return new ArrayList<>(ports); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should also change the callers in order to reduce copying:
//NodeDecommissionManager
private boolean validateDNPortMatch(int port, DatanodeDetails dn) {
return dn.containPort(port);
}//DatanodeDetails
public synchronized boolean containPort(int port) {
for (Port p : ports) {
if (p.getValue() == port) {
return true;
}
}
return false;
}
@@ -238,8 +239,9 @@ private static DatanodeDetailsYaml getDatanodeDetailsYaml(
= new DatanodeLayoutStorage(conf, datanodeDetails.getUuidString());
Map<String, Integer> portDetails = new LinkedHashMap<>();
- if (!CollectionUtils.isEmpty(datanodeDetails.getPorts())) {
- for (DatanodeDetails.Port port : datanodeDetails.getPorts()) {
+ final List<DatanodeDetails.Port> datanodePorts = datanodeDetails.getPorts();
+ if (!CollectionUtils.isEmpty(datanodePorts)) {
+ for (DatanodeDetails.Port port : datanodePorts) {
Field f = null;
try {
f = DatanodeDetails.Port.Name.class
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the suggestion, updated. |
||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,24 +19,25 @@ | |
| package org.apache.hadoop.hdds.scm; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
|
|
||
| /** | ||
| * ScmInfo wraps the result returned from SCM#getScmInfo which | ||
| * contains clusterId and the SCM Id. | ||
| */ | ||
| public final class ScmInfo { | ||
| private String clusterId; | ||
| private String scmId; | ||
| private List<String> peerRoles; | ||
| private final String clusterId; | ||
| private final String scmId; | ||
| private final List<String> peerRoles; | ||
|
|
||
| /** | ||
| * Builder for ScmInfo. | ||
| */ | ||
| public static class Builder { | ||
| private String clusterId; | ||
| private String scmId; | ||
| private List<String> peerRoles; | ||
| private final List<String> peerRoles; | ||
|
|
||
| public Builder() { | ||
| peerRoles = new ArrayList<>(); | ||
|
|
@@ -104,6 +105,6 @@ public String getScmId() { | |
| * @return List of peer address | ||
| */ | ||
| public List<String> getRatisPeerRoles() { | ||
| return peerRoles; | ||
| return Collections.unmodifiableList(peerRoles); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do it in constructor. private ScmInfo(String clusterId, String scmId, List<String> peerRoles) {
this.clusterId = clusterId;
this.scmId = scmId;
this.peerRoles = Collections.unmodifiableList(peerRoles);
} |
||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
QuotaListclass is inefficient. Let's remove it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deferred to HDDS-10897.