@Test void finalizeDoesNotRemoveStackLink() throws TransactionExecutionException { Cluster cluster = new Cluster(); Stack stack = new Stack(); stack.setId(STACK_ID); cluster.setStack(stack); when(clusterService.findOneWithLists(STACK_ID)).thenReturn(Optional.of(cluster)); underTest.finalizeClusterTermination(STACK_ID, true); assertThat(cluster.getStack()).isNotNull(); assertThat(cluster.getStack()).isEqualTo(stack); }
public void finalizeClusterTermination(Long clusterId, boolean force) throws TransactionExecutionException { Cluster cluster = clusterService.findOneWithLists(clusterId) .orElseThrow(NotFoundException.notFound("cluster", clusterId)); Set<RDSConfig> rdsConfigs = cluster.getRdsConfigs(); Long stackId = cluster.getStack().getId(); String terminatedName = cluster.getName() + DELIMITER + new Date().getTime(); cluster.setName(terminatedName); clusterService.cleanupCluster(stackId); FileSystem fs = cluster.getFileSystem(); if (fs != null) { deleteFileSystemResources(stackId, fs, force); } cluster.setBlueprint(null); cluster.setStatus(DELETE_COMPLETED); cluster.setFileSystem(null); transactionService.required(() -> { deleteClusterHostGroupsWithItsMetadata(cluster); rdsConfigService.deleteDefaultRdsConfigs(rdsConfigs); componentConfigProviderService.deleteComponentsForStack(stackId); return null; }); }
ClusterTerminationService { public void finalizeClusterTermination(Long clusterId, boolean force) throws TransactionExecutionException { Cluster cluster = clusterService.findOneWithLists(clusterId) .orElseThrow(NotFoundException.notFound("cluster", clusterId)); Set<RDSConfig> rdsConfigs = cluster.getRdsConfigs(); Long stackId = cluster.getStack().getId(); String terminatedName = cluster.getName() + DELIMITER + new Date().getTime(); cluster.setName(terminatedName); clusterService.cleanupCluster(stackId); FileSystem fs = cluster.getFileSystem(); if (fs != null) { deleteFileSystemResources(stackId, fs, force); } cluster.setBlueprint(null); cluster.setStatus(DELETE_COMPLETED); cluster.setFileSystem(null); transactionService.required(() -> { deleteClusterHostGroupsWithItsMetadata(cluster); rdsConfigService.deleteDefaultRdsConfigs(rdsConfigs); componentConfigProviderService.deleteComponentsForStack(stackId); return null; }); } }
ClusterTerminationService { public void finalizeClusterTermination(Long clusterId, boolean force) throws TransactionExecutionException { Cluster cluster = clusterService.findOneWithLists(clusterId) .orElseThrow(NotFoundException.notFound("cluster", clusterId)); Set<RDSConfig> rdsConfigs = cluster.getRdsConfigs(); Long stackId = cluster.getStack().getId(); String terminatedName = cluster.getName() + DELIMITER + new Date().getTime(); cluster.setName(terminatedName); clusterService.cleanupCluster(stackId); FileSystem fs = cluster.getFileSystem(); if (fs != null) { deleteFileSystemResources(stackId, fs, force); } cluster.setBlueprint(null); cluster.setStatus(DELETE_COMPLETED); cluster.setFileSystem(null); transactionService.required(() -> { deleteClusterHostGroupsWithItsMetadata(cluster); rdsConfigService.deleteDefaultRdsConfigs(rdsConfigs); componentConfigProviderService.deleteComponentsForStack(stackId); return null; }); }  }
ClusterTerminationService { public void finalizeClusterTermination(Long clusterId, boolean force) throws TransactionExecutionException { Cluster cluster = clusterService.findOneWithLists(clusterId) .orElseThrow(NotFoundException.notFound("cluster", clusterId)); Set<RDSConfig> rdsConfigs = cluster.getRdsConfigs(); Long stackId = cluster.getStack().getId(); String terminatedName = cluster.getName() + DELIMITER + new Date().getTime(); cluster.setName(terminatedName); clusterService.cleanupCluster(stackId); FileSystem fs = cluster.getFileSystem(); if (fs != null) { deleteFileSystemResources(stackId, fs, force); } cluster.setBlueprint(null); cluster.setStatus(DELETE_COMPLETED); cluster.setFileSystem(null); transactionService.required(() -> { deleteClusterHostGroupsWithItsMetadata(cluster); rdsConfigService.deleteDefaultRdsConfigs(rdsConfigs); componentConfigProviderService.deleteComponentsForStack(stackId); return null; }); }  void finalizeClusterTermination(Long clusterId, boolean force); }
ClusterTerminationService { public void finalizeClusterTermination(Long clusterId, boolean force) throws TransactionExecutionException { Cluster cluster = clusterService.findOneWithLists(clusterId) .orElseThrow(NotFoundException.notFound("cluster", clusterId)); Set<RDSConfig> rdsConfigs = cluster.getRdsConfigs(); Long stackId = cluster.getStack().getId(); String terminatedName = cluster.getName() + DELIMITER + new Date().getTime(); cluster.setName(terminatedName); clusterService.cleanupCluster(stackId); FileSystem fs = cluster.getFileSystem(); if (fs != null) { deleteFileSystemResources(stackId, fs, force); } cluster.setBlueprint(null); cluster.setStatus(DELETE_COMPLETED); cluster.setFileSystem(null); transactionService.required(() -> { deleteClusterHostGroupsWithItsMetadata(cluster); rdsConfigService.deleteDefaultRdsConfigs(rdsConfigs); componentConfigProviderService.deleteComponentsForStack(stackId); return null; }); }  void finalizeClusterTermination(Long clusterId, boolean force);  }