Search in sources :

Example 11 with TopologySegment

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);
    }
}
Also used : FreeIpaClientExceptionUtil.ignoreNotFoundException(com.sequenceiq.freeipa.client.FreeIpaClientExceptionUtil.ignoreNotFoundException) LoggerFactory(org.slf4j.LoggerFactory) StringUtils(org.apache.commons.lang3.StringUtils) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) Inject(javax.inject.Inject) RetryableFreeIpaClientException(com.sequenceiq.freeipa.client.RetryableFreeIpaClientException) Service(org.springframework.stereotype.Service) Map(java.util.Map) Retryable(org.springframework.retry.annotation.Retryable) LinkedHashSet(java.util.LinkedHashSet) InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) Stack(com.sequenceiq.freeipa.entity.Stack) InstanceMetaDataService(com.sequenceiq.freeipa.service.stack.instance.InstanceMetaDataService) Logger(org.slf4j.Logger) TopologySuffix(com.sequenceiq.freeipa.client.model.TopologySuffix) Set(java.util.Set) FreeIpaClientException(com.sequenceiq.freeipa.client.FreeIpaClientException) FreeIpaClient(com.sequenceiq.freeipa.client.FreeIpaClient) TopologySegment(com.sequenceiq.freeipa.client.model.TopologySegment) Collectors(java.util.stream.Collectors) Backoff(org.springframework.retry.annotation.Backoff) Objects(java.util.Objects) List(java.util.List) FreeIpaClientFactory(com.sequenceiq.freeipa.service.freeipa.FreeIpaClientFactory) Optional(java.util.Optional) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Predicate.not(java.util.function.Predicate.not) TopologySegment(com.sequenceiq.freeipa.client.model.TopologySegment)

Aggregations

TopologySegment (com.sequenceiq.freeipa.client.model.TopologySegment)11 TopologySuffix (com.sequenceiq.freeipa.client.model.TopologySuffix)10 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)6 FreeIpaClient (com.sequenceiq.freeipa.client.FreeIpaClient)5 HashSet (java.util.HashSet)5 LinkedList (java.util.LinkedList)4 Test (org.junit.jupiter.api.Test)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)3 Stack (com.sequenceiq.freeipa.entity.Stack)3 StringUtils (org.apache.commons.lang3.StringUtils)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 FreeIpaClientExceptionUtil.ignoreNotFoundException (com.sequenceiq.freeipa.client.FreeIpaClientExceptionUtil.ignoreNotFoundException)2 RetryableFreeIpaClientException (com.sequenceiq.freeipa.client.RetryableFreeIpaClientException)2 FreeIpaClientFactory (com.sequenceiq.freeipa.service.freeipa.FreeIpaClientFactory)2 FreeIpaServerDeletionPollerObject (com.sequenceiq.freeipa.service.freeipa.cleanup.FreeIpaServerDeletionPollerObject)2 InstanceMetaDataService (com.sequenceiq.freeipa.service.stack.instance.InstanceMetaDataService)2 LinkedHashMap (java.util.LinkedHashMap)2 LinkedHashSet (java.util.LinkedHashSet)2 List (java.util.List)2