Java Code Examples for com.google.common.collect.Sets#difference()

The following examples show how to use com.google.common.collect.Sets#difference() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PluginPackageService.java    From wecube-platform with Apache License 2.0 6 votes vote down vote up
void createRolesIfNotExistInSystem(PluginPackage pluginPackage) {
	Set<PluginPackageAuthority> pluginPackageAuthorities = pluginPackage.getPluginPackageAuthorities();
	if (null != pluginPackageAuthorities && pluginPackageAuthorities.size() > 0) {
		List<RoleDto> roleDtos = userManagementService.retrieveAllRoles();
		Set<String> existingRoleNames = new HashSet<>();
		if (null != roleDtos && roleDtos.size() > 0) {
			existingRoleNames = roleDtos.stream().map(roleDto -> roleDto.getName()).collect(Collectors.toSet());
		}
		Set<String> roleNamesInPlugin = pluginPackageAuthorities.stream().map(authority -> authority.getRoleName())
				.collect(Collectors.toSet());
		Set<String> roleNamesDefinedInPluginButNotExistInSystem = Sets.difference(roleNamesInPlugin,
				existingRoleNames);
		if (!roleNamesDefinedInPluginButNotExistInSystem.isEmpty()) {
			roleNamesDefinedInPluginButNotExistInSystem.forEach(it -> {
				RoleDto rd = new RoleDto();
				rd.setName(it);
				rd.setDisplayName(it);
				userManagementService.registerLocalRole(rd);
			});
		}
	}
}
 
Example 2
Source File: DockerComposeContainer.java    From testcontainers-java with MIT License 6 votes vote down vote up
private void waitUntilServiceStarted() {
    listChildContainers().forEach(this::createServiceInstance);

    Set<String> servicesToWaitFor = waitStrategyMap.keySet();
    Set<String> instantiatedServices = serviceInstanceMap.keySet();
    Sets.SetView<String> missingServiceInstances =
        Sets.difference(servicesToWaitFor, instantiatedServices);

    if (!missingServiceInstances.isEmpty()) {
        throw new IllegalStateException(
            "Services named " + missingServiceInstances + " " +
                "do not exist, but wait conditions have been defined " +
                "for them. This might mean that you misspelled " +
                "the service name when defining the wait condition.");
    }

    serviceInstanceMap.forEach(this::waitUntilServiceStarted);
}
 
Example 3
Source File: LocalizationService.java    From molgenis with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Adds Localization strings for missing messageIDs in a namespace. User needs write permission on
 * the {@link L10nString} entity.
 *
 * @param namespace the namespace to which the missing messageIDs should be added
 * @param messageIDs the missing messageIDs to add.
 */
@Transactional
public void addMissingMessageIds(String namespace, Set<String> messageIDs) {
  Set<String> alreadyPresent =
      getExistingMessages(namespace, messageIDs)
          .map(L10nString::getMessageID)
          .collect(toCollection(TreeSet::new));
  Set<String> toAdd = Sets.difference(messageIDs, alreadyPresent);
  if (!toAdd.isEmpty()) {
    Stream<L10nString> entities =
        toAdd.stream()
            .map(key -> l10nStringFactory.create(key).setMessageID(key))
            .map(l -> l.setNamespace(namespace));
    dataService.add(L10N_STRING, entities);
    LOG.debug("Added message IDs to namespace '{}' : {}.", namespace, messageIDs);
  }
}
 
Example 4
Source File: DLPDomainConfiguration.java    From james-project with Apache License 2.0 5 votes vote down vote up
private Optional<Event> generateAddedRulesEvent(Set<DLPConfigurationItem> existingRules, Set<DLPConfigurationItem> updateRulesSet, EventId nextEventId) {
    Set<DLPConfigurationItem> addedRules = Sets.difference(updateRulesSet, existingRules);
    if (!addedRules.isEmpty()) {
        return Optional.of(new ConfigurationItemsAdded(aggregateId, nextEventId, addedRules));
    }
    return Optional.empty();
}
 
Example 5
Source File: SSTable.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
private static Set<Component> discoverComponentsFor(Descriptor desc)
{
    Set<Component.Type> knownTypes = Sets.difference(Component.TYPES, Collections.singleton(Component.Type.CUSTOM));
    Set<Component> components = Sets.newHashSetWithExpectedSize(knownTypes.size());
    for (Component.Type componentType : knownTypes)
    {
        Component component = new Component(componentType);
        if (new File(desc.filenameFor(component)).exists())
            components.add(component);
    }
    return components;
}
 
