diff --git a/.github/workflows/checkstyle.yml b/.github/workflows/checkstyle.yml deleted file mode 100644 index cf3326a..0000000 --- a/.github/workflows/checkstyle.yml +++ /dev/null @@ -1,37 +0,0 @@ -# -# Licensed 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. -# - -name: checkstyle -on: - pull_request: - branches: - - main - -jobs: - checkstyle: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Maven Central Repository - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - - name: checkstyle - run: mvn -B clean checkstyle:check diff --git a/.github/workflows/commit_lint.yml b/.github/workflows/commit_lint.yml new file mode 100644 index 0000000..0bd90b9 --- /dev/null +++ b/.github/workflows/commit_lint.yml @@ -0,0 +1,12 @@ +name: commit lint +on: + pull_request: + branches: + - main + +jobs: + commitlint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: wagoid/commitlint-github-action@v5 diff --git a/.github/workflows/java_checkstyle.yml b/.github/workflows/java_checkstyle.yml new file mode 100644 index 0000000..7a537f4 --- /dev/null +++ b/.github/workflows/java_checkstyle.yml @@ -0,0 +1,21 @@ +name: java checkstyle +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + java_checkstyle: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Maven Central Repository + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: checkstyle + run: mvn -B clean checkstyle:check diff --git a/.github/workflows/java_spotbugs.yml b/.github/workflows/java_spotbugs.yml new file mode 100644 index 0000000..1f9b25d --- /dev/null +++ b/.github/workflows/java_spotbugs.yml @@ -0,0 +1,21 @@ +name: java spotbugs +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + java_spotbugs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Maven Central Repository + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: spotbugs + run: mvn -B -DskipTests clean verify spotbugs:spotbugs diff --git a/.github/workflows/java_spotless.yml b/.github/workflows/java_spotless.yml new file mode 100644 index 0000000..579e058 --- /dev/null +++ b/.github/workflows/java_spotless.yml @@ -0,0 +1,21 @@ +name: java spotless +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + java_spotless: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Maven Central Repository + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: spotless + run: mvn -B spotless:check diff --git a/.github/workflows/java_unit_tests.yml b/.github/workflows/java_unit_tests.yml new file mode 100644 index 0000000..c29dab5 --- /dev/null +++ b/.github/workflows/java_unit_tests.yml @@ -0,0 +1,21 @@ +name: java unit tests +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + java_unit_tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Maven Central Repository + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: unit tests + run: mvn -B clean test diff --git a/.github/workflows/license_check.yml b/.github/workflows/license_check.yml deleted file mode 100644 index 852ec3c..0000000 --- a/.github/workflows/license_check.yml +++ /dev/null @@ -1,41 +0,0 @@ -# -# Licensed 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. -# - -name: "license check" - -on: - pull_request: - branches: - - main - -jobs: - license-check: - name: License Check - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Check license header - uses: apache/skywalking-eyes@main - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - config: .licenserc.yaml diff --git a/.github/workflows/line_lint.yml b/.github/workflows/line_lint.yml index e2d2f89..b4be8bf 100644 --- a/.github/workflows/line_lint.yml +++ b/.github/workflows/line_lint.yml @@ -1,22 +1,3 @@ -# -# Licensed 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. -# - name: line lint on: pull_request: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d492f90..3892743 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,22 +1,3 @@ -# -# Licensed 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. -# - name: Release on: diff --git a/.github/workflows/spotbugs.yml b/.github/workflows/spotbugs.yml deleted file mode 100644 index 1861075..0000000 --- a/.github/workflows/spotbugs.yml +++ /dev/null @@ -1,37 +0,0 @@ -# -# Licensed 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. -# - -name: spot bugs -on: - pull_request: - branches: - - main - -jobs: - spotbugs: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Maven Central Repository - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - - name: spotbugs - run: mvn -B -DskipTests clean verify spotbugs:spotbugs diff --git a/.github/workflows/typo_check.yml b/.github/workflows/typo_check.yml new file mode 100644 index 0000000..b89a9f9 --- /dev/null +++ b/.github/workflows/typo_check.yml @@ -0,0 +1,13 @@ +name: typo check +on: + pull_request: + branches: + - main +jobs: + typo_check: + name: typo check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Check typos + uses: crate-ci/typos@master diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml deleted file mode 100644 index 76750ed..0000000 --- a/.github/workflows/unit-tests.yml +++ /dev/null @@ -1,44 +0,0 @@ -# -# Licensed 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. -# - -name: unit tests -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - unit-tests: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Maven Central Repository - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - - name: unit tests - run: mvn -B clean test - - uses: codecov/codecov-action@v2 - with: - files: ./java-tool/target/site/jacoco/jacoco.xml,./sdk-codec-bk/target/site/jacoco/jacoco.xml - flags: unittests diff --git a/.licenserc.yaml b/.licenserc.yaml index b6f7e42..7ab5f05 100644 --- a/.licenserc.yaml +++ b/.licenserc.yaml @@ -1,22 +1,3 @@ -# -# Licensed 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. -# - header: license: spdx-id: Apache-2.0 diff --git a/ci/checkstyle/checkstyle.xml b/ci/checkstyle/checkstyle.xml index d347ffc..cdb0773 100644 --- a/ci/checkstyle/checkstyle.xml +++ b/ci/checkstyle/checkstyle.xml @@ -1,24 +1,4 @@ - diff --git a/ci/checkstyle/suppressions.xml b/ci/checkstyle/suppressions.xml index d49aa63..5583c01 100644 --- a/ci/checkstyle/suppressions.xml +++ b/ci/checkstyle/suppressions.xml @@ -1,24 +1,4 @@ - diff --git a/ci/spotbugs/exclude.xml b/ci/spotbugs/exclude.xml index 7ef8216..9d17990 100644 --- a/ci/spotbugs/exclude.xml +++ b/ci/spotbugs/exclude.xml @@ -1,24 +1,4 @@ - - 4.0.0 io.github.protocol-laboratory - pulsar-admin-java + pulsar-admin-parent 0.0.1 + pom + + + pulsar-admin-jdk + 17 @@ -34,23 +19,24 @@ UTF-8 src/main/java - 4.2.0 + 4.2.2 0.0.5 - 2.14.2 - 5.9.2 + 2.17.2 + 5.11.0 2.20.0 3.10.1 3.2.0 3.4.1 - 1.18.26 + 1.18.34 1.6.13 - 10.9.3 + 10.18.0 3.0.0-M6 - 2.0.0 + 2.1.0 3.2.1 4.7.2.0 3.0.0-M9 + 2.43.0 @@ -159,6 +145,25 @@ false + + com.diffplug.spotless + spotless-maven-plugin + ${spotless-maven-plugi.version} + + + + ,java,static others + + + + + + true + 4 + + + + org.apache.maven.plugins maven-release-plugin diff --git a/pulsar-admin-jdk/pom.xml b/pulsar-admin-jdk/pom.xml new file mode 100644 index 0000000..ddf8593 --- /dev/null +++ b/pulsar-admin-jdk/pom.xml @@ -0,0 +1,14 @@ + + + 4.0.0 + + io.github.protocol-laboratory + pulsar-admin-parent + 0.0.1 + + + pulsar-admin-jdk + + diff --git a/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/BacklogQuota.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/BacklogQuota.java new file mode 100644 index 0000000..b14fb10 --- /dev/null +++ b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/BacklogQuota.java @@ -0,0 +1,32 @@ +package io.github.protocol.pulsar; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@Builder +@NoArgsConstructor +@AllArgsConstructor +@ToString +@EqualsAndHashCode +public class BacklogQuota { + + /** + * backlog quota by size in byte. + */ + private Long limitSize; + + /** + * backlog quota by time in second. + */ + private Integer limitTime; + + private RetentionPolicy policy; + +} diff --git a/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/BacklogQuotaType.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/BacklogQuotaType.java new file mode 100644 index 0000000..a4ce84b --- /dev/null +++ b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/BacklogQuotaType.java @@ -0,0 +1,9 @@ +package io.github.protocol.pulsar; + +public enum BacklogQuotaType { + + destination_storage, + + message_age, + +} diff --git a/src/main/java/io/github/protocol/pulsar/Brokers.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/Brokers.java similarity index 100% rename from src/main/java/io/github/protocol/pulsar/Brokers.java rename to pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/Brokers.java diff --git a/src/main/java/io/github/protocol/pulsar/BrokersImpl.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/BrokersImpl.java similarity index 100% rename from src/main/java/io/github/protocol/pulsar/BrokersImpl.java rename to pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/BrokersImpl.java diff --git a/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/Clusters.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/Clusters.java new file mode 100644 index 0000000..21ecfcf --- /dev/null +++ b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/Clusters.java @@ -0,0 +1,9 @@ +package io.github.protocol.pulsar; + +import java.util.List; + +public interface Clusters { + + List getClusters() throws PulsarAdminException; + +} diff --git a/src/main/java/io/github/protocol/pulsar/ClustersImpl.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/ClustersImpl.java similarity index 57% rename from src/main/java/io/github/protocol/pulsar/ClustersImpl.java rename to pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/ClustersImpl.java index 312bab2..f884659 100644 --- a/src/main/java/io/github/protocol/pulsar/ClustersImpl.java +++ b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/ClustersImpl.java @@ -1,22 +1,3 @@ -/* - * Licensed 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 io.github.protocol.pulsar; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/src/main/java/io/github/protocol/pulsar/Configuration.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/Configuration.java similarity index 100% rename from src/main/java/io/github/protocol/pulsar/Configuration.java rename to pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/Configuration.java diff --git a/src/main/java/io/github/protocol/pulsar/InnerHttpClient.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/InnerHttpClient.java similarity index 100% rename from src/main/java/io/github/protocol/pulsar/InnerHttpClient.java rename to pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/InnerHttpClient.java diff --git a/src/main/java/io/github/protocol/pulsar/InsecureTrustManager.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/InsecureTrustManager.java similarity index 100% rename from src/main/java/io/github/protocol/pulsar/InsecureTrustManager.java rename to pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/InsecureTrustManager.java index c594fcc..45a9d68 100644 --- a/src/main/java/io/github/protocol/pulsar/InsecureTrustManager.java +++ b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/InsecureTrustManager.java @@ -18,9 +18,9 @@ */ package io.github.protocol.pulsar; -import javax.net.ssl.X509TrustManager; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; +import javax.net.ssl.X509TrustManager; public class InsecureTrustManager implements X509TrustManager { diff --git a/src/main/java/io/github/protocol/pulsar/JacksonService.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/JacksonService.java similarity index 100% rename from src/main/java/io/github/protocol/pulsar/JacksonService.java rename to pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/JacksonService.java diff --git a/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/MessageIdImpl.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/MessageIdImpl.java new file mode 100644 index 0000000..9193b30 --- /dev/null +++ b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/MessageIdImpl.java @@ -0,0 +1,32 @@ +package io.github.protocol.pulsar; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Builder +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode +public class MessageIdImpl { + + private Long ledgerId; + + private Integer entryId; + + private Integer partitionIndex; + + private Integer batchIndex; + + @Override + public String toString() { + if (batchIndex != null) { + return String.valueOf(ledgerId) + ':' + entryId + ':' + partitionIndex + ':' + batchIndex; + } + return String.valueOf(ledgerId) + ':' + entryId + ':' + partitionIndex; + } + +} diff --git a/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/Mode.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/Mode.java new file mode 100644 index 0000000..c492054 --- /dev/null +++ b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/Mode.java @@ -0,0 +1,7 @@ +package io.github.protocol.pulsar; + +public enum Mode { + PERSISTENT, + NON_PERSISTENT, + ALL, +} diff --git a/src/main/java/io/github/protocol/pulsar/Namespaces.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/Namespaces.java similarity index 73% rename from src/main/java/io/github/protocol/pulsar/Namespaces.java rename to pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/Namespaces.java index d8403a8..d97d772 100644 --- a/src/main/java/io/github/protocol/pulsar/Namespaces.java +++ b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/Namespaces.java @@ -1,22 +1,3 @@ -/* - * Licensed 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 io.github.protocol.pulsar; import java.util.List; diff --git a/src/main/java/io/github/protocol/pulsar/NamespacesImpl.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/NamespacesImpl.java similarity index 95% rename from src/main/java/io/github/protocol/pulsar/NamespacesImpl.java rename to pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/NamespacesImpl.java index 54019ff..c29965c 100644 --- a/src/main/java/io/github/protocol/pulsar/NamespacesImpl.java +++ b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/NamespacesImpl.java @@ -1,22 +1,3 @@ -/* - * Licensed 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 io.github.protocol.pulsar; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/NonPersistentTopicsImpl.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/NonPersistentTopicsImpl.java new file mode 100644 index 0000000..7d13d7a --- /dev/null +++ b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/NonPersistentTopicsImpl.java @@ -0,0 +1,22 @@ +package io.github.protocol.pulsar; + +public class NonPersistentTopicsImpl extends PersistentTopicsImpl { + + private static final String BASE_URL_NON_PERSISTENT_DOMAIN = "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/admin/v2" + "/non-persistent"; + + public NonPersistentTopicsImpl(InnerHttpClient httpClient) { + super(httpClient); + } + + @Override + public String getDomainBaseUrl() { + return BASE_URL_NON_PERSISTENT_DOMAIN; + } + + @Override + public MessageIdImpl getLastMessageId(String tenant, String namespace, String encodedTopic, boolean authoritative) + throws PulsarAdminException { + throw new PulsarAdminException(new UnsupportedOperationException( + "get last message id on non-persistent topic is not allowed")); + } +} diff --git a/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/PAdmin.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/PAdmin.java new file mode 100644 index 0000000..8accb40 --- /dev/null +++ b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/PAdmin.java @@ -0,0 +1,9 @@ +package io.github.protocol.pulsar; + +public class PAdmin { + public static void main(String[] args) { + PulsarAdmin pulsarAdmin = PulsarAdmin.builder().port(8080).build(); + Tenants tenants = pulsarAdmin.tenants(); + System.out.println(tenants); + } +} diff --git a/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/PartitionedTopicMetadata.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/PartitionedTopicMetadata.java new file mode 100644 index 0000000..b4ddfbc --- /dev/null +++ b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/PartitionedTopicMetadata.java @@ -0,0 +1,28 @@ +package io.github.protocol.pulsar; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +import java.util.Map; + +@Getter +@Setter +@Builder +@NoArgsConstructor +@AllArgsConstructor +@ToString +@EqualsAndHashCode +public class PartitionedTopicMetadata { + + public int partitions; + + public boolean deleted; + + public Map properties; + +} diff --git a/src/main/java/io/github/protocol/pulsar/PersistentOfflineTopicStats.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/PersistentOfflineTopicStats.java similarity index 61% rename from src/main/java/io/github/protocol/pulsar/PersistentOfflineTopicStats.java rename to pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/PersistentOfflineTopicStats.java index 7b56c8e..386d7b8 100644 --- a/src/main/java/io/github/protocol/pulsar/PersistentOfflineTopicStats.java +++ b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/PersistentOfflineTopicStats.java @@ -1,22 +1,3 @@ -/* - * Licensed 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 io.github.protocol.pulsar; import lombok.AllArgsConstructor; diff --git a/src/main/java/io/github/protocol/pulsar/PersistentTopicsImpl.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/PersistentTopicsImpl.java similarity index 85% rename from src/main/java/io/github/protocol/pulsar/PersistentTopicsImpl.java rename to pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/PersistentTopicsImpl.java index dbc2aaa..d2c146f 100644 --- a/src/main/java/io/github/protocol/pulsar/PersistentTopicsImpl.java +++ b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/PersistentTopicsImpl.java @@ -1,22 +1,3 @@ -/* - * Licensed 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 io.github.protocol.pulsar; import com.fasterxml.jackson.core.type.TypeReference; @@ -30,21 +11,21 @@ public class PersistentTopicsImpl implements Topics { protected final InnerHttpClient httpClient; - private static final String BASE_URL_PERSISTENT_DOMAIN = UrlConst.BASE_URL_V2 + "/persistent"; + private static final String BASE_URL_PERSISTENT_DOMAIN = "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/admin/v2" + "/persistent"; public PersistentTopicsImpl(InnerHttpClient httpClient) { this.httpClient = httpClient; } public String getDomainBaseUrl() { - return BASE_URL_PERSISTENT_DOMAIN; + return "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/admin/v2" + "/persistent"; } @Override public void createPartitionedTopic(String tenant, String namespace, String encodedTopic, int numPartitions, boolean createLocalTopicOnly) throws PulsarAdminException { - String url = String.format("%s/%s/%s/%s%s", getDomainBaseUrl(), tenant, namespace, encodedTopic, - UrlConst.PARTITIONS); + String url = String.format("%s/%s/%s/%s%s", "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/admin/v2" + "/persistent", tenant, namespace, encodedTopic, + "/partitions"); try { HttpResponse response = httpClient.put(url, numPartitions, "createLocalTopicOnly", String.valueOf(createLocalTopicOnly)); @@ -61,8 +42,8 @@ public void createPartitionedTopic(String tenant, String namespace, String encod @Override public void deletePartitionedTopic(String tenant, String namespace, String encodedTopic, boolean force, boolean authoritative) throws PulsarAdminException { - String url = String.format("%s/%s/%s/%s%s", getDomainBaseUrl(), tenant, namespace, encodedTopic, - UrlConst.PARTITIONS); + String url = String.format("%s/%s/%s/%s%s", "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/admin/v2" + "/persistent", tenant, namespace, encodedTopic, + "/partitions"); try { HttpResponse response = httpClient.delete(url, "force", String.valueOf(force), "authoritative", String.valueOf(authoritative)); @@ -80,8 +61,8 @@ public void deletePartitionedTopic(String tenant, String namespace, String encod public void updatePartitionedTopic(String tenant, String namespace, String encodedTopic, boolean updateLocalTopicOnly, boolean authoritative, boolean force, int numPartitions) throws PulsarAdminException { - String url = String.format("%s/%s/%s/%s%s", getDomainBaseUrl(), tenant, namespace, encodedTopic, - UrlConst.PARTITIONS); + String url = String.format("%s/%s/%s/%s%s", "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/admin/v2" + "/persistent", tenant, namespace, encodedTopic, + "/partitions"); try { HttpResponse response = httpClient.post(url, numPartitions, "updateLocalTopicOnly", String.valueOf(updateLocalTopicOnly), @@ -101,8 +82,8 @@ public void updatePartitionedTopic(String tenant, String namespace, String encod public PartitionedTopicMetadata getPartitionedMetadata(String tenant, String namespace, String encodedTopic, boolean checkAllowAutoCreation, boolean authoritative) throws PulsarAdminException { - String url = String.format("%s/%s/%s/%s%s", getDomainBaseUrl(), - tenant, namespace, encodedTopic, UrlConst.PARTITIONS); + String url = String.format("%s/%s/%s/%s%s", "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/admin/v2" + "/persistent", + tenant, namespace, encodedTopic, "/partitions"); try { HttpResponse response = httpClient.get(url, "checkAllowAutoCreation", String.valueOf(checkAllowAutoCreation), @@ -121,7 +102,7 @@ public PartitionedTopicMetadata getPartitionedMetadata(String tenant, String nam @Override public void createNonPartitionedTopic(String tenant, String namespace, String encodedTopic, boolean authoritative, Map properties) throws PulsarAdminException { - String url = String.format("%s/%s/%s/%s", getDomainBaseUrl(), tenant, namespace, encodedTopic); + String url = String.format("%s/%s/%s/%s", "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/admin/v2" + "/persistent", tenant, namespace, encodedTopic); try { HttpResponse response = httpClient.put(url, properties, "authoritative", String.valueOf(authoritative)); @@ -138,7 +119,7 @@ public void createNonPartitionedTopic(String tenant, String namespace, String en @Override public void deleteTopic(String tenant, String namespace, String encodedTopic, boolean force, boolean authoritative) throws PulsarAdminException { - String url = String.format("%s/%s/%s/%s", getDomainBaseUrl(), tenant, namespace, encodedTopic); + String url = String.format("%s/%s/%s/%s", "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/admin/v2" + "/persistent", tenant, namespace, encodedTopic); try { HttpResponse response = httpClient.delete(url, "force", String.valueOf(force), @@ -156,7 +137,7 @@ public void deleteTopic(String tenant, String namespace, String encodedTopic, bo @Override public List getList(String tenant, String namespace, String bundle, boolean includeSystemTopic) throws PulsarAdminException { - String url = String.format("%s/%s/%s", getDomainBaseUrl(), tenant, namespace); + String url = String.format("%s/%s/%s", "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/admin/v2" + "/persistent", tenant, namespace); try { HttpResponse response; if (bundle != null) { @@ -183,7 +164,7 @@ public List getList(String tenant, String namespace, String bundle, bool @Override public List getPartitionedTopicList(String tenant, String namespace, boolean includeSystemTopic) throws PulsarAdminException { - String url = String.format("%s/%s/%s%s", getDomainBaseUrl(), tenant, namespace, UrlConst.PARTITIONED); + String url = String.format("%s/%s/%s%s", "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/admin/v2" + "/persistent", tenant, namespace, UrlConst.PARTITIONED); try { HttpResponse response = httpClient.get(url, "includeSystemTopic", String.valueOf(includeSystemTopic)); @@ -203,7 +184,7 @@ public List getPartitionedTopicList(String tenant, String namespace, boo @Override public void createMissedPartitions(String tenant, String namespace, String encodedTopic) throws PulsarAdminException { - String url = String.format("%s/%s/%s/%s%s", getDomainBaseUrl(), tenant, namespace, encodedTopic, + String url = String.format("%s/%s/%s/%s%s", "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/admin/v2" + "/persistent", tenant, namespace, encodedTopic, UrlConst.CREATE_MISSED_PARTITIONS); try { HttpResponse response = httpClient.post(url); @@ -221,7 +202,7 @@ public void createMissedPartitions(String tenant, String namespace, String encod @Override public MessageIdImpl getLastMessageId(String tenant, String namespace, String encodedTopic, boolean authoritative) throws PulsarAdminException { - String url = String.format("%s/%s/%s/%s%s", getDomainBaseUrl(), tenant, namespace, encodedTopic, + String url = String.format("%s/%s/%s/%s%s", "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/admin/v2" + "/persistent", tenant, namespace, encodedTopic, UrlConst.LAST_MESSAGE_ID); try { HttpResponse response = httpClient.get(url, "authoritative", String.valueOf(authoritative)); @@ -239,7 +220,7 @@ public MessageIdImpl getLastMessageId(String tenant, String namespace, String en @Override public RetentionPolicies getRetention(String tenant, String namespace, String encodedTopic, boolean isGlobal, boolean applied, boolean authoritative) throws PulsarAdminException { - String url = String.format("%s/%s/%s/%s%s", getDomainBaseUrl(), tenant, namespace, encodedTopic, + String url = String.format("%s/%s/%s/%s%s", "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/admin/v2" + "/persistent", tenant, namespace, encodedTopic, UrlConst.RETENTION); try { HttpResponse response = httpClient.get(url, @@ -260,7 +241,7 @@ public RetentionPolicies getRetention(String tenant, String namespace, String en @Override public void setRetention(String tenant, String namespace, String encodedTopic, boolean authoritative, boolean isGlobal, RetentionPolicies retention) throws PulsarAdminException { - String url = String.format("%s/%s/%s/%s%s", getDomainBaseUrl(), tenant, namespace, encodedTopic, + String url = String.format("%s/%s/%s/%s%s", "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/admin/v2" + "/persistent", tenant, namespace, encodedTopic, UrlConst.RETENTION); try { HttpResponse response = httpClient.post(url, retention, @@ -279,7 +260,7 @@ public void setRetention(String tenant, String namespace, String encodedTopic, b @Override public void removeRetention(String tenant, String namespace, String encodedTopic, boolean authoritative) throws PulsarAdminException { - String url = String.format("%s/%s/%s/%s%s", getDomainBaseUrl(), tenant, namespace, encodedTopic, + String url = String.format("%s/%s/%s/%s%s", "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/admin/v2" + "/persistent", tenant, namespace, encodedTopic, UrlConst.RETENTION); try { HttpResponse response = httpClient.delete(url, "authoritative", String.valueOf(authoritative)); @@ -298,7 +279,7 @@ public Map getBacklogQuotaMap(String tenant, Str String encodedTopic, boolean applied, boolean authoritative, boolean isGlobal) throws PulsarAdminException { - String url = String.format("%s/%s/%s/%s%s", getDomainBaseUrl(), tenant, namespace, encodedTopic, + String url = String.format("%s/%s/%s/%s%s", "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/admin/v2" + "/persistent", tenant, namespace, encodedTopic, UrlConst.BACKLOG_QUOTA_MAP); try { HttpResponse response = httpClient.get(url, @@ -321,7 +302,7 @@ public Map getBacklogQuotaMap(String tenant, Str public void setBacklogQuota(String tenant, String namespace, String encodedTopic, boolean authoritative, boolean isGlobal, BacklogQuotaType backlogQuotaType, BacklogQuota backlogQuota) throws PulsarAdminException { - String url = String.format("%s/%s/%s/%s%s", getDomainBaseUrl(), tenant, namespace, encodedTopic, + String url = String.format("%s/%s/%s/%s%s", "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/admin/v2" + "/persistent", tenant, namespace, encodedTopic, UrlConst.BACKLOG_QUOTA); try { HttpResponse response = httpClient.post(url, backlogQuota, @@ -342,7 +323,7 @@ public void setBacklogQuota(String tenant, String namespace, String encodedTopic public void removeBacklogQuota(String tenant, String namespace, String encodedTopic, BacklogQuotaType backlogQuotaType, boolean authoritative, boolean isGlobal) throws PulsarAdminException { - String url = String.format("%s/%s/%s/%s%s", getDomainBaseUrl(), tenant, namespace, encodedTopic, + String url = String.format("%s/%s/%s/%s%s", "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/admin/v2" + "/persistent", tenant, namespace, encodedTopic, UrlConst.BACKLOG_QUOTA); try { HttpResponse response = httpClient.delete(url, @@ -362,7 +343,7 @@ public void removeBacklogQuota(String tenant, String namespace, String encodedTo @Override public PersistentOfflineTopicStats getBacklog(String tenant, String namespace, String encodedTopic, boolean authoritative) throws PulsarAdminException { - String url = String.format("%s/%s/%s/%s%s", getDomainBaseUrl(), tenant, namespace, encodedTopic, + String url = String.format("%s/%s/%s/%s%s", "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/admin/v2" + "/persistent", tenant, namespace, encodedTopic, UrlConst.BACKLOG); try { HttpResponse response = httpClient.get(url, "authoritative", String.valueOf(authoritative)); @@ -380,7 +361,7 @@ public PersistentOfflineTopicStats getBacklog(String tenant, String namespace, S @Override public long getBacklogSizeByMessageId(String tenant, String namespace, String encodedTopic, boolean authoritative, MessageIdImpl messageId) throws PulsarAdminException { - String url = String.format("%s/%s/%s/%s%s", getDomainBaseUrl(), tenant, namespace, encodedTopic, + String url = String.format("%s/%s/%s/%s%s", "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/admin/v2" + "/persistent", tenant, namespace, encodedTopic, UrlConst.BACKLOG_SIZE); try { HttpResponse response = httpClient.put(url, messageId, "authoritative", diff --git a/src/main/java/io/github/protocol/pulsar/PulsarAdmin.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/PulsarAdmin.java similarity index 100% rename from src/main/java/io/github/protocol/pulsar/PulsarAdmin.java rename to pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/PulsarAdmin.java diff --git a/src/main/java/io/github/protocol/pulsar/PulsarAdminBuilder.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/PulsarAdminBuilder.java similarity index 100% rename from src/main/java/io/github/protocol/pulsar/PulsarAdminBuilder.java rename to pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/PulsarAdminBuilder.java diff --git a/src/main/java/io/github/protocol/pulsar/PulsarAdminBuilderImpl.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/PulsarAdminBuilderImpl.java similarity index 100% rename from src/main/java/io/github/protocol/pulsar/PulsarAdminBuilderImpl.java rename to pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/PulsarAdminBuilderImpl.java diff --git a/src/main/java/io/github/protocol/pulsar/PulsarAdminException.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/PulsarAdminException.java similarity index 100% rename from src/main/java/io/github/protocol/pulsar/PulsarAdminException.java rename to pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/PulsarAdminException.java diff --git a/src/main/java/io/github/protocol/pulsar/PulsarAdminImpl.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/PulsarAdminImpl.java similarity index 100% rename from src/main/java/io/github/protocol/pulsar/PulsarAdminImpl.java rename to pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/PulsarAdminImpl.java diff --git a/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/RetentionPolicies.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/RetentionPolicies.java new file mode 100644 index 0000000..86ecdcb --- /dev/null +++ b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/RetentionPolicies.java @@ -0,0 +1,24 @@ +package io.github.protocol.pulsar; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@Builder +@NoArgsConstructor +@AllArgsConstructor +@ToString +@EqualsAndHashCode +public class RetentionPolicies { + + private Integer retentionTimeInMinutes; + + private Integer retentionSizeInMB; + +} diff --git a/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/RetentionPolicy.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/RetentionPolicy.java new file mode 100644 index 0000000..f5d1cd4 --- /dev/null +++ b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/RetentionPolicy.java @@ -0,0 +1,20 @@ +package io.github.protocol.pulsar; + +public enum RetentionPolicy { + + /** + * Policy which holds producer's send request until the resource becomes available (or holding times out). + */ + producer_request_hold, + + /** + * Policy which throws javax.jms.ResourceAllocationException to the producer. + */ + producer_exception, + + /** + * Policy which evicts the oldest message from the slowest consumer's backlog. + */ + consumer_backlog_eviction, + +} diff --git a/src/main/java/io/github/protocol/pulsar/SslContextUtil.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/SslContextUtil.java similarity index 98% rename from src/main/java/io/github/protocol/pulsar/SslContextUtil.java rename to pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/SslContextUtil.java index c5b4d87..0e8fa7b 100644 --- a/src/main/java/io/github/protocol/pulsar/SslContextUtil.java +++ b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/SslContextUtil.java @@ -18,14 +18,14 @@ */ package io.github.protocol.pulsar; +import java.io.FileInputStream; +import java.security.KeyStore; +import java.security.SecureRandom; import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLParameters; import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; -import java.io.FileInputStream; -import java.security.KeyStore; -import java.security.SecureRandom; public class SslContextUtil { public static SSLContext buildFromJks(String keyStorePath, @@ -84,6 +84,7 @@ public static SSLContext buildFromJks(String keyStorePath, } if (disableSslVerify) { + // FIXME: This can't really disable ssl verification sslContext.getDefaultSSLParameters().setEndpointIdentificationAlgorithm(null); } diff --git a/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/TenantInfo.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/TenantInfo.java new file mode 100644 index 0000000..3ae65bb --- /dev/null +++ b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/TenantInfo.java @@ -0,0 +1,25 @@ +package io.github.protocol.pulsar; + + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.util.Set; + +@Getter +@Setter +@Builder +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode +public class TenantInfo { + + private Set adminRoles; + + private Set allowedClusters; + +} diff --git a/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/Tenants.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/Tenants.java new file mode 100644 index 0000000..68b79ba --- /dev/null +++ b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/Tenants.java @@ -0,0 +1,17 @@ +package io.github.protocol.pulsar; + +import java.util.List; + +public interface Tenants { + + void createTenant(String tenant, TenantInfo tenantInfo) throws PulsarAdminException; + + void deleteTenant(String tenant, boolean force) throws PulsarAdminException; + + void updateTenant(String tenant, TenantInfo tenantInfo) throws PulsarAdminException; + + TenantInfo getTenantAdmin(String tenant) throws PulsarAdminException; + + List getTenants() throws PulsarAdminException; + +} diff --git a/src/main/java/io/github/protocol/pulsar/TenantsImpl.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/TenantsImpl.java similarity index 81% rename from src/main/java/io/github/protocol/pulsar/TenantsImpl.java rename to pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/TenantsImpl.java index e7000f2..8c90317 100644 --- a/src/main/java/io/github/protocol/pulsar/TenantsImpl.java +++ b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/TenantsImpl.java @@ -1,22 +1,3 @@ -/* - * Licensed 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 io.github.protocol.pulsar; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/src/main/java/io/github/protocol/pulsar/TopicVersion.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/TopicVersion.java similarity index 100% rename from src/main/java/io/github/protocol/pulsar/TopicVersion.java rename to pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/TopicVersion.java diff --git a/src/main/java/io/github/protocol/pulsar/Topics.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/Topics.java similarity index 81% rename from src/main/java/io/github/protocol/pulsar/Topics.java rename to pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/Topics.java index aa5c67f..d80b5c5 100644 --- a/src/main/java/io/github/protocol/pulsar/Topics.java +++ b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/Topics.java @@ -1,22 +1,3 @@ -/* - * Licensed 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 io.github.protocol.pulsar; import java.util.List; diff --git a/src/main/java/io/github/protocol/pulsar/UrlConst.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/UrlConst.java similarity index 87% rename from src/main/java/io/github/protocol/pulsar/UrlConst.java rename to pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/UrlConst.java index df927ed..e2dd67a 100644 --- a/src/main/java/io/github/protocol/pulsar/UrlConst.java +++ b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/UrlConst.java @@ -22,13 +22,13 @@ public class UrlConst { public static final String BASE_URL_V2 = "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/admin/v2"; - public static final String CLUSTERS = BASE_URL_V2 + "/clusters"; + public static final String CLUSTERS = "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/admin/v2" + "/clusters"; - public static final String BROKERS = BASE_URL_V2 + "/brokers"; + public static final String BROKERS = "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/admin/v2" + "/brokers"; - public static final String TENANTS = BASE_URL_V2 + "/tenants"; + public static final String TENANTS = "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/admin/v2" + "/tenants"; - public static final String NAMESPACES = BASE_URL_V2 + "/namespaces"; + public static final String NAMESPACES = "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/admin/v2" + "/namespaces"; public static final String BACKLOG_QUOTA_MAP = "/backlogQuotaMap"; diff --git a/src/main/java/io/github/protocol/pulsar/package-info.java b/pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/package-info.java similarity index 100% rename from src/main/java/io/github/protocol/pulsar/package-info.java rename to pulsar-admin-jdk/src/main/java/io/github/protocol/pulsar/package-info.java diff --git a/src/test/java/io/github/protocol/pulsar/BrokersTest.java b/pulsar-admin-jdk/src/test/java/io/github/protocol/pulsar/BrokersTest.java similarity index 100% rename from src/test/java/io/github/protocol/pulsar/BrokersTest.java rename to pulsar-admin-jdk/src/test/java/io/github/protocol/pulsar/BrokersTest.java diff --git a/src/test/java/io/github/protocol/pulsar/ClustersTest.java b/pulsar-admin-jdk/src/test/java/io/github/protocol/pulsar/ClustersTest.java similarity index 50% rename from src/test/java/io/github/protocol/pulsar/ClustersTest.java rename to pulsar-admin-jdk/src/test/java/io/github/protocol/pulsar/ClustersTest.java index b3d32c2..2bbae28 100644 --- a/src/test/java/io/github/protocol/pulsar/ClustersTest.java +++ b/pulsar-admin-jdk/src/test/java/io/github/protocol/pulsar/ClustersTest.java @@ -1,22 +1,3 @@ -/* - * Licensed 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 io.github.protocol.pulsar; import io.github.embedded.pulsar.core.EmbeddedPulsarServer; diff --git a/src/test/java/io/github/protocol/pulsar/InnerHttpClientTest.java b/pulsar-admin-jdk/src/test/java/io/github/protocol/pulsar/InnerHttpClientTest.java similarity index 100% rename from src/test/java/io/github/protocol/pulsar/InnerHttpClientTest.java rename to pulsar-admin-jdk/src/test/java/io/github/protocol/pulsar/InnerHttpClientTest.java diff --git a/src/test/java/io/github/protocol/pulsar/NamespacesTest.java b/pulsar-admin-jdk/src/test/java/io/github/protocol/pulsar/NamespacesTest.java similarity index 90% rename from src/test/java/io/github/protocol/pulsar/NamespacesTest.java rename to pulsar-admin-jdk/src/test/java/io/github/protocol/pulsar/NamespacesTest.java index d225db6..d5b6fe6 100644 --- a/src/test/java/io/github/protocol/pulsar/NamespacesTest.java +++ b/pulsar-admin-jdk/src/test/java/io/github/protocol/pulsar/NamespacesTest.java @@ -1,22 +1,3 @@ -/* - * Licensed 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 io.github.protocol.pulsar; import io.github.embedded.pulsar.core.EmbeddedPulsarServer; diff --git a/src/test/java/io/github/protocol/pulsar/NonPersistentTopicsTest.java b/pulsar-admin-jdk/src/test/java/io/github/protocol/pulsar/NonPersistentTopicsTest.java similarity index 83% rename from src/test/java/io/github/protocol/pulsar/NonPersistentTopicsTest.java rename to pulsar-admin-jdk/src/test/java/io/github/protocol/pulsar/NonPersistentTopicsTest.java index 02c7b07..1a9cba1 100644 --- a/src/test/java/io/github/protocol/pulsar/NonPersistentTopicsTest.java +++ b/pulsar-admin-jdk/src/test/java/io/github/protocol/pulsar/NonPersistentTopicsTest.java @@ -1,22 +1,3 @@ -/* - * Licensed 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 io.github.protocol.pulsar; import io.github.embedded.pulsar.core.EmbeddedPulsarServer; diff --git a/src/test/java/io/github/protocol/pulsar/PersistentTopicsTest.java b/pulsar-admin-jdk/src/test/java/io/github/protocol/pulsar/PersistentTopicsTest.java similarity index 93% rename from src/test/java/io/github/protocol/pulsar/PersistentTopicsTest.java rename to pulsar-admin-jdk/src/test/java/io/github/protocol/pulsar/PersistentTopicsTest.java index 0cee9fe..4785bd8 100644 --- a/src/test/java/io/github/protocol/pulsar/PersistentTopicsTest.java +++ b/pulsar-admin-jdk/src/test/java/io/github/protocol/pulsar/PersistentTopicsTest.java @@ -1,22 +1,3 @@ -/* - * Licensed 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 io.github.protocol.pulsar; import io.github.embedded.pulsar.core.EmbeddedPulsarServer; diff --git a/pulsar-admin-jdk/src/test/java/io/github/protocol/pulsar/RandomUtil.java b/pulsar-admin-jdk/src/test/java/io/github/protocol/pulsar/RandomUtil.java new file mode 100644 index 0000000..9580b94 --- /dev/null +++ b/pulsar-admin-jdk/src/test/java/io/github/protocol/pulsar/RandomUtil.java @@ -0,0 +1,34 @@ +package io.github.protocol.pulsar; + +import java.util.Random; +import java.util.UUID; + +public class RandomUtil { + + public static Random random = new Random(); + + public static String randomString() { + return UUID.randomUUID().toString(); + } + + public static int randomInt() { + return random.nextInt(); + } + + public static long randomLong() { + return random.nextLong(); + } + + public static long randomPositiveLong(){ + return random.nextLong(0, Long.MAX_VALUE); + } + + public static int randomPositiveInt(){ + return random.nextInt(0, Integer.MAX_VALUE); + } + + public static int randomNegativeInt(){ + return random.nextInt(Integer.MIN_VALUE, -1); + } + +} diff --git a/src/test/java/io/github/protocol/pulsar/TenantsTest.java b/pulsar-admin-jdk/src/test/java/io/github/protocol/pulsar/TenantsTest.java similarity index 70% rename from src/test/java/io/github/protocol/pulsar/TenantsTest.java rename to pulsar-admin-jdk/src/test/java/io/github/protocol/pulsar/TenantsTest.java index 61250b0..17fbeaf 100644 --- a/src/test/java/io/github/protocol/pulsar/TenantsTest.java +++ b/pulsar-admin-jdk/src/test/java/io/github/protocol/pulsar/TenantsTest.java @@ -1,22 +1,3 @@ -/* - * Licensed 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 io.github.protocol.pulsar; import io.github.embedded.pulsar.core.EmbeddedPulsarServer; diff --git a/src/test/java/io/github/protocol/pulsar/TlsClientTest.java b/pulsar-admin-jdk/src/test/java/io/github/protocol/pulsar/TlsClientTest.java similarity index 86% rename from src/test/java/io/github/protocol/pulsar/TlsClientTest.java rename to pulsar-admin-jdk/src/test/java/io/github/protocol/pulsar/TlsClientTest.java index 4448855..38e2cbf 100644 --- a/src/test/java/io/github/protocol/pulsar/TlsClientTest.java +++ b/pulsar-admin-jdk/src/test/java/io/github/protocol/pulsar/TlsClientTest.java @@ -1,22 +1,3 @@ -/* - * Licensed 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 io.github.protocol.pulsar; import io.github.embedded.pulsar.core.EmbeddedPulsarConfig; diff --git a/src/test/java/io/github/protocol/pulsar/TlsClientWrongHostTest.java b/pulsar-admin-jdk/src/test/java/io/github/protocol/pulsar/TlsClientWrongHostTest.java similarity index 100% rename from src/test/java/io/github/protocol/pulsar/TlsClientWrongHostTest.java rename to pulsar-admin-jdk/src/test/java/io/github/protocol/pulsar/TlsClientWrongHostTest.java diff --git a/src/test/resources/gen_jks.sh b/pulsar-admin-jdk/src/test/resources/gen_jks.sh similarity index 59% rename from src/test/resources/gen_jks.sh rename to pulsar-admin-jdk/src/test/resources/gen_jks.sh index 4da68f4..e79198b 100644 --- a/src/test/resources/gen_jks.sh +++ b/pulsar-admin-jdk/src/test/resources/gen_jks.sh @@ -1,23 +1,4 @@ #!/bin/bash -# -# Licensed 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. -# - client_pass=pulsar_client_pwd server_pass=pulsar_server_pwd server_dname="C=CN,ST=GD,L=SZ,O=sh,OU=sh,CN=localhost" diff --git a/src/test/resources/gen_jks_wrong_host.sh b/pulsar-admin-jdk/src/test/resources/gen_jks_wrong_host.sh similarity index 60% rename from src/test/resources/gen_jks_wrong_host.sh rename to pulsar-admin-jdk/src/test/resources/gen_jks_wrong_host.sh index 549ab3c..7a62a18 100644 --- a/src/test/resources/gen_jks_wrong_host.sh +++ b/pulsar-admin-jdk/src/test/resources/gen_jks_wrong_host.sh @@ -1,23 +1,4 @@ #!/bin/bash -# -# Licensed 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. -# - client_pass=pulsar_client_pwd server_pass=pulsar_server_pwd server_dname="C=CN,ST=GD,L=SZ,O=sh,OU=sh,CN=nonlocalhost" diff --git a/pulsar-admin-jdk/src/test/resources/log4j2.xml b/pulsar-admin-jdk/src/test/resources/log4j2.xml new file mode 100644 index 0000000..dae563d --- /dev/null +++ b/pulsar-admin-jdk/src/test/resources/log4j2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/src/test/resources/pulsar_client_key.jks b/pulsar-admin-jdk/src/test/resources/pulsar_client_key.jks similarity index 100% rename from src/test/resources/pulsar_client_key.jks rename to pulsar-admin-jdk/src/test/resources/pulsar_client_key.jks diff --git a/src/test/resources/pulsar_client_key_wrong_host.jks b/pulsar-admin-jdk/src/test/resources/pulsar_client_key_wrong_host.jks similarity index 100% rename from src/test/resources/pulsar_client_key_wrong_host.jks rename to pulsar-admin-jdk/src/test/resources/pulsar_client_key_wrong_host.jks diff --git a/src/test/resources/pulsar_client_trust.jks b/pulsar-admin-jdk/src/test/resources/pulsar_client_trust.jks similarity index 100% rename from src/test/resources/pulsar_client_trust.jks rename to pulsar-admin-jdk/src/test/resources/pulsar_client_trust.jks diff --git a/src/test/resources/pulsar_client_trust_wrong_host.jks b/pulsar-admin-jdk/src/test/resources/pulsar_client_trust_wrong_host.jks similarity index 100% rename from src/test/resources/pulsar_client_trust_wrong_host.jks rename to pulsar-admin-jdk/src/test/resources/pulsar_client_trust_wrong_host.jks diff --git a/src/test/resources/pulsar_server_key.jks b/pulsar-admin-jdk/src/test/resources/pulsar_server_key.jks similarity index 100% rename from src/test/resources/pulsar_server_key.jks rename to pulsar-admin-jdk/src/test/resources/pulsar_server_key.jks diff --git a/src/test/resources/pulsar_server_key_wrong_host.jks b/pulsar-admin-jdk/src/test/resources/pulsar_server_key_wrong_host.jks similarity index 100% rename from src/test/resources/pulsar_server_key_wrong_host.jks rename to pulsar-admin-jdk/src/test/resources/pulsar_server_key_wrong_host.jks diff --git a/src/test/resources/pulsar_server_trust.jks b/pulsar-admin-jdk/src/test/resources/pulsar_server_trust.jks similarity index 100% rename from src/test/resources/pulsar_server_trust.jks rename to pulsar-admin-jdk/src/test/resources/pulsar_server_trust.jks diff --git a/src/test/resources/pulsar_server_trust_wrong_host.jks b/pulsar-admin-jdk/src/test/resources/pulsar_server_trust_wrong_host.jks similarity index 100% rename from src/test/resources/pulsar_server_trust_wrong_host.jks rename to pulsar-admin-jdk/src/test/resources/pulsar_server_trust_wrong_host.jks diff --git a/src/main/java/io/github/protocol/pulsar/BacklogQuota.java b/src/main/java/io/github/protocol/pulsar/BacklogQuota.java deleted file mode 100644 index 7c3e3b7..0000000 --- a/src/main/java/io/github/protocol/pulsar/BacklogQuota.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed 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 io.github.protocol.pulsar; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.ToString; - -@Getter -@Setter -@Builder -@NoArgsConstructor -@AllArgsConstructor -@ToString -@EqualsAndHashCode -public class BacklogQuota { - - /** - * backlog quota by size in byte. - */ - private Long limitSize; - - /** - * backlog quota by time in second. - */ - private Integer limitTime; - - private RetentionPolicy policy; - -} diff --git a/src/main/java/io/github/protocol/pulsar/BacklogQuotaType.java b/src/main/java/io/github/protocol/pulsar/BacklogQuotaType.java deleted file mode 100644 index 3aee379..0000000 --- a/src/main/java/io/github/protocol/pulsar/BacklogQuotaType.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed 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 io.github.protocol.pulsar; - -public enum BacklogQuotaType { - - destination_storage, - - message_age, - -} diff --git a/src/main/java/io/github/protocol/pulsar/Clusters.java b/src/main/java/io/github/protocol/pulsar/Clusters.java deleted file mode 100644 index 66f117b..0000000 --- a/src/main/java/io/github/protocol/pulsar/Clusters.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed 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 io.github.protocol.pulsar; - -import java.util.List; - -public interface Clusters { - - List getClusters() throws PulsarAdminException; - -} diff --git a/src/main/java/io/github/protocol/pulsar/MessageIdImpl.java b/src/main/java/io/github/protocol/pulsar/MessageIdImpl.java deleted file mode 100644 index f4f9bc4..0000000 --- a/src/main/java/io/github/protocol/pulsar/MessageIdImpl.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed 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 io.github.protocol.pulsar; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@Builder -@NoArgsConstructor -@AllArgsConstructor -@EqualsAndHashCode -public class MessageIdImpl { - - private Long ledgerId; - - private Integer entryId; - - private Integer partitionIndex; - - private Integer batchIndex; - - @Override - public String toString() { - if (batchIndex != null) { - return String.valueOf(ledgerId) + ':' + entryId + ':' + partitionIndex + ':' + batchIndex; - } - return String.valueOf(ledgerId) + ':' + entryId + ':' + partitionIndex; - } - -} diff --git a/src/main/java/io/github/protocol/pulsar/Mode.java b/src/main/java/io/github/protocol/pulsar/Mode.java deleted file mode 100644 index d43ddb9..0000000 --- a/src/main/java/io/github/protocol/pulsar/Mode.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed 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 io.github.protocol.pulsar; - -public enum Mode { - PERSISTENT, - NON_PERSISTENT, - ALL, -} diff --git a/src/main/java/io/github/protocol/pulsar/NonPersistentTopicsImpl.java b/src/main/java/io/github/protocol/pulsar/NonPersistentTopicsImpl.java deleted file mode 100644 index 3401d66..0000000 --- a/src/main/java/io/github/protocol/pulsar/NonPersistentTopicsImpl.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed 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 io.github.protocol.pulsar; - -public class NonPersistentTopicsImpl extends PersistentTopicsImpl { - - private static final String BASE_URL_NON_PERSISTENT_DOMAIN = UrlConst.BASE_URL_V2 + "/non-persistent"; - - public NonPersistentTopicsImpl(InnerHttpClient httpClient) { - super(httpClient); - } - - @Override - public String getDomainBaseUrl() { - return BASE_URL_NON_PERSISTENT_DOMAIN; - } - - @Override - public MessageIdImpl getLastMessageId(String tenant, String namespace, String encodedTopic, boolean authoritative) - throws PulsarAdminException { - throw new PulsarAdminException(new UnsupportedOperationException( - "get last message id on non-persistent topic is not allowed")); - } -} diff --git a/src/main/java/io/github/protocol/pulsar/PartitionedTopicMetadata.java b/src/main/java/io/github/protocol/pulsar/PartitionedTopicMetadata.java deleted file mode 100644 index b920018..0000000 --- a/src/main/java/io/github/protocol/pulsar/PartitionedTopicMetadata.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed 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 io.github.protocol.pulsar; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.ToString; - -import java.util.Map; - -@Getter -@Setter -@Builder -@NoArgsConstructor -@AllArgsConstructor -@ToString -@EqualsAndHashCode -public class PartitionedTopicMetadata { - - public int partitions; - - public boolean deleted; - - public Map properties; - -} diff --git a/src/main/java/io/github/protocol/pulsar/RetentionPolicies.java b/src/main/java/io/github/protocol/pulsar/RetentionPolicies.java deleted file mode 100644 index 02c9ce4..0000000 --- a/src/main/java/io/github/protocol/pulsar/RetentionPolicies.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed 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 io.github.protocol.pulsar; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.ToString; - -@Getter -@Setter -@Builder -@NoArgsConstructor -@AllArgsConstructor -@ToString -@EqualsAndHashCode -public class RetentionPolicies { - - private Integer retentionTimeInMinutes; - - private Integer retentionSizeInMB; - -} diff --git a/src/main/java/io/github/protocol/pulsar/RetentionPolicy.java b/src/main/java/io/github/protocol/pulsar/RetentionPolicy.java deleted file mode 100644 index 18074b2..0000000 --- a/src/main/java/io/github/protocol/pulsar/RetentionPolicy.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed 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 io.github.protocol.pulsar; - -public enum RetentionPolicy { - - /** - * Policy which holds producer's send request until the resource becomes available (or holding times out). - */ - producer_request_hold, - - /** - * Policy which throws javax.jms.ResourceAllocationException to the producer. - */ - producer_exception, - - /** - * Policy which evicts the oldest message from the slowest consumer's backlog. - */ - consumer_backlog_eviction, - -} diff --git a/src/main/java/io/github/protocol/pulsar/TenantInfo.java b/src/main/java/io/github/protocol/pulsar/TenantInfo.java deleted file mode 100644 index c399030..0000000 --- a/src/main/java/io/github/protocol/pulsar/TenantInfo.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed 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 io.github.protocol.pulsar; - - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import java.util.Set; - -@Getter -@Setter -@Builder -@NoArgsConstructor -@AllArgsConstructor -@EqualsAndHashCode -public class TenantInfo { - - private Set adminRoles; - - private Set allowedClusters; - -} diff --git a/src/main/java/io/github/protocol/pulsar/Tenants.java b/src/main/java/io/github/protocol/pulsar/Tenants.java deleted file mode 100644 index 846ff17..0000000 --- a/src/main/java/io/github/protocol/pulsar/Tenants.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed 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 io.github.protocol.pulsar; - -import java.util.List; - -public interface Tenants { - - void createTenant(String tenant, TenantInfo tenantInfo) throws PulsarAdminException; - - void deleteTenant(String tenant, boolean force) throws PulsarAdminException; - - void updateTenant(String tenant, TenantInfo tenantInfo) throws PulsarAdminException; - - TenantInfo getTenantAdmin(String tenant) throws PulsarAdminException; - - List getTenants() throws PulsarAdminException; - -} diff --git a/src/test/java/io/github/protocol/pulsar/RandomUtil.java b/src/test/java/io/github/protocol/pulsar/RandomUtil.java deleted file mode 100644 index 65f585a..0000000 --- a/src/test/java/io/github/protocol/pulsar/RandomUtil.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed 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 io.github.protocol.pulsar; - -import java.util.Random; -import java.util.UUID; - -public class RandomUtil { - - public static Random random = new Random(); - - public static String randomString() { - return UUID.randomUUID().toString(); - } - - public static int randomInt() { - return random.nextInt(); - } - - public static long randomLong() { - return random.nextLong(); - } - - public static long randomPositiveLong(){ - return random.nextLong(0, Long.MAX_VALUE); - } - - public static int randomPositiveInt(){ - return random.nextInt(0, Integer.MAX_VALUE); - } - - public static int randomNegativeInt(){ - return random.nextInt(Integer.MIN_VALUE, -1); - } - -} diff --git a/src/test/resources/log4j2.xml b/src/test/resources/log4j2.xml deleted file mode 100644 index 04d6119..0000000 --- a/src/test/resources/log4j2.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - -