Skip to content

Commit f11481a

Browse files
authored
added code style plugin and applied spotless fixes (#64)
1 parent b102518 commit f11481a

File tree

32 files changed

+580
-445
lines changed

32 files changed

+580
-445
lines changed

build.gradle.kts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ plugins {
66
id("org.hypertrace.ci-utils-plugin") version "0.3.0"
77
id("org.hypertrace.publish-plugin") version "1.0.2" apply false
88
id("org.hypertrace.jacoco-report-plugin") version "0.2.0" apply false
9+
id("org.hypertrace.code-style-plugin") version "1.1.2" apply false
910
}
1011

1112
subprojects {
@@ -15,4 +16,12 @@ subprojects {
1516
license.set(License.APACHE_2_0)
1617
}
1718
}
19+
pluginManager.withPlugin("java") {
20+
configure<JavaPluginExtension> {
21+
sourceCompatibility = JavaVersion.VERSION_11
22+
targetCompatibility = JavaVersion.VERSION_11
23+
24+
apply(plugin = "org.hypertrace.code-style-plugin")
25+
}
26+
}
1827
}
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
plugins {
2-
`java-library`
3-
jacoco
4-
id("org.hypertrace.publish-plugin")
5-
id("org.hypertrace.jacoco-report-plugin")
2+
`java-library`
3+
jacoco
4+
id("org.hypertrace.publish-plugin")
5+
id("org.hypertrace.jacoco-report-plugin")
66
}
77

88
tasks.test {
9-
useJUnitPlatform()
9+
useJUnitPlatform()
1010
}
1111

1212
dependencies {
13-
implementation(project(":platform-service-framework"))
13+
implementation(project(":platform-service-framework"))
1414

15-
// Configuration
16-
implementation("com.typesafe:config:1.4.2")
17-
// Logging
18-
implementation("org.slf4j:slf4j-api:1.7.36")
19-
implementation("org.awaitility:awaitility:4.0.3")
15+
// Configuration
16+
implementation("com.typesafe:config:1.4.2")
17+
// Logging
18+
implementation("org.slf4j:slf4j-api:1.7.36")
19+
implementation("org.awaitility:awaitility:4.0.3")
2020
}
Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package org.hypertrace.core.serviceframework;
22

3-
import org.hypertrace.core.serviceframework.config.ConfigClient;
4-
import org.hypertrace.core.serviceframework.config.IntegrationTestConfigClientFactory;
53
import java.io.IOException;
64
import java.net.URI;
75
import java.net.http.HttpClient;
@@ -13,10 +11,10 @@
1311
import java.util.concurrent.Executors;
1412
import java.util.concurrent.TimeUnit;
1513
import org.awaitility.Awaitility;
14+
import org.hypertrace.core.serviceframework.config.ConfigClient;
15+
import org.hypertrace.core.serviceframework.config.IntegrationTestConfigClientFactory;
1616

17-
/**
18-
* Utility class used in Integration tests with helper methods to start/shutdown services
19-
*/
17+
/** Utility class used in Integration tests with helper methods to start/shutdown services */
2018
public class IntegrationTestServerUtil {
2119
private static final long INITIAL_DELAY_IN_MILLIS = 1000L;
2220
private static final long INTERVAL_CHECK_IN_MILLIS = 1000L;
@@ -36,57 +34,61 @@ public static void startServices(String testName, String[] services) {
3634
private static void startServices(Optional<String> testName, String[] services) {
3735
executorService = Executors.newFixedThreadPool(services.length);
3836
IntegrationTestServerUtil.services = services;
39-
for (String service:services) {
40-
executorService.submit(() -> {
41-
try {
42-
IntegrationTestServiceLauncher.launchService(testName, service);
43-
} catch (Throwable t) {
44-
System.out.println("Error starting the service with these message: "
45-
+ t.getMessage());
46-
}
47-
});
37+
for (String service : services) {
38+
executorService.submit(
39+
() -> {
40+
try {
41+
IntegrationTestServiceLauncher.launchService(testName, service);
42+
} catch (Throwable t) {
43+
System.out.println(
44+
"Error starting the service with these message: " + t.getMessage());
45+
}
46+
});
4847
waitTillServerReady(service);
4948
}
5049
}
5150

5251
public static void shutdownServices() {
53-
for (String service:services) {
52+
for (String service : services) {
5453
IntegrationTestServiceLauncher.shutdown();
55-
Awaitility.await().pollInterval(INTERVAL_CHECK_IN_MILLIS, TimeUnit.MILLISECONDS)
56-
.and().pollDelay(INITIAL_DELAY_IN_MILLIS, TimeUnit.MILLISECONDS)
54+
Awaitility.await()
55+
.pollInterval(INTERVAL_CHECK_IN_MILLIS, TimeUnit.MILLISECONDS)
56+
.and()
57+
.pollDelay(INITIAL_DELAY_IN_MILLIS, TimeUnit.MILLISECONDS)
5758
.atMost(MAX_CHECK_DURATION_IN_MILLIS, TimeUnit.MILLISECONDS)
5859
.until(() -> !isServerReady(service));
5960
}
6061
executorService.shutdownNow();
6162
}
6263

6364
private static void waitTillServerReady(String service) {
64-
Awaitility.await().pollInterval(INTERVAL_CHECK_IN_MILLIS, TimeUnit.MILLISECONDS)
65-
.and().pollDelay(INITIAL_DELAY_IN_MILLIS, TimeUnit.MILLISECONDS)
65+
Awaitility.await()
66+
.pollInterval(INTERVAL_CHECK_IN_MILLIS, TimeUnit.MILLISECONDS)
67+
.and()
68+
.pollDelay(INITIAL_DELAY_IN_MILLIS, TimeUnit.MILLISECONDS)
6669
.atMost(MAX_CHECK_DURATION_IN_MILLIS, TimeUnit.MILLISECONDS)
6770
.until(() -> isServerReady(service));
6871
}
6972

7073
private static boolean isServerReady(String service) {
7174
try {
72-
ConfigClient configClient = IntegrationTestConfigClientFactory.getConfigClientForService(service);
75+
ConfigClient configClient =
76+
IntegrationTestConfigClientFactory.getConfigClientForService(service);
7377
int port = configClient.getConfig().getInt("service.admin.port");
7478
HttpClient client = HttpClient.newHttpClient();
75-
HttpRequest request = HttpRequest.newBuilder()
76-
.uri(URI.create(
77-
String.format("http://localhost:%d/health", port)))
78-
.build();
79+
HttpRequest request =
80+
HttpRequest.newBuilder()
81+
.uri(URI.create(String.format("http://localhost:%d/health", port)))
82+
.build();
7983

80-
HttpResponse<String> response =
81-
client.send(request, BodyHandlers.ofString());
84+
HttpResponse<String> response = client.send(request, BodyHandlers.ofString());
8285
String responseBody = response.body();
83-
return response.statusCode() == 200 && "OK".equals(responseBody);
86+
return response.statusCode() == 200 && "OK".equals(responseBody);
8487
} catch (IOException re) {
8588
return false;
8689
} catch (InterruptedException ie) {
8790
Thread.currentThread().interrupt();
8891
}
8992
return false;
9093
}
91-
9294
}

integrationtest-service-framework/src/main/java/org/hypertrace/core/serviceframework/IntegrationTestServiceLauncher.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import java.util.ArrayList;
44
import java.util.List;
55
import java.util.Optional;
6-
76
import org.hypertrace.core.serviceframework.config.ConfigClient;
87
import org.hypertrace.core.serviceframework.config.IntegrationTestConfigClientFactory;
98
import org.slf4j.Logger;
@@ -26,7 +25,7 @@ public static void launchService(Optional<String> testName, String serviceName)
2625
try {
2726
LOGGER.info("Trying to start PlatformService: {}", serviceName);
2827
final ConfigClient configClient =
29-
IntegrationTestConfigClientFactory.getConfigClientForService(testName, serviceName);
28+
IntegrationTestConfigClientFactory.getConfigClientForService(testName, serviceName);
3029
PlatformService app = PlatformServiceFactory.get(configClient);
3130
app.initialize();
3231
Runtime.getRuntime().addShutdownHook(new Thread(app::shutdown));

integrationtest-service-framework/src/main/java/org/hypertrace/core/serviceframework/config/IntegrationTestConfigClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ public Config getConfig() {
3636

3737
@Override
3838
public Config getConfig(String service, String cluster, String pod, String container) {
39-
return defaultTestName.map(testName -> loadConfig(service, testName))
39+
return defaultTestName
40+
.map(testName -> loadConfig(service, testName))
4041
.orElse(ConfigFactory.empty())
4142
.withFallback(loadConfig(service, cluster, pod))
4243
.withFallback(loadConfig(service, cluster))
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
package org.hypertrace.core.serviceframework.config;
22

3-
import org.hypertrace.core.serviceframework.IntegrationTestServiceLauncher;
4-
53
import java.util.Optional;
4+
import org.hypertrace.core.serviceframework.IntegrationTestServiceLauncher;
65

76
/**
8-
* Used by {@link IntegrationTestServiceLauncher} to initialize
9-
* the config client for the respective service
10-
* Config is loaded from resources/config/application.conf
7+
* Used by {@link IntegrationTestServiceLauncher} to initialize the config client for the respective
8+
* service Config is loaded from resources/config/application.conf
119
*/
1210
public class IntegrationTestConfigClientFactory {
1311
public static ConfigClient getConfigClientForService(String serviceName) {
1412
return new IntegrationTestConfigClient(serviceName);
1513
}
1614

17-
public static ConfigClient getConfigClientForService(Optional<String> testName, String serviceName) {
15+
public static ConfigClient getConfigClientForService(
16+
Optional<String> testName, String serviceName) {
1817
return new IntegrationTestConfigClient(testName, serviceName);
1918
}
20-
}
19+
}

platform-grpc-service-framework/src/main/java/org/hypertrace/core/serviceframework/grpc/GrpcPlatformServiceContainer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import io.grpc.inprocess.InProcessServerBuilder;
1414
import io.grpc.protobuf.services.HealthStatusManager;
1515
import io.micrometer.core.instrument.binder.grpc.MetricCollectingClientInterceptor;
16+
import io.micrometer.core.instrument.binder.grpc.MetricCollectingServerInterceptor;
1617
import java.io.IOException;
1718
import java.util.Collection;
1819
import java.util.Collections;
@@ -25,8 +26,6 @@
2526
import java.util.function.Function;
2627
import java.util.stream.Collectors;
2728
import java.util.stream.Stream;
28-
29-
import io.micrometer.core.instrument.binder.grpc.MetricCollectingServerInterceptor;
3029
import lombok.Value;
3130
import lombok.extern.slf4j.Slf4j;
3231
import org.hypertrace.core.grpcutils.client.GrpcRegistryConfig;

platform-http-service-framework/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,4 @@ dependencies {
2020

2121
annotationProcessor("org.projectlombok:lombok:1.18.24")
2222
compileOnly("org.projectlombok:lombok:1.18.24")
23-
2423
}

platform-metrics/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ Platform metrics library is a utility library to help with:
44
* Make it easy to collect custom metrics in the service code very easily
55
* Report all the metrics to either monitoring backends like Prometheus or
66
log them to files, so that we can have access to metrics in all environments
7-
7+
88
The metric backends, report interval, and the default tags for all the metrics
99
are configurable. Different reporters supported are:
1010
* prometheus
1111
* logging --> to log metrics into log files or console
1212
* testing --> in-memory reporter. Purely for unit tests.
13-
13+
1414
The default metrics backend is "prometheus" with 30s reporting interval.
1515

1616
## Usage

platform-metrics/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ dependencies {
2525
implementation("io.prometheus:simpleclient_servlet:0.12.0")
2626
implementation("io.prometheus:simpleclient_pushgateway:0.12.0")
2727
implementation("org.eclipse.jetty:jetty-servlet:9.4.48.v20220622")
28-
implementation ("com.google.guava:guava:30.1.1-jre")
28+
implementation("com.google.guava:guava:30.1.1-jre")
2929

3030
testImplementation("org.junit.jupiter:junit-jupiter:5.9.0")
3131
testImplementation("org.mockito:mockito-core:4.8.0")

0 commit comments

Comments
 (0)