Example 6
Source File: MessageFastViewFactory.java    From james-project with Apache License 2.0 5 votes vote down vote up
private Flux<MessageFastView> gatherMessageViews(Set<MessageId> messageIds, MailboxSession mailboxSession,
                                                 Map<MessageId, MessageFastViewPrecomputedProperties> fastProjections) {
    Set<MessageId> withProjectionEntry = fastProjections.keySet();
    Set<MessageId> withoutProjectionEntry = Sets.difference(messageIds, withProjectionEntry);
    return Flux.merge(
        Helpers.toMessageViews(fetch(withProjectionEntry, FetchGroup.HEADERS, mailboxSession),
            new FromMessageResultAndPreview(blobManager, fastProjections)),
        Helpers.toMessageViews(fetch(withoutProjectionEntry, FetchGroup.FULL_CONTENT, mailboxSession),
            messageFullViewFactory::fromMessageResults));
}
 
Example 7
Source File: TestDistributedSet.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public CompletableFuture<Boolean> retainAll(Collection<? extends E> c) {
    Set<? extends E> s = (c instanceof Set) ?
                         (Set<? extends E>) c :
                         ImmutableSet.copyOf(c);
    Set<E> notInSet2 = Sets.difference(set, s);
    return removeAll(ImmutableSet.copyOf(notInSet2));
}
 
Example 8
Source File: ParboiledFilterSpecifier.java    From batfish with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public Set<IpAccessList> visitDifferenceFilterAstNode(
    DifferenceFilterAstNode differenceFilterAstNode) {
  return Sets.difference(
      differenceFilterAstNode.getLeft().accept(this),
      differenceFilterAstNode.getRight().accept(this));
}
 
Example 9
Source File: ParboiledLocationSpecifier.java    From batfish with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public Set<Location> visitDifferenceLocationAstNode(
    DifferenceLocationAstNode differenceLocationAstNode) {
  return Sets.difference(
      differenceLocationAstNode.getLeft().accept(this),
      differenceLocationAstNode.getRight().accept(this));
}
 
Example 10
Source File: ProjectExplorerAnalysisTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test which analyses are present for a user space trace
 */
@Test
public void testUstAnalyses() {
    Set<AnalysisNode> actualNodes = getAnalysisNodes(fBot, fUstTraceFile, false);
    StringJoiner sj = new StringJoiner(", ", "{", "}");
    actualNodes.forEach(node -> sj.add(node.fTitle));
    assertTrue(sj.toString(), actualNodes.containsAll(UST_ANALYSIS_NODES));

    if (!UST_ANALYSIS_NODES.containsAll(actualNodes)) {
        SetView<AnalysisNode> diff = Sets.difference(UST_ANALYSIS_NODES, actualNodes);
        diff.forEach(elem -> System.err.println("New untested analysis : " + elem));
    }
}
 
Example 11
Source File: MessageMovesWithMailbox.java    From james-project with Apache License 2.0 4 votes vote down vote up
public Set<Mailbox> removedMailboxes() {
    return Sets.difference(previousMailboxes, targetMailboxes);
}
 
