Skip to content

Commit

Permalink
Fix bazel tests again
Browse files Browse the repository at this point in the history
  • Loading branch information
chenj-hub committed Aug 12, 2024
1 parent 4bd30b2 commit eef5cb9
Showing 1 changed file with 4 additions and 31 deletions.
35 changes: 4 additions & 31 deletions src/main/java/build/buildfarm/instance/shard/ServerInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public class ServerInstance extends NodeInstance {
private Cache<RequestMetadata, Boolean> recentCacheServedExecutions;

private final Random rand = new Random();
private final Writes writes;
private final Writes writes = new Writes(this::writeInstanceSupplier);
private final int maxCpu;
private final int maxRequeueAttempts;

Expand Down Expand Up @@ -382,7 +382,6 @@ public ServerInstance(
this.actionCacheFetchService = actionCacheFetchService;
backplane.setOnUnsubscribe(this::stop);

this.writes = new Writes(writeInstanceCacheLoader());
initializeCaches();

remoteInputStreamFactory =
Expand Down Expand Up @@ -1248,35 +1247,9 @@ public void onSuccess(List<String> workersList) {
protected abstract void onQueue(Deque<String> workers);
}

private CacheLoader<BlobWriteKey, Instance> writeInstanceCacheLoader() {
return new CacheLoader<BlobWriteKey, Instance>() {
@SuppressWarnings("NullableProblems")
@Override
public Instance load(BlobWriteKey key) {
String instance = null;
// Per the REAPI the identifier should end up as a unique UUID per a
// client level - adding bytes to further mitigate collisions and not
// store the entire BlobWriteKey.
String blobKey = key.getIdentifier() + "." + key.getDigest().getSizeBytes();
try {
instance = backplane.getWriteInstance(blobKey);
if (instance != null) {
return workerStub(instance);
}
} catch (IOException e) {
log.log(Level.WARNING, "error getting write instance for " + instance, e);
}

instance = getRandomWorker();
try {
backplane.setWriteInstance(blobKey, instance);
log.log(Level.INFO, "set write-instance: " + blobKey + " -> " + instance); // TODO: [jmarino]: remove
} catch (IOException e) {
log.log(Level.WARNING, "error getting write instance for " + instance, e);
}
return workerStub(instance);
}
};
private Instance writeInstanceSupplier() {
String worker = getRandomWorker();
return workerStub(worker);
}

String getRandomWorker() {
Expand Down

0 comments on commit eef5cb9

Please sign in to comment.