@Test public void testNoRebalancingIfRecentlyDeployed() { RebalancerTester tester = new RebalancerTester(); tester.deployApp(cpuApp); Node cpuSkewedNode = tester.getNode(cpuApp); tester.maintain(); assertFalse("No better place to move the skewed node, so no action is taken", tester.getNode(cpuSkewedNode.hostname()).get().status().wantToRetire()); Node newCpuHost = tester.makeReadyNode("cpu"); tester.activateTenantHosts(); tester.deployApp(cpuApp, false ); tester.maintain(); assertFalse("No action, since app was recently deployed", tester.isNodeRetired(cpuSkewedNode)); tester.clock().advance(waitTimeAfterPreviousDeployment); tester.maintain(); assertTrue("Rebalancer retired the node we wanted to move away from", tester.isNodeRetired(cpuSkewedNode)); assertTrue("... and added a node on the new host instead", tester.getNodes(cpuApp, Node.State.active).stream().anyMatch(node -> node.hasParent(newCpuHost.hostname()))); }
@Override protected boolean maintain() { boolean success = true; if ( ! nodeRepository().zone().getCloud().allowHostSharing()) return success; if (nodeRepository().zone().environment().isTest()) return success; NodeList allNodes = nodeRepository().list(); updateSkewMetric(allNodes); if ( ! zoneIsStable(allNodes)) return success; findBestMove(allNodes).execute(true, Agent.Rebalancer, deployer, metric, nodeRepository()); return success; }
Rebalancer extends NodeRepositoryMaintainer { @Override protected boolean maintain() { boolean success = true; if ( ! nodeRepository().zone().getCloud().allowHostSharing()) return success; if (nodeRepository().zone().environment().isTest()) return success; NodeList allNodes = nodeRepository().list(); updateSkewMetric(allNodes); if ( ! zoneIsStable(allNodes)) return success; findBestMove(allNodes).execute(true, Agent.Rebalancer, deployer, metric, nodeRepository()); return success; } }
Rebalancer extends NodeRepositoryMaintainer { @Override protected boolean maintain() { boolean success = true; if ( ! nodeRepository().zone().getCloud().allowHostSharing()) return success; if (nodeRepository().zone().environment().isTest()) return success; NodeList allNodes = nodeRepository().list(); updateSkewMetric(allNodes); if ( ! zoneIsStable(allNodes)) return success; findBestMove(allNodes).execute(true, Agent.Rebalancer, deployer, metric, nodeRepository()); return success; } Rebalancer(Deployer deployer,
                      NodeRepository nodeRepository,
                      Metric metric,
                      Clock clock,
                      Duration interval); }
Rebalancer extends NodeRepositoryMaintainer { @Override protected boolean maintain() { boolean success = true; if ( ! nodeRepository().zone().getCloud().allowHostSharing()) return success; if (nodeRepository().zone().environment().isTest()) return success; NodeList allNodes = nodeRepository().list(); updateSkewMetric(allNodes); if ( ! zoneIsStable(allNodes)) return success; findBestMove(allNodes).execute(true, Agent.Rebalancer, deployer, metric, nodeRepository()); return success; } Rebalancer(Deployer deployer,
                      NodeRepository nodeRepository,
                      Metric metric,
                      Clock clock,
                      Duration interval);  }
Rebalancer extends NodeRepositoryMaintainer { @Override protected boolean maintain() { boolean success = true; if ( ! nodeRepository().zone().getCloud().allowHostSharing()) return success; if (nodeRepository().zone().environment().isTest()) return success; NodeList allNodes = nodeRepository().list(); updateSkewMetric(allNodes); if ( ! zoneIsStable(allNodes)) return success; findBestMove(allNodes).execute(true, Agent.Rebalancer, deployer, metric, nodeRepository()); return success; } Rebalancer(Deployer deployer,
                      NodeRepository nodeRepository,
                      Metric metric,
                      Clock clock,
                      Duration interval);   }