AbdulElahGwaith commited on
Commit
fe5d4e8
·
verified ·
1 Parent(s): 9946de8

Upload folder using huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .asf.yaml +91 -0
  2. .dlc.json +89 -0
  3. .gitattributes +2 -0
  4. .github/ISSUE_TEMPLATE.md +38 -0
  5. .github/ISSUE_TEMPLATE/bp.md +19 -0
  6. .github/ISSUE_TEMPLATE/bug_report.md +34 -0
  7. .github/ISSUE_TEMPLATE/feature_request.md +18 -0
  8. .github/ISSUE_TEMPLATE/flaky_test.md +31 -0
  9. .github/ISSUE_TEMPLATE/question.md +14 -0
  10. .github/PULL_REQUEST_TEMPLATE.md +47 -0
  11. .github/actions/bot/package.json +31 -0
  12. .github/actions/bot/src/run.js +69 -0
  13. .github/actions/clean-disk/action.yml +57 -0
  14. .github/actions/copy-test-reports/action.yml +27 -0
  15. .github/actions/tune-runner-vm/action.yml +95 -0
  16. .github/changes-filter.yaml +17 -0
  17. .github/workflows/README.md +60 -0
  18. .github/workflows/bk-ci.yml +604 -0
  19. .github/workflows/bk-streamstorage-python.yml +85 -0
  20. .github/workflows/bot.yml +43 -0
  21. .github/workflows/ci-bkbot.yaml +298 -0
  22. .github/workflows/codeql.yml +97 -0
  23. .github/workflows/dead-link-checker.yaml +43 -0
  24. .github/workflows/java21-daily-build.yml +47 -0
  25. .github/workflows/owasp-daily-build.yml +47 -0
  26. .github/workflows/website-deploy.yaml +63 -0
  27. .github/workflows/website-pr-validation.yml +57 -0
  28. .github/workflows/windows-daily-build.yml +47 -0
  29. .gitignore +50 -0
  30. .test-infra/scripts/post-docker-tests.sh +22 -0
  31. .test-infra/scripts/pre-docker-tests.sh +33 -0
  32. .test-infra/scripts/slack-email-digest/.gitignore +1 -0
  33. .test-infra/scripts/slack-email-digest/README.md +4 -0
  34. .test-infra/scripts/slack-email-digest/configuration-example.yaml +34 -0
  35. .test-infra/scripts/slack-email-digest/requirements.txt +20 -0
  36. .test-infra/scripts/slack-email-digest/slack_email_digest.py +96 -0
  37. .typos.toml +56 -0
  38. CONTRIBUTING.md +25 -0
  39. LICENSE +202 -0
  40. NOTICE +5 -0
  41. README.md +53 -0
  42. bin/bkctl +68 -0
  43. bin/bkperf +69 -0
  44. bin/bookkeeper +181 -0
  45. bin/bookkeeper-cluster.sh +135 -0
  46. bin/bookkeeper-daemon.sh +221 -0
  47. bin/common.sh +376 -0
  48. bin/dlog +133 -0
  49. bin/standalone +65 -0
  50. bin/standalone.docker-compose +186 -0
