Skip to content

Commit 64b71b2

Browse files
committed
Remediate some issues to successfully pass bazel tests
1 parent 26cb1df commit 64b71b2

File tree

6 files changed

+12
-43
lines changed

6 files changed

+12
-43
lines changed

src/main/java/build/buildfarm/cas/cfc/CASFileCache.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3209,6 +3209,7 @@ void commit() throws IOException {
32093209
Entry existingEntry = null;
32103210
boolean inserted = false;
32113211
try {
3212+
// acquire the key lock
32123213
log.log(Level.FINEST, "comitting " + key + " from " + writePath);
32133214
Path cachePath = CASFileCache.this.getPath(key);
32143215
CASFileCache.this.renamePath(writePath, cachePath);

src/main/java/build/buildfarm/common/redis/RedisClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public JedisMisconfigurationException(final String message, final Throwable caus
8383
// We store the factory in case we want to re-create the jedis client.
8484
private Supplier<UnifiedJedis> unifiedJedisFactory;
8585

86-
private final UnifiedJedis jedis;
86+
private UnifiedJedis jedis;
8787

8888
private boolean closed = false;
8989

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -538,18 +538,12 @@ public void start(String clientPublicName) throws IOException {
538538
// Construct a single redis client to be used throughout the entire backplane.
539539
// We wish to avoid various synchronous and error handling issues that could occur when using
540540
// multiple clients.
541-
client =
542-
new RedisClient(
543-
jedisClusterFactory,
544-
configs.getBackplane().getReconnectClientAttempts(),
545-
configs.getBackplane().getReconnectClientWaitDurationMs());
546-
// Create containers that make up the backplane
547541
start(new RedisClient(jedisClusterFactory.get()), clientPublicName);
548-
}
542+
}
549543

550544
private void start(RedisClient client, String clientPublicName) throws IOException {
551-
// Create containers that make up the backplane
552-
start(client, DistributedStateCreator.create(client), clientPublicName);
545+
// Create containers that make up the backplane
546+
start(client, DistributedStateCreator.create(client), clientPublicName);
553547
}
554548

555549
@VisibleForTesting

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() {

src/main/java/build/buildfarm/worker/shard/CFCExecFileSystem.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import build.buildfarm.cas.ContentAddressableStorage;
4141
import build.buildfarm.cas.cfc.CASFileCache;
4242
import build.buildfarm.common.BuildfarmExecutors;
43+
import build.buildfarm.common.DigestUtil;
4344
import build.buildfarm.common.io.Directories;
4445
import build.buildfarm.common.io.Dirent;
4546
import build.buildfarm.worker.ExecDirException;

src/test/java/build/buildfarm/worker/PipelineTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void stageThreadReturnCompletesJoin() throws InterruptedException {
5858
public void run() {}
5959
},
6060
1);
61-
pipeline.start(null);
61+
pipeline.start();
6262
pipeline.join();
6363
}
6464

@@ -73,7 +73,7 @@ public void run() {
7373
}
7474
},
7575
1);
76-
pipeline.start(null);
76+
pipeline.start();
7777
pipeline.join();
7878
}
7979

0 commit comments

Comments
 (0)