-
Notifications
You must be signed in to change notification settings - Fork 909
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 isSealed()
to ReadHandle
#765
Comments
This is required for distributedlog to implement streaming/tailing reads in apache/distributedlog#239 |
|
Updating the tutorial is blocked on this. |
|
Do we want all the syntactic sugar of autoclosable though? Surely sealing a ledger should be an intentional action, not a sideeffect of an exception being thrown. |
Also, WriteHandle#close is inherited from Handle, so its definition isn't that clear. All handles are closable, so why do some of them mutate. I'd probably keep the close on WriteHandle, for resource cleanup, but move sealing to another method. |
I am not sure is there a strong reason to make this change. because separating this to a method means user can close a ledger without sealing. I would suggest we should have one simple close for WriteHandle. regarding javadoc, we can update the javadoc for #close() to be more explicitly. |
I'm ok with keeping just #close/asyncClose, but in that case, close should only be part of WriteHandle. The reason I suggested keeping #close and #seal is in case we ever do need to free resources in all handles, we already have #close being called, but maybe that doesn't make sense. |
isClosed()
to WriteHandle and ReadHandleisSealed()
to ReadHandle
Also, asyncClose and close in Handle are a completely different pattern to the rest of the calls. There's no asyncX and X for everything else. They just return a future. #close/#seal should follow the same pattern. It seems like we jump through a lot of hoops just to get AutoCloseable, when the value of AutoCloseable for this is questionable. I think part of the motivation for have a close is that things are called Handle, and this is suggesting that LedgerHandle/WriteHandle/ReadHandle actually hold on to resources somewhere else (like how a FileHandle holds a file descriptor), and it also suggests that when we are finished with *Handle the resource needs to be freed. However, this is not the case for any of the Handle types. They just bundle a bunch of integers together to allow us to read/write. They're contexts more than anything. |
@ivankelly ReadOnlyLedgerHandle need to release listener registered at ledger manager. so we need close at ReadHandle. I am not sure what you are trying to propose in the last comment. Are you suggesting renaming the API from Handle to something else? |
@sijie If we need #close on all Handle, then there's no need for rename, but I was going to propose renaming WriteHandle -> LedgerWriter and ReadHandle ->LedgerReader. There's still in inconsistency of #asyncClose and all other methods. I think i'd prefer to remove asyncClose, leave close as autoclosable, and add a method to WriteHandle.
Especially if were going to rename isClosed to isSealed. I don't think there's a problem of people calling #close without sealing. If it happens, the writer will start writing to the next ledger, but tailers will block waiting for the previous ledger to be sealed. This should be fairly obvious, and quickly fixed. In any case, there's no risk of data corruption. |
okay I will change I am not sure we want to do this rename here. I don't see it is necessary. but if you do have a strong feeling, please make a BP and bring it to mailing list. because current set of API was proposed by Enrico and reviewed before. so if we are going to make the rename change, we need another BP to review it. regarding seal and close, my take is - this is fairly clear to people. I don't think there is a real need to split this into two methods of seal() and close() -- to me it is complicating the usage of WriteHandle. However @eolivelli might have a different opinion, since he is the original interface proposer. |
I'll create a BP. There's a couple of issues with API that should be
addressed.
…On Wed, Nov 29, 2017 at 11:29 AM, Sijie Guo ***@***.***> wrote:
okay I will change isSealed back to isClosed.
I am not sure we want to do this rename here. I don't see it is necessary.
but if you do have a strong feeling, please make a BP and bring it to
mailing list. because current set of API was proposed by Enrico and
reviewed before. so if we are going to make the rename change, we need
another BP to review it.
regarding seal and close, my take is - this is fairly clear to people. I
don't think there is a real need to split this into two methods of seal()
and close() -- to me it is complicating the usage of WriteHandle. However
@eolivelli <https://github.com/eolivelli> might have a different opinion,
since he is the original interface proposer.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#765 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADWq5wRTyNJKEm_CAS6w5hLFTuA9gAEks5s7UAWgaJpZM4QoNlw>
.
|
@sijie @ivankelly For "isClosed()", as an user I would expect that Object.isClosed() will return true if I have called Object.close() not if someone else (from another application/JVM/network...) have "sealed" the ledger, so that no new entry is expected. |
Anyhow, I'll create a BP. |
@sijie @eolivelli could you check #760 again, so I can create the BP using the new workflow. |
Descriptions of the changes in this PR: add `isClosed` to ReadHandle, so distributedlog can use this for implementing readers. Author: Sijie Guo <[email protected]> Reviewers: Jia Zhai <None> This closes #786 from sijie/is_sealed, closes #765 (cherry picked from commit 64650cf) Signed-off-by: Jia Zhai <[email protected]>
The new API is missing
isClosed()
on handles. It is hard to learn whether a ledger is closed or not for tailing-read applications.blocker
N/A
The text was updated successfully, but these errors were encountered: