Refine search
protected void removeMissingServerConnectionPools(List<Server> oldList, List<Server> newList) { Set<Server> oldSet = new HashSet<>(oldList); Set<Server> newSet = new HashSet<>(newList); Set<Server> removedSet = Sets.difference(oldSet, newSet); if (!removedSet.isEmpty()) { LOG.debug("Removing connection pools for missing servers. vip = " + this.vip + ". " + removedSet.size() + " servers gone."); for (Server s : removedSet) { IConnectionPool pool = perServerPools.remove(s); if (pool != null) { pool.shutdown(); } } } }
public Set<String> difference(Set<String> set1, Set<String> set2) { if (set1.isEmpty() || set2.isEmpty()) { return set1; } return Sets.difference(set1, set2).immutableCopy(); }
private synchronized void updateCompletedDriverGroups(TaskStatus taskStatus) { // Sets.difference returns a view. // Once we add the difference into `completedDriverGroups`, the view will be empty. // `completedLifespansChangeListeners.invoke` happens asynchronously. // As a result, calling the listeners before updating `completedDriverGroups` doesn't make a difference. // That's why a copy must be made here. Set<Lifespan> newlyCompletedDriverGroups = ImmutableSet.copyOf(Sets.difference(taskStatus.getCompletedDriverGroups(), this.completedDriverGroups)); if (newlyCompletedDriverGroups.isEmpty()) { return; } completedLifespansChangeListeners.invoke(newlyCompletedDriverGroups, executor); // newlyCompletedDriverGroups is a view. // Making changes to completedDriverGroups will change newlyCompletedDriverGroups. completedDriverGroups.addAll(newlyCompletedDriverGroups); } }
public StaticSelector( Optional<Pattern> userRegex, Optional<Pattern> sourceRegex, Optional<List<String>> clientTags, Optional<SelectorResourceEstimate> selectorResourceEstimate, Optional<String> queryType, ResourceGroupIdTemplate group) { this.userRegex = requireNonNull(userRegex, "userRegex is null"); this.sourceRegex = requireNonNull(sourceRegex, "sourceRegex is null"); requireNonNull(clientTags, "clientTags is null"); this.clientTags = ImmutableSet.copyOf(clientTags.orElse(ImmutableList.of())); this.selectorResourceEstimate = requireNonNull(selectorResourceEstimate, "selectorResourceEstimate is null"); this.queryType = requireNonNull(queryType, "queryType is null"); this.group = requireNonNull(group, "group is null"); HashSet<String> variableNames = new HashSet<>(ImmutableList.of(USER_VARIABLE, SOURCE_VARIABLE)); userRegex.ifPresent(u -> addNamedGroups(u, variableNames)); sourceRegex.ifPresent(s -> addNamedGroups(s, variableNames)); this.variableNames = ImmutableSet.copyOf(variableNames); Set<String> unresolvedVariables = Sets.difference(group.getVariableNames(), variableNames); checkArgument(unresolvedVariables.isEmpty(), "unresolved variables %s in resource group ID '%s', available: %s\"", unresolvedVariables, group, variableNames); }
@Override public Optional<ConnectorNewTableLayout> getNewTableLayout(ConnectorSession connectorSession, ConnectorTableMetadata tableMetadata) { List<String> distributeColumns = (List<String>) tableMetadata.getProperties().get(DISTRIBUTED_ON); if (distributeColumns.isEmpty()) { return Optional.empty(); } Set<String> undefinedColumns = Sets.difference( ImmutableSet.copyOf(distributeColumns), tableMetadata.getColumns().stream() .map(ColumnMetadata::getName) .collect(toSet())); if (!undefinedColumns.isEmpty()) { throw new PrestoException(INVALID_TABLE_PROPERTY, "Distribute columns not defined on table: " + undefinedColumns); } return Optional.of(new ConnectorNewTableLayout(BlackHolePartitioningHandle.INSTANCE, distributeColumns)); }
@Override public Map<NamedKey, byte[]> getBulk(Iterable<NamedKey> keys) { Set<NamedKey> remaining = Sets.newHashSet(keys); Map<NamedKey, byte[]> res = level1.getBulk(keys); hitCount.addAndGet(res.size()); remaining = Sets.difference(remaining, res.keySet()); if (!remaining.isEmpty()) { Map<NamedKey, byte[]> res2 = getBulkL2(remaining); for (Map.Entry<NamedKey, byte[]> entry : res2.entrySet()) { level1.put(entry.getKey(), entry.getValue()); } int size = res2.size(); hitCount.addAndGet(size); missCount.addAndGet(remaining.size() - size); if (size != 0) { res = new HashMap<>(res); res.putAll(res2); } } return res; }
/** * Assemble watch keys for the given appId, cluster, namespaces, dataCenter combination * * @return a multimap with namespace as the key and watch keys as the value */ public Multimap<String, String> assembleAllWatchKeys(String appId, String clusterName, Set<String> namespaces, String dataCenter) { Multimap<String, String> watchedKeysMap = assembleWatchKeys(appId, clusterName, namespaces, dataCenter); //Every app has an 'application' namespace if (!(namespaces.size() == 1 && namespaces.contains(ConfigConsts.NAMESPACE_APPLICATION))) { Set<String> namespacesBelongToAppId = namespacesBelongToAppId(appId, namespaces); Set<String> publicNamespaces = Sets.difference(namespaces, namespacesBelongToAppId); //Listen on more namespaces if it's a public namespace if (!publicNamespaces.isEmpty()) { watchedKeysMap .putAll(findPublicConfigWatchKeys(appId, clusterName, publicNamespaces, dataCenter)); } } return watchedKeysMap; }
/** * Validate the Job's added Linux capabilities. * * @param job The Job to check. * * @return A set of error Strings */ private Set<String> validateAddCapabilities(final Job job) { final Set<String> caps = job.getAddCapabilities(); if (caps == null) { return emptySet(); } final Set<String> errors = Sets.newHashSet(); final Set<String> disallowedCaps = Sets.difference(caps, whitelistedCapabilities); if (!disallowedCaps.isEmpty()) { errors.add(String.format( "The following Linux capabilities aren't allowed by the Helios master: '%s'. " + "The allowed capabilities are: '%s'.", Joiner.on(", ").join(disallowedCaps), Joiner.on(", ").join(whitelistedCapabilities))); } return errors; }
Set<String> missingColumns = Sets.difference(inputColumnMap.keySet(), new HashSet<>(fileColumnNames)); if (!missingColumns.isEmpty()) { throw new PrestoException(NOT_FOUND, format("Table %s.%s does not have columns %s", schema, tableName, missingColumns));
private List<IssueDto> loadIssues(SearchResponseData preloadedResponseData, Collector collector, DbSession dbSession) { List<IssueDto> preloadedIssues = preloadedResponseData.getIssues(); Set<String> preloadedIssueKeys = preloadedIssues.stream().map(IssueDto::getKey).collect(MoreCollectors.toSet(preloadedIssues.size())); ImmutableSet<String> issueKeys = ImmutableSet.copyOf(collector.getIssueKeys()); Set<String> issueKeysToLoad = copyOf(difference(issueKeys, preloadedIssueKeys)); if (issueKeysToLoad.isEmpty()) { return issueKeys.stream() .map(new KeyToIssueFunction(preloadedIssues)::apply).filter(Objects::nonNull) .collect(Collectors.toList()); } List<IssueDto> loadedIssues = dbClient.issueDao().selectByKeys(dbSession, issueKeysToLoad); List<IssueDto> unorderedIssues = concat(preloadedIssues.stream(), loadedIssues.stream()) .collect(toList(preloadedIssues.size() + loadedIssues.size())); return issueKeys.stream() .map(new KeyToIssueFunction(unorderedIssues)::apply).filter(Objects::nonNull) .collect(Collectors.toList()); }
final Set<SegmentId> missingFromRequested = Sets.difference(current, requested); if (!missingFromRequested.isEmpty()) { throw new ISE( "Merge is invalid: current segment(s) are not in the requested set: %s", final Set<SegmentId> missingFromCurrent = Sets.difference(requested, current); if (!missingFromCurrent.isEmpty()) { throw new ISE( "Merge is invalid: requested segment(s) are not in the current set: %s",
private void doHasAllFauxveridesTest(Class<?> descendant, Class<?> ancestor) { Set<MethodSignature> required = getAllRequiredToFauxveride(ancestor); Set<MethodSignature> found = getAllFauxveridden(descendant, ancestor); Set<MethodSignature> missing = ImmutableSortedSet.copyOf(difference(required, found)); if (!missing.isEmpty()) { fail( rootLocaleFormat( "%s should hide the public static methods declared in %s: %s", descendant.getSimpleName(), ancestor.getSimpleName(), missing)); } }
if (keys == null || keys.isEmpty()) { return Collections.emptyMap(); Sets.difference(keys, res.stream().map(InternalPropertyDto::getKey).collect(Collectors.toSet())) .forEach(key -> builder.put(key, Optional.empty())); List<String> keyWithClobValue = ImmutableList.copyOf(Sets.difference(keys, builder.keySet())); if (keyWithClobValue.isEmpty()) { return ImmutableMap.copyOf(builder); Sets.difference(ImmutableSet.copyOf(keyWithClobValue), builder.keySet()).forEach(key -> builder.put(key, Optional.empty()));
protected void removeMissingServerConnectionPools(List<Server> oldList, List<Server> newList) { Set<Server> oldSet = new HashSet<>(oldList); Set<Server> newSet = new HashSet<>(newList); Set<Server> removedSet = Sets.difference(oldSet, newSet); if (!removedSet.isEmpty()) { LOG.debug("Removing connection pools for missing servers. vip = " + this.vip + ". " + removedSet.size() + " servers gone."); for (Server s : removedSet) { IConnectionPool pool = perServerPools.remove(s); if (pool != null) { pool.shutdown(); } } } }
for (final PostAggregator postAgg : postAggs) { final Set<String> dependencies = postAgg.getDependentFields(); final Set<String> missing = Sets.difference(dependencies, combinedOutputNames); missing.isEmpty(), "Missing fields [%s] for postAggregator [%s]", missing, postAgg.getName() );
private void loadProjects(Collector collector, DbSession dbSession, SearchResponseData result) { Collection<ComponentDto> loadedComponents = result.getComponents(); for (ComponentDto component : loadedComponents) { collector.addProjectUuid(component.projectUuid()); } Set<String> loadedProjectUuids = loadedComponents.stream().filter(cpt -> cpt.uuid().equals(cpt.projectUuid())).map(ComponentDto::uuid).collect(MoreCollectors.toSet()); Set<String> projectUuidsToLoad = copyOf(difference(collector.getProjectUuids(), loadedProjectUuids)); if (!projectUuidsToLoad.isEmpty()) { List<ComponentDto> projects = dbClient.componentDao().selectByUuids(dbSession, collector.getProjectUuids()); result.addComponents(projects); } }
Sets.difference(new TreeSet<>(Arrays.asList(modifiers)), originalModifiers.getFlags()); SuggestedFix.Builder fix = SuggestedFix.builder(); List<Modifier> modifiersToWrite = new ArrayList<>(); if (!originalModifiers.getFlags().isEmpty()) {
private void loadComponents(SearchResponseData preloadedResponseData, Collector collector, DbSession dbSession, SearchResponseData result) { Collection<ComponentDto> preloadedComponents = preloadedResponseData.getComponents(); Set<String> preloadedComponentUuids = preloadedComponents.stream().map(ComponentDto::uuid).collect(MoreCollectors.toSet(preloadedComponents.size())); Set<String> componentUuidsToLoad = copyOf(difference(collector.getComponentUuids(), preloadedComponentUuids)); result.addComponents(preloadedComponents); if (!componentUuidsToLoad.isEmpty()) { result.addComponents(dbClient.componentDao().selectByUuids(dbSession, componentUuidsToLoad)); } // always load components and projects, because some issue fields still relate to component ids/keys. // They should be dropped but are kept for backward-compatibility (see SearchResponseFormat) result.addComponents(dbClient.componentDao().selectSubProjectsByComponentUuids(dbSession, collector.getComponentUuids())); loadProjects(collector, dbSession, result); }
(!segmentsNeedingRefresh.isEmpty() || !dataSourcesNeedingRebuild.isEmpty()) && (refreshImmediately || nextRefresh < System.currentTimeMillis())) { segmentsNeedingRefresh.addAll(Sets.difference(segmentsToRefresh, refreshed));
private void insertSegments(final Set<DataSegment> segments) throws IOException { final Set<DataSegment> segmentsInserted = indexerMetadataStorageCoordinator.announceHistoricalSegments(segments); for (DataSegment dataSegment : segmentsInserted) { log.info("Sucessfully inserted Segment [%s] into metadata storage", dataSegment.getId()); } final Set<DataSegment> segmentsAlreadyExist = Sets.difference(segments, segmentsInserted); if (!segmentsAlreadyExist.isEmpty()) { for (DataSegment dataSegment : segmentsAlreadyExist) { log.info("Segment [%s] already exists in metadata storage, updating the payload", dataSegment.getId()); } indexerMetadataStorageCoordinator.updateSegmentMetadata(segmentsAlreadyExist); } } }