List of usage examples for com.google.common.collect ImmutableSet.Builder addAll
boolean addAll(Collection<? extends E> c);
From source file:google.registry.flows.domain.DomainAllocateFlow.java
@Override public final EppResponse run() throws EppException { extensionManager.register(FeeCreateCommandExtension.class, SecDnsCreateExtension.class, MetadataExtension.class, AllocateCreateExtension.class); extensionManager.validate();//from www . j a va2s. c o m validateClientIsLoggedIn(clientId); verifyIsSuperuser(); DateTime now = ofy().getTransactionTime(); Create command = cloneAndLinkReferences((Create) resourceCommand, now); failfastForCreate(targetId, now); verifyResourceDoesNotExist(DomainResource.class, targetId, now); InternetDomainName domainName = validateDomainName(command.getFullyQualifiedDomainName()); Registry registry = Registry.get(domainName.parent().toString()); Period period = command.getPeriod(); Integer years = period.getValue(); verifyUnitIsYears(period); validateCreateCommandContactsAndNameservers(command, registry.getTldStr()); SecDnsCreateExtension secDnsCreate = validateSecDnsExtension( eppInput.getSingleExtension(SecDnsCreateExtension.class)); boolean isSunrushAddGracePeriod = isNullOrEmpty(command.getNameservers()); AllocateCreateExtension allocateCreate = eppInput.getSingleExtension(AllocateCreateExtension.class); DomainApplication application = loadAndValidateApplication(allocateCreate.getApplicationRoid(), now); String repoId = createDomainRepoId(ObjectifyService.allocateId(), registry.getTldStr()); ImmutableSet.Builder<ImmutableObject> entitiesToSave = new ImmutableSet.Builder<>(); HistoryEntry historyEntry = buildHistory(repoId, period, now); entitiesToSave.add(historyEntry); ImmutableSet<? extends ImmutableObject> billsAndPolls = createBillingEventsAndPollMessages(domainName, application, historyEntry, isSunrushAddGracePeriod, registry, now, years); entitiesToSave.addAll(billsAndPolls); DateTime registrationExpirationTime = leapSafeAddYears(now, years); DomainResource newDomain = new DomainResource.Builder().setCreationClientId(clientId) .setCurrentSponsorClientId(clientId).setRepoId(repoId) .setIdnTableName(validateDomainNameWithIdnTables(domainName)) .setRegistrationExpirationTime(registrationExpirationTime) .setAutorenewBillingEvent(Key.create(getOnly(billsAndPolls, BillingEvent.Recurring.class))) .setAutorenewPollMessage(Key.create(getOnly(billsAndPolls, PollMessage.Autorenew.class))) .setApplicationTime(allocateCreate.getApplicationTime()).setApplication(Key.create(application)) .setSmdId(allocateCreate.getSmdId()).setLaunchNotice(allocateCreate.getNotice()) .setDsData(secDnsCreate == null ? application.getDsData() : secDnsCreate.getDsData()) .addGracePeriod(createGracePeriod(isSunrushAddGracePeriod, getOnly(billsAndPolls, BillingEvent.OneTime.class))) // Names on the collision list will not be delegated. Set server hold. .setStatusValues(ReservationType.NAME_COLLISION == getReservationType(domainName) ? ImmutableSet.of(StatusValue.SERVER_HOLD) : ImmutableSet.<StatusValue>of()) .setRegistrant(command.getRegistrant()).setAuthInfo(command.getAuthInfo()) .setFullyQualifiedDomainName(targetId).setNameservers(command.getNameservers()) .setContacts(command.getContacts()).build(); entitiesToSave.add(newDomain, buildApplicationHistory(application, now), updateApplication(application), ForeignKeyIndex.create(newDomain, newDomain.getDeletionTime()), EppResourceIndex.create(Key.create(newDomain))); // Anchor tenant registrations override LRP. String authInfoToken = authInfo.getPw().getValue(); if (hasLrpToken(domainName, registry, authInfoToken, now)) { entitiesToSave.add(prepareMarkedLrpTokenEntity(authInfoToken, domainName, historyEntry)); } ofy().save().entities(entitiesToSave.build()); enqueueTasks(allocateCreate, newDomain); return responseBuilder.setResData(DomainCreateData.create(targetId, now, registrationExpirationTime)) .setExtensions(createResponseExtensions(now, registry, years)).build(); }
From source file:com.google.inject.assistedinject.FactoryProvider2.java
/** Calculates all dependencies required by the implementation and constructor. */ private Set<Dependency<?>> getDependencies(InjectionPoint ctorPoint, TypeLiteral<?> implementation) { ImmutableSet.Builder<Dependency<?>> builder = ImmutableSet.builder(); builder.addAll(ctorPoint.getDependencies()); if (!implementation.getRawType().isInterface()) { for (InjectionPoint ip : InjectionPoint.forInstanceMethodsAndFields(implementation)) { builder.addAll(ip.getDependencies()); }//from w ww. j av a 2 s . c o m } return builder.build(); }
From source file:com.google.devtools.build.lib.rules.cpp.LibrariesToLinkCollector.java
/** * When linking a shared library fully or mostly static then we need to link in *all* dependent * files, not just what the shared library needs for its own code. This is done by wrapping all * objects/libraries with -Wl,-whole-archive and -Wl,-no-whole-archive. For this case the * globalNeedWholeArchive parameter must be set to true. Otherwise only library objects (.lo) need * to be wrapped with -Wl,-whole-archive and -Wl,-no-whole-archive. * * <p>TODO: Factor out of the bazel binary into build variables for crosstool action_configs. *//*from w w w .j av a 2s .co m*/ public CollectedLibrariesToLink collectLibrariesToLink() { ImmutableSet.Builder<String> librarySearchDirectories = ImmutableSet.builder(); ImmutableSet.Builder<String> runtimeLibrarySearchDirectories = ImmutableSet.builder(); ImmutableSet.Builder<String> rpathRootsForExplicitSoDeps = ImmutableSet.builder(); ImmutableSet.Builder<LinkerInput> expandedLinkerInputsBuilder = ImmutableSet.builder(); // List of command line parameters that need to be placed *outside* of // --whole-archive ... --no-whole-archive. SequenceBuilder librariesToLink = new SequenceBuilder(); String toolchainLibrariesSolibName = toolchainLibrariesSolibDir != null ? toolchainLibrariesSolibDir.getBaseName() : null; if (isNativeDeps && cppConfiguration.shareNativeDeps()) { if (needToolchainLibrariesRpath) { runtimeLibrarySearchDirectories.add("../" + toolchainLibrariesSolibName + "/"); } } else { // For all other links, calculate the relative path from the output file to _solib_[arch] // (the directory where all shared libraries are stored, which resides under the blaze-bin // directory. In other words, given blaze-bin/my/package/binary, rpathRoot would be // "../../_solib_[arch]". if (needToolchainLibrariesRpath) { runtimeLibrarySearchDirectories .add(Strings.repeat("../", outputArtifact.getRootRelativePath().segmentCount() - 1) + toolchainLibrariesSolibName + "/"); } if (isNativeDeps) { // We also retain the $ORIGIN/ path to solibs that are in _solib_<arch>, as opposed to // the package directory) if (needToolchainLibrariesRpath) { runtimeLibrarySearchDirectories.add("../" + toolchainLibrariesSolibName + "/"); } } } if (needToolchainLibrariesRpath) { if (isNativeDeps) { runtimeLibrarySearchDirectories.add("."); } runtimeLibrarySearchDirectories.add(toolchainLibrariesSolibName + "/"); } Pair<Boolean, Boolean> includeSolibsPair = addLinkerInputs(librarySearchDirectories, rpathRootsForExplicitSoDeps, librariesToLink, expandedLinkerInputsBuilder); boolean includeSolibDir = includeSolibsPair.first; boolean includeToolchainLibrariesSolibDir = includeSolibsPair.second; Preconditions.checkState(ltoMap == null || ltoMap.isEmpty(), "Still have LTO objects left: %s", ltoMap); ImmutableSet.Builder<String> allRuntimeLibrarySearchDirectories = ImmutableSet.builder(); // rpath ordering matters for performance; first add the one where most libraries are found. if (includeSolibDir) { allRuntimeLibrarySearchDirectories.add(rpathRoot); } allRuntimeLibrarySearchDirectories.addAll(rpathRootsForExplicitSoDeps.build()); if (includeToolchainLibrariesSolibDir) { allRuntimeLibrarySearchDirectories.addAll(runtimeLibrarySearchDirectories.build()); } return new CollectedLibrariesToLink(librariesToLink, expandedLinkerInputsBuilder.build(), librarySearchDirectories.build(), allRuntimeLibrarySearchDirectories.build()); }
From source file:com.facebook.buck.apple.xcode.WorkspaceAndProjectGenerator.java
private void addTestNodeAndDependencies(TargetNode<?> testBundleBuildTarget, ImmutableSet.Builder<TargetNode<?>> recursiveTestTargetNodesBuilder, ImmutableSet.Builder<TargetNode<?>> orderedTestBundleTargetNodesBuilder) { Iterable<TargetNode<?>> testBundleTargetDependencies = AppleBuildRules .getRecursiveTargetNodeDependenciesOfTypes(projectGraph, AppleBuildRules.RecursiveDependenciesMode.BUILDING, projectGraph.get(testBundleBuildTarget.getBuildTarget()), Optional.<ImmutableSet<BuildRuleType>>absent()); recursiveTestTargetNodesBuilder.addAll(testBundleTargetDependencies); recursiveTestTargetNodesBuilder.add(testBundleBuildTarget); orderedTestBundleTargetNodesBuilder.add(testBundleBuildTarget); }
From source file:org.voltcore.agreement.AgreementSeeker.java
/** * Is the given hsid considered dead by anyone in my survivor set? * @param hsid a site hsid/* w w w. ja va 2 s .c om*/ * @return a subset of my survivor set that considers the given site dead */ public Set<Long> forWhomSiteIsDead(long hsid) { ImmutableSet.Builder<Long> isb = ImmutableSet.builder(); Set<Long> deadBy = m_dead.get(hsid); if (!deadBy.isEmpty() && m_survivors.contains(hsid) && m_strategy == ArbitrationStrategy.MATCHING_CARDINALITY) { isb.addAll(Sets.filter(deadBy, amongSurvivors)); } return isb.build(); }
From source file:com.facebook.buck.io.ProjectFilesystem.java
private static ImmutableSet<PathOrGlobMatcher> extractIgnorePaths(final Path root, Config config, final BuckPaths buckPaths) { ImmutableSet.Builder<PathOrGlobMatcher> builder = ImmutableSet.builder(); builder.add(new PathOrGlobMatcher(root, ".idea")); final String projectKey = "project"; final String ignoreKey = "ignore"; String buckdDirProperty = System.getProperty(BUCK_BUCKD_DIR_KEY, ".buckd"); if (!Strings.isNullOrEmpty(buckdDirProperty)) { builder.add(new PathOrGlobMatcher(root, buckdDirProperty)); }/* w w w . ja v a 2 s.c o m*/ Path cacheDir = getCacheDir(root, config.getValue("cache", "dir"), buckPaths); builder.add(new PathOrGlobMatcher(cacheDir)); builder.addAll(FluentIterable.from(config.getListWithoutComments(projectKey, ignoreKey)) .transform(new Function<String, PathOrGlobMatcher>() { @Nullable @Override public PathOrGlobMatcher apply(String input) { // We don't really want to ignore the output directory when doing things like filesystem // walks, so return null if (buckPaths.getBuckOut().toString().equals(input)) { return null; //root.getFileSystem().getPathMatcher("glob:**"); } if (GLOB_CHARS.matcher(input).find()) { return new PathOrGlobMatcher(root.getFileSystem().getPathMatcher("glob:" + input), input); } return new PathOrGlobMatcher(root, input); } }) // And now remove any null patterns .filter(Objects::nonNull).toList()); return builder.build(); }
From source file:com.facebook.buck.apple.project_generator.WorkspaceAndProjectGenerator.java
public WorkspaceAndProjectGenerator(Cell cell, TargetGraph projectGraph, XcodeWorkspaceConfigDescription.Arg workspaceArguments, BuildTarget workspaceBuildTarget, Set<ProjectGenerator.Option> projectGeneratorOptions, boolean combinedProject, boolean buildWithBuck, ImmutableList<String> buildWithBuckFlags, ImmutableSet<UnflavoredBuildTarget> focusModules, boolean parallelizeBuild, ExecutableFinder executableFinder, ImmutableMap<String, String> environment, FlavorDomain<CxxPlatform> cxxPlatforms, CxxPlatform defaultCxxPlatform, String buildFileName, Function<TargetNode<?, ?>, SourcePathResolver> sourcePathResolverForNode, BuckEventBus buckEventBus, HalideBuckConfig halideBuckConfig, CxxBuckConfig cxxBuckConfig, AppleConfig appleConfig, SwiftBuckConfig swiftBuckConfig) { this.rootCell = cell; this.projectGraph = projectGraph; this.dependenciesCache = new AppleDependenciesCache(projectGraph); this.workspaceArguments = workspaceArguments; this.workspaceBuildTarget = workspaceBuildTarget; this.projectGeneratorOptions = ImmutableSet.copyOf(projectGeneratorOptions); this.combinedProject = combinedProject; this.buildWithBuck = buildWithBuck; this.buildWithBuckFlags = buildWithBuckFlags; this.parallelizeBuild = parallelizeBuild; this.executableFinder = executableFinder; this.environment = environment; this.cxxPlatforms = cxxPlatforms; this.defaultCxxPlatform = defaultCxxPlatform; this.buildFileName = buildFileName; this.sourcePathResolverForNode = sourcePathResolverForNode; this.buckEventBus = buckEventBus; this.swiftBuckConfig = swiftBuckConfig; this.combinedProjectGenerator = Optional.empty(); this.halideBuckConfig = halideBuckConfig; this.cxxBuckConfig = cxxBuckConfig; this.appleConfig = appleConfig; ImmutableSet.Builder<UnflavoredBuildTarget> builder = ImmutableSet.builder(); builder.addAll(focusModules); // Add the main target only if focusModules is actually used. if (!focusModules.isEmpty() && workspaceArguments.srcTarget.isPresent()) { builder.add(workspaceArguments.srcTarget.get().getUnflavoredBuildTarget()); }/* w w w .j av a 2 s . c o m*/ this.focusModules = builder.build(); }
From source file:com.facebook.presto.raptor.RaptorMetadata.java
@Override public void commitDelete(ConnectorSession session, ConnectorTableHandle tableHandle, Collection<Slice> fragments) { RaptorTableHandle table = checkType(tableHandle, RaptorTableHandle.class, "tableHandle"); long transactionId = table.getTransactionId().getAsLong(); long tableId = table.getTableId(); List<ColumnInfo> columns = getColumnHandles(session, tableHandle).values().stream() .map(handle -> checkType(handle, RaptorColumnHandle.class, "columnHandle")) .map(ColumnInfo::fromHandle).collect(toList()); ImmutableSet.Builder<UUID> oldShardUuids = ImmutableSet.builder(); ImmutableList.Builder<ShardInfo> newShards = ImmutableList.builder(); fragments.stream().map(fragment -> shardDeltaCodec.fromJson(fragment.getBytes())).forEach(delta -> { oldShardUuids.addAll(delta.getOldShardUuids()); newShards.addAll(delta.getNewShards()); });/*from w w w . j a v a 2s. c o m*/ shardManager.replaceShardUuids(transactionId, tableId, columns, oldShardUuids.build(), newShards.build()); }
From source file:org.apache.aurora.scheduler.storage.db.DbJobUpdateStore.java
@Timed("job_update_store_prune_history") @Override//from w w w.j a v a 2s.c o m public Set<IJobUpdateKey> pruneHistory(int perJobRetainCount, long historyPruneThresholdMs) { ImmutableSet.Builder<IJobUpdateKey> pruned = ImmutableSet.builder(); Set<Long> jobKeyIdsToPrune = detailsMapper.selectJobKeysForPruning(perJobRetainCount, historyPruneThresholdMs); for (long jobKeyId : jobKeyIdsToPrune) { Set<PruneVictim> pruneVictims = detailsMapper.selectPruneVictims(jobKeyId, perJobRetainCount, historyPruneThresholdMs); detailsMapper.deleteCompletedUpdates( FluentIterable.from(pruneVictims).transform(PruneVictim::getRowId).toSet()); pruned.addAll(FluentIterable.from(pruneVictims).transform(GET_UPDATE_KEY)); } return pruned.build(); }
From source file:co.cask.tigon.internal.app.runtime.flow.FlowletProgramRunner.java
private SchemaCache createSchemaCache(Program program) throws Exception { ImmutableSet.Builder<Schema> schemas = ImmutableSet.builder(); for (FlowletDefinition flowletDef : program.getSpecification().getFlowlets().values()) { schemas.addAll(Iterables.concat(flowletDef.getInputs().values())); schemas.addAll(Iterables.concat(flowletDef.getOutputs().values())); }/* ww w. ja v a 2s .c o m*/ return new SchemaCache(schemas.build(), program.getClassLoader()); }