WORK-IN-PROGRESS

this document is currently subject to changes

Motivation

Currently (in BookKeeper 4.5) we have several overloaded versions of the methods createLedger/createLedegerAdv/asyncCreateLeader/asyncCreateLeaderAdv. This methods are present because from version to version we added new configuration options for the Ledger.

In order to support new features in the future we need to have a more extensible API.

Proposed Change

So we will introduce a new set of APIs to construct Ledgers, in the future this pattern will be extended to other operations, like delete/close/addEntry.

This is how the client code will look like:

 BookKeeper bookeeper = ....;
 CreateBuilder builder = bookkeeper.createBuilder();
 CompletableFuture<LedgerHandler> future = builder
    .ensembleSize(3)
    .writeQuorumSize(2)
    .ackQuorumSize(1)
    .digestType(DigestType.CRC32)                                       
    .customMetadata(metadata)
    .password(password)
    .advanced(true|false)
    .build();
LedgerHandler lh = future.get();

 

Migration Plan and Compatibility

No issue about migration and compatibility.

Legacy methods will be retained. No @Deprecated annotation will be added. Further removal of existing APIs will be evaluated in the future, maybe while starting a new major release, like 5.0.0

Rejected Alternatives

This is an example of an alternative API which has been rejected, as it will not be really extensible in the future

        BookKeeper bookeeper = ....;
        LedgerConfiguration ledgerConfiguration = LedgerConfiguration.builder()
                                                                              .ensembleSize(3)
                                                                              .writeQuorumSize(2)
                                                                              .ackQuorumSize(1)
                                                                              .digestType(DigestType.CRC32)                                       
																			  .customMetadata(Map<String, byte[]> metadata)
                                                                              .password(password)
                                                                              .advanced(true|false);
        LedgerHandle ledger = bookeeper.createLedger(ledgerConfiguration);