apache / bookkeeper

Apache BookKeeper - a scalable, fault tolerant and low latency storage service optimized for append-only workloads
https://bookkeeper.apache.org/
Apache License 2.0
1.9k stars 901 forks source link

[feature] [distributedlog] The api for delete empty zookeeper node #3132

Closed poorbarcode closed 2 years ago

poorbarcode commented 2 years ago

FEATURE REQUEST

// Def a log
DistributedLogManager logManager = namespace.openLog(“default/example/v0.1”);
// Write 
DLOutputStream.openWriterAsync( logManager )
.thenCompose(dlOutputStream -> dlOutputStream.writeAsync(inputStream)).get();

// Delte it 
namespace.getNamespaceDriver()
    .getLogMetadataStore()
    .getLogLocation(“default/example/v0.1”)
    .thenCompose(uri -> uri.map(value -> namespace.getNamespaceDriver()
                                                                                     .getLogStreamMetadataStore(NamespaceDriver.Role.WRITER)
                                                                                     .deleteLog(value, path)
    );

After deleted, there has an dirty zk-node: default/example

I think there should has a safe way to remove nodes, just like this:

/**
 * Delete the metadata of a log, this method will not delete any child node,
 * When {@param streamName} is not empty, delete nothing.
 *
 * @param uri the location to store the metadata of the log
 * @param streamName the name of the log stream
 * @return When delete finish return {@link Boolean#TRUE};
 *         when {@param streamName} not exists return {@link Boolean#TRUE}
 *         when delete nothing return {@link Boolean#FALSE}
 */
CompletableFuture<Boolean> deleteLogUnRecursive(URI uri, final String streamName);
poorbarcode commented 2 years ago

I submitted a PR: https://github.com/apache/bookkeeper/pull/3133