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

Issue 550: add readLastAddConfirmedAndEntry in ReadHandle for long poll read #729

Closed
wants to merge 6 commits into from

Conversation

zhaijack
Copy link
Contributor

Descriptions of the changes in this PR:
1, add a class LastAddConfirmedAndEntry and metnod readLastAddConfirmedAndEntry() in ReadHandle;
2, add implementation for readLastAddConfirmedAndEntry in LedgerHandler;
3, add testcase in BookKeeperApiTest;
4, remove un-used imports, break down long lines, fix wrong comments.


Be sure to do all of the following to help us incorporate your contribution
quickly and easily:

  • Make sure the PR title is formatted like:
    <Issue # or BOOKKEEPER-#>: Description of pull request
    e.g. Issue 123: Description ...
    e.g. BOOKKEEPER-1234: Description ...
  • Make sure tests pass via mvn clean apache-rat:check install findbugs:check.
  • Replace <Issue # or BOOKKEEPER-#> in the title with the actual Issue/JIRA number.

@asfgit
Copy link

asfgit commented Nov 15, 2017

FAILURE

--none--

* It is used for readLastAddConfirmedAndEntry.
*/
@Data
class LastConfirmedAndEntry {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is better that this class is not an inner class but a top level class

Copy link
Member

Choose a reason for hiding this comment

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

move it out of ReadHandle.java, make it an interface

interface LastConfirmedAndEntry extends AutoCloseable {

     long getLastAddConfirmed();

     boolean hasEntry();

     LedgerEntry getEntry();

}

create a class LastConfirmedAndEntryImpl to implement the interface.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @eolivelli @sijie , will change it.

*
* @param entryId
* next entry id to read
* @param timeOutInMillis
Copy link
Contributor

Choose a reason for hiding this comment

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

in case of THIS timeout the CompletableFuture will return null ? or is will be completed exceptionally ?

Copy link
Member

Choose a reason for hiding this comment

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

it will return null entry and latest lac on timeout.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. In LedgerHandle, most of the similar situation will return null.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a line which explains? That was my real request, sorry

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a line which explains? That was my real request, sorry

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. sure will add it.

@asfgit
Copy link

asfgit commented Nov 15, 2017

FAILURE

--none--

1 similar comment
@asfgit
Copy link

asfgit commented Nov 15, 2017

FAILURE

--none--

@@ -17,12 +17,12 @@
*/
package org.apache.bookkeeper.client;

import static org.apache.bookkeeper.client.LedgerHandle.LOG;
Copy link
Member

Choose a reason for hiding this comment

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

it is not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. It is originally there, this change adjust the order of importing, will handle it.

* It is used for readLastAddConfirmedAndEntry.
*/
@Data
class LastConfirmedAndEntry {
Copy link
Member

Choose a reason for hiding this comment

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

move it out of ReadHandle.java, make it an interface

interface LastConfirmedAndEntry extends AutoCloseable {

     long getLastAddConfirmed();

     boolean hasEntry();