Example 12
Source File: DiffUtil.java    From owltools with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public static Diff getDiff(Diff diff) throws OWLOntologyCreationException {
    OWLOntology ontology1 = diff.ontology1;
    OWLOntology ontology2 = diff.ontology2;
    Set<OWLAxiom> axioms1 = ontology1.getAxioms();
    Set<OWLAxiom> axioms2 = ontology2.getAxioms();

    Set<OWLAxiom> sharedDeclarations = new HashSet<>();
    if (diff.isCompareClassesInCommon) {
        Set<OWLClass> cs1 = ontology1.getClassesInSignature();
        Set<OWLClass> cs2 = ontology2.getClassesInSignature();
        Set<OWLClass> cs = Sets.intersection(cs1, cs2);
        axioms1 = new HashSet<>();
        axioms2 = new HashSet<>();
        for (OWLClass c : cs) {
            sharedDeclarations.add(ontology1.
                    getOWLOntologyManager().
                    getOWLDataFactory().
                    getOWLDeclarationAxiom(c));
            axioms1.addAll(ontology1.getAxioms(c));
            axioms1.addAll(ontology1.getAnnotationAssertionAxioms(c.getIRI()));
            axioms2.addAll(ontology2.getAxioms(c));
            axioms2.addAll(ontology2.getAnnotationAssertionAxioms(c.getIRI()));
        }
    }
    
    axioms1 = filter(axioms1, diff);
    axioms2 = filter(axioms2, diff);

    // map from compared axiom to full axiom
    Map<OWLAxiom, Set<OWLAxiom>> umap1 = diff.umap1;
    Map<OWLAxiom, Set<OWLAxiom>> umap2 = diff.umap2;

    axioms1 = unannotateAxioms(axioms1, umap1, 
            ontology1.getOWLOntologyManager().getOWLDataFactory(),
            diff.isCompareUnannotatedForm);
    axioms2 = unannotateAxioms(axioms2, umap2, 
            ontology2.getOWLOntologyManager().getOWLDataFactory(),
            diff.isCompareUnannotatedForm);

    Set<OWLAxiom> intersectionAxioms = Sets.intersection(axioms1, axioms2);
    Set<OWLAxiom> unionAxioms = Sets.union(axioms1, axioms2);
    Set<OWLAxiom> axioms1remaining = Sets.difference(axioms1, axioms2);
    Set<OWLAxiom> axioms2remaining = Sets.difference(axioms2, axioms1);
    //System.out.println("A2R="+axioms2remaining);
    
    
    if (diff.isCompareUnannotatedForm) {
        intersectionAxioms = 
                Sets.union(
                        diff.mapAxioms1(intersectionAxioms),
                        diff.mapAxioms2(intersectionAxioms));
        axioms1remaining = diff.mapAxioms1(axioms1remaining);
        axioms2remaining = diff.mapAxioms2(axioms2remaining);
    }
    
    if (diff.isAddSharedDeclarations) {
        axioms1remaining = Sets.union(axioms1remaining, sharedDeclarations);
        axioms2remaining = Sets.union(axioms2remaining, sharedDeclarations);
    }
 
    diff.intersectionOntology = diff.ontology(intersectionAxioms);
    diff.ontology1remaining = diff.ontology(axioms1remaining);
    diff.ontology2remaining = diff.ontology(axioms2remaining);
    diff.ontologyDiff = diff.ontology(Sets.union(axioms1remaining , axioms2remaining ));

    return diff;
}
 
Example 13
Source File: GermlinePloidyAnnotatedTargetCollection.java    From gatk-protected with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Perform a number of checks on the arguments passed to the constructor:
 * <dl>
 *     <dt> Assert both lists are non-empty </dt>
 *     <dt> Assert targets have unique names </dt>
 *     <dt> Assert each contig is annotated only once </dt>
 *     <dt> Assert all targets have annotated contigs </dt>
 * </dl>
 *
 * @param targetList list of targets
 * @param contigAnnotsList list of contig ploidy annotations
 */
private void performValidityChecks(@Nonnull final List<Target> targetList,
                                   @Nonnull final List<ContigGermlinePloidyAnnotation> contigAnnotsList) {
    /* assert the lists are non-empty */
    Utils.validateArg(!Utils.nonNull(targetList, "Target list must be non-null").isEmpty(),
            "Target list can not be empty");
    Utils.validateArg(!Utils.nonNull(contigAnnotsList, "Contig ploidy annotation list must be non-null").isEmpty(),
            "Contig germline ploidy annotation list can not be empty");

    /* assert targets have unique names */
    final Map<String, Long> targetNameCounts = targetList.stream()
            .map(Target::getName)
            .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
    Utils.validateArg(targetNameCounts.keySet().size() == targetList.size(),
            "Targets must have unique names. Non-unique target names: " + targetNameCounts.keySet().stream()
                    .filter(name -> targetNameCounts.get(name) > 1)
                    .collect(Collectors.joining(", ")));

    /* assert contigs are not annotated multiple times */
    final Map<String, Long> contigAnnotsCounts = contigAnnotsList.stream()
            .map(ContigGermlinePloidyAnnotation::getContigName)
            .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
    Utils.validateArg(contigAnnotsCounts.keySet().size() == contigAnnotsList.size(),
            "Some contigs are multiply annotated: " + contigAnnotsCounts.keySet().stream()
                        .filter(contig -> contigAnnotsCounts.get(contig) > 1) /* multiply annotated contigs */
                        .collect(Collectors.joining(", ")));

    /* assert all contigs present in the target list are annotated */
    final Set<String> contigNamesFromTargets = targetList.stream()
            .map(Target::getContig).collect(Collectors.toSet());
    final Set<String> contigNamesFromAnnots = contigAnnotsList.stream()
            .map(ContigGermlinePloidyAnnotation::getContigName).collect(Collectors.toSet());
    final Set<String> missingContigs = Sets.difference(contigNamesFromTargets, contigNamesFromAnnots);
    Utils.validateArg(missingContigs.isEmpty(), "All contigs must be annotated. Annotations are missing for: " +
                missingContigs.stream().collect(Collectors.joining(", ")));

    /* assert all contigs have annotations for all ploidy classes */
    final Set<String> firstAnnotPloidyTagSet = contigAnnotsList.get(0).getGenotypesSet();
    Utils.validateArg(contigAnnotsList.stream().allMatch(annot -> annot.getGenotypesSet().equals(firstAnnotPloidyTagSet)),
            "Not all entries in the contig germline ploidy annotation list have the same set of genotypes");
}
 
