Skip to content

Commit

Permalink
HDDS-11062. Minor code cleanup in XceiverServerRatis (#6857)
Browse files Browse the repository at this point in the history
  • Loading branch information
jianghuazhu authored Jun 25, 2024
1 parent e6cadc0 commit c6ab3a7
Showing 1 changed file with 5 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ private XceiverServerRatis(DatanodeDetails dd,
StateContext context, ConfigurationSource conf, Parameters parameters)
throws IOException {
this.conf = conf;
Objects.requireNonNull(dd, "id == null");
Objects.requireNonNull(dd, "DatanodeDetails == null");
datanodeDetails = dd;
ratisServerConfig = conf.getObject(DatanodeRatisServerConfig.class);
assignPorts();
Expand Down Expand Up @@ -372,12 +372,11 @@ public RaftProperties newRaftProperties() {
}

private void setRatisLeaderElectionTimeout(RaftProperties properties) {
long duration;
TimeUnit leaderElectionMinTimeoutUnit =
OzoneConfigKeys.
HDDS_RATIS_LEADER_ELECTION_MINIMUM_TIMEOUT_DURATION_DEFAULT
.getUnit();
duration = conf.getTimeDuration(
long duration = conf.getTimeDuration(
OzoneConfigKeys.HDDS_RATIS_LEADER_ELECTION_MINIMUM_TIMEOUT_DURATION_KEY,
OzoneConfigKeys.
HDDS_RATIS_LEADER_ELECTION_MINIMUM_TIMEOUT_DURATION_DEFAULT
Expand All @@ -393,12 +392,10 @@ private void setRatisLeaderElectionTimeout(RaftProperties properties) {
}

private void setTimeoutForRetryCache(RaftProperties properties) {
TimeUnit timeUnit;
long duration;
timeUnit =
TimeUnit timeUnit =
OzoneConfigKeys.HDDS_RATIS_SERVER_RETRY_CACHE_TIMEOUT_DURATION_DEFAULT
.getUnit();
duration = conf.getTimeDuration(
long duration = conf.getTimeDuration(
OzoneConfigKeys.HDDS_RATIS_SERVER_RETRY_CACHE_TIMEOUT_DURATION_KEY,
OzoneConfigKeys.HDDS_RATIS_SERVER_RETRY_CACHE_TIMEOUT_DURATION_DEFAULT
.getDuration(), timeUnit);
Expand Down Expand Up @@ -515,7 +512,6 @@ private RpcType setRpcType(RaftProperties properties) {
}

private void setPendingRequestsLimits(RaftProperties properties) {

long pendingRequestsBytesLimit = (long) conf.getStorageSize(
OzoneConfigKeys.HDDS_CONTAINER_RATIS_LEADER_PENDING_BYTES_LIMIT,
OzoneConfigKeys.HDDS_CONTAINER_RATIS_LEADER_PENDING_BYTES_LIMIT_DEFAULT,
Expand Down Expand Up @@ -819,17 +815,6 @@ public List<PipelineReport> getPipelineReport() {
}
}

@VisibleForTesting
public List<PipelineID> getPipelineIds() {
Iterable<RaftGroupId> gids = server.getGroupIds();
List<PipelineID> pipelineIDs = new ArrayList<>();
for (RaftGroupId groupId : gids) {
pipelineIDs.add(PipelineID.valueOf(groupId.getUuid()));
LOG.info("pipeline id {}", PipelineID.valueOf(groupId.getUuid()));
}
return pipelineIDs;
}

@Override
public void addGroup(HddsProtos.PipelineID pipelineId,
List<DatanodeDetails> peers) throws IOException {
Expand Down Expand Up @@ -939,10 +924,9 @@ public void handleNodeLogFailure(RaftGroupId groupId, Throwable t) {
}

public long getMinReplicatedIndex(PipelineID pipelineID) throws IOException {
Long minIndex;
GroupInfoReply reply = getServer()
.getGroupInfo(createGroupInfoRequest(pipelineID.getProtobuf()));
minIndex = RatisHelper.getMinReplicatedIndex(reply.getCommitInfos());
Long minIndex = RatisHelper.getMinReplicatedIndex(reply.getCommitInfos());
return minIndex == null ? -1 : minIndex;
}

Expand Down

0 comments on commit c6ab3a7

Please sign in to comment.