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

Adding user input retries to HelixBootstrapTool #2754

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -2123,14 +2123,20 @@ private void removeDataNodeConfigFromHelix(String dcName, String instanceName,
String question =
String.format("Are you sure you want to remove instance %s from property store and instance config",
instanceName);
String line = System.console().readLine("%s (y[es]/n[o]): ", question).toLowerCase();
boolean shouldDelete = line.equals("yes") || line.equals("y");
lock.unlock();

if (!shouldDelete) {
// terminate the process right away.
System.exit(1);
// Keep retrying until the user provides a valid input
boolean validInput = false;
while (!validInput) {
String line = System.console().readLine("%s (y[es]/n[o]): ", question).toLowerCase();
if (line.equals("yes") || line.equals("y")) {
validInput = true;
} else if (line.equals("no") || line.equals("n")) {
lock.unlock();
System.exit(1);
} else {
System.out.println("Invalid input. Please enter 'yes' or 'no'.");
}
}
lock.unlock();
}
adminForDc.get(dcName).dropInstance(clusterName, new InstanceConfig(instanceName));
if (dataNodeConfigSourceType == PROPERTY_STORE) {
Expand Down Expand Up @@ -3354,4 +3360,4 @@ private void logSummary() {
validatingHelixClusterManager.helixClusterManagerMetrics.ignoredUpdatesCount.getCount());
}
}
}
}