Example 14
Source File: AbstractCSQueue.java    From big-c with Apache License 2.0 4 votes vote down vote up
synchronized void setupQueueConfigs(Resource clusterResource)
    throws IOException {
  // get labels
  this.accessibleLabels =
      csContext.getConfiguration().getAccessibleNodeLabels(getQueuePath());
  this.defaultLabelExpression = csContext.getConfiguration()
      .getDefaultNodeLabelExpression(getQueuePath());

  // inherit from parent if labels not set
  if (this.accessibleLabels == null && parent != null) {
    this.accessibleLabels = parent.getAccessibleNodeLabels();
  }
  
  // inherit from parent if labels not set
  if (this.defaultLabelExpression == null && parent != null
      && this.accessibleLabels.containsAll(parent.getAccessibleNodeLabels())) {
    this.defaultLabelExpression = parent.getDefaultNodeLabelExpression();
  }

  // After we setup labels, we can setup capacities
  setupConfigurableCapacities();
  
  this.maximumAllocation =
      csContext.getConfiguration().getMaximumAllocationPerQueue(
          getQueuePath());
  
  authorizer = YarnAuthorizationProvider.getInstance(csContext.getConf());
  
  this.state = csContext.getConfiguration().getState(getQueuePath());
  this.acls = csContext.getConfiguration().getAcls(getQueuePath());

  // Update metrics
  CSQueueUtils.updateQueueStatistics(
      resourceCalculator, this, parent, clusterResource, minimumAllocation);
  
  // Check if labels of this queue is a subset of parent queue, only do this
  // when we not root
  if (parent != null && parent.getParent() != null) {
    if (parent.getAccessibleNodeLabels() != null
        && !parent.getAccessibleNodeLabels().contains(RMNodeLabelsManager.ANY)) {
      // if parent isn't "*", child shouldn't be "*" too
      if (this.getAccessibleNodeLabels().contains(RMNodeLabelsManager.ANY)) {
        throw new IOException("Parent's accessible queue is not ANY(*), "
            + "but child's accessible queue is *");
      } else {
        Set<String> diff =
            Sets.difference(this.getAccessibleNodeLabels(),
                parent.getAccessibleNodeLabels());
        if (!diff.isEmpty()) {
          throw new IOException("Some labels of child queue is not a subset "
              + "of parent queue, these labels=["
              + StringUtils.join(diff, ",") + "]");
        }
      }
    }
  }

  this.reservationsContinueLooking = csContext.getConfiguration()
      .getReservationContinueLook();

  this.preemptionDisabled = isQueueHierarchyPreemptionDisabled(this);
}
 
