Github user kanakb commented on a diff in the pull request:
https://github.com/apache/helix/pull/27#discussion_r30104417
--- Diff:
helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java ---
@@ -715,14 +715,26 @@ public ExternalView getResourceExternalView(String
clusterName, String resourceN
@Override
public void addStateModelDef(String clusterName, String stateModelDef,
StateModelDefinition stateModel) {
+ addStateModelDef(clusterName, stateModelDef, stateModel, false);
+ }
+
+ @Override
+ public void addStateModelDef(String clusterName, String stateModelDef,
+ StateModelDefinition stateModel, boolean recreateIfExists) {
if (!ZKUtil.isClusterSetup(clusterName, _zkClient)) {
throw new HelixException("cluster " + clusterName + " is not setup
yet");
}
String stateModelDefPath =
HelixUtil.getStateModelDefinitionPath(clusterName);
String stateModelPath = stateModelDefPath + "/" + stateModelDef;
if (_zkClient.exists(stateModelPath)) {
- logger.warn("Skip the operation.State Model directory exists:" +
stateModelPath);
- throw new HelixException("State model path " + stateModelPath + "
already exists.");
+ if (recreateIfExists) {
+ logger.warn("Operation.State Model directory exists:" +
stateModelPath +
+ ", remove and recreate.");
+ _zkClient.deleteRecursive(stateModelPath);
+ } else {
+ logger.warn("Skip the operation.State Model directory exists:" +
stateModelPath);
+ return;
--- End diff --
Why was this changed to no longer throw an exception? It's better to fail
loudly in methods that return `void`.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---