eric-maynard commented on code in PR #1844: URL: https://github.com/apache/polaris/pull/1844#discussion_r2223103043
########## persistence/relational-jdbc/src/main/resources/h2/schema-v1.sql: ########## @@ -118,3 +118,17 @@ CREATE TABLE IF NOT EXISTS policy_mapping_record ( ); CREATE INDEX IF NOT EXISTS idx_policy_mapping_record ON policy_mapping_record (realm_id, policy_type_code, policy_catalog_id, policy_id, target_catalog_id, target_id); + +CREATE TABLE IF NOT EXISTS events ( Review Comment: Why are we changing v1 of this schema? ########## persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/models/ModelEvent.java: ########## @@ -0,0 +1,142 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.persistence.relational.jdbc.models; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import org.apache.polaris.core.entity.PolarisEvent; +import org.apache.polaris.immutables.PolarisImmutable; +import org.apache.polaris.persistence.relational.jdbc.DatabaseType; + +@PolarisImmutable +public interface ModelEvent extends Converter<PolarisEvent> { + String TABLE_NAME = "EVENTS"; + + List<String> ALL_COLUMNS = + List.of( + "catalog_id", + "event_id", + "request_id", + "event_type", + "timestamp_ms", + "principal_name", + "resource_type", + "resource_identifier", + "additional_parameters"); Review Comment: `properties`? ########## polaris-core/src/main/java/org/apache/polaris/core/PolarisCallContext.java: ########## @@ -44,22 +46,34 @@ public class PolarisCallContext implements CallContext { private final Clock clock; + // A request ID to identify this REST request + private final String requestId; + private final RealmContext realmContext; private final RealmConfig realmConfig; + private static final String REQUEST_ID_KEY = "requestId"; + public PolarisCallContext( @Nonnull RealmContext realmContext, @Nonnull BasePersistence metaStore, @Nonnull PolarisDiagnostics diagServices, @Nonnull PolarisConfigurationStore configurationStore, - @Nonnull Clock clock) { + @Nonnull Clock clock, + ContainerRequestContext containerRequestContext) { Review Comment: Can this just be injected independently instead of bundling it with the callcontext? ########## polaris-core/src/main/java/org/apache/polaris/core/entity/PolarisEvent.java: ########## @@ -0,0 +1,135 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.core.entity; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.util.Map; + +public class PolarisEvent { Review Comment: Is this intended to match Iceberg events? Having two types called `PolarisEvent` seems confusing. ########## runtime/service/src/main/java/org/apache/polaris/service/quarkus/events/QuarkusPolarisEventListenerConfiguration.java: ########## @@ -20,13 +20,23 @@ import io.quarkus.runtime.annotations.StaticInitSafe; import io.smallrye.config.ConfigMapping; +import java.time.Duration; +import java.util.Optional; +import org.apache.polaris.service.events.EventListenerConfiguration; +import org.apache.polaris.service.events.listeners.PolarisEventListener; @StaticInitSafe @ConfigMapping(prefix = "polaris.event-listener") -public interface QuarkusPolarisEventListenerConfiguration { +public interface QuarkusPolarisEventListenerConfiguration extends EventListenerConfiguration { Review Comment: Same as the cloudwatch PR, these properties can be pulled into a config specific to this listener ########## service/common/src/main/java/org/apache/polaris/service/ratelimiter/RateLimiterFilter.java: ########## @@ -56,7 +58,11 @@ public void filter(ContainerRequestContext ctx) throws IOException { if (!rateLimiter.canProceed()) { polarisEventListener.onBeforeRequestRateLimited( new BeforeRequestRateLimitedEvent( - ctx.getMethod(), ctx.getUriInfo().getAbsolutePath().toString())); + PolarisEvent.createEventId(), + ctx.getMethod(), + ctx.getUriInfo().getAbsolutePath().toString()), + CallContext.getCurrentContext(), + ctx.getSecurityContext()); ctx.abortWith(Response.status(Response.Status.TOO_MANY_REQUESTS).build()); Review Comment: > If it helps - I can confirm, I will not be attempting to persist this event in this event listener implementation. I find this comment confusing -- what's the point of this implementation, then? Isn't it to persist all the events in the metastore? -- 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]
