use of io.datarouter.clustersetting.ClusterSettingScope in project datarouter by hotpads.
the class ClusterSettingsHandler method parseClusterSettingKeyFromParams.
private ClusterSettingKey parseClusterSettingKeyFromParams() {
String name = params.required("name").trim();
// allow unrecognized serverType
String serverTypePersistentString = params.required("serverType");
String serverName = params.optional("serverName").orElse("");
ClusterSettingScope scope = ClusterSettingScope.fromParams(serverTypePersistentString, serverName);
return new ClusterSettingKey(name, scope, serverTypePersistentString, serverName);
}
use of io.datarouter.clustersetting.ClusterSettingScope in project datarouter by hotpads.
the class ClusterSettingService method getValidityForWebappInstance.
private ClusterSettingValidity getValidityForWebappInstance(ClusterSetting databeanSetting, WebappInstance webappInstance) {
String name = databeanSetting.getName();
ClusterSettingScope scope = databeanSetting.getScope();
if (!settingRootFinder.isRecognized(name)) {
if (clusterSettingRoot.settingsExcludedFromUnknownSettingsAlert.get().stream().anyMatch(setting -> StringTool.containsCaseInsensitive(name, setting))) {
return ClusterSettingValidity.VALID;
}
return ClusterSettingValidity.UNKNOWN;
}
CachedSetting<?> memorySetting = settingRootFinder.getSettingByName(name).orElse(null);
if (memorySetting == null) {
return ClusterSettingValidity.UNREFERENCED;
}
if (scope == ClusterSettingScope.SERVER_TYPE) {
String serverType = databeanSetting.getServerType();
try {
serverTypes.fromPersistentString(serverType);
} catch (RuntimeException e) {
return ClusterSettingValidity.INVALID_SERVER_TYPE;
}
}
if (scope == ClusterSettingScope.SERVER_NAME) {
String serverName = databeanSetting.getServerName();
String serverTypeFromWebappInstanceDao = webappInstanceDao.getServerTypeByServerName().get(serverName);
if (StringTool.isEmpty(serverTypeFromWebappInstanceDao)) {
return ClusterSettingValidity.INVALID_SERVER_NAME;
}
}
if (isClusterSettingRedundantForWebappInstance(memorySetting, databeanSetting, webappInstance)) {
return ClusterSettingValidity.REDUNDANT;
}
int oldSettingAlertThresholdDays = clusterSettingRoot.oldSettingAlertThresholdDays.get();
if (clusterSettingLogDao.isOldDatabaseSetting(databeanSetting, oldSettingAlertThresholdDays)) {
if (clusterSettingRoot.isExcludedOldSettingString(name)) {
return ClusterSettingValidity.VALID;
}
return ClusterSettingValidity.OLD;
}
return ClusterSettingValidity.VALID;
}
Aggregations