Create MaintenanceDeployment in try-with-resources
@@ -45,7 +45,7 @@ public class AutoscalingMaintainer extends Maintainer {
}
private void autoscale(ApplicationId application, List<Node> applicationNodes) {
- MaintenanceDeployment deployment = new MaintenanceDeployment(application, deployer, nodeRepository());
+ try (MaintenanceDeployment deployment = new MaintenanceDeployment(application, deployer, nodeRepository())) {
if ( ! deployment.isValid()) return; // Another config server will consider this application
nodesByCluster(applicationNodes).forEach((clusterSpec, clusterNodes) -> {
Optional<ClusterResources> target = autoscaler.autoscale(application, clusterSpec, clusterNodes);
@@ -54,6 +54,7 @@ public class AutoscalingMaintainer extends Maintainer {
" to " + t.nodes() + " * " + t.nodeResources()));
});
}
+ }
private Map<ClusterSpec, List<Node>> nodesByCluster(List<Node> applicationNodes) {
return applicationNodes.stream().collect(Collectors.groupingBy(n -> n.allocation().get().membership().cluster()));
