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

HBASE-27202 Clean up error-prone findings in hbase-balancer #4623

Merged
merged 1 commit into from
Jul 18, 2022
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 @@ -111,7 +111,7 @@ public void initialize() {
break;
}
}
serverList.add((sn));
serverList.add(sn);
this.regionServerToRackMap.put(sn.getHostname(), rackName);
}
}
Expand Down Expand Up @@ -235,7 +235,7 @@ public void placePrimaryRSAsRoundRobin(Map<ServerName, List<RegionInfo>> assignm
if (numIterations % rackList.size() == 0) {
if (++serverIndex >= maxRackSize) serverIndex = 0;
}
if ((++rackIndex) >= rackList.size()) {
if (++rackIndex >= rackList.size()) {
rackIndex = 0; // reset the rack index to 0
}
} else break;
Expand All @@ -259,7 +259,7 @@ public void placePrimaryRSAsRoundRobin(Map<ServerName, List<RegionInfo>> assignm
if (numIterations % rackList.size() == 0) {
++serverIndex;
}
if ((++rackIndex) >= rackList.size()) {
if (++rackIndex >= rackList.size()) {
rackIndex = 0; // reset the rack index to 0
}
}
Expand Down Expand Up @@ -298,7 +298,7 @@ public ServerName[] getSecondaryAndTertiary(RegionInfo regionInfo, ServerName pr
if (getTotalNumberOfRacks() == 1) {
favoredNodes = singleRackCase(regionInfo, primaryRS, primaryRack);
} else {
favoredNodes = multiRackCase(regionInfo, primaryRS, primaryRack);
favoredNodes = multiRackCase(primaryRS, primaryRack);
}
return favoredNodes;
}
Expand Down Expand Up @@ -483,14 +483,12 @@ private ServerName[] singleRackCase(RegionInfo regionInfo, ServerName primaryRS,
* has only one region server, then we place primary and tertiary on one rack and secondary on
* another. The aim is two distribute the three favored nodes on >= 2 racks. TODO: see how we can
* use generateMissingFavoredNodeMultiRack API here
* @param regionInfo Region for which we are trying to generate FN
* @param primaryRS The primary favored node.
* @param primaryRack The rack of the primary favored node.
* @return Array containing secondary and tertiary favored nodes.
* @throws IOException Signals that an I/O exception has occurred.
*/
private ServerName[] multiRackCase(RegionInfo regionInfo, ServerName primaryRS,
String primaryRack) throws IOException {
private ServerName[] multiRackCase(ServerName primaryRS, String primaryRack) throws IOException {

List<ServerName> favoredNodes = Lists.newArrayList(primaryRS);
// Create the secondary and tertiary pair
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static Position getFavoredServerPosition(List<ServerName> favoredNodes,
}

/**
* @return the mapping between each region to its favored region server list
* Return the mapping between each region to its favored region server list.
*/
public Map<String, List<ServerName>> getAssignmentMap() {
// Make a deep copy so changes don't harm our copy of favoredNodesMap.
Expand All @@ -119,7 +119,7 @@ public boolean equals(Object o) {
if (o == null) {
return false;
}
if (getClass() != o.getClass()) {
if (!(o instanceof FavoredNodesPlan)) {
return false;
}
// To compare the map from object o is identical to current assignment map.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,8 @@ public void fillUpDispersion(TableName tableName, SnapshotOfRegionAssignmentFrom
}

/**
* @return list which contains just 3 elements: average dispersion score, max dispersion score and
* min dispersion score as first, second and third element respectively.
* Return a list which contains 3 elements: average dispersion score, max dispersion score and min
* dispersion score as first, second and third elements, respectively.
*/
public List<Float> getDispersionInformation() {
List<Float> dispersion = new ArrayList<>();
Expand Down Expand Up @@ -578,7 +578,7 @@ private void printHServerAddressSet(Set<ServerName> serverSet) {
}
int i = 0;
for (ServerName addr : serverSet) {
if ((i++) % 3 == 0) {
if (i++ % 3 == 0) {
System.out.print("\n\t\t\t");
}
System.out.print(addr.getAddress() + " ; ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,7 @@ public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
if (!(obj instanceof RegionPlan)) {
return false;
}
RegionPlan other = (RegionPlan) obj;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public String getRack(ServerName server) {
colocatedReplicaCountsPerHost = new Int2IntCounterMap[numHosts];
colocatedReplicaCountsPerRack = new Int2IntCounterMap[numRacks];

int tableIndex = 0, regionIndex = 0, regionPerServerIndex = 0;
int regionIndex = 0, regionPerServerIndex = 0;

for (Map.Entry<ServerName, List<RegionInfo>> entry : clusterState.entrySet()) {
if (entry.getKey() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ private TableDescriptor getDescriptor(TableName tableName) throws IOException {
*/
@RestrictedApi(explanation = "Should only be called in tests", link = "",
allowedOnPath = ".*/src/test/.*|.*/RegionHDFSBlockLocationFinder.java")
@SuppressWarnings("MixedMutabilityReturnType")
List<ServerName> mapHostNameToServerName(List<String> hosts) {
if (hosts == null || status == null) {
if (hosts == null) {
Expand Down