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

Persist individually deleted messages #276

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Code review fixes
  • Loading branch information
merlimat committed Mar 9, 2017
commit 54907709587c8c0b29332b7cb2da7c3e8f2cf98d
7 changes: 7 additions & 0 deletions conf/broker.conf
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,13 @@ managedLedgerCursorMaxEntriesPerLedger=50000
# Max time before triggering a rollover on a cursor ledger
managedLedgerCursorRolloverTimeInSeconds=14400

# Max number of "acknowledgment holes" that are going to be persistently stored.
# When acknowledging out of order, a consumer will leave holes that are supposed
# to be quickly filled by acking all the messages. The information of which
# messages are acknowledged is persisted by compressing in "ranges" of messages
# that were acknowledged. After the max number of ranges is reached, the information
# will only be tracked in memory and messages will be redelivered in case of
# crashes.
managedLedgerMaxUnackedRangesToPersist=1000
Copy link
Contributor

Choose a reason for hiding this comment

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

should we add the documentation?

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, we should



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
*/
package org.apache.bookkeeper.mledger;

import com.google.common.annotations.Beta;
import java.util.List;
import java.util.Set;

import org.apache.bookkeeper.mledger.AsyncCallbacks.ClearBacklogCallback;
import org.apache.bookkeeper.mledger.AsyncCallbacks.DeleteCallback;
import org.apache.bookkeeper.mledger.AsyncCallbacks.FindEntryCallback;
Expand All @@ -24,10 +26,8 @@
import org.apache.bookkeeper.mledger.AsyncCallbacks.ReadEntryCallback;
import org.apache.bookkeeper.mledger.AsyncCallbacks.SkipEntriesCallback;


import java.util.List;
import java.util.Set;
import java.util.function.Predicate;
import com.google.common.annotations.Beta;
import com.google.common.base.Predicate;

/**
* A ManangedCursor is a persisted cursor inside a ManagedLedger.
Expand Down Expand Up @@ -326,7 +326,7 @@ public void asyncSkipEntries(int numEntriesToSkip, IndividualDeletedEntries dele
* opaque context
*/
public void asyncFindNewestMatching(FindPositionConstraint constraint, Predicate<Entry> condition,
FindEntryCallback callback, Object ctx);
FindEntryCallback callback, Object ctx);

/**
* reset the cursor to specified position to enable replay of messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import org.apache.bookkeeper.client.AsyncCallback.CloseCallback;
Expand Down Expand Up @@ -65,6 +64,7 @@
import org.slf4j.LoggerFactory;

import com.google.common.base.Objects;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
import com.google.common.collect.Range;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
*/
package org.apache.bookkeeper.mledger.impl;

import org.apache.bookkeeper.mledger.AsyncCallbacks.FindEntryCallback;
import org.apache.bookkeeper.mledger.AsyncCallbacks.ReadEntryCallback;
import org.apache.bookkeeper.mledger.AsyncCallbacks.FindEntryCallback;
import org.apache.bookkeeper.mledger.Entry;
import org.apache.bookkeeper.mledger.ManagedLedgerException;
import org.apache.bookkeeper.mledger.Position;
import org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl.PositionBound;

import java.util.function.Predicate;
import com.google.common.base.Predicate;

