List of usage examples for com.google.common.collect Sets difference
public static <E> SetView<E> difference(final Set<E> set1, final Set<?> set2)
From source file:org.jclouds.atmosonline.saas.functions.ParseUserMetadataFromHeaders.java
public UserMetadata apply(HttpResponse from) { UserMetadata md = new UserMetadata(); Map<String, String> metaMap = getMetaMap( checkNotNull(from.getFirstHeaderOrNull(AtmosStorageHeaders.META), AtmosStorageHeaders.META)); Set<String> keys = Sets.difference(metaMap.keySet(), sysKeys); for (String key : keys) { md.getMetadata().put(key, metaMap.get(key)); }//from ww w . j a v a 2 s . c om if (from.getFirstHeaderOrNull(AtmosStorageHeaders.LISTABLE_META) != null) md.getListableMetadata() .putAll(getMetaMap(from.getFirstHeaderOrNull(AtmosStorageHeaders.LISTABLE_META))); if (from.getFirstHeaderOrNull(AtmosStorageHeaders.TAGS) != null) md.getTags().addAll(getTags(from.getFirstHeaderOrNull(AtmosStorageHeaders.TAGS))); if (from.getFirstHeaderOrNull(AtmosStorageHeaders.LISTABLE_TAGS) != null) md.getTags().addAll(getTags(from.getFirstHeaderOrNull(AtmosStorageHeaders.LISTABLE_TAGS))); return md; }
From source file:org.jdag.graph.scheduler.BoundedWorkerSchedulingPolicy.java
/** * {@inheritDoc}/* w w w. j a v a2s .c o m*/ */ @Override public HostID getWorkerNode(VertexID graphVertexID, ExecutionRegistry stateRegistry) { Set<HostID> workers = stateRegistry.getWorkers(); if (workers.isEmpty()) { return null; } Set<HostID> currentWorkersForGraph = stateRegistry.getWorkersForGraph(graphVertexID.getGraphID()); if (currentWorkersForGraph.isEmpty()) { return workers.iterator().next(); } else { SetView<HostID> availableWorkers = Sets.difference(workers, currentWorkersForGraph); if (availableWorkers.isEmpty()) { return null; } else { return availableWorkers.iterator().next(); } } }
From source file:au.edu.uq.nmerge.mvd.CompactNode.java
/** * Find the set of versions this node lacks as incoming * * @return the difference outgoing - incoming *///from w ww . jav a 2 s. c o m Set<Witness> getWantsIncoming() { return Sets.newHashSet(Sets.difference(outgoing, incoming)); }
From source file:net.sourceforge.fenixedu.applicationTier.Servico.scientificCouncil.UpdateDegreeCurricularPlanMembersGroup.java
private static void updateBolonhaManagerRoleToGroupDelta(DegreeCurricularPlan degreeCurricularPlan, Group original, Group changed) { Set<User> originalMembers = original.getMembers(); Set<User> newMembers = changed.getMembers(); for (User user : Sets.difference(originalMembers, newMembers)) { Person person = user.getPerson(); if (person.hasRole(RoleType.BOLONHA_MANAGER) && !belongsToOtherGroupsWithSameRole(degreeCurricularPlan, person)) { person.removeRoleByType(RoleType.BOLONHA_MANAGER); }//w w w . j av a2 s . co m } Role bolonhaRole = Role.getRoleByRoleType(RoleType.BOLONHA_MANAGER); for (User user : Sets.difference(newMembers, originalMembers)) { Person person = user.getPerson(); if (!person.hasRole(RoleType.BOLONHA_MANAGER)) { person.addPersonRoles(bolonhaRole); } } }
From source file:com.cognifide.aet.cleaner.processors.RemoveArtifactsProcessor.java
@Override @SuppressWarnings("unchecked") public void process(Exchange exchange) throws Exception { final CleanerContext cleanerContext = exchange.getIn().getHeader(CleanerContext.KEY_NAME, CleanerContext.class); final ReferencedArtifactsMessageBody messageBody = exchange.getIn() .getBody(ReferencedArtifactsMessageBody.class); final Sets.SetView<String> artifactsToRemove = Sets.difference(messageBody.getArtifactsToRemove(), messageBody.getArtifactsToKeep()); LOGGER.debug("Artifacts that will be removed: {}", artifactsToRemove); if (!cleanerContext.isDryRun()) { LOGGER.info("{} unreferenced artifacts will be removed from {} after cleaning suite `{}`", artifactsToRemove.size(), messageBody.getDbKey(), messageBody.getData()); artifactsDAO.removeArtifacts(messageBody.getDbKey(), artifactsToRemove); LOGGER.info("{} artifacts removed successfully!", artifactsToRemove.size()); } else {/*from www . j a v a 2 s. com*/ LOGGER.info( "Dry run completed! {} unreferenced artifacts should be removed from {} after cleaning suite `{}`", artifactsToRemove.size(), messageBody.getDbKey(), messageBody.getData()); } }
From source file:de.bund.bfr.jung.BetterDirectedSparseMultigraph.java
@Override public Collection<E> getEdges() { Set<E> picked = owner.getPickedEdgeState().getPicked(); Set<E> unPicked = Sets.difference(edges.keySet(), picked); return Sets.union(unPicked, picked); }
From source file:com.facebook.buck.graph.DirectedAcyclicGraph.java
@Override public ImmutableSet<T> getNodesWithNoIncomingEdges() { return ImmutableSet.copyOf(Sets.difference(nodes, incomingEdges.keySet())); }
From source file:org.lib.sharding.repository.SimpleNodeRepository.java
@Override public void sync(@NotNull Set<ClusterNode> actual, @NotNull ClusterNode self) { synchronized (nodes) { Set<ClusterNode> uniqueNodes = ImmutableSet.copyOf(nodes); Sets.SetView<ClusterNode> removedNodes = Sets.difference(uniqueNodes, actual); Sets.SetView<ClusterNode> addedNodes = Sets.difference(actual, uniqueNodes); for (ClusterNode added : addedNodes) { log.info("Adding node to the list with [{}] on node [{}]", added, self); add(added);//from ww w . j a v a 2 s . c o m } for (ClusterNode removed : removedNodes) { log.info("Removing node from the list [{}] on node [{}]", removed, self); remove(removed); } } }
From source file:org.apache.druid.data.input.impl.MapInputRowParser.java
@Override public List<InputRow> parseBatch(Map<String, Object> theMap) { final List<String> dimensions = parseSpec.getDimensionsSpec().hasCustomDimensions() ? parseSpec.getDimensionsSpec().getDimensionNames() : Lists.newArrayList(//from ww w .ja v a 2s . c om Sets.difference(theMap.keySet(), parseSpec.getDimensionsSpec().getDimensionExclusions())); final DateTime timestamp; try { timestamp = parseSpec.getTimestampSpec().extractTimestamp(theMap); if (timestamp == null) { final String input = theMap.toString(); throw new NullPointerException(StringUtils.format("Null timestamp in input: %s", input.length() < 100 ? input : input.substring(0, 100) + "...")); } } catch (Exception e) { throw new ParseException(e, "Unparseable timestamp found! Event: %s", theMap); } return ImmutableList.of(new MapBasedInputRow(timestamp.getMillis(), dimensions, theMap)); }
From source file:ezbake.frack.common.utils.INSUtil.java
/** * This method returns the INS information for a feed. The INS information includes the Warehaus URI prefix and * the set of topics to which the given feed will be broadcasting. NOTE: only non-system topics will be returned * from this method. To view system topics, please consult INS. * * @param pipeline the pipeline object for which we are gathering INS information * @param feedName the feed name to gather information for * @return the {@link ezbake.frack.common.utils.INSUtil.INSInfo} object containing the URI prefix and broadcast * topics for the given feed//www . j a v a 2 s.c o m */ public static INSInfo getINSInfo(Pipeline pipeline, String feedName) { ThriftClientPool pool = null; InternalNameService.Client insClient = null; Properties props = pipeline.getProperties(); String applicationSecurityId = new EzBakeApplicationConfigurationHelper(props).getSecurityID(); try { pool = new ThriftClientPool(props); insClient = pool.getClient(InternalNameServiceConstants.SERVICE_NAME, InternalNameService.Client.class); Set<String> topics = insClient.getTopicsForFeed(applicationSecurityId, feedName); Set<String> systemTopics = insClient.getSystemTopics(); String prefix = insClient.getURIPrefix(applicationSecurityId, feedName); return new INSInfo(new HashSet<>(Sets.difference(topics, systemTopics)), prefix); } catch (TException e) { logger.error("Could not retrieve information from INS service", e); throw new RuntimeException(e); } finally { if (pool != null) { pool.returnToPool(insClient); pool.close(); } } }