Remove the now-unneeded SpawnStrategyRegistry.Builder/Impl distinction.
PiperOrigin-RevId: 315875478
diff --git a/src/main/java/com/google/devtools/build/lib/exec/SpawnStrategyRegistry.java b/src/main/java/com/google/devtools/build/lib/exec/SpawnStrategyRegistry.java
index 5607ec1..ec49364 100644
--- a/src/main/java/com/google/devtools/build/lib/exec/SpawnStrategyRegistry.java
+++ b/src/main/java/com/google/devtools/build/lib/exec/SpawnStrategyRegistry.java
@@ -222,7 +222,7 @@
/** Returns a new {@link Builder} suitable for creating instances of SpawnStrategyRegistry. */
public static Builder builder() {
- return new BuilderImpl();
+ return new Builder();
}
/**
@@ -239,133 +239,7 @@
* all registered strategies, in registration order (i.e. the earliest strategy registered will be
* first in the list of strategies returned by {@link SpawnStrategyRegistry#getStrategies}).
*/
- // TODO(katre): This exists only to allow incremental migration from SpawnActionContextMaps.
- // Delete ASAP.
- public interface Builder {
-
- /**
- * Adds a filter limiting any spawn whose {@linkplain
- * com.google.devtools.build.lib.actions.ActionExecutionMetadata#getProgressMessage() owner's
- * progress message} matches the regular expression to only use strategies with the given
- * command-line identifiers, in order.
- *
- * <p>If multiple filters match the same spawn (including an identical filter) the order of
- * precedence of calls to this method is determined by {@link
- * #useLegacyDescriptionFilterPrecedence()}.
- */
- SpawnStrategyRegistry.Builder addDescriptionFilter(
- RegexFilter filter, List<String> identifiers);
-
- /**
- * Adds a filter limiting any spawn whose {@linkplain Spawn#getMnemonic() mnemonic}
- * (case-sensitively) matches the given mnemonic to only use strategies with the given
- * command-line identifiers, in order.
- *
- * <p>If the same mnemonic is registered multiple times the last such call will take precedence.
- *
- * <p>Note that if a spawn matches a {@linkplain #addDescriptionFilter registered description
- * filter} that filter will take precedence over any mnemonic-based filters.
- */
- // last one wins
- SpawnStrategyRegistry.Builder addMnemonicFilter(String mnemonic, List<String> identifiers);
-
- default SpawnStrategyRegistry.Builder registerStrategy(
- SpawnStrategy strategy, String... commandlineIdentifiers) {
- return registerStrategy(strategy, ImmutableList.copyOf(commandlineIdentifiers));
- }
-
- /**
- * Registers a strategy implementation with this collector, distinguishing it from other
- * strategies with the given command-line identifiers (of which at least one is required).
- *
- * <p>If multiple strategies are registered with the same command-line identifier the last one
- * so registered will take precedence.
- */
- SpawnStrategyRegistry.Builder registerStrategy(
- SpawnStrategy strategy, List<String> commandlineIdentifiers);
-
- /**
- * Instructs this collector to use the legacy description filter precedence, i.e. to prefer the
- * first regular expression filter that matches a spawn over any later registered filters.
- *
- * <p>The default behavior of this collector is to prefer the last registered description filter
- * over any previously registered matching filters.
- */
- SpawnStrategyRegistry.Builder useLegacyDescriptionFilterPrecedence();
-
- /**
- * Explicitly sets the identifiers of default strategies to use if a spawn matches no filters.
- *
- * <p>Note that if this method is not called on the builder, all registered strategies are
- * considered default strategies, in registration order. See also the {@linkplain Builder class
- * documentation}.
- */
- SpawnStrategyRegistry.Builder setDefaultStrategies(List<String> defaultStrategies);
-
- /**
- * Reset the default strategies (see {@link #setDefaultStrategies}) to the reverse of the order
- * they were registered in.
- */
- SpawnStrategyRegistry.Builder resetDefaultStrategies();
-
- /**
- * Sets the strategy names to use in the remote branch of dynamic execution for a given action
- * mnemonic.
- *
- * <p>During execution, each strategy is {@linkplain SpawnStrategy#canExec(Spawn,
- * ActionContextRegistry) asked} whether it can execute a given Spawn. The first strategy in the
- * list that says so will get the job.
- */
- SpawnStrategyRegistry.Builder addDynamicRemoteStrategiesByMnemonic(
- String mnemonic, List<String> strategies);
-
- /**
- * Sets the strategy names to use in the local branch of dynamic execution for a given action
- * mnemonic.
- *
- * <p>During execution, each strategy is {@linkplain SpawnStrategy#canExec(Spawn,
- * ActionContextRegistry) asked} whether it can execute a given Spawn. The first strategy in the
- * list that says so will get the job.
- */
- SpawnStrategyRegistry.Builder addDynamicLocalStrategiesByMnemonic(
- String mnemonic, List<String> strategies);
-
- /**
- * Sets the commandline identifier of the strategy to be used when falling back from remote to
- * local execution.
- *
- * <p>Note that this is an optional setting, if not provided {@link
- * SpawnStrategyRegistry#getRemoteLocalFallbackStrategy()} will return {@code null}. If the
- * value <b>is</b> provided it must match the commandline identifier of a registered strategy
- * (at {@linkplain #build build} time).
- */
- SpawnStrategyRegistry.Builder setRemoteLocalFallbackStrategyIdentifier(
- String commandlineIdentifier);
-
- /**
- * Finalizes the construction of the registry.
- *
- * @throws AbruptExitException if a strategy command-line identifier was used in a filter or the
- * default strategies but no strategy for that identifier was registered
- */
- SpawnStrategyRegistry build() throws AbruptExitException;
- }
-
- /**
- * Builder collecting the strategies and restrictions thereon for a {@link SpawnStrategyRegistry}.
- *
- * <p>To {@linkplain SpawnStrategyRegistry#getStrategies match a strategy to a spawn} it needs to
- * be both {@linkplain #registerStrategy registered} and its registered command-line identifier
- * has to match {@linkplain #addDescriptionFilter a filter on the spawn's progress message},
- * {@linkplain #addMnemonicFilter a filter on the spawn's mnemonic} or be part of the default
- * strategies (see below).
- *
- * <p><strong>Default strategies</strong> are either {@linkplain #setDefaultStrategies set
- * explicitly} or, if {@link #setDefaultStrategies} is not called on this builder, comprised of
- * all registered strategies, in registration order (i.e. the earliest strategy registered will be
- * first in the list of strategies returned by {@link SpawnStrategyRegistry#getStrategies}).
- */
- private static final class BuilderImpl implements Builder {
+ public static final class Builder {
private ImmutableList<String> explicitDefaultStrategies = ImmutableList.of();
// TODO(schmitt): Using a list and autovalue so as to be able to reverse order while legacy sort
@@ -392,7 +266,6 @@
* precedence of calls to this method is determined by {@link
* #useLegacyDescriptionFilterPrecedence()}.
*/
- @Override
public Builder addDescriptionFilter(RegexFilter filter, List<String> identifiers) {
filterAndIdentifiers.add(
new AutoValue_SpawnStrategyRegistry_FilterAndIdentifiers(
@@ -411,7 +284,6 @@
* filter} that filter will take precedence over any mnemonic-based filters.
*/
// last one wins
- @Override
public Builder addMnemonicFilter(String mnemonic, List<String> identifiers) {
mnemonicToIdentifiers.put(mnemonic, identifiers);
return this;
@@ -424,7 +296,6 @@
* <p>If multiple strategies are registered with the same command-line identifier the last one
* so registered will take precedence.
*/
- @Override
public Builder registerStrategy(SpawnStrategy strategy, List<String> commandlineIdentifiers) {
Preconditions.checkArgument(
commandlineIdentifiers.size() >= 1, "At least one commandLineIdentifier must be given");
@@ -435,6 +306,10 @@
return this;
}
+ public Builder registerStrategy(SpawnStrategy strategy, String... commandlineIdentifiers) {
+ return registerStrategy(strategy, ImmutableList.copyOf(commandlineIdentifiers));
+ }
+
/**
* Instructs this collector to use the legacy description filter precedence, i.e. to prefer the
* first regular expression filter that matches a spawn over any later registered filters.
@@ -442,7 +317,6 @@
* <p>The default behavior of this collector is to prefer the last registered description filter
* over any previously registered matching filters.
*/
- @Override
public Builder useLegacyDescriptionFilterPrecedence() {
legacyFilterIterationOrder = true;
return this;
@@ -455,7 +329,6 @@
* considered default strategies, in registration order. See also the {@linkplain Builder class
* documentation}.
*/
- @Override
public Builder setDefaultStrategies(List<String> defaultStrategies) {
// Ensure there are actual strategies and the contents are not empty.
Preconditions.checkArgument(!defaultStrategies.isEmpty());
@@ -469,7 +342,6 @@
* Reset the default strategies (see {@link #setDefaultStrategies}) to the reverse of the order
* they were registered in.
*/
- @Override
public Builder resetDefaultStrategies() {
this.explicitDefaultStrategies = ImmutableList.of();
return this;
@@ -483,7 +355,6 @@
* ActionContextRegistry) asked} whether it can execute a given Spawn. The first strategy in the
* list that says so will get the job.
*/
- @Override
public Builder addDynamicRemoteStrategiesByMnemonic(String mnemonic, List<String> strategies) {
mnemonicToRemoteIdentifiers.put(mnemonic, strategies);
return this;
@@ -497,7 +368,6 @@
* ActionContextRegistry) asked} whether it can execute a given Spawn. The first strategy in the
* list that says so will get the job.
*/
- @Override
public Builder addDynamicLocalStrategiesByMnemonic(String mnemonic, List<String> strategies) {
mnemonicToLocalIdentifiers.put(mnemonic, strategies);
return this;
@@ -512,7 +382,6 @@
* value <b>is</b> provided it must match the commandline identifier of a registered strategy
* (at {@linkplain #build build} time).
*/
- @Override
public Builder setRemoteLocalFallbackStrategyIdentifier(String commandlineIdentifier) {
this.remoteLocalFallbackStrategyIdentifier = commandlineIdentifier;
return this;
@@ -524,7 +393,6 @@
* @throws AbruptExitException if a strategy command-line identifier was used in a filter or the
* default strategies but no strategy for that identifier was registered
*/
- @Override
public SpawnStrategyRegistry build() throws AbruptExitException {
List<FilterAndIdentifiers> orderedFilterAndIdentifiers = filterAndIdentifiers;