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

MINOR: Fix Some Exceptions in MetaPropertiesEnsemble and MetadataQuorumCommand #18957

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -115,7 +115,7 @@ public Loader addMetadataLogDir(String metadataLogDir) {
return this;
}

public MetaPropertiesEnsemble load() throws IOException {
public MetaPropertiesEnsemble load() {
if (logDirs.isEmpty()) {
throw new RuntimeException("You must specify at least one log directory.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,13 @@ else if (leader.lastCaughtUpTimestamp().isPresent() && maxLagFollower.lastCaught

System.out.println(
"ClusterId: " + clusterId +
"\nLeaderId: " + quorumInfo.leaderId() +
"\nLeaderEpoch: " + quorumInfo.leaderEpoch() +
"\nHighWatermark: " + quorumInfo.highWatermark() +
"\nMaxFollowerLag: " + maxFollowerLag +
"\nMaxFollowerLagTimeMs: " + maxFollowerLagTimeMs +
"\nCurrentVoters: " + printVoterState(quorumInfo) +
"\nCurrentObservers: " + printObserverState(quorumInfo)
"\nLeaderId: " + quorumInfo.leaderId() +
"\nLeaderEpoch: " + quorumInfo.leaderEpoch() +
"\nHighWatermark: " + quorumInfo.highWatermark() +
"\nMaxFollowerLag: " + maxFollowerLag +
"\nMaxFollowerLagTimeMs: " + maxFollowerLagTimeMs +
"\nCurrentVoters: " + printVoterState(quorumInfo) +
"\nCurrentObservers: " + printObserverState(quorumInfo)
Copy link
Member

Choose a reason for hiding this comment

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

This indentation doesn't look correct. We indent Java code using 4 spaces.

);
}

Expand Down Expand Up @@ -373,7 +373,7 @@ static String getMetadataDirectory(Properties props) throws TerseException {
"configuration file?");
}

static Uuid getMetadataDirectoryId(String metadataDirectory) throws Exception {
static Uuid getMetadataDirectoryId(String metadataDirectory) throws TerseException {
MetaPropertiesEnsemble ensemble = new MetaPropertiesEnsemble.Loader().
addLogDirs(Collections.singletonList(metadataDirectory)).
addMetadataLogDir(metadataDirectory).
Expand All @@ -390,7 +390,7 @@ static Uuid getMetadataDirectoryId(String metadataDirectory) throws Exception {

static Set<RaftVoterEndpoint> getControllerAdvertisedListeners(
Properties props
) throws Exception {
) throws TerseException {
Map<String, Endpoint> listeners = new HashMap<>();
SocketServerConfigs.listenerListToEndPoints(
props.getOrDefault(SocketServerConfigs.LISTENERS_CONFIG, "").toString(),
Expand All @@ -404,16 +404,16 @@ static Set<RaftVoterEndpoint> getControllerAdvertisedListeners(
}
LinkedHashSet<RaftVoterEndpoint> results = new LinkedHashSet<>();
for (String listenerName : props.getProperty(
KRaftConfigs.CONTROLLER_LISTENER_NAMES_CONFIG).split(",")) {
KRaftConfigs.CONTROLLER_LISTENER_NAMES_CONFIG).split(",")) {
Copy link
Member

Choose a reason for hiding this comment

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

How about this indentation and formatting so that the for loop statement block is clearly separated from the for loop iterable.

        for (String listenerName : props.getProperty(
            KRaftConfigs.CONTROLLER_LISTENER_NAMES_CONFIG).split(",")
        ) {

listenerName = ListenerName.normalised(listenerName).value();
Endpoint endpoint = listeners.get(listenerName);
if (endpoint == null) {
throw new TerseException("Cannot find information about controller listener name: " +
listenerName);
}
results.add(new RaftVoterEndpoint(endpoint.listenerName().get(),
endpoint.host() == null ? "localhost" : endpoint.host(),
endpoint.port()));
endpoint.host() == null ? "localhost" : endpoint.host(),
endpoint.port()));
Copy link
Member

Choose a reason for hiding this comment

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

How about this formatting?

            results.add(
                new RaftVoterEndpoint(
                    endpoint.listenerName().get(),
                    endpoint.host() == null ? "localhost" : endpoint.host(),
                    endpoint.port()
                )
            );

}
return results;
}
Expand Down