Skip to content

Commit

Permalink
Refactor main worker target.
Browse files Browse the repository at this point in the history
Partly to deal with dependency cycles, partly to try the process.

PiperOrigin-RevId: 495017606
Change-Id: If2b3559138b797f2bd21404a9ef09dd457e0bbc7
  • Loading branch information
larsrc-google authored and copybara-github committed Dec 13, 2022
1 parent 2f39c04 commit 2f82235
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 52 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/google/devtools/build/lib/actions/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ java_library(
"//src/main/java/com/google/devtools/build/lib/profiler",
"//src/main/java/com/google/devtools/build/lib/util",
"//src/main/java/com/google/devtools/build/lib/worker",
"//src/main/java/com/google/devtools/build/lib/worker:worker_factory",
"//src/main/java/com/google/devtools/build/lib/worker:worker_key",
"//third_party:guava",
"//third_party:jsr305",
Expand Down
175 changes: 124 additions & 51 deletions src/main/java/com/google/devtools/build/lib/worker/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,53 +8,6 @@ filegroup(
visibility = ["//src:__subpackages__"],
)

# Do not depend on this target when making a worker. To use WorkRequestHandler, depend on :work_request_handlers.
java_library(
name = "worker",
srcs = glob(
["*.java"],
exclude = [
"WorkerFilesHash.java",
"WorkerSpawnRunner.java",
"WorkerModule.java",
"WorkerParser.java",
"WorkerSpawnStrategy.java",
"WorkerKey.java",
"WorkerMetricsCollector.java",
"WorkerMetric.java",
"WorkerMetricsEvent.java",
"WorkerOptions.java",
"WorkerLifecycleManager.java",
"JsonWorkerMessageProtocol.java",
"JsonWorkerProtocol.java",
"ProtoWorkerMessageProtocol.java",
"ProtoWorkerProtocol.java",
"WorkerProtocolImpl.java",
],
),
deps = [
":worker_key",
":worker_protocol",
"//src/main/java/com/google/devtools/build/lib/actions",
"//src/main/java/com/google/devtools/build/lib/events",
"//src/main/java/com/google/devtools/build/lib/sandbox:linux_sandbox_command_line_builder",
"//src/main/java/com/google/devtools/build/lib/sandbox:sandbox_helpers",
"//src/main/java/com/google/devtools/build/lib/shell",
"//src/main/java/com/google/devtools/build/lib/vfs",
"//src/main/java/com/google/devtools/build/lib/vfs:pathfragment",
"//src/main/protobuf:failure_details_java_proto",
"//src/main/protobuf:worker_protocol_java_proto",
"//third_party:apache_commons_pool2",
"//third_party:auto_value",
"//third_party:flogger",
"//third_party:gson",
"//third_party:guava",
"//third_party:jsr305",
"//third_party/protobuf:protobuf_java",
"//third_party/protobuf:protobuf_java_util",
],
)

java_library(
name = "worker_protocol",
srcs = [
Expand All @@ -63,11 +16,8 @@ java_library(
"WorkerProtocolImpl.java",
],
deps = [
"//src/main/java/com/google/devtools/common/options",
"//src/main/protobuf:worker_protocol_java_proto",
"//third_party:gson",
"//third_party:guava",
"//third_party/protobuf:protobuf_java",
"//third_party/protobuf:protobuf_java_util",
],
)
Expand All @@ -94,7 +44,9 @@ java_library(
"WorkerSpawnRunner.java",
],
deps = [
":error_message",
":worker",
":worker_factory",
":worker_files_hash",
":worker_key",
":worker_metric",
Expand Down Expand Up @@ -133,7 +85,9 @@ java_library(
"WorkerSpawnStrategy.java",
],
deps = [
":worker",
":multiplex_worker",
":singleplex_worker",
":worker_factory",
":worker_metric",
":worker_options",
":worker_spawn_runner",
Expand Down Expand Up @@ -164,6 +118,7 @@ java_library(
],
deps = [
"//src/main/protobuf:worker_protocol_java_proto",
"//third_party:error_prone_annotations",
"//third_party:gson",
"//third_party:guava",
"//third_party/protobuf:protobuf_java",
Expand Down Expand Up @@ -212,3 +167,121 @@ java_library(
"//third_party:guava",
],
)

java_library(
name = "worker_factory",
srcs = [
"SimpleWorkerPool.java",
"WorkerFactory.java",
"WorkerPool.java",
],
deps = [
":error_message",
":multiplex_worker",
":singleplex_worker",
":worker",
":worker_key",
"//src/main/java/com/google/devtools/build/lib/events",
"//src/main/java/com/google/devtools/build/lib/vfs",
"//src/main/java/com/google/devtools/build/lib/vfs:pathfragment",
"//third_party:apache_commons_pool2",
"//third_party:flogger",
"//third_party:guava",
"//third_party:jsr305",
],
)

java_library(
name = "worker",
srcs = ["Worker.java"],
deps = [
":worker_key",
"//src/main/java/com/google/devtools/build/lib/events",
"//src/main/java/com/google/devtools/build/lib/sandbox:sandbox_helpers",
"//src/main/java/com/google/devtools/build/lib/vfs",
"//src/main/java/com/google/devtools/build/lib/vfs:pathfragment",
"//src/main/protobuf:worker_protocol_java_proto",
"//third_party:guava",
],
)

java_library(
name = "singleplex_worker",
srcs = [
"SandboxedWorker.java",
"SingleplexWorker.java",
],
deps = [
":recording_input_stream",
":worker",
":worker_exec_root",
":worker_key",
":worker_protocol",
"//src/main/java/com/google/devtools/build/lib/sandbox:linux_sandbox_command_line_builder",
"//src/main/java/com/google/devtools/build/lib/sandbox:sandbox_helpers",
"//src/main/java/com/google/devtools/build/lib/shell",
"//src/main/java/com/google/devtools/build/lib/vfs",
"//src/main/java/com/google/devtools/build/lib/vfs:pathfragment",
"//src/main/protobuf:worker_protocol_java_proto",
"//third_party:auto_value",
"//third_party:flogger",
"//third_party:guava",
"//third_party:jsr305",
],
)

java_library(
name = "multiplex_worker",
srcs = [
"SandboxedWorkerProxy.java",
"WorkerMultiplexer.java",
"WorkerMultiplexerManager.java",
"WorkerProxy.java",
],
deps = [
":recording_input_stream",
":worker",
":worker_exec_root",
":worker_key",
":worker_protocol",
"//src/main/java/com/google/devtools/build/lib/actions",
"//src/main/java/com/google/devtools/build/lib/events",
"//src/main/java/com/google/devtools/build/lib/sandbox:sandbox_helpers",
"//src/main/java/com/google/devtools/build/lib/shell",
"//src/main/java/com/google/devtools/build/lib/vfs",
"//src/main/java/com/google/devtools/build/lib/vfs:pathfragment",
"//src/main/protobuf:failure_details_java_proto",
"//src/main/protobuf:worker_protocol_java_proto",
"//third_party:flogger",
"//third_party:guava",
"//third_party:jsr305",
],
)

java_library(
name = "worker_exec_root",
srcs = ["WorkerExecRoot.java"],
deps = [
"//src/main/java/com/google/devtools/build/lib/sandbox:sandbox_helpers",
"//src/main/java/com/google/devtools/build/lib/vfs",
"//src/main/java/com/google/devtools/build/lib/vfs:pathfragment",
"//third_party:guava",
],
)

java_library(
name = "error_message",
srcs = ["ErrorMessage.java"],
deps = [
"//src/main/java/com/google/devtools/build/lib/vfs",
"//third_party:auto_value",
"//third_party:flogger",
"//third_party:guava",
],
)

java_library(
name = "recording_input_stream",
srcs = ["RecordingInputStream.java"],
deps = ["//third_party:guava"],
)
1 change: 1 addition & 0 deletions src/test/java/com/google/devtools/build/lib/actions/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ java_library(
"//src/main/java/com/google/devtools/build/lib/vfs:pathfragment",
"//src/main/java/com/google/devtools/build/lib/vfs/inmemoryfs",
"//src/main/java/com/google/devtools/build/lib/worker",
"//src/main/java/com/google/devtools/build/lib/worker:worker_factory",
"//src/main/java/com/google/devtools/build/lib/worker:worker_key",
"//src/main/java/com/google/devtools/build/skyframe:skyframe-objects",
"//src/main/java/com/google/devtools/common/options",
Expand Down
8 changes: 7 additions & 1 deletion src/test/java/com/google/devtools/build/lib/worker/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ java_library(
"//src/main/java/com/google/devtools/build/lib/shell",
"//src/main/java/com/google/devtools/build/lib/vfs",
"//src/main/java/com/google/devtools/build/lib/vfs:pathfragment",
"//src/main/java/com/google/devtools/build/lib/worker",
"//src/main/java/com/google/devtools/build/lib/worker:singleplex_worker",
"//src/main/java/com/google/devtools/build/lib/worker:worker_key",
"//src/main/java/com/google/devtools/build/lib/worker:worker_options",
"//src/main/java/com/google/devtools/build/lib/worker:worker_spawn_runner",
Expand Down Expand Up @@ -103,6 +103,12 @@ java_library(
"//src/main/java/com/google/devtools/build/lib/vfs:pathfragment",
"//src/main/java/com/google/devtools/build/lib/vfs/inmemoryfs",
"//src/main/java/com/google/devtools/build/lib/worker",
"//src/main/java/com/google/devtools/build/lib/worker:error_message",
"//src/main/java/com/google/devtools/build/lib/worker:multiplex_worker",
"//src/main/java/com/google/devtools/build/lib/worker:recording_input_stream",
"//src/main/java/com/google/devtools/build/lib/worker:singleplex_worker",
"//src/main/java/com/google/devtools/build/lib/worker:worker_exec_root",
"//src/main/java/com/google/devtools/build/lib/worker:worker_factory",
"//src/main/java/com/google/devtools/build/lib/worker:worker_files_hash",
"//src/main/java/com/google/devtools/build/lib/worker:worker_key",
"//src/main/java/com/google/devtools/build/lib/worker:worker_metric",
Expand Down

0 comments on commit 2f82235

Please sign in to comment.