http-api, http-service, rl-client: bulk upload configuration changes

This commit is contained in:
Max Weber
2020-11-23 00:14:55 -07:00
parent 4309dcd53e
commit e769ee0a7b
6 changed files with 175 additions and 77 deletions

View File

@@ -894,40 +894,32 @@ public class ConfigManager
private CompletableFuture<Void> sendConfig()
{
CompletableFuture<Void> future = null;
boolean changed;
synchronized (pendingChanges)
{
if (pendingChanges.isEmpty())
{
return null;
}
if (configClient != null)
{
future = CompletableFuture.allOf(pendingChanges.entrySet().stream().map(entry ->
{
String key = entry.getKey();
String value = entry.getValue();
Configuration patch = new Configuration(pendingChanges.entrySet().stream()
.map(e -> new ConfigEntry(e.getKey(), e.getValue()))
.collect(Collectors.toList()));
if (Strings.isNullOrEmpty(value))
{
return configClient.unset(key);
}
else
{
return configClient.set(key, value);
}
}).toArray(CompletableFuture[]::new));
future = configClient.patch(patch);
}
changed = !pendingChanges.isEmpty();
pendingChanges.clear();
}
if (changed)
try
{
try
{
saveToFile(propertiesFile);
}
catch (IOException ex)
{
log.warn("unable to save configuration file", ex);
}
saveToFile(propertiesFile);
}
catch (IOException ex)
{
log.warn("unable to save configuration file", ex);
}
return future;