Skip to content

Commit 3af626b

Browse files
committed
JAVA: fix linting issues
1 parent a83d1e4 commit 3af626b

File tree

8 files changed

+880
-710
lines changed

8 files changed

+880
-710
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ on:
33
push:
44
branches:
55
- master
6+
paths:
7+
- 'java/*'
68
pull_request:
9+
paths:
10+
- 'java/*'
711

812
jobs:
913
compile:
@@ -19,5 +23,9 @@ jobs:
1923
distribution: temurin
2024
java-version: 8
2125
cache: maven
26+
2227
- name: Compile Tests
23-
run: mvn test-compile
28+
run: make compile compile-test
29+
30+
- name: Validate
31+
run: make verify

java/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
clean:
2+
mvn clean
3+
4+
verify:
5+
mvn verify
6+
mvn javadoc:test-javadoc
7+
mvn javadoc:test-aggregate
8+
mvn javadoc:test-jar
9+
mvn javadoc:test-resource-bundle
10+
11+
fix:
12+
mvn com.coveo:fmt-maven-plugin:format
13+
echo y | mvn javadoc:fix
14+
echo y | mvn javadoc:test-fix
15+
16+
compile:
17+
mvn compile
18+
19+
compile-test:
20+
mvn test-compile

java/src/main/java/com/scylladb/alternator/AlternatorEndpointProvider.java

Lines changed: 54 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import java.util.concurrent.ConcurrentHashMap;
77
import java.util.logging.Level;
88
import java.util.logging.Logger;
9-
109
import software.amazon.awssdk.endpoints.Endpoint;
1110
import software.amazon.awssdk.services.dynamodb.endpoints.DynamoDbEndpointParams;
1211
import software.amazon.awssdk.services.dynamodb.endpoints.DynamoDbEndpointProvider;
@@ -16,42 +15,63 @@
1615
// AlternatorEndpointProvider, which maintains up-to-date knowledge of the
1716
// live nodes in Alternator data center (by holding a AlternatorLiveNodes
1817
// object), and choose a different node for each request.
18+
/**
19+
* AlternatorEndpointProvider class.
20+
*
21+
* @author dmitry.kropachev
22+
*/
1923
public class AlternatorEndpointProvider implements DynamoDbEndpointProvider {
20-
private final AlternatorLiveNodes liveNodes;
21-
private final Map<URI, CompletableFuture<Endpoint>> futureCache;
22-
private static Logger logger = Logger.getLogger(AlternatorEndpointProvider.class.getName());
24+
private final AlternatorLiveNodes liveNodes;
25+
private final Map<URI, CompletableFuture<Endpoint>> futureCache;
26+
private static Logger logger = Logger.getLogger(AlternatorEndpointProvider.class.getName());
2327

24-
public AlternatorEndpointProvider(URI seedURI) {
25-
this(seedURI, "", "");
26-
}
28+
/**
29+
* Constructor for AlternatorEndpointProvider.
30+
*
31+
* @param seedURI a {@link java.net.URI} object
32+
*/
33+
public AlternatorEndpointProvider(URI seedURI) {
34+
this(seedURI, "", "");
35+
}
2736

28-
public AlternatorEndpointProvider(URI seedURI, String datacenter, String rack) {
29-
futureCache = new ConcurrentHashMap<>();
30-
liveNodes = new AlternatorLiveNodes(seedURI, datacenter, rack);
31-
try {
32-
liveNodes.validate();
33-
liveNodes.checkIfRackAndDatacenterSetCorrectly();
34-
if (!datacenter.isEmpty() || !rack.isEmpty()) {
35-
if (!liveNodes.checkIfRackDatacenterFeatureIsSupported()) {
36-
logger.log(Level.SEVERE, String.format("server %s does not support rack or datacenter filtering", seedURI));
37-
}
38-
}
39-
} catch (AlternatorLiveNodes.ValidationError | AlternatorLiveNodes.FailedToCheck e) {
40-
throw new RuntimeException(e);
37+
/**
38+
* Constructor for AlternatorEndpointProvider.
39+
*
40+
* @param seedURI a {@link java.net.URI} object
41+
* @param datacenter a {@link java.lang.String} object
42+
* @param rack a {@link java.lang.String} object
43+
* @since 1.0.1
44+
*/
45+
public AlternatorEndpointProvider(URI seedURI, String datacenter, String rack) {
46+
futureCache = new ConcurrentHashMap<>();
47+
liveNodes = new AlternatorLiveNodes(seedURI, datacenter, rack);
48+
try {
49+
liveNodes.validate();
50+
liveNodes.checkIfRackAndDatacenterSetCorrectly();
51+
if (!datacenter.isEmpty() || !rack.isEmpty()) {
52+
if (!liveNodes.checkIfRackDatacenterFeatureIsSupported()) {
53+
logger.log(
54+
Level.SEVERE,
55+
String.format("server %s does not support rack or datacenter filtering", seedURI));
4156
}
42-
liveNodes.start();
43-
}
57+
}
58+
} catch (AlternatorLiveNodes.ValidationError | AlternatorLiveNodes.FailedToCheck e) {
59+
throw new RuntimeException(e);
60+
}
61+
liveNodes.start();
62+
}
4463

45-
@Override
46-
public CompletableFuture<Endpoint> resolveEndpoint(DynamoDbEndpointParams endpointParams) {
47-
URI uri = liveNodes.nextAsURI();
48-
CompletableFuture<Endpoint> endpoint = futureCache.getOrDefault(uri, null);
49-
if (endpoint != null) {
50-
return endpoint;
51-
}
52-
endpoint = new CompletableFuture<>();
53-
endpoint.complete(Endpoint.builder().url(uri).build());
54-
futureCache.put(uri, endpoint);
55-
return endpoint;
56-
}
64+
/** {@inheritDoc} */
65+
@Override
66+
public CompletableFuture<Endpoint> resolveEndpoint(DynamoDbEndpointParams endpointParams) {
67+
URI uri = liveNodes.nextAsURI();
68+
CompletableFuture<Endpoint> endpoint = futureCache.getOrDefault(uri, null);
69+
if (endpoint != null) {
70+
return endpoint;
71+
}
72+
endpoint = new CompletableFuture<>();
73+
endpoint.complete(Endpoint.builder().url(uri).build());
74+
futureCache.put(uri, endpoint);
75+
return endpoint;
76+
}
5777
}

0 commit comments

Comments
 (0)