Skip to content

Commit cb10d4f

Browse files
tjgqcopybara-github
authored andcommitted
Pass the BlazeServices to BlazeModule.globalInit().
Some modules (e.g. BazelFileSystemModule) need to access services before the BlazeRuntime has been constructed. Instead of calling the blazeServicesAvailable() lifecycle method earlier, just merge its responsibilities into globalInit(). PiperOrigin-RevId: 869131080 Change-Id: I7baf11fbe1e0b756d4ffeea0404554b13c207524
1 parent 787c9ca commit cb10d4f

File tree

4 files changed

+10
-16
lines changed

4 files changed

+10
-16
lines changed

src/main/java/com/google/devtools/build/lib/remote/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ java_library(
5959
":store",
6060
"//src/main/java/com/google/devtools/build/lib:build-request-options",
6161
"//src/main/java/com/google/devtools/build/lib:runtime",
62+
"//src/main/java/com/google/devtools/build/lib:runtime/blaze_service",
6263
"//src/main/java/com/google/devtools/build/lib:runtime/command_line_path_factory",
6364
"//src/main/java/com/google/devtools/build/lib/actions",
6465
"//src/main/java/com/google/devtools/build/lib/actions:action_input_helper",

src/main/java/com/google/devtools/build/lib/remote/RemoteModule.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
import com.google.devtools.build.lib.runtime.BlazeModule;
8383
import com.google.devtools.build.lib.runtime.BlazeRuntime;
8484
import com.google.devtools.build.lib.runtime.BlazeServerStartupOptions;
85+
import com.google.devtools.build.lib.runtime.BlazeService;
8586
import com.google.devtools.build.lib.runtime.BlockWaitingModule;
8687
import com.google.devtools.build.lib.runtime.BuildEventArtifactUploaderFactory;
8788
import com.google.devtools.build.lib.runtime.CommandEnvironment;
@@ -191,7 +192,8 @@ public ImmutableList<Class<? extends OptionsBase>> getStartupOptions() {
191192
}
192193

193194
@Override
194-
public void globalInit(OptionsParsingResult startupOptions) {
195+
public void globalInit(
196+
OptionsParsingResult startupOptions, Iterable<BlazeService> blazeServices) {
195197
outputBase = startupOptions.getOptions(BlazeServerStartupOptions.class).outputBase;
196198
useRemoteRepoContentsCache =
197199
startupOptions.getOptions(RemoteStartupOptions.class).useRemoteRepoContentsCache;

src/main/java/com/google/devtools/build/lib/runtime/BlazeModule.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,11 @@ public Iterable<Class<? extends OptionsBase>> getStartupOptions() {
7878
* #blazeStartup}.
7979
*
8080
* @param startupOptions the server's startup options
81+
* @param blazeServices the available services
8182
* @throws AbruptExitException to shut down the server immediately
8283
*/
83-
public void globalInit(OptionsParsingResult startupOptions) throws AbruptExitException {}
84+
public void globalInit(OptionsParsingResult startupOptions, Iterable<BlazeService> blazeServices)
85+
throws AbruptExitException {}
8486

8587
/**
8688
* Returns the file system implementation used by Bazel.
@@ -153,15 +155,8 @@ public SubscriberExceptionHandler getEventBusAndAsyncExceptionHandler() {
153155
}
154156

155157
/**
156-
* Called to provide the list of available Blaze services to the module.
157-
*
158-
* <p>This is called after {@link #getFileSystem} and before {@link #blazeStartup}.
159-
*/
160-
public void blazeServicesAvailable(Iterable<BlazeService> blazeServices) {}
161-
162-
/**
163-
* Called when Bazel starts up after {@link #getStartupOptions}, {@link #globalInit}, {@link
164-
* #getFileSystem}, and {@link #blazeServicesAvailable}.
158+
* Called when Bazel starts up after {@link #getStartupOptions}, {@link #globalInit} and {@link
159+
* #getFileSystem}.
165160
*
166161
* @param startupOptions the server's startup options
167162
* @param versionInfo the Bazel version currently running

src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,7 +1352,7 @@ private static BlazeRuntime newRuntime(
13521352
}
13531353

13541354
for (BlazeModule module : blazeModules) {
1355-
module.globalInit(options);
1355+
module.globalInit(options, blazeServices);
13561356
}
13571357

13581358
String productName = startupOptions.productName.toLowerCase(Locale.US);
@@ -1711,10 +1711,6 @@ public BlazeRuntime build() throws AbruptExitException {
17111711
}
17121712
}
17131713

1714-
var blazeServicesCopy = ImmutableList.copyOf(blazeServices);
1715-
for (BlazeModule module : blazeModules) {
1716-
module.blazeServicesAvailable(blazeServicesCopy);
1717-
}
17181714
for (BlazeModule module : blazeModules) {
17191715
module.blazeStartup(
17201716
startupOptionsProvider,

0 commit comments

Comments
 (0)