Skip to content

Commit 86da926

Browse files
IGNITE-26580 Improve code after self-review
1 parent 089f85e commit 86da926

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/MdcAffinityBackupFilter.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,8 @@ public class MdcAffinityBackupFilter implements IgniteBiPredicate<ClusterNode, L
7474
/** */
7575
private static final long serialVersionUID = 1L;
7676

77-
/** Number of data centers. */
78-
private final int dcsNum;
79-
80-
/** Number of copies of each partition, including primary. */
81-
private final int primaryAndBackups;
77+
/** */
78+
private final int partCopiesPerDc;
8279

8380
/** Map is used to optimize the time it takes to perform a partition assignment procedure. */
8481
private final Map<String, Integer> partsDistrMap;
@@ -88,9 +85,8 @@ public class MdcAffinityBackupFilter implements IgniteBiPredicate<ClusterNode, L
8885
* @param backups Number of backups.
8986
*/
9087
public MdcAffinityBackupFilter(int dcsNum, int backups) {
91-
this.dcsNum = dcsNum;
9288
partsDistrMap = new HashMap<>(dcsNum + 1);
93-
primaryAndBackups = backups + 1;
89+
partCopiesPerDc = (backups + 1) / dcsNum;
9490
}
9591

9692
/**
@@ -108,18 +104,16 @@ public MdcAffinityBackupFilter(int dcsNum, int backups) {
108104
partsDistrMap.put(previouslySelected.get(0).dataCenterId(), 1);
109105
}
110106

107+
boolean res = false;
111108
String candidateDcId = candidate.dataCenterId();
112109
Integer candDcPartsCopies = partsDistrMap.get(candidateDcId);
113-
boolean res = false;
114110

115111
if (candDcPartsCopies == null || candDcPartsCopies == -1) {
116112
partsDistrMap.put(candidateDcId, 1);
117113

118114
res = true;
119115
}
120116
else {
121-
int partCopiesPerDc = primaryAndBackups / dcsNum;
122-
123117
if (candDcPartsCopies < partCopiesPerDc) {
124118
partsDistrMap.put(candidateDcId, candDcPartsCopies + 1);
125119

0 commit comments

Comments
 (0)