Skip to content

Commit e459a8d

Browse files
Bump com.arpnetworking.build:arpnetworking-parent-pom from 3.3.6 to 3.3.9 (#483)
* Bump com.arpnetworking.build:arpnetworking-parent-pom Bumps [com.arpnetworking.build:arpnetworking-parent-pom](https://github.com/arpnetworking/arpnetworking-parent-pom) from 3.3.6 to 3.3.9. - [Release notes](https://github.com/arpnetworking/arpnetworking-parent-pom/releases) - [Commits](ArpNetworking/arpnetworking-parent-pom@arpnetworking-parent-pom-3.3.6...arpnetworking-parent-pom-3.3.9) --- updated-dependencies: - dependency-name: com.arpnetworking.build:arpnetworking-parent-pom dependency-version: 3.3.9 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * spotbugs issues fixed --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Brandon Arp <[email protected]>
1 parent 73fc9aa commit e459a8d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+577
-35
lines changed

.junie/guidelines.md

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
# Metrics Cluster Aggregator Development Guidelines
2+
3+
This document provides guidelines and information for developers working on the Metrics Cluster Aggregator project.
4+
5+
## Build/Configuration Instructions
6+
7+
### Prerequisites
8+
9+
- **Java**: The project requires Java 17 or later. The project uses the Maven wrapper (`mvnw`) which will download the appropriate JDK version if needed.
10+
- **Docker**: Required for building and running integration tests.
11+
12+
### Building the Project
13+
14+
To build the project:
15+
16+
```bash
17+
./mvnw verify
18+
```
19+
20+
To build without running tests:
21+
22+
```bash
23+
./mvnw package -DskipTests
24+
```
25+
26+
To install the project locally:
27+
28+
```bash
29+
./mvnw install
30+
```
31+
32+
### Docker Build
33+
34+
The project includes Docker support. To build the Docker image:
35+
36+
```bash
37+
./mvnw package docker:build
38+
```
39+
40+
### Debugging
41+
42+
To debug the server during run on port 9000:
43+
44+
```bash
45+
./mvnw -Ddebug=true docker:start
46+
```
47+
48+
To debug the server during integration tests on port 9000:
49+
50+
```bash
51+
./mvnw -Ddebug=true verify
52+
```
53+
54+
## Testing Information
55+
56+
### Testing Framework
57+
58+
The project uses:
59+
- JUnit 4 for unit testing
60+
- Mockito for mocking
61+
- Hamcrest for assertions
62+
- Pekko TestKit for testing actors
63+
64+
### Running Tests
65+
66+
To run all tests:
67+
68+
```bash
69+
./mvnw test
70+
```
71+
72+
To run a specific test:
73+
74+
```bash
75+
./mvnw test -Dtest=ClassName
76+
```
77+
78+
### Writing Tests
79+
80+
1. **Unit Tests**: Place in `src/test/java` following the same package structure as the main code.
81+
2. **Actor Tests**: Extend `BaseActorTest` which provides an ActorSystem and Mockito initialization.
82+
3. **Test Naming**: Use descriptive names that indicate what is being tested.
83+
4. **Assertions**: Use Hamcrest matchers with `assertThat()` for readable assertions.
84+
85+
### Example Test
86+
87+
Here's a simple example of a test class:
88+
89+
```java
90+
package com.arpnetworking.utility;
91+
92+
import org.hamcrest.Matchers;
93+
import org.junit.Test;
94+
95+
import static org.hamcrest.MatcherAssert.assertThat;
96+
97+
public class StringUtilsTest {
98+
99+
@Test
100+
public void testReverseWithNormalString() {
101+
final String input = "hello";
102+
final String expected = "olleh";
103+
final String result = StringUtils.reverse(input);
104+
assertThat(result, Matchers.equalTo(expected));
105+
}
106+
107+
@Test
108+
public void testReverseWithEmptyString() {
109+
final String input = "";
110+
final String expected = "";
111+
final String result = StringUtils.reverse(input);
112+
assertThat(result, Matchers.equalTo(expected));
113+
}
114+
115+
@Test
116+
public void testReverseWithNullString() {
117+
final String input = null;
118+
final String result = StringUtils.reverse(input);
119+
assertThat(result, Matchers.nullValue());
120+
}
121+
}
122+
```
123+
124+
## Code Style and Development Practices
125+
126+
### Code Style
127+
128+
1. **Builder Pattern**: Use the `OvalBuilder` for creating objects with many parameters.
129+
2. **Immutability**: Use immutable collections (Guava's `ImmutableList`, `ImmutableSet`, etc.) and final fields.
130+
3. **Validation**: Use Oval for validation with annotations like `@NotNull`, `@NotEmpty`, and `@Range`.
131+
4. **Optional Values**: Use `Optional<T>` for values that might be absent.
132+
5. **Field Naming**: Private fields are prefixed with underscore (e.g., `_fieldName`).
133+
6. **Parameters**: Method parameters should be marked as `final`.
134+
7. **toString()**: Use `MoreObjects.toStringHelper` for implementing `toString()` methods.
135+
8. **Time Values**: Use `Duration` for representing time values.
136+
137+
### Documentation
138+
139+
1. **JavaDoc**: All public classes and methods should have JavaDoc comments.
140+
2. **License Header**: All source files should include the Apache 2.0 license header.
141+
142+
### Project Structure
143+
144+
1. **Package Organization**: Code is organized by functionality in packages.
145+
2. **Configuration**: Configuration is handled through JSON or HOCON files.
146+
3. **Actors**: The project uses Pekko (formerly Akka) for the actor system.
147+
148+
### Dependency Injection
149+
150+
The project uses Guice for dependency injection.
151+
152+
### Logging
153+
154+
The project uses SLF4J with Logback for logging.
155+
156+
## Additional Development Information
157+
158+
### Metrics
159+
160+
The project uses the Metrics Client library for collecting and reporting metrics.
161+
162+
### Configuration
163+
164+
The application configuration is specified in JSON or HOCON format. Key configuration files:
165+
166+
1. **Main Configuration**: Specifies system settings like ports, hosts, and timeouts.
167+
2. **Pipeline Configuration**: Defines the data processing pipeline for host and cluster statistics.
168+
169+
### Pekko Configuration
170+
171+
Pekko (formerly Akka) configuration is specified in the main configuration file under the `pekkoConfiguration` key.
172+
173+
### Database Support
174+
175+
The project supports multiple database configurations through the `databaseConfigurations` setting.
176+
177+
### Deployment
178+
179+
The project can be deployed as:
180+
1. A standalone application
181+
2. A Docker container
182+
3. An RPM package (using the `rpm` profile)

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<parent>
1919
<groupId>com.arpnetworking.build</groupId>
2020
<artifactId>arpnetworking-parent-pom</artifactId>
21-
<version>3.3.6</version>
21+
<version>3.3.9</version>
2222
<relativePath />
2323
</parent>
2424

spotbugs.exclude.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,33 @@
2929
</Or>
3030
</Match>
3131

32+
<!-- Match THROWS_METHOD_THROWS_RUNTIMEEXCEPTION violations. We commonly
33+
use runtime exceptions with lambdas, streams, and promises to indicate
34+
failure
35+
-->
36+
<Match>
37+
<Bug pattern="THROWS_METHOD_THROWS_RUNTIMEEXCEPTION" />
38+
</Match>
39+
40+
<!-- We often throw Exception in tests to indicate an error. The exception itself is the point, not how to handle it
41+
-->
42+
<Match>
43+
<Or>
44+
<Bug pattern="THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION" />
45+
<Bug pattern="DE_MIGHT_IGNORE" />
46+
</Or>
47+
<Or>
48+
<Class name="~.*\.[^\.]+Test" />
49+
<Class name="~.*\.[^\.]+Test\$.*" />
50+
<Class name="~.*\.[^\.]+TestPerf" />
51+
<Class name="~.*\.[^\.]+TestPerf\$.*" />
52+
<Class name="~.*\.[^\.]+IT" />
53+
<Class name="~.*\.[^\.]+IT\$.*" />
54+
<Class name="~.*\.[^\.]+ITPerf" />
55+
<Class name="~.*\.[^\.]+ITPerf\$.*" />
56+
</Or>
57+
</Match>
58+
3259
<!-- Match all RV_RETURN_VALUE_IGNORED_BAD_PRACTICE violations on all unit
3360
test files since Mockito usage can cause this violation when stating
3461
expectations.
@@ -57,6 +84,7 @@
5784
<Bug pattern="CI_CONFUSED_INHERITANCE" />
5885
<Bug pattern="MS_SHOULD_BE_FINAL" />
5986
<Bug pattern="NP_NONNULL_PARAM_VIOLATION" />
87+
<Bug pattern="AT_NONATOMIC_OPERATIONS_ON_SHARED_VARIABLE" />
6088
</Or>
6189
<Or>
6290
<Class name="~com\.arpnetworking\.clusteraggregator\.models\.ebean.*" />

src/main/java/com/arpnetworking/clusteraggregator/GracefulShutdownActor.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import com.arpnetworking.steno.LoggerFactory;
2222
import com.google.inject.Inject;
2323
import com.google.inject.name.Named;
24-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
2524
import org.apache.pekko.actor.AbstractActor;
2625
import org.apache.pekko.actor.ActorRef;
2726
import org.apache.pekko.actor.ActorSystem;
@@ -50,7 +49,6 @@ public class GracefulShutdownActor extends AbstractActor {
5049
* @param ingestActor ingest actor
5150
*/
5251
@Inject
53-
@SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR", justification = "Context is safe to use in constructor.")
5452
public GracefulShutdownActor(
5553
@Named("aggregator-shard-region") final ActorRef shardRegion,
5654
@Named("host-emitter") final ActorRef hostEmitter,

src/main/java/com/arpnetworking/clusteraggregator/Status.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import com.arpnetworking.steno.Logger;
2323
import com.arpnetworking.steno.LoggerFactory;
2424
import com.arpnetworking.utility.CastMapper;
25-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
2625
import org.apache.pekko.actor.AbstractActor;
2726
import org.apache.pekko.actor.ActorRef;
2827
import org.apache.pekko.actor.Props;
@@ -58,7 +57,6 @@ public class Status extends AbstractActor {
5857
* @param clusterStatusCache The actor holding the cached cluster status.
5958
* @param localMetrics The actor holding the local node metrics.
6059
*/
61-
@SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR", justification = "context is safe to be used in constructors")
6260
public Status(
6361
final Cluster cluster,
6462
final ActorRef clusterStatusCache,

src/main/java/com/arpnetworking/clusteraggregator/aggregation/AggregationRouter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ public static Props props(
8383
* @param periodicMetrics The {@link PeriodicMetrics} instance.
8484
*/
8585
@Inject
86-
@SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR", justification = "context is safe to be used in constructors")
8786
public AggregationRouter(
8887
@Named("periodic-statistics") final ActorRef periodicStatistics,
8988
@Named("cluster-emitter") final ActorRef emitter,
@@ -139,6 +138,7 @@ public void postStop() {
139138
}
140139

141140
@Override
141+
@SuppressFBWarnings(value = "THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION", justification = "Exception is thrown by super method")
142142
public void preRestart(final Throwable reason, final Optional<Object> message) throws Exception {
143143
_periodicMetrics.recordCounter("actors/aggregation_router/restarted", 1);
144144
LOGGER.error()

src/main/java/com/arpnetworking/clusteraggregator/aggregation/StreamingAggregator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ public static Props props(
100100
* @param periodicMetrics The {@link PeriodicMetrics} instance.
101101
*/
102102
@Inject
103-
@SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR", justification = "context is safe to be used in constructors")
104103
public StreamingAggregator(
105104
@Named("periodic-statistics") final ActorRef periodicStatistics,
106105
@Named("cluster-emitter") final ActorRef emitter,
@@ -209,6 +208,7 @@ public void postStop() {
209208
}
210209

211210
@Override
211+
@SuppressFBWarnings(value = "THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION", justification = "Exception is thrown by super method")
212212
public void preRestart(final Throwable reason, final Optional<Object> message) throws Exception {
213213
_periodicMetrics.recordCounter("actors/streaming_aggregator/restarted", 1);
214214
LOGGER.error()

src/main/java/com/arpnetworking/clusteraggregator/aggregation/package-info.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@
1414
* limitations under the License.
1515
*/
1616

17+
/**
18+
* Package containing components for metrics data aggregation.
19+
* <p>
20+
* This package provides classes that handle the aggregation of metrics data
21+
* across a cluster, including routing of aggregation messages, extraction of
22+
* message data, and streaming aggregation of metrics. These components form
23+
* the core aggregation functionality of the cluster aggregator service.
24+
* </p>
25+
*
26+
* @author Inscope Metrics
27+
*/
1728
@ParametersAreNonnullByDefault
1829
@ReturnValuesAreNonnullByDefault
1930
package com.arpnetworking.clusteraggregator.aggregation;

src/main/java/com/arpnetworking/clusteraggregator/client/AggClientConnection.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import com.google.common.collect.ImmutableList;
3030
import com.google.common.collect.ImmutableMap;
3131
import com.google.protobuf.GeneratedMessage;
32-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
3332
import org.apache.pekko.actor.AbstractActor;
3433
import org.apache.pekko.actor.ActorRef;
3534
import org.apache.pekko.actor.Props;
@@ -78,7 +77,6 @@ public static Props props(
7877
* @param maxConnectionAge The maximum duration to keep a connection open before cycling it.
7978
* @param calculateAggregates True to compute cluster aggregations, false to only publish host aggregations
8079
*/
81-
@SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR", justification = "context is safe to be used in constructors")
8280
public AggClientConnection(
8381
final ActorRef connection,
8482
final InetSocketAddress remote,

src/main/java/com/arpnetworking/clusteraggregator/client/AggClientServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void preStart() throws Exception {
6767
}
6868

6969
@Override
70-
public void onReceive(final Object message) throws Exception {
70+
public void onReceive(final Object message) {
7171
if (message instanceof Tcp.Bound) {
7272
final Tcp.Bound bound = (Tcp.Bound) message;
7373
LOGGER.debug()

0 commit comments

Comments
 (0)