Skip to content

Commit eef5cb9

Browse files
committed
Fix bazel tests again
1 parent 4bd30b2 commit eef5cb9

File tree

1 file changed

+4
-31
lines changed

1 file changed

+4
-31
lines changed

src/main/java/build/buildfarm/instance/shard/ServerInstance.java

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ public class ServerInstance extends NodeInstance {
247247
private Cache<RequestMetadata, Boolean> recentCacheServedExecutions;
248248

249249
private final Random rand = new Random();
250-
private final Writes writes;
250+
private final Writes writes = new Writes(this::writeInstanceSupplier);
251251
private final int maxCpu;
252252
private final int maxRequeueAttempts;
253253

@@ -382,7 +382,6 @@ public ServerInstance(
382382
this.actionCacheFetchService = actionCacheFetchService;
383383
backplane.setOnUnsubscribe(this::stop);
384384

385-
this.writes = new Writes(writeInstanceCacheLoader());
386385
initializeCaches();
387386

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

1251-
private CacheLoader<BlobWriteKey, Instance> writeInstanceCacheLoader() {
1252-
return new CacheLoader<BlobWriteKey, Instance>() {
1253-
@SuppressWarnings("NullableProblems")
1254-
@Override
1255-
public Instance load(BlobWriteKey key) {
1256-
String instance = null;
1257-
// Per the REAPI the identifier should end up as a unique UUID per a
1258-
// client level - adding bytes to further mitigate collisions and not
1259-
// store the entire BlobWriteKey.
1260-
String blobKey = key.getIdentifier() + "." + key.getDigest().getSizeBytes();
1261-
try {
1262-
instance = backplane.getWriteInstance(blobKey);
1263-
if (instance != null) {
1264-
return workerStub(instance);
1265-
}
1266-
} catch (IOException e) {
1267-
log.log(Level.WARNING, "error getting write instance for " + instance, e);
1268-
}
1269-
1270-
instance = getRandomWorker();
1271-
try {
1272-
backplane.setWriteInstance(blobKey, instance);
1273-
log.log(Level.INFO, "set write-instance: " + blobKey + " -> " + instance); // TODO: [jmarino]: remove
1274-
} catch (IOException e) {
1275-
log.log(Level.WARNING, "error getting write instance for " + instance, e);
1276-
}
1277-
return workerStub(instance);
1278-
}
1279-
};
1250+
private Instance writeInstanceSupplier() {
1251+
String worker = getRandomWorker();
1252+
return workerStub(worker);
12801253
}
12811254

12821255
String getRandomWorker() {

0 commit comments

Comments
 (0)