Example 15
Source File: CombineSegmentBreakpoints.java    From gatk with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void traverse() {

    final AnnotatedIntervalCollection annotatedIntervalCollection1 = AnnotatedIntervalCollection.create(segmentFiles.get(0).toPath(), columnsOfInterest);
    final List<AnnotatedInterval> segments1 = annotatedIntervalCollection1.getRecords();

    final AnnotatedIntervalCollection annotatedIntervalCollection2 = AnnotatedIntervalCollection.create(segmentFiles.get(1).toPath(), columnsOfInterest);
    final List<AnnotatedInterval> segments2 = annotatedIntervalCollection2.getRecords();

    final SAMFileHeader outputSamFileHeader = createOutputSamFileHeader(annotatedIntervalCollection1, annotatedIntervalCollection2);

    // Check to see if we should warn the user that one or more columns of interest were not seen in any input file.
    final Set<String> allSeenAnnotations = Sets.union(new HashSet<>(annotatedIntervalCollection1.getAnnotations()),
            new HashSet<>(annotatedIntervalCollection2.getAnnotations()));
    final Set<String> unusedColumnsOfInterest = Sets.difference(columnsOfInterest, allSeenAnnotations);
    if (unusedColumnsOfInterest.size() > 0) {
        final List<String> missingColumns = new ArrayList<>(unusedColumnsOfInterest);
        throw new UserException.BadInput("Some columns of interest specified by the user were not seen in any input files: " + StringUtils.join(missingColumns, ", "));
    }

    // Create a map of input to output headers.  I.e. the annotation in the segment1 to the output that should be written in the final file.
    //  This assumes that the keys in each entry of the list is the same.
    // TODO: If we want to support more than two segment files, this is the only bit that requires thinking.  Once this is solved, then this logic can go into a utility class.
    final Set<String> intersectingAnnotations = Sets.intersection(segments1.get(0).getAnnotations().keySet(), segments2.get(0).getAnnotations().keySet());

    // Create the obvious mappings that are identity then tack on new annotations for conflicts.
    // These are mappings that take the header name from the segment files and map to an output header to avoid conflicts.
    final Map<String, String> input1ToOutputHeaderMap = segments1.get(0).getAnnotations().keySet().stream().filter(a -> !intersectingAnnotations.contains(a))
            .collect(Collectors.toMap(Function.identity(), Function.identity()));
    intersectingAnnotations.forEach(a -> input1ToOutputHeaderMap.put(a, a + "_" + segmentFileLabels.get(0)));

    final Map<String, String> input2ToOutputHeaderMap = segments2.get(0).getAnnotations().keySet().stream().filter(a -> !intersectingAnnotations.contains(a))
            .collect(Collectors.toMap(Function.identity(), Function.identity()));
    intersectingAnnotations.forEach(a -> input2ToOutputHeaderMap.put(a, a + "_" + segmentFileLabels.get(1)));

    final List<AnnotatedInterval> finalList = annotateCombinedIntervals(segments1, segments2,
            Arrays.asList(input1ToOutputHeaderMap, input2ToOutputHeaderMap), outputSamFileHeader.getSequenceDictionary(),
            l -> progressMeter.update(l));

    final List<String> finalAnnotations = Lists.newArrayList(finalList.get(0).getAnnotations().keySet());
    finalAnnotations.sort(String::compareTo);

    final AnnotatedIntervalCollection finalCollection =
            AnnotatedIntervalCollection.create(finalList, outputSamFileHeader, finalAnnotations);
    finalCollection.write(outputFile);
}
 
Example 16
Source File: IdentifierSet.java    From raptor with Apache License 2.0 4 votes vote down vote up
public Set<String> unusedIncludes() {
  return Sets.difference(includes, usedIncludes);
}
 
Example 17
Source File: DBHistoricalUserState.java    From passopolis-server with GNU General Public License v3.0 4 votes vote down vote up
public DBHistoricalUserState(ListMySecretsAndGroupKeysResponse resp, Map<Integer, GroupInfo> orgIdToOrg, long timestampMs) {
  this.userId = resp.myUserId;
  this.timestampMs = timestampMs;
  // sort the users
  this.visibleUsers = Sets.newTreeSet(resp.autocompleteUsers);
  numVisibleUsersInSameDomain = 0;
  String myDomain = userId.split("@")[1];
  for (String u : visibleUsers) {
    if (myDomain.equals(u.split("@")[1])) {
      ++numVisibleUsersInSameDomain;
    }
  }
  
  this.organizations = Lists.newArrayList();
  
  this.secrets = resp.secretToPath.values();
  this.groups = resp.groups.values();
  numGroups = groups.size();
  Set<Integer> myPrivateGroups = Sets.newHashSet();
  Set<Integer> seenOrgs = Sets.newHashSet();
  for (GroupInfo gi : groups) {
    if (gi.isNonOrgPrivateGroup || gi.isOrgPrivateGroup) {
      myPrivateGroups.add(gi.groupId);
    }
    if (gi.owningOrgId != null && seenOrgs.add(gi.owningOrgId)) {
      organizations.add(orgIdToOrg.get(gi.owningOrgId));
    }
    if (gi.isTopLevelOrg && seenOrgs.add(gi.groupId)) {
      organizations.add(orgIdToOrg.get(gi.groupId));
    }
  }
  numOrganizations = organizations.size();
  numSecrets = secrets.size();
  numVisibleUsers = visibleUsers.size();
  Set<Integer> sharedSecrets = new HashSet<Integer>();
  for (Secret s : secrets) {
    // the user should be excluded from this list.
    Set<String> usersExcludingMe = Sets.difference(Sets.newHashSet(s.users), ImmutableSet.of(userId));
    Set<Integer> groupsExcludingMe = Sets.difference(Sets.newHashSet(s.groups), myPrivateGroups);
    if (!(usersExcludingMe.isEmpty() && groupsExcludingMe.isEmpty())) {
      sharedSecrets.add(s.secretId);
    }
  }
  numSharedSecrets = sharedSecrets.size();
}
 