     LedgerEntry getEntry();

}

create a class LastConfirmedAndEntryImpl to implement the interface.

*
* @param entryId
* next entry id to read
* @param timeOutInMillis
Copy link
Member

Choose a reason for hiding this comment

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

it will return null entry and latest lac on timeout.

@asfgit
Copy link

asfgit commented Nov 16, 2017

FAILURE

--none--

@@ -21,6 +21,7 @@
package org.apache.bookkeeper.client.api;

import java.util.concurrent.CompletableFuture;
import lombok.Data;
Copy link
Member

Choose a reason for hiding this comment

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

you don't this import

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right. will remove it.

}

/**
* {@inheritDoc }
Copy link
Member

Choose a reason for hiding this comment

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

no space before '}'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, will change it.

}

/**
* {@inheritDoc }
Copy link
Member

Choose a reason for hiding this comment

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

no space before '}'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, will change it.

}

/**
* {@inheritDoc }
Copy link
Member

Choose a reason for hiding this comment

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

no space before '}'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, will change it.

* This contains LastAddConfirmed entryId and a LedgerEntry wanted to read.
* It is used for readLastAddConfirmedAndEntry.
*/
public class LastConfirmedAndEntryImpl implements LastConfirmedAndEntry{
Copy link
Member

Choose a reason for hiding this comment

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

I think you can simplify this class using lombok. you don't need to write constructor and getters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. I got your idea, but since this is an implementation for interface, explict these method seems more easy to read.

* This contains LastAddConfirmed entryId and a LedgerEntry wanted to read.
* It is used for readLastAddConfirmedAndEntry.
*/
public class LastConfirmedAndEntryImpl implements LastConfirmedAndEntry{
Copy link
Member

Choose a reason for hiding this comment

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

space before '{'

@jvrao
Copy link
Contributor

jvrao commented Nov 16, 2017

LGTM

@asfgit
Copy link

asfgit commented Nov 16, 2017

FAILURE

--none--

Copy link
Member

@sijie sijie left a comment

Choose a reason for hiding this comment

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

LGTM.

@jiazhai can you address @eolivelli 's comment on timeoutMillis? then we can move forward.

@jiazhai
Copy link
Member

jiazhai commented Nov 17, 2017

@sijie , thanks. have added it.

@asfgit
Copy link

asfgit commented Nov 17, 2017

FAILURE

--none--

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

Sorry @jiazhai maybe the test could become flaky. Do you think we can enhance it

@ivankelly @sijie


// test readLastAddConfirmedAndEntry
LastConfirmedAndEntry lastConfirmedAndEntry =
result(reader.readLastAddConfirmedAndEntry(0, 999, false));
Copy link
Contributor

Choose a reason for hiding this comment

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

We have a 999 timeout less then 1 second. This test could be flaky.
Maybe we can do a loop until the condition is verified

Copy link
Member

Choose a reason for hiding this comment

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

@eolivelli Thanks.
This is only for test the interface works, There are other tests for the functionality of asyncReadLastConfirmedAndEntry().
Here it read an old entry, which has already been there, so ideally it need no wait time.

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

Sorry @jiazhai maybe the test could become flaky. Do you think we can enhance it

@ivankelly @sijie

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

+1 looks good

@sijie sijie added this to the 4.7.0 milestone Nov 20, 2017
@sijie sijie closed this in c9a1b8a Nov 20, 2017
sijie pushed a commit that referenced this pull request Nov 20, 2017
…oll read

Descriptions of the changes in this PR:
1, add a class LastAddConfirmedAndEntry and metnod readLastAddConfirmedAndEntry() in ReadHandle;
2, add implementation for readLastAddConfirmedAndEntry in LedgerHandler;
3, add testcase in BookKeeperApiTest;
4, remove un-used imports, break down long lines, fix wrong comments.

Author: Jia Zhai <zhaijia@apache.org>

Reviewers: Enrico Olivelli <eolivelli@gmail.com>, Sijie Guo <sijie@apache.org>, Venkateswararao Jujjuri (JV) <None>

This closes #729 from zhaijack/issue-550, closes #550

(cherry picked from commit c9a1b8a)
Signed-off-by: Sijie Guo <sijie@apache.org>
@sijie sijie modified the milestones: 4.7.0, 4.6.0 Nov 22, 2017
philipsu522 pushed a commit to philipsu522/bookkeeper that referenced this pull request Dec 8, 2017
…long poll read

Descriptions of the changes in this PR:
1, add a class LastAddConfirmedAndEntry and metnod readLastAddConfirmedAndEntry() in ReadHandle;
2, add implementation for readLastAddConfirmedAndEntry in LedgerHandler;
3, add testcase in BookKeeperApiTest;
4, remove un-used imports, break down long lines, fix wrong comments.

Author: Jia Zhai <zhaijia@apache.org>

Reviewers: Enrico Olivelli <eolivelli@gmail.com>, Sijie Guo <sijie@apache.org>, Venkateswararao Jujjuri (JV) <None>

This closes apache#729 from zhaijack/issue-550, closes apache#550
athanatos pushed a commit to athanatos/bookkeeper that referenced this pull request Jan 25, 2019
…by mistake during maven migration

Author: Fangmin Lyu <fangmin@apache.org>

Reviewers: andor@apache.org

Closes apache#729 from lvfangmin/ZOOKEEPER-3207
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants