protected against a wrong format in the index.auto_expand_replicas setting

This commit is contained in:
kimchy 2011-03-21 14:36:28 +02:00
parent d2e61af9ee
commit 6c241f3de8
1 changed files with 12 additions and 6 deletions

View File

@ -55,13 +55,19 @@ public class MetaDataUpdateSettingsService extends AbstractComponent implements
try { try {
final int numberOfReplicas = event.state().nodes().dataNodes().size() - 1; final int numberOfReplicas = event.state().nodes().dataNodes().size() - 1;
int min = Integer.parseInt(autoExpandReplicas.substring(0, autoExpandReplicas.indexOf('-'))); int min;
int max; int max;
String sMax = autoExpandReplicas.substring(autoExpandReplicas.indexOf('-') + 1); try {
if (sMax.equals("all")) { min = Integer.parseInt(autoExpandReplicas.substring(0, autoExpandReplicas.indexOf('-')));
max = event.state().nodes().dataNodes().size() - 1; String sMax = autoExpandReplicas.substring(autoExpandReplicas.indexOf('-') + 1);
} else { if (sMax.equals("all")) {
max = Integer.parseInt(sMax); max = event.state().nodes().dataNodes().size() - 1;
} else {
max = Integer.parseInt(sMax);
}
} catch (Exception e) {
logger.warn("failed to set [{}], wrong format [{}]", IndexMetaData.SETTING_AUTO_EXPAND_REPLICAS, autoExpandReplicas);
continue;
} }
// same value, nothing to do there // same value, nothing to do there