@Test public void mountDisksOnNewNodesShouldUseReachableNodes() throws CloudbreakException { Set<String> newNodeAddresses = Set.of("1.1.1.1"); try { when(stackService.getByIdWithListsInTransaction(1L)).thenReturn(stack); when(stack.getPlatformVariant()).thenReturn(CloudConstants.MOCK); expectedException.expect(NullPointerException.class); underTest.mountDisksOnNewNodes(1L, newNodeAddresses); } catch (Exception e) { verify(stackUtil).collectReachableNodes(stack); verify(stackUtil).collectNewNodesWithDiskData(stack, newNodeAddresses); throw e; } }
public void mountDisksOnNewNodes(Long stackId, Set<String> upscaleCandidateAddresses) throws CloudbreakException { Stack stack = stackService.getByIdWithListsInTransaction(stackId); stack.setResources(new HashSet<>(resourceService.getAllByStackId(stackId))); if (!StackService.REATTACH_COMPATIBLE_PLATFORMS.contains(stack.getPlatformVariant())) { return; } Set<Node> allNodes = stackUtil.collectReachableNodes(stack); Set<Node> nodes = stackUtil.collectNewNodesWithDiskData(stack, upscaleCandidateAddresses); mountDisks(stack, nodes, allNodes); }
MountDisks { public void mountDisksOnNewNodes(Long stackId, Set<String> upscaleCandidateAddresses) throws CloudbreakException { Stack stack = stackService.getByIdWithListsInTransaction(stackId); stack.setResources(new HashSet<>(resourceService.getAllByStackId(stackId))); if (!StackService.REATTACH_COMPATIBLE_PLATFORMS.contains(stack.getPlatformVariant())) { return; } Set<Node> allNodes = stackUtil.collectReachableNodes(stack); Set<Node> nodes = stackUtil.collectNewNodesWithDiskData(stack, upscaleCandidateAddresses); mountDisks(stack, nodes, allNodes); } }
MountDisks { public void mountDisksOnNewNodes(Long stackId, Set<String> upscaleCandidateAddresses) throws CloudbreakException { Stack stack = stackService.getByIdWithListsInTransaction(stackId); stack.setResources(new HashSet<>(resourceService.getAllByStackId(stackId))); if (!StackService.REATTACH_COMPATIBLE_PLATFORMS.contains(stack.getPlatformVariant())) { return; } Set<Node> allNodes = stackUtil.collectReachableNodes(stack); Set<Node> nodes = stackUtil.collectNewNodesWithDiskData(stack, upscaleCandidateAddresses); mountDisks(stack, nodes, allNodes); }  }
MountDisks { public void mountDisksOnNewNodes(Long stackId, Set<String> upscaleCandidateAddresses) throws CloudbreakException { Stack stack = stackService.getByIdWithListsInTransaction(stackId); stack.setResources(new HashSet<>(resourceService.getAllByStackId(stackId))); if (!StackService.REATTACH_COMPATIBLE_PLATFORMS.contains(stack.getPlatformVariant())) { return; } Set<Node> allNodes = stackUtil.collectReachableNodes(stack); Set<Node> nodes = stackUtil.collectNewNodesWithDiskData(stack, upscaleCandidateAddresses); mountDisks(stack, nodes, allNodes); }  void mountAllDisks(Long stackId); void mountDisksOnNewNodes(Long stackId, Set<String> upscaleCandidateAddresses); }
MountDisks { public void mountDisksOnNewNodes(Long stackId, Set<String> upscaleCandidateAddresses) throws CloudbreakException { Stack stack = stackService.getByIdWithListsInTransaction(stackId); stack.setResources(new HashSet<>(resourceService.getAllByStackId(stackId))); if (!StackService.REATTACH_COMPATIBLE_PLATFORMS.contains(stack.getPlatformVariant())) { return; } Set<Node> allNodes = stackUtil.collectReachableNodes(stack); Set<Node> nodes = stackUtil.collectNewNodesWithDiskData(stack, upscaleCandidateAddresses); mountDisks(stack, nodes, allNodes); }  void mountAllDisks(Long stackId); void mountDisksOnNewNodes(Long stackId, Set<String> upscaleCandidateAddresses);  }