-
Notifications
You must be signed in to change notification settings - Fork 298
Add Events for PolarisServiceImpl APIs #1904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Events for PolarisServiceImpl APIs #1904
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! This isn't all the new events we'll need to add but it's a good start.
@eric-maynard - any way to retrigger the tests? Seems like it failed on a processing step unrelated to the changes. |
This PR received a lot of comments, should wait for @adutra's review as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change exposes secrets to event listeners, which is quite concerning.
I've posted a bunch of comments for discussion about the approach on the dev-ML.
service/common/src/main/java/org/apache/polaris/service/events/AfterCatalogGetEvent.java
Outdated
Show resolved
Hide resolved
service/common/src/main/java/org/apache/polaris/service/events/AfterCredentialsRotateEvent.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still LGTM, and the secrets are gone from the events now which is good
@snazy are there still changes you'd like to see here? |
Yea, I think we should simplify and enhance the API, as proposed on dev@ |
@snazy - I've replied on the referenced email thread >2 weeks ago but there is not any response to any of the comments on the thread since then. If you have a hard opinion on this, can you please reply to the email thread to keep this work moving forward? If there is not a hard opinion, I will continue pushing to get this PR merged as-is. |
My impression was that you're working on the proposed ideas. My (hard) opinion on this is that we have to allow event listeners to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we have all the records in one class ?
The current events aren't all in one file, so while I think grouping them that way is fine we should be consistent. IIUC association* of different events is possible (and intended) on the EventListener side. |
Agreed, I can do this in the next round of revisions. But am waiting for the followup meeting regarding events to put further work in on this PR.
This is correct as well. @snazy - does that resolve your concerns? |
Thanks for removing the secrets. But I still believe that it can be simplified, and have the currently missing the failure notifications. I've proposed a way to achieve this using Java pseudo code on the dev-ML. Adding it here as well below. public interface EventListener {
/**
* "Dummy event foo" about to happen, with parameters x + y, no additional information collected
* for "after the fact".
*/
InFlightVoid beforeEventFoo(String x, int y);
/** About to commit to an Iceberg table. */
InFlight<IcebergTableCommitted> beforeIcebergTableCommit(UpdateTableRequest updateTableRequest);
}
public interface InFlight<SUCCESS_PAYLOAD> {
/** Called "after the fact". */
void success(SUCCESS_PAYLOAD payload);
/** Potentially called "after the fact" in case of a failure. */
void failure(Throwable throwable);
/** Potentially called "after the fact" in case of a failure. */
void failure(String reason);
}
/** Convenience for events that do not have a success-payload. */
public interface InFlightVoid extends InFlight<Void> {
default void success() {
success(null);
}
}
/** Success-payload for table-committed. */
public record IcebergTableCommitted(TableMetadata originalState, TableMetadata newState) {} Example for a simple event "foo", w/o a success-payload: public interface Foo {
void doFoo();
}
class FooImpl implements Foo {
EventListener eventListener;
@Override
public void doFoo() {
InFlightVoid event = eventListener.beforeEventFoo("foo", 42);
try {
// do foo stuff
event.success();
} catch (Exception x) {
event.failure(x);
}
}
} Example for table committed, with update-request, before and after states. Up to the event listener implementation which parts are consumed. public interface Commit {
void doCommit(UpdateTableRequest updateTableRequest);
}
class CommitImpl implements Commit {
EventListener eventListener;
@Override
public void doCommit(UpdateTableRequest updateTableRequest) {
InFlight<IcebergTableCommitted> event =
eventListener.beforeIcebergTableCommit(updateTableRequest);
try {
// do table commit
TableMetadata previousTableMetadata = ...;
if (somePreconditionFailed) {
event.failure("Precondition xyz failed");
return;
}
TableMetadata updatedTableMetadata = ...;
event.success(new IcebergTableCommitted(previousTableMetadata, updatedTableMetadata));
} catch (Exception x) {
event.failure(x);
}
}
} |
Further discussion on stateful event handling is on the Dev ML. |
Closed in favor of #2482. |
Adding instrumentation for events for all events defined in
PolarisServiceImpl.java
. Not all events will be useful and/or necessary - but allow users to plug in with custom event listeners for any of these APIs. The default event listener is a no-op.The main file to review here is
PolarisServiceImpl
. All new events are simply just a constructor and getter methods.