forked from apache/pulsar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support exclude the message when reset cursor by message ID (apache#8306
) Fixes apache#8259 ### Motivation Currently, when reset the cursor to a position, the broker will set the mark delete position to the previous position of the reset position. For some usecase, we don't want to consume the reset position again, so it's better to provide a way to reset the cursor to a specific position and exclude this position. So that the consumers under the subscription can start consume messages from the next position of the reset position. ### Modifications Add a new API to exclude the message when reset cursor by message ID ### Verifying this change SimpleProducerConsumerTest#testResetPosition
- Loading branch information
Showing
18 changed files
with
424 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ResetCursorData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.pulsar.client.impl; | ||
|
||
|
||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import org.apache.pulsar.client.api.MessageId; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
public class ResetCursorData { | ||
protected long ledgerId; | ||
protected long entryId; | ||
protected int partitionIndex = -1; | ||
protected boolean isExcluded = false; | ||
|
||
public ResetCursorData(long ledgerId, long entryId) { | ||
this.ledgerId = ledgerId; | ||
this.entryId = entryId; | ||
} | ||
|
||
public ResetCursorData(long ledgerId, long entryId, boolean isExcluded) { | ||
this.ledgerId = ledgerId; | ||
this.entryId = entryId; | ||
this.isExcluded = isExcluded; | ||
} | ||
|
||
public ResetCursorData(MessageId messageId) { | ||
if (messageId instanceof MessageIdImpl) { | ||
MessageIdImpl messageIdImpl = (MessageIdImpl) messageId; | ||
this.ledgerId = messageIdImpl.getLedgerId(); | ||
this.entryId = messageIdImpl.getEntryId(); | ||
} else if (messageId instanceof TopicMessageIdImpl) { | ||
throw new IllegalArgumentException("Not supported operation on partitioned-topic"); | ||
} | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
...c/test/java/org/apache/pulsar/tests/integration/backwardscompatibility/ClientTest2_2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.pulsar.tests.integration.backwardscompatibility; | ||
|
||
|
||
import org.apache.pulsar.tests.integration.topologies.ClientTestBase; | ||
import org.testng.annotations.Test; | ||
|
||
public class ClientTest2_2 extends PulsarStandaloneTestSuite2_2 { | ||
|
||
private final ClientTestBase clientTestBase = new ClientTestBase(); | ||
|
||
@Test(dataProvider = "StandaloneServiceUrlAndHttpUrl") | ||
public void testResetCursorCompatibility(String serviceUrl, String httpServiceUrl) throws Exception { | ||
String topicName = generateTopicName("test-reset-cursor-compatibility", true); | ||
clientTestBase.resetCursorCompatibility(serviceUrl, httpServiceUrl, topicName); | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
...c/test/java/org/apache/pulsar/tests/integration/backwardscompatibility/ClientTest2_3.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.pulsar.tests.integration.backwardscompatibility; | ||
|
||
|
||
import org.apache.pulsar.tests.integration.topologies.ClientTestBase; | ||
import org.testng.annotations.Test; | ||
|
||
public class ClientTest2_3 extends PulsarStandaloneTestSuite2_3 { | ||
|
||
private final ClientTestBase clientTestBase = new ClientTestBase(); | ||
|
||
@Test(dataProvider = "StandaloneServiceUrlAndHttpUrl") | ||
public void testResetCursorCompatibility(String serviceUrl, String httpServiceUrl) throws Exception { | ||
String topicName = generateTopicName("test-reset-cursor-compatibility", true); | ||
clientTestBase.resetCursorCompatibility(serviceUrl, httpServiceUrl, topicName); | ||
} | ||
|
||
} |
Oops, something went wrong.