make some method of ManagedLedger public
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.
@@ -209,7 +209,7 @@ public class ManagedLedgerImpl implements ManagedLedger, CreateCallback {
}
// define boundaries for position based seeks and searches
- enum PositionBound {
+ public enum PositionBound {
startIncluded, startExcluded
}
@@ -1727,7 +1727,7 @@ public class ManagedLedgerImpl implements ManagedLedger, CreateCallback {
return mbean;
}
- boolean hasMoreEntries(PositionImpl position) {
+ public boolean hasMoreEntries(PositionImpl position) {
PositionImpl lastPos = lastConfirmedEntry;
boolean result = position.compareTo(lastPos) <= 0;
if (log.isDebugEnabled()) {
@@ -2625,7 +2625,7 @@ public class ManagedLedgerImpl implements ManagedLedger, CreateCallback {
* 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;
@@ -2693,7 +2693,7 @@ public class ManagedLedgerImpl implements ManagedLedger, CreateCallback {
* 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);
}
@@ -2755,15 +2755,15 @@ public class ManagedLedgerImpl implements ManagedLedger, CreateCallback {
}
}
- 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);
@@ -2775,7 +2775,7 @@ public class ManagedLedgerImpl implements ManagedLedger, CreateCallback {
return nextPosition;
}
- PositionImpl getFirstPosition() {
+ public PositionImpl getFirstPosition() {
Long ledgerId = ledgers.firstKey();
if (ledgerId == null) {
return null;
