Skip to content
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 user-defined properties to cursor position #744

Merged
merged 2 commits into from
Sep 8, 2017

Conversation

merlimat
Copy link
Contributor

@merlimat merlimat commented Sep 6, 2017

Motivation

Add user-defined properties that can be attached to a particular cursor position. The properties allows to attach store atomically some metadata along with a cursor position.

Wiki proposal with design doc:
https://github.com/apache/incubator-pulsar/wiki/PIP-6:-Guaranteed-Message-Deduplication

Modifications

  • Added new repeated field in ManagedCursor protobuf definition
  • markDelete() operations now accepts a Map<String, Long> that will be stored with the position
  • Added ManagedCursor.getProperties() to retrieve the properties after cursor recovery

@merlimat merlimat added the type/feature The PR added a new feature or issue requested a new feature label Sep 6, 2017
@merlimat merlimat added this to the 1.20.0-incubating milestone Sep 6, 2017
@merlimat merlimat self-assigned this Sep 6, 2017
@merlimat
Copy link
Contributor Author

merlimat commented Sep 7, 2017 via email

@@ -87,9 +90,10 @@

protected volatile PositionImpl markDeletePosition;
protected volatile PositionImpl readPosition;
private volatile PendingMarkDeleteEntry lastMarkDeleteEntry;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it necessary to introduce lastMarkDeleteEntry field in this PR?

The lastMarkDeleteEntry is important to guarantee that we are storing the
same couple of (mark-delete-pos, properties) together, even when we are
rolling over the ledger.

Yes, I removed comment to understand more. But using class PendingMarkDeleteEntry for markDeleteEntry is little confusing and hard to set the context. Should we create dedicated sub-class to store this tuple?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PendingMarkDeleteEntry is only a container for position plus other fields. I guess we could rename it into MarkDeleteEntry or similar.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we could rename it into MarkDeleteEntry or similar.

Yes, renaming would be also fine.

callback.deleteComplete(ctx);
return;
}

try {
internalAsyncMarkDelete(newMarkDeletePosition, new MarkDeleteCallback() {
internalAsyncMarkDelete(newMarkDeletePosition, Collections.emptyMap(), new MarkDeleteCallback() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are creating map even in case we don't need to store properties for cursor. Can we store it as null/Optional to avoid additional object creation (yes, it will add additional validation for null everywhere).?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Collections.emptyMap() always return the same static instance of an empty map.

@merlimat
Copy link
Contributor Author

merlimat commented Sep 7, 2017

@rdhabalia Renamed PendingMarkDeleteEntry into MarkDeleteEntry

Copy link
Contributor

@rdhabalia rdhabalia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature The PR added a new feature or issue requested a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants