You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by ch...@apache.org on 2024/03/01 02:16:53 UTC
(bookkeeper) branch master updated: BenchReadThroughputLatency support config the way of gen ledger path. (#4219)
This is an automated email from the ASF dual-hosted git repository.
chenhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/master by this push:
new 7576f224bc BenchReadThroughputLatency support config the way of gen ledger path. (#4219)
7576f224bc is described below
commit 7576f224bcb1866fc2cadd48ccf51af4866e7bcd
Author: Yan Zhao <ho...@apache.org>
AuthorDate: Fri Mar 1 10:16:47 2024 +0800
BenchReadThroughputLatency support config the way of gen ledger path. (#4219)
### Motivation
In BenchReadThroughputLatency, it generates the ledger zk node path using
`String.format("/ledgers/L%010d", ledger.get());`
But if the user uses `HierarchicalLedgerManager`, `LegacyHierarchicalLedgerManager`, or `LongHierarchicalLedgerManager`, the ledger zk node path is not the same as the way in the BenchReadThroughputLatency.
So we need support config the `genLedgerWay` to match the custom LedgerManager.
---
.../benchmark/BenchReadThroughputLatency.java | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchReadThroughputLatency.java b/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchReadThroughputLatency.java
index 5c04558b84..5cd029b3c1 100644
--- a/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchReadThroughputLatency.java
+++ b/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchReadThroughputLatency.java
@@ -36,6 +36,7 @@ import org.apache.bookkeeper.client.BookKeeper;
import org.apache.bookkeeper.client.LedgerEntry;
import org.apache.bookkeeper.client.LedgerHandle;
import org.apache.bookkeeper.conf.ClientConfiguration;
+import org.apache.bookkeeper.util.StringUtils;
import org.apache.bookkeeper.zookeeper.ZooKeeperClient;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
@@ -159,6 +160,9 @@ public class BenchReadThroughputLatency {
Options options = new Options();
options.addOption("ledger", true, "Ledger to read. If empty, read all ledgers which come available. "
+ " Cannot be used with -listen");
+ //How to generate ledger node path.
+ options.addOption("ledgerManagerType", true, "The ledger manager type. "
+ + "The optional value: flat, hierarchical, legacyHierarchical, longHierarchical. Default: flat");
options.addOption("listen", true, "Listen for creation of <arg> ledgers, and read each one fully");
options.addOption("password", true, "Password used to access ledgers (default 'benchPasswd')");
options.addOption("zookeeper", true, "Zookeeper ensemble, default \"localhost:2181\"");
@@ -199,7 +203,21 @@ public class BenchReadThroughputLatency {
}
final CountDownLatch shutdownLatch = new CountDownLatch(1);
- final String nodepath = String.format("/ledgers/L%010d", ledger.get());
+
+ String ledgerManagerType = cmd.getOptionValue("ledgerManagerType", "flat");
+ String nodepath;
+ if ("flat".equals(ledgerManagerType)) {
+ nodepath = String.format("/ledgers/L%010d", ledger.get());
+ } else if ("hierarchical".equals(ledgerManagerType)) {
+ nodepath = String.format("/ledgers%s", StringUtils.getHybridHierarchicalLedgerPath(ledger.get()));
+ } else if ("legacyHierarchical".equals(ledgerManagerType)) {
+ nodepath = String.format("/ledgers%s", StringUtils.getShortHierarchicalLedgerPath(ledger.get()));
+ } else if ("longHierarchical".equals(ledgerManagerType)) {
+ nodepath = String.format("/ledgers%s", StringUtils.getLongHierarchicalLedgerPath(ledger.get()));
+ } else {
+ LOG.warn("Unknown ledger manager type: {}, use flat as the value", ledgerManagerType);
+ nodepath = String.format("/ledgers/L%010d", ledger.get());
+ }
final ClientConfiguration conf = new ClientConfiguration();
conf.setReadTimeout(sockTimeout).setZkServers(servers);