[feat][broker] PIP-180 Part VI: Add ShadowManagedLedgerImpl#18265
[feat][broker] PIP-180 Part VI: Add ShadowManagedLedgerImpl#18265Jason918 merged 11 commits intoapache:masterfrom
Conversation
|
/pulsarbot run-failure-checks |
|
LGTM with minor comments |
9295d45 to
eb300b8
Compare
| super(factory, bookKeeper, store, config, scheduledExecutor, name, mlOwnershipChecker); | ||
| this.shadowSource = TopicName.get(config.getShadowSource()); | ||
| this.sourceMLName = shadowSource.getPersistenceNamingEncoding(); | ||
| if (config.getTopicName().isPartitioned() && TopicName.getPartitionIndex(config.getShadowSource()) == -1) { |
There was a problem hiding this comment.
Why the name is not able to be used? It's a little confusing that we need to introduce the topic name in ManagedLedgerConfig
Or maybe we can introduce a properties?
There was a problem hiding this comment.
Why the
nameis not able to be used? It's a little confusing that we need to introduce the topic name inManagedLedgerConfig
Good point.
- We need to know the
TopicNameof the source topic in the shadow topic. But thenamehere is in the format ofPersistenceNamingEncoding. - I get that we'd better not introduce the concept of "topic" into managed-ledger. I will move this logic to the "broker" layer. So that the source topic name is in
propertiesand the managedLedgerName of the source topic is stored in the new fieldManagedLedgerConfig.shadowSourceName.
| sourceLedgersStat, stat); | ||
| } | ||
|
|
||
| sourceLedgersStat = stat; |
There was a problem hiding this comment.
Do we need to check the data version?
Maybe the watcher gets a notification first, and then we get the response from get managed ledger info operation. Will we add the deleted ledger back?
There was a problem hiding this comment.
Nice catch. Added a version check.
| sourceLedgersStat = stat; | ||
|
|
||
| if (mlInfo.hasTerminatedPosition()) { | ||
| state = State.Terminated; |
There was a problem hiding this comment.
Do you need Terminated state for a shadow ledger? If the source topic changes to the terminated state, the shadow topic will not get any new messages.
There was a problem hiding this comment.
Not needed actually, just keeping the original logic at first.
After another thought, we should remove this, because the source topic can be terminated but the replication to the shadow topic should go on.
So comes these updates:
- Removed Terminated state from ShadowManagedLedger.
- Overrides
asyncTerminateand return fail directly.
| if (state == State.Terminated) { | ||
| addOperation.failed(new ManagedLedgerException.ManagedLedgerTerminatedException( | ||
| "Managed ledger was already terminated")); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Looks like we don't need to check if the topic is terminated.
And if the broker receives the zookeeper notification first, then the shadow topic changes to the terminated state. But the shadow replicator hasn't reached the end of the source topic. In this case, the consumer connected to the shadow topic will have a different view.
| currentLedgerEntries = position.getEntryId(); | ||
| currentLedgerSize += addOperation.data.readableBytes(); | ||
| addOperation.initiateShadowWrite(); | ||
| } |
There was a problem hiding this comment.
How about the position's ledger ID that is not equal to the current ledger ID? It looks like the addOperation will never be complete.
There was a problem hiding this comment.
Fixed, and add ut in ShadowManagedLedgerImplTest
|
@codelipenghui Comments all addressed. PTAL. |
- finish processSourceManagedLedgerInfo - finish internalAsyncAddEntry - ShadowTopicTest pass - ShadowReplicatorTest pass Add test cases
69b8222 to
536f10a
Compare
|
Hi @Jason918, do you have any updates for documenting this feature? |
@momo-jun I have communicated with @Jason918 , I'll help him update the documentation |
|
Thanks @Jason918 @StevenLuMT. Feel free to ping me if you need any assistance with docs. |
Thanks @momo-jun ,my WeChat ID is 863199780, add me, keep fast communication |
Master Issue: #16153
Motivation
After this PR, the basic function of
PIP-180 shadow topicwill be ready.Modifications
ShadowManagedLedgerImplVerifying this change
This change added tests and can be verified as follows:
ShadowTopicTest.javaDoes this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: Jason918#12