class MetadataUpdateLoop
extends java.lang.Object
The loop takes the following steps: 1. Check if the metadata needs to be changed. 2. Make a copy of the metadata and modify it. 3. Write the modified copy to zookeeper. 3.1 If the write succeeds, go to 6. 3.2 If the write fails because of a failed compare and swap, go to 4. 4. Read the metadata back from the store 5. Update the local copy of the metadata with the metadata read in 4, go to 1. 6. Update the local copy of the metadata with the metadata which has just been written.
All mutating operations are compare and swap operation. If the compare fails, another iteration of the loop begins.
| Modifier and Type | Class and Description |
|---|---|
(package private) static interface |
MetadataUpdateLoop.LocalValueUpdater |
(package private) static interface |
MetadataUpdateLoop.MetadataTransform |
(package private) static interface |
MetadataUpdateLoop.NeedsUpdatePredicate |
| Modifier and Type | Field and Description |
|---|---|
(package private) static org.slf4j.Logger |
LOG |
| Constructor and Description |
|---|
MetadataUpdateLoop(org.apache.bookkeeper.meta.LedgerManager lm,
long ledgerId,
java.util.function.Supplier<org.apache.bookkeeper.versioning.Versioned<LedgerMetadata>> currentLocalValue,
MetadataUpdateLoop.NeedsUpdatePredicate needsTransformation,
MetadataUpdateLoop.MetadataTransform transform,
MetadataUpdateLoop.LocalValueUpdater updateLocalValue) |
MetadataUpdateLoop(org.apache.bookkeeper.meta.LedgerManager lm,
long ledgerId,
java.util.function.Supplier<org.apache.bookkeeper.versioning.Versioned<LedgerMetadata>> currentLocalValue,
MetadataUpdateLoop.NeedsUpdatePredicate needsTransformation,
MetadataUpdateLoop.MetadataTransform transform,
MetadataUpdateLoop.LocalValueUpdater updateLocalValue,
com.google.common.util.concurrent.RateLimiter throttler)
Construct the loop.
|
| Modifier and Type | Method and Description |
|---|---|
(package private) java.util.concurrent.CompletableFuture<org.apache.bookkeeper.versioning.Versioned<LedgerMetadata>> |
run() |
MetadataUpdateLoop(org.apache.bookkeeper.meta.LedgerManager lm,
long ledgerId,
java.util.function.Supplier<org.apache.bookkeeper.versioning.Versioned<LedgerMetadata>> currentLocalValue,
MetadataUpdateLoop.NeedsUpdatePredicate needsTransformation,
MetadataUpdateLoop.MetadataTransform transform,
MetadataUpdateLoop.LocalValueUpdater updateLocalValue)
MetadataUpdateLoop(org.apache.bookkeeper.meta.LedgerManager lm,
long ledgerId,
java.util.function.Supplier<org.apache.bookkeeper.versioning.Versioned<LedgerMetadata>> currentLocalValue,
MetadataUpdateLoop.NeedsUpdatePredicate needsTransformation,
MetadataUpdateLoop.MetadataTransform transform,
MetadataUpdateLoop.LocalValueUpdater updateLocalValue,
com.google.common.util.concurrent.RateLimiter throttler)
lm - the ledger manager used for reading and writing metadataledgerId - the id of the ledger we will be operating oncurrentLocalValue - should return the current local value of the metadataneedsTransformation - should return true, if the metadata needs to be modified.
should throw an exception, if this update doesn't make sense.transform - takes a metadata objects, transforms, and returns it, without modifying
the originalupdateLocalValue - if the local value matches the first parameter, update it to the
second parameter and return true, return false otherwisejava.util.concurrent.CompletableFuture<org.apache.bookkeeper.versioning.Versioned<LedgerMetadata>> run()
Copyright © 2011–2024 The Apache Software Foundation. All rights reserved.