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

W 16554282.library upgrade #991

Merged
merged 14 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from 13 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
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up JDK 1.17
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'zulu'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 1.17
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: 17
Expand Down
35 changes: 15 additions & 20 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@ buildscript {
repositories {
mavenCentral()
mavenLocal()
jcenter()
Copy link
Contributor

Choose a reason for hiding this comment

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

why are we removing this repo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BTW, in this PR, I am upgrading gradle 8 as well.

}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springbootVersion}")
}
}

plugins {
id 'com.palantir.docker' version "0.36.0"
id "com.github.jk1.dependency-license-report" version "2.9"
id "com.github.hierynomus.license" version "0.16.1"
id "org.sonarqube" version "5.1.0.4882"
id 'net.researchgate.release' version "3.0.2"
id 'com.palantir.docker' version "${palantirDocker}"
id "com.github.jk1.dependency-license-report" version "${dependencyLicenseReport}"
id "com.github.hierynomus.license" version "${hierynomusLicense}"
id "org.sonarqube" version "${sonarqube}"
id 'net.researchgate.release' version "${gradleRelease}"
}

release {
Expand Down Expand Up @@ -53,19 +52,15 @@ subprojects {
}

dependencies {
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.17.2'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.17.2'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.17.2'
implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-smile', version: '2.17.2'
implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-cbor', version: '2.17.2'
implementation group: 'com.google.re2j', name: 're2j', version: '1.7'
testImplementation group: 'org.powermock', name: 'powermock-module-javaagent', version: '2.0.9'
testImplementation group: 'org.jacoco', name: 'org.jacoco.agent', version: '0.8.12', classifier: 'runtime'
testImplementation group: 'org.powermock', name: 'powermock-core', version: '2.0.9'

testImplementation("junit:junit")
// testImplementation("org.springframework.boot:spring-boot-starter-test")
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: "${jackson}"
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: "${jackson}"
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: "${jackson}"
implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-smile', version: "${jackson}"
implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-cbor', version: "${jackson}"
implementation group: 'com.google.re2j', name: 're2j', version: "${re2j}"
testImplementation group: 'org.powermock', name: 'powermock-module-javaagent', version: "${powermock}"
testImplementation group: 'org.jacoco', name: 'org.jacoco.agent', version: "${jacoco}", classifier: 'runtime'
testImplementation group: 'org.powermock', name: 'powermock-core', version: "${powermock}"
testImplementation("org.junit.jupiter:junit-jupiter:${junit}")
}


}
83 changes: 32 additions & 51 deletions carbonj.service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,24 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent

buildscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
mavenLocal()
mavenCentral()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springbootVersion}"
classpath 'org.hibernate.build.gradle:gradle-maven-publish-auth:2.0.1'
classpath 'com.netflix.nebula:gradle-ospackage-plugin:8.6.3'
classpath "org.hibernate.build.gradle:gradle-maven-publish-auth:${mavenPublish}"
}
}

plugins {
id "com.github.hierynomus.license"
id 'maven-publish'
id 'org.springframework.boot'
id 'net.researchgate.release' version "3.0.2"
id 'net.researchgate.release' version "${gradleRelease}"
id 'com.netflix.nebula.ospackage' version "${ospackage}"
}

