Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to add jdk17, remove jdk 8,14, OS 2.0 and upgrade to gradle 7 #156

Merged
merged 12 commits into from
Apr 6, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ jobs:
strategy:
matrix:
java:
- 8
- 11
- 14
- 17
runs-on: [ubuntu-latest]
name: Building RCA package
steps:
Expand Down
6 changes: 3 additions & 3 deletions DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- [Developer Guide](#developer-guide)
- [Forking and Cloning](#forking-and-cloning)
- [Install Prerequisites](#install-prerequisites)
- [JDK 11](#jdk-11)
- [JDK](#jdk)
- [Building](#building)
- [Using IntelliJ IDEA](#using-intellij-idea)
- [Submitting Changes](#submitting-changes)
Expand All @@ -16,9 +16,9 @@ Fork this repository on GitHub, and clone locally with `git clone`.

### Install Prerequisites

#### JDK 11
#### JDK

OpenSearch components build using Java 11 at a minimum. This means you must have a JDK 11 installed with the environment variable `JAVA_HOME` referencing the path to Java home for your JDK 11 installation, e.g. `JAVA_HOME=/usr/lib/jvm/jdk-11`.
OpenSearch components build using Java 11 at a minimum and supports JDK 11, 17. This means you must have a JDK of supported version installed with the environment variable `JAVA_HOME` referencing the path to Java home for your JDK installation, e.g. `JAVA_HOME=/usr/lib/jvm/jdk-11`.

### Building

Expand Down
83 changes: 47 additions & 36 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ plugins {
id 'java'
id 'application'
id 'maven-publish'
id 'com.google.protobuf' version '0.8.8'
id 'com.google.protobuf' version '0.8.18'
id 'jacoco'
id 'idea'
id 'com.github.spotbugs' version '4.6.0'
id 'com.github.spotbugs' version '5.0.0'
id "de.undercouch.download" version "4.0.4"
id 'com.adarshr.test-logger' version '2.1.0'
id 'org.gradle.test-retry' version '1.3.1'
Expand Down Expand Up @@ -62,7 +62,7 @@ ext {
spotless {
java {
licenseHeaderFile(file('license-header'))
googleJavaFormat().aosp()
googleJavaFormat('1.12.0').aosp()
importOrder()
removeUnusedImports()
trimTrailingWhitespace()
Expand Down Expand Up @@ -103,7 +103,7 @@ testlogger {
spotbugsMain {
excludeFilter = file("checkstyle/findbugs-exclude.xml")
effort = 'max'
ignoreFailures = false
ignoreFailures = true // TODO: Set this to false later as they are too many warnings to be fixed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are not planning to fix this now, can we open an issue and link it here?

Looks like you fixed almost all the issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have created issue - #157 to track this.

There are still many medium related warnings which needs to be fixed. I fixed high priority ones.


reports {
xml.enabled = false
Expand All @@ -121,7 +121,7 @@ check {
}

jacoco {
toolVersion = "0.8.5"
toolVersion = "0.8.7"
}

jacocoTestReport {
Expand Down Expand Up @@ -230,6 +230,15 @@ test {
}
}

tasks.withType(Test) {
jvmArgs('--add-opens=java.base/java.io=ALL-UNNAMED')
jvmArgs('--add-opens=java.base/java.util.concurrent=ALL-UNNAMED')
jvmArgs('--add-opens=java.base/java.time=ALL-UNNAMED')
jvmArgs('--add-opens=java.base/java.util.stream=ALL-UNNAMED')
jvmArgs('--add-opens=java.base/sun.nio.fs=ALL-UNNAMED')
jvmArgs('--add-opens=java.base/java.nio.file=ALL-UNNAMED')
}

task rcaTest(type: Test) {
useJUnit {
includeCategories 'org.opensearch.performanceanalyzer.rca.GradleTaskForRca'
Expand All @@ -245,21 +254,23 @@ task rcaIt(type: Test) {
//testLogging.showStandardStreams = true
}

sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11

compileJava {
dependsOn spotlessApply
JavaVersion targetVersion = JavaVersion.toVersion(targetCompatibility);
if (targetVersion.isJava9Compatible()) {
options.compilerArgs += ["--add-exports", "jdk.attach/sun.tools.attach=ALL-UNNAMED"]
options.compilerArgs += ["--add-exports", "jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED"]
}
}

javadoc {
JavaVersion targetVersion = JavaVersion.toVersion(targetCompatibility);
if (targetVersion.isJava9Compatible()) {
options.addStringOption("-add-exports", "jdk.attach/sun.tools.attach=ALL-UNNAMED")
options.addStringOption("-add-exports", "jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED")
}
}

Expand Down Expand Up @@ -291,45 +302,45 @@ tasks.withType(JavaCompile) {

dependencies {
if (JavaVersion.current() <= JavaVersion.VERSION_1_8) {
compile files("${System.properties['java.home']}/../lib/tools.jar")
implementation files("${System.properties['java.home']}/../lib/tools.jar")
}

def jacksonVersion = "2.12.6"

compile 'org.jooq:jooq:3.10.8'
compile 'org.bouncycastle:bcprov-jdk15on:1.70'
compile 'org.bouncycastle:bcpkix-jdk15on:1.70'
compile 'org.xerial:sqlite-jdbc:3.32.3.2'
compile 'com.google.guava:guava:30.1-jre'
compile 'com.google.code.gson:gson:2.8.9'
compile 'org.checkerframework:checker-qual:3.5.0'
compile "com.fasterxml.jackson.core:jackson-annotations:${jacksonVersion}"
compile "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}"
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.17.1'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.17.1'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.9'
compile group: 'commons-io', name: 'commons-io', version: '2.7'
compile group: 'com.google.errorprone', name: 'error_prone_annotations', version: '2.9.0'
compile group: 'com.google.protobuf', name: 'protobuf-java', version: '3.19.2'
implementation 'org.jooq:jooq:3.10.8'
implementation 'org.bouncycastle:bcprov-jdk15on:1.70'
implementation 'org.bouncycastle:bcpkix-jdk15on:1.70'
implementation 'org.xerial:sqlite-jdbc:3.32.3.2'
implementation 'com.google.guava:guava:30.1-jre'
implementation 'com.google.code.gson:gson:2.8.9'
implementation 'org.checkerframework:checker-qual:3.5.0'
implementation "com.fasterxml.jackson.core:jackson-annotations:${jacksonVersion}"
implementation "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}"
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.17.1'
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.17.1'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.9'
implementation group: 'commons-io', name: 'commons-io', version: '2.7'
implementation group: 'com.google.errorprone', name: 'error_prone_annotations', version: '2.9.0'
implementation group: 'com.google.protobuf', name: 'protobuf-java', version: '3.19.2'
implementation 'io.grpc:grpc-netty:1.44.0'
implementation 'io.grpc:grpc-protobuf:1.44.0'
implementation 'io.grpc:grpc-stub:1.44.0'
implementation 'javax.annotation:javax.annotation-api:1.3.2'

// JDK9+ has to run powermock 2+. https://github.com/powermock/powermock/issues/888
testCompile group: 'org.powermock', name: 'powermock-api-mockito2', version: '2.0.0'
testCompile group: 'org.powermock', name: 'powermock-module-junit4', version: '2.0.0'
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.23.0'
testCompile group: 'org.powermock', name: 'powermock-core', version: '2.0.0'
testCompile group: 'org.powermock', name: 'powermock-api-support', version: '2.0.0'
testCompile group: 'org.powermock', name: 'powermock-module-junit4-common', version: '2.0.0'
testCompile group: 'org.javassist', name: 'javassist', version: '3.24.0-GA'
testCompile group: 'org.powermock', name: 'powermock-reflect', version: '2.0.0'
testCompile group: 'net.bytebuddy', name: 'byte-buddy', version: '1.9.3'
testCompile group: 'org.objenesis', name: 'objenesis', version: '3.0.1'
testCompile group: 'org.hamcrest', name: 'hamcrest-library', version: '2.1'
testCompile group: 'org.hamcrest', name: 'hamcrest', version: '2.1'
testCompile group: 'junit', name: 'junit', version: '4.12'
testImplementation group: 'org.powermock', name: 'powermock-api-mockito2', version: '2.0.0'
testImplementation group: 'org.powermock', name: 'powermock-module-junit4', version: '2.0.0'
testImplementation group: 'org.mockito', name: 'mockito-core', version: '2.23.0'
testImplementation group: 'org.powermock', name: 'powermock-core', version: '2.0.0'
testImplementation group: 'org.powermock', name: 'powermock-api-support', version: '2.0.0'
testImplementation group: 'org.powermock', name: 'powermock-module-junit4-common', version: '2.0.0'
testImplementation group: 'org.javassist', name: 'javassist', version: '3.24.0-GA'
testImplementation group: 'org.powermock', name: 'powermock-reflect', version: '2.0.0'
testImplementation group: 'net.bytebuddy', name: 'byte-buddy', version: '1.9.3'
testImplementation group: 'org.objenesis', name: 'objenesis', version: '3.0.1'
testImplementation group: 'org.hamcrest', name: 'hamcrest-library', version: '2.1'
testImplementation group: 'org.hamcrest', name: 'hamcrest', version: '2.1'
testImplementation group: 'junit', name: 'junit', version: '4.12'
}

protobuf {
Expand Down
8 changes: 7 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@
# SPDX-License-Identifier: Apache-2.0
#

localPaDir=../performance-analyzer
localPaDir=../performance-analyzer
# Below were added to fix build issue. Refer - https://github.com/diffplug/spotless/issues/834
org.gradle.jvmargs=--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Tue Jan 28 11:59:31 PST 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,15 @@ public double getCurrentRatio() {
}
NodeConfigCache cache = appContext.getNodeConfigCache();
NodeKey key = new NodeKey(appContext.getDataNodeInstances().get(0));

try {
Double oldGenMaxSizeInBytes = cache.get(key, ResourceUtil.OLD_GEN_MAX_SIZE);
LOG.debug("old gen max size is {}", oldGenMaxSizeInBytes);
Double youngGenMaxSizeInBytes = cache.get(key, ResourceUtil.YOUNG_GEN_MAX_SIZE);
LOG.debug("young gen max size is {}", youngGenMaxSizeInBytes);
LOG.debug("current ratio is {}", (oldGenMaxSizeInBytes / youngGenMaxSizeInBytes));
return (oldGenMaxSizeInBytes / youngGenMaxSizeInBytes);
} catch (IllegalArgumentException | NullPointerException e) {
} catch (IllegalArgumentException e) {
LOG.error("Exception while computing old:young generation sizing ratio", e);
return -1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ public String getName() {
*/
@Nullable
public static HotClusterSummary buildSummary(Record record) {
if (record == null) {
return null;
}
HotClusterSummary summary = null;
try {
Integer numOfNodes =
Expand All @@ -196,17 +199,19 @@ public static HotClusterSummary buildSummary(Record record) {
record.get(
ClusterSummaryField.NUM_OF_UNHEALTHY_NODES_FIELD.getField(),
Integer.class);
if (numOfNodes == null || numOfUnhealthyNodes == null) {
LOG.warn(
"read null object from SQL, numOfNodes: {}, numOfUnhealthyNodes: {}",
numOfNodes,
numOfUnhealthyNodes);
return null;
}
summary = new HotClusterSummary(numOfNodes, numOfUnhealthyNodes);
} catch (IllegalArgumentException ie) {
LOG.error("Some fields might not be found in record, cause : {}", ie.getMessage());
} catch (DataTypeException de) {
LOG.error("Fails to convert data type");
}
// we are very unlikely to catch this exception unless some fields are not persisted
// properly.
catch (NullPointerException ne) {
LOG.error("read null object from SQL, trace : {} ", ne.getStackTrace());
}
return summary;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ public static HotNodeSummary buildSummary(Record record) {
String nodeId = record.get(NodeSummaryField.NODE_ID_FIELD.getField(), String.class);
String ipAddress =
record.get(NodeSummaryField.HOST_IP_ADDRESS_FIELD.getField(), String.class);
if (nodeId == null || ipAddress == null) {
LOG.warn("read null object from SQL, nodeId: {}, ipAddress: {}", nodeId, ipAddress);
return null;
}
summary =
new HotNodeSummary(
new InstanceDetails.Id(nodeId), new InstanceDetails.Ip(ipAddress));
Expand All @@ -270,11 +274,6 @@ public static HotNodeSummary buildSummary(Record record) {
} catch (DataTypeException de) {
LOG.error("Fails to convert data type");
}
// we are very unlikely to catch this exception unless some fields are not persisted
// properly.
catch (NullPointerException ne) {
LOG.error("read null object from SQL, trace : {} ", ne.getStackTrace());
}
return summary;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,9 @@ public String getName() {
*/
@Nullable
public static HotResourceSummary buildSummary(Record record) {
if (record == null) {
return null;
}
HotResourceSummary summary = null;
try {
int resourceTypeEnumVal =
Expand All @@ -336,6 +339,15 @@ public static HotResourceSummary buildSummary(Record record) {
record.get(ResourceSummaryField.TIME_PERIOD_FIELD.getField(), Integer.class);
String metaData =
record.get(ResourceSummaryField.METADATA_FIELD.getField(), String.class);
// If below condition not checked, will result in NPE.
if (threshold == null || value == null || timePeriod == null) {
LOG.warn(
"read null object from SQL, threshold: {}, value: {}, timePeriod: {}",
threshold,
value,
timePeriod);
return null;
}
summary =
new HotResourceSummary(
ResourceUtil.buildResource(resourceTypeEnumVal, resourceMetricEnumVal),
Expand All @@ -352,11 +364,6 @@ public static HotResourceSummary buildSummary(Record record) {
} catch (DataTypeException de) {
LOG.error("Fails to convert data type");
}
// we are very unlikely to catch this exception unless some fields are not persisted
// properly.
catch (NullPointerException ne) {
LOG.error("read null object from SQL, trace : {} ", ne.getStackTrace());
}
return summary;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ public String getName() {
*/
@Nullable
public static HotShardSummary buildSummary(final Record record) {
if (record == null) {
return null;
}
HotShardSummary summary = null;
try {
String indexName =
Expand Down Expand Up @@ -308,6 +311,24 @@ public static HotShardSummary buildSummary(final Record record) {
Double.class);
Integer timePeriod =
record.get(HotShardSummaryField.TIME_PERIOD_FIELD.getField(), Integer.class);
if (timePeriod == null
|| cpu_utilization == null
|| cpu_utilization_threshold == null
|| io_throughput == null
|| io_throughput_threshold == null
|| io_sys_callrate == null
|| io_sys_callrate_threshold == null) {
LOG.warn(
"read null object from SQL, timePeriod: {}, cpu_utilization: {}, cpu_utilization_threshold: {},"
+ " io_throughput: {}, io_throughput_threshold: {}, io_sys_callrate: {}",
timePeriod,
cpu_utilization,
cpu_utilization_threshold,
io_throughput,
io_throughput_threshold,
io_sys_callrate);
return null;
}
summary = new HotShardSummary(indexName, shardId, nodeId, timePeriod);
summary.setcpuUtilization(cpu_utilization);
summary.setCpuUtilizationThreshold(cpu_utilization_threshold);
Expand All @@ -320,11 +341,6 @@ public static HotShardSummary buildSummary(final Record record) {
} catch (DataTypeException de) {
LOG.error("Fails to convert data type");
}
// we are very unlikely to catch this exception unless some fields are not persisted
// properly.
catch (NullPointerException ne) {
LOG.error("read null object from SQL, trace : {} ", ne.getStackTrace());
}
return summary;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,6 @@ public static TopConsumerSummary buildSummary(Record record) {
} catch (DataTypeException de) {
LOG.error("Fails to convert data type");
}
// we are very unlikely to catch this exception unless some fields are not persisted
// properly.
catch (NullPointerException ne) {
LOG.error("read null object from SQL, trace : {} ", ne.getStackTrace());
}
return summary;
}
}
Loading