/**
*/
Expand All @@ -44,7 +43,7 @@ enum State {
State state;

public OpFindNewest(ManagedCursorImpl cursor, PositionImpl startPosition, Predicate<Entry> condition,
long numberOfEntries, FindEntryCallback callback, Object ctx) {
long numberOfEntries, FindEntryCallback callback, Object ctx) {
this.cursor = cursor;
this.startPosition = startPosition;
this.callback = callback;
Expand All @@ -62,7 +61,7 @@ public OpFindNewest(ManagedCursorImpl cursor, PositionImpl startPosition, Predic
public void readEntryComplete(Entry entry, Object ctx) {
switch (state) {
case checkFirst:
if (!condition.test(entry)) {
if (!condition.apply(entry)) {
callback.findEntryComplete(null, OpFindNewest.this.ctx);
return;
} else {
Expand All @@ -75,7 +74,7 @@ public void readEntryComplete(Entry entry, Object ctx) {
}
break;
case checkLast:
if (condition.test(entry)) {
if (condition.apply(entry)) {
callback.findEntryComplete(entry.getPosition(), OpFindNewest.this.ctx);
return;
} else {
Expand All @@ -86,7 +85,7 @@ public void readEntryComplete(Entry entry, Object ctx) {
}
break;
case searching:
if (condition.test(entry)) {
if (condition.apply(entry)) {
// mid - last
lastMatchedPosition = entry.getPosition();
min = mid();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,30 @@
*/
package org.apache.bookkeeper.mledger.impl;

import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.apache.bookkeeper.mledger.*;
import org.apache.bookkeeper.mledger.AsyncCallbacks.*;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;

import java.util.List;
import java.util.Set;
import java.util.function.Predicate;

import static org.testng.Assert.*;
import org.apache.bookkeeper.mledger.AsyncCallbacks;
import org.apache.bookkeeper.mledger.AsyncCallbacks.ClearBacklogCallback;
import org.apache.bookkeeper.mledger.AsyncCallbacks.DeleteCallback;
import org.apache.bookkeeper.mledger.AsyncCallbacks.MarkDeleteCallback;
import org.apache.bookkeeper.mledger.AsyncCallbacks.ReadEntriesCallback;
import org.apache.bookkeeper.mledger.AsyncCallbacks.ReadEntryCallback;
import org.apache.bookkeeper.mledger.AsyncCallbacks.SkipEntriesCallback;
import org.apache.bookkeeper.mledger.Entry;
import org.apache.bookkeeper.mledger.ManagedCursor;
import org.apache.bookkeeper.mledger.ManagedLedgerException;
import org.apache.bookkeeper.mledger.Position;
import org.testng.annotations.Test;

import com.google.common.base.Predicate;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;

@Test
public class ManagedCursorContainerTest {
Expand Down Expand Up @@ -110,7 +123,7 @@ public void close() {
}

@Override
public void asyncClose(CloseCallback callback, Object ctx) {
public void asyncClose(AsyncCallbacks.CloseCallback callback, Object ctx) {
}

@Override
Expand Down Expand Up @@ -147,11 +160,11 @@ public Position findNewestMatching(Predicate<Entry> condition)

@Override
public void asyncFindNewestMatching(FindPositionConstraint constraint, Predicate<Entry> condition,
FindEntryCallback callback, Object ctx) {
AsyncCallbacks.FindEntryCallback callback, Object ctx) {
}

@Override
public void asyncResetCursor(final Position position, ResetCursorCallback callback) {
public void asyncResetCursor(final Position position, AsyncCallbacks.ResetCursorCallback callback) {

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,13 @@ public class ServiceConfiguration implements PulsarConfiguration{
private int managedLedgerCursorMaxEntriesPerLedger = 50000;
// Max time before triggering a rollover on a cursor ledger
private int managedLedgerCursorRolloverTimeInSeconds = 14400;
// Max number of entries to append to a ledger before triggering a rollover
// A ledger rollover is triggered on these conditions Either the max
// rollover time has been reached or max entries have been written to the
// ledged and at least min-time has passed
// Max number of "acknowledgment holes" that are going to be persistently stored.
// When acknowledging out of order, a consumer will leave holes that are supposed
// to be quickly filled by acking all the messages. The information of which
// messages are acknowledged is persisted by compressing in "ranges" of messages
// that were acknowledged. After the max number of ranges is reached, the information
// will only be tracked in memory and messages will be redelivered in case of
// crashes.
private int managedLedgerMaxUnackedRangesToPersist = 1000;

/*** --- Load balancer --- ****/
Expand Down