.asf.yaml ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+
20
+ github:
21
+ description: "Apache BookKeeper - a scalable, fault tolerant and low latency storage service optimized for append-only workloads"
22
+ homepage: https://bookkeeper.apache.org/
23
+ labels:
24
+ - apache
25
+ - bookkeeper
26
+ - big-data
27
+ - distributed-log
28
+ - distributed-systems
29
+ - wal
30
+ features:
31
+ # Enable wiki for documentation
32
+ wiki: false
33
+ # Enable issues management
34
+ issues: true
35
+ # Enable projects for project management boards
36
+ projects: true
37
+ enabled_merge_buttons:
38
+ # enable squash button:
39
+ squash: true
40
+ # disable merge button:
41
+ merge: false
42
+ # disable rebase button:
43
+ rebase: false
44
+ protected_branches:
45
+ master:
46
+ required_status_checks:
47
+ # strict means "Require branches to be up to date before merging".
48
+ strict: false
49
+ # Contexts are the names of checks that must pass.
50
+ # See ./github/workflows/README.md for more documentation on this list.
51
+ contexts:
52
+ - BookKeeper CI checks completed
53
+
54
+ required_pull_request_reviews:
55
+ dismiss_stale_reviews: false
56
+ require_code_owner_reviews: true
57
+ required_approving_review_count: 1
58
+
59
+ # squash or rebase must be allowed in the repo for this setting to be set to true.
60
+ required_linear_history: true
61
+
62
+ required_signatures: false
63
+
64
+ # The following branch protections only ensure that force pushes are not allowed
65
+ branch-4.0: {}
66
+ branch-4.1: {}
67
+ branch-4.2: {}
68
+ branch-4.3: {}
69
+ branch-4.4: {}
70
+ branch-4.5: {}
71
+ branch-4.6: {}
72
+ branch-4.7: {}
73
+ branch-4.8: {}
74
+ branch-4.9: {}
75
+ branch-4.10: {}
76
+ branch-4.11: {}
77
+ branch-4.12: {}
78
+ branch-4.13: {}
79
+ branch-4.14: {}
80
+ branch-4.15: {}
81
+ branch-4.16: {}
82
+
83
+ publish:
84
+ whoami: asf-site
85
+
86
+ notifications:
87
+ commits: commits@bookkeeper.apache.org
88
+ issues: commits@bookkeeper.apache.org
89
+ pullrequests: commits@bookkeeper.apache.org
90
+ discussions: dev@bookkeeper.apache.org
91
+ jira_options: link label
.dlc.json ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "ignorePatterns": [
3
+ {
4
+ "pattern": "^http://localhost"
5
+ },
6
+ {
7
+ "pattern": "^https://kubernetes.io/docs/resources-reference/v1.6/"
8
+ },
9
+ {
10
+ "pattern": "^https://zookeeper.apache.org/doc/"
11
+ },
12
+ {
13
+ "pattern": "^http://zookeeper.apache.org/doc/current/api/"
14
+ },
15
+ {
16
+ "pattern": "^https://github.com/apache/bookkeeper/"
17
+ },
18
+ {
19
+ "pattern": "^https://github.com/sijie/bookkeeper/tree/bookie_shell_refactor"
20
+ },
21
+ {
22
+ "pattern": "^http://pulsar.incubator.apache.org/docs/latest/getting-started/ConceptsAndArchitecture/#persistent-storage"
23
+ },
24
+ {
25
+ "pattern": "^https://zookeeper.apache.org/doc/current/api/org/apache/zookeeper/"
26
+ },
27
+ {
28
+ "pattern": "^http://pulsar.incubator.apache.org/docs/latest/getting-started/ConceptsAndArchitecture/#persistent-storage"
29
+ },
30
+ {
31
+ "pattern": "^https://bookkeeper.apache.org/docs/api/javadoc/"
32
+ },
33
+ {
34
+ "pattern": "^http://hbtc2012.hadooper.cn/subject/track1maheswara2.pdf"
35
+ },
36
+ {
37
+ "pattern": "^https://developer.yahoo.com/blogs/ydn/bookkeeper-durability-scale-54048.html"
38
+ },
39
+ {
40
+ "pattern": "^http://apache.claz.org/bookkeeper"
41
+ },
42
+ {
43
+ "pattern": "^https://dcos.io/"
44
+ },
45
+ {
46
+ "pattern": "^ https://docs.mesosphere.com"
47
+ },
48
+ {
49
+ "pattern": "^http://master.dcos/exhibitor"
50
+ },
51
+ {
52
+ "pattern": "^https://docs.mesosphere.com/"
53
+ },
54
+ {
55
+ "pattern": "^https://distributedlog.io"
56
+ },
57
+ {
58
+ "pattern": "^https://www.opengroup.org/membership/forums/platform/unix"
59
+ },
60
+ {
61
+ "pattern": "^https://docs.oracle.com/javase/8/docs/technotes/guides/security/jgss/tutorials/KerberosReq.html"
62
+ },
63
+ {
64
+ "pattern": "^http://daxue.qq.com/content/content/id/2492"
65
+ },
66
+ {
67
+ "pattern": "^https://calendar.google.com/"
68
+ },
69
+ {
70
+ "pattern": "^#"
71
+ },
72
+ {
73
+ "pattern": ".*\\{\\{.*"
74
+ },
75
+ {
76
+ "pattern": "^//"
77
+ }
78
+ ],
79
+ "timeout": "60s",
80
+ "retryOn429": true,
81
+ "retryCount": 10,
82
+ "fallbackRetryDelay": "1000s",
83
+ "aliveStatusCodes": [
84
+ 200,
85
+ 400,
86
+ 401,
87
+ 403
88
+ ]
89
+ }
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ site3/website/static/img/batch_read.png filter=lfs diff=lfs merge=lfs -text
37
+ site3/website/static/img/single_read.png filter=lfs diff=lfs merge=lfs -text
.github/ISSUE_TEMPLATE.md ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Is this a question, feature request, bug report, or bookkeeper proposal?
2
+
3
+ **QUESTION**
4
+
5
+ Have you checked our documentation at https://bookkeeper.apache.org/ , If you could not find an answer there, please consider asking your question in our community forum at user@bookkeeper.apache.org, as it would benefit other members of our community.
6
+
7
+
8
+ **FEATURE REQUEST**
9
+
10
+ 1. Please describe the feature you are requesting.
11
+
12
+ 2. Indicate the importance of this issue to you (blocker, must-have, should-have, nice-to-have). Are you currently using any workarounds to address this issue?
13
+
14
+ 3. Provide any additional detail on your proposed use case for this feature.
15
+
16
+ 4. If there are some sub-tasks using -[] for each subtask and create a corresponding issue to map to the sub task:
17
+ - [ ] [sub-task1-issue-number](example_sub_issue1_link_here): sub-task1 discription here,
18
+ - [ ] [sub-task2-issue-number](example_sub_issue2_link_here): sub-task2 discription here,
19
+ - ...
20
+
21
+
22
+ **BUG REPORT**
23
+
24
+ 1. Please describe the issue you observed:
25
+
26
+ - What did you do?
27
+
28
+ - What did you expect to see?
29
+
30
+ - What did you see instead?
31
+
32
+ **BP**
33
+
34
+ This is the master ticket for tracking BP-<bp-number> :
35
+
36
+ [a short description for this BP]
37
+
38
+ Proposal PR - #<pr-number>
.github/ISSUE_TEMPLATE/bp.md ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: BookKeeper Proposal
3
+ about: Propose a major change to BookKeeper
4
+ title: ''
5
+ labels: type/proposal
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **BP**
11
+
12
+ > Follow the instructions at https://bookkeeper.apache.org/community/bookkeeper-proposals/ to create a proposal.
13
+
14
+ This is the master ticket for tracking BP-xyz :
15
+
16
+ [a short description for this BP]
17
+
18
+ <!-- add a proposal PR link below -->
19
+ Proposal PR - #abc
.github/ISSUE_TEMPLATE/bug_report.md ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: Bug report
3
+ about: Create a bug report to help us improve
4
+ title: ''
5
+ labels: type/bug
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **BUG REPORT**
11
+
12
+ ***Describe the bug***
13
+
14
+ A clear and concise description of what the bug is.
15
+
16
+ ***To Reproduce***
17
+
18
+ Steps to reproduce the behavior:
19
+ 1. Go to '...'
20
+ 2. Click on '....'
21
+ 3. Scroll down to '....'
22
+ 4. See error
23
+
24
+ ***Expected behavior***
25
+
26
+ A clear and concise description of what you expected to happen.
27
+
28
+ ***Screenshots***
29
+
30
+ If applicable, add screenshots to help explain your problem.
31
+
32
+ ***Additional context***
33
+
34
+ Add any other context about the problem here.
.github/ISSUE_TEMPLATE/feature_request.md ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: type/feature
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **FEATURE REQUEST**
11
+
12
+ 1. Please describe the feature you are requesting.
13
+
14
+ 2. Indicate the importance of this issue to you (blocker, must-have, should-have, nice-to-have).
15
+ Are you currently using any workarounds to address this issue?
16
+
17
+ 3. Provide any additional detail on your proposed use case for this feature.
18
+
.github/ISSUE_TEMPLATE/flaky_test.md ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: Flaky test
3
+ about: Report a flaky test failure
4
+ title: 'Flaky-test: test_class.test_method'
5
+ labels: ["area/tests", "flaky-tests"]
6
+ assignees: ''
7
+ ---
8
+ <!---
9
+
10
+ Instructions for reporting a flaky test using this issue template:
11
+
12
+ 1. Replace test_class in title and body with the short test class name WITHOUT the package name.
13
+ 2. Replace test_method in title and body with the test method that failed. Multiple methods are flaky, remove the content that refers to the test method.
14
+ 3. Replace "relevant parts of the exception stacktrace here" with the a few lines of the stack trace that shows at least the exception message and the line of test code where the stacktrace occurred.
15
+ 4. Replace "full exception stacktrace here" with the full exception stacktrace from logs. This section will be hidden by default.
16
+ 5. Remove all unused fields / content to unclutter the reported issue. Remove this comment too.
17
+
18
+ -->
19
+ test_class.test_method is flaky. It fails sporadically.
20
+
21
+ ```
22
+ [relevant parts of the exception stacktrace here]
23
+ ```
24
+
25
+ <!-- optionally provide the full stacktrace ->
26
+ <details>
27
+ <summary>Full exception stacktrace</summary>
28
+ <code><pre>
29
+ full exception stacktrace here
30
+ </pre></code>
31
+ </details>
.github/ISSUE_TEMPLATE/question.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: Question
3
+ about: Ask the community for answering questions of BookKeeper
4
+ labels: type/question
5
+ assignees: ''
6
+
7
+ ---
8
+
9
+ **QUESTION**
10
+
11
+ Have you checked our documentation at https://bookkeeper.apache.org/?
12
+ If you could not find an answer there, please consider asking your question
13
+ in our community mailing list at user@bookkeeper.apache.org, as it would benefit
14
+ other members of our community.
.github/PULL_REQUEST_TEMPLATE.md ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Descriptions of the changes in this PR:
2
+
3
+ <!-- Either this PR fixes an issue, -->
4
+
5
+ Fix #xyz
6
+
7
+ <!-- or this PR is one task of an issue -->
8
+
9
+ Main Issue: #xyz
10
+
11
+ <!-- If the PR belongs to a BP, please add the BP link here -->
12
+
13
+ BP: #xyz
14
+
15
+ ### Motivation
16
+
17
+ (Explain: why you're making that change, what is the problem you're trying to solve)
18
+
19
+ ### Changes
20
+
21
+ (Describe: what changes you have made)
22
+
23
+ > ---
24
+ > In order to uphold a high standard for quality for code contributions, Apache BookKeeper runs various precommit
25
+ > checks for pull requests. A pull request can only be merged when it passes precommit checks.
26
+ >
27
+ > ---
28
+ > Be sure to do all the following to help us incorporate your contribution
29
+ > quickly and easily:
30
+ >
31
+ > If this PR is a BookKeeper Proposal (BP):
32
+ >
33
+ > - [ ] Make sure the PR title is formatted like:
34
+ > `<BP-#>: Description of bookkeeper proposal`
35
+ > `e.g. BP-1: 64 bits ledger is support`
36
+ > - [ ] Attach the master issue link in the description of this PR.
37
+ > - [ ] Attach the google doc link if the BP is written in Google Doc.
38
+ >
39
+ > Otherwise:
40
+ >
41
+ > - [ ] Make sure the PR title is formatted like:
42
+ > `<Issue #>: Description of pull request`
43
+ > `e.g. Issue 123: Description ...`
44
+ > - [ ] Make sure tests pass via `mvn clean apache-rat:check install spotbugs:check`.
45
+ > - [ ] Replace `<Issue #>` in the title with the actual Issue number.
46
+ >
47
+ > ---
.github/actions/bot/package.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "github-action-bot",
3
+ "description": "Bot for github actions",
4
+ "version": "1.1.1",
5
+ "author": "GitHub",
6
+ "license": "Apache LICENSE 2.0",
7
+ "main": "dist/index.js",
8
+ "private": true,
9
+ "scripts": {
10
+ "build": "ncc build src/run.js"
11
+ },
12
+ "dependencies": {
13
+ "@actions/core": "^1.2.4",
14
+ "@actions/github": "^2.2.0",
15
+ "@actions/io": "^1.0.2"
16
+ },
17
+ "devDependencies": {
18
+ "@types/jest": "^25.1.4",
19
+ "@typescript-eslint/eslint-plugin": "^2.33.0",
20
+ "@typescript-eslint/parser": "^2.33.0",
21
+ "@zeit/ncc": "^0.22.0",
22
+ "eslint": "^7.0.0",
23
+ "eslint-config-prettier": "^6.11.0",
24
+ "husky": "^4.2.5",
25
+ "jest": "^25.1.0",
26
+ "npm-run-all": "^4.1.5",
27
+ "prettier": "^2.0.5",
28
+ "ts-jest": "^25.2.1",
29
+ "typescript": "^3.8.3"
30
+ }
31
+ }
.github/actions/bot/src/run.js ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ async function run(core, context, github) {
20
+
21
+ try {
22
+ const owner = context.repo.owner;
23
+ const repo = context.repo.repo;
24
+ const reRunCmd = process.env.RERUN_CMD;
25
+ const comment = context.payload.comment.body;
26
+
27
+ if (comment !== reRunCmd) {
28
+ core.info("this is not a bot command");
29
+ return;
30
+ }
31
+
32
+ const {
33
+ data: {
34
+ head: {
35
+ sha: prRef,
36
+ }
37
+ }
38
+ } = await github.rest.pulls.get({
39
+ owner,
40
+ repo,
41
+ pull_number: context.issue.number,
42
+ });
43
+
44
+ const jobs = await github.rest.checks.listForRef({
45
+ owner,
46
+ repo,
47
+ ref: prRef,
48
+ status: "completed"
49
+ });
50
+
51
+ jobs.data.check_runs.forEach(job => {
52
+ if (job.conclusion === 'failure' || job.conclusion === 'cancelled') {
53
+ core.info("rerun job " + job.name);
54
+ github.rest.checks.rerequestSuite({
55
+ owner,
56
+ repo,
57
+ check_suite_id: job.check_suite.id
58
+ })
59
+ }
60
+ });
61
+ } catch (e) {
62
+ core.setFailed(e);
63
+ }
64
+
65
+ }
66
+
67
+ module.exports = ({core}, {context}, {github}) => {
68
+ return run(core, context, github);
69
+ }
.github/actions/clean-disk/action.yml ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+
20
+ name: clean disk
21
+ description: makes some more space available on the disk by removing files
22
+ inputs:
23
+ mode:
24
+ description: "Use 'full' to clean as much as possible"
25
+ required: false
26
+ runs:
27
+ using: composite
28
+ steps:
29
+ - run: |
30
+ if [[ "$OSTYPE" == "linux-gnu"* ]]; then
31
+ directories=(/usr/local/lib/android /opt/ghc)
32
+ if [[ "${{ inputs.mode }}" == "full" ]]; then
33
+ # remove these directories only when mode is 'full'
34
+ directories+=(/usr/share/dotnet /opt/hostedtoolcache/CodeQL)
35
+ fi
36
+ emptydir=/tmp/empty$$/
37
+ mkdir $emptydir
38
+ echo "::group::Available diskspace"
39
+ time df -BM / /mnt
40
+ echo "::endgroup::"
41
+ for directory in "${directories[@]}"; do
42
+ echo "::group::Removing $directory"
43
+ # fast way to delete a lot of files on linux
44
+ time sudo eatmydata rsync -a --delete $emptydir ${directory}/
45
+ time sudo eatmydata rm -rf ${directory}
46
+ time df -BM / /mnt
47
+ echo "::endgroup::"
48
+ done
49
+ echo "::group::Cleaning apt state"
50
+ time sudo bash -c "apt-get clean; apt-get autoclean; apt-get -y --purge autoremove"
51
+ time df -BM / /mnt
52
+ echo "::endgroup::"
53
+ fi
54
+ echo "::group::Available diskspace"
55
+ time df -BM / /mnt
56
+ echo "::endgroup::"
57
+ shell: bash
.github/actions/copy-test-reports/action.yml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+
20
+ name: Copy test reports
21
+ description: Aggregates all test reports to ./test-reports and ./surefire-reports directories
22
+ runs:
23
+ using: composite
24
+ steps:
25
+ - run: |
26
+ $GITHUB_WORKSPACE/dev/ci-tool move_test_reports
27
+ shell: bash
.github/actions/tune-runner-vm/action.yml ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+
20
+ name: Tune Runner VM performance
21
+ description: tunes the GitHub Runner VM operation system
22
+ runs:
23
+ using: composite
24
+ steps:
25
+ - run: |
26
+ if [[ "$OSTYPE" == "linux-gnu"* ]]; then
27
+ echo "::group::Configure and tune OS"
28
+ # Ensure that reverse lookups for current hostname are handled properly
29
+ # Add the current IP address, long hostname and short hostname record to /etc/hosts file
30
+ echo -e "$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)\t$(hostname -f) $(hostname -s)" | sudo tee -a /etc/hosts
31
+
32
+ # The default vm.swappiness setting is 60 which has a tendency to start swapping when memory
33
+ # consumption is high.
34
+ # Set vm.swappiness=1 to avoid swapping and allow high RAM usage
35
+ echo 1 | sudo tee /proc/sys/vm/swappiness
36
+ (
37
+ shopt -s nullglob
38
+ # Set swappiness to 1 for all cgroups and sub-groups
39
+ for swappiness_file in /sys/fs/cgroup/memory/*/memory.swappiness /sys/fs/cgroup/memory/*/*/memory.swappiness; do
40
+ echo 1 | sudo tee $swappiness_file > /dev/null
41
+ done
42
+ ) || true
43
+
44
+ # use "madvise" Linux Transparent HugePages (THP) setting
45
+ # https://www.kernel.org/doc/html/latest/admin-guide/mm/transhuge.html
46
+ # "madvise" is generally a better option than the default "always" setting
47
+ # Based on Azul instructions from https://docs.azul.com/prime/Enable-Huge-Pages#transparent-huge-pages-thp
48
+ echo madvise | sudo tee /sys/kernel/mm/transparent_hugepage/enabled
49
+ echo advise | sudo tee /sys/kernel/mm/transparent_hugepage/shmem_enabled
50
+ echo defer+madvise | sudo tee /sys/kernel/mm/transparent_hugepage/defrag
51
+ echo 1 | sudo tee /sys/kernel/mm/transparent_hugepage/khugepaged/defrag
52
+
53
+ # tune filesystem mount options, https://www.kernel.org/doc/Documentation/filesystems/ext4.txt
54
+ # commit=999999, effectively disables automatic syncing to disk (default is every 5 seconds)
55
+ # nobarrier/barrier=0, loosen data consistency on system crash (no negative impact to empheral CI nodes)
56
+ sudo mount -o remount,nodiscard,commit=999999,barrier=0 / || true
57
+ sudo mount -o remount,nodiscard,commit=999999,barrier=0 /mnt || true
58
+ # disable discard/trim at device level since remount with nodiscard doesn't seem to be effective
59
+ # https://www.spinics.net/lists/linux-ide/msg52562.html
60
+ for i in /sys/block/sd*/queue/discard_max_bytes; do
61
+ echo 0 | sudo tee $i
62
+ done
63
+ # disable any background jobs that run SSD discard/trim
64
+ sudo systemctl disable fstrim.timer || true
65
+ sudo systemctl stop fstrim.timer || true
66
+ sudo systemctl disable fstrim.service || true
67
+ sudo systemctl stop fstrim.service || true
68
+
69
+ # stop php-fpm
70
+ sudo systemctl stop php8.0-fpm.service || true
71
+ sudo systemctl stop php7.4-fpm.service || true
72
+ # stop mono-xsp4
73
+ sudo systemctl disable mono-xsp4.service || true
74
+ sudo systemctl stop mono-xsp4.service || true
75
+ sudo killall mono || true
76
+
77
+ # stop Azure Linux agent to save RAM
78
+ sudo systemctl stop walinuxagent.service || true
79
+ echo '::endgroup::'
80
+
81
+ # show memory
82
+ echo "::group::Available Memory"
83
+ free -m
84
+ echo '::endgroup::'
85
+ # show disk
86
+ echo "::group::Available diskspace"
87
+ df -BM
88
+ echo "::endgroup::"
89
+ # show cggroup
90
+ echo "::group::Cgroup settings for current cgroup $CURRENT_CGGROUP"
91
+ CURRENT_CGGROUP=$(cat /proc/self/cgroup | grep '0::' | awk -F: '{ print $3 }')
92
+ sudo cgget -a $CURRENT_CGGROUP || true
93
+ echo '::endgroup::'
94
+ fi
95
+ shell: bash
.github/changes-filter.yaml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # contains pattern definitions used in workflows "changes" step
2
+ # pattern syntax: https://github.com/micromatch/picomatch
3
+ all:
4
+ - '**'
5
+ docs:
6
+ - 'site3/**'
7
+ - '.asf.yaml'
8
+ - '*.md'
9
+ - '**/*.md'
10
+ - '.github/changes-filter.yaml'
11
+ - '.github/ISSUE_TEMPLATE/**'
12
+ - 'src/owasp-dependency-check-suppressions.xml'
13
+ need_owasp:
14
+ - 'pom.xml'
15
+ - '**/pom.xml'
16
+ - 'src/owasp-dependency-check-false-positives.xml'
17
+ - 'src/owasp-dependency-check-suppressions.xml'
.github/workflows/README.md ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+
3
+ Licensed to the Apache Software Foundation (ASF) under one
4
+ or more contributor license agreements. See the NOTICE file
5
+ distributed with this work for additional information
6
+ regarding copyright ownership. The ASF licenses this file
7
+ to you under the Apache License, Version 2.0 (the
8
+ "License"); you may not use this file except in compliance
9
+ with the License. You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing,
14
+ software distributed under the License is distributed on an
15
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ KIND, either express or implied. See the License for the
17
+ specific language governing permissions and limitations
18
+ under the License.
19
+
20
+ -->
21
+
22
+ ## GitHub Workflows
23
+
24
+ This directory contains all BookKeeper CI checks.
25
+
26
+ ### Required Workflows
27
+
28
+ When adding new CI workflows, please update the [.asf.yaml](../../.asf.yaml) if the workflow is required to pass before
29
+ a PR can be merged. Instructions on how to update the file are below.
30
+
31
+ This project uses the [.asf.yaml](../../.asf.yaml) to configure which workflows are required to pass before a PR can
32
+ be merged. In the `.asf.yaml`, the required contexts are defined in the `github.protected_branches.*.required_status_checks.contexts.[]`
33
+ where * is any key in the `protected_branches` map.
34
+
35
+ You can view the currently required status checks by running the following command:
36
+
37
+ ```shell
38
+ curl -s -H 'Accept: application/vnd.github.v3+json' https://api.github.com/repos/apache/bookkeeper/branches/master | \
39
+ jq .protection
40
+ ```
41
+
42
+ These contexts get their names in one of two ways depending on how the workflow file is written in this directory. The
43
+ following command will print out the names of each file and the associated with the check. If the `name` field is `null`,
44
+ the context will be named by the `id`.
45
+
46
+ ```shell
47
+ for f in .github/workflows/*.yaml .github/workflows/*.yml; \
48
+ do FILE=$f yq eval -o j '.jobs | to_entries | {"file": env(FILE),"id":.[].key, "name":.[].value.name}' $f; \
49
+ done
50
+ ```
51
+
52
+ Duplicate names are allowed, and all checks with the same name will be treated the same (required or not required).
53
+
54
+ When working on workflow changes, one way to find out the names of the status checks is to retrieve the names
55
+ from the PR build run. The "check-runs" can be found by commit id. Here's an example:
56
+
57
+ ```shell
58
+ curl -s "https://api.github.com/repos/apache/bookkeeper/commits/$(git rev-parse HEAD)/check-runs" | \
59
+ jq -r '.check_runs | .[] | .name' |sort
60
+ ```
.github/workflows/bk-ci.yml ADDED
@@ -0,0 +1,604 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+
20
+ name: BookKeeper CI
21
+
22
+ on:
23
+ pull_request:
24
+ branches:
25
+ - master
26
+ - branch-*
27
+ push:
28
+ branches:
29
+ - master
30
+ - branch-*
31
+ workflow_dispatch:
32
+
33
+ env:
34
+ MAVEN_OPTS: -Xss1500k -Xmx1500m -Daether.connector.http.reuseConnections=false -Daether.connector.requestTimeout=60000 -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.http.retryHandler.requestSentEnabled=true -Dmaven.wagon.http.serviceUnavailableRetryStrategy.class=standard -Dmaven.wagon.rto=60000
35
+ NIST_NVD_API_KEY: ${{ secrets.NIST_NVD_API_KEY }}
36
+
37
+ concurrency:
38
+ group: ${{ github.workflow }}-${{ github.ref }}
39
+ cancel-in-progress: true
40
+
41
+ jobs:
42
+ build-and-license-check:
43
+ name: PR Validation
44
+ runs-on: ubuntu-latest
45
+ timeout-minutes: 60
46
+ steps:
47
+ - name: Checkout
48
+ uses: actions/checkout@v4
49
+
50
+ - name: Tune Runner VM
51
+ uses: ./.github/actions/tune-runner-vm
52
+
53
+ - name: Detect changed files
54
+ id: changes
55
+ uses: apache/pulsar-test-infra/paths-filter@master
56
+ with:
57
+ filters: .github/changes-filter.yaml
58
+ list-files: csv
59
+
60
+ - name: Check changed files
61
+ id: check_changes
62
+ run: |
63
+ echo "docs_only=${{ fromJSON(steps.changes.outputs.all_count) == fromJSON(steps.changes.outputs.docs_count) && fromJSON(steps.changes.outputs.docs_count) > 0 }}" >> $GITHUB_OUTPUT
64
+ echo "need_owasp=${{ fromJSON(steps.changes.outputs.need_owasp) }}" >> $GITHUB_OUTPUT
65
+
66
+ - name: Cache local Maven repository
67
+ if: steps.check_changes.outputs.docs_only != 'true'
68
+ id: cache
69
+ uses: actions/cache@v4
70
+ with:
71
+ path: |
72
+ ~/.m2/repository/*/*/*
73
+ !~/.m2/repository/org/apache/bookkeeper
74
+ !~/.m2/repository/org/apache/distributedlog
75
+ key: ${{ runner.os }}-bookkeeper-all-${{ hashFiles('**/pom.xml') }}
76
+
77
+ - name: Set up JDK 11
78
+ if: steps.check_changes.outputs.docs_only != 'true'
79
+ uses: actions/setup-java@v4
80
+ with:
81
+ distribution: 'temurin'
82
+ java-version: 11
83
+
84
+ - name: Validate pull request
85
+ if: steps.check_changes.outputs.docs_only != 'true'
86
+ run: |
87
+ mvn -T 1C -B -nsu clean install -Ddistributedlog -DskipTests
88
+ mvn -T 1C -B -nsu apache-rat:check checkstyle:check spotbugs:check spotless:check package -Ddistributedlog -DskipTests
89
+
90
+ - name: Check license files
91
+ if: steps.check_changes.outputs.docs_only != 'true'
92
+ run: dev/check-all-licenses
93
+
94
+ - name: Generate Javadoc
95
+ if: steps.check_changes.outputs.docs_only != 'true'
96
+ run: mvn -B -nsu -am -pl bookkeeper-common,bookkeeper-server,:bookkeeper-stats-api,:bookkeeper-stats-providers,:codahale-metrics-provider,:prometheus-metrics-provider javadoc:aggregate -DskipTests -Pdelombok -Dchesktyle.skip -Dspotbugs.skip
97
+ outputs:
98
+ docs_only: ${{ steps.check_changes.outputs.docs_only }}
99
+ need_owasp: ${{ steps.check_changes.outputs.need_owasp }}
100
+
101
+ unit-tests:
102
+ name: ${{ matrix.step_name }}
103
+ runs-on: ubuntu-latest
104
+ timeout-minutes: ${{ matrix.timeout || 60 }}
105
+ needs: [ 'build-and-license-check' ]
106
+ if: ${{ needs.build-and-license-check.outputs.docs_only != 'true' }}
107
+ strategy:
108
+ fail-fast: false
109
+ matrix:
110
+ include:
111
+ - step_name: Bookie Tests
112
+ module: bookkeeper-server
113
+ flag: bookie
114
+ test_args: "-Dtest='org.apache.bookkeeper.bookie.**'"
115
+ - step_name: Client Tests
116
+ module: bookkeeper-server
117
+ flag: client
118
+ test_args: "-Dtest='org.apache.bookkeeper.client.**'"
119
+ timeout: 75
120
+ - step_name: Replication Tests
121
+ module: bookkeeper-server
122
+ flag: replication
123
+ test_args: "-Dtest='org.apache.bookkeeper.replication.**'"
124
+ - step_name: Remaining Tests
125
+ module: bookkeeper-server
126
+ flag: remaining
127
+ test_args: "-Dtest='!org.apache.bookkeeper.client.**,!org.apache.bookkeeper.bookie.**,!org.apache.bookkeeper.replication.**,!org.apache.bookkeeper.tls.**'"
128
+ - step_name: TLS Tests
129
+ module: bookkeeper-server
130
+ flag: tls
131
+ test_args: "-Dtest='org.apache.bookkeeper.tls.**'"
132
+ - step_name: StreamStorage Tests
133
+ test_args: "-f stream/pom.xml -DstreamTests"
134
+ flag: stream
135
+ - step_name: Shell tests
136
+ module: tests/scripts
137
+ flag: shell
138
+
139
+ steps:
140
+ - name: checkout
141
+ uses: actions/checkout@v4
142
+
143
+ - name: Tune Runner VM
144
+ uses: ./.github/actions/tune-runner-vm
145
+
146
+ - name: Cache local Maven repository
147
+ id: cache
148
+ uses: actions/cache@v4
149
+ with:
150
+ path: |
151
+ ~/.m2/repository/*/*/*
152
+ !~/.m2/repository/org/apache/bookkeeper
153
+ !~/.m2/repository/org/apache/distributedlog
154
+ key: ${{ runner.os }}-bookkeeper-all-${{ hashFiles('**/pom.xml') }}
155
+
156
+ - name: Set up JDK 11
157
+ uses: actions/setup-java@v4
158
+ with:
159
+ distribution: 'temurin'
160
+ java-version: 11
161
+
162
+ - name: Tune Java DNS TTL settings
163
+ run: |
164
+ sudo tee -a $JAVA_HOME/conf/security/java.security <<EOF
165
+ networkaddress.cache.ttl=1
166
+ networkaddress.cache.negative.ttl=1
167
+ EOF
168
+
169
+ - name: Build
170
+ run: |
171
+ projects_list=
172
+ if [[ ! -z "${{ matrix.module }}" ]]; then
173
+ projects_list="-pl ${{ matrix.module }}"
174
+ fi
175
+ mvn -q -T 1C -B -nsu $projects_list install -am -DskipTests -Dcheckstyle.skip -Dspotbugs.skip -Drat.skip -Dmaven.javadoc.skip
176
+
177
+ - name: Test - ${{ matrix.step_name }}
178
+ run: |
179
+ projects_list=
180
+ if [[ ! -z "${{ matrix.module }}" ]]; then
181
+ projects_list="-pl ${{ matrix.module }}"
182
+ fi
183
+ mvn -B -nsu $projects_list verify ${{ matrix.test_args }}
184
+
185
+ - name: Aggregates all test reports to ./test-reports and ./surefire-reports directories
186
+ if: ${{ always() }}
187
+ uses: ./.github/actions/copy-test-reports
188
+
189
+ - name: Publish Test Report
190
+ uses: apache/pulsar-test-infra/action-junit-report@master
191
+ if: ${{ always() }}
192
+ with:
193
+ report_paths: 'surefire-reports/TEST-*.xml'
194
+ annotate_only: 'true'
195
+
196
+ - name: Upload Surefire reports
197
+ uses: actions/upload-artifact@v4
198
+ if: failure()
199
+ continue-on-error: true
200
+ with:
201
+ name: unit-${{ matrix.step_name }}-reports
202
+ path: surefire-reports
203
+ retention-days: 7
204
+
205
+ - name: print JVM thread dumps when cancelled
206
+ if: cancelled()
207
+ run: ./dev/ci-tool print_thread_dumps
208
+
209
+ integration-tests:
210
+ name: Integration Tests
211
+ runs-on: ubuntu-latest
212
+ timeout-minutes: 75
213
+ needs: [ 'build-and-license-check' ]
214
+ if: ${{ needs.build-and-license-check.outputs.docs_only != 'true' }}
215
+ steps:
216
+ - name: Checkout
217
+ uses: actions/checkout@v4
218
+
219
+ - name: Tune Runner VM
220
+ uses: ./.github/actions/tune-runner-vm
221
+
222
+ - name: Clean Disk
223
+ uses: ./.github/actions/clean-disk
224
+ with:
225
+ mode: full
226
+
227
+ - name: Cache local Maven repository
228
+ id: cache
229
+ uses: actions/cache@v4
230
+ with:
231
+ path: |
232
+ ~/.m2/repository/*/*/*
233
+ !~/.m2/repository/org/apache/bookkeeper
234
+ !~/.m2/repository/org/apache/distributedlog
235
+ key: ${{ runner.os }}-bookkeeper-all-${{ hashFiles('**/pom.xml') }}
236
+
237
+ - name: Set up JDK 11
238
+ uses: actions/setup-java@v4
239
+ with:
240
+ distribution: 'temurin'
241
+ java-version: 11
242
+
243
+ - name: Tune Java DNS TTL settings
244
+ run: |
245
+ sudo tee -a $JAVA_HOME/conf/security/java.security <<EOF
246
+ networkaddress.cache.ttl=1
247
+ networkaddress.cache.negative.ttl=1
248
+ EOF
249
+
250
+ - name: Pick ubuntu mirror for the docker image build
251
+ run: |
252
+ # pick the closest ubuntu mirror and set it to UBUNTU_MIRROR environment variable
253
+ $GITHUB_WORKSPACE/dev/ci-tool pick_ubuntu_mirror
254
+
255
+ - name: Build with Maven
256
+ run: mvn -B -nsu clean install -Pdocker -DskipTests
257
+
258
+ - name: Run metadata driver tests
259
+ # Exclude jetcd-core-shaded from integration tests, as it’s a POM-only project used internally,
260
+ # and maven prioritizes workspace artifacts during testing.
261
+ run: mvn -B -nsu -f metadata-drivers/pom.xml -pl '!jetcd-core-shaded' test -DintegrationTests
262
+
263
+ - name: Run all integration tests (except backward compatibility tests)
264
+ run: |
265
+ mvn -B -nsu -f tests/pom.xml test -DintegrationTests -DredirectTestOutputToFile=false -DtestRetryCount=0
266
+
267
+ - name: print JVM thread dumps when cancelled
268
+ if: cancelled()
269
+ run: ./dev/ci-tool print_thread_dumps
270
+
271
+ - name: Upload container logs on failure
272
+ uses: actions/upload-artifact@v4
273
+ if: ${{ !success() }}
274
+ continue-on-error: true
275
+ with:
276
+ retention-days: 7
277
+ name: integration-tests-container-logs
278
+ if-no-files-found: ignore
279
+ path: |
280
+ **/docker.log
281
+
282
+ - name: Aggregates all test reports to ./test-reports and ./surefire-reports directories
283
+ if: ${{ always() }}
284
+ uses: ./.github/actions/copy-test-reports
285
+
286
+ - name: Publish Test Report
287
+ uses: apache/pulsar-test-infra/action-junit-report@master
288
+ if: ${{ always() }}
289
+ with:
290
+ report_paths: 'surefire-reports/TEST-*.xml'
291
+ annotate_only: 'true'
292
+
293
+ - name: Upload Surefire reports
294
+ uses: actions/upload-artifact@v4
295
+ if: failure()
296
+ continue-on-error: true
297
+ with:
298
+ name: integration-tests-reports
299
+ path: surefire-reports
300
+ if-no-files-found: ignore
301
+ retention-days: 7
302
+
303
+ backward-compatibility-tests:
304
+ name: Backward compatibility tests
305
+ runs-on: ubuntu-latest
306
+ timeout-minutes: 75
307
+ needs: [ 'build-and-license-check' ]
308
+ if: ${{ needs.build-and-license-check.outputs.docs_only != 'true' }}
309
+ steps:
310
+ - name: Checkout
311
+ uses: actions/checkout@v4
312
+
313
+ - name: Tune Runner VM
314
+ uses: ./.github/actions/tune-runner-vm
315
+
316
+ - name: Clean Disk
317
+ uses: ./.github/actions/clean-disk
318
+ with:
319
+ mode: full
320
+
321
+ - name: Cache local Maven repository
322
+ id: cache
323
+ uses: actions/cache@v4
324
+ with:
325
+ path: |
326
+ ~/.m2/repository/*/*/*
327
+ !~/.m2/repository/org/apache/bookkeeper
328
+ !~/.m2/repository/org/apache/distributedlog
329
+ key: ${{ runner.os }}-bookkeeper-all-${{ hashFiles('**/pom.xml') }}
330
+
331
+ - name: Set up JDK 8
332
+ uses: actions/setup-java@v4
333
+ with:
334
+ distribution: 'temurin'
335
+ java-version: 8
336
+
337
+ - name: Pick ubuntu mirror for the docker image build
338
+ run: |
339
+ # pick the closest ubuntu mirror and set it to UBUNTU_MIRROR environment variable
340
+ $GITHUB_WORKSPACE/dev/ci-tool pick_ubuntu_mirror
341
+
342
+ - name: Build with Maven
343
+ run: mvn -B -nsu clean install -Pdocker -DskipTests
344
+
345
+ - name: Test current server with old clients
346
+ run: mvn -B -nsu -DbackwardCompatTests -DfailIfNoTests -pl :backward-compat-current-server-old-clients test
347
+
348
+ - name: Test progressive upgrade
349
+ run: mvn -B -nsu -DbackwardCompatTests -DfailIfNoTests -pl :upgrade test
350
+
351
+ - name: Other tests
352
+ run: |
353
+ mvn -B -nsu -DbackwardCompatTests -DfailIfNoTests -pl :bc-non-fips,:hierarchical-ledger-manager,:hostname-bookieid,:old-cookie-new-cluster,:recovery-no-password,:upgrade-direct test
354
+
355
+ - name: Upload container logs on failure
356
+ uses: actions/upload-artifact@v4
357
+ if: ${{ !success() }}
358
+ continue-on-error: true
359
+ with:
360
+ retention-days: 7
361
+ name: backward-compatibility-tests-container-logs
362
+ if-no-files-found: ignore
363
+ path: |
364
+ **/docker.log
365
+
366
+ - name: Aggregates all test reports to ./test-reports and ./surefire-reports directories
367
+ if: ${{ always() }}
368
+ uses: ./.github/actions/copy-test-reports
369
+
370
+ - name: Publish Test Report
371
+ uses: apache/pulsar-test-infra/action-junit-report@master
372
+ if: ${{ always() }}
373
+ with:
374
+ report_paths: 'surefire-reports/TEST-*.xml'
375
+ annotate_only: 'true'
376
+
377
+ - name: Upload Surefire reports
378
+ uses: actions/upload-artifact@v4
379
+ if: failure()
380
+ continue-on-error: true
381
+ with:
382
+ name: backward-compatibility-tests-reports
383
+ path: surefire-reports
384
+ if-no-files-found: ignore
385
+ retention-days: 7
386
+
387
+ windows-build:
388
+ name: Build with windows on JDK 11
389
+ runs-on: windows-latest
390
+ timeout-minutes: 30
391
+ needs: [ 'build-and-license-check' ]
392
+ if: ${{ needs.build-and-license-check.outputs.docs_only != 'true' }}
393
+ steps:
394
+ - name: Checkout
395
+ uses: actions/checkout@v4
396
+
397
+ - name: Tune Runner VM
398
+ uses: ./.github/actions/tune-runner-vm
399
+
400
+ - name: Install mingw
401
+ run: choco install mingw
402
+
403
+ - name: Cache local Maven repository
404
+ id: cache
405
+ uses: actions/cache@v4
406
+ with:
407
+ path: |
408
+ ~/.m2/repository/*/*/*
409
+ !~/.m2/repository/org/apache/bookkeeper
410
+ !~/.m2/repository/org/apache/distributedlog
411
+ key: ${{ runner.os }}-bookkeeper-all-${{ hashFiles('**/pom.xml') }}
412
+
413
+ - name: Set up JDK 11
414
+ uses: actions/setup-java@v4
415
+ with:
416
+ distribution: 'temurin'
417
+ java-version: 11
418
+
419
+ - name: mvn package
420
+ run: mvn -B -nsu clean package -DskipTests
421
+
422
+ macos-build:
423
+ name: Build with macos on JDK 11
424
+ runs-on: macos-latest
425
+ timeout-minutes: 30
426
+ needs: [ 'build-and-license-check' ]
427
+ if: ${{ needs.build-and-license-check.outputs.docs_only != 'true' }}
428
+ steps:
429
+ - name: Checkout
430
+ uses: actions/checkout@v4
431
+
432
+ - name: Tune Runner VM
433
+ uses: ./.github/actions/tune-runner-vm
434
+
435
+ - name: Cache local Maven repository
436
+ id: cache
437
+ uses: actions/cache@v4
438
+ with:
439
+ path: |
440
+ ~/.m2/repository/*/*/*
441
+ !~/.m2/repository/org/apache/bookkeeper
442
+ !~/.m2/repository/org/apache/distributedlog
443
+ key: ${{ runner.os }}-bookkeeper-all-${{ hashFiles('**/pom.xml') }}
444
+
445
+ - name: Set up JDK 11
446
+ uses: actions/setup-java@v4
447
+ with:
448
+ distribution: 'temurin'
449
+ java-version: 11
450
+
451
+ - name: mvn package
452
+ run: mvn -B -nsu clean package -DskipTests
453
+
454
+ jdk-compatibility-checks:
455
+ name: ${{ matrix.step_name }}
456
+ runs-on: ubuntu-latest
457
+ timeout-minutes: ${{ matrix.timeout || 60 }}
458
+ needs: [ 'build-and-license-check' ]
459
+ if: ${{ needs.build-and-license-check.outputs.docs_only != 'true' }}
460
+ strategy:
461
+ fail-fast: false
462
+ matrix:
463
+ include:
464
+ - step_name: Compatibility Check Java8
465
+ jdk_version: 8
466
+ - step_name: Compatibility Check Java11
467
+ jdk_version: 11
468
+ - step_name: Compatibility Check Java17
469
+ jdk_version: 17
470
+ - step_name: Compatibility Check Java21
471
+ jdk_version: 21
472
+
473
+ steps:
474
+ - name: checkout
475
+ uses: actions/checkout@v4
476
+
477
+ - name: Tune Runner VM
478
+ uses: ./.github/actions/tune-runner-vm
479
+
480
+ - name: Cache local Maven repository
481
+ id: cache
482
+ uses: actions/cache@v4
483
+ with:
484
+ path: |
485
+ ~/.m2/repository/*/*/*
486
+ !~/.m2/repository/org/apache/bookkeeper
487
+ !~/.m2/repository/org/apache/distributedlog
488
+ key: ${{ runner.os }}-bookkeeper-all-${{ hashFiles('**/pom.xml') }}
489
+
490
+ - name: Set up JDK ${{ matrix.jdk_version }}
491
+ uses: actions/setup-java@v4
492
+ with:
493
+ distribution: 'temurin'
494
+ java-version: ${{ matrix.jdk_version }}
495
+
496
+ - name: Build with Maven
497
+ run: mvn clean package -B -nsu -DskipBookKeeperServerTests
498
+
499
+ - name: print JVM thread dumps when cancelled
500
+ if: cancelled()
501
+ run: ./dev/ci-tool print_thread_dumps
502
+
503
+ typo-check:
504
+ name: Typo Check
505
+ # only run on pull requests because of security reasons
506
+ # we shouldn't trust external actions for builds within the repository
507
+ if: ${{ github.event_name == 'pull_request' }}
508
+ runs-on: ubuntu-latest
509
+ steps:
510
+ - uses: actions/checkout@v4
511
+ - name: Check typos
512
+ uses: crate-ci/typos@v1.22.4
513
+
514
+ owasp-dependency-check:
515
+ name: OWASP Dependency Check
516
+ runs-on: ubuntu-latest
517
+ timeout-minutes: 60
518
+ needs: [ 'build-and-license-check' ]
519
+ if: ${{ needs.build-and-license-check.outputs.need_owasp == 'true' }}
520
+ steps:
521
+ - name: Checkout
522
+ uses: actions/checkout@v4
523
+
524
+ - name: Tune Runner VM
525
+ uses: ./.github/actions/tune-runner-vm
526
+
527
+ - name: Cache local Maven repository
528
+ id: cache
529
+ uses: actions/cache@v4
530
+ with:
531
+ path: |
532
+ ~/.m2/repository/*/*/*
533
+ !~/.m2/repository/org/apache/bookkeeper
534
+ !~/.m2/repository/org/apache/distributedlog
535
+ key: ${{ runner.os }}-bookkeeper-all-${{ hashFiles('**/pom.xml') }}
536
+
537
+ - name: Set up JDK 11
538
+ uses: actions/setup-java@v4
539
+ with:
540
+ distribution: 'temurin'
541
+ java-version: 21
542
+
543
+ - name: run "clean install verify" to trigger dependency check
544
+ # excluding dlfs because it includes hadoop lib with
545
+ # CVEs that we cannot patch up anyway
546
+ run: mvn -q -B -ntp clean install verify -Powasp-dependency-check -DskipTests -pl '!stream/distributedlog/io/dlfs,!tests'
547
+
548
+ - name: Upload report
549
+ uses: actions/upload-artifact@v4
550
+ if: ${{ cancelled() || failure() }}
551
+ continue-on-error: true
552
+ with:
553
+ name: dependency report
554
+ path: target/dependency-check-report.html
555
+ retention-days: 7
556
+
557
+ bookkeeper-ci-checks-completed:
558
+ name: "BookKeeper CI checks completed"
559
+ if: ${{ always() && ((github.event_name != 'schedule') || (github.repository == 'apache/bookkeeper')) }}
560
+ runs-on: ubuntu-latest
561
+ timeout-minutes: 10
562
+ needs: [
563
+ 'backward-compatibility-tests',
564
+ 'build-and-license-check',
565
+ 'integration-tests',
566
+ 'jdk-compatibility-checks',
567
+ 'macos-build',
568
+ 'owasp-dependency-check',
569
+ 'typo-check',
570
+ 'unit-tests',
571
+ 'windows-build'
572
+ ]
573
+ steps:
574
+ - name: Check build-and-license-check success
575
+ run: |
576
+ if [[ ! ( \
577
+ "${{ needs.build-and-license-check.result }}" == "success" \
578
+ ) ]]; then
579
+ echo "Required jobs haven't been completed successfully."
580
+ exit 1
581
+ fi
582
+ - name: Check typo-check success for pull requests
583
+ if: ${{ github.event_name == 'pull_request' }}
584
+ run: |
585
+ if [[ ! ( \
586
+ "${{ needs.typo-check.result }}" == "success" \
587
+ ) ]]; then
588
+ echo "Required jobs haven't been completed successfully."
589
+ exit 1
590
+ fi
591
+ - name: Check that other required jobs were completed successfully
592
+ if: ${{ needs.build-and-license-check.outputs.docs_only != 'true' }}
593
+ run: |
594
+ if [[ ! ( \
595
+ "${{ needs.backward-compatibility-tests.result }}" == "success" \
596
+ && "${{ needs.integration-tests.result }}" == "success" \
597
+ && "${{ needs.jdk-compatibility-checks.result }}" == "success" \
598
+ && "${{ needs.macos-build.result }}" == "success" \
599
+ && "${{ needs.unit-tests.result }}" == "success" \
600
+ && "${{ needs.windows-build.result }}" == "success" \
601
+ ) ]]; then
602
+ echo "Required jobs haven't been completed successfully."
603
+ exit 1
604
+ fi
.github/workflows/bk-streamstorage-python.yml ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+
20
+ name: BookKeeper StreamStorage Python Client
21
+ on:
22
+ pull_request:
23
+ branches:
24
+ - master
25
+ - branch-*
26
+ paths:
27
+ - 'stream/**'
28
+ - '.github/workflows/bk-streamstorage-python.yml'
29
+ push:
30
+ branches:
31
+ - master
32
+ - branch-*
33
+ paths:
34
+ - 'stream/**'
35
+ - '.github/workflows/bk-streamstorage-python.yml'
36
+
37
+ jobs:
38
+ stream-storage-python-client-unit-tests:
39
+ name: StreamStorage Python Client Unit Tests
40
+ runs-on: ubuntu-latest
41
+ timeout-minutes: 60
42
+ steps:
43
+ - name: checkout
44
+ uses: actions/checkout@v4
45
+ - name: Tune Runner VM
46
+ uses: ./.github/actions/tune-runner-vm
47
+ - name: Test
48
+ run: ./stream/clients/python/scripts/test.sh
49
+
50
+
51
+ Stream-storage-python-client-integration-tests:
52
+ name: StreamStorage Python Client Integration Tests
53
+ runs-on: ubuntu-latest
54
+ timeout-minutes: 60
55
+ steps:
56
+ - name: checkout
57
+ uses: actions/checkout@v4
58
+ - name: Tune Runner VM
59
+ uses: ./.github/actions/tune-runner-vm
60
+ - name: Cache local Maven repository
61
+ id: cache
62
+ uses: actions/cache@v4
63
+ with:
64
+ path: |
65
+ ~/.m2/repository/*/*/*
66
+ !~/.m2/repository/org/apache/bookkeeper
67
+ !~/.m2/repository/org/apache/distributedlog
68
+ key: ${{ runner.os }}-bookkeeper-all-${{ hashFiles('**/pom.xml') }}
69
+ - name: Set up JDK 11
70
+ uses: actions/setup-java@v4
71
+ with:
72
+ distribution: 'temurin'
73
+ java-version: 11
74
+ - name: Build
75
+ run: mvn -q -T 1C -B -nsu clean install -DskipTests -Dcheckstyle.skip -Dspotbugs.skip -Drat.skip -Dmaven.javadoc.skip
76
+ - name: Pick ubuntu mirror for the docker image build
77
+ run: |
78
+ # pick the closest ubuntu mirror and set it to UBUNTU_MIRROR environment variable
79
+ $GITHUB_WORKSPACE/dev/ci-tool pick_ubuntu_mirror
80
+ - name: Build Test image
81
+ run: ./stream/clients/python/docker/build-local-image.sh
82
+ - name: Test
83
+ run: ./stream/clients/python/scripts/docker_integration_tests.sh
84
+
85
+
.github/workflows/bot.yml ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+
20
+ name: Bot tests
21
+ on:
22
+ issue_comment:
23
+ types: [created]
24
+
25
+ jobs:
26
+ bot:
27
+ name: Bot tests
28
+ runs-on: ubuntu-latest
29
+
30
+ steps:
31
+ - name: clone repository
32
+ uses: actions/checkout@v4
33
+
34
+ - name: bot actions
35
+ uses: actions/github-script@v7
36
+ env:
37
+ RERUN_CMD: 'rerun failure checks'
38
+ with:
39
+ github-token: ${{secrets.BKBOT_TOKEN}}
40
+ script: |
41
+ const path = require('path')
42
+ const scriptPath = path.resolve('.github/actions/bot/src/run.js')
43
+ require(scriptPath)({core}, {context}, {github})
.github/workflows/ci-bkbot.yaml ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+ #
18
+ # Description:
19
+ # This GitHub Actions workflow enables rerunning CI via PR/Issue comments using the /bkbot command.
20
+ # Supported commands: /bkbot rerun [keyword]
21
+ # - /bkbot rerun => Rerun the latest run of each workflow under the same head SHA, limited to runs with a conclusion of failure/cancelled/timed_out/skipped (entire run).
22
+ # - /bkbot rerun <keyword> => Regardless of workflow/job status, fetch all jobs in the latest runs, match by name, and rerun each matching job.
23
+ # Logging instructions:
24
+ # - Jobs that are failed/cancelled/timed_out/skipped are scanned from all the latest workflow runs (including those in progress), thus jobs fail/skipped during progress can be captured.
25
+ # Triggering condition: When a new comment is created containing /bkbot.
26
+
27
+ name: BookKeeper Bot
28
+ on:
29
+ issue_comment:
30
+ types: [created]
31
+
32
+ permissions:
33
+ actions: write
34
+ contents: read
35
+
36
+ jobs:
37
+ bkbot:
38
+ runs-on: ubuntu-24.04
39
+ timeout-minutes: 10
40
+ if: github.event_name == 'issue_comment' && contains(github.event.comment.body, '/bkbot')
41
+ steps:
42
+ - name: Execute bkbot command
43
+ uses: actions/github-script@v7
44
+ with:
45
+ github-token: ${{ secrets.GITHUB_TOKEN }}
46
+ script: |
47
+ // Supported commands:
48
+ // - /bkbot rerun
49
+ // Reruns all completed workflows with conclusions of failure/timed_out/skipped/cancelled
50
+ // If workflow is still running, cannot rerun whole workflow, just suggest using "/bkbot rerun jobname"
51
+ // - /bkbot rerun jobname
52
+ // Matches job.name by keyword, reruns matching jobs (regardless of current state, failures are logged)
53
+ // - /bkbot stop or /bkbot cancel
54
+ // Cancels all still running (queued/in_progress) workflow runs associated with the current PR
55
+
56
+ const commentBody = context.payload.comment.body.trim();
57
+ const prefix = '/bkbot';
58
+ if (!commentBody.startsWith(prefix)) {
59
+ console.log('Not a bkbot command, skipping ...');
60
+ return;
61
+ }
62
+
63
+ if (!context.payload.issue || !context.payload.issue.pull_request) {
64
+ console.error('This comment is not on a Pull Request. bkbot only works on PRs.');
65
+ return;
66
+ }
67
+
68
+ const parts = commentBody.split(/\s+/);
69
+ const sub = (parts[1] || '').toLowerCase();
70
+ const arg = parts.length > 2 ? parts.slice(2).join(' ') : '';
71
+
72
+ const supported = ['rerun', 'stop', 'cancel'];
73
+ if (!supported.includes(sub)) {
74
+ console.log(`Unsupported command '${sub}'. Supported: '/bkbot rerun [jobName?]', '/bkbot stop', '/bkbot cancel'.`);
75
+ return;
76
+ }
77
+
78
+ const prNum = context.payload.issue.number;
79
+
80
+ // Get PR info
81
+ let pr;
82
+ try {
83
+ ({ data: pr } = await github.rest.pulls.get({
84
+ owner: context.repo.owner,
85
+ repo: context.repo.repo,
86
+ pull_number: prNum
87
+ }));
88
+ } catch (e) {
89
+ console.error(`Failed to fetch PR #${prNum}: ${e.message}`);
90
+ return;
91
+ }
92
+
93
+ const headSha = pr.head.sha;
94
+ const prBranch = pr.head.ref;
95
+ const prUser = (pr.head && pr.head.user && pr.head.user.login) ? pr.head.user.login : pr.user.login;
96
+ const prUrl = pr.html_url;
97
+
98
+ console.log(`bkbot handling PR #${prNum} ${prUrl}`);
99
+ console.log(`PR branch='${prBranch}', headSha='${headSha}', author='${prUser}'`);
100
+ console.log(`Command parsed => sub='${sub}', arg='${arg || ''}'`);
101
+
102
+ // Fetch workflow runs in this repo triggered by this user on this branch, then filter by headSha
103
+ let page = 1;
104
+ const allRunsRaw = [];
105
+ while (true) {
106
+ const { data } = await github.rest.actions.listWorkflowRunsForRepo({
107
+ owner: context.repo.owner,
108
+ repo: context.repo.repo,
109
+ actor: prUser,
110
+ branch: prBranch,
111
+ per_page: 100,
112
+ page
113
+ });
114
+ const wr = data.workflow_runs || [];
115
+ if (wr.length === 0) break;
116
+ allRunsRaw.push(...wr);
117
+ if (wr.length < 100) break;
118
+ page++;
119
+ }
120
+
121
+ const runsAtHead = allRunsRaw.filter(r => r.head_sha === headSha);
122
+ if (runsAtHead.length === 0) {
123
+ console.error(`No workflow runs found for head SHA ${headSha} on branch ${prBranch}.`);
124
+ return;
125
+ }
126
+
127
+ // Only keep the latest run for each workflow_id
128
+ runsAtHead.sort((a, b) => {
129
+ if (a.workflow_id !== b.workflow_id) return a.workflow_id - b.workflow_id;
130
+ return new Date(b.created_at) - new Date(a.created_at);
131
+ });
132
+ const latestRuns = [];
133
+ const seen = new Set();
134
+ for (const r of runsAtHead) {
135
+ if (!seen.has(r.workflow_id)) {
136
+ seen.add(r.workflow_id);
137
+ latestRuns.push(r);
138
+ }
139
+ }
140
+
141
+ function runKey(r) {
142
+ return `[run_id=${r.id}] ${r.name || '(unnamed)'} | status=${r.status} | conclusion=${r.conclusion || '-'} | ${r.html_url}`;
143
+ }
144
+
145
+ console.log('--- Latest workflow runs for this PR headSHA (one per workflow) ---');
146
+ for (const r of latestRuns) console.log('- ' + runKey(r));
147
+
148
+ // Utility: list all jobs in a run
149
+ async function listAllJobs(runId) {
150
+ let jobs = [];
151
+ let p = 1;
152
+ while (true) {
153
+ const { data } = await github.rest.actions.listJobsForWorkflowRun({
154
+ owner: context.repo.owner,
155
+ repo: context.repo.repo,
156
+ run_id: runId,
157
+ per_page: 100,
158
+ page: p
159
+ });
160
+ const js = data.jobs || [];
161
+ if (js.length === 0) break;
162
+ jobs.push(...js);
163
+ if (js.length < 100) break;
164
+ p++;
165
+ }
166
+ return jobs;
167
+ }
168
+
169
+ // Utility: rerun a single job
170
+ async function rerunJob(job, run) {
171
+ try {
172
+ if (github.rest.actions.reRunJobForWorkflowRun) {
173
+ await github.rest.actions.reRunJobForWorkflowRun({
174
+ owner: context.repo.owner,
175
+ repo: context.repo.repo,
176
+ job_id: job.id
177
+ });
178
+ } else {
179
+ await github.request('POST /repos/{owner}/{repo}/actions/jobs/{job_id}/rerun', {
180
+ owner: context.repo.owner,
181
+ repo: context.repo.repo,
182
+ job_id: job.id
183
+ });
184
+ }
185
+ console.log(`Re-ran job '${job.name}' (job_id=${job.id}) in run '${run.name}' | ${run.html_url}`);
186
+ return true;
187
+ } catch (e) {
188
+ console.log(`Failed to re-run job '${job.name}' (job_id=${job.id}) in run '${run.name}': ${e.message}`);
189
+ return false;
190
+ }
191
+ }
192
+
193
+ // Command 1: /bkbot rerun
194
+ if (sub === 'rerun' && !arg) {
195
+ const targetConclusions = new Set(['failure', 'timed_out', 'cancelled', 'skipped']);
196
+ let fullRerunCount = 0;
197
+ let skippedRunning = 0;
198
+ let skippedConclusion = 0;
199
+
200
+ console.log('Mode: full workflow re-run for completed runs with conclusions in [failure,timed_out,cancelled,skipped].');
201
+ for (const r of latestRuns) {
202
+ if (r.status !== 'completed') {
203
+ console.log(`Skip (still running) ${runKey(r)}. Cannot re-run whole workflow. Consider '/bkbot rerun <jobName>' for single job.`);
204
+ skippedRunning++;
205
+ continue;
206
+ }
207
+ if (!targetConclusions.has(r.conclusion)) {
208
+ console.log(`Skip (conclusion not eligible) ${runKey(r)}`);
209
+ skippedConclusion++;
210
+ continue;
211
+ }
212
+ try {
213
+ await github.rest.actions.reRunWorkflow({
214
+ owner: context.repo.owner,
215
+ repo: context.repo.repo,
216
+ run_id: r.id
217
+ });
218
+ console.log(`Triggered full re-run for ${runKey(r)}`);
219
+ fullRerunCount++;
220
+ } catch (e) {
221
+ console.log(`Failed to trigger full re-run for ${runKey(r)}: ${e.message}`);
222
+ }
223
+ }
224
+
225
+ if (fullRerunCount === 0) {
226
+ console.error(`No eligible workflow runs to re-run. Skipped running=${skippedRunning}, skipped by conclusion=${skippedConclusion}.`);
227
+ } else {
228
+ console.log(`Finished. Triggered full re-run for ${fullRerunCount} workflow run(s). Skipped running=${skippedRunning}, skipped by conclusion=${skippedConclusion}.`);
229
+ }
230
+ return;
231
+ }
232
+
233
+ // Command 2: /bkbot rerun jobname
234
+ if (sub === 'rerun' && arg) {
235
+ const keyword = arg.trim();
236
+ console.log(`Mode: job-level re-run. keyword='${keyword}'`);
237
+
238
+ let matchedJobs = 0;
239
+ let successJobs = 0;
240
+
241
+ for (const r of latestRuns) {
242
+ let jobs = [];
243
+ try {
244
+ jobs = await listAllJobs(r.id);
245
+ } catch (e) {
246
+ console.log(`Failed to list jobs for ${runKey(r)}: ${e.message}`);
247
+ continue;
248
+ }
249
+ for (const j of jobs) {
250
+ if (j.name && j.name.includes(keyword)) {
251
+ matchedJobs++;
252
+ const ok = await rerunJob(j, r);
253
+ if (ok) successJobs++;
254
+ }
255
+ }
256
+ }
257
+
258
+ if (matchedJobs === 0) {
259
+ console.error(`No jobs matched keyword '${keyword}' among latest runs for this PR head.`);
260
+ } else {
261
+ console.log(`Finished. Matched ${matchedJobs} job(s); successfully requested re-run for ${successJobs} job(s).`);
262
+ }
263
+ return;
264
+ }
265
+
266
+ // Command 3: /bkbot stop or /bkbot cancel
267
+ if (sub === 'stop' || sub === 'cancel') {
268
+ console.log('Mode: cancel running workflow runs (queued/in_progress).');
269
+
270
+ let cancelCount = 0;
271
+ let alreadyCompleted = 0;
272
+
273
+ for (const r of latestRuns) {
274
+ if (r.status === 'completed') {
275
+ console.log(`Skip (already completed) ${runKey(r)}`);
276
+ alreadyCompleted++;
277
+ continue;
278
+ }
279
+ try {
280
+ await github.rest.actions.cancelWorkflowRun({
281
+ owner: context.repo.owner,
282
+ repo: context.repo.repo,
283
+ run_id: r.id
284
+ });
285
+ console.log(`Cancel requested for ${runKey(r)}`);
286
+ cancelCount++;
287
+ } catch (e) {
288
+ console.log(`Failed to cancel ${runKey(r)}: ${e.message}`);
289
+ }
290
+ }
291
+
292
+ if (cancelCount === 0) {
293
+ console.error(`No running workflow runs to cancel. Already completed: ${alreadyCompleted}.`);
294
+ } else {
295
+ console.log(`Finished. Requested cancel for ${cancelCount} running workflow run(s). Already completed: ${alreadyCompleted}.`);
296
+ }
297
+ return;
298
+ }
.github/workflows/codeql.yml ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+ name: "CodeQL"
20
+
21
+ on:
22
+ push:
23
+ branches: [ "master" ]
24
+ pull_request:
25
+ branches: [ "master" ]
26
+ schedule:
27
+ - cron: '27 11 * * 6'
28
+
29
+ jobs:
30
+ analyze:
31
+ name: Analyze
32
+ runs-on: 'ubuntu-latest'
33
+ timeout-minutes: 360
34
+ permissions:
35
+ # required for all workflows
36
+ security-events: write
37
+
38
+ # only required for workflows in private repositories
39
+ actions: read
40
+ contents: read
41
+ pull-requests: read
42
+
43
+ strategy:
44
+ fail-fast: false
45
+ matrix:
46
+ language: [ 'c-cpp', 'java-kotlin', 'python' ]
47
+
48
+ steps:
49
+ - name: Checkout repository
50
+ uses: actions/checkout@v4
51
+
52
+ - name: Detect changed files
53
+ id: changes
54
+ uses: apache/pulsar-test-infra/paths-filter@master
55
+ with:
56
+ filters: .github/changes-filter.yaml
57
+ list-files: csv
58
+
59
+ - name: Check changed files
60
+ id: check_changes
61
+ run: |
62
+ echo "docs_only=${{ fromJSON(steps.changes.outputs.all_count) == fromJSON(steps.changes.outputs.docs_count) && fromJSON(steps.changes.outputs.docs_count) > 0 }}" >> $GITHUB_OUTPUT
63
+
64
+ - name: Cache local Maven repository
65
+ if: steps.check_changes.outputs.docs_only != 'true'
66
+ id: cache
67
+ uses: actions/cache@v4
68
+ with:
69
+ path: |
70
+ ~/.m2/repository/*/*/*
71
+ !~/.m2/repository/org/apache/bookkeeper
72
+ !~/.m2/repository/org/apache/distributedlog
73
+ key: ${{ runner.os }}-bookkeeper-all-${{ hashFiles('**/pom.xml') }}
74
+
75
+ # Initializes the CodeQL tools for scanning.
76
+ - name: Initialize CodeQL
77
+ uses: github/codeql-action/init@v3
78
+ with:
79
+ languages: ${{ matrix.language }}
80
+
81
+ - name: Set up JDK 11
82
+ if: steps.check_changes.outputs.docs_only != 'true'
83
+ uses: actions/setup-java@v4
84
+ with:
85
+ distribution: 'temurin'
86
+ java-version: 11
87
+
88
+ - name: Validate pull request
89
+ if: steps.check_changes.outputs.docs_only != 'true'
90
+ run: |
91
+ mvn -T 1C -B -nsu clean install -Ddistributedlog -DskipTests
92
+
93
+ - name: Perform CodeQL Analysis
94
+ if: steps.check_changes.outputs.docs_only != 'true'
95
+ uses: github/codeql-action/analyze@v3
96
+ with:
97
+ category: "/language:${{matrix.language}}"
.github/workflows/dead-link-checker.yaml ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ name: Dead link checker
18
+
19
+ on:
20
+ push:
21
+ pull_request:
22
+ branches:
23
+ - master
24
+ - branch-*
25
+ paths:
26
+ - '**.md'
27
+
28
+ concurrency:
29
+ group: dlc-${{ github.event.pull_request.number || github.ref }}
30
+ cancel-in-progress: true
31
+
32
+ jobs:
33
+ check-dead-links:
34
+ name: Dead link checker
35
+ runs-on: ubuntu-latest
36
+ timeout-minutes: 30
37
+ steps:
38
+ - uses: actions/checkout@v4
39
+ - run: sudo npm install -g markdown-link-check@3.11.2
40
+ - run: |
41
+ for file in $(find . -name "*.md"); do
42
+ markdown-link-check -c .dlc.json -q "$file"
43
+ done
.github/workflows/java21-daily-build.yml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ name: JDK 21 Daily Build
18
+
19
+ on:
20
+ schedule:
21
+ - cron: '0 0 * * *' # Runs at 00:00 UTC every day
22
+ workflow_dispatch:
23
+
24
+ jobs:
25
+ jdk21-daily-build:
26
+ name: Build on JDK 21
27
+ runs-on: ubuntu-latest
28
+ steps:
29
+ - uses: actions/checkout@v4
30
+ - name: Set up JDK 21
31
+ uses: actions/setup-java@v4
32
+ with:
33
+ distribution: 'temurin'
34
+ java-version: 21
35
+ - name: Build with Maven
36
+ run: mvn -B clean install
37
+ - name: Aggregates all test reports to ./test-reports and ./surefire-reports directories If failure
38
+ if: failure()
39
+ continue-on-error: true
40
+ uses: ./.github/actions/copy-test-reports
41
+ - name: Upload Surefire reports
42
+ uses: actions/upload-artifact@v4
43
+ if: failure()
44
+ continue-on-error: true
45
+ with:
46
+ name: jdk21-tests-reports
47
+ path: surefire-reports
.github/workflows/owasp-daily-build.yml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ name: OWASP Daily Build
18
+
19
+ on:
20
+ schedule:
21
+ - cron: '0 0 * * *' # Runs at 00:00 UTC every day
22
+ workflow_dispatch:
23
+
24
+ env:
25
+ NIST_NVD_API_KEY: ${{ secrets.NIST_NVD_API_KEY }}
26
+
27
+ jobs:
28
+ owasp-daily-build:
29
+ name: OWASP Dependency Check
30
+ runs-on: ubuntu-latest
31
+ steps:
32
+ - name: Checkout
33
+ uses: actions/checkout@v4
34
+
35
+ - name: Tune Runner VM
36
+ uses: ./.github/actions/tune-runner-vm
37
+
38
+ - name: Set up JDK 21
39
+ uses: actions/setup-java@v4
40
+ with:
41
+ distribution: 'temurin'
42
+ java-version: 21
43
+
44
+ - name: run "clean install verify" to trigger dependency check
45
+ # excluding dlfs because it includes hadoop lib with
46
+ # CVEs that we cannot patch up anyway
47
+ run: mvn -q -B -ntp clean install verify -Powasp-dependency-check -DskipTests -pl '!stream/distributedlog/io/dlfs,!tests'
.github/workflows/website-deploy.yaml ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+
20
+ name: Website deploy
21
+ on:
22
+ workflow_dispatch:
23
+ push:
24
+ branches:
25
+ - master
26
+ paths:
27
+ - 'site3/**'
28
+ - '.github/workflows/website-deploy.yaml'
29
+
30
+ env:
31
+ DEPLOY_URL: "https://bookkeeper.apache.org/"
32
+
33
+ jobs:
34
+ build-website:
35
+ name: Build and deploy the website
36
+ if: ${{ github.repository == 'apache/bookkeeper' }}
37
+ runs-on: ubuntu-latest
38
+ timeout-minutes: 180
39
+ steps:
40
+ - name: Checkout
41
+ uses: actions/checkout@v4
42
+
43
+ - name: Set up JDK 11
44
+ uses: actions/setup-java@v4
45
+ with:
46
+ distribution: 'temurin'
47
+ java-version: 11
48
+
49
+
50
+ - name: Setup NodeJS
51
+ uses: actions/setup-node@v4
52
+ with:
53
+ node-version: '16'
54
+
55
+ - name: Setup yarn
56
+ run: npm install -g yarn
57
+
58
+ - name: Publish
59
+ env:
60
+ GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
61
+ run: |
62
+ ./site3/website/scripts/build-website.sh
63
+ ./site3/website/scripts/publish-website.sh
.github/workflows/website-pr-validation.yml ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+
20
+ name: Website PR validation
21
+
22
+ on:
23
+ workflow_dispatch:
24
+ pull_request:
25
+ branches:
26
+ - master
27
+ - branch-*
28
+ paths:
29
+ - 'site3/**'
30
+ - '.github/workflows/website-pr-validation.yaml'
31
+
32
+ jobs:
33
+ website-pull-validation:
34
+ runs-on: ubuntu-latest
35
+ timeout-minutes: 60
36
+ steps:
37
+ - name: Checkout
38
+ uses: actions/checkout@v4
39
+
40
+ - name: Set up JDK 11
41
+ uses: actions/setup-java@v4
42
+ with:
43
+ distribution: 'temurin'
44
+ java-version: 11
45
+
46
+
47
+ - name: Setup NodeJS
48
+ uses: actions/setup-node@v4
49
+ with:
50
+ node-version: '16'
51
+
52
+ - name: Setup yarn
53
+ run: npm install -g yarn
54
+
55
+ - name: Build website
56
+ run: |
57
+ ./site3/website/scripts/build-website.sh
.github/workflows/windows-daily-build.yml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ name: Windows Daily Build
18
+
19
+ on:
20
+ schedule:
21
+ - cron: '0 0 * * *' # Runs at 00:00 UTC every day
22
+ workflow_dispatch:
23
+
24
+ jobs:
25
+ windows-daily-build:
26
+ name: Daily Build and Test on Windows
27
+ runs-on: windows-latest
28
+ steps:
29
+ - uses: actions/checkout@v4
30
+ - name: Set up JDK 17
31
+ uses: actions/setup-java@v4
32
+ with:
33
+ distribution: 'temurin'
34
+ java-version: 21
35
+ - name: Build with Maven
36
+ run: mvn -B clean install
37
+ - name: Aggregates all test reports to ./test-reports and ./surefire-reports directories If failure
38
+ if: failure()
39
+ continue-on-error: true
40
+ uses: ./.github/actions/copy-test-reports
41
+ - name: Upload Surefire reports
42
+ uses: actions/upload-artifact@v4
43
+ if: failure()
44
+ continue-on-error: true
45
+ with:
46
+ name: windows-tests-reports
47
+ path: surefire-reports
.gitignore ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Eclipse
2
+ .classpath
3
+ .project
4
+ .settings/
5
+ .recommenders/
6
+
7
+ # IntelliJ
8
+ .idea/
9
+ !.idea/icon.svg
10
+ !.idea/vcs.xml
11
+ *.iml
12
+ *.iws
13
+
14
+ # NetBeans
15
+ /**/nb-configuration.xml
16
+
17
+ # Mac
18
+ .DS_Store
19
+
20
+ # Maven
21
+ lib/
22
+ log/
23
+ target/
24
+ dependency-reduced-pom.xml
25
+
26
+ # Logs
27
+ logs/
28
+
29
+ # Vagrant
30
+ **/.vagrant
31
+
32
+ # Data directory
33
+ data/
34
+
35
+ # Pid files
36
+ **/*.pid
37
+
38
+ # files are generated under following directories
39
+ tools/all/src/main/resources
40
+
41
+ # Exclude versionBackup file (generated by `mvn versions:set`)
42
+ **/*.versionsBackup
43
+
44
+ node_modules
45
+ package-lock.json
46
+ # gradle
47
+ build/
48
+ .gradle/
49
+ *.log
50
+ *.dat
.test-infra/scripts/post-docker-tests.sh ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ #
3
+ # Licensed to the Apache Software Foundation (ASF) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The ASF licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+ #
20
+
21
+ set -ex
22
+ kill $(cat docker-log.pid) || true
.test-infra/scripts/pre-docker-tests.sh ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ #
3
+ # Licensed to the Apache Software Foundation (ASF) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The ASF licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+ #
20
+
21
+ set -ex
22
+
23
+ id
24
+ ulimit -a
25
+ pwd
26
+ df -Th
27
+ ps -eo euser,pid,ppid,pgid,start,pcpu,pmem,cmd
28
+ docker info
29
+ docker system prune -f
30
+ # clean up any dangling networks from previous runs
31
+ docker network prune -f --filter "until=12h"
32
+ docker system events > docker.debug-info & echo $! > docker-log.pid
33
+ docker pull quay.io/coreos/etcd:v3.5.14
.test-infra/scripts/slack-email-digest/.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ configuration.yaml
.test-infra/scripts/slack-email-digest/README.md ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ # Slack to email digest bot
2
+
3
+ This script is responsible for generating daily per channel digests and emailing them to certail mailing lists.
4
+
.test-infra/scripts/slack-email-digest/configuration-example.yaml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+
20
+ slack:
21
+ token: xoxp-xxxxxxxxxxxxxx
22
+
23
+ mail:
24
+ fromAddress: '"My Slack" <my.slack@gmail.com>'
25
+ smtp: smtp.gmail.com:587
26
+ useTLS: true
27
+ username: my.slack@gmail.com
28
+ password: xxxxxxxxx
29
+
30
+ channels:
31
+ # Maps channels to a particular email address
32
+ general: users@my.project.org
33
+ dev: dev@my.project.org
34
+ random: users@my.project.org
.test-infra/scripts/slack-email-digest/requirements.txt ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+ slacker
20
+ PyYAML
.test-infra/scripts/slack-email-digest/slack_email_digest.py ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ #
3
+ # Licensed to the Apache Software Foundation (ASF) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The ASF licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+ #
20
+
21
+ import slacker
22
+ import yaml
23
+ import time
24
+ import re
25
+ import datetime
26
+ import smtplib
27
+ from email.mime.text import MIMEText
28
+
29
+
30
+ conf = yaml.load(open('configuration.yaml'))
31
+
32
+
33
+ def send_digest(channel, address, digest):
34
+ msg = MIMEText(digest, _charset='utf-8')
35
+ msg['From'] = conf['mail']['fromAddress']
36
+ msg['To'] = address
37
+ msg['Subject'] = 'Slack digest for #%s - %s' % (
38
+ channel, datetime.datetime.now().strftime('%Y-%m-%d'))
39
+ server = smtplib.SMTP(conf['mail']['smtp'])
40
+ if conf['mail']['useTLS']:
41
+ server.starttls()
42
+ if 'username' in conf['mail']:
43
+ server.login(conf['mail']['username'], conf['mail']['password'])
44
+
45
+ server.sendmail(conf['mail']['fromAddress'], address, msg.as_string())
46
+ server.quit()
47
+
48
+
49
+ slack = slacker.Slacker(conf['slack']['token'])
50
+
51
+ channels = slack.channels.list().body['channels']
52
+
53
+ # Get a mapping between Slack internal user ids and real names
54
+ users = {}
55
+ for user in slack.users.list().body['members']:
56
+ real_name = user.get('real_name', user.get('name'))
57
+ users[user['id']] = real_name
58
+
59
+ last_day_timestamp = time.time() - (24 * 3600)
60
+
61
+ for channel in channels:
62
+ id = channel['id']
63
+ name = channel['name']
64
+ topic = channel['topic']['value']
65
+
66
+ if name not in conf['channels']:
67
+ print('Ignoring channel: #%s' % name)
68
+ continue
69
+
70
+ toAddress = conf['channels'][name]
71
+ print('Getting digest of #%s --> %s' % (name, toAddress))
72
+
73
+ messages = slack.channels.history(channel=id,
74
+ oldest=last_day_timestamp,
75
+ count=1000)
76
+ digest = ''
77
+ for m in reversed(messages.body['messages']):
78
+ if not m['type'] == 'message':
79
+ continue
80
+
81
+ user = m.get('user')
82
+ if not user:
83
+ user = m['comment']['user']
84
+ sender = users.get(user, '')
85
+
86
+ date = datetime.datetime.utcfromtimestamp(float(m['ts'])).strftime('%Y-%m-%d %H:%M:%S UTC')
87
+ # Replace users id mentions with real names
88
+ text = re.sub(r'<@(\w+)>', lambda m: '@' + users[m.group(1)], m['text'])
89
+
90
+ digest += '%s - %s: %s\n' % (date, sender, text)
91
+ for reaction in m.get('reactions', []):
92
+ digest += '%s : %s\n' % (reaction['name'], ', '.join(map(users.get, reaction['users'])))
93
+ digest += '----\n'
94
+
95
+ if digest:
96
+ send_digest(name, toAddress, digest)
.typos.toml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+
20
+ [default.extend-words]
21
+ # abbr
22
+ "ba" = "ba"
23
+ "bve" = "bve"
24
+ "cace" = "cace"
25
+ "cann" = "cann"
26
+ "dbe" = "dbe"
27
+ "entrys" = "entrys"
28
+ "fo" = "fo"
29
+ "ine" = "ine"
30
+ "isse" = "isse"
31
+ "mor" = "mor"
32
+ "nwe" = "nwe"
33
+ "nd" = "nd"
34
+ "nin" = "nin"
35
+ "oce" = "oce"
36
+ "ot" = "ot"
37
+ "ser" = "ser"
38
+ "shouldnot" = "shouldnot"
39
+ "tio" = "tio"
40
+ "ue" = "ue"
41
+ # keep for comptability
42
+ "deleteable" = "deleteable"
43
+ "infinit" = "infinit"
44
+ "explict" = "explict"
45
+ "uninitalize" = "uninitalize"
46
+ # keyword fp
47
+ "guage" = "guage"
48
+ "passin" = "passin"
49
+ "testng" = "testng"
50
+ "vertx" = "vertx"
51
+ "verticle" = "verticle"
52
+
53
+ [files]
54
+ extend-exclude = [
55
+ "bookkeeper-server/src/test/java/org/apache/bookkeeper/meta/TestLedgerMetadataSerDe.java",
56
+ ]
CONTRIBUTING.md ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ Licensed to the Apache Software Foundation (ASF) under one
3
+ or more contributor license agreements. See the NOTICE file
4
+ distributed with this work for additional information
5
+ regarding copyright ownership. The ASF licenses this file
6
+ to you under the Apache License, Version 2.0 (the
7
+ "License"); you may not use this file except in compliance
8
+ with the License. You may obtain a copy of the License at
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+ Unless required by applicable law or agreed to in writing,
11
+ software distributed under the License is distributed on an
12
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13
+ KIND, either express or implied. See the License for the
14
+ specific language governing permissions and limitations
15
+ under the License.
16
+ -->
17
+
18
+ ## Contributing to Apache BookKeeper
19
+ The Apache BookKeeper community welcomes contributions from anyone with a passion for distributed systems! BookKeeper has many different opportunities for contributions -- write new examples/tutorials, add new user-facing libraries, work on the core storage components, integrate with different metadata stores (ZooKeeper, Etcd etc), or participate on the documentation effort.
20
+
21
+ We use a review-then-commit workflow in BookKeeper for all contributions.
22
+
23
+ We would love for you to contribute to Apache BookKeeper and make it even better!
24
+ Please check the [Contributing to Apache BookKeeper](https://bookkeeper.apache.org/community/contributing/)
25
+ page before starting to work on the project.
LICENSE ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
NOTICE ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ Apache BookKeeper
2
+ Copyright 2011-2025 The Apache Software Foundation
3
+
4
+ This product includes software developed at
5
+ The Apache Software Foundation (http://www.apache.org/).
README.md ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <img src="https://pbs.twimg.com/profile_images/545716709311520769/piLLa1iC_400x400.png" alt="logo" style="width: 32px;"/>
2
+
3
+ [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.apache.bookkeeper/bookkeeper/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.apache.bookkeeper/bookkeeper)
4
+
5
+ # Apache BookKeeper
6
+
7
+ Apache BookKeeper is a scalable, fault-tolerant and low latency storage service optimized for append-only workloads.
8
+
9
+ It is suitable for being used in following scenarios:
10
+
11
+ - WAL (Write-Ahead-Logging), e.g. HDFS NameNode, Pravega.
12
+ - Message Store, e.g. Apache Pulsar.
13
+ - Offset/Cursor Store, e.g. Apache Pulsar.
14
+ - Object/Blob Store, e.g. storing state machine snapshots.
15
+
16
+ ## Get Started
17
+
18
+ * Checkout the project [website](https://bookkeeper.apache.org/).
19
+ * *Concepts*: Start with the [basic concepts](https://bookkeeper.apache.org/docs/getting-started/concepts) of Apache BookKeeper.
20
+ This will help you to fully understand the other parts of the documentation.
21
+ * Follow the [Installation](https://bookkeeper.apache.org/docs/getting-started/installation) guide to set up BookKeeper.
22
+
23
+ ## Documentation
24
+
25
+ Please visit the [Documentation](https://bookkeeper.apache.org/docs/overview/) from the project website for more information.
26
+
27
+ ## Get In Touch
28
+
29
+ ### Report a Bug
30
+
31
+ For filing bugs, suggesting improvements, or requesting new features, help us out by [opening a GitHub issue](https://github.com/apache/bookkeeper/issues).
32
+
33
+ ### Need Help?
34
+
35
+ [Subscribe](mailto:user-subscribe@bookkeeper.apache.org) or [mail](mailto:user@bookkeeper.apache.org) the [user@bookkeeper.apache.org](mailto:user@bookkeeper.apache.org) list - Ask questions, find answers, and also help other users.
36
+
37
+ [Subscribe](mailto:dev-subscribe@bookkeeper.apache.org) or [mail](mailto:dev@bookkeeper.apache.org) the [dev@bookkeeper.apache.org](mailto:dev@bookkeeper.apache.org) list - Join development discussions, propose new ideas and connect with contributors.
38
+
39
+ [Join us on Slack](https://communityinviter.com/apps/apachebookkeeper/apache-bookkeeper) - This is the most immediate way to connect with Apache BookKeeper committers and contributors.
40
+
41
+ ## Contributing
42
+
43
+ We feel that a welcoming open community is important and welcome contributions.
44
+
45
+ ### Contributing Code
46
+
47
+ 1. See our [installation guide](https://bookkeeper.apache.org/docs/next/getting-started/installation/) to get your local environment setup.
48
+
49
+ 2. Take a look at our open issues: [GitHub Issues](https://github.com/apache/bookkeeper/issues).
50
+
51
+ 3. Review our [coding style](https://bookkeeper.apache.org/community/coding-guide/) and follow our [pull requests](https://github.com/apache/bookkeeper/pulls) to learn more about our conventions.
52
+
53
+ 4. Make your changes according to our [contributing guide](https://bookkeeper.apache.org/community/contributing/)
bin/bkctl ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ #
3
+ #/**
4
+ # * Licensed to the Apache Software Foundation (ASF) under one
5
+ # * or more contributor license agreements. See the NOTICE file
6
+ # * distributed with this work for additional information
7
+ # * regarding copyright ownership. The ASF licenses this file
8
+ # * to you under the Apache License, Version 2.0 (the
9
+ # * "License"); you may not use this file except in compliance
10
+ # * with the License. You may obtain a copy of the License at
11
+ # *
12
+ # * http://www.apache.org/licenses/LICENSE-2.0
13
+ # *
14
+ # * Unless required by applicable law or agreed to in writing, software
15
+ # * distributed under the License is distributed on an "AS IS" BASIS,
16
+ # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # * See the License for the specific language governing permissions and
18
+ # * limitations under the License.
19
+ # */
20
+
21
+ # BookKeeper CLI (experimental)
22
+
23
+ BINDIR=`dirname "$0"`
24
+ BK_HOME=`cd ${BINDIR}/..;pwd`
25
+ mkdir -p $BK_HOME/logs
26
+
27
+ source ${BK_HOME}/bin/common.sh
28
+ source ${BK_HOME}/conf/bk_cli_env.sh
29
+
30
+ CLI_MODULE_PATH=tools/all
31
+ CLI_MODULE_NAME="(org.apache.bookkeeper-)?bookkeeper-tools"
32
+ CLI_MODULE_HOME=${BK_HOME}/${CLI_MODULE_PATH}
33
+
34
+ # find the module jar
35
+ CLI_JAR=$(find_module_jar ${CLI_MODULE_PATH} ${CLI_MODULE_NAME})
36
+
37
+ # set up the classpath
38
+ CLI_CLASSPATH=$(set_module_classpath ${CLI_MODULE_PATH})
39
+
40
+ DEFAULT_CONF=${BK_HOME}/conf/bk_server.conf
41
+ if [ -z "${CLI_CONF}" ]; then
42
+ CLI_CONF=${DEFAULT_CONF}
43
+ fi
44
+
45
+ DEFAULT_LOG_CONF=${BK_HOME}/conf/log4j2.cli.xml
46
+ if [ -z "${CLI_LOG_CONF}" ]; then
47
+ CLI_LOG_CONF=${DEFAULT_LOG_CONF}
48
+ fi
49
+ CLI_LOG_DIR=${CLI_LOG_DIR:-"$BK_HOME/logs"}
50
+ CLI_LOG_FILE=${CLI_LOG_FILE:-"bkctl.log"}
51
+ CLI_ROOT_LOG_LEVEL=${CLI_ROOT_LOG_LEVEL:-"INFO"}
52
+ CLI_ROOT_LOG_APPENDER=${CLI_ROOT_LOG_APPENDER:-"CONSOLE"}
53
+
54
+ # Configure the classpath
55
+ CLI_CLASSPATH="$CLI_JAR:$CLI_CLASSPATH:$CLI_EXTRA_CLASSPATH"
56
+ CLI_CLASSPATH="`dirname $CLI_LOG_CONF`:$CLI_CLASSPATH"
57
+
58
+ # Build the OPTs
59
+ BOOKIE_OPTS=$(build_bookie_opts)
60
+ GC_OPTS=$(build_cli_jvm_opts ${CLI_LOG_DIR} "bkctl-gc.log")
61
+ NETTY_OPTS=$(build_netty_opts)
62
+ LOGGING_OPTS=$(build_cli_logging_opts ${CLI_LOG_CONF} ${CLI_ROOT_LOG_LEVEL} ${CLI_ROOT_LOG_APPENDER} ${CLI_LOG_DIR} ${CLI_LOG_FILE})
63
+
64
+ OPTS="${OPTS} -cp ${CLI_CLASSPATH} ${BOOKIE_OPTS} ${GC_OPTS} ${NETTY_OPTS} ${LOGGING_OPTS} ${CLI_EXTRA_OPTS}"
65
+
66
+ #Change to BK_HOME to support relative paths
67
+ cd "$BK_HOME"
68
+ exec "${JAVA}" ${OPTS} org.apache.bookkeeper.tools.cli.BKCtl --conf ${CLI_CONF} $@
bin/bkperf ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ #
3
+ #/**
4
+ # * Licensed to the Apache Software Foundation (ASF) under one
5
+ # * or more contributor license agreements. See the NOTICE file
6
+ # * distributed with this work for additional information
7
+ # * regarding copyright ownership. The ASF licenses this file
8
+ # * to you under the Apache License, Version 2.0 (the
9
+ # * "License"); you may not use this file except in compliance
10
+ # * with the License. You may obtain a copy of the License at
11
+ # *
12
+ # * http://www.apache.org/licenses/LICENSE-2.0
13
+ # *
14
+ # * Unless required by applicable law or agreed to in writing, software
15
+ # * distributed under the License is distributed on an "AS IS" BASIS,
16
+ # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # * See the License for the specific language governing permissions and
18
+ # * limitations under the License.
19
+ # */
20
+
21
+ # BookKeeper Perf Tool (experimental)
22
+
23
+ BINDIR=`dirname "$0"`
24
+ BK_HOME=`cd ${BINDIR}/..;pwd`
25
+
26
+ source ${BK_HOME}/bin/common.sh
27
+ source ${BK_HOME}/conf/bk_cli_env.sh
28
+
29
+ CLI_MODULE_PATH=tools/perf
30
+ CLI_MODULE_NAME="(org.apache.bookkeeper-)?bookkeeper-perf"
31
+ CLI_MODULE_HOME=${BK_HOME}/${CLI_MODULE_PATH}
32
+
33
+ # find the module jar
34
+ CLI_JAR=$(find_module_jar ${CLI_MODULE_PATH} ${CLI_MODULE_NAME})
35
+
36
+ # set up the classpath
37
+ CLI_CLASSPATH=$(set_module_classpath ${CLI_MODULE_PATH})
38
+
39
+ DEFAULT_CONF=${BK_HOME}/conf/bk_server.conf
40
+ if [ -z "${CLI_CONF}" ]; then
41
+ CLI_CONF=${DEFAULT_CONF}
42
+ fi
43
+
44
+ DEFAULT_LOG_CONF=${BK_HOME}/conf/log4j2.cli.xml
45
+ if [ -z "${CLI_LOG_CONF}" ]; then
46
+ CLI_LOG_CONF=${DEFAULT_LOG_CONF}
47
+ fi
48
+ CLI_LOG_DIR=${CLI_LOG_DIR:-"$BK_HOME/logs"}
49
+ CLI_LOG_FILE=${CLI_LOG_FILE:-"bkperf.log"}
50
+ CLI_ROOT_LOG_LEVEL=${CLI_ROOT_LOG_LEVEL:-"INFO"}
51
+ CLI_ROOT_LOG_APPENDER=${CLI_ROOT_LOG_APPENDER:-"CONSOLE"}
52
+
53
+ mkdir -p ${CLI_LOG_DIR}
54
+
55
+ # Configure the classpath
56
+ CLI_CLASSPATH="$CLI_JAR:$CLI_CLASSPATH:$CLI_EXTRA_CLASSPATH"
57
+ CLI_CLASSPATH="`dirname $CLI_LOG_CONF`:$CLI_CLASSPATH"
58
+
59
+ # Build the OPTs
60
+ BOOKIE_OPTS=$(build_bookie_opts)
61
+ GC_OPTS=$(build_cli_jvm_opts ${CLI_LOG_DIR} "bkperf-gc.log")
62
+ NETTY_OPTS=$(build_netty_opts)
63
+ LOGGING_OPTS=$(build_cli_logging_opts ${CLI_LOG_CONF} ${CLI_ROOT_LOG_LEVEL} ${CLI_ROOT_LOG_APPENDER} ${CLI_LOG_DIR} ${CLI_LOG_FILE})
64
+
65
+ OPTS="${OPTS} -cp ${CLI_CLASSPATH} ${BOOKIE_OPTS} ${GC_OPTS} ${NETTY_OPTS} ${LOGGING_OPTS} ${CLI_EXTRA_OPTS}"
66
+
67
+ #Change to BK_HOME to support relative paths
68
+ cd "$BK_HOME"
69
+ exec ${JAVA} ${OPTS} org.apache.bookkeeper.tools.perf.BKPerf --conf ${CLI_CONF} $@
bin/bookkeeper ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ #
3
+ #/**
4
+ # * Licensed to the Apache Software Foundation (ASF) under one
5
+ # * or more contributor license agreements. See the NOTICE file
6
+ # * distributed with this work for additional information
7
+ # * regarding copyright ownership. The ASF licenses this file
8
+ # * to you under the Apache License, Version 2.0 (the
9
+ # * "License"); you may not use this file except in compliance
10
+ # * with the License. You may obtain a copy of the License at
11
+ # *
12
+ # * http://www.apache.org/licenses/LICENSE-2.0
13
+ # *
14
+ # * Unless required by applicable law or agreed to in writing, software
15
+ # * distributed under the License is distributed on an "AS IS" BASIS,
16
+ # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # * See the License for the specific language governing permissions and
18
+ # * limitations under the License.
19
+ # */
20
+
21
+ set -e
22
+
23
+ BINDIR=`dirname "$0"`
24
+ BK_HOME=`cd ${BINDIR}/..;pwd`
25
+
26
+ source ${BK_HOME}/bin/common.sh
27
+
28
+ # default variables
29
+ DEFAULT_CONF=${BK_HOME}/conf/bk_server.conf
30
+ DEFAULT_ZK_CONF=${BK_HOME}/conf/zookeeper.conf
31
+
32
+ if [ -z "$BOOKIE_CONF" ]; then
33
+ BOOKIE_CONF_TO_CHECK=${DEFAULT_CONF}
34
+ else
35
+ BOOKIE_CONF_TO_CHECK=${BOOKIE_CONF}
36
+ fi
37
+
38
+ FIND_TABLE_SERVICE_RESULT=$(find_table_service ${BOOKIE_CONF_TO_CHECK} $1)
39
+
40
+ if [ "x${FIND_TABLE_SERVICE_RESULT}" == "xtrue" ]; then
41
+ BOOKIE_MODULE_PATH=stream/server
42
+ BOOKIE_MODULE_NAME=${TABLE_SERVICE_MODULE_NAME}
43
+ elif [ "x${FIND_TABLE_SERVICE_RESULT}" == "xfalse" ]; then
44
+ BOOKIE_MODULE_PATH=bookkeeper-server
45
+ BOOKIE_MODULE_NAME=${BOOKIE_SERVER_MODULE_NAME}
46
+ else
47
+ echo ${FIND_TABLE_SERVICE_RESULT}
48
+ exit 1
49
+ fi
50
+
51
+ # find the module jar
52
+ BOOKIE_JAR=$(find_module_jar ${BOOKIE_MODULE_PATH} ${BOOKIE_MODULE_NAME})
53
+
54
+ # set up the classpath
55
+ BOOKIE_CLASSPATH=$(set_module_classpath ${BOOKIE_MODULE_PATH})
56
+
57
+ bookkeeper_help() {
58
+ cat <<EOF
59
+ Usage: bookkeeper <command>
60
+ where command is one of:
61
+
62
+ [service commands]
63
+
64
+ bookie Run a bookie server
65
+ autorecovery Run AutoRecovery service
66
+ zookeeper Run zookeeper server
67
+
68
+ [development commands]
69
+
70
+ localbookie <n> Run a test ensemble of <n> bookies locally
71
+ standalone Run a standalone cluster (with all service components) locally
72
+
73
+ [tooling commands]
74
+
75
+ upgrade Upgrade bookie filesystem
76
+ shell Run shell for admin commands
77
+
78
+ [other commands]
79
+
80
+ help This help message
81
+
82
+ or command is the full name of a class with a defined main() method.
83
+
84
+ Environment variables:
85
+ BOOKIE_LOG_CONF Log4j configuration file (default ${DEFAULT_LOG_CONF})
86
+ BOOKIE_CONF Configuration file (default: ${DEFAULT_CONF})
87
+ BOOKIE_ZK_CONF Configuration file for zookeeper (default: $DEFAULT_ZK_CONF)
88
+ BOOKIE_EXTRA_OPTS Extra options to be passed to the jvm
89
+ BOOKIE_EXTRA_CLASSPATH Add extra paths to the bookkeeper classpath
90
+ BOOKIE_PID_DIR Folder where the Bookie server PID file should be stored
91
+ BOOKIE_STOP_TIMEOUT Wait time before forcefully kill the Bookie server instance, if the stop is not successful
92
+
93
+ These variable can also be set in conf/bkenv.sh
94
+ EOF
95
+ }
96
+
97
+ # if no args specified, show usage
98
+ if [ $# = 0 ]; then
99
+ bookkeeper_help;
100
+ exit 1;
101
+ fi
102
+
103
+ # get arguments
104
+ COMMAND=$1
105
+ shift
106
+
107
+ LOCALBOOKIES_CONFIG_DIR="${LOCALBOOKIES_CONFIG_DIR:-/tmp/localbookies-config}"
108
+ if [ ${COMMAND} == "shell" ]; then
109
+ DEFAULT_LOG_CONF=${BK_HOME}/conf/log4j2.shell.xml
110
+ if [[ $1 == "-localbookie" ]]; then
111
+ if [[ $2 == *:* ]];
112
+ then
113
+ BOOKIE_CONF=${LOCALBOOKIES_CONFIG_DIR}/$2.conf
114
+ shift 2
115
+ else
116
+ BOOKIE_CONF=${LOCALBOOKIES_CONFIG_DIR}/baseconf.conf
117
+ shift
118
+ fi
119
+ fi
120
+ fi
121
+
122
+ if [ -z "$BOOKIE_ZK_CONF" ]; then
123
+ BOOKIE_ZK_CONF=$DEFAULT_ZK_CONF
124
+ fi
125
+
126
+ if [ -z "$BOOKIE_CONF" ]; then
127
+ BOOKIE_CONF=${DEFAULT_CONF}
128
+ fi
129
+
130
+ # Configure logging
131
+ if [ -z "$BOOKIE_LOG_CONF" ]; then
132
+ BOOKIE_LOG_CONF=${DEFAULT_LOG_CONF}
133
+ fi
134
+ BOOKIE_LOG_DIR=${BOOKIE_LOG_DIR:-"$BK_HOME/logs"}
135
+ BOOKIE_LOG_FILE=${BOOKIE_LOG_FILE:-"bookkeeper-server.log"}
136
+ BOOKIE_ROOT_LOG_LEVEL=${BOOKIE_ROOT_LOG_LEVEL:-"INFO"}
137
+ BOOKIE_ROOT_LOG_APPENDER=${BOOKIE_ROOT_LOG_APPENDER:-"CONSOLE"}
138
+
139
+ # Configure the classpath
140
+ BOOKIE_CLASSPATH="$BOOKIE_JAR:$BOOKIE_CLASSPATH:$BOOKIE_EXTRA_CLASSPATH"
141
+ BOOKIE_CLASSPATH="`dirname $BOOKIE_LOG_CONF`:$BOOKIE_CLASSPATH"
142
+
143
+ # Build the OPTS
144
+ BOOKIE_OPTS=$(build_bookie_opts)
145
+ GC_OPTS=$(build_bookie_jvm_opts ${BOOKIE_LOG_DIR} "gc_%p.log")
146
+ NETTY_OPTS=$(build_netty_opts)
147
+ LOGGING_OPTS=$(build_logging_opts ${BOOKIE_LOG_CONF} ${BOOKIE_ROOT_LOG_LEVEL} ${BOOKIE_ROOT_LOG_APPENDER} ${BOOKIE_LOG_DIR} ${BOOKIE_LOG_FILE})
148
+
149
+ BOOKIE_EXTRA_OPTS="${BOOKIE_EXTRA_OPTS} -Dorg.bouncycastle.fips.approved_only=true"
150
+ OPTS="${OPTS} -cp ${BOOKIE_CLASSPATH} ${BOOKIE_OPTS} ${GC_OPTS} ${NETTY_OPTS} ${LOGGING_OPTS} ${BOOKIE_EXTRA_OPTS}"
151
+
152
+ # Create log dir if it doesn't exist
153
+ if [ ! -d ${BOOKIE_LOG_DIR} ]; then
154
+ mkdir ${BOOKIE_LOG_DIR}
155
+ fi
156
+
157
+ #Change to BK_HOME to support relative paths
158
+ cd "$BK_HOME"
159
+ if [ ${COMMAND} == "bookie" ]; then
160
+ exec "${JAVA}" ${OPTS} ${JMX_ARGS} org.apache.bookkeeper.server.Main --conf ${BOOKIE_CONF} $@
161
+ elif [ ${COMMAND} == "autorecovery" ]; then
162
+ exec "${JAVA}" ${OPTS} ${JMX_ARGS} org.apache.bookkeeper.replication.AutoRecoveryMain --conf ${BOOKIE_CONF} $@
163
+ elif [ ${COMMAND} == "localbookie" ]; then
164
+ NUMBER=$1
165
+ shift
166
+ exec "${JAVA}" ${OPTS} ${JMX_ARGS} -Dzookeeper.4lw.commands.whitelist='*' org.apache.bookkeeper.util.LocalBookKeeper ${NUMBER} ${BOOKIE_CONF} $@
167
+ elif [ ${COMMAND} == "standalone" ]; then
168
+ exec "${JAVA}" ${OPTS} ${JMX_ARGS} -Dzookeeper.4lw.commands.whitelist='*' org.apache.bookkeeper.stream.cluster.StandaloneStarter --conf ${BK_HOME}/conf/standalone.conf $@
169
+ elif [ ${COMMAND} == "upgrade" ]; then
170
+ exec "${JAVA}" ${OPTS} org.apache.bookkeeper.bookie.FileSystemUpgrade --conf ${BOOKIE_CONF} $@
171
+ elif [ $COMMAND == "zookeeper" ]; then
172
+ BOOKIE_LOG_FILE=${BOOKIE_LOG_FILE:-"zookeeper.log"}
173
+ exec "${JAVA}" $OPTS -Dbookkeeper.log.file=$BOOKIE_LOG_FILE org.apache.zookeeper.server.quorum.QuorumPeerMain $BOOKIE_ZK_CONF $@
174
+ elif [ ${COMMAND} == "shell" ]; then
175
+ exec "${JAVA}" ${OPTS} org.apache.bookkeeper.bookie.BookieShell -conf ${BOOKIE_CONF} $@
176
+ elif [ ${COMMAND} == "help" ]; then
177
+ bookkeeper_help;
178
+ else
179
+ exec "${JAVA}" ${OPTS} ${COMMAND} $@
180
+ fi
181
+
bin/bookkeeper-cluster.sh ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ #
3
+ #/**
4
+ # * Licensed to the Apache Software Foundation (ASF) under one
5
+ # * or more contributor license agreements. See the NOTICE file
6
+ # * distributed with this work for additional information
7
+ # * regarding copyright ownership. The ASF licenses this file
8
+ # * to you under the Apache License, Version 2.0 (the
9
+ # * "License"); you may not use this file except in compliance
10
+ # * with the License. You may obtain a copy of the License at
11
+ # *
12
+ # * http://www.apache.org/licenses/LICENSE-2.0
13
+ # *
14
+ # * Unless required by applicable law or agreed to in writing, software
15
+ # * distributed under the License is distributed on an "AS IS" BASIS,
16
+ # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # * See the License for the specific language governing permissions and
18
+ # * limitations under the License.
19
+ # */
20
+
21
+
22
+ BINDIR=`dirname "$0"`
23
+ BK_HOME=`cd $BINDIR/..;pwd`
24
+ if [ -f $BK_HOME/conf/bkenv.sh ]
25
+ then
26
+ . $BK_HOME/conf/bkenv.sh
27
+ fi
28
+
29
+ BKCFG=$BK_HOME/conf/bk_server.conf
30
+ CLUSTER=$BK_HOME/conf/bookies
31
+ usage() {
32
+ cat <<EOF
33
+ Usage: bookkeeper-cluster.sh (start|stop|kill)
34
+
35
+ The list of hosts in the cluster must be available in
36
+ $CLUSTER
37
+ with one hostname per line.
38
+
39
+ BookKeeper must be installed in the same location on each host.
40
+ EOF
41
+ }
42
+
43
+ if [ ! -f $CLUSTER ]; then
44
+ echo -e "\nCluster file ($CLUSTER) does not exist\n"
45
+ usage
46
+ exit 1
47
+ fi
48
+
49
+ NUMHOSTS=$(wc -l $CLUSTER | awk '{print $1}')
50
+ if [ "$NUMHOSTS" = "0" ]; then
51
+ echo -e "\nCluster file ($CLUSTER) is empty\n"
52
+ usage
53
+ exit 1
54
+ fi
55
+
56
+ bookies_list() {
57
+ $BINDIR/bookkeeper shell listbookies 2> /dev/null
58
+ }
59
+
60
+ bookies_available() {
61
+ bookies_list | wc -l
62
+ }
63
+
64
+ start() {
65
+ for B in `cat $CLUSTER`; do
66
+ echo "Starting bookie on $B"
67
+ ssh $B $BINDIR/bookkeeper-daemon.sh start bookie
68
+ done
69
+
70
+ BOOKIESSTARTED=0
71
+ COUNT=0
72
+
73
+ while [ $BOOKIESSTARTED -lt $NUMHOSTS ]; do
74
+ sleep 1
75
+ COUNT=$(($COUNT+1))
76
+ if [ $COUNT = 20 ]; then
77
+ echo "Could not start all bookies"
78
+ exit 1
79
+ fi
80
+
81
+ BOOKIESSTARTED=$(bookies_available)
82
+
83
+ echo "$BOOKIESSTARTED bookies started"
84
+ done
85
+ }
86
+
87
+ stop() {
88
+ for B in `cat $CLUSTER`; do
89
+ echo "Stopping bookie on $B"
90
+ ssh $B $BINDIR/bookkeeper-daemon.sh stop bookie $FORCE
91
+ done
92
+
93
+ COUNT=0
94
+ BOOKIESSTARTED=$NUMHOSTS
95
+ while [ $BOOKIESSTARTED -gt 0 ]; do
96
+ sleep 1
97
+
98
+ COUNT=$((COUNT+1))
99
+ if [ $COUNT = 20 ]; then
100
+ echo "Couldn not stop all bookies. $BOOKIESSTARTED still running"
101
+ exit 2
102
+ fi
103
+
104
+ BOOKIESSTARTED=$(bookies_available)
105
+ done
106
+ }
107
+
108
+ status() {
109
+ BOOKIESSTARTED=$(bookies_available)
110
+ echo "$BOOKIESSTARTED bookies running"
111
+ COUNT=1
112
+ for b in $(bookies_list); do
113
+ echo "$COUNT: $b"
114
+ COUNT=$(($COUNT+1))
115
+ done
116
+ }
117
+
118
+ case $1 in
119
+ start)
120
+ start
121
+ ;;
122
+ stop)
123
+ stop
124
+ ;;
125
+ kill)
126
+ FORCE="-force"
127
+ stop
128
+ ;;
129
+ status)
130
+ status
131
+ ;;
132
+ *)
133
+ usage
134
+ ;;
135
+ esac
bin/bookkeeper-daemon.sh ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ #
3
+ #/**
4
+ # * Licensed to the Apache Software Foundation (ASF) under one
5
+ # * or more contributor license agreements. See the NOTICE file
6
+ # * distributed with this work for additional information
7
+ # * regarding copyright ownership. The ASF licenses this file
8
+ # * to you under the Apache License, Version 2.0 (the
9
+ # * "License"); you may not use this file except in compliance
10
+ # * with the License. You may obtain a copy of the License at
11
+ # *
12
+ # * http://www.apache.org/licenses/LICENSE-2.0
13
+ # *
14
+ # * Unless required by applicable law or agreed to in writing, software
15
+ # * distributed under the License is distributed on an "AS IS" BASIS,
16
+ # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # * See the License for the specific language governing permissions and
18
+ # * limitations under the License.
19
+ # */
20
+
21
+ usage() {
22
+ cat <<EOF
23
+ Usage: bookkeeper-daemon.sh (start|stop) <command> <args...>
24
+ where command is one of:
25
+ bookie Run the bookie server
26
+ autorecovery Run the AutoRecovery service daemon
27
+ zookeeper Run the zookeeper server
28
+
29
+ where argument is one of:
30
+ -force (accepted only with stop command): Decides whether to stop the Bookie Server forcefully if not stopped by normal shutdown
31
+ EOF
32
+ }
33
+
34
+ BINDIR=$(dirname "$0")
35
+ BK_HOME=$(cd $BINDIR/..;pwd)
36
+
37
+ if [ -f $BK_HOME/conf/bkenv.sh ]
38
+ then
39
+ . $BK_HOME/conf/bkenv.sh
40
+ fi
41
+
42
+ BOOKIE_LOG_DIR=${BOOKIE_LOG_DIR:-"$BK_HOME/logs"}
43
+
44
+ BOOKIE_ROOT_LOG_LEVEL=${BOOKIE_ROOT_LOG_LEVEL:-'INFO'}
45
+ BOOKIE_ROOT_LOG_APPENDER=${BOOKIE_ROOT_LOG_APPENDER:-'ROLLINGFILE'}
46
+
47
+ BOOKIE_STOP_TIMEOUT=${BOOKIE_STOP_TIMEOUT:-30}
48
+
49
+ BOOKIE_PID_DIR=${BOOKIE_PID_DIR:-$BK_HOME/bin}
50
+
51
+ if [ $# -lt 2 ]
52
+ then
53
+ echo "Error: no enough arguments provided."
54
+ usage
55
+ exit 1
56
+ fi
57
+
58
+ startStop=$1
59
+ shift
60
+ command=$1
61
+ shift
62
+
63
+ case $command in
64
+ (zookeeper)
65
+ echo "doing $startStop $command ..."
66
+ ;;
67
+ (bookie)
68
+ echo "doing $startStop $command ..."
69
+ ;;
70
+ (autorecovery)
71
+ echo "doing $startStop $command ..."
72
+ ;;
73
+ (standalone)
74
+ echo "doing $startStop $command ..."
75
+ ;;
76
+ (*)
77
+ echo "Error: unknown service name $command"
78
+ usage
79
+ exit 1
80
+ ;;
81
+ esac
82
+
83
+ export BOOKIE_LOG_DIR=$BOOKIE_LOG_DIR
84
+ export BOOKIE_ROOT_LOG_LEVEL=$BOOKIE_ROOT_LOG_LEVEL
85
+ export BOOKIE_ROOT_LOG_APPENDER=$BOOKIE_ROOT_LOG_APPENDER
86
+ export BOOKIE_LOG_FILE=bookkeeper-$command-$HOSTNAME.log
87
+
88
+ pid_file="${BOOKIE_PID_DIR}/bookkeeper-${command}.pid"
89
+ out=$BOOKIE_LOG_DIR/bookkeeper-$command-$HOSTNAME.out
90
+ logfile=$BOOKIE_LOG_DIR/$BOOKIE_LOG_FILE
91
+
92
+ rotate_out_log ()
93
+ {
94
+ log=$1;
95
+ num=5;
96
+ if [ -n "$2" ]; then
97
+ num=$2
98
+ fi
99
+ if [ -f "$log" ]; then # rotate logs
100
+ while [ $num -gt 1 ]; do
101
+ prev=$(expr $num - 1)
102
+ [ -f "$log.$prev" ] && mv "$log.$prev" "$log.$num"
103
+ num=$prev
104
+ done
105
+ mv "$log" "$log.$num";
106
+ fi
107
+ }
108
+
109
+ mkdir -p "$BOOKIE_LOG_DIR"
110
+
111
+ start()
112
+ {
113
+ if [ -f $pid_file ]; then
114
+ PREVIOUS_PID=$(cat $pid_file)
115
+ if ps -p $PREVIOUS_PID > /dev/null 2>&1; then
116
+ echo $command running as process $PREVIOUS_PID. Stop it first.
117
+ exit 1
118
+ fi
119
+ fi
120
+
121
+ rotate_out_log $out
122
+ echo starting $command, logging to $logfile
123
+ bookkeeper=$BK_HOME/bin/bookkeeper
124
+ nohup $bookkeeper $command "$@" > "$out" 2>&1 < /dev/null &
125
+ echo $! > $pid_file
126
+ sleep 1; head $out
127
+ sleep 2;
128
+ if ! ps -p $! > /dev/null ; then
129
+ exit 1
130
+ fi
131
+ }
132
+
133
+ stop()
134
+ {
135
+ if [ -f $pid_file ]; then
136
+ TARGET_PID=$(cat $pid_file)
137
+ if ps -p $TARGET_PID > /dev/null 2>&1; then
138
+ echo stopping $command
139
+ kill $TARGET_PID
140
+
141
+ count=0
142
+ location=$BOOKIE_LOG_DIR
143
+ while ps -p $TARGET_PID > /dev/null 2>&1;
144
+ do
145
+ echo "Shutdown is in progress... Please wait..."
146
+ sleep 1
147
+ count=$(expr $count + 1)
148
+
149
+ if [ "$count" = "$BOOKIE_STOP_TIMEOUT" ]; then
150
+ break
151
+ fi
152
+ done
153
+
154
+ if [ "$count" != "$BOOKIE_STOP_TIMEOUT" ]; then
155
+ echo "Shutdown completed."
156
+ fi
157
+
158
+ if ps -p $TARGET_PID > /dev/null 2>&1; then
159
+ fileName=$location/$command.out
160
+ # Check for the java to use
161
+ if [[ -z ${JAVA_HOME} ]]; then
162
+ JSTACK=$(which jstack)
163
+ if [ $? -ne 0 ]; then
164
+ echo "Error: JAVA_HOME not set, and no jstack executable found in $PATH." 1>&2
165
+ exit 1
166
+ fi
167
+ else
168
+ JSTACK=${JAVA_HOME}/bin/jstack
169
+ fi
170
+ $JSTACK $TARGET_PID > $fileName
171
+ echo Thread dumps are taken for analysis at $fileName
172
+ if [ "$1" == "-force" ]
173
+ then
174
+ echo forcefully stopping $command
175
+ kill -9 $TARGET_PID >/dev/null 2>&1
176
+ echo Successfully stopped the process
177
+ else
178
+ echo "WARNNING : Bookie Server is not stopped completely."
179
+ exit 1
180
+ fi
181
+ fi
182
+ else
183
+ echo no $command to stop
184
+ fi
185
+ rm $pid_file
186
+ else
187
+ echo no $command to stop
188
+ fi
189
+ }
190
+ case $startStop in
191
+ (start)
192
+ start "$*"
193
+ ;;
194
+
195
+ (stop)
196
+ stop $1
197
+ ;;
198
+ (restart)
199
+ forceStopFlag=$(echo "$*"|grep "\-force")
200
+ if [[ "$forceStopFlag" != "" ]]
201
+ then
202
+ stop "-force"
203
+ else
204
+ stop
205
+ fi
206
+ if [ "$?" == 0 ]
207
+ then
208
+ sleep 3
209
+ parameters="$*"
210
+ startParameters=${parameters//-force/}
211
+ start "$startParameters"
212
+ else
213
+ echo "WARNNING : $command failed restart, for $command is not stopped completely."
214
+ fi
215
+ ;;
216
+ (*)
217
+ usage
218
+ echo $supportedargs
219
+ exit 1
220
+ ;;
221
+ esac
bin/common.sh ADDED
@@ -0,0 +1,376 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ #/**
3
+ # * Licensed to the Apache Software Foundation (ASF) under one
4
+ # * or more contributor license agreements. See the NOTICE file
5
+ # * distributed with this work for additional information
6
+ # * regarding copyright ownership. The ASF licenses this file
7
+ # * to you under the Apache License, Version 2.0 (the
8
+ # * "License"); you may not use this file except in compliance
9
+ # * with the License. You may obtain a copy of the License at
10
+ # *
11
+ # * http://www.apache.org/licenses/LICENSE-2.0
12
+ # *
13
+ # * Unless required by applicable law or agreed to in writing, software
14
+ # * distributed under the License is distributed on an "AS IS" BASIS,
15
+ # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # * See the License for the specific language governing permissions and
17
+ # * limitations under the License.
18
+ # */
19
+
20
+ # Check net.ipv6.bindv6only
21
+ if [ -f /sbin/sysctl ] && [ -f /proc/sys/net/ipv6/bindv6only ]; then
22
+ # check if net.ipv6.bindv6only is set to 1
23
+ bindv6only=$(/sbin/sysctl -n net.ipv6.bindv6only 2> /dev/null)
24
+ if [ -n "$bindv6only" ] && [ "$bindv6only" -eq "1" ]
25
+ then
26
+ echo "Error: \"net.ipv6.bindv6only\" is set to 1 - Java networking could be broken"
27
+ echo "For more info (the following page also applies to bookkeeper): http://wiki.apache.org/hadoop/HadoopIPv6"
28
+ exit 1
29
+ fi
30
+ fi
31
+
32
+ # See the following page for extensive details on setting
33
+ # up the JVM to accept JMX remote management:
34
+ # http://java.sun.com/javase/6/docs/technotes/guides/management/agent.html
35
+ # by default we allow local JMX connections
36
+ if [ "x$JMXLOCALONLY" = "x" ]
37
+ then
38
+ JMXLOCALONLY=false
39
+ fi
40
+
41
+ if [ "x$JMXDISABLE" = "x" ]
42
+ then
43
+ # for some reason these two options are necessary on jdk6 on Ubuntu
44
+ # accord to the docs they are not necessary, but otw jconsole cannot
45
+ # do a local attach
46
+ JMX_ARGS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=$JMXLOCALONLY"
47
+ else
48
+ echo "JMX disabled by user request" >&2
49
+ fi
50
+
51
+ # Check for the java to use
52
+ if [[ -z ${JAVA_HOME} ]]; then
53
+ JAVA=$(which java)
54
+ if [ $? != 0 ]; then
55
+ echo "Error: JAVA_HOME not set, and no java executable found in $PATH." 1>&2
56
+ exit 1
57
+ fi
58
+ else
59
+ JAVA=${JAVA_HOME}/bin/java
60
+ fi
61
+
62
+ BINDIR=${BK_BINDIR:-"`dirname "$0"`"}
63
+ BK_HOME=${BK_HOME:-"`cd ${BINDIR}/..;pwd`"}
64
+ BK_CONFDIR=${BK_HOME}/conf
65
+ DEFAULT_LOG_CONF=${BK_CONFDIR}/log4j2.xml
66
+
67
+ source ${BK_CONFDIR}/nettyenv.sh
68
+ source ${BK_CONFDIR}/bkenv.sh
69
+ source ${BK_CONFDIR}/bk_cli_env.sh
70
+
71
+ detect_jdk8() {
72
+ local is_java_8=$($JAVA -version 2>&1 | grep version | grep '"1\.8')
73
+ if [ -z "$is_java_8" ]; then
74
+ echo "0"
75
+ else
76
+ echo "1"
77
+ fi
78
+ }
79
+
80
+ # default netty settings
81
+ NETTY_LEAK_DETECTION_LEVEL=${NETTY_LEAK_DETECTION_LEVEL:-"disabled"}
82
+
83
+ USING_JDK8=$(detect_jdk8)
84
+
85
+ if [ "$USING_JDK8" -ne "1" ]; then
86
+ DEFAULT_BOOKIE_GC_OPTS="-XX:+UseG1GC \
87
+ -XX:MaxGCPauseMillis=10 \
88
+ -XX:+ParallelRefProcEnabled \
89
+ -XX:+DisableExplicitGC"
90
+ DEFAULT_BOOKIE_GC_LOGGING_OPTS=""
91
+ else
92
+ DEFAULT_BOOKIE_GC_OPTS="-XX:+UseG1GC \
93
+ -XX:MaxGCPauseMillis=10 \
94
+ -XX:+ParallelRefProcEnabled \
95
+ -XX:+UnlockExperimentalVMOptions \
96
+ -XX:+DoEscapeAnalysis \
97
+ -XX:ParallelGCThreads=32 \
98
+ -XX:ConcGCThreads=32 \
99
+ -XX:G1NewSizePercent=50 \
100
+ -XX:+DisableExplicitGC \
101
+ -XX:-ResizePLAB"
102
+ DEFAULT_BOOKIE_GC_LOGGING_OPTS="-XX:+PrintGCDetails \
103
+ -XX:+PrintGCApplicationStoppedTime \
104
+ -XX:+UseGCLogFileRotation \
105
+ -XX:NumberOfGCLogFiles=5 \
106
+ -XX:GCLogFileSize=64m"
107
+ fi
108
+
109
+ BOOKIE_MAX_HEAP_MEMORY=${BOOKIE_MAX_HEAP_MEMORY:-"1g"}
110
+ BOOKIE_MIN_HEAP_MEMORY=${BOOKIE_MIN_HEAP_MEMORY:-"1g"}
111
+ BOOKIE_MAX_DIRECT_MEMORY=${BOOKIE_MAX_DIRECT_MEMORY:-"2g"}
112
+ BOOKIE_MEM_OPTS=${BOOKIE_MEM_OPTS:-"-Xms${BOOKIE_MIN_HEAP_MEMORY} -Xmx${BOOKIE_MAX_HEAP_MEMORY} -XX:MaxDirectMemorySize=${BOOKIE_MAX_DIRECT_MEMORY}"}
113
+ BOOKIE_GC_OPTS=${BOOKIE_GC_OPTS:-"${DEFAULT_BOOKIE_GC_OPTS}"}
114
+ BOOKIE_GC_LOGGING_OPTS=${BOOKIE_GC_LOGGING_OPTS:-"${DEFAULT_BOOKIE_GC_LOGGING_OPTS}"}
115
+
116
+ # default CLI JVM settings
117
+ DEFAULT_CLI_GC_OPTS="-XX:+UseG1GC \
118
+ -XX:MaxGCPauseMillis=10"
119
+ if [ "$USING_JDK8" -ne "1" ]; then
120
+ DEFAULT_CLI_GC_LOGGING_OPTS=""
121
+ else
122
+ DEFAULT_CLI_GC_LOGGING_OPTS="-XX:+PrintGCDetails \
123
+ -XX:+PrintGCApplicationStoppedTime \
124
+ -XX:+UseGCLogFileRotation \
125
+ -XX:NumberOfGCLogFiles=5 \
126
+ -XX:GCLogFileSize=64m"
127
+ fi
128
+
129
+ CLI_MAX_HEAP_MEMORY=${CLI_MAX_HEAP_MEMORY:-"512M"}
130
+ CLI_MIN_HEAP_MEMORY=${CLI_MIN_HEAP_MEMORY:-"256M"}
131
+ CLI_MEM_OPTS=${CLI_MEM_OPTS:-"-Xms${CLI_MIN_HEAP_MEMORY} -Xmx${CLI_MAX_HEAP_MEMORY}"}
132
+ CLI_GC_OPTS=${CLI_GC_OPTS:-"${DEFAULT_CLI_GC_OPTS}"}
133
+ CLI_GC_LOGGING_OPTS=${CLI_GC_LOGGING_OPTS:-"${DEFAULT_CLI_GC_LOGGING_OPTS}"}
134
+
135
+ # module names
136
+ BOOKIE_SERVER_MODULE_NAME="(org.apache.bookkeeper-)?bookkeeper-server"
137
+ TABLE_SERVICE_MODULE_NAME="(org.apache.bookkeeper-)?stream-storage-server"
138
+
139
+ is_released_binary() {
140
+ if [ -d ${BK_HOME}/lib ]; then
141
+ echo "true"
142
+ return
143
+ else
144
+ echo "false"
145
+ return
146
+ fi
147
+ }
148
+
149
+ find_module_jar_at() {
150
+ DIR=$1
151
+ MODULE=$2
152
+ REGEX="^${MODULE}-[0-9\\.]*((-[a-zA-Z]*(-[0-9]*)?)|(-SNAPSHOT))?.jar$"
153
+ if [ -d ${DIR} ]; then
154
+ cd ${DIR}
155
+ for f in *.jar; do
156
+ if [[ ${f} =~ ${REGEX} ]]; then
157
+ echo ${DIR}/${f}
158
+ return
159
+ fi
160
+ done
161
+ fi
162
+ }
163
+
164
+ find_module_release_jar() {
165
+ MODULE_NAME=$1
166
+ RELEASE_JAR=$(find_module_jar_at ${BK_HOME} ${MODULE_NAME})
167
+ if [ -n "${RELEASE_JAR}" ]; then
168
+ MODULE_JAR=${RELEASE_JAR}
169
+ else
170
+ RELEASE_JAR=$(find_module_jar_at ${BK_HOME}/lib ${MODULE_NAME})
171
+ if [ -n "${RELEASE_JAR}" ]; then
172
+ MODULE_JAR=${RELEASE_JAR}
173
+ fi
174
+ fi
175
+ echo ${RELEASE_JAR}
176
+ return
177
+ }
178
+
179
+ find_module_jar() {
180
+ MODULE_PATH=$1
181
+ MODULE_NAME=$2
182
+ RELEASE_JAR=$(find_module_jar_at ${BK_HOME} ${MODULE_NAME})
183
+ if [ -n "${RELEASE_JAR}" ]; then
184
+ MODULE_JAR=${RELEASE_JAR}
185
+ else
186
+ RELEASE_JAR=$(find_module_jar_at ${BK_HOME}/lib ${MODULE_NAME})
187
+ if [ -n "${RELEASE_JAR}" ]; then
188
+ MODULE_JAR=${RELEASE_JAR}
189
+ fi
190
+ fi
191
+
192
+ if [ -z "${MODULE_JAR}" ]; then
193
+ BUILT_JAR=$(find_module_jar_at ${BK_HOME}/${MODULE_PATH}/target ${MODULE_NAME})
194
+ if [ -z "${BUILT_JAR}" ]; then
195
+ echo "Couldn't find module '${MODULE_NAME}' jar." >&2
196
+ read -p "Do you want me to run \`mvn install -DskipTests\` for you ? (y|n) " answer
197
+ case "${answer:0:1}" in
198
+ y|Y )
199
+ mkdir -p ${BK_HOME}/logs
200
+ output="${BK_HOME}/logs/build.out"
201
+ echo "see output at ${output} for the progress ..." >&2
202
+ mvn install -DskipTests &> ${output}
203
+ ;;
204
+ * )
205
+ exit 1
206
+ ;;
207
+ esac
208
+
209
+ BUILT_JAR=$(find_module_jar_at ${BK_HOME}/${MODULE_PATH}/target ${MODULE_NAME})
210
+ fi
211
+ if [ -n "${BUILT_JAR}" ]; then
212
+ MODULE_JAR=${BUILT_JAR}
213
+ fi
214
+ fi
215
+
216
+ if [ ! -e "${MODULE_JAR}" ]; then
217
+ echo "Could not find module '${MODULE_JAR}' jar." >&2
218
+ exit 1
219
+ fi
220
+ echo ${MODULE_JAR}
221
+ return
222
+ }
223
+
224
+ add_maven_deps_to_classpath() {
225
+ MODULE_PATH=$1
226
+ MVN="mvn"
227
+ if [ "$MAVEN_HOME" != "" ]; then
228
+ MVN=${MAVEN_HOME}/bin/mvn
229
+ fi
230
+
231
+ # Need to generate classpath from maven pom. This is costly so generate it
232
+ # and cache it. Save the file into our target dir so a mvn clean will get
233
+ # clean it up and force us create a new one.
234
+ f="${BK_HOME}/${MODULE_PATH}/target/cached_classpath.txt"
235
+ output="${BK_HOME}/${MODULE_PATH}/target/build_classpath.out"
236
+
237
+ if [ ! -f ${f} ]; then
238
+ echo "the classpath of module '${MODULE_PATH}' is not found, generating it ..." >&2
239
+ echo "see output at ${output} for the progress ..." >&2
240
+ ${MVN} -f "${BK_HOME}/${MODULE_PATH}/pom.xml" dependency:build-classpath -Dmdep.outputFile="target/cached_classpath.txt" &> ${output}
241
+ echo "the classpath of module '${MODULE_PATH}' is generated at '${f}'." >&2
242
+ fi
243
+ }
244
+
245
+ set_module_classpath() {
246
+ MODULE_PATH=$1
247
+ if [ -d "${BK_HOME}/lib" ]; then
248
+ BK_CLASSPATH=""
249
+ for i in ${BK_HOME}/lib/*.jar; do
250
+ BK_CLASSPATH=${BK_CLASSPATH}:${i}
251
+ done
252
+ echo ${BK_CLASSPATH}
253
+ else
254
+ add_maven_deps_to_classpath ${MODULE_PATH} >&2
255
+ cat ${BK_HOME}/${MODULE_PATH}/target/cached_classpath.txt
256
+ fi
257
+ return
258
+ }
259
+
260
+ build_bookie_jvm_opts() {
261
+ LOG_DIR=$1
262
+ GC_LOG_FILENAME=$2
263
+ if [ "$USING_JDK8" -eq "1" ]; then
264
+ echo "$BOOKIE_MEM_OPTS $BOOKIE_GC_OPTS $BOOKIE_GC_LOGGING_OPTS $BOOKIE_PERF_OPTS -Xloggc:${LOG_DIR}/${GC_LOG_FILENAME}"
265
+ else
266
+ echo "$BOOKIE_MEM_OPTS $BOOKIE_GC_OPTS $BOOKIE_GC_LOGGING_OPTS $BOOKIE_PERF_OPTS -Xlog:gc=info:file=${LOG_DIR}/${GC_LOG_FILENAME}::filecount=5,filesize=64m"
267
+ fi
268
+ return
269
+ }
270
+
271
+ build_cli_jvm_opts() {
272
+ LOG_DIR=$1
273
+ GC_LOG_FILENAME=$2
274
+ if [ "$USING_JDK8" -eq "1" ]; then
275
+ echo "$CLI_MEM_OPTS $CLI_GC_OPTS $CLI_GC_LOGGING_OPTS -Xloggc:${LOG_DIR}/${GC_LOG_FILENAME}"
276
+ else
277
+ echo "$CLI_MEM_OPTS $CLI_GC_OPTS $CLI_GC_LOGGING_OPTS -Xlog:gc=info:file=${LOG_DIR}/${GC_LOG_FILENAME}::filecount=5,filesize=64m"
278
+ fi
279
+ return
280
+ }
281
+
282
+ build_netty_opts() {
283
+ NETTY_OPTS="-Dio.netty.leakDetectionLevel=${NETTY_LEAK_DETECTION_LEVEL} -Dio.netty.tryReflectionSetAccessible=true"
284
+ # --add-opens does not exist on jdk8
285
+ if [ "$USING_JDK8" -eq "0" ]; then
286
+ # Enable java.nio.DirectByteBuffer
287
+ # https://github.com/netty/netty/blob/4.1/common/src/main/java/io/netty/util/internal/PlatformDependent0.java
288
+ # https://github.com/netty/netty/issues/12265
289
+ NETTY_OPTS="$NETTY_OPTS --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED"
290
+ fi
291
+ echo $NETTY_OPTS
292
+ }
293
+
294
+ build_logging_opts() {
295
+ CONF_FILE=$1
296
+ LOG_LEVEL=$2
297
+ LOG_APPENDER=$3
298
+ LOG_DIR=$4
299
+ LOG_FILE=$5
300
+
301
+ echo "-Dlog4j.configurationFile=`basename ${CONF_FILE}` \
302
+ -Dbookkeeper.log.root.level=${LOG_LEVEL} \
303
+ -Dbookkeeper.log.root.appender=${LOG_APPENDER} \
304
+ -Dbookkeeper.log.dir=${LOG_DIR} \
305
+ -Dbookkeeper.log.file=${LOG_FILE}"
306
+ }
307
+
308
+ build_cli_logging_opts() {
309
+ CONF_FILE=$1
310
+ LOG_LEVEL=$2
311
+ LOG_APPENDER=$3
312
+ LOG_DIR=$4
313
+ LOG_FILE=$5
314
+
315
+ echo "-Dlog4j.configurationFile=`basename ${CONF_FILE}` \
316
+ -Dbookkeeper.cli.log.root.level=${LOG_LEVEL} \
317
+ -Dbookkeeper.cli.log.root.appender=${LOG_APPENDER} \
318
+ -Dbookkeeper.cli.log.dir=${LOG_DIR} \
319
+ -Dbookkeeper.cli.log.file=${LOG_FILE}"
320
+ }
321
+
322
+ build_bookie_opts() {
323
+ BOOKIE_OPTS="-Djava.net.preferIPv4Stack=true"
324
+ # --add-opens does not exist on jdk8
325
+ if [ "$USING_JDK8" -eq "0" ]; then
326
+ # enable posix_fadvise usage in the Journal
327
+ BOOKIE_OPTS="$BOOKIE_OPTS --add-opens java.base/java.io=ALL-UNNAMED"
328
+ # DirectMemoryCRC32Digest
329
+ BOOKIE_OPTS="$BOOKIE_OPTS --add-opens java.base/java.util.zip=ALL-UNNAMED"
330
+ fi
331
+ echo $BOOKIE_OPTS
332
+ }
333
+
334
+ find_table_service() {
335
+ BOOKIE_CONF_TO_CHECK=$1
336
+ SERVICE_COMMAND=$2
337
+
338
+ # check if it is a released binary
339
+ IS_RELEASED_BINARY=$(is_released_binary)
340
+
341
+ # check if table service is released
342
+ TABLE_SERVICE_RELEASED="true"
343
+ if [ "x${IS_RELEASED_BINARY}" == "xtrue" ]; then
344
+ TABLE_SERVICE_RELEASE_JAR=$(find_module_release_jar ${TABLE_SERVICE_MODULE_NAME})
345
+ if [ "x${TABLE_SERVICE_RELEASE_JAR}" == "x" ]; then
346
+ TABLE_SERVICE_RELEASED="false"
347
+ fi
348
+ fi
349
+
350
+ # check the configuration to see if table service is enabled or not.
351
+ if [ -z "${ENABLE_TABLE_SERVICE}" ]; then
352
+ # mask exit code if the configuration file doesn't contain `StreamStorageLifecycleComponent`
353
+ TABLE_SERVICE_SETTING=$(grep StreamStorageLifecycleComponent ${BOOKIE_CONF_TO_CHECK} | cat)
354
+ if [[ "${TABLE_SERVICE_SETTING}" =~ ^extraServerComponents.* ]]; then
355
+ if [ "x${TABLE_SERVICE_RELEASED}" == "xfalse" ]; then
356
+ echo "The release binary is built without table service. Please disable \`StreamStorageLifecycleComponent\` in your bookie configuration at '${BOOKIE_CONF_TO_CHECK}'."
357
+ return
358
+ fi
359
+ ENABLE_TABLE_SERVICE="true"
360
+ fi
361
+ fi
362
+
363
+ # standalone only run
364
+ if [ \( "x${SERVICE_COMMAND}" == "xstandalone" \) -a \( "x${TABLE_SERVICE_RELEASED}" == "xfalse" \) ]; then
365
+ echo "The release binary is built without table service. Use \`localbookie <n>\` instead of \`standalone\` for local development."
366
+ return
367
+ fi
368
+
369
+ if [ \( "x${SERVICE_COMMAND}" == "xstandalone" \) -o \( "x${ENABLE_TABLE_SERVICE}" == "xtrue" \) ]; then
370
+ echo "true"
371
+ return
372
+ else
373
+ echo "false"
374
+ return
375
+ fi
376
+ }
bin/dlog ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ #
3
+ # vim:et:ft=sh:sts=2:sw=2
4
+ #
5
+ #/**
6
+ # * Licensed to the Apache Software Foundation (ASF) under one
7
+ # * or more contributor license agreements. See the NOTICE file
8
+ # * distributed with this work for additional information
9
+ # * regarding copyright ownership. The ASF licenses this file
10
+ # * to you under the Apache License, Version 2.0 (the
11
+ # * "License"); you may not use this file except in compliance
12
+ # * with the License. You may obtain a copy of the License at
13
+ # *
14
+ # * http://www.apache.org/licenses/LICENSE-2.0
15
+ # *
16
+ # * Unless required by applicable law or agreed to in writing, software
17
+ # * distributed under the License is distributed on an "AS IS" BASIS,
18
+ # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ # * See the License for the specific language governing permissions and
20
+ # * limitations under the License.
21
+ # */
22
+
23
+ BINDIR=`dirname "$0"`
24
+ BK_HOME=`cd ${BINDIR}/..;pwd`
25
+
26
+ source ${BK_HOME}/bin/common.sh
27
+
28
+ DLOG_MODULE_NAME="(org.apache.distributedlog-)?distributedlog-core"
29
+ DLOG_MODULE_PATH=stream/distributedlog/core
30
+ DLOG_MODULE_HOME=${BK_HOME}/${DLOG_MODULE_PATH}
31
+
32
+ # find the module jar
33
+ DLOG_JAR=$(find_module_jar ${DLOG_MODULE_PATH} ${DLOG_MODULE_NAME})
34
+
35
+ # set up the classpath
36
+ DLOG_CLASSPATH=$(set_module_classpath ${DLOG_MODULE_PATH})
37
+
38
+ # default variables
39
+ DEFAULT_CONF=${BK_HOME}/conf/bk_server.conf
40
+ DEFAULT_CLI_CONF=${BK_HOME}/conf/bk_server.conf
41
+ DEFAULT_LOG_CONF=${BK_HOME}/conf/log4j2.xml
42
+ DEFAULT_CLI_LOG_CONF=${BK_HOME}/conf/log4j2.cli.xml
43
+
44
+ dlog_help() {
45
+ cat <<EOF
46
+ Usage: dlog <command>
47
+ where command is one of:
48
+ local Run distributedlog sandbox
49
+ tool Run distributedlog tool
50
+ admin Run distributedlog admin tool
51
+ help This help message
52
+
53
+ or command is the full name of a class with a defined main() method.
54
+
55
+ Environment variables:
56
+
57
+ BOOKIE_CONF Bookie configuration file (default: ${DEFAULT_CONF})
58
+ BOOKIE_EXTRA_OPTS Extra options to be passed to the bookie jvm
59
+ BOOKIE_EXTRA_CLASSPATH Add extra paths to the bookie classpath
60
+ CLI_CONF CLI configuration file (default: ${DEFAULT_CLI_CONF})
61
+ CLI_EXTRA_OPTS Extra options to be passed to the CLI jvm
62
+ CLI_EXTRA_CLASSPATH Add extra paths to the CLI classpath
63
+
64
+ These variable can also be set in conf/bkenv.sh & conf/bk_cli_env.sh
65
+ EOF
66
+ }
67
+
68
+ # if no args specified, show usage
69
+ if [ $# = 0 ]; then
70
+ dlog_help;
71
+ exit 1;
72
+ fi
73
+
74
+ # get arguments
75
+ COMMAND=$1
76
+ shift
77
+
78
+ if [ ${COMMAND} == "local" ]; then
79
+ DLOG_CONF=${BOOKIE_CONF:-"${DEFAULT_CONF}"}
80
+ DLOG_LOG_CONF=${BOOKIE_LOG_CONF:-"${DEFAULT_LOG_CONF}"}
81
+ DLOG_LOG_DIR=${BOOKIE_LOG_DIR:-"${BK_HOME}/logs"}
82
+ DLOG_LOG_FILE=${BOOKIE_LOG_FILE:-"dlog.log"}
83
+ DLOG_ROOT_LOG_LEVEL=${BOOKIE_ROOT_LOG_LEVEL:-"INFO"}
84
+ DLOG_ROOT_LOG_APPENDER=${BOOKIE_ROOT_LOG_APPENDER:-"CONSOLE"}
85
+ DLOG_EXTRA_CLASSPATH=${BOOKIE_EXTRA_CLASSPATH}
86
+ DLOG_GC_OPTS=$(build_bookie_jvm_opts ${DLOG_LOG_DIR} "dlog_gc_%p.log")
87
+ DLOG_EXTRA_OPTS=${BOOKIE_EXTRA_OPTS}
88
+ DLOG_LOGGING_OPTS=$(build_logging_opts ${DLOG_LOG_CONF} ${DLOG_ROOT_LOG_LEVEL} ${DLOG_ROOT_LOG_APPENDER} ${DLOG_LOG_DIR} ${DLOG_LOG_FILE})
89
+ else
90
+ DLOG_CONF=${CLI_CONF:-"${DEFAULT_CLI_CONF}"}
91
+ DLOG_LOG_CONF=${CLI_LOG_CONF:-"${DEFAULT_CLI_LOG_CONF}"}
92
+ DLOG_LOG_DIR=${CLI_LOG_DIR:-"${BK_HOME}/logs"}
93
+ DLOG_LOG_FILE=${CLI_LOG_FILE:-"dlog-cli.log"}
94
+ DLOG_ROOT_LOG_LEVEL=${CLI_ROOT_LOG_LEVEL:-"INFO"}
95
+ DLOG_ROOT_LOG_APPENDER=${CLI_ROOT_LOG_APPENDER:-"ROLLINGFILE"}
96
+ DLOG_EXTRA_CLASSPATH=${CLI_EXTRA_CLASSPATH}
97
+ DLOG_GC_OPTS=$(build_cli_jvm_opts ${DLOG_LOG_DIR} "dlog-cli-gc.log")
98
+ DLOG_EXTRA_OPTS=${CLI_EXTRA_OPTS}
99
+ DLOG_LOGGING_OPTS=$(build_cli_logging_opts ${DLOG_LOG_CONF} ${DLOG_ROOT_LOG_LEVEL} ${DLOG_ROOT_LOG_APPENDER} ${DLOG_LOG_DIR} ${DLOG_LOG_FILE})
100
+ fi
101
+
102
+ DLOG_CLASSPATH="$DLOG_JAR:$DLOG_CLASSPATH:$DLOG_EXTRA_CLASSPATH"
103
+ DLOG_CLASSPATH="`dirname $DLOG_LOG_CONF`:$DLOG_CLASSPATH"
104
+
105
+ # Build the OPTS
106
+ BOOKIE_OPTS=$(build_bookie_opts)
107
+ NETTY_OPTS=$(build_netty_opts)
108
+ OPTS="${OPTS} -cp ${DLOG_CLASSPATH} ${BOOKIE_OPTS} ${DLOG_GC_OPTS} ${NETTY_OPTS} ${DLOG_LOGGING_OPTS} ${DLOG_EXTRA_OPTS}"
109
+
110
+ if [ ! -d ${DLOG_LOG_DIR} ]; then
111
+ mkdir ${DLOG_LOG_DIR}
112
+ fi
113
+
114
+ #Change to BK_HOME to support relative paths
115
+ cd "$BK_HOME"
116
+ case "${COMMAND}" in
117
+ local)
118
+ exec "${JAVA}" ${OPTS} ${JMX_ARGS} -Dzookeeper.4lw.commands.whitelist='*' org.apache.distributedlog.LocalDLMEmulator $@
119
+ ;;
120
+ tool)
121
+ exec "${JAVA}" ${OPTS} org.apache.distributedlog.tools.Tool org.apache.distributedlog.tools.DistributedLogTool $@
122
+ ;;
123
+ admin)
124
+ exec "${JAVA}" ${OPTS} org.apache.distributedlog.tools.Tool org.apache.distributedlog.admin.DistributedLogAdmin $@
125
+ ;;
126
+ help)
127
+ dlog_help
128
+ ;;
129
+ *)
130
+ exec "${JAVA}" ${OPTS} ${COMMAND} $@
131
+ ;;
132
+ esac
133
+
bin/standalone ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ #
3
+ # vim:et:ft=sh:sts=2:sw=2
4
+ #
5
+ #/**
6
+ # * Licensed to the Apache Software Foundation (ASF) under one
7
+ # * or more contributor license agreements. See the NOTICE file
8
+ # * distributed with this work for additional information
9
+ # * regarding copyright ownership. The ASF licenses this file
10
+ # * to you under the Apache License, Version 2.0 (the
11
+ # * "License"); you may not use this file except in compliance
12
+ # * with the License. You may obtain a copy of the License at
13
+ # *
14
+ # * http://www.apache.org/licenses/LICENSE-2.0
15
+ # *
16
+ # * Unless required by applicable law or agreed to in writing, software
17
+ # * distributed under the License is distributed on an "AS IS" BASIS,
18
+ # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ # * See the License for the specific language governing permissions and
20
+ # * limitations under the License.
21
+ # */
22
+ usage() {
23
+ cat <<EOF
24
+ Usage: standalone <runtime> (up|down)
25
+ where runtime is one of:
26
+ process Run a standalone cluster in one process
27
+ docker-compose Run a standalone cluster in a docker-composed cluster
28
+ EOF
29
+ }
30
+
31
+ BINDIR=${BK_BINDIR:-"`dirname "$0"`"}
32
+
33
+ if [ $# -lt 2 ]
34
+ then
35
+ echo "Error: no enough arguments provided."
36
+ usage
37
+ exit 1
38
+ fi
39
+
40
+ runtime=$1
41
+ shift
42
+ action=$1
43
+ shift
44
+
45
+ case $runtime in
46
+ (process)
47
+ ${BINDIR}/standalone.process $action $@
48
+ ;;
49
+ (docker-compose)
50
+ DOCKER_COMPOSE=$(which docker-compose)
51
+ if [ $? != 0 ]; then
52
+ echo "Error: docker-compose is not found in ${PATH}." 1>&2
53
+ usage
54
+ exit 1
55
+ else
56
+ echo ${BINDIR}/standalone.docker-compose $action $@
57
+ ${BINDIR}/standalone.docker-compose $action $@
58
+ fi
59
+ ;;
60
+ (*)
61
+ echo "Error: unknown runtime $command"
62
+ usage
63
+ exit 1
64
+ ;;
65
+ esac
bin/standalone.docker-compose ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ #
3
+ # vim:et:ft=sh:sts=2:sw=2
4
+ #
5
+ #/**
6
+ # * Licensed to the Apache Software Foundation (ASF) under one
7
+ # * or more contributor license agreements. See the NOTICE file
8
+ # * distributed with this work for additional information
9
+ # * regarding copyright ownership. The ASF licenses this file
10
+ # * to you under the Apache License, Version 2.0 (the
11
+ # * "License"); you may not use this file except in compliance
12
+ # * with the License. You may obtain a copy of the License at
13
+ # *
14
+ # * http://www.apache.org/licenses/LICENSE-2.0
15
+ # *
16
+ # * Unless required by applicable law or agreed to in writing, software
17
+ # * distributed under the License is distributed on an "AS IS" BASIS,
18
+ # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ # * See the License for the specific language governing permissions and
20
+ # * limitations under the License.
21
+ # */
22
+
23
+ BINDIR=${BK_BINDIR:-"`dirname "$0"`"}
24
+
25
+ source ${BINDIR}/common.sh
26
+
27
+ DOCKER_COMPOSE=docker-compose
28
+
29
+ DATA_ROOT_DIR=${BK_DATA_DIR:-"${BK_HOME}/data"}
30
+ mkdir -p ${DATA_ROOT_DIR}
31
+
32
+ function gen_metadata_service_section() {
33
+ local cluster=$1
34
+ local image=$2
35
+ cat <<EOF
36
+ metadata-service:
37
+ image: ${image}
38
+ hostname: metadata-service
39
+ command: ["zookeeper"]
40
+ environment:
41
+ - ZK_dataDir=/data/zookeeper/data
42
+ - ZK_dataLogDir=/data/zookeeper/txlog
43
+ - ZK_standaloneEnabled=true
44
+ ports:
45
+ - "9990:9990"
46
+ - "2181:2181"
47
+ volumes:
48
+ - "${DATA_ROOT_DIR}/${cluster}/zookeeper/data:/data/zookeeper/data"
49
+ - "${DATA_ROOT_DIR}/${cluster}/zookeeper/txlog:/data/zookeeper/txlog"
50
+ EOF
51
+ }
52
+
53
+ function gen_bookie_section() {
54
+ local cluster=$1
55
+ local bookie_name=$2
56
+ local bookie_port=$3
57
+ local bookie_http_port=$4
58
+ local bookie_grpc_port=$5
59
+ local image=$6
60
+ cat <<EOF
61
+ ${bookie_name}:
62
+ image: ${image}
63
+ depends_on:
64
+ - metadata-service
65
+ environment:
66
+ # metadata service
67
+ - BK_zkServers=metadata-service
68
+ - BK_zkLedgersRootPath=/ledgers
69
+ - BK_metadataServiceUri=zk://metadata-service/ledgers
70
+ # bookie
71
+ - BK_DATA_DIR=/data/bookkeeper
72
+ - BK_advertisedAddress=${bookie_name}
73
+ # bookie http
74
+ - BK_httpServerEnabled=true
75
+ # stream storage
76
+ - BK_extraServerComponents=org.apache.bookkeeper.stream.server.StreamStorageLifecycleComponent
77
+ ports:
78
+ - "${bookie_port}:3181"
79
+ - "${bookie_http_port}:8080"
80
+ - "${bookie_grpc_port}:4181"
81
+ volumes:
82
+ - "${DATA_ROOT_DIR}/${cluster}/${bookie_name}/journal:/data/bookkeeper/journal"
83
+ - "${DATA_ROOT_DIR}/${cluster}/${bookie_name}/ledgers:/data/bookkeeper/ledgers"
84
+ EOF
85
+ }
86
+
87
+ function generate_docker_compose_file() {
88
+ local cluster=$1
89
+ local num_bookies=$2
90
+ local image=$3
91
+ local docker_compose_file="${DATA_ROOT_DIR}/${cluster}/docker-compose.yml"
92
+
93
+ local metadata_service_section=$(gen_metadata_service_section ${cluster} ${image})
94
+
95
+ echo "version: '3'" > ${docker_compose_file}
96
+ echo "" >> ${docker_compose_file}
97
+ echo "services:" >> ${docker_compose_file}
98
+ echo "" >> ${docker_compose_file}
99
+ echo "${metadata_service_section}" >> ${docker_compose_file}
100
+ echo "" >> ${docker_compose_file}
101
+ local BI=0
102
+ while [ ${BI} -lt $((num_bookies)) ]; do
103
+ local bookie_port=$((3181 + BI))
104
+ local bookie_http_port=$((8080 + BI))
105
+ local bookie_grpc_port=$((4181 + BI))
106
+ local bookie_section=$(gen_bookie_section ${cluster} "bookie-${BI}" ${bookie_port} ${bookie_http_port} ${bookie_grpc_port} ${image})
107
+ echo "${bookie_section}" >> ${docker_compose_file}
108
+ let BI=BI+1
109
+ done
110
+ }
111
+
112
+ function show_help() {
113
+ cat <<EOF
114
+ Usage: standalone.docker-compose [-c <cluster_name>] [-h] <action:[up|down]>
115
+ EOF
116
+ }
117
+
118
+ # main entrypoint
119
+
120
+ CLUSTER_NAME="bk-standalone-dc"
121
+ OPTIND=1
122
+ IMAGE=${IMAGE:-"apachebookkeeper/bookkeeper-current"}
123
+ NUM_BOOKIES=${NUM_BOOKIES:-"3"}
124
+
125
+ while getopts "h:c:" opt; do
126
+ case "${opt}" in
127
+ c )
128
+ CLUSTER_NAME=${OPTARG}
129
+ echo "use cluster = '${CLUSTER_NAME}'."
130
+ ;;
131
+ h|\? )
132
+ show_help
133
+ exit 1
134
+ ;;
135
+ esac
136
+ done
137
+
138
+ shift $((OPTIND-1))
139
+
140
+ [ "${1:-}" = "--" ] && shift
141
+
142
+ if [ $# -le 0 ]; then
143
+ show_help
144
+ exit 1
145
+ fi
146
+
147
+ ACTION=$1
148
+ DOCKER_COMPOSE_OPTS=""
149
+ case "${ACTION}" in
150
+ up)
151
+ DOCKER_COMPOSE_OPTS="--detach"
152
+ ;;
153
+ down)
154
+ ;;
155
+ *)
156
+ echo "Unknown action : ${ACTION}"
157
+ show_help
158
+ exit 1
159
+ ;;
160
+ esac
161
+
162
+ CLUSTER_DATA_ROOT="${DATA_ROOT_DIR}/${CLUSTER_NAME}"
163
+ mkdir -p ${CLUSTER_DATA_ROOT}
164
+
165
+ # generate docker compose file
166
+ DOCKER_COMPOSE_FILE="${CLUSTER_DATA_ROOT}/docker-compose.yml"
167
+
168
+ if [ ! -f ${DOCKER_COMPOSE_FILE} ]; then
169
+ generate_docker_compose_file ${CLUSTER_NAME} ${NUM_BOOKIES} ${IMAGE}
170
+ fi
171
+
172
+ cd ${CLUSTER_DATA_ROOT}
173
+
174
+
175
+
176
+ ${DOCKER_COMPOSE} $@ ${DOCKER_COMPOSE_OPTS}
177
+
178
+ if [ $? == 0 -a "${ACTION}" == "up" ]; then
179
+ echo ""
180
+ echo "Standalone cluster '${CLUSTER_NAME}' is up running."
181
+ echo "Use following uris to connect to standalone cluster:"
182
+ echo ""
183
+ echo " - metadata service uri = 'zk://localhost/ledgers'"
184
+ echo " - dlog uri = 'distributedlog://localhost/distributedlog'"
185
+ fi
186
+ exit $?