no need for specific time / empty based classes, just as final fields
This commit is contained in:
parent
3a534c64e5
commit
877105ee19
|
@ -56,14 +56,14 @@ public class DynamicSettings {
|
|||
}
|
||||
|
||||
public synchronized void addDynamicSetting(String setting) {
|
||||
addDynamicSetting(setting, Validator.EmptyValidator.INSTANCE);
|
||||
addDynamicSetting(setting, Validator.EMPTY);
|
||||
}
|
||||
|
||||
|
||||
public synchronized void addDynamicSettings(String... settings) {
|
||||
MapBuilder<String, Validator> updatedSettings = MapBuilder.newMapBuilder(dynamicSettings);
|
||||
for (String setting : settings) {
|
||||
updatedSettings.put(setting, Validator.EmptyValidator.INSTANCE);
|
||||
updatedSettings.put(setting, Validator.EMPTY);
|
||||
}
|
||||
dynamicSettings = updatedSettings.immutableMap();
|
||||
}
|
||||
|
|
|
@ -23,32 +23,20 @@ import org.elasticsearch.ElasticSearchParseException;
|
|||
import org.elasticsearch.common.unit.TimeValue;
|
||||
|
||||
/**
|
||||
* Validates a setting, returning a failure message if applicable.
|
||||
*/
|
||||
public interface Validator {
|
||||
|
||||
String validate(String setting, String value);
|
||||
|
||||
public static class EmptyValidator implements Validator {
|
||||
|
||||
public static final EmptyValidator INSTANCE = new EmptyValidator();
|
||||
|
||||
private EmptyValidator() {
|
||||
|
||||
}
|
||||
|
||||
public static final Validator EMPTY = new Validator() {
|
||||
@Override
|
||||
public String validate(String setting, String value) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class TimeValueValidator implements Validator {
|
||||
|
||||
public static final TimeValueValidator INSTANCE = new TimeValueValidator();
|
||||
|
||||
private TimeValueValidator() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
public static final Validator TIME = new Validator() {
|
||||
@Override
|
||||
public String validate(String setting, String value) {
|
||||
try {
|
||||
|
@ -60,5 +48,5 @@ public interface Validator {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public class IndexDynamicSettingsModule extends AbstractModule {
|
|||
indexDynamicSettings.addDynamicSetting(IndexMetaData.SETTING_BLOCKS_METADATA);
|
||||
indexDynamicSettings.addDynamicSetting(IndexShardGatewayService.INDEX_GATEWAY_SNAPSHOT_INTERVAL);
|
||||
indexDynamicSettings.addDynamicSetting(IndicesTTLService.INDEX_TTL_DISABLE_PURGE);
|
||||
indexDynamicSettings.addDynamicSetting(InternalIndexShard.INDEX_REFRESH_INTERVAL, Validator.TimeValueValidator.INSTANCE);
|
||||
indexDynamicSettings.addDynamicSetting(InternalIndexShard.INDEX_REFRESH_INTERVAL, Validator.TIME);
|
||||
indexDynamicSettings.addDynamicSetting(LocalGatewayAllocator.INDEX_RECOVERY_INITIAL_SHARDS);
|
||||
indexDynamicSettings.addDynamicSetting(LogByteSizeMergePolicyProvider.INDEX_MERGE_POLICY_MIN_MERGE_SIZE);
|
||||
indexDynamicSettings.addDynamicSetting(LogByteSizeMergePolicyProvider.INDEX_MERGE_POLICY_MAX_MERGE_SIZE);
|
||||
|
|
Loading…
Reference in New Issue