diff --git a/.github/ISSUE_TEMPLATE/flaky-test.yml b/.github/ISSUE_TEMPLATE/flaky-test.yml
index f46ff539849ec..d3e5ec061713e 100644
--- a/.github/ISSUE_TEMPLATE/flaky-test.yml
+++ b/.github/ISSUE_TEMPLATE/flaky-test.yml
@@ -51,9 +51,9 @@ body:
Full exception stacktrace
-
+
full exception stacktrace here
-
+
validations:
required: true
diff --git a/.github/workflows/ci-go-functions.yaml b/.github/workflows/ci-go-functions.yaml
index cb21a5028c63e..8ff8023fe4660 100644
--- a/.github/workflows/ci-go-functions.yaml
+++ b/.github/workflows/ci-go-functions.yaml
@@ -32,10 +32,10 @@ concurrency:
cancel-in-progress: true
env:
- MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3
+ MAVEN_OPTS: -Xss1500k -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3
jobs:
- changed_files_job:
+ preconditions:
name: Preconditions
runs-on: ubuntu-20.04
outputs:
@@ -65,8 +65,8 @@ jobs:
build/pulsar_ci_tool.sh check_ready_to_test
check-style:
- needs: changed_files_job
- if: ${{ needs.changed_files_job.outputs.docs_only != 'true' }}
+ needs: preconditions
+ if: ${{ needs.preconditions.outputs.docs_only != 'true' }}
name: Go ${{ matrix.go-version }} Functions style check
runs-on: ubuntu-20.04
strategy:
diff --git a/.github/workflows/ci-maven-cache-update.yaml b/.github/workflows/ci-maven-cache-update.yaml
index bf7f70bb032f2..daba3dcc0321e 100644
--- a/.github/workflows/ci-maven-cache-update.yaml
+++ b/.github/workflows/ci-maven-cache-update.yaml
@@ -42,7 +42,7 @@ on:
- cron: '30 */12 * * *'
env:
- MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3
+ MAVEN_OPTS: -Xss1500k -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3
jobs:
update-maven-dependencies-cache:
diff --git a/.github/workflows/ci-owasp-dependency-check.yaml b/.github/workflows/ci-owasp-dependency-check.yaml
index 595d82f4ce07e..38bd7f9eec419 100644
--- a/.github/workflows/ci-owasp-dependency-check.yaml
+++ b/.github/workflows/ci-owasp-dependency-check.yaml
@@ -23,7 +23,7 @@ on:
- cron: '15 0 * * *'
env:
- MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3
+ MAVEN_OPTS: -Xss1500k -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3
jobs:
run-owasp-dependency-check:
diff --git a/.github/workflows/ci-semantic-pull-request.yml b/.github/workflows/ci-semantic-pull-request.yml
index 2473f8e11266c..28246eb2b819c 100644
--- a/.github/workflows/ci-semantic-pull-request.yml
+++ b/.github/workflows/ci-semantic-pull-request.yml
@@ -57,10 +57,12 @@ jobs:
# txn -> transaction
# ws -> websocket
# ml -> managed ledger
+ # zk -> zookeeper
+ # bk -> bookkeeper
scopes: |
admin
+ bk
broker
- ml
build
ci
cli
@@ -70,6 +72,7 @@ jobs:
io
meta
misc
+ ml
monitor
offload
proxy
@@ -81,12 +84,13 @@ jobs:
test
txn
ws
- # The pull request's title should be fulfill the following pattern:
+ zk
+ # The pull request's title should be fulfilled the following pattern:
#
# [][]
#
# ... where valid types and scopes can be found above; for example:
#
# [fix][test] flaky test V1_ProxyAuthenticationTest.anonymousSocketTest
- headerPattern: '^\[(\w*)\](?:\[(.*)\])? (.*)$'
+ headerPattern: '^\[(\w*?)\](?:\[(.*?)\])?(?:\s*)(.*)$'
headerPatternCorrespondence: type, scope, subject
diff --git a/.github/workflows/pulsar-ci-flaky.yaml b/.github/workflows/pulsar-ci-flaky.yaml
index b5fa8e4a7540c..9c52cfe77d65d 100644
--- a/.github/workflows/pulsar-ci-flaky.yaml
+++ b/.github/workflows/pulsar-ci-flaky.yaml
@@ -29,14 +29,14 @@ concurrency:
cancel-in-progress: true
env:
- MAVEN_OPTS: -Xmx1024m -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3
+ MAVEN_OPTS: -Xss1500k -Xmx1024m -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3
# defines the retention period for the intermediate build artifacts needed for rerunning a failed build job
# it's possible to rerun individual failed jobs when the build artifacts are available
# if the artifacts have already been expired, the complete workflow can be rerun by closing and reopening the PR or by rebasing the PR
ARTIFACT_RETENTION_DAYS: 3
jobs:
- changed_files_job:
+ preconditions:
name: Preconditions
runs-on: ubuntu-20.04
outputs:
@@ -67,11 +67,11 @@ jobs:
build/pulsar_ci_tool.sh check_ready_to_test
build-and-test:
- needs: changed_files_job
+ needs: preconditions
name: Flaky tests suite
runs-on: ubuntu-20.04
timeout-minutes: 100
- if: ${{ needs.changed_files_job.outputs.docs_only != 'true' }}
+ if: ${{ needs.preconditions.outputs.docs_only != 'true' }}
steps:
- name: checkout
uses: actions/checkout@v3
@@ -108,7 +108,7 @@ jobs:
- name: Run unit test group BROKER_FLAKY
run: |
- CHANGED_TESTS="${{ needs.changed_files_job.outputs.tests_files }}" ./build/run_unit_group.sh BROKER_FLAKY
+ CHANGED_TESTS="${{ needs.preconditions.outputs.tests_files }}" ./build/run_unit_group.sh BROKER_FLAKY
- name: print JVM thread dumps when cancelled
if: cancelled()
diff --git a/.github/workflows/pulsar-ci.yaml b/.github/workflows/pulsar-ci.yaml
index c7198b04917ec..ea518b580432d 100644
--- a/.github/workflows/pulsar-ci.yaml
+++ b/.github/workflows/pulsar-ci.yaml
@@ -22,6 +22,8 @@ on:
pull_request:
branches:
- master
+ schedule:
+ - cron: '0 12 * * *'
workflow_dispatch:
concurrency:
@@ -29,16 +31,17 @@ concurrency:
cancel-in-progress: true
env:
- MAVEN_OPTS: -Xmx1024m -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3
+ MAVEN_OPTS: -Xss1500k -Xmx1024m -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3
# defines the retention period for the intermediate build artifacts needed for rerunning a failed build job
# it's possible to rerun individual failed jobs when the build artifacts are available
# if the artifacts have already been expired, the complete workflow can be rerun by closing and reopening the PR or by rebasing the PR
ARTIFACT_RETENTION_DAYS: 3
jobs:
- changed_files_job:
+ preconditions:
name: Preconditions
runs-on: ubuntu-20.04
+ if: (github.event_name != 'schedule') || (github.repository == 'apache/pulsar')
outputs:
docs_only: ${{ steps.check_changes.outputs.docs_only }}
changed_tests: ${{ steps.changes.outputs.tests_files }}
@@ -68,11 +71,11 @@ jobs:
build/pulsar_ci_tool.sh check_ready_to_test
build-and-license-check:
- needs: changed_files_job
+ needs: preconditions
name: Build and License check
runs-on: ubuntu-20.04
timeout-minutes: 60
- if: ${{ needs.changed_files_job.outputs.docs_only != 'true' }}
+ if: ${{ needs.preconditions.outputs.docs_only != 'true' }}
steps:
- name: checkout
uses: actions/checkout@v3
@@ -106,9 +109,12 @@ jobs:
- name: Check source code license headers
run: mvn -B -T 8 -ntp initialize apache-rat:check license:check
+ - name: Check source code style
+ run: mvn -B -T 8 -ntp initialize checkstyle:check
+
- name: Build core-modules
run: |
- mvn -B -T 1C -ntp -Pcore-modules,-main clean install -DskipTests -Dlicense.skip=true -Drat.skip=true
+ mvn -B -T 1C -ntp -Pcore-modules,-main clean install -DskipTests -Dlicense.skip=true -Drat.skip=true -Dcheckstyle.skip=true
- name: Check binary licenses
run: src/check-binary-license.sh ./distribution/server/target/apache-pulsar-*-bin.tar.gz
@@ -139,8 +145,8 @@ jobs:
name: CI - Unit - ${{ matrix.name }}
runs-on: ubuntu-20.04
timeout-minutes: ${{ matrix.timeout || 60 }}
- needs: ['changed_files_job', 'build-and-license-check']
- if: ${{ needs.changed_files_job.outputs.docs_only != 'true' }}
+ needs: ['preconditions', 'build-and-license-check']
+ if: ${{ needs.preconditions.outputs.docs_only != 'true' }}
strategy:
fail-fast: false
matrix:
@@ -162,6 +168,8 @@ jobs:
group: PROXY
- name: Pulsar IO
group: PULSAR_IO
+ - name: Pulsar Client
+ group: CLIENT
steps:
- name: checkout
@@ -207,7 +215,7 @@ jobs:
- name: Run unit test group '${{ matrix.group }}'
run: |
- CHANGED_TESTS="${{ needs.changed_files_job.outputs.tests_files }}" ./build/run_unit_group.sh ${{ matrix.group }}
+ CHANGED_TESTS="${{ needs.preconditions.outputs.tests_files }}" ./build/run_unit_group.sh ${{ matrix.group }}
- name: print JVM thread dumps when cancelled
if: cancelled()
@@ -260,8 +268,8 @@ jobs:
name: Build Pulsar java-test-image docker image
runs-on: ubuntu-20.04
timeout-minutes: 60
- needs: ['changed_files_job', 'build-and-license-check']
- if: ${{ needs.changed_files_job.outputs.docs_only != 'true'}}
+ needs: ['preconditions', 'build-and-license-check']
+ if: ${{ needs.preconditions.outputs.docs_only != 'true'}}
env:
UBUNTU_MIRROR: http://azure.archive.ubuntu.com/ubuntu/
steps:
@@ -325,8 +333,8 @@ jobs:
name: CI - Integration - ${{ matrix.name }}
runs-on: ubuntu-20.04
timeout-minutes: ${{ matrix.timeout || 60 }}
- needs: ['changed_files_job', 'pulsar-java-test-image']
- if: ${{ needs.changed_files_job.outputs.docs_only != 'true' }}
+ needs: ['preconditions', 'pulsar-java-test-image']
+ if: ${{ needs.preconditions.outputs.docs_only != 'true' }}
env:
PULSAR_TEST_IMAGE_NAME: apachepulsar/java-test-image:latest
strategy:
@@ -465,10 +473,10 @@ jobs:
runs-on: ubuntu-20.04
timeout-minutes: 10
needs: [
- 'changed_files_job',
+ 'preconditions',
'integration-tests'
]
- if: ${{ needs.changed_files_job.outputs.docs_only != 'true' }}
+ if: ${{ needs.preconditions.outputs.docs_only != 'true' }}
steps:
- name: checkout
uses: actions/checkout@v3
@@ -487,8 +495,8 @@ jobs:
name: Build Pulsar docker image
runs-on: ubuntu-20.04
timeout-minutes: 60
- needs: ['changed_files_job', 'build-and-license-check']
- if: ${{ needs.changed_files_job.outputs.docs_only != 'true' }}
+ needs: ['preconditions', 'build-and-license-check']
+ if: ${{ needs.preconditions.outputs.docs_only != 'true' }}
env:
UBUNTU_MIRROR: http://azure.archive.ubuntu.com/ubuntu/
steps:
@@ -541,29 +549,33 @@ jobs:
-Pmain,docker -Dmaven.test.skip=true -Ddocker.squash=true \
-Dspotbugs.skip=true -Dlicense.skip=true -Dcheckstyle.skip=true -Drat.skip=true
+ # check full build artifacts licenses
+ - name: Check binary licenses
+ run: src/check-binary-license.sh ./distribution/server/target/apache-pulsar-*-bin.tar.gz
+
- name: Clean up disk space
run: |
# release disk space since saving docker image consumes local disk space
#
echo "::group::Available diskspace before cleaning"
time df -BM / /mnt
- echo "::endgroup::"
+ echo "::endgroup::"
echo "::group::Clean build directory"
# docker build changes some files to root ownership, fix this before deleting files
sudo chown -R $USER:$GROUP .
# clean build directories
time git clean -fdx
- echo "::endgroup::"
+ echo "::endgroup::"
echo "::group::Available diskspace after cleaning build directory"
time df -BM / /mnt
echo "::endgroup::"
echo "::group::Delete maven repository"
# delete maven repository
time rm -rf ~/.m2/repository
- echo "::endgroup::"
+ echo "::endgroup::"
echo "::group::Available diskspace after cleaning maven repository"
time df -BM / /mnt
- echo "::endgroup::"
+ echo "::endgroup::"
- name: save docker image apachepulsar/pulsar-test-latest-version:latest to Github artifact cache
run: |
@@ -581,8 +593,8 @@ jobs:
name: CI - System - ${{ matrix.name }}
runs-on: ubuntu-20.04
timeout-minutes: 60
- needs: ['changed_files_job', 'pulsar-test-latest-version-image']
- if: ${{ needs.changed_files_job.outputs.docs_only != 'true' }}
+ needs: ['preconditions', 'pulsar-test-latest-version-image']
+ if: ${{ needs.preconditions.outputs.docs_only != 'true' }}
env:
PULSAR_TEST_IMAGE_NAME: apachepulsar/pulsar-test-latest-version:latest
strategy:
@@ -709,8 +721,8 @@ jobs:
name: CI Flaky - System - ${{ matrix.name }}
runs-on: ubuntu-20.04
timeout-minutes: 60
- needs: [ 'changed_files_job', 'pulsar-test-latest-version-image' ]
- if: ${{ needs.changed_files_job.outputs.docs_only != 'true' }}
+ needs: [ 'preconditions', 'pulsar-test-latest-version-image' ]
+ if: ${{ needs.preconditions.outputs.docs_only != 'true' }}
env:
PULSAR_TEST_IMAGE_NAME: apachepulsar/pulsar-test-latest-version:latest
strategy:
@@ -821,11 +833,11 @@ jobs:
runs-on: ubuntu-20.04
timeout-minutes: 10
needs: [
- 'changed_files_job',
+ 'preconditions',
'system-tests',
'flaky-system-tests'
]
- if: ${{ needs.changed_files_job.outputs.docs_only != 'true' }}
+ if: ${{ needs.preconditions.outputs.docs_only != 'true' }}
steps:
- name: checkout
uses: actions/checkout@v3
@@ -844,8 +856,8 @@ jobs:
name: Build Pulsar on MacOS
runs-on: macos-11
timeout-minutes: 120
- needs: ['changed_files_job', 'integration-tests']
- if: ${{ needs.changed_files_job.outputs.docs_only != 'true' }}
+ needs: ['preconditions', 'integration-tests']
+ if: ${{ needs.preconditions.outputs.docs_only != 'true' }}
steps:
- name: checkout
uses: actions/checkout@v3
@@ -876,8 +888,8 @@ jobs:
name: OWASP dependency check
runs-on: ubuntu-20.04
timeout-minutes: 120
- needs: [ 'changed_files_job', 'integration-tests' ]
- if: ${{ needs.changed_files_job.outputs.need_owasp == 'true' }}
+ needs: [ 'preconditions', 'integration-tests' ]
+ if: ${{ needs.preconditions.outputs.need_owasp == 'true' }}
steps:
- name: checkout
uses: actions/checkout@v3
@@ -942,11 +954,11 @@ jobs:
# It cleans up the binaries in the same job in order to not spin up another runner for basically doing nothing.
pulsar-ci-checks-completed:
name: "Pulsar CI checks completed"
- if: always()
+ if: ${{ always() && ((github.event_name != 'schedule') || (github.repository == 'apache/pulsar')) }}
runs-on: ubuntu-20.04
timeout-minutes: 10
needs: [
- 'changed_files_job',
+ 'preconditions',
'unit-tests',
'integration-tests',
'system-tests',
@@ -955,7 +967,7 @@ jobs:
]
steps:
- name: Check that all required jobs were completed successfully
- if: ${{ needs.changed_files_job.outputs.docs_only != 'true' }}
+ if: ${{ needs.preconditions.outputs.docs_only != 'true' }}
run: |
if [[ ! ( \
"${{ needs.unit-tests.result }}" == "success" \
@@ -964,23 +976,23 @@ jobs:
&& "${{ needs.macos-build.result }}" == "success" \
) ]]; then
echo "Required jobs haven't been completed successfully."
- exit 1
+ exit 1
fi
- name: checkout
- if: ${{ needs.changed_files_job.outputs.docs_only != 'true' }}
+ if: ${{ needs.preconditions.outputs.docs_only != 'true' }}
uses: actions/checkout@v3
- name: Tune Runner VM
- if: ${{ needs.changed_files_job.outputs.docs_only != 'true' }}
+ if: ${{ needs.preconditions.outputs.docs_only != 'true' }}
uses: ./.github/actions/tune-runner-vm
- name: Install gh-actions-artifact-client.js
- if: ${{ needs.changed_files_job.outputs.docs_only != 'true' }}
+ if: ${{ needs.preconditions.outputs.docs_only != 'true' }}
uses: apache/pulsar-test-infra/gh-actions-artifact-client/dist@master
- name: Delete maven repository binaries from GitHub Actions Artifacts
- if: ${{ needs.changed_files_job.outputs.docs_only != 'true' }}
+ if: ${{ needs.preconditions.outputs.docs_only != 'true' }}
run: |
gh-actions-artifact-client.js delete pulsar-maven-repository-binaries.tar.zst || true
gh-actions-artifact-client.js delete pulsar-server-distribution.tar.zst || true
diff --git a/.gitignore b/.gitignore
index 19a86045daf17..2759cf054f57e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,6 +31,7 @@ pulsar-functions/worker/src/test/resources/
!.idea/vcs.xml
*.iml
*.iws
+.fleet/*
# NetBeans
nb-configuration.xml
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index c57f9ab74b94e..db83924c47c8a 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -21,6 +21,4 @@
## Contributing to Apache Pulsar
-We would love for you to contribute to Apache Pulsar and make it even better!
-Please check the [Contributing to Apache Pulsar](https://pulsar.apache.org/contributing/)
-page before starting to work on the project.
+We would love for you to contribute to Apache Pulsar and make it even better! Please check the [Apache Pulsar Contributing Guide](https://pulsar.apache.org/contribute/) before starting to work on the project.
diff --git a/README.md b/README.md
index 4b2486e50b7e1..59911199f9810 100644
--- a/README.md
+++ b/README.md
@@ -24,8 +24,7 @@
[](https://hub.docker.com/r/apachepulsar/pulsar)
[](https://github.com/apache/pulsar/graphs/contributors)
[](https://github.com/apache/pulsar/commits/master)
-[](https://github.com/apache/pulsar/releases)
-[](https://github.com/apache/pulsar/releases)
+[](https://pulsar.apache.org/download/)
[](https://pulsar.apache.org/download/)
Pulsar is a distributed pub-sub messaging platform with a very
@@ -68,18 +67,15 @@ components in the Pulsar ecosystem, including connectors, adapters, and other la
### Ecosystem
- [Pulsar Adapters](https://github.com/apache/pulsar-adapters)
-- [Pulsar Connectors](https://github.com/apache/pulsar-connectors)
-- [Pulsar SQL (Pulsar Presto Connector)](https://github.com/apache/pulsar-presto)
### Clients
-- [C++ Client](https://github.com/apache/pulsar-client-cpp)
-- [Python Client](https://github.com/apache/pulsar-client-python)
- [.NET/C# Client](https://github.com/apache/pulsar-dotpulsar)
+- [C++ Client](https://github.com/apache/pulsar-client-cpp)
- [Go Client](https://github.com/apache/pulsar-client-go)
- [NodeJS Client](https://github.com/apache/pulsar-client-node)
+- [Python Client](https://github.com/apache/pulsar-client-python)
- [Reactive Java Client](https://github.com/apache/pulsar-client-reactive)
-- [Ruby Client](https://github.com/apache/pulsar-client-ruby)
### Dashboard & Management Tools
@@ -89,39 +85,42 @@ components in the Pulsar ecosystem, including connectors, adapters, and other la
- [Pulsar Site](https://github.com/apache/pulsar-site)
-### Documentation
-
-- [Pulsar Translation](https://github.com/apache/pulsar-translation)
-
### CI/CD
- [Pulsar CI](https://github.com/apache/pulsar-test-infra)
+### Archived/Halted
+
+- [Pulsar Connectors](https://github.com/apache/pulsar-connectors) (bundled as [pulsar-io](pulsar-io))
+- [Pulsar Translation](https://github.com/apache/pulsar-translation)
+- [Pulsar SQL (Pulsar Presto Connector)](https://github.com/apache/pulsar-presto) (bundled as [pulsar-sql](pulsar-sql))
+- [Ruby Client](https://github.com/apache/pulsar-client-ruby)
+
## Pulsar Runtime Java Version Recommendation
- pulsar ver > 2.10 and master branch
-| Pulsar Components | Java Version |
-| ----------------- | :-----------: |
-| Broker | 17 |
-| Functions / IO | 17 |
-| CLI | 17 |
-| Java Client | 8 or 11 or 17 |
+| Components | Java Version |
+|----------------|:-------------:|
+| Broker | 17 |
+| Functions / IO | 17 |
+| CLI | 17 |
+| Java Client | 8 or 11 or 17 |
- 2.8 <= pulsar ver <= 2.10
-| Pulsar Components | Java Version |
-| ----------------- | :----------: |
-| Broker | 11 |
-| Functions / IO | 11 |
-| CLI | 8 or 11 |
-| Java Client | 8 or 11 |
+| Components | Java Version |
+|----------------|:------------:|
+| Broker | 11 |
+| Functions / IO | 11 |
+| CLI | 8 or 11 |
+| Java Client | 8 or 11 |
- pulsar ver < 2.8
-| Pulsar Components | Java Version |
-| ----------------- | :----------: |
-| All | 8 or 11 |
+| Components | Java Version |
+|------------|:------------:|
+| All | 8 or 11 |
## Build Pulsar
@@ -129,19 +128,24 @@ components in the Pulsar ecosystem, including connectors, adapters, and other la
- JDK
- | Pulsar Version | JDK Version |
- | ----------------- | :----------: |
- | master and 2.11 + | [JDK 17](https://adoptium.net/?variant=openjdk17) |
- | 2.8 / 2.9 / 2.10 | [JDK 11](https://adoptium.net/?variant=openjdk11) |
- | 2.7 - | [JDK 8](https://adoptium.net/?variant=openjdk8) |
+ | Pulsar Version | JDK Version |
+ |-------------------|:-------------------------------------------------:|
+ | master and 2.11 + | [JDK 17](https://adoptium.net/?variant=openjdk17) |
+ | 2.8 / 2.9 / 2.10 | [JDK 11](https://adoptium.net/?variant=openjdk11) |
+ | 2.7 - | [JDK 8](https://adoptium.net/?variant=openjdk8) |
- Maven 3.6.1+
- zip
-> Note: this project includes a [Maven Wrapper](https://maven.apache.org/wrapper/) that can be used instead of a system installed Maven.
-> Use it by replacing `mvn` by `./mvnw` on Linux and `mvnw.cmd` on Windows in the commands below.
+> **Note**:
+>
+> This project includes a [Maven Wrapper](https://maven.apache.org/wrapper/) that can be used instead of a system-installed Maven.
+> Use it by replacing `mvn` by `./mvnw` on Linux and `mvnw.cmd` on Windows in the commands below.
+>
+> It's better to use CMD rather than Powershell on Windows. Because maven will activate the `windows` profile which runs `rename-netty-native-libs.cmd`.
### Build
+
Compile and install:
```bash
@@ -156,7 +160,7 @@ $ mvn -pl module-name (e.g: pulsar-broker) install -DskipTests
### Minimal build (This skips most of external connectors and tiered storage handlers)
-```
+```bash
mvn install -Pcore-modules,-main -DskipTests
```
@@ -188,21 +192,18 @@ Check https://pulsar.apache.org for documentation and examples.
## Build custom docker images
-Docker images must be built with Java 8 for `branch-2.7` or previous branches because of
-[issue 8445](https://github.com/apache/pulsar/issues/8445).
-Java 11 is the recommended JDK version in `branch-2.8`, `branch-2.9` and `branch-2.10`.
-Java 17 is the recommended JDK version in `master`.
+* Docker images must be built with Java 8 for `branch-2.7` or previous branches because of [ISSUE-8445](https://github.com/apache/pulsar/issues/8445).
+* Java 11 is the recommended JDK version in `branch-2.8`, `branch-2.9` and `branch-2.10`.
+* Java 17 is the recommended JDK version in `master`.
-This builds the docker images `apachepulsar/pulsar-all:latest` and `apachepulsar/pulsar:latest`.
+The following command builds the docker images `apachepulsar/pulsar-all:latest` and `apachepulsar/pulsar:latest`:
```bash
mvn clean install -DskipTests
mvn package -Pdocker,-main -am -pl docker/pulsar-all -DskipTests
```
-After the images are built, they can be tagged and pushed to your custom repository.
-Here's an example of a bash script that tags the docker images with the current version and git revision and
-pushes them to `localhost:32000/apachepulsar`.
+After the images are built, they can be tagged and pushed to your custom repository. Here's an example of a bash script that tags the docker images with the current version and git revision and pushes them to `localhost:32000/apachepulsar`.
```bash
image_repo_and_project=localhost:32000/apachepulsar
@@ -218,134 +219,20 @@ docker push ${image_repo_and_project}/pulsar:$tag
## Setting up your IDE
-Apache Pulsar is using [lombok](https://projectlombok.org/) so you have to ensure your IDE setup with
-required plugins.
-
-### IntelliJ
-
-#### Configure Project JDK to Java 17 JDK
-
-1. Open **Project Settings**.
-
- Click **File** -> **Project Structure** -> **Project Settings** -> **Project**.
-
-2. Select the JDK version.
-
- From the JDK version drop-down list, select **Download JDK...** or choose an existing recent Java 17 JDK version.
-
-3. In the download dialog, select version **17**. You can pick a version from many vendors. Unless you have a specific preference, choose **Eclipse Temurin (AdoptOpenJDK (Hotspot))**.
-
-#### Configure Java version for Maven in IntelliJ
-
-1. Open Maven Importing Settings dialog by going to
- **Settings** -> **Build, Execution, Deployment** -> **Build Tools** -> **Maven** -> **Importing**.
-
-2. Choose **Use Project JDK** for **JDK for Importer** setting. This uses the Java 17 JDK for running Maven
- when importing the project to IntelliJ. Some of the configuration in the Maven build is conditional based on
- the JDK version. Incorrect configuration gets chosen when the "JDK for Importer" isn't the same as the "Project JDK".
-
-3. Validate that the JRE setting in **Maven** -> **Runner** dialog is set to **Use Project JDK**.
-
-#### Configure annotation processing in IntelliJ
-
-1. Open Annotation Processors Settings dialog box by going to
- **Settings** -> **Build, Execution, Deployment** -> **Compiler** -> **Annotation Processors**.
-
-2. Select the following buttons:
-
- 1. **Enable annotation processing**
- 2. **Obtain processors from project classpath**
- 3. Store generated sources relative to: **Module content root**
-
-3. Set the generated source directories to be equal to the Maven directories:
-
- 1. Set "Production sources directory:" to "target/generated-sources/annotations".
- 2. Set "Test sources directory:" to "target/generated-test-sources/test-annotations".
-
-4. Click **OK**.
-
-5. Install the lombok plugin in intelliJ.
-
-#### Configure code style
-
-1. Open Code Style Settings dialog box by going to **Settings** -> **Editor** -> **Code Style**.
-
-2. Click on the :gear: symbol -> **Import scheme** -> **IntelliJ IDEA code style XML**
-
-3. Pick the file `${pulsar_dir}/src/idea-code-style.xml`
-
-4. On the dialog box that opens, click **OK**.
-
-5. Ensure the scheme you just created is selected in **Scheme** dropdown then click **OK**.
-
-#### Configure Checkstyle
-
-1. Install the Checkstyle-IDEA plugin.
-
-2. Open Checkstyle Settings dialog box by going to **Settings** -> **Tools** -> **Checkstyle**.
-
-3. Set **Checkstyle version** to **8.37**.
-
-4. Set **Scan scope** to **Only Java sources (including tests)**.
-
-5. Click **+** button in the **Configuration** section to open a dialog to choose the checkfile file.
-
- 1. Enter a **Description**. For example, Pulsar.
- 2. Select **Use a local checkstyle file**.
- 3. Set **File** to **buildtools/src/main/resources/pulsar/checkstyle.xml**.
- 4. Select **Store relative to project location**.
- 5. Click **Next** -> **Next** -> **Finish**.
-
-6. Activate the configuration you just added by toggling the corresponding box.
-
-7. Click **OK**.
-
-#### Further configuration in IntelliJ
-
-- When working on the Pulsar core modules in IntelliJ, reduce the number of active projects in IntelliJ to speed up IDE actions and reduce unrelated IDE warnings.
-
- - In IntelliJ's Maven UI's tree view under "Profiles"
- - Activate "core-modules" Maven profile
- - De-activate "main" Maven profile
- - Run the "Reload All Maven Projects" action from the Maven UI toolbar. You can also find the action by the name in the IntelliJ "Search Everywhere" window that gets activated by pressing the **Shift** key twice.
-
-- Run the "Generate Sources and Update Folders For All Projects" action from the Maven UI toolbar. You can also find the action by the name in the IntelliJ "Search Everywhere" window that gets activated by pressing the **Shift** key twice. Running the action takes about 10 minutes for all projects. This is faster when the "core-modules" profile is the only active profile.
-
-#### IntelliJ usage tips
-
-- In the case of compilation errors with missing Protobuf classes, ensure to run the "Generate Sources and Update Folders For All Projects" action.
-
-- All of the Pulsar source code doesn't compile properly in IntelliJ and there are compilation errors.
- - Use the "core-modules" profile if working on the Pulsar core modules since the source code for those modules can be compiled in IntelliJ.
- - Sometimes it might help to mark a specific project ignored in IntelliJ Maven UI by right-clicking the project name and select **Ignore Projects** from the menu.
- - Currently, it is not always possible to run unit tests directly from the IDE because of the compilation issues. As a workaround, individual test classes can be run by using the `mvn test -Dtest=TestClassName` command.
-- The above steps have all been performed, but a test still won't run.
- - In this case, try the following steps:
- 1. Close IntelliJ.
- 2. Run `mvn clean install -DskipTests` on the command line.
- 3. Reopen IntelliJ.
- - If that still doesn't work:
- 1. Verify Maven is using a supported version. Currently, the supported version of Maven is specified in the
- section of the main pom.xml file.
- 2. Try "restart and clear caches" in IntelliJ and repeat the above steps to reload projects and generate sources.
-
-### Eclipse
-
-Follow the instructions [here](https://howtodoinjava.com/automation/lombok-eclipse-installation-examples/)
-to configure your Eclipse setup.
+Read https://pulsar.apache.org/contribute/setup-ide for setting up IntelliJ IDEA or Eclipse for developing Pulsar.
## Documentation
-> **Tip**
+> **Note**:
>
-> For how to make contributions to Pulsar documentation, see [Pulsar Documentation Contribution Guide](https://docs.google.com/document/d/11DTnNPpvcPrebLkMAFcDEIFlD8ARD-k6F-LXoIwdD9Y/edit#).
+> For how to make contributions to Pulsar documentation, see [Pulsar Documentation Contribution Guide](https://pulsar.apache.org/contribute/document-intro/).
## Contact
##### Mailing lists
-| Name | Scope | | | |
-| :-------------------------------------------------------- | :------------------------------ | :---------------------------------------------------- | :-------------------------------------------------------- | :----------------------------------------------------------------- |
+| Name | Scope | Subscribe | Unsubscribe | Archives |
+|:----------------------------------------------------------|:--------------------------------|:------------------------------------------------------|:----------------------------------------------------------|:-------------------------------------------------------------------|
| [users@pulsar.apache.org](mailto:users@pulsar.apache.org) | User-related discussions | [Subscribe](mailto:users-subscribe@pulsar.apache.org) | [Unsubscribe](mailto:users-unsubscribe@pulsar.apache.org) | [Archives](http://mail-archives.apache.org/mod_mbox/pulsar-users/) |
| [dev@pulsar.apache.org](mailto:dev@pulsar.apache.org) | Development-related discussions | [Subscribe](mailto:dev-subscribe@pulsar.apache.org) | [Unsubscribe](mailto:dev-unsubscribe@pulsar.apache.org) | [Archives](http://mail-archives.apache.org/mod_mbox/pulsar-dev/) |
diff --git a/bin/bookkeeper b/bin/bookkeeper
index c66cc42dd801d..fb516a98acdc2 100755
--- a/bin/bookkeeper
+++ b/bin/bookkeeper
@@ -182,11 +182,11 @@ fi
OPTS="-cp $BOOKIE_CLASSPATH $OPTS"
-OPTS="$OPTS $BOOKIE_MEM $BOOKIE_GC $BOOKIE_GC_LOG $BOOKIE_EXTRA_OPTS"
-
# Disable ipv6 as it can cause issues
OPTS="$OPTS -Djava.net.preferIPv4Stack=true"
+OPTS="$OPTS $BOOKIE_MEM $BOOKIE_GC $BOOKIE_GC_LOG $BOOKIE_EXTRA_OPTS"
+
# log directory & file
BOOKIE_LOG_APPENDER=${BOOKIE_LOG_APPENDER:-"Console"}
diff --git a/bouncy-castle/bc/src/main/java/org/apache/pulsar/bcloader/BouncyCastleLoader.java b/bouncy-castle/bc/src/main/java/org/apache/pulsar/bcloader/BouncyCastleLoader.java
index 69002f1603962..a14ecaa517ab6 100644
--- a/bouncy-castle/bc/src/main/java/org/apache/pulsar/bcloader/BouncyCastleLoader.java
+++ b/bouncy-castle/bc/src/main/java/org/apache/pulsar/bcloader/BouncyCastleLoader.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/bouncy-castle/bc/src/main/java/org/apache/pulsar/bcloader/package-info.java b/bouncy-castle/bc/src/main/java/org/apache/pulsar/bcloader/package-info.java
index b6308e37b4443..e4f6c2e2f1384 100644
--- a/bouncy-castle/bc/src/main/java/org/apache/pulsar/bcloader/package-info.java
+++ b/bouncy-castle/bc/src/main/java/org/apache/pulsar/bcloader/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
/**
* Package for Bouncy Castle provider Loader.
*/
diff --git a/bouncy-castle/bcfips-include-test/src/test/java/org/apache/pulsar/client/TlsProducerConsumerBase.java b/bouncy-castle/bcfips-include-test/src/test/java/org/apache/pulsar/client/TlsProducerConsumerBase.java
index b074b22580d67..330d4fbc06897 100644
--- a/bouncy-castle/bcfips-include-test/src/test/java/org/apache/pulsar/client/TlsProducerConsumerBase.java
+++ b/bouncy-castle/bcfips-include-test/src/test/java/org/apache/pulsar/client/TlsProducerConsumerBase.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/bouncy-castle/bcfips-include-test/src/test/java/org/apache/pulsar/client/TlsProducerConsumerTest.java b/bouncy-castle/bcfips-include-test/src/test/java/org/apache/pulsar/client/TlsProducerConsumerTest.java
index fe5c0d1e9f187..624315ae0c9cd 100644
--- a/bouncy-castle/bcfips-include-test/src/test/java/org/apache/pulsar/client/TlsProducerConsumerTest.java
+++ b/bouncy-castle/bcfips-include-test/src/test/java/org/apache/pulsar/client/TlsProducerConsumerTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/bouncy-castle/bcfips/pom.xml b/bouncy-castle/bcfips/pom.xml
index 287ce656a657d..8ff2a38792e94 100644
--- a/bouncy-castle/bcfips/pom.xml
+++ b/bouncy-castle/bcfips/pom.xml
@@ -43,13 +43,13 @@
org.bouncycastlebc-fips
- ${bouncycastlefips.version}
+ ${bouncycastle.bc-fips.version}org.bouncycastlebcpkix-fips
- ${bouncycastlefips.version}
+ ${bouncycastle.bcpkix-fips.version}
diff --git a/bouncy-castle/bcfips/src/main/java/org/apache/pulsar/bcloader/BouncyCastleFipsLoader.java b/bouncy-castle/bcfips/src/main/java/org/apache/pulsar/bcloader/BouncyCastleFipsLoader.java
index 984df776d1e34..5e2f2fd9c2451 100644
--- a/bouncy-castle/bcfips/src/main/java/org/apache/pulsar/bcloader/BouncyCastleFipsLoader.java
+++ b/bouncy-castle/bcfips/src/main/java/org/apache/pulsar/bcloader/BouncyCastleFipsLoader.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -19,7 +19,6 @@
package org.apache.pulsar.bcloader;
import static org.apache.pulsar.common.util.SecurityUtility.BC_FIPS;
-
import java.security.Provider;
import java.security.Security;
import lombok.extern.slf4j.Slf4j;
diff --git a/bouncy-castle/bcfips/src/main/java/org/apache/pulsar/bcloader/package-info.java b/bouncy-castle/bcfips/src/main/java/org/apache/pulsar/bcloader/package-info.java
new file mode 100644
index 0000000000000..d610ff5642da4
--- /dev/null
+++ b/bouncy-castle/bcfips/src/main/java/org/apache/pulsar/bcloader/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.bcloader;
diff --git a/build/run_integration_group.sh b/build/run_integration_group.sh
index ab69544308ff3..c107a2adb1e3d 100755
--- a/build/run_integration_group.sh
+++ b/build/run_integration_group.sh
@@ -25,6 +25,8 @@ set -o pipefail
set -o errexit
JAVA_MAJOR_VERSION="$(java -version 2>&1 |grep " version " | awk -F\" '{ print $2 }' | awk -F. '{ if ($1=="1") { print $2 } else { print $1 } }')"
+# Used to shade run test on Java 8, because the latest TestNG requires Java 11 or higher.
+TESTNG_VERSION="7.3.0"
# lists all active maven modules with given parameters
# parses the modules from the "mvn initialize" output
@@ -95,6 +97,11 @@ test_group_shade_run() {
if [[ $JAVA_MAJOR_VERSION -gt 8 && $JAVA_MAJOR_VERSION -lt 17 ]]; then
additional_args="-Dmaven.compiler.source=$JAVA_MAJOR_VERSION -Dmaven.compiler.target=$JAVA_MAJOR_VERSION"
fi
+
+ if [[ $JAVA_MAJOR_VERSION -ge 8 && $JAVA_MAJOR_VERSION -lt 11 ]]; then
+ additional_args="$additional_args -Dtestng.version=$TESTNG_VERSION"
+ fi
+
mvn_run_integration_test --skip-build-deps --clean "$@" -Denforcer.skip=true -DShadeTests -DtestForkCount=1 -DtestReuseFork=false $additional_args
}
@@ -122,6 +129,8 @@ test_group_messaging() {
mvn_run_integration_test --skip-build-deps "$@" -DintegrationTestSuiteFile=pulsar-proxy.xml -DintegrationTests
# run integration WebSocket tests
mvn_run_integration_test --skip-build-deps "$@" -DintegrationTestSuiteFile=pulsar-websocket.xml -DintegrationTests
+ # run integration TLS tests
+ mvn_run_integration_test "$@" -DintegrationTestSuiteFile=pulsar-tls.xml -DintegrationTests
}
test_group_plugin() {
diff --git a/build/run_unit_group.sh b/build/run_unit_group.sh
index 6d8cafbee2c7f..c0b5d9781f544 100755
--- a/build/run_unit_group.sh
+++ b/build/run_unit_group.sh
@@ -24,7 +24,7 @@ set -e
set -o pipefail
set -o errexit
-MVN_TEST_OPTIONS='mvn -Pcoverage -B -ntp -DskipSourceReleaseAssembly=true -DskipBuildDistribution=true -Dspotbugs.skip=true -Dlicense.skip=true -Dcheckstyle.skip=true -Drat.skip=true'
+MVN_TEST_OPTIONS='mvn -B -ntp -DskipSourceReleaseAssembly=true -DskipBuildDistribution=true -Dspotbugs.skip=true -Dlicense.skip=true -Dcheckstyle.skip=true -Drat.skip=true'
function mvn_test() {
(
@@ -33,7 +33,11 @@ function mvn_test() {
clean_arg="clean"
shift
fi
- TARGET=verify
+ if echo "${FUNCNAME[@]}" | grep "flaky"; then
+ TARGET="verify"
+ else
+ TARGET="verify -Pcoverage"
+ fi
if [[ "$1" == "--install" ]]; then
TARGET="install"
shift
@@ -77,6 +81,10 @@ function test_group_broker_client_impl() {
mvn_test -pl pulsar-broker -Dgroups='broker-impl'
}
+function test_group_client() {
+ mvn_test -pl pulsar-client
+}
+
# prints summaries of failed tests to console
# by using the targer/surefire-reports files
# works only when testForkCount > 1 since that is when surefire will create reports for individual test classes
@@ -134,18 +142,16 @@ function test_group_other() {
-Dexclude='**/ManagedLedgerTest.java,
**/OffloadersCacheTest.java
**/PrimitiveSchemaTest.java,
- BlobStoreManagedLedgerOffloaderTest.java' -DtestReuseFork=false
+ BlobStoreManagedLedgerOffloaderTest.java'
mvn_test -pl managed-ledger -Dinclude='**/ManagedLedgerTest.java,
**/OffloadersCacheTest.java'
- mvn_test -pl pulsar-client -Dinclude='**/PrimitiveSchemaTest.java'
-
mvn_test -pl tiered-storage/jcloud -Dinclude='**/BlobStoreManagedLedgerOffloaderTest.java'
echo "::endgroup::"
local modules_with_quarantined_tests=$(git grep -l '@Test.*"quarantine"' | grep '/src/test/java/' | \
- awk -F '/src/test/java/' '{ print $1 }' | grep -v -E 'pulsar-broker|pulsar-proxy|pulsar-io|pulsar-sql' | sort | uniq | \
+ awk -F '/src/test/java/' '{ print $1 }' | grep -v -E 'pulsar-broker|pulsar-proxy|pulsar-io|pulsar-sql|pulsar-client' | sort | uniq | \
perl -0777 -p -e 's/\n(\S)/,$1/g')
if [ -n "${modules_with_quarantined_tests}" ]; then
echo "::group::Running quarantined tests outside of pulsar-broker & pulsar-proxy (if any)"
diff --git a/buildtools/pom.xml b/buildtools/pom.xml
index f3d116ab34899..2fd5c9aca9ea9 100644
--- a/buildtools/pom.xml
+++ b/buildtools/pom.xml
@@ -26,7 +26,6 @@
org.apacheapache23
- org.apache.pulsar
@@ -41,8 +40,9 @@
3.0.0-M32.18.01.7.32
- 7.3.0
+ 7.6.13.11
+ 4.13.4.08.373.1.2
@@ -151,7 +151,7 @@
com.mycilalicense-maven-plugin
- 4.0.rc2
+ ${license-maven-plugin.version}
@@ -159,7 +159,7 @@
- JAVADOC_STYLE
+ SLASHSTAR_STYLE
diff --git a/buildtools/src/main/java/org/apache/pulsar/tests/AnnotationListener.java b/buildtools/src/main/java/org/apache/pulsar/tests/AnnotationListener.java
index b139f90faf41e..38cd2a1747a63 100644
--- a/buildtools/src/main/java/org/apache/pulsar/tests/AnnotationListener.java
+++ b/buildtools/src/main/java/org/apache/pulsar/tests/AnnotationListener.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/buildtools/src/main/java/org/apache/pulsar/tests/BetweenTestClassesListenerAdapter.java b/buildtools/src/main/java/org/apache/pulsar/tests/BetweenTestClassesListenerAdapter.java
index 7e803f29ef16a..8463e8519a0f1 100644
--- a/buildtools/src/main/java/org/apache/pulsar/tests/BetweenTestClassesListenerAdapter.java
+++ b/buildtools/src/main/java/org/apache/pulsar/tests/BetweenTestClassesListenerAdapter.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/buildtools/src/main/java/org/apache/pulsar/tests/EnumValuesDataProvider.java b/buildtools/src/main/java/org/apache/pulsar/tests/EnumValuesDataProvider.java
index 3c43baed98ac7..6192a062955f6 100644
--- a/buildtools/src/main/java/org/apache/pulsar/tests/EnumValuesDataProvider.java
+++ b/buildtools/src/main/java/org/apache/pulsar/tests/EnumValuesDataProvider.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/buildtools/src/main/java/org/apache/pulsar/tests/FailFastNotifier.java b/buildtools/src/main/java/org/apache/pulsar/tests/FailFastNotifier.java
index 0f001332a98d8..2040567f96c76 100644
--- a/buildtools/src/main/java/org/apache/pulsar/tests/FailFastNotifier.java
+++ b/buildtools/src/main/java/org/apache/pulsar/tests/FailFastNotifier.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/buildtools/src/main/java/org/apache/pulsar/tests/FastThreadLocalCleanupListener.java b/buildtools/src/main/java/org/apache/pulsar/tests/FastThreadLocalCleanupListener.java
index c40956a9e259e..2cd2f5792793b 100644
--- a/buildtools/src/main/java/org/apache/pulsar/tests/FastThreadLocalCleanupListener.java
+++ b/buildtools/src/main/java/org/apache/pulsar/tests/FastThreadLocalCleanupListener.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/buildtools/src/main/java/org/apache/pulsar/tests/FastThreadLocalStateCleaner.java b/buildtools/src/main/java/org/apache/pulsar/tests/FastThreadLocalStateCleaner.java
index 05dbae115f177..ed23fe4f6980c 100644
--- a/buildtools/src/main/java/org/apache/pulsar/tests/FastThreadLocalStateCleaner.java
+++ b/buildtools/src/main/java/org/apache/pulsar/tests/FastThreadLocalStateCleaner.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/buildtools/src/main/java/org/apache/pulsar/tests/MockitoCleanupListener.java b/buildtools/src/main/java/org/apache/pulsar/tests/MockitoCleanupListener.java
index ff590c05bbcf7..1796d457d0921 100644
--- a/buildtools/src/main/java/org/apache/pulsar/tests/MockitoCleanupListener.java
+++ b/buildtools/src/main/java/org/apache/pulsar/tests/MockitoCleanupListener.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -32,16 +32,18 @@
*/
public class MockitoCleanupListener extends BetweenTestClassesListenerAdapter {
private static final Logger LOG = LoggerFactory.getLogger(MockitoCleanupListener.class);
- private static final boolean
- MOCKITO_CLEANUP_ENABLED = Boolean.parseBoolean(System.getProperty("testMockitoCleanup", "true"));
+ private static final boolean MOCKITO_CLEANUP_ENABLED = Boolean.parseBoolean(
+ System.getProperty("testMockitoCleanup", "true"));
+
+ private static final String MOCKITO_CLEANUP_INFO =
+ "Cleaning up Mockito's ThreadSafeMockingProgress.MOCKING_PROGRESS_PROVIDER thread local state.";
@Override
protected void onBetweenTestClasses(Class> endedTestClass, Class> startedTestClass) {
if (MOCKITO_CLEANUP_ENABLED) {
try {
if (MockitoThreadLocalStateCleaner.INSTANCE.isEnabled()) {
- LOG.info(
- "Cleaning up Mockito's ThreadSafeMockingProgress.MOCKING_PROGRESS_PROVIDER thread local state.");
+ LOG.info(MOCKITO_CLEANUP_INFO);
MockitoThreadLocalStateCleaner.INSTANCE.cleanup();
}
} finally {
@@ -53,7 +55,7 @@ protected void onBetweenTestClasses(Class> endedTestClass, Class> startedTes
/**
* Mockito-inline can leak mocked objects, we need to clean up the inline mocks after every test.
* See
- * mockito docs.
+ * mockito docs.
*/
private void cleanupMockitoInline() {
Mockito.framework().clearInlineMocks();
diff --git a/buildtools/src/main/java/org/apache/pulsar/tests/MockitoThreadLocalStateCleaner.java b/buildtools/src/main/java/org/apache/pulsar/tests/MockitoThreadLocalStateCleaner.java
index 4fe4ea7e0e2d3..c8e269ac56afb 100644
--- a/buildtools/src/main/java/org/apache/pulsar/tests/MockitoThreadLocalStateCleaner.java
+++ b/buildtools/src/main/java/org/apache/pulsar/tests/MockitoThreadLocalStateCleaner.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/buildtools/src/main/java/org/apache/pulsar/tests/PulsarTestListener.java b/buildtools/src/main/java/org/apache/pulsar/tests/PulsarTestListener.java
index dfec5dcef959f..b3d70621843ca 100644
--- a/buildtools/src/main/java/org/apache/pulsar/tests/PulsarTestListener.java
+++ b/buildtools/src/main/java/org/apache/pulsar/tests/PulsarTestListener.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -45,9 +45,12 @@ public void onTestFailure(ITestResult result) {
System.out.format("!!!!!!!!! FAILURE-- %s.%s(%s)-------\n", result.getTestClass(),
result.getMethod().getMethodName(), Arrays.toString(result.getParameters()));
}
- if (result.getThrowable() instanceof ThreadTimeoutException) {
- System.out.println("====== THREAD DUMPS ======");
- System.out.println(ThreadDumpUtil.buildThreadDiagnosticString());
+ if (result.getThrowable() != null) {
+ result.getThrowable().printStackTrace();
+ if (result.getThrowable() instanceof ThreadTimeoutException) {
+ System.out.println("====== THREAD DUMPS ======");
+ System.out.println(ThreadDumpUtil.buildThreadDiagnosticString());
+ }
}
}
diff --git a/buildtools/src/main/java/org/apache/pulsar/tests/RetryAnalyzer.java b/buildtools/src/main/java/org/apache/pulsar/tests/RetryAnalyzer.java
index 696058ddc5224..e76a2bab9dc05 100644
--- a/buildtools/src/main/java/org/apache/pulsar/tests/RetryAnalyzer.java
+++ b/buildtools/src/main/java/org/apache/pulsar/tests/RetryAnalyzer.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/buildtools/src/main/java/org/apache/pulsar/tests/TestRetrySupport.java b/buildtools/src/main/java/org/apache/pulsar/tests/TestRetrySupport.java
index a9bf4b49771cb..fd368bd01915f 100644
--- a/buildtools/src/main/java/org/apache/pulsar/tests/TestRetrySupport.java
+++ b/buildtools/src/main/java/org/apache/pulsar/tests/TestRetrySupport.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/buildtools/src/main/java/org/apache/pulsar/tests/ThreadDumpUtil.java b/buildtools/src/main/java/org/apache/pulsar/tests/ThreadDumpUtil.java
index bf0d8bf41caf1..e20a02f95a992 100644
--- a/buildtools/src/main/java/org/apache/pulsar/tests/ThreadDumpUtil.java
+++ b/buildtools/src/main/java/org/apache/pulsar/tests/ThreadDumpUtil.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/buildtools/src/main/java/org/apache/pulsar/tests/ThreadLeakDetectorListener.java b/buildtools/src/main/java/org/apache/pulsar/tests/ThreadLeakDetectorListener.java
index 163591cf82554..803d1c4980bc9 100644
--- a/buildtools/src/main/java/org/apache/pulsar/tests/ThreadLeakDetectorListener.java
+++ b/buildtools/src/main/java/org/apache/pulsar/tests/ThreadLeakDetectorListener.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/buildtools/src/main/java/org/apache/pulsar/tests/ThreadLocalStateCleaner.java b/buildtools/src/main/java/org/apache/pulsar/tests/ThreadLocalStateCleaner.java
index 3183960df8ec4..1f77402a4b1a7 100644
--- a/buildtools/src/main/java/org/apache/pulsar/tests/ThreadLocalStateCleaner.java
+++ b/buildtools/src/main/java/org/apache/pulsar/tests/ThreadLocalStateCleaner.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/buildtools/src/main/java/org/apache/pulsar/tests/package-info.java b/buildtools/src/main/java/org/apache/pulsar/tests/package-info.java
index f1c6f5153c33c..ad0ca6f8cd186 100644
--- a/buildtools/src/main/java/org/apache/pulsar/tests/package-info.java
+++ b/buildtools/src/main/java/org/apache/pulsar/tests/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/buildtools/src/main/resources/pulsar/checkstyle.xml b/buildtools/src/main/resources/pulsar/checkstyle.xml
index d1e65416043b5..b5141cc5eb51a 100644
--- a/buildtools/src/main/resources/pulsar/checkstyle.xml
+++ b/buildtools/src/main/resources/pulsar/checkstyle.xml
@@ -137,7 +137,7 @@ page at http://checkstyle.sourceforge.net/config.html -->
+ value="autovalue.shaded, avro.shaded, bk-shade, com.google.api.client.repackaged, com.google.appengine.repackaged, org.apache.curator.shaded, org.testcontainers.shaded" />
diff --git a/buildtools/src/main/resources/pulsar/suppressions.xml b/buildtools/src/main/resources/pulsar/suppressions.xml
index 49cfa48d3c562..7c78988db3e90 100644
--- a/buildtools/src/main/resources/pulsar/suppressions.xml
+++ b/buildtools/src/main/resources/pulsar/suppressions.xml
@@ -28,8 +28,9 @@
-
+
+
diff --git a/buildtools/src/test/java/org/apache/pulsar/tests/AnnotationListenerTest.java b/buildtools/src/test/java/org/apache/pulsar/tests/AnnotationListenerTest.java
index 5121d3d3414a2..5b7f05da2cdca 100644
--- a/buildtools/src/test/java/org/apache/pulsar/tests/AnnotationListenerTest.java
+++ b/buildtools/src/test/java/org/apache/pulsar/tests/AnnotationListenerTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/buildtools/src/test/java/org/apache/pulsar/tests/DefaultTestRetriesTest.java b/buildtools/src/test/java/org/apache/pulsar/tests/DefaultTestRetriesTest.java
index dc5f9e23fd3d2..6b663d6e134c1 100644
--- a/buildtools/src/test/java/org/apache/pulsar/tests/DefaultTestRetriesTest.java
+++ b/buildtools/src/test/java/org/apache/pulsar/tests/DefaultTestRetriesTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/buildtools/src/test/java/org/apache/pulsar/tests/EnumValuesDataProviderTest.java b/buildtools/src/test/java/org/apache/pulsar/tests/EnumValuesDataProviderTest.java
index 9eb24ccf4bfc3..2ab349bb90b4f 100644
--- a/buildtools/src/test/java/org/apache/pulsar/tests/EnumValuesDataProviderTest.java
+++ b/buildtools/src/test/java/org/apache/pulsar/tests/EnumValuesDataProviderTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/buildtools/src/test/java/org/apache/pulsar/tests/FastThreadLocalStateCleanerTest.java b/buildtools/src/test/java/org/apache/pulsar/tests/FastThreadLocalStateCleanerTest.java
index 2fd8c4bbbe2c7..93af1d6478190 100644
--- a/buildtools/src/test/java/org/apache/pulsar/tests/FastThreadLocalStateCleanerTest.java
+++ b/buildtools/src/test/java/org/apache/pulsar/tests/FastThreadLocalStateCleanerTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/buildtools/src/test/java/org/apache/pulsar/tests/RetryAnalyzerTest.java b/buildtools/src/test/java/org/apache/pulsar/tests/RetryAnalyzerTest.java
index 90f19e8053513..64d25fbc76c8b 100644
--- a/buildtools/src/test/java/org/apache/pulsar/tests/RetryAnalyzerTest.java
+++ b/buildtools/src/test/java/org/apache/pulsar/tests/RetryAnalyzerTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/buildtools/src/test/java/org/apache/pulsar/tests/TestRetrySupportBeforeMethodRetryTest.java b/buildtools/src/test/java/org/apache/pulsar/tests/TestRetrySupportBeforeMethodRetryTest.java
index a447e09c9bf5d..fb85d1ceeaec2 100644
--- a/buildtools/src/test/java/org/apache/pulsar/tests/TestRetrySupportBeforeMethodRetryTest.java
+++ b/buildtools/src/test/java/org/apache/pulsar/tests/TestRetrySupportBeforeMethodRetryTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/buildtools/src/test/java/org/apache/pulsar/tests/TestRetrySupportRetryTest.java b/buildtools/src/test/java/org/apache/pulsar/tests/TestRetrySupportRetryTest.java
index bffcd16b01ac0..0e2b25dc62be2 100644
--- a/buildtools/src/test/java/org/apache/pulsar/tests/TestRetrySupportRetryTest.java
+++ b/buildtools/src/test/java/org/apache/pulsar/tests/TestRetrySupportRetryTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/buildtools/src/test/java/org/apache/pulsar/tests/TestRetrySupportSuccessTest.java b/buildtools/src/test/java/org/apache/pulsar/tests/TestRetrySupportSuccessTest.java
index 1621a68ed9cf5..d449f1ffb0aef 100644
--- a/buildtools/src/test/java/org/apache/pulsar/tests/TestRetrySupportSuccessTest.java
+++ b/buildtools/src/test/java/org/apache/pulsar/tests/TestRetrySupportSuccessTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/buildtools/src/test/java/org/apache/pulsar/tests/ThreadDumpUtilTest.java b/buildtools/src/test/java/org/apache/pulsar/tests/ThreadDumpUtilTest.java
index 494621b2dae5f..7a663ac286a4e 100644
--- a/buildtools/src/test/java/org/apache/pulsar/tests/ThreadDumpUtilTest.java
+++ b/buildtools/src/test/java/org/apache/pulsar/tests/ThreadDumpUtilTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/buildtools/src/test/java/org/apache/pulsar/tests/ThreadLocalStateCleanerTest.java b/buildtools/src/test/java/org/apache/pulsar/tests/ThreadLocalStateCleanerTest.java
index 612dd7811638c..8dc20980cdb39 100644
--- a/buildtools/src/test/java/org/apache/pulsar/tests/ThreadLocalStateCleanerTest.java
+++ b/buildtools/src/test/java/org/apache/pulsar/tests/ThreadLocalStateCleanerTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/conf/bookkeeper.conf b/conf/bookkeeper.conf
index 01adae7b2ca38..4083ba1d373f1 100644
--- a/conf/bookkeeper.conf
+++ b/conf/bookkeeper.conf
@@ -277,6 +277,17 @@ useV2WireProtocol=true
#
# ensemblePlacementPolicy=org.apache.bookkeeper.client.RackawareEnsemblePlacementPolicy
+# The DNS resolver class used for resolving the network location of each bookie. All bookkeeper clients
+# should be configured with the same value to ensure that each bookkeeper client builds
+# the same network topology in order to then place ensembles consistently. The setting is used
+# when using either RackawareEnsemblePlacementPolicy and RegionAwareEnsemblePlacementPolicy.
+# The setting in this file is used to configure the bookkeeper client used in the bookkeeper, which
+# is used by the autorecovery process.
+# Some available options:
+# - org.apache.pulsar.zookeeper.ZkBookieRackAffinityMapping (Pulsar default)
+# - org.apache.bookkeeper.net.ScriptBasedMapping (Bookkeeper default)
+reppDnsResolverClass=org.apache.pulsar.zookeeper.ZkBookieRackAffinityMapping
+
#############################################################################
## Netty server settings
#############################################################################
diff --git a/conf/broker.conf b/conf/broker.conf
index f5e4be9d6f390..04f38c958e1ad 100644
--- a/conf/broker.conf
+++ b/conf/broker.conf
@@ -1149,6 +1149,14 @@ managedLedgerOffloadDeletionLagMs=14400000
# (default is -1, which is disabled)
managedLedgerOffloadAutoTriggerSizeThresholdBytes=-1
+# Read priority when ledgers exists in both bookkeeper and the second layer storage
+# (tiered-storage-first/bookkeeper-first, default is tiered-storage-first)
+managedLedgerDataReadPriority=tiered-storage-first
+
+# The number of seconds before triggering automatic offload to long term storage
+# (default is -1, which is disabled)
+managedLedgerOffloadThresholdInSeconds=-1
+
# Max number of entries to append to a cursor ledger
managedLedgerCursorMaxEntriesPerLedger=50000
@@ -1164,6 +1172,14 @@ managedLedgerCursorRolloverTimeInSeconds=14400
# crashes.
managedLedgerMaxUnackedRangesToPersist=10000
+# Maximum amount of memory used hold data read from storage (or from the cache).
+# This mechanism prevents the broker to have too many concurrent
+# reads from storage and fall into Out of Memory errors in case
+# of multiple concurrent reads to multiple concurrent consumers.
+# Set 0 in order to disable the feature.
+#
+managedLedgerMaxReadsInFlightSizeInMB=0
+
# Max number of "acknowledgment holes" that can be stored in MetadataStore. If number of unack message range is higher
# than this limit then broker will persist unacked ranges into bookkeeper to avoid additional data overhead into
# MetadataStore.
diff --git a/deployment/terraform-ansible/deploy-pulsar.yaml b/deployment/terraform-ansible/deploy-pulsar.yaml
index ae1243ad66e63..db2fd1257ca41 100644
--- a/deployment/terraform-ansible/deploy-pulsar.yaml
+++ b/deployment/terraform-ansible/deploy-pulsar.yaml
@@ -154,6 +154,7 @@
# - jdbc-mariadb
# - jdbc-postgres
# - jdbc-sqlite
+# - http
- kafka
# - kafka-connect-adaptor
# - kinesis
diff --git a/distribution/io/src/assemble/io.xml b/distribution/io/src/assemble/io.xml
index 7657b35ae0919..33ca4e79ba942 100644
--- a/distribution/io/src/assemble/io.xml
+++ b/distribution/io/src/assemble/io.xml
@@ -47,6 +47,7 @@
${basedir}/../../pulsar-io/cassandra/target/pulsar-io-cassandra-${project.version}.nar${basedir}/../../pulsar-io/twitter/target/pulsar-io-twitter-${project.version}.nar${basedir}/../../pulsar-io/kafka/target/pulsar-io-kafka-${project.version}.nar
+ ${basedir}/../../pulsar-io/http/target/pulsar-io-http-${project.version}.nar${basedir}/../../pulsar-io/kinesis/target/pulsar-io-kinesis-${project.version}.nar${basedir}/../../pulsar-io/rabbitmq/target/pulsar-io-rabbitmq-${project.version}.nar${basedir}/../../pulsar-io/nsq/target/pulsar-io-nsq-${project.version}.nar
diff --git a/distribution/server/src/assemble/LICENSE.bin.txt b/distribution/server/src/assemble/LICENSE.bin.txt
index 786c19171928d..6d54074451fcf 100644
--- a/distribution/server/src/assemble/LICENSE.bin.txt
+++ b/distribution/server/src/assemble/LICENSE.bin.txt
@@ -248,13 +248,13 @@ The Apache Software License, Version 2.0
* Jackson
- com.fasterxml.jackson.core-jackson-annotations-2.13.4.jar
- com.fasterxml.jackson.core-jackson-core-2.13.4.jar
- - com.fasterxml.jackson.core-jackson-databind-2.13.4.jar
+ - com.fasterxml.jackson.core-jackson-databind-2.13.4.2.jar
- com.fasterxml.jackson.dataformat-jackson-dataformat-yaml-2.13.4.jar
- com.fasterxml.jackson.jaxrs-jackson-jaxrs-base-2.13.4.jar
- com.fasterxml.jackson.jaxrs-jackson-jaxrs-json-provider-2.13.4.jar
- com.fasterxml.jackson.module-jackson-module-jaxb-annotations-2.13.4.jar
- com.fasterxml.jackson.module-jackson-module-jsonSchema-2.13.4.jar
- * Caffeine -- com.github.ben-manes.caffeine-caffeine-2.9.1.jar
+ * Caffeine -- com.github.ben-manes.caffeine-caffeine-3.1.2.jar
* Conscrypt -- org.conscrypt-conscrypt-openjdk-uber-2.5.2.jar
* Proto Google Common Protos -- com.google.api.grpc-proto-google-common-protos-2.0.1.jar
* Bitbucket -- org.bitbucket.b_c-jose4j-0.7.6.jar
@@ -311,6 +311,9 @@ The Apache Software License, Version 2.0
- io.netty-netty-tcnative-boringssl-static-2.0.52.Final-osx-x86_64.jar
- io.netty-netty-tcnative-boringssl-static-2.0.52.Final-windows-x86_64.jar
- io.netty-netty-tcnative-classes-2.0.52.Final.jar
+ - io.netty.incubator-netty-incubator-transport-classes-io_uring-0.0.15.Final.jar
+ - io.netty.incubator-netty-incubator-transport-native-io_uring-0.0.15.Final-linux-x86_64.jar
+ - io.netty.incubator-netty-incubator-transport-native-io_uring-0.0.15.Final-linux-aarch_64.jar
* Prometheus client
- io.prometheus.jmx-collector-0.16.1.jar
- io.prometheus-simpleclient-0.16.0.jar
@@ -335,31 +338,31 @@ The Apache Software License, Version 2.0
- org.apache.logging.log4j-log4j-web-2.18.0.jar
* Java Native Access JNA -- net.java.dev.jna-jna-5.12.1.jar
* BookKeeper
- - org.apache.bookkeeper-bookkeeper-common-4.15.1.jar
- - org.apache.bookkeeper-bookkeeper-common-allocator-4.15.1.jar
- - org.apache.bookkeeper-bookkeeper-proto-4.15.1.jar
- - org.apache.bookkeeper-bookkeeper-server-4.15.1.jar
- - org.apache.bookkeeper-bookkeeper-tools-framework-4.15.1.jar
- - org.apache.bookkeeper-circe-checksum-4.15.1.jar
- - org.apache.bookkeeper-cpu-affinity-4.15.1.jar
- - org.apache.bookkeeper-statelib-4.15.1.jar
- - org.apache.bookkeeper-stream-storage-api-4.15.1.jar
- - org.apache.bookkeeper-stream-storage-common-4.15.1.jar
- - org.apache.bookkeeper-stream-storage-java-client-4.15.1.jar
- - org.apache.bookkeeper-stream-storage-java-client-base-4.15.1.jar
- - org.apache.bookkeeper-stream-storage-proto-4.15.1.jar
- - org.apache.bookkeeper-stream-storage-server-4.15.1.jar
- - org.apache.bookkeeper-stream-storage-service-api-4.15.1.jar
- - org.apache.bookkeeper-stream-storage-service-impl-4.15.1.jar
- - org.apache.bookkeeper.http-http-server-4.15.1.jar
- - org.apache.bookkeeper.http-vertx-http-server-4.15.1.jar
- - org.apache.bookkeeper.stats-bookkeeper-stats-api-4.15.1.jar
- - org.apache.bookkeeper.stats-prometheus-metrics-provider-4.15.1.jar
- - org.apache.distributedlog-distributedlog-common-4.15.1.jar
- - org.apache.distributedlog-distributedlog-core-4.15.1-tests.jar
- - org.apache.distributedlog-distributedlog-core-4.15.1.jar
- - org.apache.distributedlog-distributedlog-protocol-4.15.1.jar
- - org.apache.bookkeeper.stats-codahale-metrics-provider-4.15.1.jar
+ - org.apache.bookkeeper-bookkeeper-common-4.15.3.jar
+ - org.apache.bookkeeper-bookkeeper-common-allocator-4.15.3.jar
+ - org.apache.bookkeeper-bookkeeper-proto-4.15.3.jar
+ - org.apache.bookkeeper-bookkeeper-server-4.15.3.jar
+ - org.apache.bookkeeper-bookkeeper-tools-framework-4.15.3.jar
+ - org.apache.bookkeeper-circe-checksum-4.15.3.jar
+ - org.apache.bookkeeper-cpu-affinity-4.15.3.jar
+ - org.apache.bookkeeper-statelib-4.15.3.jar
+ - org.apache.bookkeeper-stream-storage-api-4.15.3.jar
+ - org.apache.bookkeeper-stream-storage-common-4.15.3.jar
+ - org.apache.bookkeeper-stream-storage-java-client-4.15.3.jar
+ - org.apache.bookkeeper-stream-storage-java-client-base-4.15.3.jar
+ - org.apache.bookkeeper-stream-storage-proto-4.15.3.jar
+ - org.apache.bookkeeper-stream-storage-server-4.15.3.jar
+ - org.apache.bookkeeper-stream-storage-service-api-4.15.3.jar
+ - org.apache.bookkeeper-stream-storage-service-impl-4.15.3.jar
+ - org.apache.bookkeeper.http-http-server-4.15.3.jar
+ - org.apache.bookkeeper.http-vertx-http-server-4.15.3.jar
+ - org.apache.bookkeeper.stats-bookkeeper-stats-api-4.15.3.jar
+ - org.apache.bookkeeper.stats-prometheus-metrics-provider-4.15.3.jar
+ - org.apache.distributedlog-distributedlog-common-4.15.3.jar
+ - org.apache.distributedlog-distributedlog-core-4.15.3-tests.jar
+ - org.apache.distributedlog-distributedlog-core-4.15.3.jar
+ - org.apache.distributedlog-distributedlog-protocol-4.15.3.jar
+ - org.apache.bookkeeper.stats-codahale-metrics-provider-4.15.3.jar
* Apache HTTP Client
- org.apache.httpcomponents-httpclient-4.5.13.jar
- org.apache.httpcomponents-httpcore-4.4.15.jar
diff --git a/docker/pulsar-all/pom.xml b/docker/pulsar-all/pom.xml
index 6d8c656f1dd41..8c7174c04c286 100644
--- a/docker/pulsar-all/pom.xml
+++ b/docker/pulsar-all/pom.xml
@@ -138,46 +138,7 @@
packagebuild
-
-
-
-
- ${docker.organization}/pulsar-all
-
- ${project.basedir}
-
- latest
- ${project.version}
-
-
-
-
-
-
-
- push-latest
-
- push
-
-
-
-
- ${docker.organization}/pulsar-all
-
- ${project.basedir}
-
- latest
-
-
-
-
-
-
-
- add-no-repo
- package
-
- build
+ tag
@@ -187,11 +148,12 @@
${project.basedir}latest
- ${project.version}
+ latest
+ ${docker.organization}
diff --git a/docker/pulsar/Dockerfile b/docker/pulsar/Dockerfile
index 7ec8788b89c60..2194fc03cb233 100644
--- a/docker/pulsar/Dockerfile
+++ b/docker/pulsar/Dockerfile
@@ -98,6 +98,7 @@ ARG PULSAR_CLIENT_PYTHON_VERSION
ENV PULSAR_CLIENT_PYTHON_VERSION ${PULSAR_CLIENT_PYTHON_VERSION}
# This script is intentionally run as the root user to make the dependencies available for all UIDs.
+RUN chmod +x /pulsar/bin/install-pulsar-client.sh
RUN /pulsar/bin/install-pulsar-client.sh
# The UID must be non-zero. Otherwise, it is arbitrary. No logic should rely on its specific value.
diff --git a/docker/pulsar/pom.xml b/docker/pulsar/pom.xml
index f7d91b2120841..c620f591d223b 100644
--- a/docker/pulsar/pom.xml
+++ b/docker/pulsar/pom.xml
@@ -66,46 +66,7 @@
packagebuild
-
-
-
-
- ${docker.organization}/pulsar
-
- ${project.basedir}
-
- latest
- ${project.version}
-
-
-
-
-
-
-
- push-latest
-
- push
-
-
-
-
- ${docker.organization}/pulsar
-
- ${project.basedir}
-
- latest
-
-
-
-
-
-
-
- add-no-repo
- package
-
- build
+ tag
@@ -115,11 +76,12 @@
${project.basedir}latest
- ${project.version}
+ latest
+ ${docker.organization}
diff --git a/jclouds-shaded/src/main/java/org/apache/pulsar/jclouds/ShadedJCloudsUtils.java b/jclouds-shaded/src/main/java/org/apache/pulsar/jclouds/ShadedJCloudsUtils.java
index d2c1b0740a80b..98960b04f5e39 100644
--- a/jclouds-shaded/src/main/java/org/apache/pulsar/jclouds/ShadedJCloudsUtils.java
+++ b/jclouds-shaded/src/main/java/org/apache/pulsar/jclouds/ShadedJCloudsUtils.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -19,6 +19,8 @@
package org.apache.pulsar.jclouds;
import com.google.inject.AbstractModule;
+import java.util.ArrayList;
+import java.util.List;
import lombok.experimental.UtilityClass;
import lombok.extern.slf4j.Slf4j;
import org.jclouds.ContextBuilder;
@@ -26,9 +28,6 @@
import org.jclouds.http.okhttp.config.OkHttpCommandExecutorServiceModule;
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* This utility class helps in dealing with shaded dependencies (especially Guice).
*/
diff --git a/jclouds-shaded/src/main/java/org/apache/pulsar/jclouds/package-info.java b/jclouds-shaded/src/main/java/org/apache/pulsar/jclouds/package-info.java
new file mode 100644
index 0000000000000..6e463663675b2
--- /dev/null
+++ b/jclouds-shaded/src/main/java/org/apache/pulsar/jclouds/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.jclouds;
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/AsyncCallbacks.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/AsyncCallbacks.java
index 395da52b2aff9..dcf2c225e8b35 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/AsyncCallbacks.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/AsyncCallbacks.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -24,6 +24,7 @@
import java.util.Optional;
import org.apache.bookkeeper.common.annotation.InterfaceAudience;
import org.apache.bookkeeper.common.annotation.InterfaceStability;
+import org.apache.bookkeeper.mledger.impl.ReadOnlyManagedLedgerImpl;
/**
* Definition of all the callbacks used for the ManagedLedger asynchronous API.
@@ -46,6 +47,12 @@ interface OpenReadOnlyCursorCallback {
void openReadOnlyCursorFailed(ManagedLedgerException exception, Object ctx);
}
+ interface OpenReadOnlyManagedLedgerCallback {
+ void openReadOnlyManagedLedgerComplete(ReadOnlyManagedLedgerImpl managedLedger, Object ctx);
+
+ void openReadOnlyManagedLedgerFailed(ManagedLedgerException exception, Object ctx);
+ }
+
interface DeleteLedgerCallback {
void deleteLedgerComplete(Object ctx);
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/Entry.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/Entry.java
index 5d1ccf81fd934..428dcc9d97c76 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/Entry.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/Entry.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/LedgerOffloader.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/LedgerOffloader.java
index e9403f509776c..b60ae41670de7 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/LedgerOffloader.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/LedgerOffloader.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/LedgerOffloaderFactory.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/LedgerOffloaderFactory.java
index bb94cee6fde49..42f92359f9a94 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/LedgerOffloaderFactory.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/LedgerOffloaderFactory.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/LedgerOffloaderStats.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/LedgerOffloaderStats.java
index c9330ff9e056c..4059d4be94aad 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/LedgerOffloaderStats.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/LedgerOffloaderStats.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/LedgerOffloaderStatsDisable.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/LedgerOffloaderStatsDisable.java
index 862d466067e69..0fe0f453347bf 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/LedgerOffloaderStatsDisable.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/LedgerOffloaderStatsDisable.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedCursor.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedCursor.java
index cf022d3552e64..0df07f60d76f4 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedCursor.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedCursor.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedCursorMXBean.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedCursorMXBean.java
index 9abe50d8a3ea3..7402bd65f793e 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedCursorMXBean.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedCursorMXBean.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedger.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedger.java
index 7fcbfdc8b476c..4ca56508891a1 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedger.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedger.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -221,8 +221,7 @@ void asyncAddEntry(byte[] data, int numberOfMessages, int offset, int length, Ad
* @param name
* the name associated with the ManagedCursor
* @param initialPosition
- * the cursor will be set at latest position or not when first created
- * default is true
+ * if null, the cursor will be set at latest position when first created
* @return the ManagedCursor
* @throws ManagedLedgerException
*/
@@ -237,8 +236,7 @@ ManagedCursor openCursor(String name, InitialPosition initialPosition) throws In
* @param name
* the name associated with the ManagedCursor
* @param initialPosition
- * the cursor will be set at latest position or not when first created
- * default is true
+ * if null, the cursor will be set at latest position when first created
* @param properties
* user defined properties that will be attached to the first position of the cursor, if the open
* operation will trigger the creation of the cursor.
@@ -324,8 +322,7 @@ ManagedCursor newNonDurableCursor(Position startPosition, String subscriptionNam
* @param name
* the name associated with the ManagedCursor
* @param initialPosition
- * the cursor will be set at lastest position or not when first created
- * default is true
+ * if null, the cursor will be set at latest position when first created
* @param callback
* callback object
* @param ctx
@@ -340,8 +337,7 @@ ManagedCursor newNonDurableCursor(Position startPosition, String subscriptionNam
* @param name
* the name associated with the ManagedCursor
* @param initialPosition
- * the cursor will be set at lastest position or not when first created
- * default is true
+ * if null, the cursor will be set at latest position when first created
* @param cursorProperties
* the properties for the Cursor
* @param callback
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedgerConfig.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedgerConfig.java
index 24228d8d6d238..6e88a8e650d58 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedgerConfig.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedgerConfig.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -62,7 +62,7 @@ public class ManagedLedgerConfig {
private int ledgerRolloverTimeout = 4 * 3600;
private double throttleMarkDelete = 0;
private long retentionTimeMs = 0;
- private long retentionSizeInMB = 0;
+ private int retentionSizeInMB = 0;
private boolean autoSkipNonRecoverableData;
private boolean lazyCursorRecovery = false;
private long metadataOperationsTimeoutSeconds = 60;
@@ -86,6 +86,10 @@ public class ManagedLedgerConfig {
private int minimumBacklogEntriesForCaching = 1000;
private int maxBacklogBetweenCursorsForCaching = 1000;
+ @Getter
+ @Setter
+ private String shadowSourceName;
+
public boolean isCreateIfMissing() {
return createIfMissing;
}
@@ -392,7 +396,7 @@ public ManagedLedgerConfig setThrottleMarkDelete(double throttleMarkDelete) {
/**
* Set the retention time for the ManagedLedger.
*
- * Retention time and retention size ({@link #setRetentionSizeInMB(long)}) are together used to retain the
+ * Retention time and retention size ({@link #setRetentionSizeInMB(int)}) are together used to retain the
* ledger data when there are no cursors or when all the cursors have marked the data for deletion.
* Data will be deleted in this case when both retention time and retention size settings don't prevent deleting
* the data marked for deletion.
@@ -434,7 +438,7 @@ public long getRetentionTimeMillis() {
* @param retentionSizeInMB
* quota for message retention
*/
- public ManagedLedgerConfig setRetentionSizeInMB(long retentionSizeInMB) {
+ public ManagedLedgerConfig setRetentionSizeInMB(int retentionSizeInMB) {
this.retentionSizeInMB = retentionSizeInMB;
return this;
}
@@ -443,7 +447,7 @@ public ManagedLedgerConfig setRetentionSizeInMB(long retentionSizeInMB) {
* @return quota for message retention
*
*/
- public long getRetentionSizeInMB() {
+ public int getRetentionSizeInMB() {
return retentionSizeInMB;
}
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedgerException.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedgerException.java
index fa6dc59d14753..1fa565d6ec788 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedgerException.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedgerException.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedgerFactory.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedgerFactory.java
index 667d641ac9ae0..b1427bab80b22 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedgerFactory.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedgerFactory.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -117,6 +117,17 @@ ReadOnlyCursor openReadOnlyCursor(String managedLedgerName, Position startPositi
void asyncOpenReadOnlyCursor(String managedLedgerName, Position startPosition, ManagedLedgerConfig config,
OpenReadOnlyCursorCallback callback, Object ctx);
+ /**
+ * Asynchronous open a Read-only managedLedger.
+ * @param managedLedgerName the unique name that identifies the managed ledger
+ * @param callback
+ * @param config the managed ledger configuration.
+ * @param ctx opaque context
+ */
+ void asyncOpenReadOnlyManagedLedger(String managedLedgerName,
+ AsyncCallbacks.OpenReadOnlyManagedLedgerCallback callback,
+ ManagedLedgerConfig config, Object ctx);
+
/**
* Get the current metadata info for a managed ledger.
*
@@ -146,6 +157,16 @@ void asyncOpenReadOnlyCursor(String managedLedgerName, Position startPosition, M
*/
void delete(String name) throws InterruptedException, ManagedLedgerException;
+ /**
+ * Delete a managed ledger. If it's not open, it's metadata will get regardless deleted.
+ *
+ * @param name
+ * @throws InterruptedException
+ * @throws ManagedLedgerException
+ */
+ void delete(String name, CompletableFuture mlConfigFuture)
+ throws InterruptedException, ManagedLedgerException;
+
/**
* Delete a managed ledger. If it's not open, it's metadata will get regardless deleted.
*
@@ -155,6 +176,16 @@ void asyncOpenReadOnlyCursor(String managedLedgerName, Position startPosition, M
*/
void asyncDelete(String name, DeleteLedgerCallback callback, Object ctx);
+ /**
+ * Delete a managed ledger. If it's not open, it's metadata will get regardless deleted.
+ *
+ * @param name
+ * @throws InterruptedException
+ * @throws ManagedLedgerException
+ */
+ void asyncDelete(String name, CompletableFuture mlConfigFuture,
+ DeleteLedgerCallback callback, Object ctx);
+
/**
* Releases all the resources maintained by the ManagedLedgerFactory.
*
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedgerFactoryConfig.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedgerFactoryConfig.java
index 78314be45c390..5aa4e8374d73a 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedgerFactoryConfig.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedgerFactoryConfig.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -57,6 +57,11 @@ public class ManagedLedgerFactoryConfig {
*/
private boolean copyEntriesInCache = false;
+ /**
+ * Maximum number of (estimated) data in-flight reading from storage and the cache.
+ */
+ private long managedLedgerMaxReadsInFlightSize = 0;
+
/**
* Whether trace managed ledger task execution time.
*/
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedgerFactoryMXBean.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedgerFactoryMXBean.java
index f71583ab88661..35c26c5dfdb89 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedgerFactoryMXBean.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedgerFactoryMXBean.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedgerInfo.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedgerInfo.java
index e0c9982c04ea2..3e4e56187e5ee 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedgerInfo.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedgerInfo.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedgerMXBean.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedgerMXBean.java
index 6eccd029cbaf5..94c2f61e00afe 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedgerMXBean.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedgerMXBean.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/OffloadedLedgerMetadata.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/OffloadedLedgerMetadata.java
index 7bbf2e5fe0c7f..7498ff823f838 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/OffloadedLedgerMetadata.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/OffloadedLedgerMetadata.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/OffloadedLedgerMetadataConsumer.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/OffloadedLedgerMetadataConsumer.java
index c4c30d1299e72..3706d513dc0b5 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/OffloadedLedgerMetadataConsumer.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/OffloadedLedgerMetadataConsumer.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/Position.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/Position.java
index c76e7b75ab581..ac5810bbf01e7 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/Position.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/Position.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ReadOnlyCursor.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ReadOnlyCursor.java
index fe086f009808e..18d412f893152 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ReadOnlyCursor.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ReadOnlyCursor.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ScanOutcome.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ScanOutcome.java
index c7a4cff474cb4..c679c40e85e91 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ScanOutcome.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ScanOutcome.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/WaitingEntryCallBack.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/WaitingEntryCallBack.java
index fc1f3b4b5ec46..cc6dbf3239204 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/WaitingEntryCallBack.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/WaitingEntryCallBack.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/EntryImpl.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/EntryImpl.java
index c387aa970adb6..6512399173f0a 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/EntryImpl.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/EntryImpl.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -44,6 +44,8 @@ protected EntryImpl newObject(Handle handle) {
private long entryId;
ByteBuf data;
+ private Runnable onDeallocate;
+
public static EntryImpl create(LedgerEntry ledgerEntry) {
EntryImpl entry = RECYCLER.get();
entry.timestamp = System.nanoTime();
@@ -102,6 +104,22 @@ private EntryImpl(Recycler.Handle recyclerHandle) {
this.recyclerHandle = recyclerHandle;
}
+ public void onDeallocate(Runnable r) {
+ if (this.onDeallocate == null) {
+ this.onDeallocate = r;
+ } else {
+ // this is not expected to happen
+ Runnable previous = this.onDeallocate;
+ this.onDeallocate = () -> {
+ try {
+ previous.run();
+ } finally {
+ r.run();
+ }
+ };
+ }
+ }
+
public long getTimestamp() {
return timestamp;
}
@@ -167,6 +185,13 @@ public ReferenceCounted touch(Object hint) {
@Override
protected void deallocate() {
// This method is called whenever the ref-count of the EntryImpl reaches 0, so that now we can recycle it
+ if (onDeallocate != null) {
+ try {
+ onDeallocate.run();
+ } finally {
+ onDeallocate = null;
+ }
+ }
data.release();
data = null;
timestamp = -1;
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/LedgerMetadataUtils.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/LedgerMetadataUtils.java
index b32b81b234922..399811e4b3b17 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/LedgerMetadataUtils.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/LedgerMetadataUtils.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/LedgerOffloaderStatsImpl.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/LedgerOffloaderStatsImpl.java
index 72382b1ac4574..be2895bf81867 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/LedgerOffloaderStatsImpl.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/LedgerOffloaderStatsImpl.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorContainer.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorContainer.java
index 293ce8d2fcbc2..f9c7a6d2efe0e 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorContainer.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorContainer.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
index f9cb6a9ec6e37..5755f528c6ace 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -566,7 +566,7 @@ protected void recoverFromLedger(final ManagedCursorInfo info, final VoidCallbac
if (positionInfo.getIndividualDeletedMessagesCount() > 0) {
recoverIndividualDeletedMessages(positionInfo.getIndividualDeletedMessagesList());
}
- if (config.isDeletionAtBatchIndexLevelEnabled() && batchDeletedIndexes != null
+ if (config.isDeletionAtBatchIndexLevelEnabled()
&& positionInfo.getBatchedEntryDeletionIndexInfoCount() > 0) {
recoverBatchDeletedIndexes(positionInfo.getBatchedEntryDeletionIndexInfoList());
}
@@ -1183,29 +1183,33 @@ public Position getFirstPosition() {
return firstLedgerId == null ? null : new PositionImpl(firstLedgerId, 0);
}
- protected void internalResetCursor(PositionImpl position, AsyncCallbacks.ResetCursorCallback resetCursorCallback) {
- if (position.equals(PositionImpl.EARLIEST)) {
- position = ledger.getFirstPosition();
- } else if (position.equals(PositionImpl.LATEST)) {
- position = ledger.getLastPosition().getNext();
+ protected void internalResetCursor(PositionImpl proposedReadPosition,
+ AsyncCallbacks.ResetCursorCallback resetCursorCallback) {
+ final PositionImpl newReadPosition;
+ if (proposedReadPosition.equals(PositionImpl.EARLIEST)) {
+ newReadPosition = ledger.getFirstPosition();
+ } else if (proposedReadPosition.equals(PositionImpl.LATEST)) {
+ newReadPosition = ledger.getLastPosition().getNext();
+ } else {
+ newReadPosition = proposedReadPosition;
}
- log.info("[{}] Initiate reset position to {} on cursor {}", ledger.getName(), position, name);
+ log.info("[{}] Initiate reset readPosition to {} on cursor {}", ledger.getName(), newReadPosition, name);
synchronized (pendingMarkDeleteOps) {
if (!RESET_CURSOR_IN_PROGRESS_UPDATER.compareAndSet(this, FALSE, TRUE)) {
- log.error("[{}] reset requested - position [{}], previous reset in progress - cursor {}",
- ledger.getName(), position, name);
+ log.error("[{}] reset requested - readPosition [{}], previous reset in progress - cursor {}",
+ ledger.getName(), newReadPosition, name);
resetCursorCallback.resetFailed(
new ManagedLedgerException.ConcurrentFindCursorPositionException("reset already in progress"),
- position);
+ newReadPosition);
return;
}
}
final AsyncCallbacks.ResetCursorCallback callback = resetCursorCallback;
- final PositionImpl newPosition = position;
+ final PositionImpl newMarkDeletePosition = ledger.getPreviousPosition(newReadPosition);
VoidCallback finalCallback = new VoidCallback() {
@Override
@@ -1214,8 +1218,6 @@ public void operationComplete() {
// modify mark delete and read position since we are able to persist new position for cursor
lock.writeLock().lock();
try {
- PositionImpl newMarkDeletePosition = ledger.getPreviousPosition(newPosition);
-
if (markDeletePosition.compareTo(newMarkDeletePosition) >= 0) {
MSG_CONSUMED_COUNTER_UPDATER.addAndGet(cursorImpl(), -getNumberOfEntries(
Range.closedOpen(newMarkDeletePosition, markDeletePosition)));
@@ -1227,37 +1229,37 @@ public void operationComplete() {
lastMarkDeleteEntry = new MarkDeleteEntry(newMarkDeletePosition, isCompactionCursor()
? getProperties() : Collections.emptyMap(), null, null);
individualDeletedMessages.clear();
- if (config.isDeletionAtBatchIndexLevelEnabled() && batchDeletedIndexes != null) {
+ if (config.isDeletionAtBatchIndexLevelEnabled()) {
batchDeletedIndexes.values().forEach(BitSetRecyclable::recycle);
batchDeletedIndexes.clear();
- long[] resetWords = newPosition.ackSet;
+ long[] resetWords = newReadPosition.ackSet;
if (resetWords != null) {
BitSetRecyclable ackSet = BitSetRecyclable.create().resetWords(resetWords);
- batchDeletedIndexes.put(newPosition, ackSet);
+ batchDeletedIndexes.put(newReadPosition, ackSet);
}
}
PositionImpl oldReadPosition = readPosition;
- if (oldReadPosition.compareTo(newPosition) >= 0) {
- log.info("[{}] reset position to {} before current read position {} on cursor {}",
- ledger.getName(), newPosition, oldReadPosition, name);
+ if (oldReadPosition.compareTo(newReadPosition) >= 0) {
+ log.info("[{}] reset readPosition to {} before current read readPosition {} on cursor {}",
+ ledger.getName(), newReadPosition, oldReadPosition, name);
} else {
- log.info("[{}] reset position to {} skipping from current read position {} on cursor {}",
- ledger.getName(), newPosition, oldReadPosition, name);
+ log.info("[{}] reset readPosition to {} skipping from current read readPosition {} on "
+ + "cursor {}", ledger.getName(), newReadPosition, oldReadPosition, name);
}
- readPosition = newPosition;
- ledger.onCursorReadPositionUpdated(ManagedCursorImpl.this, newPosition);
+ readPosition = newReadPosition;
+ ledger.onCursorReadPositionUpdated(ManagedCursorImpl.this, newReadPosition);
} finally {
lock.writeLock().unlock();
}
synchronized (pendingMarkDeleteOps) {
pendingMarkDeleteOps.clear();
if (!RESET_CURSOR_IN_PROGRESS_UPDATER.compareAndSet(ManagedCursorImpl.this, TRUE, FALSE)) {
- log.error("[{}] expected reset position [{}], but another reset in progress on cursor {}",
- ledger.getName(), newPosition, name);
+ log.error("[{}] expected reset readPosition [{}], but another reset in progress on cursor {}",
+ ledger.getName(), newReadPosition, name);
}
}
- callback.resetComplete(newPosition);
+ callback.resetComplete(newReadPosition);
updateLastActive();
}
@@ -1265,20 +1267,20 @@ public void operationComplete() {
public void operationFailed(ManagedLedgerException exception) {
synchronized (pendingMarkDeleteOps) {
if (!RESET_CURSOR_IN_PROGRESS_UPDATER.compareAndSet(ManagedCursorImpl.this, TRUE, FALSE)) {
- log.error("[{}] expected reset position [{}], but another reset in progress on cursor {}",
- ledger.getName(), newPosition, name);
+ log.error("[{}] expected reset readPosition [{}], but another reset in progress on cursor {}",
+ ledger.getName(), newReadPosition, name);
}
}
callback.resetFailed(new ManagedLedgerException.InvalidCursorPositionException(
- "unable to persist position for cursor reset " + newPosition.toString()), newPosition);
+ "unable to persist readPosition for cursor reset " + newReadPosition), newReadPosition);
}
};
persistentMarkDeletePosition = null;
inProgressMarkDeletePersistPosition = null;
- lastMarkDeleteEntry = new MarkDeleteEntry(newPosition, getProperties(), null, null);
- internalAsyncMarkDelete(newPosition, isCompactionCursor() ? getProperties() : Collections.emptyMap(),
+ lastMarkDeleteEntry = new MarkDeleteEntry(newMarkDeletePosition, getProperties(), null, null);
+ internalAsyncMarkDelete(newMarkDeletePosition, isCompactionCursor() ? getProperties() : Collections.emptyMap(),
new MarkDeleteCallback() {
@Override
public void markDeleteComplete(Object ctx) {
@@ -1298,7 +1300,7 @@ public void asyncResetCursor(Position newPos, boolean forceReset, AsyncCallbacks
final PositionImpl newPosition = (PositionImpl) newPos;
// order trim and reset operations on a ledger
- ledger.getExecutor().executeOrdered(ledger.getName(), safeRun(() -> {
+ ledger.getExecutor().execute(safeRun(() -> {
PositionImpl actualPosition = newPosition;
if (!ledger.isValidPosition(actualPosition)
@@ -1866,9 +1868,29 @@ public void asyncMarkDelete(final Position position, Map propertie
PositionImpl newPosition = (PositionImpl) position;
- if (config.isDeletionAtBatchIndexLevelEnabled() && batchDeletedIndexes != null) {
+ if (config.isDeletionAtBatchIndexLevelEnabled()) {
if (newPosition.ackSet != null) {
- batchDeletedIndexes.put(newPosition, BitSetRecyclable.create().resetWords(newPosition.ackSet));
+ AtomicReference bitSetRecyclable = new AtomicReference<>();
+ BitSetRecyclable givenBitSet = BitSetRecyclable.create().resetWords(newPosition.ackSet);
+ // In order to prevent the batch index recorded in batchDeletedIndexes from rolling back,
+ // only update batchDeletedIndexes when the submitted batch index is greater
+ // than the recorded index.
+ batchDeletedIndexes.compute(newPosition,
+ (k, v) -> {
+ if (v == null) {
+ return givenBitSet;
+ }
+ if (givenBitSet.nextSetBit(0) > v.nextSetBit(0)) {
+ bitSetRecyclable.set(v);
+ return givenBitSet;
+ } else {
+ bitSetRecyclable.set(givenBitSet);
+ return v;
+ }
+ });
+ if (bitSetRecyclable.get() != null) {
+ bitSetRecyclable.get().recycle();
+ }
newPosition = ledger.getPreviousPosition(newPosition);
}
Map subMap = batchDeletedIndexes.subMap(PositionImpl.EARLIEST, newPosition);
@@ -1975,7 +1997,7 @@ void internalMarkDelete(final MarkDeleteEntry mdEntry) {
+ "is later.", mdEntry.newPosition, persistentMarkDeletePosition);
}
// run with executor to prevent deadlock
- ledger.getExecutor().executeOrdered(ledger.getName(), safeRun(() -> mdEntry.triggerComplete()));
+ ledger.getExecutor().execute(safeRun(() -> mdEntry.triggerComplete()));
return;
}
@@ -1994,7 +2016,7 @@ void internalMarkDelete(final MarkDeleteEntry mdEntry) {
+ "in progress {} is later.", mdEntry.newPosition, inProgressLatest);
}
// run with executor to prevent deadlock
- ledger.getExecutor().executeOrdered(ledger.getName(), safeRun(() -> mdEntry.triggerComplete()));
+ ledger.getExecutor().execute(safeRun(() -> mdEntry.triggerComplete()));
return;
}
@@ -2029,7 +2051,7 @@ public void operationComplete() {
try {
individualDeletedMessages.removeAtMost(mdEntry.newPosition.getLedgerId(),
mdEntry.newPosition.getEntryId());
- if (config.isDeletionAtBatchIndexLevelEnabled() && batchDeletedIndexes != null) {
+ if (config.isDeletionAtBatchIndexLevelEnabled()) {
Map subMap = batchDeletedIndexes.subMap(PositionImpl.EARLIEST,
false, PositionImpl.get(mdEntry.newPosition.getLedgerId(),
mdEntry.newPosition.getEntryId()), true);
@@ -2158,7 +2180,7 @@ public void asyncDelete(Iterable positions, AsyncCallbacks.DeleteCallb
if (individualDeletedMessages.contains(position.getLedgerId(), position.getEntryId())
|| position.compareTo(markDeletePosition) <= 0) {
- if (config.isDeletionAtBatchIndexLevelEnabled() && batchDeletedIndexes != null) {
+ if (config.isDeletionAtBatchIndexLevelEnabled()) {
BitSetRecyclable bitSetRecyclable = batchDeletedIndexes.remove(position);
if (bitSetRecyclable != null) {
bitSetRecyclable.recycle();
@@ -2170,7 +2192,7 @@ public void asyncDelete(Iterable positions, AsyncCallbacks.DeleteCallb
continue;
}
if (position.ackSet == null) {
- if (config.isDeletionAtBatchIndexLevelEnabled() && batchDeletedIndexes != null) {
+ if (config.isDeletionAtBatchIndexLevelEnabled()) {
BitSetRecyclable bitSetRecyclable = batchDeletedIndexes.remove(position);
if (bitSetRecyclable != null) {
bitSetRecyclable.recycle();
@@ -2187,7 +2209,7 @@ public void asyncDelete(Iterable positions, AsyncCallbacks.DeleteCallb
log.debug("[{}] [{}] Individually deleted messages: {}", ledger.getName(), name,
individualDeletedMessages);
}
- } else if (config.isDeletionAtBatchIndexLevelEnabled() && batchDeletedIndexes != null) {
+ } else if (config.isDeletionAtBatchIndexLevelEnabled()) {
BitSetRecyclable givenBitSet = BitSetRecyclable.create().resetWords(position.ackSet);
BitSetRecyclable bitSet = batchDeletedIndexes.computeIfAbsent(position, (v) -> givenBitSet);
if (givenBitSet != bitSet) {
@@ -2601,8 +2623,8 @@ public void operationFailed(MetaStoreException e) {
@Override
public void asyncClose(final AsyncCallbacks.CloseCallback callback, final Object ctx) {
- State oldState = STATE_UPDATER.getAndSet(this, State.Closing);
- if (oldState == State.Closed || oldState == State.Closing) {
+ boolean alreadyClosing = !trySetStateToClosing();
+ if (alreadyClosing) {
log.info("[{}] [{}] State is already closed", ledger.getName(), name);
callback.closeComplete(ctx);
return;
@@ -2685,6 +2707,28 @@ public void operationFailed(ManagedLedgerException exception) {
});
}
+ /**
+ * Try set {@link #state} to {@link State#Closing}.
+ * @return false if the {@link #state} already is {@link State#Closing} or {@link State#Closed}.
+ */
+ private boolean trySetStateToClosing() {
+ final AtomicBoolean notClosing = new AtomicBoolean(false);
+ STATE_UPDATER.updateAndGet(this, state -> {
+ switch (state){
+ case Closing:
+ case Closed: {
+ notClosing.set(false);
+ return state;
+ }
+ default: {
+ notClosing.set(true);
+ return State.Closing;
+ }
+ }
+ });
+ return notClosing.get();
+ }
+
private void flushPendingMarkDeletes() {
if (!pendingMarkDeleteOps.isEmpty()) {
internalFlushPendingMarkDeletes();
@@ -2842,8 +2886,7 @@ private List buildIndividualDeletedMessageRanges() {
private List buildBatchEntryDeletionIndexInfoList() {
lock.readLock().lock();
try {
- if (!config.isDeletionAtBatchIndexLevelEnabled() || batchDeletedIndexes == null
- || batchDeletedIndexes.isEmpty()) {
+ if (!config.isDeletionAtBatchIndexLevelEnabled() || batchDeletedIndexes.isEmpty()) {
return Collections.emptyList();
}
MLDataFormats.NestedPositionInfo.Builder nestedPositionBuilder = MLDataFormats.NestedPositionInfo
@@ -3284,8 +3327,14 @@ public Range getLastIndividualDeletedRange() {
@Override
public void trimDeletedEntries(List entries) {
- entries.removeIf(entry -> ((PositionImpl) entry.getPosition()).compareTo(markDeletePosition) <= 0
- || individualDeletedMessages.contains(entry.getLedgerId(), entry.getEntryId()));
+ entries.removeIf(entry -> {
+ boolean isDeleted = ((PositionImpl) entry.getPosition()).compareTo(markDeletePosition) <= 0
+ || individualDeletedMessages.contains(entry.getLedgerId(), entry.getEntryId());
+ if (isDeleted) {
+ entry.release();
+ }
+ return isDeleted;
+ });
}
private ManagedCursorImpl cursorImpl() {
@@ -3294,7 +3343,7 @@ private ManagedCursorImpl cursorImpl() {
@Override
public long[] getDeletedBatchIndexesAsLongArray(PositionImpl position) {
- if (config.isDeletionAtBatchIndexLevelEnabled() && batchDeletedIndexes != null) {
+ if (config.isDeletionAtBatchIndexLevelEnabled()) {
BitSetRecyclable bitSet = batchDeletedIndexes.get(position);
return bitSet == null ? null : bitSet.toLongArray();
} else {
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorMXBeanImpl.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorMXBeanImpl.java
index fd9dcc1e17f1c..48465e6294b0e 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorMXBeanImpl.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorMXBeanImpl.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerFactoryImpl.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerFactoryImpl.java
index e0af1cc632612..9f3fe9bb0c4a7 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerFactoryImpl.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerFactoryImpl.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -26,6 +26,7 @@
import io.netty.util.concurrent.DefaultThreadFactory;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@@ -71,6 +72,7 @@
import org.apache.bookkeeper.mledger.impl.MetaStore.MetaStoreCallback;
import org.apache.bookkeeper.mledger.impl.cache.EntryCacheManager;
import org.apache.bookkeeper.mledger.impl.cache.RangeEntryCacheManagerImpl;
+import org.apache.bookkeeper.mledger.offload.OffloadUtils;
import org.apache.bookkeeper.mledger.proto.MLDataFormats;
import org.apache.bookkeeper.mledger.proto.MLDataFormats.LongProperty;
import org.apache.bookkeeper.mledger.proto.MLDataFormats.ManagedCursorInfo;
@@ -78,6 +80,7 @@
import org.apache.bookkeeper.mledger.util.Futures;
import org.apache.bookkeeper.stats.NullStatsLogger;
import org.apache.bookkeeper.stats.StatsLogger;
+import org.apache.commons.lang3.tuple.Pair;
import org.apache.pulsar.common.policies.data.EnsemblePlacementPolicyConfig;
import org.apache.pulsar.common.util.DateFormatter;
import org.apache.pulsar.common.util.FutureUtil;
@@ -338,7 +341,7 @@ public void asyncOpen(final String name, final ManagedLedgerConfig config, final
if (existingFuture.isDone()) {
try {
ManagedLedgerImpl l = existingFuture.get();
- if (l.getState() == State.Fenced || l.getState() == State.Closed) {
+ if (l.getState().isFenced() || l.getState() == State.Closed) {
// Managed ledger is in unusable state. Recreate it.
log.warn("[{}] Attempted to open ledger in {} state. Removing from the map to recreate it",
name, l.getState());
@@ -420,7 +423,29 @@ public void closeFailed(ManagedLedgerException exception, Object ctx) {
});
}
+ @Override
+ public void asyncOpenReadOnlyManagedLedger(String managedLedgerName,
+ AsyncCallbacks.OpenReadOnlyManagedLedgerCallback callback,
+ ManagedLedgerConfig config, Object ctx) {
+ if (closed) {
+ callback.openReadOnlyManagedLedgerFailed(
+ new ManagedLedgerException.ManagedLedgerFactoryClosedException(), ctx);
+ }
+ ReadOnlyManagedLedgerImpl roManagedLedger = new ReadOnlyManagedLedgerImpl(this,
+ bookkeeperFactory
+ .get(new EnsemblePlacementPolicyConfig(config.getBookKeeperEnsemblePlacementPolicyClassName(),
+ config.getBookKeeperEnsemblePlacementPolicyProperties())),
+ store, config, scheduledExecutor, managedLedgerName);
+ roManagedLedger.initialize().thenRun(() -> {
+ log.info("[{}] Successfully initialize Read-only managed ledger", managedLedgerName);
+ callback.openReadOnlyManagedLedgerComplete(roManagedLedger, ctx);
+ }).exceptionally(e -> {
+ log.error("[{}] Failed to initialize Read-only managed ledger", managedLedgerName, e);
+ callback.openReadOnlyManagedLedgerFailed((ManagedLedgerException) e.getCause(), ctx);
+ return null;
+ });
+ }
@Override
public ReadOnlyCursor openReadOnlyCursor(String managedLedgerName, Position startPosition,
@@ -462,28 +487,20 @@ public void asyncOpenReadOnlyCursor(String managedLedgerName, Position startPosi
return;
}
checkArgument(startPosition instanceof PositionImpl);
- ReadOnlyManagedLedgerImpl roManagedLedger = new ReadOnlyManagedLedgerImpl(this,
- bookkeeperFactory
- .get(new EnsemblePlacementPolicyConfig(config.getBookKeeperEnsemblePlacementPolicyClassName(),
- config.getBookKeeperEnsemblePlacementPolicyProperties())),
- store, config, scheduledExecutor, managedLedgerName);
-
- roManagedLedger.initializeAndCreateCursor((PositionImpl) startPosition)
- .thenAccept(roCursor -> callback.openReadOnlyCursorComplete(roCursor, ctx))
- .exceptionally(ex -> {
- Throwable t = ex;
- if (t instanceof CompletionException) {
- t = ex.getCause();
+ AsyncCallbacks.OpenReadOnlyManagedLedgerCallback openReadOnlyManagedLedgerCallback =
+ new AsyncCallbacks.OpenReadOnlyManagedLedgerCallback() {
+ @Override
+ public void openReadOnlyManagedLedgerComplete(ReadOnlyManagedLedgerImpl readOnlyManagedLedger, Object ctx) {
+ callback.openReadOnlyCursorComplete(readOnlyManagedLedger.
+ createReadOnlyCursor((PositionImpl) startPosition), ctx);
}
- if (t instanceof ManagedLedgerException) {
- callback.openReadOnlyCursorFailed((ManagedLedgerException) t, ctx);
- } else {
- callback.openReadOnlyCursorFailed(new ManagedLedgerException(t), ctx);
+ @Override
+ public void openReadOnlyManagedLedgerFailed(ManagedLedgerException exception, Object ctx) {
+ callback.openReadOnlyCursorFailed(exception, ctx);
}
-
- return null;
- });
+ };
+ asyncOpenReadOnlyManagedLedger(managedLedgerName, openReadOnlyManagedLedgerCallback, config, null);
}
void close(ManagedLedger ledger) {
@@ -804,12 +821,18 @@ public void operationFailed(MetaStoreException e) {
@Override
public void delete(String name) throws InterruptedException, ManagedLedgerException {
+ delete(name, CompletableFuture.completedFuture(null));
+ }
+
+ @Override
+ public void delete(String name, CompletableFuture mlConfigFuture)
+ throws InterruptedException, ManagedLedgerException {
class Result {
ManagedLedgerException e = null;
}
final Result r = new Result();
final CountDownLatch latch = new CountDownLatch(1);
- asyncDelete(name, new DeleteLedgerCallback() {
+ asyncDelete(name, mlConfigFuture, new DeleteLedgerCallback() {
@Override
public void deleteLedgerComplete(Object ctx) {
latch.countDown();
@@ -831,10 +854,16 @@ public void deleteLedgerFailed(ManagedLedgerException exception, Object ctx) {
@Override
public void asyncDelete(String name, DeleteLedgerCallback callback, Object ctx) {
+ asyncDelete(name, CompletableFuture.completedFuture(null), callback, ctx);
+ }
+
+ @Override
+ public void asyncDelete(String name, CompletableFuture mlConfigFuture,
+ DeleteLedgerCallback callback, Object ctx) {
CompletableFuture future = ledgers.get(name);
if (future == null) {
// Managed ledger does not exist and we're not currently trying to open it
- deleteManagedLedger(name, callback, ctx);
+ deleteManagedLedger(name, mlConfigFuture, callback, ctx);
} else {
future.thenAccept(ml -> {
// If it's open, delete in the normal way
@@ -849,7 +878,8 @@ public void asyncDelete(String name, DeleteLedgerCallback callback, Object ctx)
/**
* Delete all managed ledger resources and metadata.
*/
- void deleteManagedLedger(String managedLedgerName, DeleteLedgerCallback callback, Object ctx) {
+ void deleteManagedLedger(String managedLedgerName, CompletableFuture mlConfigFuture,
+ DeleteLedgerCallback callback, Object ctx) {
// Read the managed ledger metadata from store
asyncGetManagedLedgerInfo(managedLedgerName, new ManagedLedgerInfoCallback() {
@Override
@@ -861,7 +891,7 @@ public void getInfoComplete(ManagedLedgerInfo info, Object ctx) {
.map(e -> deleteCursor(bkc, managedLedgerName, e.getKey(), e.getValue()))
.collect(Collectors.toList());
Futures.waitForAll(futures).thenRun(() -> {
- deleteManagedLedgerData(bkc, managedLedgerName, info, callback, ctx);
+ deleteManagedLedgerData(bkc, managedLedgerName, info, mlConfigFuture, callback, ctx);
}).exceptionally(ex -> {
callback.deleteLedgerFailed(new ManagedLedgerException(ex), ctx);
return null;
@@ -876,22 +906,80 @@ public void getInfoFailed(ManagedLedgerException exception, Object ctx) {
}
private void deleteManagedLedgerData(BookKeeper bkc, String managedLedgerName, ManagedLedgerInfo info,
- DeleteLedgerCallback callback, Object ctx) {
+ CompletableFuture mlConfigFuture,
+ DeleteLedgerCallback callback, Object ctx) {
+ final CompletableFuture
4false1
-
+ /tmpapachepulsarfalse
@@ -118,7 +118,7 @@ flexible messaging model and an intuitive client API.
1.21
- 4.15.1
+ 4.15.33.8.01.5.01.10.0
@@ -126,7 +126,7 @@ flexible messaging model and an intuitive client API.
4.1.12.15.1.04.1.77.Final
- 2.0.52.Final
+ 0.0.15.Final9.4.48.v202206222.5.22.34
@@ -138,8 +138,9 @@ flexible messaging model and an intuitive client API.
4.42.18.01.69
- 1.0.2
- 2.13.4
+ 1.0.6
+ 1.0.2.3
+ 2.13.4.202210130.9.111.6.28.37
@@ -174,10 +175,10 @@ flexible messaging model and an intuitive client API.
3.3.32.4.71.2.4
- 8.1.0
+ 8.5.23632.13
- 1.9.5.Final
+ 1.9.7.Final42.5.08.0.300.11.1
@@ -199,14 +200,14 @@ flexible messaging model and an intuitive client API.
2.12.1.93.1.0
- 2.9.1
+ 3.1.20.9.02.14.63.21.00.9.12.1.03.18.1
- 1.18.22
+ 1.18.241.3.22.3.11.2.0
@@ -234,13 +235,13 @@ flexible messaging model and an intuitive client API.
2.0.6
- 1.17.2
+ 1.17.62.23.2.131.1.1
- 7.3.0
+ 7.6.13.12.43.25.0-GA1.5.0
@@ -248,11 +249,12 @@ flexible messaging model and an intuitive client API.
4.2.01.2.221.5.1
+ 2.33.20.6.13.0.0
- 4.0.rc2
+ 4.11.03.1.0
@@ -282,6 +284,7 @@ flexible messaging model and an intuitive client API.
7.1.00.9.151.6.1
+ 1.18.20.0rename-netty-native-libs.sh
@@ -290,6 +293,12 @@ flexible messaging model and an intuitive client API.
+
+ org.jline
+ jline
+ ${jline3.version}
+
+
org.asynchttpclientasync-http-client
@@ -624,15 +633,26 @@ flexible messaging model and an intuitive client API.
- io.netty
- netty-tcnative-boringssl-static
- ${netty-tc-native.version}
+ io.netty.incubator
+ netty-incubator-transport-classes-io_uring
+ ${netty-iouring.version}
-
- io.netty
- netty-codec-haproxy
- ${netty.version}
+ io.netty.incubator
+ netty-incubator-transport-native-io_uring
+ ${netty-iouring.version}
+
+
+ io.netty.incubator
+ netty-incubator-transport-native-io_uring
+ ${netty-iouring.version}
+ linux-x86_64
+
+
+ io.netty.incubator
+ netty-incubator-transport-native-io_uring
+ ${netty-iouring.version}
+ linux-aarch_64
@@ -683,6 +703,12 @@ flexible messaging model and an intuitive client API.
${commons-io.version}
+
+ org.apache.commons
+ commons-text
+ ${commons-text.version}
+
+
org.slf4jslf4j-api
@@ -1404,13 +1430,6 @@ flexible messaging model and an intuitive client API.
org.apache.maven.pluginsmaven-checkstyle-plugin
-
-
- org.apache.pulsar
- buildtools
- ${project.version}
-
- org.apache.maven.plugins
@@ -1548,7 +1567,7 @@ flexible messaging model and an intuitive client API.
- JAVADOC_STYLE
+ SLASHSTAR_STYLEJAVADOC_STYLEDOUBLESLASH_STYLESCRIPT_STYLE
@@ -1793,8 +1812,22 @@ flexible messaging model and an intuitive client API.
nonetrue
+ ${project.build.directory}/generated-sources/delombok
+
+ org.projectlombok
+ lombok-maven-plugin
+ ${lombok.plugin.version}
+
+
+ generate-sources
+
+ delombok
+
+
+
+ maven-antrun-plugin${maven-antrun-plugin.version}
@@ -2058,7 +2091,6 @@ flexible messaging model and an intuitive client API.
pulsar-commonpulsar-broker-commonpulsar-broker
- pulsar-broker-shadedpulsar-client-apipulsar-clientpulsar-client-shaded
diff --git a/pulsar-broker-auth-athenz/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderAthenz.java b/pulsar-broker-auth-athenz/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderAthenz.java
index 4a82e54962338..2e062b87a8325 100644
--- a/pulsar-broker-auth-athenz/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderAthenz.java
+++ b/pulsar-broker-auth-athenz/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderAthenz.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-auth-athenz/src/main/java/org/apache/pulsar/broker/authentication/package-info.java b/pulsar-broker-auth-athenz/src/main/java/org/apache/pulsar/broker/authentication/package-info.java
index 025caadc09bbf..e6fd55da98e5c 100644
--- a/pulsar-broker-auth-athenz/src/main/java/org/apache/pulsar/broker/authentication/package-info.java
+++ b/pulsar-broker-auth-athenz/src/main/java/org/apache/pulsar/broker/authentication/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-auth-athenz/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationProviderAthenzTest.java b/pulsar-broker-auth-athenz/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationProviderAthenzTest.java
index f1cc632ec0236..89ee5ca083079 100644
--- a/pulsar-broker-auth-athenz/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationProviderAthenzTest.java
+++ b/pulsar-broker-auth-athenz/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationProviderAthenzTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-auth-sasl/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderSasl.java b/pulsar-broker-auth-sasl/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderSasl.java
index 0e090c638c135..93f7d3f420699 100644
--- a/pulsar-broker-auth-sasl/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderSasl.java
+++ b/pulsar-broker-auth-sasl/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderSasl.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-auth-sasl/src/main/java/org/apache/pulsar/broker/authentication/PulsarSaslServer.java b/pulsar-broker-auth-sasl/src/main/java/org/apache/pulsar/broker/authentication/PulsarSaslServer.java
index 92c026ce601cc..7f99d677a980d 100644
--- a/pulsar-broker-auth-sasl/src/main/java/org/apache/pulsar/broker/authentication/PulsarSaslServer.java
+++ b/pulsar-broker-auth-sasl/src/main/java/org/apache/pulsar/broker/authentication/PulsarSaslServer.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.pulsar.broker.authentication;
import java.io.IOException;
diff --git a/pulsar-broker-auth-sasl/src/main/java/org/apache/pulsar/broker/authentication/SaslAuthenticationDataSource.java b/pulsar-broker-auth-sasl/src/main/java/org/apache/pulsar/broker/authentication/SaslAuthenticationDataSource.java
index f023556bc2bac..1ace01aee0238 100644
--- a/pulsar-broker-auth-sasl/src/main/java/org/apache/pulsar/broker/authentication/SaslAuthenticationDataSource.java
+++ b/pulsar-broker-auth-sasl/src/main/java/org/apache/pulsar/broker/authentication/SaslAuthenticationDataSource.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-auth-sasl/src/main/java/org/apache/pulsar/broker/authentication/SaslAuthenticationState.java b/pulsar-broker-auth-sasl/src/main/java/org/apache/pulsar/broker/authentication/SaslAuthenticationState.java
index f089ed77df715..862e171043ce7 100644
--- a/pulsar-broker-auth-sasl/src/main/java/org/apache/pulsar/broker/authentication/SaslAuthenticationState.java
+++ b/pulsar-broker-auth-sasl/src/main/java/org/apache/pulsar/broker/authentication/SaslAuthenticationState.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.pulsar.broker.authentication;
import java.util.concurrent.atomic.AtomicLong;
diff --git a/pulsar-broker-auth-sasl/src/main/java/org/apache/pulsar/broker/authentication/SaslRoleToken.java b/pulsar-broker-auth-sasl/src/main/java/org/apache/pulsar/broker/authentication/SaslRoleToken.java
index 7795fa75e76d9..452f1e352d2ca 100644
--- a/pulsar-broker-auth-sasl/src/main/java/org/apache/pulsar/broker/authentication/SaslRoleToken.java
+++ b/pulsar-broker-auth-sasl/src/main/java/org/apache/pulsar/broker/authentication/SaslRoleToken.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-auth-sasl/src/main/java/org/apache/pulsar/broker/authentication/SaslRoleTokenSigner.java b/pulsar-broker-auth-sasl/src/main/java/org/apache/pulsar/broker/authentication/SaslRoleTokenSigner.java
index 6ded38132e1ad..c979566e485ce 100644
--- a/pulsar-broker-auth-sasl/src/main/java/org/apache/pulsar/broker/authentication/SaslRoleTokenSigner.java
+++ b/pulsar-broker-auth-sasl/src/main/java/org/apache/pulsar/broker/authentication/SaslRoleTokenSigner.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-auth-sasl/src/main/java/org/apache/pulsar/broker/authentication/package-info.java b/pulsar-broker-auth-sasl/src/main/java/org/apache/pulsar/broker/authentication/package-info.java
index 025caadc09bbf..e6fd55da98e5c 100644
--- a/pulsar-broker-auth-sasl/src/main/java/org/apache/pulsar/broker/authentication/package-info.java
+++ b/pulsar-broker-auth-sasl/src/main/java/org/apache/pulsar/broker/authentication/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-auth-sasl/src/test/java/org/apache/pulsar/broker/authentication/MiniKdc.java b/pulsar-broker-auth-sasl/src/test/java/org/apache/pulsar/broker/authentication/MiniKdc.java
index 4d4cd3748309f..4e095a32b03bf 100644
--- a/pulsar-broker-auth-sasl/src/test/java/org/apache/pulsar/broker/authentication/MiniKdc.java
+++ b/pulsar-broker-auth-sasl/src/test/java/org/apache/pulsar/broker/authentication/MiniKdc.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.pulsar.broker.authentication;
import java.io.File;
diff --git a/pulsar-broker-auth-sasl/src/test/java/org/apache/pulsar/broker/authentication/ProxySaslAuthenticationTest.java b/pulsar-broker-auth-sasl/src/test/java/org/apache/pulsar/broker/authentication/ProxySaslAuthenticationTest.java
index 66737c80de878..261efe680f862 100644
--- a/pulsar-broker-auth-sasl/src/test/java/org/apache/pulsar/broker/authentication/ProxySaslAuthenticationTest.java
+++ b/pulsar-broker-auth-sasl/src/test/java/org/apache/pulsar/broker/authentication/ProxySaslAuthenticationTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -25,6 +25,7 @@
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Paths;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Optional;
@@ -36,7 +37,6 @@
import lombok.Cleanup;
import org.apache.commons.io.FileUtils;
-import org.apache.curator.shaded.com.google.common.collect.Maps;
import org.apache.pulsar.client.admin.PulsarAdmin;
import org.apache.pulsar.client.api.Authentication;
import org.apache.pulsar.client.api.AuthenticationFactory;
@@ -199,7 +199,7 @@ protected void setup() throws Exception {
lookupUrl = new URI(pulsar.getBrokerServiceUrl());
// set admin auth, to verify admin web resources
- Map clientSaslConfig = Maps.newHashMap();
+ Map clientSaslConfig = new HashMap<>();
clientSaslConfig.put("saslJaasClientSectionName", "PulsarClient");
clientSaslConfig.put("serverType", "broker");
log.info("set client jaas section name: PulsarClient");
@@ -295,7 +295,7 @@ void testAuthentication() throws Exception {
}
private PulsarClient createProxyClient(String proxyServiceUrl, int numberOfConnections) throws PulsarClientException {
- Map clientSaslConfig = Maps.newHashMap();
+ Map clientSaslConfig = new HashMap<>();
clientSaslConfig.put("saslJaasClientSectionName", "PulsarClient");
clientSaslConfig.put("serverType", "proxy");
log.info("set client jaas section name: PulsarClient, serverType: proxy");
diff --git a/pulsar-broker-auth-sasl/src/test/java/org/apache/pulsar/broker/authentication/SaslAuthenticateTest.java b/pulsar-broker-auth-sasl/src/test/java/org/apache/pulsar/broker/authentication/SaslAuthenticateTest.java
index f7fc4abaf808a..9965a2c085985 100644
--- a/pulsar-broker-auth-sasl/src/test/java/org/apache/pulsar/broker/authentication/SaslAuthenticateTest.java
+++ b/pulsar-broker-auth-sasl/src/test/java/org/apache/pulsar/broker/authentication/SaslAuthenticateTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.pulsar.broker.authentication;
import static org.testng.Assert.assertFalse;
@@ -29,6 +28,7 @@
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Paths;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Properties;
@@ -40,7 +40,6 @@
import com.google.common.collect.ImmutableSet;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
-import org.apache.curator.shaded.com.google.common.collect.Maps;
import org.apache.pulsar.client.admin.PulsarAdmin;
import org.apache.pulsar.client.api.Authentication;
import org.apache.pulsar.client.api.AuthenticationDataProvider;
@@ -141,7 +140,7 @@ public static void startMiniKdc() throws Exception {
Configuration.getConfiguration().refresh();
// Client config
- Map clientSaslConfig = Maps.newHashMap();
+ Map clientSaslConfig = new HashMap<>();
clientSaslConfig.put("saslJaasClientSectionName", "PulsarClient");
clientSaslConfig.put("serverType", "broker");
log.info("set client jaas section name: PulsarClient");
@@ -192,7 +191,7 @@ protected void setup() throws Exception {
.authentication(authSasl));
// set admin auth, to verify admin web resources
- Map clientSaslConfig = Maps.newHashMap();
+ Map clientSaslConfig = new HashMap<>();
clientSaslConfig.put("saslJaasClientSectionName", "PulsarClient");
clientSaslConfig.put("serverType", "broker");
log.info("set client jaas section name: PulsarClient");
diff --git a/pulsar-broker-auth-sasl/src/test/java/org/apache/pulsar/broker/authentication/SaslServerTokenSignerTest.java b/pulsar-broker-auth-sasl/src/test/java/org/apache/pulsar/broker/authentication/SaslServerTokenSignerTest.java
index f0381580deecd..b99c46c6573ea 100644
--- a/pulsar-broker-auth-sasl/src/test/java/org/apache/pulsar/broker/authentication/SaslServerTokenSignerTest.java
+++ b/pulsar-broker-auth-sasl/src/test/java/org/apache/pulsar/broker/authentication/SaslServerTokenSignerTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.pulsar.broker.authentication;
import javax.naming.AuthenticationException;
diff --git a/pulsar-broker-common/pom.xml b/pulsar-broker-common/pom.xml
index ccebe3f6906c7..8146dc83fa8ba 100644
--- a/pulsar-broker-common/pom.xml
+++ b/pulsar-broker-common/pom.xml
@@ -73,7 +73,7 @@
org.bouncycastlebc-fips
- ${bouncycastlefips.version}
+ ${bouncycastle.bc-fips.version}test
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/bookie/rackawareness/BookieRackAffinityMapping.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/bookie/rackawareness/BookieRackAffinityMapping.java
index 3354d823adc05..6602dfcd04970 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/bookie/rackawareness/BookieRackAffinityMapping.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/bookie/rackawareness/BookieRackAffinityMapping.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/bookie/rackawareness/ConfigurationStringUtil.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/bookie/rackawareness/ConfigurationStringUtil.java
index 99736b4f2f4a8..2d6f77d7598ab 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/bookie/rackawareness/ConfigurationStringUtil.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/bookie/rackawareness/ConfigurationStringUtil.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.pulsar.bookie.rackawareness;
import java.util.ArrayList;
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/bookie/rackawareness/IsolatedBookieEnsemblePlacementPolicy.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/bookie/rackawareness/IsolatedBookieEnsemblePlacementPolicy.java
index 9e6affbb7ef36..9e416985ec553 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/bookie/rackawareness/IsolatedBookieEnsemblePlacementPolicy.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/bookie/rackawareness/IsolatedBookieEnsemblePlacementPolicy.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/bookie/rackawareness/package-info.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/bookie/rackawareness/package-info.java
index fd1f46466bbf9..18616b10ac599 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/bookie/rackawareness/package-info.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/bookie/rackawareness/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/BitRateUnit.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/BitRateUnit.java
index 7e0d0dcfda1cc..8bf04d7c2c451 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/BitRateUnit.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/BitRateUnit.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ClassLoaderSwitcher.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ClassLoaderSwitcher.java
index 787182ef012bc..55cb9198da2bc 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ClassLoaderSwitcher.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ClassLoaderSwitcher.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/MetadataSessionExpiredPolicy.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/MetadataSessionExpiredPolicy.java
index 5038912851177..97c37e902d4e3 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/MetadataSessionExpiredPolicy.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/MetadataSessionExpiredPolicy.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/PulsarServerException.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/PulsarServerException.java
index 1fd1d0770213a..2235b9a7128b8 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/PulsarServerException.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/PulsarServerException.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
index 8ba741801043b..d7617ef277444 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -58,6 +58,7 @@
*/
@Getter
@Setter
+@ToString
public class ServiceConfiguration implements PulsarConfiguration {
@Category
@@ -643,12 +644,14 @@ The delayed message index bucket time step(in seconds) in per bucket snapshot se
@FieldContext(
category = CATEGORY_POLICIES,
+ dynamic = true,
doc = "Allow forced deletion of tenants. Default is false."
)
private boolean forceDeleteTenantAllowed = false;
@FieldContext(
category = CATEGORY_POLICIES,
+ dynamic = true,
doc = "Allow forced deletion of namespaces. Default is false."
)
private boolean forceDeleteNamespaceAllowed = false;
@@ -1861,6 +1864,12 @@ The delayed message index bucket time step(in seconds) in per bucket snapshot se
@FieldContext(category = CATEGORY_STORAGE_ML, doc = "Whether we should make a copy of the entry payloads when "
+ "inserting in cache")
private boolean managedLedgerCacheCopyEntries = false;
+
+ @FieldContext(category = CATEGORY_STORAGE_ML, doc = "Maximum buffer size for bytes read from storage."
+ + " This is the memory retained by data read from storage (or cache) until it has been delivered to the"
+ + " Consumer Netty channel. Use O to disable")
+ private long managedLedgerMaxReadsInFlightSizeInMB = 0;
+
@FieldContext(
category = CATEGORY_STORAGE_ML,
dynamic = true,
@@ -1960,6 +1969,11 @@ The delayed message index bucket time step(in seconds) in per bucket snapshot se
doc = "The number of bytes before triggering automatic offload to long term storage"
)
private long managedLedgerOffloadAutoTriggerSizeThresholdBytes = -1L;
+ @FieldContext(
+ category = CATEGORY_STORAGE_OFFLOADING,
+ doc = "The threshold to triggering automatic offload to long term storage"
+ )
+ private long managedLedgerOffloadThresholdInSeconds = -1L;
@FieldContext(
category = CATEGORY_STORAGE_ML,
doc = "Max number of entries to append to a cursor ledger"
@@ -2658,6 +2672,7 @@ The delayed message index bucket time step(in seconds) in per bucket snapshot se
private boolean splitTopicAndPartitionLabelInPrometheus = false;
@FieldContext(
+ dynamic = true,
category = CATEGORY_METRICS,
doc = "Enable expose the broker bundles metrics."
)
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfigurationUtils.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfigurationUtils.java
index 7507181f34bdd..b5a0af97f8f10 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfigurationUtils.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfigurationUtils.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ShutdownService.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ShutdownService.java
index 37aa365a2ab8e..69ac157aa1265 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ShutdownService.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ShutdownService.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationDataCommand.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationDataCommand.java
index 0bd03d5daf686..9dd666b4cb1bd 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationDataCommand.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationDataCommand.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationDataHttp.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationDataHttp.java
index f48dbc263e0e6..876dfb87fc582 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationDataHttp.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationDataHttp.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationDataHttps.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationDataHttps.java
index ec4dc292c13ce..31328df35d2eb 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationDataHttps.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationDataHttps.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationDataSource.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationDataSource.java
index 453fafbab3244..4a159b16e3fd8 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationDataSource.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationDataSource.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationDataSubscription.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationDataSubscription.java
index f6723609908ac..69ef526012daa 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationDataSubscription.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationDataSubscription.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProvider.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProvider.java
index 840b5cb057db6..9e7b25930e0be 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProvider.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProvider.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderBasic.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderBasic.java
index 9f6bacf729891..3c4759fec7da9 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderBasic.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderBasic.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.pulsar.broker.authentication;
import java.io.BufferedReader;
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderList.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderList.java
index f921a6f1e0918..f3712168104ba 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderList.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderList.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderTls.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderTls.java
index 4cfcad6a68695..47e5316bce9ce 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderTls.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderTls.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderToken.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderToken.java
index 9cc220aa8c75b..7fe20d5c5421a 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderToken.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderToken.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationService.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationService.java
index 6fe6c5f8e7ca7..c63f5505e5974 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationService.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationService.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -87,7 +87,6 @@ public AuthenticationService(ServiceConfiguration conf) throws PulsarServerExcep
public String authenticateHttpRequest(HttpServletRequest request, AuthenticationDataSource authData)
throws AuthenticationException {
- AuthenticationException authenticationException = null;
String authMethodName = request.getHeader(AuthenticationFilter.PULSAR_AUTH_METHOD_NAME);
if (authMethodName != null) {
@@ -108,8 +107,6 @@ public String authenticateHttpRequest(HttpServletRequest request, Authentication
LOG.debug("Authentication failed for provider " + providerToUse.getAuthMethodName() + " : "
+ e.getMessage(), e);
}
- // Store the exception so we can throw it later instead of a generic one
- authenticationException = e;
throw e;
}
} else {
@@ -133,11 +130,7 @@ public String authenticateHttpRequest(HttpServletRequest request, Authentication
return anonymousUserRole;
}
// If at least a provider was configured, then the authentication needs to be provider
- if (authenticationException != null) {
- throw authenticationException;
- } else {
- throw new AuthenticationException("Authentication required");
- }
+ throw new AuthenticationException("Authentication required");
} else {
// No authentication required
return "";
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationState.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationState.java
index 0e5dcc3121f27..469a3fbe3e9de 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationState.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationState.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.pulsar.broker.authentication;
import java.util.concurrent.CompletableFuture;
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/OneStageAuthenticationState.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/OneStageAuthenticationState.java
index 6e5b889ff3c9c..a355ce959562f 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/OneStageAuthenticationState.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/OneStageAuthenticationState.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.pulsar.broker.authentication;
import static java.nio.charset.StandardCharsets.UTF_8;
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/metrics/AuthenticationMetrics.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/metrics/AuthenticationMetrics.java
index b4ae44e200d01..0a095235f3cb3 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/metrics/AuthenticationMetrics.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/metrics/AuthenticationMetrics.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/metrics/package-info.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/metrics/package-info.java
index 068c693b9c395..acfc53788ee10 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/metrics/package-info.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/metrics/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/package-info.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/package-info.java
index e4432e5951756..3104a84ec7f22 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/package-info.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/utils/AuthTokenUtils.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/utils/AuthTokenUtils.java
index 12063d3f0528e..cb917a9e0bf00 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/utils/AuthTokenUtils.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/utils/AuthTokenUtils.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/utils/package-info.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/utils/package-info.java
index 5492a2dea9d6c..4bdf8e66bc47c 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/utils/package-info.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/utils/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authorization/AuthorizationProvider.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authorization/AuthorizationProvider.java
index 12a54d502f4cb..9adc212019d63 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authorization/AuthorizationProvider.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authorization/AuthorizationProvider.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authorization/AuthorizationService.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authorization/AuthorizationService.java
index 3baaf57990a9a..9e9e2e832385c 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authorization/AuthorizationService.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authorization/AuthorizationService.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authorization/MultiRolesTokenAuthorizationProvider.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authorization/MultiRolesTokenAuthorizationProvider.java
index d77288e30850f..fa613245cfa27 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authorization/MultiRolesTokenAuthorizationProvider.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authorization/MultiRolesTokenAuthorizationProvider.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authorization/PulsarAuthorizationProvider.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authorization/PulsarAuthorizationProvider.java
index de586345fd0da..a43591dd1d94f 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authorization/PulsarAuthorizationProvider.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authorization/PulsarAuthorizationProvider.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -554,6 +554,7 @@ public CompletableFuture allowTopicOperationAsync(TopicName topicName,
case OFFLOAD:
case UNLOAD:
case DELETE_METADATA:
+ case UPDATE_METADATA:
case ADD_BUNDLE_RANGE:
case GET_BUNDLE_RANGE:
case DELETE_BUNDLE_RANGE:
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authorization/package-info.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authorization/package-info.java
index 26c9419d8e36e..d17d8d91f0adb 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authorization/package-info.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authorization/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/cache/ConfigurationCacheService.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/cache/ConfigurationCacheService.java
index ad820b36aebee..7fc9ea8d3f1a2 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/cache/ConfigurationCacheService.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/cache/ConfigurationCacheService.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/cache/package-info.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/cache/package-info.java
index 83e11fdf2c61b..5d8fe448344ef 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/cache/package-info.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/cache/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/limiter/ConnectionController.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/limiter/ConnectionController.java
index 609d0cc19071c..fcf010a04816c 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/limiter/ConnectionController.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/limiter/ConnectionController.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/limiter/package-info.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/limiter/package-info.java
index 9483f3427982c..db36dc5e66e19 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/limiter/package-info.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/limiter/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/package-info.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/package-info.java
index cf095a74f8d9b..4df99bf52ada3 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/package-info.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/BaseResources.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/BaseResources.java
index 31409e3789076..e705581a9d54d 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/BaseResources.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/BaseResources.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/BookieResources.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/BookieResources.java
index 32c0e7a395e80..23befce463877 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/BookieResources.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/BookieResources.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/BrokerResources.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/BrokerResources.java
index 9ba2f6ef51b88..77fc2f3e69f8c 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/BrokerResources.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/BrokerResources.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/ClusterResources.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/ClusterResources.java
index 5bde79e632113..843cec7b20594 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/ClusterResources.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/ClusterResources.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/DynamicConfigurationResources.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/DynamicConfigurationResources.java
index c142e0896a132..2c9823bd84e27 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/DynamicConfigurationResources.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/DynamicConfigurationResources.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/LoadManagerReportResources.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/LoadManagerReportResources.java
index acc5e23869d12..c3ecc1cf3fac0 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/LoadManagerReportResources.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/LoadManagerReportResources.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/LocalPoliciesResources.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/LocalPoliciesResources.java
index 6432bfbac7835..797eb089cbefb 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/LocalPoliciesResources.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/LocalPoliciesResources.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/MetadataStoreCacheLoader.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/MetadataStoreCacheLoader.java
index eada0db382dcb..43376f4055063 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/MetadataStoreCacheLoader.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/MetadataStoreCacheLoader.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/NamespaceResources.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/NamespaceResources.java
index 2223e951f6628..899cf01bc4bfc 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/NamespaceResources.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/NamespaceResources.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -26,18 +26,17 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
+import java.util.function.Supplier;
import java.util.stream.Collectors;
import lombok.Getter;
import org.apache.pulsar.common.naming.NamespaceName;
import org.apache.pulsar.common.naming.TopicDomain;
import org.apache.pulsar.common.naming.TopicName;
import org.apache.pulsar.common.partition.PartitionedTopicMetadata;
-import org.apache.pulsar.common.policies.data.LocalPolicies;
import org.apache.pulsar.common.policies.data.NamespaceIsolationDataImpl;
import org.apache.pulsar.common.policies.data.Policies;
import org.apache.pulsar.common.policies.impl.NamespaceIsolationPolicies;
import org.apache.pulsar.common.util.Codec;
-import org.apache.pulsar.metadata.api.MetadataCache;
import org.apache.pulsar.metadata.api.MetadataStore;
import org.apache.pulsar.metadata.api.MetadataStoreException;
import org.slf4j.Logger;
@@ -51,23 +50,15 @@ public class NamespaceResources extends BaseResources {
private final PartitionedTopicResources partitionedTopicResources;
private final MetadataStore configurationStore;
- private final MetadataCache localPoliciesCache;
-
private static final String POLICIES_READONLY_FLAG_PATH = "/admin/flags/policies-readonly";
private static final String NAMESPACE_BASE_PATH = "/namespace";
private static final String BUNDLE_DATA_BASE_PATH = "/loadbalance/bundle-data";
- public NamespaceResources(MetadataStore localStore, MetadataStore configurationStore, int operationTimeoutSec) {
+ public NamespaceResources(MetadataStore configurationStore, int operationTimeoutSec) {
super(configurationStore, Policies.class, operationTimeoutSec);
this.configurationStore = configurationStore;
isolationPolicies = new IsolationPolicyResources(configurationStore, operationTimeoutSec);
partitionedTopicResources = new PartitionedTopicResources(configurationStore, operationTimeoutSec);
-
- if (localStore != null) {
- localPoliciesCache = localStore.getMetadataCache(LocalPolicies.class);
- } else {
- localPoliciesCache = null;
- }
}
public CompletableFuture> listNamespacesAsync(String tenant) {
@@ -295,6 +286,79 @@ public CompletableFuture clearPartitionedTopicTenantAsync(String tenant) {
final String partitionedTopicPath = joinPath(PARTITIONED_TOPIC_PATH, tenant);
return deleteIfExistsAsync(partitionedTopicPath);
}
+
+ public CompletableFuture markPartitionedTopicDeletedAsync(TopicName tn) {
+ if (tn.isPartitioned()) {
+ return CompletableFuture.completedFuture(null);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("markPartitionedTopicDeletedAsync {}", tn);
+ }
+ return updatePartitionedTopicAsync(tn, md -> {
+ md.deleted = true;
+ return md;
+ });
+ }
+
+ public CompletableFuture unmarkPartitionedTopicDeletedAsync(TopicName tn) {
+ if (tn.isPartitioned()) {
+ return CompletableFuture.completedFuture(null);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("unmarkPartitionedTopicDeletedAsync {}", tn);
+ }
+ return updatePartitionedTopicAsync(tn, md -> {
+ md.deleted = false;
+ return md;
+ });
+ }
+
+ public CompletableFuture isPartitionedTopicBeingDeletedAsync(TopicName tn) {
+ if (tn.isPartitioned()) {
+ tn = TopicName.get(tn.getPartitionedTopicName());
+ }
+ return getPartitionedTopicMetadataAsync(tn)
+ .thenApply(mdOpt -> mdOpt.map(partitionedTopicMetadata -> partitionedTopicMetadata.deleted)
+ .orElse(false));
+ }
+
+ public CompletableFuture runWithMarkDeleteAsync(TopicName topic,
+ Supplier> supplier) {
+ CompletableFuture future = new CompletableFuture<>();
+
+ markPartitionedTopicDeletedAsync(topic).whenCompleteAsync((markResult, markExc) -> {
+ final boolean mdFound;
+ if (markExc != null) {
+ if (markExc.getCause() instanceof MetadataStoreException.NotFoundException) {
+ mdFound = false;
+ } else {
+ log.error("Failed to mark the topic {} as deleted", topic, markExc);
+ future.completeExceptionally(markExc);
+ return;
+ }
+ } else {
+ mdFound = true;
+ }
+
+ supplier.get().whenComplete((deleteResult, deleteExc) -> {
+ if (deleteExc != null && mdFound) {
+ unmarkPartitionedTopicDeletedAsync(topic)
+ .thenRun(() -> future.completeExceptionally(deleteExc))
+ .exceptionally(ex -> {
+ log.warn("Failed to unmark the topic {} as deleted", topic, ex);
+ future.completeExceptionally(deleteExc);
+ return null;
+ });
+ } else if (deleteExc != null) {
+ future.completeExceptionally(deleteExc);
+ } else {
+ future.complete(deleteResult);
+ }
+ });
+ });
+
+ return future;
+ }
}
// clear resource of `/loadbalance/bundle-data/{tenant}/{namespace}/` in metadata-store
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/PulsarResources.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/PulsarResources.java
index 9cfeddd123d80..161a44703a703 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/PulsarResources.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/PulsarResources.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -60,8 +60,7 @@ public PulsarResources(MetadataStore localMetadataStore, MetadataStore configura
if (configurationMetadataStore != null) {
tenantResources = new TenantResources(configurationMetadataStore, operationTimeoutSec);
clusterResources = new ClusterResources(configurationMetadataStore, operationTimeoutSec);
- namespaceResources = new NamespaceResources(localMetadataStore, configurationMetadataStore,
- operationTimeoutSec);
+ namespaceResources = new NamespaceResources(configurationMetadataStore, operationTimeoutSec);
resourcegroupResources = new ResourceGroupResources(configurationMetadataStore, operationTimeoutSec);
} else {
tenantResources = null;
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/ResourceGroupResources.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/ResourceGroupResources.java
index 414bf4ffcfc35..578609b21958f 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/ResourceGroupResources.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/ResourceGroupResources.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/TenantResources.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/TenantResources.java
index 87f48f7e682a4..f82ea0da2c04c 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/TenantResources.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/TenantResources.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/TopicResources.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/TopicResources.java
index ee537431280f3..840ced0a1c1c4 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/TopicResources.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/TopicResources.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -19,8 +19,6 @@
package org.apache.pulsar.broker.resources;
import static org.apache.pulsar.common.util.Codec.decode;
-import java.util.EnumSet;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -30,6 +28,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
+import lombok.extern.slf4j.Slf4j;
import org.apache.pulsar.common.naming.NamespaceName;
import org.apache.pulsar.common.naming.TopicDomain;
import org.apache.pulsar.common.naming.TopicName;
@@ -37,6 +36,7 @@
import org.apache.pulsar.metadata.api.Notification;
import org.apache.pulsar.metadata.api.NotificationType;
+@Slf4j
public class TopicResources {
private static final String MANAGED_LEDGER_PATH = "/managed-ledgers";
@@ -125,10 +125,14 @@ public CompletableFuture clearTenantPersistence(String tenant) {
}
void handleNotification(Notification notification) {
+ if (topicListeners.isEmpty()) {
+ return;
+ }
if (notification.getPath().startsWith(MANAGED_LEDGER_PATH)
- && EnumSet.of(NotificationType.Created, NotificationType.Deleted).contains(notification.getType())) {
+ && (notification.getType() == NotificationType.Created
+ || notification.getType() == NotificationType.Deleted)) {
for (Map.Entry, Pattern> entry :
- new HashMap<>(topicListeners).entrySet()) {
+ topicListeners.entrySet()) {
Matcher matcher = entry.getValue().matcher(notification.getPath());
if (matcher.matches()) {
TopicName topicName = TopicName.get(
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/package-info.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/package-info.java
index 94cd53aed5797..e23a45fc39fd5 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/package-info.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsGeneratorUtils.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsGeneratorUtils.java
index c2aa40e030d80..4b0cf76f2276b 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsGeneratorUtils.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsGeneratorUtils.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsServlet.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsServlet.java
index 1c3277d5ee480..136fe77d77aff 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsServlet.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsServlet.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -66,7 +66,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) {
HttpServletResponse res = (HttpServletResponse) context.getResponse();
try {
res.setStatus(HTTP_STATUS_OK_200);
- res.setContentType("text/plain");
+ res.setContentType("text/plain;charset=utf-8");
generateMetrics(cluster, res.getOutputStream());
} catch (Exception e) {
long end = System.currentTimeMillis();
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/stats/prometheus/PrometheusRawMetricsProvider.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/stats/prometheus/PrometheusRawMetricsProvider.java
index d2067766a41b7..fe232fc941b8c 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/stats/prometheus/PrometheusRawMetricsProvider.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/stats/prometheus/PrometheusRawMetricsProvider.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/stats/prometheus/package-info.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/stats/prometheus/package-info.java
index 3723fb4ff5c99..5289e0938e57b 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/stats/prometheus/package-info.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/stats/prometheus/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/validator/BindAddressValidator.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/validator/BindAddressValidator.java
index 00313c6048cc9..f417e0b59b78d 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/validator/BindAddressValidator.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/validator/BindAddressValidator.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/validator/MultipleListenerValidator.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/validator/MultipleListenerValidator.java
index 05688f0660b18..780203371ecdc 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/validator/MultipleListenerValidator.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/validator/MultipleListenerValidator.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/validator/package-info.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/validator/package-info.java
index 09ccc74260cef..7f1cdeda66ffc 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/validator/package-info.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/validator/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/AuthenticationFilter.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/AuthenticationFilter.java
index 6c69bce42685e..55265b21b3b1b 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/AuthenticationFilter.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/AuthenticationFilter.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/DisableDebugHttpMethodFilter.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/DisableDebugHttpMethodFilter.java
index 2bd68a7be0856..f51bd537f8769 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/DisableDebugHttpMethodFilter.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/DisableDebugHttpMethodFilter.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/DynamicSkipUnknownPropertyHandler.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/DynamicSkipUnknownPropertyHandler.java
index 3ebdbab761e35..af437e8c27f3f 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/DynamicSkipUnknownPropertyHandler.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/DynamicSkipUnknownPropertyHandler.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/JettyRequestLogFactory.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/JettyRequestLogFactory.java
index 8b9b507ee8b01..e5daa5852b51f 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/JettyRequestLogFactory.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/JettyRequestLogFactory.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/JsonMapperProvider.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/JsonMapperProvider.java
index f4c4fc1837d9d..0aa2d01adf11e 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/JsonMapperProvider.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/JsonMapperProvider.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/RateLimitingFilter.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/RateLimitingFilter.java
index b2c2b84bbdf79..502b691fa34b0 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/RateLimitingFilter.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/RateLimitingFilter.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.pulsar.broker.web;
import com.google.common.util.concurrent.RateLimiter;
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/UnrecognizedPropertyExceptionMapper.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/UnrecognizedPropertyExceptionMapper.java
index 6311157002425..6badf31bb1969 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/UnrecognizedPropertyExceptionMapper.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/UnrecognizedPropertyExceptionMapper.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/WebExecutorThreadPool.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/WebExecutorThreadPool.java
index c3cbe7a0ab6eb..a1d566e135cf6 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/WebExecutorThreadPool.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/WebExecutorThreadPool.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/package-info.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/package-info.java
index 5f61532b031b6..1c201419df475 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/package-info.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServlet.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServlet.java
index 21a00107c1bce..1ecf4c4e53943 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServlet.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServlet.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletDefinition.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletDefinition.java
index b8c407420de48..4f68889a74499 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletDefinition.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletDefinition.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletDefinitions.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletDefinitions.java
index b018c4ac6025b..e8ced486bfb57 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletDefinitions.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletDefinitions.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletMetadata.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletMetadata.java
index 4138d4ea8bab0..87a531032a3d7 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletMetadata.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletMetadata.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletUtils.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletUtils.java
index f7df7aaf7c39d..d79dbc2c44f6c 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletUtils.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletUtils.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletWithClassLoader.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletWithClassLoader.java
index 9ebbf8cf260dc..c2b4b90073391 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletWithClassLoader.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletWithClassLoader.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServlets.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServlets.java
index 4feef4c7a6fbc..0046d28afa444 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServlets.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServlets.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/package-info.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/package-info.java
index 8c3b3b2b8c828..71f2737abb426 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/package-info.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/plugin/servlet/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
/**
* Pulsar additional servlet plugin.
*/
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/BindAddress.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/BindAddress.java
index a5b4aa20b3126..633462d0dbe22 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/BindAddress.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/BindAddress.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/Category.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/Category.java
index 7a2c81e48f53c..5f3e01f526d7d 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/Category.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/Category.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/FieldContext.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/FieldContext.java
index 3c0ffb36ebfd5..839e1f9929e84 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/FieldContext.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/FieldContext.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/PropertiesContext.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/PropertiesContext.java
index 27f42775451ad..782e0d0749121 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/PropertiesContext.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/PropertiesContext.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/PropertyContext.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/PropertyContext.java
index 59657e728b335..cc5bbc65bec6c 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/PropertyContext.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/PropertyContext.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/PulsarConfiguration.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/PulsarConfiguration.java
index 7dbbffadcfebd..59e2a4bc78d76 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/PulsarConfiguration.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/PulsarConfiguration.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/PulsarConfigurationLoader.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/PulsarConfigurationLoader.java
index b0479d8158857..66b8e042675e2 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/PulsarConfigurationLoader.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/PulsarConfigurationLoader.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/VipStatus.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/VipStatus.java
index dcde2d02dd571..5e6a31b323f55 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/VipStatus.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/VipStatus.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/package-info.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/package-info.java
index 7306dab9a3b7a..7e2494b1537a7 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/package-info.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/common/configuration/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/jetty/package-info.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/jetty/package-info.java
index f01bd9198f568..05e3f33593f8c 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/jetty/package-info.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/jetty/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/jetty/tls/JettySslContextFactory.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/jetty/tls/JettySslContextFactory.java
index 514fa4a07250e..46a86045995f9 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/jetty/tls/JettySslContextFactory.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/jetty/tls/JettySslContextFactory.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/jetty/tls/package-info.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/jetty/tls/package-info.java
index 8978699ff7926..4e9cc9273b2d1 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/jetty/tls/package-info.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/jetty/tls/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/zookeeper/ZkBookieRackAffinityMapping.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/zookeeper/ZkBookieRackAffinityMapping.java
index 35438afb7d99b..e7688f5b7470d 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/zookeeper/ZkBookieRackAffinityMapping.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/zookeeper/ZkBookieRackAffinityMapping.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/zookeeper/ZkIsolatedBookieEnsemblePlacementPolicy.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/zookeeper/ZkIsolatedBookieEnsemblePlacementPolicy.java
index 2855957395f06..f85c355726e16 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/zookeeper/ZkIsolatedBookieEnsemblePlacementPolicy.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/zookeeper/ZkIsolatedBookieEnsemblePlacementPolicy.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/zookeeper/package-info.java b/pulsar-broker-common/src/main/java/org/apache/pulsar/zookeeper/package-info.java
index 5e129c634444f..18f76f21e54d5 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/zookeeper/package-info.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/zookeeper/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/bookie/rackawareness/BookieRackAffinityMappingTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/bookie/rackawareness/BookieRackAffinityMappingTest.java
index 8cbd0ebe9ca55..bbc0c9257fdaa 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/bookie/rackawareness/BookieRackAffinityMappingTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/bookie/rackawareness/BookieRackAffinityMappingTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/bookie/rackawareness/IsolatedBookieEnsemblePlacementPolicyTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/bookie/rackawareness/IsolatedBookieEnsemblePlacementPolicyTest.java
index 3ae5fd2b0eaaa..5ca946bbbb501 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/bookie/rackawareness/IsolatedBookieEnsemblePlacementPolicyTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/bookie/rackawareness/IsolatedBookieEnsemblePlacementPolicyTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/BitRateUnitTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/BitRateUnitTest.java
index 14adcc7027334..60f009a27ca2f 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/BitRateUnitTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/BitRateUnitTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationProviderBasicTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationProviderBasicTest.java
index fa72af76e8a34..723fde7083d38 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationProviderBasicTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationProviderBasicTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationProviderListTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationProviderListTest.java
index 7d7e0ca92f61a..98deee514a962 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationProviderListTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationProviderListTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationProviderTokenTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationProviderTokenTest.java
index c7ab278130021..82e8a8f87ee55 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationProviderTokenTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationProviderTokenTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authorization/MultiRolesTokenAuthorizationProviderTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authorization/MultiRolesTokenAuthorizationProviderTest.java
index ca80ee3aa3a38..7e329d14307c7 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authorization/MultiRolesTokenAuthorizationProviderTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/authorization/MultiRolesTokenAuthorizationProviderTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/resources/NamespaceResourcesTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/resources/NamespaceResourcesTest.java
index ba755572c214e..85f54a76dc3c4 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/resources/NamespaceResourcesTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/resources/NamespaceResourcesTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.pulsar.broker.resources;
import static org.testng.Assert.assertFalse;
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/resources/TopicResourcesTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/resources/TopicResourcesTest.java
index cfafc5107d2de..9a0fe5b9fce34 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/resources/TopicResourcesTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/resources/TopicResourcesTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsGeneratorUtilsTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsGeneratorUtilsTest.java
index 9bbfa5d771438..0ac3e22197606 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsGeneratorUtilsTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/stats/prometheus/PrometheusMetricsGeneratorUtilsTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/stats/prometheus/package-info.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/stats/prometheus/package-info.java
index 3723fb4ff5c99..5289e0938e57b 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/stats/prometheus/package-info.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/stats/prometheus/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/validator/BindAddressValidatorTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/validator/BindAddressValidatorTest.java
index ea36074a259a6..2e354acbdc823 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/validator/BindAddressValidatorTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/validator/BindAddressValidatorTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/validator/MultipleListenerValidatorTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/validator/MultipleListenerValidatorTest.java
index 5ec3858bc1bc2..5f5c536c93c86 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/validator/MultipleListenerValidatorTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/validator/MultipleListenerValidatorTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/DynamicSkipUnknownPropertyHandlerTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/DynamicSkipUnknownPropertyHandlerTest.java
index 2d7b8e7e78340..adf2b621d5381 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/DynamicSkipUnknownPropertyHandlerTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/DynamicSkipUnknownPropertyHandlerTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletUtilsTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletUtilsTest.java
index c1929eb09208e..e9d91dde26d7d 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletUtilsTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletUtilsTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletWithClassLoaderTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletWithClassLoaderTest.java
index 07ae5ec6790ad..2392b5e0528f5 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletWithClassLoaderTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletWithClassLoaderTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletsTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletsTest.java
index 0d5e6f5262be9..dd5045b1b09eb 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletsTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/AdditionalServletsTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -52,10 +52,8 @@ public void testEmptyStringAsExtractionDirectory() throws IOException {
AdditionalServletWithClassLoader as1 = mock(AdditionalServletWithClassLoader.class);
AdditionalServletWithClassLoader as2 = mock(AdditionalServletWithClassLoader.class);
- String originalTmpDirectory = System.getProperty("java.io.tmpdir");
try (MockedStatic utils = mockStatic(AdditionalServletUtils.class)) {
- String tmpDirectory = "/my/tmp/directory";
- System.setProperty("java.io.tmpdir", tmpDirectory);
+ String tmpDirectory = System.getProperty("java.io.tmpdir");
utils.when(() -> AdditionalServletUtils.searchForServlets(
"/additionalServletDirectory", tmpDirectory)).thenReturn(definitions);
utils.when(() -> AdditionalServletUtils.load(asm1, tmpDirectory)).thenReturn(as1);
@@ -65,8 +63,6 @@ public void testEmptyStringAsExtractionDirectory() throws IOException {
Assert.assertEquals(servlets.getServlets().get("AS1"), as1);
Assert.assertEquals(servlets.getServlets().get("AS2"), as2);
- } finally {
- System.setProperty("java.io.tmpdir", originalTmpDirectory);
}
}
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/MockAdditionalServlet.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/MockAdditionalServlet.java
index 05b955c31c975..22b8fa5ea35f5 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/MockAdditionalServlet.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/broker/web/plugin/servlet/MockAdditionalServlet.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/common/configuration/PulsarConfigurationLoaderTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/common/configuration/PulsarConfigurationLoaderTest.java
index 983816ec4f02f..afbec583b4d50 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/common/configuration/PulsarConfigurationLoaderTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/common/configuration/PulsarConfigurationLoaderTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/jetty/tls/JettySslContextFactoryTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/jetty/tls/JettySslContextFactoryTest.java
index c1816674880a7..bf91dab14fe1f 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/jetty/tls/JettySslContextFactoryTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/jetty/tls/JettySslContextFactoryTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.pulsar.jetty.tls;
import com.google.common.io.Resources;
diff --git a/pulsar-broker-common/src/test/java/org/apache/pulsar/jetty/tls/JettySslContextFactoryWithKeyStoreTest.java b/pulsar-broker-common/src/test/java/org/apache/pulsar/jetty/tls/JettySslContextFactoryWithKeyStoreTest.java
index c79ea6103d8e5..1d41cd3684124 100644
--- a/pulsar-broker-common/src/test/java/org/apache/pulsar/jetty/tls/JettySslContextFactoryWithKeyStoreTest.java
+++ b/pulsar-broker-common/src/test/java/org/apache/pulsar/jetty/tls/JettySslContextFactoryWithKeyStoreTest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker-shaded/pom.xml b/pulsar-broker-shaded/pom.xml
deleted file mode 100644
index c3dfc658aad88..0000000000000
--- a/pulsar-broker-shaded/pom.xml
+++ /dev/null
@@ -1,377 +0,0 @@
-
-
-
- 4.0.0
-
-
- org.apache.pulsar
- pulsar
- 2.11.0-SNAPSHOT
- ..
-
-
- pulsar-broker-shaded
- jar
- Pulsar Shaded Broker
-
-
-
- ${project.groupId}
- pulsar-broker
- ${project.parent.version}
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-dependency-plugin
-
-
- unpack
- prepare-package
-
- unpack
-
-
-
-
- org.asynchttpclient
- async-http-client
- ${asynchttpclient.version}
- jar
- true
- org/asynchttpclient/config/ahc-default.properties
- ${project.build.directory}/classes
-
-
-
-
-
-
-
-
- maven-antrun-plugin
-
-
- shade-ahc-properties
- prepare-package
-
- run
-
-
-
-
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-shade-plugin
-
-
- ${shadePluginPhase}
-
- shade
-
-
- true
- true
- false
-
-
-
- org.apache.pulsar:*
- org.apache.bookkeeper*:*
- commons-*:*
- org.apache.commons:*
- org.asynchttpclient:*
- org.reactivestreams:reactive-streams
- com.typesafe.netty:netty-reactive-streams
- org.javassist:javassist
- com.google.*:*
- com.fasterxml.jackson.*:*
- io.netty:*
- org.apache.pulsar:pulsar-common
- org.apache.bookkeeper:circe-checksum
- com.yahoo.datasketches:sketches-core
-
- javax.ws.rs:*
- javax.websocket:*
- org.glassfish.hk2*:*
- org.eclipse.jetty*:*
- net.java.dev.jna:*
- com.carrotsearch:*
- io.prometheus:*
- io.perfmark:*
- com.github.ben-manes.caffeine:*
- org.glassfish.jersey.*:*
- org.rocksdb:*
- org.apache.bookkeeper:*
- org.apache.zookeeper:*
- jline:*
- javax.servlet:*
-
- com.beust:*
- io.swagger:*
- joda-time:*
- org.yaml:snakeyaml
- org.hdrhistogram:*
- com.github.zafarkhaja:java-semver
- org.apache.avro:avro
-
- com.thoughtworks.paranamer:paranamer
- org.apache.commons:commons-compress
- org.tukaani:xz
-
-
-
-
- org.apache.pulsar:pulsar-client-original
-
- **
-
-
-
- org/bouncycastle/**
-
-
-
-
-
- org.asynchttpclient
- org.apache.pulsar.shade.org.asynchttpclient
-
-
- org.apache.commons
- org.apache.pulsar.shade.org.apache.commons
-
-
- com.google
- org.apache.pulsar.shade.com.google
-
-
- com.fasterxml.jackson
- org.apache.pulsar.shade.com.fasterxml.jackson
-
-
- io.netty
- org.apache.pulsar.shade.io.netty
-
-
- org.apache.pulsar.common
- org.apache.pulsar.shade.org.apache.pulsar.common
-
-
- org.apache.pulsar.policies
- org.apache.pulsar.shade.org.apache.pulsar.policies
-
-
- org.apache.pulsar.checksum
- org.apache.pulsar.shade.org.apache.pulsar.checksum
-
-
- com.yahoo.datasketches
- org.apache.pulsar.shade.com.yahoo.datasketches
-
-
- com.yahoo.sketches
- org.apache.pulsar.shade.com.yahoo.sketches
-
-
-
- org.apache.zookeeper
- org.apache.pulsar.shade.org.apache.zookeeper
-
-
- org.apache.jute
- org.apache.pulsar.shade.org.apache.jute
-
-
- com.typesafe
- org.apache.pulsar.shade.com.typesafe
-
-
- org.eclipse.jetty
- org.apache.pulsar.shade.org.eclipse.jetty
-
-
- javax.websocket
- org.apache.pulsar.shade.javax.websocket
-
-
- org.glassfish
- org.apache.pulsar.shade.org.glassfish
-
-
- org.apache.bookkeeper
- org.apache.pulsar.shade.org.apache.bookkeeper
-
-
- org.rocksdb
- org.apache.pulsar.shade.org.rocksdb
-
-
- com.sun.jna
- org.apache.pulsar.shade.com.sun.jna
-
-
- com.carrotsearch
- org.apache.pulsar.shade.com.carrotsearch
-
-
- javax.servlet
- org.apache.pulsar.shade.javax.servlet
-
-
- com.github
- org.apache.pulsar.shade.com.github
-
-
- jline
- org.apache.pulsar.shade.jline
-
-
- com.sun
- org.apache.pulsar.shade.com.sun
-
-
- jersey
- org.apache.pulsar.shade.jersey
-
-
- javax.ws
- org.apache.pulsar.shade.javax.ws
-
-
- javax.inject
- org.apache.pulsar.shade.javax.inject
-
-
- org.jvnet
- org.apache.pulsar.shade.org.jvnet
-
-
- com.beust
- org.apache.pulsar.shade.com.beust
-
-
- com.wordnik
- org.apache.pulsar.shade.com.worknik
-
-
- io.prometheus
- org.apache.pulsar.shade.io.prometheus
-
-
- io.swagger
- org.apache.pulsar.shade.io.swagger
-
-
- org.joda
- org.apache.pulsar.shade.org.joda
-
-
- org.yaml
- org.apache.pulsar.shade.org.yaml
-
-
- org.HdrHistogram
- org.apache.pulsar.shade.org.HdrHistogram
-
-
- com.ea
- org.apache.pulsar.shade.com.ea
-
-
- javassist
- org.apache.pulsar.shade.javassist
-
-
- org.reactivestreams
- org.apache.pulsar.shade.org.reactivestreams
-
-
- org.aopalliance
- org.apache.pulsar.shade.org.aopalliance
-
-
- com.wordnik
- org.apache.pulsar.shade.com.worknik
-
-
- org.apache.avro
- org.apache.pulsar.shade.org.apache.avro
-
-
-
- org.codehaus.jackson
- org.apache.pulsar.shade.org.codehaus.jackson
-
-
- com.thoughtworks.paranamer
- org.apache.pulsar.shade.com.thoughtworks.paranamer
-
-
- org.tukaani
- org.apache.pulsar.shade.org.tukaani
-
-
-
-
-
-
-
-
- exec-maven-plugin
- org.codehaus.mojo
-
-
- rename-epoll-library
- package
-
- exec
-
-
- ${project.parent.basedir}/src/${rename.netty.native.libs}
-
- ${project.artifactId}
-
-
-
-
-
-
-
-
diff --git a/pulsar-broker/pom.xml b/pulsar-broker/pom.xml
index a8e39ef7d2401..8d0f0e7547fc3 100644
--- a/pulsar-broker/pom.xml
+++ b/pulsar-broker/pom.xml
@@ -857,7 +857,7 @@
-
+
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarBrokerStarter.java b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarBrokerStarter.java
index 5f574356bf134..e5e50985491e3 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarBrokerStarter.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarBrokerStarter.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarClusterMetadataSetup.java b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarClusterMetadataSetup.java
index 1b4edf8686eac..6b0b4ed8d730c 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarClusterMetadataSetup.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarClusterMetadataSetup.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarClusterMetadataTeardown.java b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarClusterMetadataTeardown.java
index d0ba5c47f7502..cbbf909cdf7fa 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarClusterMetadataTeardown.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarClusterMetadataTeardown.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarInitialNamespaceSetup.java b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarInitialNamespaceSetup.java
index bb27be60b3512..c4020546d1c6c 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarInitialNamespaceSetup.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarInitialNamespaceSetup.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarStandalone.java b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarStandalone.java
index e0ebcc7657c2c..06147a1fb3b0f 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarStandalone.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarStandalone.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -23,6 +23,7 @@
import com.beust.jcommander.Parameter;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Sets;
+import io.netty.util.internal.PlatformDependent;
import java.io.File;
import java.nio.file.Paths;
import java.util.Optional;
@@ -434,16 +435,18 @@ public void close() {
}
}
- private void startBookieWithMetadataStore() throws Exception {
+ @VisibleForTesting
+ void startBookieWithMetadataStore() throws Exception {
if (StringUtils.isBlank(metadataStoreUrl)){
log.info("Starting BK with RocksDb metadata store");
metadataStoreUrl = "rocksdb://" + Paths.get(metadataDir).toAbsolutePath();
} else {
- log.info("Starting BK with metadata store:", metadataStoreUrl);
+ log.info("Starting BK with metadata store: {}", metadataStoreUrl);
}
ServerConfiguration bkServerConf = new ServerConfiguration();
bkServerConf.loadConf(new File(configFile).toURI().toURL());
+ calculateCacheSize(bkServerConf);
bkCluster = BKCluster.builder()
.baseServerConfiguration(bkServerConf)
.metadataServiceUri(metadataStoreUrl)
@@ -460,7 +463,7 @@ private void startBookieWithZookeeper() throws Exception {
log.info("Starting BK & ZK cluster");
ServerConfiguration bkServerConf = new ServerConfiguration();
bkServerConf.loadConf(new File(configFile).toURI().toURL());
-
+ calculateCacheSize(bkServerConf);
// Start LocalBookKeeper
bkEnsemble = new LocalBookkeeperEnsemble(
this.getNumOfBk(), this.getZkPort(), this.getBkPort(), this.getStreamStoragePort(), this.getZkDir(),
@@ -469,6 +472,22 @@ private void startBookieWithZookeeper() throws Exception {
config.setMetadataStoreUrl("zk:127.0.0.1:" + zkPort);
}
+ private void calculateCacheSize(ServerConfiguration bkServerConf) {
+ String writeCacheMaxSizeMb = "dbStorage_writeCacheMaxSizeMb";
+ String readAheadCacheMaxSizeMb = "dbStorage_readAheadCacheMaxSizeMb";
+ Object writeCache = bkServerConf.getProperty(writeCacheMaxSizeMb);
+ Object readCache = bkServerConf.getProperty(readAheadCacheMaxSizeMb);
+ // we need to add one broker and one zk (if needed) to calculate the default cache
+ int instanceCount = usingNewDefaultsPIP117 ? (1 + numOfBk) : (2 + numOfBk);
+ long defaultCacheMB = PlatformDependent.maxDirectMemory() / (1024 * 1024) / instanceCount / 4;
+ if (writeCache == null || writeCache.equals("")) {
+ bkServerConf.setProperty(writeCacheMaxSizeMb, defaultCacheMB);
+ }
+ if (readCache == null || readCache.equals("")) {
+ bkServerConf.setProperty(readAheadCacheMaxSizeMb, defaultCacheMB);
+ }
+ }
+
private static void processTerminator(int exitCode) {
log.info("Halting standalone process with code {}", exitCode);
ShutdownUtil.triggerImmediateForcefulShutdown(exitCode);
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarStandaloneBuilder.java b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarStandaloneBuilder.java
index 428f3b09b8a95..5469d24782958 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarStandaloneBuilder.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarStandaloneBuilder.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarStandaloneStarter.java b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarStandaloneStarter.java
index f2c397e170db6..33dd58deac095 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarStandaloneStarter.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarStandaloneStarter.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarTransactionCoordinatorMetadataSetup.java b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarTransactionCoordinatorMetadataSetup.java
index b1fae8753ec10..78ce55f1b2ce2 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarTransactionCoordinatorMetadataSetup.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarTransactionCoordinatorMetadataSetup.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarVersionStarter.java b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarVersionStarter.java
index 6dab0b4a496e0..7eee9d083fc29 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarVersionStarter.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarVersionStarter.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/BookKeeperClientFactory.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/BookKeeperClientFactory.java
index ecdde80910dea..95923baac0294 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/BookKeeperClientFactory.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/BookKeeperClientFactory.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/BookKeeperClientFactoryImpl.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/BookKeeperClientFactoryImpl.java
index f3d69202a080b..20f109d03771b 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/BookKeeperClientFactoryImpl.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/BookKeeperClientFactoryImpl.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -37,7 +37,6 @@
import org.apache.bookkeeper.client.RackawareEnsemblePlacementPolicy;
import org.apache.bookkeeper.client.RegionAwareEnsemblePlacementPolicy;
import org.apache.bookkeeper.conf.ClientConfiguration;
-import org.apache.bookkeeper.meta.MetadataDrivers;
import org.apache.bookkeeper.stats.NullStatsLogger;
import org.apache.bookkeeper.stats.StatsLogger;
import org.apache.pulsar.bookie.rackawareness.BookieRackAffinityMapping;
@@ -68,7 +67,7 @@ public BookKeeper create(ServiceConfiguration conf, MetadataStoreExtended store,
EventLoopGroup eventLoopGroup,
Optional> ensemblePlacementPolicyClass,
Map properties, StatsLogger statsLogger) throws IOException {
- MetadataDrivers.registerClientDriver("metadata-store", PulsarMetadataClientDriver.class);
+ PulsarMetadataClientDriver.init();
ClientConfiguration bkConf = createBkClientConfiguration(store, conf);
if (properties != null) {
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/ManagedLedgerClientFactory.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/ManagedLedgerClientFactory.java
index 25ed135a7a4fa..b16b9a7dd4833 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/ManagedLedgerClientFactory.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/ManagedLedgerClientFactory.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -63,6 +63,8 @@ public void initialize(ServiceConfiguration conf, MetadataStoreExtended metadata
managedLedgerFactoryConfig.setCacheEvictionTimeThresholdMillis(
conf.getManagedLedgerCacheEvictionTimeThresholdMillis());
managedLedgerFactoryConfig.setCopyEntriesInCache(conf.isManagedLedgerCacheCopyEntries());
+ managedLedgerFactoryConfig.setManagedLedgerMaxReadsInFlightSize(
+ conf.getManagedLedgerMaxReadsInFlightSizeInMB() * 1024L * 1024L);
managedLedgerFactoryConfig.setPrometheusStatsLatencyRolloverSeconds(
conf.getManagedLedgerPrometheusStatsLatencyRolloverSeconds());
managedLedgerFactoryConfig.setTraceTaskExecution(conf.isManagedLedgerTraceTaskExecution());
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java
index f6aec263f1360..ec7a8f85fffee 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -98,11 +98,10 @@
import org.apache.pulsar.broker.rest.Topics;
import org.apache.pulsar.broker.service.BrokerService;
import org.apache.pulsar.broker.service.PulsarMetadataEventSynchronizer;
-import org.apache.pulsar.broker.service.SystemTopicBaseTxnBufferSnapshotService;
import org.apache.pulsar.broker.service.SystemTopicBasedTopicPoliciesService;
import org.apache.pulsar.broker.service.Topic;
import org.apache.pulsar.broker.service.TopicPoliciesService;
-import org.apache.pulsar.broker.service.TransactionBufferSnapshotService;
+import org.apache.pulsar.broker.service.TransactionBufferSnapshotServiceFactory;
import org.apache.pulsar.broker.service.schema.SchemaRegistryService;
import org.apache.pulsar.broker.service.schema.SchemaStorageFactory;
import org.apache.pulsar.broker.stats.MetricsGenerator;
@@ -260,8 +259,7 @@ public class PulsarService implements AutoCloseable, ShutdownService {
private MetadataStoreExtended localMetadataStore;
private PulsarMetadataEventSynchronizer localMetadataSynchronizer;
private CoordinationService coordinationService;
- private TransactionBufferSnapshotService transactionBufferSnapshotService;
-
+ private TransactionBufferSnapshotServiceFactory transactionBufferSnapshotServiceFactory;
private MetadataStore configurationMetadataStore;
private PulsarMetadataEventSynchronizer configMetadataSynchronizer;
private boolean shouldShutdownConfigurationMetadataStore;
@@ -317,13 +315,13 @@ public PulsarService(ServiceConfiguration config,
this.config = config;
this.processTerminator = processTerminator;
this.loadManagerExecutor = Executors
- .newSingleThreadScheduledExecutor(new DefaultThreadFactory("pulsar-load-manager"));
+ .newSingleThreadScheduledExecutor(new ExecutorProvider.ExtendedThreadFactory("pulsar-load-manager"));
this.workerConfig = workerConfig;
this.functionWorkerService = functionWorkerService;
this.executor = Executors.newScheduledThreadPool(config.getNumExecutorThreadPoolSize(),
- new DefaultThreadFactory("pulsar"));
+ new ExecutorProvider.ExtendedThreadFactory("pulsar"));
this.cacheExecutor = Executors.newScheduledThreadPool(config.getNumCacheExecutorThreadPoolSize(),
- new DefaultThreadFactory("zk-cache-callback"));
+ new ExecutorProvider.ExtendedThreadFactory("zk-cache-callback"));
if (config.isTransactionCoordinatorEnabled()) {
this.transactionExecutorProvider = new ExecutorProvider(this.getConfiguration()
@@ -510,9 +508,9 @@ public CompletableFuture closeAsync() {
adminClient = null;
}
- if (transactionBufferSnapshotService != null) {
- transactionBufferSnapshotService.close();
- transactionBufferSnapshotService = null;
+ if (transactionBufferSnapshotServiceFactory != null) {
+ transactionBufferSnapshotServiceFactory.close();
+ transactionBufferSnapshotServiceFactory = null;
}
if (transactionBufferClient != null) {
@@ -617,7 +615,7 @@ private synchronized void resetMetricsServlet() {
private CompletableFuture addTimeoutHandling(CompletableFuture future) {
ScheduledExecutorService shutdownExecutor = Executors.newSingleThreadScheduledExecutor(
- new DefaultThreadFactory(getClass().getSimpleName() + "-shutdown"));
+ new ExecutorProvider.ExtendedThreadFactory(getClass().getSimpleName() + "-shutdown"));
FutureUtil.addTimeoutHandling(future,
Duration.ofMillis(Math.max(1L, getConfiguration().getBrokerShutdownTimeoutMs())),
shutdownExecutor, () -> FutureUtil.createTimeoutException("Timeout in close", getClass(), "close"));
@@ -837,7 +835,8 @@ public void start() throws PulsarServerException {
MLTransactionMetadataStoreProvider.initBufferedWriterMetrics(getAdvertisedAddress());
MLPendingAckStoreProvider.initBufferedWriterMetrics(getAdvertisedAddress());
- this.transactionBufferSnapshotService = new SystemTopicBaseTxnBufferSnapshotService(getClient());
+ this.transactionBufferSnapshotServiceFactory = new TransactionBufferSnapshotServiceFactory(getClient());
+
this.transactionTimer =
new HashedWheelTimer(new DefaultThreadFactory("pulsar-transaction-timer"));
transactionBufferClient = TransactionBufferClientImpl.create(this, transactionTimer,
@@ -903,9 +902,8 @@ public void start() throws PulsarServerException {
+ (config.getWebServicePortTls().isPresent() ? ", tls-port = " + config.getWebServicePortTls() : "")
+ (StringUtils.isNotEmpty(brokerServiceUrl) ? ", broker url= " + brokerServiceUrl : "")
+ (StringUtils.isNotEmpty(brokerServiceUrlTls) ? ", broker tls url= " + brokerServiceUrlTls : "");
- LOG.info("messaging service is ready, bootstrap_seconds={}", bootstrapTimeSeconds);
- LOG.info("messaging service is ready, {}, cluster={}, configs={}", bootstrapMessage,
- config.getClusterName(), config);
+ LOG.info("messaging service is ready, bootstrap_seconds={}, {}, cluster={}, configs={}",
+ bootstrapTimeSeconds, bootstrapMessage, config.getClusterName(), config);
state = State.Started;
} catch (Exception e) {
@@ -1426,7 +1424,8 @@ public BookKeeperClientFactory getBookKeeperClientFactory() {
protected synchronized ScheduledExecutorService getCompactorExecutor() {
if (this.compactorExecutor == null) {
- compactorExecutor = Executors.newSingleThreadScheduledExecutor(new DefaultThreadFactory("compaction"));
+ compactorExecutor = Executors.newSingleThreadScheduledExecutor(
+ new ExecutorProvider.ExtendedThreadFactory("compaction"));
}
return this.compactorExecutor;
}
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/TransactionMetadataStoreService.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/TransactionMetadataStoreService.java
index a15039b3ff8ba..3d9e6924d1168 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/TransactionMetadataStoreService.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/TransactionMetadataStoreService.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -24,7 +24,6 @@
import com.google.common.annotations.VisibleForTesting;
import io.netty.util.HashedWheelTimer;
import io.netty.util.Timer;
-import io.netty.util.concurrent.DefaultThreadFactory;
import java.util.Collections;
import java.util.Deque;
import java.util.List;
@@ -52,6 +51,7 @@
import org.apache.pulsar.client.api.transaction.TransactionBufferClientException.ReachMaxPendingOpsException;
import org.apache.pulsar.client.api.transaction.TransactionBufferClientException.RequestTimeoutException;
import org.apache.pulsar.client.api.transaction.TxnID;
+import org.apache.pulsar.client.util.ExecutorProvider;
import org.apache.pulsar.common.api.proto.TxnAction;
import org.apache.pulsar.common.naming.SystemTopicNames;
import org.apache.pulsar.common.util.FutureUtil;
@@ -93,7 +93,7 @@ public class TransactionMetadataStoreService {
private static final long HANDLE_PENDING_CONNECT_TIME_OUT = 30000L;
private final ThreadFactory threadFactory =
- new DefaultThreadFactory("transaction-coordinator-thread-factory");
+ new ExecutorProvider.ExtendedThreadFactory("transaction-coordinator-thread-factory");
public TransactionMetadataStoreService(TransactionMetadataStoreProvider transactionMetadataStoreProvider,
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/AdminResource.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/AdminResource.java
index e2c44a80d4ae8..ad141c5884fc1 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/AdminResource.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/AdminResource.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -61,10 +61,12 @@
import org.apache.pulsar.common.policies.data.SubscribeRate;
import org.apache.pulsar.common.policies.data.TopicOperation;
import org.apache.pulsar.common.policies.data.TopicPolicies;
+import org.apache.pulsar.common.policies.data.impl.AutoSubscriptionCreationOverrideImpl;
import org.apache.pulsar.common.policies.data.impl.DispatchRateImpl;
import org.apache.pulsar.common.util.Codec;
import org.apache.pulsar.common.util.FutureUtil;
import org.apache.pulsar.common.util.ObjectMapperFactory;
+import org.apache.pulsar.functions.worker.WorkerService;
import org.apache.pulsar.metadata.api.MetadataStoreException;
import org.apache.pulsar.metadata.api.MetadataStoreException.AlreadyExistsException;
import org.apache.pulsar.metadata.api.MetadataStoreException.BadVersionException;
@@ -295,6 +297,14 @@ protected void validatePersistentTopicName(String property, String cluster, Stri
}
}
+ protected WorkerService validateAndGetWorkerService() {
+ try {
+ return pulsar().getWorkerService();
+ } catch (UnsupportedOperationException e) {
+ throw new RestException(Status.CONFLICT, e.getMessage());
+ }
+ }
+
protected Policies getNamespacePolicies(NamespaceName namespaceName) {
try {
Policies policies = namespaceResources().getPolicies(namespaceName)
@@ -428,6 +438,13 @@ protected SubscribeRate subscribeRate() {
);
}
+ protected AutoSubscriptionCreationOverrideImpl autoSubscriptionCreationOverride() {
+ boolean allowAutoSubscriptionCreation = pulsar().getConfiguration().isAllowAutoSubscriptionCreation();
+ return AutoSubscriptionCreationOverrideImpl.builder()
+ .allowAutoSubscriptionCreation(allowAutoSubscriptionCreation)
+ .build();
+ }
+
public static ObjectMapper jsonMapper() {
return ObjectMapperFactory.getThreadLocal();
}
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokerStatsBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokerStatsBase.java
index 53227fd641ba1..670fa10b28b88 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokerStatsBase.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokerStatsBase.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokersBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokersBase.java
index 2aa6ee7886449..3328fa9715b99 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokersBase.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokersBase.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/ClustersBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/ClustersBase.java
index 9e2c7c6b06c19..391cfe5ebbfcc 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/ClustersBase.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/ClustersBase.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/FunctionsBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/FunctionsBase.java
index 81d90b84c8fd1..bee81bf5dcdb6 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/FunctionsBase.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/FunctionsBase.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -56,7 +56,7 @@
public class FunctionsBase extends AdminResource {
Functions extends WorkerService> functions() {
- return pulsar().getWorkerService().getFunctions();
+ return validateAndGetWorkerService().getFunctions();
}
@POST
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java
index 1991867627e73..1af182c2d5901 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.pulsar.broker.admin.impl;
import static org.apache.commons.lang3.StringUtils.isBlank;
@@ -219,24 +218,29 @@ protected CompletableFuture internalDeleteNamespaceAsync(boolean force) {
}))
.thenCompose(topics -> {
List allTopics = topics.get(0);
+ ArrayList allUserCreatedTopics = new ArrayList<>();
List allPartitionedTopics = topics.get(1);
- if (!force) {
- boolean hasNonSystemTopic = false;
- for (String topic : allTopics) {
- if (!pulsar().getBrokerService().isSystemTopic(TopicName.get(topic))) {
- hasNonSystemTopic = true;
- break;
- }
+ ArrayList allUserCreatedPartitionTopics = new ArrayList<>();
+ boolean hasNonSystemTopic = false;
+ List allSystemTopics = new ArrayList<>();
+ List allPartitionedSystemTopics = new ArrayList<>();
+ for (String topic : allTopics) {
+ if (!pulsar().getBrokerService().isSystemTopic(TopicName.get(topic))) {
+ hasNonSystemTopic = true;
+ allUserCreatedTopics.add(topic);
+ } else {
+ allSystemTopics.add(topic);
}
- if (!hasNonSystemTopic) {
- for (String topic : allPartitionedTopics) {
- if (!pulsar().getBrokerService().isSystemTopic(TopicName.get(topic))) {
- hasNonSystemTopic = true;
- break;
- }
- }
+ }
+ for (String topic : allPartitionedTopics) {
+ if (!pulsar().getBrokerService().isSystemTopic(TopicName.get(topic))) {
+ hasNonSystemTopic = true;
+ allUserCreatedPartitionTopics.add(topic);
+ } else {
+ allPartitionedSystemTopics.add(topic);
}
-
+ }
+ if (!force) {
if (hasNonSystemTopic) {
throw new RestException(Status.CONFLICT, "Cannot delete non empty namespace");
}
@@ -244,13 +248,17 @@ protected CompletableFuture internalDeleteNamespaceAsync(boolean force) {
return namespaceResources().setPoliciesAsync(namespaceName, old -> {
old.deleted = true;
return old;
- }).thenCompose(__ -> {
- return internalDeleteTopicsAsync(allTopics);
- }).thenCompose(__ -> {
- return internalDeletePartitionedTopicsAsync(allPartitionedTopics);
+ }).thenCompose(ignore -> {
+ return internalDeleteTopicsAsync(allUserCreatedTopics);
+ }).thenCompose(ignore -> {
+ return internalDeletePartitionedTopicsAsync(allUserCreatedPartitionTopics);
+ }).thenCompose(ignore -> {
+ return internalDeleteTopicsAsync(allSystemTopics);
+ }).thenCompose(ignore__ -> {
+ return internalDeletePartitionedTopicsAsync(allPartitionedSystemTopics);
});
})
- .thenCompose(__ -> pulsar().getNamespaceService()
+ .thenCompose(ignore -> pulsar().getNamespaceService()
.getNamespaceBundleFactory().getBundlesAsync(namespaceName))
.thenCompose(bundles -> FutureUtil.waitForAll(bundles.getBundles().stream()
.map(bundle -> pulsar().getNamespaceService().getOwnerAsync(bundle)
@@ -267,12 +275,12 @@ protected CompletableFuture internalDeleteNamespaceAsync(boolean force) {
return FutureUtil.failedFuture(ex);
}
return admin.namespaces().deleteNamespaceBundleAsync(namespaceName.toString(),
- bundle.getBundleRange());
+ bundle.getBundleRange(), force);
}
return CompletableFuture.completedFuture(null);
})
).collect(Collectors.toList())))
- .thenCompose(__ -> internalClearZkSources());
+ .thenCompose(ignore -> internalClearZkSources());
}
private CompletableFuture internalDeletePartitionedTopicsAsync(List topicNames) {
@@ -281,8 +289,10 @@ private CompletableFuture internalDeletePartitionedTopicsAsync(List> futures = new ArrayList<>();
for (String topicName : topicNames) {
- futures.add(namespaceResources().getPartitionedTopicResources()
- .deletePartitionedTopicAsync(TopicName.get(topicName)));
+ TopicName tn = TopicName.get(topicName);
+ futures.add(pulsar().getPulsarResources().getNamespaceResources().getPartitionedTopicResources()
+ .runWithMarkDeleteAsync(tn,
+ () -> namespaceResources().getPartitionedTopicResources().deletePartitionedTopicAsync(tn)));
}
return FutureUtil.waitForAll(futures);
}
@@ -1966,6 +1976,37 @@ protected void internalSetOffloadThreshold(long newThreshold) {
}
}
+ protected CompletableFuture internalSetOffloadThresholdInSecondsAsync(long newThreshold) {
+ CompletableFuture f = new CompletableFuture<>();
+
+ validateNamespacePolicyOperationAsync(namespaceName, PolicyName.OFFLOAD, PolicyOperation.WRITE)
+ .thenApply(v -> validatePoliciesReadOnlyAccessAsync())
+ .thenApply(v -> updatePoliciesAsync(namespaceName,
+ policies -> {
+ if (policies.offload_policies == null) {
+ policies.offload_policies = new OffloadPoliciesImpl();
+ }
+ ((OffloadPoliciesImpl) policies.offload_policies)
+ .setManagedLedgerOffloadThresholdInSeconds(newThreshold);
+ policies.offload_threshold_in_seconds = newThreshold;
+ return policies;
+ })
+ )
+ .thenAccept(v -> {
+ log.info("[{}] Successfully updated offloadThresholdInSeconds configuration:"
+ + " namespace={}, value={}", clientAppId(), namespaceName, newThreshold);
+ f.complete(null);
+ })
+ .exceptionally(t -> {
+ log.error("[{}] Failed to update offloadThresholdInSeconds configuration for namespace {}",
+ clientAppId(), namespaceName, t);
+ f.completeExceptionally(new RestException(t));
+ return null;
+ });
+
+ return f;
+ }
+
protected void internalSetOffloadDeletionLag(Long newDeletionLagMs) {
validateNamespacePolicyOperation(namespaceName, PolicyName.OFFLOAD, PolicyOperation.WRITE);
validatePoliciesReadOnlyAccess();
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/OffloaderObjectsScannerUtils.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/OffloaderObjectsScannerUtils.java
index c5aedf8c80c39..7eb648a8b55ac 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/OffloaderObjectsScannerUtils.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/OffloaderObjectsScannerUtils.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PackagesBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PackagesBase.java
index 8a8dcd9f03be9..c5b0f60e91c5e 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PackagesBase.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PackagesBase.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
index a00d90e92162d..4f77bb608cd7a 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -106,6 +106,7 @@
import org.apache.pulsar.common.partition.PartitionedTopicMetadata;
import org.apache.pulsar.common.policies.data.AuthAction;
import org.apache.pulsar.common.policies.data.AuthPolicies;
+import org.apache.pulsar.common.policies.data.AutoSubscriptionCreationOverride;
import org.apache.pulsar.common.policies.data.BacklogQuota;
import org.apache.pulsar.common.policies.data.DelayedDeliveryPolicies;
import org.apache.pulsar.common.policies.data.DispatchRate;
@@ -129,6 +130,7 @@
import org.apache.pulsar.common.policies.data.TopicOperation;
import org.apache.pulsar.common.policies.data.TopicPolicies;
import org.apache.pulsar.common.policies.data.TopicStats;
+import org.apache.pulsar.common.policies.data.impl.AutoSubscriptionCreationOverrideImpl;
import org.apache.pulsar.common.policies.data.impl.BacklogQuotaImpl;
import org.apache.pulsar.common.policies.data.impl.DispatchRateImpl;
import org.apache.pulsar.common.policies.data.stats.PartitionedTopicStatsImpl;
@@ -619,7 +621,7 @@ protected CompletableFuture internalUpdatePropertiesAsync(boolean authorit
return CompletableFuture.completedFuture(null);
}
return validateTopicOwnershipAsync(topicName, authoritative)
- .thenCompose(__ -> validateTopicOperationAsync(topicName, TopicOperation.PRODUCE))
+ .thenCompose(__ -> validateTopicOperationAsync(topicName, TopicOperation.UPDATE_METADATA))
.thenCompose(__ -> {
if (topicName.isPartitioned()) {
return internalUpdateNonPartitionedTopicProperties(properties);
@@ -745,8 +747,9 @@ protected void internalDeletePartitionedTopic(AsyncResponse asyncResponse,
.thenCompose(unused -> internalRemovePartitionsTopicAsync(numPartitions, force));
})
// Only tries to delete the znode for partitioned topic when all its partitions are successfully deleted
- ).thenCompose(__ -> namespaceResources()
- .getPartitionedTopicResources().deletePartitionedTopicAsync(topicName))
+ ).thenCompose(__ -> getPulsarResources().getNamespaceResources().getPartitionedTopicResources()
+ .runWithMarkDeleteAsync(topicName, () -> namespaceResources()
+ .getPartitionedTopicResources().deletePartitionedTopicAsync(topicName)))
.thenAccept(__ -> {
log.info("[{}] Deleted partitioned topic {}", clientAppId(), topicName);
asyncResponse.resume(Response.noContent().build());
@@ -780,6 +783,13 @@ protected void internalDeletePartitionedTopic(AsyncResponse asyncResponse,
}
private CompletableFuture internalRemovePartitionsTopicAsync(int numPartitions, boolean force) {
+ return pulsar().getPulsarResources().getNamespaceResources().getPartitionedTopicResources()
+ .runWithMarkDeleteAsync(topicName,
+ () -> internalRemovePartitionsTopicNoAutocreationDisableAsync(numPartitions, force));
+ }
+
+ private CompletableFuture internalRemovePartitionsTopicNoAutocreationDisableAsync(int numPartitions,
+ boolean force) {
return FutureUtil.waitForAll(IntStream.range(0, numPartitions)
.mapToObj(i -> {
TopicName topicNamePartition = topicName.getPartition(i);
@@ -1209,7 +1219,14 @@ protected void internalGetSubscriptions(AsyncResponse asyncResponse, boolean aut
resumeAsyncResponseExceptionally(asyncResponse, ex);
return null;
})
- );
+ ).exceptionally(ex -> {
+ // If the exception is not redirect exception we need to log it.
+ if (!isRedirectException(ex)) {
+ log.error("[{}] Failed to get subscriptions for {}", clientAppId(), topicName, ex);
+ }
+ resumeAsyncResponseExceptionally(asyncResponse, ex);
+ return null;
+ });
}
private void resumeAsyncResponse(AsyncResponse asyncResponse, Set subscriptions,
@@ -1887,7 +1904,7 @@ protected void internalSkipAllMessages(AsyncResponse asyncResponse, String subNa
.thenCompose(__ -> {
// If the topic name is a partition name, no need to get partition topic metadata again
if (topicName.isPartitioned()) {
- return internalSkipAllMessagesForNonPartitionedTopicAsync(asyncResponse, subName, authoritative);
+ return internalSkipAllMessagesForNonPartitionedTopicAsync(asyncResponse, subName);
} else {
return getPartitionedTopicMetadataAsync(topicName,
authoritative, false).thenCompose(partitionMetadata -> {
@@ -1928,8 +1945,7 @@ protected void internalSkipAllMessages(AsyncResponse asyncResponse, String subNa
return null;
});
} else {
- return internalSkipAllMessagesForNonPartitionedTopicAsync(asyncResponse, subName,
- authoritative);
+ return internalSkipAllMessagesForNonPartitionedTopicAsync(asyncResponse, subName);
}
});
}
@@ -1945,8 +1961,7 @@ protected void internalSkipAllMessages(AsyncResponse asyncResponse, String subNa
}
private CompletableFuture internalSkipAllMessagesForNonPartitionedTopicAsync(AsyncResponse asyncResponse,
- String subName,
- boolean authoritative) {
+ String subName) {
return getTopicReferenceAsync(topicName).thenCompose(t -> {
PersistentTopic topic = (PersistentTopic) t;
BiConsumer biConsumer = (v, ex) -> {
@@ -2304,79 +2319,81 @@ protected void internalCreateSubscription(AsyncResponse asyncResponse, String su
internalCreateSubscriptionForNonPartitionedTopic(asyncResponse,
subscriptionName, targetMessageId, authoritative, replicated, properties);
} else {
- boolean allowAutoTopicCreation = pulsar().getBrokerService().isAllowAutoTopicCreation(topicName);
- getPartitionedTopicMetadataAsync(topicName,
- authoritative, allowAutoTopicCreation).thenAccept(partitionMetadata -> {
- final int numPartitions = partitionMetadata.partitions;
- if (numPartitions > 0) {
- final CompletableFuture future = new CompletableFuture<>();
- final AtomicInteger count = new AtomicInteger(numPartitions);
- final AtomicInteger failureCount = new AtomicInteger(0);
- final AtomicReference partitionException = new AtomicReference<>();
+ pulsar().getBrokerService().isAllowAutoTopicCreationAsync(topicName)
+ .thenCompose(allowAutoTopicCreation -> getPartitionedTopicMetadataAsync(topicName,
+ authoritative, allowAutoTopicCreation).thenAccept(partitionMetadata -> {
+ final int numPartitions = partitionMetadata.partitions;
+ if (numPartitions > 0) {
+ final CompletableFuture future = new CompletableFuture<>();
+ final AtomicInteger count = new AtomicInteger(numPartitions);
+ final AtomicInteger failureCount = new AtomicInteger(0);
+ final AtomicReference partitionException = new AtomicReference<>();
+
+ // Create the subscription on each partition
+ for (int i = 0; i < numPartitions; i++) {
+ TopicName topicNamePartition = topicName.getPartition(i);
+ try {
+ pulsar().getAdminClient().topics()
+ .createSubscriptionAsync(topicNamePartition.toString(),
+ subscriptionName, targetMessageId, false, properties)
+ .handle((r, ex) -> {
+ if (ex != null) {
+ // fail the operation on unknown exception or
+ // if all the partitioned failed due to
+ // subscription-already-exist
+ if (failureCount.incrementAndGet() == numPartitions
+ || !(ex instanceof PulsarAdminException
+ .ConflictException)) {
+ partitionException.set(ex);
+ }
+ }
- // Create the subscription on each partition
- for (int i = 0; i < numPartitions; i++) {
- TopicName topicNamePartition = topicName.getPartition(i);
- try {
- pulsar().getAdminClient().topics()
- .createSubscriptionAsync(topicNamePartition.toString(),
- subscriptionName, targetMessageId, false, properties)
- .handle((r, ex) -> {
- if (ex != null) {
- // fail the operation on unknown exception or
- // if all the partitioned failed due to
- // subscription-already-exist
- if (failureCount.incrementAndGet() == numPartitions
- || !(ex instanceof PulsarAdminException.ConflictException)) {
- partitionException.set(ex);
- }
- }
+ if (count.decrementAndGet() == 0) {
+ future.complete(null);
+ }
- if (count.decrementAndGet() == 0) {
- future.complete(null);
- }
+ return null;
+ });
+ } catch (Exception e) {
+ log.warn("[{}] [{}] Failed to create subscription {} at message id {}",
+ clientAppId(), topicNamePartition, subscriptionName, targetMessageId, e);
+ future.completeExceptionally(e);
+ }
+ }
- return null;
- });
- } catch (Exception e) {
- log.warn("[{}] [{}] Failed to create subscription {} at message id {}", clientAppId(),
- topicNamePartition, subscriptionName, targetMessageId, e);
- future.completeExceptionally(e);
- }
- }
+ future.whenComplete((r, ex) -> {
+ if (ex != null) {
+ if (ex instanceof PulsarAdminException) {
+ asyncResponse.resume(new RestException((PulsarAdminException) ex));
+ return;
+ } else {
+ asyncResponse.resume(new RestException(ex));
+ return;
+ }
+ }
- future.whenComplete((r, ex) -> {
- if (ex != null) {
- if (ex instanceof PulsarAdminException) {
- asyncResponse.resume(new RestException((PulsarAdminException) ex));
- return;
- } else {
- asyncResponse.resume(new RestException(ex));
- return;
- }
- }
+ if (partitionException.get() != null) {
+ log.warn("[{}] [{}] Failed to create subscription {} at message id {}",
+ clientAppId(), topicName,
+ subscriptionName, targetMessageId, partitionException.get());
+ if (partitionException.get() instanceof PulsarAdminException) {
+ asyncResponse.resume(
+ new RestException((PulsarAdminException) partitionException.get()));
+ return;
+ } else {
+ asyncResponse.resume(new RestException(partitionException.get()));
+ return;
+ }
+ }
- if (partitionException.get() != null) {
- log.warn("[{}] [{}] Failed to create subscription {} at message id {}",
- clientAppId(), topicName,
- subscriptionName, targetMessageId, partitionException.get());
- if (partitionException.get() instanceof PulsarAdminException) {
- asyncResponse.resume(
- new RestException((PulsarAdminException) partitionException.get()));
- return;
- } else {
- asyncResponse.resume(new RestException(partitionException.get()));
- return;
- }
+ asyncResponse.resume(Response.noContent().build());
+ });
+ } else {
+ internalCreateSubscriptionForNonPartitionedTopic(asyncResponse,
+ subscriptionName, targetMessageId, authoritative, replicated, properties);
}
- asyncResponse.resume(Response.noContent().build());
- });
- } else {
- internalCreateSubscriptionForNonPartitionedTopic(asyncResponse,
- subscriptionName, targetMessageId, authoritative, replicated, properties);
- }
- }).exceptionally(ex -> {
+ })).exceptionally(ex -> {
// If the exception is not redirect exception we need to log it.
if (!isRedirectException(ex)) {
log.error("[{}] Failed to create subscription {} on topic {}",
@@ -2402,12 +2419,12 @@ private void internalCreateSubscriptionForNonPartitionedTopic(
MessageIdImpl targetMessageId, boolean authoritative, boolean replicated,
Map properties) {
- boolean isAllowAutoTopicCreation = pulsar().getBrokerService().isAllowAutoTopicCreation(topicName);
-
validateTopicOwnershipAsync(topicName, authoritative)
.thenCompose(__ -> {
validateTopicOperation(topicName, TopicOperation.SUBSCRIBE, subscriptionName);
- return pulsar().getBrokerService().getTopic(topicName.toString(), isAllowAutoTopicCreation);
+ return pulsar().getBrokerService().isAllowAutoTopicCreationAsync(topicName)
+ .thenCompose(isAllowAutoTopicCreation -> pulsar().getBrokerService()
+ .getTopic(topicName.toString(), isAllowAutoTopicCreation));
}).thenApply(optTopic -> {
if (optTopic.isPresent()) {
return optTopic.get();
@@ -4502,12 +4519,13 @@ private CompletableFuture createSubscriptions(TopicName topicName, int num
// We must not re-create non-durable subscriptions on the new partitions
return;
}
+ boolean replicated = ss.isReplicated();
for (int i = partitionMetadata.partitions; i < numPartitions; i++) {
final String topicNamePartition = topicName.getPartition(i).toString();
CompletableFuture future = new CompletableFuture<>();
admin.topics().createSubscriptionAsync(topicNamePartition,
- subscription, MessageId.latest).whenComplete((__, ex) -> {
+ subscription, MessageId.latest, replicated).whenComplete((__, ex) -> {
if (ex == null) {
future.complete(null);
} else {
@@ -5507,4 +5525,30 @@ protected CompletableFuture internalDeleteShadowTopics() {
updateTopicPoliciesAsync(topicName, topicPolicies);
});
}
+
+ protected CompletableFuture internalSetAutoSubscriptionCreation(
+ AutoSubscriptionCreationOverrideImpl autoSubscriptionCreationOverride, boolean isGlobal) {
+ return getTopicPoliciesAsyncWithRetry(topicName, isGlobal)
+ .thenCompose(op -> {
+ TopicPolicies topicPolicies = op.orElseGet(TopicPolicies::new);
+ topicPolicies.setAutoSubscriptionCreationOverride(autoSubscriptionCreationOverride);
+ topicPolicies.setIsGlobal(isGlobal);
+ return pulsar().getTopicPoliciesService().updateTopicPoliciesAsync(topicName, topicPolicies);
+ });
+ }
+
+ protected CompletableFuture internalGetAutoSubscriptionCreation(boolean applied,
+ boolean isGlobal) {
+ return getTopicPoliciesAsyncWithRetry(topicName, isGlobal)
+ .thenApply(op -> op.map(TopicPolicies::getAutoSubscriptionCreationOverride)
+ .orElseGet(() -> {
+ if (applied) {
+ AutoSubscriptionCreationOverride namespacePolicy = getNamespacePolicies(namespaceName)
+ .autoSubscriptionCreationOverride;
+ return namespacePolicy == null ? autoSubscriptionCreationOverride()
+ : (AutoSubscriptionCreationOverrideImpl) namespacePolicy;
+ }
+ return null;
+ }));
+ }
}
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/ResourceGroupsBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/ResourceGroupsBase.java
index 1ce3aa592eb4c..826b9c322e353 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/ResourceGroupsBase.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/ResourceGroupsBase.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/ResourceQuotasBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/ResourceQuotasBase.java
index 9254c9b44c216..8e4d6f3211d67 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/ResourceQuotasBase.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/ResourceQuotasBase.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SchemasResourceBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SchemasResourceBase.java
index 76af582514300..78bf5ad43ef20 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SchemasResourceBase.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SchemasResourceBase.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SinksBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SinksBase.java
index 26186fe17ab6c..7a3a554a3a00c 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SinksBase.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SinksBase.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -50,7 +50,7 @@
public class SinksBase extends AdminResource {
Sinks extends WorkerService> sinks() {
- return pulsar().getWorkerService().getSinks();
+ return validateAndGetWorkerService().getSinks();
}
@POST
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SourcesBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SourcesBase.java
index 4a5efdad80cb8..1bf092784dd3a 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SourcesBase.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SourcesBase.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -50,7 +50,7 @@
public class SourcesBase extends AdminResource {
Sources extends WorkerService> sources() {
- return pulsar().getWorkerService().getSources();
+ return validateAndGetWorkerService().getSources();
}
@POST
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/TenantsBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/TenantsBase.java
index fdf0433b340cf..32538eda1d11d 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/TenantsBase.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/TenantsBase.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.pulsar.broker.admin.impl;
import static org.apache.pulsar.common.naming.Constants.GLOBAL_CLUSTER;
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/TransactionsBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/TransactionsBase.java
index dbd70feb1c052..f537f0ecdb9eb 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/TransactionsBase.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/TransactionsBase.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -39,6 +39,7 @@
import org.apache.pulsar.broker.service.Topic;
import org.apache.pulsar.broker.service.persistent.PersistentTopic;
import org.apache.pulsar.broker.web.RestException;
+import org.apache.pulsar.client.admin.PulsarAdmin;
import org.apache.pulsar.client.admin.Transactions;
import org.apache.pulsar.client.api.transaction.TxnID;
import org.apache.pulsar.common.naming.NamespaceName;
@@ -47,6 +48,7 @@
import org.apache.pulsar.common.naming.TopicName;
import org.apache.pulsar.common.partition.PartitionedTopicMetadata;
import org.apache.pulsar.common.policies.data.TransactionBufferStats;
+import org.apache.pulsar.common.policies.data.TransactionCoordinatorInfo;
import org.apache.pulsar.common.policies.data.TransactionCoordinatorInternalStats;
import org.apache.pulsar.common.policies.data.TransactionCoordinatorStats;
import org.apache.pulsar.common.policies.data.TransactionInBufferStats;
@@ -68,6 +70,33 @@
@Slf4j
public abstract class TransactionsBase extends AdminResource {
+ protected void internalListCoordinators(AsyncResponse asyncResponse) {
+ final PulsarAdmin admin;
+ try {
+ admin = pulsar().getAdminClient();
+ } catch (PulsarServerException ex) {
+ asyncResponse.resume(new RestException(ex));
+ return;
+ }
+ Map result = new HashMap<>();
+ admin.lookups()
+ .lookupPartitionedTopicAsync(SystemTopicNames.TRANSACTION_COORDINATOR_ASSIGN.getPartitionedTopicName())
+ .thenAccept(map -> {
+ map.forEach((topicPartition, brokerServiceUrl) -> {
+ final int coordinatorId = TopicName.getPartitionIndex(topicPartition);
+ result.put(coordinatorId, new TransactionCoordinatorInfo(coordinatorId, brokerServiceUrl));
+ });
+
+ asyncResponse.resume(result.values());
+ })
+ .exceptionally(ex -> {
+ log.error("[{}] Failed to list transaction coordinators: {}",
+ clientAppId(), ex.getMessage(), ex);
+ resumeAsyncResponseExceptionally(asyncResponse, ex);
+ return null;
+ });
+ }
+
protected void internalGetCoordinatorStats(AsyncResponse asyncResponse, boolean authoritative,
Integer coordinatorId) {
if (coordinatorId != null) {
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/package-info.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/package-info.java
index ffb050ddf4de9..8546c66fe83c1 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/package-info.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/package-info.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/package-info.java
index c13919497e2f5..6a5060e09059b 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/package-info.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/BrokerStats.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/BrokerStats.java
index ba8ff81dac471..a228f249fa6c2 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/BrokerStats.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/BrokerStats.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/Brokers.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/Brokers.java
index 2bf14b33add95..356f29e9429ea 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/Brokers.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/Brokers.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/Clusters.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/Clusters.java
index 995bb29cb42bc..41ae0717764c9 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/Clusters.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/Clusters.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/Functions.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/Functions.java
index da06f91f8261f..16df1118171c1 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/Functions.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/Functions.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/Namespaces.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/Namespaces.java
index 3fd09ddd594e3..d4a27f0fb3abf 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/Namespaces.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/Namespaces.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -881,6 +881,7 @@ public void unloadNamespace(@Suspended final AsyncResponse asyncResponse, @PathP
@ApiOperation(hidden = true, value = "Unload a namespace bundle")
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace"),
+ @ApiResponse(code = 404, message = "Namespace doesn't exist"),
@ApiResponse(code = 403, message = "Don't have admin permission") })
public void unloadNamespaceBundle(@Suspended final AsyncResponse asyncResponse,
@PathParam("property") String property, @PathParam("cluster") String cluster,
@@ -907,6 +908,7 @@ public void unloadNamespaceBundle(@Suspended final AsyncResponse asyncResponse,
@ApiOperation(hidden = true, value = "Split a namespace bundle")
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace"),
+ @ApiResponse(code = 404, message = "Namespace doesn't exist"),
@ApiResponse(code = 403, message = "Don't have admin permission") })
public void splitNamespaceBundle(
@Suspended final AsyncResponse asyncResponse,
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/NonPersistentTopics.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/NonPersistentTopics.java
index fef5eda009bde..0d857f2211f41 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/NonPersistentTopics.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/NonPersistentTopics.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.pulsar.broker.admin.v1;
import io.swagger.annotations.Api;
@@ -122,7 +121,9 @@ public void getInternalStats(
@Path("/{property}/{cluster}/{namespace}/{topic}/partitions")
@ApiOperation(hidden = true, value = "Create a partitioned topic.",
notes = "It needs to be called before creating a producer on a partitioned topic.")
- @ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
+ @ApiResponses(value = {
+ @ApiResponse(code = 403, message = "Don't have admin permission"),
+ @ApiResponse(code = 404, message = "Namespace doesn't exist"),
@ApiResponse(code = 406, message = "The number of partitions should be more than 0 and less than or equal"
+ " to maxNumPartitionsPerPartitionedTopic"),
@ApiResponse(code = 409, message = "Partitioned topic already exist")})
@@ -149,7 +150,7 @@ public void createPartitionedTopic(
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist")})
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist")})
public void unloadTopic(@Suspended final AsyncResponse asyncResponse, @PathParam("property") String property,
@PathParam("cluster") String cluster, @PathParam("namespace") String namespace,
@PathParam("topic") @Encoded String encodedTopic,
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/PersistentTopics.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/PersistentTopics.java
index 520e11d1c66c6..943b191209fa8 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/PersistentTopics.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/PersistentTopics.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -190,6 +190,7 @@ public void revokePermissionsOnTopic(@Suspended final AsyncResponse asyncRespons
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
+ @ApiResponse(code = 404, message = "Namespace doesn't exist"),
@ApiResponse(code = 406, message = "The number of partitions should be "
+ "more than 0 and less than or equal to maxNumPartitionsPerPartitionedTopic"),
@ApiResponse(code = 409, message = "Partitioned topic already exist")})
@@ -218,6 +219,7 @@ public void createPartitionedTopic(
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
+ @ApiResponse(code = 404, message = "Namespace doesn't exist"),
@ApiResponse(code = 409, message = "Partitioned topic already exist"),
@ApiResponse(code = 412,
message = "Failed Reason : Name is invalid or Namespace does not have any clusters configured"),
@@ -272,6 +274,7 @@ public void createNonPartitionedTopic(
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist"),
@ApiResponse(code = 406, message = "The number of partitions should be more than 0"
+ " and less than or equal to maxNumPartitionsPerPartitionedTopic"
+ " and number of new partitions must be greater than existing number of partitions"),
@@ -302,7 +305,8 @@ public void updatePartitionedTopic(
@ApiOperation(hidden = true, value = "Get partitioned topic metadata.")
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
- @ApiResponse(code = 403, message = "Don't have admin permission") })
+ @ApiResponse(code = 403, message = "Don't have admin permission"),
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist")})
public void getPartitionedMetadata(
@Suspended final AsyncResponse asyncResponse,
@PathParam("property") String property,
@@ -329,7 +333,7 @@ public void getPartitionedMetadata(
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Partitioned topic does not exist")})
+ @ApiResponse(code = 404, message = "Namespace or partitioned topic does not exist")})
public void deletePartitionedTopic(@Suspended final AsyncResponse asyncResponse,
@PathParam("property") String property, @PathParam("cluster") String cluster,
@PathParam("namespace") String namespace, @PathParam("topic") @Encoded String encodedTopic,
@@ -349,7 +353,7 @@ public void deletePartitionedTopic(@Suspended final AsyncResponse asyncResponse,
@Path("/{property}/{cluster}/{namespace}/{topic}/unload")
@ApiOperation(hidden = true, value = "Unload a topic")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist") })
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist") })
public void unloadTopic(@Suspended final AsyncResponse asyncResponse, @PathParam("property") String property,
@PathParam("cluster") String cluster, @PathParam("namespace") String namespace,
@PathParam("topic") @Encoded String encodedTopic,
@@ -367,7 +371,7 @@ public void unloadTopic(@Suspended final AsyncResponse asyncResponse, @PathParam
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist"),
@ApiResponse(code = 412, message = "Topic has active producers/subscriptions")})
public void deleteTopic(
@Suspended AsyncResponse asyncResponse,
@@ -401,7 +405,7 @@ public void deleteTopic(
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist") })
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist") })
public void getSubscriptions(@Suspended final AsyncResponse asyncResponse, @PathParam("property") String property,
@PathParam("cluster") String cluster, @PathParam("namespace") String namespace,
@PathParam("topic") @Encoded String encodedTopic,
@@ -422,7 +426,7 @@ public void getSubscriptions(@Suspended final AsyncResponse asyncResponse, @Path
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist")})
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist")})
public void getStats(
@Suspended final AsyncResponse asyncResponse,
@PathParam("property") String property, @PathParam("cluster") String cluster,
@@ -448,7 +452,7 @@ public void getStats(
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist") })
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist")})
public void getInternalStats(
@Suspended final AsyncResponse asyncResponse,
@PathParam("property") String property,
@@ -472,7 +476,7 @@ public void getInternalStats(
@Path("{property}/{cluster}/{namespace}/{topic}/internal-info")
@ApiOperation(hidden = true, value = "Get the stored topic metadata.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist")})
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist")})
public void getManagedLedgerInfo(@PathParam("property") String property, @PathParam("cluster") String cluster,
@PathParam("namespace") String namespace, @PathParam("topic") @Encoded
String encodedTopic,
@@ -488,7 +492,7 @@ public void getManagedLedgerInfo(@PathParam("property") String property, @PathPa
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist") })
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist")})
public void getPartitionedStats(@Suspended final AsyncResponse asyncResponse,
@PathParam("property") String property,
@PathParam("cluster") String cluster, @PathParam("namespace") String namespace,
@@ -512,7 +516,7 @@ public void getPartitionedStats(@Suspended final AsyncResponse asyncResponse,
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist") })
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist")})
public void getPartitionedStatsInternal(
@Suspended final AsyncResponse asyncResponse,
@PathParam("property") String property,
@@ -538,7 +542,7 @@ public void getPartitionedStatsInternal(
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic or subscription does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic or subscription does not exist"),
@ApiResponse(code = 412, message = "Subscription has active consumers")})
public void deleteSubscription(@Suspended final AsyncResponse asyncResponse, @PathParam("property") String property,
@PathParam("cluster") String cluster, @PathParam("namespace") String namespace,
@@ -563,7 +567,7 @@ public void deleteSubscription(@Suspended final AsyncResponse asyncResponse, @Pa
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponse(code = 405, message = "Operation not allowed on non-persistent topic"),
- @ApiResponse(code = 404, message = "Topic or subscription does not exist")})
+ @ApiResponse(code = 404, message = "Namespace or topic or subscription does not exist")})
public void skipAllMessages(@Suspended final AsyncResponse asyncResponse, @PathParam("property") String property,
@PathParam("cluster") String cluster, @PathParam("namespace") String namespace,
@PathParam("topic") @Encoded String encodedTopic, @PathParam("subName") String encodedSubName,
@@ -584,7 +588,7 @@ public void skipAllMessages(@Suspended final AsyncResponse asyncResponse, @PathP
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic or subscription does not exist") })
+ @ApiResponse(code = 404, message = "Namesapce or topic or subscription does not exist") })
public void skipMessages(@Suspended final AsyncResponse asyncResponse, @PathParam("property") String property,
@PathParam("cluster") String cluster, @PathParam("namespace") String namespace,
@PathParam("topic") @Encoded String encodedTopic, @PathParam("subName") String encodedSubName,
@@ -606,7 +610,7 @@ public void skipMessages(@Suspended final AsyncResponse asyncResponse, @PathPara
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic or subscription does not exist") })
+ @ApiResponse(code = 404, message = "Namespace or topic or subscription does not exist") })
public void expireTopicMessages(@Suspended final AsyncResponse asyncResponse,
@PathParam("property") String property, @PathParam("cluster") String cluster,
@PathParam("namespace") String namespace, @PathParam("topic") @Encoded String encodedTopic,
@@ -631,7 +635,7 @@ public void expireTopicMessages(@Suspended final AsyncResponse asyncResponse,
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant or"
+ "subscriber is not authorized to access this operation"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic or subscription does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic or subscription does not exist"),
@ApiResponse(code = 405, message = "Expiry messages on a non-persistent topic is not allowed"),
@ApiResponse(code = 500, message = "Internal server error"),
@ApiResponse(code = 503, message = "Failed to validate global cluster configuration")})
@@ -667,7 +671,7 @@ public void expireTopicMessages(
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic or subscription does not exist") })
+ @ApiResponse(code = 404, message = "Namespace or topic or subscription does not exist") })
public void expireMessagesForAllSubscriptions(@Suspended final AsyncResponse asyncResponse,
@PathParam("property") String property, @PathParam("cluster") String cluster,
@PathParam("namespace") String namespace, @PathParam("topic") @Encoded String encodedTopic,
@@ -691,7 +695,7 @@ public void expireMessagesForAllSubscriptions(@Suspended final AsyncResponse asy
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic/Subscription does not exist")})
+ @ApiResponse(code = 404, message = "Namespace or topic or subscription does not exist")})
public void resetCursor(@Suspended final AsyncResponse asyncResponse, @PathParam("property") String property,
@PathParam("cluster") String cluster, @PathParam("namespace") String namespace,
@PathParam("topic") @Encoded String encodedTopic, @PathParam("subName") String encodedSubName,
@@ -725,7 +729,7 @@ public void resetCursor(@Suspended final AsyncResponse asyncResponse, @PathParam
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic/Subscription does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic or subscription does not exist"),
@ApiResponse(code = 405, message = "Not supported for partitioned topics")})
public void resetCursorOnPosition(@Suspended final AsyncResponse asyncResponse,
@PathParam("property") String property, @PathParam("cluster") String cluster,
@@ -753,7 +757,7 @@ public void resetCursorOnPosition(@Suspended final AsyncResponse asyncResponse,
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 400, message = "Create subscription on non persistent topic is not supported"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic/Subscription does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic or subscription does not exist"),
@ApiResponse(code = 405, message = "Not supported for partitioned topics")})
public void createSubscription(@Suspended final AsyncResponse asyncResponse, @PathParam("property") String property,
@PathParam("cluster") String cluster, @PathParam("namespace") String namespace,
@@ -781,7 +785,8 @@ public void createSubscription(@Suspended final AsyncResponse asyncResponse, @Pa
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic, subscription or the message position does not exist") })
+ @ApiResponse(code = 404, message = "Namespace or topic or subscription or the message position does not"
+ + " exist") })
public void peekNthMessage(
@Suspended final AsyncResponse asyncResponse,
@PathParam("property") String property, @PathParam("cluster") String cluster,
@@ -807,7 +812,7 @@ public void peekNthMessage(
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 403, message = "Don't java admin permission"),
- @ApiResponse(code = 404, message = "Topic, subscription or the messageId does not exist")
+ @ApiResponse(code = 404, message = "Namespace or topic or subscription or the messageId does not exist")
})
public void getMessageByID(@Suspended final AsyncResponse asyncResponse, @PathParam("property") String property,
@PathParam("cluster") String cluster, @PathParam("namespace") String namespace,
@@ -862,7 +867,7 @@ public void getBacklog(
@ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponse(code = 405, message = "Operation not allowed on non-persistent topic"),
@ApiResponse(code = 406, message = "Need to provide a persistent topic name"),
- @ApiResponse(code = 404, message = "Topic does not exist") })
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist") })
public void terminate(
@Suspended final AsyncResponse asyncResponse,
@PathParam("property") String property,
@@ -889,7 +894,7 @@ public void terminate(
+ "messages to be published and will let consumer to drain existing messages in backlog")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponse(code = 405, message = "Operation not allowed on non-persistent topic"),
- @ApiResponse(code = 404, message = "Topic does not exist")})
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist")})
public void terminatePartitionedTopic(@Suspended final AsyncResponse asyncResponse,
@PathParam("property") String property, @PathParam("cluster") String cluster,
@PathParam("namespace") String namespace, @PathParam("topic") @Encoded String encodedTopic,
@@ -905,7 +910,7 @@ public void terminatePartitionedTopic(@Suspended final AsyncResponse asyncRespon
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponse(code = 405, message = "Operation not allowed on persistent topic"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist"),
@ApiResponse(code = 409, message = "Compaction already running")})
public void compact(@Suspended final AsyncResponse asyncResponse,
@PathParam("property") String property, @PathParam("cluster") String cluster,
@@ -928,7 +933,7 @@ public void compact(@Suspended final AsyncResponse asyncResponse,
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponse(code = 405, message = "Operation not allowed on persistent topic"),
- @ApiResponse(code = 404, message = "Topic does not exist, or compaction hasn't run") })
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist, or compaction hasn't run") })
public void compactionStatus(
@Suspended final AsyncResponse asyncResponse,
@PathParam("property") String property, @PathParam("cluster") String cluster,
@@ -954,7 +959,7 @@ public void compactionStatus(
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponse(code = 405, message = "Operation not allowed on persistent topic"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist"),
@ApiResponse(code = 409, message = "Offload already running")})
public void triggerOffload(@Suspended final AsyncResponse asyncResponse,
@PathParam("tenant") String tenant,
@@ -980,7 +985,7 @@ public void triggerOffload(@Suspended final AsyncResponse asyncResponse,
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponse(code = 405, message = "Operation not allowed on persistent topic"),
- @ApiResponse(code = 404, message = "Topic does not exist")})
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist")})
public void offloadStatus(@Suspended final AsyncResponse asyncResponse,
@PathParam("tenant") String tenant,
@PathParam("cluster") String cluster,
@@ -1005,7 +1010,7 @@ public void offloadStatus(@Suspended final AsyncResponse asyncResponse,
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant or"
+ "subscriber is not authorized to access this operation"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist"),
@ApiResponse(code = 405, message = "Operation is not allowed on the persistent topic"),
@ApiResponse(code = 412, message = "Topic name is not valid"),
@ApiResponse(code = 500, message = "Internal server error"),
@@ -1038,7 +1043,7 @@ public void getLastMessageId(
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant or "
+ "subscriber is not authorized to access this operation"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic or subscription does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic or subscription does not exist"),
@ApiResponse(code = 405, message = "Operation not allowed on this topic"),
@ApiResponse(code = 412, message = "Can't find owner for topic"),
@ApiResponse(code = 500, message = "Internal server error"),
@@ -1075,7 +1080,7 @@ public void setReplicatedSubscriptionStatus(
@ApiResponses(value = {
@ApiResponse(code = 401, message = "Don't have permission to administrate resources"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist"),
@ApiResponse(code = 412, message = "Can't find owner for topic"),
@ApiResponse(code = 500, message = "Internal server error")})
public void getReplicatedSubscriptionStatus(
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/Properties.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/Properties.java
index 50d5f245b8399..66764d41ce467 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/Properties.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/Properties.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/ResourceQuotas.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/ResourceQuotas.java
index 6773c3d8a99ff..37244fea1cd6c 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/ResourceQuotas.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/ResourceQuotas.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/SchemasResource.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/SchemasResource.java
index 13bfba351216b..ca90eb4bac0c0 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/SchemasResource.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/SchemasResource.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/package-info.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/package-info.java
index 158a2802eb19b..f6cffb50fb6e3 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/package-info.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Bookies.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Bookies.java
index 05eb1dd94f92d..a50bc7515ff6f 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Bookies.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Bookies.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/BrokerStats.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/BrokerStats.java
index 7e388596a4afe..aba6cb1a0aba4 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/BrokerStats.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/BrokerStats.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Brokers.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Brokers.java
index 2a9e13c79bdbd..088962e6ed098 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Brokers.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Brokers.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Clusters.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Clusters.java
index 1e0dede8e48dd..8b9d35c80939d 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Clusters.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Clusters.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Functions.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Functions.java
index a83ea8cd51473..0d302bec065bc 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Functions.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Functions.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -53,7 +53,7 @@
public class Functions extends AdminResource {
FunctionsV2 extends WorkerService> functions() {
- return pulsar().getWorkerService().getFunctionsV2();
+ return validateAndGetWorkerService().getFunctionsV2();
}
@POST
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Namespaces.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Namespaces.java
index 9b07427c72d49..b6bf1f0927cc6 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Namespaces.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Namespaces.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -808,6 +808,7 @@ public void unloadNamespace(@Suspended final AsyncResponse asyncResponse,
@ApiOperation(value = "Unload a namespace bundle")
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace"),
+ @ApiResponse(code = 404, message = "Namespace doesn't exist"),
@ApiResponse(code = 403, message = "Don't have admin permission") })
public void unloadNamespaceBundle(@Suspended final AsyncResponse asyncResponse,
@PathParam("tenant") String tenant, @PathParam("namespace") String namespace,
@@ -834,6 +835,7 @@ public void unloadNamespaceBundle(@Suspended final AsyncResponse asyncResponse,
@ApiOperation(value = "Split a namespace bundle")
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace"),
+ @ApiResponse(code = 404, message = "Namespace doesn't exist"),
@ApiResponse(code = 403, message = "Don't have admin permission") })
public void splitNamespaceBundle(
@Suspended final AsyncResponse asyncResponse,
@@ -2088,6 +2090,58 @@ public void setOffloadThreshold(@PathParam("tenant") String tenant,
internalSetOffloadThreshold(newThreshold);
}
+ @GET
+ @Path("/{tenant}/{namespace}/offloadThresholdInSeconds")
+ @ApiOperation(value = "Maximum number of bytes stored on the pulsar cluster for a topic,"
+ + " before the broker will start offloading to longterm storage",
+ notes = "A negative value disables automatic offloading")
+ @ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"),
+ @ApiResponse(code = 404, message = "Namespace doesn't exist") })
+ public void getOffloadThresholdInSeconds(
+ @Suspended final AsyncResponse asyncResponse,
+ @PathParam("tenant") String tenant,
+ @PathParam("namespace") String namespace) {
+ validateNamespaceName(tenant, namespace);
+ validateNamespacePolicyOperationAsync(namespaceName, PolicyName.OFFLOAD, PolicyOperation.READ)
+ .thenCompose(__ -> getNamespacePoliciesAsync(namespaceName))
+ .thenAccept(policies -> {
+ if (policies.offload_policies == null
+ || policies.offload_policies.getManagedLedgerOffloadThresholdInSeconds() == null) {
+ asyncResponse.resume(policies.offload_threshold_in_seconds);
+ } else {
+ asyncResponse.resume(policies.offload_policies.getManagedLedgerOffloadThresholdInSeconds());
+ }
+ })
+ .exceptionally(ex -> {
+ log.error("[{}] Failed to get offload threshold on namespace {}", clientAppId(), namespaceName, ex);
+ resumeAsyncResponseExceptionally(asyncResponse, ex);
+ return null;
+ });
+ }
+
+ @PUT
+ @Path("/{tenant}/{namespace}/offloadThresholdInSeconds")
+ @ApiOperation(value = "Set maximum number of seconds stored on the pulsar cluster for a topic,"
+ + " before the broker will start offloading to longterm storage",
+ notes = "A negative value disables automatic offloading")
+ @ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
+ @ApiResponse(code = 404, message = "Namespace doesn't exist"),
+ @ApiResponse(code = 409, message = "Concurrent modification"),
+ @ApiResponse(code = 412, message = "offloadThresholdInSeconds value is not valid") })
+ public void setOffloadThresholdInSeconds(
+ @Suspended final AsyncResponse response,
+ @PathParam("tenant") String tenant,
+ @PathParam("namespace") String namespace,
+ long newThreshold) {
+ validateNamespaceName(tenant, namespace);
+ internalSetOffloadThresholdInSecondsAsync(newThreshold)
+ .thenAccept(response::resume)
+ .exceptionally(t -> {
+ resumeAsyncResponseExceptionally(response, t);
+ return null;
+ });
+ }
+
@GET
@Path("/{tenant}/{namespace}/offloadDeletionLagMs")
@ApiOperation(value = "Number of milliseconds to wait before deleting a ledger segment which has been offloaded"
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/NonPersistentTopics.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/NonPersistentTopics.java
index 5b0deccd0378b..de1ee46fd8ed5 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/NonPersistentTopics.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/NonPersistentTopics.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.pulsar.broker.admin.v2;
import io.swagger.annotations.Api;
@@ -190,7 +189,7 @@ public void createPartitionedTopic(
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist"),
@ApiResponse(code = 412, message = "Partitioned topic name is invalid"),
@ApiResponse(code = 500, message = "Internal server error"),
@ApiResponse(code = 503, message = "Failed to validate global cluster configuration")
@@ -542,7 +541,7 @@ public void getEntryFilters(@Suspended AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/entryFilters")
@ApiOperation(value = "Set entry filters for specified topic")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Tenant or namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, please enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -570,7 +569,7 @@ public void setEntryFilters(@Suspended final AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/entryFilters")
@ApiOperation(value = "Remove entry filters for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Tenant or namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, please enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/PersistentTopics.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/PersistentTopics.java
index 6c63129c4835e..9ba408d1b5209 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/PersistentTopics.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/PersistentTopics.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -69,6 +69,7 @@
import org.apache.pulsar.common.policies.data.SchemaCompatibilityStrategy;
import org.apache.pulsar.common.policies.data.SubscribeRate;
import org.apache.pulsar.common.policies.data.TopicPolicies;
+import org.apache.pulsar.common.policies.data.impl.AutoSubscriptionCreationOverrideImpl;
import org.apache.pulsar.common.policies.data.impl.BacklogQuotaImpl;
import org.apache.pulsar.common.policies.data.impl.DispatchRateImpl;
import org.apache.pulsar.common.util.Codec;
@@ -256,7 +257,7 @@ public void revokePermissionsOnTopic(
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Tenant does not exist"),
+ @ApiResponse(code = 404, message = "Tenant or namespace doesn't exist"),
@ApiResponse(code = 406, message = "The number of partitions should be more than 0 and"
+ " less than or equal to maxNumPartitionsPerPartitionedTopic"),
@ApiResponse(code = 409, message = "Partitioned topic already exist"),
@@ -299,7 +300,7 @@ public void createPartitionedTopic(
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Tenant does not exist"),
+ @ApiResponse(code = 404, message = "Tenant or namespace doesn't exist"),
@ApiResponse(code = 406, message = "The number of partitions should be more than 0 and"
+ " less than or equal to maxNumPartitionsPerPartitionedTopic"),
@ApiResponse(code = 409, message = "Partitioned topic already exist"),
@@ -340,6 +341,7 @@ public void createPartitionedTopic(
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant"),
+ @ApiResponse(code = 404, message = "Tenant or namespace doesn't exist"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponse(code = 409, message = "Partitioned topic already exist"),
@ApiResponse(code = 412,
@@ -941,7 +943,7 @@ public void getPartitionedMetadata(
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist"),
@ApiResponse(code = 409, message = "Concurrent modification"),
@ApiResponse(code = 412, message = "Topic name is invalid"),
@ApiResponse(code = 500, message = "Internal server error")
@@ -976,7 +978,7 @@ public void getProperties(
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant or"
+ "subscriber is not authorized to access this operation"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic/Subscription does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic or subscription does not exist"),
@ApiResponse(code = 405, message = "Method Not Allowed"),
@ApiResponse(code = 500, message = "Internal server error"),
@ApiResponse(code = 503, message = "Failed to validate global cluster configuration")
@@ -1081,7 +1083,7 @@ public void deletePartitionedTopic(
@ApiResponses(value = {
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist"),
@ApiResponse(code = 409, message = "Concurrent modification"),
@ApiResponse(code = 412, message = "Topic name is not valid or can't find owner for topic"),
@ApiResponse(code = 500, message = "Internal server error"),
@@ -1116,7 +1118,7 @@ public void unloadTopic(
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist"),
@ApiResponse(code = 412, message = "Topic has active producers/subscriptions"),
@ApiResponse(code = 500, message = "Internal server error")})
public void deleteTopic(
@@ -1159,7 +1161,7 @@ public void deleteTopic(
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist"),
@ApiResponse(code = 412, message = "Topic name is not valid"),
@ApiResponse(code = 500, message = "Internal server error"),
@ApiResponse(code = 503, message = "Failed to validate global cluster configuration"),
@@ -1191,7 +1193,7 @@ public void getSubscriptions(
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist"),
@ApiResponse(code = 412, message = "Topic name is not valid"),
@ApiResponse(code = 500, message = "Internal server error"),
@ApiResponse(code = 503, message = "Failed to validate global cluster configuration") })
@@ -1232,7 +1234,7 @@ public void getStats(
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist"),
@ApiResponse(code = 412, message = "Topic name is not valid"),
@ApiResponse(code = 500, message = "Internal server error"),
@ApiResponse(code = 503, message = "Failed to validate global cluster configuration") })
@@ -1265,7 +1267,7 @@ public void getInternalStats(
@ApiResponses(value = {
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist"),
@ApiResponse(code = 412, message = "Topic name is not valid"),
@ApiResponse(code = 500, message = "Internal server error"),
@ApiResponse(code = 503, message = "Failed to validate global cluster configuration")})
@@ -1290,7 +1292,7 @@ public void getManagedLedgerInfo(
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist"),
@ApiResponse(code = 412, message = "Partitioned topic name is invalid"),
@ApiResponse(code = 500, message = "Internal server error"),
@ApiResponse(code = 503, message = "Failed to validate global cluster configuration")
@@ -1332,7 +1334,7 @@ public void getPartitionedStats(
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist"),
@ApiResponse(code = 412, message = "Topic name is not valid"),
@ApiResponse(code = 500, message = "Internal server error"),
@ApiResponse(code = 503, message = "Failed to validate global cluster configuration") })
@@ -1366,7 +1368,7 @@ public void getPartitionedStatsInternal(
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic or subscription does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic or subscription does not exist"),
@ApiResponse(code = 412, message = "Subscription has active consumers"),
@ApiResponse(code = 500, message = "Internal server error"),
@ApiResponse(code = 503, message = "Failed to validate global cluster configuration")})
@@ -1405,7 +1407,7 @@ public void deleteSubscription(
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant or"
+ "subscriber is not authorized to access this operation"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic or subscription does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic or subscription does not exist"),
@ApiResponse(code = 405, message = "Operation not allowed on non-persistent topic"),
@ApiResponse(code = 412, message = "Can't find owner for topic"),
@ApiResponse(code = 500, message = "Internal server error"),
@@ -1439,7 +1441,7 @@ public void skipAllMessages(
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic or subscription does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic or subscription does not exist"),
@ApiResponse(code = 405, message = "Skipping messages on a partitioned topic is not allowed"),
@ApiResponse(code = 500, message = "Internal server error"),
@ApiResponse(code = 503, message = "Failed to validate global cluster configuration")
@@ -1476,7 +1478,7 @@ public void skipMessages(
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant or"
+ "subscriber is not authorized to access this operation"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic or subscription does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic or subscription does not exist"),
@ApiResponse(code = 405, message = "Expiry messages on a non-persistent topic is not allowed"),
@ApiResponse(code = 500, message = "Internal server error"),
@ApiResponse(code = 503, message = "Failed to validate global cluster configuration")})
@@ -1513,7 +1515,7 @@ public void expireTopicMessages(
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant or"
+ "subscriber is not authorized to access this operation"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic or subscription does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic or subscription does not exist"),
@ApiResponse(code = 405, message = "Expiry messages on a non-persistent topic is not allowed"),
@ApiResponse(code = 500, message = "Internal server error"),
@ApiResponse(code = 503, message = "Failed to validate global cluster configuration")})
@@ -1552,7 +1554,7 @@ public void expireTopicMessages(
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant or"
+ "subscriber is not authorized to access this operation"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic or subscription does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic or subscription does not exist"),
@ApiResponse(code = 405, message = "Expiry messages on a non-persistent topic is not allowed"),
@ApiResponse(code = 412, message = "Can't find owner for topic"),
@ApiResponse(code = 500, message = "Internal server error"),
@@ -1589,7 +1591,7 @@ public void expireMessagesForAllSubscriptions(
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant or"
+ "subscriber is not authorized to access this operation"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic/Subscription does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic or subscription does not exist"),
@ApiResponse(code = 405, message = "Not supported for partitioned topics"),
@ApiResponse(code = 500, message = "Internal server error"),
@ApiResponse(code = 503, message = "Failed to validate global cluster configuration")})
@@ -1643,7 +1645,7 @@ public void createSubscription(
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant or"
+ "subscriber is not authorized to access this operation"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic/Subscription does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic or subscription does not exist"),
@ApiResponse(code = 405, message = "Method Not Allowed"),
@ApiResponse(code = 412, message = "Failed to reset cursor on subscription or "
+ "Unable to find position for timestamp specified"),
@@ -1693,7 +1695,7 @@ public void resetCursor(
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant or"
+ "subscriber is not authorized to access this operation"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic/Subscription does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic or subscription does not exist"),
@ApiResponse(code = 405, message = "Method Not Allowed"),
@ApiResponse(code = 500, message = "Internal server error"),
@ApiResponse(code = 503, message = "Failed to validate global cluster configuration")
@@ -1730,7 +1732,7 @@ public void updateSubscriptionProperties(
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant or"
+ "subscriber is not authorized to access this operation"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic/Subscription does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic or subscription does not exist"),
@ApiResponse(code = 405, message = "Method Not Allowed"),
@ApiResponse(code = 500, message = "Internal server error"),
@ApiResponse(code = 503, message = "Failed to validate global cluster configuration")
@@ -1766,7 +1768,7 @@ public void getSubscriptionProperties(
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant or"
+ "subscriber is not authorized to access this operation"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic/Subscription does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic or subscription does not exist"),
@ApiResponse(code = 405, message = "Method Not Allowed"),
@ApiResponse(code = 500, message = "Internal server error"),
@ApiResponse(code = 503, message = "Failed to validate global cluster configuration")
@@ -1812,7 +1814,7 @@ public void analyzeSubscriptionBacklog(
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant or"
+ "subscriber is not authorized to access this operation"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic/Subscription does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic or subscription does not exist"),
@ApiResponse(code = 405, message = "Not supported for partitioned topics"),
@ApiResponse(code = 412, message = "Unable to find position for position specified"),
@ApiResponse(code = 500, message = "Internal server error"),
@@ -1850,7 +1852,8 @@ public void resetCursorOnPosition(
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant or"
+ "subscriber is not authorized to access this operation"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic, subscription or the message position does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic, subscription or the message position does not"
+ + " exist"),
@ApiResponse(code = 405, message = "Skipping messages on a non-persistent topic is not allowed"),
@ApiResponse(code = 412, message = "Topic name is not valid"),
@ApiResponse(code = 500, message = "Internal server error"),
@@ -1889,7 +1892,7 @@ public void peekNthMessage(
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic, the message position does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic, the message position does not exist"),
@ApiResponse(code = 405, message = "If given partitioned topic"),
@ApiResponse(code = 412, message = "Topic name is not valid"),
@ApiResponse(code = 500, message = "Internal server error")})
@@ -1932,7 +1935,8 @@ public void examineMessage(
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant or"
+ "subscriber is not authorized to access this operation"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic, subscription or the message position does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic, subscription or the message position does not"
+ + " exist"),
@ApiResponse(code = 405, message = "Skipping messages on a non-persistent topic is not allowed"),
@ApiResponse(code = 412, message = "Topic name is not valid"),
@ApiResponse(code = 500, message = "Internal server error"),
@@ -1969,7 +1973,7 @@ public void getMessageById(
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant or"
+ "subscriber is not authorized to access this operation"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist"),
@ApiResponse(code = 405, message = "Topic is not non-partitioned and persistent"),
@ApiResponse(code = 412, message = "Topic name is not valid"),
@ApiResponse(code = 500, message = "Internal server error"),
@@ -2044,7 +2048,7 @@ public void getBacklog(
@ApiOperation(value = "Calculate backlog size by a message ID (in bytes).")
@ApiResponses(value = {
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist"),
@ApiResponse(code = 412, message = "Topic name is not valid"),
@ApiResponse(code = 500, message = "Internal server error"),
@ApiResponse(code = 503, message = "Failed to validate global cluster configuration") })
@@ -2066,7 +2070,7 @@ public void getBacklogSizeByMessageId(
@Path("/{tenant}/{namespace}/{topic}/backlogQuotaMap")
@ApiOperation(value = "Get backlog quota map on a topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic policy does not exist"),
+ @ApiResponse(code = 404, message = "Topic policy or namespace does not exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, to enable the topic level policy and retry")})
public void getBacklogQuotaMap(
@@ -2092,7 +2096,7 @@ public void getBacklogQuotaMap(
@Path("/{tenant}/{namespace}/{topic}/backlogQuota")
@ApiOperation(value = "Set a backlog quota for a topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 409, message = "Concurrent modification"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, to enable the topic level policy and retry"),
@@ -2105,7 +2109,8 @@ public void setBacklogQuota(
@ApiParam(value = "Whether leader broker redirected this call to this broker. For internal use.")
@QueryParam("authoritative") @DefaultValue("false") boolean authoritative,
@QueryParam("isGlobal") @DefaultValue("false") boolean isGlobal,
- @QueryParam("backlogQuotaType") BacklogQuotaType backlogQuotaType, BacklogQuotaImpl backlogQuota) {
+ @QueryParam("backlogQuotaType") BacklogQuotaType backlogQuotaType,
+ @ApiParam(value = "backlog quota policies for the specified topic") BacklogQuotaImpl backlogQuota) {
validateTopicName(tenant, namespace, encodedTopic);
preValidation(authoritative)
.thenCompose(__ -> internalSetBacklogQuota(backlogQuotaType, backlogQuota, isGlobal))
@@ -2120,7 +2125,7 @@ public void setBacklogQuota(
@Path("/{tenant}/{namespace}/{topic}/backlogQuota")
@ApiOperation(value = "Remove a backlog quota policy from a topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, to enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -2145,7 +2150,7 @@ public void removeBacklogQuota(@Suspended final AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/replication")
@ApiOperation(value = "Get the replication clusters for a topic")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405, message =
"Topic level policy is disabled, enable the topic level policy and retry")})
public void getReplicationClusters(@Suspended final AsyncResponse asyncResponse,
@@ -2177,7 +2182,7 @@ public void getReplicationClusters(@Suspended final AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/replication")
@ApiOperation(value = "Set the replication clusters for a topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 409, message = "Concurrent modification"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, to enable the topic level policy and retry"),
@@ -2203,7 +2208,7 @@ public void setReplicationClusters(
@Path("/{tenant}/{namespace}/{topic}/replication")
@ApiOperation(value = "Remove the replication clusters from a topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, to enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -2227,7 +2232,7 @@ public void removeReplicationClusters(@Suspended final AsyncResponse asyncRespon
@Path("/{tenant}/{namespace}/{topic}/messageTTL")
@ApiOperation(value = "Get message TTL in seconds for a topic")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405, message =
"Topic level policy is disabled, enable the topic level policy and retry")})
public void getMessageTTL(@Suspended final AsyncResponse asyncResponse,
@@ -2262,7 +2267,7 @@ public void getMessageTTL(@Suspended final AsyncResponse asyncResponse,
@ApiOperation(value = "Set message TTL in seconds for a topic")
@ApiResponses(value = {@ApiResponse(code = 403, message =
"Not authenticate to perform the request or policy is read only"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405, message =
"Topic level policy is disabled, enable the topic level policy and retry"),
@ApiResponse(code = 412, message = "Invalid message TTL value")})
@@ -2270,7 +2275,7 @@ public void setMessageTTL(@Suspended final AsyncResponse asyncResponse,
@PathParam("tenant") String tenant,
@PathParam("namespace") String namespace,
@PathParam("topic") @Encoded String encodedTopic,
- @ApiParam(value = "TTL in seconds for the specified namespace", required = true)
+ @ApiParam(value = "TTL in seconds for the specified topic", required = true)
@QueryParam("messageTTL") Integer messageTTL,
@QueryParam("isGlobal") @DefaultValue("false") boolean isGlobal,
@ApiParam(value = "Whether leader broker redirected this call to this broker. For internal use.")
@@ -2291,7 +2296,7 @@ public void setMessageTTL(@Suspended final AsyncResponse asyncResponse,
@ApiResponses(value = {
@ApiResponse(code = 403,
message = "Not authenticate to perform the request or policy is read only"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, enable the topic level policy and retry"),
@ApiResponse(code = 412, message = "Invalid message TTL value")})
@@ -2394,7 +2399,7 @@ public void removeDeduplication(@Suspended final AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/retention")
@ApiOperation(value = "Get retention configuration for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, to enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -2420,7 +2425,7 @@ public void getRetention(@Suspended final AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/retention")
@ApiOperation(value = "Set retention configuration for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405, message =
"Topic level policy is disabled, to enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification"),
@@ -2432,7 +2437,7 @@ public void setRetention(@Suspended final AsyncResponse asyncResponse,
@ApiParam(value = "Whether leader broker redirected this call to this broker. For internal use.")
@QueryParam("authoritative") @DefaultValue("false") boolean authoritative,
@QueryParam("isGlobal") @DefaultValue("false") boolean isGlobal,
- @ApiParam(value = "Retention policies for the specified namespace") RetentionPolicies retention) {
+ @ApiParam(value = "Retention policies for the specified topic") RetentionPolicies retention) {
validateTopicName(tenant, namespace, encodedTopic);
preValidation(authoritative)
.thenCompose(__ -> internalSetRetention(retention, isGlobal))
@@ -2457,7 +2462,7 @@ public void setRetention(@Suspended final AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/retention")
@ApiOperation(value = "Remove retention configuration for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, to enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification"),
@@ -2489,7 +2494,7 @@ public void removeRetention(@Suspended final AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/persistence")
@ApiOperation(value = "Get configuration of persistence policies for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, to enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -2515,7 +2520,7 @@ public void getPersistence(@Suspended final AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/persistence")
@ApiOperation(value = "Set configuration of persistence policies for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, to enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification"),
@@ -2554,7 +2559,7 @@ public void setPersistence(@Suspended final AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/persistence")
@ApiOperation(value = "Remove configuration of persistence policies for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, to enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -2585,7 +2590,7 @@ public void removePersistence(@Suspended final AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/maxSubscriptionsPerTopic")
@ApiOperation(value = "Get maxSubscriptionsPerTopic config for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, to enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -2611,7 +2616,7 @@ public void getMaxSubscriptionsPerTopic(@Suspended final AsyncResponse asyncResp
@Path("/{tenant}/{namespace}/{topic}/maxSubscriptionsPerTopic")
@ApiOperation(value = "Set maxSubscriptionsPerTopic config for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, to enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification"),
@@ -2643,7 +2648,7 @@ public void setMaxSubscriptionsPerTopic(@Suspended final AsyncResponse asyncResp
@Path("/{tenant}/{namespace}/{topic}/maxSubscriptionsPerTopic")
@ApiOperation(value = "Remove maxSubscriptionsPerTopic config for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, to enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -2672,7 +2677,7 @@ public void removeMaxSubscriptionsPerTopic(@Suspended final AsyncResponse asyncR
@Path("/{tenant}/{namespace}/{topic}/replicatorDispatchRate")
@ApiOperation(value = "Get replicatorDispatchRate config for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, to enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -2698,7 +2703,7 @@ public void getReplicatorDispatchRate(@Suspended final AsyncResponse asyncRespon
@Path("/{tenant}/{namespace}/{topic}/replicatorDispatchRate")
@ApiOperation(value = "Set replicatorDispatchRate config for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, to enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification"),
@@ -2730,7 +2735,7 @@ public void setReplicatorDispatchRate(@Suspended final AsyncResponse asyncRespon
@Path("/{tenant}/{namespace}/{topic}/replicatorDispatchRate")
@ApiOperation(value = "Remove replicatorDispatchRate config for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, to enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -2759,7 +2764,7 @@ public void removeReplicatorDispatchRate(@Suspended final AsyncResponse asyncRes
@Path("/{tenant}/{namespace}/{topic}/maxProducers")
@ApiOperation(value = "Get maxProducers config for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, to enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -2785,7 +2790,7 @@ public void getMaxProducers(@Suspended final AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/maxProducers")
@ApiOperation(value = "Set maxProducers config for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, to enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification"),
@@ -2819,7 +2824,7 @@ public void setMaxProducers(@Suspended final AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/maxProducers")
@ApiOperation(value = "Remove maxProducers config for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, to enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -2850,7 +2855,7 @@ public void removeMaxProducers(@Suspended final AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/maxConsumers")
@ApiOperation(value = "Get maxConsumers config for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, to enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -2876,7 +2881,7 @@ public void getMaxConsumers(@Suspended final AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/maxConsumers")
@ApiOperation(value = "Set maxConsumers config for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, to enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification"),
@@ -2910,7 +2915,7 @@ public void setMaxConsumers(@Suspended final AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/maxConsumers")
@ApiOperation(value = "Remove maxConsumers config for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, to enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -2941,7 +2946,7 @@ public void removeMaxConsumers(@Suspended final AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/maxMessageSize")
@ApiOperation(value = "Get maxMessageSize config for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, to enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -2968,7 +2973,7 @@ public void getMaxMessageSize(@Suspended final AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/maxMessageSize")
@ApiOperation(value = "Set maxMessageSize config for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, to enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification"),
@@ -3004,7 +3009,7 @@ public void setMaxMessageSize(@Suspended final AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/maxMessageSize")
@ApiOperation(value = "Remove maxMessageSize config for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, to enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -3041,7 +3046,7 @@ public void removeMaxMessageSize(@Suspended final AsyncResponse asyncResponse,
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant or"
+ "subscriber is not authorized to access this operation"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist"),
@ApiResponse(code = 405, message = "Termination of a partitioned topic is not allowed"),
@ApiResponse(code = 406, message = "Need to provide a persistent topic name"),
@ApiResponse(code = 412, message = "Topic name is not valid"),
@@ -3077,7 +3082,7 @@ public void terminate(
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant or"
+ "subscriber is not authorized to access this operation"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist"),
@ApiResponse(code = 405, message = "Termination of a non-partitioned topic is not allowed"),
@ApiResponse(code = 412, message = "Topic name is not valid"),
@ApiResponse(code = 500, message = "Internal server error"),
@@ -3104,7 +3109,7 @@ public void terminatePartitionedTopic(@Suspended final AsyncResponse asyncRespon
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant or"
+ "subscriber is not authorized to access this operation"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist"),
@ApiResponse(code = 405, message = "Operation is not allowed on the persistent topic"),
@ApiResponse(code = 409, message = "Compaction already running"),
@ApiResponse(code = 412, message = "Topic name is not valid"),
@@ -3138,7 +3143,7 @@ public void compact(
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant or"
+ "subscriber is not authorized to access this operation"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist, or compaction hasn't run"),
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist, or compaction hasn't run"),
@ApiResponse(code = 405, message = "Operation is not allowed on the persistent topic"),
@ApiResponse(code = 412, message = "Topic name is not valid"),
@ApiResponse(code = 500, message = "Internal server error"),
@@ -3175,7 +3180,7 @@ public void compactionStatus(
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant or"
+ "subscriber is not authorized to access this operation"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist"),
@ApiResponse(code = 405, message = "Operation is not allowed on the persistent topic"),
@ApiResponse(code = 409, message = "Offload already running"),
@ApiResponse(code = 412, message = "Topic name is not valid"),
@@ -3213,7 +3218,7 @@ public void triggerOffload(
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant or"
+ "subscriber is not authorized to access this operation"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist"),
@ApiResponse(code = 405, message = "Operation is not allowed on the persistent topic"),
@ApiResponse(code = 412, message = "Topic name is not valid"),
@ApiResponse(code = 500, message = "Internal server error"),
@@ -3246,7 +3251,7 @@ public void offloadStatus(
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant or"
+ "subscriber is not authorized to access this operation"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist"),
@ApiResponse(code = 405, message = "Operation is not allowed on the persistent topic"),
@ApiResponse(code = 412, message = "Topic name is not valid"),
@ApiResponse(code = 500, message = "Internal server error"),
@@ -3273,7 +3278,7 @@ public void getLastMessageId(
@Path("/{tenant}/{namespace}/{topic}/dispatchRate")
@ApiOperation(value = "Get dispatch rate configuration for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, please enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -3299,7 +3304,7 @@ public void getDispatchRate(@Suspended final AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/dispatchRate")
@ApiOperation(value = "Set message dispatch rate configuration for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, please enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -3336,7 +3341,7 @@ public void setDispatchRate(@Suspended final AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/dispatchRate")
@ApiOperation(value = "Remove message dispatch rate configuration for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, please enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -3368,7 +3373,7 @@ public void removeDispatchRate(@Suspended final AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/subscriptionDispatchRate")
@ApiOperation(value = "Get subscription message dispatch rate configuration for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, please enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -3394,7 +3399,7 @@ public void getSubscriptionDispatchRate(@Suspended final AsyncResponse asyncResp
@Path("/{tenant}/{namespace}/{topic}/subscriptionDispatchRate")
@ApiOperation(value = "Set subscription message dispatch rate configuration for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, please enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -3433,7 +3438,7 @@ public void setSubscriptionDispatchRate(
@Path("/{tenant}/{namespace}/{topic}/subscriptionDispatchRate")
@ApiOperation(value = "Remove subscription message dispatch rate configuration for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, please enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -3465,7 +3470,7 @@ public void removeSubscriptionDispatchRate(@Suspended final AsyncResponse asyncR
@Path("/{tenant}/{namespace}/{topic}/{subName}/dispatchRate")
@ApiOperation(value = "Get message dispatch rate configuration for specified subscription.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, please enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -3493,7 +3498,7 @@ public void getSubscriptionLevelDispatchRate(@Suspended final AsyncResponse asyn
@Path("/{tenant}/{namespace}/{topic}/{subName}/dispatchRate")
@ApiOperation(value = "Set message dispatch rate configuration for specified subscription.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, please enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -3533,7 +3538,7 @@ public void setSubscriptionLevelDispatchRate(
@Path("/{tenant}/{namespace}/{topic}/{subName}/dispatchRate")
@ApiOperation(value = "Remove message dispatch rate configuration for specified subscription.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, please enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -3566,7 +3571,7 @@ public void removeSubscriptionLevelDispatchRate(
@Path("/{tenant}/{namespace}/{topic}/compactionThreshold")
@ApiOperation(value = "Get compaction threshold configuration for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, please enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -3592,7 +3597,7 @@ public void getCompactionThreshold(@Suspended final AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/compactionThreshold")
@ApiOperation(value = "Set compaction threshold configuration for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, please enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -3629,7 +3634,7 @@ public void setCompactionThreshold(@Suspended final AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/compactionThreshold")
@ApiOperation(value = "Remove compaction threshold configuration for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, please enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -3661,7 +3666,7 @@ public void removeCompactionThreshold(@Suspended final AsyncResponse asyncRespon
@Path("/{tenant}/{namespace}/{topic}/maxConsumersPerSubscription")
@ApiOperation(value = "Get max consumers per subscription configuration for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, please enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -3687,7 +3692,7 @@ public void getMaxConsumersPerSubscription(@Suspended final AsyncResponse asyncR
@Path("/{tenant}/{namespace}/{topic}/maxConsumersPerSubscription")
@ApiOperation(value = "Set max consumers per subscription configuration for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, please enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -3725,7 +3730,7 @@ public void setMaxConsumersPerSubscription(
@Path("/{tenant}/{namespace}/{topic}/maxConsumersPerSubscription")
@ApiOperation(value = "Remove max consumers per subscription configuration for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, please enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -3758,7 +3763,7 @@ public void removeMaxConsumersPerSubscription(@Suspended final AsyncResponse asy
@Path("/{tenant}/{namespace}/{topic}/publishRate")
@ApiOperation(value = "Get publish rate configuration for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, please enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -3784,7 +3789,7 @@ public void getPublishRate(@Suspended final AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/publishRate")
@ApiOperation(value = "Set message publish rate configuration for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, please enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -3822,7 +3827,7 @@ public void setPublishRate(@Suspended final AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/publishRate")
@ApiOperation(value = "Remove message publish rate configuration for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, please enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -3855,7 +3860,7 @@ public void removePublishRate(@Suspended final AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/subscriptionTypesEnabled")
@ApiOperation(value = "Get is enable sub type fors specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, please enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -3883,7 +3888,7 @@ public void getSubscriptionTypesEnabled(@Suspended final AsyncResponse asyncResp
@Path("/{tenant}/{namespace}/{topic}/subscriptionTypesEnabled")
@ApiOperation(value = "Set is enable sub types for specified topic")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, please enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -3921,7 +3926,7 @@ public void setSubscriptionTypesEnabled(@Suspended final AsyncResponse asyncResp
@Path("/{tenant}/{namespace}/{topic}/subscriptionTypesEnabled")
@ApiOperation(value = "Remove subscription types enabled for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, to enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -3952,7 +3957,7 @@ public void removeSubscriptionTypesEnabled(@Suspended final AsyncResponse asyncR
@Path("/{tenant}/{namespace}/{topic}/subscribeRate")
@ApiOperation(value = "Get subscribe rate configuration for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, please enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -3977,7 +3982,7 @@ public void getSubscribeRate(@Suspended final AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/subscribeRate")
@ApiOperation(value = "Set subscribe rate configuration for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, please enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -4016,7 +4021,7 @@ public void setSubscribeRate(
@Path("/{tenant}/{namespace}/{topic}/subscribeRate")
@ApiOperation(value = "Remove subscribe rate configuration for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, please enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -4056,7 +4061,7 @@ public void removeSubscribeRate(@Suspended final AsyncResponse asyncResponse,
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic does not exist"),
@ApiResponse(code = 500, message = "Internal server error")})
public void truncateTopic(
@Suspended final AsyncResponse asyncResponse,
@@ -4127,7 +4132,7 @@ public void setReplicatedSubscriptionStatus(
@ApiResponses(value = {
@ApiResponse(code = 401, message = "Don't have permission to administrate resources"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 412, message = "Can't find owner for topic"),
@ApiResponse(code = 500, message = "Internal server error")})
public void getReplicatedSubscriptionStatus(
@@ -4153,7 +4158,7 @@ public void getReplicatedSubscriptionStatus(
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponse(code = 405, message = "Operation not allowed on persistent topic"),
- @ApiResponse(code = 404, message = "Topic does not exist")})
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist")})
public void getSchemaCompatibilityStrategy(
@Suspended AsyncResponse asyncResponse,
@ApiParam(value = "Specify the tenant", required = true)
@@ -4183,7 +4188,7 @@ public void getSchemaCompatibilityStrategy(
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponse(code = 405, message = "Operation not allowed on persistent topic"),
- @ApiResponse(code = 404, message = "Topic does not exist")})
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist")})
public void setSchemaCompatibilityStrategy(
@Suspended AsyncResponse asyncResponse,
@ApiParam(value = "Specify the tenant", required = true)
@@ -4223,7 +4228,7 @@ public void setSchemaCompatibilityStrategy(
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponse(code = 405, message = "Operation not allowed on persistent topic"),
- @ApiResponse(code = 404, message = "Topic does not exist")})
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist")})
public void removeSchemaCompatibilityStrategy(
@Suspended AsyncResponse asyncResponse,
@ApiParam(value = "Specify the tenant", required = true)
@@ -4340,7 +4345,7 @@ public void getEntryFilters(@Suspended AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/entryFilters")
@ApiOperation(value = "Set entry filters for specified topic")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, please enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -4368,7 +4373,7 @@ public void setEntryFilters(@Suspended final AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/entryFilters")
@ApiOperation(value = "Remove entry filters for specified topic.")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405,
message = "Topic level policy is disabled, please enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification")})
@@ -4403,7 +4408,7 @@ public void removeEntryFilters(@Suspended final AsyncResponse asyncResponse,
@Path("/{tenant}/{namespace}/{topic}/shadowTopics")
@ApiOperation(value = "Get the shadow topic list for a topic")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405, message =
"Topic level policy is disabled, enable the topic level policy and retry")})
public void getShadowTopics(
@@ -4429,7 +4434,7 @@ public void getShadowTopics(
@Path("/{tenant}/{namespace}/{topic}/shadowTopics")
@ApiOperation(value = "Set shadow topic list for a topic")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405, message =
"Topic level policy is disabled, enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification"),
@@ -4456,7 +4461,7 @@ public void setShadowTopics(
@Path("/{tenant}/{namespace}/{topic}/shadowTopics")
@ApiOperation(value = "Delete shadow topics for a topic")
@ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 404, message = "Namespace or topic doesn't exist"),
@ApiResponse(code = 405, message =
"Topic level policy is disabled, enable the topic level policy and retry"),
@ApiResponse(code = 409, message = "Concurrent modification"),
@@ -4478,5 +4483,93 @@ public void deleteShadowTopics(
});
}
+ @POST
+ @Path("/{tenant}/{namespace}/{topic}/autoSubscriptionCreation")
+ @ApiOperation(value = "Override namespace's allowAutoSubscriptionCreation setting for a topic")
+ @ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
+ @ApiResponse(code = 404, message = "Topic doesn't exist"),
+ @ApiResponse(code = 405, message =
+ "Topic level policy is disabled, enable the topic level policy and retry"),
+ @ApiResponse(code = 409, message = "Concurrent modification")})
+ public void setAutoSubscriptionCreation(
+ @Suspended final AsyncResponse asyncResponse,
+ @PathParam("tenant") String tenant,
+ @PathParam("namespace") String namespace,
+ @PathParam("topic") String encodedTopic,
+ @QueryParam("isGlobal") @DefaultValue("false") boolean isGlobal,
+ @QueryParam("authoritative") @DefaultValue("false") boolean authoritative,
+ @ApiParam(value = "Settings for automatic subscription creation")
+ AutoSubscriptionCreationOverrideImpl autoSubscriptionCreationOverride) {
+ validateTopicName(tenant, namespace, encodedTopic);
+ preValidation(authoritative)
+ .thenCompose(__ -> internalSetAutoSubscriptionCreation(autoSubscriptionCreationOverride, isGlobal))
+ .thenAccept(__ -> asyncResponse.resume(Response.noContent().build()))
+ .exceptionally(ex -> {
+ handleTopicPolicyException("setAutoSubscriptionCreation", ex, asyncResponse);
+ return null;
+ });
+ }
+
+ @GET
+ @Path("/{tenant}/{namespace}/{topic}/autoSubscriptionCreation")
+ @ApiOperation(value = "Get autoSubscriptionCreation info in a topic")
+ @ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
+ @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 405,
+ message = "Topic level policy is disabled, please enable the topic level policy and retry"),
+ @ApiResponse(code = 409, message = "Concurrent modification")})
+ public void getAutoSubscriptionCreation(
+ @Suspended final AsyncResponse asyncResponse,
+ @PathParam("tenant") String tenant,
+ @PathParam("namespace") String namespace,
+ @PathParam("topic") @Encoded String encodedTopic,
+ @QueryParam("applied") @DefaultValue("false") boolean applied,
+ @QueryParam("isGlobal") @DefaultValue("false") boolean isGlobal,
+ @QueryParam("authoritative") @DefaultValue("false") boolean authoritative) {
+ validateTopicName(tenant, namespace, encodedTopic);
+ preValidation(authoritative)
+ .thenCompose(__ -> internalGetAutoSubscriptionCreation(applied, isGlobal))
+ .thenApply(asyncResponse::resume).exceptionally(ex -> {
+ handleTopicPolicyException("getAutoSubscriptionCreation", ex, asyncResponse);
+ return null;
+ });
+ }
+
+ @DELETE
+ @Path("/{tenant}/{namespace}/{topic}/autoSubscriptionCreation")
+ @ApiOperation(value = "Remove autoSubscriptionCreation ina a topic.")
+ @ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
+ @ApiResponse(code = 404, message = "Topic does not exist"),
+ @ApiResponse(code = 405,
+ message = "Topic level policy is disabled, please enable the topic level policy and retry"),
+ @ApiResponse(code = 409, message = "Concurrent modification")})
+ public void removeAutoSubscriptionCreation(
+ @Suspended final AsyncResponse asyncResponse,
+ @PathParam("tenant") String tenant,
+ @PathParam("namespace") String namespace,
+ @PathParam("topic") @Encoded String encodedTopic,
+ @QueryParam("isGlobal") @DefaultValue("false") boolean isGlobal,
+ @ApiParam(value = "Whether leader broker redirected this call to this broker. For internal use.")
+ @QueryParam("authoritative") @DefaultValue("false") boolean authoritative) {
+ validateTopicName(tenant, namespace, encodedTopic);
+ preValidation(authoritative)
+ .thenCompose(__ -> internalSetAutoSubscriptionCreation(null, isGlobal))
+ .thenRun(() -> {
+ log.info(
+ "[{}] Successfully remove topic removeAutoSubscriptionCreation: "
+ + "tenant={}, namespace={}, topic={}, isGlobal={}",
+ clientAppId(),
+ tenant,
+ namespace,
+ topicName.getLocalName(),
+ isGlobal);
+ asyncResponse.resume(Response.noContent().build());
+ })
+ .exceptionally(ex -> {
+ handleTopicPolicyException("removeAutoSubscriptionCreation", ex, asyncResponse);
+ return null;
+ });
+ }
+
private static final Logger log = LoggerFactory.getLogger(PersistentTopics.class);
}
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/ResourceGroups.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/ResourceGroups.java
index f89ea9d4320aa..52fd03b18ed0b 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/ResourceGroups.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/ResourceGroups.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/ResourceQuotas.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/ResourceQuotas.java
index 45e2ec74a8f2e..58ccc1c10288c 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/ResourceQuotas.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/ResourceQuotas.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/SchemasResource.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/SchemasResource.java
index 335510f0893ca..45d6bff42ca6a 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/SchemasResource.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/SchemasResource.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Tenants.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Tenants.java
index 94ecec552ce6f..ebd02dffa0921 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Tenants.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Tenants.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Worker.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Worker.java
index 12b7950a58223..80c75b04917ce 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Worker.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Worker.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -45,12 +45,12 @@
public class Worker extends AdminResource implements Supplier {
Workers extends WorkerService> workers() {
- return pulsar().getWorkerService().getWorkers();
+ return validateAndGetWorkerService().getWorkers();
}
@Override
public WorkerService get() {
- return pulsar().getWorkerService();
+ return validateAndGetWorkerService();
}
@GET
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/WorkerStats.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/WorkerStats.java
index 6703caa7a278b..5a77d81b6f1e3 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/WorkerStats.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/WorkerStats.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -40,7 +40,7 @@
public class WorkerStats extends AdminResource {
public Workers extends WorkerService> workers() {
- return pulsar().getWorkerService().getWorkers();
+ return validateAndGetWorkerService().getWorkers();
}
@GET
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/package-info.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/package-info.java
index fe67309d67d05..b6a32e71dbcb7 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/package-info.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Functions.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Functions.java
index cdada46d67873..e4d3b88c292f5 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Functions.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Functions.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Packages.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Packages.java
index 03a83bf314520..15e7b69554dc7 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Packages.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Packages.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Sink.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Sink.java
index d6bf22c294937..59f2c698c8fb2 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Sink.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Sink.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Sinks.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Sinks.java
index 3b398416de3b9..35c777592bdb6 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Sinks.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Sinks.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Source.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Source.java
index ad19db3af01d5..9b3ce2b4b516d 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Source.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Source.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Sources.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Sources.java
index 336e6fa501af8..e0f533799811a 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Sources.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Sources.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Transactions.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Transactions.java
index 5dcf57f80f97c..aa24dbdcc3ae9 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Transactions.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Transactions.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -52,6 +52,17 @@
@Slf4j
public class Transactions extends TransactionsBase {
+ @GET
+ @Path("/coordinators")
+ @ApiOperation(value = "List transaction coordinators.")
+ @ApiResponses(value = {@ApiResponse(code = 403, message = "Don't have admin permission"),
+ @ApiResponse(code = 503, message = "This Broker is not "
+ + "configured with transactionCoordinatorEnabled=true.")})
+ public void listCoordinators(@Suspended final AsyncResponse asyncResponse) {
+ checkTransactionCoordinatorEnabled();
+ internalListCoordinators(asyncResponse);
+ }
+
@GET
@Path("/coordinatorStats")
@ApiOperation(value = "Get transaction coordinator stats.")
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/package-info.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/package-info.java
index f64d9ac6b59a5..839d8de12608b 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/package-info.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/cache/BundlesQuotas.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/cache/BundlesQuotas.java
index 88ddaf15314c7..d70520a09f3ce 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/cache/BundlesQuotas.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/cache/BundlesQuotas.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/cache/package-info.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/cache/package-info.java
index 77dc2b9adb932..d4fbef69a9b50 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/cache/package-info.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/cache/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/AbstractDelayedDeliveryTracker.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/AbstractDelayedDeliveryTracker.java
new file mode 100644
index 0000000000000..5c99e4c307d7c
--- /dev/null
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/AbstractDelayedDeliveryTracker.java
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.delayed;
+
+import io.netty.util.Timeout;
+import io.netty.util.Timer;
+import io.netty.util.TimerTask;
+import java.time.Clock;
+import java.util.concurrent.TimeUnit;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.pulsar.broker.service.persistent.PersistentDispatcherMultipleConsumers;
+
+@Slf4j
+public abstract class AbstractDelayedDeliveryTracker implements DelayedDeliveryTracker, TimerTask {
+
+ protected final PersistentDispatcherMultipleConsumers dispatcher;
+
+ // Reference to the shared (per-broker) timer for delayed delivery
+ protected final Timer timer;
+
+ // Current timeout or null if not set
+ protected Timeout timeout;
+
+ // Timestamp at which the timeout is currently set
+ private long currentTimeoutTarget;
+
+ // Last time the TimerTask was triggered for this class
+ private long lastTickRun;
+
+ protected long tickTimeMillis;
+
+ protected final Clock clock;
+
+ private final boolean isDelayedDeliveryDeliverAtTimeStrict;
+
+ public AbstractDelayedDeliveryTracker(PersistentDispatcherMultipleConsumers dispatcher, Timer timer,
+ long tickTimeMillis,
+ boolean isDelayedDeliveryDeliverAtTimeStrict) {
+ this(dispatcher, timer, tickTimeMillis, Clock.systemUTC(), isDelayedDeliveryDeliverAtTimeStrict);
+ }
+
+ public AbstractDelayedDeliveryTracker(PersistentDispatcherMultipleConsumers dispatcher, Timer timer,
+ long tickTimeMillis, Clock clock,
+ boolean isDelayedDeliveryDeliverAtTimeStrict) {
+ this.dispatcher = dispatcher;
+ this.timer = timer;
+ this.tickTimeMillis = tickTimeMillis;
+ this.clock = clock;
+ this.isDelayedDeliveryDeliverAtTimeStrict = isDelayedDeliveryDeliverAtTimeStrict;
+ }
+
+
+ /**
+ * When {@link #isDelayedDeliveryDeliverAtTimeStrict} is false, we allow for early delivery by as much as the
+ * {@link #tickTimeMillis} because it is a slight optimization to let messages skip going back into the delay
+ * tracker for a brief amount of time when we're already trying to dispatch to the consumer.
+ *
+ * When {@link #isDelayedDeliveryDeliverAtTimeStrict} is true, we use the current time to determine when messages
+ * can be delivered. As a consequence, there are two delays that will affect delivery. The first is the
+ * {@link #tickTimeMillis} and the second is the {@link Timer}'s granularity.
+ *
+ * @return the cutoff time to determine whether a message is ready to deliver to the consumer
+ */
+ protected long getCutoffTime() {
+ return isDelayedDeliveryDeliverAtTimeStrict ? clock.millis() : clock.millis() + tickTimeMillis;
+ }
+
+ public void resetTickTime(long tickTime) {
+ if (this.tickTimeMillis != tickTime) {
+ this.tickTimeMillis = tickTime;
+ }
+ }
+
+ protected void updateTimer() {
+ if (getNumberOfDelayedMessages() == 0) {
+ if (timeout != null) {
+ currentTimeoutTarget = -1;
+ timeout.cancel();
+ timeout = null;
+ }
+ return;
+ }
+ long timestamp = nextDeliveryTime();
+ if (timestamp == currentTimeoutTarget) {
+ // The timer is already set to the correct target time
+ return;
+ }
+
+ if (timeout != null) {
+ timeout.cancel();
+ }
+
+ long now = clock.millis();
+ long delayMillis = timestamp - now;
+
+ if (delayMillis < 0) {
+ // There are messages that are already ready to be delivered. If
+ // the dispatcher is not getting them is because the consumer is
+ // either not connected or slow.
+ // We don't need to keep retriggering the timer. When the consumer
+ // catches up, the dispatcher will do the readMoreEntries() and
+ // get these messages
+ return;
+ }
+
+ // Compute the earliest time that we schedule the timer to run.
+ long remainingTickDelayMillis = lastTickRun + tickTimeMillis - now;
+ long calculatedDelayMillis = Math.max(delayMillis, remainingTickDelayMillis);
+
+ if (log.isDebugEnabled()) {
+ log.debug("[{}] Start timer in {} millis", dispatcher.getName(), calculatedDelayMillis);
+ }
+
+ // Even though we may delay longer than this timestamp because of the tick delay, we still track the
+ // current timeout with reference to the next message's timestamp.
+ currentTimeoutTarget = timestamp;
+ timeout = timer.newTimeout(this, calculatedDelayMillis, TimeUnit.MILLISECONDS);
+ }
+
+ @Override
+ public void run(Timeout timeout) throws Exception {
+ if (log.isDebugEnabled()) {
+ log.debug("[{}] Timer triggered", dispatcher.getName());
+ }
+ if (timeout == null || timeout.isCancelled()) {
+ return;
+ }
+
+ synchronized (dispatcher) {
+ lastTickRun = clock.millis();
+ currentTimeoutTarget = -1;
+ this.timeout = null;
+ dispatcher.readMoreEntries();
+ }
+ }
+
+ @Override
+ public void close() {
+ if (timeout != null) {
+ timeout.cancel();
+ timeout = null;
+ }
+ }
+
+ protected abstract long nextDeliveryTime();
+}
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/DelayedDeliveryTracker.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/DelayedDeliveryTracker.java
index 4e9cf296cf8e8..2f248a441cdee 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/DelayedDeliveryTracker.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/DelayedDeliveryTracker.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -19,7 +19,7 @@
package org.apache.pulsar.broker.delayed;
import com.google.common.annotations.Beta;
-import java.util.Set;
+import java.util.NavigableSet;
import org.apache.bookkeeper.mledger.impl.PositionImpl;
/**
@@ -58,7 +58,7 @@ public interface DelayedDeliveryTracker extends AutoCloseable {
/**
* Get a set of position of messages that have already reached the delivery time.
*/
- Set getScheduledMessages(int maxMessages);
+ NavigableSet getScheduledMessages(int maxMessages);
/**
* Tells whether the dispatcher should pause any message deliveries, until the DelayedDeliveryTracker has
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/DelayedDeliveryTrackerFactory.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/DelayedDeliveryTrackerFactory.java
index 748b059c12980..0530a01779b39 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/DelayedDeliveryTrackerFactory.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/DelayedDeliveryTrackerFactory.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/DelayedDeliveryTrackerLoader.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/DelayedDeliveryTrackerLoader.java
index 91a56b51a54b0..0b9f45b1393bb 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/DelayedDeliveryTrackerLoader.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/DelayedDeliveryTrackerLoader.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/InMemoryDelayedDeliveryTracker.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/InMemoryDelayedDeliveryTracker.java
index ba8a931181776..f55d5fd11694b 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/InMemoryDelayedDeliveryTracker.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/InMemoryDelayedDeliveryTracker.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -18,47 +18,28 @@
*/
package org.apache.pulsar.broker.delayed;
-import io.netty.util.Timeout;
+import com.google.common.annotations.VisibleForTesting;
import io.netty.util.Timer;
-import io.netty.util.TimerTask;
import java.time.Clock;
-import java.util.Set;
+import java.util.NavigableSet;
import java.util.TreeSet;
-import java.util.concurrent.TimeUnit;
+import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.apache.bookkeeper.mledger.impl.PositionImpl;
import org.apache.pulsar.broker.service.persistent.PersistentDispatcherMultipleConsumers;
import org.apache.pulsar.common.util.collections.TripleLongPriorityQueue;
@Slf4j
-public class InMemoryDelayedDeliveryTracker implements DelayedDeliveryTracker, TimerTask {
+public class InMemoryDelayedDeliveryTracker extends AbstractDelayedDeliveryTracker {
protected final TripleLongPriorityQueue priorityQueue = new TripleLongPriorityQueue();
- private final PersistentDispatcherMultipleConsumers dispatcher;
-
- // Reference to the shared (per-broker) timer for delayed delivery
- private final Timer timer;
-
- // Current timeout or null if not set
- protected Timeout timeout;
-
- // Timestamp at which the timeout is currently set
- private long currentTimeoutTarget;
-
- // Last time the TimerTask was triggered for this class
- private long lastTickRun;
-
- private long tickTimeMillis;
-
- private final Clock clock;
-
- private final boolean isDelayedDeliveryDeliverAtTimeStrict;
-
// If we detect that all messages have fixed delay time, such that the delivery is
// always going to be in FIFO order, then we can avoid pulling all the messages in
// tracker. Instead, we use the lookahead for detection and pause the read from
// the cursor if the delays are fixed.
+ @Getter
+ @VisibleForTesting
private final long fixedDelayDetectionLookahead;
// This is the timestamp of the message with the highest delivery time
@@ -76,33 +57,14 @@ public class InMemoryDelayedDeliveryTracker implements DelayedDeliveryTracker, T
fixedDelayDetectionLookahead);
}
- InMemoryDelayedDeliveryTracker(PersistentDispatcherMultipleConsumers dispatcher, Timer timer,
+ public InMemoryDelayedDeliveryTracker(PersistentDispatcherMultipleConsumers dispatcher, Timer timer,
long tickTimeMillis, Clock clock,
boolean isDelayedDeliveryDeliverAtTimeStrict,
long fixedDelayDetectionLookahead) {
- this.dispatcher = dispatcher;
- this.timer = timer;
- this.tickTimeMillis = tickTimeMillis;
- this.clock = clock;
- this.isDelayedDeliveryDeliverAtTimeStrict = isDelayedDeliveryDeliverAtTimeStrict;
+ super(dispatcher, timer, tickTimeMillis, clock, isDelayedDeliveryDeliverAtTimeStrict);
this.fixedDelayDetectionLookahead = fixedDelayDetectionLookahead;
}
- /**
- * When {@link #isDelayedDeliveryDeliverAtTimeStrict} is false, we allow for early delivery by as much as the
- * {@link #tickTimeMillis} because it is a slight optimization to let messages skip going back into the delay
- * tracker for a brief amount of time when we're already trying to dispatch to the consumer.
- *
- * When {@link #isDelayedDeliveryDeliverAtTimeStrict} is true, we use the current time to determine when messages
- * can be delivered. As a consequence, there are two delays that will affect delivery. The first is the
- * {@link #tickTimeMillis} and the second is the {@link Timer}'s granularity.
- *
- * @return the cutoff time to determine whether a message is ready to deliver to the consumer
- */
- private long getCutoffTime() {
- return isDelayedDeliveryDeliverAtTimeStrict ? clock.millis() : clock.millis() + tickTimeMillis;
- }
-
@Override
public boolean addMessage(long ledgerId, long entryId, long deliverAt) {
if (deliverAt < 0 || deliverAt <= getCutoffTime()) {
@@ -115,19 +77,24 @@ public boolean addMessage(long ledgerId, long entryId, long deliverAt) {
deliverAt - clock.millis());
}
-
priorityQueue.add(deliverAt, ledgerId, entryId);
updateTimer();
- // Check that new delivery time comes after the current highest, or at
- // least within a single tick time interval of 1 second.
+ checkAndUpdateHighest(deliverAt);
+
+ return true;
+ }
+
+ /**
+ * Check that new delivery time comes after the current highest, or at
+ * least within a single tick time interval of 1 second.
+ */
+ private void checkAndUpdateHighest(long deliverAt) {
if (deliverAt < (highestDeliveryTimeTracked - tickTimeMillis)) {
messagesHaveFixedDelay = false;
}
highestDeliveryTimeTracked = Math.max(highestDeliveryTimeTracked, deliverAt);
-
- return true;
}
/**
@@ -146,9 +113,9 @@ public boolean hasMessageAvailable() {
* Get a set of position of messages that have already reached.
*/
@Override
- public Set getScheduledMessages(int maxMessages) {
+ public NavigableSet getScheduledMessages(int maxMessages) {
int n = maxMessages;
- Set positions = new TreeSet<>();
+ NavigableSet positions = new TreeSet<>();
long cutoffTime = getCutoffTime();
while (n > 0 && !priorityQueue.isEmpty()) {
@@ -179,14 +146,6 @@ public Set getScheduledMessages(int maxMessages) {
return positions;
}
- @Override
- public void resetTickTime(long tickTime) {
-
- if (this.tickTimeMillis != tickTime) {
- this.tickTimeMillis = tickTime;
- }
- }
-
@Override
public void clear() {
this.priorityQueue.clear();
@@ -202,87 +161,9 @@ public long getBufferMemoryUsage() {
return priorityQueue.bytesCapacity();
}
- /**
- * Update the scheduled timer task such that:
- * 1. If there are no delayed messages, return and do not schedule a timer task.
- * 2. If the next message in the queue has the same deliverAt time as the timer task, return and leave existing
- * timer task in place.
- * 3. If the deliverAt time for the next delayed message has already passed (i.e. the delay is negative), return
- * without scheduling a timer task since the subscription is backlogged.
- * 4. Else, schedule a timer task where the delay is the greater of these two: the next message's deliverAt time or
- * the last tick time plus the tickTimeMillis (to ensure we do not schedule the task more frequently than the
- * tickTimeMillis).
- */
- private void updateTimer() {
- if (priorityQueue.isEmpty()) {
- if (timeout != null) {
- currentTimeoutTarget = -1;
- timeout.cancel();
- timeout = null;
- }
- return;
- }
-
- long timestamp = priorityQueue.peekN1();
- if (timestamp == currentTimeoutTarget) {
- // The timer is already set to the correct target time
- return;
- }
-
- if (timeout != null) {
- timeout.cancel();
- }
-
- long now = clock.millis();
- long delayMillis = timestamp - now;
-
- if (delayMillis < 0) {
- // There are messages that are already ready to be delivered. If
- // the dispatcher is not getting them is because the consumer is
- // either not connected or slow.
- // We don't need to keep retriggering the timer. When the consumer
- // catches up, the dispatcher will do the readMoreEntries() and
- // get these messages
- return;
- }
-
- // Compute the earliest time that we schedule the timer to run.
- long remainingTickDelayMillis = lastTickRun + tickTimeMillis - now;
- long calculatedDelayMillis = Math.max(delayMillis, remainingTickDelayMillis);
-
- if (log.isDebugEnabled()) {
- log.debug("[{}] Start timer in {} millis", dispatcher.getName(), calculatedDelayMillis);
- }
-
- // Even though we may delay longer than this timestamp because of the tick delay, we still track the
- // current timeout with reference to the next message's timestamp.
- currentTimeoutTarget = timestamp;
- timeout = timer.newTimeout(this, calculatedDelayMillis, TimeUnit.MILLISECONDS);
- }
-
- @Override
- public void run(Timeout timeout) throws Exception {
- if (log.isDebugEnabled()) {
- log.debug("[{}] Timer triggered", dispatcher.getName());
- }
- if (timeout == null || timeout.isCancelled()) {
- return;
- }
-
- synchronized (dispatcher) {
- lastTickRun = clock.millis();
- currentTimeoutTarget = -1;
- this.timeout = null;
- dispatcher.readMoreEntries();
- }
- }
-
@Override
public void close() {
- if (timeout != null) {
- timeout.cancel();
- timeout = null;
- }
+ super.close();
priorityQueue.close();
}
@@ -291,7 +172,7 @@ public boolean shouldPauseAllDeliveries() {
// Pause deliveries if we know all delays are fixed within the lookahead window
return fixedDelayDetectionLookahead > 0
&& messagesHaveFixedDelay
- && priorityQueue.size() >= fixedDelayDetectionLookahead
+ && getNumberOfDelayedMessages() >= fixedDelayDetectionLookahead
&& !hasMessageAvailable();
}
@@ -299,4 +180,8 @@ public boolean shouldPauseAllDeliveries() {
public boolean containsMessage(long ledgerId, long entryId) {
return false;
}
+
+ protected long nextDeliveryTime() {
+ return priorityQueue.peekN1();
+ }
}
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/InMemoryDelayedDeliveryTrackerFactory.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/InMemoryDelayedDeliveryTrackerFactory.java
index 7bf0ca87c40c7..de8ceca7a71db 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/InMemoryDelayedDeliveryTrackerFactory.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/InMemoryDelayedDeliveryTrackerFactory.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/Bucket.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/Bucket.java
new file mode 100644
index 0000000000000..fbd6d765705d4
--- /dev/null
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/Bucket.java
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.delayed.bucket;
+
+import static org.apache.bookkeeper.mledger.util.Futures.executeWithRetry;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.bookkeeper.mledger.ManagedCursor;
+import org.apache.bookkeeper.mledger.ManagedLedgerException;
+import org.apache.pulsar.broker.delayed.proto.DelayedMessageIndexBucketSnapshotFormat;
+import org.roaringbitmap.RoaringBitmap;
+
+@Slf4j
+@Data
+@AllArgsConstructor
+abstract class Bucket {
+
+ static final String DELAYED_BUCKET_KEY_PREFIX = "#pulsar.internal.delayed.bucket";
+ static final String DELIMITER = "_";
+ static final int MaxRetryTimes = 3;
+
+ protected final ManagedCursor cursor;
+ protected final BucketSnapshotStorage bucketSnapshotStorage;
+
+ long startLedgerId;
+ long endLedgerId;
+
+ Map delayedIndexBitMap;
+
+ long numberBucketDelayedMessages;
+
+ int lastSegmentEntryId;
+
+ int currentSegmentEntryId;
+
+ long snapshotLength;
+
+ private volatile Long bucketId;
+
+ private volatile CompletableFuture snapshotCreateFuture;
+
+
+ Bucket(ManagedCursor cursor, BucketSnapshotStorage storage, long startLedgerId, long endLedgerId) {
+ this(cursor, storage, startLedgerId, endLedgerId, new HashMap<>(), -1, -1, 0, 0, null, null);
+ }
+
+ boolean containsMessage(long ledgerId, long entryId) {
+ RoaringBitmap bitSet = delayedIndexBitMap.get(ledgerId);
+ if (bitSet == null) {
+ return false;
+ }
+ return bitSet.contains(entryId, entryId + 1);
+ }
+
+ void putIndexBit(long ledgerId, long entryId) {
+ delayedIndexBitMap.computeIfAbsent(ledgerId, k -> new RoaringBitmap()).add(entryId, entryId + 1);
+ }
+
+ boolean removeIndexBit(long ledgerId, long entryId) {
+ boolean contained = false;
+ RoaringBitmap bitSet = delayedIndexBitMap.get(ledgerId);
+ if (bitSet != null && bitSet.contains(entryId, entryId + 1)) {
+ contained = true;
+ bitSet.remove(entryId, entryId + 1);
+
+ if (bitSet.isEmpty()) {
+ delayedIndexBitMap.remove(ledgerId);
+ }
+
+ if (numberBucketDelayedMessages > 0) {
+ numberBucketDelayedMessages--;
+ }
+ }
+ return contained;
+ }
+
+ String bucketKey() {
+ return String.join(DELIMITER, DELAYED_BUCKET_KEY_PREFIX, String.valueOf(startLedgerId),
+ String.valueOf(endLedgerId));
+ }
+
+ Optional> getSnapshotCreateFuture() {
+ return Optional.ofNullable(snapshotCreateFuture);
+ }
+
+ Optional getBucketId() {
+ return Optional.ofNullable(bucketId);
+ }
+
+ long getAndUpdateBucketId() {
+ Optional bucketIdOptional = getBucketId();
+ if (bucketIdOptional.isPresent()) {
+ return bucketIdOptional.get();
+ }
+
+ String bucketIdStr = cursor.getCursorProperties().get(bucketKey());
+ long bucketId = Long.parseLong(bucketIdStr);
+ setBucketId(bucketId);
+ return bucketId;
+ }
+
+ CompletableFuture asyncSaveBucketSnapshot(
+ ImmutableBucket bucketState, DelayedMessageIndexBucketSnapshotFormat.SnapshotMetadata snapshotMetadata,
+ List bucketSnapshotSegments) {
+
+ return bucketSnapshotStorage.createBucketSnapshot(snapshotMetadata, bucketSnapshotSegments)
+ .thenCompose(newBucketId -> {
+ bucketState.setBucketId(newBucketId);
+ String bucketKey = bucketState.bucketKey();
+ return putBucketKeyId(bucketKey, newBucketId).exceptionally(ex -> {
+ log.warn("Failed to record bucketId to cursor property, bucketKey: {}", bucketKey);
+ return null;
+ }).thenApply(__ -> newBucketId);
+ });
+ }
+
+ private CompletableFuture putBucketKeyId(String bucketKey, Long bucketId) {
+ Objects.requireNonNull(bucketId);
+ return executeWithRetry(() -> cursor.putCursorProperty(bucketKey, String.valueOf(bucketId)),
+ ManagedLedgerException.BadVersionException.class, MaxRetryTimes);
+ }
+}
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/BucketDelayedDeliveryTracker.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/BucketDelayedDeliveryTracker.java
new file mode 100644
index 0000000000000..b7f0e0a1bc1e5
--- /dev/null
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/BucketDelayedDeliveryTracker.java
@@ -0,0 +1,324 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.delayed.bucket;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import com.google.common.collect.HashBasedTable;
+import com.google.common.collect.Range;
+import com.google.common.collect.RangeMap;
+import com.google.common.collect.Table;
+import com.google.common.collect.TreeRangeMap;
+import io.netty.util.Timeout;
+import io.netty.util.Timer;
+import java.time.Clock;
+import java.util.Iterator;
+import java.util.NavigableSet;
+import java.util.Optional;
+import java.util.TreeSet;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import javax.annotation.concurrent.ThreadSafe;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.bookkeeper.mledger.ManagedCursor;
+import org.apache.bookkeeper.mledger.impl.PositionImpl;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.pulsar.broker.delayed.AbstractDelayedDeliveryTracker;
+import org.apache.pulsar.broker.delayed.proto.DelayedMessageIndexBucketSnapshotFormat;
+import org.apache.pulsar.broker.delayed.proto.DelayedMessageIndexBucketSnapshotFormat.DelayedIndex;
+import org.apache.pulsar.broker.service.persistent.PersistentDispatcherMultipleConsumers;
+import org.apache.pulsar.common.util.collections.TripleLongPriorityQueue;
+
+@Slf4j
+@ThreadSafe
+public class BucketDelayedDeliveryTracker extends AbstractDelayedDeliveryTracker {
+
+ static final int AsyncOperationTimeoutSeconds = 30;
+
+ private final long minIndexCountPerBucket;
+
+ private final long timeStepPerBucketSnapshotSegment;
+
+ private final int maxNumBuckets;
+
+ private long numberDelayedMessages;
+
+ private final MutableBucket lastMutableBucket;
+
+ private final TripleLongPriorityQueue sharedBucketPriorityQueue;
+
+ private final RangeMap immutableBuckets;
+
+ private final Table snapshotSegmentLastIndexTable;
+
+ public BucketDelayedDeliveryTracker(PersistentDispatcherMultipleConsumers dispatcher,
+ Timer timer, long tickTimeMillis,
+ boolean isDelayedDeliveryDeliverAtTimeStrict,
+ BucketSnapshotStorage bucketSnapshotStorage,
+ long minIndexCountPerBucket, long timeStepPerBucketSnapshotSegment,
+ int maxNumBuckets) {
+ this(dispatcher, timer, tickTimeMillis, Clock.systemUTC(), isDelayedDeliveryDeliverAtTimeStrict,
+ bucketSnapshotStorage, minIndexCountPerBucket, timeStepPerBucketSnapshotSegment, maxNumBuckets);
+ }
+
+ public BucketDelayedDeliveryTracker(PersistentDispatcherMultipleConsumers dispatcher,
+ Timer timer, long tickTimeMillis, Clock clock,
+ boolean isDelayedDeliveryDeliverAtTimeStrict,
+ BucketSnapshotStorage bucketSnapshotStorage,
+ long minIndexCountPerBucket, long timeStepPerBucketSnapshotSegment,
+ int maxNumBuckets) {
+ super(dispatcher, timer, tickTimeMillis, clock, isDelayedDeliveryDeliverAtTimeStrict);
+ this.minIndexCountPerBucket = minIndexCountPerBucket;
+ this.timeStepPerBucketSnapshotSegment = timeStepPerBucketSnapshotSegment;
+ this.maxNumBuckets = maxNumBuckets;
+ this.sharedBucketPriorityQueue = new TripleLongPriorityQueue();
+ this.immutableBuckets = TreeRangeMap.create();
+ this.snapshotSegmentLastIndexTable = HashBasedTable.create();
+ this.numberDelayedMessages = 0L;
+ ManagedCursor cursor = dispatcher.getCursor();
+ this.lastMutableBucket = new MutableBucket(cursor, bucketSnapshotStorage);
+ }
+
+ @Override
+ public void run(Timeout timeout) throws Exception {
+ synchronized (this) {
+ if (timeout == null || timeout.isCancelled()) {
+ return;
+ }
+ lastMutableBucket.moveScheduledMessageToSharedQueue(getCutoffTime(), sharedBucketPriorityQueue);
+ }
+ super.run(timeout);
+ }
+
+ private Optional findImmutableBucket(long ledgerId) {
+ if (immutableBuckets.asMapOfRanges().isEmpty()) {
+ return Optional.empty();
+ }
+
+ return Optional.ofNullable(immutableBuckets.get(ledgerId));
+ }
+
+ private void sealBucket() {
+ Pair immutableBucketDelayedIndexPair =
+ lastMutableBucket.sealBucketAndAsyncPersistent(this.timeStepPerBucketSnapshotSegment,
+ this.sharedBucketPriorityQueue);
+ if (immutableBucketDelayedIndexPair != null) {
+ ImmutableBucket immutableBucket = immutableBucketDelayedIndexPair.getLeft();
+ immutableBuckets.put(Range.closed(immutableBucket.startLedgerId, immutableBucket.endLedgerId),
+ immutableBucket);
+
+ DelayedIndex lastDelayedIndex = immutableBucketDelayedIndexPair.getRight();
+ snapshotSegmentLastIndexTable.put(lastDelayedIndex.getLedgerId(), lastDelayedIndex.getEntryId(),
+ immutableBucket);
+ if (log.isDebugEnabled()) {
+ log.debug("[{}] Create bucket snapshot, bucket: {}", dispatcher.getName(),
+ lastMutableBucket);
+ }
+ }
+ }
+
+ @Override
+ public synchronized boolean addMessage(long ledgerId, long entryId, long deliverAt) {
+ if (containsMessage(ledgerId, entryId)) {
+ return true;
+ }
+
+ if (deliverAt < 0 || deliverAt <= getCutoffTime()) {
+ return false;
+ }
+
+ boolean existBucket = findImmutableBucket(ledgerId).isPresent();
+
+ // Create bucket snapshot
+ if (!existBucket && ledgerId > lastMutableBucket.endLedgerId
+ && lastMutableBucket.size() >= minIndexCountPerBucket
+ && !lastMutableBucket.isEmpty()) {
+ sealBucket();
+ lastMutableBucket.resetLastMutableBucketRange();
+
+ if (immutableBuckets.asMapOfRanges().size() > maxNumBuckets) {
+ // TODO merge bucket snapshot (synchronize operate)
+ }
+ }
+
+ if (ledgerId < lastMutableBucket.startLedgerId || existBucket) {
+ // If (ledgerId < startLedgerId || existBucket) means that message index belong to previous bucket range,
+ // enter sharedBucketPriorityQueue directly
+ sharedBucketPriorityQueue.add(deliverAt, ledgerId, entryId);
+ } else {
+ checkArgument(ledgerId >= lastMutableBucket.endLedgerId);
+ lastMutableBucket.addMessage(ledgerId, entryId, deliverAt);
+ }
+
+ numberDelayedMessages++;
+
+ if (log.isDebugEnabled()) {
+ log.debug("[{}] Add message {}:{} -- Delivery in {} ms ", dispatcher.getName(), ledgerId, entryId,
+ deliverAt - clock.millis());
+ }
+
+ updateTimer();
+
+ return true;
+ }
+
+ @Override
+ public synchronized boolean hasMessageAvailable() {
+ long cutoffTime = getCutoffTime();
+
+ boolean hasMessageAvailable = getNumberOfDelayedMessages() > 0 && nextDeliveryTime() <= cutoffTime;
+ if (!hasMessageAvailable) {
+ updateTimer();
+ }
+ return hasMessageAvailable;
+ }
+
+ @Override
+ protected long nextDeliveryTime() {
+ if (lastMutableBucket.isEmpty() && !sharedBucketPriorityQueue.isEmpty()) {
+ return sharedBucketPriorityQueue.peekN1();
+ } else if (sharedBucketPriorityQueue.isEmpty() && !lastMutableBucket.isEmpty()) {
+ return lastMutableBucket.nextDeliveryTime();
+ }
+ long timestamp = lastMutableBucket.nextDeliveryTime();
+ long bucketTimestamp = sharedBucketPriorityQueue.peekN1();
+ return Math.min(timestamp, bucketTimestamp);
+ }
+
+ @Override
+ public synchronized long getNumberOfDelayedMessages() {
+ return numberDelayedMessages;
+ }
+
+ @Override
+ public synchronized long getBufferMemoryUsage() {
+ return this.lastMutableBucket.getBufferMemoryUsage() + sharedBucketPriorityQueue.bytesCapacity();
+ }
+
+ @Override
+ public synchronized NavigableSet getScheduledMessages(int maxMessages) {
+ long cutoffTime = getCutoffTime();
+
+ lastMutableBucket.moveScheduledMessageToSharedQueue(cutoffTime, sharedBucketPriorityQueue);
+
+ NavigableSet positions = new TreeSet<>();
+ int n = maxMessages;
+
+ while (n > 0 && !sharedBucketPriorityQueue.isEmpty()) {
+ long timestamp = sharedBucketPriorityQueue.peekN1();
+ if (timestamp > cutoffTime) {
+ break;
+ }
+
+ long ledgerId = sharedBucketPriorityQueue.peekN2();
+ long entryId = sharedBucketPriorityQueue.peekN3();
+ positions.add(new PositionImpl(ledgerId, entryId));
+
+ sharedBucketPriorityQueue.pop();
+ removeIndexBit(ledgerId, entryId);
+
+ ImmutableBucket bucket = snapshotSegmentLastIndexTable.remove(ledgerId, entryId);
+ if (bucket != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("[{}] Load next snapshot segment, bucket: {}", dispatcher.getName(), bucket);
+ }
+ // All message of current snapshot segment are scheduled, load next snapshot segment
+ // TODO make it asynchronous and not blocking this process
+ try {
+ bucket.asyncLoadNextBucketSnapshotEntry(false).thenAccept(indexList -> {
+ if (CollectionUtils.isEmpty(indexList)) {
+ return;
+ }
+ DelayedMessageIndexBucketSnapshotFormat.DelayedIndex
+ lastDelayedIndex = indexList.get(indexList.size() - 1);
+ this.snapshotSegmentLastIndexTable.put(lastDelayedIndex.getLedgerId(),
+ lastDelayedIndex.getEntryId(), bucket);
+ for (DelayedMessageIndexBucketSnapshotFormat.DelayedIndex index : indexList) {
+ sharedBucketPriorityQueue.add(index.getTimestamp(), index.getLedgerId(),
+ index.getEntryId());
+ }
+ }).get(AsyncOperationTimeoutSeconds, TimeUnit.SECONDS);
+ } catch (InterruptedException | ExecutionException | TimeoutException e) {
+ // TODO make this segment load again
+ throw new RuntimeException(e);
+ }
+ }
+
+ --n;
+ --numberDelayedMessages;
+ }
+
+ updateTimer();
+
+ return positions;
+ }
+
+ @Override
+ public boolean shouldPauseAllDeliveries() {
+ return false;
+ }
+
+ @Override
+ public synchronized void clear() {
+ cleanImmutableBuckets(true);
+ sharedBucketPriorityQueue.clear();
+ lastMutableBucket.clear();
+ snapshotSegmentLastIndexTable.clear();
+ numberDelayedMessages = 0;
+ }
+
+ @Override
+ public synchronized void close() {
+ super.close();
+ lastMutableBucket.close();
+ cleanImmutableBuckets(false);
+ sharedBucketPriorityQueue.close();
+ }
+
+ private void cleanImmutableBuckets(boolean delete) {
+ if (immutableBuckets != null) {
+ Iterator iterator = immutableBuckets.asMapOfRanges().values().iterator();
+ while (iterator.hasNext()) {
+ ImmutableBucket bucket = iterator.next();
+ bucket.clear(delete);
+ iterator.remove();
+ }
+ }
+ }
+
+ private boolean removeIndexBit(long ledgerId, long entryId) {
+ if (lastMutableBucket.removeIndexBit(ledgerId, entryId)) {
+ return true;
+ }
+
+ return findImmutableBucket(ledgerId).map(bucket -> bucket.removeIndexBit(ledgerId, entryId))
+ .orElse(false);
+ }
+
+ @Override
+ public boolean containsMessage(long ledgerId, long entryId) {
+ if (lastMutableBucket.containsMessage(ledgerId, entryId)) {
+ return true;
+ }
+
+ return findImmutableBucket(ledgerId).map(bucket -> bucket.containsMessage(ledgerId, entryId))
+ .orElse(false);
+ }
+}
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/BucketSnapshotStorage.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/BucketSnapshotStorage.java
similarity index 98%
rename from pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/BucketSnapshotStorage.java
rename to pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/BucketSnapshotStorage.java
index da411736d7740..3ab4ce1ad2792 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/BucketSnapshotStorage.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/BucketSnapshotStorage.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.pulsar.broker.delayed;
+package org.apache.pulsar.broker.delayed.bucket;
import java.util.List;
import java.util.concurrent.CompletableFuture;
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/ImmutableBucket.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/ImmutableBucket.java
new file mode 100644
index 0000000000000..833030c575172
--- /dev/null
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/ImmutableBucket.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.delayed.bucket;
+
+import static org.apache.pulsar.broker.delayed.bucket.BucketDelayedDeliveryTracker.AsyncOperationTimeoutSeconds;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.bookkeeper.mledger.ManagedCursor;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.pulsar.broker.delayed.proto.DelayedMessageIndexBucketSnapshotFormat;
+import org.apache.pulsar.broker.delayed.proto.DelayedMessageIndexBucketSnapshotFormat.DelayedIndex;
+
+@Slf4j
+class ImmutableBucket extends Bucket {
+ ImmutableBucket(ManagedCursor cursor, BucketSnapshotStorage storage, long startLedgerId, long endLedgerId) {
+ super(cursor, storage, startLedgerId, endLedgerId);
+ }
+
+ /**
+ * Asynchronous load next bucket snapshot entry.
+ * @param isRecover whether used to recover bucket snapshot
+ * @return CompletableFuture
+ */
+ CompletableFuture> asyncLoadNextBucketSnapshotEntry(boolean isRecover) {
+ if (log.isDebugEnabled()) {
+ log.debug("[{}] Load next bucket snapshot data, bucket: {}", cursor.getName(), this);
+ }
+
+ // Wait bucket snapshot create finish
+ CompletableFuture snapshotCreateFuture =
+ getSnapshotCreateFuture().orElseGet(() -> CompletableFuture.completedFuture(null))
+ .thenApply(__ -> null);
+
+ return snapshotCreateFuture.thenCompose(__ -> {
+ final long bucketId = getAndUpdateBucketId();
+ CompletableFuture loadMetaDataFuture = new CompletableFuture<>();
+ if (isRecover) {
+ // TODO Recover bucket snapshot
+ } else {
+ loadMetaDataFuture.complete(currentSegmentEntryId + 1);
+ }
+
+ return loadMetaDataFuture.thenCompose(nextSegmentEntryId -> {
+ if (nextSegmentEntryId > lastSegmentEntryId) {
+ // TODO Delete bucket snapshot
+ return CompletableFuture.completedFuture(null);
+ }
+
+ return bucketSnapshotStorage.getBucketSnapshotSegment(bucketId, nextSegmentEntryId, nextSegmentEntryId)
+ .thenApply(bucketSnapshotSegments -> {
+ if (CollectionUtils.isEmpty(bucketSnapshotSegments)) {
+ return Collections.emptyList();
+ }
+
+ DelayedMessageIndexBucketSnapshotFormat.SnapshotSegment snapshotSegment =
+ bucketSnapshotSegments.get(0);
+ List indexList =
+ snapshotSegment.getIndexesList();
+ this.setCurrentSegmentEntryId(nextSegmentEntryId);
+ return indexList;
+ });
+ });
+ });
+ }
+
+ void clear(boolean delete) {
+ delayedIndexBitMap.clear();
+ getSnapshotCreateFuture().ifPresent(snapshotGenerateFuture -> {
+ if (delete) {
+ snapshotGenerateFuture.cancel(true);
+ // TODO delete bucket snapshot
+ } else {
+ try {
+ snapshotGenerateFuture.get(AsyncOperationTimeoutSeconds, TimeUnit.SECONDS);
+ } catch (Exception e) {
+ log.warn("Failed wait to snapshot generate, bucketId: {}, bucketKey: {}", getBucketId(),
+ bucketKey());
+ }
+ }
+ });
+ }
+}
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/MutableBucket.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/MutableBucket.java
new file mode 100644
index 0000000000000..36026298269d7
--- /dev/null
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/MutableBucket.java
@@ -0,0 +1,203 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.delayed.bucket;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import com.google.protobuf.ByteString;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.bookkeeper.mledger.ManagedCursor;
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.pulsar.broker.delayed.proto.DelayedMessageIndexBucketSnapshotFormat.DelayedIndex;
+import org.apache.pulsar.broker.delayed.proto.DelayedMessageIndexBucketSnapshotFormat.SnapshotMetadata;
+import org.apache.pulsar.broker.delayed.proto.DelayedMessageIndexBucketSnapshotFormat.SnapshotSegment;
+import org.apache.pulsar.broker.delayed.proto.DelayedMessageIndexBucketSnapshotFormat.SnapshotSegmentMetadata;
+import org.apache.pulsar.common.util.collections.TripleLongPriorityQueue;
+import org.roaringbitmap.RoaringBitmap;
+
+@Slf4j
+class MutableBucket extends Bucket implements AutoCloseable {
+
+ private final TripleLongPriorityQueue priorityQueue;
+
+ MutableBucket(ManagedCursor cursor,
+ BucketSnapshotStorage bucketSnapshotStorage) {
+ super(cursor, bucketSnapshotStorage, -1L, -1L);
+ this.priorityQueue = new TripleLongPriorityQueue();
+ }
+
+ Pair sealBucketAndAsyncPersistent(
+ long timeStepPerBucketSnapshotSegment,
+ TripleLongPriorityQueue sharedQueue) {
+ if (priorityQueue.isEmpty()) {
+ return null;
+ }
+ long numMessages = 0;
+
+ final long startLedgerId = getStartLedgerId();
+ final long endLedgerId = getEndLedgerId();
+
+ List bucketSnapshotSegments = new ArrayList<>();
+ List segmentMetadataList = new ArrayList<>();
+ Map bitMap = new HashMap<>();
+ SnapshotSegment.Builder snapshotSegmentBuilder = SnapshotSegment.newBuilder();
+ SnapshotSegmentMetadata.Builder segmentMetadataBuilder = SnapshotSegmentMetadata.newBuilder();
+
+ long currentTimestampUpperLimit = 0;
+ while (!priorityQueue.isEmpty()) {
+ long timestamp = priorityQueue.peekN1();
+ if (currentTimestampUpperLimit == 0) {
+ currentTimestampUpperLimit = timestamp + timeStepPerBucketSnapshotSegment - 1;
+ }
+
+ long ledgerId = priorityQueue.peekN2();
+ long entryId = priorityQueue.peekN3();
+
+ checkArgument(ledgerId >= startLedgerId && ledgerId <= endLedgerId);
+
+ // Move first segment of bucket snapshot to sharedBucketPriorityQueue
+ if (segmentMetadataList.size() == 0) {
+ sharedQueue.add(timestamp, ledgerId, entryId);
+ }
+
+ priorityQueue.pop();
+ numMessages++;
+
+ DelayedIndex delayedIndex = DelayedIndex.newBuilder()
+ .setTimestamp(timestamp)
+ .setLedgerId(ledgerId)
+ .setEntryId(entryId).build();
+
+ bitMap.computeIfAbsent(ledgerId, k -> new RoaringBitmap()).add(entryId, entryId + 1);
+
+ snapshotSegmentBuilder.addIndexes(delayedIndex);
+
+ if (priorityQueue.isEmpty() || priorityQueue.peekN1() > currentTimestampUpperLimit) {
+ segmentMetadataBuilder.setMaxScheduleTimestamp(timestamp);
+ currentTimestampUpperLimit = 0;
+
+ Iterator> iterator = bitMap.entrySet().iterator();
+ while (iterator.hasNext()) {
+ Map.Entry entry = iterator.next();
+ byte[] array = new byte[entry.getValue().serializedSizeInBytes()];
+ entry.getValue().serialize(ByteBuffer.wrap(array));
+ segmentMetadataBuilder.putDelayedIndexBitMap(entry.getKey(), ByteString.copyFrom(array));
+ iterator.remove();
+ }
+
+ segmentMetadataList.add(segmentMetadataBuilder.build());
+ segmentMetadataBuilder.clear();
+
+ bucketSnapshotSegments.add(snapshotSegmentBuilder.build());
+ snapshotSegmentBuilder.clear();
+ }
+ }
+
+ SnapshotMetadata bucketSnapshotMetadata = SnapshotMetadata.newBuilder()
+ .addAllMetadataList(segmentMetadataList)
+ .build();
+
+ final int lastSegmentEntryId = segmentMetadataList.size();
+
+ ImmutableBucket bucket = new ImmutableBucket(cursor, bucketSnapshotStorage, startLedgerId, endLedgerId);
+ bucket.setCurrentSegmentEntryId(1);
+ bucket.setNumberBucketDelayedMessages(numMessages);
+ bucket.setLastSegmentEntryId(lastSegmentEntryId);
+
+ // Add the first snapshot segment last message to snapshotSegmentLastMessageTable
+ checkArgument(!bucketSnapshotSegments.isEmpty());
+ SnapshotSegment snapshotSegment = bucketSnapshotSegments.get(0);
+ DelayedIndex lastDelayedIndex = snapshotSegment.getIndexes(snapshotSegment.getIndexesCount() - 1);
+ Pair result = Pair.of(bucket, lastDelayedIndex);
+
+ CompletableFuture future = asyncSaveBucketSnapshot(bucket,
+ bucketSnapshotMetadata, bucketSnapshotSegments);
+ bucket.setSnapshotCreateFuture(future);
+ future.whenComplete((__, ex) -> {
+ if (ex == null) {
+ bucket.setSnapshotCreateFuture(null);
+ } else {
+ //TODO Record create snapshot failed
+ log.error("Failed to create snapshot: ", ex);
+ }
+ });
+
+ return result;
+ }
+
+ void moveScheduledMessageToSharedQueue(long cutoffTime, TripleLongPriorityQueue sharedBucketPriorityQueue) {
+ while (!priorityQueue.isEmpty()) {
+ long timestamp = priorityQueue.peekN1();
+ if (timestamp > cutoffTime) {
+ break;
+ }
+
+ long ledgerId = priorityQueue.peekN2();
+ long entryId = priorityQueue.peekN3();
+ sharedBucketPriorityQueue.add(timestamp, ledgerId, entryId);
+
+ priorityQueue.pop();
+ }
+ }
+
+ void resetLastMutableBucketRange() {
+ this.startLedgerId = -1L;
+ this.endLedgerId = -1L;
+ }
+
+ void clear() {
+ this.resetLastMutableBucketRange();
+ this.delayedIndexBitMap.clear();
+ }
+
+ public void close() {
+ priorityQueue.close();
+ }
+
+ long getBufferMemoryUsage() {
+ return priorityQueue.bytesCapacity();
+ }
+
+ boolean isEmpty() {
+ return priorityQueue.isEmpty();
+ }
+
+ long nextDeliveryTime() {
+ return priorityQueue.peekN1();
+ }
+
+ long size() {
+ return priorityQueue.size();
+ }
+
+ void addMessage(long ledgerId, long entryId, long deliverAt) {
+ priorityQueue.add(deliverAt, ledgerId, entryId);
+ if (startLedgerId == -1L) {
+ this.startLedgerId = ledgerId;
+ }
+ this.endLedgerId = ledgerId;
+ putIndexBit(ledgerId, entryId);
+ }
+}
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/package-info.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/package-info.java
new file mode 100644
index 0000000000000..0ab45ecded2cf
--- /dev/null
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.delayed.bucket;
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/package-info.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/package-info.java
index 609382dc0db0d..9247ece8efbbc 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/package-info.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptor.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptor.java
index 6ba72370d1e3b..08b6c1559e5f3 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptor.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptor.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptorDefinition.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptorDefinition.java
index 9b3f3d7aaf61a..cfe5f0d8729d1 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptorDefinition.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptorDefinition.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptorDefinitions.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptorDefinitions.java
index 2d026d368d28e..3c33ed576d223 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptorDefinitions.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptorDefinitions.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptorMetadata.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptorMetadata.java
index 686602c7bbef2..9343ba6ebc7b6 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptorMetadata.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptorMetadata.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptorUtils.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptorUtils.java
index 96421e8b508e2..903feeb849a3a 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptorUtils.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptorUtils.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptorWithClassLoader.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptorWithClassLoader.java
index f309aff9a6170..a74730d23e102 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptorWithClassLoader.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptorWithClassLoader.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptors.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptors.java
index ade496c192f26..e2e6b2e051b72 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptors.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/BrokerInterceptors.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/ManagedLedgerInterceptorImpl.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/ManagedLedgerInterceptorImpl.java
index 0f634e0553ed8..bcc4a0754ad80 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/ManagedLedgerInterceptorImpl.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/ManagedLedgerInterceptorImpl.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/package-info.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/package-info.java
index f91af71dd18e9..89ec9c1b4ae86 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/package-info.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/intercept/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
/**
* Pulsar broker interceptor.
*/
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/BrokerFilter.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/BrokerFilter.java
index 0e58be3bfcc62..1e5e41488d623 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/BrokerFilter.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/BrokerFilter.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/BrokerFilterBadVersionException.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/BrokerFilterBadVersionException.java
index 4be60de7cb753..180c05f9c3061 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/BrokerFilterBadVersionException.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/BrokerFilterBadVersionException.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/BrokerFilterException.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/BrokerFilterException.java
index 4b78a24584ec2..5d9507d5bda8b 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/BrokerFilterException.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/BrokerFilterException.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/BrokerHostUsage.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/BrokerHostUsage.java
index e728de1dad125..5653666400f26 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/BrokerHostUsage.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/BrokerHostUsage.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/BundleSplitStrategy.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/BundleSplitStrategy.java
index 0e5f931716231..d3d76b8e92db1 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/BundleSplitStrategy.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/BundleSplitStrategy.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LeaderBroker.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LeaderBroker.java
index 7b31f86767c3c..acd34e151ed2a 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LeaderBroker.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LeaderBroker.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LeaderElectionService.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LeaderElectionService.java
index 5f1fc9b5bb550..5ef95761e4ec6 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LeaderElectionService.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LeaderElectionService.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LinuxInfoUtils.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LinuxInfoUtils.java
index 26528491f1ebb..aec527b5c9645 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LinuxInfoUtils.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LinuxInfoUtils.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadCalculator.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadCalculator.java
index 7e7c50708a1a7..6d372552d57b4 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadCalculator.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadCalculator.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadData.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadData.java
index 066b656a9dd0a..87f630f1a09fb 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadData.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadData.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadManager.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadManager.java
index fc0b0ddfd357e..e34215d199648 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadManager.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadManager.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadRanker.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadRanker.java
index d9845b65d4490..f0775cdd54d52 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadRanker.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadRanker.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadReport.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadReport.java
index 376068afd8bea..9a00154cbfc9d 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadReport.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadReport.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadReportUpdaterTask.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadReportUpdaterTask.java
index 23405138affcd..e76967ff07dc6 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadReportUpdaterTask.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadReportUpdaterTask.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadResourceQuotaUpdaterTask.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadResourceQuotaUpdaterTask.java
index 5f805d2bccddd..3ad31fcdfecc4 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadResourceQuotaUpdaterTask.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadResourceQuotaUpdaterTask.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadSheddingStrategy.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadSheddingStrategy.java
index 6e102061c9981..ee136d6e9b851 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadSheddingStrategy.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadSheddingStrategy.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadSheddingTask.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadSheddingTask.java
index b4a01d89e5221..eb7eacec60815 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadSheddingTask.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadSheddingTask.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ModularLoadManager.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ModularLoadManager.java
index b0ca2b5412408..fa6895568e918 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ModularLoadManager.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ModularLoadManager.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ModularLoadManagerStrategy.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ModularLoadManagerStrategy.java
index 112e59d557f52..2be8200aef5c1 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ModularLoadManagerStrategy.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ModularLoadManagerStrategy.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/NoopLoadManager.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/NoopLoadManager.java
index 424cb1514c557..1ab56b50cdef4 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/NoopLoadManager.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/NoopLoadManager.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/PlacementStrategy.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/PlacementStrategy.java
index ce25713250fa3..63ec8a8b253e6 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/PlacementStrategy.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/PlacementStrategy.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ResourceDescription.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ResourceDescription.java
index a8769accba9fa..5dafab0ac26a4 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ResourceDescription.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ResourceDescription.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ResourceUnit.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ResourceUnit.java
index 51becdb7f77cd..ef4dd2a97b280 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ResourceUnit.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ResourceUnit.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ServiceRequest.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ServiceRequest.java
index 239058f63d6c2..24d494dbc69ce 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ServiceRequest.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ServiceRequest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ServiceUnit.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ServiceUnit.java
index 824069f92fac7..cbadd19ea5e8f 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ServiceUnit.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/ServiceUnit.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitState.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitState.java
new file mode 100644
index 0000000000000..cd1092a26ea04
--- /dev/null
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitState.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.loadbalance.extensions.channel;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Defines the possible states for service units.
+ *
+ * The following diagram defines the valid state changes
+ *
+ * ┌───────────┐
+ * ┌──────────┤ released │◄────────┐
+ * │own └───────────┘ │release
+ * │ │
+ * │ │
+ * ▼ │
+ * ┌────────┐ assign(transfer) ┌─────┴────┐
+ * │ ├───────────────────►│ │
+ * │ owned │ │ assigned │
+ * │ │◄───────────────────┤ │
+ * └──┬─────┤ own └──────────┘
+ * │ ▲ │ ▲
+ * │ │ │ │
+ * │ │ └──────────────┐ │
+ * │ │ │ │
+ * │ │ unload │ │ assign(assignment)
+ * split │ │ │ │
+ * │ │ │ │
+ * │ │ create(child) │ │
+ * │ │ │ │
+ * ▼ │ │ │
+ * ┌─────┴─────┐ └─────►┌───┴──────┐
+ * │ │ │ │
+ * │ splitting ├────────────────► │ free │
+ * │ │ discard(parent)│ │
+ * └───────────┘ └──────────┘
+ */
+public enum ServiceUnitState {
+
+ Free, // not owned by any broker (terminal state)
+
+ Owned, // owned by a broker (terminal state)
+
+ Assigned, // the ownership is assigned(but the assigned broker has not been notified the ownership yet)
+
+ Released, // the source broker's ownership has been released (e.g. the topic connections are closed)
+
+ Splitting; // the service unit(e.g. bundle) is in the process of splitting.
+
+ private static Map> validTransitions = Map.of(
+ Free, Set.of(Owned, Assigned),
+ Owned, Set.of(Assigned, Splitting, Free),
+ Assigned, Set.of(Owned, Released, Free),
+ Released, Set.of(Owned, Free),
+ Splitting, Set.of(Free)
+ );
+
+ public static boolean isValidTransition(ServiceUnitState from, ServiceUnitState to) {
+ Set transitions = validTransitions.get(from);
+ return transitions.contains(to);
+ }
+
+}
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannel.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannel.java
new file mode 100644
index 0000000000000..3727050ec015e
--- /dev/null
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannel.java
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.loadbalance.extensions.channel;
+
+import java.io.Closeable;
+import java.util.concurrent.CompletableFuture;
+import org.apache.pulsar.broker.PulsarServerException;
+import org.apache.pulsar.broker.loadbalance.extensions.models.Split;
+import org.apache.pulsar.broker.loadbalance.extensions.models.Unload;
+import org.apache.pulsar.metadata.api.NotificationType;
+import org.apache.pulsar.metadata.api.extended.SessionEvent;
+
+/**
+ * Defines the ServiceUnitStateChannel interface.
+ */
+public interface ServiceUnitStateChannel extends Closeable {
+
+ /**
+ * Starts the ServiceUnitStateChannel.
+ * @throws PulsarServerException if it fails to start the channel.
+ */
+ void start() throws PulsarServerException;
+
+ /**
+ * Closes the ServiceUnitStateChannel.
+ * @throws PulsarServerException if it fails to close the channel.
+ */
+ @Override
+ void close() throws PulsarServerException;
+
+ /**
+ * Schedules the periodic compaction for the system topic in this channel.
+ * @throws PulsarServerException if it fails to schedule the compaction.
+ */
+ void scheduleCompaction() throws PulsarServerException;
+
+ /**
+ * Gets the current owner broker of the system topic in this channel.
+ * @return the service url without the protocol prefix, 'http://'. e.g. broker-xyz:abcd
+ *
+ * ServiceUnitStateChannel elects the separate leader as the owner broker of the system topic in this channel.
+ * If there is no leader at the moment, it will throw a runtime exception.
+ */
+ String getChannelOwner();
+
+ /**
+ * Checks if the current broker is the owner broker of the system topic in this channel.
+ * @return True if the current broker is the owner. Otherwise, false.
+ */
+ boolean isChannelOwner();
+
+ /**
+ * Handles the metadata session events to track
+ * if the connection between the broker and metadata store is stable or not.
+ * This will be registered as a metadata SessionEvent listener.
+ *
+ * The stability of the metadata connection is important
+ * to determine how to handle the broker deletion(unavailable) event notified from the metadata store.
+ *
+ * Please refer to handleBrokerRegistrationEvent(String broker, NotificationType type) for more details.
+ *
+ * @param event metadata session events
+ */
+ void handleMetadataSessionEvent(SessionEvent event);
+
+ /**
+ * Handles the broker registration event from the broker registry.
+ * This will be registered as a broker registry listener.
+ *
+ * Case 1: If NotificationType is Deleted,
+ * it will schedule a clean-up operation to release the ownerships of the deleted broker.
+ *
+ * Sub-case1: If the metadata connection has been stable for long time,
+ * it will immediately execute the cleanup operation to guarantee high-availability.
+ *
+ * Sub-case2: If the metadata connection has been stable only for short time,
+ * it will defer the clean-up operation for some time and execute it.
+ * This is to gracefully handle the case when metadata connection is flaky --
+ * If the deleted broker comes back very soon,
+ * we better cancel the clean-up operation for high-availability.
+ *
+ * Sub-case3: If the metadata connection is unstable,
+ * it will not schedule the clean-up operation, as the broker-metadata connection is lost.
+ * The brokers will continue to serve existing topics connections,
+ * and we better not to interrupt the existing topic connections for high-availability.
+ *
+ *
+ * Case 2: If NotificationType is Created,
+ * it will cancel any scheduled clean-up operation if still not executed.
+ *
+ * @param broker notified broker
+ * @param type notification type
+ */
+ void handleBrokerRegistrationEvent(String broker, NotificationType type);
+
+ /**
+ * Asynchronously gets the current owner broker of the service unit.
+ *
+ *
+ * @param serviceUnit (e.g. bundle)
+ * @return the future object of the owner broker
+ *
+ * Case 1: If the service unit is owned, it returns the completed future object with the current owner.
+ * Case 2: If the service unit's assignment is ongoing, it returns the non-completed future object.
+ * Sub-case1: If the assigned broker is available and finally takes the ownership,
+ * the future object will complete and return the owner broker.
+ * Sub-case2: If the assigned broker does not take the ownership in time,
+ * the future object will time out.
+ * Case 3: If none of them, it returns null.
+ */
+ CompletableFuture getOwnerAsync(String serviceUnit);
+
+ /**
+ * Asynchronously publishes the service unit assignment event to the system topic in this channel.
+ * It de-duplicates assignment events if there is any ongoing assignment event for the same service unit.
+ * @param serviceUnit (e.g bundle)
+ * @param broker the assigned broker
+ * @return the completable future object with the owner broker
+ * case 1: If the assigned broker is available and takes the ownership,
+ * the future object will complete and return the owner broker.
+ * The returned owner broker could be different from the input broker (due to assignment race-condition).
+ * case 2: If the assigned broker does not take the ownership in time,
+ * the future object will time out.
+ */
+ CompletableFuture publishAssignEventAsync(String serviceUnit, String broker);
+
+ /**
+ * Asynchronously publishes the service unit unload event to the system topic in this channel.
+ * @param unload (unload specification object)
+ * @return the completable future object staged from the event message sendAsync.
+ */
+ CompletableFuture publishUnloadEventAsync(Unload unload);
+
+ /**
+ * Asynchronously publishes the bundle split event to the system topic in this channel.
+ * @param split (split specification object)
+ * @return the completable future object staged from the event message sendAsync.
+ */
+ CompletableFuture publishSplitEventAsync(Split split);
+
+}
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateData.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateData.java
new file mode 100644
index 0000000000000..cba459b7875f7
--- /dev/null
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateData.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.loadbalance.extensions.channel;
+
+
+import java.util.Objects;
+
+/**
+ * Defines data for the service unit state changes.
+ * This data will be broadcast in ServiceUnitStateChannel.
+ */
+
+public record ServiceUnitStateData(ServiceUnitState state, String broker, String sourceBroker, long timestamp) {
+
+ public ServiceUnitStateData {
+ Objects.requireNonNull(state);
+ Objects.requireNonNull(broker);
+ }
+
+ public ServiceUnitStateData(ServiceUnitState state, String broker, String sourceBroker) {
+ this(state, broker, sourceBroker, System.currentTimeMillis());
+ }
+
+ public ServiceUnitStateData(ServiceUnitState state, String broker) {
+ this(state, broker, null, System.currentTimeMillis());
+ }
+}
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/channel/package-info.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/channel/package-info.java
new file mode 100644
index 0000000000000..a95ce9ea8e567
--- /dev/null
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/channel/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.loadbalance.extensions.channel;
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/models/Split.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/models/Split.java
new file mode 100644
index 0000000000000..fcec8b0ae5541
--- /dev/null
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/models/Split.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.loadbalance.extensions.models;
+
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+
+/**
+ * Defines the information required for a service unit split(e.g. bundle split).
+ */
+public record Split(
+ String serviceUnit, String sourceBroker, Map> splitServiceUnitToDestBroker) {
+
+ public Split {
+ Objects.requireNonNull(serviceUnit);
+ }
+}
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/models/Unload.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/models/Unload.java
new file mode 100644
index 0000000000000..d474011919d97
--- /dev/null
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/models/Unload.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.loadbalance.extensions.models;
+
+import java.util.Objects;
+import java.util.Optional;
+
+/**
+ * Defines the information required to unload or transfer a service unit(e.g. bundle).
+ */
+public record Unload(String sourceBroker, String serviceUnit, Optional destBroker) {
+ public Unload {
+ Objects.requireNonNull(sourceBroker);
+ Objects.requireNonNull(serviceUnit);
+ }
+ public Unload(String sourceBroker, String serviceUnit) {
+ this(sourceBroker, serviceUnit, Optional.empty());
+ }
+}
\ No newline at end of file
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/models/package-info.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/models/package-info.java
new file mode 100644
index 0000000000000..db9028076f992
--- /dev/null
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/models/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.loadbalance.extensions.models;
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/BrokerVersionFilter.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/BrokerVersionFilter.java
index db709cce978c0..4509911191212 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/BrokerVersionFilter.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/BrokerVersionFilter.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/BundleSplitterTask.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/BundleSplitterTask.java
index 480f466c2ab4d..c0c6eebc32a6e 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/BundleSplitterTask.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/BundleSplitterTask.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/DeviationShedder.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/DeviationShedder.java
index de2ce6cedc7de..fd90a728478f4 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/DeviationShedder.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/DeviationShedder.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/GenericBrokerHostUsageImpl.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/GenericBrokerHostUsageImpl.java
index 1405e8e3953ac..1a28bd7a39269 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/GenericBrokerHostUsageImpl.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/GenericBrokerHostUsageImpl.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LeastLongTermMessageRate.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LeastLongTermMessageRate.java
index d2662b6d981d1..fe161467338ff 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LeastLongTermMessageRate.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LeastLongTermMessageRate.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LeastResourceUsageWithWeight.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LeastResourceUsageWithWeight.java
index 4763eaf23daa8..3abb6d6283558 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LeastResourceUsageWithWeight.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LeastResourceUsageWithWeight.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -91,7 +91,7 @@ private double updateAndGetMaxResourceUsageWithWeight(String broker, BrokerData
ServiceConfiguration conf) {
final double historyPercentage = conf.getLoadBalancerHistoryResourcePercentage();
Double historyUsage = brokerAvgResourceUsageWithWeight.get(broker);
- double resourceUsage = brokerData.getLocalData().getMaxResourceUsageWithWeightWithinLimit(
+ double resourceUsage = brokerData.getLocalData().getMaxResourceUsageWithWeight(
conf.getLoadBalancerCPUResourceWeight(),
conf.getLoadBalancerMemoryResourceWeight(),
conf.getLoadBalancerDirectMemoryResourceWeight(),
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LinuxBrokerHostUsageImpl.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LinuxBrokerHostUsageImpl.java
index b605c523ddc40..ecba0d3ae0169 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LinuxBrokerHostUsageImpl.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LinuxBrokerHostUsageImpl.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LoadManagerShared.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LoadManagerShared.java
index a298558f34502..2c90b8a4047a2 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LoadManagerShared.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/LoadManagerShared.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ModularLoadManagerImpl.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ModularLoadManagerImpl.java
index faa6fe48bbc6a..7d1a21a8c900e 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ModularLoadManagerImpl.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ModularLoadManagerImpl.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -20,7 +20,6 @@
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
-import io.netty.util.concurrent.DefaultThreadFactory;
import java.util.ArrayList;
import java.util.Collection;
import java.util.ConcurrentModificationException;
@@ -60,6 +59,7 @@
import org.apache.pulsar.broker.resources.ClusterResources;
import org.apache.pulsar.broker.stats.prometheus.metrics.Summary;
import org.apache.pulsar.client.admin.PulsarAdminException;
+import org.apache.pulsar.client.util.ExecutorProvider;
import org.apache.pulsar.common.naming.NamespaceBundleFactory;
import org.apache.pulsar.common.naming.NamespaceName;
import org.apache.pulsar.common.naming.ServiceUnitId;
@@ -212,7 +212,8 @@ public ModularLoadManagerImpl() {
loadData = new LoadData();
loadSheddingPipeline = new ArrayList<>();
preallocatedBundleToBroker = new ConcurrentHashMap<>();
- scheduler = Executors.newSingleThreadScheduledExecutor(new DefaultThreadFactory("pulsar-modular-load-manager"));
+ scheduler = Executors.newSingleThreadScheduledExecutor(
+ new ExecutorProvider.ExtendedThreadFactory("pulsar-modular-load-manager"));
this.brokerToFailureDomainMap = new HashMap<>();
this.brokerTopicLoadingPredicate = new BrokerTopicLoadingPredicate() {
@@ -442,9 +443,8 @@ private boolean needBrokerDataUpdate() {
long timeSinceLastReportWrittenToStore = System.currentTimeMillis() - localData.getLastUpdate();
if (timeSinceLastReportWrittenToStore > updateMaxIntervalMillis) {
log.info("Writing local data to metadata store because time since last"
- + " update exceeded threshold of {} minutes. ResourceUsage:[{}]",
- conf.getLoadBalancerReportUpdateMaxIntervalMinutes(),
- localData.printResourceUsage());
+ + " update exceeded threshold of {} minutes",
+ conf.getLoadBalancerReportUpdateMaxIntervalMinutes());
// Always update after surpassing the maximum interval.
return true;
}
@@ -458,10 +458,9 @@ private boolean needBrokerDataUpdate() {
percentChange(lastData.getNumBundles(), localData.getNumBundles()))));
if (maxChange > conf.getLoadBalancerReportUpdateThresholdPercentage()) {
log.info("Writing local data to metadata store because maximum change {}% exceeded threshold {}%; "
- + "time since last report written is {} seconds. ResourceUsage:[{}]", maxChange,
+ + "time since last report written is {} seconds", maxChange,
conf.getLoadBalancerReportUpdateThresholdPercentage(),
- timeSinceLastReportWrittenToStore / 1000.0,
- localData.printResourceUsage());
+ timeSinceLastReportWrittenToStore / 1000.0);
return true;
}
return false;
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ModularLoadManagerWrapper.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ModularLoadManagerWrapper.java
index d18cd6165865f..5f7cd5b8c38fa 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ModularLoadManagerWrapper.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ModularLoadManagerWrapper.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/OverloadShedder.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/OverloadShedder.java
index 1eff3dd250a44..a4eb5077224ce 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/OverloadShedder.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/OverloadShedder.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -114,9 +114,7 @@ public Multimap findBundlesForUnloading(final LoadData loadData,
}).filter(e -> {
// Only consider bundles that were not already unloaded recently
return !recentlyUnloadedBundles.containsKey(e.getLeft());
- }).filter(e ->
- localData.getBundles().contains(e.getLeft())
- ).sorted((e1, e2) -> {
+ }).sorted((e1, e2) -> {
// Sort by throughput in reverse order
return Double.compare(e2.getRight(), e1.getRight());
}).forEach(e -> {
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/PulsarLoadReportImpl.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/PulsarLoadReportImpl.java
index 53c005279043a..caf9707df5805 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/PulsarLoadReportImpl.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/PulsarLoadReportImpl.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/PulsarResourceDescription.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/PulsarResourceDescription.java
index 676d15a51dc6a..3a1e5bce48ebf 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/PulsarResourceDescription.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/PulsarResourceDescription.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/PulsarServiceRequest.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/PulsarServiceRequest.java
index 59da5313281a3..625ef7d1237d1 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/PulsarServiceRequest.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/PulsarServiceRequest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/PulsarServiceUnit.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/PulsarServiceUnit.java
index 277675347f7d4..b99f0c3f6a150 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/PulsarServiceUnit.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/PulsarServiceUnit.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ResourceAvailabilityRanker.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ResourceAvailabilityRanker.java
index 2effd4eedc641..6c1c174f0c36f 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ResourceAvailabilityRanker.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ResourceAvailabilityRanker.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/SimpleLoadCalculatorImpl.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/SimpleLoadCalculatorImpl.java
index 8998ea9cc24a8..3d9e363b4af9f 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/SimpleLoadCalculatorImpl.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/SimpleLoadCalculatorImpl.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/SimpleLoadManagerImpl.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/SimpleLoadManagerImpl.java
index be45e215811b5..c2c0d1947c93e 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/SimpleLoadManagerImpl.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/SimpleLoadManagerImpl.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -26,7 +26,6 @@
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
import com.google.common.collect.TreeMultimap;
-import io.netty.util.concurrent.DefaultThreadFactory;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
@@ -55,6 +54,7 @@
import org.apache.pulsar.broker.loadbalance.PlacementStrategy;
import org.apache.pulsar.broker.loadbalance.ResourceUnit;
import org.apache.pulsar.broker.loadbalance.impl.LoadManagerShared.BrokerTopicLoadingPredicate;
+import org.apache.pulsar.client.util.ExecutorProvider;
import org.apache.pulsar.common.naming.NamespaceName;
import org.apache.pulsar.common.naming.ServiceUnitId;
import org.apache.pulsar.common.policies.data.ResourceQuota;
@@ -189,7 +189,7 @@ public class SimpleLoadManagerImpl implements LoadManager, Consumer());
this.currentLoadReports = new HashMap<>();
this.resourceUnitRankings = new HashMap<>();
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/SimpleResourceAllocationPolicies.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/SimpleResourceAllocationPolicies.java
index 7021a767fcde2..4a1577a4e28b6 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/SimpleResourceAllocationPolicies.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/SimpleResourceAllocationPolicies.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/SimpleResourceUnit.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/SimpleResourceUnit.java
index 863a75dff4235..3b67b73dc682a 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/SimpleResourceUnit.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/SimpleResourceUnit.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ThresholdShedder.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ThresholdShedder.java
index 928f045369cff..c75c9c8a3178c 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ThresholdShedder.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ThresholdShedder.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -56,37 +56,16 @@ public class ThresholdShedder implements LoadSheddingStrategy {
private static final double LOWER_BOUNDARY_THRESHOLD_MARGIN = 0.5;
private static final double MB = 1024 * 1024;
-
- private static final long LOAD_LOG_SAMPLE_DELAY_IN_SEC = 5 * 60; // 5 mins
private final Map brokerAvgResourceUsage = new HashMap<>();
- private long lastSampledLoadLogTS = 0;
-
-
- private static int toPercentage(double usage) {
- return (int) (usage * 100);
- }
-
- private boolean canSampleLog() {
- long now = System.currentTimeMillis() / 1000;
- boolean sampleLog = now - lastSampledLoadLogTS >= LOAD_LOG_SAMPLE_DELAY_IN_SEC;
- if (sampleLog) {
- lastSampledLoadLogTS = now;
- }
- return sampleLog;
- }
@Override
public Multimap findBundlesForUnloading(final LoadData loadData, final ServiceConfiguration conf) {
selectedBundlesCache.clear();
- boolean sampleLog = canSampleLog();
final double threshold = conf.getLoadBalancerBrokerThresholdShedderPercentage() / 100.0;
final Map recentlyUnloadedBundles = loadData.getRecentlyUnloadedBundles();
final double minThroughputThreshold = conf.getLoadBalancerBundleUnloadMinThroughputThreshold() * MB;
- final double avgUsage = getBrokerAvgUsage(loadData, conf, sampleLog);
- if (sampleLog) {
- log.info("brokers' resource avgUsage:{}%", toPercentage(avgUsage));
- }
+ final double avgUsage = getBrokerAvgUsage(loadData, conf.getLoadBalancerHistoryResourcePercentage(), conf);
if (avgUsage == 0) {
log.warn("average max resource usage is 0");
@@ -98,9 +77,8 @@ public Multimap findBundlesForUnloading(final LoadData loadData,
final double currentUsage = brokerAvgResourceUsage.getOrDefault(broker, 0.0);
if (currentUsage < avgUsage + threshold) {
- if (sampleLog) {
- log.info("[{}] broker is not overloaded, ignoring at this point, currentUsage:{}%",
- broker, toPercentage(currentUsage));
+ if (log.isDebugEnabled()) {
+ log.debug("[{}] broker is not overloaded, ignoring at this point", broker);
}
return;
}
@@ -111,13 +89,14 @@ public Multimap findBundlesForUnloading(final LoadData loadData,
double minimumThroughputToOffload = brokerCurrentThroughput * percentOfTrafficToOffload;
if (minimumThroughputToOffload < minThroughputThreshold) {
- if (sampleLog) {
- log.info("[{}] broker is planning to shed throughput {} MByte/s less than "
+ if (log.isDebugEnabled()) {
+ log.debug("[{}] broker is planning to shed throughput {} MByte/s less than "
+ "minimumThroughputThreshold {} MByte/s, skipping bundle unload.",
broker, minimumThroughputToOffload / MB, minThroughputThreshold / MB);
}
return;
}
+
log.info(
"Attempting to shed load on {}, which has max resource usage above avgUsage and threshold {}%"
+ " > {}% + {}% -- Offloading at least {} MByte/s of traffic, left throughput {} MByte/s",
@@ -168,16 +147,15 @@ private void filterAndSelectBundle(LoadData loadData, Map recently
});
}
- private double getBrokerAvgUsage(final LoadData loadData,
- final ServiceConfiguration conf, boolean sampleLog) {
- double historyPercentage = conf.getLoadBalancerHistoryResourcePercentage();
+ private double getBrokerAvgUsage(final LoadData loadData, final double historyPercentage,
+ final ServiceConfiguration conf) {
double totalUsage = 0.0;
int totalBrokers = 0;
for (Map.Entry entry : loadData.getBrokerData().entrySet()) {
LocalBrokerData localBrokerData = entry.getValue().getLocalData();
String broker = entry.getKey();
- totalUsage += updateAvgResourceUsage(broker, localBrokerData, historyPercentage, conf, sampleLog);
+ totalUsage += updateAvgResourceUsage(broker, localBrokerData, historyPercentage, conf);
totalBrokers++;
}
@@ -185,8 +163,7 @@ private double getBrokerAvgUsage(final LoadData loadData,
}
private double updateAvgResourceUsage(String broker, LocalBrokerData localBrokerData,
- final double historyPercentage, final ServiceConfiguration conf,
- boolean sampleLog) {
+ final double historyPercentage, final ServiceConfiguration conf) {
Double historyUsage =
brokerAvgResourceUsage.get(broker);
double resourceUsage = localBrokerData.getMaxResourceUsageWithWeight(
@@ -194,41 +171,6 @@ private double updateAvgResourceUsage(String broker, LocalBrokerData localBroker
conf.getLoadBalancerMemoryResourceWeight(), conf.getLoadBalancerDirectMemoryResourceWeight(),
conf.getLoadBalancerBandwithInResourceWeight(),
conf.getLoadBalancerBandwithOutResourceWeight());
-
- if (sampleLog) {
- log.info("{} broker load: historyUsage={}%, resourceUsage={}%",
- broker,
- historyUsage == null ? 0 : toPercentage(historyUsage),
- toPercentage(resourceUsage));
- }
-
- // wrap if resourceUsage is bigger than 1.0
- if (resourceUsage > 1.0) {
- log.error("{} broker resourceUsage is bigger than 100%. "
- + "Some of the resource limits are mis-configured. "
- + "Try to disable the error resource signals by setting their weights to zero "
- + "or fix the resource limit configurations. "
- + "Ref:https://pulsar.apache.org/docs/administration-load-balance/#thresholdshedder "
- + "ResourceUsage:[{}], "
- + "CPUResourceWeight:{}, MemoryResourceWeight:{}, DirectMemoryResourceWeight:{}, "
- + "BandwithInResourceWeight:{}, BandwithOutResourceWeight:{}",
- broker,
- localBrokerData.printResourceUsage(),
- conf.getLoadBalancerCPUResourceWeight(),
- conf.getLoadBalancerMemoryResourceWeight(),
- conf.getLoadBalancerDirectMemoryResourceWeight(),
- conf.getLoadBalancerBandwithInResourceWeight(),
- conf.getLoadBalancerBandwithOutResourceWeight());
-
- resourceUsage = localBrokerData.getMaxResourceUsageWithWeightWithinLimit(
- conf.getLoadBalancerCPUResourceWeight(),
- conf.getLoadBalancerMemoryResourceWeight(), conf.getLoadBalancerDirectMemoryResourceWeight(),
- conf.getLoadBalancerBandwithInResourceWeight(),
- conf.getLoadBalancerBandwithOutResourceWeight());
-
- log.warn("{} broker recomputed max resourceUsage={}%. Skipped usage signals bigger than 100%",
- broker, toPercentage(resourceUsage));
- }
historyUsage = historyUsage == null
? resourceUsage : historyUsage * historyPercentage + (1 - historyPercentage) * resourceUsage;
@@ -239,7 +181,7 @@ private double updateAvgResourceUsage(String broker, LocalBrokerData localBroker
private void tryLowerBoundaryShedding(LoadData loadData, ServiceConfiguration conf) {
// Select the broker with the most resource usage.
final double threshold = conf.getLoadBalancerBrokerThresholdShedderPercentage() / 100.0;
- final double avgUsage = getBrokerAvgUsage(loadData, conf, canSampleLog());
+ final double avgUsage = getBrokerAvgUsage(loadData, conf.getLoadBalancerHistoryResourcePercentage(), conf);
Pair result = getMaxUsageBroker(loadData, threshold, avgUsage);
boolean hasBrokerBelowLowerBound = result.getLeft();
String maxUsageBroker = result.getRight();
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/UniformLoadShedder.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/UniformLoadShedder.java
index c31f9e14196df..b92af5b7c69f3 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/UniformLoadShedder.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/UniformLoadShedder.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/WRRPlacementStrategy.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/WRRPlacementStrategy.java
index 54a4646f86a74..bee9ae6d5f00f 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/WRRPlacementStrategy.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/WRRPlacementStrategy.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/package-info.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/package-info.java
index 06fdd0a7fb112..5e5ca40f2a75f 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/package-info.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/package-info.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/package-info.java
index 9d148446ca653..223446837332a 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/package-info.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/LookupResult.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/LookupResult.java
index 7ed90c9de6e1a..face01a8bffd7 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/LookupResult.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/LookupResult.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/NamespaceData.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/NamespaceData.java
index 4e59906e1a16f..c56ccb1fbfb2c 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/NamespaceData.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/NamespaceData.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/RedirectData.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/RedirectData.java
index 38351f1a6d6c7..1d9f6094bb725 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/RedirectData.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/RedirectData.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/TopicLookupBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/TopicLookupBase.java
index 3c29ef1597a3f..0acde9947226b 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/TopicLookupBase.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/TopicLookupBase.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -68,11 +68,12 @@ protected CompletableFuture internalLookupTopicAsync(TopicName topic
// Currently, it's hard to check the non-persistent-non-partitioned topic, because it only exists
// in the broker, it doesn't have metadata. If the topic is non-persistent and non-partitioned,
// we'll return the true flag.
- CompletableFuture existFuture = pulsar().getBrokerService()
- .isAllowAutoTopicCreation(topicName)
- || (!topicName.isPersistent() && !topicName.isPartitioned())
+ CompletableFuture existFuture = (!topicName.isPersistent() && !topicName.isPartitioned())
? CompletableFuture.completedFuture(true)
- : pulsar().getNamespaceService().checkTopicExists(topicName);
+ : pulsar().getNamespaceService().checkTopicExists(topicName)
+ .thenCompose(exists -> exists ? CompletableFuture.completedFuture(true)
+ : pulsar().getBrokerService().isAllowAutoTopicCreationAsync(topicName));
+
return existFuture;
})
.thenCompose(exist -> {
@@ -250,9 +251,19 @@ public static CompletableFuture lookupTopicAsync(PulsarService pulsarSe
requestId,
false));
}).exceptionally(ex -> {
+ Throwable throwable = FutureUtil.unwrapCompletionException(ex);
+ if (throwable instanceof RestException restException){
+ if (restException.getResponse().getStatus()
+ == Response.Status.NOT_FOUND.getStatusCode()) {
+ validationFuture.complete(
+ newLookupErrorResponse(ServerError.TopicNotFound,
+ throwable.getMessage(), requestId));
+ return null;
+ }
+ }
validationFuture.complete(
newLookupErrorResponse(ServerError.MetadataError,
- FutureUtil.unwrapCompletionException(ex).getMessage(), requestId));
+ throwable.getMessage(), requestId));
return null;
});
})
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/package-info.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/package-info.java
index 6b2a61b00438c..8460f41d681c2 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/package-info.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/v1/TopicLookup.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/v1/TopicLookup.java
index 064a393da6570..ac471a1a819e6 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/v1/TopicLookup.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/v1/TopicLookup.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/v1/package-info.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/v1/package-info.java
index 4b1cdc4be8aea..81fe5cb610575 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/v1/package-info.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/v1/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/v2/TopicLookup.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/v2/TopicLookup.java
index 01fb15ba4951c..18dc75860888f 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/v2/TopicLookup.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/v2/TopicLookup.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/v2/package-info.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/v2/package-info.java
index d0bebb15daed2..3c12f8a65cabc 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/v2/package-info.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/v2/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/LookupOptions.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/LookupOptions.java
index 6552090e1907d..431266682c51c 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/LookupOptions.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/LookupOptions.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceBundleOwnershipListener.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceBundleOwnershipListener.java
index eacade4c60b8f..edfb8d213da7c 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceBundleOwnershipListener.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceBundleOwnershipListener.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceEphemeralData.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceEphemeralData.java
index e86007b64460d..1ffc03786d555 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceEphemeralData.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceEphemeralData.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java
index 127a5be70bb16..4be64f4b7b50c 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -113,32 +113,17 @@
* @see org.apache.pulsar.broker.PulsarService
*/
public class NamespaceService implements AutoCloseable {
-
- public enum AddressType {
- BROKER_URL, LOOKUP_URL
- }
-
private static final Logger LOG = LoggerFactory.getLogger(NamespaceService.class);
private final ServiceConfiguration config;
-
- private final MetadataCache localPoliciesCache;
-
private final AtomicReference loadManager;
-
private final PulsarService pulsar;
-
private final OwnershipCache ownershipCache;
private final MetadataCache localBrokerDataCache;
-
private final NamespaceBundleFactory bundleFactory;
-
- private int uncountedNamespaces;
-
private final String host;
private static final int BUNDLE_SPLIT_RETRY_LIMIT = 7;
-
public static final String SLA_NAMESPACE_PROPERTY = "sla-monitor";
public static final Pattern HEARTBEAT_NAMESPACE_PATTERN = Pattern.compile("pulsar/[^/]+/([^:]+:\\d+)");
public static final Pattern HEARTBEAT_NAMESPACE_PATTERN_V2 = Pattern.compile("pulsar/([^:]+:\\d+)");
@@ -166,8 +151,6 @@ public enum AddressType {
/**
* Default constructor.
- *
- * @throws PulsarServerException
*/
public NamespaceService(PulsarService pulsar) {
this.pulsar = pulsar;
@@ -180,7 +163,6 @@ public NamespaceService(PulsarService pulsar) {
ConcurrentOpenHashMap.newBuilder().build();
this.bundleOwnershipListeners = new CopyOnWriteArrayList<>();
this.localBrokerDataCache = pulsar.getLocalMetadataStore().getMetadataCache(LocalBrokerData.class);
- this.localPoliciesCache = pulsar.getLocalMetadataStore().getMetadataCache(LocalPolicies.class);
}
public void initialize() {
@@ -302,13 +284,11 @@ public void registerBootstrapNamespaces() throws PulsarServerException {
// ensure that we own the heartbeat namespace
if (registerNamespace(getHeartbeatNamespace(host, config), true)) {
- this.uncountedNamespaces++;
LOG.info("added heartbeat namespace name in local cache: ns={}", getHeartbeatNamespace(host, config));
}
// ensure that we own the heartbeat namespace
if (registerNamespace(getHeartbeatNamespaceV2(host, config), true)) {
- this.uncountedNamespaces++;
LOG.info("added heartbeat namespace name in local cache: ns={}", getHeartbeatNamespaceV2(host, config));
}
@@ -1183,7 +1163,15 @@ public CompletableFuture> getOwnedTopicListForNamespaceBundle(Names
public CompletableFuture checkTopicExists(TopicName topic) {
if (topic.isPersistent()) {
- return pulsar.getPulsarResources().getTopicResources().persistentTopicExists(topic);
+ if (topic.isPartitioned()) {
+ return pulsar.getPulsarResources().getNamespaceResources().getPartitionedTopicResources()
+ .partitionedTopicExistsAsync(TopicName.get(topic.getPartitionedTopicName()))
+ .thenCompose(exists -> exists
+ ? pulsar.getPulsarResources().getTopicResources().persistentTopicExists(topic)
+ : CompletableFuture.completedFuture(false));
+ } else {
+ return pulsar.getPulsarResources().getTopicResources().persistentTopicExists(topic);
+ }
} else {
if (topic.isPartitioned()) {
final TopicName partitionedTopicName = TopicName.get(topic.getPartitionedTopicName());
@@ -1461,8 +1449,6 @@ public static boolean isHeartbeatNamespace(ServiceUnitId ns) {
public boolean registerSLANamespace() throws PulsarServerException {
boolean isNameSpaceRegistered = registerNamespace(getSLAMonitorNamespace(host, config), false);
if (isNameSpaceRegistered) {
- this.uncountedNamespaces++;
-
if (LOG.isDebugEnabled()) {
LOG.debug("Added SLA Monitoring namespace name in local cache: ns={}",
getSLAMonitorNamespace(host, config));
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/OwnedBundle.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/OwnedBundle.java
index ac6e30e7c5233..e7cf23a042750 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/OwnedBundle.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/OwnedBundle.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/OwnershipCache.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/OwnershipCache.java
index e0cdd129a8f03..a9dd44d4589d9 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/OwnershipCache.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/OwnershipCache.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -21,6 +21,7 @@
import com.github.benmanes.caffeine.cache.AsyncCacheLoader;
import com.github.benmanes.caffeine.cache.AsyncLoadingCache;
import com.github.benmanes.caffeine.cache.Caffeine;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.util.concurrent.MoreExecutors;
import java.util.ArrayList;
import java.util.List;
@@ -207,7 +208,7 @@ public CompletableFuture tryAcquiringOwnership(Namespace
*
*/
public CompletableFuture removeOwnership(NamespaceBundle bundle) {
- ResourceLock lock = locallyAcquiredLocks.get(bundle);
+ ResourceLock lock = locallyAcquiredLocks.remove(bundle);
if (lock == null) {
// We don't own the specified bundle anymore
return CompletableFuture.completedFuture(null);
@@ -328,6 +329,12 @@ public void invalidateLocalOwnerCache(NamespaceBundle namespaceBundle) {
this.ownedBundlesCache.synchronous().invalidate(namespaceBundle);
}
+ @VisibleForTesting
+ public Map> getLocallyAcquiredLocks() {
+ return locallyAcquiredLocks;
+ }
+
+
public synchronized boolean refreshSelfOwnerInfo() {
this.selfOwnerInfo = new NamespaceEphemeralData(pulsar.getBrokerServiceUrl(),
pulsar.getBrokerServiceUrlTls(), pulsar.getSafeWebServiceAddress(),
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/ServiceUnitUtils.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/ServiceUnitUtils.java
index b209abf50bf1c..c86aac5316fb9 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/ServiceUnitUtils.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/ServiceUnitUtils.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/package-info.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/package-info.java
index e7243dc2a8b68..747637188b7ea 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/package-info.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/package-info.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/package-info.java
index 874ac45a2f500..5f89b7356c379 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/package-info.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/ProtocolHandler.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/ProtocolHandler.java
index 482d7a6f0b71b..85d2a93df7b8c 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/ProtocolHandler.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/ProtocolHandler.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/ProtocolHandlerDefinition.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/ProtocolHandlerDefinition.java
index 6123b390aa0f6..cd06a89f33b32 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/ProtocolHandlerDefinition.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/ProtocolHandlerDefinition.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/ProtocolHandlerDefinitions.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/ProtocolHandlerDefinitions.java
index d79bd7f024621..0401cae4e89b8 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/ProtocolHandlerDefinitions.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/ProtocolHandlerDefinitions.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/ProtocolHandlerMetadata.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/ProtocolHandlerMetadata.java
index 86c486fea6d42..50c06cf8bc4d1 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/ProtocolHandlerMetadata.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/ProtocolHandlerMetadata.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/ProtocolHandlerUtils.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/ProtocolHandlerUtils.java
index c65bf3713aebe..0f75a06cb3ef4 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/ProtocolHandlerUtils.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/ProtocolHandlerUtils.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/ProtocolHandlerWithClassLoader.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/ProtocolHandlerWithClassLoader.java
index 63aa6696917d9..d648c261403d4 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/ProtocolHandlerWithClassLoader.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/ProtocolHandlerWithClassLoader.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/ProtocolHandlers.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/ProtocolHandlers.java
index a7d09bff9236f..42a82b2de762b 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/ProtocolHandlers.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/ProtocolHandlers.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/package-info.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/package-info.java
index 211099e6463c2..3c18262d8a3bf 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/package-info.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/protocol/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroup.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroup.java
index dc0a25cc1f479..ef40a18ab08ed 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroup.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroup.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupConfigListener.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupConfigListener.java
index 7c487b8496bca..5428d12ebad8c 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupConfigListener.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupConfigListener.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupNamespaceConfigListener.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupNamespaceConfigListener.java
index e0d62f15b5ef5..e19034c525761 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupNamespaceConfigListener.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupNamespaceConfigListener.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupPublishLimiter.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupPublishLimiter.java
index f2f6bcd8df1d5..85e00bb2f87dc 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupPublishLimiter.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupPublishLimiter.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupService.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupService.java
index c74681fdb731a..d3f8eb7613a40 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupService.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupService.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceQuotaCalculator.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceQuotaCalculator.java
index 80eb6888a6f65..4c8b9275b9725 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceQuotaCalculator.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceQuotaCalculator.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceQuotaCalculatorImpl.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceQuotaCalculatorImpl.java
index 5dc50f2a25536..09f76aa8e6fe2 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceQuotaCalculatorImpl.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceQuotaCalculatorImpl.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceUsageConsumer.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceUsageConsumer.java
index a8be0766636fd..7e82d4eb0eee5 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceUsageConsumer.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceUsageConsumer.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceUsagePublisher.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceUsagePublisher.java
index 7ae0bab86031f..2cde6769294f6 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceUsagePublisher.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceUsagePublisher.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceUsageTopicTransportManager.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceUsageTopicTransportManager.java
index 6ce0781781a54..84917d00da409 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceUsageTopicTransportManager.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceUsageTopicTransportManager.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceUsageTransportManager.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceUsageTransportManager.java
index 448460526543a..665f6a7eb7da5 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceUsageTransportManager.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceUsageTransportManager.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/package-info.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/package-info.java
index ba7ee9ee21c63..a842db96a84e3 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/package-info.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/rest/RestMessagePublishContext.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/rest/RestMessagePublishContext.java
index 9891572ab3997..d7cee8b600b31 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/rest/RestMessagePublishContext.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/rest/RestMessagePublishContext.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/rest/Topics.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/rest/Topics.java
index a8095f0327905..5b17b05db209f 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/rest/Topics.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/rest/Topics.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/rest/TopicsBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/rest/TopicsBase.java
index 86e8956d950d7..d4f71740d9e9e 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/rest/TopicsBase.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/rest/TopicsBase.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/rest/package-info.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/rest/package-info.java
index bafd56b716f2b..3662fdcd6909e 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/rest/package-info.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/rest/package-info.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractBaseDispatcher.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractBaseDispatcher.java
index 5069f7cd44000..a7a39e2ff0dcb 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractBaseDispatcher.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractBaseDispatcher.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -16,10 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.pulsar.broker.service;
import io.netty.buffer.ByteBuf;
+import io.prometheus.client.Gauge;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -50,6 +50,12 @@
@Slf4j
public abstract class AbstractBaseDispatcher extends EntryFilterSupport implements Dispatcher {
+ private static final Gauge PENDING_BYTES_TO_DISPATCH = Gauge
+ .build()
+ .name("pulsar_broker_pending_bytes_to_dispatch")
+ .help("Amount of bytes loaded in memory to be dispatched to Consumers")
+ .register();
+
protected final ServiceConfiguration serviceConfig;
protected final boolean dispatchThrottlingOnBatchMessageEnabled;
private final LongAdder filterProcessedMsgs = new LongAdder();
@@ -164,7 +170,8 @@ public int filterEntriesForConsumer(Optional optMetadataArray
entry.release();
continue;
} else if (((PersistentTopic) subscription.getTopic())
- .isTxnAborted(new TxnID(msgMetadata.getTxnidMostBits(), msgMetadata.getTxnidLeastBits()))) {
+ .isTxnAborted(new TxnID(msgMetadata.getTxnidMostBits(), msgMetadata.getTxnidLeastBits()),
+ (PositionImpl) entry.getPosition())) {
individualAcknowledgeMessageIfNeeded(entry.getPosition(), Collections.emptyMap());
entries.set(i, null);
entry.release();
@@ -276,8 +283,12 @@ protected void acquirePermitsForDeliveredMessages(Topic topic, ManagedCursor cur
protected abstract boolean isConsumersExceededOnSubscription();
protected boolean isConsumersExceededOnSubscription(AbstractTopic topic, int consumerSize) {
+ if (topic.isSystemTopic()) {
+ return false;
+ }
Integer maxConsumersPerSubscription = topic.getHierarchyTopicPolicies().getMaxConsumersPerSubscription().get();
- return maxConsumersPerSubscription > 0 && maxConsumersPerSubscription <= consumerSize;
+ return maxConsumersPerSubscription != null && maxConsumersPerSubscription > 0
+ && maxConsumersPerSubscription <= consumerSize;
}
private void processReplicatedSubscriptionSnapshot(PositionImpl pos, ByteBuf headersAndPayload) {
@@ -370,4 +381,8 @@ public long getFilterRejectedMsgCount() {
public long getFilterRescheduledMsgCount() {
return this.filterRescheduledMsgs.longValue();
}
+
+ protected final void updatePendingBytesToDispatch(long size) {
+ PENDING_BYTES_TO_DISPATCH.inc(size);
+ }
}
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractDispatcherMultipleConsumers.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractDispatcherMultipleConsumers.java
index ad9805964b303..90e20790fae2a 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractDispatcherMultipleConsumers.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractDispatcherMultipleConsumers.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -20,8 +20,8 @@
import com.carrotsearch.hppc.ObjectHashSet;
import com.carrotsearch.hppc.ObjectSet;
-import java.util.Random;
import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import org.apache.pulsar.broker.ServiceConfiguration;
import org.apache.pulsar.broker.service.persistent.PersistentStickyKeyDispatcherMultipleConsumers;
@@ -45,8 +45,6 @@ public abstract class AbstractDispatcherMultipleConsumers extends AbstractBaseDi
.newUpdater(AbstractDispatcherMultipleConsumers.class, "isClosed");
private volatile int isClosed = FALSE;
- private Random random = new Random(42);
-
protected AbstractDispatcherMultipleConsumers(Subscription subscription, ServiceConfiguration serviceConfig) {
super(subscription, serviceConfig);
}
@@ -157,7 +155,7 @@ public Consumer getRandomConsumer() {
return null;
}
- return consumerList.get(random.nextInt(consumerList.size()));
+ return consumerList.get(ThreadLocalRandom.current().nextInt(consumerList.size()));
}
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractDispatcherSingleActiveConsumer.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractDispatcherSingleActiveConsumer.java
index 8cab06be116af..6380fb8384b04 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractDispatcherSingleActiveConsumer.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractDispatcherSingleActiveConsumer.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractReplicator.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractReplicator.java
index a3fe39b7438e7..deab89cda72dc 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractReplicator.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractReplicator.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractSubscription.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractSubscription.java
index 6a38667055679..10e6b79609721 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractSubscription.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractSubscription.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractTopic.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractTopic.java
index a995192cead11..c9f95ab524f55 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractTopic.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractTopic.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -438,14 +438,21 @@ private PublishRate publishRateInBroker(ServiceConfiguration config) {
return new PublishRate(config.getMaxPublishRatePerTopicInMessages(), config.getMaxPublishRatePerTopicInBytes());
}
- protected boolean isProducersExceeded() {
+ protected boolean isProducersExceeded(Producer producer) {
+ if (isSystemTopic() || producer.isRemote()) {
+ return false;
+ }
Integer maxProducers = topicPolicies.getMaxProducersPerTopic().get();
- if (maxProducers > 0 && maxProducers <= producers.size()) {
+ if (maxProducers != null && maxProducers > 0 && maxProducers <= getUserCreatedProducersSize()) {
return true;
}
return false;
}
+ private long getUserCreatedProducersSize() {
+ return producers.values().stream().filter(p -> !p.isRemote()).count();
+ }
+
protected void registerTopicPolicyListener() {
if (brokerService.pulsar().getConfig().isSystemTopicEnabled()
&& brokerService.pulsar().getConfig().isTopicLevelPoliciesEnabled()) {
@@ -463,6 +470,9 @@ protected void unregisterTopicPolicyListener() {
}
protected boolean isSameAddressProducersExceeded(Producer producer) {
+ if (isSystemTopic() || producer.isRemote()) {
+ return false;
+ }
final int maxSameAddressProducers = brokerService.pulsar().getConfiguration()
.getMaxSameAddressProducersPerTopic();
@@ -487,14 +497,21 @@ public int getNumberOfSameAddressProducers(final String clientAddress) {
}
protected boolean isConsumersExceededOnTopic() {
- int maxConsumersPerTopic = topicPolicies.getMaxConsumerPerTopic().get();
- if (maxConsumersPerTopic > 0 && maxConsumersPerTopic <= getNumberOfConsumers()) {
+ if (isSystemTopic()) {
+ return false;
+ }
+ Integer maxConsumersPerTopic = topicPolicies.getMaxConsumerPerTopic().get();
+ if (maxConsumersPerTopic != null && maxConsumersPerTopic > 0
+ && maxConsumersPerTopic <= getNumberOfConsumers()) {
return true;
}
return false;
}
protected boolean isSameAddressConsumersExceededOnTopic(Consumer consumer) {
+ if (isSystemTopic()) {
+ return false;
+ }
final int maxSameAddressConsumers = brokerService.pulsar().getConfiguration()
.getMaxSameAddressConsumersPerTopic();
@@ -603,13 +620,15 @@ public String getReplicatorPrefix() {
return replicatorPrefix;
}
+ protected String getSchemaId() {
+ String base = TopicName.get(getName()).getPartitionedTopicName();
+ return TopicName.get(base).getSchemaName();
+ }
@Override
public CompletableFuture hasSchema() {
- String base = TopicName.get(getName()).getPartitionedTopicName();
- String id = TopicName.get(base).getSchemaName();
return brokerService.pulsar()
.getSchemaRegistryService()
- .getSchema(id).thenApply(Objects::nonNull);
+ .getSchema(getSchemaId()).thenApply(Objects::nonNull);
}
@Override
@@ -618,8 +637,7 @@ public CompletableFuture addSchema(SchemaData schema) {
return CompletableFuture.completedFuture(SchemaVersion.Empty);
}
- String base = TopicName.get(getName()).getPartitionedTopicName();
- String id = TopicName.get(base).getSchemaName();
+ String id = getSchemaId();
SchemaRegistryService schemaRegistryService = brokerService.pulsar().getSchemaRegistryService();
if (allowAutoUpdateSchema()) {
@@ -650,8 +668,7 @@ private boolean allowAutoUpdateSchema() {
@Override
public CompletableFuture deleteSchema() {
- String base = TopicName.get(getName()).getPartitionedTopicName();
- String id = TopicName.get(base).getSchemaName();
+ String id = getSchemaId();
SchemaRegistryService schemaRegistryService = brokerService.pulsar().getSchemaRegistryService();
return BookkeeperSchemaStorage.ignoreUnrecoverableBKException(schemaRegistryService.getSchema(id))
.thenCompose(schema -> {
@@ -670,8 +687,7 @@ public CompletableFuture deleteSchema() {
@Override
public CompletableFuture checkSchemaCompatibleForConsumer(SchemaData schema) {
- String base = TopicName.get(getName()).getPartitionedTopicName();
- String id = TopicName.get(base).getSchemaName();
+ String id = getSchemaId();
return brokerService.pulsar()
.getSchemaRegistryService()
.checkConsumerCompatibility(id, schema, getSchemaCompatibilityStrategy());
@@ -937,15 +953,6 @@ protected void enableProducerReadForPublishRateLimiting() {
}
}
- protected void enableProducerReadForPublishBufferLimiting() {
- if (producers != null) {
- producers.values().forEach(producer -> {
- producer.getCnx().cancelPublishBufferLimiting();
- producer.getCnx().enableCnxAutoRead();
- });
- }
- }
-
protected void disableProducerRead() {
if (producers != null) {
producers.values().forEach(producer -> producer.getCnx().disableCnxAutoRead());
@@ -960,7 +967,7 @@ protected void checkTopicFenced() throws BrokerServiceException {
}
protected void internalAddProducer(Producer producer) throws BrokerServiceException {
- if (isProducersExceeded()) {
+ if (isProducersExceeded(producer)) {
log.warn("[{}] Attempting to add producer to topic which reached max producers limit", topic);
throw new BrokerServiceException.ProducerBusyException("Topic reached max producers limit");
}
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AnalyzeBacklogResult.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AnalyzeBacklogResult.java
index d21412153334f..e227acf4e8f62 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AnalyzeBacklogResult.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AnalyzeBacklogResult.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BacklogQuotaManager.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BacklogQuotaManager.java
index 210c6f8767a06..bc2541c802e63 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BacklogQuotaManager.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BacklogQuotaManager.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
index 1def78e0266ef..c5f3d508a56db 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -19,6 +19,7 @@
package org.apache.pulsar.broker.service;
import static com.google.common.base.Preconditions.checkArgument;
+import static org.apache.bookkeeper.mledger.ManagedLedgerConfig.PROPERTY_SOURCE_TOPIC_KEY;
import static org.apache.bookkeeper.mledger.util.SafeRun.safeRun;
import static org.apache.commons.collections4.CollectionUtils.isEmpty;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
@@ -85,6 +86,7 @@
import org.apache.bookkeeper.mledger.ManagedLedgerFactory;
import org.apache.bookkeeper.mledger.impl.NullLedgerOffloader;
import org.apache.bookkeeper.mledger.util.Futures;
+import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.pulsar.bookie.rackawareness.IsolatedBookieEnsemblePlacementPolicy;
import org.apache.pulsar.broker.PulsarServerException;
@@ -127,6 +129,7 @@
import org.apache.pulsar.client.impl.ClientBuilderImpl;
import org.apache.pulsar.client.impl.conf.ClientConfigurationData;
import org.apache.pulsar.client.internal.PropertiesUtils;
+import org.apache.pulsar.client.util.ExecutorProvider;
import org.apache.pulsar.common.allocator.PulsarByteBufAllocator;
import org.apache.pulsar.common.configuration.BindAddress;
import org.apache.pulsar.common.configuration.FieldContext;
@@ -311,13 +314,14 @@ public BrokerService(PulsarService pulsar, EventLoopGroup eventLoopGroup) throws
this.topicOrderedExecutor = OrderedExecutor.newBuilder()
.numThreads(pulsar.getConfiguration().getNumWorkerThreadsForNonPersistentTopic())
.name("broker-topic-workers").build();
- final DefaultThreadFactory acceptorThreadFactory = new DefaultThreadFactory("pulsar-acceptor");
+ final DefaultThreadFactory acceptorThreadFactory =
+ new ExecutorProvider.ExtendedThreadFactory("pulsar-acceptor");
this.acceptorGroup = EventLoopUtil.newEventLoopGroup(
pulsar.getConfiguration().getNumAcceptorThreads(), false, acceptorThreadFactory);
this.workerGroup = eventLoopGroup;
- this.statsUpdater = Executors
- .newSingleThreadScheduledExecutor(new DefaultThreadFactory("pulsar-stats-updater"));
+ this.statsUpdater = Executors.newSingleThreadScheduledExecutor(
+ new ExecutorProvider.ExtendedThreadFactory("pulsar-stats-updater"));
this.authorizationService = new AuthorizationService(
pulsar.getConfiguration(), pulsar().getPulsarResources());
if (!pulsar.getConfiguration().getEntryFilterNames().isEmpty()) {
@@ -327,22 +331,22 @@ public BrokerService(PulsarService pulsar, EventLoopGroup eventLoopGroup) throws
pulsar.getLocalMetadataStore().registerListener(this::handleMetadataChanges);
pulsar.getConfigurationMetadataStore().registerListener(this::handleMetadataChanges);
- this.inactivityMonitor = Executors
- .newSingleThreadScheduledExecutor(new DefaultThreadFactory("pulsar-inactivity-monitor"));
- this.messageExpiryMonitor = Executors
- .newSingleThreadScheduledExecutor(new DefaultThreadFactory("pulsar-msg-expiry-monitor"));
+ this.inactivityMonitor = Executors.newSingleThreadScheduledExecutor(
+ new ExecutorProvider.ExtendedThreadFactory("pulsar-inactivity-monitor"));
+ this.messageExpiryMonitor = Executors.newSingleThreadScheduledExecutor(
+ new ExecutorProvider.ExtendedThreadFactory("pulsar-msg-expiry-monitor"));
this.compactionMonitor =
Executors.newSingleThreadScheduledExecutor(
- new DefaultThreadFactory("pulsar-compaction-monitor"));
- this.consumedLedgersMonitor = Executors
- .newSingleThreadScheduledExecutor(new DefaultThreadFactory("consumed-Ledgers-monitor"));
+ new ExecutorProvider.ExtendedThreadFactory("pulsar-compaction-monitor"));
+ this.consumedLedgersMonitor = Executors.newSingleThreadScheduledExecutor(
+ new ExecutorProvider.ExtendedThreadFactory("consumed-Ledgers-monitor"));
this.topicPublishRateLimiterMonitor =
new PublishRateLimiterMonitor("pulsar-topic-publish-rate-limiter-monitor");
this.brokerPublishRateLimiterMonitor =
new PublishRateLimiterMonitor("pulsar-broker-publish-rate-limiter-monitor");
this.backlogQuotaManager = new BacklogQuotaManager(pulsar);
- this.backlogQuotaChecker = Executors
- .newSingleThreadScheduledExecutor(new DefaultThreadFactory("pulsar-backlog-quota-checker"));
+ this.backlogQuotaChecker = Executors.newSingleThreadScheduledExecutor(
+ new ExecutorProvider.ExtendedThreadFactory("pulsar-backlog-quota-checker"));
this.authenticationService = new AuthenticationService(pulsar.getConfiguration());
this.blockedDispatchers =
ConcurrentOpenHashSet.newBuilder().build();
@@ -429,7 +433,8 @@ private void startProtocolHandler(String protocol,
bootstrap.childOption(ChannelOption.RCVBUF_ALLOCATOR,
new AdaptiveRecvByteBufAllocator(1024, 16 * 1024, 1 * 1024 * 1024));
EventLoopUtil.enableTriggeredMode(bootstrap);
- DefaultThreadFactory defaultThreadFactory = new DefaultThreadFactory("pulsar-ph-" + protocol);
+ DefaultThreadFactory defaultThreadFactory =
+ new ExecutorProvider.ExtendedThreadFactory("pulsar-ph-" + protocol);
EventLoopGroup dedicatedWorkerGroup =
EventLoopUtil.newEventLoopGroup(configuration.getNumIOThreads(), false, defaultThreadFactory);
bootstrap.channel(EventLoopUtil.getServerSocketChannelClass(dedicatedWorkerGroup));
@@ -551,7 +556,7 @@ protected void startDeduplicationSnapshotMonitor() {
int interval = pulsar().getConfiguration().getBrokerDeduplicationSnapshotFrequencyInSeconds();
if (interval > 0 && pulsar().getConfiguration().isBrokerDeduplicationEnabled()) {
this.deduplicationSnapshotMonitor =
- Executors.newSingleThreadScheduledExecutor(new DefaultThreadFactory(
+ Executors.newSingleThreadScheduledExecutor(new ExecutorProvider.ExtendedThreadFactory(
"deduplication-snapshot-monitor"));
deduplicationSnapshotMonitor.scheduleAtFixedRate(safeRun(() -> forEachTopic(
Topic::checkDeduplicationSnapshot))
@@ -685,7 +690,7 @@ synchronized void startOrUpdate(long tickTimeMs, Runnable checkTask, Runnable re
stop();
}
//start monitor.
- scheduler = Executors.newSingleThreadScheduledExecutor(new DefaultThreadFactory(name));
+ scheduler = Executors.newSingleThreadScheduledExecutor(new ExecutorProvider.ExtendedThreadFactory(name));
// schedule task that sums up publish-rate across all cnx on a topic ,
// and check the rate limit exceeded or not.
scheduler.scheduleAtFixedRate(safeRun(checkTask), tickTimeMs, tickTimeMs, TimeUnit.MILLISECONDS);
@@ -966,7 +971,9 @@ public CompletableFuture> getTopicIfExists(final String topic) {
}
public CompletableFuture getOrCreateTopic(final String topic) {
- return getTopic(topic, isAllowAutoTopicCreation(topic)).thenApply(Optional::get);
+ return isAllowAutoTopicCreationAsync(topic)
+ .thenCompose(isAllowed -> getTopic(topic, isAllowed))
+ .thenApply(Optional::get);
}
public CompletableFuture> getTopic(final String topic, boolean createIfMissing) {
@@ -1046,7 +1053,9 @@ public CompletableFuture> getTopic(final TopicName topicName, bo
}
public CompletableFuture deleteTopic(String topic, boolean forceDelete) {
+ TopicName topicName = TopicName.get(topic);
Optional optTopic = getTopicReference(topic);
+
if (optTopic.isPresent()) {
Topic t = optTopic.get();
if (forceDelete) {
@@ -1073,9 +1082,8 @@ public CompletableFuture deleteTopic(String topic, boolean forceDelete) {
return t.delete();
}
- if (log.isDebugEnabled()) {
- log.debug("Topic {} is not loaded, try to delete from metadata", topic);
- }
+ log.info("Topic {} is not loaded, try to delete from metadata", topic);
+
// Topic is not loaded, though we still might be able to delete from metadata
TopicName tn = TopicName.get(topic);
if (!tn.isPersistent()) {
@@ -1084,28 +1092,29 @@ public CompletableFuture deleteTopic(String topic, boolean forceDelete) {
}
CompletableFuture future = new CompletableFuture<>();
-
CompletableFuture deleteTopicAuthenticationFuture = new CompletableFuture<>();
deleteTopicAuthenticationWithRetry(topic, deleteTopicAuthenticationFuture, 5);
+
deleteTopicAuthenticationFuture.whenComplete((v, ex) -> {
if (ex != null) {
future.completeExceptionally(ex);
return;
}
- managedLedgerFactory.asyncDelete(tn.getPersistenceNamingEncoding(), new DeleteLedgerCallback() {
- @Override
- public void deleteLedgerComplete(Object ctx) {
- future.complete(null);
- }
+ CompletableFuture mlConfigFuture = getManagedLedgerConfig(topicName);
+ managedLedgerFactory.asyncDelete(tn.getPersistenceNamingEncoding(),
+ mlConfigFuture, new DeleteLedgerCallback() {
+ @Override
+ public void deleteLedgerComplete(Object ctx) {
+ future.complete(null);
+ }
- @Override
- public void deleteLedgerFailed(ManagedLedgerException exception, Object ctx) {
- future.completeExceptionally(exception);
- }
- }, null);
+ @Override
+ public void deleteLedgerFailed(ManagedLedgerException exception, Object ctx) {
+ future.completeExceptionally(exception);
+ }
+ }, null);
});
-
return future;
}
@@ -1258,9 +1267,18 @@ public PulsarClient getReplicationClient(String cluster, Optional c
: data.getServiceUrlTls();
if (data.isBrokerClientTlsEnabled()) {
configTlsSettings(clientBuilder, serviceUrlTls,
- data.isBrokerClientTlsEnabledWithKeyStore(), data.isTlsAllowInsecureConnection(),
- data.getBrokerClientTlsTrustStoreType(), data.getBrokerClientTlsTrustStore(),
- data.getBrokerClientTlsTrustStorePassword(), data.getBrokerClientTrustCertsFilePath());
+ data.isBrokerClientTlsEnabledWithKeyStore(),
+ data.isTlsAllowInsecureConnection(),
+ data.getBrokerClientTlsTrustStoreType(),
+ data.getBrokerClientTlsTrustStore(),
+ data.getBrokerClientTlsTrustStorePassword(),
+ data.getBrokerClientTlsKeyStoreType(),
+ data.getBrokerClientTlsKeyStore(),
+ data.getBrokerClientTlsKeyStorePassword(),
+ data.getBrokerClientTrustCertsFilePath(),
+ data.getBrokerClientKeyFilePath(),
+ data.getBrokerClientCertificateFilePath()
+ );
} else if (pulsar.getConfiguration().isBrokerClientTlsEnabled()) {
configTlsSettings(clientBuilder, serviceUrlTls,
pulsar.getConfiguration().isBrokerClientTlsEnabledWithKeyStore(),
@@ -1268,7 +1286,13 @@ public PulsarClient getReplicationClient(String cluster, Optional c
pulsar.getConfiguration().getBrokerClientTlsTrustStoreType(),
pulsar.getConfiguration().getBrokerClientTlsTrustStore(),
pulsar.getConfiguration().getBrokerClientTlsTrustStorePassword(),
- pulsar.getConfiguration().getBrokerClientTrustCertsFilePath());
+ pulsar.getConfiguration().getBrokerClientTlsKeyStoreType(),
+ pulsar.getConfiguration().getBrokerClientTlsKeyStore(),
+ pulsar.getConfiguration().getBrokerClientTlsKeyStorePassword(),
+ pulsar.getConfiguration().getBrokerClientTrustCertsFilePath(),
+ pulsar.getConfiguration().getBrokerClientKeyFilePath(),
+ pulsar.getConfiguration().getBrokerClientCertificateFilePath()
+ );
} else {
clientBuilder.serviceUrl(
isNotBlank(data.getBrokerServiceUrl()) ? data.getBrokerServiceUrl() : data.getServiceUrl());
@@ -1294,18 +1318,25 @@ public PulsarClient getReplicationClient(String cluster, Optional c
private void configTlsSettings(ClientBuilder clientBuilder, String serviceUrl,
boolean brokerClientTlsEnabledWithKeyStore, boolean isTlsAllowInsecureConnection,
String brokerClientTlsTrustStoreType, String brokerClientTlsTrustStore,
- String brokerClientTlsTrustStorePassword, String brokerClientTrustCertsFilePath) {
+ String brokerClientTlsTrustStorePassword, String brokerClientTlsKeyStoreType,
+ String brokerClientTlsKeyStore, String brokerClientTlsKeyStorePassword,
+ String brokerClientTrustCertsFilePath,
+ String brokerClientKeyFilePath, String brokerClientCertificateFilePath) {
clientBuilder
.serviceUrl(serviceUrl)
- .enableTls(true)
.allowTlsInsecureConnection(isTlsAllowInsecureConnection);
if (brokerClientTlsEnabledWithKeyStore) {
clientBuilder.useKeyStoreTls(true)
.tlsTrustStoreType(brokerClientTlsTrustStoreType)
.tlsTrustStorePath(brokerClientTlsTrustStore)
- .tlsTrustStorePassword(brokerClientTlsTrustStorePassword);
+ .tlsTrustStorePassword(brokerClientTlsTrustStorePassword)
+ .tlsKeyStoreType(brokerClientTlsKeyStoreType)
+ .tlsKeyStorePath(brokerClientTlsKeyStore)
+ .tlsKeyStorePassword(brokerClientTlsKeyStorePassword);
} else {
- clientBuilder.tlsTrustCertsFilePath(brokerClientTrustCertsFilePath);
+ clientBuilder.tlsTrustCertsFilePath(brokerClientTrustCertsFilePath)
+ .tlsKeyFilePath(brokerClientKeyFilePath)
+ .tlsCertificateFilePath(brokerClientCertificateFilePath);
}
}
@@ -1423,8 +1454,17 @@ protected CompletableFuture