Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into load-search-analyze…
Browse files Browse the repository at this point in the history
…rs-on-shard2
  • Loading branch information
mayya-sharipova committed Jul 3, 2023
2 parents 592be0b + dd8ac78 commit 5805967
Show file tree
Hide file tree
Showing 505 changed files with 8,992 additions and 3,416 deletions.
2 changes: 2 additions & 0 deletions .ci/bwcVersions
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ BWC_VERSION:
- "7.17.9"
- "7.17.10"
- "7.17.11"
- "7.17.12"
- "8.0.0"
- "8.0.1"
- "8.1.0"
Expand Down Expand Up @@ -90,5 +91,6 @@ BWC_VERSION:
- "8.8.0"
- "8.8.1"
- "8.8.2"
- "8.8.3"
- "8.9.0"
- "8.10.0"
4 changes: 2 additions & 2 deletions .ci/snapshotBwcVersions
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BWC_VERSION:
- "7.17.11"
- "8.8.2"
- "7.17.12"
- "8.8.3"
- "8.9.0"
- "8.10.0"
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,11 @@
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.inject.Inject;
import java.io.Serializable;

import javax.inject.Inject;

/**
* Checks files for license headers..
*/
Expand Down Expand Up @@ -193,9 +189,8 @@ public void runRat() {
boolean unApprovedLicenses = stats.getNumUnApproved() > 0;
if (unknownLicenses || unApprovedLicenses) {
getLogger().error("The following files contain unapproved license headers:");
unapprovedFiles(repFile).stream().forEachOrdered(unapprovedFile -> getLogger().error(unapprovedFile));
throw new GradleException("Check failed. License header problems were found. Full details: " +
repFile.getAbsolutePath());
unapprovedFiles(repFile).forEach(getLogger()::error);
throw new GradleException("Check failed. License header problems were found. Full details: " + repFile.getAbsolutePath());
}
}

