@Test public void devhostCapacityTest() { var nodeFlavors = FlavorConfigBuilder.createDummies("devhost", "container"); var devHost = Node.create("devhost", new IP.Config(Set.of("::1"), generateIPs(2, 10)), "devhost", Optional.empty(), Optional.empty(), nodeFlavors.getFlavorOrThrow("devhost"), Optional.empty(), NodeType.devhost, Optional.empty()); var cfg = Node.createDockerNode(Set.of("::2"), "cfg", "devhost", resources1, NodeType.config); var nodes = new ArrayList<>(List.of(cfg)); var capacity = new HostCapacity(new LockedNodeList(nodes, () -> {}), hostResourcesCalculator); assertTrue(capacity.hasCapacity(devHost, resources1)); var container1 = Node.createDockerNode(Set.of("::3"), "container1", "devhost", resources1, NodeType.tenant); nodes = new ArrayList<>(List.of(cfg, container1)); capacity = new HostCapacity(new LockedNodeList(nodes, () -> {}), hostResourcesCalculator); assertFalse(capacity.hasCapacity(devHost, resources1)); }
boolean hasCapacity(Node dockerHost, NodeResources requestedCapacity) { return freeCapacityOf(dockerHost, false).satisfies(requestedCapacity) && freeIPs(dockerHost) > 0; }
HostCapacity { boolean hasCapacity(Node dockerHost, NodeResources requestedCapacity) { return freeCapacityOf(dockerHost, false).satisfies(requestedCapacity) && freeIPs(dockerHost) > 0; } }
HostCapacity { boolean hasCapacity(Node dockerHost, NodeResources requestedCapacity) { return freeCapacityOf(dockerHost, false).satisfies(requestedCapacity) && freeIPs(dockerHost) > 0; } HostCapacity(NodeList allNodes, HostResourcesCalculator hostResourcesCalculator); }
HostCapacity { boolean hasCapacity(Node dockerHost, NodeResources requestedCapacity) { return freeCapacityOf(dockerHost, false).satisfies(requestedCapacity) && freeIPs(dockerHost) > 0; } HostCapacity(NodeList allNodes, HostResourcesCalculator hostResourcesCalculator); NodeList allNodes(); Set<Node> findSpareHosts(List<Node> candidates, int count); NodeResources freeCapacityOf(Node host); }
HostCapacity { boolean hasCapacity(Node dockerHost, NodeResources requestedCapacity) { return freeCapacityOf(dockerHost, false).satisfies(requestedCapacity) && freeIPs(dockerHost) > 0; } HostCapacity(NodeList allNodes, HostResourcesCalculator hostResourcesCalculator); NodeList allNodes(); Set<Node> findSpareHosts(List<Node> candidates, int count); NodeResources freeCapacityOf(Node host);  }