use of com.sequenceiq.freeipa.client.model.TopologySegment in project cloudbreak by hortonworks.
the class FreeIpaTopologyService method removeExtraSegments.
private void removeExtraSegments(FreeIpaClient freeIpaClient, String topologySuffixCn, Set<TopologySegment> topology) throws FreeIpaClientException {
Set<UnorderedPair> topologyToKeep = topology.stream().map(segment -> new UnorderedPair(segment.getLeftNode(), segment.getRightNode())).collect(Collectors.toSet());
Set<TopologySegment> segmentsToRemove = freeIpaClient.findTopologySegments(topologySuffixCn).stream().filter(segment -> !topologyToKeep.contains(new UnorderedPair(segment.getLeftNode(), segment.getRightNode()))).collect(Collectors.toSet());
for (TopologySegment segment : segmentsToRemove) {
ignoreNotFoundException(() -> freeIpaClient.deleteTopologySegment(topologySuffixCn, segment), "Deleting topology segment for [{}] but it was not found", segment);
}
}
Aggregations