{"id":20231016,"url":"https://github.com/bewaremypower/bkclientexamples","last_synced_at":"2026-05-10T11:45:38.719Z","repository":{"id":109019901,"uuid":"241115809","full_name":"BewareMyPower/BKClientExamples","owner":"BewareMyPower","description":"BookKeeper 客户端示例代码集","archived":false,"fork":false,"pushed_at":"2020-10-11T12:47:03.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-14T00:22:41.402Z","etag":null,"topics":["bookkeeper"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BewareMyPower.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-17T13:35:33.000Z","updated_at":"2024-03-22T13:18:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"600b69f5-8e77-43b0-a240-f233db165da6","html_url":"https://github.com/BewareMyPower/BKClientExamples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BewareMyPower%2FBKClientExamples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BewareMyPower%2FBKClientExamples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BewareMyPower%2FBKClientExamples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BewareMyPower%2FBKClientExamples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BewareMyPower","download_url":"https://codeload.github.com/BewareMyPower/BKClientExamples/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241677354,"owners_count":20001673,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bookkeeper"],"created_at":"2024-11-14T07:44:51.309Z","updated_at":"2026-05-10T11:45:33.688Z","avatar_url":"https://github.com/BewareMyPower.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## BKClientExamples\n\nBookKeeper 客户端示例代码集\n\n## 构建\n\n环境要求：Java 8、Maven。\n\n目前需要修改 `src/main/java/com/github/bewaremypower/config/DefaultConfig.java` 的 `ZK_SERVERS` 为 BookKeeper 集群所连接的 ZooKeeper 服务器，然后运行以下命令编译：\n\n```bash\nmvn clean package\n```\n\n部署 BookKeeper 集群，参考 [BookKeeper deploy](https://bookkeeper.apache.org/docs/latest/deployment/manual/)。\n\n## 示例代码\n\n见 `src/main/java/com/github/bewaremypower` 目录下的 `*.java` 文件，每个类都包含 `main` 方法，可独立运行。通过 Maven 运行的命令包装到了脚本 `bin/bookkeeper-cli` 中，通过命令行选项运行不同的示例。\n\n### 1. WriteAndRead\n\n```\n./bin/bookkeeper-cli w\n```\n\n流程：创建 ledger，接收命令行输入，将每一行字符串的字节序列作为 entry 写入到创建的 ledger 中，输入 Ctrl+D 停止输入，之后会打开该 ledger，读取所有 entries 并打印。\n\n### 2. DeleteLedgers\n\n```\n./bin/bookkeeper-cli d \u003cMinLedgerId\u003e \u003cMaxLedgerId\u003e\n```\n\n流程：删除闭区间 `[MinLedgerId, MaxLedgerId]` 的 id 对应的 ledgers\n\n### 3. MultiThreadRead\n\n```\n./bin/bookkeeper-cli m \u003cLedgerId\u003e [ThreadNum]\n```\n\n流程：开启 `ThreadNum` 个线程，打开 `ledgerId` 对应的 ledger，读取所有 entries 并打印。\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbewaremypower%2Fbkclientexamples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbewaremypower%2Fbkclientexamples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbewaremypower%2Fbkclientexamples/lists"}