@Test public void retireFromOvercommitedHosts() { var tester = new SpareCapacityMaintainerTester(5); tester.addHosts(7, new NodeResources(10, 100, 1000, 1)); tester.addNodes(0, 5, new NodeResources( 7, 70, 700, 0.7), 0); tester.addNodes(1, 4, new NodeResources( 2, 20, 200, 0.2), 0); tester.addNodes(2, 2, new NodeResources( 1.1, 10, 100, 0.1), 1); tester.maintainer.maintain(); assertEquals(2, tester.metric.values.get("overcommittedHosts")); assertEquals(1, tester.deployer.redeployments); assertEquals(List.of(new NodeResources( 1.1, 10, 100, 0.1)), tester.nodeRepository.list().retired().mapToList(Node::resources)); }
@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);   }