Skip to content

Commit 7910075

Browse files
committed
Introducing changes to enable forwarding of Polaris events to AWS CloudWatch
1 parent 1a5e37c commit 7910075

File tree

10 files changed

+1080
-69
lines changed

10 files changed

+1080
-69
lines changed

runtime/defaults/src/main/resources/application.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ polaris.event-listener.type=no-op
144144
# polaris.event-listener.aws-cloudwatch.log-stream=polaris-cloudwatch-default-stream
145145
# polaris.event-listener.aws-cloudwatch.region=us-east-1
146146
# polaris.event-listener.aws-cloudwatch.synchronous-mode=false
147+
# polaris.event-listener.aws-cloudwatch.event-types= // the absence of this property would result if processing all Polaris event types.
147148

148149
polaris.log.request-id-header-name=Polaris-Request-Id
149150
# polaris.log.mdc.aid=polaris

runtime/service/src/main/java/org/apache/polaris/service/config/PolarisIcebergObjectMapperCustomizer.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@
3030
import io.smallrye.config.WithConverter;
3131
import jakarta.inject.Inject;
3232
import jakarta.inject.Singleton;
33+
import org.apache.iceberg.catalog.Namespace;
34+
import org.apache.iceberg.catalog.TableIdentifier;
3335
import org.apache.iceberg.rest.RESTSerializers;
36+
import org.apache.polaris.service.events.PolarisEvent;
37+
import org.apache.polaris.service.events.json.mixins.IcebergMixins;
38+
import org.apache.polaris.service.events.json.mixins.PolarisEventBaseMixin;
3439
import org.eclipse.microprofile.config.inject.ConfigProperty;
3540
import org.slf4j.Logger;
3641
import org.slf4j.LoggerFactory;
@@ -56,6 +61,10 @@ public void customize(ObjectMapper objectMapper) {
5661
objectMapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
5762
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
5863
objectMapper.setPropertyNamingStrategy(new PropertyNamingStrategies.KebabCaseStrategy());
64+
objectMapper.addMixIn(PolarisEvent.class, PolarisEventBaseMixin.class);
65+
objectMapper.addMixIn(TableIdentifier.class, IcebergMixins.TableIdentifierMixin.class);
66+
objectMapper.addMixIn(Namespace.class, IcebergMixins.NamespaceMixin.class);
67+
5968
RESTSerializers.registerAll(objectMapper);
6069
Serializers.registerSerializers(objectMapper);
6170
objectMapper
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.polaris.service.events.json.mixins;
21+
22+
import com.fasterxml.jackson.annotation.JsonProperty;
23+
import org.apache.iceberg.catalog.Namespace;
24+
25+
/** Mixins for Iceberg classes we don't control, to keep JSON concise. */
26+
public final class IcebergMixins {
27+
28+
// Private constructor to prevent instantiation
29+
private IcebergMixins() {}
30+
31+
/** Serializes Namespace as an object like: "namespace": ["sales", "north.america"] */
32+
public abstract static class NamespaceMixin {
33+
@JsonProperty("namespace")
34+
public abstract String[] levels();
35+
}
36+
37+
/**
38+
* Serializes TableIdentifier as a scalar string like: {"namespace": ["sales", "north.america"],
39+
* "name": "transactions"}
40+
*/
41+
public abstract static class TableIdentifierMixin {
42+
@JsonProperty("namespace")
43+
public abstract Namespace namespace();
44+
45+
@JsonProperty("name")
46+
public abstract String name();
47+
}
48+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.polaris.service.events.json.mixins;
21+
22+
import com.fasterxml.jackson.annotation.JsonInclude;
23+
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
24+
import com.fasterxml.jackson.databind.annotation.JsonNaming;
25+
26+
@JsonInclude(JsonInclude.Include.NON_NULL)
27+
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
28+
public abstract class PolarisEventBaseMixin {}

runtime/service/src/main/java/org/apache/polaris/service/events/jsonEventListener/PropertyMapEventListener.java

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)