Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Excavator: Upgrades Baseline to the latest version (#7432)
Browse files Browse the repository at this point in the history
  • Loading branch information
svc-excavator-bot authored Nov 11, 2024
1 parent 54d0055 commit ce9fcab
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ private ImmutableSet<CassandraServer> cleanupAbsentServer(ImmutableSet<Cassandra
absentServersSnapshot.forEach(this::incrementAbsenceCountIfPresent);
return absentServersSnapshot.stream()
.map(this::removeIfAbsenceThresholdReached)
.flatMap(Optional::stream)
.filter(Optional::isPresent)
.map(Optional::get)
.collect(ImmutableSet.toImmutableSet());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ private Set<CassandraServer> getRecommendedHostsFromAThousandTrials(
CassandraService cassandra, Set<CassandraServer> hosts) {
return IntStream.range(0, 1_000)
.mapToObj(attempt -> cassandra.getRandomGoodHostForPredicate(address -> true, hosts))
.flatMap(Optional::stream)
.filter(Optional::isPresent)
.map(Optional::get)
.map(CassandraClientPoolingContainer::getCassandraServer)
.collect(Collectors.toSet());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ private OptionalResolver() {
public static <T> T resolve(Optional<T> optional1, Optional<T> optional2) {
Set<T> values = Stream.of(optional1, optional2)
.filter(Objects::nonNull)
.flatMap(Optional::stream)
.filter(Optional::isPresent)
.map(Optional::get)
.collect(Collectors.toSet());

if (values.size() == 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ private void applyLockedDescriptors(Set<LockDescriptor> lockDescriptors) {
private Stream<CellReference> getCandidateCells(Set<LockDescriptor> lockDescriptors) {
return lockDescriptors.stream()
.map(AtlasLockDescriptorUtils::tryParseTableRef)
.flatMap(Optional::stream)
.filter(Optional::isPresent)
.map(Optional::get)
// Explicitly exclude descriptors corresponding to watched rows from non-watched tables
.filter(this::isTableWatched)
.flatMap(this::extractCandidateCells);
Expand Down Expand Up @@ -192,7 +193,8 @@ public Void visit(UnlockEvent unlockEvent) {
public Void visit(LockWatchCreatedEvent lockWatchCreatedEvent) {
lockWatchCreatedEvent.references().stream()
.map(reference -> reference.accept(LockWatchReferenceTableExtractor.INSTANCE))
.flatMap(Optional::stream)
.filter(Optional::isPresent)
.map(Optional::get)
.forEach(tableReference -> watchedTables.with(tables -> tables.add(tableReference)));

applyLockedDescriptors(lockWatchCreatedEvent.lockDescriptors());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ public static LockWatchManagerInternal create(
.collect(Collectors.toSet());
Set<TableReference> watchedTablesFromSchema = referencesFromSchema.stream()
.map(schema -> schema.accept(LockWatchReferenceTableExtractor.INSTANCE))
.flatMap(Optional::stream)
.filter(Optional::isPresent)
.map(Optional::get)
.collect(Collectors.toSet());
CacheMetrics metrics = CacheMetrics.create(metricsManager);
LockWatchEventCache eventCache = LockWatchEventCacheImpl.create(metrics, config.maxEvents());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,10 @@ public Optional<BytesAndTimestamp> getInternal(Cell cell, Set<Node> quorumNodes)
Set<Optional<BytesAndTimestamp>> reads = quorumNodes.stream()
.map(node -> Optional.ofNullable(node.get(cell)))
.collect(Collectors.toSet());
Optional<BytesAndTimestamp> result =
reads.stream().flatMap(Optional::stream).max(Comparator.comparing(BytesAndTimestamp::timestamp));
Optional<BytesAndTimestamp> result = reads.stream()
.filter(Optional::isPresent)
.map(Optional::get)
.max(Comparator.comparing(BytesAndTimestamp::timestamp));
if (reads.size() > 1) {
runStateMutatingTaskOnNodes(cell, quorumNodes, node -> node.tryUpdateTo(cell, result.get()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ private void validateConsistencyObservedAcrossReaders(Collection<TimestampReader
Set<Long> concreteValuesAgreedByReaders = readers.stream()
.map(TimestampReader::getTimestampReads)
.flatMap(List::stream)
.flatMap(Optional::stream)
.filter(Optional::isPresent)
.map(Optional::get)
.collect(Collectors.toSet());
assertThat(concreteValuesAgreedByReaders)
.as("cannot have readers individually diverge on concretely observed values")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ public Future<List<WitnessedTransaction>> runConcurrentTransactionTask(
.collect(Collectors.toList());
return Futures.transform(
Futures.allAsList(taskFutures),
outcome -> outcome.stream().flatMap(Optional::stream).collect(Collectors.toList()),
outcome -> outcome.stream()
.filter(Optional::isPresent)
.map(Optional::get)
.collect(Collectors.toList()),
MoreExecutors.directExecutor());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ public static Workflow create(
Futures.allAsList(
Stream.of(reads, writes).flatMap(Collection::stream).collect(Collectors.toList())),
maybeWitnessedTransactions -> maybeWitnessedTransactions.stream()
.flatMap(Optional::stream)
.filter(Optional::isPresent)
.map(Optional::get)
.collect(Collectors.toList()),
MoreExecutors.directExecutor());
ReadOnlyTransactionStore readOnlyTransactionStore = new ReadOnlyTransactionStore(store);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public static Workflow create(
Futures.allAsList(
Stream.of(reads, writes).flatMap(Collection::stream).collect(Collectors.toList())),
maybeWitnessedTransactions -> maybeWitnessedTransactions.stream()
.flatMap(Optional::stream)
.filter(Optional::isPresent)
.map(Optional::get)
.collect(Collectors.toList()),
MoreExecutors.directExecutor());
ReadOnlyTransactionStore readOnlyTransactionStore = new ReadOnlyTransactionStore(store);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public static Workflow create(
Futures.allAsList(
Stream.of(reads, writes).flatMap(Collection::stream).collect(Collectors.toList())),
maybeWitnessedTransactions -> maybeWitnessedTransactions.stream()
.flatMap(Optional::stream)
.filter(Optional::isPresent)
.map(Optional::get)
.collect(Collectors.toList()),
MoreExecutors.directExecutor());
ReadOnlyTransactionStore readOnlyTransactionStore = new ReadOnlyTransactionStore(store);
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {
classpath 'com.palantir.jakartapackagealignment:jakarta-package-alignment:0.6.0'
classpath 'com.netflix.nebula:gradle-info-plugin:13.3.0'
classpath 'com.netflix.nebula:nebula-publishing-plugin:21.1.0'
classpath 'com.palantir.baseline:gradle-baseline-java:6.0.0'
classpath 'com.palantir.baseline:gradle-baseline-java:6.1.0'
classpath 'com.palantir.gradle.conjure:gradle-conjure:5.51.0'
classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.29.0'
classpath 'com.palantir.gradle.docker:gradle-docker:0.35.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ public static LockWatchManagerInternal extractInternalLockWatchManager(Transacti
public static List<Optional<LockRequestMetadata>> extractMetadata(List<LockWatchEvent> lockWatchEvents) {
return lockWatchEvents.stream()
.map(event -> event.accept(LockEventVisitor.INSTANCE))
.flatMap(Optional::stream)
.filter(Optional::isPresent)
.map(Optional::get)
.map(LockEvent::metadata)
.collect(Collectors.toList());
}
Expand Down

0 comments on commit ce9fcab

Please sign in to comment.