Skip to content

Commit

Permalink
make some method of ManagedLedger public (apache#5472)
Browse files Browse the repository at this point in the history
Some of the ManagedLedger methods, such as hasMoreEntries/getPreviousPosition/getNextValidPosition, are protected. This change try to make them public.
These methods are useful when user want to do some advanced operation in Data Processing.
  • Loading branch information
jiazhai authored Oct 28, 2019
1 parent 6fb5fd2 commit 89e3f30
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ enum State {
}

// define boundaries for position based seeks and searches
enum PositionBound {
public enum PositionBound {
startIncluded, startExcluded
}

Expand Down Expand Up @@ -1727,7 +1727,7 @@ public ManagedLedgerMXBean getStats() {
return mbean;
}

boolean hasMoreEntries(PositionImpl position) {
public boolean hasMoreEntries(PositionImpl position) {
PositionImpl lastPos = lastConfirmedEntry;
boolean result = position.compareTo(lastPos) <= 0;
if (log.isDebugEnabled()) {
Expand Down Expand Up @@ -2625,7 +2625,7 @@ long getNumberOfEntries(Range<PositionImpl> range) {
* specifies whether or not to include the start position in calculating the distance
* @return the new position that is n entries ahead
*/
PositionImpl getPositionAfterN(final PositionImpl startPosition, long n, PositionBound startRange) {
public PositionImpl getPositionAfterN(final PositionImpl startPosition, long n, PositionBound startRange) {
long entriesToSkip = n;
long currentLedgerId;
long currentEntryId;
Expand Down Expand Up @@ -2693,7 +2693,7 @@ PositionImpl getPositionAfterN(final PositionImpl startPosition, long n, Positio
* the current position
* @return the previous position
*/
PositionImpl getPreviousPosition(PositionImpl position) {
public PositionImpl getPreviousPosition(PositionImpl position) {
if (position.getEntryId() > 0) {
return PositionImpl.get(position.getLedgerId(), position.getEntryId() - 1);
}
Expand Down Expand Up @@ -2755,15 +2755,15 @@ boolean isValidPosition(PositionImpl position) {
}
}

boolean ledgerExists(long ledgerId) {
public boolean ledgerExists(long ledgerId) {
return ledgers.get(ledgerId) != null;
}

Long getNextValidLedger(long ledgerId) {
public Long getNextValidLedger(long ledgerId) {
return ledgers.ceilingKey(ledgerId + 1);
}

PositionImpl getNextValidPosition(final PositionImpl position) {
public PositionImpl getNextValidPosition(final PositionImpl position) {
PositionImpl nextPosition = position.getNext();
while (!isValidPosition(nextPosition)) {
Long nextLedgerId = ledgers.ceilingKey(nextPosition.getLedgerId() + 1);
Expand All @@ -2775,7 +2775,7 @@ PositionImpl getNextValidPosition(final PositionImpl position) {
return nextPosition;
}

PositionImpl getFirstPosition() {
public PositionImpl getFirstPosition() {
Long ledgerId = ledgers.firstKey();
if (ledgerId == null) {
return null;
Expand Down

0 comments on commit 89e3f30

Please sign in to comment.