Skip to content

Commit

Permalink
done 🎉
Browse files Browse the repository at this point in the history
  • Loading branch information
szabolcsgelencser authored and bvatai-br committed Nov 26, 2024
1 parent c0991bc commit 092e38f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.google.devtools.build.lib.vfs.PathFragment;
import java.util.SortedMap;
import javax.annotation.Nullable;
import java.io.FileWriter;

/**
* A value class representing an action which can be executed remotely.
Expand Down Expand Up @@ -73,6 +74,35 @@ public class RemoteAction {
this.actionKey = actionKey;
}

private void writeDirectoryToFile(FileWriter writer, String root, MerkleTree t) throws IOException {
writer.write("[Root proto of " + root + "]\n");
writer.write(t.rootProto.toString());
for (String dirName : t.directories.keySet()) {
MerkleTree dir = t.directories.get(dirName);
writeDirectoryToFile(writer, root + "/" + dirName, dir);
}
}

public void writeToFile() {
String jsonPath = "/tmp/bazeldebug/" + actionKey.getDigest().getHash() + ".json";
try (FileWriter writer = new FileWriter(jsonPath)) {
writer.write("[Action]\n");
writer.write(action.toString());
writer.write("\n\n");

writer.write("[Command]\n");
writer.write(command.toString());
writer.write("\n\n");

writer.write("[InputRoot]\n");
writeDirectoryToFile(writer, ".", merkleTree);

System.out.println(jsonPath + " written.");
} catch (IOException e) {
e.printStackTrace();
}
}

public RemoteActionExecutionContext getRemoteActionExecutionContext() {
return remoteActionExecutionContext;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@
import io.reactivex.rxjava3.schedulers.Schedulers;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.FileWriter;
import java.io.File;
import java.time.Instant;
import java.util.ArrayList;
Expand Down Expand Up @@ -671,36 +670,7 @@ public RemoteAction buildRemoteAction(Spawn spawn, SpawnExecutionContext context
Spawns.mayBeCachedRemotely(spawn),
buildSalt(spawn, spawnScrubber));

System.out.println("[DEBUG] RemoteExecutionService.buildRemoteAction");
ActionKey actionKey = digestUtil.computeActionKey(action);

String jsonPath = "/tmp/bazeldebug/" + actionKey.getDigest().getHash() + ".json";
File file = new File(jsonPath);
try (FileWriter writer = new FileWriter(file)) {
writer.write("[Action]\n");
writer.write(action.toString());
writer.write("\n\n");

writer.write("[Command]\n");
writer.write(command.toString());
writer.write("\n\n");

writer.write("[Platform]\n");
writer.write(platform.toString());
writer.write("\n\n");

writer.write("[InputRoot]\n");
writer.write(merkleTree.rootDigest.toString());
writer.write("[Root proto]\n");
writer.write(merkleTree.rootProto.toString());
writer.write("[Files]\n");
writer.write(merkleTree.files.toString());

System.out.println(jsonPath + " written.");
} catch (IOException e) {
e.printStackTrace();
}

RequestMetadata metadata =
TracingMetadataUtils.buildMetadata(
buildRequestId, commandId, actionKey.getDigest().getHash(), spawn.getResourceOwner());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ public void store(SpawnResult result) throws ExecException, InterruptedException
return;
}

action.writeToFile();

if (options.experimentalGuardAgainstConcurrentChanges) {
try (SilentCloseable c = prof.profile("checkForConcurrentModifications")) {
checkForConcurrentModifications();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private interface MerkleTreeDirectoryVisitor {
public final Digest rootDigest;
public final SortedSet<DirectoryTree.FileNode> files;
private final SortedSet<DirectoryTree.SymlinkNode> symlinks;
private final SortedMap<String, MerkleTree> directories;
public final SortedMap<String, MerkleTree> directories;
private final long inputFiles;
private final long inputBytes;

Expand Down

0 comments on commit 092e38f

Please sign in to comment.