@Test public void provision_exact_capacity() { var tester = new DynamicProvisioningTester(Cloud.builder().dynamicProvisioning(false).build()); NodeResources resources1 = new NodeResources(24, 64, 100, 1); NodeResources resources2 = new NodeResources(16, 24, 100, 1); tester.flagSource.withListFlag(Flags.TARGET_CAPACITY.id(), List.of(new HostCapacity(resources1.vcpu(), resources1.memoryGb(), resources1.diskGb(), 1), new HostCapacity(resources2.vcpu(), resources2.memoryGb(), resources2.diskGb(), 2)), HostCapacity.class); tester.maintainer.maintain(); assertEquals(1, tester.provisionedHostsMatching(resources1)); assertEquals(2, tester.provisionedHostsMatching(resources2)); tester.assertNodesUnchanged(); NodeResources resources3 = new NodeResources(48, 128, 1000, 1); tester.flagSource.withListFlag(Flags.TARGET_CAPACITY.id(), List.of(new HostCapacity(resources1.vcpu(), resources1.memoryGb(), resources1.diskGb(), 1), new HostCapacity(resources3.vcpu(), resources3.memoryGb(), resources3.diskGb(), 1)), HostCapacity.class); tester.maintainer.maintain(); assertEquals(1, tester.provisionedHostsMatching(resources1)); assertEquals(0, tester.provisionedHostsMatching(resources2)); assertEquals(1, tester.provisionedHostsMatching(resources3)); assertEquals(2, tester.nodeRepository.getNodes(Node.State.deprovisioned).size()); tester.maintainer.maintain(); List<Node> provisioned = tester.nodeRepository.list().state(Node.State.provisioned).asList(); tester.nodeRepository.setReady(provisioned, Agent.system, this.getClass().getSimpleName()); tester.provisioningTester.activateTenantHosts(); ApplicationId application = ProvisioningTester.makeApplicationId(); tester.provisioningTester.deploy(application, Capacity.from(new ClusterResources(2, 1, new NodeResources(4, 8, 50, 0.1)))); assertEquals(2, tester.nodeRepository.list().owner(application).size()); tester.assertNodesUnchanged(); tester.flagSource.withListFlag(Flags.TARGET_CAPACITY.id(), List.of(), HostCapacity.class); tester.assertNodesUnchanged(); tester.flagSource.withListFlag(Flags.TARGET_CAPACITY.id(), List.of(new HostCapacity(resources1.vcpu(), resources1.memoryGb(), resources1.diskGb(), 1)), HostCapacity.class); tester.assertNodesUnchanged(); }
@Override protected boolean maintain() { try (Mutex lock = nodeRepository().lockUnallocated()) { NodeList nodes = nodeRepository().list(); resumeProvisioning(nodes, lock); convergeToCapacity(nodes); } return true; }
DynamicProvisioningMaintainer extends NodeRepositoryMaintainer { @Override protected boolean maintain() { try (Mutex lock = nodeRepository().lockUnallocated()) { NodeList nodes = nodeRepository().list(); resumeProvisioning(nodes, lock); convergeToCapacity(nodes); } return true; } }
DynamicProvisioningMaintainer extends NodeRepositoryMaintainer { @Override protected boolean maintain() { try (Mutex lock = nodeRepository().lockUnallocated()) { NodeList nodes = nodeRepository().list(); resumeProvisioning(nodes, lock); convergeToCapacity(nodes); } return true; } DynamicProvisioningMaintainer(NodeRepository nodeRepository,
                                  Duration interval,
                                  HostProvisioner hostProvisioner,
                                  FlagSource flagSource,
                                  Metric metric); }
DynamicProvisioningMaintainer extends NodeRepositoryMaintainer { @Override protected boolean maintain() { try (Mutex lock = nodeRepository().lockUnallocated()) { NodeList nodes = nodeRepository().list(); resumeProvisioning(nodes, lock); convergeToCapacity(nodes); } return true; } DynamicProvisioningMaintainer(NodeRepository nodeRepository,
                                  Duration interval,
                                  HostProvisioner hostProvisioner,
                                  FlagSource flagSource,
                                  Metric metric);  }
DynamicProvisioningMaintainer extends NodeRepositoryMaintainer { @Override protected boolean maintain() { try (Mutex lock = nodeRepository().lockUnallocated()) { NodeList nodes = nodeRepository().list(); resumeProvisioning(nodes, lock); convergeToCapacity(nodes); } return true; } DynamicProvisioningMaintainer(NodeRepository nodeRepository,
                                  Duration interval,
                                  HostProvisioner hostProvisioner,
                                  FlagSource flagSource,
                                  Metric metric);   }