license {
Expand All @@ -39,16 +42,11 @@ licenseMain.dependsOn licenseCheckDockerFiles
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.palantir.docker'
apply plugin: 'org.sonarqube'
apply plugin: 'maven-publish'
apply plugin: 'maven-publish-auth'
apply plugin: 'net.researchgate.release'
apply plugin: 'distribution'
apply plugin: 'nebula.rpm'


ext {
if (project.hasProperty('dockerRepo')) {
Expand Down Expand Up @@ -80,7 +78,6 @@ ext {
repositories {
mavenLocal()
mavenCentral()
jcenter()
}

bootJar {
Expand Down Expand Up @@ -144,23 +141,10 @@ task rpm(type: Rpm) {
}
}

distributions {
custom {
// baseName = project.name
contents {
from { 'build/libs' }
from { 'scripts/carbonj.sh' }
from { 'README.md' }
}
}
}

// for release automatically push released docker and mvn image to repo
afterReleaseBuild.dependsOn publish
publish.dependsOn dockerPush
publish.dependsOn build
rpm.dependsOn bootJar
publish.dependsOn rpm

publishing {
publications {
Expand Down Expand Up @@ -190,34 +174,31 @@ release {
description = 'CarbonJ Service Implementation'
dependencies {
implementation project(':cc-metrics-reporter')
// compile group: 'com.sfcc.um', name: 'metrics_reporter', version:'0.0.2'
implementation group: 'org.apache.logging.log4j', name: 'log4j-1.2-api', version: '2.23.1'
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.23.1'
implementation group: 'org.apache.logging.log4j', name: 'log4j-to-slf4j', version: '2.23.1'
implementation group: 'org.slf4j', name: 'slf4j-api'
implementation group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2'
implementation group: 'org.rocksdb', name: 'rocksdbjni', version: '9.4.0'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.11.0'
implementation group: 'com.google.code.externalsortinginjava', name: 'externalsortinginjava', version: '0.6.2'
implementation group: 'com.google.guava', name: 'guava', version: '33.3.0-jre'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.17.0'
implementation group: 'commons-io', name: 'commons-io', version: '2.16.1'
implementation group: 'joda-time', name: 'joda-time', version: '2.12.7'
implementation group: 'io.netty', name: 'netty-all', version: '4.1.101.Final'
implementation group: 'net.razorvine', name: 'pickle', version: '1.5'
implementation group: 'org.python', name: 'jython-standalone', version: '2.7.4'
implementation group: 'com.amazonaws', name: 'amazon-kinesis-client', version: '1.15.2'
implementation group: 'com.amazonaws', name: 'aws-java-sdk-sts', version: '1.12.771'
implementation group: 'io.dropwizard.metrics', name: 'metrics-core', version: '4.2.27'
implementation group: 'io.dropwizard.metrics', name: 'metrics-jvm', version: '4.2.26'
implementation group: 'io.dropwizard.metrics', name: 'metrics-graphite', version: '4.2.27'
implementation group: 'org.msgpack', name: 'jackson-dataformat-msgpack', version: '0.9.8'
implementation 'jakarta.servlet:jakarta.servlet-api:6.1.0'
implementation 'org.eclipse.jetty:jetty-server'
// implementation 'org.mockito:mockito-core:4.11.0'

testImplementation group: 'junit', name: 'junit', version: '4.13.2'
testImplementation group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3'
implementation group: 'org.apache.logging.log4j', name: 'log4j-1.2-api', version: "${log4j}"
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: "${log4j}"
implementation group: 'org.apache.logging.log4j', name: 'log4j-to-slf4j', version: "${log4j}"
implementation group: 'org.slf4j', name: 'slf4j-api', version: "${slf4j}"
implementation group: 'javax.annotation', name: 'javax.annotation-api', version: "${annotationApi}"
implementation group: 'org.rocksdb', name: 'rocksdbjni', version: "${rocksdb}"
implementation group: 'com.google.code.gson', name: 'gson', version: "${gson}"
implementation group: 'com.google.code.externalsortinginjava', name: 'externalsortinginjava', version: "${externalsortinginjava}"
implementation group: 'com.google.guava', name: 'guava', version: "${guava}"
implementation group: 'org.apache.commons', name: 'commons-lang3', version: "${commonsLang3}"
implementation group: 'commons-io', name: 'commons-io', version: "${commonsIo}"
implementation group: 'joda-time', name: 'joda-time', version: "${jodaTime}"
implementation group: 'io.netty', name: 'netty-all', version: "${nettyAll}"
implementation group: 'net.razorvine', name: 'pickle', version: "${pickle}"
implementation group: 'org.python', name: 'jython-standalone', version: "${jythonStandalone}"
implementation group: 'com.amazonaws', name: 'amazon-kinesis-client', version: "${amazonKinesisClient}"
implementation group: 'com.amazonaws', name: 'aws-java-sdk-sts', version: "${awsJavaSdkV1}"
implementation group: 'io.dropwizard.metrics', name: 'metrics-core', version: "${metrics}"
implementation group: 'io.dropwizard.metrics', name: 'metrics-jvm', version: "${metrics}"
implementation group: 'io.dropwizard.metrics', name: 'metrics-graphite', version: "${metrics}"
implementation group: 'org.msgpack', name: 'jackson-dataformat-msgpack', version: "${msgpack}"
implementation "jakarta.servlet:jakarta.servlet-api:${servletApi}"
implementation "org.eclipse.jetty:jetty-server:${jettyServer}"

testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: "${junit}"

implementation (group:"org.springframework.boot", name:"spring-boot-starter-logging", version: "${springbootVersion}") {
exclude group: 'org.apache.logging.log4j', module: 'log4j-to-slf4j'
Expand All @@ -232,10 +213,10 @@ dependencies {
}
implementation group:"org.springframework.boot", name:"spring-boot-starter-actuator", version: "${springbootVersion}"
testImplementation group:"org.springframework.boot", name:"spring-boot-starter-test", version: "${springbootVersion}"

}

test {
useJUnitPlatform()
maxHeapSize = "2g"
jvmArgs = [
'--add-opens', 'java.base/java.util=ALL-UNNAMED',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.demandware.carbonj.service.db.util.CacheStatsReporter;
import com.demandware.carbonj.service.db.util.DatabaseMetrics;
import com.demandware.carbonj.service.db.util.FileUtils;
import com.demandware.carbonj.service.db.util.Quota;
import com.demandware.carbonj.service.ns.NamespaceCounter;
import com.demandware.carbonj.service.strings.StringsCache;
import com.google.common.base.Preconditions;
Expand Down Expand Up @@ -153,6 +154,8 @@ public class MetricIndexImpl implements MetricIndex, ApplicationListener<NameInd

private final ExecutorService executorService = Executors.newSingleThreadExecutor();

private final Quota invalidLeafMetricsReceivedLogQuota;

private static class DeleteResult extends DeleteAPIResult
{
public List<Metric> metrics = new ArrayList<>();
Expand All @@ -170,7 +173,7 @@ public MetricIndexImpl( MetricRegistry metricRegistry, String metricsStoreConfig
expireAfterAccessInMinutes, nameUtils, aggrPolicySource, nameIndexQueryCacheMaxSize,
expireAfterWriteQueryCacheInSeconds, idCacheEnabled, longId,
new NamespaceCounter(metricRegistry, 7200), false, true, 100,
nameIndexQueryPatternCacheMaxSize, expireAfterWriteQueryPatternCacheInSeconds);
nameIndexQueryPatternCacheMaxSize, expireAfterWriteQueryPatternCacheInSeconds, 10);
}

public MetricIndexImpl( MetricRegistry metricRegistry, String metricsStoreConfigFile,
Expand All @@ -184,7 +187,8 @@ public MetricIndexImpl( MetricRegistry metricRegistry, String metricsStoreConfig
boolean rocksdbReadonly,
boolean syncSecondaryDb,
int nameIndexKeyQueueSizeLimit,
int nameIndexQueryPatternCacheMaxSize, int expireAfterWriteQueryPatternCacheInSeconds) {
int nameIndexQueryPatternCacheMaxSize, int expireAfterWriteQueryPatternCacheInSeconds,
int maxInvalidLeafMetricsLoggedPerMin) {
this.metricRegistry = metricRegistry;
this.metricsStoreConfigFile = metricsStoreConfigFile;
this.nameUtils = Preconditions.checkNotNull(nameUtils);
Expand All @@ -201,6 +205,7 @@ public MetricIndexImpl( MetricRegistry metricRegistry, String metricsStoreConfig
this.rocksdbReadonly = rocksdbReadonly;
this.syncSecondaryDb = syncSecondaryDb;
this.nameIndexKeyQueueSizeLimit = nameIndexKeyQueueSizeLimit;
this.invalidLeafMetricsReceivedLogQuota = new Quota(maxInvalidLeafMetricsLoggedPerMin, 60);

this.metricCache =
CacheBuilder.newBuilder().initialCapacity(nameIndexMaxCacheSize).maximumSize(nameIndexMaxCacheSize)
Expand Down Expand Up @@ -997,6 +1002,9 @@ private Metric insert( String key )
String msg =
String.format( "Cannot create metric with name [%s] because [%s] is already a leaf", key,
entryKey );
if (invalidLeafMetricsReceivedLogQuota.allow()) {
log.error(msg);
}
throw new RuntimeException( msg );
}
// key already exists. may need to update list of children
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ public class cfgMetricIndex
@Value("${metrics.store.sync.queue.size.limit:10000}")
private int nameIndexKeyQueueSizeLimit = 10000;

@Value( "${log.invalidLeafMetrics.quota.min:10}" )
private int maxInvalidLeafMetricsLoggedPerMin;

// TODO duplicated in different cfg beans
@Value( "${app.servicedir:}" )
private String serviceDir;
Expand Down Expand Up @@ -134,7 +137,7 @@ MetricIndex metricIndex(@Qualifier( "metricNameIndexStore" ) IndexStore<String,
nameIndexMaxCacheSize, metricCacheExpireAfterAccessInMinutes, nameUtils, policySource,
nameIndexQueryCacheMaxSize, expireAfterWriteQueryCacheInSeconds, enableIdCache, longId,
namespaceCounter, rocksdbReadonly, syncSecondaryDb, nameIndexKeyQueueSizeLimit,
nameIndexQueryPatternCacheMaxSize, expireAfterWriteQueryPatternCacheInSeconds);
nameIndexQueryPatternCacheMaxSize, expireAfterWriteQueryPatternCacheInSeconds, maxInvalidLeafMetricsLoggedPerMin);
s.scheduleWithFixedDelay(metricIndex::reload, 300, 300, TimeUnit.SECONDS);
return metricIndex;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
*/
package com.demandware.carbonj.service.accumulator;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

@RunWith(JUnit4.class)
public class TestDefaultSlotStrategy {

@Test
Expand All @@ -27,12 +25,12 @@ public void testSlotStrategy() {
}

private void verify(SlotStrategy slotStrategy, int metricTs, int expectedSlotTs, int expectedSlotStartTs, int expectedSlotEndTs) {
Assert.assertEquals(expectedSlotTs, slotStrategy.getSlotTs(metricTs));
Assert.assertEquals(expectedSlotStartTs, slotStrategy.getStartTs(metricTs));
Assert.assertEquals(expectedSlotEndTs, slotStrategy.getEndTs(metricTs));
assertEquals(expectedSlotTs, slotStrategy.getSlotTs(metricTs));
assertEquals(expectedSlotStartTs, slotStrategy.getStartTs(metricTs));
assertEquals(expectedSlotEndTs, slotStrategy.getEndTs(metricTs));
}

private void verify(SlotStrategy slotStrategy, int metricTs, int expectedSlotTs) {
Assert.assertEquals(expectedSlotTs, slotStrategy.getSlotTs(metricTs));
assertEquals(expectedSlotTs, slotStrategy.getSlotTs(metricTs));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@

import com.demandware.carbonj.service.db.util.time.TimeSource;
import com.demandware.carbonj.service.engine.DataPoint;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.jupiter.api.Test;

import java.util.Map;

@RunWith(JUnit4.class)
import static org.junit.jupiter.api.Assertions.assertEquals;

public class TestLatencyAggregation {

@Test
Expand All @@ -28,10 +26,10 @@ public void testLatencyAggregation() {
la.add(new DataPoint("metric4", 2, time), time + 3);
la.add(new DataPoint("metric5", 2, time), time + 4);
Map<String, Double> aggTypeToValues = la.getValues();
Assert.assertEquals(4, aggTypeToValues.size());
Assert.assertEquals(0, aggTypeToValues.get("min").intValue());
Assert.assertEquals(4, aggTypeToValues.get("max").intValue());
Assert.assertEquals(5, aggTypeToValues.get("count").intValue());
Assert.assertEquals(2, aggTypeToValues.get("mean").intValue());
assertEquals(4, aggTypeToValues.size());
assertEquals(0, aggTypeToValues.get("min").intValue());
assertEquals(4, aggTypeToValues.get("max").intValue());
assertEquals(5, aggTypeToValues.get("count").intValue());
assertEquals(2, aggTypeToValues.get("mean").intValue());
}
}
Loading
Loading