adutra commented on code in PR #2962:
URL: https://github.com/apache/polaris/pull/2962#discussion_r2493598585
##########
runtime/service/src/main/java/org/apache/polaris/service/events/listeners/aws/cloudwatch/AwsCloudWatchEventListener.java:
##########
@@ -51,33 +55,55 @@
@ApplicationScoped
@Identifier("aws-cloudwatch")
-public class AwsCloudWatchEventListener extends PropertyMapEventListener {
+public class AwsCloudWatchEventListener extends AllEventsForwardingListener {
private static final Logger LOGGER =
LoggerFactory.getLogger(AwsCloudWatchEventListener.class);
- final ObjectMapper objectMapper = new ObjectMapper();
+ final ObjectMapper objectMapper;
private CloudWatchLogsAsyncClient client;
private final String logGroup;
private final String logStream;
private final Region region;
private final boolean synchronousMode;
private final Clock clock;
+ private final Set<Class<? extends PolarisEvent>> allowedEventTypes;
+ private final boolean listenToAllEvents;
@Inject CallContext callContext;
@Context SecurityContext securityContext;
@Inject
public AwsCloudWatchEventListener(
- AwsCloudWatchConfiguration config,
- Clock clock,
- PolarisIcebergObjectMapperCustomizer customizer) {
+ AwsCloudWatchConfiguration config, Clock clock, ObjectMapper mapper) {
this.logStream = config.awsCloudWatchLogStream();
this.logGroup = config.awsCloudWatchLogGroup();
this.region = Region.of(config.awsCloudWatchRegion());
this.synchronousMode = config.synchronousMode();
this.clock = clock;
- customizer.customize(this.objectMapper);
+ this.objectMapper = mapper;
+ this.allowedEventTypes = config.eventTypes().orElse(Set.of());
+ this.listenToAllEvents =
+ allowedEventTypes.isEmpty()
+ || allowedEventTypes.stream().anyMatch(c -> c ==
PolarisEvent.class);
+ }
+
+ @Override
+ protected boolean shouldHandle(PolarisEvent event) {
+ if (event == null) {
Review Comment:
nit: `event` will never be false here, this test is redundant.
##########
runtime/service/src/test/java/org/apache/polaris/service/events/listeners/aws/cloudwatch/AwsCloudWatchEventListenerTest.java:
##########
@@ -86,17 +92,22 @@ class AwsCloudWatchEventListenerTest {
private ExecutorService executorService;
private AutoCloseable mockitoContext;
+ private static final ObjectMapper objectMapper = new ObjectMapper();
Review Comment:
```suggestion
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
static {
new PolarisIcebergObjectMapperCustomizer(new
MemorySize(BigInteger.valueOf(1024 * 1024)))
.customize(OBJECT_MAPPER);
}
```
##########
runtime/service/src/test/java/org/apache/polaris/service/events/listeners/aws/cloudwatch/AwsCloudWatchEventListenerTest.java:
##########
@@ -309,17 +327,49 @@ void shouldSendEventInSynchronousMode() {
@Test
void ensureObjectMapperCustomizerIsApplied() {
Review Comment:
Unnecessary test. You are testing a Quarkus feature.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]