Expand Down
2 changes: 1 addition & 1 deletion build-tools-internal/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ dependencies {
// ensuring brought asm version brought in by spock is up-to-date
testImplementation buildLibs.asm
integTestImplementation buildLibs.asm
integTestImplementation('org.ow2.asm:asm:9.4')
integTestImplementation('org.ow2.asm:asm:9.5')
api("org.yaml:snakeyaml") {
version { strictly(versions.snakeyaml) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import javax.inject.Inject;

Expand Down Expand Up @@ -287,7 +288,7 @@ static Map<String, String> parseOsRelease(final List<String> osReleaseLines) {
*/
private Optional<String> getDockerPath() {
// Check if the Docker binary exists
return List.of(DOCKER_BINARIES).stream().filter(path -> new File(path).exists()).findFirst();
return Stream.of(DOCKER_BINARIES).filter(path -> new File(path).exists()).findFirst();
}

/**
Expand All @@ -298,7 +299,7 @@ private Optional<String> getDockerPath() {
*/
private Optional<String> getDockerComposePath() {
// Check if the Docker binary exists
return List.of(DOCKER_COMPOSE_BINARIES).stream().filter(path -> new File(path).exists()).findFirst();
return Stream.of(DOCKER_COMPOSE_BINARIES).filter(path -> new File(path).exists()).findFirst();
}

private void throwDockerRequiredException(final String message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,24 +114,19 @@ public void checkInvalidPatterns() throws IOException {
} catch (UncheckedIOException e) {
throw new IllegalArgumentException("Failed to read " + f + " as UTF_8", e);
}
List<Integer> invalidLines = IntStream.range(0, lines.size())
.filter(i -> allPatterns.matcher(lines.get(i)).find())
.boxed()
.collect(Collectors.toList());

URI baseUri = getRootDir().orElse(projectLayout.getProjectDirectory().getAsFile()).get().toURI();
String path = baseUri.relativize(f.toURI()).toString();
failures.addAll(
invalidLines.stream()
.map(l -> new AbstractMap.SimpleEntry<>(l + 1, lines.get(l)))
.flatMap(
kv -> patterns.entrySet()
.stream()
.filter(p -> Pattern.compile(p.getValue()).matcher(kv.getValue()).find())
.map(p -> "- " + p.getKey() + " on line " + kv.getKey() + " of " + path)
)
.collect(Collectors.toList())
);
IntStream.range(0, lines.size())
.filter(i -> allPatterns.matcher(lines.get(i)).find())
.mapToObj(l -> new AbstractMap.SimpleEntry<>(l + 1, lines.get(l)))
.flatMap(
kv -> patterns.entrySet()
.stream()
.filter(p -> Pattern.compile(p.getValue()).matcher(kv.getValue()).find())
.map(p -> "- " + p.getKey() + " on line " + kv.getKey() + " of " + path)
)
.forEach(failures::add);
}
if (failures.isEmpty() == false) {
throw new GradleException("Found invalid patterns:\n" + String.join("\n", failures));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ private static ModuleReference esModuleFor(File filePath) {
return ModuleFinder.of(filePath.toPath())
.findAll()
.stream()
.sorted(Comparator.comparing(ModuleReference::descriptor))
.findFirst()
.min(Comparator.comparing(ModuleReference::descriptor))
.orElseThrow(() -> new GradleException("module not found in " + filePath));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import java.util.Set;
import java.util.TreeSet;
import java.util.function.Consumer;
import java.util.stream.Collectors;

import javax.inject.Inject;

Expand Down Expand Up @@ -234,7 +233,7 @@ private void filterSplitPackages(Map<String, Set<String>> splitPackages) {
String lastPackageName = null;
Set<String> currentClasses = null;
boolean filterErrorsFound = false;
for (String fqcn : getParameters().getIgnoreClasses().get().stream().sorted().collect(Collectors.toList())) {
for (String fqcn : getParameters().getIgnoreClasses().get().stream().sorted().toList()) {
int lastDot = fqcn.lastIndexOf('.');
if (lastDot == -1) {
LOGGER.error("Missing package in classname in split package ignores: " + fqcn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import javax.inject.Inject;

Expand Down Expand Up @@ -128,7 +129,7 @@ private void assertNoMissmatchingTest(List<? extends Class<?>> testClassesCandid
var mismatchingBaseClasses = testClassesCandidate.stream()
.filter(testClassDefaultPredicate)
.filter(TestingConventionsCheckWorkAction::seemsLikeATest)
.collect(Collectors.toList());
.toList();
if (mismatchingBaseClasses.isEmpty() == false) {
throw new GradleException(
"Following test classes do not extend any supported base class:\n\t"
Expand All @@ -141,7 +142,7 @@ private void assertMatchesSuffix(List<String> suffixes, List<Class> matchingBase
// ensure base class matching do match suffix
var matchingBaseClassNotMatchingSuffix = matchingBaseClass.stream()
.filter(c -> suffixes.stream().allMatch(s -> c.getName().endsWith(s) == false))
.collect(Collectors.toList());
.toList();
if (matchingBaseClassNotMatchingSuffix.isEmpty() == false) {
throw new GradleException(
"Following test classes do not match naming convention to use suffix "
Expand Down Expand Up @@ -202,8 +203,7 @@ private static boolean matchesTestMethodNamingConvention(Method method) {
}

private static boolean isAnnotated(Method method, Class<?> annotation) {
return List.of(method.getAnnotations())
.stream()
return Stream.of(method.getAnnotations())
.anyMatch(presentAnnotation -> annotation.isAssignableFrom(presentAnnotation.getClass()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,11 @@ private List<ElasticsearchDistribution> configureDistributions(Project project)
List<ElasticsearchDistribution> currentDistros = new ArrayList<>();

for (Architecture architecture : Architecture.values()) {
ALL_INTERNAL.stream()
.forEach(
type -> currentDistros.add(
createDistro(distributions, architecture, type, null, true, VersionProperties.getElasticsearch())
)
);
ALL_INTERNAL.forEach(
type -> currentDistros.add(
createDistro(distributions, architecture, type, null, true, VersionProperties.getElasticsearch())
)
);
}

for (Architecture architecture : Architecture.values()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ public List<ObjectNode> transformRestTests(LinkedList<ObjectNode> tests, List<Re
List<RestTestTransformGlobalSetup> setupTransforms = transformations.stream()
.filter(transform -> transform instanceof RestTestTransformGlobalSetup)
.map(transform -> (RestTestTransformGlobalSetup) transform)
.collect(Collectors.toList());
.toList();

// Collect any global teardown transformations
List<RestTestTransformGlobalTeardown> teardownTransforms = transformations.stream()
.filter(transform -> transform instanceof RestTestTransformGlobalTeardown)
.map(transform -> (RestTestTransformGlobalTeardown) transform)
.collect(Collectors.toList());
.toList();

// Collect any transformations that are identified by an object key.
Map<String, List<RestTestTransformByParentObject>> objectKeyFinders = transformations.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ private Optional<AdoptiumVersionInfo> resolveAvailableVersion(AdoptiumVersionReq
return Optional.of(
Lists.newArrayList(versionsNode.iterator())
.stream()
.map(node -> toVersionInfo(node))
.sorted(Comparator.comparing(AdoptiumVersionInfo::semver).reversed())
.findFirst()
.map(this::toVersionInfo)
.max(Comparator.comparing(AdoptiumVersionInfo::semver))
.get()
);
} catch (FileNotFoundException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void checkVersion(Project project, String tool, Pattern versionRegex, int... min
}

String version = matcher.group(1);
List<Integer> versionParts = Stream.of(version.split("\\.")).map(Integer::parseInt).collect(Collectors.toList());
List<Integer> versionParts = Stream.of(version.split("\\.")).map(Integer::parseInt).toList();
for (int i = 0; i < minVersion.length; ++i) {
int found = versionParts.get(i);
if (found > minVersion[i]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.Arrays;
import java.util.List;
import java.util.function.UnaryOperator;
import java.util.stream.Collectors;

import static org.elasticsearch.gradle.internal.vagrant.VagrantMachine.convertLinuxPath;
import static org.elasticsearch.gradle.internal.vagrant.VagrantMachine.convertWindowsPath;
Expand Down Expand Up @@ -71,7 +70,7 @@ public void runScript() {
script.add("try {");
script.add("cd " + convertWindowsPath(buildLayout.getRootDirectory(), buildLayout.getRootDirectory().toString()));
extension.getVmEnv().forEach((k, v) -> script.add("$Env:" + k + " = \"" + v + "\""));
script.addAll(getWindowsScript().stream().map(s -> " " + s).collect(Collectors.toList()));
script.addAll(getWindowsScript().stream().map(s -> " " + s).toList());
script.addAll(
Arrays.asList(
" exit $LASTEXITCODE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,6 @@ org.elasticsearch.cluster.service.ClusterService#submitUnbatchedStateUpdateTask(
@defaultMessage Reacting to the published cluster state is an obstruction to batching cluster state tasks which leads to performance and stability bugs. Use the variants that accept a Runnable instead.
org.elasticsearch.cluster.ClusterStateTaskExecutor$TaskContext#success(java.util.function.Consumer)
org.elasticsearch.cluster.ClusterStateTaskExecutor$TaskContext#success(java.util.function.Consumer, org.elasticsearch.cluster.ClusterStateAckListener)

@defaultMessage ClusterState#transportVersions are for internal use only. Use ClusterState#getMinTransportVersion or a different version. See TransportVersion javadocs for more info.
org.elasticsearch.cluster.ClusterState#transportVersions()
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.nio.file.Paths;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
Expand Down Expand Up @@ -62,7 +61,7 @@ public static void main(String[] args) throws Exception {

private void reap() {
try (Stream<Path> stream = Files.list(inputDir)) {
final List<Path> inputFiles = stream.filter(p -> p.getFileName().toString().endsWith(".cmd")).collect(Collectors.toList());
final List<Path> inputFiles = stream.filter(p -> p.getFileName().toString().endsWith(".cmd")).toList();

for (Path inputFile : inputFiles) {
System.out.println("Process file: " + inputFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public Object[] toArray() {

@Override
public <T1> T1[] toArray(T1[] a) {
return delegate.stream().peek(this::validate).map(PropertyListEntry::getValue).collect(Collectors.toList()).toArray(a);
return delegate.stream().peek(this::validate).map(PropertyListEntry::getValue).toList().toArray(a);
}

@Override
Expand All @@ -79,7 +79,7 @@ public boolean remove(Object o) {

@Override
public boolean containsAll(Collection<?> c) {
return delegate.stream().map(PropertyListEntry::getValue).collect(Collectors.toList()).containsAll(c);
return delegate.stream().map(PropertyListEntry::getValue).collect(Collectors.toSet()).containsAll(c);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void beforeStart() {
entry -> entry.getValue().toString()
)
);
boolean singleNode = getClusters().stream().flatMap(c -> c.getNodes().stream()).count() == 1;
boolean singleNode = getClusters().stream().mapToLong(c -> c.getNodes().size()).sum() == 1;
final Function<ElasticsearchNode, Path> getDataPath;
if (singleNode) {
getDataPath = n -> dataDir;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ default void useCluster(ElasticsearchCluster cluster) {
}

cluster.getNodes()
.all(node -> node.getDistributions().stream().forEach(distro -> dependsOn(getProject().provider(() -> distro.maybeFreeze()))));
.all(node -> node.getDistributions().forEach(distro -> dependsOn(getProject().provider(() -> distro.maybeFreeze()))));
cluster.getNodes().all(node -> dependsOn((Callable<Collection<Configuration>>) node::getPluginAndModuleConfigurations));
getClusters().add(cluster);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.lang.management.ManagementFactory;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public abstract class AbstractBenchmark<T extends Closeable> {
private static final int SEARCH_BENCHMARK_ITERATIONS = 10_000;
Expand Down Expand Up @@ -92,7 +91,7 @@ private void runSearchBenchmark(String[] args) throws Exception {
String benchmarkTargetHost = args[1];
String indexName = args[2];
String searchBody = args[3];
List<Integer> throughputRates = Arrays.asList(args[4].split(",")).stream().map(Integer::valueOf).collect(Collectors.toList());
List<Integer> throughputRates = Arrays.stream(args[4].split(",")).map(Integer::valueOf).toList();

T client = client(benchmarkTargetHost);

Expand Down
6 changes: 3 additions & 3 deletions client/test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ dependencies {
api "org.hamcrest:hamcrest:${versions.hamcrest}"

// mockito
api 'org.mockito:mockito-core:5.1.1'
api 'org.mockito:mockito-subclass:5.1.1'
api 'net.bytebuddy:byte-buddy:1.12.22'
api 'org.mockito:mockito-core:5.4.0'
api 'org.mockito:mockito-subclass:5.4.0'
api 'net.bytebuddy:byte-buddy:1.14.5'
api 'org.objenesis:objenesis:3.3'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import java.security.MessageDigest;
import java.util.Arrays;
import java.util.Locale;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.zip.GZIPOutputStream;

Expand Down Expand Up @@ -74,15 +73,15 @@ private void copyTgzToTarget(Path source, Path target) throws IOException {
return;
}
try (Stream<Path> files = Files.list(source)) {
for (Path path : files.filter(p -> p.getFileName().toString().endsWith(".tgz")).collect(Collectors.toList())) {
for (Path path : files.filter(p -> p.getFileName().toString().endsWith(".tgz")).toList()) {
Files.copy(path, target.resolve(path.getFileName()), StandardCopyOption.REPLACE_EXISTING);
}
}
}

private void packDatabasesToTgz(Terminal terminal, Path source, Path target) throws IOException {
try (Stream<Path> files = Files.list(source)) {
for (Path path : files.filter(p -> p.getFileName().toString().endsWith(".mmdb")).collect(Collectors.toList())) {
for (Path path : files.filter(p -> p.getFileName().toString().endsWith(".mmdb")).toList()) {
String fileName = path.getFileName().toString();
Path compressedPath = target.resolve(fileName.replaceAll("mmdb$", "") + "tgz");
terminal.println("Found " + fileName + ", will compress it to " + compressedPath.getFileName());
Expand Down Expand Up @@ -111,7 +110,7 @@ private void createOverviewJson(Terminal terminal, Path directory) throws IOExce
XContentGenerator generator = XContentType.JSON.xContent().createGenerator(os)
) {
generator.writeStartArray();
for (Path db : files.filter(p -> p.getFileName().toString().endsWith(".tgz")).collect(Collectors.toList())) {
for (Path db : files.filter(p -> p.getFileName().toString().endsWith(".tgz")).toList()) {
terminal.println("Adding " + db.getFileName() + " to overview.json");
MessageDigest md5 = MessageDigests.md5();
try (InputStream dis = new DigestInputStream(new BufferedInputStream(Files.newInputStream(db)), md5)) {
Expand Down
4 changes: 2 additions & 2 deletions distribution/tools/plugin-cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ dependencies {
compileOnly project(":libs:elasticsearch-cli")
implementation project(":libs:elasticsearch-plugin-api")
implementation project(":libs:elasticsearch-plugin-scanner")
implementation 'org.ow2.asm:asm:9.4'
implementation 'org.ow2.asm:asm-tree:9.4'
implementation 'org.ow2.asm:asm:9.5'
implementation 'org.ow2.asm:asm-tree:9.5'

api "org.bouncycastle:bcpg-fips:1.0.4"
api "org.bouncycastle:bc-fips:1.0.2"
Expand Down
Loading

0 comments on commit 5805967

Please sign in to comment.