private ServerName generateMissingFavoredNodeSingleRack(List<ServerName> favoredNodes, List<ServerName> excludeNodes) throws IOException { ServerName newServer = null; Set<ServerName> excludeFNSet = Sets.newHashSet(favoredNodes); if (excludeNodes != null && excludeNodes.size() > 0) { excludeFNSet.addAll(excludeNodes); } if (favoredNodes.size() < FAVORED_NODES_NUM) { newServer = this.getOneRandomServer(this.uniqueRackList.get(0), excludeFNSet); } return newServer; }
Set<String> oldHostsNoLongerPresent = Sets.newTreeSet();
newFilesSet = Sets.difference(newFilesSet, compactedFilesSet.keySet()); Set<StoreFileInfo> toBeAddedFiles = Sets.difference(newFilesSet, currentFilesSet.keySet()); Set<StoreFileInfo> toBeRemovedFiles = Sets.difference(currentFilesSet.keySet(), newFilesSet);
@Override public Set<E> adjacentEdges(E edge) { EndpointPair<N> endpointPair = incidentNodes(edge); // Verifies that edge is in this network. Set<E> endpointPairIncidentEdges = Sets.union(incidentEdges(endpointPair.nodeU()), incidentEdges(endpointPair.nodeV())); return Sets.difference(endpointPairIncidentEdges, ImmutableSet.of(edge)); }
private Set<ServerName> getInheritedFNForDaughter(FavoredNodeAssignmentHelper helper, List<ServerName> parentFavoredNodes, Position primary, Position secondary) throws IOException { Set<ServerName> daughterFN = Sets.newLinkedHashSet(); if (parentFavoredNodes.size() >= primary.ordinal()) { daughterFN.add(parentFavoredNodes.get(primary.ordinal())); } if (parentFavoredNodes.size() >= secondary.ordinal()) { daughterFN.add(parentFavoredNodes.get(secondary.ordinal())); } while (daughterFN.size() < FavoredNodeAssignmentHelper.FAVORED_NODES_NUM) { ServerName newNode = helper.generateMissingFavoredNode(Lists.newArrayList(daughterFN)); daughterFN.add(newNode); } return daughterFN; }
Set<String> gcBeanNames = Sets.intersection(gcTimesAfterSleep.keySet(), gcTimesBeforeSleep.keySet()); List<String> gcDiffs = Lists.newArrayList();
private Set<ServerName> getInheritedFNForDaughter(FavoredNodeAssignmentHelper helper, List<ServerName> parentFavoredNodes, Position primary, Position secondary) throws IOException { Set<ServerName> daughterFN = Sets.newLinkedHashSet(); if (parentFavoredNodes.size() >= primary.ordinal()) { daughterFN.add(parentFavoredNodes.get(primary.ordinal())); } if (parentFavoredNodes.size() >= secondary.ordinal()) { daughterFN.add(parentFavoredNodes.get(secondary.ordinal())); } while (daughterFN.size() < FAVORED_NODES_NUM) { ServerName newNode = helper.generateMissingFavoredNode(Lists.newArrayList(daughterFN)); daughterFN.add(newNode); } return daughterFN; }
if (Sets.intersection(srcAddrs, desAddrs).size() > 0) { return true;
@VisibleForTesting Set<Path> getLastestPath() { synchronized (latestPaths) { return Sets.newHashSet(latestPaths.values()); } }
private SortedSet<Address> getDefaultServers() throws IOException { SortedSet<Address> defaultServers = Sets.newTreeSet(); for (ServerName serverName : getOnlineRS()) { Address server = Address.fromParts(serverName.getHostname(), serverName.getPort()); boolean found = false; for (RSGroupInfo rsgi : listRSGroups()) { if (!RSGroupInfo.DEFAULT_GROUP.equals(rsgi.getName()) && rsgi.containsServer(server)) { found = true; break; } } if (!found) { defaultServers.add(server); } } return defaultServers; }
/** * Creates a <i>mutable</i> {@code LinkedHashSet} instance containing the given elements in order. * * <p><b>Note:</b> if mutability is not required and the elements are non-null, use {@link * ImmutableSet#copyOf(Iterable)} instead. * * <p><b>Note for Java 7 and later:</b> if {@code elements} is a {@link Collection}, you don't * need this method. Instead, use the {@code LinkedHashSet} constructor directly, taking advantage * of the new <a href="http://goo.gl/iz2Wi">"diamond" syntax</a>. * * <p>Overall, this method is not very useful and will likely be deprecated in the future. * * @param elements the elements that the set should contain, in order * @return a new {@code LinkedHashSet} containing those elements (minus duplicates) */ public static <E> LinkedHashSet<E> newLinkedHashSet(Iterable<? extends E> elements) { if (elements instanceof Collection) { return new LinkedHashSet<E>(Collections2.cast(elements)); } LinkedHashSet<E> set = newLinkedHashSet(); Iterables.addAll(set, elements); return set; }
@Override Set<E> createElementSet() { return Sets.intersection(multiset1.elementSet(), multiset2.elementSet()); }
checkNotNull(set2, "set2"); final Set<? extends E> set2minus1 = difference(set2, set1);
ClusterCompactionQueues(int concurrentServers) { this.concurrentServers = concurrentServers; this.compactionQueues = Maps.newHashMap(); this.lock = new ReentrantReadWriteLock(); this.compactingServers = Sets.newHashSet(); }
/** * List all of the files in 'dir' that match the regex 'pattern'. * Then check that this list is identical to 'expectedMatches'. * @throws IOException if the dir is inaccessible */ public static void assertGlobEquals(File dir, String pattern, String ... expectedMatches) throws IOException { Set<String> found = Sets.newTreeSet(); for (File f : FileUtil.listFiles(dir)) { if (f.getName().matches(pattern)) { found.add(f.getName()); } } Set<String> expectedSet = Sets.newTreeSet( Arrays.asList(expectedMatches)); Assert.assertEquals("Bad files matching " + pattern + " in " + dir, Joiner.on(",").join(expectedSet), Joiner.on(",").join(found)); }
Set<K> keysToLoad = Sets.newLinkedHashSet(); for (K key : keys) { V value = get(key);
@Override protected Set<String> getColumnFamilies() { return Sets.newHashSet(FAMILY_NAME); }
if (tPerm.getFamily() != null) { if (tPerm.getQualifier() != null) { Set<byte[]> qualifiers = Sets.newTreeSet(Bytes.BYTES_COMPARATOR); qualifiers.add(tPerm.getQualifier()); familyMap.put(tPerm.getFamily(), qualifiers);
/** * Filter and return regions for which favored nodes is not applicable. * * @param regions - collection of regions * @return set of regions for which favored nodes is not applicable */ public static Set<RegionInfo> filterNonFNApplicableRegions(Collection<RegionInfo> regions) { Set<RegionInfo> fnRegions = Sets.newHashSet(); for (RegionInfo regionInfo : regions) { if (!isFavoredNodeApplicable(regionInfo)) { fnRegions.add(regionInfo); } } return fnRegions; }
if (tperm.getFamily() != null) { if (tperm.getQualifier() != null) { Set<byte[]> qualifiers = Sets.newTreeSet(Bytes.BYTES_COMPARATOR); qualifiers.add(tperm.getQualifier()); familyMap.put(tperm.getFamily(), qualifiers);