Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.1.0] Make SpawnLogConvert an abstract class instead of an interface. #21325

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@
package com.google.devtools.build.lib.exec;

import static com.google.common.base.Preconditions.checkState;
import static com.google.devtools.build.lib.exec.SpawnLogContext.computeDigest;
import static com.google.devtools.build.lib.exec.SpawnLogContext.getEnvironmentVariables;
import static com.google.devtools.build.lib.exec.SpawnLogContext.getPlatform;
import static com.google.devtools.build.lib.exec.SpawnLogContext.getSpawnMetricsProto;
import static com.google.devtools.build.lib.exec.SpawnLogContext.isInputDirectory;

import com.github.luben.zstd.ZstdOutputStream;
import com.google.common.collect.ImmutableList;
Expand Down Expand Up @@ -58,7 +53,7 @@
import javax.annotation.concurrent.GuardedBy;

/** A {@link SpawnLogContext} implementation that produces a log in compact format. */
public class CompactSpawnLogContext implements SpawnLogContext {
public class CompactSpawnLogContext extends SpawnLogContext {

private interface ExecLogEntrySupplier {
ExecLogEntry.Builder get() throws IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
// limitations under the License.
package com.google.devtools.build.lib.exec;

import static com.google.devtools.build.lib.exec.SpawnLogContext.computeDigest;
import static com.google.devtools.build.lib.exec.SpawnLogContext.getEnvironmentVariables;
import static com.google.devtools.build.lib.exec.SpawnLogContext.getPlatform;
import static com.google.devtools.build.lib.exec.SpawnLogContext.getSpawnMetricsProto;
import static com.google.devtools.build.lib.exec.SpawnLogContext.isInputDirectory;

import com.google.common.collect.ImmutableSet;
import com.google.common.flogger.GoogleLogger;
import com.google.devtools.build.lib.actions.ActionInput;
Expand Down Expand Up @@ -62,7 +56,7 @@
import javax.annotation.Nullable;

/** A {@link SpawnLogContext} implementation that produces a log in expanded format. */
public class ExpandedSpawnLogContext implements SpawnLogContext {
public class ExpandedSpawnLogContext extends SpawnLogContext {

/** The log encoding. */
public enum Encoding {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import javax.annotation.Nullable;

/** An {@link ActionContext} providing the ability to log executed spawns. */
public interface SpawnLogContext extends ActionContext {
public abstract class SpawnLogContext implements ActionContext {
/**
* Logs an executed spawn.
*
Expand All @@ -64,7 +64,7 @@ public interface SpawnLogContext extends ActionContext {
* @param timeout the timeout the spawn was run under
* @param result the spawn result
*/
void logSpawn(
public abstract void logSpawn(
Spawn spawn,
InputMetadataProvider inputMetadataProvider,
SortedMap<PathFragment, ActionInput> inputMap,
Expand All @@ -74,10 +74,10 @@ void logSpawn(
throws IOException, ExecException;

/** Finishes writing the log and performs any required post-processing. */
void close() throws IOException;
public abstract void close() throws IOException;

/** Computes the environment variables. */
static ImmutableList<EnvironmentVariable> getEnvironmentVariables(Spawn spawn) {
protected ImmutableList<EnvironmentVariable> getEnvironmentVariables(Spawn spawn) {
ImmutableMap<String, String> environment = spawn.getEnvironment();
ImmutableList.Builder<EnvironmentVariable> builder =
ImmutableList.builderWithExpectedSize(environment.size());
Expand All @@ -93,7 +93,8 @@ static ImmutableList<EnvironmentVariable> getEnvironmentVariables(Spawn spawn) {

/** Computes the execution platform. */
@Nullable
static Platform getPlatform(Spawn spawn, RemoteOptions remoteOptions) throws UserExecException {
protected Platform getPlatform(Spawn spawn, RemoteOptions remoteOptions)
throws UserExecException {
var execPlatform = PlatformUtils.getPlatformProto(spawn, remoteOptions);
if (execPlatform == null) {
return null;
Expand All @@ -110,7 +111,7 @@ static Platform getPlatform(Spawn spawn, RemoteOptions remoteOptions) throws Use
*
* <p>Do not call for action outputs.
*/
static boolean isInputDirectory(ActionInput input, InputMetadataProvider inputMetadataProvider)
protected boolean isInputDirectory(ActionInput input, InputMetadataProvider inputMetadataProvider)
throws IOException {
if (input.isDirectory()) {
return true;
Expand All @@ -134,7 +135,7 @@ static boolean isInputDirectory(ActionInput input, InputMetadataProvider inputMe
* <p>Will try to obtain the digest from cached metadata first, falling back to digesting the
* contents manually.
*/
static Digest computeDigest(
protected Digest computeDigest(
@Nullable ActionInput input,
Path path,
InputMetadataProvider inputMetadataProvider,
Expand Down Expand Up @@ -183,7 +184,7 @@ static Digest computeDigest(
.build();
}

static Protos.SpawnMetrics getSpawnMetricsProto(SpawnResult result) {
protected static Protos.SpawnMetrics getSpawnMetricsProto(SpawnResult result) {
SpawnMetrics metrics = result.getMetrics();
Protos.SpawnMetrics.Builder builder = Protos.SpawnMetrics.newBuilder();
if (metrics.totalTimeInMs() != 0L) {
Expand Down
Loading