Example 18
Source File: OrphanedKmsKeyCleanUpJob.java    From cerberus with Apache License 2.0 4 votes vote down vote up
/**
 * Downloads all the KMS CMK policies for the keys in the given region to determine what keys it
 * created and compares that set to the set of keys it has in the datastore to find and delete
 * orphaned keys
 *
 * @param authKmsKeyMetadataList The kms metadata from the data store
 * @param regionName The region to process and delete orphaned keys in
 * @return The set or orphaned keys it found and processed
 */
protected Set<String> processRegion(
    List<AuthKmsKeyMetadata> authKmsKeyMetadataList, String regionName) {
  log.info("Processing region: {}", regionName);
  // Get the KMS Key Ids that are in the db for the current region
  Set<String> currentKmsCmkIdsForRegion =
      authKmsKeyMetadataList.stream()
          .filter(
              authKmsKeyMetadata ->
                  StringUtils.equalsIgnoreCase(authKmsKeyMetadata.getAwsRegion(), regionName))
          .map(
              authKmsKeyMetadata -> {
                String fullArn = authKmsKeyMetadata.getAwsKmsKeyId();
                return fullArn.split("/")[1];
              })
          .collect(Collectors.toSet());

  log.info("Fetching all KMS CMK ids keys for the region: {}", regionName);
  Set<String> allKmsCmkIdsForRegion = kmsService.getKmsKeyIdsForRegion(regionName);
  log.info("Found {} keys to process for region: {}", allKmsCmkIdsForRegion.size(), regionName);

  log.info("Filtering out the keys that were not created by this environment");
  Set<String> kmsCmksCreatedByKmsService =
      kmsService.filterKeysCreatedByKmsService(allKmsCmkIdsForRegion, regionName);
  log.info(
      "Found {} keys to created by this environment process for region: {}",
      kmsCmksCreatedByKmsService.size(),
      regionName);

  log.info(
      "Calculating difference between the set of keys created by this env to the set of keys in the db");
  Set<String> orphanedKmsKeysForRegion =
      Sets.difference(kmsCmksCreatedByKmsService, currentKmsCmkIdsForRegion);
  log.info(
      "Found {} keys that were orphaned for region: {}",
      orphanedKmsKeysForRegion.size(),
      regionName);

  logRegionSummary(
      regionName,
      kmsCmksCreatedByKmsService,
      currentKmsCmkIdsForRegion,
      orphanedKmsKeysForRegion);

  // Delete the orphaned keys
  if (!isDeleteOrphanKeysInDryMode) {
    orphanedKmsKeysForRegion.forEach(
        kmsCmkId ->
            kmsService.scheduleKmsKeyDeletion(
                kmsCmkId, regionName, SOONEST_A_KMS_KEY_CAN_BE_DELETED));
  }

  return orphanedKmsKeysForRegion;
}
 
Example 19
Source File: TestDistributedSet.java    From onos with Apache License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<Boolean> retainAll(Collection<? extends E> c) {
    Set notInSet2;
    notInSet2 = Sets.difference(set, (Set<?>) c);
    return removeAll(ImmutableSet.copyOf(notInSet2));
}
 
Example 20
Source File: SetUtil.java    From j360-dubbo-app-all with Apache License 2.0 2 votes vote down vote up
/**
 * set1, set2的差集(在set1,不在set2中的对象)的只读view,不复制产生新的Set对象.
 * 
 * 如果尝试写入该View会抛出UnsupportedOperationException
 */
public static <E> Set<E> differenceView(final Set<E> set1, final Set<?> set2) {
	return Sets.difference(set1, set2);
}