@Test public void testMultipleNodesMustMoveFromOneHostButInsufficientCapacity() { var tester = new SpareCapacityMaintainerTester(); setupMultipleHosts(tester, 3); tester.maintainer.maintain(); assertEquals(0, tester.deployer.redeployments); assertEquals(0, tester.nodeRepository.list().retired().size()); assertEquals(0, tester.metric.values.get("spareHostCapacity")); }
@Override protected boolean maintain() { boolean success = true; if ( ! nodeRepository().zone().getCloud().allowHostSharing()) return success; NodeList allNodes = nodeRepository().list(); CapacityChecker capacityChecker = new CapacityChecker(allNodes); List<Node> overcommittedHosts = capacityChecker.findOvercommittedHosts(); metric.set("overcommittedHosts", overcommittedHosts.size(), null); retireOvercommitedHosts(allNodes, overcommittedHosts); Optional<CapacityChecker.HostFailurePath> failurePath = capacityChecker.worstCaseHostLossLeadingToFailure(); if (failurePath.isPresent()) { int spareHostCapacity = failurePath.get().hostsCausingFailure.size() - 1; if (spareHostCapacity == 0) { List<Move> mitigation = findMitigation(failurePath.get()); if (execute(mitigation)) { spareHostCapacity++; } else { success = false; } } metric.set("spareHostCapacity", spareHostCapacity, null); } return success; }
SpareCapacityMaintainer extends NodeRepositoryMaintainer { @Override protected boolean maintain() { boolean success = true; if ( ! nodeRepository().zone().getCloud().allowHostSharing()) return success; NodeList allNodes = nodeRepository().list(); CapacityChecker capacityChecker = new CapacityChecker(allNodes); List<Node> overcommittedHosts = capacityChecker.findOvercommittedHosts(); metric.set("overcommittedHosts", overcommittedHosts.size(), null); retireOvercommitedHosts(allNodes, overcommittedHosts); Optional<CapacityChecker.HostFailurePath> failurePath = capacityChecker.worstCaseHostLossLeadingToFailure(); if (failurePath.isPresent()) { int spareHostCapacity = failurePath.get().hostsCausingFailure.size() - 1; if (spareHostCapacity == 0) { List<Move> mitigation = findMitigation(failurePath.get()); if (execute(mitigation)) { spareHostCapacity++; } else { success = false; } } metric.set("spareHostCapacity", spareHostCapacity, null); } return success; } }
SpareCapacityMaintainer extends NodeRepositoryMaintainer { @Override protected boolean maintain() { boolean success = true; if ( ! nodeRepository().zone().getCloud().allowHostSharing()) return success; NodeList allNodes = nodeRepository().list(); CapacityChecker capacityChecker = new CapacityChecker(allNodes); List<Node> overcommittedHosts = capacityChecker.findOvercommittedHosts(); metric.set("overcommittedHosts", overcommittedHosts.size(), null); retireOvercommitedHosts(allNodes, overcommittedHosts); Optional<CapacityChecker.HostFailurePath> failurePath = capacityChecker.worstCaseHostLossLeadingToFailure(); if (failurePath.isPresent()) { int spareHostCapacity = failurePath.get().hostsCausingFailure.size() - 1; if (spareHostCapacity == 0) { List<Move> mitigation = findMitigation(failurePath.get()); if (execute(mitigation)) { spareHostCapacity++; } else { success = false; } } metric.set("spareHostCapacity", spareHostCapacity, null); } return success; } SpareCapacityMaintainer(Deployer deployer,
                                   NodeRepository nodeRepository,
                                   Metric metric,
                                   Duration interval);  SpareCapacityMaintainer(Deployer deployer,
                                   NodeRepository nodeRepository,
                                   Metric metric,
                                   Duration interval,
                                   int maxIterations); }
SpareCapacityMaintainer extends NodeRepositoryMaintainer { @Override protected boolean maintain() { boolean success = true; if ( ! nodeRepository().zone().getCloud().allowHostSharing()) return success; NodeList allNodes = nodeRepository().list(); CapacityChecker capacityChecker = new CapacityChecker(allNodes); List<Node> overcommittedHosts = capacityChecker.findOvercommittedHosts(); metric.set("overcommittedHosts", overcommittedHosts.size(), null); retireOvercommitedHosts(allNodes, overcommittedHosts); Optional<CapacityChecker.HostFailurePath> failurePath = capacityChecker.worstCaseHostLossLeadingToFailure(); if (failurePath.isPresent()) { int spareHostCapacity = failurePath.get().hostsCausingFailure.size() - 1; if (spareHostCapacity == 0) { List<Move> mitigation = findMitigation(failurePath.get()); if (execute(mitigation)) { spareHostCapacity++; } else { success = false; } } metric.set("spareHostCapacity", spareHostCapacity, null); } return success; } SpareCapacityMaintainer(Deployer deployer,
                                   NodeRepository nodeRepository,
                                   Metric metric,
                                   Duration interval);  SpareCapacityMaintainer(Deployer deployer,
                                   NodeRepository nodeRepository,
                                   Metric metric,
                                   Duration interval,
                                   int maxIterations);  }
SpareCapacityMaintainer extends NodeRepositoryMaintainer { @Override protected boolean maintain() { boolean success = true; if ( ! nodeRepository().zone().getCloud().allowHostSharing()) return success; NodeList allNodes = nodeRepository().list(); CapacityChecker capacityChecker = new CapacityChecker(allNodes); List<Node> overcommittedHosts = capacityChecker.findOvercommittedHosts(); metric.set("overcommittedHosts", overcommittedHosts.size(), null); retireOvercommitedHosts(allNodes, overcommittedHosts); Optional<CapacityChecker.HostFailurePath> failurePath = capacityChecker.worstCaseHostLossLeadingToFailure(); if (failurePath.isPresent()) { int spareHostCapacity = failurePath.get().hostsCausingFailure.size() - 1; if (spareHostCapacity == 0) { List<Move> mitigation = findMitigation(failurePath.get()); if (execute(mitigation)) { spareHostCapacity++; } else { success = false; } } metric.set("spareHostCapacity", spareHostCapacity, null); } return success; } SpareCapacityMaintainer(Deployer deployer,
                                   NodeRepository nodeRepository,
                                   Metric metric,
                                   Duration interval);  SpareCapacityMaintainer(Deployer deployer,
                                   NodeRepository nodeRepository,
                                   Metric metric,
                                   Duration interval,
                                   int maxIterations);   }