Skip to content

Commit

Permalink
reduce duplication by creating two instances of ContainerSafeModeRule
Browse files Browse the repository at this point in the history
  • Loading branch information
adoroszlai committed Nov 19, 2024
1 parent 1e6dcd5 commit fb815f3
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 167 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ public int getRequiredNodes() {
return data + parity;
}

@Override
public int getMinimumNodes() {
return data;
}

@Override
@JsonIgnore
public String getReplication() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ public int getRequiredNodes() {
return replicationFactor.getNumber();
}

@Override
public int getMinimumNodes() {
return 1;
}

@Override
public ReplicationFactor getReplicationFactor() {
return replicationFactor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ static ReplicationConfig parseWithoutFallback(ReplicationType type,
*/
int getRequiredNodes();

/** Minimum number of nodes, below this data loss happens. */
int getMinimumNodes();

/**
* Returns the replication option in string format.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ public int getRequiredNodes() {
return replicationFactor.getNumber();
}

@Override
public int getMinimumNodes() {
return replicationFactor.getNumber();
}

@Override
@JsonIgnore
public String getReplication() {
Expand Down
Loading

2 comments on commit fb815f3

@slfan1989
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adoroszlai Thank you very much for providing this part of the code! The quality is excellent, and its readability is even better. I agree with your approach to splitting the EC and Ratis Container rules. However, would it be possible for me to complete HDDS-11243 first and then submit a separate PR to separate the EC and Ratis Container rules? Would you be okay with this approach? Also, in apache#7008, I referenced your logic for the minimum replica count.

@adoroszlai
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I can post a follow-up PR.

Please sign in to comment.